ch1: Support function call

This commit is contained in:
Tateisi 2025-08-02 17:36:14 +08:00
parent 5de7bac424
commit 43fd85405b
2 changed files with 26 additions and 2 deletions

View file

@ -1,4 +1,12 @@
.section .text.entry
.globl _start
_start:
li x1, 100
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:

View file

@ -4,4 +4,20 @@
mod lang_items;
use core::arch::global_asm;
global_asm!(include_str!("entry.asm"));
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) }
});
}