1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-24 19:23:46 +02:00
This commit is contained in:
Andrew Walbran 2023-04-06 15:55:29 +01:00
parent f6daca3dde
commit cddf766491
2 changed files with 10 additions and 2 deletions

View File

@ -553,3 +553,11 @@ pub fn irq_enable() {
asm!("msr DAIFClr, #0xf", options(nomem, nostack));
}
}
/// Waits for an interrupt.
pub fn wfi() {
// Safe because this doesn't access memory in any way.
unsafe {
asm!("wfi", options(nomem, nostack));
}
}

View File

@ -23,7 +23,7 @@ mod pl011;
// ANCHOR_END: top
mod pl031;
use crate::gicv3::{irq_enable, GicV3, Trigger, SPI_START};
use crate::gicv3::{irq_enable, wfi, GicV3, Trigger, SPI_START};
use crate::pl031::Rtc;
use chrono::{TimeZone, Utc};
use core::hint::spin_loop;
@ -113,7 +113,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
rtc.interrupt_pending()
);
while !rtc.interrupt_pending() {
spin_loop();
wfi();
}
trace!(
"matched={}, interrupt_pending={}",