source: trunk/softs/tests_ccvcache_v4/test_llsc/test.S @ 265

Last change on this file since 265 was 265, checked in by bouyer, 12 years ago

Update/add 2 new tests, from tests_mips32_vcache:
test_llsc: check basic functionnality of ll/sc
test_sc_no_ll: check that a sc without prior ll fails as expected

File size: 1.9 KB
Line 
1/*
2 * Check interraction between cached read/write and ll/sc
3 */
4#include <registers.h>
5#include <misc.h>
6#include <vcache.h>
7
8        .text
9        .globl  _start
10_start:
11        .set noreorder
12        la      k0, TTY_BASE
13        la      k1, EXIT_BASE
14
15        /* reset cop0 status (keep BEV) */
16        lui     a0, 0x0040;
17        mtc0    a0, COP0_STATUS
18
19        la      a0, pte1
20        srl     a0, a0, 13
21        mtc2    a0, VC_PTPR
22        nop
23
24        li      a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
25        mtc2    a0, VC_TLB_EN
26
27        /* make sure myvar is in cache */
28        la      s1, myvar
29        lw      a0, 0(s1)
30        PRINTX
31        PUTCHAR(' ')
32
33        /* now write to myvar via ll/sc */
34        la      s1, myvar
351:
36        ll      a0, 0(s1)
37        li      a1, MAGIC2
38        sc      a1, 0(s1)
39        beqz    a1, 1b
40        nop
41
42        PRINTX /* print what we read with ll */
43        PUTCHAR(' ')
44
45        la      s1, myvar
46        lw      a0, 0(s1) /* print the new value */
47        PRINTX
48        PUTCHAR(' ')
49
50        /* restore myvar value via normal write */
51        la      s1, myvar
52        li      a1, MAGIC1
53        sw      a1, 0(s1)
54
55        /* read myvar */
56        lw      a0, 0(s1)
57        PRINTX
58        PUTCHAR('\n');
59       
60        EXIT(0)
61
62        .globl excep
63excep:
64        .set noreorder
65        PRINT(statusstr)
66        mfc0    a0, COP0_STATUS
67        PRINTX
68
69        PRINT(causestr)
70        mfc0    a0, COP0_CAUSE
71        PRINTX
72
73        PRINT(pcstr)
74        mfc0    a0, COP0_EXPC
75        PRINTX
76
77        PRINT(badvastr)
78        mfc0    a0, COP_0_BADVADDR
79        PRINTX
80
81        PUTCHAR('\n')
82        /* we should not get there */
83        EXIT(1)
84
85        .rodata:
86statusstr: .ascii "status \0"
87causestr: .ascii " cause \0"
88pcstr: .ascii " pc \0"
89badvastr: .ascii " badva \0"
90value:  .word 0x1234abcd
91string: .ascii "hello world \0"
92
93        .org EXCEP_ADDRESS - BOOT_ADDRESS
94        .globl evect
95evect:
96        j       excep
97        nop
98
99        .data
100myvar:  .word MAGIC1
101        .globl pte1
102pte1:
103        .align 13
104        .word PTE1_V | PTE1_W | 0x0 /* map PA 0 at VA 0 */
105        .org pte1 + (BOOT_ADDRESS >> 21) * 4
106        .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
107        .org pte1 + (TTY_BASE >> 21) * 4
108        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
109        .org pte1 + (EXIT_BASE >> 21) * 4
110        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
111        .org pte1 + 8192
112        .word 0
113
Note: See TracBrowser for help on using the repository browser.