32 lines
574 B
Rust
32 lines
574 B
Rust
//! Interrupt instructions
|
|
|
|
static mut INTERRUPTS_ENABLED: bool = false;
|
|
|
|
/// Clear interrupts
|
|
#[inline(always)]
|
|
pub unsafe fn disable() {
|
|
println!("CLEAR INTERRUPTS");
|
|
INTERRUPTS_ENABLED = false;
|
|
}
|
|
|
|
/// Set interrupts
|
|
#[inline(always)]
|
|
pub unsafe fn enable() {
|
|
println!("SET INTERRUPTS");
|
|
INTERRUPTS_ENABLED = true;
|
|
}
|
|
|
|
/// Halt instruction
|
|
#[inline(always)]
|
|
pub unsafe fn halt() {
|
|
assert!(INTERRUPTS_ENABLED);
|
|
::std::thread::yield_now();
|
|
}
|
|
|
|
/// Set interrupts and halt
|
|
#[inline(always)]
|
|
pub unsafe fn enable_and_halt() {
|
|
enable();
|
|
halt();
|
|
}
|