Functions | |
void | dsi_init_streams (void) |
Initialize stream table. | |
static dsi_stream_t * | __allocate_stream (void) |
Find and allocate unused stream descriptor. | |
int | dsi_is_valid_stream (dsi_stream_t *stream) |
Check if stream is a valid stream descriptor. | |
static int | dsi_is_valid_component (dsi_component_t *component) |
Check if component is a valid component decription. | |
static int | __get_dm_id (void) |
Request dataspace manager from L4 environment. | |
static int | __map_ctrl_ds (dsi_socket_t *socket, dsi_stream_cfg_t cfg) |
Map control dataspace, setup pointers in socket structure. | |
int | dsi_create_ctrl_area (dsi_socket_t *socket, dsi_jcp_stream_t jcp_stream, dsi_stream_cfg_t cfg) |
Allocate and setup control area. | |
int | dsi_set_ctrl_area (dsi_socket_t *socket, l4dm_dataspace_t ctrl_ds, dsi_jcp_stream_t jcp_stream, dsi_stream_cfg_t cfg) |
Attach and setup control area. | |
int | dsi_release_ctrl_area (dsi_socket_t *socket) |
Release control dataspace. | |
int | dsi_set_data_area (dsi_socket_t *socket, l4dm_dataspace_t data_ds) |
Attach data dataspace. | |
void | dsi_init_event_signalling (void) |
Init event signalling. | |
static int | __client_wakeup (l4_threadid_t client, l4_uint32_t events, int error) |
Send event notification to client application. | |
static int | __set_event (dsi_socketid_t id, l4_uint32_t events) |
Set events. | |
static int | __reset_event (l4_threadid_t client, dsi_socketid_t id, l4_uint32_t events) |
Reset events. | |
static int | __wait_for_events (l4_threadid_t client, dsi_socketid_t id, l4_uint32_t events) |
Wait for events. | |
static void | __event_thread (void *data) |
Component event signalling thread. | |
int | dsi_event_set (dsi_socketid_t socket_id, l4_uint32_t events) |
Set events. | |
int | dsi_event_reset (l4_threadid_t event_thread, dsi_socketid_t socket_id, l4_uint32_t events) |
Reset events. | |
l4_int32_t | dsi_event_wait (l4_threadid_t event_thread, dsi_socketid_t socket_id, l4_uint32_t events) |
Wait for events. | |
static int | __is_valid_packet (dsi_socket_t *socket, dsi_packet_t *packet) |
Check if packet points to a valid packet descriptor of socket. | |
static int | __get_packet_index (dsi_socket_t *socket, dsi_packet_t *packet) |
Calculate packet index. | |
static int | __send_release_notification (dsi_socket_t *socket, dsi_packet_t *packet) |
Send release packet notification to send component. | |
static int | __get_sg_elem (dsi_socket_t *socket, int *sg_elem) |
Find unused scatter gather list element. | |
static int | __get_send_packet (dsi_socket_t *socket, int *packet) |
Try to lock next send packet in packet ring list. | |
static int | __get_receive_packet (dsi_socket_t *socket, int *packet) |
Try to lock next receive packet in packet ring list. | |
static int | __commit_send_packet (dsi_socket_t *socket, dsi_packet_t *packet) |
Commit send packet. | |
static int | __commit_receive_packet (dsi_socket_t *socket, dsi_packet_t *packet) |
Commit (release) received packet. | |
static void | __select_thread (void *data) |
Select thread. | |
void | dsi_init_sockets (void) |
Initialize socket table. | |
static int | __allocate_socket (void) |
Find and allocate unused socket in socket table. | |
void | dsi_sync_thread_receive (void *data) |
Synchronization thread, receive component. | |
int | dsi_start_sync_thread (dsi_socket_t *socket) |
Send connect message to synchronization thread. | |
int | dsi_create_sync_thread (dsi_socket_t *socket) |
Create new synchronization thread for socket. | |
int | dsi_shutdown_sync_thread (dsi_socket_t *socket) |
Shutdown synchronization thread. | |
l4_threadid_t | dsi_create_event_thread (l4thread_fn_t fn) |
Start event signalling thread. | |
Variables | |
static int | next_socket = 0 |
next index to search for unused socket |
Functions provided by this module should not be used directly by external programms. They are subject to change. This covers structures and defines aswell.
static int __allocate_socket | ( | void | ) | [static] |
Find and allocate unused socket in socket table.
Definition at line 79 of file socket.c.
References next_socket.
Referenced by dsi_socket_create().
static dsi_stream_t* __allocate_stream | ( | void | ) | [static] |
Find and allocate unused stream descriptor.
NULL
if no stream is available. Definition at line 56 of file app.c.
References next_stream.
Referenced by dsi_stream_create().
static int __client_wakeup | ( | l4_threadid_t | client, | |
l4_uint32_t | events, | |||
int | error | |||
) | [inline, static] |
Send event notification to client application.
client | Client thread id | |
events | Event mask | |
error | Error code to be sent to the client |
Definition at line 84 of file event.c.
Referenced by __set_event(), and __wait_for_events().
static int __commit_receive_packet | ( | dsi_socket_t * | socket, | |
dsi_packet_t * | packet | |||
) | [inline, static] |
Commit (release) received packet.
socket | socket descriptor | |
packet | packet to commit |
0 | success | |
-L4_EINVAL | invalid packet descriptor | |
-L4_EIPC | IPC error sending release notifcation to sender | |
-DSI_ENOPACKET | peer in blocking mode: IPC error sending unblock-notification |
Definition at line 619 of file packet.c.
References __get_packet_index(), __is_valid_packet(), __send_release_notification(), dsi_sg_elem::addr, dsi_socket::data_area, dsi_sg_elem::flags, dsi_socket::flags, dsi_socket::header, dsi_sg_elem::next, dsi_packet::no, dsi_ctrl_header::packets_committed, dsi_packet::sg_idx, dsi_packet::sg_len, dsi_packet::sg_list, dsi_socket::sg_lists, dsi_sg_elem::size, dsi_socket::sync_th, and dsi_packet::tx_sem.
Referenced by dsi_packet_commit().
static int __commit_send_packet | ( | dsi_socket_t * | socket, | |
dsi_packet_t * | packet | |||
) | [inline, static] |
Commit send packet.
socket | Socket descriptor | |
packet | Packet descriptor |
Definition at line 563 of file packet.c.
References __get_packet_index(), __is_valid_packet(), dsi_packet::flags, dsi_socket::header, dsi_ctrl_header::packets_committed, dsi_packet::rx_sem, dsi_packet::sg_len, and dsi_socket::sync_th.
Referenced by dsi_packet_commit().
static void __event_thread | ( | void * | data | ) | [static] |
Component event signalling thread.
data | Thread data (unused). |
request: dw0 bits 31/30 command 0 ... set events (only allowed by other threads of the component) 1 ... reset events 2 ... wait for events bits 29-0 event mask dw1 socket id
reply: dw0 error code dw1 event mask (reply for EVENT_WAIT)
Definition at line 350 of file event.c.
References __reset_event(), __set_event(), __wait_for_events(), and EVENT_SET.
Referenced by dsi_init_event_signalling().
static int __get_dm_id | ( | void | ) | [inline, static] |
Request dataspace manager from L4 environment.
Definition at line 73 of file dataspace.c.
References dsi_dm_id.
Referenced by dsi_create_ctrl_area(), and dsi_set_data_area().
static int __get_packet_index | ( | dsi_socket_t * | socket, | |
dsi_packet_t * | packet | |||
) | [inline, static] |
Calculate packet index.
socket | Socket descriptor | |
packet | Packet descriptor |
Definition at line 91 of file packet.c.
References dsi_socket::packets.
Referenced by __commit_receive_packet(), __commit_send_packet(), and __send_release_notification().
static int __get_receive_packet | ( | dsi_socket_t * | socket, | |
int * | packet | |||
) | [inline, static] |
Try to lock next receive packet in packet ring list.
socket | Socket descriptor |
packet | Index of next receive packet | |
0 | on success (packet contains valid index) | |
-DSI_ENOPACKET | - non-blocking mode: next packet still used by the send component
| |
-DSI_EEOS | aborted by dsi_packet_get_abort() | |
-DSI_ECONNECT | blocking mode: communication peer does not exist |
There are two ways to map/copy the data of a packet (required if DSI_SOCKET_MAP or DSI_SOCKET_COPY flags are set for the socket). If dsi_down calls the sender sync thread to wait for the next packet, the sender maps/copies the data in the reply message (see dsi_sync_thread_send()). If we get the packet without calling the remote sync thread, we must map/copy the data explicitly.
Definition at line 410 of file packet.c.
References __copy_receive_data(), __map_receive_data(), dsi_socket::data_area, dsi_socket::data_map_size, dsi_socket::data_size, dsi_socket::flags, dsi_socket::header, dsi_socket::next_packet, dsi_packet::no, dsi_ctrl_header::num_packets, dsi_socket::packet_get_abort_env, dsi_socket::packets, dsi_socket::remote_socket, dsi_packet::rx_sem, dsi_socket::sync_callback, and dsi_socket_ref::sync_th.
Referenced by dsi_packet_get().
static int __get_send_packet | ( | dsi_socket_t * | socket, | |
int * | packet | |||
) | [inline, static] |
Try to lock next send packet in packet ring list.
socket | Socket descriptor |
packet | Index of next send packet | |
0 | on success (packet contains valid index) | |
-DSI_ENOPACKET | - non-blocking mode: next packet still used by the receive component
| |
-DSI_ECONNECT | blocking mode: communication peer does not exist |
Definition at line 231 of file packet.c.
References dsi_packet::flags, dsi_socket::flags, dsi_socket::header, dsi_socket::next_packet, dsi_packet::no, dsi_ctrl_header::num_packets, dsi_socket::packet_count, dsi_socket::packet_get_abort_env, dsi_socket::packets, dsi_socket::remote_socket, dsi_packet::sg_len, dsi_packet::sg_list, dsi_socket::sync_callback, dsi_socket_ref::sync_th, and dsi_packet::tx_sem.
Referenced by dsi_packet_get().
static int __get_sg_elem | ( | dsi_socket_t * | socket, | |
int * | sg_elem | |||
) | [inline, static] |
Find unused scatter gather list element.
socket | Socket descriptor. |
sg_elem | Index of empty scattet gather list element | |
0 | got unused element, sg_elem contains index to empty scatter-gather list element | |
-DSI_ENOSGELEM | no scatter-gather list element found |
Definition at line 175 of file packet.c.
References dsi_sg_elem::flags, dsi_socket::header, dsi_socket::next_sg_elem, dsi_ctrl_header::num_sg_elems, and dsi_socket::sg_lists.
Referenced by dsi_packet_add_data().
static int __is_valid_packet | ( | dsi_socket_t * | socket, | |
dsi_packet_t * | packet | |||
) | [inline, static] |
Check if packet points to a valid packet descriptor of socket.
socket | Socket descriptor | |
packet | Packet descriptor |
Definition at line 51 of file packet.c.
References dsi_socket::header, dsi_ctrl_header::num_packets, and dsi_socket::packets.
Referenced by __commit_receive_packet(), __commit_send_packet(), dsi_packet_add_data(), dsi_packet_get_data(), dsi_packet_get_no(), and dsi_packet_set_no().
static int __map_ctrl_ds | ( | dsi_socket_t * | socket, | |
dsi_stream_cfg_t | cfg | |||
) | [static] |
Map control dataspace, setup pointers in socket structure.
socket | Socket descriptor | |
cfg | Low level stream configuration |
Definition at line 170 of file dataspace.c.
References cds_map_area, dsi_socket::ctrl_ds, dsi_socket::header, dsi_stream_cfg::num_packets, dsi_socket::packets, and dsi_socket::sg_lists.
Referenced by dsi_create_ctrl_area(), and dsi_set_ctrl_area().
static int __reset_event | ( | l4_threadid_t | client, | |
dsi_socketid_t | id, | |||
l4_uint32_t | events | |||
) | [static] |
Reset events.
client | Client thread id | |
id | Socket id | |
events | Event mask |
-L4_EINVAL
invalid socket id or event mask Definition at line 202 of file event.c.
References DSI_MAX_EVENTS, dsi_socket_get_descriptor(), and dsi_socket::events.
Referenced by __event_thread().
static void __select_thread | ( | void * | data | ) | [static] |
Select thread.
data | Thread data, pointer to dsi_select_thread_arg struct |
Definition at line 54 of file select.c.
References dsi_event_wait(), dsi_select_thread_arg::error, dsi_socket_ref::event_th, dsi_select_thread_arg::events, dsi_select_thread_arg::mask, dsi_select_thread_arg::sem, dsi_socket_ref::socket, and dsi_select_thread_arg::socket.
Referenced by dsi_stream_select().
static int __send_release_notification | ( | dsi_socket_t * | socket, | |
dsi_packet_t * | packet | |||
) | [inline, static] |
Send release packet notification to send component.
socket | Socket descriptor | |
packet | Packet descriptor |
Definition at line 110 of file packet.c.
References __get_packet_index(), dsi_packet::no, dsi_socket::remote_socket, and dsi_socket_ref::sync_th.
Referenced by __commit_receive_packet().
static int __set_event | ( | dsi_socketid_t | id, | |
l4_uint32_t | events | |||
) | [static] |
Set events.
id | Socket id | |
events | Event mask |
-L4_EINVAL
invalid socket id-L4_EIPC
IPC error sending wakeup messageDefinition at line 118 of file event.c.
References __client_wakeup(), dsi_socket::clients, DSI_MAX_EVENTS, dsi_socket_get_descriptor(), dsi_event_client::events, dsi_socket::events, dsi_event_client::id, dsi_event_client::next, and dsi_socket::waiting.
Referenced by __event_thread().
static int __wait_for_events | ( | l4_threadid_t | client, | |
dsi_socketid_t | id, | |||
l4_uint32_t | events | |||
) | [static] |
Wait for events.
client | Client thread id | |
id | Socket id | |
events | Event mask |
-L4_EINVAL
invalid socket id-L4_EBUSY
someone else already registered for one of the eventsDefinition at line 256 of file event.c.
References __client_wakeup(), dsi_socket::clients, DSI_MAX_EVENTS, dsi_socket_get_descriptor(), dsi_event_client::events, dsi_socket::events, dsi_event_client::id, dsi_event_client::next, and dsi_socket::waiting.
Referenced by __event_thread().
int dsi_create_ctrl_area | ( | dsi_socket_t * | socket, | |
dsi_jcp_stream_t | jcp_stream, | |||
dsi_stream_cfg_t | cfg | |||
) |
Allocate and setup control area.
socket | Socket descriptor | |
jcp_stream | Stream description | |
cfg | Low level stream configuration |
Definition at line 245 of file dataspace.c.
References __get_ctrl_ds_size(), __get_dm_id(), __init_ctrl_ds(), __map_ctrl_ds(), dsi_socket::ctrl_ds, dsi_dm_id, dsi_socket::header, dsi_ctrl_header::num_packets, dsi_socket::num_packets, dsi_ctrl_header::num_sg_elems, and dsi_socket::num_sg_elems.
Referenced by dsi_socket_create().
l4_threadid_t dsi_create_event_thread | ( | l4thread_fn_t | fn | ) |
Start event signalling thread.
fn | Signalling thread function |
L4_INVALID_ID
if creation failed.Definition at line 212 of file thread.c.
Referenced by dsi_init_event_signalling().
int dsi_create_sync_thread | ( | dsi_socket_t * | socket | ) |
Create new synchronization thread for socket.
socket | Socket descriptor |
Definition at line 132 of file thread.c.
References dsi_sync_thread_receive(), dsi_sync_thread_send(), dsi_socket::socket_id, dsi_socket::sync_id, and dsi_socket::sync_th.
Referenced by dsi_socket_create().
int dsi_event_reset | ( | l4_threadid_t | event_thread, | |
dsi_socketid_t | socket_id, | |||
l4_uint32_t | events | |||
) |
Reset events.
event_thread | Event signalling thread id | |
socket_id | Socket id | |
events | Event mask |
-L4_EIPC
error calling signalling thread-L4_EINVAL
invalid socket id or event mask Definition at line 494 of file event.c.
Referenced by dsi_stream_select().
int dsi_event_set | ( | dsi_socketid_t | socket_id, | |
l4_uint32_t | events | |||
) |
Set events.
socket_id | Socket id | |
events | Event mask |
-L4_EINVAL
invalid socket id-L4_EIPC
IPC error sending wakeup message to clientDefinition at line 438 of file event.c.
References dsi_component_event_id, and EVENT_SET.
Referenced by dsi_socket_set_event().
l4_int32_t dsi_event_wait | ( | l4_threadid_t | event_thread, | |
dsi_socketid_t | socket_id, | |||
l4_uint32_t | events | |||
) |
Wait for events.
event_thread | Event signalling thread id | |
socket_id | Socket id | |
events | Event mask |
-L4_EIPC
error calling signalling thread-L4_EINVAL
invalid socket id-L4_EBUSY
another client is already registered for one of the eventsDefinition at line 537 of file event.c.
Referenced by __select_thread().
static int dsi_is_valid_component | ( | dsi_component_t * | component | ) | [static] |
Check if component
is a valid component decription.
component | component description |
!0 | if component is valid description | |
0 | otherwise |
Definition at line 107 of file app.c.
References dsi_component::connect, dsi_component::socketref, dsi_socket_ref::sync_th, and dsi_socket_ref::work_th.
Referenced by dsi_stream_create().
int dsi_is_valid_stream | ( | dsi_stream_t * | stream | ) |
Check if stream
is a valid stream descriptor.
stream | stream descriptor |
!0 | if stream points to valid stream descriptor | |
0 | otherwise |
Definition at line 89 of file app.c.
References dsi_stream::flags.
Referenced by dsi_stream_close(), dsi_stream_select(), dsi_stream_start(), and dsi_stream_stop().
int dsi_release_ctrl_area | ( | dsi_socket_t * | socket | ) |
Release control dataspace.
socket | Socket descriptor |
Definition at line 399 of file dataspace.c.
References dsi_socket::ctrl_ds, dsi_socket::flags, and dsi_socket::header.
Referenced by dsi_socket_close(), and dsi_socket_create().
int dsi_set_ctrl_area | ( | dsi_socket_t * | socket, | |
l4dm_dataspace_t | ctrl_ds, | |||
dsi_jcp_stream_t | jcp_stream, | |||
dsi_stream_cfg_t | cfg | |||
) |
Attach and setup control area.
socket | Socket descriptor | |
ctrl_ds | Control dataspace | |
jcp_stream | Stream description | |
cfg | Low level stream configuration |
Definition at line 317 of file dataspace.c.
References __map_ctrl_ds(), dsi_socket::ctrl_ds, dsi_socket::header, dsi_stream_cfg::max_sg, dsi_stream_cfg::num_packets, dsi_ctrl_header::num_packets, dsi_socket::num_packets, dsi_ctrl_header::num_sg_elems, dsi_socket::num_sg_elems, dsi_socket::packets, and dsi_socket::sg_lists.
Referenced by dsi_socket_create().
int dsi_set_data_area | ( | dsi_socket_t * | socket, | |
l4dm_dataspace_t | data_ds | |||
) |
Attach data dataspace.
socket | Socket descriptor | |
data_ds | Data dataspace |
Definition at line 449 of file dataspace.c.
References __get_dm_id(), dsi_socket::data_area, dsi_socket::data_ds, dsi_socket::data_map_size, dsi_socket::data_size, dds_map_area, dsi_dm_id, dsi_socket::flags, and dsi_socket::next_buf.
Referenced by dsi_socket_create().
int dsi_shutdown_sync_thread | ( | dsi_socket_t * | socket | ) |
Shutdown synchronization thread.
socket | Socket descriptor. |
Definition at line 189 of file thread.c.
References dsi_socket::sync_id.
Referenced by dsi_socket_close(), dsi_socket_create(), and dsi_socket_stop().
int dsi_start_sync_thread | ( | dsi_socket_t * | socket | ) |
Send connect message to synchronization thread.
socket | Socket descriptor |
Definition at line 528 of file sync.c.
References dsi_socket::sync_th.
Referenced by dsi_socket_connect().
void dsi_sync_thread_receive | ( | void * | data | ) |
Synchronization thread, receive component.
data | thread data, pointer to socket descriptor |
Definition at line 370 of file sync.c.
References dsi_packet::flags, dsi_socket::packets, dsi_socket::remote_socket, dsi_socket_ref::socket, dsi_socket::work_th, and dsi_socket_ref::work_th.
Referenced by dsi_create_sync_thread().