From 6ca1cfbce53c7eeb398c0d3aa611b85cfa76d20d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 7 Aug 2024 01:07:13 -0400 Subject: [PATCH] boot: Add freestanding stall One minor implementation change from the BootServices version: the Status value is ignored rather than asserting it is `SUCCESS`. There shouldn't be any practical difference, as stalling should always succeed. In the unlikely event that some implementation returns an error, a panic is unlikely to be desirable to the caller. --- uefi/src/boot.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/uefi/src/boot.rs b/uefi/src/boot.rs index 2de6cf680..f4d2eb3bd 100644 --- a/uefi/src/boot.rs +++ b/uefi/src/boot.rs @@ -521,6 +521,18 @@ pub unsafe fn exit( ) } +/// Stalls execution for the given number of microseconds. +pub fn stall(microseconds: usize) { + let bt = boot_services_raw_panicking(); + let bt = unsafe { bt.as_ref() }; + + unsafe { + // No error conditions are defined in the spec for this function, so + // ignore the status. + let _ = (bt.stall)(microseconds); + } +} + /// A buffer returned by [`locate_handle_buffer`] that contains an array of /// [`Handle`]s that support the requested protocol. #[derive(Debug, Eq, PartialEq)]