source: trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/test.S @ 520

Last change on this file since 520 was 520, checked in by bouyer, 11 years ago

Re-add the tests; reverting previous which was done at the wrong level (sorry)

File size: 2.3 KB
Line 
1/*
2 * load/store bus fault exception test: we can restart the jump when the
3 * instruction in the delay slot takes a fault.
4 * We use the MMU to cause fault
5 */
6#include <registers.h>
7#include <misc.h>
8#include <vcache.h>
9
10        .text
11        .globl  _start
12_start:
13        .set noreorder
14        la      k0, TTY_BASE
15        la      k1, EXIT_BASE
16        la      sp, 0x00400000 - 16
17
18        PRINT(startstr)
19
20        /* reset cop0 status (keep BEV) */
21        lui     a0, 0x0040;
22        mtc0    a0, COP0_STATUS
23
24        la      a0, pte1
25        srl     a0, a0, 13
26        mtc2    a0, VC_PTPR
27        nop
28
29        li      a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
30        mtc2    a0, VC_TLB_EN
31
32        PRINT(mmustr)
33
34        /* 0x00000000 not mapped yet: we fault, load the MMU and retry */
35        move    a1, zero
36        la      s0, testval
37        jal     doload
38        move    a0, s0
39        PRINTX
40        PUTCHAR(':')
41        PUTCHAR(' ')
42        move    a0, a1
43        PRINTX
44        PUTCHAR('\n')
45
46        /* we should get there */
47        EXIT(0)
48
49        .globl doload
50doload:
51        nop
52        nop
53        jr      ra
54        lw      a1, 0(s0) /* this should trigger the exception */
55
56        /* we should not get there */
57        EXIT(1)
58
59        .globl excep
60excep:
61        .set noreorder
62        /* don't clobber a0 and ra */
63        addiu   sp, sp, -8
64        sw      a0, 4(sp)
65        sw      ra, 8(sp)
66        PRINT(statusstr)
67        mfc0    a0, COP0_STATUS
68        PRINTX
69
70        PRINT(causestr)
71        mfc0    a0, COP0_CAUSE
72        PRINTX
73
74        PRINT(pcstr)
75        mfc0    a0, COP0_EXPC
76        PRINTX
77
78        PRINT(badvastr)
79        mfc0    a0, COP_0_BADVADDR
80        PRINTX
81
82        PUTCHAR('\n')
83        /* map VA 0 at PA 0: just copy entry for 0x00200000 */
84        la      t0, pte1 + 0x00200000
85        lw      a0, 4(t0)
86        sw      a0, 0(t0)
87        /* mtc2 zero, VC_DTLB_INVAL */
88        lw      a0, 4(sp)
89        lw      ra, 8(sp)
90        addiu   sp, sp, 8
91        eret
92
93        .rodata:
94statusstr: .ascii "status \0"
95causestr: .ascii " cause \0"
96pcstr: .ascii " pc \0"
97badvastr: .ascii " badva \0"
98mmustr: .ascii "mmu started\n\0"
99startstr: .ascii "start\n\0"
100
101        .org EXCEP_ADDRESS - BOOT_ADDRESS
102        .globl evect
103evect:
104        j       excep
105        nop
106        .data
107        .word MAGIC1
108testval:
109        .word MAGIC2
110        .globl pte1
111pte1:
112        .align 13
113        .word 0x0                            /* map PA 0 at VA 0 */
114        .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
115        .org pte1 + (BOOT_ADDRESS >> 21) * 4
116        .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
117        .org pte1 + (TTY_BASE >> 21) * 4
118        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
119        .org pte1 + (EXIT_BASE >> 21) * 4
120        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
121        .org pte1 + 8192
122        .word 0
123
Note: See TracBrowser for help on using the repository browser.