1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 {}
}
|