From 5df04727033216fdb035171dc4d8e7147e120570 Mon Sep 17 00:00:00 2001 From: gil Date: Thu, 16 May 2024 08:19:15 -0500 Subject: [PATCH] Loop for non-0 hartid's --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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}",