From 6f6f012be97ba51e118942dcf1207293602c5fa2 Mon Sep 17 00:00:00 2001 From: gil Date: Thu, 23 May 2024 14:10:40 -0500 Subject: [PATCH] Trying to figure stuff out --- lds/kernel.lds | 2 +- src/main.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lds/kernel.lds b/lds/kernel.lds index 085be83..338c442 100644 --- a/lds/kernel.lds +++ b/lds/kernel.lds @@ -4,7 +4,7 @@ OUTPUT_ARCH("riscv") ENTRY(_entry) MEMORY { - ram (wxa) : ORIGIN = 0x80000000, LENGTH = 128M + ram (wxa) : ORIGIN = 0x80000000, LENGTH = 128M } PHDRS { diff --git a/src/main.rs b/src/main.rs index 17aa2ae..4f488fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,9 +15,10 @@ core::arch::global_asm!(include_str!("entry.s")); /// After some initialization in asm/entry.s, the kernel will jump here and /// each hart will have its own setup sequence. #[no_mangle] +#[allow(unreachable_code)] unsafe extern "C" fn start() { use core::arch::asm; - use riscv::register::{mepc, mstatus, satp, sie, sstatus}; + use riscv::register::{mstatus, pmpaddr0, satp, sie, sstatus}; // Set previous privilege for all harts to M-mode, set previous interrupt // enable, and set floating-point unit to initial state @@ -37,22 +38,24 @@ unsafe extern "C" fn start() { sie::set_stimer(); sie::set_ssoft(); + // hhhh + // pmpaddr0::write(0x3fffffffffffff_usize); // TODO configure PMP // TODO timer init // Trying to figure out why I can't use mret here. Might need // asm!( - // "la t1, 1f", + // "la t1, main", // "csrw mepc, t1", - // "la ra, 1f", // "mret", - // "1:", + // options(noreturn), // ); main(); } -fn main() { +#[no_mangle] +extern "C" fn main() { use riscv::interrupt; use riscv::register::{mstatus, sstatus};