authorgravatar for carmen@dotcarmen.devCarmen <carmen@dotcarmen.dev> 2025-04-01 03:47:51-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-04-01 10:47:51+00:00
logfa86e09fb39c8007c7b63e70ed7db1afc7022476
treede1aeccdded0b5fc25a791b50af469f9bd1e967c
parentb636d56d6a71b9ed521de7fccb519b7d0fa3db90
signaturebadge-check Signed by PGP key B5690EEEBB952194

std.os.uefi.protocol: ziggify function signatures (#23214)


27 files changed, 2075 insertions(+), 469 deletions(-)

lib/std/debug.zig+3-3
...@@ -629,9 +629,9 @@ pub fn defaultPanic(...@@ -629,9 +629,9 @@ pub fn defaultPanic(
629 // isn't visible on actual hardware if directly booted into629 // isn't visible on actual hardware if directly booted into
630 inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| {630 inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| {
631 if (o) |out| {631 if (o) |out| {
632 _ = out.setAttribute(uefi.protocol.SimpleTextOutput.red);632 out.setAttribute(.{ .foreground = .red }) catch {};
633 _ = out.outputString(exit_msg);633 _ = out.outputString(exit_msg) catch {};
634 _ = out.setAttribute(uefi.protocol.SimpleTextOutput.white);634 out.setAttribute(.{ .foreground = .white }) catch {};
635 }635 }
636 }636 }
637637
lib/std/os/uefi.zig+13-53
...@@ -43,6 +43,11 @@ pub const Ipv6Address = extern struct {...@@ -43,6 +43,11 @@ pub const Ipv6Address = extern struct {
43 address: [16]u8,43 address: [16]u8,
44};44};
4545
46pub const IpAddress = extern union {
47 v4: Ipv4Address,
48 v6: Ipv6Address,
49};
50
46/// GUIDs are align(8) unless otherwise specified.51/// GUIDs are align(8) unless otherwise specified.
47pub const Guid = extern struct {52pub const Guid = extern struct {
48 time_low: u32,53 time_low: u32,
...@@ -190,60 +195,15 @@ test "GUID formatting" {...@@ -190,60 +195,15 @@ test "GUID formatting" {
190 try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));195 try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));
191}196}
192197
193pub const FileInfo = extern struct {
194 size: u64,
195 file_size: u64,
196 physical_size: u64,
197 create_time: Time,
198 last_access_time: Time,
199 modification_time: Time,
200 attribute: u64,
201
202 pub fn getFileName(self: *const FileInfo) [*:0]const u16 {
203 return @ptrCast(@alignCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FileInfo)));
204 }
205
206 pub const efi_file_read_only: u64 = 0x0000000000000001;
207 pub const efi_file_hidden: u64 = 0x0000000000000002;
208 pub const efi_file_system: u64 = 0x0000000000000004;
209 pub const efi_file_reserved: u64 = 0x0000000000000008;
210 pub const efi_file_directory: u64 = 0x0000000000000010;
211 pub const efi_file_archive: u64 = 0x0000000000000020;
212 pub const efi_file_valid_attr: u64 = 0x0000000000000037;
213
214 pub const guid align(8) = Guid{
215 .time_low = 0x09576e92,
216 .time_mid = 0x6d3f,
217 .time_high_and_version = 0x11d2,
218 .clock_seq_high_and_reserved = 0x8e,
219 .clock_seq_low = 0x39,
220 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
221 };
222};
223
224pub const FileSystemInfo = extern struct {
225 size: u64,
226 read_only: bool,
227 volume_size: u64,
228 free_space: u64,
229 block_size: u32,
230 _volume_label: u16,
231
232 pub fn getVolumeLabel(self: *const FileSystemInfo) [*:0]const u16 {
233 return @as([*:0]const u16, @ptrCast(&self._volume_label));
234 }
235
236 pub const guid align(8) = Guid{
237 .time_low = 0x09576e93,
238 .time_mid = 0x6d3f,
239 .time_high_and_version = 0x11d2,
240 .clock_seq_high_and_reserved = 0x8e,
241 .clock_seq_low = 0x39,
242 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
243 };
244};
245
246test {198test {
247 _ = tables;199 _ = tables;
248 _ = protocol;200 _ = protocol;
249}201}
202
203pub const UnexpectedError = error{Unexpected};
204
205pub fn unexpectedStatus(status: Status) UnexpectedError {
206 // TODO: debug printing the encountered error? maybe handle warnings?
207 _ = status;
208 return error.Unexpected;
209}
lib/std/os/uefi/protocol.zig+21-2
...@@ -1,3 +1,8 @@...@@ -1,3 +1,8 @@
1const std = @import("std");
2const uefi = std.os.uefi;
3
4pub const ServiceBinding = @import("protocol/service_binding.zig").ServiceBinding;
5
1pub const LoadedImage = @import("protocol/loaded_image.zig").LoadedImage;6pub const LoadedImage = @import("protocol/loaded_image.zig").LoadedImage;
2pub const DevicePath = @import("protocol/device_path.zig").DevicePath;7pub const DevicePath = @import("protocol/device_path.zig").DevicePath;
3pub const Rng = @import("protocol/rng.zig").Rng;8pub const Rng = @import("protocol/rng.zig").Rng;
...@@ -23,11 +28,25 @@ pub const edid = @import("protocol/edid.zig");...@@ -23,11 +28,25 @@ pub const edid = @import("protocol/edid.zig");
23pub const SimpleNetwork = @import("protocol/simple_network.zig").SimpleNetwork;28pub const SimpleNetwork = @import("protocol/simple_network.zig").SimpleNetwork;
24pub const ManagedNetwork = @import("protocol/managed_network.zig").ManagedNetwork;29pub const ManagedNetwork = @import("protocol/managed_network.zig").ManagedNetwork;
2530
26pub const Ip6ServiceBinding = @import("protocol/ip6_service_binding.zig").Ip6ServiceBinding;31pub const Ip6ServiceBinding = ServiceBinding(.{
32 .time_low = 0xec835dd3,
33 .time_mid = 0xfe0f,
34 .time_high_and_version = 0x617b,
35 .clock_seq_high_and_reserved = 0xa6,
36 .clock_seq_low = 0x21,
37 .node = [_]u8{ 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 },
38});
27pub const Ip6 = @import("protocol/ip6.zig").Ip6;39pub const Ip6 = @import("protocol/ip6.zig").Ip6;
28pub const Ip6Config = @import("protocol/ip6_config.zig").Ip6Config;40pub const Ip6Config = @import("protocol/ip6_config.zig").Ip6Config;
2941
30pub const Udp6ServiceBinding = @import("protocol/udp6_service_binding.zig").Udp6ServiceBinding;42pub const Udp6ServiceBinding = ServiceBinding(.{
43 .time_low = 0x66ed4721,
44 .time_mid = 0x3c98,
45 .time_high_and_version = 0x4d3e,
46 .clock_seq_high_and_reserved = 0x81,
47 .clock_seq_low = 0xe3,
48 .node = [_]u8{ 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54 },
49});
31pub const Udp6 = @import("protocol/udp6.zig").Udp6;50pub const Udp6 = @import("protocol/udp6.zig").Udp6;
3251
33pub const HiiDatabase = @import("protocol/hii_database.zig").HiiDatabase;52pub const HiiDatabase = @import("protocol/hii_database.zig").HiiDatabase;
lib/std/os/uefi/protocol/absolute_pointer.zig+19-5
...@@ -4,22 +4,36 @@ const Event = uefi.Event;...@@ -4,22 +4,36 @@ const Event = uefi.Event;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Protocol for touchscreens.9/// Protocol for touchscreens.
9pub const AbsolutePointer = extern struct {10pub const AbsolutePointer = extern struct {
10 _reset: *const fn (*const AbsolutePointer, bool) callconv(cc) Status,11 _reset: *const fn (*AbsolutePointer, bool) callconv(cc) Status,
11 _get_state: *const fn (*const AbsolutePointer, *State) callconv(cc) Status,12 _get_state: *const fn (*const AbsolutePointer, *State) callconv(cc) Status,
12 wait_for_input: Event,13 wait_for_input: Event,
13 mode: *Mode,14 mode: *Mode,
1415
16 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
17 pub const GetStateError = uefi.UnexpectedError || error{ NotReady, DeviceError };
18
15 /// Resets the pointer device hardware.19 /// Resets the pointer device hardware.
16 pub fn reset(self: *const AbsolutePointer, verify: bool) Status {20 pub fn reset(self: *AbsolutePointer, verify: bool) ResetError!void {
17 return self._reset(self, verify);21 switch (self._reset(self, verify)) {
22 .success => {},
23 .device_error => return Error.DeviceError,
24 else => |status| return uefi.unexpectedStatus(status),
25 }
18 }26 }
1927
20 /// Retrieves the current state of a pointer device.28 /// Retrieves the current state of a pointer device.
21 pub fn getState(self: *const AbsolutePointer, state: *State) Status {29 pub fn getState(self: *const AbsolutePointer) GetStateError!State {
22 return self._get_state(self, state);30 var state: State = undefined;
31 switch (self._get_state(self, &state)) {
32 .success => return state,
33 .not_ready => return Error.NotReady,
34 .device_error => return Error.DeviceError,
35 else => |status| return uefi.unexpectedStatus(status),
36 }
23 }37 }
2438
25 pub const guid align(8) = Guid{39 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/block_io.zig+55-9
...@@ -2,6 +2,7 @@ const std = @import("std");...@@ -2,6 +2,7 @@ const std = @import("std");
2const uefi = std.os.uefi;2const uefi = std.os.uefi;
3const Status = uefi.Status;3const Status = uefi.Status;
4const cc = uefi.cc;4const cc = uefi.cc;
5const Error = Status.Error;
56
6pub const BlockIo = extern struct {7pub const BlockIo = extern struct {
7 const Self = @This();8 const Self = @This();
...@@ -11,27 +12,72 @@ pub const BlockIo = extern struct {...@@ -11,27 +12,72 @@ pub const BlockIo = extern struct {
1112
12 _reset: *const fn (*BlockIo, extended_verification: bool) callconv(cc) Status,13 _reset: *const fn (*BlockIo, extended_verification: bool) callconv(cc) Status,
13 _read_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,14 _read_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
14 _write_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,15 _write_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]const u8) callconv(cc) Status,
15 _flush_blocks: *const fn (*BlockIo) callconv(cc) Status,16 _flush_blocks: *const fn (*BlockIo) callconv(cc) Status,
1617
18 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
19 pub const ReadBlocksError = uefi.UnexpectedError || error{
20 DeviceError,
21 NoMedia,
22 BadBufferSize,
23 InvalidParameter,
24 };
25 pub const WriteBlocksError = uefi.UnexpectedError || error{
26 WriteProtected,
27 NoMedia,
28 MediaChanged,
29 DeviceError,
30 BadBufferSize,
31 InvalidParameter,
32 };
33 pub const FlushBlocksError = uefi.UnexpectedError || error{
34 DeviceError,
35 NoMedia,
36 };
37
17 /// Resets the block device hardware.38 /// Resets the block device hardware.
18 pub fn reset(self: *Self, extended_verification: bool) Status {39 pub fn reset(self: *Self, extended_verification: bool) ResetError!void {
19 return self._reset(self, extended_verification);40 switch (self._reset(self, extended_verification)) {
41 .success => {},
42 .device_error => return Error.DeviceError,
43 else => |status| return uefi.unexpectedStatus(status),
44 }
20 }45 }
2146
22 /// Reads the number of requested blocks from the device.47 /// Reads the number of requested blocks from the device.
23 pub fn readBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {48 pub fn readBlocks(self: *Self, media_id: u32, lba: u64, buf: []u8) ReadBlocksError!void {
24 return self._read_blocks(self, media_id, lba, buffer_size, buf);49 switch (self._read_blocks(self, media_id, lba, buf.len, buf.ptr)) {
50 .success => {},
51 .device_error => return Error.DeviceError,
52 .no_media => return Error.NoMedia,
53 .bad_buffer_size => return Error.BadBufferSize,
54 .invalid_parameter => return Error.InvalidParameter,
55 else => |status| return uefi.unexpectedStatus(status),
56 }
25 }57 }
2658
27 /// Writes a specified number of blocks to the device.59 /// Writes a specified number of blocks to the device.
28 pub fn writeBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {60 pub fn writeBlocks(self: *Self, media_id: u32, lba: u64, buf: []const u8) WriteBlocksError!void {
29 return self._write_blocks(self, media_id, lba, buffer_size, buf);61 switch (self._write_blocks(self, media_id, lba, buf.len, buf.ptr)) {
62 .success => {},
63 .write_protected => return Error.WriteProtected,
64 .no_media => return Error.NoMedia,
65 .media_changed => return Error.MediaChanged,
66 .device_error => return Error.DeviceError,
67 .bad_buffer_size => return Error.BadBufferSize,
68 .invalid_parameter => return Error.InvalidParameter,
69 else => |status| return uefi.unexpectedStatus(status),
70 }
30 }71 }
3172
32 /// Flushes all modified data to a physical block device.73 /// Flushes all modified data to a physical block device.
33 pub fn flushBlocks(self: *Self) Status {74 pub fn flushBlocks(self: *Self) FlushBlocksError!void {
34 return self._flush_blocks(self);75 switch (self._flush_blocks(self)) {
76 .success => {},
77 .device_error => return Error.DeviceError,
78 .no_media => return Error.NoMedia,
79 else => |status| return uefi.unexpectedStatus(status),
80 }
35 }81 }
3682
37 pub const guid align(8) = uefi.Guid{83 pub const guid align(8) = uefi.Guid{
lib/std/os/uefi/protocol/device_path.zig+14-6
...@@ -13,6 +13,8 @@ pub const DevicePath = extern struct {...@@ -13,6 +13,8 @@ pub const DevicePath = extern struct {
13 subtype: u8,13 subtype: u8,
14 length: u16 align(1),14 length: u16 align(1),
1515
16 pub const CreateFileDevicePathError = Allocator.Error;
17
16 pub const guid align(8) = Guid{18 pub const guid align(8) = Guid{
17 .time_low = 0x09576e91,19 .time_low = 0x09576e91,
18 .time_mid = 0x6d3f,20 .time_mid = 0x6d3f,
...@@ -23,15 +25,17 @@ pub const DevicePath = extern struct {...@@ -23,15 +25,17 @@ pub const DevicePath = extern struct {
23 };25 };
2426
25 /// Returns the next DevicePath node in the sequence, if any.27 /// Returns the next DevicePath node in the sequence, if any.
26 pub fn next(self: *DevicePath) ?*DevicePath {28 pub fn next(self: *const DevicePath) ?*const DevicePath {
27 if (self.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .end_entire)29 const bytes: [*]const u8 = @ptrCast(self);
30 const next_node: *const DevicePath = @ptrCast(bytes + self.length);
31 if (next_node.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .end_entire)
28 return null;32 return null;
2933
30 return @as(*DevicePath, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length));34 return next_node;
31 }35 }
3236
33 /// Calculates the total length of the device path structure in bytes, including the end of device path node.37 /// Calculates the total length of the device path structure in bytes, including the end of device path node.
34 pub fn size(self: *DevicePath) usize {38 pub fn size(self: *const DevicePath) usize {
35 var node = self;39 var node = self;
3640
37 while (node.next()) |next_node| {41 while (node.next()) |next_node| {
...@@ -42,7 +46,11 @@ pub const DevicePath = extern struct {...@@ -42,7 +46,11 @@ pub const DevicePath = extern struct {
42 }46 }
4347
44 /// Creates a file device path from the existing device path and a file path.48 /// Creates a file device path from the existing device path and a file path.
45 pub fn create_file_device_path(self: *DevicePath, allocator: Allocator, path: [:0]align(1) const u16) !*DevicePath {49 pub fn createFileDevicePath(
50 self: *const DevicePath,
51 allocator: Allocator,
52 path: []const u16,
53 ) CreateFileDevicePathError!*const DevicePath {
46 const path_size = self.size();54 const path_size = self.size();
4755
48 // 2 * (path.len + 1) for the path and its null terminator, which are u16s56 // 2 * (path.len + 1) for the path and its null terminator, which are u16s
...@@ -67,7 +75,7 @@ pub const DevicePath = extern struct {...@@ -67,7 +75,7 @@ pub const DevicePath = extern struct {
6775
68 ptr[path.len] = 0;76 ptr[path.len] = 0;
6977
70 var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@as(*DevicePath, @ptrCast(new)).next().?));78 var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@constCast(@as(*DevicePath, @ptrCast(new)).next().?)));
71 end.type = .end;79 end.type = .end;
72 end.subtype = .end_entire;80 end.subtype = .end_entire;
73 end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath);81 end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath);
lib/std/os/uefi/protocol/edid.zig+25-9
...@@ -4,6 +4,7 @@ const Guid = uefi.Guid;...@@ -4,6 +4,7 @@ const Guid = uefi.Guid;
4const Handle = uefi.Handle;4const Handle = uefi.Handle;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// EDID information for an active video output device9/// EDID information for an active video output device
9pub const Active = extern struct {10pub const Active = extern struct {
...@@ -37,17 +38,27 @@ pub const Discovered = extern struct {...@@ -37,17 +38,27 @@ pub const Discovered = extern struct {
3738
38/// Override EDID information39/// Override EDID information
39pub const Override = extern struct {40pub const Override = extern struct {
40 _get_edid: *const fn (*const Override, Handle, *Attributes, *usize, *?[*]u8) callconv(cc) Status,41 _get_edid: *const fn (*const Override, *const Handle, *Attributes, *usize, *?[*]u8) callconv(cc) Status,
42
43 pub const GetEdidError = uefi.UnexpectedError || error{
44 Unsupported,
45 };
4146
42 /// Returns policy information and potentially a replacement EDID for the specified video output device.47 /// Returns policy information and potentially a replacement EDID for the specified video output device.
43 pub fn getEdid(48 pub fn getEdid(self: *const Override, handle: Handle) GetEdidError!Edid {
44 self: *const Override,49 var size: usize = undefined;
45 handle: Handle,50 var ptr: ?[*]u8 = undefined;
46 attributes: *Attributes,51 var attributes: Attributes = undefined;
47 edid_size: *usize,52 switch (self._get_edid(self, &handle, &attributes, &size, &ptr)) {
48 edid: *?[*]u8,53 .success => {},
49 ) Status {54 .unsupported => return Error.Unsupported,
50 return self._get_edid(self, handle, attributes, edid_size, edid);55 else => |status| return uefi.unexpectedStatus(status),
56 }
57
58 return .{
59 .attributes = attributes,
60 .edid = if (ptr) |p| p[0..size] else null,
61 };
51 }62 }
5263
53 pub const guid align(8) = Guid{64 pub const guid align(8) = Guid{
...@@ -59,6 +70,11 @@ pub const Override = extern struct {...@@ -59,6 +70,11 @@ pub const Override = extern struct {
59 .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },70 .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },
60 };71 };
6172
73 pub const Edid = struct {
74 attributes: Attributes,
75 edid: ?[]u8,
76 };
77
62 pub const Attributes = packed struct(u32) {78 pub const Attributes = packed struct(u32) {
63 dont_override: bool,79 dont_override: bool,
64 enable_hot_plug: bool,80 enable_hot_plug: bool,
lib/std/os/uefi/protocol/file.zig+301-84
...@@ -5,28 +5,89 @@ const Guid = uefi.Guid;...@@ -5,28 +5,89 @@ const Guid = uefi.Guid;
5const Time = uefi.Time;5const Time = uefi.Time;
6const Status = uefi.Status;6const Status = uefi.Status;
7const cc = uefi.cc;7const cc = uefi.cc;
8const Error = Status.Error;
89
9pub const File = extern struct {10pub const File = extern struct {
10 revision: u64,11 revision: u64,
11 _open: *const fn (*const File, **const File, [*:0]const u16, u64, u64) callconv(cc) Status,12 _open: *const fn (*const File, **File, [*:0]const u16, u64, u64) callconv(cc) Status,
12 _close: *const fn (*const File) callconv(cc) Status,13 _close: *const fn (*File) callconv(cc) Status,
13 _delete: *const fn (*const File) callconv(cc) Status,14 _delete: *const fn (*File) callconv(cc) Status,
14 _read: *const fn (*const File, *usize, [*]u8) callconv(cc) Status,15 _read: *const fn (*File, *usize, [*]u8) callconv(cc) Status,
15 _write: *const fn (*const File, *usize, [*]const u8) callconv(cc) Status,16 _write: *const fn (*File, *usize, [*]const u8) callconv(cc) Status,
16 _get_position: *const fn (*const File, *u64) callconv(cc) Status,17 _get_position: *const fn (*const File, *u64) callconv(cc) Status,
17 _set_position: *const fn (*const File, u64) callconv(cc) Status,18 _set_position: *const fn (*File, u64) callconv(cc) Status,
18 _get_info: *const fn (*const File, *align(8) const Guid, *const usize, [*]u8) callconv(cc) Status,19 _get_info: *const fn (*const File, *align(8) const Guid, *const usize, [*]u8) callconv(cc) Status,
19 _set_info: *const fn (*const File, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status,20 _set_info: *const fn (*File, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status,
20 _flush: *const fn (*const File) callconv(cc) Status,21 _flush: *const fn (*File) callconv(cc) Status,
2122
22 pub const SeekError = error{SeekError};23 pub const OpenError = uefi.UnexpectedError || error{
23 pub const GetSeekPosError = error{GetSeekPosError};24 NotFound,
24 pub const ReadError = error{ReadError};25 NoMedia,
25 pub const WriteError = error{WriteError};26 MediaChanged,
27 DeviceError,
28 VolumeCorrupted,
29 WriteProtected,
30 AccessDenied,
31 OutOfResources,
32 VolumeFull,
33 InvalidParameter,
34 };
35 pub const CloseError = uefi.UnexpectedError;
36 pub const SeekError = uefi.UnexpectedError || error{
37 Unsupported,
38 DeviceError,
39 };
40 pub const ReadError = uefi.UnexpectedError || error{
41 NoMedia,
42 DeviceError,
43 VolumeCorrupted,
44 BufferTooSmall,
45 };
46 pub const WriteError = uefi.UnexpectedError || error{
47 Unsupported,
48 NoMedia,
49 DeviceError,
50 VolumeCorrupted,
51 WriteProtected,
52 AccessDenied,
53 VolumeFull,
54 };
55 pub const GetInfoError = uefi.UnexpectedError || error{
56 Unsupported,
57 NoMedia,
58 DeviceError,
59 VolumeCorrupted,
60 BufferTooSmall,
61 };
62 pub const SetInfoError = uefi.UnexpectedError || error{
63 Unsupported,
64 NoMedia,
65 DeviceError,
66 VolumeCorrupted,
67 WriteProtected,
68 AccessDenied,
69 VolumeFull,
70 BadBufferSize,
71 };
72 pub const FlushError = uefi.UnexpectedError || error{
73 DeviceError,
74 VolumeCorrupted,
75 WriteProtected,
76 AccessDenied,
77 VolumeFull,
78 };
2679
27 pub const SeekableStream = io.SeekableStream(*const File, SeekError, GetSeekPosError, seekTo, seekBy, getPos, getEndPos);80 pub const SeekableStream = io.SeekableStream(
28 pub const Reader = io.Reader(*const File, ReadError, readFn);81 *File,
29 pub const Writer = io.Writer(*const File, WriteError, writeFn);82 SeekError,
83 SeekError,
84 setPosition,
85 seekBy,
86 getPosition,
87 getEndPos,
88 );
89 pub const Reader = io.Reader(*File, ReadError, read);
90 pub const Writer = io.Writer(*File, WriteError, write);
3091
31 pub fn seekableStream(self: *File) SeekableStream {92 pub fn seekableStream(self: *File) SeekableStream {
32 return .{ .context = self };93 return .{ .context = self };
...@@ -40,75 +101,111 @@ pub const File = extern struct {...@@ -40,75 +101,111 @@ pub const File = extern struct {
40 return .{ .context = self };101 return .{ .context = self };
41 }102 }
42103
43 pub fn open(self: *const File, new_handle: **const File, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {104 pub fn open(
44 return self._open(self, new_handle, file_name, open_mode, attributes);105 self: *const File,
45 }106 file_name: [*:0]const u16,
46107 mode: OpenMode,
47 pub fn close(self: *const File) Status {108 create_attributes: Attributes,
48 return self._close(self);109 ) OpenError!*File {
110 var new: *File = undefined;
111 switch (self._open(
112 self,
113 &new,
114 file_name,
115 @intFromEnum(mode),
116 @bitCast(create_attributes),
117 )) {
118 .success => return new,
119 .not_found => return Error.NotFound,
120 .no_media => return Error.NoMedia,
121 .media_changed => return Error.MediaChanged,
122 .device_error => return Error.DeviceError,
123 .volume_corrupted => return Error.VolumeCorrupted,
124 .write_protected => return Error.WriteProtected,
125 .access_denied => return Error.AccessDenied,
126 .out_of_resources => return Error.OutOfResources,
127 .volume_full => return Error.VolumeFull,
128 .invalid_parameter => return Error.InvalidParameter,
129 else => |status| return uefi.unexpectedStatus(status),
130 }
49 }131 }
50132
51 pub fn delete(self: *const File) Status {133 pub fn close(self: *File) CloseError!void {
52 return self._delete(self);134 switch (self._close(self)) {
135 .success => {},
136 else => |status| return uefi.unexpectedStatus(status),
137 }
53 }138 }
54139
55 pub fn read(self: *const File, buffer_size: *usize, buffer: [*]u8) Status {140 /// Delete the file.
56 return self._read(self, buffer_size, buffer);141 ///
142 /// Returns true if the file was deleted, false if the file was not deleted, which is a warning
143 /// according to the UEFI specification.
144 pub fn delete(self: *File) uefi.UnexpectedError!bool {
145 switch (self._delete(self)) {
146 .success => return true,
147 .warn_delete_failure => return false,
148 else => |status| return uefi.unexpectedStatus(status),
149 }
57 }150 }
58151
59 fn readFn(self: *const File, buffer: []u8) ReadError!usize {152 pub fn read(self: *File, buffer: []u8) ReadError!usize {
60 var size: usize = buffer.len;153 var size: usize = buffer.len;
61 if (.success != self.read(&size, buffer.ptr)) return ReadError.ReadError;154 switch (self._read(self, &size, buffer.ptr)) {
62 return size;155 .success => return size,
63 }156 .no_media => return Error.NoMedia,
64157 .device_error => return Error.DeviceError,
65 pub fn write(self: *const File, buffer_size: *usize, buffer: [*]const u8) Status {158 .volume_corrupted => return Error.VolumeCorrupted,
66 return self._write(self, buffer_size, buffer);159 .buffer_too_small => return Error.BufferTooSmall,
67 }160 else => |status| return uefi.unexpectedStatus(status),
68161 }
69 fn writeFn(self: *const File, bytes: []const u8) WriteError!usize {
70 var size: usize = bytes.len;
71 if (.success != self.write(&size, bytes.ptr)) return WriteError.WriteError;
72 return size;
73 }162 }
74163
75 pub fn getPosition(self: *const File, position: *u64) Status {164 pub fn write(self: *File, buffer: []const u8) WriteError!usize {
76 return self._get_position(self, position);165 var size: usize = buffer.len;
166 switch (self._write(self, &size, buffer.ptr)) {
167 .success => return size,
168 .unsupported => return Error.Unsupported,
169 .no_media => return Error.NoMedia,
170 .device_error => return Error.DeviceError,
171 .volume_corrupted => return Error.VolumeCorrupted,
172 .write_protected => return Error.WriteProtected,
173 .access_denied => return Error.AccessDenied,
174 .volume_full => return Error.VolumeFull,
175 else => |status| return uefi.unexpectedStatus(status),
176 }
77 }177 }
78178
79 fn getPos(self: *const File) GetSeekPosError!u64 {179 pub fn getPosition(self: *const File) SeekError!u64 {
80 var pos: u64 = undefined;180 var position: u64 = undefined;
81 if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;181 switch (self._get_position(self, &position)) {
82 return pos;182 .success => return position,
183 .unsupported => return Error.Unsupported,
184 .device_error => return Error.DeviceError,
185 else => |status| return uefi.unexpectedStatus(status),
186 }
83 }187 }
84188
85 fn getEndPos(self: *const File) GetSeekPosError!u64 {189 fn getEndPos(self: *File) SeekError!u64 {
86 // preserve the old file position190 const start_pos = try self.getPosition();
87 var pos: u64 = undefined;191 // ignore error
88 var end_pos: u64 = undefined;192 defer self.setPosition(start_pos) catch {};
89 if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
90 // seek to end of file to get position = file size
91 if (.success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError;
92 // get the position
93 if (.success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError;
94 // restore the old position
95 if (.success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError;
96 // return the file size = position
97 return end_pos;
98 }
99193
100 pub fn setPosition(self: *const File, position: u64) Status {194 try self.setPosition(end_of_file);
101 return self._set_position(self, position);195 return self.getPosition();
102 }196 }
103197
104 fn seekTo(self: *const File, pos: u64) SeekError!void {198 pub fn setPosition(self: *File, position: u64) SeekError!void {
105 if (.success != self.setPosition(pos)) return SeekError.SeekError;199 switch (self._set_position(self, position)) {
200 .success => {},
201 .unsupported => return Error.Unsupported,
202 .device_error => return Error.DeviceError,
203 else => |status| return uefi.unexpectedStatus(status),
204 }
106 }205 }
107206
108 fn seekBy(self: *const File, offset: i64) SeekError!void {207 fn seekBy(self: *File, offset: i64) SeekError!void {
109 // save the old position and calculate the delta208 var pos = try self.getPosition();
110 var pos: u64 = undefined;
111 if (.success != self.getPosition(&pos)) return SeekError.SeekError;
112 const seek_back = offset < 0;209 const seek_back = offset < 0;
113 const amt = @abs(offset);210 const amt = @abs(offset);
114 if (seek_back) {211 if (seek_back) {
...@@ -116,32 +213,152 @@ pub const File = extern struct {...@@ -116,32 +213,152 @@ pub const File = extern struct {
116 } else {213 } else {
117 pos -= amt;214 pos -= amt;
118 }215 }
119 if (.success != self.setPosition(pos)) return SeekError.SeekError;216 try self.setPosition(pos);
120 }217 }
121218
122 pub fn getInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: *usize, buffer: [*]u8) Status {219 pub fn getInfo(
123 return self._get_info(self, information_type, buffer_size, buffer);220 self: *const File,
221 comptime info: std.meta.Tag(Info),
222 ) GetInfoError!std.meta.TagPayload(Info, info) {
223 const InfoType = std.meta.TagPayload(Info, info);
224
225 var val: InfoType = undefined;
226 var len: usize = @sizeOf(InfoType);
227 switch (self._get_info(self, &InfoType.guid, &len, @ptrCast(&val))) {
228 .success => return val,
229 .unsupported => return Error.Unsupported,
230 .no_media => return Error.NoMedia,
231 .device_error => return Error.DeviceError,
232 .volume_corrupted => return Error.VolumeCorrupted,
233 .buffer_too_small => return Error.BufferTooSmall,
234 else => |status| return uefi.unexpectedStatus(status),
235 }
124 }236 }
125237
126 pub fn setInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: usize, buffer: [*]const u8) Status {238 pub fn setInfo(
127 return self._set_info(self, information_type, buffer_size, buffer);239 self: *File,
240 comptime info: std.meta.Tag(Info),
241 data: *const std.meta.TagPayload(Info, info),
242 ) SetInfoError!void {
243 const InfoType = @TypeOf(data);
244 switch (self._set_info(self, &InfoType.guid, @sizeOf(InfoType), @ptrCast(data))) {
245 .success => {},
246 .unsupported => return Error.Unsupported,
247 .no_media => return Error.NoMedia,
248 .device_error => return Error.DeviceError,
249 .volume_corrupted => return Error.VolumeCorrupted,
250 .write_protected => return Error.WriteProtected,
251 .access_denied => return Error.AccessDenied,
252 .volume_full => return Error.VolumeFull,
253 .bad_buffer_size => return Error.BadBufferSize,
254 else => |status| return uefi.unexpectedStatus(status),
255 }
128 }256 }
129257
130 pub fn flush(self: *const File) Status {258 pub fn flush(self: *File) FlushError!void {
131 return self._flush(self);259 switch (self._flush(self)) {
260 .success => {},
261 .device_error => return Error.DeviceError,
262 .volume_corrupted => return Error.VolumeCorrupted,
263 .write_protected => return Error.WriteProtected,
264 .access_denied => return Error.AccessDenied,
265 .volume_full => return Error.VolumeFull,
266 else => |status| return uefi.unexpectedStatus(status),
267 }
132 }268 }
133269
134 pub const efi_file_mode_read: u64 = 0x0000000000000001;270 pub const OpenMode = enum(u64) {
135 pub const efi_file_mode_write: u64 = 0x0000000000000002;271 read = 0x0000000000000001,
136 pub const efi_file_mode_create: u64 = 0x8000000000000000;272 // implies read
273 write = 0x0000000000000002,
274 // implies read+write
275 create = 0x8000000000000000,
276 };
277
278 pub const Attributes = packed struct(u64) {
279 // 0x0000000000000001
280 read_only: bool = false,
281 // 0x0000000000000002
282 hidden: bool = false,
283 // 0x0000000000000004
284 system: bool = false,
285 // 0x0000000000000008
286 reserved: bool = false,
287 // 0x0000000000000010
288 directory: bool = false,
289 // 0x0000000000000020
290 archive: bool = false,
291 _pad: u58 = 0,
292 };
293
294 pub const Info = union(enum) {
295 file: Info.File,
296 file_system: FileSystem,
297 volume_label: VolumeLabel,
298
299 pub const File = extern struct {
300 size: u64,
301 file_size: u64,
302 physical_size: u64,
303 create_time: Time,
304 last_access_time: Time,
305 modification_time: Time,
306 attribute: Attributes,
307 _file_name: u16,
308
309 pub fn getFileName(self: *const Info.File) [*:0]const u16 {
310 return @as([*:0]const u16, @ptrCast(&self._file_name));
311 }
312
313 pub const guid align(8) = Guid{
314 .time_low = 0x09576e92,
315 .time_mid = 0x6d3f,
316 .time_high_and_version = 0x11d2,
317 .clock_seq_high_and_reserved = 0x8e,
318 .clock_seq_low = 0x39,
319 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
320 };
321 };
322
323 pub const FileSystem = extern struct {
324 size: u64,
325 read_only: bool,
326 volume_size: u64,
327 free_space: u64,
328 block_size: u32,
329 _volume_label: u16,
330
331 pub fn getVolumeLabel(self: *const FileSystem) [*:0]const u16 {
332 return @as([*:0]const u16, @ptrCast(&self._volume_label));
333 }
334
335 pub const guid align(8) = Guid{
336 .time_low = 0x09576e93,
337 .time_mid = 0x6d3f,
338 .time_high_and_version = 0x11d2,
339 .clock_seq_high_and_reserved = 0x8e,
340 .clock_seq_low = 0x39,
341 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
342 };
343 };
344
345 pub const VolumeLabel = extern struct {
346 _volume_label: u16,
347
348 pub fn getVolumeLabel(self: *const VolumeLabel) [*:0]const u16 {
349 return @as([*:0]const u16, @ptrCast(&self._volume_label));
350 }
137351
138 pub const efi_file_read_only: u64 = 0x0000000000000001;352 pub const guid align(8) = Guid{
139 pub const efi_file_hidden: u64 = 0x0000000000000002;353 .time_low = 0xdb47d7d3,
140 pub const efi_file_system: u64 = 0x0000000000000004;354 .time_mid = 0xfe81,
141 pub const efi_file_reserved: u64 = 0x0000000000000008;355 .time_high_and_version = 0x11d3,
142 pub const efi_file_directory: u64 = 0x0000000000000010;356 .clock_seq_high_and_reserved = 0x9a,
143 pub const efi_file_archive: u64 = 0x0000000000000020;357 .clock_seq_low = 0x35,
144 pub const efi_file_valid_attr: u64 = 0x0000000000000037;358 .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
359 };
360 };
361 };
145362
146 pub const efi_file_position_end_of_file: u64 = 0xffffffffffffffff;363 const end_of_file: u64 = 0xffffffffffffffff;
147};364};
lib/std/os/uefi/protocol/graphics_output.zig+61-8
...@@ -3,26 +3,79 @@ const uefi = std.os.uefi;...@@ -3,26 +3,79 @@ const uefi = std.os.uefi;
3const Guid = uefi.Guid;3const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const cc = uefi.cc;5const cc = uefi.cc;
6const Error = Status.Error;
67
7pub const GraphicsOutput = extern struct {8pub const GraphicsOutput = extern struct {
8 _query_mode: *const fn (*const GraphicsOutput, u32, *usize, **Mode.Info) callconv(cc) Status,9 _query_mode: *const fn (*const GraphicsOutput, u32, *usize, **Mode.Info) callconv(cc) Status,
9 _set_mode: *const fn (*const GraphicsOutput, u32) callconv(cc) Status,10 _set_mode: *const fn (*GraphicsOutput, u32) callconv(cc) Status,
10 _blt: *const fn (*const GraphicsOutput, ?[*]BltPixel, BltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status,11 _blt: *const fn (*GraphicsOutput, ?[*]BltPixel, BltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status,
11 mode: *Mode,12 mode: *Mode,
1213
14 pub const QueryModeError = uefi.UnexpectedError || error{
15 DeviceError,
16 InvalidParameter,
17 };
18 pub const SetModeError = uefi.UnexpectedError || error{
19 DeviceError,
20 Unsupported,
21 };
22 pub const BltError = uefi.UnexpectedError || error{
23 InvalidParameter,
24 DeviceError,
25 };
26
13 /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.27 /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
14 pub fn queryMode(self: *const GraphicsOutput, mode: u32, size_of_info: *usize, info: **Mode.Info) Status {28 pub fn queryMode(self: *const GraphicsOutput, mode_id: u32) QueryModeError!*Mode.Info {
15 return self._query_mode(self, mode, size_of_info, info);29 var size_of_info: usize = undefined;
30 var info: *Mode.Info = undefined;
31 switch (self._query_mode(self, mode_id, &size_of_info, &info)) {
32 .success => return info,
33 .device_error => return Error.DeviceError,
34 .invalid_parameter => return Error.InvalidParameter,
35 else => |status| return uefi.unexpectedStatus(status),
36 }
16 }37 }
1738
18 /// Set the video device into the specified mode and clears the visible portions of the output display to black.39 /// Set the video device into the specified mode and clears the visible portions of the output display to black.
19 pub fn setMode(self: *const GraphicsOutput, mode: u32) Status {40 pub fn setMode(self: *GraphicsOutput, mode_id: u32) SetModeError!void {
20 return self._set_mode(self, mode);41 switch (self._set_mode(self, mode_id)) {
42 .success => {},
43 .device_error => return Error.DeviceError,
44 .unsupported => return Error.Unsupported,
45 else => |status| return uefi.unexpectedStatus(status),
46 }
21 }47 }
2248
23 /// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.49 /// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
24 pub fn blt(self: *const GraphicsOutput, blt_buffer: ?[*]BltPixel, blt_operation: BltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) Status {50 pub fn blt(
25 return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta);51 self: *GraphicsOutput,
52 blt_buffer: ?[*]BltPixel,
53 blt_operation: BltOperation,
54 source_x: usize,
55 source_y: usize,
56 destination_x: usize,
57 destination_y: usize,
58 width: usize,
59 height: usize,
60 delta: usize,
61 ) BltError!void {
62 switch (self._blt(
63 self,
64 blt_buffer,
65 blt_operation,
66 source_x,
67 source_y,
68 destination_x,
69 destination_y,
70 width,
71 height,
72 delta,
73 )) {
74 .success => {},
75 .device_error => return Error.DeviceError,
76 .invalid_parameter => return Error.InvalidParameter,
77 else => |status| return uefi.unexpectedStatus(status),
78 }
26 }79 }
2780
28 pub const guid align(8) = Guid{81 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/hii_database.zig+72-11
...@@ -4,14 +4,15 @@ const Guid = uefi.Guid;...@@ -4,14 +4,15 @@ const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const hii = uefi.hii;5const hii = uefi.hii;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Database manager for HII-related data structures.9/// Database manager for HII-related data structures.
9pub const HiiDatabase = extern struct {10pub const HiiDatabase = extern struct {
10 _new_package_list: Status, // TODO11 _new_package_list: Status, // TODO
11 _remove_package_list: *const fn (*const HiiDatabase, hii.Handle) callconv(cc) Status,12 _remove_package_list: *const fn (*HiiDatabase, hii.Handle) callconv(cc) Status,
12 _update_package_list: *const fn (*const HiiDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status,13 _update_package_list: *const fn (*HiiDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status,
13 _list_package_lists: *const fn (*const HiiDatabase, u8, ?*const Guid, *usize, [*]hii.Handle) callconv(cc) Status,14 _list_package_lists: *const fn (*const HiiDatabase, u8, ?*const Guid, *usize, [*]hii.Handle) callconv(cc) Status,
14 _export_package_lists: *const fn (*const HiiDatabase, ?hii.Handle, *usize, *hii.PackageList) callconv(cc) Status,15 _export_package_lists: *const fn (*const HiiDatabase, ?hii.Handle, *usize, [*]hii.PackageList) callconv(cc) Status,
15 _register_package_notify: Status, // TODO16 _register_package_notify: Status, // TODO
16 _unregister_package_notify: Status, // TODO17 _unregister_package_notify: Status, // TODO
17 _find_keyboard_layouts: Status, // TODO18 _find_keyboard_layouts: Status, // TODO
...@@ -19,24 +20,84 @@ pub const HiiDatabase = extern struct {...@@ -19,24 +20,84 @@ pub const HiiDatabase = extern struct {
19 _set_keyboard_layout: Status, // TODO20 _set_keyboard_layout: Status, // TODO
20 _get_package_list_handle: Status, // TODO21 _get_package_list_handle: Status, // TODO
2122
23 pub const RemovePackageListError = uefi.UnexpectedError || error{NotFound};
24 pub const UpdatePackageListError = uefi.UnexpectedError || error{
25 OutOfResources,
26 InvalidParameter,
27 NotFound,
28 };
29 pub const ListPackageListsError = uefi.UnexpectedError || error{
30 BufferTooSmall,
31 InvalidParameter,
32 NotFound,
33 };
34 pub const ExportPackageListError = uefi.UnexpectedError || error{
35 BufferTooSmall,
36 InvalidParameter,
37 NotFound,
38 };
39
22 /// Removes a package list from the HII database.40 /// Removes a package list from the HII database.
23 pub fn removePackageList(self: *const HiiDatabase, handle: hii.Handle) Status {41 pub fn removePackageList(self: *HiiDatabase, handle: hii.Handle) !void {
24 return self._remove_package_list(self, handle);42 switch (self._remove_package_list(self, handle)) {
43 .success => {},
44 .not_found => return Error.NotFound,
45 else => |status| return uefi.unexpectedStatus(status),
46 }
25 }47 }
2648
27 /// Update a package list in the HII database.49 /// Update a package list in the HII database.
28 pub fn updatePackageList(self: *const HiiDatabase, handle: hii.Handle, buffer: *const hii.PackageList) Status {50 pub fn updatePackageList(
29 return self._update_package_list(self, handle, buffer);51 self: *HiiDatabase,
52 handle: hii.Handle,
53 buffer: *const hii.PackageList,
54 ) UpdatePackageListError!void {
55 switch (self._update_package_list(self, handle, buffer)) {
56 .success => {},
57 .out_of_resources => return Error.OutOfResources,
58 .invalid_parameter => return Error.InvalidParameter,
59 .not_found => return Error.NotFound,
60 else => |status| return uefi.unexpectedStatus(status),
61 }
30 }62 }
3163
32 /// Determines the handles that are currently active in the database.64 /// Determines the handles that are currently active in the database.
33 pub fn listPackageLists(self: *const HiiDatabase, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.Handle) Status {65 pub fn listPackageLists(
34 return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);66 self: *const HiiDatabase,
67 package_type: u8,
68 package_guid: ?*const Guid,
69 handles: []hii.Handle,
70 ) ListPackageListsError![]hii.Handle {
71 var len: usize = handles.len;
72 switch (self._list_package_lists(
73 self,
74 package_type,
75 package_guid,
76 &len,
77 handles.ptr,
78 )) {
79 .success => return handles[0..len],
80 .buffer_too_small => return Error.BufferTooSmall,
81 .invalid_parameter => return Error.InvalidParameter,
82 .not_found => return Error.NotFound,
83 else => |status| return uefi.unexpectedStatus(status),
84 }
35 }85 }
3686
37 /// Exports the contents of one or all package lists in the HII database into a buffer.87 /// Exports the contents of one or all package lists in the HII database into a buffer.
38 pub fn exportPackageLists(self: *const HiiDatabase, handle: ?hii.Handle, buffer_size: *usize, buffer: *hii.PackageList) Status {88 pub fn exportPackageLists(
39 return self._export_package_lists(self, handle, buffer_size, buffer);89 self: *const HiiDatabase,
90 handle: ?hii.Handle,
91 buffer: []hii.PackageList,
92 ) ExportPackageListError![]hii.PackageList {
93 var len = buffer.len;
94 switch (self._export_package_lists(self, handle, &len, buffer.ptr)) {
95 .success => return buffer[0..len],
96 .buffer_too_small => return Error.BufferTooSmall,
97 .invalid_parameter => return Error.InvalidParameter,
98 .not_found => return Error.NotFound,
99 else => |status| return uefi.unexpectedStatus(status),
100 }
40 }101 }
41102
42 pub const guid align(8) = Guid{103 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/hii_popup.zig+20-2
...@@ -4,15 +4,33 @@ const Guid = uefi.Guid;...@@ -4,15 +4,33 @@ const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const hii = uefi.hii;5const hii = uefi.hii;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Display a popup window9/// Display a popup window
9pub const HiiPopup = extern struct {10pub const HiiPopup = extern struct {
10 revision: u64,11 revision: u64,
11 _create_popup: *const fn (*const HiiPopup, PopupStyle, PopupType, hii.Handle, u16, ?*PopupSelection) callconv(cc) Status,12 _create_popup: *const fn (*const HiiPopup, PopupStyle, PopupType, hii.Handle, u16, ?*PopupSelection) callconv(cc) Status,
1213
14 pub const CreatePopupError = uefi.UnexpectedError || error{
15 InvalidParameter,
16 OutOfResources,
17 };
18
13 /// Displays a popup window.19 /// Displays a popup window.
14 pub fn createPopup(self: *const HiiPopup, style: PopupStyle, popup_type: PopupType, handle: hii.Handle, msg: u16, user_selection: ?*PopupSelection) Status {20 pub fn createPopup(
15 return self._create_popup(self, style, popup_type, handle, msg, user_selection);21 self: *const HiiPopup,
22 style: PopupStyle,
23 popup_type: PopupType,
24 handle: hii.Handle,
25 msg: u16,
26 ) CreatePopupError!PopupSelection {
27 var res: PopupSelection = undefined;
28 switch (self._create_popup(self, style, popup_type, handle, msg, &res)) {
29 .success => return res,
30 .invalid_parameter => return Error.InvalidParameter,
31 .out_of_resources => return Error.OutOfResources,
32 else => |status| return uefi.unexpectedStatus(status),
33 }
16 }34 }
1735
18 pub const guid align(8) = Guid{36 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/ip6.zig+265-26
...@@ -7,61 +7,290 @@ const MacAddress = uefi.MacAddress;...@@ -7,61 +7,290 @@ const MacAddress = uefi.MacAddress;
7const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config;7const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config;
8const SimpleNetwork = uefi.protocol.SimpleNetwork;8const SimpleNetwork = uefi.protocol.SimpleNetwork;
9const cc = uefi.cc;9const cc = uefi.cc;
10const Error = Status.Error;
1011
11pub const Ip6 = extern struct {12pub const Ip6 = extern struct {
12 _get_mode_data: *const fn (*const Ip6, ?*Mode, ?*ManagedNetworkConfigData, ?*SimpleNetwork) callconv(cc) Status,13 _get_mode_data: *const fn (*const Ip6, ?*Mode, ?*ManagedNetworkConfigData, ?*SimpleNetwork) callconv(cc) Status,
13 _configure: *const fn (*const Ip6, ?*const Config) callconv(cc) Status,14 _configure: *const fn (*Ip6, ?*const Config) callconv(cc) Status,
14 _groups: *const fn (*const Ip6, bool, ?*const Address) callconv(cc) Status,15 _groups: *const fn (*Ip6, bool, ?*const Address) callconv(cc) Status,
15 _routes: *const fn (*const Ip6, bool, ?*const Address, u8, ?*const Address) callconv(cc) Status,16 _routes: *const fn (*Ip6, bool, ?*const Address, u8, ?*const Address) callconv(cc) Status,
16 _neighbors: *const fn (*const Ip6, bool, *const Address, ?*const MacAddress, u32, bool) callconv(cc) Status,17 _neighbors: *const fn (*Ip6, bool, *const Address, ?*const MacAddress, u32, bool) callconv(cc) Status,
17 _transmit: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status,18 _transmit: *const fn (*Ip6, *CompletionToken) callconv(cc) Status,
18 _receive: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status,19 _receive: *const fn (*Ip6, *CompletionToken) callconv(cc) Status,
19 _cancel: *const fn (*const Ip6, ?*CompletionToken) callconv(cc) Status,20 _cancel: *const fn (*Ip6, ?*CompletionToken) callconv(cc) Status,
20 _poll: *const fn (*const Ip6) callconv(cc) Status,21 _poll: *const fn (*Ip6) callconv(cc) Status,
22
23 pub const GetModeDataError = uefi.UnexpectedError || error{
24 InvalidParameter,
25 OutOfResources,
26 };
27 pub const ConfigureError = uefi.UnexpectedError || error{
28 InvalidParameter,
29 OutOfResources,
30 NoMapping,
31 AlreadyStarted,
32 DeviceError,
33 Unsupported,
34 };
35 pub const GroupsError = uefi.UnexpectedError || error{
36 InvalidParameter,
37 NotStarted,
38 OutOfResources,
39 Unsupported,
40 AlreadyStarted,
41 NotFound,
42 DeviceError,
43 };
44 pub const RoutesError = uefi.UnexpectedError || error{
45 NotStarted,
46 InvalidParameter,
47 OutOfResources,
48 NotFound,
49 AccessDenied,
50 };
51 pub const NeighborsError = uefi.UnexpectedError || error{
52 NotStarted,
53 InvalidParameter,
54 OutOfResources,
55 NotFound,
56 AccessDenied,
57 };
58 pub const TransmitError = uefi.UnexpectedError || error{
59 NotStarted,
60 NoMapping,
61 InvalidParameter,
62 AccessDenied,
63 NotReady,
64 NotFound,
65 OutOfResources,
66 BufferTooSmall,
67 BadBufferSize,
68 DeviceError,
69 NoMedia,
70 };
71 pub const ReceiveError = uefi.UnexpectedError || error{
72 NotStarted,
73 NoMapping,
74 InvalidParameter,
75 OutOfResources,
76 DeviceError,
77 AccessDenied,
78 NotReady,
79 NoMedia,
80 };
81 pub const CancelError = uefi.UnexpectedError || error{
82 InvalidParameter,
83 NotStarted,
84 NotFound,
85 DeviceError,
86 };
87 pub const PollError = uefi.UnexpectedError || error{
88 NotStarted,
89 InvalidParameter,
90 DeviceError,
91 Timeout,
92 };
93
94 pub const ModeData = struct {
95 ip6_mode: Mode,
96 mnp_config: ManagedNetworkConfigData,
97 snp_mode: SimpleNetwork,
98 };
2199
22 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.100 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
23 pub fn getModeData(self: *const Ip6, ip6_mode_data: ?*Mode, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetwork) Status {101 pub fn getModeData(self: *const Ip6) GetModeDataError!ModeData {
24 return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);102 var data: ModeData = undefined;
103 switch (self._get_mode_data(self, &data.ip6_mode, &data.mnp_config, &data.snp_mode)) {
104 .success => return data,
105 .invalid_parameter => return Error.InvalidParameter,
106 .out_of_resources => return Error.OutOfResources,
107 else => |status| return uefi.unexpectedStatus(status),
108 }
25 }109 }
26110
27 /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.111 /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
28 pub fn configure(self: *const Ip6, ip6_config_data: ?*const Config) Status {112 ///
29 return self._configure(self, ip6_config_data);113 /// To reset the configuration, use `disable` instead.
114 pub fn configure(self: *Ip6, ip6_config_data: *const Config) ConfigureError!void {
115 switch (self._configure(self, ip6_config_data)) {
116 .success => {},
117 .invalid_parameter => return Error.InvalidParameter,
118 .out_of_resources => return Error.OutOfResources,
119 .no_mapping => return Error.NoMapping,
120 .already_started => return Error.AlreadyStarted,
121 .device_error => return Error.DeviceError,
122 .unsupported => return Error.Unsupported,
123 else => |status| return uefi.unexpectedStatus(status),
124 }
125 }
126
127 pub fn disable(self: *Ip6) ConfigureError!void {
128 switch (self._configure(self, null)) {
129 .success => {},
130 .invalid_parameter => return Error.InvalidParameter,
131 .out_of_resources => return Error.OutOfResources,
132 .no_mapping => return Error.NoMapping,
133 .already_started => return Error.AlreadyStarted,
134 .device_error => return Error.DeviceError,
135 .unsupported => return Error.Unsupported,
136 else => |status| return uefi.unexpectedStatus(status),
137 }
138 }
139
140 pub fn leaveAllGroups(self: *Ip6) GroupsError!void {
141 switch (self._groups(self, false, null)) {
142 .success => {},
143 .invalid_parameter => return Error.InvalidParameter,
144 .not_started => return Error.NotStarted,
145 .out_of_resources => return Error.OutOfResources,
146 .unsupported => return Error.Unsupported,
147 .already_started => return Error.AlreadyStarted,
148 .not_found => return Error.NotFound,
149 .device_error => return Error.DeviceError,
150 else => |status| return uefi.unexpectedStatus(status),
151 }
30 }152 }
31153
32 /// Joins and leaves multicast groups.154 /// Joins and leaves multicast groups.
33 pub fn groups(self: *const Ip6, join_flag: bool, group_address: ?*const Address) Status {155 ///
34 return self._groups(self, join_flag, group_address);156 /// To leave all groups, use `leaveAllGroups` instead.
157 pub fn groups(
158 self: *Ip6,
159 join_flag: JoinFlag,
160 group_address: *const Address,
161 ) GroupsError!void {
162 switch (self._groups(
163 self,
164 // set to TRUE to join the multicast group session and FALSE to leave
165 join_flag == .join,
166 group_address,
167 )) {
168 .success => {},
169 .invalid_parameter => return Error.InvalidParameter,
170 .not_started => return Error.NotStarted,
171 .out_of_resources => return Error.OutOfResources,
172 .unsupported => return Error.Unsupported,
173 .already_started => return Error.AlreadyStarted,
174 .not_found => return Error.NotFound,
175 .device_error => return Error.DeviceError,
176 else => |status| return uefi.unexpectedStatus(status),
177 }
35 }178 }
36179
37 /// Adds and deletes routing table entries.180 /// Adds and deletes routing table entries.
38 pub fn routes(self: *const Ip6, delete_route: bool, destination: ?*const Address, prefix_length: u8, gateway_address: ?*const Address) Status {181 pub fn routes(
39 return self._routes(self, delete_route, destination, prefix_length, gateway_address);182 self: *Ip6,
183 delete_route: DeleteFlag,
184 destination: ?*const Address,
185 prefix_length: u8,
186 gateway_address: ?*const Address,
187 ) RoutesError!void {
188 switch (self._routes(
189 self,
190 delete_route == .delete,
191 destination,
192 prefix_length,
193 gateway_address,
194 )) {
195 .success => {},
196 .not_started => return Error.NotStarted,
197 .invalid_parameter => return Error.InvalidParameter,
198 .out_of_resources => return Error.OutOfResources,
199 .not_found => return Error.NotFound,
200 .access_denied => return Error.AccessDenied,
201 else => |status| return uefi.unexpectedStatus(status),
202 }
40 }203 }
41204
42 /// Add or delete Neighbor cache entries.205 /// Add or delete Neighbor cache entries.
43 pub fn neighbors(self: *const Ip6, delete_flag: bool, target_ip6_address: *const Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) Status {206 pub fn neighbors(
44 return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);207 self: *Ip6,
208 delete_flag: DeleteFlag,
209 target_ip6_address: *const Address,
210 target_link_address: ?*const MacAddress,
211 timeout: u32,
212 override: bool,
213 ) NeighborsError!void {
214 switch (self._neighbors(
215 self,
216 // set to TRUE to delete this route from the routing table.
217 // set to FALSE to add this route to the routing table.
218 delete_flag == .delete,
219 target_ip6_address,
220 target_link_address,
221 timeout,
222 override,
223 )) {
224 .success => {},
225 .not_started => return Error.NotStarted,
226 .invalid_parameter => return Error.InvalidParameter,
227 .out_of_resources => return Error.OutOfResources,
228 .not_found => return Error.NotFound,
229 .access_denied => return Error.AccessDenied,
230 else => |status| return uefi.unexpectedStatus(status),
231 }
45 }232 }
46233
47 /// Places outgoing data packets into the transmit queue.234 /// Places outgoing data packets into the transmit queue.
48 pub fn transmit(self: *const Ip6, token: *CompletionToken) Status {235 pub fn transmit(self: *Ip6, token: *CompletionToken) TransmitError!void {
49 return self._transmit(self, token);236 switch (self._transmit(self, token)) {
237 .success => {},
238 .not_started => return Error.NotStarted,
239 .no_mapping => return Error.NoMapping,
240 .invalid_parameter => return Error.InvalidParameter,
241 .access_denied => return Error.AccessDenied,
242 .not_ready => return Error.NotReady,
243 .not_found => return Error.NotFound,
244 .out_of_resources => return Error.OutOfResources,
245 .buffer_too_small => return Error.BufferTooSmall,
246 .bad_buffer_size => return Error.BadBufferSize,
247 .device_error => return Error.DeviceError,
248 .no_media => return Error.NoMedia,
249 else => |status| return uefi.unexpectedStatus(status),
250 }
50 }251 }
51252
52 /// Places a receiving request into the receiving queue.253 /// Places a receiving request into the receiving queue.
53 pub fn receive(self: *const Ip6, token: *CompletionToken) Status {254 pub fn receive(self: *Ip6, token: *CompletionToken) ReceiveError!void {
54 return self._receive(self, token);255 switch (self._receive(self, token)) {
256 .success => {},
257 .not_started => return Error.NotStarted,
258 .no_mapping => return Error.NoMapping,
259 .invalid_parameter => return Error.InvalidParameter,
260 .out_of_resources => return Error.OutOfResources,
261 .device_error => return Error.DeviceError,
262 .access_denied => return Error.AccessDenied,
263 .not_ready => return Error.NotReady,
264 .no_media => return Error.NoMedia,
265 else => |status| return uefi.unexpectedStatus(status),
266 }
55 }267 }
56268
57 /// Abort an asynchronous transmits or receive request.269 /// Abort an asynchronous transmits or receive request.
58 pub fn cancel(self: *const Ip6, token: ?*CompletionToken) Status {270 pub fn cancel(self: *Ip6, token: ?*CompletionToken) CancelError!void {
59 return self._cancel(self, token);271 switch (self._cancel(self, token)) {
272 .success => {},
273 .invalid_parameter => return Error.InvalidParameter,
274 .not_started => return Error.NotStarted,
275 .not_found => return Error.NotFound,
276 .device_error => return Error.DeviceError,
277 else => |status| return uefi.unexpectedStatus(status),
278 }
60 }279 }
61280
62 /// Polls for incoming data packets and processes outgoing data packets.281 /// Polls for incoming data packets and processes outgoing data packets.
63 pub fn poll(self: *const Ip6) Status {282 ///
64 return self._poll(self);283 /// Returns true if a packet was received or processed.
284 pub fn poll(self: *Ip6) PollError!bool {
285 switch (self._poll(self)) {
286 .success => return true,
287 .not_ready => return false,
288 .not_started => return Error.NotStarted,
289 .invalid_parameter => return Error.InvalidParameter,
290 .device_error => return Error.DeviceError,
291 .timeout => return Error.Timeout,
292 else => |status| return uefi.unexpectedStatus(status),
293 }
65 }294 }
66295
67 pub const guid align(8) = Guid{296 pub const guid align(8) = Guid{
...@@ -73,6 +302,16 @@ pub const Ip6 = extern struct {...@@ -73,6 +302,16 @@ pub const Ip6 = extern struct {
73 .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },302 .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },
74 };303 };
75304
305 pub const DeleteFlag = enum {
306 delete,
307 add,
308 };
309
310 pub const JoinFlag = enum {
311 join,
312 leave,
313 };
314
76 pub const Mode = extern struct {315 pub const Mode = extern struct {
77 is_started: bool,316 is_started: bool,
78 max_packet_size: u32,317 max_packet_size: u32,
lib/std/os/uefi/protocol/ip6_config.zig+127-16
...@@ -4,6 +4,9 @@ const Guid = uefi.Guid;...@@ -4,6 +4,9 @@ const Guid = uefi.Guid;
4const Event = uefi.Event;4const Event = uefi.Event;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
8const MacAddress = uefi.MacAddress;
9const Ip6 = uefi.protocol.Ip6;
710
8pub const Ip6Config = extern struct {11pub const Ip6Config = extern struct {
9 _set_data: *const fn (*const Ip6Config, DataType, usize, *const anyopaque) callconv(cc) Status,12 _set_data: *const fn (*const Ip6Config, DataType, usize, *const anyopaque) callconv(cc) Status,
...@@ -11,20 +14,98 @@ pub const Ip6Config = extern struct {...@@ -11,20 +14,98 @@ pub const Ip6Config = extern struct {
11 _register_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,14 _register_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,
12 _unregister_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,15 _unregister_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,
1316
14 pub fn setData(self: *const Ip6Config, data_type: DataType, data_size: usize, data: *const anyopaque) Status {17 pub const SetDataError = uefi.UnexpectedError || error{
15 return self._set_data(self, data_type, data_size, data);18 InvalidParameter,
19 WriteProtected,
20 AccessDenied,
21 NotReady,
22 BadBufferSize,
23 Unsupported,
24 OutOfResources,
25 DeviceError,
26 };
27 pub const GetDataError = uefi.UnexpectedError || error{
28 InvalidParameter,
29 BufferTooSmall,
30 NotReady,
31 NotFound,
32 };
33 pub const RegisterDataNotifyError = uefi.UnexpectedError || error{
34 InvalidParameter,
35 Unsupported,
36 OutOfResources,
37 AccessDenied,
38 };
39 pub const UnregisterDataNotifyError = uefi.UnexpectedError || error{
40 InvalidParameter,
41 NotFound,
42 };
43
44 pub fn setData(
45 self: *const Ip6Config,
46 comptime data_type: std.meta.Tag(DataType),
47 payload: *const std.meta.TagPayload(DataType, data_type),
48 ) SetDataError!void {
49 const data_size = @sizeOf(@TypeOf(payload));
50 switch (self._set_data(self, data_type, data_size, @ptrCast(payload))) {
51 .success => {},
52 .invalid_parameter => return Error.InvalidParameter,
53 .write_protected => return Error.WriteProtected,
54 .access_denied => return Error.AccessDenied,
55 .not_ready => return Error.NotReady,
56 .bad_buffer_size => return Error.BadBufferSize,
57 .unsupported => return Error.Unsupported,
58 .out_of_resources => return Error.OutOfResources,
59 .device_error => return Error.DeviceError,
60 else => |status| return uefi.unexpectedStatus(status),
61 }
16 }62 }
1763
18 pub fn getData(self: *const Ip6Config, data_type: DataType, data_size: *usize, data: ?*const anyopaque) Status {64 pub fn getData(
19 return self._get_data(self, data_type, data_size, data);65 self: *const Ip6Config,
66 comptime data_type: std.meta.Tag(DataType),
67 ) GetDataError!std.meta.TagPayload(DataType, data_type) {
68 const DataPayload = std.meta.TagPayload(DataType, data_type);
69
70 var payload: DataPayload = undefined;
71 var payload_size: usize = @sizeOf(DataPayload);
72
73 switch (self._get_data(self, data_type, &payload_size, @ptrCast(&payload))) {
74 .success => return payload,
75 .invalid_parameter => return Error.InvalidParameter,
76 .buffer_too_small => return Error.BufferTooSmall,
77 .not_ready => return Error.NotReady,
78 .not_found => return Error.NotFound,
79 else => |status| return uefi.unexpectedStatus(status),
80 }
20 }81 }
2182
22 pub fn registerDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status {83 pub fn registerDataNotify(
23 return self._register_data_notify(self, data_type, event);84 self: *const Ip6Config,
85 data_type: DataType,
86 event: Event,
87 ) RegisterDataNotifyError!void {
88 switch (self._register_data_notify(self, data_type, event)) {
89 .success => {},
90 .invalid_parameter => return Error.InvalidParameter,
91 .unsupported => return Error.Unsupported,
92 .out_of_resources => return Error.OutOfResources,
93 .access_denied => return Error.AccessDenied,
94 else => |status| return uefi.unexpectedStatus(status),
95 }
24 }96 }
2597
26 pub fn unregisterDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status {98 pub fn unregisterDataNotify(
27 return self._unregister_data_notify(self, data_type, event);99 self: *const Ip6Config,
100 data_type: DataType,
101 event: Event,
102 ) UnregisterDataNotifyError!void {
103 switch (self._unregister_data_notify(self, data_type, event)) {
104 .success => {},
105 .invalid_parameter => return Error.InvalidParameter,
106 .not_found => return Error.NotFound,
107 else => |status| return uefi.unexpectedStatus(status),
108 }
28 }109 }
29110
30 pub const guid align(8) = Guid{111 pub const guid align(8) = Guid{
...@@ -36,13 +117,43 @@ pub const Ip6Config = extern struct {...@@ -36,13 +117,43 @@ pub const Ip6Config = extern struct {
36 .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a },117 .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a },
37 };118 };
38119
39 pub const DataType = enum(u32) {120 pub const DataType = union(enum(u32)) {
40 interface_info,121 interface_info: InterfaceInfo,
41 alt_interface_id,122 alt_interface_id: InterfaceId,
42 policy,123 policy: Policy,
43 dup_addr_detect_transmits,124 dup_addr_detect_transmits: DupAddrDetectTransmits,
44 manual_address,125 manual_address: [*]ManualAddress,
45 gateway,126 gateway: [*]Ip6.Address,
46 dns_server,127 dns_server: [*]Ip6.Address,
128 };
129
130 pub const InterfaceInfo = extern struct {
131 name: [32]u16,
132 if_type: u8,
133 hw_address_size: u32,
134 hw_address: MacAddress,
135 address_info_count: u32,
136 address_info: [*]Ip6.AddressInfo,
137 route_count: u32,
138 route_table: Ip6.RouteTable,
139 };
140
141 pub const InterfaceId = extern struct {
142 id: [8]u8,
143 };
144
145 pub const Policy = enum(u32) {
146 manual,
147 automatic,
148 };
149
150 pub const DupAddrDetectTransmits = extern struct {
151 dup_addr_detect_transmits: u32,
152 };
153
154 pub const ManualAddress = extern struct {
155 address: Ip6.Address,
156 is_anycast: bool,
157 prefix_length: u8,
47 };158 };
48};159};
lib/std/os/uefi/protocol/ip6_service_binding.zig deleted-28
...@@ -1,28 +0,0 @@
1const std = @import("std");
2const uefi = std.os.uefi;
3const Handle = uefi.Handle;
4const Guid = uefi.Guid;
5const Status = uefi.Status;
6const cc = uefi.cc;
7
8pub const Ip6ServiceBinding = extern struct {
9 _create_child: *const fn (*const Ip6ServiceBinding, *?Handle) callconv(cc) Status,
10 _destroy_child: *const fn (*const Ip6ServiceBinding, Handle) callconv(cc) Status,
11
12 pub fn createChild(self: *const Ip6ServiceBinding, handle: *?Handle) Status {
13 return self._create_child(self, handle);
14 }
15
16 pub fn destroyChild(self: *const Ip6ServiceBinding, handle: Handle) Status {
17 return self._destroy_child(self, handle);
18 }
19
20 pub const guid align(8) = Guid{
21 .time_low = 0xec835dd3,
22 .time_mid = 0xfe0f,
23 .time_high_and_version = 0x617b,
24 .clock_seq_high_and_reserved = 0xa6,
25 .clock_seq_low = 0x21,
26 .node = [_]u8{ 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 },
27 };
28};
lib/std/os/uefi/protocol/loaded_image.zig+10-3
...@@ -7,6 +7,7 @@ const SystemTable = uefi.tables.SystemTable;...@@ -7,6 +7,7 @@ const SystemTable = uefi.tables.SystemTable;
7const MemoryType = uefi.tables.MemoryType;7const MemoryType = uefi.tables.MemoryType;
8const DevicePath = uefi.protocol.DevicePath;8const DevicePath = uefi.protocol.DevicePath;
9const cc = uefi.cc;9const cc = uefi.cc;
10const Error = Status.Error;
1011
11pub const LoadedImage = extern struct {12pub const LoadedImage = extern struct {
12 revision: u32,13 revision: u32,
...@@ -21,11 +22,17 @@ pub const LoadedImage = extern struct {...@@ -21,11 +22,17 @@ pub const LoadedImage = extern struct {
21 image_size: u64,22 image_size: u64,
22 image_code_type: MemoryType,23 image_code_type: MemoryType,
23 image_data_type: MemoryType,24 image_data_type: MemoryType,
24 _unload: *const fn (*const LoadedImage, Handle) callconv(cc) Status,25 _unload: *const fn (*LoadedImage, Handle) callconv(cc) Status,
26
27 pub const UnloadError = uefi.UnexpectedError || error{InvalidParameter};
2528
26 /// Unloads an image from memory.29 /// Unloads an image from memory.
27 pub fn unload(self: *const LoadedImage, handle: Handle) Status {30 pub fn unload(self: *LoadedImage, handle: Handle) UnloadError!void {
28 return self._unload(self, handle);31 switch (self._unload(self, handle)) {
32 .success => {},
33 .invalid_parameter => return Error.InvalidParameter,
34 else => |status| return uefi.unexpectedStatus(status),
35 }
29 }36 }
3037
31 pub const guid align(8) = Guid{38 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/managed_network.zig+151-23
...@@ -8,58 +8,186 @@ const Time = uefi.Time;...@@ -8,58 +8,186 @@ const Time = uefi.Time;
8const SimpleNetwork = uefi.protocol.SimpleNetwork;8const SimpleNetwork = uefi.protocol.SimpleNetwork;
9const MacAddress = uefi.MacAddress;9const MacAddress = uefi.MacAddress;
10const cc = uefi.cc;10const cc = uefi.cc;
11const Error = Status.Error;
1112
12pub const ManagedNetwork = extern struct {13pub const ManagedNetwork = extern struct {
13 _get_mode_data: *const fn (*const ManagedNetwork, ?*Config, ?*SimpleNetwork) callconv(cc) Status,14 _get_mode_data: *const fn (*const ManagedNetwork, ?*Config, ?*SimpleNetwork) callconv(cc) Status,
14 _configure: *const fn (*const ManagedNetwork, ?*const Config) callconv(cc) Status,15 _configure: *const fn (*ManagedNetwork, ?*const Config) callconv(cc) Status,
15 _mcast_ip_to_mac: *const fn (*const ManagedNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,16 _mcast_ip_to_mac: *const fn (*ManagedNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
16 _groups: *const fn (*const ManagedNetwork, bool, ?*const MacAddress) callconv(cc) Status,17 _groups: *const fn (*ManagedNetwork, bool, ?*const MacAddress) callconv(cc) Status,
17 _transmit: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status,18 _transmit: *const fn (*ManagedNetwork, *CompletionToken) callconv(cc) Status,
18 _receive: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status,19 _receive: *const fn (*ManagedNetwork, *CompletionToken) callconv(cc) Status,
19 _cancel: *const fn (*const ManagedNetwork, ?*const CompletionToken) callconv(cc) Status,20 _cancel: *const fn (*ManagedNetwork, ?*const CompletionToken) callconv(cc) Status,
20 _poll: *const fn (*const ManagedNetwork) callconv(cc) Status,21 _poll: *const fn (*ManagedNetwork) callconv(cc) Status,
22
23 pub const GetModeDataError = uefi.UnexpectedError || error{
24 InvalidParameter,
25 Unsupported,
26 NotStarted,
27 } || Error;
28 pub const ConfigureError = uefi.UnexpectedError || error{
29 InvalidParameter,
30 OutOfResources,
31 Unsupported,
32 DeviceError,
33 } || Error;
34 pub const McastIpToMacError = uefi.UnexpectedError || error{
35 InvalidParameter,
36 NotStarted,
37 Unsupported,
38 DeviceError,
39 } || Error;
40 pub const GroupsError = uefi.UnexpectedError || error{
41 InvalidParameter,
42 NotStarted,
43 AlreadyStarted,
44 NotFound,
45 DeviceError,
46 Unsupported,
47 } || Error;
48 pub const TransmitError = uefi.UnexpectedError || error{
49 NotStarted,
50 InvalidParameter,
51 AccessDenied,
52 OutOfResources,
53 DeviceError,
54 NotReady,
55 NoMedia,
56 };
57 pub const ReceiveError = uefi.UnexpectedError || error{
58 NotStarted,
59 InvalidParameter,
60 OutOfResources,
61 DeviceError,
62 AccessDenied,
63 NotReady,
64 NoMedia,
65 };
66 pub const CancelError = uefi.UnexpectedError || error{
67 NotStarted,
68 InvalidParameter,
69 NotFound,
70 };
71 pub const PollError = uefi.UnexpectedError || error{
72 NotStarted,
73 DeviceError,
74 NotReady,
75 Timeout,
76 };
77
78 pub const GetModeDataData = struct {
79 mnp_config: Config,
80 snp_mode: SimpleNetwork,
81 };
2182
22 /// Returns the operational parameters for the current MNP child driver.83 /// Returns the operational parameters for the current MNP child driver.
23 /// May also support returning the underlying SNP driver mode data.84 /// May also support returning the underlying SNP driver mode data.
24 pub fn getModeData(self: *const ManagedNetwork, mnp_config_data: ?*Config, snp_mode_data: ?*SimpleNetwork) Status {85 pub fn getModeData(self: *const ManagedNetwork) GetModeDataError!GetModeDataData {
25 return self._get_mode_data(self, mnp_config_data, snp_mode_data);86 var data: GetModeDataData = undefined;
87 switch (self._get_mode_data(self, &data.mnp_config, &data.snp_mode)) {
88 .success => return data,
89 else => |status| {
90 try status.err();
91 return uefi.unexpectedStatus(status);
92 },
93 }
26 }94 }
2795
28 /// Sets or clears the operational parameters for the MNP child driver.96 /// Sets or clears the operational parameters for the MNP child driver.
29 pub fn configure(self: *const ManagedNetwork, mnp_config_data: ?*const Config) Status {97 pub fn configure(self: *ManagedNetwork, mnp_config_data: ?*const Config) ConfigureError!void {
30 return self._configure(self, mnp_config_data);98 switch (self._configure(self, mnp_config_data)) {
99 .success => {},
100 else => |status| {
101 try status.err();
102 return uefi.unexpectedStatus(status);
103 },
104 }
31 }105 }
32106
33 /// Translates an IP multicast address to a hardware (MAC) multicast address.107 /// Translates an IP multicast address to a hardware (MAC) multicast address.
34 /// This function may be unsupported in some MNP implementations.108 /// This function may be unsupported in some MNP implementations.
35 pub fn mcastIpToMac(self: *const ManagedNetwork, ipv6flag: bool, ipaddress: *const anyopaque, mac_address: *MacAddress) Status {109 pub fn mcastIpToMac(
36 return self._mcast_ip_to_mac(self, ipv6flag, ipaddress, mac_address);110 self: *ManagedNetwork,
111 ipv6flag: bool,
112 ipaddress: *const uefi.IpAddress,
113 ) McastIpToMacError!MacAddress {
114 var result: MacAddress = undefined;
115 switch (self._mcast_ip_to_mac(self, ipv6flag, ipaddress, &result)) {
116 .success => return result,
117 else => |status| {
118 try status.err();
119 return uefi.unexpectedStatus(status);
120 },
121 }
37 }122 }
38123
39 /// Enables and disables receive filters for multicast address.124 /// Enables and disables receive filters for multicast address.
40 /// This function may be unsupported in some MNP implementations.125 /// This function may be unsupported in some MNP implementations.
41 pub fn groups(self: *const ManagedNetwork, join_flag: bool, mac_address: ?*const MacAddress) Status {126 pub fn groups(
42 return self._groups(self, join_flag, mac_address);127 self: *ManagedNetwork,
128 join_flag: bool,
129 mac_address: ?*const MacAddress,
130 ) GroupsError!void {
131 switch (self._groups(self, join_flag, mac_address)) {
132 .success => {},
133 else => |status| {
134 try status.err();
135 return uefi.unexpectedStatus(status);
136 },
137 }
43 }138 }
44139
45 /// Places asynchronous outgoing data packets into the transmit queue.140 /// Places asynchronous outgoing data packets into the transmit queue.
46 pub fn transmit(self: *const ManagedNetwork, token: *const CompletionToken) Status {141 pub fn transmit(self: *ManagedNetwork, token: *CompletionToken) TransmitError!void {
47 return self._transmit(self, token);142 switch (self._transmit(self, token)) {
143 .success => {},
144 .not_started => return Error.NotStarted,
145 .invalid_parameter => return Error.InvalidParameter,
146 .access_denied => return Error.AccessDenied,
147 .out_of_resources => return Error.OutOfResources,
148 .device_error => return Error.DeviceError,
149 .not_ready => return Error.NotReady,
150 .no_media => return Error.NoMedia,
151 else => |status| return uefi.unexpectedStatus(status),
152 }
48 }153 }
49154
50 /// Places an asynchronous receiving request into the receiving queue.155 /// Places an asynchronous receiving request into the receiving queue.
51 pub fn receive(self: *const ManagedNetwork, token: *const CompletionToken) Status {156 pub fn receive(self: *ManagedNetwork, token: *CompletionToken) TransmitError!void {
52 return self._receive(self, token);157 switch (self._receive(self, token)) {
158 .success => {},
159 .not_started => return Error.NotStarted,
160 .invalid_parameter => return Error.InvalidParameter,
161 .out_of_resources => return Error.OutOfResources,
162 .device_error => return Error.DeviceError,
163 .access_denied => return Error.AccessDenied,
164 .not_ready => return Error.NotReady,
165 .no_media => return Error.NoMedia,
166 else => |status| return uefi.unexpectedStatus(status),
167 }
53 }168 }
54169
55 /// Aborts an asynchronous transmit or receive request.170 /// Aborts an asynchronous transmit or receive request.
56 pub fn cancel(self: *const ManagedNetwork, token: ?*const CompletionToken) Status {171 pub fn cancel(self: *ManagedNetwork, token: ?*const CompletionToken) CancelError!void {
57 return self._cancel(self, token);172 switch (self._cancel(self, token)) {
173 .success => {},
174 .not_started => return Error.NotStarted,
175 .invalid_parameter => return Error.InvalidParameter,
176 .not_found => return Error.NotFound,
177 else => |status| return uefi.unexpectedStatus(status),
178 }
58 }179 }
59180
60 /// Polls for incoming data packets and processes outgoing data packets.181 /// Polls for incoming data packets and processes outgoing data packets.
61 pub fn poll(self: *const ManagedNetwork) Status {182 pub fn poll(self: *ManagedNetwork) PollError!void {
62 return self._poll(self);183 switch (self._poll(self)) {
184 .success => {},
185 .not_started => return Error.NotStarted,
186 .device_error => return Error.DeviceError,
187 .not_ready => return Error.NotReady,
188 .timeout => return Error.Timeout,
189 else => |status| return uefi.unexpectedStatus(status),
190 }
63 }191 }
64192
65 pub const guid align(8) = Guid{193 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/rng.zig+31-4
...@@ -3,20 +3,47 @@ const uefi = std.os.uefi;...@@ -3,20 +3,47 @@ const uefi = std.os.uefi;
3const Guid = uefi.Guid;3const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const cc = uefi.cc;5const cc = uefi.cc;
6const Error = Status.Error;
67
7/// Random Number Generator protocol8/// Random Number Generator protocol
8pub const Rng = extern struct {9pub const Rng = extern struct {
9 _get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status,10 _get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status,
10 _get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,11 _get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,
1112
13 pub const GetInfoError = uefi.UnexpectedError || error{
14 Unsupported,
15 DeviceError,
16 BufferTooSmall,
17 };
18 pub const GetRNGError = uefi.UnexpectedError || error{
19 Unsupported,
20 DeviceError,
21 NotReady,
22 InvalidParameter,
23 };
24
12 /// Returns information about the random number generation implementation.25 /// Returns information about the random number generation implementation.
13 pub fn getInfo(self: *const Rng, list_size: *usize, list: [*]align(8) Guid) Status {26 pub fn getInfo(self: *const Rng, list: []align(8) Guid) GetInfoError![]align(8) Guid {
14 return self._get_info(self, list_size, list);27 var len: usize = list.len;
28 switch (self._get_info(self, &len, list.ptr)) {
29 .success => return list[0..len],
30 .unsupported => return Error.Unsupported,
31 .device_error => return Error.DeviceError,
32 .buffer_too_small => return Error.BufferTooSmall,
33 else => |status| return uefi.unexpectedStatus(status),
34 }
15 }35 }
1636
17 /// Produces and returns an RNG value using either the default or specified RNG algorithm.37 /// Produces and returns an RNG value using either the default or specified RNG algorithm.
18 pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) Status {38 pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value: []u8) GetRNGError!void {
19 return self._get_rng(self, algo, value_length, value);39 switch (self._get_rng(self, algo, value.len, value.ptr)) {
40 .success => {},
41 .unsupported => return Error.Unsupported,
42 .device_error => return Error.DeviceError,
43 .not_ready => return Error.NotReady,
44 .invalid_parameter => return Error.InvalidParameter,
45 else => |status| return uefi.unexpectedStatus(status),
46 }
20 }47 }
2148
22 pub const guid align(8) = Guid{49 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/serial_io.zig+84-17
...@@ -3,46 +3,113 @@ const uefi = std.os.uefi;...@@ -3,46 +3,113 @@ const uefi = std.os.uefi;
3const Guid = uefi.Guid;3const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const cc = uefi.cc;5const cc = uefi.cc;
6const Error = Status.Error;
67
7pub const SerialIo = extern struct {8pub const SerialIo = extern struct {
8 revision: u64,9 revision: u64,
9 _reset: *const fn (*const SerialIo) callconv(cc) Status,10 _reset: *const fn (*SerialIo) callconv(cc) Status,
10 _set_attribute: *const fn (*const SerialIo, u64, u32, u32, ParityType, u8, StopBitsType) callconv(cc) Status,11 _set_attribute: *const fn (*SerialIo, u64, u32, u32, ParityType, u8, StopBitsType) callconv(cc) Status,
11 _set_control: *const fn (*const SerialIo, u32) callconv(cc) Status,12 _set_control: *const fn (*SerialIo, u32) callconv(cc) Status,
12 _get_control: *const fn (*const SerialIo, *u32) callconv(cc) Status,13 _get_control: *const fn (*const SerialIo, *u32) callconv(cc) Status,
13 _write: *const fn (*const SerialIo, *usize, *anyopaque) callconv(cc) Status,14 _write: *const fn (*SerialIo, *usize, *const anyopaque) callconv(cc) Status,
14 _read: *const fn (*const SerialIo, *usize, *anyopaque) callconv(cc) Status,15 _read: *const fn (*SerialIo, *usize, *anyopaque) callconv(cc) Status,
15 mode: *Mode,16 mode: *Mode,
16 device_type_guid: ?*Guid,17 device_type_guid: ?*Guid,
1718
19 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
20 pub const SetAttributeError = uefi.UnexpectedError || error{
21 InvalidParameter,
22 DeviceError,
23 };
24 pub const SetControlError = uefi.UnexpectedError || error{
25 Unsupported,
26 DeviceError,
27 };
28 pub const GetControlError = uefi.UnexpectedError || error{DeviceError};
29 pub const WriteError = uefi.UnexpectedError || error{
30 DeviceError,
31 Timeout,
32 };
33 pub const ReadError = uefi.UnexpectedError || error{
34 DeviceError,
35 Timeout,
36 };
37
18 /// Resets the serial device.38 /// Resets the serial device.
19 pub fn reset(self: *const SerialIo) Status {39 pub fn reset(self: *SerialIo) ResetError!void {
20 return self._reset(self);40 switch (self._reset(self)) {
41 .success => {},
42 .device_error => return Error.DeviceError,
43 else => |status| return uefi.unexpectedStatus(status),
44 }
21 }45 }
2246
23 /// Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device.47 /// Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device.
24 pub fn setAttribute(self: *const SerialIo, baud_rate: u64, receiver_fifo_depth: u32, timeout: u32, parity: ParityType, data_bits: u8, stop_bits: StopBitsType) Status {48 pub fn setAttribute(
25 return self._set_attribute(self, baud_rate, receiver_fifo_depth, timeout, parity, data_bits, stop_bits);49 self: *SerialIo,
50 baud_rate: u64,
51 receiver_fifo_depth: u32,
52 timeout: u32,
53 parity: ParityType,
54 data_bits: u8,
55 stop_bits: StopBitsType,
56 ) SetAttributeError!void {
57 switch (self._set_attribute(
58 self,
59 baud_rate,
60 receiver_fifo_depth,
61 timeout,
62 parity,
63 data_bits,
64 stop_bits,
65 )) {
66 .success => {},
67 .invalid_parameter => return Error.InvalidParameter,
68 .device_error => return Error.DeviceError,
69 else => |status| return uefi.unexpectedStatus(status),
70 }
26 }71 }
2772
28 /// Sets the control bits on a serial device.73 /// Sets the control bits on a serial device.
29 pub fn setControl(self: *const SerialIo, control: u32) Status {74 pub fn setControl(self: *SerialIo, control: u32) SetControlError!void {
30 return self._set_control(self, control);75 switch (self._set_control(self, control)) {
76 .success => {},
77 .unsupported => return Error.Unsupported,
78 .device_error => return Error.DeviceError,
79 else => |status| return uefi.unexpectedStatus(status),
80 }
31 }81 }
3282
33 /// Retrieves the status of the control bits on a serial device.83 /// Retrieves the status of the control bits on a serial device.
34 pub fn getControl(self: *const SerialIo, control: *u32) Status {84 pub fn getControl(self: *SerialIo) GetControlError!u32 {
35 return self._get_control(self, control);85 var control: u32 = undefined;
86 switch (self._get_control(self, &control)) {
87 .success => return control,
88 .device_error => return Error.DeviceError,
89 else => |status| return uefi.unexpectedStatus(status),
90 }
36 }91 }
3792
38 /// Writes data to a serial device.93 /// Writes data to a serial device.
39 pub fn write(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status {94 pub fn write(self: *SerialIo, buffer: []const u8) WriteError!usize {
40 return self._write(self, buffer_size, buffer);95 var len: usize = buffer.len;
96 switch (self._write(self, &len, buffer.ptr)) {
97 .success => return len,
98 .device_error => return Error.DeviceError,
99 .timeout => return Error.Timeout,
100 else => |status| return uefi.unexpectedStatus(status),
101 }
41 }102 }
42103
43 /// Reads data from a serial device.104 /// Reads data from a serial device.
44 pub fn read(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status {105 pub fn read(self: *SerialIo, buffer: []u8) ReadError!usize {
45 return self._read(self, buffer_size, buffer);106 var len: usize = buffer.len;
107 switch (self._read(self, &len, buffer.ptr)) {
108 .success => return len,
109 .device_error => return Error.DeviceError,
110 .timeout => return Error.Timeout,
111 else => |status| return uefi.unexpectedStatus(status),
112 }
46 }113 }
47114
48 pub const guid align(8) = Guid{115 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/service_binding.zig created+60
...@@ -0,0 +1,60 @@
1const std = @import("std");
2const uefi = std.uefi;
3const Guid = uefi.Guid;
4const Handle = uefi.Handle;
5const Status = uefi.Status;
6const Error = Status.Error;
7const cc = uefi.cc;
8
9pub fn ServiceBinding(service_guid: Guid) type {
10 return struct {
11 const Self = @This();
12
13 _create_child: *const fn (*Self, *?Handle) callconv(cc) Status,
14 _destroy_child: *const fn (*Self, Handle) callconv(cc) Status,
15
16 pub const CreateChildError = uefi.UnexpectedError || error{
17 InvalidParameter,
18 OutOfResources,
19 } || Error;
20 pub const DestroyChildError = uefi.UnexpectedError || error{
21 Unsupported,
22 InvalidParameter,
23 AccessDenied,
24 } || Error;
25
26 /// To add this protocol to an existing handle, use `addToHandle` instead.
27 pub fn createChild(self: *Self) CreateChildError!Handle {
28 var handle: ?Handle = null;
29 switch (self._create_child(self, &handle)) {
30 .success => return handle orelse error.Unexpected,
31 else => |status| {
32 try status.err();
33 return uefi.unexpectedStatus(status);
34 },
35 }
36 }
37
38 pub fn addToHandle(self: *Self, handle: Handle) CreateChildError!void {
39 switch (self._create_child(self, @ptrCast(@constCast(&handle)))) {
40 .success => {},
41 else => |status| {
42 try status.err();
43 return uefi.unexpectedStatus(status);
44 },
45 }
46 }
47
48 pub fn destroyChild(self: *Self, handle: Handle) DestroyChildError!void {
49 switch (self._destroy_child(self, handle)) {
50 .success => {},
51 else => |status| {
52 try status.err();
53 return uefi.unexpectedStatus(status);
54 },
55 }
56 }
57
58 pub const guid align(8) = service_guid;
59 };
60}
lib/std/os/uefi/protocol/simple_file_system.zig+26-4
...@@ -1,16 +1,38 @@...@@ -1,16 +1,38 @@
1const std = @import("std");1const std = @import("std");
2const uefi = std.os.uefi;2const uefi = std.os.uefi;
3const Guid = uefi.Guid;3const Guid = uefi.Guid;
4const FileProtocol = uefi.protocol.File;4const File = uefi.protocol.File;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8pub const SimpleFileSystem = extern struct {9pub const SimpleFileSystem = extern struct {
9 revision: u64,10 revision: u64,
10 _open_volume: *const fn (*const SimpleFileSystem, **const FileProtocol) callconv(cc) Status,11 _open_volume: *const fn (*const SimpleFileSystem, **File) callconv(cc) Status,
1112
12 pub fn openVolume(self: *const SimpleFileSystem, root: **const FileProtocol) Status {13 pub const OpenVolumeError = uefi.UnexpectedError || error{
13 return self._open_volume(self, root);14 Unsupported,
15 NoMedia,
16 DeviceError,
17 VolumeCorrupted,
18 AccessDenied,
19 OutOfResources,
20 MediaChanged,
21 };
22
23 pub fn openVolume(self: *const SimpleFileSystem) OpenVolumeError!*File {
24 var root: *File = undefined;
25 switch (self._open_volume(self, &root)) {
26 .success => return root,
27 .unsupported => return Error.Unsupported,
28 .no_media => return Error.NoMedia,
29 .device_error => return Error.DeviceError,
30 .volume_corrupted => return Error.VolumeCorrupted,
31 .access_denied => return Error.AccessDenied,
32 .out_of_resources => return Error.OutOfResources,
33 .media_changed => return Error.MediaChanged,
34 else => |status| return uefi.unexpectedStatus(status),
35 }
14 }36 }
1537
16 pub const guid align(8) = Guid{38 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/simple_network.zig+312-38
...@@ -4,88 +4,349 @@ const Event = uefi.Event;...@@ -4,88 +4,349 @@ const Event = uefi.Event;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8pub const SimpleNetwork = extern struct {9pub const SimpleNetwork = extern struct {
9 revision: u64,10 revision: u64,
10 _start: *const fn (*const SimpleNetwork) callconv(cc) Status,11 _start: *const fn (*SimpleNetwork) callconv(cc) Status,
11 _stop: *const fn (*const SimpleNetwork) callconv(cc) Status,12 _stop: *const fn (*SimpleNetwork) callconv(cc) Status,
12 _initialize: *const fn (*const SimpleNetwork, usize, usize) callconv(cc) Status,13 _initialize: *const fn (*SimpleNetwork, usize, usize) callconv(cc) Status,
13 _reset: *const fn (*const SimpleNetwork, bool) callconv(cc) Status,14 _reset: *const fn (*SimpleNetwork, bool) callconv(cc) Status,
14 _shutdown: *const fn (*const SimpleNetwork) callconv(cc) Status,15 _shutdown: *const fn (*SimpleNetwork) callconv(cc) Status,
15 _receive_filters: *const fn (*const SimpleNetwork, ReceiveFilter, ReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status,16 _receive_filters: *const fn (*SimpleNetwork, ReceiveFilter, ReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status,
16 _station_address: *const fn (*const SimpleNetwork, bool, ?*const MacAddress) callconv(cc) Status,17 _station_address: *const fn (*SimpleNetwork, bool, ?*const MacAddress) callconv(cc) Status,
17 _statistics: *const fn (*const SimpleNetwork, bool, ?*usize, ?*Statistics) callconv(cc) Status,18 _statistics: *const fn (*const SimpleNetwork, bool, ?*usize, ?*Statistics) callconv(cc) Status,
18 _mcast_ip_to_mac: *const fn (*const SimpleNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,19 _mcast_ip_to_mac: *const fn (*SimpleNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
19 _nvdata: *const fn (*const SimpleNetwork, bool, usize, usize, [*]u8) callconv(cc) Status,20 _nvdata: *const fn (*SimpleNetwork, bool, usize, usize, [*]u8) callconv(cc) Status,
20 _get_status: *const fn (*const SimpleNetwork, *InterruptStatus, ?*?[*]u8) callconv(cc) Status,21 _get_status: *const fn (*SimpleNetwork, ?*InterruptStatus, ?*?[*]u8) callconv(cc) Status,
21 _transmit: *const fn (*const SimpleNetwork, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(cc) Status,22 _transmit: *const fn (*SimpleNetwork, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(cc) Status,
22 _receive: *const fn (*const SimpleNetwork, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status,23 _receive: *const fn (*SimpleNetwork, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status,
23 wait_for_packet: Event,24 wait_for_packet: Event,
24 mode: *Mode,25 mode: *Mode,
2526
27 pub const StartError = uefi.UnexpectedError || error{
28 AlreadyStarted,
29 InvalidParameter,
30 DeviceError,
31 Unsupported,
32 };
33 pub const StopError = uefi.UnexpectedError || error{
34 NotStarted,
35 InvalidParameter,
36 DeviceError,
37 Unsupported,
38 };
39 pub const InitializeError = uefi.UnexpectedError || error{
40 NotStarted,
41 OutOfResources,
42 InvalidParameter,
43 DeviceError,
44 Unsupported,
45 };
46 pub const ResetError = uefi.UnexpectedError || error{
47 NotStarted,
48 InvalidParameter,
49 DeviceError,
50 Unsupported,
51 };
52 pub const ShutdownError = uefi.UnexpectedError || error{
53 NotStarted,
54 InvalidParameter,
55 DeviceError,
56 };
57 pub const ReceiveFiltersError = uefi.UnexpectedError || error{
58 NotStarted,
59 InvalidParameter,
60 DeviceError,
61 Unsupported,
62 };
63 pub const StationAddressError = uefi.UnexpectedError || error{
64 NotStarted,
65 InvalidParameter,
66 DeviceError,
67 Unsupported,
68 };
69 pub const StatisticsError = uefi.UnexpectedError || error{
70 NotStarted,
71 BufferTooSmall,
72 InvalidParameter,
73 DeviceError,
74 Unsupported,
75 };
76 pub const McastIpToMacError = uefi.UnexpectedError || error{
77 NotStarted,
78 InvalidParameter,
79 DeviceError,
80 Unsupported,
81 };
82 pub const NvDataError = uefi.UnexpectedError || error{
83 NotStarted,
84 InvalidParameter,
85 DeviceError,
86 Unsupported,
87 };
88 pub const GetStatusError = uefi.UnexpectedError || error{
89 NotStarted,
90 InvalidParameter,
91 DeviceError,
92 };
93 pub const TransmitError = uefi.UnexpectedError || error{
94 NotStarted,
95 NotReady,
96 BufferTooSmall,
97 InvalidParameter,
98 DeviceError,
99 Unsupported,
100 };
101 pub const ReceiveError = uefi.UnexpectedError || error{
102 NotStarted,
103 NotReady,
104 BufferTooSmall,
105 InvalidParameter,
106 DeviceError,
107 };
108
26 /// Changes the state of a network interface from "stopped" to "started".109 /// Changes the state of a network interface from "stopped" to "started".
27 pub fn start(self: *const SimpleNetwork) Status {110 pub fn start(self: *SimpleNetwork) StartError!void {
28 return self._start(self);111 switch (self._start(self)) {
112 .success => {},
113 .already_started => return Error.AlreadyStarted,
114 .invalid_parameter => return Error.InvalidParameter,
115 .device_error => return Error.DeviceError,
116 .unsupported => return Error.Unsupported,
117 else => |status| return uefi.unexpectedStatus(status),
118 }
29 }119 }
30120
31 /// Changes the state of a network interface from "started" to "stopped".121 /// Changes the state of a network interface from "started" to "stopped".
32 pub fn stop(self: *const SimpleNetwork) Status {122 pub fn stop(self: *SimpleNetwork) StopError!void {
33 return self._stop(self);123 switch (self._stop(self)) {
124 .success => {},
125 .not_started => return Error.NotStarted,
126 .invalid_parameter => return Error.InvalidParameter,
127 .device_error => return Error.DeviceError,
128 .unsupported => return Error.Unsupported,
129 else => |status| return uefi.unexpectedStatus(status),
130 }
34 }131 }
35132
36 /// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.133 /// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.
37 pub fn initialize(self: *const SimpleNetwork, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) Status {134 pub fn initialize(
38 return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size);135 self: *SimpleNetwork,
136 extra_rx_buffer_size: usize,
137 extra_tx_buffer_size: usize,
138 ) InitializeError!void {
139 switch (self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size)) {
140 .success => {},
141 .not_started => return Error.NotStarted,
142 .out_of_resources => return Error.OutOfResources,
143 .invalid_parameter => return Error.InvalidParameter,
144 .device_error => return Error.DeviceError,
145 .unsupported => return Error.Unsupported,
146 else => |status| return uefi.unexpectedStatus(status),
147 }
39 }148 }
40149
41 /// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().150 /// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().
42 pub fn reset(self: *const SimpleNetwork, extended_verification: bool) Status {151 pub fn reset(self: *SimpleNetwork, extended_verification: bool) ResetError!void {
43 return self._reset(self, extended_verification);152 switch (self._reset(self, extended_verification)) {
153 .success => {},
154 .not_started => return Error.NotStarted,
155 .invalid_parameter => return Error.InvalidParameter,
156 .device_error => return Error.DeviceError,
157 .unsupported => return Error.Unsupported,
158 else => |status| return uefi.unexpectedStatus(status),
159 }
44 }160 }
45161
46 /// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.162 /// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.
47 pub fn shutdown(self: *const SimpleNetwork) Status {163 pub fn shutdown(self: *SimpleNetwork) ShutdownError!void {
48 return self._shutdown(self);164 switch (self._shutdown(self)) {
165 .success => {},
166 .not_started => return ShutdownError.NotStarted,
167 .invalid_parameter => return ShutdownError.InvalidParameter,
168 .device_error => return ShutdownError.DeviceError,
169 else => |status| return uefi.unexpectedStatus(status),
170 }
49 }171 }
50172
51 /// Manages the multicast receive filters of a network interface.173 /// Manages the multicast receive filters of a network interface.
52 pub fn receiveFilters(self: *const SimpleNetwork, enable: ReceiveFilter, disable: ReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) Status {174 pub fn receiveFilters(
53 return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter);175 self: *SimpleNetwork,
176 enable: ReceiveFilter,
177 disable: ReceiveFilter,
178 reset_mcast_filter: bool,
179 mcast_filter: ?[]const MacAddress,
180 ) ReceiveFiltersError!void {
181 const count: usize, const ptr: ?[*]const MacAddress =
182 if (mcast_filter) |f|
183 .{ f.len, f.ptr }
184 else
185 .{ 0, null };
186
187 switch (self._receive_filters(self, enable, disable, reset_mcast_filter, count, ptr)) {
188 .success => {},
189 .not_started => return Error.NotStarted,
190 .invalid_parameter => return Error.InvalidParameter,
191 .device_error => return Error.DeviceError,
192 .unsupported => return Error.Unsupported,
193 else => |status| return uefi.unexpectedStatus(status),
194 }
54 }195 }
55196
56 /// Modifies or resets the current station address, if supported.197 /// Modifies or resets the current station address, if supported.
57 pub fn stationAddress(self: *const SimpleNetwork, reset_flag: bool, new: ?*const MacAddress) Status {198 pub fn stationAddress(
58 return self._station_address(self, reset_flag, new);199 self: *SimpleNetwork,
200 reset_flag: bool,
201 new: ?*const MacAddress,
202 ) StationAddressError!void {
203 switch (self._station_address(self, reset_flag, new)) {
204 .success => {},
205 .not_started => return Error.NotStarted,
206 .invalid_parameter => return Error.InvalidParameter,
207 .device_error => return Error.DeviceError,
208 .unsupported => return Error.Unsupported,
209 else => |status| return uefi.unexpectedStatus(status),
210 }
211 }
212
213 pub fn resetStatistics(self: *SimpleNetwork) StatisticsError!void {
214 switch (self._statistics(self, true, null, null)) {
215 .success => {},
216 .not_started => return Error.NotStarted,
217 .invalid_parameter => return Error.InvalidParameter,
218 .device_error => return Error.DeviceError,
219 .unsupported => return Error.Unsupported,
220 else => |status| return uefi.unexpectedStatus(status),
221 }
59 }222 }
60223
61 /// Resets or collects the statistics on a network interface.224 /// Resets or collects the statistics on a network interface.
62 pub fn statistics(self: *const SimpleNetwork, reset_flag: bool, statistics_size: ?*usize, statistics_table: ?*Statistics) Status {225 pub fn statistics(self: *SimpleNetwork, reset_flag: bool) StatisticsError!Statistics {
63 return self._statistics(self, reset_flag, statistics_size, statistics_table);226 var stats: Statistics = undefined;
227 var stats_size: usize = @sizeOf(Statistics);
228 switch (self._statistics(self, reset_flag, &stats_size, &stats)) {
229 .success => {},
230 .not_started => return Error.NotStarted,
231 .invalid_parameter => return Error.InvalidParameter,
232 .device_error => return Error.DeviceError,
233 .unsupported => return Error.Unsupported,
234 else => |status| return uefi.unexpectedStatus(status),
235 }
236
237 if (stats_size != @sizeOf(Statistics))
238 return error.Unexpected
239 else
240 return stats;
64 }241 }
65242
66 /// Converts a multicast IP address to a multicast HW MAC address.243 /// Converts a multicast IP address to a multicast HW MAC address.
67 pub fn mcastIpToMac(self: *const SimpleNetwork, ipv6: bool, ip: *const anyopaque, mac: *MacAddress) Status {244 pub fn mcastIpToMac(
68 return self._mcast_ip_to_mac(self, ipv6, ip, mac);245 self: *SimpleNetwork,
246 ipv6: bool,
247 ip: *const anyopaque,
248 ) McastIpToMacError!MacAddress {
249 var mac: MacAddress = undefined;
250 switch (self._mcast_ip_to_mac(self, ipv6, ip, &mac)) {
251 .success => return mac,
252 .not_started => return Error.NotStarted,
253 .invalid_parameter => return Error.InvalidParameter,
254 .device_error => return Error.DeviceError,
255 .unsupported => return Error.Unsupported,
256 else => |status| return uefi.unexpectedStatus(status),
257 }
69 }258 }
70259
71 /// Performs read and write operations on the NVRAM device attached to a network interface.260 /// Performs read and write operations on the NVRAM device attached to a network interface.
72 pub fn nvdata(self: *const SimpleNetwork, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) Status {261 pub fn nvData(
73 return self._nvdata(self, read_write, offset, buffer_size, buffer);262 self: *SimpleNetwork,
263 read_write: NvDataOperation,
264 offset: usize,
265 buffer: []u8,
266 ) NvDataError!void {
267 switch (self._nvdata(
268 self,
269 // if ReadWrite is TRUE, a read operation is performed
270 read_write == .read,
271 offset,
272 buffer.len,
273 buffer.ptr,
274 )) {
275 .success => {},
276 .not_started => return Error.NotStarted,
277 .invalid_parameter => return Error.InvalidParameter,
278 .device_error => return Error.DeviceError,
279 .unsupported => return Error.Unsupported,
280 else => |status| return uefi.unexpectedStatus(status),
281 }
74 }282 }
75283
76 /// Reads the current interrupt status and recycled transmit buffer status from a network interface.284 /// Reads the current interrupt status and recycled transmit buffer status from a network interface.
77 pub fn getStatus(self: *const SimpleNetwork, interrupt_status: *InterruptStatus, tx_buf: ?*?[*]u8) Status {285 pub fn getStatus(
78 return self._get_status(self, interrupt_status, tx_buf);286 self: *SimpleNetwork,
287 interrupt_status: ?*InterruptStatus,
288 recycled_tx_buf: ?*?[*]u8,
289 ) GetStatusError!void {
290 switch (self._get_status(self, interrupt_status, recycled_tx_buf)) {
291 .success => {},
292 .not_started => return Error.NotStarted,
293 .invalid_parameter => return Error.InvalidParameter,
294 .device_error => return Error.DeviceError,
295 else => |status| return uefi.unexpectedStatus(status),
296 }
79 }297 }
80298
81 /// Places a packet in the transmit queue of a network interface.299 /// Places a packet in the transmit queue of a network interface.
82 pub fn transmit(self: *const SimpleNetwork, header_size: usize, buffer_size: usize, buffer: [*]const u8, src_addr: ?*const MacAddress, dest_addr: ?*const MacAddress, protocol: ?*const u16) Status {300 pub fn transmit(
83 return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);301 self: *SimpleNetwork,
302 header_size: usize,
303 buffer: []const u8,
304 src_addr: ?*const MacAddress,
305 dest_addr: ?*const MacAddress,
306 protocol: ?*const u16,
307 ) TransmitError!void {
308 switch (self._transmit(
309 self,
310 header_size,
311 buffer.len,
312 buffer.ptr,
313 src_addr,
314 dest_addr,
315 protocol,
316 )) {
317 .success => {},
318 .not_started => return Error.NotStarted,
319 .not_ready => return Error.NotReady,
320 .buffer_too_small => return Error.BufferTooSmall,
321 .invalid_parameter => return Error.InvalidParameter,
322 .device_error => return Error.DeviceError,
323 .unsupported => return Error.Unsupported,
324 else => |status| return uefi.unexpectedStatus(status),
325 }
84 }326 }
85327
86 /// Receives a packet from a network interface.328 /// Receives a packet from a network interface.
87 pub fn receive(self: *const SimpleNetwork, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) Status {329 pub fn receive(self: *SimpleNetwork, buffer: []u8) ReceiveError!Packet {
88 return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);330 var packet: Packet = undefined;
331 packet.buffer = buffer;
332
333 switch (self._receive(
334 self,
335 &packet.header_size,
336 &packet.buffer.len,
337 packet.buffer.ptr,
338 &packet.src_addr,
339 &packet.dst_addr,
340 &packet.protocol,
341 )) {
342 .success => return packet,
343 .not_started => return Error.NotStarted,
344 .not_ready => return Error.NotReady,
345 .buffer_too_small => return Error.BufferTooSmall,
346 .invalid_parameter => return Error.InvalidParameter,
347 .device_error => return Error.DeviceError,
348 else => |status| return uefi.unexpectedStatus(status),
349 }
89 }350 }
90351
91 pub const guid align(8) = Guid{352 pub const guid align(8) = Guid{
...@@ -97,6 +358,11 @@ pub const SimpleNetwork = extern struct {...@@ -97,6 +358,11 @@ pub const SimpleNetwork = extern struct {
97 .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },358 .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
98 };359 };
99360
361 pub const NvDataOperation = enum {
362 read,
363 write,
364 };
365
100 pub const MacAddress = [32]u8;366 pub const MacAddress = [32]u8;
101367
102 pub const Mode = extern struct {368 pub const Mode = extern struct {
...@@ -172,4 +438,12 @@ pub const SimpleNetwork = extern struct {...@@ -172,4 +438,12 @@ pub const SimpleNetwork = extern struct {
172 software_interrupt: bool,438 software_interrupt: bool,
173 _pad: u28 = 0,439 _pad: u28 = 0,
174 };440 };
441
442 pub const Packet = struct {
443 header_size: usize,
444 buffer: []u8,
445 src_addr: MacAddress,
446 dst_addr: MacAddress,
447 protocol: u16,
448 };
175};449};
lib/std/os/uefi/protocol/simple_pointer.zig+22-5
...@@ -4,22 +4,39 @@ const Event = uefi.Event;...@@ -4,22 +4,39 @@ const Event = uefi.Event;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Protocol for mice.9/// Protocol for mice.
9pub const SimplePointer = struct {10pub const SimplePointer = struct {
10 _reset: *const fn (*const SimplePointer, bool) callconv(cc) Status,11 _reset: *const fn (*SimplePointer, bool) callconv(cc) Status,
11 _get_state: *const fn (*const SimplePointer, *State) callconv(cc) Status,12 _get_state: *const fn (*const SimplePointer, *State) callconv(cc) Status,
12 wait_for_input: Event,13 wait_for_input: Event,
13 mode: *Mode,14 mode: *Mode,
1415
16 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
17 pub const GetStateError = uefi.UnexpectedError || error{
18 NotReady,
19 DeviceError,
20 };
21
15 /// Resets the pointer device hardware.22 /// Resets the pointer device hardware.
16 pub fn reset(self: *const SimplePointer, verify: bool) Status {23 pub fn reset(self: *SimplePointer, verify: bool) ResetError!void {
17 return self._reset(self, verify);24 switch (self._reset(self, verify)) {
25 .success => {},
26 .device_error => return Error.DeviceError,
27 else => |status| return uefi.unexpectedStatus(status),
28 }
18 }29 }
1930
20 /// Retrieves the current state of a pointer device.31 /// Retrieves the current state of a pointer device.
21 pub fn getState(self: *const SimplePointer, state: *State) Status {32 pub fn getState(self: *const SimplePointer) GetStateError!State {
22 return self._get_state(self, state);33 var state: State = undefined;
34 switch (self._get_state(self, &state)) {
35 .success => return state,
36 .not_ready => return Error.NotReady,
37 .device_error => return Error.DeviceError,
38 else => |status| return uefi.unexpectedStatus(status),
39 }
23 }40 }
2441
25 pub const guid align(8) = Guid{42 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/simple_text_input.zig+25-6
...@@ -4,21 +4,40 @@ const Event = uefi.Event;...@@ -4,21 +4,40 @@ const Event = uefi.Event;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Character input devices, e.g. Keyboard9/// Character input devices, e.g. Keyboard
9pub const SimpleTextInput = extern struct {10pub const SimpleTextInput = extern struct {
10 _reset: *const fn (*const SimpleTextInput, bool) callconv(cc) Status,11 _reset: *const fn (*SimpleTextInput, bool) callconv(cc) Status,
11 _read_key_stroke: *const fn (*const SimpleTextInput, *Key.Input) callconv(cc) Status,12 _read_key_stroke: *const fn (*SimpleTextInput, *Key.Input) callconv(cc) Status,
12 wait_for_key: Event,13 wait_for_key: Event,
1314
15 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
16 pub const ReadKeyStrokeError = uefi.UnexpectedError || error{
17 NotReady,
18 DeviceError,
19 Unsupported,
20 };
21
14 /// Resets the input device hardware.22 /// Resets the input device hardware.
15 pub fn reset(self: *const SimpleTextInput, verify: bool) Status {23 pub fn reset(self: *SimpleTextInput, verify: bool) ResetError!void {
16 return self._reset(self, verify);24 switch (self._reset(self, verify)) {
25 .success => {},
26 .device_error => return Error.DeviceError,
27 else => |status| return uefi.unexpectedStatus(status),
28 }
17 }29 }
1830
19 /// Reads the next keystroke from the input device.31 /// Reads the next keystroke from the input device.
20 pub fn readKeyStroke(self: *const SimpleTextInput, input_key: *Key.Input) Status {32 pub fn readKeyStroke(self: *SimpleTextInput) ReadKeyStrokeError!Key.Input {
21 return self._read_key_stroke(self, input_key);33 var key: Key.Input = undefined;
34 switch (self._read_key_stroke(self, &key)) {
35 .success => return key,
36 .not_ready => return Error.NotReady,
37 .device_error => return Error.DeviceError,
38 .unsupported => return Error.Unsupported,
39 else => |status| return uefi.unexpectedStatus(status),
40 }
22 }41 }
2342
24 pub const guid align(8) = Guid{43 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/simple_text_input_ex.zig+61-15
...@@ -4,39 +4,85 @@ const Event = uefi.Event;...@@ -4,39 +4,85 @@ const Event = uefi.Event;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
5const Status = uefi.Status;5const Status = uefi.Status;
6const cc = uefi.cc;6const cc = uefi.cc;
7const Error = Status.Error;
78
8/// Character input devices, e.g. Keyboard9/// Character input devices, e.g. Keyboard
9pub const SimpleTextInputEx = extern struct {10pub const SimpleTextInputEx = extern struct {
10 _reset: *const fn (*const SimpleTextInputEx, bool) callconv(cc) Status,11 _reset: *const fn (*SimpleTextInputEx, bool) callconv(cc) Status,
11 _read_key_stroke_ex: *const fn (*const SimpleTextInputEx, *Key) callconv(cc) Status,12 _read_key_stroke_ex: *const fn (*SimpleTextInputEx, *Key) callconv(cc) Status,
12 wait_for_key_ex: Event,13 wait_for_key_ex: Event,
13 _set_state: *const fn (*const SimpleTextInputEx, *const u8) callconv(cc) Status,14 _set_state: *const fn (*SimpleTextInputEx, *const u8) callconv(cc) Status,
14 _register_key_notify: *const fn (*const SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) usize, **anyopaque) callconv(cc) Status,15 _register_key_notify: *const fn (*SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) Status, **anyopaque) callconv(cc) Status,
15 _unregister_key_notify: *const fn (*const SimpleTextInputEx, *const anyopaque) callconv(cc) Status,16 _unregister_key_notify: *const fn (*SimpleTextInputEx, *const anyopaque) callconv(cc) Status,
17
18 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
19 pub const ReadKeyStrokeError = uefi.UnexpectedError || error{
20 NotReady,
21 DeviceError,
22 Unsupported,
23 };
24 pub const SetStateError = uefi.UnexpectedError || error{
25 DeviceError,
26 Unsupported,
27 };
28 pub const RegisterKeyNotifyError = uefi.UnexpectedError || error{OutOfResources};
29 pub const UnregisterKeyNotifyError = uefi.UnexpectedError || error{InvalidParameter};
1630
17 /// Resets the input device hardware.31 /// Resets the input device hardware.
18 pub fn reset(self: *const SimpleTextInputEx, verify: bool) Status {32 pub fn reset(self: *SimpleTextInputEx, verify: bool) ResetError!void {
19 return self._reset(self, verify);33 switch (self._reset(self, verify)) {
34 .success => {},
35 .device_error => return Error.DeviceError,
36 else => |status| return uefi.unexpectedStatus(status),
37 }
20 }38 }
2139
22 /// Reads the next keystroke from the input device.40 /// Reads the next keystroke from the input device.
23 pub fn readKeyStrokeEx(self: *const SimpleTextInputEx, key_data: *Key) Status {41 pub fn readKeyStroke(self: *SimpleTextInputEx) ReadKeyStrokeError!Key {
24 return self._read_key_stroke_ex(self, key_data);42 var key: Key = undefined;
43 switch (self._read_key_stroke_ex(self, &key)) {
44 .success => return key,
45 .not_ready => return Error.NotReady,
46 .device_error => return Error.DeviceError,
47 .unsupported => return Error.Unsupported,
48 else => |status| return uefi.unexpectedStatus(status),
49 }
25 }50 }
2651
27 /// Set certain state for the input device.52 /// Set certain state for the input device.
28 pub fn setState(self: *const SimpleTextInputEx, state: *const u8) Status {53 pub fn setState(self: *SimpleTextInputEx, state: *const Key.State.Toggle) SetStateError!void {
29 return self._set_state(self, state);54 switch (self._set_state(self, @ptrCast(state))) {
55 .success => {},
56 .device_error => return Error.DeviceError,
57 .unsupported => return Error.Unsupported,
58 else => |status| return uefi.unexpectedStatus(status),
59 }
30 }60 }
3161
32 /// Register a notification function for a particular keystroke for the input device.62 /// Register a notification function for a particular keystroke for the input device.
33 pub fn registerKeyNotify(self: *const SimpleTextInputEx, key_data: *const Key, notify: *const fn (*const Key) callconv(cc) usize, handle: **anyopaque) Status {63 pub fn registerKeyNotify(
34 return self._register_key_notify(self, key_data, notify, handle);64 self: *SimpleTextInputEx,
65 key_data: *const Key,
66 notify: *const fn (*const Key) callconv(cc) Status,
67 ) RegisterKeyNotifyError!uefi.Handle {
68 var handle: uefi.Handle = undefined;
69 switch (self._register_key_notify(self, key_data, notify, &handle)) {
70 .success => return handle,
71 .out_of_resources => return Error.OutOfResources,
72 else => |status| return uefi.unexpectedStatus(status),
73 }
35 }74 }
3675
37 /// Remove the notification that was previously registered.76 /// Remove the notification that was previously registered.
38 pub fn unregisterKeyNotify(self: *const SimpleTextInputEx, handle: *const anyopaque) Status {77 pub fn unregisterKeyNotify(
39 return self._unregister_key_notify(self, handle);78 self: *SimpleTextInputEx,
79 handle: uefi.Handle,
80 ) UnregisterKeyNotifyError!void {
81 switch (self._unregister_key_notify(self, handle)) {
82 .success => {},
83 .invalid_parameter => return Error.InvalidParameter,
84 else => |status| return uefi.unexpectedStatus(status),
85 }
40 }86 }
4187
42 pub const guid align(8) = Guid{88 pub const guid align(8) = Guid{
lib/std/os/uefi/protocol/simple_text_output.zig+144-50
...@@ -3,63 +3,142 @@ const uefi = std.os.uefi;...@@ -3,63 +3,142 @@ const uefi = std.os.uefi;
3const Guid = uefi.Guid;3const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
5const cc = uefi.cc;5const cc = uefi.cc;
6const Error = Status.Error;
67
7/// Character output devices8/// Character output devices
8pub const SimpleTextOutput = extern struct {9pub const SimpleTextOutput = extern struct {
9 _reset: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status,10 _reset: *const fn (*SimpleTextOutput, bool) callconv(cc) Status,
10 _output_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,11 _output_string: *const fn (*SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
11 _test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,12 _test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
12 _query_mode: *const fn (*const SimpleTextOutput, usize, *usize, *usize) callconv(cc) Status,13 _query_mode: *const fn (*const SimpleTextOutput, usize, *usize, *usize) callconv(cc) Status,
13 _set_mode: *const fn (*const SimpleTextOutput, usize) callconv(cc) Status,14 _set_mode: *const fn (*SimpleTextOutput, usize) callconv(cc) Status,
14 _set_attribute: *const fn (*const SimpleTextOutput, usize) callconv(cc) Status,15 _set_attribute: *const fn (*SimpleTextOutput, usize) callconv(cc) Status,
15 _clear_screen: *const fn (*const SimpleTextOutput) callconv(cc) Status,16 _clear_screen: *const fn (*SimpleTextOutput) callconv(cc) Status,
16 _set_cursor_position: *const fn (*const SimpleTextOutput, usize, usize) callconv(cc) Status,17 _set_cursor_position: *const fn (*SimpleTextOutput, usize, usize) callconv(cc) Status,
17 _enable_cursor: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status,18 _enable_cursor: *const fn (*SimpleTextOutput, bool) callconv(cc) Status,
18 mode: *Mode,19 mode: *Mode,
1920
21 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
22 pub const OutputStringError = uefi.UnexpectedError || error{
23 DeviceError,
24 Unsupported,
25 };
26 pub const QueryModeError = uefi.UnexpectedError || error{
27 DeviceError,
28 Unsupported,
29 };
30 pub const SetModeError = uefi.UnexpectedError || error{
31 DeviceError,
32 Unsupported,
33 };
34 pub const SetAttributeError = uefi.UnexpectedError || error{DeviceError};
35 pub const ClearScreenError = uefi.UnexpectedError || error{
36 DeviceError,
37 Unsupported,
38 };
39 pub const SetCursorPositionError = uefi.UnexpectedError || error{
40 DeviceError,
41 Unsupported,
42 };
43 pub const EnableCursorError = uefi.UnexpectedError || error{
44 DeviceError,
45 Unsupported,
46 };
47
20 /// Resets the text output device hardware.48 /// Resets the text output device hardware.
21 pub fn reset(self: *const SimpleTextOutput, verify: bool) Status {49 pub fn reset(self: *SimpleTextOutput, verify: bool) ResetError!void {
22 return self._reset(self, verify);50 switch (self._reset(self, verify)) {
51 .success => {},
52 .device_error => return Error.DeviceError,
53 else => |status| return uefi.unexpectedStatus(status),
54 }
23 }55 }
2456
25 /// Writes a string to the output device.57 /// Writes a string to the output device.
26 pub fn outputString(self: *const SimpleTextOutput, msg: [*:0]const u16) Status {58 ///
27 return self._output_string(self, msg);59 /// Returns `true` if the string was successfully written, `false` if an unknown glyph was encountered.
60 pub fn outputString(self: *SimpleTextOutput, msg: [*:0]const u16) OutputStringError!bool {
61 switch (self._output_string(self, msg)) {
62 .success => return true,
63 .warn_unknown_glyph => return false,
64 .device_error => return Error.DeviceError,
65 .unsupported => return Error.Unsupported,
66 else => |status| return uefi.unexpectedStatus(status),
67 }
28 }68 }
2969
30 /// Verifies that all characters in a string can be output to the target device.70 /// Verifies that all characters in a string can be output to the target device.
31 pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) Status {71 pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) uefi.UnexpectedError!bool {
32 return self._test_string(self, msg);72 switch (self._test_string(self, msg)) {
73 .success => return true,
74 .unsupported => return false,
75 else => |status| return uefi.unexpectedStatus(status),
76 }
33 }77 }
3478
35 /// Returns information for an available text mode that the output device(s) supports.79 /// Returns information for an available text mode that the output device(s) supports.
36 pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize, columns: *usize, rows: *usize) Status {80 pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize) QueryModeError!Geometry {
37 return self._query_mode(self, mode_number, columns, rows);81 var geo: Geometry = undefined;
82 switch (self._query_mode(self, mode_number, &geo.columns, &geo.rows)) {
83 .success => return geo,
84 .device_error => return Error.DeviceError,
85 .unsupported => return Error.Unsupported,
86 else => |status| return uefi.unexpectedStatus(status),
87 }
38 }88 }
3989
40 /// Sets the output device(s) to a specified mode.90 /// Sets the output device(s) to a specified mode.
41 pub fn setMode(self: *const SimpleTextOutput, mode_number: usize) Status {91 pub fn setMode(self: *SimpleTextOutput, mode_number: usize) SetModeError!void {
42 return self._set_mode(self, mode_number);92 switch (self._set_mode(self, mode_number)) {
93 .success => {},
94 .device_error => return Error.DeviceError,
95 .unsupported => return Error.Unsupported,
96 else => |status| return uefi.unexpectedStatus(status),
97 }
43 }98 }
4499
45 /// Sets the background and foreground colors for the outputString() and clearScreen() functions.100 /// Sets the background and foreground colors for the outputString() and clearScreen() functions.
46 pub fn setAttribute(self: *const SimpleTextOutput, attribute: usize) Status {101 pub fn setAttribute(self: *SimpleTextOutput, attribute: Attribute) SetAttributeError!void {
47 return self._set_attribute(self, attribute);102 const attr_as_num: u8 = @bitCast(attribute);
103 switch (self._set_attribute(self, @intCast(attr_as_num))) {
104 .success => {},
105 .device_error => return Error.DeviceError,
106 else => |status| return uefi.unexpectedStatus(status),
107 }
48 }108 }
49109
50 /// Clears the output device(s) display to the currently selected background color.110 /// Clears the output device(s) display to the currently selected background color.
51 pub fn clearScreen(self: *const SimpleTextOutput) Status {111 pub fn clearScreen(self: *SimpleTextOutput) ClearScreenError!void {
52 return self._clear_screen(self);112 switch (self._clear_screen(self)) {
113 .success => {},
114 .device_error => return Error.DeviceError,
115 .unsupported => return Error.Unsupported,
116 else => |status| return uefi.unexpectedStatus(status),
117 }
53 }118 }
54119
55 /// Sets the current coordinates of the cursor position.120 /// Sets the current coordinates of the cursor position.
56 pub fn setCursorPosition(self: *const SimpleTextOutput, column: usize, row: usize) Status {121 pub fn setCursorPosition(
57 return self._set_cursor_position(self, column, row);122 self: *SimpleTextOutput,
123 column: usize,
124 row: usize,
125 ) SetCursorPositionError!void {
126 switch (self._set_cursor_position(self, column, row)) {
127 .success => {},
128 .device_error => return Error.DeviceError,
129 .unsupported => return Error.Unsupported,
130 else => |status| return uefi.unexpectedStatus(status),
131 }
58 }132 }
59133
60 /// Makes the cursor visible or invisible.134 /// Makes the cursor visible or invisible.
61 pub fn enableCursor(self: *const SimpleTextOutput, visible: bool) Status {135 pub fn enableCursor(self: *SimpleTextOutput, visible: bool) EnableCursorError!void {
62 return self._enable_cursor(self, visible);136 switch (self._enable_cursor(self, visible)) {
137 .success => {},
138 .device_error => return Error.DeviceError,
139 .unsupported => return Error.Unsupported,
140 else => |status| return uefi.unexpectedStatus(status),
141 }
63 }142 }
64143
65 pub const guid align(8) = Guid{144 pub const guid align(8) = Guid{
...@@ -118,31 +197,41 @@ pub const SimpleTextOutput = extern struct {...@@ -118,31 +197,41 @@ pub const SimpleTextOutput = extern struct {
118 pub const geometricshape_left_triangle: u16 = 0x25c4;197 pub const geometricshape_left_triangle: u16 = 0x25c4;
119 pub const arrow_up: u16 = 0x2591;198 pub const arrow_up: u16 = 0x2591;
120 pub const arrow_down: u16 = 0x2593;199 pub const arrow_down: u16 = 0x2593;
121 pub const black: u8 = 0x00;200
122 pub const blue: u8 = 0x01;201 pub const Attribute = packed struct(u8) {
123 pub const green: u8 = 0x02;202 foreground: ForegroundColor = .white,
124 pub const cyan: u8 = 0x03;203 background: BackgroundColor = .black,
125 pub const red: u8 = 0x04;204
126 pub const magenta: u8 = 0x05;205 pub const ForegroundColor = enum(u4) {
127 pub const brown: u8 = 0x06;206 black,
128 pub const lightgray: u8 = 0x07;207 blue,
129 pub const bright: u8 = 0x08;208 green,
130 pub const darkgray: u8 = 0x08;209 cyan,
131 pub const lightblue: u8 = 0x09;210 red,
132 pub const lightgreen: u8 = 0x0a;211 magenta,
133 pub const lightcyan: u8 = 0x0b;212 brown,
134 pub const lightred: u8 = 0x0c;213 lightgray,
135 pub const lightmagenta: u8 = 0x0d;214 darkgray,
136 pub const yellow: u8 = 0x0e;215 lightblue,
137 pub const white: u8 = 0x0f;216 lightgreen,
138 pub const background_black: u8 = 0x00;217 lightcyan,
139 pub const background_blue: u8 = 0x10;218 lightred,
140 pub const background_green: u8 = 0x20;219 lightmagenta,
141 pub const background_cyan: u8 = 0x30;220 yellow,
142 pub const background_red: u8 = 0x40;221 white,
143 pub const background_magenta: u8 = 0x50;222 };
144 pub const background_brown: u8 = 0x60;223
145 pub const background_lightgray: u8 = 0x70;224 pub const BackgroundColor = enum(u4) {
225 black,
226 blue,
227 green,
228 cyan,
229 red,
230 magenta,
231 brown,
232 lightgray,
233 };
234 };
146235
147 pub const Mode = extern struct {236 pub const Mode = extern struct {
148 max_mode: u32, // specified as signed237 max_mode: u32, // specified as signed
...@@ -152,4 +241,9 @@ pub const SimpleTextOutput = extern struct {...@@ -152,4 +241,9 @@ pub const SimpleTextOutput = extern struct {
152 cursor_row: i32,241 cursor_row: i32,
153 cursor_visible: bool,242 cursor_visible: bool,
154 };243 };
244
245 pub const Geometry = struct {
246 columns: usize,
247 rows: usize,
248 };
155};249};
lib/std/os/uefi/protocol/udp6.zig+153-14
...@@ -8,6 +8,7 @@ const Ip6 = uefi.protocol.Ip6;...@@ -8,6 +8,7 @@ const Ip6 = uefi.protocol.Ip6;
8const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config;8const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config;
9const SimpleNetwork = uefi.protocol.SimpleNetwork;9const SimpleNetwork = uefi.protocol.SimpleNetwork;
10const cc = uefi.cc;10const cc = uefi.cc;
11const Error = Status.Error;
1112
12pub const Udp6 = extern struct {13pub const Udp6 = extern struct {
13 _get_mode_data: *const fn (*const Udp6, ?*Config, ?*Ip6.Mode, ?*ManagedNetworkConfigData, ?*SimpleNetwork) callconv(cc) Status,14 _get_mode_data: *const fn (*const Udp6, ?*Config, ?*Ip6.Mode, ?*ManagedNetworkConfigData, ?*SimpleNetwork) callconv(cc) Status,
...@@ -18,32 +19,158 @@ pub const Udp6 = extern struct {...@@ -18,32 +19,158 @@ pub const Udp6 = extern struct {
18 _cancel: *const fn (*const Udp6, ?*CompletionToken) callconv(cc) Status,19 _cancel: *const fn (*const Udp6, ?*CompletionToken) callconv(cc) Status,
19 _poll: *const fn (*const Udp6) callconv(cc) Status,20 _poll: *const fn (*const Udp6) callconv(cc) Status,
2021
21 pub fn getModeData(self: *const Udp6, udp6_config_data: ?*Config, ip6_mode_data: ?*Ip6.Mode, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetwork) Status {22 pub const GetModeDataError = uefi.UnexpectedError || error{
22 return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);23 NotStarted,
24 InvalidParameter,
25 };
26 pub const ConfigureError = uefi.UnexpectedError || error{
27 NoMapping,
28 InvalidParameter,
29 AlreadyStarted,
30 AccessDenied,
31 OutOfResources,
32 DeviceError,
33 };
34 pub const GroupsError = uefi.UnexpectedError || error{
35 NotStarted,
36 OutOfResources,
37 InvalidParameter,
38 AlreadyStarted,
39 NotFound,
40 DeviceError,
41 };
42 pub const TransmitError = uefi.UnexpectedError || error{
43 NotStarted,
44 NoMapping,
45 InvalidParameter,
46 AccessDenied,
47 NotReady,
48 OutOfResources,
49 NotFound,
50 BadBufferSize,
51 NoMedia,
52 };
53 pub const ReceiveError = uefi.UnexpectedError || error{
54 NotStarted,
55 NoMapping,
56 InvalidParameter,
57 OutOfResources,
58 DeviceError,
59 AccessDenied,
60 NotReady,
61 NoMedia,
62 };
63 pub const CancelError = uefi.UnexpectedError || error{
64 InvalidParameter,
65 NotStarted,
66 NotFound,
67 };
68 pub const PollError = uefi.UnexpectedError || error{
69 InvalidParameter,
70 DeviceError,
71 Timeout,
72 };
73
74 pub fn getModeData(self: *const Udp6) GetModeDataError!ModeData {
75 var data: ModeData = undefined;
76 switch (self._get_mode_data(
77 self,
78 &data.udp6_config_data,
79 &data.ip6_mode_data,
80 &data.mnp_config_data,
81 &data.snp_mode_data,
82 )) {
83 .success => return data,
84 .not_started => return Error.NotStarted,
85 .invalid_parameter => return Error.InvalidParameter,
86 else => |status| return uefi.unexpectedStatus(status),
87 }
23 }88 }
2489
25 pub fn configure(self: *const Udp6, udp6_config_data: ?*const Config) Status {90 pub fn configure(self: *Udp6, udp6_config_data: ?*const Config) ConfigureError!void {
26 return self._configure(self, udp6_config_data);91 switch (self._configure(self, udp6_config_data)) {
92 .success => {},
93 .no_mapping => return Error.NoMapping,
94 .invalid_parameter => return Error.InvalidParameter,
95 .already_started => return Error.AlreadyStarted,
96 .access_denied => return Error.AccessDenied,
97 .out_of_resources => return Error.OutOfResources,
98 .device_error => return Error.DeviceError,
99 else => |status| return uefi.unexpectedStatus(status),
100 }
27 }101 }
28102
29 pub fn groups(self: *const Udp6, join_flag: bool, multicast_address: ?*const Ip6.Address) Status {103 pub fn groups(
30 return self._groups(self, join_flag, multicast_address);104 self: *Udp6,
105 join_flag: JoinFlag,
106 multicast_address: ?*const Ip6.Address,
107 ) GroupsError!void {
108 switch (self._groups(
109 self,
110 // set to TRUE to join a multicast group
111 join_flag == .join,
112 multicast_address,
113 )) {
114 .success => {},
115 .not_started => return Error.NotStarted,
116 .out_of_resources => return Error.OutOfResources,
117 .invalid_parameter => return Error.InvalidParameter,
118 .already_started => return Error.AlreadyStarted,
119 .not_found => return Error.NotFound,
120 .device_error => return Error.DeviceError,
121 else => |status| return uefi.unexpectedStatus(status),
122 }
31 }123 }
32124
33 pub fn transmit(self: *const Udp6, token: *CompletionToken) Status {125 pub fn transmit(self: *Udp6, token: *CompletionToken) TransmitError!void {
34 return self._transmit(self, token);126 switch (self._transmit(self, token)) {
127 .success => {},
128 .not_started => return Error.NotStarted,
129 .no_mapping => return Error.NoMapping,
130 .invalid_parameter => return Error.InvalidParameter,
131 .access_denied => return Error.AccessDenied,
132 .not_ready => return Error.NotReady,
133 .out_of_resources => return Error.OutOfResources,
134 .not_found => return Error.NotFound,
135 .bad_buffer_size => return Error.BadBufferSize,
136 .no_media => return Error.NoMedia,
137 else => |status| return uefi.unexpectedStatus(status),
138 }
35 }139 }
36140
37 pub fn receive(self: *const Udp6, token: *CompletionToken) Status {141 pub fn receive(self: *Udp6, token: *CompletionToken) ReceiveError!void {
38 return self._receive(self, token);142 switch (self._receive(self, token)) {
143 .success => {},
144 .not_started => return Error.NotStarted,
145 .no_mapping => return Error.NoMapping,
146 .invalid_parameter => return Error.InvalidParameter,
147 .out_of_resources => return Error.OutOfResources,
148 .device_error => return Error.DeviceError,
149 .access_denied => return Error.AccessDenied,
150 .not_ready => return Error.NotReady,
151 .no_media => return Error.NoMedia,
152 else => |status| return uefi.unexpectedStatus(status),
153 }
39 }154 }
40155
41 pub fn cancel(self: *const Udp6, token: ?*CompletionToken) Status {156 pub fn cancel(self: *Udp6, token: ?*CompletionToken) CancelError!void {
42 return self._cancel(self, token);157 switch (self._cancel(self, token)) {
158 .success => {},
159 .invalid_parameter => return Error.InvalidParameter,
160 .not_started => return Error.NotStarted,
161 .not_found => return Error.NotFound,
162 else => |status| return uefi.unexpectedStatus(status),
163 }
43 }164 }
44165
45 pub fn poll(self: *const Udp6) Status {166 pub fn poll(self: *Udp6) PollError!void {
46 return self._poll(self);167 switch (self._poll(self)) {
168 .success => {},
169 .invalid_parameter => return Error.InvalidParameter,
170 .device_error => return Error.DeviceError,
171 .timeout => return Error.Timeout,
172 else => |status| return uefi.unexpectedStatus(status),
173 }
47 }174 }
48175
49 pub const guid align(8) = uefi.Guid{176 pub const guid align(8) = uefi.Guid{
...@@ -55,6 +182,18 @@ pub const Udp6 = extern struct {...@@ -55,6 +182,18 @@ pub const Udp6 = extern struct {
55 .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 },182 .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 },
56 };183 };
57184
185 pub const JoinFlag = enum {
186 join,
187 leave,
188 };
189
190 pub const ModeData = struct {
191 udp6_config_data: Config,
192 ip6_mode_data: Ip6.Mode,
193 mnp_config_data: ManagedNetworkConfigData,
194 snp_mode_data: SimpleNetwork,
195 };
196
58 pub const Config = extern struct {197 pub const Config = extern struct {
59 accept_promiscuous: bool,198 accept_promiscuous: bool,
60 accept_any_port: bool,199 accept_any_port: bool,
lib/std/os/uefi/protocol/udp6_service_binding.zig deleted-28
...@@ -1,28 +0,0 @@
1const std = @import("std");
2const uefi = std.os.uefi;
3const Handle = uefi.Handle;
4const Guid = uefi.Guid;
5const Status = uefi.Status;
6const cc = uefi.cc;
7
8pub const Udp6ServiceBinding = extern struct {
9 _create_child: *const fn (*const Udp6ServiceBinding, *?Handle) callconv(cc) Status,
10 _destroy_child: *const fn (*const Udp6ServiceBinding, Handle) callconv(cc) Status,
11
12 pub fn createChild(self: *const Udp6ServiceBinding, handle: *?Handle) Status {
13 return self._create_child(self, handle);
14 }
15
16 pub fn destroyChild(self: *const Udp6ServiceBinding, handle: Handle) Status {
17 return self._destroy_child(self, handle);
18 }
19
20 pub const guid align(8) = Guid{
21 .time_low = 0x66ed4721,
22 .time_mid = 0x3c98,
23 .time_high_and_version = 0x4d3e,
24 .clock_seq_high_and_reserved = 0x81,
25 .clock_seq_low = 0xe3,
26 .node = [_]u8{ 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54 },
27 };
28};