xref: /openbmc/qemu/tests/tcg/xtensa/test_cache.S (revision 4179575898fcc17c5e67306a357b8dfe64122e8e)
12c09eee1SMax Filippov#include "macros.inc"
22c09eee1SMax Filippov
32c09eee1SMax Filippov.purgem test_init
42c09eee1SMax Filippov.macro test_init
52c09eee1SMax Filippov    call0   cache_unlock_invalidate
62c09eee1SMax Filippov.endm
72c09eee1SMax Filippov
82c09eee1SMax Filippovtest_suite cache
92c09eee1SMax Filippov
10*ecf5b577SMax Filippov#if XCHAL_HAVE_PTP_MMU
11*ecf5b577SMax Filippov
122c09eee1SMax Filippov.macro      pf_op op
132c09eee1SMax Filippov    \op     a2, 0
142c09eee1SMax Filippov    \op     a3, 0
152c09eee1SMax Filippov    \op     a4, 0
162c09eee1SMax Filippov.endm
172c09eee1SMax Filippov
182c09eee1SMax Filippovtest prefetch
192c09eee1SMax Filippov    movi    a2, 0xd0000000 /* cacheable */
202c09eee1SMax Filippov    movi    a3, 0xd8000000 /* non-cacheable */
212c09eee1SMax Filippov    movi    a4, 0x00001235 /* unmapped */
222c09eee1SMax Filippov
23*ecf5b577SMax Filippov#if XCHAL_DCACHE_SIZE
242c09eee1SMax Filippov    pf_op   dpfr
252c09eee1SMax Filippov    pf_op   dpfro
262c09eee1SMax Filippov    pf_op   dpfw
272c09eee1SMax Filippov    pf_op   dpfwo
28*ecf5b577SMax Filippov#endif
29*ecf5b577SMax Filippov#ifdef XCHAL_ICACHE_SIZE
302c09eee1SMax Filippov    pf_op   ipf
31*ecf5b577SMax Filippov#endif
32*ecf5b577SMax Filippov#if XCHAL_HAVE_PTP_MMU && !XCHAL_HAVE_SPANNING_WAY
33*ecf5b577SMax Filippov#if XCHAL_DCACHE_LINE_LOCKABLE
342c09eee1SMax Filippov    dpfl    a2, 0
35*ecf5b577SMax Filippov#endif
36*ecf5b577SMax Filippov#if XCHAL_ICACHE_LINE_LOCKABLE
372c09eee1SMax Filippov    ipfl    a2, 0
38*ecf5b577SMax Filippov#endif
39*ecf5b577SMax Filippov#endif
402c09eee1SMax Filippovtest_end
412c09eee1SMax Filippov
422c09eee1SMax Filippov.macro cache_fault op, addr, exc_code
432c09eee1SMax Filippov    set_vector kernel, 2f
442c09eee1SMax Filippov
452c09eee1SMax Filippov    movi    a4, \addr
462c09eee1SMax Filippov1:
472c09eee1SMax Filippov    \op     a4, 0
482c09eee1SMax Filippov    test_fail
492c09eee1SMax Filippov2:
502c09eee1SMax Filippov    rsr     a2, epc1
512c09eee1SMax Filippov    movi    a3, 1b
522c09eee1SMax Filippov    assert  eq, a2, a3
532c09eee1SMax Filippov    rsr     a2, excvaddr
542c09eee1SMax Filippov    assert  eq, a2, a4
552c09eee1SMax Filippov    rsr     a2, exccause
562c09eee1SMax Filippov    movi    a3, \exc_code
572c09eee1SMax Filippov    assert  eq, a2, a3
582c09eee1SMax Filippov.endm
592c09eee1SMax Filippov
60*ecf5b577SMax Filippov#if XCHAL_HAVE_PTP_MMU && !XCHAL_HAVE_SPANNING_WAY
61*ecf5b577SMax Filippov
62*ecf5b577SMax Filippov#if XCHAL_DCACHE_LINE_LOCKABLE
632c09eee1SMax Filippovtest dpfl_tlb_miss
642c09eee1SMax Filippov    cache_fault dpfl, 0x00002345, 24
652c09eee1SMax Filippovtest_end
66*ecf5b577SMax Filippov#endif
672c09eee1SMax Filippov
68*ecf5b577SMax Filippov#if XCHAL_DCACHE_SIZE
69*ecf5b577SMax Filippov#if XCHAL_DCACHE_IS_WRITEBACK
702c09eee1SMax Filippovtest dhwb_tlb_miss
712c09eee1SMax Filippov    cache_fault dhwb, 0x00002345, 24
722c09eee1SMax Filippovtest_end
732c09eee1SMax Filippov
742c09eee1SMax Filippovtest dhwbi_tlb_miss
752c09eee1SMax Filippov    cache_fault dhwbi, 0x00002345, 24
762c09eee1SMax Filippovtest_end
77*ecf5b577SMax Filippov#endif
782c09eee1SMax Filippov
792c09eee1SMax Filippovtest dhi_tlb_miss
802c09eee1SMax Filippov    cache_fault dhi, 0x00002345, 24
812c09eee1SMax Filippovtest_end
822c09eee1SMax Filippov
83*ecf5b577SMax Filippov#if XCHAL_DCACHE_LINE_LOCKABLE
842c09eee1SMax Filippovtest dhu_tlb_miss
852c09eee1SMax Filippov    cache_fault dhu, 0x00002345, 24
862c09eee1SMax Filippovtest_end
87*ecf5b577SMax Filippov#endif
88*ecf5b577SMax Filippov#endif
892c09eee1SMax Filippov
90*ecf5b577SMax Filippov#if XCHAL_ICACHE_SIZE
91*ecf5b577SMax Filippov#if XCHAL_ICACHE_LINE_LOCKABLE
922c09eee1SMax Filippovtest ipfl_tlb_miss
932c09eee1SMax Filippov    cache_fault ipfl, 0x00002345, 16
942c09eee1SMax Filippovtest_end
952c09eee1SMax Filippov
962c09eee1SMax Filippovtest ihu_tlb_miss
972c09eee1SMax Filippov    cache_fault ihu, 0x00002345, 16
982c09eee1SMax Filippovtest_end
99*ecf5b577SMax Filippov#endif
1002c09eee1SMax Filippov
1012c09eee1SMax Filippovtest ihi_tlb_miss
1022c09eee1SMax Filippov    cache_fault ihi, 0x00002345, 16
1032c09eee1SMax Filippovtest_end
104*ecf5b577SMax Filippov#endif
105*ecf5b577SMax Filippov
106*ecf5b577SMax Filippov#endif
107*ecf5b577SMax Filippov
108*ecf5b577SMax Filippov#endif
1092c09eee1SMax Filippov
1102c09eee1SMax Filippovtest_suite_end
1112c09eee1SMax Filippov
1122c09eee1SMax Filippovcache_unlock_invalidate:
113*ecf5b577SMax Filippov#if XCHAL_DCACHE_SIZE
114*ecf5b577SMax Filippov    movi    a2, 0
115*ecf5b577SMax Filippov    movi    a3, XCHAL_DCACHE_SIZE
116*ecf5b577SMax Filippov1:
117*ecf5b577SMax Filippov#if XCHAL_DCACHE_LINE_LOCKABLE
118*ecf5b577SMax Filippov    diu     a2, 0
119*ecf5b577SMax Filippov#endif
120*ecf5b577SMax Filippov    dii     a2, 0
121*ecf5b577SMax Filippov    addi    a2, a2, XCHAL_DCACHE_LINESIZE
122*ecf5b577SMax Filippov    bltu    a2, a3, 1b
123*ecf5b577SMax Filippov#endif
124*ecf5b577SMax Filippov#if XCHAL_ICACHE_SIZE
125*ecf5b577SMax Filippov    movi    a2, 0
126*ecf5b577SMax Filippov    movi    a3, XCHAL_ICACHE_SIZE
127*ecf5b577SMax Filippov1:
128*ecf5b577SMax Filippov#if XCHAL_ICACHE_LINE_LOCKABLE
129*ecf5b577SMax Filippov    iiu     a2, 0
130*ecf5b577SMax Filippov#endif
131*ecf5b577SMax Filippov    iii     a2, 0
132*ecf5b577SMax Filippov    addi    a2, a2, XCHAL_ICACHE_LINESIZE
133*ecf5b577SMax Filippov    bltu    a2, a3, 1b
134*ecf5b577SMax Filippov#endif
1352c09eee1SMax Filippov    ret
136