rmm: Remove PageMapper::{map,unmap}

There is already (un)map_phys.
This commit is contained in:
bjorn3
2026-03-29 12:38:16 +02:00
parent a876d66648
commit a5aeea9cfc
3 changed files with 23 additions and 35 deletions
+7 -2
View File
@@ -235,8 +235,12 @@ unsafe fn new_tables<A: Arch>(areas: &'static [MemoryArea]) {
let mut flush_all = PageFlushAll::new();
for i in 0..16 {
let virt = VirtualAddress::new(MEGABYTE + i * A::PAGE_SIZE);
let phys = mapper
.allocator_mut()
.allocate_one()
.expect("failed to map page");
let flush = mapper
.map(virt, PageFlags::<A>::new().user(true).write(true))
.map_phys(virt, phys, PageFlags::<A>::new().user(true).write(true))
.expect("failed to map page");
flush_all.consume(flush);
}
@@ -245,7 +249,8 @@ unsafe fn new_tables<A: Arch>(areas: &'static [MemoryArea]) {
let mut flush_all = PageFlushAll::new();
for i in 0..16 {
let virt = VirtualAddress::new(MEGABYTE + i * A::PAGE_SIZE);
let flush = mapper.unmap(virt).expect("failed to unmap page");
let (old, _, flush) = mapper.unmap_phys(virt).expect("failed to unmap page");
mapper.allocator_mut().free_one(old);
flush_all.consume(flush);
}
flush_all.flush();
-22
View File
@@ -157,17 +157,6 @@ impl<A: Arch, F: FrameAllocator> PageMapper<A, F> {
}
}
pub unsafe fn map(
&mut self,
virt: VirtualAddress,
flags: PageFlags<A>,
) -> Option<PageFlush<A>> {
unsafe {
let phys = self.allocator.allocate_one()?;
self.map_phys(virt, phys, flags)
}
}
pub unsafe fn map_phys(
&mut self,
virt: VirtualAddress,
@@ -218,17 +207,6 @@ impl<A: Arch, F: FrameAllocator> PageMapper<A, F> {
}
}
pub unsafe fn unmap(&mut self, virt: VirtualAddress) -> Option<PageFlush<A>>
where
F: FrameAllocator,
{
unsafe {
let (old, _, flush) = self.unmap_phys(virt)?;
self.allocator.free_one(old);
Some(flush)
}
}
pub unsafe fn unmap_phys(
&mut self,
virt: VirtualAddress,
+16 -11
View File
@@ -2,31 +2,36 @@ use crate::{
memory::KernelMapper,
paging::{mapper::PageFlushAll, Page, PageFlags, VirtualAddress},
};
use rmm::Flusher;
use rmm::{Flusher, FrameAllocator};
pub use self::linked_list::Allocator;
mod linked_list;
unsafe fn map_heap(mapper: &mut KernelMapper<true>, offset: usize, size: usize) {
unsafe {
let mut flush_all = PageFlushAll::new();
let mut flush_all = PageFlushAll::new();
let heap_start_page = Page::containing_address(VirtualAddress::new(offset));
let heap_end_page = Page::containing_address(VirtualAddress::new(offset + size - 1));
for page in Page::range_inclusive(heap_start_page, heap_end_page) {
let result = mapper
.map(
let heap_start_page = Page::containing_address(VirtualAddress::new(offset));
let heap_end_page = Page::containing_address(VirtualAddress::new(offset + size - 1));
for page in Page::range_inclusive(heap_start_page, heap_end_page) {
unsafe {
let phys = mapper
.allocator_mut()
.allocate_one()
.expect("failed to allocate kernel heap");
let flush = mapper
.map_phys(
page.start_address(),
phys,
PageFlags::new()
.write(true)
.global(cfg!(not(feature = "pti"))),
)
.expect("failed to map kernel heap");
flush_all.consume(result);
flush_all.consume(flush);
}
flush_all.flush();
}
flush_all.flush();
}
pub unsafe fn init() {