Changeset 671 for trunk/kernel/libk/remote_buf.h
- Timestamp:
- Nov 19, 2020, 11:47:00 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_buf.h
r666 r671 32 32 * This structure and the associated access functions define a remotely accessible, 33 33 * kernel buffer, handled as a single-reader & single-writer FIFO. 34 * This kernel buffer is implementes as an array of bytes , whose size is35 * dynamically defined by an argument of the "remote_buf_init()" function.34 * This kernel buffer is implementes as an array of bytes. The size must be a power 35 * of 2, dynamically defined by an argument of the "remote_buf_init()" function. 36 36 * The "put()" and "get()" functions defined below move the content of another 37 37 * buffer (can be in kernel or in user space) to/from this circular kernel buffer. 38 38 * This structure is NOT protected by a lock, as the only shared variable is the 39 39 * "sts" variable, that is updated by the hal_remote_atomic_add() primitive. 40 * It is used to implement the three socket buffers (rx_buf / r2tq / crqq).41 * - the "ptw" field defines the first empty slot (for write).42 * - the "ptr" field defines the first non empty slot (for read).43 * - the "sts" field defines the total number of non empty slots.40 * 41 * - It is used to implement the three socket buffers (rx_buf / r2tq / crqq). 42 * - It is also used to implement the inter-process communications channels 43 * based on named "fifos", or unamed "pipes". 44 44 ***********************************************************************************/ 45 45 46 46 typedef struct remote_buf_s 47 47 { 48 uint32_t size; /*! number of slots in data buffer*/49 uint32_t ptw; /*! first empty slot index */50 uint32_t ptr; /*! first non-empty slot index */48 uint32_t order; /*! ln2( size of data buffer in bytes) */ 49 uint32_t rid; /*! first empty slot index */ 50 uint32_t wid; /*! first non-empty slot index */ 51 51 uint32_t sts; /*! current number of non empty slots */ 52 52 uint8_t * data; /*! local pointer on local data buffer */ … … 55 55 56 56 /************************************************************************************ 57 * This function allocates memory for a remote_buf descriptor in cluster 58 * defined by the <cxy> argument, and return a local pointer on this descriptor. 59 ************************************************************************************ 60 * @ cxy : target cluster identifier. 61 * @ return local pointer on remote_buf descriptor. 62 ***********************************************************************************/ 63 remote_buf_t * remote_buf_alloc( cxy_t cxy ); 64 65 /************************************************************************************ 57 66 * This function initializes a remote_buf descriptor identified by the <buf_xp> 58 * argument. It allocates memory for the data, as defined by the < size> argument,67 * argument. It allocates memory for the data, as defined by the <order> argument, 59 68 * and initializes the buffer as empty. It must be called by a local thread. 60 * No memory is allocated if <size> value is 0.69 * The <order> value cannot be larger than 31. 61 70 ************************************************************************************ 62 71 * @ buf_xp : [in] extended pointer on buffer descriptor. 63 * @ size : [in] number of bytes in buffer / no memory allocated when null.64 * @ return 0 if success / return -1 if memory failure .72 * @ order : [in] ln2( number of bytes in buffer) / must be in [0,31]. 73 * @ return 0 if success / return -1 if memory failure or illegal order. 65 74 ***********************************************************************************/ 66 75 error_t remote_buf_init( xptr_t buf_xp, 67 uint32_t size);76 uint32_t order ); 68 77 69 78 /************************************************************************************ 70 * This function releases memory allocated for the data buffer of a remote-buf 71 * descriptor identified by the <buf_xp> argument. 72 * It must be called by a local thread. 79 * This function releases memory allocated for the data buffer of an embedded 80 * remote-buf descriptor identified by the <buf_xp> argument, when the "data" 81 * pointer is not NULL. It does nothing if the data buffer was not allocated. 82 * WARNING : do NOT use this function for a dynamically allocated remote_buf. 83 ************************************************************************************ 84 * @ buf_xp : [in] extended pointer on buffer descriptor. 85 ***********************************************************************************/ 86 void remote_buf_release_data( xptr_t buf_xp ); 87 88 /************************************************************************************ 89 * This function releases both the memory allocated for the data buffer, and the 90 * memory allocated for the remote_buf descriptor, for a remote-buf identified 91 * by the <buf_xp> argument. 92 * WARNING : do NOT use this function an embedded remote_buf. 73 93 ************************************************************************************ 74 94 * @ buf_xp : [in] extended pointer on buffer descriptor.
Note: See TracChangeset
for help on using the changeset viewer.