|
11 | 11 |
|
12 | 12 | /* Status register flags */ |
13 | 13 | #define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */ |
| 14 | +#define SR_MIE _AC(0x00000008, UL) /* Machine Interrupt Enable */ |
14 | 15 | #define SR_SPIE _AC(0x00000020, UL) /* Previous Supervisor IE */ |
| 16 | +#define SR_MPIE _AC(0x00000080, UL) /* Previous Machine IE */ |
15 | 17 | #define SR_SPP _AC(0x00000100, UL) /* Previously Supervisor */ |
| 18 | +#define SR_MPP _AC(0x00001800, UL) /* Previously Machine */ |
16 | 19 | #define SR_SUM _AC(0x00040000, UL) /* Supervisor User Memory Access */ |
17 | 20 |
|
18 | 21 | #define SR_FS _AC(0x00006000, UL) /* Floating-point Status */ |
|
44 | 47 | #define SATP_MODE SATP_MODE_39 |
45 | 48 | #endif |
46 | 49 |
|
47 | | -/* SCAUSE */ |
48 | | -#define SCAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) |
| 50 | +/* Exception cause high bit - is an interrupt if set */ |
| 51 | +#define CAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) |
49 | 52 |
|
| 53 | +/* Interrupt causes (minus the high bit) */ |
50 | 54 | #define IRQ_U_SOFT 0 |
51 | 55 | #define IRQ_S_SOFT 1 |
52 | 56 | #define IRQ_M_SOFT 3 |
|
57 | 61 | #define IRQ_S_EXT 9 |
58 | 62 | #define IRQ_M_EXT 11 |
59 | 63 |
|
| 64 | +/* Exception causes */ |
60 | 65 | #define EXC_INST_MISALIGNED 0 |
61 | 66 | #define EXC_INST_ACCESS 1 |
62 | 67 | #define EXC_BREAKPOINT 3 |
|
67 | 72 | #define EXC_LOAD_PAGE_FAULT 13 |
68 | 73 | #define EXC_STORE_PAGE_FAULT 15 |
69 | 74 |
|
70 | | -/* SIE (Interrupt Enable) and SIP (Interrupt Pending) flags */ |
71 | | -#define SIE_SSIE (_AC(0x1, UL) << IRQ_S_SOFT) |
72 | | -#define SIE_STIE (_AC(0x1, UL) << IRQ_S_TIMER) |
73 | | -#define SIE_SEIE (_AC(0x1, UL) << IRQ_S_EXT) |
74 | | - |
| 75 | +/* symbolic CSR names: */ |
75 | 76 | #define CSR_CYCLE 0xc00 |
76 | 77 | #define CSR_TIME 0xc01 |
77 | 78 | #define CSR_INSTRET 0xc02 |
| 79 | +#define CSR_CYCLEH 0xc80 |
| 80 | +#define CSR_TIMEH 0xc81 |
| 81 | +#define CSR_INSTRETH 0xc82 |
| 82 | + |
78 | 83 | #define CSR_SSTATUS 0x100 |
79 | 84 | #define CSR_SIE 0x104 |
80 | 85 | #define CSR_STVEC 0x105 |
|
85 | 90 | #define CSR_STVAL 0x143 |
86 | 91 | #define CSR_SIP 0x144 |
87 | 92 | #define CSR_SATP 0x180 |
88 | | -#define CSR_CYCLEH 0xc80 |
89 | | -#define CSR_TIMEH 0xc81 |
90 | | -#define CSR_INSTRETH 0xc82 |
| 93 | + |
| 94 | +#define CSR_MSTATUS 0x300 |
| 95 | +#define CSR_MIE 0x304 |
| 96 | +#define CSR_MTVEC 0x305 |
| 97 | +#define CSR_MSCRATCH 0x340 |
| 98 | +#define CSR_MEPC 0x341 |
| 99 | +#define CSR_MCAUSE 0x342 |
| 100 | +#define CSR_MTVAL 0x343 |
| 101 | +#define CSR_MIP 0x344 |
| 102 | + |
| 103 | +#ifdef CONFIG_RISCV_M_MODE |
| 104 | +# define CSR_STATUS CSR_MSTATUS |
| 105 | +# define CSR_IE CSR_MIE |
| 106 | +# define CSR_TVEC CSR_MTVEC |
| 107 | +# define CSR_SCRATCH CSR_MSCRATCH |
| 108 | +# define CSR_EPC CSR_MEPC |
| 109 | +# define CSR_CAUSE CSR_MCAUSE |
| 110 | +# define CSR_TVAL CSR_MTVAL |
| 111 | +# define CSR_IP CSR_MIP |
| 112 | + |
| 113 | +# define SR_IE SR_MIE |
| 114 | +# define SR_PIE SR_MPIE |
| 115 | +# define SR_PP SR_MPP |
| 116 | + |
| 117 | +# define IRQ_SOFT IRQ_M_SOFT |
| 118 | +# define IRQ_TIMER IRQ_M_TIMER |
| 119 | +# define IRQ_EXT IRQ_M_EXT |
| 120 | +#else /* CONFIG_RISCV_M_MODE */ |
| 121 | +# define CSR_STATUS CSR_SSTATUS |
| 122 | +# define CSR_IE CSR_SIE |
| 123 | +# define CSR_TVEC CSR_STVEC |
| 124 | +# define CSR_SCRATCH CSR_SSCRATCH |
| 125 | +# define CSR_EPC CSR_SEPC |
| 126 | +# define CSR_CAUSE CSR_SCAUSE |
| 127 | +# define CSR_TVAL CSR_STVAL |
| 128 | +# define CSR_IP CSR_SIP |
| 129 | + |
| 130 | +# define SR_IE SR_SIE |
| 131 | +# define SR_PIE SR_SPIE |
| 132 | +# define SR_PP SR_SPP |
| 133 | + |
| 134 | +# define IRQ_SOFT IRQ_S_SOFT |
| 135 | +# define IRQ_TIMER IRQ_S_TIMER |
| 136 | +# define IRQ_EXT IRQ_S_EXT |
| 137 | +#endif /* CONFIG_RISCV_M_MODE */ |
| 138 | + |
| 139 | +/* IE/IP (Supervisor/Machine Interrupt Enable/Pending) flags */ |
| 140 | +#define IE_SIE (_AC(0x1, UL) << IRQ_SOFT) |
| 141 | +#define IE_TIE (_AC(0x1, UL) << IRQ_TIMER) |
| 142 | +#define IE_EIE (_AC(0x1, UL) << IRQ_EXT) |
91 | 143 |
|
92 | 144 | #ifndef __ASSEMBLY__ |
93 | 145 |
|
|
0 commit comments