diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/main.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100755 index 0000000..0f77639 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,38 @@ +#![feature(naked_functions)] + +#![no_std] +#![no_main] + +use core::arch::asm; + +#[no_mangle] +fn main(_hartid: usize) -> ! { + loop {} +} + +#[naked] +#[link_section = ".text.init"] +#[export_name = "_start"] +unsafe extern "C" fn _start() -> ! { + // At boot, the hart is in privilege mode M, mstatus fields MIE + // and MPRV are 0, the pc is set to a reset vector, the mcause + // register specifies why the reset occurred. + // c.f.: [^super::rism2] ยง 3.4 (Reset) + asm!( + ".option push", + ".option norelax", + "la gp, __global_pointer$", + ".option pop", + + "csrr a0, mhartid", + "la sp, _stack_top", + + "j main", + options(noreturn) + ) +} + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} |