source: soft/giet_vm/giet_libs/mwmr_channel.h @ 661

Last change on this file since 661 was 521, checked in by alain, 10 years ago

Introducing in the stdio.c / stdio.h files the system calls
related to the hardware coprocessors configuration and use.

  • Property svn:executable set to *
File size: 3.4 KB
RevLine 
[258]1//////////////////////////////////////////////////////////////////////////////////
2// File     : mwmr_channel.h         
3// Date     : 01/04/2012
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
[450]7// The mwmr_channel.c and mwmr_channel.h files are part of the GIET nano-kernel.
8// This  middleware implements a user level Multi-Writers / Multi-Readers
9// communication channel, that can be used by parallel multi-tasks applications
10// respecting the TCG (Tasks and Communications Graph) formalism.
11//
12// The mwmr_read() and mwmr_write() functions do not require a system call.
[461]13// The channel must have been allocated in a non cacheable segment,
[450]14// if the platform does not provide hardware cache coherence.
15//
16// An MWMR transaction transfer an integer number of items, and an item is
17// an integer number of unsigned int (32 bits words).
18// The max number of words that can be stored in a MWMR channel is defined by the
19// "depth" parameter, and the "width" parameter define the minimal number of
20// word contained in an atomic item. Therefore, the "depth" parameter must be
21// a multiple of the "width" parameter.
22//
23// Both the mwmr_read() and mwmr_write() functions are blocking functions.
[479]24// A queuing lock provides exclusive access to the MWMR channel.
[450]25///////////////////////////////////////////////////////////////////////////////////
[258]26
27#ifndef _MWMR_CHANNEL_H_
28#define _MWMR_CHANNEL_H_
29
[461]30#include "user_lock.h"
31
[258]32///////////////////////////////////////////////////////////////////////////////////
33//  MWMR channel structure
34///////////////////////////////////////////////////////////////////////////////////
35
36typedef struct mwmr_channel_s
37{
[521]38    user_lock_t    lock;         // exclusive access lock
39    unsigned int   sts;          // number of words available
40    unsigned int   ptr;          // index of the first valid data word
41    unsigned int   ptw;          // index of the first empty slot
42    unsigned int   depth;        // max number of words in the channel
43    unsigned int   width;        // number of words in an item     
44    unsigned int*  data;         // circular buffer base address
45    unsigned int   padding[10];  // for 64 bytes alignment
[258]46} mwmr_channel_t;
47
48//////////////////////////////////////////////////////////////////////////////
49//  MWMR access functions
50//////////////////////////////////////////////////////////////////////////////
51
[450]52void mwmr_init(  mwmr_channel_t* mwmr,
[461]53                 unsigned int*   buffer,    // data buffer base address
[450]54                 unsigned int    width,     // number of words per item
[461]55                 unsigned int    nitems );  // max number of items
[450]56
[461]57void mwmr_read(  mwmr_channel_t* mwmr,
58                 unsigned int*   buffer,
59                 unsigned int    items );
[258]60
[461]61void mwmr_write( mwmr_channel_t* mwmr,
62                 unsigned int*   buffer,
63                 unsigned int    items );
[258]64
[278]65unsigned int nb_mwmr_read ( mwmr_channel_t * mwmr,
66                            unsigned int * buffer,
[461]67                            unsigned int items );
[278]68
69unsigned int nb_mwmr_write( mwmr_channel_t * mwmr,
70                            unsigned int * buffer,
[461]71                            unsigned int items );
[278]72
[258]73#endif
74
75// Local Variables:
76// tab-width: 4
77// c-basic-offset: 4
78// c-file-offsets:((innamespace . 0)(inline-open . 0))
79// indent-tabs-mode: nil
80// End:
81// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
82
Note: See TracBrowser for help on using the repository browser.