Skip to main content
Mailbox provides a driver interface to exchange messages between mailbox clients and RTSS. Messages are stored in designated mailbox regions. The following figure shows exchange of messages between RTSS and APSS through mailbox:
Image The figure explains the mailbox driver features: Image The following are the key components in the mailbox driver: Image Linux HLOS mailbox server The Linux HLOS mailbox server (often called the HLOS mailbox resource manager or HLOS mailbox interface) is the user‑space or kernel‑space interface that lets Linux (HLOS) applications exchange messages with RTSS over the DDR region using the mailbox IPC mechanism. The Linux HLOS mailbox server acts as the HLOS mailbox resource manager and provides device nodes that:
  • Map the mailbox hardware (configured by the RTSS mailbox driver) into /dev/sail/* channels.
  • Offer notification APIs for HLOS applications.
  • Allow full duplex, structured IPC between Linux and RTSS/NHLOS over the mailbox IPC mechanism.
Typical usage flow (HLOS side) for a simple mailbox message read/write:
  1. Open channel: Application opens Tx and Rx device nodes exposed by the mailbox resource manager.
  2. Send: Application writes a structured message to the Tx device node.
  3. Receive:
    • Application blocks (or uses poll()/select()) on the Rx device node.
    • Reads messages when notified (async or poll based).
  4. Close: Application closes the mailbox handles; resource manager cleans up context.
Source code details:
  • sources/sail-mailbox/sail-mb-umd/include/sail_mailbox.h
  • sources/sail-mailbox/sail-mb-umd/src/sail_mbox_core.c, sail_mbox_lib.c, sail_mbox_lib.h, and sailmb_internal.c
RTSS mailbox external driver The mailbox external driver is the mechanism that creates and manages shared-memory channels between RTSS and APSS (HLOS).
  • Carves the shared DDR mailbox region into multiple regions such as region 0, region 1, and region 2.
  • Treats each region as a channel/subregion identified by a unique channel/subregion IDN.
  • Provides the buffering and notification infrastructure for message passing between RTSS and APSS.
This is the RTSS side counterpart to the HLOS mailbox server. The mailbox external driver manages the low-level shared-memory regions and IPC controller, while the HLOS communicates using /dev/sail/* nodes. Message flow and notifications:
  1. RTSS and APSS share DDR mailbox regions managed by mailbox external driver (RTSS side) and the corresponding APSS/HLOS drivers.
  2. When APSS or RTSS writes data into a region’s circular buffer, that data becomes available to the application.
  3. To notify the application that new data is available or that a buffer has been consumed:
    The mailbox external driver uses an IPCC to generate asynchronous events between APSS and RTSS.
  4. On RTSS:
  • These IPC events trigger the mailbox external driver callbacks.
  • Typical RTOS IPC mechanisms are used to wake up or synchronize tasks that consume/produce messages in real time.
Source code details:
  • sail_proc/BSP/mailboxExt/public/mailboxExt_api.h
  • sail_proc/BSP/mailboxExt/src/mailboxExt_api.c, mailboxExt_config.c
Mailbox region - DDR DDR is an external memory used as shared memory for the mailbox driver to store the messages by Linux HLOS and RTSS.

Create a new mailbox channel

On RTSS side
  1. Add client ID.
    1. Add the new client ID to xMailboxExtclienttype in mailboxExt_api.h.
    2. Place the entry between the QCMI start and end markers:
  1. Add channel IDs.
a. Add RTSS Receiver (Rx), Sender (Tx), or both Rx-Tx ID pairs to mailboxEBChanType_e in mailboxExt_config.h. b. Insert the IDs within the QCMI start and end markers:
  1. Update subregion count.
a. Update mailboxEB_QCMI_NUMSUBREGION in mailboxExt_config.h to reflect the new channel:
  • For an Rx-Tx pair, the number of subregions is 2, so set mailboxEB_QCMI_NUMSUBREGION to 22.
  • For Rx or Tx only, the number of subregions is 1, so set mailboxEB_QCMI_NUMSUBREGION to 21.
  1. Define a new channel configuration entry.
a. Add a new channel configuration entry in the mailboxEB_DATA static resource table:
This entry must follow the updated channel index numbering defined in the xMailboxExtClientType enum. Structure definition of mbsub_rgn_config_t:
See the mailboxExt_config.c file for examples of existing channel configurations. The MAILBOX_CONSOLE entry with index value 3 in the xMailboxExtClientType enum is defined as follows:
Note
  • The name field should have three characters, with suffix 0 for read and 1 for write channels.
  • If a single Rx or Tx ID is mapped to the xMailboxExtClientType client entry, initialize other channel entries with default values, see MAILBOX_CONSOLE example
  1. Add entry in xMailboxClientRec table. a. Update the mailboxEB_CONST table:
Structure definition of xMailboxEBClientRec_t:
Structure definition of xMailboxEBChanRec_t:
For the /dev/sail/log channel, the client with MAILBOX_CONSOLE client ID contains the following configuration entries, where only the Tx (write) channel is defined.
Protocol and channel mapping:
The following table lists the protocol signals, sender, receiver, and channel support for integrator reference when adding a new channel in the mailboxExt driver.
  • Select the protocol, sender, and receiver according to the table.
  • RTSS cores use logical number suffixes appended to macros, for example, IPCC_C_SAIL0 for core 0.
  • The sender column indicates the sender client line used by APSS to link with the RTSS domain receiver client. Each sender client provides the number of signals specified in the table based on protocol selection.
Reference: The mailbox_test application is location at sail_proc\BSP\tests\sailsw1\mailbox_test\src\MBtests_sailsw1.c.
On APPS side
  1. Add a new channel entry in the devicetree.
    1. Update the devicetree with the new channel configuration:
    Note
    &ipcc_computeL1 IPCC_CLIENT_SAIL0 0xA indicates:
    • ipcc_computeL1: Protocol name (currently only this is supported).
    • IPCC_CLIENT_SAIL1: RTSS core number.
    • 0XA: Channel number.
    • Example mapping:
      This corresponds to the /dev/sail/log, mapped to MAILBOX_CONSOLE with index value 3 in the xMailboxExtClientType enum.
References:
  • saildbg
    • Location sail-mailbox/reference_apps/sail_dbg/src/saildbg.c
    • Key APIs:
      • open_sail_mailbox(): Opens the mailbox channel for TX and RX.
      • write_sail_mailbox(): Writes a message to the TX channel.
      • read_sail_mailbox(): Reads a message from the RX channel.
      • close_sail_mailbox(): Closes the mailbox channel for TX and RX.
    • Structures:
      • struct SailClientDataType *pTxClientData: TX structure for transmitting messages.
      • struct SailClientDataType *pRxClientData: RX structure for receiving messages.
    • Mailbox test application: Mailbox test application: saildbg
  • sail_console_chan:

RTSS mailbox demo application

The sailmb_demo reference application demonstrates bidirectional mailbox communication between the APSS, which runs Linux, and RTSS, which runs Free RTOS. The application sends a message from APSS to an RTSS CPU core and receives a response from that RTSS CPU core. A successful message exchange verifies the following:
  • The RTSS firmware has initialized the shared mailbox structure in DDR.
  • The Linux mailbox driver has loaded, mapped the shared memory, and completed the hardware handshake with RTSS.
  • The APSS application can write a message to shared memory and trigger an interrupt to RTSS.
  • RTSS can receive the interrupt, read the message, write a response, and trigger an interrupt to APSS.
  • APSS can receive the interrupt, read the response, and display it on the console.
The application communicates with four RTSS CPU cores. Each core uses a dedicated transmit and receive channel pair. The mailbox channel mappings in the following table are from the APSS perspective: To run the RTSS mailbox demo application, see Mailbox test application: sailmb_demo.