x86-64: implement ACPI stall function
This commit is contained in:
parent
12e3e2fe28
commit
b00670ea77
@ -24,6 +24,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
mem::{heap::GLOBAL_HEAP, ConvertAddress},
|
mem::{heap::GLOBAL_HEAP, ConvertAddress},
|
||||||
sync::IrqSafeSpinlock,
|
sync::IrqSafeSpinlock,
|
||||||
|
util,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::intrinsics;
|
use super::intrinsics;
|
||||||
@ -198,6 +199,10 @@ impl acpi_system::Handler for AcpiHandlerImpl {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stall(duration: Duration) {
|
||||||
|
util::polling_sleep(duration).ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl aml::Handler for AcpiHandlerImpl {
|
impl aml::Handler for AcpiHandlerImpl {
|
||||||
|
@ -46,6 +46,7 @@ pub mod proc;
|
|||||||
pub mod sync;
|
pub mod sync;
|
||||||
pub mod syscall;
|
pub mod syscall;
|
||||||
pub mod task;
|
pub mod task;
|
||||||
|
pub mod util;
|
||||||
|
|
||||||
static CPU_INIT_FENCE: SpinFence = SpinFence::new();
|
static CPU_INIT_FENCE: SpinFence = SpinFence::new();
|
||||||
|
|
||||||
|
16
src/util.rs
Normal file
16
src/util.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use core::time::Duration;
|
||||||
|
|
||||||
|
use yggdrasil_abi::error::Error;
|
||||||
|
|
||||||
|
use crate::arch::{Architecture, ARCHITECTURE};
|
||||||
|
|
||||||
|
pub fn polling_sleep(duration: Duration) -> Result<(), Error> {
|
||||||
|
let timer = ARCHITECTURE.monotonic_timer();
|
||||||
|
let deadline = timer.monotonic_timestamp()? + duration;
|
||||||
|
|
||||||
|
while timer.monotonic_timestamp()? < deadline {
|
||||||
|
core::hint::spin_loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user