18 lines
669 B
Rust
18 lines
669 B
Rust
//! Constants used in rCore
|
|
|
|
pub const USER_STACK_SIZE: usize = 4096 * 2;
|
|
pub const KERNEL_STACK_SIZE: usize = 4096 * 2;
|
|
pub const KERNEL_HEAP_SIZE: usize = 0x30_0000;
|
|
pub const PAGE_SIZE: usize = 0x1000;
|
|
pub const PAGE_SIZE_BITS: usize = 0xc;
|
|
|
|
pub const TRAMPOLINE: usize = usize::MAX - PAGE_SIZE + 1;
|
|
pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE;
|
|
/// Return (bottom, top) of a kernel stack in kernel space.
|
|
pub fn kernel_stack_position(app_id: usize) -> (usize, usize) {
|
|
let top = TRAMPOLINE - app_id * (KERNEL_STACK_SIZE + PAGE_SIZE);
|
|
let bottom = top - KERNEL_STACK_SIZE;
|
|
(bottom, top)
|
|
}
|
|
|
|
pub use crate::board::{CLOCK_FREQ, MEMORY_END, MMIO};
|