Skip to main content

kernel/arch/x86_64/
instructions.rs

1// SPDX-License-Identifier: GPL-3.0-only
2//! Safe wrappers around x86_64 privileged instructions.
3//!
4//! Authors: MarioS271
5
6use x86_64::instructions;
7
8/// Set the CPU's Interrupt Flag via `sti`; only call once the IDT and PIC are initialized.
9pub fn enable_interrupts() {
10    instructions::interrupts::enable();
11}
12
13/// Clear the CPU's Interrupt Flag via `cli`, masking hardware IRQs (NMIs and exceptions still fire).
14pub fn disable_interrupts() {
15    instructions::interrupts::disable();
16}
17
18/// Issue `hlt`, suspending the CPU until the next interrupt.
19pub fn halt_cpu() {
20    instructions::hlt();
21}