![]() |
TF-M Reference Manual
1.2.0
TrustedFirmware-M
|
#include <stdint.h>
#include <stdbool.h>
#include <arm_cmse.h>
#include "tfm_nspm.h"
#include "tfm_api.h"
#include "tfm_arch.h"
#include "tfm_irq_list.h"
#include "psa/service.h"
#include "tfm_core_mem_check.h"
#include "tfm_peripherals_def.h"
#include "tfm_secure_api.h"
#include "tfm_spm_hal.h"
#include "tfm_core_trustzone.h"
#include "spm_func.h"
#include "region_defs.h"
#include "region.h"
#include "spm_partition_defs.h"
#include "psa_manifest/pid.h"
#include "tfm/tfm_spm_services.h"
#include "tfm_spm_db_func.inc"
Go to the source code of this file.
Macros | |
#define | EXC_RETURN_SECURE_FUNCTION 0xFFFFFFFD |
#define | EXC_RETURN_SECURE_HANDLER 0xFFFFFFF1 |
Functions | |
REGION_DECLARE_T (Image $$, TFM_SECURE_STACK,$$ZI $$Base, uint32_t) | |
REGION_DECLARE_T (Image $$, TFM_SECURE_STACK,$$ZI $$Limit, struct iovec_args_t)[] | |
REGION_DECLARE_T (Image $$, ARM_LIB_STACK_SEAL,$$ZI $$Base, uint32_t) | |
void | tfm_spm_seal_psp_stacks (void) |
Function to seal the PSP stacks for Function mode. More... | |
uint32_t | tfm_spm_partition_get_partition_id (uint32_t partition_idx) |
Get the id of the partition for its index from the db. 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... | |
void | tfm_spm_secure_api_init_done (void) |
Signal that secure partition initialisation is finished. More... | |
enum tfm_status_e | tfm_spm_sfn_request_handler (struct tfm_sfn_req_s *desc_ptr, uint32_t excReturn) |
int32_t | tfm_spm_sfn_request_thread_mode (struct tfm_sfn_req_s *desc_ptr) |
int32_t | tfm_spm_check_buffer_access (uint32_t partition_idx, void *start_addr, size_t len, uint32_t alignment) |
Check whether a buffer is ok for writing to by the privileged API function. More... | |
void | tfm_spm_get_caller_client_id_handler (uint32_t *svc_args) |
Stores caller's client id in state context. More... | |
uint32_t | tfm_spm_partition_request_svc_handler (const uint32_t *svc_ctx, uint32_t excReturn) |
Called if veneer is running in thread mode. More... | |
uint32_t | tfm_spm_depriv_req_handler (uint32_t *svc_args, uint32_t excReturn) |
Handle deprivileged request. More... | |
uint32_t | tfm_spm_partition_return_handler (uint32_t lr) |
Called when secure service returns. More... | |
uint32_t | tfm_spm_depriv_return_handler (uint32_t *irq_svc_args, uint32_t lr) |
Handle request to return to privileged. More... | |
void | tfm_spm_enable_irq_handler (uint32_t *svc_args) |
Handle IRQ enable request. More... | |
void | tfm_spm_disable_irq_handler (uint32_t *svc_args) |
Handle IRQ disable request. More... | |
void | tfm_spm_psa_wait (uint32_t *svc_args) |
Handle signal wait request. More... | |
void | tfm_spm_psa_eoi (uint32_t *svc_args) |
Handle request to record IRQ processed. More... | |
enum spm_err_t | tfm_spm_partition_init (void) |
Execute partition init function. More... | |
void | tfm_spm_partition_push_interrupted_ctx (uint32_t partition_idx) |
Save interrupted partition context on ctx stack. More... | |
void | tfm_spm_partition_pop_interrupted_ctx (uint32_t partition_idx) |
Restores interrupted partition context on ctx stack. More... | |
void | tfm_spm_partition_push_handler_ctx (uint32_t partition_idx) |
Save handler partition context on ctx stack. More... | |
void | tfm_spm_partition_pop_handler_ctx (uint32_t partition_idx) |
Restores handler partition context on ctx stack. More... | |
void | tfm_spm_partition_store_context (uint32_t partition_idx, uint32_t stack_ptr, uint32_t lr) |
Save stack pointer and link register for partition in database. More... | |
const struct spm_partition_runtime_data_t * | tfm_spm_partition_get_runtime_data (uint32_t partition_idx) |
Get the current runtime data of a partition. More... | |
void | tfm_spm_partition_set_state (uint32_t partition_idx, uint32_t state) |
Set the current state of a partition. More... | |
void | tfm_spm_partition_set_caller_partition_idx (uint32_t partition_idx, uint32_t caller_partition_idx) |
Set the caller partition index for a given partition. More... | |
void | tfm_spm_partition_set_signal_mask (uint32_t partition_idx, uint32_t signal_mask) |
Set the signal mask for a given partition. More... | |
void | tfm_spm_partition_set_caller_client_id (uint32_t partition_idx, int32_t caller_client_id) |
Set the caller client ID for a given partition. More... | |
enum spm_err_t | tfm_spm_partition_set_iovec (uint32_t partition_idx, const int32_t *args) |
Set the iovec parameters for the partition. More... | |
uint32_t | tfm_spm_partition_get_running_partition_idx (void) |
Returns the index of the partition that has running state. More... | |
void | tfm_spm_partition_cleanup_context (uint32_t partition_idx) |
Clears the context info from the database for a partition. 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... | |
#define EXC_RETURN_SECURE_FUNCTION 0xFFFFFFFD |
Definition at line 29 of file spm_func.c.
#define EXC_RETURN_SECURE_HANDLER 0xFFFFFFF1 |
Definition at line 30 of file spm_func.c.
REGION_DECLARE_T | ( | Image | $$, |
TFM_SECURE_STACK | , | ||
$$ZI, | |||
uint32_t | |||
) |
REGION_DECLARE_T | ( | Image | $$, |
TFM_SECURE_STACK | , | ||
$$ZI, | |||
struct iovec_args_t | |||
) |
REGION_DECLARE_T | ( | Image | $$, |
ARM_LIB_STACK_SEAL | , | ||
$$ZI, | |||
uint32_t | |||
) |
bool tfm_is_partition_privileged | ( | uint32_t | partition_idx | ) |
Return whether a secure partition is privileged.
[in] | partition_idx | The index of the partition in the partition_db. |
Definition at line 722 of file spm_func.c.
int32_t tfm_spm_check_buffer_access | ( | uint32_t | partition_idx, |
void * | start_addr, | ||
size_t | len, | ||
uint32_t | alignment | ||
) |
Check whether a buffer is ok for writing to by the privileged API function.
This function checks whether the caller partition owns the buffer, can write to it, and the buffer has proper alignment.
[in] | partition_idx | Partition index |
[in] | start_addr | The start address of the buffer |
[in] | len | The length of the buffer |
[in] | alignment | The expected alignment (in bits) |
Definition at line 818 of file spm_func.c.
enum spm_err_t tfm_spm_db_init | ( | void | ) |
Initialize partition database.
Definition at line 1415 of file spm_func.c.
uint32_t tfm_spm_depriv_req_handler | ( | uint32_t * | svc_args, |
uint32_t | excReturn | ||
) |
Handle deprivileged request.
Definition at line 921 of file spm_func.c.
uint32_t tfm_spm_depriv_return_handler | ( | uint32_t * | irq_svc_args, |
uint32_t | lr | ||
) |
Handle request to return to privileged.
Definition at line 976 of file spm_func.c.
void tfm_spm_disable_irq_handler | ( | uint32_t * | svc_args | ) |
Handle IRQ disable request.
Definition at line 1060 of file spm_func.c.
void tfm_spm_enable_irq_handler | ( | uint32_t * | svc_args | ) |
Handle IRQ enable request.
Definition at line 1033 of file spm_func.c.
void tfm_spm_get_caller_client_id_handler | ( | uint32_t * | svc_args | ) |
Stores caller's client id in state context.
Definition at line 851 of file spm_func.c.
void tfm_spm_partition_cleanup_context | ( | uint32_t | partition_idx | ) |
Clears the context info from the database for a partition.
[in] | partition_idx | Partition index |
Definition at line 1362 of file spm_func.c.
uint32_t tfm_spm_partition_get_partition_id | ( | uint32_t | partition_idx | ) |
Get the id of the partition for its index from the db.
[in] | partition_idx | Partition index |
Definition at line 707 of file spm_func.c.
uint32_t tfm_spm_partition_get_privileged_mode | ( | uint32_t | partition_flags | ) |
Get the current partition mode.
[in] | partition_flags | Flags of current partition |
TFM_PARTITION_PRIVILEGED_MODE | Privileged mode |
TFM_PARTITION_UNPRIVILEGED_MODE | Unprivileged mode |
Definition at line 713 of file spm_func.c.
uint32_t tfm_spm_partition_get_running_partition_idx | ( | void | ) |
Returns the index of the partition that has running state.
Definition at line 1357 of file spm_func.c.
const struct spm_partition_runtime_data_t* tfm_spm_partition_get_runtime_data | ( | uint32_t | partition_idx | ) |
Get the current runtime data of a partition.
[in] | partition_idx | Partition index |
Definition at line 1292 of file spm_func.c.
enum spm_err_t tfm_spm_partition_init | ( | void | ) |
Execute partition init function.
Definition at line 1168 of file spm_func.c.
void tfm_spm_partition_pop_handler_ctx | ( | uint32_t | partition_idx | ) |
Restores handler partition context on ctx stack.
[in] | partition_idx | Partition index |
Definition at line 1263 of file spm_func.c.
void tfm_spm_partition_pop_interrupted_ctx | ( | uint32_t | partition_idx | ) |
Restores interrupted partition context on ctx stack.
[in] | partition_idx | Partition index |
Definition at line 1233 of file spm_func.c.
void tfm_spm_partition_push_handler_ctx | ( | uint32_t | partition_idx | ) |
Save handler partition context on ctx stack.
[in] | partition_idx | Partition index |
Definition at line 1248 of file spm_func.c.
void tfm_spm_partition_push_interrupted_ctx | ( | uint32_t | partition_idx | ) |
Save interrupted partition context on ctx stack.
[in] | partition_idx | Partition index |
Definition at line 1220 of file spm_func.c.
uint32_t tfm_spm_partition_request_svc_handler | ( | const uint32_t * | svc_ctx, |
uint32_t | excReturn | ||
) |
Called if veneer is running in thread mode.
Definition at line 894 of file spm_func.c.
uint32_t tfm_spm_partition_return_handler | ( | uint32_t | lr | ) |
Called when secure service returns.
Definition at line 949 of file spm_func.c.
void tfm_spm_partition_set_caller_client_id | ( | uint32_t | partition_idx, |
int32_t | caller_client_id | ||
) |
Set the caller client ID for a given partition.
[in] | partition_idx | Partition index |
[in] | caller_client_id | The ID of the calling client |
Definition at line 1321 of file spm_func.c.
void tfm_spm_partition_set_caller_partition_idx | ( | uint32_t | partition_idx, |
uint32_t | caller_partition_idx | ||
) |
Set the caller partition index for a given partition.
[in] | partition_idx | Partition index |
[in] | caller_partition_idx | The index of the caller partition |
Definition at line 1307 of file spm_func.c.
enum spm_err_t tfm_spm_partition_set_iovec | ( | uint32_t | partition_idx, |
const int32_t * | args | ||
) |
Set the iovec parameters for the partition.
[in] | partition_idx | Partition index |
[in] | args | The arguments of the secure function |
args is expected to be of type int32_t[4] where: args[0] is in_vec args[1] is in_len args[2] is out_vec args[3] is out_len
Definition at line 1328 of file spm_func.c.
void tfm_spm_partition_set_signal_mask | ( | uint32_t | partition_idx, |
uint32_t | signal_mask | ||
) |
Set the signal mask for a given partition.
[in] | partition_idx | Partition index |
[in] | signal_mask | The signal mask to be set for the partition |
Definition at line 1314 of file spm_func.c.
void tfm_spm_partition_set_state | ( | uint32_t | partition_idx, |
uint32_t | state | ||
) |
Set the current state of a partition.
[in] | partition_idx | Partition index |
[in] | state | The state to be set |
Definition at line 1297 of file spm_func.c.
void tfm_spm_partition_store_context | ( | uint32_t | partition_idx, |
uint32_t | stack_ptr, | ||
uint32_t | lr | ||
) |
Save stack pointer and link register for partition in database.
[in] | partition_idx | Partition index |
[in] | stack_ptr | Stack pointer to be stored |
[in] | lr | Link register to be stored |
Definition at line 1282 of file spm_func.c.
void tfm_spm_psa_eoi | ( | uint32_t * | svc_args | ) |
Handle request to record IRQ processed.
SVC handler for psa_eoi.
Definition at line 1118 of file spm_func.c.
void tfm_spm_psa_wait | ( | uint32_t * | svc_args | ) |
void tfm_spm_request_handler | ( | const struct tfm_state_context_t * | svc_ctx | ) |
Handle an SPM request by a secure service.
[in] | svc_ctx | The stacked SVC context |
Definition at line 1382 of file spm_func.c.
void tfm_spm_seal_psp_stacks | ( | void | ) |
Function to seal the PSP stacks for Function mode.
Definition at line 51 of file spm_func.c.
void tfm_spm_secure_api_init_done | ( | void | ) |
Signal that secure partition initialisation is finished.
Definition at line 730 of file spm_func.c.
enum tfm_status_e tfm_spm_sfn_request_handler | ( | struct tfm_sfn_req_s * | desc_ptr, |
uint32_t | excReturn | ||
) |
Definition at line 735 of file spm_func.c.
int32_t tfm_spm_sfn_request_thread_mode | ( | struct tfm_sfn_req_s * | desc_ptr | ) |
Definition at line 780 of file spm_func.c.