Add qemu 2.4.0
[kvmfornfv.git] / qemu / tests / tcg / xtensa / test_cache.S
1 #include "macros.inc"
2
3 .purgem test_init
4 .macro test_init
5     call0   cache_unlock_invalidate
6 .endm
7
8 test_suite cache
9
10 .macro      pf_op op
11     \op     a2, 0
12     \op     a3, 0
13     \op     a4, 0
14 .endm
15
16 test prefetch
17     movi    a2, 0xd0000000 /* cacheable */
18     movi    a3, 0xd8000000 /* non-cacheable */
19     movi    a4, 0x00001235 /* unmapped */
20
21     pf_op   dpfr
22     pf_op   dpfro
23     pf_op   dpfw
24     pf_op   dpfwo
25     pf_op   ipf
26
27     dpfl    a2, 0
28     ipfl    a2, 0
29 test_end
30
31 .macro cache_fault op, addr, exc_code
32     set_vector kernel, 2f
33
34     movi    a4, \addr
35 1:
36     \op     a4, 0
37     test_fail
38 2:
39     rsr     a2, epc1
40     movi    a3, 1b
41     assert  eq, a2, a3
42     rsr     a2, excvaddr
43     assert  eq, a2, a4
44     rsr     a2, exccause
45     movi    a3, \exc_code
46     assert  eq, a2, a3
47 .endm
48
49 test dpfl_tlb_miss
50     cache_fault dpfl, 0x00002345, 24
51 test_end
52
53 test dhwb_tlb_miss
54     cache_fault dhwb, 0x00002345, 24
55 test_end
56
57 test dhwbi_tlb_miss
58     cache_fault dhwbi, 0x00002345, 24
59 test_end
60
61 test dhi_tlb_miss
62     cache_fault dhi, 0x00002345, 24
63 test_end
64
65 test dhu_tlb_miss
66     cache_fault dhu, 0x00002345, 24
67 test_end
68
69
70 test ipfl_tlb_miss
71     cache_fault ipfl, 0x00002345, 16
72 test_end
73
74 test ihu_tlb_miss
75     cache_fault ihu, 0x00002345, 16
76 test_end
77
78 test ihi_tlb_miss
79     cache_fault ihi, 0x00002345, 16
80 test_end
81
82 test_suite_end
83
84 .macro cache_all op1, op2, size, linesize
85     movi    a2, 0
86     movi    a3, \size
87 1:
88     \op1    a2, 0
89     \op2    a2, 0
90     addi    a2, a2, \linesize
91     bltu    a2, a3, 1b
92 .endm
93
94 cache_unlock_invalidate:
95     cache_all diu, dii, XCHAL_DCACHE_SIZE, XCHAL_DCACHE_LINESIZE
96     cache_all iiu, iii, XCHAL_ICACHE_SIZE, XCHAL_ICACHE_LINESIZE
97     ret