source: trunk/softs/tests_cc_vcache/test_excep_if_llsc/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.5 KB
Line 
1/*
2 * ifetch bus fault exception test: we can restart the faulting instruction
3 * We use the MMU to cause fault.
4 * Match what NetBSD does for page table update: sw for ppn, ll/sc for flags
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, 0x00200000 - 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        move    a1, zero
35        la      s0, testval
36        jal     doload
37        move    a0, s0
38        PRINTX
39        PUTCHAR(':')
40        PUTCHAR(' ')
41        move    a0, a1
42        PRINTX
43        PUTCHAR('\n')
44
45        /* we should get there */
46        EXIT(0)
47
48        .globl excep
49excep:
50        .set noreorder
51        /* don't clobber a0 and ra */
52        addiu   sp, sp, -8
53        sw      a0, 4(sp)
54        sw      ra, 8(sp)
55
56        PRINT(statusstr)
57        mfc0    a0, COP0_STATUS
58        PRINTX
59
60        PRINT(causestr)
61        mfc0    a0, COP0_CAUSE
62        PRINTX
63
64        PRINT(pcstr)
65        mfc0    a0, COP0_EXPC
66        PRINTX
67
68        PRINT(badvastr)
69        mfc0    a0, COP_0_BADVADDR
70        PRINTX
71
72        PUTCHAR('\n')
73        /* map VA 0xbfc01000 at PA 0xbfc01000 */
74        la      t0, pte2 + VADDR_TO_PTE2I(0xbfc01000) * 8
75        la      a0, (0xbfc01000 >> PTE2_SHIFT)
76        sw      a0, 4(t0)
771:
78        ll      a0, 0(t0)
79        la      a0, (PTE2_V | PTE2_C | PTE2_X)
80        sc      a0, 0(t0)
81        beqz    a0, 1b
82
83        lw      a0, 4(sp)
84        lw      ra, 8(sp)
85        addiu   sp, sp, 8
86        eret
87
88        .rodata:
89statusstr: .ascii "status \0"
90causestr: .ascii " cause \0"
91pcstr: .ascii " pc \0"
92badvastr: .ascii " badva \0"
93mmustr: .ascii "mmu started\n\0"
94startstr: .ascii "start\n\0"
95
96        .org EXCEP_ADDRESS - BOOT_ADDRESS
97        .globl evect
98evect:
99        j       excep
100        nop
101        /*
102         * we use a ldscript trick here, to load this function at
103         * the appropriate address
104         */
105        .section .text2, "ax"
106        .globl doload
107doload:
108        jr      ra
109        lw      a1, 0(s0) /* this should trigger the exception */
110        /* we should not get there */
111        nop
112        nop
113        EXIT(1)
114
115        .data
116        .word MAGIC1
117testval:
118        .word MAGIC2
119        .globl pte2
120pte2:
121        .align 12
122        .word PTE2_V | PTE2_C | PTE2_X
123        .word BOOT_ADDRESS >> 12
124        .org pte2 + 4092
125        .globl pte1
126pte1:
127        .align 13
128        .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
129        .word 0x0
130        .org pte1 + (BOOT_ADDRESS >> 21) * 4
131        .word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of PTE2 !!! */
132        .org pte1 + (TTY_BASE >> 21) * 4
133        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
134        .org pte1 + (EXIT_BASE >> 21) * 4
135        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
136        .org pte1 + 8192
Note: See TracBrowser for help on using the repository browser.