|
TF-M Reference Manual
1.2.0
TrustedFirmware-M
|
#include <inttypes.h>#include <stdbool.h>#include "psa/client.h"#include "psa/service.h"#include "tfm_thread.h"#include "tfm_wait.h"#include "tfm_internal_defines.h"#include "tfm_spm_hal.h"#include "tfm_irq_list.h"#include "tfm_api.h"#include "tfm_secure_api.h"#include "tfm_memory_utils.h"#include "tfm_hal_defs.h"#include "tfm_hal_isolation.h"#include "spm_ipc.h"#include "tfm_peripherals_def.h"#include "tfm_core_utils.h"#include "tfm_rpc.h"#include "tfm_core_trustzone.h"#include "tfm_list.h"#include "tfm_pools.h"#include "region.h"#include "region_defs.h"#include "spm_partition_defs.h"#include "psa_manifest/pid.h"#include "tfm/tfm_spm_services.h"#include "secure_fw/partitions/tfm_service_list.inc"#include "tfm_spm_db_ipc.inc"#include "tfm_secure_irq_handlers_ipc.inc"
Go to the source code of this file.
Macros | |
| #define | CLIENT_HANDLE_VALUE_MIN 32 |
| #define | CONVERSION_FACTOR_BITOFFSET 3 |
| #define | CONVERSION_FACTOR_VALUE (1 << CONVERSION_FACTOR_BITOFFSET) |
| #define | CONVERSION_FACTOR_VALUE_MAX 0x20 |
Functions | |
| void | tfm_irq_handler (uint32_t partition_id, psa_signal_t signal, IRQn_Type irq_line) |
| assert signal for a given IRQ line. More... | |
| psa_handle_t | tfm_spm_to_user_handle (struct tfm_conn_handle_t *handle_instance) |
| Converts a handle instance into a corresponded user handle. More... | |
| struct tfm_conn_handle_t * | tfm_spm_to_handle_instance (psa_handle_t user_handle) |
| Converts a user handle into a corresponded handle instance. More... | |
| struct tfm_conn_handle_t * | tfm_spm_create_conn_handle (struct tfm_spm_service_t *service, int32_t client_id) |
| Create connection handle for client connect. More... | |
| int32_t | tfm_spm_validate_conn_handle (const struct tfm_conn_handle_t *conn_handle, int32_t client_id) |
| Validate connection handle for client connect. More... | |
| int32_t | tfm_spm_free_conn_handle (struct tfm_spm_service_t *service, struct tfm_conn_handle_t *conn_handle) |
| Free connection handle which not used anymore. More... | |
| int32_t | tfm_spm_set_rhandle (struct tfm_spm_service_t *service, struct tfm_conn_handle_t *conn_handle, void *rhandle) |
| Set reverse handle value for connection. More... | |
| struct tfm_msg_body_t * | tfm_spm_get_msg_by_signal (struct partition_t *partition, psa_signal_t signal) |
| Get the msg context by signal. More... | |
| uint32_t | tfm_spm_partition_get_privileged_mode (uint32_t partition_flags) |
| Get the current partition mode. More... | |
| bool | tfm_is_partition_privileged (uint32_t partition_idx) |
| Return whether a secure partition is privileged. More... | |
| struct tfm_spm_service_t * | tfm_spm_get_service_by_sid (uint32_t sid) |
| Get the service context by service ID. More... | |
| struct partition_t * | tfm_spm_get_running_partition (void) |
| Get current running partition context. More... | |
| int32_t | tfm_spm_check_client_version (struct tfm_spm_service_t *service, uint32_t version) |
| Check the client version according to version policy. More... | |
| int32_t | tfm_spm_check_authorization (uint32_t sid, struct tfm_spm_service_t *service, bool ns_caller) |
| Check the client access authorization. More... | |
| struct tfm_msg_body_t * | tfm_spm_get_msg_from_handle (psa_handle_t msg_handle) |
| Get message context by message handle. More... | |
| struct tfm_msg_body_t * | tfm_spm_get_msg_buffer_from_conn_handle (struct tfm_conn_handle_t *conn_handle) |
| Get message context by connect handle. More... | |
| void | tfm_spm_fill_msg (struct tfm_msg_body_t *msg, struct tfm_spm_service_t *service, psa_handle_t handle, int32_t type, int32_t client_id, psa_invec *invec, size_t in_len, psa_outvec *outvec, size_t out_len, psa_outvec *caller_outvec) |
| Fill the message for PSA client call. More... | |
| int32_t | tfm_spm_send_event (struct tfm_spm_service_t *service, struct tfm_msg_body_t *msg) |
| Send message and wake up the SP who is waiting on message queue, block the current thread and scheduler triggered. More... | |
| uint32_t | tfm_spm_partition_get_running_partition_id (void) |
| Get the running partition ID. More... | |
| int32_t | tfm_memory_check (const void *buffer, size_t len, bool ns_caller, enum tfm_memory_access_e access, uint32_t privileged) |
| Check the memory reference is valid. More... | |
| uint32_t | tfm_spm_init (void) |
| SPM initialization implementation. More... | |
| void | tfm_pendsv_do_schedule (struct tfm_arch_ctx_t *p_actx) |
| void | update_caller_outvec_len (struct tfm_msg_body_t *msg) |
| void | notify_with_signal (int32_t partition_id, psa_signal_t signal) |
| notify the partition with the signal. More... | |
| int32_t | get_irq_line_for_signal (int32_t partition_id, psa_signal_t signal, IRQn_Type *irq_line) |
| Return the IRQ line number associated with a signal. More... | |
| void | tfm_spm_enable_irq (uint32_t *args) |
| SVC handler of enabling irq_line of the specified irq_signal. More... | |
| void | tfm_spm_disable_irq (uint32_t *args) |
| SVC handler of disabling irq_line of the specified irq_signal. More... | |
| void | tfm_spm_validate_caller (struct partition_t *p_cur_sp, uint32_t *p_ctx, uint32_t exc_return, bool ns_caller) |
| Validate the whether NS caller re-enter. More... | |
| void | tfm_spm_request_handler (const struct tfm_state_context_t *svc_ctx) |
| Handle an SPM request by a secure service. More... | |
| enum spm_err_t | tfm_spm_db_init (void) |
| Initialize partition database. More... | |
Variables | |
| struct tfm_spm_service_t | service [] |
| const struct tfm_spm_service_db_t | service_db [] |
| #define CONVERSION_FACTOR_VALUE (1 << CONVERSION_FACTOR_BITOFFSET) |
| int32_t get_irq_line_for_signal | ( | int32_t | partition_id, |
| psa_signal_t | signal, | ||
| IRQn_Type * | irq_line | ||
| ) |
Return the IRQ line number associated with a signal.
| [in] | partition_id | The ID of the partition in which we look for the signal. |
| [in] | signal | The signal we do the query for. |
| [out] | irq_line | The irq line associated with signal |
| IPC_SUCCESS | Execution successful, irq_line contains a valid value. |
| IPC_ERROR_GENERIC | There was an error finding the IRQ line for the signal. irq_line is unchanged. |
Definition at line 881 of file spm_ipc.c.

| void notify_with_signal | ( | int32_t | partition_id, |
| psa_signal_t | signal | ||
| ) |
notify the partition with the signal.
| [in] | partition_id | The ID of the partition to be notified. |
| [in] | signal | The signal that the partition is to be notified with. |
| void | Success. |
| Does not return | If partition_id is invalid. |
Definition at line 831 of file spm_ipc.c.


| void tfm_irq_handler | ( | uint32_t | partition_id, |
| psa_signal_t | signal, | ||
| IRQn_Type | irq_line | ||
| ) |
assert signal for a given IRQ line.
| [in] | partition_id | The ID of the partition which handles this IRQ |
| [in] | signal | The signal associated with this IRQ |
| [in] | irq_line | The number of the IRQ line |
| void | Success. |
| Does not return | Partition ID is invalid |
Definition at line 874 of file spm_ipc.c.

| bool tfm_is_partition_privileged | ( | uint32_t | partition_idx | ) |
| int32_t tfm_memory_check | ( | const void * | buffer, |
| size_t | len, | ||
| bool | ns_caller, | ||
| enum tfm_memory_access_e | access, | ||
| uint32_t | privileged | ||
| ) |
Check the memory reference is valid.
| [in] | buffer | Pointer of memory reference |
| [in] | len | Length of memory reference in bytes |
| [in] | ns_caller | From non-secure caller |
| [in] | access | Type of access specified by the tfm_memory_access_e |
| [in] | privileged | Privileged mode or unprivileged mode: TFM_PARTITION_UNPRIVILEGED_MODE TFM_PARTITION_PRIVILEGED_MODE |
| IPC_SUCCESS | Success |
| IPC_ERROR_BAD_PARAMETERS | Bad parameters input |
| IPC_ERROR_MEMORY_CHECK | Check failed |
Definition at line 596 of file spm_ipc.c.

| void tfm_pendsv_do_schedule | ( | struct tfm_arch_ctx_t * | p_actx | ) |
| int32_t tfm_spm_check_authorization | ( | uint32_t | sid, |
| struct tfm_spm_service_t * | service, | ||
| bool | ns_caller | ||
| ) |
Check the client access authorization.
| [in] | sid | Target RoT Service identity |
| [in] | service | Target service context pointer, which can be get by partition management functions |
| [in] | ns_caller | Whether from NS caller |
| IPC_SUCCESS | Success |
| IPC_ERROR_GENERIC | Authorization check failed |
Definition at line 416 of file spm_ipc.c.


| int32_t tfm_spm_check_client_version | ( | struct tfm_spm_service_t * | service, |
| uint32_t | version | ||
| ) |
Check the client version according to version policy.
| [in] | service | Target service context pointer, which can be get by partition management functions |
| [in] | version | Client support version |
| IPC_SUCCESS | Success |
| IPC_ERROR_BAD_PARAMETERS | Bad parameters input |
| IPC_ERROR_VERSION | Check failed |
Definition at line 394 of file spm_ipc.c.

| struct tfm_conn_handle_t* tfm_spm_create_conn_handle | ( | struct tfm_spm_service_t * | service, |
| int32_t | client_id | ||
| ) |
Create connection handle for client connect.
| [in] | service | Target service context pointer |
| [in] | client_id | Partition ID of the sender of the message |
| NULL | Create failed |
| Not NULL | Service handle created |
Definition at line 137 of file spm_ipc.c.


| enum spm_err_t tfm_spm_db_init | ( | void | ) |
| void tfm_spm_disable_irq | ( | uint32_t * | args | ) |
SVC handler of disabling irq_line of the specified irq_signal.
| [in] | args | Include all input arguments: irq_signal. |
| void | Success. |
| Does not return | The call is invalid, one or more of the following are true:
|
Definition at line 925 of file spm_ipc.c.

| void tfm_spm_enable_irq | ( | uint32_t * | args | ) |
SVC handler of enabling irq_line of the specified irq_signal.
| [in] | args | Include all input arguments: irq_signal. |
| void | Success. |
| Does not return | The call is invalid, one or more of the following are true:
|
Definition at line 897 of file spm_ipc.c.

| void tfm_spm_fill_msg | ( | struct tfm_msg_body_t * | msg, |
| struct tfm_spm_service_t * | service, | ||
| psa_handle_t | handle, | ||
| int32_t | type, | ||
| int32_t | client_id, | ||
| psa_invec * | invec, | ||
| size_t | in_len, | ||
| psa_outvec * | outvec, | ||
| size_t | out_len, | ||
| psa_outvec * | caller_outvec | ||
| ) |
Fill the message for PSA client call.
| [in] | msg | Service Message Queue buffer pointer |
| [in] | service | Target service context pointer, which can be obtained by partition management functions |
| [in] | handle | Connect handle return by psa_connect(). |
| [in] | type | Message type, PSA_IPC_CONNECT, PSA_IPC_CALL or PSA_IPC_DISCONNECT |
| [in] | client_id | Partition ID of the sender of the message |
| [in] | invec | Array of input psa_invec structures |
| [in] | in_len | Number of input psa_invec structures |
| [in] | outvec | Array of output psa_outvec structures |
| [in] | out_len | Number of output psa_outvec structures |
| [in] | caller_outvec | Array of caller output psa_outvec structures |
Definition at line 498 of file spm_ipc.c.


| int32_t tfm_spm_free_conn_handle | ( | struct tfm_spm_service_t * | service, |
| struct tfm_conn_handle_t * | conn_handle | ||
| ) |
Free connection handle which not used anymore.
| [in] | service | Target service context pointer |
| [in] | conn_handle | Connection handle created by tfm_spm_create_conn_handle() |
| IPC_SUCCESS | Success |
| IPC_ERROR_BAD_PARAMETERS | Bad parameters input |
| Does not return | Panic for not find service by handle |
Definition at line 179 of file spm_ipc.c.


| struct tfm_msg_body_t* tfm_spm_get_msg_buffer_from_conn_handle | ( | struct tfm_conn_handle_t * | conn_handle | ) |
Get message context by connect handle.
| [in] | conn_handle | Service connect handle. |
Definition at line 491 of file spm_ipc.c.

| struct tfm_msg_body_t* tfm_spm_get_msg_by_signal | ( | struct partition_t * | partition, |
| psa_signal_t | signal | ||
| ) |
Get the msg context by signal.
| [in] | partition | Partition context pointer partition_t structures |
| [in] | signal | Signal associated with inputs to the Secure Partition, psa_signal_t |
| NULL | Failed |
| Not NULL | Target service context pointer, tfm_msg_body_t structures |
Definition at line 233 of file spm_ipc.c.


| struct tfm_msg_body_t* tfm_spm_get_msg_from_handle | ( | psa_handle_t | msg_handle | ) |
Get message context by message handle.
| [in] | msg_handle | Message handle which is a reference generated by the SPM to a specific message. |
Definition at line 450 of file spm_ipc.c.


| struct partition_t* tfm_spm_get_running_partition | ( | void | ) |
Get current running partition context.
| NULL | Failed |
| Not NULL | Return the parttion context pointer partition_t structures |
Definition at line 384 of file spm_ipc.c.


| struct tfm_spm_service_t* tfm_spm_get_service_by_sid | ( | uint32_t | sid | ) |
Get the service context by service ID.
| [in] | sid | RoT Service identity |
| NULL | Failed |
| Not NULL | Target service context pointer, tfm_spm_service_t structures |
Definition at line 351 of file spm_ipc.c.

| uint32_t tfm_spm_init | ( | void | ) |
SPM initialization implementation.
This function must be called under handler mode.
| This | function returns an EXC_RETURN value. Other faults would panic the execution and never returned. |
Definition at line 641 of file spm_ipc.c.


| uint32_t tfm_spm_partition_get_privileged_mode | ( | uint32_t | partition_flags | ) |
| uint32_t tfm_spm_partition_get_running_partition_id | ( | void | ) |
| void tfm_spm_request_handler | ( | const struct tfm_state_context_t * | svc_ctx | ) |
| int32_t tfm_spm_send_event | ( | struct tfm_spm_service_t * | service, |
| struct tfm_msg_body_t * | msg | ||
| ) |
Send message and wake up the SP who is waiting on message queue, block the current thread and scheduler triggered.
| [in] | service | Target service context pointer, which can be obtained by partition management functions |
| [in] | msg | message created by tfm_spm_create_msg() tfm_msg_body_t structures |
| IPC_SUCCESS | Success |
| IPC_ERROR_BAD_PARAMETERS | Bad parameters input |
| IPC_ERROR_GENERIC | Failed to enqueue message to service message queue |
Definition at line 556 of file spm_ipc.c.


| int32_t tfm_spm_set_rhandle | ( | struct tfm_spm_service_t * | service, |
| struct tfm_conn_handle_t * | conn_handle, | ||
| void * | rhandle | ||
| ) |
Set reverse handle value for connection.
| [in] | service | Target service context pointer |
| [in] | conn_handle | Connection handle created by tfm_spm_create_conn_handle() |
| [in] | rhandle | rhandle need to save |
| IPC_SUCCESS | Success |
| IPC_ERROR_BAD_PARAMETERS | Bad parameters input |
| Does not return | Panic for not find handle node |
Definition at line 196 of file spm_ipc.c.

| struct tfm_conn_handle_t* tfm_spm_to_handle_instance | ( | psa_handle_t | user_handle | ) |
| psa_handle_t tfm_spm_to_user_handle | ( | struct tfm_conn_handle_t * | handle_instance | ) |
| void tfm_spm_validate_caller | ( | struct partition_t * | p_cur_sp, |
| uint32_t * | p_ctx, | ||
| uint32_t | exc_return, | ||
| bool | ns_caller | ||
| ) |
Validate the whether NS caller re-enter.
| [in] | p_cur_sp | Pointer to current partition. |
| [in] | p_ctx | Pointer to current stack context. |
| [in] | exc_return | EXC_RETURN value. |
| [in] | ns_caller | If 'true', call from non-secure client. Or from secure client. |
| void | Success. |
Definition at line 953 of file spm_ipc.c.

| int32_t tfm_spm_validate_conn_handle | ( | const struct tfm_conn_handle_t * | conn_handle, |
| int32_t | client_id | ||
| ) |
Validate connection handle for client connect.
| [in] | conn_handle | Handle to be validated |
| [in] | client_id | Partition ID of the sender of the message |
| IPC_SUCCESS | Success |
| IPC_ERROR_GENERIC | Invalid handle |
Definition at line 161 of file spm_ipc.c.


| void update_caller_outvec_len | ( | struct tfm_msg_body_t * | msg | ) |
| struct tfm_spm_service_t service[] |
The service list
Definition at line 538 of file tfm_service_list.inc.
| const struct tfm_spm_service_db_t service_db[] |
Definition at line 56 of file tfm_service_list.inc.