Remove ACPI search from the kernel

The bootloader provides the RSDP address to the kernel. If the
bootloader can't find it, there is no RSDP.
This commit is contained in:
bjorn3
2026-04-04 11:50:24 +02:00
parent 1352fafd00
commit 50c68cd746
3 changed files with 5 additions and 53 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ pub unsafe fn init(already_supplied_rsdp: Option<*const u8>) {
}
// Search for RSDP
let rsdp_opt = Rsdp::get_rsdp(&mut KernelMapper::lock_rw(), already_supplied_rsdp);
let rsdp_opt = Rsdp::get_rsdp(already_supplied_rsdp);
if let Some(rsdp) = rsdp_opt {
debug!("SDT address: {:#x}", rsdp.sdt_address());
+4 -44
View File
@@ -1,5 +1,3 @@
use crate::memory::{Frame, KernelMapper, Page, PageFlags, PhysicalAddress, VirtualAddress};
/// RSDP
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
@@ -16,52 +14,14 @@ pub struct Rsdp {
}
impl Rsdp {
fn get_already_supplied_rsdp(rsdp_ptr: *const u8) -> Rsdp {
// TODO: Validate
unsafe { *(rsdp_ptr as *const Rsdp) }
}
pub fn get_rsdp(
mapper: &mut KernelMapper<true>,
already_supplied_rsdp: Option<*const u8>,
) -> Option<Rsdp> {
pub unsafe fn get_rsdp(already_supplied_rsdp: Option<*const u8>) -> Option<Rsdp> {
if let Some(rsdp_ptr) = already_supplied_rsdp {
Some(Self::get_already_supplied_rsdp(rsdp_ptr))
// TODO: Validate
Some(unsafe { *(rsdp_ptr as *const Rsdp) })
} else {
Self::get_rsdp_by_searching(mapper)
None
}
}
/// Search for the RSDP
pub fn get_rsdp_by_searching(mapper: &mut KernelMapper<true>) -> Option<Rsdp> {
let start_addr = 0xE_0000;
let end_addr = 0xF_FFFF;
// Map all of the ACPI RSDP space
{
let start_frame = Frame::containing(PhysicalAddress::new(start_addr));
let end_frame = Frame::containing(PhysicalAddress::new(end_addr));
for frame in Frame::range_inclusive(start_frame, end_frame) {
let page = Page::containing_address(VirtualAddress::new(frame.base().data()));
let result = unsafe {
mapper
.map_phys(page.start_address(), frame.base(), PageFlags::new())
.expect("failed to map page while searching for RSDP")
};
result.flush();
}
}
Rsdp::search(start_addr, end_addr)
}
fn search(start_addr: usize, end_addr: usize) -> Option<Rsdp> {
for i in 0..(end_addr + 1 - start_addr) / 16 {
let rsdp = unsafe { &*((start_addr + i * 16) as *const Rsdp) };
if &rsdp.signature == b"RSD PTR " {
return Some(*rsdp);
}
}
None
}
/// Get the RSDT or XSDT address
pub fn sdt_address(&self) -> usize {
-8
View File
@@ -318,14 +318,6 @@ impl Frame {
PhysicalAddress::new(self.physaddr.get())
}
//TODO: Set private
pub fn range_inclusive(start: Frame, end: Frame) -> impl Iterator<Item = Frame> {
(start.physaddr.get()..=end.physaddr.get())
.step_by(PAGE_SIZE)
.map(|number| Frame {
physaddr: NonZeroUsize::new(number).unwrap(),
})
}
#[track_caller]
pub fn next_by(self, n: usize) -> Self {
Self {