Skip to content

Commit e6df749

Browse files
Merge branch 'master' into riscv-pac
2 parents fc4f314 + 9d3fb05 commit e6df749

File tree

7 files changed

+48
-7
lines changed

7 files changed

+48
-7
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ If `v-trap` feature is enabled, this macro also generates its corresponding trap
2222
- Made `cfg` variable selection more robust for custom targets
2323
- `_start_trap_rust` now only deals with exceptions. When an interrupt is detected, it now calls
2424
to `_dispatch_core_interrupt`.
25+
- Upgrade rust-version to 1.61
26+
- Update `syn` to version 2.0
2527

2628
### Removed
2729

riscv-rt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "riscv-rt"
33
version = "0.13.0"
4-
rust-version = "1.60"
4+
rust-version = "1.61"
55
repository = "https://github.com/rust-embedded/riscv"
66
authors = ["The RISC-V Team <risc-v@teams.rust-embedded.org>"]
77
categories = ["embedded", "no-std"]

riscv-rt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project is developed and maintained by the [RISC-V team][team].
1111

1212
## Minimum Supported Rust Version (MSRV)
1313

14-
This crate is guaranteed to compile on stable Rust 1.60 and up. It *might*
14+
This crate is guaranteed to compile on stable Rust 1.61 and up. It *might*
1515
compile with older versions but that may change in any new patch release.
1616

1717
## License

riscv-rt/macros/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ proc-macro = true
1919
[dependencies]
2020
quote = "1.0"
2121
proc-macro2 = "1.0"
22-
23-
[dependencies.syn]
24-
version = "1.0"
25-
features = ["extra-traits", "full"]
22+
syn = { version = "2.0", features = ["extra-traits", "full"] }
2623

2724
[features]
2825
s-mode = []

riscv-rt/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! # Minimum Supported Rust Version (MSRV)
44
//!
5-
//! This crate is guaranteed to compile on stable Rust 1.60 and up. It *might*
5+
//! This crate is guaranteed to compile on stable Rust 1.61 and up. It *might*
66
//! compile with older versions but that may change in any new patch release.
77
//!
88
//! # Features

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2121
- Export `riscv::register::macros` module macros for external use
2222
- Add `riscv::register::mcountinhibit` module for `mcountinhibit` CSR
2323
- Add `Mcounteren` in-memory update functions
24+
- Add `Mstatus` vector extension support
2425

2526
### Changed
2627

riscv/src/register/mstatus.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ pub enum FS {
4141
Dirty = 3,
4242
}
4343

44+
/// Vector extension state
45+
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
46+
pub enum VS {
47+
Off = 0,
48+
Initial = 1,
49+
Clean = 2,
50+
Dirty = 3,
51+
}
52+
4453
/// Machine Previous Privilege Mode
4554
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
4655
pub enum MPP {
@@ -216,6 +225,19 @@ impl Mstatus {
216225
}
217226
}
218227

228+
/// Vector extension state
229+
#[inline]
230+
pub fn vs(&self) -> VS {
231+
let fs = bf_extract(self.bits, 9, 2); // bits 9-10
232+
match fs {
233+
0b00 => VS::Off,
234+
0b01 => VS::Initial,
235+
0b10 => VS::Clean,
236+
0b11 => VS::Dirty,
237+
_ => unreachable!(),
238+
}
239+
}
240+
219241
/// Update Floating-point extension state
220242
///
221243
/// Note this updates a previously read [`Mstatus`] value, but does not
@@ -226,6 +248,16 @@ impl Mstatus {
226248
self.bits = bf_insert(self.bits, 13, 2, fs as usize);
227249
}
228250

251+
/// Update vector extension state
252+
///
253+
/// Note this updates a previously read [`Mstatus`] value, but does not
254+
/// affect the mstatus CSR itself. See [`set_vs`] to directly update the
255+
/// CSR.
256+
#[inline]
257+
pub fn set_vs(&mut self, vs: VS) {
258+
self.bits = bf_insert(self.bits, 9, 2, vs as usize);
259+
}
260+
229261
/// Additional extension state
230262
///
231263
/// Encodes the status of additional user-mode extensions and associated
@@ -559,6 +591,15 @@ pub unsafe fn set_fs(fs: FS) {
559591
_write(value);
560592
}
561593

594+
/// Vector extension state
595+
#[inline]
596+
pub unsafe fn set_vs(vs: VS) {
597+
let mut value = _read();
598+
value &= !(0x3 << 9); // clear previous value
599+
value |= (vs as usize) << 9;
600+
_write(value);
601+
}
602+
562603
/// Set S-mode non-instruction-fetch memory endianness
563604
///
564605
/// # Note

0 commit comments

Comments
 (0)