diff options
| author | joboet <jonasboettiger@icloud.com> | 2024-08-15 13:28:02 +0200 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2024-09-23 10:29:51 +0200 |
| commit | 5c1c72572479afe98734d5f78fa862abe662c41a (patch) | |
| tree | 4f43788d776b0b1dfc423ef8d9852ece3960f9b3 /library/std/src/sys/pal/uefi | |
| parent | 702987f75b74f789ba227ee04a3d7bb1680c2309 (diff) | |
| download | rust-5c1c72572479afe98734d5f78fa862abe662c41a.tar.gz rust-5c1c72572479afe98734d5f78fa862abe662c41a.zip | |
std: implement the `random` feature
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
Diffstat (limited to 'library/std/src/sys/pal/uefi')
| -rw-r--r-- | library/std/src/sys/pal/uefi/mod.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs index ac22f4ded88..c0ab52f650a 100644 --- a/library/std/src/sys/pal/uefi/mod.rs +++ b/library/std/src/sys/pal/uefi/mod.rs @@ -179,39 +179,6 @@ pub extern "C" fn __rust_abort() { abort_internal(); } -#[inline] -pub fn hashmap_random_keys() -> (u64, u64) { - get_random().unwrap() -} - -fn get_random() -> Option<(u64, u64)> { - use r_efi::protocols::rng; - - let mut buf = [0u8; 16]; - let handles = helpers::locate_handles(rng::PROTOCOL_GUID).ok()?; - for handle in handles { - if let Ok(protocol) = helpers::open_protocol::<rng::Protocol>(handle, rng::PROTOCOL_GUID) { - let r = unsafe { - ((*protocol.as_ptr()).get_rng)( - protocol.as_ptr(), - crate::ptr::null_mut(), - buf.len(), - buf.as_mut_ptr(), - ) - }; - if r.is_error() { - continue; - } else { - return Some(( - u64::from_le_bytes(buf[..8].try_into().ok()?), - u64::from_le_bytes(buf[8..].try_into().ok()?), - )); - } - } - } - None -} - /// Disable access to BootServices if `EVT_SIGNAL_EXIT_BOOT_SERVICES` is signaled extern "efiapi" fn exit_boot_service_handler(_e: r_efi::efi::Event, _ctx: *mut crate::ffi::c_void) { uefi::env::disable_boot_services(); |
