Secure Request Framework

| Secure Request Framework

Data Structures
Data Structures
Secure Request IPC integration | Secure Request IPC integration Initialization

## General Description

## Data Structures
struct | mtb_srf_ipc_packet_t
| Default request structure for use in IPC-enabled SRF This couples normal SRF data with an IPC semaphore index to provide cross-core signalling. More...
struct | mtb_srf_ipc_pool_s
| Secure request pool data structure with IPC integration. More...
struct | mtb_srf_ipc_ringbuf_t
| Ringbuffer implementation for storing requests. More...
struct | mtb_srf_ipc_relay_context_s
| A Relay context, used to receive requests over IPC and then submit them as SRF requests to the secure environment. More...
struct | mtb_srf_ipc_client_context_s
| A Client context which is used to track the state of a core sending requests to the secure environment. More...
struct | mtb_srf_ipc_pool_cfg_t
| IPC Pool config, used to setup an SRF IPC pool. More...
struct | mtb_srf_ipc_client_context_cfg_t
| A Client context config used to configure a client context. More...
struct | mtb_srf_ipc_relay_context_cfg_t
| Config to setup a relay context. More...
struct | mtb_srf_ipc_client_init_cfg_t
| Config struct to set up entire SRF system including IPC mailbox, semaphores and Client context. More...
struct | mtb_srf_ipc_relay_init_cfg_t
| Config struct to set up entire SRF system including IPC mailbox, semaphores and Relay context. More...

## Data Structure Documentation

## ◆ mtb_srf_ipc_packet_t

struct mtb_srf_ipc_packet_t

Data Fields
mtb_srf_invec_ns_t * | inVec_ptr | Pointer to vector for all operation and SRF input.
uint8_t | inVec_cnt_ns | Number of input vectors in inVec_ns array.
mtb_srf_outvec_ns_t * | outVec_ptr | Pointer to vector for all operation and SRF output.
uint8_t | outVec_cnt_ns | Number of output vectors in outVec_ns array.
uint16_t | semaphore_idx | Index in the semaphore array for semaphore used to signal completion.
cy_rslt_t | request_rslt | Result of the SRF operation, which may not be success even if the IPC request succeeded.

## ◆ mtb_srf_ipc_pool_s

struct mtb_srf_ipc_pool_s

Data Fields
mtb_srf_ipc_packet_t * | request_pool | Request pool to align with semaphores for signalling.
uint32_t | num_requests | Number of requests.
uint32_t | request_available | A bitmap where ach bit indicates request object is available or not. It implies a max secure request pool size of 32.
mtb_ipc_semaphore_t * | request_semaphores | List of semaphores to allocate to each request.
uint32_t | num_semaphores | Numnber of semaphore.
uint32_t | semaphore_available | A bitmap where ach bit indicates semaphore object is available or not. It implies a max semaphore pool size of 32.

## ◆ mtb_srf_ipc_ringbuf_t

struct mtb_srf_ipc_ringbuf_t

Data Fields
mtb_srf_ipc_packet_t ** | buffer | Buffer for storing packets.
size_t | head | Buffer head.
size_t | tail | Buffer tail.
size_t | max | Number of elements the buffer can contain.
bool | full | Status on if the buffer is full.

## ◆ mtb_srf_ipc_relay_context_s

struct mtb_srf_ipc_relay_context_s

Data Fields
uint32_t | num_semaphores | Number of semaphores.
mtb_ipc_semaphore_t * | request_semaphores | Array of IPC semaphores for signalling back to the client process. These match up with the semaphores on the client's pool
mtb_ipc_mbox_receiver_t * | mailbox_handle | Pointer to mailbox handle for sending data over IPC.
mtb_srf_ipc_ringbuf_t | ipc_req_buffer | Ringbuffer for storing requests as they come in.

## ◆ mtb_srf_ipc_client_context_s

struct mtb_srf_ipc_client_context_s

Data Fields
mtb_srf_ipc_pool_t * | pool | Pool of memory and semaphores used to allocate for requests from a client process through the relay process to the secure server.
mtb_ipc_mbox_sender_t * | mailbox_handle | Pointer to the mailbox used to sed/receive data over IPC.

## ◆ mtb_srf_ipc_pool_cfg_t

struct mtb_srf_ipc_pool_cfg_t

Data Fields
mtb_srf_ipc_packet_t * | request_pool | Pointer to a section of memory allocated by the caller for the request pool. Recommend using MTB_SRF_IPC_REQUEST_DATA_ALLOC to allocate the memory.
uint32_t | num_requests | Numnber of requests.
mtb_ipc_semaphore_t * | request_semaphores | Pointer to array of initialized IPC semaphore handles. This must be in same order as the array on the relay context
uint32_t | num_semaphores | Numnber of semaphore.

## ◆ mtb_srf_ipc_client_context_cfg_t

struct mtb_srf_ipc_client_context_cfg_t

Data Fields
mtb_srf_ipc_pool_t * | pool | Pool of memory and semaphores used to allocate for requests from a client process through the relay process to the secure server.
mtb_ipc_mbox_sender_t * | mailbox_handle | Pointer to the mailbox used to sed/receive data over IPC.

## ◆ mtb_srf_ipc_relay_context_cfg_t

struct mtb_srf_ipc_relay_context_cfg_t

Data Fields
mtb_ipc_mbox_receiver_t * | mailbox | Mailbox object for receiving secure requests over IPC.
uint32_t | num_semaphores | Number of semaphores.
mtb_ipc_semaphore_t * | request_semaphores | Pointer to array of initialized IPC semaphore handles. This must match the ordering of those on the client's IPC pool
uint32_t | num_requests | Number of entries in the pool on the client core.
mtb_srf_ipc_packet_t ** | buffer | A buffer of length num_requests that is used for holding addresses of recieved mailbox packets.

## ◆ mtb_srf_ipc_client_init_cfg_t

struct mtb_srf_ipc_client_init_cfg_t

Data Fields
uint32_t | mbox_idx | MTB IPC Mailbox index to use for SRF.
mtb_srf_ipc_packet_t * | srf_ipc_requests | Pointer to requests array to be used by MTB SRF IPC.
uint32_t | num_requests | Number of entries in the pool on the client core.
mtb_ipc_t * | ipc_instance | Pointer to the initialized IPC instance.
mtb_ipc_semaphore_t * | semaphore_handles | Pointer to array of handles for semaphores to be used by MTB SRF IPC.
uint32_t | num_semaphores | Number of semaphores.
mtb_ipc_mbox_sender_t * | mailbox_handle | Pointer to mailbox handle to set up IPC mailbox.
mtb_srf_ipc_pool_t * | srf_ipc_pool | Pointer to SRF IPC pool.
uint32_t * | ipc_sem_indexes | Pointer to IPC semaphore indexes to be used by SRF.

## ◆ mtb_srf_ipc_relay_init_cfg_t

struct mtb_srf_ipc_relay_init_cfg_t

Data Fields
uint32_t | mbox_idx | MTB IPC Mailbox index to use for SRF.
uint32_t | mbox_read_sema_idx | MTB IPC Mailbox read_semaphore index to use for SRF.
uint32_t | mbox_write_sema_idx | MTB IPC Mailbox write semaphore index to use for SRF.
mtb_ipc_semaphore_data_t * | semaphore_data | Pointer to array of data for semaphores to be used by MTB SRF IPC.
mtb_ipc_mbox_data_t * | mailbox_data | Pointer to Mailbox data to set up IPC mailbox.
mtb_ipc_t * | ipc_instance | Pointer to the initialized IPC instance.
mtb_ipc_semaphore_t * | semaphore_handles | Pointer to array of handles for semaphores to be used by MTB SRF IPC.
uint32_t | num_semaphores | Number of semaphores.
mtb_ipc_mbox_receiver_t * | mailbox_handle | Pointer to mailbox handle to set up IPC mailbox.
uint32_t * | ipc_sem_indexes | Pointer to IPC semaphore indexes to be used by SRF.
uint32_t | num_requests | Number of entries in the pool on the client core.
mtb_srf_ipc_packet_t ** | buffer | A buffer of length num_requests that is used for holding addresses of recieved mailbox packets.