mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
chore: adjust boot_stack
This commit is contained in:
parent
6b1d8d366a
commit
e2a88ec4e2
@ -6,7 +6,7 @@ unsafe extern "C" fn _start(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
// no stack here
|
||||
|
||||
const STACK_SIZE: usize = 4096 * 16;
|
||||
#[link_section = ".boot_stack"]
|
||||
#[link_section = ".bss.boot_stack"]
|
||||
static mut STACK: [u8; STACK_SIZE] = [0u8; STACK_SIZE];
|
||||
|
||||
core::arch::asm!(
|
||||
@ -20,6 +20,8 @@ unsafe extern "C" fn _start(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
}
|
||||
|
||||
extern "C" fn pre_main(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
// TODO: multiboot
|
||||
|
||||
unsafe { zero_bss() }
|
||||
|
||||
// TODO: initialize page table
|
||||
@ -28,16 +30,14 @@ extern "C" fn pre_main(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static mut __bss_start: u8;
|
||||
static mut __boot_stack_end: u8;
|
||||
static mut __bss_end: u8;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
let mut cur = &mut __bss_start as *mut u8;
|
||||
let cur = &mut __boot_stack_end as *mut u8;
|
||||
let end = &mut __bss_end as *mut u8;
|
||||
|
||||
while cur < end {
|
||||
cur.write_volatile(0);
|
||||
cur = cur.add(1);
|
||||
}
|
||||
core::slice::from_raw_parts_mut(cur, end.offset_from(cur) as usize).fill(0);
|
||||
}
|
||||
|
@ -42,14 +42,12 @@ SECTIONS {
|
||||
__data_end = .;
|
||||
} > DRAM
|
||||
|
||||
.stack : {
|
||||
. = ALIGN(8);
|
||||
*(.boot_stack)
|
||||
} > DRAM
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(8);
|
||||
__bss_start = .;
|
||||
*(.bss.boot_stack)
|
||||
__boot_stack_end = .;
|
||||
|
||||
*(.bss .bss.*)
|
||||
*(.sbss .sbss.*)
|
||||
__bss_end = .;
|
||||
|
Loading…
Reference in New Issue
Block a user