Ignore:
Timestamp:
Nov 21, 2015, 1:57:51 PM (9 years ago)
Author:
alain
Message:

1) introduce the stdint.h file to define uint*_t and int*_t types.
2) introduce the bufio service in the mwmr library.
3) modify the fbf_cma system calls to support chbuf containing more than 2 buffers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/mwmr_channel.h

    r521 r722  
    1515//
    1616// An MWMR transaction transfer an integer number of items, and an item is
    17 // an integer number of unsigned int (32 bits words).
     17// an integer number of uint32_t (32 bits words).
    1818// The max number of words that can be stored in a MWMR channel is defined by the
    1919// "depth" parameter, and the "width" parameter define the minimal number of
     
    2929
    3030#include "user_lock.h"
     31#include "stdint.h"
    3132
    3233///////////////////////////////////////////////////////////////////////////////////
    33 //  MWMR channel structure
     34//         MWMR channel
     35// This structure define a - shared - communication buffer between threads.
     36// It must be declared as a global variable.
    3437///////////////////////////////////////////////////////////////////////////////////
    3538
    3639typedef struct mwmr_channel_s
    3740{
    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
     41    user_lock_t lock;         // exclusive access lock
     42    uint32_t    sts;          // number of words available
     43    uint32_t    ptr;          // index of the first valid data word
     44    uint32_t    ptw;          // index of the first empty slot
     45    uint32_t    depth;        // max number of words in the channel
     46    uint32_t    width;        // number of words in an item     
     47    uint32_t*   data;         // circular buffer base address
    4648} mwmr_channel_t;
    4749
     50///////////////////////////////////////////////////////////////////////////////////
     51//         MWMR bufio
     52// This structure define a - private - input or output buffer, that can be used
     53// to move data to (or ftom a shared MWMR communication channel.
     54// It is a local variable in the stack of the reader/writer thread.
     55// It can be used to simplify access to a MWMR channel when the transfered
     56// data have a non fixed format, and must be analysed or produced byte per byte.
     57// An input buffer is automatically refill when it becomes empty.
     58// An output buffer is automatically flushed when it becomes full.
     59///////////////////////////////////////////////////////////////////////////////////
     60
     61typedef struct mwmr_bufio_s
     62{
     63    uint32_t         is_input;    // input buffer if non zero
     64    uint32_t         ptr;         // current byte index (0 to max-1)
     65    uint8_t*         base;        // data buffer base address
     66    uint32_t         max;         // number of bytes after refill (only for input bufio)
     67    uint32_t         nitems;      // buffer size (number of items)
     68    uint32_t         nbytes;      // buffer size (number of bytes)
     69    mwmr_channel_t*  mwmr;        // associated MWMR channel
     70} mwmr_bufio_t;
     71
    4872//////////////////////////////////////////////////////////////////////////////
    49 //  MWMR access functions
     73//  MWMR channel access functions
    5074//////////////////////////////////////////////////////////////////////////////
    5175
    5276void 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
     77                 uint32_t*       buffer,
     78                 uint32_t        width,        // number of words per item
     79                 uint32_t        nitems );     // max number of items
     80
     81void mwmr_dump( mwmr_channel_t* mwmr );
    5682
    5783void mwmr_read(  mwmr_channel_t* mwmr,
    58                  unsigned int*   buffer,
    59                  unsigned int    items );
     84                 uint32_t*       buffer,
     85                 uint32_t        items );
    6086
    6187void mwmr_write( mwmr_channel_t* mwmr,
    62                  unsigned int*   buffer,
    63                  unsigned int    items );
     88                 uint32_t*       buffer,
     89                 uint32_t        items );
    6490
    65 unsigned int nb_mwmr_read ( mwmr_channel_t * mwmr,
    66                             unsigned int * buffer,
    67                             unsigned int items );
     91uint32_t nb_mwmr_read ( mwmr_channel_t* mwmr,
     92                        uint32_t*        buffer,
     93                        uint32_t        items );
    6894
    69 unsigned int nb_mwmr_write( mwmr_channel_t * mwmr,
    70                             unsigned int * buffer,
    71                             unsigned int items );
     95uint32_t nb_mwmr_write( mwmr_channel_t*  mwmr,
     96                        uint32_t*        buffer,
     97                        uint32_t         items );
     98
     99//////////////////////////////////////////////////////////////////////////////
     100//  MWMR bufio access functions
     101//////////////////////////////////////////////////////////////////////////////
     102
     103void mwmr_bufio_init( mwmr_bufio_t*    bufio, 
     104                      uint8_t*         buffer,
     105                      uint32_t         size,       // number of bytes
     106                      uint32_t         is_input,
     107                      mwmr_channel_t*  mwmr );
     108                   
     109void mwmr_bufio_dump( mwmr_bufio_t* bufio );
     110
     111uint8_t mwmr_bufio_read_byte( mwmr_bufio_t* bufio );
     112
     113void mwmr_bufio_skip( mwmr_bufio_t* bufio,
     114                      uint32_t      length );
     115
     116void mwmr_bufio_align( mwmr_bufio_t* bufio );
     117
     118void mwmr_bufio_write_byte( mwmr_bufio_t* bufio,
     119                            uint8_t       value );
     120
     121void mwmr_bufio_flush( mwmr_bufio_t* bufio );
    72122
    73123#endif
Note: See TracChangeset for help on using the changeset viewer.