Remove unused and deduplicate identical arch specific consts

This commit is contained in:
bjorn3
2026-04-02 19:31:39 +02:00
parent 10b1ae2ecc
commit 980f1c6af8
7 changed files with 11 additions and 37 deletions
+2 -2
View File
@@ -29,9 +29,9 @@ unsafe impl GlobalAlloc for Allocator {
super::map_heap(
&mut KernelMapper::lock_rw(),
crate::KERNEL_HEAP_OFFSET + size,
crate::KERNEL_HEAP_SIZE,
super::KERNEL_HEAP_SIZE,
);
heap.extend(crate::KERNEL_HEAP_SIZE);
heap.extend(super::KERNEL_HEAP_SIZE);
}
}
}
+4 -1
View File
@@ -7,6 +7,9 @@ use rmm::{Flusher, FrameAllocator};
pub use self::linked_list::Allocator;
mod linked_list;
/// Size of kernel heap
const KERNEL_HEAP_SIZE: usize = ::rmm::MEGABYTE;
unsafe fn map_heap(mapper: &mut KernelMapper<true>, offset: usize, size: usize) {
let mut flush_all = PageFlushAll::new();
@@ -37,7 +40,7 @@ unsafe fn map_heap(mapper: &mut KernelMapper<true>, offset: usize, size: usize)
pub unsafe fn init() {
unsafe {
let offset = crate::KERNEL_HEAP_OFFSET;
let size = crate::KERNEL_HEAP_SIZE;
let size = KERNEL_HEAP_SIZE;
// Map heap pages
map_heap(&mut KernelMapper::lock_rw(), offset, size);
+1 -10
View File
@@ -5,20 +5,11 @@
/// The size of a single PML4
pub const PML4_SIZE: usize = 0x0000_0080_0000_0000;
/// Offset of recursive paging (deprecated, but still reserved)
pub const RECURSIVE_PAGE_OFFSET: usize = (-(PML4_SIZE as isize)) as usize;
/// Offset of kernel
pub const KERNEL_OFFSET: usize = RECURSIVE_PAGE_OFFSET - PML4_SIZE;
pub const KERNEL_OFFSET: usize = (2 * PML4_SIZE).wrapping_neg();
/// Offset to kernel heap
pub const KERNEL_HEAP_OFFSET: usize = KERNEL_OFFSET - PML4_SIZE;
/// Size of kernel heap
pub const KERNEL_HEAP_SIZE: usize = 1 * 1024 * 1024; // 1 MB
/// Offset of physmap
// This needs to match RMM's PHYS_OFFSET
pub const PHYS_OFFSET: usize = 0xFFFF_8000_0000_0000;
/// End offset of the user image, i.e. kernel start
pub const USER_END_OFFSET: usize = 256 * PML4_SIZE;
+1 -10
View File
@@ -6,20 +6,11 @@ const PML4_SHIFT: usize = (CurrentRmmArch::PAGE_LEVELS - 1) * CurrentRmmArch::PA
/// The size of a single PML4
pub const PML4_SIZE: usize = 1_usize << PML4_SHIFT;
/// Offset of recursive paging (deprecated, but still reserved)
pub const RECURSIVE_PAGE_OFFSET: usize = (-(PML4_SIZE as isize)) as usize;
/// Offset of kernel
pub const KERNEL_OFFSET: usize = RECURSIVE_PAGE_OFFSET - PML4_SIZE;
pub const KERNEL_OFFSET: usize = (2 * PML4_SIZE).wrapping_neg();
/// Offset to kernel heap
pub const KERNEL_HEAP_OFFSET: usize = KERNEL_OFFSET - PML4_SIZE;
/// Size of kernel heap
pub const KERNEL_HEAP_SIZE: usize = 1 * 1024 * 1024; // 1 MB
/// Offset of physmap
// This needs to match RMM's PHYS_OFFSET
pub const PHYS_OFFSET: usize = (-1_isize << (CurrentRmmArch::PAGE_ADDRESS_SHIFT - 1)) as usize;
/// End offset of the user image, i.e. kernel start
pub const USER_END_OFFSET: usize = 1_usize << (CurrentRmmArch::PAGE_ADDRESS_SHIFT - 1);
-6
View File
@@ -15,12 +15,6 @@ pub const HPET_OFFSET: usize = IOAPIC_OFFSET + 4096;
/// Offset to kernel heap (256 MiB max)
pub const KERNEL_HEAP_OFFSET: usize = 0xE000_0000;
/// Size of kernel heap
pub const KERNEL_HEAP_SIZE: usize = rmm::MEGABYTE;
/// Offset of physmap (1 GiB max)
// This needs to match RMM's PHYS_OFFSET
pub const PHYS_OFFSET: usize = 0x8000_0000;
/// End offset of the user image, i.e. kernel start
pub const USER_END_OFFSET: usize = 0x8000_0000;
+1 -8
View File
@@ -12,17 +12,10 @@
pub const PML4_SIZE: usize = 0x0000_0080_0000_0000;
/// Offset of kernel
pub const KERNEL_MAX_SIZE: usize = 1_usize << 31;
pub const KERNEL_OFFSET: usize = KERNEL_MAX_SIZE.wrapping_neg();
pub const KERNEL_OFFSET: usize = (1_usize << 31).wrapping_neg();
/// Offset to kernel heap
pub const KERNEL_HEAP_OFFSET: usize = KERNEL_OFFSET - PML4_SIZE;
/// Size of kernel heap
pub const KERNEL_HEAP_SIZE: usize = 1 * 1024 * 1024; // 1 MB
/// Offset of physmap
// This needs to match RMM's PHYS_OFFSET
pub const PHYS_OFFSET: usize = 0xFFFF_8000_0000_0000;
/// End offset of the user image, i.e. kernel start
// TODO: Make this offset at least PAGE_SIZE less? There are known hardware bugs on some arches,
+2
View File
@@ -36,6 +36,8 @@ mod macros;
#[allow(dead_code)] // TODO
mod arch;
use crate::arch::*;
/// Offset of physmap
const PHYS_OFFSET: usize = <arch::CurrentRmmArch as ::rmm::Arch>::PHYS_OFFSET;
/// Heap allocators
mod allocator;