diff --git a/src/main.rs b/src/main.rs index 4a68e4d..420df16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,8 @@ mod uart; unsafe extern "C" fn _enter() -> ! { use core::arch::asm; asm!( + "csrr t0, mhartid", + "bnez t0, 3f", // before we use the `la` pseudo-instruction for the first time, // we need to set `gp` (google linker relaxation) ".option push", // pushes the current option stack @@ -38,6 +40,11 @@ unsafe extern "C" fn _enter() -> ! { "bne t0, t1, 1b", "2:", // BSS is clear! + "j 4f", + "3:", + "wfi", + "j 3b", + "4:", // "tail-call" to {start} (call without saving a return address) "tail {start}",