use crate::arch::acpi::Acpi;
use crate::arch::cpu;
use crate::arch::int::apic::{parse_apic_table, LAPIC_IDS};
use crate::arch::int::ioapic::{Device, IOAPIC};
use crate::arch::int::lapic::LAPIC;
use crate::arch::int::pic;
pub mod epilog;
pub mod guard;
pub mod idt;
pub const TIMER_MS: usize = 1;
#[derive(Debug, Clone, Copy)]
#[allow(unused)]
pub enum Vector {
Timer = 32,
Keyboard = 33,
Serial = 34,
Mouse = 44,
Panic = 99,
Assassin = 100,
WakeUp = 101,
Syscall = 0x80,
Spurious = 0xff,
}
pub fn setup_global(acpi: Acpi) -> usize {
pic::init(pic::PicPort::new());
let (ioapic_id, num_lapics) = parse_apic_table(acpi);
IOAPIC.init(ioapic_id, Vector::Panic as u8 as _);
IOAPIC.config(Device::Keyboard, Vector::Keyboard as u8, true);
IOAPIC.enable(Device::Keyboard, true);
num_lapics
}
pub fn setup_local() {
idt::load();
let core_id = unsafe { LAPIC_IDS }
.iter()
.position(|v| *v == cpu::id() as u8)
.expect("Unknown LAPIC");
LAPIC.init(core_id as _);
cpu::init(core_id);
LAPIC.timer(TIMER_MS * 1000, Vector::Timer as _, true, false);
}
fn eoi(_vector: u8) {
LAPIC.eoi()
}