ch1: Support function call
This commit is contained in:
parent
5de7bac424
commit
43fd85405b
2 changed files with 26 additions and 2 deletions
|
@ -1,4 +1,12 @@
|
||||||
.section .text.entry
|
.section .text.entry
|
||||||
.globl _start
|
.globl _start
|
||||||
_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:
|
18
src/main.rs
18
src/main.rs
|
@ -4,4 +4,20 @@
|
||||||
mod lang_items;
|
mod lang_items;
|
||||||
|
|
||||||
use core::arch::global_asm;
|
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) }
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue