Remove the system device's IO memory access

This commit is contained in:
Yuke Peng
2024-10-31 08:43:52 +08:00
committed by Tate, Hongliang Tian
parent 8a26b785a4
commit 05ec50def3
7 changed files with 32 additions and 24 deletions

View File

@ -8,8 +8,9 @@ use core::{
use bit_field::BitField;
use spin::Once;
use xapic::get_xapic_base_address;
use crate::{cpu::PinCurrentCpu, cpu_local};
use crate::{cpu::PinCurrentCpu, cpu_local, io::IoMemAllocatorBuilder};
pub mod ioapic;
pub mod x2apic;
@ -346,7 +347,7 @@ pub enum DivideConfig {
Divide128 = 0b1010,
}
pub fn init() -> Result<(), ApicInitError> {
pub fn init(io_mem_builder: &IoMemAllocatorBuilder) -> Result<(), ApicInitError> {
crate::arch::x86::kernel::pic::disable_temp();
if x2apic::X2Apic::has_x2apic() {
log::info!("x2APIC found!");
@ -354,6 +355,8 @@ pub fn init() -> Result<(), ApicInitError> {
Ok(())
} else if xapic::XApic::has_xapic() {
log::info!("xAPIC found!");
let base_address = get_xapic_base_address();
io_mem_builder.remove(base_address..(base_address + size_of::<[u32; 256]>()));
APIC_TYPE.call_once(|| ApicType::XApic);
Ok(())
} else {