Skip to content

Commit

Permalink
feat?(riscv): force inline (some) isr callees
Browse files Browse the repository at this point in the history
This change gets a fair bit less clear; removing `#[ram]` from
`handle_interrupt` does indeed change the resulting binary (because it's
implicitly removing `#[inline(never)]`, but `get_core` is so small a
function LLVM will always inline it at all the optimization levels I've
tried, whether it's marked `#[inline]` or not.

So rather than a specific solution to an actual problem, this patch is
more of an example and a warning for what's to come: lacking a precise
mechanism to trace and identify properties of all callees along a
particular path, everything from here on out is highly dependent on
relatively distant effects: in attempting to assert whether "the trap
handling flow is entirely located in SRAM" we necessarily have to
qualify the answer with "given these optimization settings" (and, soon,
much worse).

If correcteness here is "not touching flash," then, in the usual
language of Rust, we're about to leave attempts at demonstrating
soundness behind. Instead, we now shift our focus to showing safety
under a particular set of (somewhat fragile) circumstances.
  • Loading branch information
sethp committed May 14, 2023
1 parent e29f3d5 commit 34fc2fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion esp-hal-common/src/interrupt/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ mod vectored {
}
}

#[ram]
#[inline(always)]
unsafe fn handle_interrupt(interrupt: Interrupt, save_frame: &mut TrapFrame) {
extern "C" {
// defined in each hal
Expand Down
1 change: 1 addition & 0 deletions esp-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub enum Cpu {
AppCpu,
}

#[inline(always)]
pub fn get_core() -> Cpu {
#[cfg(all(xtensa, multi_core))]
match ((xtensa_lx::get_processor_id() >> 13) & 1) != 0 {
Expand Down

0 comments on commit 34fc2fb

Please sign in to comment.