diff --git a/src/acpi/madt/arch/x86.rs b/src/acpi/madt/arch/x86.rs index 7035e47ac4..0956a5e806 100644 --- a/src/acpi/madt/arch/x86.rs +++ b/src/acpi/madt/arch/x86.rs @@ -1,8 +1,10 @@ -use core::sync::atomic::{AtomicU8, Ordering}; +use core::{ + hint, + sync::atomic::{AtomicU8, Ordering}, +}; use crate::{ device::local_apic::the_local_apic, - interrupt, memory::{allocate_p2frame, Frame, KernelMapper}, paging::{Page, PageFlags, PhysicalAddress, RmmA, RmmArch, VirtualAddress, PAGE_SIZE}, start::{kstart_ap, AP_READY, CPU_COUNT}, @@ -127,11 +129,11 @@ pub(super) fn init(madt: Madt) { while unsafe { (*ap_ready.cast::()).load(Ordering::SeqCst) } == 0 { - interrupt::pause(); + hint::spin_loop(); } print!(" Trampoline..."); while !AP_READY.load(Ordering::SeqCst) { - interrupt::pause(); + hint::spin_loop(); } println!(" Ready"); diff --git a/src/arch/aarch64/interrupt/mod.rs b/src/arch/aarch64/interrupt/mod.rs index ad9d12e8f0..82a97ece80 100644 --- a/src/arch/aarch64/interrupt/mod.rs +++ b/src/arch/aarch64/interrupt/mod.rs @@ -50,13 +50,6 @@ pub unsafe fn halt() { } } -/// Pause instruction -/// Safe because it is similar to a NOP, and has no memory effects -#[inline(always)] -pub fn pause() { - unsafe { asm!("nop") }; -} - #[inline(always)] pub unsafe fn init() { unsafe { diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index d087139922..9fea42d816 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -1,9 +1,11 @@ -/// This function is where the kernel sets up IRQ handlers -/// It is increcibly unsafe, and should be minimal in nature -/// It must create the IDT with the correct entries, those entries are -/// defined in other files inside of the `arch` module -use core::slice; -use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; +//! This function is where the kernel sets up IRQ handlers +//! It is increcibly unsafe, and should be minimal in nature +//! It must create the IDT with the correct entries, those entries are +//! defined in other files inside of the `arch` module +use core::{ + slice, + sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}, +}; use fdt::Fdt; diff --git a/src/arch/riscv64/interrupt/mod.rs b/src/arch/riscv64/interrupt/mod.rs index 9b191cbbab..89b30a1db2 100644 --- a/src/arch/riscv64/interrupt/mod.rs +++ b/src/arch/riscv64/interrupt/mod.rs @@ -43,16 +43,6 @@ pub unsafe fn halt() { unsafe { asm!("wfi", options(nomem, nostack)) } } -/// Pause instruction -/// Safe because it is similar to a NOP, and has no memory effects -#[inline(always)] -pub fn pause() { - unsafe { - // It's a hint instruction, safe to execute without Zihintpause extension - asm!("pause", options(nomem, nostack)); - } -} - #[inline(always)] pub unsafe fn init() { unsafe { diff --git a/src/arch/x86_shared/interrupt/mod.rs b/src/arch/x86_shared/interrupt/mod.rs index 0eb966c5bb..5502cc01f6 100644 --- a/src/arch/x86_shared/interrupt/mod.rs +++ b/src/arch/x86_shared/interrupt/mod.rs @@ -42,12 +42,3 @@ pub unsafe fn halt() { core::arch::asm!("hlt", options(nomem, nostack)); } } - -/// Pause instruction -/// Safe because it is similar to a NOP, and has no memory effects -#[inline(always)] -pub fn pause() { - unsafe { - core::arch::asm!("pause", options(nomem, nostack)); - } -} diff --git a/src/arch/x86_shared/start.rs b/src/arch/x86_shared/start.rs index b456864fa2..30a1124c36 100644 --- a/src/arch/x86_shared/start.rs +++ b/src/arch/x86_shared/start.rs @@ -1,10 +1,10 @@ -/// This function is where the kernel sets up IRQ handlers -/// It is increcibly unsafe, and should be minimal in nature -/// It must create the IDT with the correct entries, those entries are -/// defined in other files inside of the `arch` module -use core::slice; +//! This function is where the kernel sets up IRQ handlers +//! It is increcibly unsafe, and should be minimal in nature +//! It must create the IDT with the correct entries, those entries are +//! defined in other files inside of the `arch` module use core::{ cell::SyncUnsafeCell, + hint, slice, sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}, }; @@ -294,7 +294,7 @@ pub unsafe extern "C" fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! { }; while !BSP_READY.load(Ordering::SeqCst) { - interrupt::pause(); + hint::spin_loop(); } crate::kmain_ap(cpu_id); diff --git a/src/context/switch.rs b/src/context/switch.rs index 84b95e2efb..033b7cb212 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -3,7 +3,7 @@ ///! handling process states and synchronization. use core::{ cell::{Cell, RefCell}, - mem, + hint, mem, ops::Bound, sync::atomic::Ordering, }; @@ -15,7 +15,7 @@ use syscall::PtraceFlags; use crate::{ context::{arch, contexts, Context}, cpu_set::LogicalCpuId, - cpu_stats, interrupt, + cpu_stats, percpu::PercpuBlock, ptrace, time, }; @@ -153,7 +153,7 @@ pub fn switch() -> SwitchResult { .compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed) .is_err() { - interrupt::pause(); + hint::spin_loop(); percpu.maybe_handle_tlb_shootdown(); }