authorgravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-16 03:04:37-05:00
committergravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-16 03:04:37-05:00
log03347114c3e5f6238d7871e878e1d2295bdf0260
tree8a83ae562064cc9324d65fc4652bbd6c4556a972
parentc727bd1bb68917f39f03f68765c5db7572069729

std/os/uefi: Add util function for opening protocols


1 files changed, 21 insertions(+), 0 deletions(-)

lib/std/os/uefi/tables/boot_services.zig+21
......@@ -154,6 +154,27 @@ pub const BootServices = extern struct {
154154 /// Creates an event in a group.
155155 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,
156156
157 /// Opens a protocol with a structure as the loaded image for a UEFI application
158 pub fn openProtocolSt(self: *BootServices, comptime protocol: type, handle: Handle) !*protocol {
159 if (!@hasDecl(protocol, "guid"))
160 @compileError("Protocol is missing guid!");
161
162 var ptr: ?*protocol = undefined;
163
164 try self.openProtocol(
165 handle,
166 &protocol.guid,
167 @ptrCast(*?*anyopaque, &ptr),
168 // Invoking handle (loaded image)
169 uefi.handle,
170 // Control handle (null as not a driver)
171 null,
172 uefi.tables.OpenProtocolAttributes{ .by_handle_protocol = true },
173 ).err();
174
175 return ptr.?;
176 }
177
157178 pub const signature: u64 = 0x56524553544f4f42;
158179
159180 pub const event_timer: u32 = 0x80000000;