aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/os/uefi/tables/boot_services.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/std/os/uefi/tables/boot_services.zig b/lib/std/os/uefi/tables/boot_services.zig
index 468aaf4cf7..ee1e72f094 100644
--- a/lib/std/os/uefi/tables/boot_services.zig
+++ b/lib/std/os/uefi/tables/boot_services.zig
@@ -154,6 +154,27 @@ pub const BootServices = extern struct {
/// Creates an event in a group.
createEventEx: fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(.C) Status,
+ /// Opens a protocol with a structure as the loaded image for a UEFI application
+ pub fn openProtocolSt(self: *BootServices, comptime protocol: type, handle: Handle) !*protocol {
+ if (!@hasDecl(protocol, "guid"))
+ @compileError("Protocol is missing guid!");
+
+ var ptr: ?*protocol = undefined;
+
+ try self.openProtocol(
+ handle,
+ &protocol.guid,
+ @ptrCast(*?*anyopaque, &ptr),
+ // Invoking handle (loaded image)
+ uefi.handle,
+ // Control handle (null as not a driver)
+ null,
+ uefi.tables.OpenProtocolAttributes{ .by_handle_protocol = true },
+ ).err();
+
+ return ptr.?;
+ }
+
pub const signature: u64 = 0x56524553544f4f42;
pub const event_timer: u32 = 0x80000000;