source: branches/fault_tolerance/softs/tests_cc_vcache/test_excep_ls_llsc/test.S @ 724

Last change on this file since 724 was 724, checked in by cfuguet, 10 years ago

branches/fault_tolerance:

  • Recreating fault_tolerance branch with all new modifications from trunk.
  • Introducing distributed boot rom in the tsar_generic_iob platform
File size: 2.1 KB
Line 
1/*
2 * load/store bus fault exception test: we can restart the faulting instruction
3 * We use the MMU to cause fault
4 * Match what NetBSD does for page table update: sw for ppn, ll/sc for flags
5 */
6#include <registers.h>
7#include <misc.h>
8#include <vcache.h>
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
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
32        /* 0x00000000 not mapped yet: we fault, load the MMU and retry */
33        move    a1, zero
34        la      s0, testval
35        lw      a1, 0(s0) /* this should trigger the exception */
36        move    a0, s0
37        PRINTX
38        PUTCHAR(':')
39        PUTCHAR(' ')
40        move    a0, a1
41        PRINTX
42        PUTCHAR('\n')
43
44        /* we should get there */
45        EXIT(0)
46
47        .globl excep
48excep:
49        .set noreorder
50        PRINT(statusstr)
51        mfc0    a0, COP0_STATUS
52        PRINTX
53
54        PRINT(causestr)
55        mfc0    a0, COP0_CAUSE
56        PRINTX
57
58        PRINT(pcstr)
59        mfc0    a0, COP0_EXPC
60        PRINTX
61
62        PRINT(badvastr)
63        mfc0    a0, COP_0_BADVADDR
64        PRINTX
65
66        PUTCHAR('\n')
67        /* map VA 0 at PA 0: just copy entry for 0x00200000 */
68        la      t0, pte1 + 0x00200000
691:
70        ll      a0, 0(t0)
71        lw      a0, 4(t0)
72        sc      a0, 0(t0)
73        beqz    a0, 1b
74        /* mtc2 zero, VC_DTLB_INVAL */
75        eret
76
77        .rodata:
78statusstr: .ascii "status \0"
79causestr: .ascii " cause \0"
80pcstr: .ascii " pc \0"
81badvastr: .ascii " badva \0"
82mmustr: .ascii "mmu started\n\0"
83startstr: .ascii "start\n\0"
84
85        .org EXCEP_ADDRESS - BOOT_ADDRESS
86        .globl evect
87evect:
88        j       excep
89        nop
90        .data
91        .word MAGIC1
92testval:
93        .word MAGIC2
94        .globl pte1
95pte1:
96        .align 13
97        .word 0x0                            /* map PA 0 at VA 0 */
98        .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
99        .org pte1 + (BOOT_ADDRESS >> 21) * 4
100        .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
101        .org pte1 + (TTY_BASE >> 21) * 4
102        .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
103        .org pte1 + (EXIT_BASE >> 21) * 4
104        .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
105        .org pte1 + 8192
106        .word 0
107
Note: See TracBrowser for help on using the repository browser.