diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-04-06 16:24:02 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-04-06 17:05:38 +0100 |
commit | ca87b093d46dfc590fbebac68c7ae90ad050f3eb (patch) | |
tree | d8ba901648c7257f8fddd8f3e4c64962d690dd83 | |
parent | e3cfbb872b84606ea1483340ce713549ca794032 (diff) |
test8: Update to tapit format
Update the MPU tests in test8 to use tapit format.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | armv7m.c | 2 | ||||
-rw-r--r-- | test8.c | 89 |
3 files changed, 45 insertions, 48 deletions
@@ -34,7 +34,7 @@ test4-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o testme.o test4.o test5-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o testme.o test5.o test6-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o test6.o test7-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o testme.o test7.o -test8-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o test8.o inst_skip.o +test8-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m.o testme.o test8.o inst_skip.o test9-kern.elf: cortexm.ld common.ld setup.o armv7m.o init-m-test9.o testme.o test9.o test10-kern.elf:cortexm.ld common.ld setup.o armv7m.o init-m.o testme.o test10.o test11-kern.elf:cortexm.ld common.ld setup.o armv7m.o init-m.o test11-buserr.o inst_skip.o @@ -129,7 +129,7 @@ void set_mpu(unsigned region, uint32_t base, uint32_t size, unsigned sbits = log2_ceil(size<32 ? 32 : size)-2; uint32_t rbase = base&(~0x1f); uint32_t rattr = (attrs&~0xffff) | (sbits<<1) | 1; - puts("set_mpu "); + puts("# set_mpu "); putc('0'+region); putc(' '); puthex(rbase); @@ -1,6 +1,12 @@ /* Test MPU */ #include "armv7m.h" +#include "testme.h" + +static inline void test_equal(const char *m, uint32_t expect, uint32_t actual) +{ + testEqI(expect, actual, "%s", m); +} char __end_rom, __after_all_load; @@ -12,13 +18,9 @@ static void try(volatile char *p) { uint32_t tval = 0; - puts("Try "); - puthex((uint32_t)p); - putc('\n'); + testDiag("Try %x", (uint32_t)p); __asm__ ("mov %r0, #'X'; ldr %r0, [%r1]" : "+r"(tval) : "r"(p) :); - puts("Got "); - putc(tval); - putc('\n'); + testDiag("Got %x", tval); } static volatile @@ -27,27 +29,21 @@ unsigned expect_fault = 1; static void checkfault(unsigned v) { - if(v!=expect_fault) { - puts("expect_fault "); - puthex(expect_fault); - puts(" != "); - puthex(v); - putc('\n'); - abort(); - } + testEqI(v, expect_fault, "fault state"); } void hard(uint32_t *sp) { + testDiag("In HardFault handler"); if(expect_fault==10) { sp = get_src_stack(sp); inst_skip(sp); - puts("HardFault access offlimits\n"); + testDiag("Trying access offlimits inside HardFault handler"); try(offlimits); expect_fault = 11; return; } - puts("Unexpected HardFault!!\n"); + testDiag("Unexpected HardFault!!"); abort(); } @@ -60,25 +56,22 @@ void hard_entry(void) void mem(uint32_t *sp) { + uint32_t addr; + sp = get_src_stack(sp); inst_skip(sp); - puts("In MemFault\n Addr "); - puthex(in32((void*)0xe000ed34)); - puts(" From "); - puthex(sp[6]); - putc('\n'); + addr = in32((void*)0xe000ed34); + testDiag("In MemFault, Addr 0x%x, from 0x%x", addr, sp[6]); switch(expect_fault) { case 2: /* expected */ expect_fault = 3; break; case 1: - puts("Unexpected MemFault!!\n"); + testDiag("Unexpected MemFault!!"); abort(); default: - puts("Unexpected state "); - puthex(expect_fault); - putc('\n'); + testDiag("Unexpected state 0x%x", expect_fault); abort(); } } @@ -104,13 +97,11 @@ void svc(void *sp) int num; sp = get_src_stack(sp); num = get_svc(sp); - puts("In SVC "); if(num<0) { - puts("BAD\n"); + testDiag("SVC but not looking at an SVC insn??\n"); abort(); } else { - puthex(num); - putc('\n'); + testDiag("SVC 0x%x", num); } switch(num) { case 1: /* restore privlage */ @@ -124,7 +115,7 @@ void svc(void *sp) case 2: abort(); default: - puts("Unknown\n"); + testDiag("Unknown SVC request value"); abort(); } } @@ -142,10 +133,12 @@ void main(void) run_table.svc = &svc_entry; run_table.mem = &mem_entry; + testInit(6); + asm("cpsid if"); out32(SCB(0xd24), 1<<16); // enable MemFault with SHCSR - puts("1. In Main\n"); + testDiag("In Main"); expect_fault = 1; /* priority of entries is highest to lowest (0 checked last) */ @@ -162,56 +155,60 @@ void main(void) set_mpu(5, (uint32_t)privonly, sizeof(privonly), MPU_XN|MPU_NORMAL|MPU_RONA); - puts("2. Access offlimits\n"); + testDiag("Access offlimits with MPU disabled (should not fault)"); try(offlimits); checkfault(1); - puts("3. Enable MPU\n"); + testDiag("Enable MPU"); enable_mpu(1,1,0); asm("cpsie if"); expect_fault = 2; - puts("4. Access offlimits\n"); + testDiag("Access offlimits with MPU enabled (should fault)"); try(offlimits); checkfault(3); - puts("6. In Main\n"); + testDiag("In Main"); expect_fault = 1; - puts("7. Access privonly\n"); + testDiag("Access privonly (should not fault)"); try(privonly); checkfault(1); - puts("8. drop_priv\n"); + testDiag("drop_priv"); expect_fault = 2; drop_priv(); - puts("9. Access privonly\n"); + testDiag("Access privonly as user (should fault)"); try(privonly); + checkfault(3); - puts("11. In Main\n"); + testDiag("Back in Main, regaining privilege"); asm("svc 1"); - checkfault(3); expect_fault = 1; - puts("12. Access privonly\n"); + testDiag("Access privonly as priv (should not fault)"); try(privonly); checkfault(1); - puts("13. In Main\n"); + asm("cpsid i"); - puts("14. fault to hardfault\n"); + testDiag("Check escalation of MemManage to HardFault"); expect_fault = 10; try(offlimits); checkfault(11); - puts("15. Enable MPU w/ HFNMIENA\n"); +#if 0 + /* don't try to test unrecoverable errors */ + testDiag("Enable MPU w/ HFNMIENA"); enable_mpu(1,1,1); - puts("16. fault to hardfault (will escalate to unrecoverable)\n"); + testDiag("fault to hardfault (will escalate to unrecoverable)"); expect_fault = 10; try(offlimits); + testDiag("Shouldn't be here!"); +#endif - puts("Shouldn't be here!\n"); + testDiag("Done."); } |