kernel/arch/x86_64/cpu/instructions.rs
1// SPDX-License-Identifier: GPL-3.0-only
2//! Safe wrappers around x86_64 privileged instructions
3//!
4//! Authors: MarioS271
5
6use core::arch::asm;
7
8/// Set the CPU's Interrupt Flag via `sti`, unmasking hardware IRQs
9pub fn enable_interrupts() {
10 unsafe { asm!("sti", options(nostack, nomem)) };
11}
12
13/// Clear the CPU's Interrupt Flag via `cli`, masking hardware IRQs (CPU exceptions like `#PF`, `#MC` or NMI can still fire)
14pub fn disable_interrupts() {
15 unsafe { asm!("cli", options(nostack, nomem)) };
16}
17
18/// Halt the CPU until an interrupt arrives
19pub fn halt_cpu() {
20 unsafe { asm!("hlt", options(nostack)) }
21}