aboutsummaryrefslogtreecommitdiff
path: root/platform/ext/target
diff options
context:
space:
mode:
authorAndreas Vibeto <andreas.vibeto@nordicsemi.no>2021-06-21 12:11:26 +0200
committerDavid Hu <david.hu@arm.com>2021-08-12 09:50:43 +0200
commit9eef8aafb54496f122ab4aa09c73c53a0d95a133 (patch)
tree47b14a6cc7facd854a908b9fb1495d030566d680 /platform/ext/target
parent7094041a540387c2d967ba64b3225747357666fa (diff)
downloadtrusted-firmware-m-9eef8aafb54496f122ab4aa09c73c53a0d95a133.tar.gz
platform: nrf: Fix PSA test scratch area
Change the PSA test scratch area to be fixed to the end of the non secure RAM area so that the scratch are will be the same for both secure and non secure partitions. Signed-off-by: Andreas Vibeto <andreas.vibeto@nordicsemi.no> Change-Id: Iee0497a58605f1da3551e753ce55c3c86c122417
Diffstat (limited to 'platform/ext/target')
-rw-r--r--platform/ext/target/nordic_nrf/common/core/CMakeLists.txt10
-rw-r--r--platform/ext/target/nordic_nrf/common/core/plat_test.c15
-rw-r--r--platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h5
-rw-r--r--platform/ext/target/nordic_nrf/common/nrf9160/partition/region_defs.h5
4 files changed, 27 insertions, 8 deletions
diff --git a/platform/ext/target/nordic_nrf/common/core/CMakeLists.txt b/platform/ext/target/nordic_nrf/common/core/CMakeLists.txt
index db1b391688..f8993875a8 100644
--- a/platform/ext/target/nordic_nrf/common/core/CMakeLists.txt
+++ b/platform/ext/target/nordic_nrf/common/core/CMakeLists.txt
@@ -74,6 +74,11 @@ target_compile_options(platform_s
${COMPILER_CMSE_FLAG}
)
+target_compile_definitions(platform_s
+ PUBLIC
+ $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_ENABLED>
+)
+
#========================= Platform Non-Secure ================================#
target_sources(platform_ns
@@ -95,6 +100,11 @@ target_include_directories(platform_ns
${PLATFORM_DIR}/../interface/include
)
+target_compile_definitions(platform_ns
+ PUBLIC
+ $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_ENABLED>
+)
+
#========================= Platform BL2 =======================================#
if(BL2)
diff --git a/platform/ext/target/nordic_nrf/common/core/plat_test.c b/platform/ext/target/nordic_nrf/common/core/plat_test.c
index 9f459f25bc..7b8df3aedc 100644
--- a/platform/ext/target/nordic_nrf/common/core/plat_test.c
+++ b/platform/ext/target/nordic_nrf/common/core/plat_test.c
@@ -29,8 +29,6 @@
#define TIMER_RELOAD_VALUE (1*1000*1000)
#define USERLED_MASK (1UL)
-/* Area used by psa-arch-tests to keep state. */
-#define PSA_TEST_SCRATCH_AREA_SIZE (0x400)
static bool initialized = false;
@@ -153,9 +151,9 @@ void TIMER1_Handler(void)
}
#endif
+#ifdef PSA_API_TEST_ENABLED
uint32_t pal_nvmem_get_addr(void)
{
- static __ALIGN(4) uint8_t __psa_scratch[PSA_TEST_SCRATCH_AREA_SIZE];
#ifdef NRF_TRUSTZONE_NONSECURE
static bool psa_scratch_initialized = false;
@@ -166,12 +164,13 @@ uint32_t pal_nvmem_get_addr(void)
int is_pinreset = reset_reason & NRFX_RESET_REASON_RESETPIN_MASK;
if ((reset_reason == 0) || is_pinreset){
/* PSA API tests expect this area to be initialized to all 0xFFs
- * after a power-on or pin reset.
- */
- memset(__psa_scratch, 0xFF, PSA_TEST_SCRATCH_AREA_SIZE);
+ * after a power-on or pin reset.
+ */
+ memset((void*)PSA_TEST_SCRATCH_AREA_BASE, 0xFF, PSA_TEST_SCRATCH_AREA_SIZE);
}
psa_scratch_initialized = true;
}
-#endif
- return (uint32_t)__psa_scratch;
+#endif /* NRF_TRUSTZONE_NONSECURE */
+ return (uint32_t)PSA_TEST_SCRATCH_AREA_BASE;
}
+#endif /* PSA_API_TEST_ENABLED */
diff --git a/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h b/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h
index b9a5188cea..3651b4bb7e 100644
--- a/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h
+++ b/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h
@@ -163,4 +163,9 @@
#define BOOT_TFM_SHARED_DATA_LIMIT (BOOT_TFM_SHARED_DATA_BASE + \
BOOT_TFM_SHARED_DATA_SIZE - 1)
+/* Region used by psa-arch-tests to keep state */
+#define PSA_TEST_SCRATCH_AREA_SIZE (0x400)
+#define PSA_TEST_SCRATCH_AREA_BASE (NS_DATA_LIMIT + 1 - \
+ PSA_TEST_SCRATCH_AREA_SIZE)
+
#endif /* __REGION_DEFS_H__ */
diff --git a/platform/ext/target/nordic_nrf/common/nrf9160/partition/region_defs.h b/platform/ext/target/nordic_nrf/common/nrf9160/partition/region_defs.h
index da4d07b738..98f20808d5 100644
--- a/platform/ext/target/nordic_nrf/common/nrf9160/partition/region_defs.h
+++ b/platform/ext/target/nordic_nrf/common/nrf9160/partition/region_defs.h
@@ -166,4 +166,9 @@
#define BOOT_TFM_SHARED_DATA_LIMIT (BOOT_TFM_SHARED_DATA_BASE + \
BOOT_TFM_SHARED_DATA_SIZE - 1)
+/* Region used by psa-arch-tests to keep state */
+#define PSA_TEST_SCRATCH_AREA_SIZE (0x400)
+#define PSA_TEST_SCRATCH_AREA_BASE (NS_DATA_LIMIT + 1 - \
+ PSA_TEST_SCRATCH_AREA_SIZE)
+
#endif /* __REGION_DEFS_H__ */