10 #include "region_defs.h"
12 #include "tfm_spm_hal.h"
32 static enum tfm_status_e has_access_to_region(
const void *p,
size_t s,
35 int32_t range_access_allowed_by_mpu;
38 range_access_allowed_by_mpu =
39 cmse_check_address_range((
void *)p, s, flags) != NULL;
41 #if !defined(__SAUREGION_PRESENT) || (__SAUREGION_PRESENT == 0)
42 if (!range_access_allowed_by_mpu) {
48 cmse_address_info_t addr_info_base = cmse_TT((
void *)p);
49 cmse_address_info_t addr_info_last = cmse_TT((
void *)((uint32_t)p + s - 1));
51 if ((addr_info_base.flags.idau_region_valid != 0) &&
52 (addr_info_last.flags.idau_region_valid != 0) &&
53 (addr_info_base.flags.idau_region != addr_info_last.flags.idau_region)) {
54 range_access_allowed_by_mpu =
55 tfm_spm_hal_has_access_to_region(p, s, flags);
60 if (range_access_allowed_by_mpu) {
71 int flags = CMSE_MPU_READ;
79 ctrl.w = __TZ_get_CONTROL_NS();
80 if (ctrl.b.nPRIV == 1) {
88 flags |= CMSE_MPU_UNPRIV;
92 flags |= CMSE_NONSECURE;
95 return has_access_to_region(p, s, flags);
102 int flags = CMSE_MPU_READWRITE;
110 ctrl.w = __TZ_get_CONTROL_NS();
111 if (ctrl.b.nPRIV == 1) {
119 flags |= CMSE_MPU_UNPRIV;
123 flags |= CMSE_NONSECURE;
126 return has_access_to_region(p, s, flags);
#define TFM_PARTITION_UNPRIVILEGED_MODE
enum tfm_status_e tfm_core_has_read_access_to_region(const void *p, size_t s, bool ns_caller, uint32_t privileged)
Check whether the current partition has read access to a memory range.
enum tfm_status_e tfm_core_has_write_access_to_region(const void *p, size_t s, bool ns_caller, uint32_t privileged)
Check whether the current partition has write access to a memory range.
#define TFM_PARTITION_PRIVILEGED_MODE