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

Last change on this file since 652 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
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///////////////////////////////////////////////////////////////////////////////////
35
36typedef struct mwmr_channel_s
37{
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
46} mwmr_channel_t;
47
48//////////////////////////////////////////////////////////////////////////////
49//  MWMR access functions
50//////////////////////////////////////////////////////////////////////////////
51
52void mwmr_init(  mwmr_channel_t* mwmr,
53                 unsigned int*   buffer,    // data buffer base address
54                 unsigned int    width,     // number of words per item
55                 unsigned int    nitems );  // max number of items
56
57void mwmr_read(  mwmr_channel_t* mwmr,
58                 unsigned int*   buffer,
59                 unsigned int    items );
60
61void mwmr_write( mwmr_channel_t* mwmr,
62                 unsigned int*   buffer,
63                 unsigned int    items );
64
65unsigned int nb_mwmr_read ( mwmr_channel_t * mwmr,
66                            unsigned int * buffer,
67                            unsigned int items );
68
69unsigned int nb_mwmr_write( mwmr_channel_t * mwmr,
70                            unsigned int * buffer,
71                            unsigned int items );
72
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.