zig/lib/std /
os/uefi/protocol/service_binding.zig
To add this protocol to an existing handle, use addToHandle instead.
|
const std = @import("std");
const uefi = std.uefi;
const Guid = uefi.Guid;
const Handle = uefi.Handle;
const Status = uefi.Status;
const Error = Status.Error;
const cc = uefi.cc;
|
ServiceBinding()
|
pub fn ServiceBinding(service_guid: Guid) type {
return struct {
const Self = @This();
|
CreateChildError
|
_create_child: *const fn (*Self, *?Handle) callconv(cc) Status,
_destroy_child: *const fn (*Self, Handle) callconv(cc) Status,
|
DestroyChildError
|
pub const CreateChildError = uefi.UnexpectedError || error{
InvalidParameter,
OutOfResources,
} || Error;
pub const DestroyChildError = uefi.UnexpectedError || error{
Unsupported,
InvalidParameter,
AccessDenied,
} || Error;
|
createChild()
|
/// To add this protocol to an existing handle, use `addToHandle` instead.
pub fn createChild(self: *Self) CreateChildError!Handle {
var handle: ?Handle = null;
switch (self._create_child(self, &handle)) {
.success => return handle orelse error.Unexpected,
else => |status| {
try status.err();
return uefi.unexpectedStatus(status);
},
}
}
|
addToHandle()
|
pub fn addToHandle(self: *Self, handle: Handle) CreateChildError!void {
switch (self._create_child(self, @ptrCast(@constCast(&handle)))) {
.success => {},
else => |status| {
try status.err();
return uefi.unexpectedStatus(status);
},
}
}
|
destroyChild()
|
pub fn destroyChild(self: *Self, handle: Handle) DestroyChildError!void {
switch (self._destroy_child(self, handle)) {
.success => {},
else => |status| {
try status.err();
return uefi.unexpectedStatus(status);
},
}
}
|
guid
|
pub const guid align(8) = service_guid;
};
}
|
|