L4Re Operating System Framework
Interface and Usage Documentation
|
Go to the source code of this file.
Data Structures | |
struct | l4shmc_ringbuf_head_t |
Head field of a ring buffer. More... | |
struct | l4shmc_ringbuf_t |
Ring buffer. More... | |
Macros | |
#define | L4SHMC_RINGBUF_HEAD(ringbuf) ((l4shmc_ringbuf_head_t*)((ringbuf)->_addr)) |
Get ring buffer head pointer. | |
#define | L4SHMC_RINGBUF_DATA(ringbuf) (L4SHMC_RINGBUF_HEAD(ringbuf)->data) |
Get ring buffer data pointer. | |
#define | L4SHMC_RINGBUF_DATA_SIZE(ringbuf) ((ringbuf)->_size - sizeof(l4shmc_ringbuf_head_t)) |
Get size of data area. | |
Functions | |
int | l4shmc_rb_init_buffer (l4shmc_ringbuf_t *buf, l4shmc_area_t *area, char const *chunk_name, char const *signal_name, unsigned size) |
Initialize a ring buffer by creating an SHMC chunk and the corresponding signals. | |
void | l4shmc_rb_deinit_buffer (l4shmc_ringbuf_t *buf) |
De-init a ring buffer. | |
int | l4shmc_rb_attach_sender (l4shmc_ringbuf_t *buf, char const *signal_name, l4_cap_idx_t owner) |
Attach to sender signal of a ring buffer. | |
char * | l4shmc_rb_sender_alloc_packet (l4shmc_ringbuf_head_t *head, unsigned psize) |
Allocate a packet of a given size within the ring buffer. | |
void | l4shmc_rb_sender_put_data (l4shmc_ringbuf_t *buf, char *addr, char *data, unsigned dsize) |
Copy data into a previously allocated packet. | |
int | l4shmc_rb_sender_next_copy_in (l4shmc_ringbuf_t *buf, char *data, unsigned size, int block_if_necessary) |
Copy in packet from an external data source. | |
void | l4shmc_rb_sender_commit_packet (l4shmc_ringbuf_t *buf) |
Tell the consumer that new data is available. | |
int | l4shmc_rb_init_receiver (l4shmc_ringbuf_t *buf, l4shmc_area_t *area, char const *chunk_name, char const *signal_name) |
Initialize receive buffer. | |
void | l4shmc_rb_attach_receiver (l4shmc_ringbuf_t *buf, l4_cap_idx_t owner) |
Attach to receiver signal of a ring buffer. | |
int | l4shmc_rb_receiver_wait_for_data (l4shmc_ringbuf_t *buf, int blocking) |
Check if (and optionally block until) new data is ready. | |
int | l4shmc_rb_receiver_copy_out (l4shmc_ringbuf_head_t *head, char *target, unsigned *tsize) |
Copy data out of the buffer. | |
void | l4shmc_rb_receiver_notify_done (l4shmc_ringbuf_t *buf) |
Notify producer that space is available. | |
int | l4shmc_rb_receiver_read_next_size (l4shmc_ringbuf_head_t *head) |
Have a look at the ring buffer and see which size the next packet to be read has. | |
void l4shmc_rb_attach_receiver | ( | l4shmc_ringbuf_t * | buf, |
l4_cap_idx_t | owner | ||
) |
Attach to receiver signal of a ring buffer.
Attach owner to the receiver-side signal of a ring buffer, which is triggered whenever new data has been produced.
This is split from initialization, because you may not know the owner cap when initializing the buffer.
buf | pointer to ring buffer struct |
owner | owner thread |
int l4shmc_rb_attach_sender | ( | l4shmc_ringbuf_t * | buf, |
char const * | signal_name, | ||
l4_cap_idx_t | owner | ||
) |
Attach to sender signal of a ring buffer.
Attach owner to the sender-side signal of a ring buffer, which is triggered whenever new space has been freed in the buffer for the sender to write to.
This is split from initialization, because you may not know the owner cap when initializing the buffer.
buf | pointer to ring buffer struct |
signal_name | signal base name |
owner | owner thread |
void l4shmc_rb_deinit_buffer | ( | l4shmc_ringbuf_t * | buf | ) |
De-init a ring buffer.
buf | pointer to ring buffer struct |
int l4shmc_rb_init_buffer | ( | l4shmc_ringbuf_t * | buf, |
l4shmc_area_t * | area, | ||
char const * | chunk_name, | ||
char const * | signal_name, | ||
unsigned | size | ||
) |
Initialize a ring buffer by creating an SHMC chunk and the corresponding signals.
This needs to be done by one of the participating parties when setting up communication channel.
buf | pointer to ring buffer struct |
area | pointer to SHMC area |
chunk_name | name of SHMC chunk to create in area |
signal_name | base name for SHMC signals to create |
size | chunk size |
int l4shmc_rb_init_receiver | ( | l4shmc_ringbuf_t * | buf, |
l4shmc_area_t * | area, | ||
char const * | chunk_name, | ||
char const * | signal_name | ||
) |
Initialize receive buffer.
Initialize the receiver-side of a ring buffer. This requires the underlying SHMC chunk and the corresponding signals to be valid already (read: to be initialized by the sender).
buf | pointer to ring buffer struct |
area | pointer to SHMC area |
chunk_name | name of SHMC chunk to create in area |
signal_name | base name for SHMC signals to create |
int l4shmc_rb_receiver_copy_out | ( | l4shmc_ringbuf_head_t * | head, |
char * | target, | ||
unsigned * | tsize | ||
) |
Copy data out of the buffer.
head | ring buffer head pointer | |
target | valid target buffer | |
[in,out] | tsize | size of target buffer (must be >= packet size!); contains the real data size |
void l4shmc_rb_receiver_notify_done | ( | l4shmc_ringbuf_t * | buf | ) |
Notify producer that space is available.
buf | pointer to ring buffer struct |
int l4shmc_rb_receiver_read_next_size | ( | l4shmc_ringbuf_head_t * | head | ) |
Have a look at the ring buffer and see which size the next packet to be read has.
Does not modify anything.
int l4shmc_rb_receiver_wait_for_data | ( | l4shmc_ringbuf_t * | buf, |
int | blocking | ||
) |
Check if (and optionally block until) new data is ready.
buf | pointer to ring buffer struct |
blocking | block if data is not available immediately |
Returns immediately, if data is available.
char * l4shmc_rb_sender_alloc_packet | ( | l4shmc_ringbuf_head_t * | head, |
unsigned | psize | ||
) |
Allocate a packet of a given size within the ring buffer.
This packet may wrap around at the end of the buffer. Users need to be aware of that.
head | ring buffer head pointer |
psize | packet size |
NULL | if not enough space available |
void l4shmc_rb_sender_commit_packet | ( | l4shmc_ringbuf_t * | buf | ) |
Tell the consumer that new data is available.
buf | pointer to ring buffer struct |
int l4shmc_rb_sender_next_copy_in | ( | l4shmc_ringbuf_t * | buf, |
char * | data, | ||
unsigned | size, | ||
int | block_if_necessary | ||
) |
Copy in packet from an external data source.
This is the function you'll want to use. Just pass it a buffer pointer and let the lib do the work.
buf | pointer to ring buffer struct |
data | valid buffer |
size | data size |
block_if_necessary | bool: block if buffer currently full |
0 | on success |
-L4_ENOMEM | if block == false and no space available |
void l4shmc_rb_sender_put_data | ( | l4shmc_ringbuf_t * | buf, |
char * | addr, | ||
char * | data, | ||
unsigned | dsize | ||
) |
Copy data into a previously allocated packet.
This function is wrap-around aware.
buf | pointer to ring buffer struct |
addr | valid destination (allocate with alloc_packet()) |
data | data source |
dsize | data size |