about summary refs log tree commit diff
path: root/library/std/src/sys/uefi/helpers.rs
diff options
context:
space:
mode:
authorAyush Singh <ayushdevel1325@gmail.com>2023-10-02 17:00:09 +0530
committerAyush Singh <ayushdevel1325@gmail.com>2023-10-15 18:45:13 +0530
commit6713ae9d4262976aed77083b322b981c12d6a432 (patch)
tree515e7b10a18bfce069379e684c160b39c8544005 /library/std/src/sys/uefi/helpers.rs
parent15783292e5e26336f76ddc2123d66025ec6d84b7 (diff)
downloadrust-6713ae9d4262976aed77083b322b981c12d6a432.tar.gz
rust-6713ae9d4262976aed77083b322b981c12d6a432.zip
Implement args for UEFI
- Uses `EFI_LOADED_IMAGE_PROTOCOL`
- verify that cli args are valid UTF-16
- Update Docs

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
Diffstat (limited to 'library/std/src/sys/uefi/helpers.rs')
-rw-r--r--library/std/src/sys/uefi/helpers.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/std/src/sys/uefi/helpers.rs b/library/std/src/sys/uefi/helpers.rs
index 126661bfc96..9837cc89f2d 100644
--- a/library/std/src/sys/uefi/helpers.rs
+++ b/library/std/src/sys/uefi/helpers.rs
@@ -139,3 +139,10 @@ pub(crate) unsafe fn close_event(evt: NonNull<crate::ffi::c_void>) -> io::Result
 
     if r.is_error() { Err(crate::io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
 }
+
+/// Get the Protocol for current system handle.
+/// Note: Some protocols need to be manually freed. It is the callers responsibility to do so.
+pub(crate) fn image_handle_protocol<T>(protocol_guid: Guid) -> Option<NonNull<T>> {
+    let system_handle = uefi::env::try_image_handle()?;
+    open_protocol(system_handle, protocol_guid).ok()
+}