summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2019-11-05 09:02:57 +0300
committerAnup Patel <anup@brainfault.org>2019-11-06 08:05:41 +0300
commitf728a0be429d71cde966c85e3054535e3282460b (patch)
treeeb505226efac2f0c469b4ac3b22f7a4e6beda0c0 /include
parent98f4a208995b027662a7b04a25e4fa5df5f3eefe (diff)
downloadopensbi-f728a0be429d71cde966c85e3054535e3282460b.tar.xz
include: Sync-up encoding with priv v1.12-draft and hypervisor v0.5-draft
This patch sync-up encoding header with the latest privilege specifications draft v1.12 and hypervisor specifications draft v0.5. The MSTATUS.MTL and HSTATUS.STL bits are not present anymore and will be removed by another patch series for hypervisor v0.5-draft. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/riscv_encoding.h137
1 files changed, 45 insertions, 92 deletions
diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h
index 902c81a..2e59b7d 100644
--- a/include/sbi/riscv_encoding.h
+++ b/include/sbi/riscv_encoding.h
@@ -15,20 +15,16 @@
/* TODO: Make constants usable in assembly with _AC() macro */
/* clang-format off */
-#define MSTATUS_UIE 0x00000001
#define MSTATUS_SIE 0x00000002
-#define MSTATUS_HIE 0x00000004
#define MSTATUS_MIE 0x00000008
-#define MSTATUS_UPIE 0x00000010
#define MSTATUS_SPIE_SHIFT 5
#define MSTATUS_SPIE (1UL << MSTATUS_SPIE_SHIFT)
-#define MSTATUS_HPIE 0x00000040
+#define MSTATUS_UBE 0x00000040
#define MSTATUS_MPIE 0x00000080
#define MSTATUS_SPP_SHIFT 8
-#define MSTATUS_SPP (1UL << MSTATUS_SPP_SHIFT)
-#define MSTATUS_HPP 0x00000600
+#define MSTATUS_SPP (1 << MSTATUS_SPP_SHIFT)
#define MSTATUS_MPP_SHIFT 11
-#define MSTATUS_MPP (3UL << MSTATUS_MPP_SHIFT)
+#define MSTATUS_MPP (3 << MSTATUS_MPP_SHIFT)
#define MSTATUS_FS 0x00006000
#define MSTATUS_XS 0x00018000
#define MSTATUS_MPRV 0x00020000
@@ -41,34 +37,31 @@
#if __riscv_xlen == 64
#define MSTATUS_UXL 0x0000000300000000
#define MSTATUS_SXL 0x0000000C00000000
+#define MSTATUS_SBE 0x0000001000000000
+#define MSTATUS_MBE 0x0000002000000000
#define MSTATUS_MTL 0x0000004000000000
-#define MSTATUS_MTL_SHIFT 38
#define MSTATUS_MPV 0x0000008000000000
-#define MSTATUS_MPV_HIFT 39
#else
-#define MSTATUSH_UXL 0x00000003
-#define MSTATUSH_SXL 0x0000000C
+#define MSTATUSH_SBE 0x00000010
+#define MSTATUSH_MBE 0x00000020
#define MSTATUSH_MTL 0x00000040
-#define MSTATUSH_MTL_SHIFT 6
#define MSTATUSH_MPV 0x00000080
-#define MSTATUSH_MPV_HIFT 7
#endif
+#define MSTATUS32_SD 0x80000000
#define MSTATUS64_SD 0x8000000000000000
-#define SSTATUS_UIE 0x00000001
-#define SSTATUS_SIE 0x00000002
-#define SSTATUS_UPIE 0x00000010
-#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
-#define SSTATUS_MXR 0x00080000
-#define SSTATUS32_SD 0x80000000
-#define SSTATUS_UXL 0x0000000300000000
-#define SSTATUS64_SD 0x8000000000000000
+#define SSTATUS_SIE MSTATUS_SIE
+#define SSTATUS_SPIE_SHIFT MSTATUS_SPIE_SHIFT
+#define SSTATUS_SPIE MSTATUS_SPIE
+#define SSTATUS_SPP_SHIFT MSTATUS_SPP_SHIFT
+#define SSTATUS_SPP MSTATUS_SPP
+#define SSTATUS_FS MSTATUS_FS
+#define SSTATUS_XS MSTATUS_XS
+#define SSTATUS_SUM MSTATUS_SUM
+#define SSTATUS_MXR MSTATUS_MXR
+#define SSTATUS32_SD MSTATUS32_SD
+#define SSTATUS64_UXL MSTATUS_UXL
+#define SSTATUS64_SD MSTATUS64_SD
#define HSTATUS_VTSR 0x00400000
#define HSTATUS_VTVM 0x00100000
@@ -78,81 +71,24 @@
#define HSTATUS_STL 0x00000040
#define HSTATUS_SPRV 0x00000001
-#define DCSR_XDEBUGVER (3U<<30)
-#define DCSR_NDRESET (1<<29)
-#define DCSR_FULLRESET (1<<28)
-#define DCSR_EBREAKM (1<<15)
-#define DCSR_EBREAKH (1<<14)
-#define DCSR_EBREAKS (1<<13)
-#define DCSR_EBREAKU (1<<12)
-#define DCSR_STOPCYCLE (1<<10)
-#define DCSR_STOPTIME (1<<9)
-#define DCSR_CAUSE (7<<6)
-#define DCSR_DEBUGINT (1<<5)
-#define DCSR_HALT (1<<3)
-#define DCSR_STEP (1<<2)
-#define DCSR_PRV (3<<0)
-
-#define DCSR_CAUSE_NONE 0
-#define DCSR_CAUSE_SWBP 1
-#define DCSR_CAUSE_HWBP 2
-#define DCSR_CAUSE_DEBUGINT 3
-#define DCSR_CAUSE_STEP 4
-#define DCSR_CAUSE_HALT 5
-
-#define MCONTROL_TYPE(xlen) (0xfULL<<((xlen)-4))
-#define MCONTROL_DMODE(xlen) (1ULL<<((xlen)-5))
-#define MCONTROL_MASKMAX(xlen) (0x3fULL<<((xlen)-11))
-
-#define MCONTROL_SELECT (1<<19)
-#define MCONTROL_TIMING (1<<18)
-#define MCONTROL_ACTION (0x3f<<12)
-#define MCONTROL_CHAIN (1<<11)
-#define MCONTROL_MATCH (0xf<<7)
-#define MCONTROL_M (1<<6)
-#define MCONTROL_H (1<<5)
-#define MCONTROL_S (1<<4)
-#define MCONTROL_U (1<<3)
-#define MCONTROL_EXECUTE (1<<2)
-#define MCONTROL_STORE (1<<1)
-#define MCONTROL_LOAD (1<<0)
-
-#define MCONTROL_TYPE_NONE 0
-#define MCONTROL_TYPE_MATCH 2
-
-#define MCONTROL_ACTION_DEBUG_EXCEPTION 0
-#define MCONTROL_ACTION_DEBUG_MODE 1
-#define MCONTROL_ACTION_TRACE_START 2
-#define MCONTROL_ACTION_TRACE_STOP 3
-#define MCONTROL_ACTION_TRACE_EMIT 4
-
-#define MCONTROL_MATCH_EQUAL 0
-#define MCONTROL_MATCH_NAPOT 1
-#define MCONTROL_MATCH_GE 2
-#define MCONTROL_MATCH_LT 3
-#define MCONTROL_MATCH_MASK_LOW 4
-#define MCONTROL_MATCH_MASK_HIGH 5
-
#define IRQ_S_SOFT 1
-#define IRQ_H_SOFT 2
+#define IRQ_VS_SOFT 2
#define IRQ_M_SOFT 3
#define IRQ_S_TIMER 5
-#define IRQ_H_TIMER 6
+#define IRQ_VS_TIMER 6
#define IRQ_M_TIMER 7
#define IRQ_S_EXT 9
-#define IRQ_H_EXT 10
+#define IRQ_VS_EXT 10
#define IRQ_M_EXT 11
-#define IRQ_COP 12
-#define IRQ_HOST 13
#define MIP_SSIP (1 << IRQ_S_SOFT)
-#define MIP_HSIP (1 << IRQ_H_SOFT)
+#define MIP_VSSIP (1 << IRQ_VS_SOFT)
#define MIP_MSIP (1 << IRQ_M_SOFT)
#define MIP_STIP (1 << IRQ_S_TIMER)
-#define MIP_HTIP (1 << IRQ_H_TIMER)
+#define MIP_VSTIP (1 << IRQ_VS_TIMER)
#define MIP_MTIP (1 << IRQ_M_TIMER)
#define MIP_SEIP (1 << IRQ_S_EXT)
-#define MIP_HEIP (1 << IRQ_H_EXT)
+#define MIP_VSEIP (1 << IRQ_VS_EXT)
#define MIP_MEIP (1 << IRQ_M_EXT)
#define SIP_SSIP MIP_SSIP
@@ -160,7 +96,6 @@
#define PRV_U 0
#define PRV_S 1
-#define PRV_H 2
#define PRV_M 3
#define SATP32_MODE 0x80000000
@@ -276,9 +211,13 @@
#define CSR_HSTATUS 0x600
#define CSR_HEDELEG 0x602
#define CSR_HIDELEG 0x603
+#define CSR_HIE 0x604
#define CSR_HTIMEDELTA 0x605
#define CSR_HTIMEDELTAH 0x615
#define CSR_HCOUNTERNEN 0x606
+#define CSR_HTVAL 0x643
+#define CSR_HIP 0x644
+#define CSR_HTINST 0x64a
#define CSR_HGATP 0x680
#define CSR_VSSTATUS 0x200
@@ -304,6 +243,8 @@
#define CSR_MCAUSE 0x342
#define CSR_MTVAL 0x343
#define CSR_MIP 0x344
+#define CSR_MTINST 0x34a
+#define CSR_MTVAL2 0x34b
#define CSR_PMPCFG0 0x3a0
#define CSR_PMPCFG1 0x3a1
#define CSR_PMPCFG2 0x3a2
@@ -475,6 +416,9 @@
#define CAUSE_FETCH_PAGE_FAULT 0xc
#define CAUSE_LOAD_PAGE_FAULT 0xd
#define CAUSE_STORE_PAGE_FAULT 0xf
+#define CAUSE_FETCH_GUEST_PAGE_FAULT 0x14
+#define CAUSE_LOAD_GUEST_PAGE_FAULT 0x15
+#define CAUSE_STORE_GUEST_PAGE_FAULT 0x17
#define INSN_MATCH_LB 0x3
#define INSN_MASK_LB 0x707f
@@ -549,7 +493,16 @@
#define INSN_MASK_WFI 0xffffff00
#define INSN_MATCH_WFI 0x10500000
-#define INSN_LEN(insn) ((((insn) & 0x3) < 0x3) ? 2 : 4)
+#define INSN_16BIT_MASK 0x3
+#define INSN_32BIT_MASK 0x1c
+
+#define INSN_IS_16BIT(insn) \
+ (((insn) & INSN_16BIT_MASK) != INSN_16BIT_MASK)
+#define INSN_IS_32BIT(insn) \
+ (((insn) & INSN_16BIT_MASK) == INSN_16BIT_MASK && \
+ ((insn) & INSN_32BIT_MASK) != INSN_32BIT_MASK)
+
+#define INSN_LEN(insn) (INSN_IS_16BIT(insn) ? 2 : 4)
#if __riscv_xlen == 64
#define LOG_REGBYTES 3