aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-04-06 17:41:52 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-04-11 11:38:20 +0100
commite0e32b5ee3e30ad8565e92f776722f8217121b6f (patch)
tree1fde406f95e62321970e6f855ce25a7e4226e746
parent8c267e7892c0c2710e2708d9180eca3b8abcf6e6 (diff)
test8: Support no-MPU configurations
Check whether the system under test implements the MPU by looking at the MPU_TYPE register, and skip the tests that require the MPU if the MPU is not implemented. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--test8.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/test8.c b/test8.c
index 6e41c68..9f5ce63 100644
--- a/test8.c
+++ b/test8.c
@@ -168,11 +168,19 @@ void svc_entry(void)
void main(void)
{
+ int has_mpu;
+ uint32_t mpu_type;
+
run_table.hard = &hard_entry;
run_table.svc = &svc_entry;
run_table.mem = &mem_entry;
- testInit(6);
+ mpu_type = in32(SCB(0xD90));
+ has_mpu = ((mpu_type >> 8) & 0xff) != 0;
+
+ testInit(has_mpu ? 6 : 1);
+
+ testDiag("Running tests for MPU %s", has_mpu ? "present" : "not present");
asm("cpsid if");
out32(SCB(0xd24), 1<<16); // enable MemFault with SHCSR
@@ -180,24 +188,32 @@ void main(void)
testDiag("In Main");
expect_fault = EXPECT_NO_FAULT;
- /* priority of entries is highest to lowest (0 checked last) */
+ if (has_mpu) {
+ /* priority of entries is highest to lowest (0 checked last) */
- set_mpu(0, 0x00000000, (uint32_t)&__end_rom, MPU_NORMAL|MPU_RORO);
- set_mpu(1, 0x20000000, 0x00080000, MPU_NORMAL|MPU_RWRW|MPU_XN);
- set_mpu(2, 0x4000c000, 0x00001000, MPU_DEVICE|MPU_RWRW|MPU_XN);
- set_mpu(3, 0xe000e000, 0x00001000, MPU_DEVICE|MPU_RWRW|MPU_XN);
+ set_mpu(0, 0x00000000, (uint32_t)&__end_rom, MPU_NORMAL|MPU_RORO);
+ set_mpu(1, 0x20000000, 0x00080000, MPU_NORMAL|MPU_RWRW|MPU_XN);
+ set_mpu(2, 0x4000c000, 0x00001000, MPU_DEVICE|MPU_RWRW|MPU_XN);
+ set_mpu(3, 0xe000e000, 0x00001000, MPU_DEVICE|MPU_RWRW|MPU_XN);
- /* disable all access to offlimits[] */
- set_mpu(4, (uint32_t)offlimits, sizeof(offlimits),
- MPU_XN|MPU_NORMAL|MPU_NANA);
- /* disable unpriv access to privonly[] */
- set_mpu(5, (uint32_t)privonly, sizeof(privonly),
- MPU_XN|MPU_NORMAL|MPU_RONA);
+ /* disable all access to offlimits[] */
+ set_mpu(4, (uint32_t)offlimits, sizeof(offlimits),
+ MPU_XN|MPU_NORMAL|MPU_NANA);
+ /* disable unpriv access to privonly[] */
+ set_mpu(5, (uint32_t)privonly, sizeof(privonly),
+ MPU_XN|MPU_NORMAL|MPU_RONA);
+ }
testDiag("Access offlimits with MPU disabled (should not fault)");
try(offlimits);
checkfault(EXPECT_NO_FAULT);
+ /* All the other tests require an MPU. */
+ if (!has_mpu) {
+ testDiag("Done.");
+ return;
+ }
+
testDiag("Enable MPU");
enable_mpu(1,1,0);