source: trunk/softs/tests_cc_vcache/test_icache_inval_pa/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: 3.2 KB
Line 
1/*
2 * cache inval test: check that VC_ICACHE_INVAL_PA does the job
3 * on a cc_vcache, the cache invalidation/update should be done by hardware
4 * and VC_ICACHE_INVAL_PA should not be needed.
5 */
6#include <registers.h>
7#include <misc.h>
8#include <vcache.h>
9
10#define TEST_ADDRESS 0x200000
11
12        .text
13        .globl  _start
14_start:
15        .set noreorder
16        la      k0, TTY_BASE
17        la      k1, EXIT_BASE
18
19        PRINT(startstr)
20
21        /* reset cop0 status (keep BEV) */
22        lui     a0, 0x0040;
23        mtc0    a0, COP0_STATUS
24
25        la      a0, pte1_a
26        srl     a0, a0, 13
27        mtc2    a0, VC_PTPR
28        nop
29
30        li      a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
31        mtc2    a0, VC_TLB_EN
32
33        PRINT(mmustr_a)
34        #copy 'doload' to TEST_ADDRESS
35        la      a1, DMA_BASE
36        la      a0, doload
37        sw      a0, DMA_SRC(a1)
38        la      a0, TEST_ADDRESS
39        sw      a0, DMA_DST(a1)
40        li      a0, 8
41        sw      a0, DMA_LEN(a1) /* start DMA */
42loop1:
43        lw      a0, DMA_LEN(a1)
44        bne     a0, zero, loop1;
45        nop
46        sw      zero, DMA_RESET(a1)
47
48        la      a0, TEST_ADDRESS
49        jalr    a0
50        nop
51        PRINTX
52        PUTCHAR('\n')
53        #copy 'doload2' to TEST_ADDRESS
54        la      a1, DMA_BASE
55        la      a0, doload2
56        sw      a0, DMA_SRC(a1)
57        la      a0, TEST_ADDRESS
58        sw      a0, DMA_DST(a1)
59        li      a0, 8
60        sw      a0, DMA_LEN(a1) /* start DMA */
61loop2:
62        lw      a0, DMA_LEN(a1)
63        bne     a0, zero, loop2;
64        nop
65        sw      zero, DMA_RESET(a1)
66
67        PRINT(mmustr_b)
68        la      a0, TEST_ADDRESS
69        jalr    a0
70        nop
71        PRINTX
72        PUTCHAR('\n')
73
74        la      a0, TEST_ADDRESS
75        mtc2    a0, VC_DATA_LO
76        mtc2    zero, VC_DATA_HI
77        mtc2    zero, VC_ICACHE_INVAL_PA
78        addi    a0, a0, 4
79        mtc2    a0, VC_DATA_LO
80        mtc2    zero, VC_DATA_HI
81        mtc2    zero, VC_ICACHE_INVAL_PA
82        nop
83
84        PRINT(mmustr_c)
85        la      a0, TEST_ADDRESS
86        jalr    a0
87        nop
88        PRINTX
89        PUTCHAR('\n')
90        /* we should get there */
91        EXIT(0)
92
93        .globl doload
94doload:
95        jr      ra
96        li      a0, MAGIC1
97        /* we should not get there */
98        EXIT(1)
99        nop
100
101        .globl doload2
102doload2:
103        jr ra
104        li      a0, MAGIC2
105        /* we should not get there */
106        EXIT(2)
107        nop
108
109        .globl excep
110excep:
111        .set noreorder
112        PRINT(statusstr)
113        mfc0    a0, COP0_STATUS
114        PRINTX
115
116        PRINT(causestr)
117        mfc0    a0, COP0_CAUSE
118        PRINTX
119
120        PRINT(pcstr)
121        mfc0    a0, COP0_EXPC
122        PRINTX
123
124        PRINT(badvastr)
125        mfc0    a0, COP_0_BADVADDR
126        PRINTX
127
128        PUTCHAR('\n')
129        /* we should not get there */
130        EXIT(3)
131
132        .rodata:
133statusstr: .ascii "status \0"
134causestr: .ascii " cause \0"
135pcstr: .ascii " pc \0"
136badvastr: .ascii " badva \0"
137mmustr_a: .ascii "mmu started before DMA \0"
138mmustr_b: .ascii "mmu started after DMA \0"
139mmustr_c: .ascii "mmu started after FLUSH \0"
140startstr: .ascii "start\n\0"
141
142        .org EXCEP_ADDRESS - BOOT_ADDRESS
143        .globl evect
144evect:
145        j       excep
146        nop
147
148        .data
149        .word MAGIC1
150testval:
151        .word MAGIC2
152
153        .globl pte1_a
154pte1_a:
155        .align 13
156        .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
157        .org pte1_a + (TEST_ADDRESS >> 21) * 4
158        .word PTE1_V | PTE1_C | PTE1_X | (TEST_ADDRESS >> 21) /* map PA 0x200000 at VA 0x200000, read-only/exec */
159        .word 0x0
160        .org pte1_a + (BOOT_ADDRESS >> 21) * 4
161        .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
162        .org pte1_a + (TTY_BASE >> 21) * 4
163        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
164        .org pte1_a + (EXIT_BASE >> 21) * 4
165        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
166        .org pte1_a + (DMA_BASE >> 21) * 4
167        .word PTE1_V | PTE1_W | (DMA_BASE >> 21) /* map PA 0xe8000000 at VA 0xe0000000 */
Note: See TracBrowser for help on using the repository browser.