use core::time::Duration;
#[cfg(not(feature = "uefi"))]
use std::thread;
#[cfg(feature = "uefi")]
use alloc::string::{String, ToString};
#[cfg(feature = "uefi")]
pub fn get_os_version() -> String {
"UEFI".to_string()
}
#[cfg(target_family = "windows")]
pub fn get_os_version() -> String {
let ver = windows_version::OsVersion::current();
format!("{}.{}.{}.{}", ver.major, ver.minor, ver.pack, ver.build)
}
#[cfg(target_family = "unix")]
pub fn get_os_version() -> String {
if let Ok(uts) = nix::sys::utsname::uname() {
format!(
"{} {} {} {}",
uts.sysname().to_string_lossy(),
uts.release().to_string_lossy(),
uts.version().to_string_lossy(),
uts.machine().to_string_lossy(),
)
} else {
"Unknown".to_string()
}
}
pub fn sleep(micros: u64) {
let duration = Duration::from_micros(micros);
#[cfg(not(feature = "uefi"))]
{
thread::sleep(duration);
}
#[cfg(feature = "uefi")]
{
uefi::boot::stall(duration);
}
}