Skip to content

Commit 3fa1a74

Browse files
committed
Added a constant describing the kernel's initial stack
This also makes the stack bounds consistent with the other address range constants, in that the start is the smallest address in the range and the end is the largest address in the range.
1 parent f17e033 commit 3fa1a74

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

kernel/src/memory/constants.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ const KERNEL_STACK_GUARD_END: VirtAddr = const_virt_addr(0xffff_8000_5554_ffff a
7272

7373
/// KERNEL_STACK is the virtual address of the kernel's stack.
7474
///
75-
/// Note that the stack counts downwards, so the start address is larger than
76-
/// the end address.
75+
/// Note that even though the stack counts downwards, we use the smaller address as
76+
/// the start address and the larger address as the end address.
7777
///
78-
pub const KERNEL_STACK: VirtAddrRange = VirtAddrRange::new(KERNEL_STACK_END, KERNEL_STACK_START);
79-
const KERNEL_STACK_START: VirtAddr = const_virt_addr(0xffff_8000_5d5c_ffff as u64);
80-
const KERNEL_STACK_END: VirtAddr = const_virt_addr(0xffff_8000_5555_0000 as u64);
78+
pub const KERNEL_STACK: VirtAddrRange = VirtAddrRange::new(KERNEL_STACK_START, KERNEL_STACK_END);
79+
const KERNEL_STACK_START: VirtAddr = const_virt_addr(0xffff_8000_5555_0000 as u64);
80+
const KERNEL_STACK_END: VirtAddr = const_virt_addr(0xffff_8000_5d5c_ffff as u64);
81+
pub const KERNEL_STACK_0: VirtAddrRange =
82+
VirtAddrRange::new(KERNEL_STACK_0_START, KERNEL_STACK_0_END);
83+
const KERNEL_STACK_0_START: VirtAddr = KERNEL_STACK_START;
84+
const KERNEL_STACK_0_END: VirtAddr = const_virt_addr(0xffff_8000_555c_ffff as u64);
8185
pub const KERNEL_STACK_1_START: VirtAddr = const_virt_addr(0xffff_8000_555d_0000 as u64);
8286

8387
/// MMIO_SPACE is the virtual address space used for accessing

kernel/src/memory/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub mod vmm;
2828

2929
pub use crate::memory::constants::{
3030
phys_to_virt_addr, VirtAddrRange, BOOT_INFO, KERNEL_BINARY, KERNEL_HEAP, KERNEL_STACK,
31-
KERNEL_STACK_GUARD, MMIO_SPACE, NULL_PAGE, PHYSICAL_MEMORY, PHYSICAL_MEMORY_OFFSET, USERSPACE,
31+
KERNEL_STACK_0, KERNEL_STACK_GUARD, MMIO_SPACE, NULL_PAGE, PHYSICAL_MEMORY,
32+
PHYSICAL_MEMORY_OFFSET, USERSPACE,
3233
};
3334

3435
// PML4 functionality.

0 commit comments

Comments
 (0)