Skip to content

Commit

Permalink
Add unratified Smctr/Ssctr instructions and CSRs (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos authored Jun 4, 2024
1 parent 5181d13 commit ea2fec1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions csrs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
0x143, "stval"
0x144, "sip"
0x14D, "stimecmp"
0x14E, "sctrctl"
0x14F, "sctrstatus"
0x150, "siselect"
0x151, "sireg"
0x152, "sireg2"
Expand All @@ -69,6 +71,7 @@
0x156, "sireg5"
0x157, "sireg6"
0x15C, "stopei"
0x15F, "sctrdepth"
0x180, "satp"
0x181, "srmcfg"
0x5A8, "scontext"
Expand All @@ -81,6 +84,7 @@
0x243, "vstval"
0x244, "vsip"
0x24D, "vstimecmp"
0x24E, "vsctrctl"
0x250, "vsiselect"
0x251, "vsireg"
0x252, "vsireg2"
Expand Down Expand Up @@ -153,6 +157,7 @@
0x344, "mip"
0x34a, "mtinst"
0x34b, "mtval2"
0x34E, "mctrctl"
0x350, "miselect"
0x351, "mireg"
0x352, "mireg2"
Expand Down
71 changes: 71 additions & 0 deletions encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,15 @@
#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
#define MSTATEEN0_CSRIND 0x1000000000000000
#define MSTATEEN0_HENVCFG 0x4000000000000000
#define MSTATEEN_HSTATEEN 0x8000000000000000

#define MSTATEEN0H_CTR 0x00400000
#define MSTATEEN0H_PRIV114 0x00800000
#define MSTATEEN0H_HCONTEXT 0x02000000
#define MSTATEEN0H_AIA 0x08000000
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions unratified/rv_smdbltrp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sctrclr 11..7=0 19..15=0 31..20=0x104 14..12=0 6..2=0x1C 1..0=3

0 comments on commit ea2fec1

Please sign in to comment.