Skip to content

Commit

Permalink
add global label to traps
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Apr 12, 2024
1 parent 245179f commit 52d5185
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions riscv-rt/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,18 @@ fn interrupt(args: TokenStream, input: TokenStream, _arch: RiscvArch) -> TokenSt
}

// XXX should we blacklist other attributes?
let attrs = f.attrs;
let ident = f.sig.ident;
let ident = &f.sig.ident;
let export_name = format!("{:#}", ident);
let block = f.block;

#[cfg(not(feature = "v-trap"))]
let start_trap = proc_macro2::TokenStream::new();
#[cfg(feature = "v-trap")]
let start_trap = v_trap::start_interrupt_trap_asm(&ident, _arch);
let start_trap = v_trap::start_interrupt_trap_asm(ident, _arch);

quote!(
#start_trap
#[export_name = #export_name]
#(#attrs)*
pub unsafe fn #ident() #block
#f
)
.into()
}
Expand Down Expand Up @@ -443,6 +440,7 @@ mod v_trap {
core::arch::global_asm!(
\".section .trap, \\\"ax\\\"
.align {width}
.global _start_{function}_trap
_start_{function}_trap:
addi sp, sp, - {TRAP_SIZE} * {width}
{store}
Expand Down

0 comments on commit 52d5185

Please sign in to comment.