Skip to content

Commit 0853501

Browse files
Merge pull request #395 from romancardenas/custom-traps
`riscv-rt`: rename `no-interrupts` and `no-exceptions` to `custom-interrupts` and `custom-exceptions`
2 parents 8b66000 + d608a98 commit 0853501

13 files changed

Lines changed: 61 additions & 33 deletions

File tree

.github/workflows/clippy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
- name: Run clippy (no features)
4242
run: cargo clippy --all --no-default-features -- -D warnings
4343
- name: Run clippy (all features)
44-
# We exclude riscv-peripheral because it's not yet stable-compliant (added -A deprecated for pre_init macro)
45-
run: cargo clippy --exclude riscv-peripheral --all --all-features -- -D warnings -A deprecated
44+
# Added -A deprecated for pre_init macro and no-interrupts and no-exceptions features
45+
run: cargo clippy --all --all-features -- -D warnings -A deprecated
4646

4747
# Additonal clippy checks for riscv-rt
4848
clippy-riscv-rt:

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ jobs:
6666
run: RUSTFLAGS="-C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features device,memory
6767

6868
- name: Build (custom interrupts and exceptions)
69-
run: RUSTFLAGS="-C link-arg=-Tdevice.x -C link-arg=-Tmemory.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features no-interrupts,no-exceptions
69+
run: RUSTFLAGS="-C link-arg=-Tdevice.x -C link-arg=-Tmemory.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features custom-interrupts,custom-exceptions
7070
- name: Build (custom interrupts and exceptions, include device.x)
71-
run: RUSTFLAGS="-C link-arg=-Tmemory.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features no-interrupts,no-exceptions,device
71+
run: RUSTFLAGS="-C link-arg=-Tmemory.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features custom-interrupts,custom-exceptions,device
7272
- name: Build (custom interrupts and exceptions, include memory.x)
73-
run: RUSTFLAGS="-C link-arg=-Tdevice.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features no-interrupts,no-exceptions,memory
73+
run: RUSTFLAGS="-C link-arg=-Tdevice.x -C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features custom-interrupts,custom-exceptions,memory
7474
- name: Build (custom interrupts and exceptions, include device.x and memory.x)
75-
run: RUSTFLAGS="-C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features no-interrupts,no-exceptions,device,memory
75+
run: RUSTFLAGS="-C link-arg=-Tlink.x" cargo build --package tests-build --target ${{ matrix.target }} --example ${{ matrix.example }} --features custom-interrupts,custom-exceptions,device,memory
7676

7777
# Job to check that all the builds succeeded
7878
tests-check:

riscv-rt/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515

1616
### Changed
1717

18+
- Deprecate `no-interrupts` feature in favor of `custom-interrupts`
19+
- Deprecate `no-exceptions` feature in favor of `custom-exceptions`
1820
- `_setup_interrupts` can now optionally receive an `usize` input argument
1921
with the ID of the running hart. This allows users to implement hart-specific
2022
interrupt setup in multi-hart targets.

riscv-rt/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ riscv = { path = "../riscv", version = "0.16.0", features = ["critical-section-s
3939
pre-init = []
4040
post-init = []
4141
custom-setup-interrupts = []
42+
custom-interrupts = []
43+
custom-exceptions = []
4244
s-mode = ["riscv-macros/s-mode"]
4345
single-hart = []
4446
v-trap = ["riscv/rt-v-trap", "riscv-macros/rt-v-trap"]
4547
u-boot = ["riscv-macros/rvrt-u-boot", "single-hart"]
46-
no-interrupts = []
47-
no-exceptions = []
48+
no-interrupts = ["custom-interrupts"] # deprecated, use `custom-interrupts` instead
49+
no-exceptions = ["custom-exceptions"] # deprecated, use `custom-exceptions` instead
4850
no-mhartid = ["single-hart"]
4951
no-xie-xip = []
5052
no-xtvec = []

riscv-rt/build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ fn add_linker_script(arch_width: u32) -> io::Result<()> {
1414
// Get target-dependent linker configuration and replace ${INCLUDE_LINKER_FILES} with it
1515
let mut include_content = String::new();
1616

17-
// If no-exceptions is disabled, include the exceptions.x files
18-
if env::var_os("CARGO_FEATURE_NO_EXCEPTIONS").is_none() {
17+
// If custom-exceptions is disabled, include the exceptions.x files
18+
if env::var_os("CARGO_FEATURE_CUSTOM_EXCEPTIONS").is_none() {
1919
let exceptions_content = fs::read_to_string("exceptions.x")?;
2020
include_content.push_str(&(exceptions_content + "\n"));
2121
}
22-
// If no-interrupts is disabled, include the interrupts.x files
23-
if env::var_os("CARGO_FEATURE_NO_INTERRUPTS").is_none() {
22+
// If custom-interrupts is disabled, include the interrupts.x files
23+
if env::var_os("CARGO_FEATURE_CUSTOM_INTERRUPTS").is_none() {
2424
let interrupts_content = fs::read_to_string("interrupts.x")?;
2525
include_content.push_str(&(interrupts_content + "\n"));
2626
}
@@ -74,10 +74,10 @@ fn main() {
7474
println!("cargo:rerun-if-env-changed=RISCV_RT_BASE_ISA");
7575
println!("cargo:rerun-if-env-changed=RISCV_RT_LLVM_ARCH_PATCH");
7676
if env::var_os("CARGO_FEATURE_V_TRAP").is_some()
77-
&& env::var_os("CARGO_FEATURE_NO_INTERRUPTS").is_none()
77+
&& env::var_os("CARGO_FEATURE_CUSTOM_INTERRUPTS").is_none()
7878
{
7979
// This environment variable is used by the `#[riscv::pac_enum()]` call in
80-
// `src/interrupts.rs` (when `v-trap` is enabled and `no-interrupts` disabled).
80+
// `src/interrupts.rs` (when `v-trap` is enabled and `custom-interrupts` disabled).
8181
println!("cargo:rerun-if-env-changed=RISCV_MTVEC_ALIGN");
8282
}
8383

riscv-rt/exceptions.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* # EXCEPTION HANDLERS DESCRIBED IN THE STANDARD RISC-V ISA
22
3-
If the `no-exceptions` feature is DISABLED, this file will be included in link.x.in.
4-
If the `no-exceptions` feature is ENABLED, this file will be ignored.
3+
If the `custom-exceptions` feature is DISABLED, this file will be included in link.x.in.
4+
If the `custom-exceptions` feature is ENABLED, this file will be ignored.
55
*/
66

77
/* It is possible to define a special handler for each exception type.

riscv-rt/interrupts.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* # CORE INTERRUPT HANDLERS DESCRIBED IN THE STANDARD RISC-V ISA
22
3-
If the `no-interrupts` feature is DISABLED, this file will be included in link.x.in.
4-
If the `no-interrupts` feature is ENABLED, this file will be ignored.
3+
If the `custom-interrupts` feature is DISABLED, this file will be included in link.x.in.
4+
If the `custom-interrupts` feature is ENABLED, this file will be ignored.
55
*/
66

77
/* It is possible to define a special handler for each interrupt type.

riscv-rt/src/exceptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! If your target has custom exception sources, the target PAC might provide equivalent
1111
//! code to adapt for the target needs. In this case, you may need to opt out this module.
12-
//! To do so, activate the `no-exceptions` feature of the `riscv-rt` crate.
12+
//! To do so, activate the `custom-exceptions` feature of the `riscv-rt` crate.
1313
1414
use crate::TrapFrame;
1515

riscv-rt/src/interrupts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! If your target has custom core interrupt sources, the target PAC might provide equivalent code
1616
//! to adapt for the target needs (and is responsible for any alignment constraint). In this case,
17-
//! you may need to opt out this module. To do so, activate the `no-interrupts` feature of the
17+
//! you may need to opt out this module. To do so, activate the `custom-interrupts` feature of the
1818
//! `riscv-rt` crate.
1919
2020
#[riscv::pac_enum(unsafe CoreInterruptNumber)]

riscv-rt/src/lib.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,12 @@
582582
//!
583583
//! Skips disabling interrupts (to support chips without XIE/XIP CSRs).
584584
//!
585-
//! ## `no-interrupts`
585+
//! ## `custom-interrupts`
586586
//!
587587
//! Opts out of the default implementation for `_dispatch_core_interrupt` to support platforms
588588
//! with custom core interrupt sources.
589589
//!
590-
//! ## `no-exceptions`
590+
//! ## `custom-exceptions`
591591
//!
592592
//! Opts out of the default implementation for `_dispatch_exception` to support platforms
593593
//! with custom exception sources.
@@ -683,13 +683,37 @@
683683
#![no_std]
684684
#![deny(missing_docs)]
685685

686+
/// Backwards-compatibility deprecation warnings for renamed feature `no-interrupts`.
687+
/// If a user enables the old feature, emit a warning pointing them to the new `custom-interrupts`.
688+
#[cfg(feature = "no-interrupts")]
689+
#[deprecated(note = "feature `no-interrupts` is deprecated; use `custom-interrupts` instead")]
690+
pub const __RISCV_RT_DEPRECATED_NO_INTERRUPTS: () = ();
691+
692+
#[cfg(feature = "no-interrupts")]
693+
#[allow(clippy::let_unit_value)]
694+
const _: () = {
695+
let _ = __RISCV_RT_DEPRECATED_NO_INTERRUPTS;
696+
};
697+
698+
/// Backwards-compatibility deprecation warnings for renamed feature `no-exceptions`.
699+
/// If a user enables the old feature, emit a warning pointing them to the new `custom-exceptions`.
700+
#[cfg(feature = "no-exceptions")]
701+
#[deprecated(note = "feature `no-exceptions` is deprecated; use `custom-exceptions` instead")]
702+
pub const __RISCV_RT_DEPRECATED_NO_EXCEPTIONS: () = ();
703+
704+
#[cfg(feature = "no-exceptions")]
705+
#[allow(clippy::let_unit_value)]
706+
const _: () = {
707+
let _ = __RISCV_RT_DEPRECATED_NO_EXCEPTIONS;
708+
};
709+
686710
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
687711
mod asm;
688712

689-
#[cfg(not(feature = "no-exceptions"))]
713+
#[cfg(not(feature = "custom-exceptions"))]
690714
pub mod exceptions;
691715

692-
#[cfg(not(feature = "no-interrupts"))]
716+
#[cfg(not(feature = "custom-interrupts"))]
693717
pub mod interrupts;
694718

695719
#[cfg(feature = "s-mode")]
@@ -838,13 +862,13 @@ pub struct TrapFrame {
838862
/// Targets that comply with the RISC-V standard can use the implementation provided
839863
/// by this crate in the [`exceptions`] module. Targets with special exception sources
840864
/// may provide their custom implementation of the `_dispatch_exception` function. You may
841-
/// also need to enable the `no-exceptions` feature to op-out the default implementation.
865+
/// also need to enable the `custom-exceptions` feature to op-out the default implementation.
842866
///
843867
/// In direct mode (i.e., `v-trap` feature disabled), interrupt dispatching is performed
844868
/// by an extern `_dispatch_core_interrupt` function. Targets that comply with the RISC-V
845869
/// standard can use the implementation provided by this crate in the [`interrupts`] module.
846870
/// Targets with special interrupt sources may provide their custom implementation of the
847-
/// `_dispatch_core_interrupt` function. You may also need to enable the `no-interrupts`
871+
/// `_dispatch_core_interrupt` function. You may also need to enable the `custom-interrupts`
848872
/// feature to op-out the default implementation.
849873
///
850874
/// In vectored mode (i.e., `v-trap` feature enabled), interrupt dispatching is performed

0 commit comments

Comments
 (0)