Fix APIC offsets for x86 32-bit
This commit is contained in:
@@ -9,7 +9,10 @@ use crate::acpi::madt::{self, Madt, MadtEntry, MadtIntSrcOverride, MadtIoApic};
|
||||
use crate::{
|
||||
arch::interrupt::irq,
|
||||
memory::Frame,
|
||||
paging::{entry::EntryFlags, KernelMapper, Page, PageFlags, PhysicalAddress, RmmA, RmmArch},
|
||||
paging::{
|
||||
entry::EntryFlags, KernelMapper, Page, PageFlags, PhysicalAddress, RmmA, RmmArch,
|
||||
VirtualAddress,
|
||||
},
|
||||
};
|
||||
|
||||
use super::pic;
|
||||
@@ -233,7 +236,11 @@ pub unsafe fn handle_ioapic(mapper: &mut KernelMapper, madt_ioapic: &'static Mad
|
||||
// map the I/O APIC registers
|
||||
|
||||
let frame = Frame::containing_address(PhysicalAddress::new(madt_ioapic.address as usize));
|
||||
let page = Page::containing_address(RmmA::phys_to_virt(frame.start_address()));
|
||||
let page = Page::containing_address(if cfg!(target_arch = "x86") {
|
||||
VirtualAddress::new(crate::IOAPIC_OFFSET)
|
||||
} else {
|
||||
RmmA::phys_to_virt(frame.start_address())
|
||||
});
|
||||
|
||||
assert!(mapper.translate(page.start_address()).is_none());
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use core::{
|
||||
};
|
||||
use x86::msr::*;
|
||||
|
||||
use crate::paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch};
|
||||
use crate::paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch, VirtualAddress};
|
||||
|
||||
use crate::arch::cpuid::cpuid;
|
||||
|
||||
@@ -49,7 +49,11 @@ impl LocalApic {
|
||||
.expect("expected KernelMapper not to be locked re-entrant while initializing LAPIC");
|
||||
|
||||
let physaddr = PhysicalAddress::new(rdmsr(IA32_APIC_BASE) as usize & 0xFFFF_0000);
|
||||
let virtaddr = RmmA::phys_to_virt(physaddr);
|
||||
let virtaddr = if cfg!(target_arch = "x86") {
|
||||
VirtualAddress::new(crate::LAPIC_OFFSET)
|
||||
} else {
|
||||
RmmA::phys_to_virt(physaddr)
|
||||
};
|
||||
|
||||
self.address = virtaddr.data();
|
||||
self.x2 = cpuid().map_or(false, |cpuid| {
|
||||
|
||||
Reference in New Issue
Block a user