Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/instructions/interrupts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Enabling and disabling interrupts

use core::arch::asm;
use core::sync::atomic::{compiler_fence, Ordering};

/// Returns whether interrupts are enabled.
#[inline]
Expand All @@ -15,6 +16,8 @@ pub fn are_enabled() -> bool {
/// This is a wrapper around the `sti` instruction.
#[inline]
pub fn enable() {
// Prevent earlier writes to be moved beyond this point
compiler_fence(Ordering::Release);
unsafe {
asm!("sti", options(nomem, nostack));
}
Expand All @@ -25,6 +28,8 @@ pub fn enable() {
/// This is a wrapper around the `cli` instruction.
#[inline]
pub fn disable() {
// Prevent future writes to be moved before this point.
compiler_fence(Ordering::Acquire);
unsafe {
asm!("cli", options(nomem, nostack));
}
Expand Down