10 #include "region_defs.h"
21 #include "tfm_spm_hal.h"
33 #define BOOT_DATA_VALID (1u)
41 #define BOOT_DATA_INVALID (0u)
81 static int32_t tfm_core_check_boot_data_access_policy(uint8_t
major_type)
86 const uint32_t array_size =
87 sizeof(access_policy_table) /
sizeof(access_policy_table[0]);
97 for (i = 0; i < array_size; ++i) {
98 if (partition_id == access_policy_table[i].partition_id) {
99 if (major_type == access_policy_table[i].major_type) {
112 #if ((BOOT_TFM_SHARED_DATA_BASE >= NS_DATA_START && \
113 BOOT_TFM_SHARED_DATA_BASE <= NS_DATA_LIMIT) || \
114 (BOOT_TFM_SHARED_DATA_LIMIT >= NS_DATA_START && \
115 BOOT_TFM_SHARED_DATA_LIMIT <= NS_DATA_LIMIT))
116 #error "Shared data area and non-secure data area is overlapping"
121 #ifdef BOOT_DATA_AVAILABLE
124 boot_data = (
struct tfm_boot_data *)BOOT_TFM_SHARED_DATA_BASE;
136 uint8_t tlv_major = (uint8_t)args[0];
137 uint8_t *buf_start = (uint8_t *)args[1];
138 uint16_t buf_size = (uint16_t)args[2];
140 #ifdef BOOT_DATA_AVAILABLE
143 uintptr_t tlv_end, offset;
144 size_t next_tlv_offset;
147 uint32_t running_partition_idx =
192 if (tfm_core_check_boot_data_access_policy(tlv_major)) {
197 #ifdef BOOT_DATA_AVAILABLE
199 boot_data = (
struct tfm_boot_data *)BOOT_TFM_SHARED_DATA_BASE;
205 if (buf_size < SHARED_DATA_HEADER_SIZE) {
214 #ifdef BOOT_DATA_AVAILABLE
215 ptr = boot_data->
data;
219 for (; offset < tlv_end; offset += next_tlv_offset) {
221 (void)
spm_memcpy(&tlv_entry, (
const void *)offset,
228 if (((ptr - buf_start) + next_tlv_offset) > buf_size) {
233 (void)
spm_memcpy(ptr, (
const void *)offset, next_tlv_offset);
234 ptr += next_tlv_offset;
#define GET_MAJOR(tlv_type)
void tfm_core_validate_boot_data(void)
Validate the content of shared memory area, which stores the shared data between bootloader and runti...
uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
Get the current partition mode.
void tfm_core_get_boot_data_handler(uint32_t args[])
Retrieve secure partition related data from shared memory area, which stores shared data between boot...
#define SHARED_DATA_ENTRY_HEADER_SIZE
#define SHARED_DATA_HEADER_SIZE
#define SHARED_DATA_TLV_INFO_MAGIC
#define TFM_SP_INITIAL_ATTESTATION
void tfm_core_panic(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_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.
struct partition_t * tfm_spm_get_running_partition(void)
Get current running partition context.
Defines the access policy of secure partitions to data items in shared data area (between bootloader ...
Store the data for the runtime SW.
#define BOOT_DATA_INVALID
Indicates that shared data between bootloader and runtime firmware was failed on sanity check...
void * spm_memcpy(void *dest, const void *src, size_t n)
Memory copy function for TF-M core.
struct shared_data_tlv_header header
#define BOOT_DATA_VALID
Indicates that shared data between bootloader and runtime firmware was passed the sanity check with s...
const struct partition_static_t * static_data
uint32_t tfm_spm_partition_get_partition_id(uint32_t partition_idx)
Get the id of the partition for its index from the db.
uint32_t tfm_spm_partition_get_running_partition_idx(void)
Returns the index of the partition that has running state.
uint32_t tfm_spm_partition_get_running_partition_id(void)
Get the running partition ID.