Max Filippov | 3ee0141 | 2018-08-19 20:21:50 -0700 | [diff] [blame] | 1 | #include "macros.inc" |
| 2 | |
| 3 | test_suite phys_mem |
| 4 | |
Max Filippov | 3db8a95 | 2019-02-18 07:19:02 -0800 | [diff] [blame] | 5 | #if XCHAL_HAVE_PTP_MMU && !XCHAL_HAVE_SPANNING_WAY |
| 6 | |
Max Filippov | 3ee0141 | 2018-08-19 20:21:50 -0700 | [diff] [blame] | 7 | .purgem test_init |
| 8 | |
| 9 | .macro test_init |
| 10 | movi a2, 0xc0000003 /* PPN */ |
| 11 | movi a3, 0xc0000004 /* VPN */ |
| 12 | wdtlb a2, a3 |
| 13 | witlb a2, a3 |
| 14 | movi a2, 0xc0000000 |
| 15 | wsr a2, ptevaddr |
| 16 | .endm |
| 17 | |
| 18 | test inst_fetch_get_pte_no_phys |
| 19 | set_vector kernel, 2f |
| 20 | |
| 21 | movi a2, 0x20000000 |
| 22 | jx a2 |
| 23 | 2: |
| 24 | movi a2, 0x20000000 |
| 25 | rsr a3, excvaddr |
| 26 | assert eq, a2, a3 |
| 27 | rsr a3, epc1 |
| 28 | assert eq, a2, a3 |
| 29 | rsr a3, exccause |
| 30 | movi a2, 16 |
| 31 | assert eq, a2, a3 |
| 32 | test_end |
| 33 | |
| 34 | test read_get_pte_no_phys |
| 35 | set_vector kernel, 2f |
| 36 | |
| 37 | movi a2, 0x20000000 |
| 38 | 1: |
| 39 | l32i a3, a2, 0 |
| 40 | test_fail |
| 41 | 2: |
| 42 | movi a2, 0x20000000 |
| 43 | rsr a3, excvaddr |
| 44 | assert eq, a2, a3 |
| 45 | movi a2, 1b |
| 46 | rsr a3, epc1 |
| 47 | assert eq, a2, a3 |
| 48 | rsr a3, exccause |
| 49 | movi a2, 24 |
| 50 | assert eq, a2, a3 |
| 51 | test_end |
| 52 | |
| 53 | test write_get_pte_no_phys |
| 54 | set_vector kernel, 2f |
| 55 | |
| 56 | movi a2, 0x20000000 |
| 57 | 1: |
| 58 | s32i a3, a2, 0 |
| 59 | test_fail |
| 60 | 2: |
| 61 | movi a2, 0x20000000 |
| 62 | rsr a3, excvaddr |
| 63 | assert eq, a2, a3 |
| 64 | movi a2, 1b |
| 65 | rsr a3, epc1 |
| 66 | assert eq, a2, a3 |
| 67 | rsr a3, exccause |
| 68 | movi a2, 24 |
| 69 | assert eq, a2, a3 |
| 70 | test_end |
| 71 | |
Max Filippov | 3db8a95 | 2019-02-18 07:19:02 -0800 | [diff] [blame] | 72 | #endif |
| 73 | |
Max Filippov | 3ee0141 | 2018-08-19 20:21:50 -0700 | [diff] [blame] | 74 | test inst_fetch_no_phys |
| 75 | set_vector kernel, 2f |
| 76 | |
| 77 | movi a2, 0xc0000000 |
| 78 | jx a2 |
| 79 | 2: |
| 80 | movi a2, 0xc0000000 |
| 81 | rsr a3, excvaddr |
| 82 | assert eq, a2, a3 |
| 83 | rsr a3, epc1 |
| 84 | assert eq, a2, a3 |
| 85 | rsr a3, exccause |
| 86 | movi a2, 14 |
| 87 | assert eq, a2, a3 |
| 88 | test_end |
| 89 | |
| 90 | test read_no_phys |
| 91 | set_vector kernel, 2f |
| 92 | |
| 93 | movi a2, 0xc0000000 |
| 94 | 1: |
| 95 | l32i a3, a2, 0 |
| 96 | test_fail |
| 97 | 2: |
| 98 | movi a2, 0xc0000000 |
| 99 | rsr a3, excvaddr |
| 100 | assert eq, a2, a3 |
| 101 | movi a2, 1b |
| 102 | rsr a3, epc1 |
| 103 | assert eq, a2, a3 |
| 104 | rsr a3, exccause |
| 105 | movi a2, 15 |
| 106 | assert eq, a2, a3 |
| 107 | test_end |
| 108 | |
| 109 | test write_no_phys |
| 110 | set_vector kernel, 2f |
| 111 | |
| 112 | movi a2, 0xc0000000 |
| 113 | 1: |
| 114 | s32i a3, a2, 0 |
| 115 | test_fail |
| 116 | 2: |
| 117 | movi a2, 0xc0000000 |
| 118 | rsr a3, excvaddr |
| 119 | assert eq, a2, a3 |
| 120 | movi a2, 1b |
| 121 | rsr a3, epc1 |
| 122 | assert eq, a2, a3 |
| 123 | rsr a3, exccause |
| 124 | movi a2, 15 |
| 125 | assert eq, a2, a3 |
| 126 | test_end |
| 127 | |
| 128 | test_suite_end |