File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -165,13 +165,18 @@ set_csr!(
165
165
/// Supervisor Previous Privilege Mode
166
166
#[ inline]
167
167
pub unsafe fn set_spp ( spp : SPP ) {
168
- _set ( ( spp as usize ) << 8 ) ;
168
+ match spp {
169
+ SPP :: Supervisor => _set ( 1 << 8 ) ,
170
+ SPP :: User => _clear ( 1 << 8 ) ,
171
+ }
169
172
}
170
173
171
174
/// Machine Previous Privilege Mode
172
175
#[ inline]
173
176
pub unsafe fn set_mpp ( mpp : MPP ) {
174
- _set ( ( mpp as usize ) << 11 ) ;
177
+ let mut value = _read ( ) ;
178
+ value. set_bits ( 11 ..13 , mpp as usize ) ;
179
+ _write ( value) ;
175
180
}
176
181
177
182
/// Floating-point extension state
Original file line number Diff line number Diff line change @@ -131,12 +131,17 @@ set_clear_csr!(
131
131
#[ inline]
132
132
#[ cfg( riscv) ]
133
133
pub unsafe fn set_spp ( spp : SPP ) {
134
- _set ( ( spp as usize ) << 8 ) ;
134
+ match spp {
135
+ SPP :: Supervisor => _set ( 1 << 8 ) ,
136
+ SPP :: User => _clear ( 1 << 8 ) ,
137
+ }
135
138
}
136
139
137
140
/// The status of the floating-point unit
138
141
#[ inline]
139
142
#[ cfg( riscv) ]
140
143
pub unsafe fn set_fs ( fs : FS ) {
141
- _set ( ( fs as usize ) << 13 ) ;
144
+ let mut value = _read ( ) ;
145
+ value. set_bits ( 13 ..15 , fs as usize ) ;
146
+ _write ( value) ;
142
147
}
You can’t perform that action at this time.
0 commit comments