|
58 | 58 |
|
59 | 59 | /* Interrupt causes (minus the high bit) */
|
60 | 60 | #define IRQ_S_SOFT 1
|
| 61 | +#define IRQ_VS_SOFT 2 |
61 | 62 | #define IRQ_M_SOFT 3
|
62 | 63 | #define IRQ_S_TIMER 5
|
| 64 | +#define IRQ_VS_TIMER 6 |
63 | 65 | #define IRQ_M_TIMER 7
|
64 | 66 | #define IRQ_S_EXT 9
|
| 67 | +#define IRQ_VS_EXT 10 |
65 | 68 | #define IRQ_M_EXT 11
|
66 | 69 |
|
67 | 70 | /* Exception causes */
|
68 | 71 | #define EXC_INST_MISALIGNED 0
|
69 | 72 | #define EXC_INST_ACCESS 1
|
| 73 | +#define EXC_INST_ILLEGAL 2 |
70 | 74 | #define EXC_BREAKPOINT 3
|
71 | 75 | #define EXC_LOAD_ACCESS 5
|
72 | 76 | #define EXC_STORE_ACCESS 7
|
73 | 77 | #define EXC_SYSCALL 8
|
| 78 | +#define EXC_HYPERVISOR_SYSCALL 9 |
| 79 | +#define EXC_SUPERVISOR_SYSCALL 10 |
74 | 80 | #define EXC_INST_PAGE_FAULT 12
|
75 | 81 | #define EXC_LOAD_PAGE_FAULT 13
|
76 | 82 | #define EXC_STORE_PAGE_FAULT 15
|
| 83 | +#define EXC_INST_GUEST_PAGE_FAULT 20 |
| 84 | +#define EXC_LOAD_GUEST_PAGE_FAULT 21 |
| 85 | +#define EXC_VIRTUAL_INST_FAULT 22 |
| 86 | +#define EXC_STORE_GUEST_PAGE_FAULT 23 |
77 | 87 |
|
78 | 88 | /* PMP configuration */
|
79 | 89 | #define PMP_R 0x01
|
|
85 | 95 | #define PMP_A_NAPOT 0x18
|
86 | 96 | #define PMP_L 0x80
|
87 | 97 |
|
| 98 | +/* HSTATUS flags */ |
| 99 | +#ifdef CONFIG_64BIT |
| 100 | +#define HSTATUS_VSXL _AC(0x300000000, UL) |
| 101 | +#define HSTATUS_VSXL_SHIFT 32 |
| 102 | +#endif |
| 103 | +#define HSTATUS_VTSR _AC(0x00400000, UL) |
| 104 | +#define HSTATUS_VTW _AC(0x00200000, UL) |
| 105 | +#define HSTATUS_VTVM _AC(0x00100000, UL) |
| 106 | +#define HSTATUS_VGEIN _AC(0x0003f000, UL) |
| 107 | +#define HSTATUS_VGEIN_SHIFT 12 |
| 108 | +#define HSTATUS_HU _AC(0x00000200, UL) |
| 109 | +#define HSTATUS_SPVP _AC(0x00000100, UL) |
| 110 | +#define HSTATUS_SPV _AC(0x00000080, UL) |
| 111 | +#define HSTATUS_GVA _AC(0x00000040, UL) |
| 112 | +#define HSTATUS_VSBE _AC(0x00000020, UL) |
| 113 | + |
| 114 | +/* HGATP flags */ |
| 115 | +#define HGATP_MODE_OFF _AC(0, UL) |
| 116 | +#define HGATP_MODE_SV32X4 _AC(1, UL) |
| 117 | +#define HGATP_MODE_SV39X4 _AC(8, UL) |
| 118 | +#define HGATP_MODE_SV48X4 _AC(9, UL) |
| 119 | + |
| 120 | +#define HGATP32_MODE_SHIFT 31 |
| 121 | +#define HGATP32_VMID_SHIFT 22 |
| 122 | +#define HGATP32_VMID_MASK _AC(0x1FC00000, UL) |
| 123 | +#define HGATP32_PPN _AC(0x003FFFFF, UL) |
| 124 | + |
| 125 | +#define HGATP64_MODE_SHIFT 60 |
| 126 | +#define HGATP64_VMID_SHIFT 44 |
| 127 | +#define HGATP64_VMID_MASK _AC(0x03FFF00000000000, UL) |
| 128 | +#define HGATP64_PPN _AC(0x00000FFFFFFFFFFF, UL) |
| 129 | + |
| 130 | +#define HGATP_PAGE_SHIFT 12 |
| 131 | + |
| 132 | +#ifdef CONFIG_64BIT |
| 133 | +#define HGATP_PPN HGATP64_PPN |
| 134 | +#define HGATP_VMID_SHIFT HGATP64_VMID_SHIFT |
| 135 | +#define HGATP_VMID_MASK HGATP64_VMID_MASK |
| 136 | +#define HGATP_MODE_SHIFT HGATP64_MODE_SHIFT |
| 137 | +#else |
| 138 | +#define HGATP_PPN HGATP32_PPN |
| 139 | +#define HGATP_VMID_SHIFT HGATP32_VMID_SHIFT |
| 140 | +#define HGATP_VMID_MASK HGATP32_VMID_MASK |
| 141 | +#define HGATP_MODE_SHIFT HGATP32_MODE_SHIFT |
| 142 | +#endif |
| 143 | + |
| 144 | +/* VSIP & HVIP relation */ |
| 145 | +#define VSIP_TO_HVIP_SHIFT (IRQ_VS_SOFT - IRQ_S_SOFT) |
| 146 | +#define VSIP_VALID_MASK ((_AC(1, UL) << IRQ_S_SOFT) | \ |
| 147 | + (_AC(1, UL) << IRQ_S_TIMER) | \ |
| 148 | + (_AC(1, UL) << IRQ_S_EXT)) |
| 149 | + |
88 | 150 | /* symbolic CSR names: */
|
89 | 151 | #define CSR_CYCLE 0xc00
|
90 | 152 | #define CSR_TIME 0xc01
|
|
104 | 166 | #define CSR_SIP 0x144
|
105 | 167 | #define CSR_SATP 0x180
|
106 | 168 |
|
| 169 | +#define CSR_VSSTATUS 0x200 |
| 170 | +#define CSR_VSIE 0x204 |
| 171 | +#define CSR_VSTVEC 0x205 |
| 172 | +#define CSR_VSSCRATCH 0x240 |
| 173 | +#define CSR_VSEPC 0x241 |
| 174 | +#define CSR_VSCAUSE 0x242 |
| 175 | +#define CSR_VSTVAL 0x243 |
| 176 | +#define CSR_VSIP 0x244 |
| 177 | +#define CSR_VSATP 0x280 |
| 178 | + |
| 179 | +#define CSR_HSTATUS 0x600 |
| 180 | +#define CSR_HEDELEG 0x602 |
| 181 | +#define CSR_HIDELEG 0x603 |
| 182 | +#define CSR_HIE 0x604 |
| 183 | +#define CSR_HTIMEDELTA 0x605 |
| 184 | +#define CSR_HCOUNTEREN 0x606 |
| 185 | +#define CSR_HGEIE 0x607 |
| 186 | +#define CSR_HTIMEDELTAH 0x615 |
| 187 | +#define CSR_HTVAL 0x643 |
| 188 | +#define CSR_HIP 0x644 |
| 189 | +#define CSR_HVIP 0x645 |
| 190 | +#define CSR_HTINST 0x64a |
| 191 | +#define CSR_HGATP 0x680 |
| 192 | +#define CSR_HGEIP 0xe12 |
| 193 | + |
107 | 194 | #define CSR_MSTATUS 0x300
|
108 | 195 | #define CSR_MISA 0x301
|
109 | 196 | #define CSR_MIE 0x304
|
|
0 commit comments