浏览代码

Trap handler override improvments

* 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`
Scott Mabin 3 年之前
父节点
当前提交
daeaf182e2
共有 27 个文件被更改,包括 11 次插入6 次删除
  1. 2 4
      riscv-rt/asm.S
  2. 二进制
      riscv-rt/bin/riscv32i-unknown-none-elf.a
  3. 二进制
      riscv-rt/bin/riscv32ic-unknown-none-elf.a
  4. 二进制
      riscv-rt/bin/riscv32if-unknown-none-elf.a
  5. 二进制
      riscv-rt/bin/riscv32ifc-unknown-none-elf.a
  6. 二进制
      riscv-rt/bin/riscv32ifd-unknown-none-elf.a
  7. 二进制
      riscv-rt/bin/riscv32ifdc-unknown-none-elf.a
  8. 二进制
      riscv-rt/bin/riscv32im-unknown-none-elf.a
  9. 二进制
      riscv-rt/bin/riscv32imc-unknown-none-elf.a
  10. 二进制
      riscv-rt/bin/riscv32imf-unknown-none-elf.a
  11. 二进制
      riscv-rt/bin/riscv32imfc-unknown-none-elf.a
  12. 二进制
      riscv-rt/bin/riscv32imfd-unknown-none-elf.a
  13. 二进制
      riscv-rt/bin/riscv32imfdc-unknown-none-elf.a
  14. 二进制
      riscv-rt/bin/riscv64i-unknown-none-elf.a
  15. 二进制
      riscv-rt/bin/riscv64ic-unknown-none-elf.a
  16. 二进制
      riscv-rt/bin/riscv64if-unknown-none-elf.a
  17. 二进制
      riscv-rt/bin/riscv64ifc-unknown-none-elf.a
  18. 二进制
      riscv-rt/bin/riscv64ifd-unknown-none-elf.a
  19. 二进制
      riscv-rt/bin/riscv64ifdc-unknown-none-elf.a
  20. 二进制
      riscv-rt/bin/riscv64im-unknown-none-elf.a
  21. 二进制
      riscv-rt/bin/riscv64imc-unknown-none-elf.a
  22. 二进制
      riscv-rt/bin/riscv64imf-unknown-none-elf.a
  23. 二进制
      riscv-rt/bin/riscv64imfc-unknown-none-elf.a
  24. 二进制
      riscv-rt/bin/riscv64imfd-unknown-none-elf.a
  25. 二进制
      riscv-rt/bin/riscv64imfdc-unknown-none-elf.a
  26. 6 0
      riscv-rt/link.x
  27. 3 2
      riscv-rt/src/lib.rs

+ 2 - 4
riscv-rt/asm.S

@@ -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)

二进制
riscv-rt/bin/riscv32i-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32ic-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32if-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32ifc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32ifd-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32ifdc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32im-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32imc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32imf-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32imfc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32imfd-unknown-none-elf.a


二进制
riscv-rt/bin/riscv32imfdc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64i-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64ic-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64if-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64ifc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64ifd-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64ifdc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64im-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64imc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64imf-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64imfc-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64imfd-unknown-none-elf.a


二进制
riscv-rt/bin/riscv64imfdc-unknown-none-elf.a


+ 6 - 0
riscv-rt/link.x

@@ -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) :

+ 3 - 2
riscv-rt/src/lib.rs

@@ -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,
@@ -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)]