Skip to content

Commit c5e0584

Browse files
authored
Merge pull request #2667 from hermit-os/prepare-acpi-crate
refactor(x86_64/acpi): prepare for `acpi` crate
2 parents 906ea2a + 27e9c89 commit c5e0584

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/arch/x86_64/kernel/acpi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl AcpiTable<'_> {
130130
}
131131
}
132132

133-
pub fn header_start_address(&self) -> usize {
133+
fn header_start_address(&self) -> usize {
134134
ptr::from_ref(self.header).addr()
135135
}
136136

src/arch/x86_64/kernel/apic.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,6 @@ fn init_ioapic_address(phys_addr: PhysAddr) {
313313
.unwrap();
314314
}
315315

316-
#[cfg(not(feature = "acpi"))]
317-
fn detect_from_acpi() -> Result<PhysAddr, ()> {
318-
// dummy implementation if acpi support is disabled
319-
Err(())
320-
}
321-
322316
#[cfg(feature = "acpi")]
323317
fn detect_from_acpi() -> Result<PhysAddr, ()> {
324318
// Get the Multiple APIC Description Table (MADT) from the ACPI information and its specific table header.
@@ -504,9 +498,16 @@ fn apic_addr() -> PhysAddr {
504498
return default_apic();
505499
}
506500

507-
detect_from_acpi()
508-
.or_else(|()| detect_from_mp())
509-
.unwrap_or_else(|()| default_apic())
501+
#[cfg(feature = "acpi")]
502+
if let Ok(apic_addr) = detect_from_acpi() {
503+
return apic_addr;
504+
}
505+
506+
if let Ok(apic_addr) = detect_from_mp() {
507+
return apic_addr;
508+
}
509+
510+
default_apic()
510511
}
511512

512513
pub fn eoi() {

src/arch/x86_64/kernel/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::arch::kernel::core_local::*;
1313
use crate::env::{self, UhyveStartInfo};
1414

1515
#[cfg(feature = "acpi")]
16-
pub mod acpi;
16+
mod acpi;
1717
pub mod apic;
1818
pub mod core_local;
1919
pub mod gdt;

src/arch/x86_64/kernel/processor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ use x86_64::registers::xcontrol::{XCr0, XCr0Flags};
2323
use x86_64::structures::DescriptorTablePointer;
2424
use x86_64::{VirtAddr, instructions};
2525

26-
#[cfg(feature = "acpi")]
27-
use crate::arch::kernel::acpi;
2826
use crate::arch::kernel::{interrupts, pic, pit};
2927
use crate::env;
3028

@@ -1090,7 +1088,7 @@ pub fn shutdown(error_code: i32) -> ! {
10901088

10911089
#[cfg(feature = "acpi")]
10921090
{
1093-
acpi::poweroff();
1091+
super::acpi::poweroff();
10941092
}
10951093

10961094
triple_fault()

0 commit comments

Comments
 (0)