Skip to content

Commit

Permalink
Merge #81
Browse files Browse the repository at this point in the history
81: Trap handler override improvments r=almindor a=MabezDev

* Add ability to override trap handling mechanism
  * Previously, `_start_trap` was marked as weak, which when compiled
    into a static archive, that information is ignored.
  * Now by default we `PROVIDE` the default trap handler, if another one
    has not been specified from another crate.
* Mark the fields of `Vector` public, for use outside of `riscv-rt`

Co-authored-by: Scott Mabin <[email protected]>
  • Loading branch information
bors[bot] and MabezDev authored Nov 10, 2021
2 parents 629737e + daeaf18 commit 5137b0a
Show file tree
Hide file tree
Showing 27 changed files with 11 additions and 6 deletions.
6 changes: 2 additions & 4 deletions riscv-rt/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ _abs_start:
restores caller saved registers and then returns.
*/
.section .trap, "ax"
.global _start_trap
/* Make it .weak so PAC/HAL can provide their own if needed. */
.weak _start_trap
.global default_start_trap

_start_trap:
default_start_trap:
addi sp, sp, -16*REGBYTES

STORE ra, 0*REGBYTES(sp)
Expand Down
Binary file modified riscv-rt/bin/riscv32i-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32ic-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32if-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32ifc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32ifd-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32ifdc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32im-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32imc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32imf-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32imfc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32imfd-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv32imfdc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64i-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64ic-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64if-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64ifc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64ifd-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64ifdc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64im-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64imc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64imf-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64imfc-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64imfd-unknown-none-elf.a
Binary file not shown.
Binary file modified riscv-rt/bin/riscv64imfdc-unknown-none-elf.a
Binary file not shown.
6 changes: 6 additions & 0 deletions riscv-rt/link.x
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ PROVIDE(_setup_interrupts = default_setup_interrupts);
*/
PROVIDE(_mp_hook = default_mp_hook);

/* # Start trap function override
By default uses the riscv crates default trap handler
but by providing the `_start_trap` symbol external crates can override.
*/
PROVIDE(_start_trap = default_start_trap);

SECTIONS
{
.text.dummy (NOLOAD) :
Expand Down
5 changes: 3 additions & 2 deletions riscv-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ pub unsafe extern "C" fn start_rust() -> ! {
/// Registers saved in trap handler
#[allow(missing_docs)]
#[repr(C)]
#[derive(Debug)]
pub struct TrapFrame {
pub ra: usize,
pub t0: usize,
Expand Down Expand Up @@ -496,8 +497,8 @@ extern "C" {

#[doc(hidden)]
pub union Vector {
handler: unsafe extern "C" fn(),
reserved: usize,
pub handler: unsafe extern "C" fn(),
pub reserved: usize,
}

#[doc(hidden)]
Expand Down

0 comments on commit 5137b0a

Please sign in to comment.