Commit ff006514 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

add method to use default APIC addresses

parent ad524d9a
......@@ -267,6 +267,26 @@ fn detect_from_acpi() -> Result<PhysAddr, ()> {
Ok(PhysAddr(madt_header.local_apic_address.into()))
}
fn default_apic() -> Result<PhysAddr, ()> {
warn!("Try to use default APIC address");
let defaullt_address = PhysAddr(0xFEC0_0000);
unsafe {
IOAPIC_ADDRESS = virtualmem::allocate(BasePageSize::SIZE).unwrap();
debug!(
"Mapping IOAPIC at {:#X} to virtual address {:#X}",
defaullt_address, IOAPIC_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.device().writable().execute_disable();
paging::map::<BasePageSize>(IOAPIC_ADDRESS, defaullt_address, 1, flags);
}
return Ok(PhysAddr(0xFEE0_0000));
}
fn detect_from_uhyve() -> Result<PhysAddr, ()> {
if environment::is_uhyve() {
let defaullt_address = PhysAddr(0xFEC0_0000);
......@@ -310,6 +330,7 @@ pub fn init() {
// Detect CPUs and APICs.
let local_apic_physical_address = detect_from_uhyve()
.or_else(|_e| detect_from_acpi())
.or_else(|_e| default_apic())
.expect("HermitCore requires an APIC system");
// Initialize x2APIC or xAPIC, depending on what's available.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment