mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-23 00:16:17 +04:00
add .stack section. clear bss
This commit is contained in:
parent
7240198a54
commit
0af9776dbd
@ -10,7 +10,7 @@ _start:
|
||||
|
||||
call rust_main
|
||||
|
||||
.section .bss
|
||||
.section .bss.stack
|
||||
.align 12 #PGSHIFT
|
||||
.global bootstack
|
||||
bootstack:
|
||||
|
@ -22,14 +22,14 @@ SECTIONS
|
||||
.text : {
|
||||
stext = .;
|
||||
*(.text.entry)
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
*(.text .text.*)
|
||||
. = ALIGN(4K);
|
||||
etext = .;
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
srodata = .;
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.rodata .rodata.*)
|
||||
. = ALIGN(4K);
|
||||
erodata = .;
|
||||
}
|
||||
@ -37,21 +37,18 @@ SECTIONS
|
||||
.data : {
|
||||
sdata = .;
|
||||
*(.data .data.*)
|
||||
. = ALIGN(4K);
|
||||
edata = .;
|
||||
}
|
||||
|
||||
.stack : {
|
||||
*(.bss.stack)
|
||||
}
|
||||
|
||||
.bss : {
|
||||
sbss = .;
|
||||
*(.bss .bss.* .sbss*)
|
||||
. = ALIGN(4K);
|
||||
*(.bss .bss.*)
|
||||
ebss = .;
|
||||
}
|
||||
|
||||
.got : {
|
||||
*(.got .got.*)
|
||||
. = ALIGN(4K);
|
||||
}
|
||||
|
||||
PROVIDE(end = .);
|
||||
}
|
||||
|
@ -32,14 +32,16 @@ SECTIONS
|
||||
.data : {
|
||||
sdata = .;
|
||||
*(.data .data.*)
|
||||
. = ALIGN(4K);
|
||||
edata = .;
|
||||
}
|
||||
|
||||
.stack : {
|
||||
*(.bss.stack)
|
||||
}
|
||||
|
||||
.bss : {
|
||||
sbss = .;
|
||||
*(.bss .bss.*)
|
||||
. = ALIGN(4K);
|
||||
ebss = .;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ fn remap_the_kernel() {
|
||||
ms.push(MemoryArea::new_identity(stext as usize, etext as usize, MemoryAttr::default().execute().readonly(), "text"));
|
||||
ms.push(MemoryArea::new_identity(sdata as usize, edata as usize, MemoryAttr::default(), "data"));
|
||||
ms.push(MemoryArea::new_identity(srodata as usize, erodata as usize, MemoryAttr::default().readonly(), "rodata"));
|
||||
ms.push(MemoryArea::new_identity(bootstack as usize, bootstacktop as usize, MemoryAttr::default(), "stack"));
|
||||
ms.push(MemoryArea::new_identity(sbss as usize, ebss as usize, MemoryAttr::default(), "bss"));
|
||||
unsafe { ms.activate(); }
|
||||
unsafe { SATP = ms.token(); }
|
||||
@ -93,6 +94,14 @@ fn remap_the_kernel() {
|
||||
// Other cores load it later.
|
||||
static mut SATP: usize = 0;
|
||||
|
||||
pub unsafe fn clear_bss() {
|
||||
let bss_start = sbss as usize;
|
||||
let bss_end = ebss as usize;
|
||||
for i in bss_start..bss_end {
|
||||
(i as *mut u8).write(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Symbols provided by linker script
|
||||
extern {
|
||||
fn stext();
|
||||
|
@ -10,15 +10,19 @@ pub mod cpu;
|
||||
#[no_mangle]
|
||||
pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize, functions: usize) -> ! {
|
||||
unsafe { cpu::set_cpu_id(hartid); }
|
||||
unsafe { BBL_FUNCTIONS_PTR = functions as *const _; }
|
||||
println!("Hello RISCV! in hart {}, dtb @ {:#x}, functions @ {:#x}", hartid, dtb, functions);
|
||||
|
||||
if hartid != 0 {
|
||||
while unsafe { !cpu::has_started(hartid) } { }
|
||||
println!("Hello RISCV! in hart {}, dtb @ {:#x}, functions @ {:#x}", hartid, dtb, functions);
|
||||
others_main();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
unsafe { memory::clear_bss(); }
|
||||
unsafe { BBL_FUNCTIONS_PTR = functions as *const _; }
|
||||
|
||||
println!("Hello RISCV! in hart {}, dtb @ {:#x}, functions @ {:#x}", hartid, dtb, functions);
|
||||
|
||||
crate::logging::init();
|
||||
interrupt::init();
|
||||
memory::init();
|
||||
|
Loading…
Reference in New Issue
Block a user