nmc-utils  0.1.1
Simple Mail box IPC API

Data Structures

struct  easynmc_mbox_data
struct  easynmc_mbox

Enumerations

enum  mbox_status { MBOX_EMPTY = 0, MBOX_NOT_EMPTY = 1 }

Functions

struct easynmc_mboxeasynmc_mbox_new (struct easynmc_handle *h, const char *section)
int easynmc_mbox_available (struct easynmc_sync *s)
void easynmc_mbox_free (struct easynmc_sync *s)
int easynmc_mbox_post (struct easynmc_sync *s, uint32_t *data, uint32_t len)
int easynmc_mbox_post_noblock (struct easynmc_sync *s, uint32_t *data, uint32_t len)
int easynmc_mbox_recv (struct easynmc_sync *s, uint32_t *data, uint32_t *len)
int easynmc_mbox_recv_nonblock (struct easynmc_sync *s, uint32_t *data, uint32_t len)
int easynmc_mbox_get_size (struct easynmc_sync *s)
uint32_t * easynmc_mbox_get_buffer (struct easynmc_sync *s)
void easynmc_mbox_set_status (struct easynmc_sync *s)
int easynmc_mbox_get_status (struct easynmc_sync *s)

Variables

uint32_t easynmc_mbox_data::sync_status
uint32_t easynmc_mbox_data::datalen
uint32_t easynmc_mbox_data::data []
uint32_t easynmc_mbox::offset
struct easynmc_handleeasynmc_mbox::h

Detailed Description

Mail box is one of the simplest way to communicate with the DSP. This mailbox implementation on top of libeasynmc implements the simplest possible mailbox with the following assumptions:

To actually use this API you have to declare one or more mailboxes in your DSP application. They are normally allocated in easyconf.asm using EASYNMC_MBOX() macro. Each mailbox will be placed in a dedicated section that will be used to identify it.

Each mailbox has dedicated message buffer associated with it. The size of the buffer is defined by the EASYNMC_MBOX() macro when compiling the DSP app. From the host application you can query buffer size using easynmc_mbox_get_size().

To actually attach the mailbox API to your DSP app you have to call easynmc_mbox_new() on an easynmc handle BEFORE calling easynmc_load_abs(); easynmc_mbox_new() will return a pointer you will be passing around all the mailbox API calls. After loading the abs file, you should call easynmc_mbox_available() which will tell you if the abs loader has located your mailbox correctly. If your DSP app lacks a corresponding section, this is the place for you to find out and handle the error.

The mailbox automatically becomes unavailable when the application is stopped. There's no need to free the mailbox before starting the app again - it will be attached on the next abs file load

When you are done working with a mailbox you can free it using easynmc_mbox_free(). Doing that when the application

Enumeration Type Documentation

Enumerator:
MBOX_EMPTY 
MBOX_NOT_EMPTY 

Definition at line 43 of file easynmc-bsync.c.

Function Documentation

int easynmc_mbox_available ( struct easynmc_sync *  s)

Returns non-zero value when the mailbox becomes valid, e.g. the abs loader located it's section. You should do this check every time you load a new abs file before doing any operations on an easynmc_sync.

Parameters
s
Returns

Definition at line 76 of file easynmc-bsync.c.

void easynmc_mbox_free ( struct easynmc_sync *  s)

Free an allocated mail box

Parameters
s

Definition at line 85 of file easynmc-bsync.c.

uint32_t* easynmc_mbox_get_buffer ( struct easynmc_sync *  s)

Returns internal mmaped() data buffer of a sync

Parameters
s
Returns

Definition at line 177 of file easynmc-bsync.c.

int easynmc_mbox_get_size ( struct easynmc_sync *  s)

Definition at line 150 of file easynmc-bsync.c.

int easynmc_mbox_get_status ( struct easynmc_sync *  s)

Get сurrent sync status.

Parameters
s
Returns

Definition at line 199 of file easynmc-bsync.c.

struct easynmc_mbox* easynmc_mbox_new ( struct easynmc_handle h,
const char *  section 
)
read

Create a new mailbox and associate it with an easynmc handle. The mail box should be associated with the handle BEFORE the app is loaded into the nmc (e.g. call this BEFORE easynmc_load_abs())

Parameters
heasynmc handle
sectionsection containing sync data. Define this in your easyconf.asm See nmc-examples/sync-example
Returns

Definition at line 64 of file easynmc-bsync.c.

int easynmc_mbox_post ( struct easynmc_sync *  s,
uint32_t *  data,
uint32_t  len 
)

Put data of len 32-bit words into the sync. The data length should not exceed the length allocated on the sync. Otherwise an error is returned. This function may block until the sync becomes ready for operation once more. For non-blocking alternative - see easynmc_mbox_post_nonblock()

Parameters
s
data
len
Returns

Definition at line 101 of file easynmc-bsync.c.

int easynmc_mbox_post_noblock ( struct easynmc_sync *  s,
uint32_t *  data,
uint32_t  len 
)

Non-blocking alternative. Returns -EAGAIN if sync is now owned by Neuromatrix

Parameters
s
data
len
Returns

Definition at line 114 of file easynmc-bsync.c.

int easynmc_mbox_recv ( struct easynmc_sync *  s,
uint32_t *  data,
uint32_t *  len 
)

Get data from a sync. The data is stored into the user buffer. The buffer should have sufficient space to store all the data that can be found in a sync. The actual length of the data retrieved is stored into len parameter. This function may block until sync becomes available. For non-blocking variant - see easynmc_sync_get_nonblock()

Parameters
s
data- pointer to store data from a sync
len- pointer to store length
Returns

Definition at line 131 of file easynmc-bsync.c.

int easynmc_mbox_recv_nonblock ( struct easynmc_sync *  s,
uint32_t *  data,
uint32_t  len 
)

Non-blocking alternative to easynmc_sync_get(). Returns -EAGAIN if the sync is in use by DSP core.

Parameters
s
data
len
Returns

Definition at line 145 of file easynmc-bsync.c.

void easynmc_mbox_set_status ( struct easynmc_sync *  s)

Set сurrent sync status.

Parameters
s
Returns

Definition at line 188 of file easynmc-bsync.c.

Variable Documentation

uint32_t easynmc_mbox_data::data[]

Definition at line 40 of file easynmc-bsync.c.

uint32_t easynmc_mbox_data::datalen

Definition at line 39 of file easynmc-bsync.c.

struct easynmc_handle* easynmc_mbox::h

Definition at line 50 of file easynmc-bsync.c.

uint32_t easynmc_mbox::offset

Definition at line 49 of file easynmc-bsync.c.

uint32_t easynmc_mbox_data::sync_status

Definition at line 38 of file easynmc-bsync.c.