File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
kernel/src/interrupts/apic Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use crate::memory::protection;
55use crate :: { get_hhdm_offset, libs:: acpi:: ACPI_INFO } ;
66use log:: debug;
77use raw_cpuid:: CpuId ;
8- use spin:: Mutex ;
8+ use spin:: Once ;
99use x86_64:: registers:: model_specific:: Msr ;
1010
1111pub mod ioapic;
@@ -44,9 +44,7 @@ pub struct LocalApic {
4444 base : u64 , // Virtual base address for xAPIC
4545}
4646
47- lazy_static:: lazy_static! {
48- pub static ref LAPIC : Mutex <Option <LocalApic >> = Mutex :: new( None ) ;
49- }
47+ pub static LAPIC : Once < LocalApic > = Once :: new ( ) ;
5048
5149impl LocalApic {
5250 pub unsafe fn new ( ) -> Self {
@@ -152,7 +150,7 @@ impl LocalApic {
152150}
153151
154152pub fn end_of_interrupt ( ) {
155- if let Some ( lapic) = LAPIC . lock ( ) . as_ref ( ) {
153+ if let Some ( lapic) = LAPIC . get ( ) {
156154 unsafe { lapic. eoi ( ) } ;
157155 }
158156}
@@ -168,6 +166,6 @@ pub fn init() {
168166 let lapic = LocalApic :: new ( ) ;
169167 lapic. init ( ) ;
170168 lapic. calibrate_timer ( ) ;
171- * LAPIC . lock ( ) = Some ( lapic) ;
169+ LAPIC . call_once ( || lapic) ;
172170 }
173171}
You can’t perform that action at this time.
0 commit comments