2016-08-14 22:59:18 +02:00
|
|
|
//! Interrupt instructions
|
|
|
|
|
|
|
|
static mut INTERRUPTS_ENABLED: bool = false;
|
|
|
|
|
|
|
|
/// Clear interrupts
|
|
|
|
#[inline(always)]
|
2016-08-18 16:30:45 +02:00
|
|
|
pub unsafe fn disable() {
|
2016-08-14 22:59:18 +02:00
|
|
|
println!("CLEAR INTERRUPTS");
|
|
|
|
INTERRUPTS_ENABLED = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set interrupts
|
|
|
|
#[inline(always)]
|
2016-08-18 16:30:45 +02:00
|
|
|
pub unsafe fn enable() {
|
2016-08-14 22:59:18 +02:00
|
|
|
println!("SET INTERRUPTS");
|
|
|
|
INTERRUPTS_ENABLED = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Halt instruction
|
|
|
|
#[inline(always)]
|
|
|
|
pub unsafe fn halt() {
|
|
|
|
assert!(INTERRUPTS_ENABLED);
|
|
|
|
::std::thread::yield_now();
|
|
|
|
}
|
2016-08-18 16:30:45 +02:00
|
|
|
|
2016-11-14 18:46:53 +01:00
|
|
|
/// Set interrupts and nop
|
|
|
|
#[inline(always)]
|
|
|
|
pub unsafe fn enable_and_nop() {
|
|
|
|
enable();
|
|
|
|
}
|
|
|
|
|
2016-08-18 16:30:45 +02:00
|
|
|
/// Set interrupts and halt
|
|
|
|
#[inline(always)]
|
|
|
|
pub unsafe fn enable_and_halt() {
|
|
|
|
enable();
|
|
|
|
halt();
|
|
|
|
}
|