mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 17:33:23 +00:00
Understanding memory space and move higher the stack
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
dede22843a
commit
52f07458f7
@ -11,11 +11,10 @@ use log::debug;
|
||||
|
||||
use super::paddr_to_vaddr;
|
||||
use crate::{
|
||||
config::{KERNEL_HEAP_SIZE, PAGE_SIZE},
|
||||
prelude::*,
|
||||
sync::SpinLock,
|
||||
trap::disable_local,
|
||||
vm::frame_allocator::FRAME_ALLOCATOR,
|
||||
vm::{frame_allocator::FRAME_ALLOCATOR, PAGE_SIZE},
|
||||
Error,
|
||||
};
|
||||
|
||||
@ -27,12 +26,14 @@ pub fn handle_alloc_error(layout: core::alloc::Layout) -> ! {
|
||||
panic!("Heap allocation error, layout = {:?}", layout);
|
||||
}
|
||||
|
||||
static mut HEAP_SPACE: [u8; KERNEL_HEAP_SIZE] = [0; KERNEL_HEAP_SIZE];
|
||||
const INIT_KERNEL_HEAP_SIZE: usize = PAGE_SIZE * 256;
|
||||
|
||||
static mut HEAP_SPACE: [u8; INIT_KERNEL_HEAP_SIZE] = [0; INIT_KERNEL_HEAP_SIZE];
|
||||
|
||||
pub fn init() {
|
||||
// Safety: The HEAP_SPACE is a static memory range, so it's always valid.
|
||||
unsafe {
|
||||
HEAP_ALLOCATOR.init(HEAP_SPACE.as_ptr(), KERNEL_HEAP_SIZE);
|
||||
HEAP_ALLOCATOR.init(HEAP_SPACE.as_ptr(), INIT_KERNEL_HEAP_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user