[520] | 1 | /* |
---|
| 2 | * dtlb inval on PTPR write: check that no stale entry exists in the dtlb |
---|
| 3 | * after MMU context swicth |
---|
| 4 | */ |
---|
| 5 | #include <registers.h> |
---|
| 6 | #include <misc.h> |
---|
| 7 | #include <vcache.h> |
---|
| 8 | .text |
---|
| 9 | .globl _start |
---|
| 10 | _start: |
---|
| 11 | .set noreorder |
---|
| 12 | la k0, TTY_BASE |
---|
| 13 | la k1, EXIT_BASE |
---|
| 14 | |
---|
| 15 | PRINT(startstr) |
---|
| 16 | |
---|
| 17 | /* reset cop0 status (keep BEV) */ |
---|
| 18 | lui a0, 0x0040; |
---|
| 19 | mtc0 a0, COP0_STATUS |
---|
| 20 | |
---|
| 21 | la a0, pte1_b |
---|
| 22 | srl a0, a0, 13 |
---|
| 23 | mtc2 a0, VC_PTPR # PTPR <= pte1_b |
---|
| 24 | nop |
---|
| 25 | |
---|
| 26 | li a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE |
---|
| 27 | mtc2 a0, VC_TLB_EN |
---|
| 28 | |
---|
| 29 | PRINT(mmustr_b) |
---|
| 30 | la t0, testval + 0x00200000 |
---|
| 31 | lw a0, 0(t0); |
---|
| 32 | PRINTX # print MAGIC3 |
---|
| 33 | PUTCHAR('\n') |
---|
| 34 | |
---|
| 35 | la a0, pte1_a |
---|
| 36 | srl a0, a0, 13 |
---|
| 37 | mtc2 a0, VC_PTPR # PTPR <= pte1_a |
---|
| 38 | nop |
---|
| 39 | PRINT(mmustr_a) |
---|
| 40 | la t0, testval + 0x00200000 |
---|
| 41 | lw a0, 0(t0); |
---|
| 42 | PRINTX # print MAGIC1 |
---|
| 43 | PUTCHAR('\n') |
---|
| 44 | |
---|
| 45 | /* we should get there */ |
---|
| 46 | EXIT(0) |
---|
| 47 | |
---|
| 48 | .globl excep |
---|
| 49 | excep: |
---|
| 50 | .set noreorder |
---|
| 51 | PRINT(statusstr) |
---|
| 52 | mfc0 a0, COP0_STATUS |
---|
| 53 | PRINTX |
---|
| 54 | |
---|
| 55 | PRINT(causestr) |
---|
| 56 | mfc0 a0, COP0_CAUSE |
---|
| 57 | PRINTX |
---|
| 58 | |
---|
| 59 | PRINT(pcstr) |
---|
| 60 | mfc0 a0, COP0_EXPC |
---|
| 61 | PRINTX |
---|
| 62 | |
---|
| 63 | PRINT(badvastr) |
---|
| 64 | mfc0 a0, COP_0_BADVADDR |
---|
| 65 | PRINTX |
---|
| 66 | |
---|
| 67 | PUTCHAR('\n') |
---|
| 68 | /* we should not get there */ |
---|
| 69 | EXIT(3) |
---|
| 70 | |
---|
| 71 | .rodata: |
---|
| 72 | statusstr: .ascii "status \0" |
---|
| 73 | causestr: .ascii " cause \0" |
---|
| 74 | pcstr: .ascii " pc \0" |
---|
| 75 | badvastr: .ascii " badva \0" |
---|
| 76 | mmustr_a: .ascii "mmu started ptpr_a \0" |
---|
| 77 | mmustr_b: .ascii "mmu started ptpr_b \0" |
---|
| 78 | startstr: .ascii "start\n\0" |
---|
| 79 | |
---|
| 80 | .org EXCEP_ADDRESS - BOOT_ADDRESS |
---|
| 81 | .globl evect |
---|
| 82 | evect: |
---|
| 83 | j excep |
---|
| 84 | nop |
---|
| 85 | |
---|
| 86 | .data |
---|
| 87 | /* first 2 pages is data that will be switched my mmu switch */ |
---|
| 88 | data_a: |
---|
| 89 | .word MAGIC1 |
---|
| 90 | testval: |
---|
| 91 | .word MAGIC2 |
---|
| 92 | .org data_a + 0x1000 |
---|
| 93 | data_b: |
---|
| 94 | .word MAGIC3 |
---|
| 95 | .word MAGIC4 |
---|
| 96 | |
---|
| 97 | /* |
---|
| 98 | * two PD with two different PTE2 for code: check that dtlb points to |
---|
| 99 | * the right one by loading 2 different data at the same virtual address |
---|
| 100 | */ |
---|
| 101 | .globl pte2_a |
---|
| 102 | pte2_a: |
---|
| 103 | .align 12 |
---|
| 104 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 105 | .word 0x0000 >> 12 /* check real value of data_a */ |
---|
| 106 | |
---|
| 107 | .org pte2_a + 4092 |
---|
| 108 | .word 0 |
---|
| 109 | .globl pte2_b |
---|
| 110 | pte2_b: |
---|
| 111 | .align 12 |
---|
| 112 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 113 | .word 0x1000 >> 12 /* check real value of data_b */ |
---|
| 114 | |
---|
| 115 | .org pte2_b + 4092 |
---|
| 116 | .word 0 |
---|
| 117 | |
---|
| 118 | .globl pte1_a |
---|
| 119 | pte1_a: |
---|
| 120 | .align 13 |
---|
| 121 | .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */ |
---|
| 122 | .word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */ |
---|
| 123 | |
---|
| 124 | .org pte1_a + (BOOT_ADDRESS >> 21) * 4 |
---|
| 125 | .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */ |
---|
| 126 | |
---|
| 127 | .org pte1_a + (TTY_BASE >> 21) * 4 |
---|
| 128 | .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */ |
---|
| 129 | |
---|
| 130 | .org pte1_a + (EXIT_BASE >> 21) * 4 |
---|
| 131 | .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */ |
---|
| 132 | .org pte1_a + 8192 |
---|
| 133 | .globl pte1_b |
---|
| 134 | pte1_b: |
---|
| 135 | .align 13 |
---|
| 136 | .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */ |
---|
| 137 | .word PTE1_V | PTE1_T | (0x3000 >> 12) /* map PA 0x1000 at VA 0x00200000 via pte2_b */ |
---|
| 138 | .org pte1_b + (BOOT_ADDRESS >> 21) * 4 |
---|
| 139 | .word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */ |
---|
| 140 | .org pte1_b + (TTY_BASE >> 21) * 4 |
---|
| 141 | .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */ |
---|
| 142 | .org pte1_b + (EXIT_BASE >> 21) * 4 |
---|
| 143 | .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */ |
---|
| 144 | .org pte1_b + 8188 |
---|
| 145 | .word 0 |
---|