|
@@ -164,10 +164,8 @@
|
|
|
#![no_std]
|
|
|
#![deny(missing_docs)]
|
|
|
#![deny(warnings)]
|
|
|
-#![feature(asm)]
|
|
|
#![feature(compiler_builtins_lib)]
|
|
|
#![feature(const_fn)]
|
|
|
-#![feature(global_asm)]
|
|
|
#![feature(linkage)]
|
|
|
|
|
|
extern crate riscv;
|
|
@@ -192,36 +190,6 @@ extern "C" {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/// Entry point of all programs (_start).
|
|
|
-///
|
|
|
-/// It initializes DWARF call frame information, the stack pointer, the
|
|
|
-/// frame pointer (needed for closures to work in start_rust) and the global
|
|
|
-/// pointer. Then it calls _start_rust.
|
|
|
-#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
|
|
|
-global_asm!(r#"
|
|
|
-.section .init, "ax"
|
|
|
-.globl _start
|
|
|
-_start:
|
|
|
- .cfi_startproc
|
|
|
- .cfi_undefined ra
|
|
|
-
|
|
|
- // .option push
|
|
|
- // .option norelax
|
|
|
- lui gp, %hi(__global_pointer$)
|
|
|
- addi gp, gp, %lo(__global_pointer$)
|
|
|
- // .option pop
|
|
|
-
|
|
|
- lui sp, %hi(_stack_start)
|
|
|
- addi sp, sp, %lo(_stack_start)
|
|
|
-
|
|
|
- add s0, sp, zero
|
|
|
-
|
|
|
- jal zero, _start_rust
|
|
|
-
|
|
|
- .cfi_endproc
|
|
|
-"#);
|
|
|
-
|
|
|
-
|
|
|
/// Rust entry point (_start_rust)
|
|
|
///
|
|
|
/// Zeros bss section, initializes data section and calls main. This function
|
|
@@ -275,60 +243,6 @@ macro_rules! entry {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/// Trap entry point (_start_trap)
|
|
|
-///
|
|
|
-/// Saves caller saved registers ra, t0..6, a0..7, calls _start_trap_rust,
|
|
|
-/// restores caller saved registers and then returns.
|
|
|
-#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
|
|
|
-global_asm!(r#"
|
|
|
- .section .trap, "ax"
|
|
|
- .align 4
|
|
|
- .global _start_trap
|
|
|
-
|
|
|
-_start_trap:
|
|
|
- addi sp, sp, -16*4
|
|
|
-
|
|
|
- sw ra, 0*4(sp)
|
|
|
- sw t0, 1*4(sp)
|
|
|
- sw t1, 2*4(sp)
|
|
|
- sw t2, 3*4(sp)
|
|
|
- sw t3, 4*4(sp)
|
|
|
- sw t4, 5*4(sp)
|
|
|
- sw t5, 6*4(sp)
|
|
|
- sw t6, 7*4(sp)
|
|
|
- sw a0, 8*4(sp)
|
|
|
- sw a1, 9*4(sp)
|
|
|
- sw a2, 10*4(sp)
|
|
|
- sw a3, 11*4(sp)
|
|
|
- sw a4, 12*4(sp)
|
|
|
- sw a5, 13*4(sp)
|
|
|
- sw a6, 14*4(sp)
|
|
|
- sw a7, 15*4(sp)
|
|
|
-
|
|
|
- jal ra, _start_trap_rust
|
|
|
-
|
|
|
- lw ra, 0*4(sp)
|
|
|
- lw t0, 1*4(sp)
|
|
|
- lw t1, 2*4(sp)
|
|
|
- lw t2, 3*4(sp)
|
|
|
- lw t3, 4*4(sp)
|
|
|
- lw t4, 5*4(sp)
|
|
|
- lw t5, 6*4(sp)
|
|
|
- lw t6, 7*4(sp)
|
|
|
- lw a0, 8*4(sp)
|
|
|
- lw a1, 9*4(sp)
|
|
|
- lw a2, 10*4(sp)
|
|
|
- lw a3, 11*4(sp)
|
|
|
- lw a4, 12*4(sp)
|
|
|
- lw a5, 13*4(sp)
|
|
|
- lw a6, 14*4(sp)
|
|
|
- lw a7, 15*4(sp)
|
|
|
-
|
|
|
- addi sp, sp, 16*4
|
|
|
- mret
|
|
|
-"#);
|
|
|
-
|
|
|
-
|
|
|
/// Trap entry point rust (_start_trap_rust)
|
|
|
///
|
|
|
/// mcause is read to determine the cause of the trap. XLEN-1 bit indicates
|
|
@@ -351,12 +265,3 @@ pub extern "C" fn start_trap_rust() {
|
|
|
#[no_mangle]
|
|
|
#[linkage = "weak"]
|
|
|
pub fn trap_handler(_: mcause::Trap) {}
|
|
|
-
|
|
|
-// Make sure there is an abort when linking
|
|
|
-#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
|
|
|
-global_asm!(r#"
|
|
|
-.section .init
|
|
|
-.globl abort
|
|
|
-abort:
|
|
|
- jal zero, _start
|
|
|
-"#);
|