20 #define TFM_VERSION_POLICY_RELAXED 0
21 #define TFM_VERSION_POLICY_STRICT 1
23 #define TFM_HANDLE_STATUS_IDLE 0
24 #define TFM_HANDLE_STATUS_ACTIVE 1
25 #define TFM_HANDLE_STATUS_CONNECT_ERROR 2
27 #define PART_REGION_ADDR(partition, region) \
28 (uint32_t)®ION_NAME(Image$$, partition, region)
30 #define TFM_CONN_HANDLE_MAX_NUM 16
32 #define SPM_INVALID_PARTITION_IDX (~0U)
35 #define TFM_PARTITION_UNPRIVILEGED_MODE 0
36 #define TFM_PARTITION_PRIVILEGED_MODE 1
38 #define SPM_PART_FLAG_APP_ROT 0x01
39 #define SPM_PART_FLAG_PSA_ROT 0x02
40 #define SPM_PART_FLAG_IPC 0x04
42 #define TFM_PRIORITY_HIGH THRD_PRIOR_HIGHEST
43 #define TFM_PRIORITY_NORMAL THRD_PRIOR_MEDIUM
44 #define TFM_PRIORITY_LOW THRD_PRIOR_LOWEST
45 #define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL
47 #define TFM_MSG_MAGIC 0x15154343
70 #ifdef TFM_MULTI_CORE_TOPOLOGY
71 const void *caller_data;
325 int32_t type, int32_t client_id,
395 uint32_t privileged);
457 uint32_t exc_return,
bool ns_caller);
519 IRQn_Type *irq_line);
struct tfm_list_node_t list
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.
void(* sp_entry_point)(void)
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.
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.
struct tfm_msg_body_t * tfm_spm_get_msg_from_handle(psa_handle_t msg_handle)
Get message context by message handle.
int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service, uint32_t version)
Check the client version according to version policy.
struct tfm_spm_service_t * tfm_spm_get_service_by_sid(uint32_t sid)
Get the service context by service ID.
struct tfm_list_node_t list
struct tfm_spm_service_t service[]
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.
struct tfm_list_node_t msg_node
void tfm_core_handler_mode(void)
Move to handler mode by a SVC for specific purpose.
uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
Get the current partition mode.
struct tfm_list_node_t msg_list
psa_outvec outvec[PSA_MAX_IOVEC]
struct tfm_list_node_t handle_list
struct tfm_spm_service_t * service
psa_outvec * caller_outvec
struct tfm_msg_body_t internal_msg
void notify_with_signal(int32_t partition_id, psa_signal_t signal)
notify the partition with the signal.
psa_invec invec[PSA_MAX_IOVEC]
void tfm_spm_disable_irq(uint32_t *args)
SVC handler of disabling irq_line of the specified irq_signal.
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.
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.
void update_caller_outvec_len(struct tfm_msg_body_t *msg)
struct partition_t * partition
const struct tfm_spm_partition_platform_data_t ** platform_data_list
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.
sp_entry_point partition_init
uint32_t * p_dependencies
int32_t tfm_spm_check_authorization(uint32_t sid, struct tfm_spm_service_t *service, bool ns_caller)
Check the client access authorization.
void tfm_spm_enable_irq(uint32_t *args)
SVC handler of enabling irq_line of the specified irq_signal.
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.
struct tfm_spm_service_t * service
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 schedul...
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.
struct tfm_conn_handle_t * tfm_spm_to_handle_instance(psa_handle_t user_handle)
Converts a user handle into a corresponded handle instance.
uint32_t signals_asserted
uint32_t tfm_spm_init(void)
SPM initialization implementation.
uint32_t dependencies_num
uint32_t psa_framework_version
enum spm_err_t tfm_spm_db_init(void)
Initialize partition database.
uint32_t tfm_spm_partition_get_running_partition_id(void)
Get the running partition ID.
void tfm_pendsv_do_schedule(struct tfm_arch_ctx_t *p_actx)
const struct partition_static_t * static_data
void tfm_spm_request_handler(const struct tfm_state_context_t *svc_ctx)
Handle an SPM request by a secure service.
struct partition_t * partitions
struct tfm_event_t ack_evnt
struct tfm_core_thread_t sp_thread
const struct tfm_spm_partition_memory_data_t * memory_data
const struct tfm_spm_service_db_t * service_db
psa_handle_t tfm_spm_to_user_handle(struct tfm_conn_handle_t *handle_instance)
Converts a handle instance into a corresponded user handle.
struct partition_t * tfm_spm_get_running_partition(void)
Get current running partition context.
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.
uint32_t partition_priority