File tree Expand file tree Collapse file tree 5 files changed +64
-1
lines changed Expand file tree Collapse file tree 5 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ REG_READ_WRITE(mstatus, 0x300)
40
40
REG_SET_CLEAR(mstatus, 0x300 )
41
41
REG_READ_WRITE(mtvec, 0x305 )
42
42
REG_READ(mvendorid, 0xF11 )
43
+ REG_READ(marchid, 0xF12 )
44
+ REG_READ(mimpid, 0xF13 )
45
+ REG_READ(mhartid, 0xF14 )
43
46
44
47
// S-mode registers
45
48
REG_READ_WRITE(satp, 0x180 )
Original file line number Diff line number Diff line change
1
+ //! marchid register
2
+
3
+ use core:: num:: NonZeroUsize ;
4
+
5
+ /// marchid register
6
+ #[ derive( Clone , Copy , Debug ) ]
7
+ pub struct Marchid {
8
+ bits : NonZeroUsize ,
9
+ }
10
+
11
+ impl Marchid {
12
+ /// Returns the contents of the register as raw bits
13
+ pub fn bits ( & self ) -> usize {
14
+ self . bits . get ( )
15
+ }
16
+ }
17
+
18
+ read_csr ! ( 0xF11 , __read_marchid) ;
19
+
20
+ /// Reads the CSR
21
+ #[ inline]
22
+ pub fn read ( ) -> Option < Marchid > {
23
+ let r = unsafe { _read ( ) } ;
24
+ // When marchid is hardwired to zero it means that the marchid
25
+ // csr isn't implemented.
26
+ NonZeroUsize :: new ( r) . map ( |bits| Marchid { bits } )
27
+ }
Original file line number Diff line number Diff line change
1
+ //! mhartid register
2
+
3
+ read_csr_as_usize ! ( 0xf14 , __read_mhartid) ;
Original file line number Diff line number Diff line change
1
+ //! mimpid register
2
+
3
+ use core:: num:: NonZeroUsize ;
4
+
5
+ /// mimpid register
6
+ #[ derive( Clone , Copy , Debug ) ]
7
+ pub struct Mimpid {
8
+ bits : NonZeroUsize ,
9
+ }
10
+
11
+ impl Mimpid {
12
+ /// Returns the contents of the register as raw bits
13
+ pub fn bits ( & self ) -> usize {
14
+ self . bits . get ( )
15
+ }
16
+ }
17
+
18
+ read_csr ! ( 0xF11 , __read_mimpid) ;
19
+
20
+ /// Reads the CSR
21
+ #[ inline]
22
+ pub fn read ( ) -> Option < Mimpid > {
23
+ let r = unsafe { _read ( ) } ;
24
+ // When mimpid is hardwired to zero it means that the mimpid
25
+ // csr isn't implemented.
26
+ NonZeroUsize :: new ( r) . map ( |bits| Mimpid { bits } )
27
+ }
Original file line number Diff line number Diff line change @@ -15,14 +15,17 @@ mod macros;
15
15
16
16
pub mod fcsr;
17
17
18
+ pub mod marchid;
18
19
pub mod mcause;
19
20
pub mod mcycle;
20
21
pub mod mcycleh;
21
22
pub mod mepc;
23
+ pub mod mhartid;
22
24
pub mod mie;
23
- pub mod mip ;
25
+ pub mod mimpid ;
24
26
pub mod minstret;
25
27
pub mod minstreth;
28
+ pub mod mip;
26
29
pub mod misa;
27
30
pub mod mstatus;
28
31
pub mod mtvec;
You can’t perform that action at this time.
0 commit comments