summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnup Patel <[email protected]>2019-04-15 11:53:31 +0530
committerAnup Patel <[email protected]>2019-09-30 15:29:37 +0530
commitbbeb8e619d1cc528d2d56531512d6ea406f9738b (patch)
tree564a440550380b8fe3f5320ccf9c49739a158ae2 /include
parent1a5614e971cf44e08342c2b1639fa3be544b0202 (diff)
lib: Extend sbi_trap_redirect() for hypervisor extension
When hypervisor extension is available, we can get traps from VS/VU modes. We should be able to force redirect some of these traps to HS-mode. In other words, we should be able forward traps from VS/VU mode to HS-mode using sbi_trap_redirect() hence this patch. Signed-off-by: Atish Patra <[email protected]> Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/riscv_encoding.h32
-rw-r--r--include/sbi/sbi_trap.h6
2 files changed, 35 insertions, 3 deletions
diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h
index dace9e6b..0e1ea59c 100644
--- a/include/sbi/riscv_encoding.h
+++ b/include/sbi/riscv_encoding.h
@@ -58,8 +58,10 @@
#define SSTATUS_UIE 0x00000001
#define SSTATUS_SIE 0x00000002
#define SSTATUS_UPIE 0x00000010
-#define SSTATUS_SPIE 0x00000020
-#define SSTATUS_SPP 0x00000100
+#define SSTATUS_SPIE_SHIFT 5
+#define SSTATUS_SPIE (1UL << MSTATUS_SPIE_SHIFT)
+#define SSTATUS_SPP_SHIFT 8
+#define SSTATUS_SPP (1UL << MSTATUS_SPP_SHIFT)
#define SSTATUS_FS 0x00006000
#define SSTATUS_XS 0x00018000
#define SSTATUS_SUM 0x00040000
@@ -68,6 +70,14 @@
#define SSTATUS_UXL 0x0000000300000000
#define SSTATUS64_SD 0x8000000000000000
+#define HSTATUS_VTSR 0x00400000
+#define HSTATUS_VTVM 0x00100000
+#define HSTATUS_SP2V 0x00000200
+#define HSTATUS_SP2P 0x00000100
+#define HSTATUS_SPV 0x00000080
+#define HSTATUS_STL 0x00000040
+#define HSTATUS_SPRV 0x00000001
+
#define DCSR_XDEBUGVER (3U<<30)
#define DCSR_NDRESET (1<<29)
#define DCSR_FULLRESET (1<<28)
@@ -262,6 +272,23 @@
#define CSR_STVAL 0x143
#define CSR_SIP 0x144
#define CSR_SATP 0x180
+
+#define CSR_HSTATUS 0x600
+#define CSR_HEDELEG 0x602
+#define CSR_HIDELEG 0x603
+#define CSR_HCOUNTERNEN 0x606
+#define CSR_HGATP 0x680
+
+#define CSR_VSSTATUS 0x200
+#define CSR_VSIE 0x204
+#define CSR_VSTVEC 0x205
+#define CSR_VSSCRATCH 0x240
+#define CSR_VSEPC 0x241
+#define CSR_VSCAUSE 0x242
+#define CSR_VSTVAL 0x243
+#define CSR_VSIP 0x244
+#define CSR_VSATP 0x280
+
#define CSR_MSTATUS 0x300
#define CSR_MISA 0x301
#define CSR_MEDELEG 0x302
@@ -302,6 +329,7 @@
#define CSR_DCSR 0x7b0
#define CSR_DPC 0x7b1
#define CSR_DSCRATCH 0x7b2
+
#define CSR_MCYCLE 0xb00
#define CSR_MINSTRET 0xb02
#define CSR_MHPMCOUNTER3 0xb03
diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
index 19b95a7c..bc26ad13 100644
--- a/include/sbi/sbi_trap.h
+++ b/include/sbi/sbi_trap.h
@@ -80,8 +80,10 @@
#define SBI_TRAP_REGS_mepc 32
/** Index of mstatus member in sbi_trap_regs */
#define SBI_TRAP_REGS_mstatus 33
+/** Index of mstatusH member in sbi_trap_regs */
+#define SBI_TRAP_REGS_mstatusH 34
/** Last member index in sbi_trap_regs */
-#define SBI_TRAP_REGS_last 34
+#define SBI_TRAP_REGS_last 35
/* clang-format on */
@@ -164,6 +166,8 @@ struct sbi_trap_regs {
unsigned long mepc;
/** mstatus register state */
unsigned long mstatus;
+ /** mstatusH register state (only for 32-bit) */
+ unsigned long mstatusH;
} __packed;
struct sbi_scratch;