Replace the CpuLocal's borrow* APIs with get_with

This commit is contained in:
Zhang Junyang
2024-08-24 14:03:03 +08:00
committed by Tate, Hongliang Tian
parent f7a9510be0
commit 54cbacb2ff
5 changed files with 36 additions and 41 deletions

View File

@ -35,7 +35,8 @@ static APIC_TYPE: Once<ApicType> = Once::new();
/// });
/// ```
pub fn borrow<R>(f: impl FnOnce(&mut (dyn Apic + 'static)) -> R) -> R {
let apic_guard = APIC_INSTANCE.borrow_irq_disabled();
let irq_guard = crate::trap::disable_local();
let apic_guard = APIC_INSTANCE.get_with(&irq_guard);
// If it is not initialzed, lazily initialize it.
if !apic_guard.is_completed() {