From ea2fec121a59136b0dada11743bf6c545c996c65 Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue <91900059+ved-rivos@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:20:56 -0500 Subject: Add unratified Smctr/Ssctr instructions and CSRs (#252) --- csrs.csv | 5 ++++ encoding.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ unratified/rv_smdbltrp | 1 + 3 files changed, 77 insertions(+) create mode 100644 unratified/rv_smdbltrp diff --git a/csrs.csv b/csrs.csv index 81e5b27..6aae1e9 100644 --- a/csrs.csv +++ b/csrs.csv @@ -61,6 +61,8 @@ 0x143, "stval" 0x144, "sip" 0x14D, "stimecmp" +0x14E, "sctrctl" +0x14F, "sctrstatus" 0x150, "siselect" 0x151, "sireg" 0x152, "sireg2" @@ -69,6 +71,7 @@ 0x156, "sireg5" 0x157, "sireg6" 0x15C, "stopei" +0x15F, "sctrdepth" 0x180, "satp" 0x181, "srmcfg" 0x5A8, "scontext" @@ -81,6 +84,7 @@ 0x243, "vstval" 0x244, "vsip" 0x24D, "vstimecmp" +0x24E, "vsctrctl" 0x250, "vsiselect" 0x251, "vsireg" 0x252, "vsireg2" @@ -153,6 +157,7 @@ 0x344, "mip" 0x34a, "mtinst" 0x34b, "mtval2" +0x34E, "mctrctl" 0x350, "miselect" 0x351, "mireg" 0x352, "mireg2" diff --git a/encoding.h b/encoding.h index 01190e3..6de74b3 100644 --- a/encoding.h +++ b/encoding.h @@ -179,6 +179,7 @@ #define MSTATEEN0_CS 0x00000001 #define MSTATEEN0_FCSR 0x00000002 #define MSTATEEN0_JVT 0x00000004 +#define MSTATEEN0_CTR 0x0040000000000000 #define MSTATEEN0_PRIV114 0x0080000000000000 #define MSTATEEN0_HCONTEXT 0x0200000000000000 #define MSTATEEN0_AIA 0x0800000000000000 @@ -186,6 +187,7 @@ #define MSTATEEN0_HENVCFG 0x4000000000000000 #define MSTATEEN_HSTATEEN 0x8000000000000000 +#define MSTATEEN0H_CTR 0x00400000 #define MSTATEEN0H_PRIV114 0x00800000 #define MSTATEEN0H_HCONTEXT 0x02000000 #define MSTATEEN0H_AIA 0x08000000 @@ -238,12 +240,14 @@ #define HSTATEEN0_CS 0x00000001 #define HSTATEEN0_FCSR 0x00000002 #define HSTATEEN0_JVT 0x00000004 +#define MSTATEEN0_CTR 0x0040000000000000 #define HSTATEEN0_SCONTEXT 0x0200000000000000 #define HSTATEEN0_AIA 0x0800000000000000 #define HSTATEEN0_CSRIND 0x1000000000000000 #define HSTATEEN0_SENVCFG 0x4000000000000000 #define HSTATEEN_SSTATEEN 0x8000000000000000 +#define MSTATEEN0H_CTR 0x00400000 #define HSTATEEN0H_SCONTEXT 0x02000000 #define HSTATEEN0H_AIA 0x08000000 #define HSTATEEN0H_CSRIND 0x10000000 @@ -326,6 +330,73 @@ #define PMP_NA4 0x10 #define PMP_NAPOT 0x18 +#define MCTRCTL_U 0x0000000000000001 +#define MCTRCTL_S 0x0000000000000002 +#define MCTRCTL_M 0x0000000000000004 +#define MCTRCTL_RASEMU 0x0000000000000080 +#define MCTRCTL_STE 0x0000000000000100 +#define MCTRCTL_MTE 0x0000000000000200 +#define MCTRCTL_BPFRZ 0x0000000000000800 +#define MCTRCTL_LCOFIFRZ 0x0000000000001000 +#define MCTRCTL_EXCINH 0x0000000200000000 +#define MCTRCTL_INTRINH 0x0000000400000000 +#define MCTRCTL_TRETINH 0x0000000800000000 +#define MCTRCTL_NTBREN 0x0000001000000000 +#define MCTRCTL_TKBRINH 0x0000002000000000 +#define MCTRCTL_INDCALLINH 0x0000010000000000 +#define MCTRCTL_DIRCALLINH 0x0000020000000000 +#define MCTRCTL_INDJMPINH 0x0000040000000000 +#define MCTRCTL_DIRJMPINH 0x0000080000000000 +#define MCTRCTL_CORSWAPINH 0x0000100000000000 +#define MCTRCTL_RETINH 0x0000200000000000 +#define MCTRCTL_INDLJMPINH 0x0000400000000000 +#define MCTRCTL_DIRLJMPINH 0x0000800000000000 + +#define SCTRCTL_U 0x0000000000000001 +#define SCTRCTL_S 0x0000000000000002 +#define SCTRCTL_RASEMU 0x0000000000000080 +#define SCTRCTL_STE 0x0000000000000100 +#define SCTRCTL_BPFRZ 0x0000000000000800 +#define SCTRCTL_LCOFIFRZ 0x0000000000001000 +#define SCTRCTL_EXCINH 0x0000000200000000 +#define SCTRCTL_INTRINH 0x0000000400000000 +#define SCTRCTL_TRETINH 0x0000000800000000 +#define SCTRCTL_NTBREN 0x0000001000000000 +#define SCTRCTL_TKBRINH 0x0000002000000000 +#define SCTRCTL_INDCALLINH 0x0000010000000000 +#define SCTRCTL_DIRCALLINH 0x0000020000000000 +#define SCTRCTL_INDJMPINH 0x0000040000000000 +#define SCTRCTL_DIRJMPINH 0x0000080000000000 +#define SCTRCTL_CORSWAPINH 0x0000100000000000 +#define SCTRCTL_RETINH 0x0000200000000000 +#define SCTRCTL_INDLJMPINH 0x0000400000000000 +#define SCTRCTL_DIRLJMPINH 0x0000800000000000 + +#define VSCTRCTL_U 0x0000000000000001 +#define VSCTRCTL_S 0x0000000000000002 +#define VSCTRCTL_RASEMU 0x0000000000000080 +#define VSCTRCTL_STE 0x0000000000000100 +#define VSCTRCTL_BPFRZ 0x0000000000000800 +#define VSCTRCTL_LCOFIFRZ 0x0000000000001000 +#define VSCTRCTL_EXCINH 0x0000000200000000 +#define VSCTRCTL_INTRINH 0x0000000400000000 +#define VSCTRCTL_TRETINH 0x0000000800000000 +#define VSCTRCTL_NTBREN 0x0000001000000000 +#define VSCTRCTL_TKBRINH 0x0000002000000000 +#define VSCTRCTL_INDCALLINH 0x0000010000000000 +#define VSCTRCTL_DIRCALLINH 0x0000020000000000 +#define VSCTRCTL_INDJMPINH 0x0000040000000000 +#define VSCTRCTL_DIRJMPINH 0x0000080000000000 +#define VSCTRCTL_CORSWAPINH 0x0000100000000000 +#define VSCTRCTL_RETINH 0x0000200000000000 +#define VSCTRCTL_INDLJMPINH 0x0000400000000000 +#define VSCTRCTL_DIRLJMPINH 0x0000800000000000 + +#define SCTRDEPTH_DEPTH 0x00000007 + +#define SCTRSTATUS_WRPTR 0x000000FF +#define SCTRSTATUS_FROZEN 0x80000000 + #define IRQ_U_SOFT 0 #define IRQ_S_SOFT 1 #define IRQ_VS_SOFT 2 diff --git a/unratified/rv_smdbltrp b/unratified/rv_smdbltrp new file mode 100644 index 0000000..49dd9a0 --- /dev/null +++ b/unratified/rv_smdbltrp @@ -0,0 +1 @@ +sctrclr 11..7=0 19..15=0 31..20=0x104 14..12=0 6..2=0x1C 1..0=3 -- cgit v1.1