@@ -95,10 +95,11 @@ impl Mstatus {
95
95
96
96
/// Update Supervisor Interrupt Enable
97
97
///
98
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
99
- /// CSR itself. See [`set_sie`]/[`clear_sie`] to directly update the CSR.
98
+ /// Note this updates a previously read [`Mstatus`] value, but does not
99
+ /// affect the mstatus CSR itself. See [`set_sie`]/[`clear_sie`] to directly
100
+ /// update the CSR.
100
101
#[ inline]
101
- pub fn update_sie ( & self , sie : bool ) -> Self {
102
+ pub fn set_sie ( & self , sie : bool ) -> Self {
102
103
self . bf_insert ( 1 , 1 , sie as usize )
103
104
}
104
105
@@ -110,10 +111,11 @@ impl Mstatus {
110
111
111
112
/// Update Machine Interrupt Enable
112
113
///
113
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
114
- /// CSR itself. See [`set_mie`]/[`clear_mie`] to directly update the CSR.
114
+ /// Note this updates a previously read [`Mstatus`] value, but does not
115
+ /// affect the mstatus CSR itself. See [`set_mie`]/[`clear_mie`] to directly
116
+ /// update the CSR.
115
117
#[ inline]
116
- pub fn update_mie ( & self , mie : bool ) -> Self {
118
+ pub fn set_mie ( & self , mie : bool ) -> Self {
117
119
self . bf_insert ( 3 , 1 , mie as usize )
118
120
}
119
121
@@ -123,12 +125,13 @@ impl Mstatus {
123
125
self . bits & ( 1 << 5 ) != 0
124
126
}
125
127
126
- /// Updateervisor Previous Interrupt Enable
128
+ /// Update Supervisor Previous Interrupt Enable
127
129
///
128
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
129
- /// CSR itself. See [`set_spie`]` to directly update the CSR.
130
+ /// Note this updates a previously read [`Mstatus`] value, but does not
131
+ /// affect the mstatus CSR itself. See [`set_spie`]` to directly update the
132
+ /// CSR.
130
133
#[ inline]
131
- pub fn update_spie ( & self , spie : bool ) -> Self {
134
+ pub fn set_spie ( & self , spie : bool ) -> Self {
132
135
self . bf_insert ( 5 , 1 , spie as usize )
133
136
}
134
137
@@ -140,10 +143,11 @@ impl Mstatus {
140
143
141
144
/// Update U-mode non-instruction-fetch memory endianness
142
145
///
143
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
144
- /// CSR itself. See [`set_ube`] to directly update the CSR.
146
+ /// Note this updates a previously read [`Mstatus`] value, but does not
147
+ /// affect the mstatus CSR itself. See [`set_ube`] to directly update the
148
+ /// CSR.
145
149
#[ inline]
146
- pub fn update_ube ( & self , endianness : Endianness ) -> Self {
150
+ pub fn set_ube ( & self , endianness : Endianness ) -> Self {
147
151
self . bf_insert ( 6 , 1 , endianness as usize )
148
152
}
149
153
@@ -155,10 +159,11 @@ impl Mstatus {
155
159
156
160
/// Update Machine Previous Interrupt Enable
157
161
///
158
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
159
- /// CSR itself. See [`set_mpie`] to directly update the CSR.
162
+ /// Note this updates a previously read [`Mstatus`] value, but does not
163
+ /// affect the mstatus CSR itself. See [`set_mpie`] to directly update the
164
+ /// CSR.
160
165
#[ inline]
161
- pub fn update_mpie ( & self , mpie : bool ) -> Self {
166
+ pub fn set_mpie ( & self , mpie : bool ) -> Self {
162
167
self . bf_insert ( 7 , 1 , mpie as usize )
163
168
}
164
169
@@ -173,10 +178,11 @@ impl Mstatus {
173
178
174
179
/// Update Supervisor Previous Privilege Mode
175
180
///
176
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
177
- /// CSR itself. See [`set_spp`] to directly update the CSR.
181
+ /// Note this updates a previously read [`Mstatus`] value, but does not
182
+ /// affect the mstatus CSR itself. See [`set_spp`] to directly update the
183
+ /// CSR.
178
184
#[ inline]
179
- pub fn update_spp ( & self , spp : SPP ) -> Self {
185
+ pub fn set_spp ( & self , spp : SPP ) -> Self {
180
186
self . bf_insert ( 8 , 1 , spp as usize )
181
187
}
182
188
@@ -194,17 +200,18 @@ impl Mstatus {
194
200
195
201
/// Update Machine Previous Privilege Mode
196
202
///
197
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
198
- /// CSR itself. See [`set_mpp`] to directly update the CSR.
203
+ /// Note this updates a previously read [`Mstatus`] value, but does not
204
+ /// affect the mstatus CSR itself. See [`set_mpp`] to directly update the
205
+ /// CSR.
199
206
#[ inline]
200
- pub fn update_mpp ( & self , mpp : MPP ) -> Self {
207
+ pub fn set_mpp ( & self , mpp : MPP ) -> Self {
201
208
self . bf_insert ( 11 , 2 , mpp as usize )
202
209
}
203
210
204
211
/// Floating-point extension state
205
212
///
206
- /// Encodes the status of the floating-point unit,
207
- /// including the CSR `fcsr` and floating-point data registers `f0–f31`.
213
+ /// Encodes the status of the floating-point unit, including the CSR `fcsr`
214
+ /// and floating-point data registers `f0–f31`.
208
215
#[ inline]
209
216
pub fn fs ( & self ) -> FS {
210
217
let fs = ( self . bits >> 13 ) & 0x3 ; // bits 13-14
@@ -219,16 +226,18 @@ impl Mstatus {
219
226
220
227
/// Update Floating-point extension state
221
228
///
222
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
223
- /// CSR itself. See [`set_fs`] to directly update the CSR.
229
+ /// Note this updates a previously read [`Mstatus`] value, but does not
230
+ /// affect the mstatus CSR itself. See [`set_fs`] to directly update the
231
+ /// CSR.
224
232
#[ inline]
225
- pub fn update_fs ( & self , fs : FS ) -> Self {
233
+ pub fn set_fs ( & self , fs : FS ) -> Self {
226
234
self . bf_insert ( 13 , 2 , fs as usize )
227
235
}
228
236
229
237
/// Additional extension state
230
238
///
231
- /// Encodes the status of additional user-mode extensions and associated state.
239
+ /// Encodes the status of additional user-mode extensions and associated
240
+ /// state.
232
241
#[ inline]
233
242
pub fn xs ( & self ) -> XS {
234
243
let xs = ( self . bits >> 15 ) & 0x3 ; // bits 15-16
@@ -243,10 +252,10 @@ impl Mstatus {
243
252
244
253
/// Update Additional extension state
245
254
///
246
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
247
- /// CSR itself.
255
+ /// Note this updates a previously read [`Mstatus`] value, but does not
256
+ /// affect the mstatus CSR itself.
248
257
#[ inline]
249
- pub fn update_xs ( & self , xs : XS ) -> Self {
258
+ pub fn set_xs ( & self , xs : XS ) -> Self {
250
259
self . bf_insert ( 15 , 2 , xs as usize )
251
260
}
252
261
@@ -258,10 +267,11 @@ impl Mstatus {
258
267
259
268
/// Update Modify Memory PRiVilege
260
269
///
261
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
262
- /// CSR itself. See [`set_mprv`]/[`clear_mprv`] to directly update the CSR.
270
+ /// Note this updates a previously read [`Mstatus`] value, but does not
271
+ /// affect the mstatus CSR itself. See [`set_mprv`]/[`clear_mprv`] to
272
+ /// directly update the CSR.
263
273
#[ inline]
264
- pub fn update_mprv ( & self , mprv : bool ) -> Self {
274
+ pub fn set_mprv ( & self , mprv : bool ) -> Self {
265
275
self . bf_insert ( 17 , 1 , mprv as usize )
266
276
}
267
277
@@ -273,10 +283,11 @@ impl Mstatus {
273
283
274
284
/// Update Permit Supervisor User Memory access
275
285
///
276
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
277
- /// CSR itself. See [`set_sum`]/[`clear_sum`] to directly update the CSR.
286
+ /// Note this updates a previously read [`Mstatus`] value, but does not
287
+ /// affect the mstatus CSR itself. See [`set_sum`]/[`clear_sum`] to directly
288
+ /// update the CSR.
278
289
#[ inline]
279
- pub fn update_sum ( & self , sum : bool ) -> Self {
290
+ pub fn set_sum ( & self , sum : bool ) -> Self {
280
291
self . bf_insert ( 18 , 1 , sum as usize )
281
292
}
282
293
@@ -288,10 +299,11 @@ impl Mstatus {
288
299
289
300
/// Update Make eXecutable Readable
290
301
///
291
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
292
- /// CSR itself. See [`set_mxr`]/[`clear_mxr`] to directly update the CSR.
302
+ /// Note this updates a previously read [`Mstatus`] value, but does not affect
303
+ /// the mstatus CSR itself. See [`set_mxr`]/[`clear_mxr`] to directly update
304
+ /// the CSR.
293
305
#[ inline]
294
- pub fn update_mxr ( & self , mxr : bool ) -> Self {
306
+ pub fn set_mxr ( & self , mxr : bool ) -> Self {
295
307
self . bf_insert ( 19 , 1 , mxr as usize )
296
308
}
297
309
@@ -308,10 +320,11 @@ impl Mstatus {
308
320
309
321
/// Update Trap Virtual Memory
310
322
///
311
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
312
- /// CSR itself. See [`set_tvm`]/[`clear_tvm`] to directly update the CSR.
323
+ /// Note this updates a previously read [`Mstatus`] value, but does not
324
+ /// affect the mstatus CSR itself. See [`set_tvm`]/[`clear_tvm`] to directly
325
+ /// update the CSR.
313
326
#[ inline]
314
- pub fn update_tvm ( & self , tvm : bool ) -> Self {
327
+ pub fn set_tvm ( & self , tvm : bool ) -> Self {
315
328
self . bf_insert ( 20 , 1 , tvm as usize )
316
329
}
317
330
@@ -331,10 +344,11 @@ impl Mstatus {
331
344
332
345
/// Update Timeout Wait
333
346
///
334
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
335
- /// CSR itself. See [`set_tw`]/[`clear_tw`] to directly update the CSR.
347
+ /// Note this updates a previously read [`Mstatus`] value, but does not
348
+ /// affect the mstatus CSR itself. See [`set_tw`]/[`clear_tw`] to directly
349
+ /// update the CSR.
336
350
#[ inline]
337
- pub fn update_tw ( & self , tw : bool ) -> Self {
351
+ pub fn set_tw ( & self , tw : bool ) -> Self {
338
352
self . bf_insert ( 21 , 1 , tw as usize )
339
353
}
340
354
@@ -351,10 +365,11 @@ impl Mstatus {
351
365
352
366
/// Update Trap SRET
353
367
///
354
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
355
- /// CSR itself. See [`set_tsr`]/[`clear_tsr`] to directly update the CSR.
368
+ /// Note this updates a previously read [`Mstatus`] value, but does not
369
+ /// affect the mstatus CSR itself. See [`set_tsr`]/[`clear_tsr`] to directly
370
+ /// update the CSR.
356
371
#[ inline]
357
- pub fn update_tsr ( & self , tsr : bool ) -> Self {
372
+ pub fn set_tsr ( & self , tsr : bool ) -> Self {
358
373
self . bf_insert ( 22 , 1 , tsr as usize )
359
374
}
360
375
@@ -373,10 +388,10 @@ impl Mstatus {
373
388
374
389
/// Update Effective xlen in U-mode (i.e., `UXLEN`).
375
390
///
376
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
377
- /// CSR itself.
391
+ /// Note this updates a previously read [`Mstatus`] value, but does not
392
+ /// affect the mstatus CSR itself.
378
393
#[ inline]
379
- pub fn update_uxl ( & self , uxl : XLEN ) -> Self {
394
+ pub fn set_uxl ( & self , uxl : XLEN ) -> Self {
380
395
#[ cfg( riscv32) ]
381
396
{
382
397
* self
@@ -400,10 +415,10 @@ impl Mstatus {
400
415
401
416
/// Update Effective xlen in S-mode (i.e., `SXLEN`).
402
417
///
403
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
404
- /// CSR itself.
418
+ /// Note this updates a previously read [`Mstatus`] value, but does not
419
+ /// affect the mstatus CSR itself.
405
420
#[ inline]
406
- pub fn update_sxl ( & self , sxl : XLEN ) -> Self {
421
+ pub fn set_sxl ( & self , sxl : XLEN ) -> Self {
407
422
#[ cfg( riscv32) ]
408
423
{
409
424
* self
@@ -426,10 +441,11 @@ impl Mstatus {
426
441
427
442
/// Update S-mode non-instruction-fetch memory endianness
428
443
///
429
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
430
- /// CSR itself. See [`set_sbe`] to directly update the CSR.
444
+ /// Note this updates a previously read [`Mstatus`] value, but does not
445
+ /// affect the mstatus CSR itself. See [`set_sbe`] to directly update the
446
+ /// CSR.
431
447
#[ inline]
432
- pub fn update_sbe ( & self , endianness : Endianness ) -> Self {
448
+ pub fn set_sbe ( & self , endianness : Endianness ) -> Self {
433
449
#[ cfg( riscv32) ]
434
450
{
435
451
* self
@@ -451,10 +467,11 @@ impl Mstatus {
451
467
}
452
468
/// Update M-mode non-instruction-fetch memory endianness
453
469
///
454
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
455
- /// CSR itself. See [`set_mbe`] to directly update the CSR.
470
+ /// Note this updates a previously read [`Mstatus`] value, but does not
471
+ /// affect the mstatus CSR itself. See [`set_mbe`] to directly update the
472
+ /// CSR.
456
473
#[ inline]
457
- pub fn update_mbe ( & self , endianness : Endianness ) -> Self {
474
+ pub fn set_mbe ( & self , endianness : Endianness ) -> Self {
458
475
#[ cfg( riscv32) ]
459
476
{
460
477
* self
@@ -472,10 +489,10 @@ impl Mstatus {
472
489
/// Update whether either the FS field or XS field signals the presence of
473
490
/// some dirty state
474
491
///
475
- /// Note this updates the [`Mstatus`] value, but does not affect the mstatus
476
- /// CSR itself.
492
+ /// Note this updates a previously read [`Mstatus`] value, but does not
493
+ /// affect the mstatus CSR itself.
477
494
#[ inline]
478
- pub fn update_sd ( & self , sd : bool ) -> Self {
495
+ pub fn set_sd ( & self , sd : bool ) -> Self {
479
496
self . bf_insert ( usize:: BITS as usize - 1 , 1 , sd as usize )
480
497
}
481
498
}
@@ -601,11 +618,11 @@ mod test {
601
618
#[ test]
602
619
fn test_mpp ( ) {
603
620
let mut mstatus = Mstatus { bits : 0 } ;
604
- mstatus = mstatus. update_mpp ( MPP :: User ) ;
621
+ mstatus = mstatus. set_mpp ( MPP :: User ) ;
605
622
assert_eq ! ( mstatus. mpp( ) , MPP :: User ) ;
606
- mstatus = mstatus. update_mpp ( MPP :: Machine ) ;
623
+ mstatus = mstatus. set_mpp ( MPP :: Machine ) ;
607
624
assert_eq ! ( mstatus. mpp( ) , MPP :: Machine ) ;
608
- mstatus = mstatus. update_mpp ( MPP :: Supervisor ) ;
625
+ mstatus = mstatus. set_mpp ( MPP :: Supervisor ) ;
609
626
assert_eq ! ( mstatus. mpp( ) , MPP :: Supervisor ) ;
610
627
}
611
628
}
0 commit comments