diff --git a/src/acpi/mod.rs b/src/acpi/mod.rs index 47bbaafb75..2684ff5e0a 100644 --- a/src/acpi/mod.rs +++ b/src/acpi/mod.rs @@ -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()); diff --git a/src/acpi/rsdp.rs b/src/acpi/rsdp.rs index 67dcd4bc64..a68e94d5e2 100644 --- a/src/acpi/rsdp.rs +++ b/src/acpi/rsdp.rs @@ -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, - already_supplied_rsdp: Option<*const u8>, - ) -> Option { + pub unsafe fn get_rsdp(already_supplied_rsdp: Option<*const u8>) -> Option { 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) -> Option { - 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 { - 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 { diff --git a/src/memory/mod.rs b/src/memory/mod.rs index 4144bb5be6..22ad0dfafc 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -318,14 +318,6 @@ impl Frame { PhysicalAddress::new(self.physaddr.get()) } - //TODO: Set private - pub fn range_inclusive(start: Frame, end: Frame) -> impl Iterator { - (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 {