Skip to content

Commit b5604f7

Browse files
Cleanly rebase the branch
1 parent 451cfec commit b5604f7

File tree

2 files changed

+301
-29
lines changed

2 files changed

+301
-29
lines changed

riscv/CHANGELOG.md

Lines changed: 273 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,276 @@
11
## [Unreleased]
2-
32
- Improved assembly macro handling in asm.rs
3+
- Fixed bug in DCSR register read/write
4+
## [v0.15.0] - 2025-09-08
5+
6+
### Added
7+
8+
- New convenience `try_new` and `new` associated functions for `Mtvec` and `Stvec`.
9+
- New methods and functions for enabling core interrupts in the `mie` and `sie` registers
10+
using the `riscv_pac::CoreInterruptNumber` trait.
11+
- New `riscv::interrupt::{is_interrupt_enabled, disable_interrupt, enable_interrupt}` functions.
12+
- New methods and functions for dealing with pending interrupts in `mip` and `sip` registers
13+
using the `riscv_pac::CoreInterruptNumber` trait.
14+
- New `riscv::interrupt::is_interrupt_pending` function.
15+
- New `riscv::register::xip::clear_pending` atomic function for `mip` and `sip` registers.
16+
This function is marked as `unsafe`, as its availability depends both on the target chip
17+
and the target interrupt source.
18+
- Add `mseccfg` CSR
19+
- Add `mseccfgh` CSR
20+
21+
### Changed
22+
23+
- Use `cfg(any(target_arch = "riscv32", target_arch = "riscv64"))` instead of `cfg(riscv)`.
24+
- `riscv::pac_enum(unsafe CoreInterrupt)` now locates the vector table at the `.trap.vector`
25+
section instead of `.trap`.
26+
- Allow all bits to be set in Mcause::from_bits on 64-bit targets.
27+
28+
### Removed
29+
30+
- Removed custom build script, as `cfg(riscv)` is no longer necessary.
31+
- All the fields of `Mip` and `Sip` CSR proxies are now read-only. This change is motivated
32+
to avoid clearing unwanted interrupts triggered between CSR reads and CSR writes.
33+
34+
## [v0.14.0] - 2025-06-10
35+
36+
### Added
37+
38+
- CSR helper macro `write_composite_csr` for writing 64-bit CSRs on 32-bit targets.
39+
- Write utilities for `mcycle`, `minstret`
40+
- Add `senvcfg` CSR
41+
- Add `scontext` CSR
42+
- Add `mconfigptr` CSR
43+
- Bump MSRV to 1.67.0 for `log` to `ilog` name change
44+
- Add `mtval2` CSR
45+
46+
### Changed
47+
48+
- Simplify `riscv::interrupt::machine::nested`
49+
50+
## [v0.13.0] - 2025-02-18
51+
52+
### Added
53+
54+
- CSR helper macro to check for platform implementation
55+
56+
### Changed
57+
58+
- Make all CSR writes `unsafe` by default (#209)
59+
- Use `RISCV_MTVEC_ALIGN` to control the alignment constraint of the vector table
60+
- Simplify register macros with `cfg` field
61+
- Align assembly functions with `cortex-m`
62+
- Use CSR helper macros to define `marchid` register
63+
- Re-use `try_*` functions in `mcountinhibit`
64+
- Use CSR helper macros to define `mcause` register
65+
- Use CSR helper macros to define `medeleg` register
66+
- Use CSR helper macros to define `mideleg` register
67+
- Use CSR helper macros to define `mcounteren` register
68+
- Use CSR helper macros to define `mie` register
69+
- Use CSR helper macros to define `mimpid` register
70+
- Use CSR helper macros to define `misa` register
71+
- Use CSR helper macros to define `mip` register
72+
- Use CSR helper macros to define `mstatus` register
73+
- Use CSR helper macros to define `mstatush` register
74+
- Use CSR helper macros to define `mtvec` register
75+
- Use CSR helper macros to define `mtvendorid` register
76+
- Use CSR helper macros to define `satp` register
77+
- Use CSR helper macros to define `pmpcfgx` field types
78+
- Use CSR helper macros to define `scause` field types
79+
- Use CSR helper macros to define `sie` register
80+
- Use CSR helper macros to define `scounteren` field types
81+
- Use CSR helper macros to define `sip` register
82+
- Use CSR helper macros to define `sstatus` field types
83+
- Use CSR helper macros to define `stvec` field types
84+
- Add remaining `pmpcfg` CSRs from RISC-V privileged spec
85+
86+
## [v0.12.1] - 2024-10-20
87+
88+
### Changed
89+
90+
- Update critical-section to 1.2.0
91+
92+
## [v0.12.0] - 2024-10-19
93+
94+
### Added
95+
96+
- `riscv-macros` crate for `riscv-pac` enums.
97+
- Bump MSRV to 1.61.
98+
- Implementation of `riscv-pac` traits for `Interrupt` and `Exception` enums.
99+
- Tests for the `riscv-pac` trait implementations of `Interrupt` and `Exception` enums.
100+
- Add `Mcause::from(usize)` for use in unit tests
101+
- Add `Mstatus::from(usize)` for use in unit tests
102+
- Add `Mstatus.bits()`
103+
- Add `Eq` and `PartialEq` for `pmpcfgx::{Range, Permission}`
104+
- Add `Mstatus::update_*` helpers to manipulate Mstatus values without touching
105+
the CSR
106+
- Export `riscv::register::macros` module macros for external use
107+
- Add `riscv::register::mcountinhibit` module for `mcountinhibit` CSR
108+
- Add `Mcounteren` in-memory update functions
109+
- Add `Mstatus` vector extension support
110+
- Add fallible counterparts to all functions that `panic`
111+
- Add `riscv-pac` as a dependency
112+
- Add CSR-defining macros to create in-memory types
113+
114+
### Fixed
115+
116+
- Fixed `sip::set_ssoft` and `sip::clear_ssoft` using wrong address
117+
- Fixed assignment in `mstatus` unit tests.
118+
- delay implementation does not use binary labels in inline assembly.
119+
120+
## [v0.11.1] - 2024-02-15
121+
122+
### Changed
123+
124+
- Made `asm::wfi`, `fence`, `fence_i` and `sfence` safe (ie, removed `unsafe` from their definitions)
125+
- Made `cfg` variable selection more robust for custom targets
126+
127+
## [v0.11.0] - 2024-01-14
128+
129+
### Added
130+
131+
- Add `asm::ecall()`, a wrapper for implementing an `ecall` instruction
132+
- Add `nested` function for nested ISRs in `interrupt::machine` and `interrupt::supervisor`
133+
- `s-mode` feature for reexporting `interrupt::machine` or `interrupt::supervisor` to `interrupt`
134+
- Support for supervisor-level interrupts in `interrupt::supervisor`
135+
- Add CI workflow to check that CHANGELOG.md file has been modified in PRs
136+
- Add `read_csr_as_rv32`, `set_rv32`, and `clear_rv32` macros
137+
- Add `mstatus::uxl` and `mstatus::sxl`
138+
- Add `mstatus::ube`, `mstatus::sbe`, and `mstatus::mbe` endianness bit fields
139+
- Add `mstatush` registers (RISCV-32 only)
140+
- Add `asm::fence()`, a wrapper for implementing a `fence` instruction
141+
- Add `asm::fence_i()`, a wrapper for implementing a `fence.i` instruction
142+
- Add `TryFrom` implementation for `mcause::{Interrupt, Exception}` and `scause::{Interrupt, Exception}`
143+
144+
### Changed
145+
146+
- Cargo workspace for riscv and riscv-rt
147+
- Update `embedded-hal` dependency to v1.0.0 (bumps MSRV to 1.60)
148+
- `misa::MXL` renamed to `misa::XLEN`
149+
- Removed `bit_field` dependency
150+
- CI actions updated. They now use `checkout@v3` and `dtolnay/rust-toolchain`.
151+
- `mcause::{Interrupt, Exception}` and `scause::{Interrupt, Exception}` now implement `From` trait for `usize`
152+
- Set safety of `asm::nop` and `asm::delay` functions to safe.
153+
154+
### Fixed
155+
156+
- Fix `scause::Exception` missing `LoadMisaligned`
157+
- Fix `scause::Exception` missing `SupervisorEnvCall`
158+
- Removed user-level interrupts from `mcause::Interrupt` and `scause::Interrupt`
159+
- Removed user-level interrupts from `mstatus`
160+
- Removed machine environment call delegation from `medeleg`
161+
- Removed user-level interrupts from machine and supervisor mode interrupt-related registers.
162+
163+
### Removed
164+
165+
- User mode registers removed, as they are no longer supported in RISC-V
166+
- FCSR register operations removed to avoid UB (#148)
167+
168+
## [v0.10.1] - 2023-01-18
169+
170+
### Fixed
171+
172+
- Fix implementation for `SingleHartCriticalSection`
173+
174+
## [v0.10.0] - 2022-11-09
175+
176+
### Added
177+
178+
- `critical-section-single-hart` feature which provides an implementation for the `critical_section` crate for single-hart systems, based on disabling all interrupts.
179+
180+
## [v0.9.0] - 2022-10-06
181+
182+
### Fixed
183+
184+
- Fix `asm::delay()` to ensure count register is always reloaded
185+
- Fix reading marchid and mimpid (#107)
186+
187+
### Removed
188+
- `set_msoft`, `clear_msoft`, `set_mtimer` and `clear_mtimer` removed as part of fixing issue #62
189+
190+
## [v0.8.0] - 2022-04-20
191+
192+
### Added
193+
194+
- Add `#[cfg(riscv32)]` to `pmpcfg1` and `pmpcfg3` modules
195+
- Add enums `Range`, `Permission` for PMP configuration
196+
- Add `set_pmp()` and `clear_pmp()` functions to pmpcfg(x) modules
197+
- Add struct `Pmpcsr` and is returned from `pmpcfgx::read()`
198+
- Add `singleton!` macro
199+
- Add delay structure and methods using embedded-hal traits and `mcycle` register
200+
- Add `asm::delay()` function for assembly-based busy-loops
201+
- Add `asm::nop()`, a wrapper for implementing a `nop` instruction
202+
- Add missing `#[inline]` attribute to register reads, type conversations and `interrupt::free`
203+
204+
### Changed
205+
206+
- Use new `asm!` instead of `llvm_asm!`
207+
- Change `pmpcfgx::read()` macro to `read_csr_as!()` from `read_csr_as_usize!()`
208+
- Inline assembly is now always used
209+
- Update Minimum Supported Rust Version to 1.59
210+
211+
### Fixed
212+
213+
- Fix `sfence.vma` operand order
214+
215+
### Removed
216+
217+
- Remove `inline-asm` feature which is now always enabled
218+
219+
## [v0.7.0] - 2021-07-29
220+
221+
### Added
222+
223+
- Add `medeleg` register
224+
- Add `cycle[h]`, `instret[h]` and `mcounteren`
225+
- Add additional binaries for floating-point ABIs
226+
- Add support for `mxr`
227+
- Add support for `mprv`
228+
229+
### Changed
230+
231+
- Fix `scause::set`
232+
- Various formatting and comment fixes
233+
- Update `bare-metal` to `v1.0.0` removing `Nr` trait
234+
- Build targets on `docs.rs` are now RISC-V targets other than default ones
235+
236+
## [v0.6.0] - 2020-06-20
237+
238+
### Changed
239+
240+
- `Mtvec::trap_mode()`, `Stvec::trap_mode()` and `Utvec::trap_mode()` functions now return `Option<TrapMode>` (breaking change)
241+
- Updated Minimum Supported Rust Version to 1.42.0
242+
- Use `llvm_asm!` instead of `asm!`
243+
244+
### Removed
245+
246+
- vexriscv-specific registers were moved to the `vexriscv` crate
247+
248+
## [v0.5.6] - 2020-03-14
249+
250+
### Added
251+
252+
- Added vexriscv-specific registers
253+
254+
## [v0.5.5] - 2020-02-28
255+
256+
### Added
257+
258+
- Added `riscv32i-unknown-none-elf` target support
259+
- Added user trap setup and handling registers
260+
- Added write methods for the `mip` and `satp` registers
261+
- Added `mideleg` register
262+
- Added Changelog
263+
264+
### Changed
265+
266+
- Fixed MSRV by restricting the upper bound of `bare-metal` version
4267

268+
[Unreleased]: https://github.com/rust-embedded/riscv/compare/v0.10.1...HEAD
269+
[v0.10.1]: https://github.com/rust-embedded/riscv/compare/v0.10.0...v0.10.1
270+
[v0.10.0]: https://github.com/rust-embedded/riscv/compare/v0.9.0...v0.10.0
271+
[v0.9.0]: https://github.com/rust-embedded/riscv/compare/v0.8.0...v0.9.0
272+
[v0.8.0]: https://github.com/rust-embedded/riscv/compare/v0.7.0...v0.8.0
273+
[v0.7.0]: https://github.com/rust-embedded/riscv/compare/v0.6.0...v0.7.0
274+
[v0.6.0]: https://github.com/rust-embedded/riscv/compare/v0.5.6...v0.6.0
275+
[v0.5.6]: https://github.com/rust-embedded/riscv/compare/v0.5.5...v0.5.6
276+
[v0.5.5]: https://github.com/rust-embedded/riscv/compare/v0.5.4...v0.5.5

riscv/src/asm.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ instruction!(
3535

3636
instruction!(
3737
/// `WFI` instruction wrapper
38-
///
39-
/// Provides a hint to the implementation that the current hart can be stalled until an
40-
/// interrupt might need servicing. The WFI instruction is just a hint, and a legal
41-
/// implementation is to implement WFI as a NOP.
42-
///
43-
/// # Behavior
44-
///
45-
/// - May cause the hart to enter a low-power state
46-
/// - Will be interrupted by any enabled interrupt
47-
/// - No guarantee of actual power savings (implementation-dependent)
48-
,wfi, "wfi", options(nomem, nostack, preserves_flags));
38+
///
39+
/// Provides a hint to the implementation that the current hart can be stalled until an
40+
/// interrupt might need servicing. The WFI instruction is just a hint, and a legal
41+
/// implementation is to implement WFI as a NOP.
42+
///
43+
/// # Behavior
44+
///
45+
/// - May cause the hart to enter a low-power state
46+
/// - Will be interrupted by any enabled interrupt
47+
/// - No guarantee of actual power savings (implementation-dependent)
48+
,wfi, "wfi", options(nomem, nostack, preserves_flags));
4949

5050
instruction!(
5151
/// `EBREAK` instruction wrapper
@@ -66,23 +66,23 @@ instruction!(
6666

6767
instruction!(
6868
/// `ECALL` instruction wrapper
69-
///
70-
/// Generates an environment call exception for system services.
71-
///
72-
/// # Behavior
73-
///
74-
/// When executed in different privilege modes:
75-
/// - U-mode: Generates environment-call-from-U-mode exception
76-
/// - S-mode: Generates environment-call-from-S-mode exception
77-
/// - M-mode: Generates environment-call-from-M-mode exception
78-
///
79-
/// # Safety
80-
///
81-
/// This function is unsafe because:
82-
/// - It unconditionally generates an exception
83-
/// - The stack pointer is **NOT** automatically saved/restored
84-
/// - The exception handler is responsible for proper context management
85-
/// - Improper use can crash the system
69+
///
70+
/// Generates an environment call exception for system services.
71+
///
72+
/// # Behavior
73+
///
74+
/// When executed in different privilege modes:
75+
/// - U-mode: Generates environment-call-from-U-mode exception
76+
/// - S-mode: Generates environment-call-from-S-mode exception
77+
/// - M-mode: Generates environment-call-from-M-mode exception
78+
///
79+
/// # Safety
80+
///
81+
/// This function is unsafe because:
82+
/// - It unconditionally generates an exception
83+
/// - The stack pointer is **NOT** automatically saved/restored
84+
/// - The exception handler is responsible for proper context management
85+
/// - Improper use can crash the system
8686
, unsafe ecall, "ecall", options(nomem, nostack, preserves_flags));
8787

8888
instruction!(

0 commit comments

Comments
 (0)