Skip to content

Commit aad8f8d

Browse files
committed
mstatus: use update_ for names
And add a clarifying doc comment that this is an operation on Mstatus values, not on the CSR itself.
1 parent c269cbd commit aad8f8d

File tree

1 file changed

+101
-41
lines changed

1 file changed

+101
-41
lines changed

riscv/src/register/mstatus.rs

Lines changed: 101 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ impl Mstatus {
9393
self.bits & (1 << 1) != 0
9494
}
9595

96-
/// Set Supervisor Interrupt Enable
96+
/// Update Supervisor Interrupt Enable
97+
///
98+
/// Note this updates the [`Mstatus`] value, but does not affect the
99+
/// mstatus CSR itself.
97100
#[inline]
98-
pub fn set_sie(&self, sie: bool) -> Self {
101+
pub fn update_sie(&self, sie: bool) -> Self {
99102
self.bf_insert(1, 1, sie as usize)
100103
}
101104

@@ -105,9 +108,12 @@ impl Mstatus {
105108
self.bits & (1 << 3) != 0
106109
}
107110

108-
/// Set Machine Interrupt Enable
111+
/// Update Machine Interrupt Enable
112+
///
113+
/// Note this updates the [`Mstatus`] value, but does not affect the
114+
/// mstatus CSR itself.
109115
#[inline]
110-
pub fn set_mie(&self, mie: bool) -> Self {
116+
pub fn update_mie(&self, mie: bool) -> Self {
111117
self.bf_insert(3, 1, mie as usize)
112118
}
113119

@@ -117,9 +123,12 @@ impl Mstatus {
117123
self.bits & (1 << 5) != 0
118124
}
119125

120-
/// Supervisor Previous Interrupt Enable
126+
/// Updateervisor Previous Interrupt Enable
127+
///
128+
/// Note this updates the [`Mstatus`] value, but does not affect the
129+
/// mstatus CSR itself.
121130
#[inline]
122-
pub fn set_spie(&self, spie: bool) -> Self {
131+
pub fn update_spie(&self, spie: bool) -> Self {
123132
self.bf_insert(5, 1, spie as usize)
124133
}
125134

@@ -129,9 +138,12 @@ impl Mstatus {
129138
Endianness::from(self.bits & (1 << 6) != 0)
130139
}
131140

132-
/// Set U-mode non-instruction-fetch memory endianness
141+
/// Update U-mode non-instruction-fetch memory endianness
142+
///
143+
/// Note this updates the [`Mstatus`] value, but does not affect the
144+
/// mstatus CSR itself.
133145
#[inline]
134-
pub fn set_ube(&self, endianness: Endianness) -> Self {
146+
pub fn update_ube(&self, endianness: Endianness) -> Self {
135147
self.bf_insert(6, 1, endianness as usize)
136148
}
137149

@@ -141,9 +153,12 @@ impl Mstatus {
141153
self.bits & (1 << 7) != 0
142154
}
143155

144-
/// Set Machine Previous Interrupt Enable
156+
/// Update Machine Previous Interrupt Enable
157+
///
158+
/// Note this updates the [`Mstatus`] value, but does not affect the
159+
/// mstatus CSR itself.
145160
#[inline]
146-
pub fn set_mpie(&self, mpie: bool) -> Self {
161+
pub fn update_mpie(&self, mpie: bool) -> Self {
147162
self.bf_insert(7, 1, mpie as usize)
148163
}
149164

@@ -156,9 +171,12 @@ impl Mstatus {
156171
}
157172
}
158173

159-
/// Set Supervisor Previous Privilege Mode
174+
/// Update Supervisor Previous Privilege Mode
175+
///
176+
/// Note this updates the [`Mstatus`] value, but does not affect the
177+
/// mstatus CSR itself.
160178
#[inline]
161-
pub fn set_spp(&self, spp: SPP) -> Self {
179+
pub fn update_spp(&self, spp: SPP) -> Self {
162180
self.bf_insert(8, 1, spp as usize)
163181
}
164182

@@ -174,9 +192,12 @@ impl Mstatus {
174192
}
175193
}
176194

177-
/// Set Machine Previous Privilege Mode
195+
/// Update Machine Previous Privilege Mode
196+
///
197+
/// Note this updates the [`Mstatus`] value, but does not affect the
198+
/// mstatus CSR itself.
178199
#[inline]
179-
pub fn set_mpp(&self, mpp: MPP) -> Self {
200+
pub fn update_mpp(&self, mpp: MPP) -> Self {
180201
self.bf_insert(11, 2, mpp as usize)
181202
}
182203

@@ -196,9 +217,12 @@ impl Mstatus {
196217
}
197218
}
198219

199-
/// Set Floating-point extension state
220+
/// Update Floating-point extension state
221+
///
222+
/// Note this updates the [`Mstatus`] value, but does not affect the
223+
/// mstatus CSR itself.
200224
#[inline]
201-
pub fn set_fs(&self, fs: FS) -> Self {
225+
pub fn update_fs(&self, fs: FS) -> Self {
202226
self.bf_insert(13, 2, fs as usize)
203227
}
204228

@@ -217,9 +241,12 @@ impl Mstatus {
217241
}
218242
}
219243

220-
/// Set Additional extension state
244+
/// Update Additional extension state
245+
///
246+
/// Note this updates the [`Mstatus`] value, but does not affect the
247+
/// mstatus CSR itself.
221248
#[inline]
222-
pub fn set_xs(&self, xs: XS) -> Self {
249+
pub fn update_xs(&self, xs: XS) -> Self {
223250
self.bf_insert(15, 2, xs as usize)
224251
}
225252

@@ -229,9 +256,12 @@ impl Mstatus {
229256
self.bits & (1 << 17) != 0
230257
}
231258

232-
/// Set Modify Memory PRiVilege
259+
/// Update Modify Memory PRiVilege
260+
///
261+
/// Note this updates the [`Mstatus`] value, but does not affect the
262+
/// mstatus CSR itself.
233263
#[inline]
234-
pub fn set_mprv(&self, mprv: bool) -> Self {
264+
pub fn update_mprv(&self, mprv: bool) -> Self {
235265
self.bf_insert(17, 1, mprv as usize)
236266
}
237267

@@ -241,9 +271,12 @@ impl Mstatus {
241271
self.bits & (1 << 18) != 0
242272
}
243273

244-
/// Set Permit Supervisor User Memory access
274+
/// Update Permit Supervisor User Memory access
275+
///
276+
/// Note this updates the [`Mstatus`] value, but does not affect the
277+
/// mstatus CSR itself.
245278
#[inline]
246-
pub fn set_sum(&self, sum: bool) -> Self {
279+
pub fn update_sum(&self, sum: bool) -> Self {
247280
self.bf_insert(18, 1, sum as usize)
248281
}
249282

@@ -253,9 +286,12 @@ impl Mstatus {
253286
self.bits & (1 << 19) != 0
254287
}
255288

256-
/// Set Make eXecutable Readable
289+
/// Update Make eXecutable Readable
290+
///
291+
/// Note this updates the [`Mstatus`] value, but does not affect the
292+
/// mstatus CSR itself.
257293
#[inline]
258-
pub fn set_mxr(&self, mxr: bool) -> Self {
294+
pub fn update_mxr(&self, mxr: bool) -> Self {
259295
self.bf_insert(19, 1, mxr as usize)
260296
}
261297

@@ -270,9 +306,12 @@ impl Mstatus {
270306
self.bits & (1 << 20) != 0
271307
}
272308

273-
/// Set Trap Virtual Memory
309+
/// Update Trap Virtual Memory
310+
///
311+
/// Note this updates the [`Mstatus`] value, but does not affect the
312+
/// mstatus CSR itself.
274313
#[inline]
275-
pub fn set_tvm(&self, tvm: bool) -> Self {
314+
pub fn update_tvm(&self, tvm: bool) -> Self {
276315
self.bf_insert(20, 1, tvm as usize)
277316
}
278317

@@ -290,9 +329,12 @@ impl Mstatus {
290329
self.bits & (1 << 21) != 0
291330
}
292331

293-
/// Set Timeout Wait
332+
/// Update Timeout Wait
333+
///
334+
/// Note this updates the [`Mstatus`] value, but does not affect the
335+
/// mstatus CSR itself.
294336
#[inline]
295-
pub fn set_tw(&self, tw: bool) -> Self {
337+
pub fn update_tw(&self, tw: bool) -> Self {
296338
self.bf_insert(21, 1, tw as usize)
297339
}
298340

@@ -307,9 +349,12 @@ impl Mstatus {
307349
self.bits & (1 << 22) != 0
308350
}
309351

310-
/// Set Trap SRET
352+
/// Update Trap SRET
353+
///
354+
/// Note this updates the [`Mstatus`] value, but does not affect the
355+
/// mstatus CSR itself.
311356
#[inline]
312-
pub fn set_tsr(&self, tsr: bool) -> Self {
357+
pub fn update_tsr(&self, tsr: bool) -> Self {
313358
self.bf_insert(22, 1, tsr as usize)
314359
}
315360

@@ -326,9 +371,12 @@ impl Mstatus {
326371
}
327372
}
328373

329-
/// Set Effective xlen in U-mode (i.e., `UXLEN`).
374+
/// Update Effective xlen in U-mode (i.e., `UXLEN`).
375+
///
376+
/// Note this updates the [`Mstatus`] value, but does not affect the
377+
/// mstatus CSR itself.
330378
#[inline]
331-
pub fn set_uxl(&self, uxl: XLEN) -> Self {
379+
pub fn update_uxl(&self, uxl: XLEN) -> Self {
332380
#[cfg(riscv32)]
333381
{
334382
*self
@@ -350,9 +398,12 @@ impl Mstatus {
350398
}
351399
}
352400

353-
/// Set Effective xlen in S-mode (i.e., `SXLEN`).
401+
/// Update Effective xlen in S-mode (i.e., `SXLEN`).
402+
///
403+
/// Note this updates the [`Mstatus`] value, but does not affect the
404+
/// mstatus CSR itself.
354405
#[inline]
355-
pub fn set_sxl(&self, sxl: XLEN) -> Self {
406+
pub fn update_sxl(&self, sxl: XLEN) -> Self {
356407
#[cfg(riscv32)]
357408
{
358409
*self
@@ -373,9 +424,12 @@ impl Mstatus {
373424
}
374425
}
375426

376-
/// Set S-mode non-instruction-fetch memory endianness
427+
/// Update S-mode non-instruction-fetch memory endianness
428+
///
429+
/// Note this updates the [`Mstatus`] value, but does not affect the
430+
/// mstatus CSR itself.
377431
#[inline]
378-
pub fn set_sbe(&self, endianness: Endianness) -> Self {
432+
pub fn update_sbe(&self, endianness: Endianness) -> Self {
379433
#[cfg(riscv32)]
380434
{
381435
*self
@@ -395,9 +449,12 @@ impl Mstatus {
395449
() => Endianness::from(self.bits & (1 << 37) != 0),
396450
}
397451
}
398-
399-
/// Set M-mode non-instruction-fetch memory endianness
400-
pub fn set_mbe(&self, endianness: Endianness) -> Self {
452+
/// Update M-mode non-instruction-fetch memory endianness
453+
///
454+
/// Note this updates the [`Mstatus`] value, but does not affect the
455+
/// mstatus CSR itself.
456+
#[inline]
457+
pub fn update_mbe(&self, endianness: Endianness) -> Self {
401458
#[cfg(riscv32)]
402459
{
403460
*self
@@ -412,9 +469,12 @@ impl Mstatus {
412469
self.bits & (1 << (usize::BITS as usize - 1)) != 0
413470
}
414471

415-
/// Set whether either the FS field or XS field signals the presence of some dirty state
472+
/// Update whether either the FS field or XS field signals the presence of some dirty state
473+
///
474+
/// Note this updates the [`Mstatus`] value, but does not affect the
475+
/// mstatus CSR itself.
416476
#[inline]
417-
pub fn set_sd(&self, sd: bool) -> Self {
477+
pub fn update_sd(&self, sd: bool) -> Self {
418478
self.bf_insert(usize::BITS as usize - 1, 1, sd as usize)
419479
}
420480
}

0 commit comments

Comments
 (0)