Skip to content

Commit 1f4d898

Browse files
authored
feat: update x2apic to 0.5 (#17)
1 parent 3348822 commit 1f4d898

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

Cargo.lock

Lines changed: 7 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/axplat-x86-pc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ axplat = { workspace = true }
3232

3333
x86 = "0.52"
3434
x86_64 = "0.15.2"
35-
x2apic = "0.4"
35+
x2apic = "0.5"
3636
multiboot = "0.8"
3737
raw-cpuid = "11.5"
3838
uart_16550 = "0.3"

platforms/axplat-x86-pc/src/apic.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Advanced Programmable Interrupt Controller (APIC) support.
22
3-
use core::{cell::SyncUnsafeCell, mem::MaybeUninit};
3+
use core::mem::MaybeUninit;
44

55
use axplat::mem::{PhysAddr, pa, phys_to_virt};
66
use kspin::SpinNoIrq;
@@ -19,8 +19,7 @@ pub(super) mod vectors {
1919

2020
const IO_APIC_BASE: PhysAddr = pa!(0xFEC0_0000);
2121

22-
static LOCAL_APIC: SyncUnsafeCell<MaybeUninit<LocalApic>> =
23-
SyncUnsafeCell::new(MaybeUninit::uninit());
22+
static mut LOCAL_APIC: MaybeUninit<LocalApic> = MaybeUninit::uninit();
2423
static mut IS_X2APIC: bool = false;
2524
static IO_APIC: LazyInit<SpinNoIrq<IoApic>> = LazyInit::new();
2625

@@ -40,9 +39,10 @@ pub fn set_enable(vector: usize, enabled: bool) {
4039
}
4140

4241
#[cfg(any(feature = "smp", feature = "irq"))]
42+
#[allow(static_mut_refs)]
4343
pub fn local_apic<'a>() -> &'a mut LocalApic {
4444
// It's safe as `LOCAL_APIC` is initialized in `init_primary`.
45-
unsafe { LOCAL_APIC.get().as_mut().unwrap().assume_init_mut() }
45+
unsafe { LOCAL_APIC.assume_init_mut() }
4646
}
4747

4848
#[cfg(feature = "smp")]
@@ -88,7 +88,8 @@ pub fn init_primary() {
8888
let mut lapic = builder.build().unwrap();
8989
unsafe {
9090
lapic.enable();
91-
LOCAL_APIC.get().as_mut().unwrap().write(lapic);
91+
#[allow(static_mut_refs)]
92+
LOCAL_APIC.write(lapic);
9293
}
9394

9495
info!("Initialize IO APIC...");
@@ -149,7 +150,7 @@ mod irq_impl {
149150
fn handle(vector: usize) {
150151
trace!("IRQ {}", vector);
151152
if !IRQ_HANDLER_TABLE.handle(vector) {
152-
warn!("Unhandled IRQ {}", vector);
153+
warn!("Unhandled IRQ {vector}");
153154
}
154155
unsafe { super::local_apic().end_of_interrupt() };
155156
}

platforms/axplat-x86-pc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![no_std]
2-
#![feature(sync_unsafe_cell)]
32

43
#[macro_use]
54
extern crate log;

platforms/axplat-x86-pc/src/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn init_primary() {
5454
use x2apic::lapic::{TimerDivide, TimerMode};
5555
let lapic = super::apic::local_apic();
5656
lapic.set_timer_mode(TimerMode::OneShot);
57-
lapic.set_timer_divide(TimerDivide::Div256); // indeed it is Div1, the name is confusing.
57+
lapic.set_timer_divide(TimerDivide::Div1); // indeed it is Div1, the name is confusing.
5858
lapic.enable_timer();
5959

6060
// TODO: calibrate with HPET

0 commit comments

Comments
 (0)