From 17cac5fe6421e144619f4828409e8174986f3e3b Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Wed, 3 Aug 2022 09:00:58 -0400 Subject: Initial bootstrap into ‘main’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 src/main.rs (limited to 'src') 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 {} +} -- cgit v1.3