source: trunk/softs/tests_cc_vcache/test_idtlb_inval2/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.9 KB
Line 
1/*
2 * itlb inval: a write to a PTE2 should invalidate the corresponding
3 * itlb and dtlb entries.
4 */
5#include <registers.h>
6#include <misc.h>
7#include <vcache.h>
8
9        .text
10        .globl  _start
11_start:
12        .set noreorder
13        la      k0, TTY_BASE
14        la      k1, EXIT_BASE
15
16        PRINT(startstr)
17
18        /* reset cop0 status (keep BEV) */
19        lui     a0, 0x0040;
20        mtc0    a0, COP0_STATUS
21
22        la      a0, pte1_a
23        srl     a0, a0, 13
24        mtc2    a0, VC_PTPR
25        nop
26
27        li      a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
28        mtc2    a0, VC_TLB_EN
29
30        PRINT(mmustr)
31        /* cause a DTLB miss */
32        la      t0, roval
33        lw      a0, 0(t0)
34        PRINTX
35        PUTCHAR(' ')
36
37        /* cause a itlb miss */
38        jal     doload
39        nop
40        PRINTX
41        PUTCHAR(' ')
42
43        la      t0, pte2_a
44        mtc2    t0, VC_DTLB_INVAL /* force tlb miss on write */
45        la      a0, (BOOT_ADDRESS+0x2000) >> 12
46        sw      a0, 12(t0) /* change PTE2 */
47        sync
481:
49        ll      a0, 8(t0)
50        mtc2    t0, VC_DTLB_INVAL /* force tlb miss on write */
51        la      a0, PTE2_V | PTE2_C | PTE2_X
52        sc      a0, 8(t0)
53        beqz    a0, 1b
54        nop
55
56        /* now we should get the second values */
57        la      t0, roval
58        lw      a0, 0(t0)
59        PRINTX
60        PUTCHAR(' ')
61
62        jal     doload
63        nop
64        PRINTX
65        PUTCHAR('\n')
66        /* we should get there */
67        EXIT(0)
68
69        .globl excep
70excep:
71        .set noreorder
72        PRINT(statusstr)
73        mfc0    a0, COP0_STATUS
74        PRINTX
75
76        PRINT(causestr)
77        mfc0    a0, COP0_CAUSE
78        PRINTX
79
80        PRINT(pcstr)
81        mfc0    a0, COP0_EXPC
82        PRINTX
83
84        PRINT(badvastr)
85        mfc0    a0, COP_0_BADVADDR
86        PRINTX
87
88        PUTCHAR('\n')
89        /* we should not get there */
90        EXIT(1)
91
92        .rodata:
93statusstr: .ascii "status \0"
94causestr: .ascii " cause \0"
95pcstr: .ascii " pc \0"
96badvastr: .ascii " badva \0"
97mmustr: .ascii "mmu started \0"
98startstr: .ascii "start\n\0"
99
100        .org EXCEP_ADDRESS - BOOT_ADDRESS
101        .globl evect
102evect:
103        j       excep
104        nop
105
106        /*
107         * code that will be switched by MMU switch.
108         * we use a ldscript trick here, to load this function at
109         * the appropriate address
110         */
111        .section .text2, "ax"
112        .globl doload
113doload:
114        jr      ra
115        li      a0, MAGIC1
116        /* we should not get there */
117        EXIT(1)
118        nop
119roval:  .word MAGIC2
120        .align 12
121        .globl doload2
122doload2:
123        jr      ra
124        li      a0, MAGIC2
125        /* we should not get there */
126        EXIT(1)
127        nop
128roval2: .word MAGIC1
129
130        .data
131        .word MAGIC1
132testval:
133        .word MAGIC2
134        .globl pte2_a
135
136/*
137 * one PD with a level 2 PTP: we change an entry in the PTP and
138 * check that the ITLB has been invalidated
139 */
140pte2_a:
141        .align 12
142        .word PTE2_V | PTE2_C | PTE2_X
143        .word BOOT_ADDRESS >> 12
144        .word PTE2_V | PTE2_C | PTE2_X
145        .word (BOOT_ADDRESS+0x1000) >> 12
146        .org pte2_a + 4092
147        .word 0
148        .globl pte2_b
149        .globl pte1_a
150pte1_a:
151        .align 13
152        .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
153        .word 0x0
154        .org pte1_a + (BOOT_ADDRESS >> 21) * 4
155        .word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
156        .org pte1_a + (TTY_BASE >> 21) * 4
157        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
158        .org pte1_a + (EXIT_BASE >> 21) * 4
159        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
160        .org pte1_a + 8192
Note: See TracBrowser for help on using the repository browser.