diff --git a/lib/CPUs/MIPS/bsp/examples/test_exception.c b/lib/CPUs/MIPS/bsp/examples/test_exception.c index 400c676..f9e9354 100644 --- a/lib/CPUs/MIPS/bsp/examples/test_exception.c +++ b/lib/CPUs/MIPS/bsp/examples/test_exception.c @@ -7,7 +7,7 @@ void _exc_break(void) __asm ( ".set noreorder\n" - "break 0x123\n" + "break 0x9\n" ".set reorder\n" ); @@ -47,10 +47,18 @@ void _exc_store_err(void) void _exc_load_err(void) { - volatile int *pSrc = (int*)0x40000002; - volatile int *pDst = (int*)sys_led_port; + __asm + ( + ".set noreorder\n" + " li $t0, 0x40000000\n" + " li $t1, 0x40000000\n" + " lw $t1, 0($t1)\n" + " lw $t0, 2($t0)\n" + " lw $t1, 4($t0)\n" + "nop\n" + ".set reorder\n" - *pDst = *pSrc; + ); } @@ -68,12 +76,44 @@ void _exc_kaddr_err(void) } +void _exc_iaddr_daddr_err(void) +{ + __asm + ( + ".set noreorder\n" + " li $t0, 0x40000003\n" + " li $t1, 0x40000002\n" + " jr $t0\n" + " lw $t1, 0($t1)\n" + "nop\n" + ".set reorder\n" + + ); + +} + +void _exc_daddr_iaddr_err(void) +{ + __asm + ( + ".set noreorder\n" + " li $t0, 0x40000003\n" + " li $t1, 0x40000002\n" + " lw $t1, 0($t1)\n" + " jr $t0\n" + "nop\n" + ".set reorder\n" + + ); + +} + void _exc_iaddr_err(void) { __asm ( ".set noreorder\n" - " li $t0, 0x80000003\n" + " li $t0, 0x40000003\n" " jr $t0\n" "nop\n" ".set reorder\n" @@ -154,17 +194,19 @@ int main(void) { printf("Welche exception möchten Sie testen?\n"); printf(" 1 : Reserved instruction\n"); - printf(" 2 : Privileged address\n"); + printf(" 2 : Privileged address (BadVAddr = 0x80000000)\n"); printf(" 3 : Arithmetic overflow\n"); printf(" 4 : Syscall\n"); printf(" 5 : Breakpoint\n"); - printf(" 6 : Load error on instruction\n"); - printf(" 7 : Load error on data\n"); - printf(" 8 : Store error on data\n"); + printf(" 6 : Load error on instruction (BadVAddr = 0x40000003)\n"); + printf(" 7 : Load error on data (BadVAddr = 0x40000002)\n"); + printf(" 8 : Store error on data (BadVAddr = 0x40000001)\n"); printf(" 9 : Bus error on instruction\n"); printf("10 : Bus error on data\n"); printf("11 : SW-interrupt 0\n"); printf("12 : SW-interrupt 1\n"); + printf("13 : Load error on instruction and Load error on data (BadVAddr = 0x40000003)\n"); + printf("14 : Load error on data and Load error on instruction (BadVAddr = 0x40000002)\n"); scanf("%d", &sel); printf("Jetzt kommt die exception (%d)!\n", sel); @@ -218,6 +260,14 @@ int main(void) interrupt_set(sel-11); break; + case 13: + _exc_iaddr_daddr_err(); + break; + + case 14: + _exc_daddr_iaddr_err(); + break; + default: break; }