Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/acpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl AcpiTable<'_> {
}
}

pub fn header_start_address(&self) -> usize {
fn header_start_address(&self) -> usize {
ptr::from_ref(self.header).addr()
}

Expand Down
19 changes: 10 additions & 9 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,6 @@ fn init_ioapic_address(phys_addr: PhysAddr) {
.unwrap();
}

#[cfg(not(feature = "acpi"))]
fn detect_from_acpi() -> Result<PhysAddr, ()> {
// dummy implementation if acpi support is disabled
Err(())
}

#[cfg(feature = "acpi")]
fn detect_from_acpi() -> Result<PhysAddr, ()> {
// Get the Multiple APIC Description Table (MADT) from the ACPI information and its specific table header.
Expand Down Expand Up @@ -504,9 +498,16 @@ fn apic_addr() -> PhysAddr {
return default_apic();
}

detect_from_acpi()
.or_else(|()| detect_from_mp())
.unwrap_or_else(|()| default_apic())
#[cfg(feature = "acpi")]
if let Ok(apic_addr) = detect_from_acpi() {
return apic_addr;
}

if let Ok(apic_addr) = detect_from_mp() {
return apic_addr;
}

default_apic()
}

pub fn eoi() {
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::arch::kernel::core_local::*;
use crate::env::{self, UhyveStartInfo};

#[cfg(feature = "acpi")]
pub mod acpi;
mod acpi;
pub mod apic;
pub mod core_local;
pub mod gdt;
Expand Down
4 changes: 1 addition & 3 deletions src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use x86_64::registers::xcontrol::{XCr0, XCr0Flags};
use x86_64::structures::DescriptorTablePointer;
use x86_64::{VirtAddr, instructions};

#[cfg(feature = "acpi")]
use crate::arch::kernel::acpi;
use crate::arch::kernel::{interrupts, pic, pit};
use crate::env;

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

#[cfg(feature = "acpi")]
{
acpi::poweroff();
super::acpi::poweroff();
}

triple_fault()
Expand Down
Loading