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

Last change on this file since 512 was 479, checked in by alain, 10 years ago

Cosmetic: improve debug.

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : mwmr_channel.h         
3// Date     : 01/04/2012
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
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.
13// The channel must have been allocated in a non cacheable segment,
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.
24// A queuing lock provides exclusive access to the MWMR channel.
25///////////////////////////////////////////////////////////////////////////////////
26
27#ifndef _MWMR_CHANNEL_H_
28#define _MWMR_CHANNEL_H_
29
30#include "user_lock.h"
31
32///////////////////////////////////////////////////////////////////////////////////
33//  MWMR channel structure
34// The data buffer size is defined to obtain sizeof(mwmr_channel_t) = 4096 bytes.
35// The actual buffer size cannot be larger than 4072 bytes (1018 words).
36///////////////////////////////////////////////////////////////////////////////////
37
38typedef struct mwmr_channel_s
39{
40    user_lock_t    lock;       // exclusive access lock
41    unsigned int   ptr;        // index of the first valid data word
42    unsigned int   ptw;        // index of the first empty slot
43    unsigned int   sts;        // number of words available
44    unsigned int   depth;      // max number of words in the channel
45    unsigned int   width;      // number of words in an item     
46    unsigned int*  data;       // circular buffer base address
47} mwmr_channel_t;
48
49//////////////////////////////////////////////////////////////////////////////
50//  MWMR access functions
51//////////////////////////////////////////////////////////////////////////////
52
53void mwmr_init(  mwmr_channel_t* mwmr,
54                 unsigned int*   buffer,    // data buffer base address
55                 unsigned int    width,     // number of words per item
56                 unsigned int    nitems );  // max number of items
57
58void mwmr_read(  mwmr_channel_t* mwmr,
59                 unsigned int*   buffer,
60                 unsigned int    items );
61
62void mwmr_write( mwmr_channel_t* mwmr,
63                 unsigned int*   buffer,
64                 unsigned int    items );
65
66unsigned int nb_mwmr_read ( mwmr_channel_t * mwmr,
67                            unsigned int * buffer,
68                            unsigned int items );
69
70unsigned int nb_mwmr_write( mwmr_channel_t * mwmr,
71                            unsigned int * buffer,
72                            unsigned int items );
73
74#endif
75
76// Local Variables:
77// tab-width: 4
78// c-basic-offset: 4
79// c-file-offsets:((innamespace . 0)(inline-open . 0))
80// indent-tabs-mode: nil
81// End:
82// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
83
Note: See TracBrowser for help on using the repository browser.