Internal functions

DSI-Internal functionality. Not exported by libdsi-functions. More...

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

Detailed Description

DSI-Internal functionality. Not exported by libdsi-functions.

Functions provided by this module should not be used directly by external programms. They are subject to change. This covers structures and defines aswell.


Function Documentation

static int __allocate_socket ( void   )  [static]

Find and allocate unused socket in socket table.

Returns:
index of socket in socket table, -1 if no socket available

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.

Returns:
pointer to unused stream, 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.

Parameters:
client Client thread id
events Event mask
error Error code to be sent to the client
Returns:
0 on success (sent notification), -L4_EIPC on error

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.

Parameters:
socket socket descriptor
packet packet to commit
Return values:
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
The send component can now use this packet for the next send packet. If the sender is already waiting for the packet, send wakeup message.

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.

Parameters:
socket Socket descriptor
packet Packet descriptor
Returns:
0 on success, error code otherwise
  • -L4_EINVAL invalid packet descriptor
  • -DSI_ENODATA tried to commit empty packet
    • -DSI_ENOPACKET peer in blocking mode: committing required a sync-message which failed
The receiver can now use this packet. If the receiver is already waiting for this packet, send wakup message to our synchronization thread.

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.

Parameters:
data Thread data (unused).
IPC protocol

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.

Returns:
0 on success (dsi_dm_id contains ID of dataspace manager), -1 if querry failed.

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.

Parameters:
socket Socket descriptor
packet Packet descriptor
Returns:
index of packet in packet array
Note:
No sanity checks!

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.

Parameters:
socket Socket descriptor
Return values:
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
  • blocking mode: block/unblock-ipc returned an error
-DSI_EEOS aborted by dsi_packet_get_abort()
-DSI_ECONNECT blocking mode: communication peer does not exist
If the packet is not available yet (sender didn't commit data), either block and wait until sender commited data (if DSI_SOCKET_BLOCK flag is set in socket descriptor) or return an error otherwise.

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.

Parameters:
socket Socket descriptor
Return values:
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
  • blocking mode: block/unblock-ipc returned an error
-DSI_ECONNECT blocking mode: communication peer does not exist
If the packet is still used by the receiver, either block and wait until it is released (if DSI_SOCKET_BLOCK flag is set in socket descriptor) or return an error otherwise.

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.

Parameters:
socket Socket descriptor.
Return values:
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
Unused packets have data address set to 0xFFFFFFFF.

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.

Parameters:
socket Socket descriptor
packet Packet descriptor
Returns:
1 if packet is a valid packet descriptor, 0 otherwise

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.

Parameters:
socket Socket descriptor
cfg Low level stream configuration
Returns:
0 on success, error code otherwise:
  • -L4_ENOMEM out of memory attaching dataspace
  • -L4_ENOMAP no map area available
  • -L4_EINVAL invalid argument attaching dataspace

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.

Parameters:
client Client thread id
id Socket id
events Event mask
Returns:
0 on succes (decremented event counter), error code otherwise:
  • -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]

static int __send_release_notification ( dsi_socket_t socket,
dsi_packet_t packet 
) [inline, static]

Send release packet notification to send component.

Parameters:
socket Socket descriptor
packet Packet descriptor
Returns:
0 on success (notification sent), error code otherwise:
  • -L4_EIPC IPC error calling send components sync thread

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.

Parameters:
id Socket id
events Event mask
Returns:
0 on success (incremented event counter), error code otherwise:
  • -L4_EINVAL invalid socket id
  • -L4_EIPC IPC error sending wakeup message
Increment event counter for the vents specified in events and wakeup clients waiting for those events.

Definition 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.

Parameters:
client Client thread id
id Socket id
events Event mask
Returns:
0 on success (registered client), error code otherwise:
  • -L4_EINVAL invalid socket id
  • -L4_EBUSY someone else already registered for one of the events
Register the client for event notification. If one of the events is already set, wakeup client immediately.

Definition 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.

Parameters:
socket Socket descriptor
jcp_stream Stream description
cfg Low level stream configuration
Returns:
0 on success, error code otherwise:
  • -DSI_ENODSM dataspace manager not found
  • -L4_EIPC IPC error calling dataspace manager
  • -L4_ENOMEM not enough memory available allocating ctrl area or attaching dataspace
  • -L4_ENOMAP no map area avaliable mapping ctrl area
  • -L4_EINVAL invalid argument (can happen if the map area is already used by someone else)

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.

Parameters:
fn Signalling thread function
Returns:
L4 threadid of signalling thread, L4_INVALID_ID if creation failed.
The priority of the newly created thread can be set with dsi_set_event_thread_prio() prior to calling this function.

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.

Parameters:
socket Socket descriptor
Returns:
0 on success, error code otherwise (see l4thread_create_long())
The priority of the newly created thread can be set with dsi_set_sync_thread_prio() prior to calling this function.

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.

Parameters:
event_thread Event signalling thread id
socket_id Socket id
events Event mask
Returns:
0 on success (called components event signalling thread), error code otherwise:
  • -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.

Parameters:
socket_id Socket id
events Event mask
Returns:
0 on success (called signalling thread to set events), error code otherwise:
  • -L4_EINVAL invalid socket id
  • -L4_EIPC IPC error sending wakeup message to client
Call event signalling thread to set events. All the manipulation of the event counter and wait queues is done by the signalling thread to ensure synchronization with client requests.

Definition 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.

Parameters:
event_thread Event signalling thread id
socket_id Socket id
events Event mask
Returns:
Event mask set by the component (> 0), error code otherwise:
  • -L4_EIPC error calling signalling thread
  • -L4_EINVAL invalid socket id
  • -L4_EBUSY another client is already registered for one of the events
Wait for the notification by the component that one of the events in events is set.

Definition 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.

Parameters:
component component description
Return values:
!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.

Parameters:
stream stream descriptor
Return values:
!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.

Parameters:
socket Socket descriptor
Returns:
0 on success, error code otherwise.
Detach control dataspace and close dataspace if we created it.

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.

Parameters:
socket Socket descriptor
ctrl_ds Control dataspace
jcp_stream Stream description
cfg Low level stream configuration
Returns:
0 on success, error code otherwise:
  • -L4_EINVAL invalid dataspace or configuration
  • -L4_EPERM no permissions to access dataspace
  • -L4_EIPC IPC error calling dataspace manager
  • -L4_ENOMAP no map area available to attach dataspace
  • -L4_ENOMEM out of memory attaching dataspace

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.

Parameters:
socket Socket descriptor
data_ds Data dataspace
Returns:
0 on success, error code otherwise:
  • -L4_EINVAL invalid dataspace
  • -L4_EPERM no permissions to access dataspace
  • -L4_EIPC IPC error calling dataspace manager
  • -L4_ENOMEM out of memory attaching dataspace
  • -L4_ENOMAP no map area available to attach 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.

Parameters:
socket Socket descriptor.
Returns:
0 on success, error code otherwise (see l4thread_shutdown())

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.

Parameters:
socket Socket descriptor
Returns:
0 on success (sent start to sync thread), error code otherwise:
  • -L4_EINVAL invalid synchronization thread id
  • -L4_EIPC IPC error calling synchronization thread

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.

Parameters:
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().


Generated on Wed Apr 11 06:40:14 2012 for DSI - Drops Streaming Interface by  doxygen 1.5.6