This library provides support for sending requests from an alternative core to the core with the secure paritition.
The non-secure partition acts as a relay to unpack the request sent over Infineon's interprocessor communication library (MTB-IPC) and submit it in the same way as other non-secure requests. The library also provides functionality to signal completion so the requesting core can view the results. This is accomplished through two roles: Client and Relay. The Client owns a pool of requests that are tied to IPC semaphores that will signal completion. The relay receives unpacks requests on the core containing the secure region before processing and signalling. This requires each of the contexts to be set up to create the relay relationship and begin submitting requests. Refer to SRF documentation Secure Request Framework for more information on secure requests and request pools. The APIs for submiting a request remain the same on all cores, but a client context must be set up on the core that needs IPC in order for the request to be sent correctly.
Refer to Code Snippets for more information.
The IPC components of the SRF IPC integration must be set up prior to transfer. Please refer to MTB-IPC documentation on how to setup an IPC instance and a mailbox for request transfer. The MTB SRF IPC will by default consume MTB_SRF_IPC_SEMA_COUNT + 3 semaphores for its own use.
Request pool data memory allocation can be done with help of MTB_SRF_IPC_REQUEST_DATA_ALLOC macro, but using it is not mandatory, so user can allocate memory for the shared memory in any convenient for them way. This struct is necessary to store and keep track of all shared objects during operation.
Many APIs can be overridden with macros to allow custom implementations. To support this, the mtb_srf_ipc_packet_t type can be overriden via the define MTB_SRF_IPC_CUSTOM_PACKET_TYPE. However, the various APIs have minimum requirements on what this type defines.
mtb_srf_ipc_request_submit, overridden via MTB_SRF_CUSTOM_IPC_REQUEST_SUBMIT, requires all the default packet struct members to operate.
mtb_srf_ipc_process_request, overridden via MTB_SRF_CUSTOM_PROCESS_REQUEST, requires the ioVec pointers and counts (inVec_ptr, inVec_cnt_ns, outVec_ptr, outVec_cnt_ns).
mtb_srf_ipc_signal_complete, which cannot be overriden, requires the semaphore_idx member.
All other APIs interact with the packet type as a pointer and aren't affected by the contents.
Register a Client and transfer request
Register a Relay
Start Relay (Non-RTOS)
Start Relay (RTOS)
Quick init of Client
Quick init of Relay
API Reference | |
| Data Structures | |
Functions | |
| cy_rslt_t | mtb_srf_ipc_request_submit (mtb_srf_ipc_client_context_t *client_context, mtb_srf_invec_ns_t *inVec_ns, uint8_t inVec_cnt_ns, mtb_srf_outvec_ns_t *outVec_ns, uint8_t outVec_cnt_ns) |
| Submit a request from another core to a TrustZone enabled core. | |
| cy_rslt_t | mtb_srf_ipc_pool_semaphore_alloc (mtb_srf_ipc_pool_t *pool, uint16_t *sema_idx, uint32_t timeout_us) |
| Allocate IPC semaphore to use in signalling. | |
| cy_rslt_t | mtb_srf_ipc_pool_req_alloc (mtb_srf_ipc_pool_t *pool, mtb_srf_ipc_packet_t **req, uint32_t timeout_us) |
| Allocate secure request object within an SRF IPC request pool to act as a packet. | |
| cy_rslt_t | mtb_srf_ipc_pool_semaphore_free (mtb_srf_ipc_pool_t *pool, uint16_t sema_idx) |
| Deallocate an IPC semaphore. | |
| cy_rslt_t | mtb_srf_ipc_pool_req_free (mtb_srf_ipc_pool_t *pool, const mtb_srf_ipc_packet_t *req) |
| Free secure request object within an SRF IPC request pool. | |
| cy_rslt_t | mtb_srf_ipc_request_send (mtb_srf_ipc_client_context_t *client_context, mtb_srf_ipc_packet_t *request, uint64_t timeout_us) |
| Sends a request from the non-secure side to the secure and blocks for a timeout until request is processed. | |
| cy_rslt_t | mtb_srf_ipc_receive_request (mtb_srf_ipc_relay_context_t *relay_context, uint64_t timeout_us) |
| Receives an SRF request over IPC and adds to either the queue if using an RTOS or the ringbuffer. | |
| cy_rslt_t | mtb_srf_ipc_process_request (mtb_srf_ipc_packet_t *request) |
| Process the SRF request from IPC. | |
| cy_rslt_t | mtb_srf_ipc_process_pending_request (mtb_srf_ipc_relay_context_t *relay_context) |
| Process the SRF request pending in either the queue if using an RTOS or the ringbuffer. | |
| cy_rslt_t | mtb_srf_ipc_signal_complete (mtb_srf_ipc_relay_context_t *relay_context, mtb_srf_ipc_packet_t *request) |
| Signals to client that secure request has been completed and output can be read. | |
| cy_rslt_t mtb_srf_ipc_request_submit | ( | mtb_srf_ipc_client_context_t * | client_context, |
| mtb_srf_invec_ns_t * | inVec_ns, | ||
| uint8_t | inVec_cnt_ns, | ||
| mtb_srf_outvec_ns_t * | outVec_ns, | ||
| uint8_t | outVec_cnt_ns ) |
Submit a request from another core to a TrustZone enabled core.
| [in,out] | client_context | Stores state that client process needs to track between calls. |
| [in,out] | inVec_ns | Vector for all operation and SRF input |
| [in] | inVec_cnt_ns | Number of input vectors in inVec_ns array |
| [in,out] | outVec_ns | Vector for all operation and SRF output |
| [in] | outVec_cnt_ns | Number of output vectors in outVec_ns array |
| cy_rslt_t mtb_srf_ipc_pool_semaphore_alloc | ( | mtb_srf_ipc_pool_t * | pool, |
| uint16_t * | sema_idx, | ||
| uint32_t | timeout_us ) |
Allocate IPC semaphore to use in signalling.
| [in,out] | pool | The pool object that was populated by mtb_srf_pool_init |
| [in,out] | sema_idx | Pointer to the semaphore index that will be allocated. |
| [in] | timeout_us | Timeout to wait in microsecond. Set to 0 to perform no wait. |
| cy_rslt_t mtb_srf_ipc_pool_req_alloc | ( | mtb_srf_ipc_pool_t * | pool, |
| mtb_srf_ipc_packet_t ** | req, | ||
| uint32_t | timeout_us ) |
Allocate secure request object within an SRF IPC request pool to act as a packet.
| [in,out] | pool | The pool object that was populated by mtb_srf_pool_init |
| [in,out] | req | Pointer to an SRF IPC request object. |
| [in] | timeout_us | Timeout to wait in microsecond. Set to 0 to perform no wait. |
| cy_rslt_t mtb_srf_ipc_pool_semaphore_free | ( | mtb_srf_ipc_pool_t * | pool, |
| uint16_t | sema_idx ) |
Deallocate an IPC semaphore.
| [in,out] | pool | The pool object that was populated by mtb_srf_pool_init |
| [in,out] | sema_idx | Index of semaphore to be deallocated from the pool. |
| cy_rslt_t mtb_srf_ipc_pool_req_free | ( | mtb_srf_ipc_pool_t * | pool, |
| const mtb_srf_ipc_packet_t * | req ) |
Free secure request object within an SRF IPC request pool.
| [in,out] | pool | The pool object that was populated by mtb_srf_pool_init |
| [in] | req | Pointer to an MB SRF request for the pool to free |
| cy_rslt_t mtb_srf_ipc_request_send | ( | mtb_srf_ipc_client_context_t * | client_context, |
| mtb_srf_ipc_packet_t * | request, | ||
| uint64_t | timeout_us ) |
Sends a request from the non-secure side to the secure and blocks for a timeout until request is processed.
This is a function that should be added any implementation of mtb_srf_request_submit, either within the BSP or custom.
| [in,out] | client_context | Stores state that client process needs to track between calls. |
| [in,out] | request | Pointer to SRF IPC request object that will be sent by mailbox. If this is of a type other than default mtb_srf_ipc_packet_t, then please override mtb_srf_ipc_process_request to handle additional parameters. |
| [in] | timeout_us | Timeout (in uS) to attempt to send request over IPC and subsequently wait for a response. |
| cy_rslt_t mtb_srf_ipc_receive_request | ( | mtb_srf_ipc_relay_context_t * | relay_context, |
| uint64_t | timeout_us ) |
Receives an SRF request over IPC and adds to either the queue if using an RTOS or the ringbuffer.
| [in,out] | relay_context | Stores state that client process needs to track between calls. |
| [in] | timeout_us | Timeout (in uS) to attempt to receive request over IPC. |
No RTOS so we add to ring buffer
| cy_rslt_t mtb_srf_ipc_process_request | ( | mtb_srf_ipc_packet_t * | request | ) |
Process the SRF request from IPC.
| [in,out] | request | Secure request to prepare for processing. If this is of a type other than default mtb_srf_ipc_packet_t, please override this function to handle additional parameters. |
| cy_rslt_t mtb_srf_ipc_process_pending_request | ( | mtb_srf_ipc_relay_context_t * | relay_context | ) |
Process the SRF request pending in either the queue if using an RTOS or the ringbuffer.
| [in,out] | relay_context | Stores state that client process needs to track between calls. |
| cy_rslt_t mtb_srf_ipc_signal_complete | ( | mtb_srf_ipc_relay_context_t * | relay_context, |
| mtb_srf_ipc_packet_t * | request ) |
Signals to client that secure request has been completed and output can be read.
| [in,out] | relay_context | Stores state that client process needs to track between calls. |
| [in] | request | Secure request to prepare for processing. |