use r_efi::efi;
use super::BootServices;
#[must_use = "if unused the Tpl will immediately restored"]
pub struct TplGuard<'a, T: BootServices + ?Sized> {
pub(crate) boot_services: &'a T,
pub(crate) retore_tpl: Tpl,
}
impl<T: BootServices + ?Sized> Drop for TplGuard<'_, T> {
fn drop(&mut self) {
self.boot_services.restore_tpl(self.retore_tpl);
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
#[repr(transparent)]
pub struct Tpl(pub usize);
impl Tpl {
pub const APPLICATION: Tpl = Tpl(efi::TPL_APPLICATION);
pub const CALLBACK: Tpl = Tpl(efi::TPL_CALLBACK);
pub const NOTIFY: Tpl = Tpl(efi::TPL_NOTIFY);
}
impl From<Tpl> for usize {
fn from(val: Tpl) -> Self {
val.0
}
}
impl From<usize> for Tpl {
fn from(val: usize) -> Self {
Tpl(val)
}
}