diff options
Diffstat (limited to 'kernel/src/interrupts/apic.rs')
-rw-r--r-- | kernel/src/interrupts/apic.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/src/interrupts/apic.rs b/kernel/src/interrupts/apic.rs index 5c236ea..14f6169 100644 --- a/kernel/src/interrupts/apic.rs +++ b/kernel/src/interrupts/apic.rs @@ -83,12 +83,12 @@ pub enum TimerDivideConfig { static mut LOCAL_APIC: Option<Apic> = None; -pub fn set_local_apic(apic: Apic) -> &mut Apic { +pub unsafe fn set_local_apic(apic: Apic) -> &'static mut Apic { LOCAL_APIC.get_or_insert(apic) } -pub fn get_local_apic() -> Option<Apic> { - LOCAL_APIC +pub unsafe fn get_local_apic() -> Option<&'static mut Apic> { + LOCAL_APIC.as_mut() } pub struct Apic { @@ -103,7 +103,7 @@ impl Apic { if !is_apic() { return None; } let mut base_apic = unsafe { Msr::new(APIC_BASE_MSR).read() }; - let apic = Self::from_base_apic(base_apic); + let mut apic = Self::from_base_apic(base_apic); let spurious = apic.get(ApicRegister::SpuriousInterruptVec) | 0x1ff; @@ -116,11 +116,11 @@ impl Apic { apic.set(ApicRegister::LvtLint0, 0); apic.set(ApicRegister::LvtLint1, 0); - apic + Some(apic) } fn from_base_apic(base_apic: u64) -> Self { - Self { reg32: + Self { regs: ((base_apic >> 12) & 0xfffffffff) as *mut [u32; 1024] } } @@ -148,8 +148,8 @@ impl Apic { } pub fn set_timer_interrupt_handler(&mut self, divide: TimerDivideConfig, intr: super::InterruptType) { - apic.set(ApicRegister::LvtTimer, intr.into()); - apic.set(ApicRegister::TimerDivideConfig, divide); - apic.set(ApicRegister::TimerInitialCount, 0xFFFFFFFF) + self.set(ApicRegister::LvtTimer, intr.as_u8().into()); + self.set(ApicRegister::TimerDivideConfig, divide as u32); + self.set(ApicRegister::TimerInitialCount, 0xFFFFFFFF) } } |