Function openProtocol [src]
Opens a protocol with a structure as the loaded image for a UEFI application
If flag is .test_protocol, then the only valid return value is null,
and Status.unsupported is returned. Otherwise, if _openProtocol returns
Status.unsupported, then null is returned.
Prototype
pub fn openProtocol( self: *BootServices, Protocol: type, handle: Handle, attributes: OpenProtocolArgs, ) OpenProtocolError!?*Protocol Parameters
self: *BootServicesProtocol: typehandle: Handleattributes: OpenProtocolArgs Possible Errors
Source
pub fn openProtocol(
self: *BootServices,
Protocol: type,
handle: Handle,
attributes: OpenProtocolArgs,
) OpenProtocolError!?*Protocol {
if (!@hasDecl(Protocol, "guid"))
@compileError("Protocol is missing guid: " ++ @typeName(Protocol));
const agent_handle: ?Handle, const controller_handle: ?Handle = switch (attributes) {
inline else => |arg| .{ arg.agent, arg.controller },
};
var ptr: ?*Protocol = undefined;
switch (self._openProtocol(
handle,
&Protocol.guid,
@as(*?*anyopaque, @ptrCast(&ptr)),
agent_handle,
controller_handle,
std.meta.activeTag(attributes),
)) {
.success => return if (attributes == .test_protocol) null else ptr,
.unsupported => return if (attributes == .test_protocol) error.Unsupported else null,
.access_denied => return error.AccessDenied,
.already_started => return error.AlreadyStarted,
else => |status| return uefi.unexpectedStatus(status),
}
}