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

Last change on this file since 454 was 450, checked in by alain, 10 years ago

1) Introducing an explicit channel initialisation function in the MWMR library.
2) Defining new system calls in stdio.c to support user access to the NIC.

  • Property svn:executable set to *
File size: 3.9 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 itself must have been allocated in a non cacheable segment,
14// if the platform does not provide hardware cache coherence.
15//
16// WARNING : ALL MWMR channels must be defined in the mapping,
17// to be initialised by the GIET in the boot phase.
18// The vobj_get_vbase() system call (defined in stdio.c and stdio.h files)
19// can be used to get the virtual base address of the channel from it's name.
20//
21// An MWMR transaction transfer an integer number of items, and an item is
22// an integer number of unsigned int (32 bits words).
23// The max number of words that can be stored in a MWMR channel is defined by the
24// "depth" parameter, and the "width" parameter define the minimal number of
25// word contained in an atomic item. Therefore, the "depth" parameter must be
26// a multiple of the "width" parameter.
27//
28// Both the mwmr_read() and mwmr_write() functions are blocking functions.
29// A private lock provides exclusive access to the MWMR channel, that can have
30// a variable number of producers and a variable number of consumers.
31///////////////////////////////////////////////////////////////////////////////////
32
33#ifndef _MWMR_CHANNEL_H_
34#define _MWMR_CHANNEL_H_
35
36///////////////////////////////////////////////////////////////////////////////////
37//  MWMR channel structure
38// The data buffer size is defined to obtain sizeof(mwmr_channel_t) = 4096 bytes.
39// The actual buffer size cannot be larger than 4072 bytes (1018 words).
40///////////////////////////////////////////////////////////////////////////////////
41
42typedef struct mwmr_channel_s
43{
44    unsigned int ptr;        // index of the first valid data word
45    unsigned int ptw;        // index of the first empty slot
46    unsigned int sts;        // number of words available
47    unsigned int lock;       // exclusive access lock
48    unsigned int depth;      // max number of words in the channel
49    unsigned int width;      // number of words in an item     
50    unsigned int data[1018]; // circular buffer
51} mwmr_channel_t;
52
53//////////////////////////////////////////////////////////////////////////////
54//  MWMR access functions
55//////////////////////////////////////////////////////////////////////////////
56
57void mwmr_init(  mwmr_channel_t* mwmr,
58                 unsigned int    width,     // number of words per item
59                 unsigned int    items );   // max number of items
60
61void mwmr_write( mwmr_channel_t* mwmr, 
62                 unsigned int*   buffer,    // user buffer vbase address
63                 unsigned int    nitems );  // number of items to transfer
64
65void mwmr_write( mwmr_channel_t* mwmr, 
66                 unsigned int*   buffer,    // user buffer vbase address
67                 unsigned int    nitems );  // number of items to transfer
68
69unsigned int nb_mwmr_read ( mwmr_channel_t * mwmr,
70                            unsigned int * buffer,
71                            unsigned int nitems );
72
73unsigned int nb_mwmr_write( mwmr_channel_t * mwmr,
74                            unsigned int * buffer,
75                            unsigned int nitems );
76
77#endif
78
79// Local Variables:
80// tab-width: 4
81// c-basic-offset: 4
82// c-file-offsets:((innamespace . 0)(inline-open . 0))
83// indent-tabs-mode: nil
84// End:
85// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
86
Note: See TracBrowser for help on using the repository browser.