File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212- CSR helper macro ` write_composite_csr ` for writing 64-bit CSRs on 32-bit targets.
1313- Write utilities for ` mcycle ` , ` minstret `
1414- Add ` senvcfg ` CSR
15+ - Add ` scontext ` CSR
1516
1617### Changed
1718
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ pub mod stvec;
5757
5858// Supervisor Trap Handling
5959pub mod scause;
60+ pub mod scontext;
6061pub mod senvcfg;
6162pub mod sepc;
6263pub mod sip;
Original file line number Diff line number Diff line change 1+ //! `scontext` register.
2+
3+ #[ cfg( target_arch = "riscv32" ) ]
4+ const MASK : usize = 0xffff ;
5+ #[ cfg( not( target_arch = "riscv32" ) ) ]
6+ const MASK : usize = 0xffff_ffff ;
7+
8+ read_write_csr ! {
9+ /// `scontext` register.
10+ Scontext : 0x5a8 ,
11+ mask: MASK ,
12+ }
13+
14+ set ! ( 0x5a8 ) ;
15+ clear ! ( 0x5a8 ) ;
16+
17+ #[ cfg( target_arch = "riscv32" ) ]
18+ read_write_csr_field ! {
19+ Scontext ,
20+ /// Represents the `data` context number of the `scontext` CSR.
21+ data: [ 0 : 15 ] ,
22+ }
23+
24+ #[ cfg( not( target_arch = "riscv32" ) ) ]
25+ read_write_csr_field ! {
26+ Scontext ,
27+ /// Represents the `data` context number of the `scontext` CSR.
28+ data: [ 0 : 31 ] ,
29+ }
You can’t perform that action at this time.
0 commit comments