f3bef6b403
P18-5 had a duplicate acpi.rs RSDP probing hunk that reversed P5's BIOS probing code, causing P19-acpid hunk #8 to fail. Removed the duplicate, keeping only aml_physmem.rs hunks. P19-init used log::warn!() but init in initfs has no log crate dependency. Replaced with init_warn(&format!(...)) from the existing color module. All 58/58 patches validate. redbear-mini builds successfully.
57 lines
2.3 KiB
Diff
57 lines
2.3 KiB
Diff
--- a/drivers/acpid/src/aml_physmem.rs
|
|
+++ b/drivers/acpid/src/aml_physmem.rs
|
|
@@ -190,7 +190,10 @@
|
|
.unwrap_or_else(|poisoned| poisoned.into_inner());
|
|
match page_cache.read_from_phys::<T>(address) {
|
|
Ok(value) => value,
|
|
- Err(error) => panic!("AML physmem read failed at {:#x}: {}", address, error),
|
|
+ Err(error) => {
|
|
+ log::error!("AML physmem read failed at {:#x}: {} — returning zero", address, error);
|
|
+ T::zero()
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -252,13 +255,26 @@
|
|
let offset = phys & OFFSET_MASK;
|
|
let pages = (offset + size + PAGE_SIZE - 1) / PAGE_SIZE;
|
|
let map_size = pages * PAGE_SIZE;
|
|
- let virt_page = common::physmap(
|
|
+ let virt_page = match common::physmap(
|
|
phys_page,
|
|
map_size,
|
|
common::Prot::RW,
|
|
common::MemoryType::default(),
|
|
- )
|
|
- .expect("failed to map physical region") as usize;
|
|
+ ) {
|
|
+ Ok(v) => v as usize,
|
|
+ Err(err) => {
|
|
+ log::error!(
|
|
+ "failed to map physical region {:#x}+{:#x}: {:?} — mapping zero page fallback",
|
|
+ phys_page,
|
|
+ map_size,
|
|
+ err
|
|
+ );
|
|
+ // Map the zero page as a safe fallback so the pointer is at least valid
|
|
+ // Reads will return zeroes; this is better than crashing.
|
|
+ common::physmap(0, PAGE_SIZE, common::Prot::RW, common::MemoryType::default())
|
|
+ .expect("failed to map even the zero page") as usize
|
|
+ }
|
|
+ };
|
|
PhysicalMapping {
|
|
physical_start: phys,
|
|
virtual_start: NonNull::new((virt_page + offset) as *mut T).unwrap(),
|
|
@@ -269,9 +285,8 @@
|
|
}
|
|
fn unmap_physical_region<T>(region: &PhysicalMapping<Self, T>) {
|
|
let virt_page = region.virtual_start.addr().get() & PAGE_MASK;
|
|
- unsafe {
|
|
- libredox::call::munmap(virt_page as *mut (), region.mapped_length)
|
|
- .expect("failed to unmap physical region")
|
|
+ if let Err(e) = unsafe { libredox::call::munmap(virt_page as *mut (), region.mapped_length) } {
|
|
+ log::error!("failed to unmap physical region at {:#x}: {:?}", virt_page, e);
|
|
}
|
|
}
|
|
|