diff --git a/src/entry.asm b/src/entry.asm index cde07d2..bf1f801 100644 --- a/src/entry.asm +++ b/src/entry.asm @@ -1,4 +1,12 @@ .section .text.entry .globl _start _start: - li x1, 100 \ No newline at end of file + la sp, boot_start_top + call rust_main + + .section .bss.stack + .globl boot_stack_lower_bound +boot_stack_lower_bound: + .space 4096 * 16 + .globl boot_start_top +boot_start_top: \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 0feea96..dee9f08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,4 +4,20 @@ mod lang_items; use core::arch::global_asm; -global_asm!(include_str!("entry.asm")); \ No newline at end of file +global_asm!(include_str!("entry.asm")); + +#[no_mangle] +pub fn rust_main() -> ! { + clear_bss(); + loop {} +} + +fn clear_bss() { + extern "C" { + fn sbss(); + fn ebss(); + } + (sbss as usize..ebss as usize).for_each(|a| { + unsafe { (a as *mut u8).write_volatile(0) } + }); +} \ No newline at end of file