Unverified Commit 4d5d5dac authored by bors[bot]'s avatar bors[bot] Committed by GitHub
Browse files

Merge #286



286: add method to use default APIC addresses r=mkroening a=stlankes

- if ACPI isn't available, we use the default APIC addresses
- however, we don't have an guarantee, if these addresses are correct
Co-authored-by: Stefan Lankes's avatarStefan Lankes <slankes@eonerc.rwth-aachen.de>
parents ad524d9a 5502a684
Pipeline #562829 passed with stages
in 15 minutes and 23 seconds
......@@ -267,20 +267,40 @@ fn detect_from_acpi() -> Result<PhysAddr, ()> {
Ok(PhysAddr(madt_header.local_apic_address.into()))
}
fn default_apic() -> PhysAddr {
warn!("Try to use default APIC address");
let default_address = PhysAddr(0xFEC0_0000);
unsafe {
IOAPIC_ADDRESS = virtualmem::allocate(BasePageSize::SIZE).unwrap();
debug!(
"Mapping IOAPIC at {:#X} to virtual address {:#X}",
default_address, IOAPIC_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.device().writable().execute_disable();
paging::map::<BasePageSize>(IOAPIC_ADDRESS, default_address, 1, flags);
}
PhysAddr(0xFEE0_0000)
}
fn detect_from_uhyve() -> Result<PhysAddr, ()> {
if environment::is_uhyve() {
let defaullt_address = PhysAddr(0xFEC0_0000);
let default_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
default_address, IOAPIC_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.device().writable().execute_disable();
paging::map::<BasePageSize>(IOAPIC_ADDRESS, defaullt_address, 1, flags);
paging::map::<BasePageSize>(IOAPIC_ADDRESS, default_address, 1, flags);
}
return Ok(PhysAddr(0xFEE0_0000));
......@@ -309,8 +329,8 @@ pub fn init() {
// Detect CPUs and APICs.
let local_apic_physical_address = detect_from_uhyve()
.or_else(|_e| detect_from_acpi())
.expect("HermitCore requires an APIC system");
.or_else(|_| detect_from_acpi())
.unwrap_or_else(|_| default_apic());
// Initialize x2APIC or xAPIC, depending on what's available.
init_x2apic();
......
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