| author | |
| committer | |
| log | fa86e09fb39c8007c7b63e70ed7db1afc7022476 |
| tree | de1aeccdded0b5fc25a791b50af469f9bd1e967c |
| parent | b636d56d6a71b9ed521de7fccb519b7d0fa3db90 |
| signature |
27 files changed, 2075 insertions(+), 469 deletions(-)
lib/std/debug.zig+3-3| ... | ... | @@ -629,9 +629,9 @@ pub fn defaultPanic( |
| 629 | 629 | // isn't visible on actual hardware if directly booted into |
| 630 | 630 | inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| { |
| 631 | 631 | if (o) |out| { |
| 632 | _ = out.setAttribute(uefi.protocol.SimpleTextOutput.red); | |
| 633 | _ = out.outputString(exit_msg); | |
| 634 | _ = out.setAttribute(uefi.protocol.SimpleTextOutput.white); | |
| 632 | out.setAttribute(.{ .foreground = .red }) catch {}; | |
| 633 | _ = out.outputString(exit_msg) catch {}; | |
| 634 | out.setAttribute(.{ .foreground = .white }) catch {}; | |
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 |
lib/std/os/uefi.zig+13-53| ... | ... | @@ -43,6 +43,11 @@ pub const Ipv6Address = extern struct { |
| 43 | 43 | address: [16]u8, |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | pub const IpAddress = extern union { | |
| 47 | v4: Ipv4Address, | |
| 48 | v6: Ipv6Address, | |
| 49 | }; | |
| 50 | ||
| 46 | 51 | /// GUIDs are align(8) unless otherwise specified. |
| 47 | 52 | pub const Guid = extern struct { |
| 48 | 53 | time_low: u32, |
| ... | ... | @@ -190,60 +195,15 @@ test "GUID formatting" { |
| 190 | 195 | try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287")); |
| 191 | 196 | } |
| 192 | 197 | |
| 193 | pub 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 | ||
| 224 | pub 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 | ||
| 246 | 198 | test { |
| 247 | 199 | _ = tables; |
| 248 | 200 | _ = protocol; |
| 249 | 201 | } |
| 202 | ||
| 203 | pub const UnexpectedError = error{Unexpected}; | |
| 204 | ||
| 205 | pub 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 | const std = @import("std"); | |
| 2 | const uefi = std.os.uefi; | |
| 3 | ||
| 4 | pub const ServiceBinding = @import("protocol/service_binding.zig").ServiceBinding; | |
| 5 | ||
| 1 | 6 | pub const LoadedImage = @import("protocol/loaded_image.zig").LoadedImage; |
| 2 | 7 | pub const DevicePath = @import("protocol/device_path.zig").DevicePath; |
| 3 | 8 | pub const Rng = @import("protocol/rng.zig").Rng; |
| ... | ... | @@ -23,11 +28,25 @@ pub const edid = @import("protocol/edid.zig"); |
| 23 | 28 | pub const SimpleNetwork = @import("protocol/simple_network.zig").SimpleNetwork; |
| 24 | 29 | pub const ManagedNetwork = @import("protocol/managed_network.zig").ManagedNetwork; |
| 25 | 30 | |
| 26 | pub const Ip6ServiceBinding = @import("protocol/ip6_service_binding.zig").Ip6ServiceBinding; | |
| 31 | pub 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 | }); | |
| 27 | 39 | pub const Ip6 = @import("protocol/ip6.zig").Ip6; |
| 28 | 40 | pub const Ip6Config = @import("protocol/ip6_config.zig").Ip6Config; |
| 29 | 41 | |
| 30 | pub const Udp6ServiceBinding = @import("protocol/udp6_service_binding.zig").Udp6ServiceBinding; | |
| 42 | pub 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 | }); | |
| 31 | 50 | pub const Udp6 = @import("protocol/udp6.zig").Udp6; |
| 32 | 51 | |
| 33 | 52 | pub 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 | 4 | const Guid = uefi.Guid; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Protocol for touchscreens. |
| 9 | 10 | pub const AbsolutePointer = extern struct { |
| 10 | _reset: *const fn (*const AbsolutePointer, bool) callconv(cc) Status, | |
| 11 | _reset: *const fn (*AbsolutePointer, bool) callconv(cc) Status, | |
| 11 | 12 | _get_state: *const fn (*const AbsolutePointer, *State) callconv(cc) Status, |
| 12 | 13 | wait_for_input: Event, |
| 13 | 14 | mode: *Mode, |
| 14 | 15 | |
| 16 | pub const ResetError = uefi.UnexpectedError || error{DeviceError}; | |
| 17 | pub const GetStateError = uefi.UnexpectedError || error{ NotReady, DeviceError }; | |
| 18 | ||
| 15 | 19 | /// Resets the pointer device hardware. |
| 16 | pub fn reset(self: *const AbsolutePointer, verify: bool) Status { | |
| 17 | return self._reset(self, verify); | |
| 20 | pub fn reset(self: *AbsolutePointer, verify: bool) ResetError!void { | |
| 21 | switch (self._reset(self, verify)) { | |
| 22 | .success => {}, | |
| 23 | .device_error => return Error.DeviceError, | |
| 24 | else => |status| return uefi.unexpectedStatus(status), | |
| 25 | } | |
| 18 | 26 | } |
| 19 | 27 | |
| 20 | 28 | /// Retrieves the current state of a pointer device. |
| 21 | pub fn getState(self: *const AbsolutePointer, state: *State) Status { | |
| 22 | return self._get_state(self, state); | |
| 29 | pub fn getState(self: *const AbsolutePointer) GetStateError!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 | } |
| 24 | 38 | |
| 25 | 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 | 2 | const uefi = std.os.uefi; |
| 3 | 3 | const Status = uefi.Status; |
| 4 | 4 | const cc = uefi.cc; |
| 5 | const Error = Status.Error; | |
| 5 | 6 | |
| 6 | 7 | pub const BlockIo = extern struct { |
| 7 | 8 | const Self = @This(); |
| ... | ... | @@ -11,27 +12,72 @@ pub const BlockIo = extern struct { |
| 11 | 12 | |
| 12 | 13 | _reset: *const fn (*BlockIo, extended_verification: bool) callconv(cc) Status, |
| 13 | 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 | 16 | _flush_blocks: *const fn (*BlockIo) callconv(cc) Status, |
| 16 | 17 | |
| 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 | 38 | /// Resets the block device hardware. |
| 18 | pub fn reset(self: *Self, extended_verification: bool) Status { | |
| 19 | return self._reset(self, extended_verification); | |
| 39 | pub fn reset(self: *Self, extended_verification: bool) ResetError!void { | |
| 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 | } |
| 21 | 46 | |
| 22 | 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 { | |
| 24 | return self._read_blocks(self, media_id, lba, buffer_size, buf); | |
| 48 | pub fn readBlocks(self: *Self, media_id: u32, lba: u64, buf: []u8) ReadBlocksError!void { | |
| 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 | } |
| 26 | 58 | |
| 27 | 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 { | |
| 29 | return self._write_blocks(self, media_id, lba, buffer_size, buf); | |
| 60 | pub fn writeBlocks(self: *Self, media_id: u32, lba: u64, buf: []const u8) WriteBlocksError!void { | |
| 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 | } |
| 31 | 72 | |
| 32 | 73 | /// Flushes all modified data to a physical block device. |
| 33 | pub fn flushBlocks(self: *Self) Status { | |
| 34 | return self._flush_blocks(self); | |
| 74 | pub fn flushBlocks(self: *Self) FlushBlocksError!void { | |
| 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 | } |
| 36 | 82 | |
| 37 | 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 | 13 | subtype: u8, |
| 14 | 14 | length: u16 align(1), |
| 15 | 15 | |
| 16 | pub const CreateFileDevicePathError = Allocator.Error; | |
| 17 | ||
| 16 | 18 | pub const guid align(8) = Guid{ |
| 17 | 19 | .time_low = 0x09576e91, |
| 18 | 20 | .time_mid = 0x6d3f, |
| ... | ... | @@ -23,15 +25,17 @@ pub const DevicePath = extern struct { |
| 23 | 25 | }; |
| 24 | 26 | |
| 25 | 27 | /// Returns the next DevicePath node in the sequence, if any. |
| 26 | pub fn next(self: *DevicePath) ?*DevicePath { | |
| 27 | if (self.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .end_entire) | |
| 28 | pub fn next(self: *const DevicePath) ?*const DevicePath { | |
| 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 | 32 | return null; |
| 29 | 33 | |
| 30 | return @as(*DevicePath, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length)); | |
| 34 | return next_node; | |
| 31 | 35 | } |
| 32 | 36 | |
| 33 | 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 | 39 | var node = self; |
| 36 | 40 | |
| 37 | 41 | while (node.next()) |next_node| { |
| ... | ... | @@ -42,7 +46,11 @@ pub const DevicePath = extern struct { |
| 42 | 46 | } |
| 43 | 47 | |
| 44 | 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 | 54 | const path_size = self.size(); |
| 47 | 55 | |
| 48 | 56 | // 2 * (path.len + 1) for the path and its null terminator, which are u16s |
| ... | ... | @@ -67,7 +75,7 @@ pub const DevicePath = extern struct { |
| 67 | 75 | |
| 68 | 76 | ptr[path.len] = 0; |
| 69 | 77 | |
| 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 | 79 | end.type = .end; |
| 72 | 80 | end.subtype = .end_entire; |
| 73 | 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 | 4 | const Handle = uefi.Handle; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// EDID information for an active video output device |
| 9 | 10 | pub const Active = extern struct { |
| ... | ... | @@ -37,17 +38,27 @@ pub const Discovered = extern struct { |
| 37 | 38 | |
| 38 | 39 | /// Override EDID information |
| 39 | 40 | pub 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 | }; | |
| 41 | 46 | |
| 42 | 47 | /// Returns policy information and potentially a replacement EDID for the specified video output device. |
| 43 | pub fn getEdid( | |
| 44 | self: *const Override, | |
| 45 | handle: Handle, | |
| 46 | attributes: *Attributes, | |
| 47 | edid_size: *usize, | |
| 48 | edid: *?[*]u8, | |
| 49 | ) Status { | |
| 50 | return self._get_edid(self, handle, attributes, edid_size, edid); | |
| 48 | pub fn getEdid(self: *const Override, handle: Handle) GetEdidError!Edid { | |
| 49 | var size: usize = undefined; | |
| 50 | var ptr: ?[*]u8 = undefined; | |
| 51 | var attributes: Attributes = undefined; | |
| 52 | switch (self._get_edid(self, &handle, &attributes, &size, &ptr)) { | |
| 53 | .success => {}, | |
| 54 | .unsupported => return Error.Unsupported, | |
| 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 | } |
| 52 | 63 | |
| 53 | 64 | pub const guid align(8) = Guid{ |
| ... | ... | @@ -59,6 +70,11 @@ pub const Override = extern struct { |
| 59 | 70 | .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 }, |
| 60 | 71 | }; |
| 61 | 72 | |
| 73 | pub const Edid = struct { | |
| 74 | attributes: Attributes, | |
| 75 | edid: ?[]u8, | |
| 76 | }; | |
| 77 | ||
| 62 | 78 | pub const Attributes = packed struct(u32) { |
| 63 | 79 | dont_override: bool, |
| 64 | 80 | enable_hot_plug: bool, |
lib/std/os/uefi/protocol/file.zig+301-84| ... | ... | @@ -5,28 +5,89 @@ const Guid = uefi.Guid; |
| 5 | 5 | const Time = uefi.Time; |
| 6 | 6 | const Status = uefi.Status; |
| 7 | 7 | const cc = uefi.cc; |
| 8 | const Error = Status.Error; | |
| 8 | 9 | |
| 9 | 10 | pub const File = extern struct { |
| 10 | 11 | revision: u64, |
| 11 | _open: *const fn (*const File, **const File, [*:0]const u16, u64, u64) callconv(cc) Status, | |
| 12 | _close: *const fn (*const File) callconv(cc) Status, | |
| 13 | _delete: *const fn (*const File) callconv(cc) Status, | |
| 14 | _read: *const fn (*const File, *usize, [*]u8) callconv(cc) Status, | |
| 15 | _write: *const fn (*const File, *usize, [*]const u8) callconv(cc) Status, | |
| 12 | _open: *const fn (*const File, **File, [*:0]const u16, u64, u64) callconv(cc) Status, | |
| 13 | _close: *const fn (*File) callconv(cc) Status, | |
| 14 | _delete: *const fn (*File) callconv(cc) Status, | |
| 15 | _read: *const fn (*File, *usize, [*]u8) callconv(cc) Status, | |
| 16 | _write: *const fn (*File, *usize, [*]const u8) callconv(cc) Status, | |
| 16 | 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 | 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 | _flush: *const fn (*const File) callconv(cc) Status, | |
| 20 | _set_info: *const fn (*File, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status, | |
| 21 | _flush: *const fn (*File) callconv(cc) Status, | |
| 21 | 22 | |
| 22 | pub const SeekError = error{SeekError}; | |
| 23 | pub const GetSeekPosError = error{GetSeekPosError}; | |
| 24 | pub const ReadError = error{ReadError}; | |
| 25 | pub const WriteError = error{WriteError}; | |
| 23 | pub const OpenError = uefi.UnexpectedError || error{ | |
| 24 | NotFound, | |
| 25 | NoMedia, | |
| 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 | }; | |
| 26 | 79 | |
| 27 | pub const SeekableStream = io.SeekableStream(*const File, SeekError, GetSeekPosError, seekTo, seekBy, getPos, getEndPos); | |
| 28 | pub const Reader = io.Reader(*const File, ReadError, readFn); | |
| 29 | pub const Writer = io.Writer(*const File, WriteError, writeFn); | |
| 80 | pub const SeekableStream = io.SeekableStream( | |
| 81 | *File, | |
| 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); | |
| 30 | 91 | |
| 31 | 92 | pub fn seekableStream(self: *File) SeekableStream { |
| 32 | 93 | return .{ .context = self }; |
| ... | ... | @@ -40,75 +101,111 @@ pub const File = extern struct { |
| 40 | 101 | return .{ .context = self }; |
| 41 | 102 | } |
| 42 | 103 | |
| 43 | pub fn open(self: *const File, new_handle: **const File, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status { | |
| 44 | return self._open(self, new_handle, file_name, open_mode, attributes); | |
| 45 | } | |
| 46 | ||
| 47 | pub fn close(self: *const File) Status { | |
| 48 | return self._close(self); | |
| 104 | pub fn open( | |
| 105 | self: *const File, | |
| 106 | file_name: [*:0]const u16, | |
| 107 | mode: OpenMode, | |
| 108 | create_attributes: Attributes, | |
| 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 | } |
| 50 | 132 | |
| 51 | pub fn delete(self: *const File) Status { | |
| 52 | return self._delete(self); | |
| 133 | pub fn close(self: *File) CloseError!void { | |
| 134 | switch (self._close(self)) { | |
| 135 | .success => {}, | |
| 136 | else => |status| return uefi.unexpectedStatus(status), | |
| 137 | } | |
| 53 | 138 | } |
| 54 | 139 | |
| 55 | pub fn read(self: *const File, buffer_size: *usize, buffer: [*]u8) Status { | |
| 56 | return self._read(self, buffer_size, buffer); | |
| 140 | /// Delete the file. | |
| 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 | } |
| 58 | 151 | |
| 59 | fn readFn(self: *const File, buffer: []u8) ReadError!usize { | |
| 152 | pub fn read(self: *File, buffer: []u8) ReadError!usize { | |
| 60 | 153 | var size: usize = buffer.len; |
| 61 | if (.success != self.read(&size, buffer.ptr)) return ReadError.ReadError; | |
| 62 | return size; | |
| 63 | } | |
| 64 | ||
| 65 | pub fn write(self: *const File, buffer_size: *usize, buffer: [*]const u8) Status { | |
| 66 | return self._write(self, buffer_size, buffer); | |
| 67 | } | |
| 68 | ||
| 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; | |
| 154 | switch (self._read(self, &size, buffer.ptr)) { | |
| 155 | .success => return size, | |
| 156 | .no_media => return Error.NoMedia, | |
| 157 | .device_error => return Error.DeviceError, | |
| 158 | .volume_corrupted => return Error.VolumeCorrupted, | |
| 159 | .buffer_too_small => return Error.BufferTooSmall, | |
| 160 | else => |status| return uefi.unexpectedStatus(status), | |
| 161 | } | |
| 73 | 162 | } |
| 74 | 163 | |
| 75 | pub fn getPosition(self: *const File, position: *u64) Status { | |
| 76 | return self._get_position(self, position); | |
| 164 | pub fn write(self: *File, buffer: []const u8) WriteError!usize { | |
| 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 | } |
| 78 | 178 | |
| 79 | fn getPos(self: *const File) GetSeekPosError!u64 { | |
| 80 | var pos: u64 = undefined; | |
| 81 | if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; | |
| 82 | return pos; | |
| 179 | pub fn getPosition(self: *const File) SeekError!u64 { | |
| 180 | var position: u64 = undefined; | |
| 181 | switch (self._get_position(self, &position)) { | |
| 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 | } |
| 84 | 188 | |
| 85 | fn getEndPos(self: *const File) GetSeekPosError!u64 { | |
| 86 | // preserve the old file position | |
| 87 | var pos: u64 = undefined; | |
| 88 | var end_pos: u64 = undefined; | |
| 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 | } | |
| 189 | fn getEndPos(self: *File) SeekError!u64 { | |
| 190 | const start_pos = try self.getPosition(); | |
| 191 | // ignore error | |
| 192 | defer self.setPosition(start_pos) catch {}; | |
| 99 | 193 | |
| 100 | pub fn setPosition(self: *const File, position: u64) Status { | |
| 101 | return self._set_position(self, position); | |
| 194 | try self.setPosition(end_of_file); | |
| 195 | return self.getPosition(); | |
| 102 | 196 | } |
| 103 | 197 | |
| 104 | fn seekTo(self: *const File, pos: u64) SeekError!void { | |
| 105 | if (.success != self.setPosition(pos)) return SeekError.SeekError; | |
| 198 | pub fn setPosition(self: *File, position: u64) SeekError!void { | |
| 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 | } |
| 107 | 206 | |
| 108 | fn seekBy(self: *const File, offset: i64) SeekError!void { | |
| 109 | // save the old position and calculate the delta | |
| 110 | var pos: u64 = undefined; | |
| 111 | if (.success != self.getPosition(&pos)) return SeekError.SeekError; | |
| 207 | fn seekBy(self: *File, offset: i64) SeekError!void { | |
| 208 | var pos = try self.getPosition(); | |
| 112 | 209 | const seek_back = offset < 0; |
| 113 | 210 | const amt = @abs(offset); |
| 114 | 211 | if (seek_back) { |
| ... | ... | @@ -116,32 +213,152 @@ pub const File = extern struct { |
| 116 | 213 | } else { |
| 117 | 214 | pos -= amt; |
| 118 | 215 | } |
| 119 | if (.success != self.setPosition(pos)) return SeekError.SeekError; | |
| 216 | try self.setPosition(pos); | |
| 120 | 217 | } |
| 121 | 218 | |
| 122 | pub fn getInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: *usize, buffer: [*]u8) Status { | |
| 123 | return self._get_info(self, information_type, buffer_size, buffer); | |
| 219 | pub fn getInfo( | |
| 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 | } |
| 125 | 237 | |
| 126 | pub fn setInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: usize, buffer: [*]const u8) Status { | |
| 127 | return self._set_info(self, information_type, buffer_size, buffer); | |
| 238 | pub fn setInfo( | |
| 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 | } |
| 129 | 257 | |
| 130 | pub fn flush(self: *const File) Status { | |
| 131 | return self._flush(self); | |
| 258 | pub fn flush(self: *File) FlushError!void { | |
| 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 | } |
| 133 | 269 | |
| 134 | pub const efi_file_mode_read: u64 = 0x0000000000000001; | |
| 135 | pub const efi_file_mode_write: u64 = 0x0000000000000002; | |
| 136 | pub const efi_file_mode_create: u64 = 0x8000000000000000; | |
| 270 | pub const OpenMode = enum(u64) { | |
| 271 | read = 0x0000000000000001, | |
| 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 | } | |
| 137 | 351 | |
| 138 | pub const efi_file_read_only: u64 = 0x0000000000000001; | |
| 139 | pub const efi_file_hidden: u64 = 0x0000000000000002; | |
| 140 | pub const efi_file_system: u64 = 0x0000000000000004; | |
| 141 | pub const efi_file_reserved: u64 = 0x0000000000000008; | |
| 142 | pub const efi_file_directory: u64 = 0x0000000000000010; | |
| 143 | pub const efi_file_archive: u64 = 0x0000000000000020; | |
| 144 | pub const efi_file_valid_attr: u64 = 0x0000000000000037; | |
| 352 | pub const guid align(8) = Guid{ | |
| 353 | .time_low = 0xdb47d7d3, | |
| 354 | .time_mid = 0xfe81, | |
| 355 | .time_high_and_version = 0x11d3, | |
| 356 | .clock_seq_high_and_reserved = 0x9a, | |
| 357 | .clock_seq_low = 0x35, | |
| 358 | .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, | |
| 359 | }; | |
| 360 | }; | |
| 361 | }; | |
| 145 | 362 | |
| 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 | 3 | const Guid = uefi.Guid; |
| 4 | 4 | const Status = uefi.Status; |
| 5 | 5 | const cc = uefi.cc; |
| 6 | const Error = Status.Error; | |
| 6 | 7 | |
| 7 | 8 | pub const GraphicsOutput = extern struct { |
| 8 | 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 | _blt: *const fn (*const GraphicsOutput, ?[*]BltPixel, BltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status, | |
| 10 | _set_mode: *const fn (*GraphicsOutput, u32) callconv(cc) Status, | |
| 11 | _blt: *const fn (*GraphicsOutput, ?[*]BltPixel, BltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status, | |
| 11 | 12 | mode: *Mode, |
| 12 | 13 | |
| 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 | 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 { | |
| 15 | return self._query_mode(self, mode, size_of_info, info); | |
| 28 | pub fn queryMode(self: *const GraphicsOutput, mode_id: u32) QueryModeError!*Mode.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 | } |
| 17 | 38 | |
| 18 | 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 { | |
| 20 | return self._set_mode(self, mode); | |
| 40 | pub fn setMode(self: *GraphicsOutput, mode_id: u32) SetModeError!void { | |
| 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 | } |
| 22 | 48 | |
| 23 | 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 { | |
| 25 | return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta); | |
| 50 | pub fn blt( | |
| 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 | } |
| 27 | 80 | |
| 28 | 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 | 4 | const Status = uefi.Status; |
| 5 | 5 | const hii = uefi.hii; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Database manager for HII-related data structures. |
| 9 | 10 | pub const HiiDatabase = extern struct { |
| 10 | 11 | _new_package_list: Status, // TODO |
| 11 | _remove_package_list: *const fn (*const HiiDatabase, hii.Handle) callconv(cc) Status, | |
| 12 | _update_package_list: *const fn (*const HiiDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status, | |
| 12 | _remove_package_list: *const fn (*HiiDatabase, hii.Handle) callconv(cc) Status, | |
| 13 | _update_package_list: *const fn (*HiiDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status, | |
| 13 | 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 | 16 | _register_package_notify: Status, // TODO |
| 16 | 17 | _unregister_package_notify: Status, // TODO |
| 17 | 18 | _find_keyboard_layouts: Status, // TODO |
| ... | ... | @@ -19,24 +20,84 @@ pub const HiiDatabase = extern struct { |
| 19 | 20 | _set_keyboard_layout: Status, // TODO |
| 20 | 21 | _get_package_list_handle: Status, // TODO |
| 21 | 22 | |
| 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 | 40 | /// Removes a package list from the HII database. |
| 23 | pub fn removePackageList(self: *const HiiDatabase, handle: hii.Handle) Status { | |
| 24 | return self._remove_package_list(self, handle); | |
| 41 | pub fn removePackageList(self: *HiiDatabase, handle: hii.Handle) !void { | |
| 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 | } |
| 26 | 48 | |
| 27 | 49 | /// Update a package list in the HII database. |
| 28 | pub fn updatePackageList(self: *const HiiDatabase, handle: hii.Handle, buffer: *const hii.PackageList) Status { | |
| 29 | return self._update_package_list(self, handle, buffer); | |
| 50 | pub fn updatePackageList( | |
| 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 | } |
| 31 | 63 | |
| 32 | 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 { | |
| 34 | return self._list_package_lists(self, package_type, package_guid, buffer_length, handles); | |
| 65 | pub fn listPackageLists( | |
| 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 | } |
| 36 | 86 | |
| 37 | 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 { | |
| 39 | return self._export_package_lists(self, handle, buffer_size, buffer); | |
| 88 | pub fn exportPackageLists( | |
| 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 | } |
| 41 | 102 | |
| 42 | 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 | 4 | const Status = uefi.Status; |
| 5 | 5 | const hii = uefi.hii; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Display a popup window |
| 9 | 10 | pub const HiiPopup = extern struct { |
| 10 | 11 | revision: u64, |
| 11 | 12 | _create_popup: *const fn (*const HiiPopup, PopupStyle, PopupType, hii.Handle, u16, ?*PopupSelection) callconv(cc) Status, |
| 12 | 13 | |
| 14 | pub const CreatePopupError = uefi.UnexpectedError || error{ | |
| 15 | InvalidParameter, | |
| 16 | OutOfResources, | |
| 17 | }; | |
| 18 | ||
| 13 | 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 { | |
| 15 | return self._create_popup(self, style, popup_type, handle, msg, user_selection); | |
| 20 | pub fn createPopup( | |
| 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 | } |
| 17 | 35 | |
| 18 | 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 | 7 | const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config; |
| 8 | 8 | const SimpleNetwork = uefi.protocol.SimpleNetwork; |
| 9 | 9 | const cc = uefi.cc; |
| 10 | const Error = Status.Error; | |
| 10 | 11 | |
| 11 | 12 | pub const Ip6 = extern struct { |
| 12 | 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 | _groups: *const fn (*const Ip6, bool, ?*const Address) callconv(cc) Status, | |
| 15 | _routes: *const fn (*const 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 | _transmit: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status, | |
| 18 | _receive: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status, | |
| 19 | _cancel: *const fn (*const Ip6, ?*CompletionToken) callconv(cc) Status, | |
| 20 | _poll: *const fn (*const Ip6) callconv(cc) Status, | |
| 14 | _configure: *const fn (*Ip6, ?*const Config) callconv(cc) Status, | |
| 15 | _groups: *const fn (*Ip6, bool, ?*const Address) callconv(cc) Status, | |
| 16 | _routes: *const fn (*Ip6, bool, ?*const Address, u8, ?*const Address) callconv(cc) Status, | |
| 17 | _neighbors: *const fn (*Ip6, bool, *const Address, ?*const MacAddress, u32, bool) callconv(cc) Status, | |
| 18 | _transmit: *const fn (*Ip6, *CompletionToken) callconv(cc) Status, | |
| 19 | _receive: *const fn (*Ip6, *CompletionToken) callconv(cc) Status, | |
| 20 | _cancel: *const fn (*Ip6, ?*CompletionToken) 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 | }; | |
| 21 | 99 | |
| 22 | 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 { | |
| 24 | return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data); | |
| 101 | pub fn getModeData(self: *const Ip6) GetModeDataError!ModeData { | |
| 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 | } |
| 26 | 110 | |
| 27 | 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 { | |
| 29 | return self._configure(self, ip6_config_data); | |
| 112 | /// | |
| 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 | } |
| 31 | 153 | |
| 32 | 154 | /// Joins and leaves multicast groups. |
| 33 | pub fn groups(self: *const Ip6, join_flag: bool, group_address: ?*const Address) Status { | |
| 34 | return self._groups(self, join_flag, group_address); | |
| 155 | /// | |
| 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 | } |
| 36 | 179 | |
| 37 | 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 { | |
| 39 | return self._routes(self, delete_route, destination, prefix_length, gateway_address); | |
| 181 | pub fn routes( | |
| 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 | } |
| 41 | 204 | |
| 42 | 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 { | |
| 44 | return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override); | |
| 206 | pub fn neighbors( | |
| 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 | } |
| 46 | 233 | |
| 47 | 234 | /// Places outgoing data packets into the transmit queue. |
| 48 | pub fn transmit(self: *const Ip6, token: *CompletionToken) Status { | |
| 49 | return self._transmit(self, token); | |
| 235 | pub fn transmit(self: *Ip6, token: *CompletionToken) TransmitError!void { | |
| 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 | } |
| 51 | 252 | |
| 52 | 253 | /// Places a receiving request into the receiving queue. |
| 53 | pub fn receive(self: *const Ip6, token: *CompletionToken) Status { | |
| 54 | return self._receive(self, token); | |
| 254 | pub fn receive(self: *Ip6, token: *CompletionToken) ReceiveError!void { | |
| 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 | } |
| 56 | 268 | |
| 57 | 269 | /// Abort an asynchronous transmits or receive request. |
| 58 | pub fn cancel(self: *const Ip6, token: ?*CompletionToken) Status { | |
| 59 | return self._cancel(self, token); | |
| 270 | pub fn cancel(self: *Ip6, token: ?*CompletionToken) CancelError!void { | |
| 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 | } |
| 61 | 280 | |
| 62 | 281 | /// Polls for incoming data packets and processes outgoing data packets. |
| 63 | pub fn poll(self: *const Ip6) Status { | |
| 64 | return self._poll(self); | |
| 282 | /// | |
| 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 | } |
| 66 | 295 | |
| 67 | 296 | pub const guid align(8) = Guid{ |
| ... | ... | @@ -73,6 +302,16 @@ pub const Ip6 = extern struct { |
| 73 | 302 | .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 }, |
| 74 | 303 | }; |
| 75 | 304 | |
| 305 | pub const DeleteFlag = enum { | |
| 306 | delete, | |
| 307 | add, | |
| 308 | }; | |
| 309 | ||
| 310 | pub const JoinFlag = enum { | |
| 311 | join, | |
| 312 | leave, | |
| 313 | }; | |
| 314 | ||
| 76 | 315 | pub const Mode = extern struct { |
| 77 | 316 | is_started: bool, |
| 78 | 317 | max_packet_size: u32, |
lib/std/os/uefi/protocol/ip6_config.zig+127-16| ... | ... | @@ -4,6 +4,9 @@ const Guid = uefi.Guid; |
| 4 | 4 | const Event = uefi.Event; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 8 | const MacAddress = uefi.MacAddress; | |
| 9 | const Ip6 = uefi.protocol.Ip6; | |
| 7 | 10 | |
| 8 | 11 | pub const Ip6Config = extern struct { |
| 9 | 12 | _set_data: *const fn (*const Ip6Config, DataType, usize, *const anyopaque) callconv(cc) Status, |
| ... | ... | @@ -11,20 +14,98 @@ pub const Ip6Config = extern struct { |
| 11 | 14 | _register_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status, |
| 12 | 15 | _unregister_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status, |
| 13 | 16 | |
| 14 | pub fn setData(self: *const Ip6Config, data_type: DataType, data_size: usize, data: *const anyopaque) Status { | |
| 15 | return self._set_data(self, data_type, data_size, data); | |
| 17 | pub const SetDataError = uefi.UnexpectedError || error{ | |
| 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 | } |
| 17 | 63 | |
| 18 | pub fn getData(self: *const Ip6Config, data_type: DataType, data_size: *usize, data: ?*const anyopaque) Status { | |
| 19 | return self._get_data(self, data_type, data_size, data); | |
| 64 | pub fn getData( | |
| 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 | } |
| 21 | 82 | |
| 22 | pub fn registerDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status { | |
| 23 | return self._register_data_notify(self, data_type, event); | |
| 83 | pub fn registerDataNotify( | |
| 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 | } |
| 25 | 97 | |
| 26 | pub fn unregisterDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status { | |
| 27 | return self._unregister_data_notify(self, data_type, event); | |
| 98 | pub fn unregisterDataNotify( | |
| 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 | } |
| 29 | 110 | |
| 30 | 111 | pub const guid align(8) = Guid{ |
| ... | ... | @@ -36,13 +117,43 @@ pub const Ip6Config = extern struct { |
| 36 | 117 | .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a }, |
| 37 | 118 | }; |
| 38 | 119 | |
| 39 | pub const DataType = enum(u32) { | |
| 40 | interface_info, | |
| 41 | alt_interface_id, | |
| 42 | policy, | |
| 43 | dup_addr_detect_transmits, | |
| 44 | manual_address, | |
| 45 | gateway, | |
| 46 | dns_server, | |
| 120 | pub const DataType = union(enum(u32)) { | |
| 121 | interface_info: InterfaceInfo, | |
| 122 | alt_interface_id: InterfaceId, | |
| 123 | policy: Policy, | |
| 124 | dup_addr_detect_transmits: DupAddrDetectTransmits, | |
| 125 | manual_address: [*]ManualAddress, | |
| 126 | gateway: [*]Ip6.Address, | |
| 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 @@ |
| 1 | const std = @import("std"); | |
| 2 | const uefi = std.os.uefi; | |
| 3 | const Handle = uefi.Handle; | |
| 4 | const Guid = uefi.Guid; | |
| 5 | const Status = uefi.Status; | |
| 6 | const cc = uefi.cc; | |
| 7 | ||
| 8 | pub 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 | 7 | const MemoryType = uefi.tables.MemoryType; |
| 8 | 8 | const DevicePath = uefi.protocol.DevicePath; |
| 9 | 9 | const cc = uefi.cc; |
| 10 | const Error = Status.Error; | |
| 10 | 11 | |
| 11 | 12 | pub const LoadedImage = extern struct { |
| 12 | 13 | revision: u32, |
| ... | ... | @@ -21,11 +22,17 @@ pub const LoadedImage = extern struct { |
| 21 | 22 | image_size: u64, |
| 22 | 23 | image_code_type: MemoryType, |
| 23 | 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}; | |
| 25 | 28 | |
| 26 | 29 | /// Unloads an image from memory. |
| 27 | pub fn unload(self: *const LoadedImage, handle: Handle) Status { | |
| 28 | return self._unload(self, handle); | |
| 30 | pub fn unload(self: *LoadedImage, handle: Handle) UnloadError!void { | |
| 31 | switch (self._unload(self, handle)) { | |
| 32 | .success => {}, | |
| 33 | .invalid_parameter => return Error.InvalidParameter, | |
| 34 | else => |status| return uefi.unexpectedStatus(status), | |
| 35 | } | |
| 29 | 36 | } |
| 30 | 37 | |
| 31 | 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 | 8 | const SimpleNetwork = uefi.protocol.SimpleNetwork; |
| 9 | 9 | const MacAddress = uefi.MacAddress; |
| 10 | 10 | const cc = uefi.cc; |
| 11 | const Error = Status.Error; | |
| 11 | 12 | |
| 12 | 13 | pub const ManagedNetwork = extern struct { |
| 13 | 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 | _mcast_ip_to_mac: *const fn (*const ManagedNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status, | |
| 16 | _groups: *const fn (*const ManagedNetwork, bool, ?*const MacAddress) callconv(cc) Status, | |
| 17 | _transmit: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status, | |
| 18 | _receive: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status, | |
| 19 | _cancel: *const fn (*const ManagedNetwork, ?*const CompletionToken) callconv(cc) Status, | |
| 20 | _poll: *const fn (*const ManagedNetwork) callconv(cc) Status, | |
| 15 | _configure: *const fn (*ManagedNetwork, ?*const Config) callconv(cc) Status, | |
| 16 | _mcast_ip_to_mac: *const fn (*ManagedNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status, | |
| 17 | _groups: *const fn (*ManagedNetwork, bool, ?*const MacAddress) callconv(cc) Status, | |
| 18 | _transmit: *const fn (*ManagedNetwork, *CompletionToken) callconv(cc) Status, | |
| 19 | _receive: *const fn (*ManagedNetwork, *CompletionToken) callconv(cc) Status, | |
| 20 | _cancel: *const fn (*ManagedNetwork, ?*const CompletionToken) 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 | }; | |
| 21 | 82 | |
| 22 | 83 | /// Returns the operational parameters for the current MNP child driver. |
| 23 | 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 { | |
| 25 | return self._get_mode_data(self, mnp_config_data, snp_mode_data); | |
| 85 | pub fn getModeData(self: *const ManagedNetwork) GetModeDataError!GetModeDataData { | |
| 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 | } |
| 27 | 95 | |
| 28 | 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 { | |
| 30 | return self._configure(self, mnp_config_data); | |
| 97 | pub fn configure(self: *ManagedNetwork, mnp_config_data: ?*const Config) ConfigureError!void { | |
| 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 | } |
| 32 | 106 | |
| 33 | 107 | /// Translates an IP multicast address to a hardware (MAC) multicast address. |
| 34 | 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 { | |
| 36 | return self._mcast_ip_to_mac(self, ipv6flag, ipaddress, mac_address); | |
| 109 | pub fn mcastIpToMac( | |
| 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 | } |
| 38 | 123 | |
| 39 | 124 | /// Enables and disables receive filters for multicast address. |
| 40 | 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 { | |
| 42 | return self._groups(self, join_flag, mac_address); | |
| 126 | pub fn groups( | |
| 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 | } |
| 44 | 139 | |
| 45 | 140 | /// Places asynchronous outgoing data packets into the transmit queue. |
| 46 | pub fn transmit(self: *const ManagedNetwork, token: *const CompletionToken) Status { | |
| 47 | return self._transmit(self, token); | |
| 141 | pub fn transmit(self: *ManagedNetwork, token: *CompletionToken) TransmitError!void { | |
| 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 | } |
| 49 | 154 | |
| 50 | 155 | /// Places an asynchronous receiving request into the receiving queue. |
| 51 | pub fn receive(self: *const ManagedNetwork, token: *const CompletionToken) Status { | |
| 52 | return self._receive(self, token); | |
| 156 | pub fn receive(self: *ManagedNetwork, token: *CompletionToken) TransmitError!void { | |
| 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 | } |
| 54 | 169 | |
| 55 | 170 | /// Aborts an asynchronous transmit or receive request. |
| 56 | pub fn cancel(self: *const ManagedNetwork, token: ?*const CompletionToken) Status { | |
| 57 | return self._cancel(self, token); | |
| 171 | pub fn cancel(self: *ManagedNetwork, token: ?*const CompletionToken) CancelError!void { | |
| 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 | } |
| 59 | 180 | |
| 60 | 181 | /// Polls for incoming data packets and processes outgoing data packets. |
| 61 | pub fn poll(self: *const ManagedNetwork) Status { | |
| 62 | return self._poll(self); | |
| 182 | pub fn poll(self: *ManagedNetwork) PollError!void { | |
| 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 | } |
| 64 | 192 | |
| 65 | 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 | 3 | const Guid = uefi.Guid; |
| 4 | 4 | const Status = uefi.Status; |
| 5 | 5 | const cc = uefi.cc; |
| 6 | const Error = Status.Error; | |
| 6 | 7 | |
| 7 | 8 | /// Random Number Generator protocol |
| 8 | 9 | pub const Rng = extern struct { |
| 9 | 10 | _get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status, |
| 10 | 11 | _get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status, |
| 11 | 12 | |
| 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 | 25 | /// Returns information about the random number generation implementation. |
| 13 | pub fn getInfo(self: *const Rng, list_size: *usize, list: [*]align(8) Guid) Status { | |
| 14 | return self._get_info(self, list_size, list); | |
| 26 | pub fn getInfo(self: *const Rng, list: []align(8) Guid) GetInfoError![]align(8) Guid { | |
| 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 | } |
| 16 | 36 | |
| 17 | 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 { | |
| 19 | return self._get_rng(self, algo, value_length, value); | |
| 38 | pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value: []u8) GetRNGError!void { | |
| 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 | } |
| 21 | 48 | |
| 22 | 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 | 3 | const Guid = uefi.Guid; |
| 4 | 4 | const Status = uefi.Status; |
| 5 | 5 | const cc = uefi.cc; |
| 6 | const Error = Status.Error; | |
| 6 | 7 | |
| 7 | 8 | pub const SerialIo = extern struct { |
| 8 | 9 | revision: u64, |
| 9 | _reset: *const fn (*const SerialIo) callconv(cc) Status, | |
| 10 | _set_attribute: *const fn (*const SerialIo, u64, u32, u32, ParityType, u8, StopBitsType) callconv(cc) Status, | |
| 11 | _set_control: *const fn (*const SerialIo, u32) callconv(cc) Status, | |
| 10 | _reset: *const fn (*SerialIo) callconv(cc) Status, | |
| 11 | _set_attribute: *const fn (*SerialIo, u64, u32, u32, ParityType, u8, StopBitsType) callconv(cc) Status, | |
| 12 | _set_control: *const fn (*SerialIo, u32) callconv(cc) Status, | |
| 12 | 13 | _get_control: *const fn (*const SerialIo, *u32) callconv(cc) Status, |
| 13 | _write: *const fn (*const SerialIo, *usize, *anyopaque) callconv(cc) Status, | |
| 14 | _read: *const fn (*const SerialIo, *usize, *anyopaque) callconv(cc) Status, | |
| 14 | _write: *const fn (*SerialIo, *usize, *const anyopaque) callconv(cc) Status, | |
| 15 | _read: *const fn (*SerialIo, *usize, *anyopaque) callconv(cc) Status, | |
| 15 | 16 | mode: *Mode, |
| 16 | 17 | device_type_guid: ?*Guid, |
| 17 | 18 | |
| 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 | 38 | /// Resets the serial device. |
| 19 | pub fn reset(self: *const SerialIo) Status { | |
| 20 | return self._reset(self); | |
| 39 | pub fn reset(self: *SerialIo) ResetError!void { | |
| 40 | switch (self._reset(self)) { | |
| 41 | .success => {}, | |
| 42 | .device_error => return Error.DeviceError, | |
| 43 | else => |status| return uefi.unexpectedStatus(status), | |
| 44 | } | |
| 21 | 45 | } |
| 22 | 46 | |
| 23 | 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 { | |
| 25 | return self._set_attribute(self, baud_rate, receiver_fifo_depth, timeout, parity, data_bits, stop_bits); | |
| 48 | pub fn setAttribute( | |
| 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 | } |
| 27 | 72 | |
| 28 | 73 | /// Sets the control bits on a serial device. |
| 29 | pub fn setControl(self: *const SerialIo, control: u32) Status { | |
| 30 | return self._set_control(self, control); | |
| 74 | pub fn setControl(self: *SerialIo, control: u32) SetControlError!void { | |
| 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 | } |
| 32 | 82 | |
| 33 | 83 | /// Retrieves the status of the control bits on a serial device. |
| 34 | pub fn getControl(self: *const SerialIo, control: *u32) Status { | |
| 35 | return self._get_control(self, control); | |
| 84 | pub fn getControl(self: *SerialIo) GetControlError!u32 { | |
| 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 | } |
| 37 | 92 | |
| 38 | 93 | /// Writes data to a serial device. |
| 39 | pub fn write(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status { | |
| 40 | return self._write(self, buffer_size, buffer); | |
| 94 | pub fn write(self: *SerialIo, buffer: []const u8) WriteError!usize { | |
| 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 | } |
| 42 | 103 | |
| 43 | 104 | /// Reads data from a serial device. |
| 44 | pub fn read(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status { | |
| 45 | return self._read(self, buffer_size, buffer); | |
| 105 | pub fn read(self: *SerialIo, buffer: []u8) ReadError!usize { | |
| 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 | } |
| 47 | 114 | |
| 48 | 115 | pub const guid align(8) = Guid{ |
lib/std/os/uefi/protocol/service_binding.zig created+60| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | const std = @import("std"); | |
| 2 | const uefi = std.uefi; | |
| 3 | const Guid = uefi.Guid; | |
| 4 | const Handle = uefi.Handle; | |
| 5 | const Status = uefi.Status; | |
| 6 | const Error = Status.Error; | |
| 7 | const cc = uefi.cc; | |
| 8 | ||
| 9 | pub 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 | 1 | const std = @import("std"); |
| 2 | 2 | const uefi = std.os.uefi; |
| 3 | 3 | const Guid = uefi.Guid; |
| 4 | const FileProtocol = uefi.protocol.File; | |
| 4 | const File = uefi.protocol.File; | |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | pub const SimpleFileSystem = extern struct { |
| 9 | 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, | |
| 11 | 12 | |
| 12 | pub fn openVolume(self: *const SimpleFileSystem, root: **const FileProtocol) Status { | |
| 13 | return self._open_volume(self, root); | |
| 13 | pub const OpenVolumeError = uefi.UnexpectedError || error{ | |
| 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 | } |
| 15 | 37 | |
| 16 | 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 | 4 | const Guid = uefi.Guid; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | pub const SimpleNetwork = extern struct { |
| 9 | 10 | revision: u64, |
| 10 | _start: *const fn (*const SimpleNetwork) callconv(cc) Status, | |
| 11 | _stop: *const fn (*const SimpleNetwork) callconv(cc) Status, | |
| 12 | _initialize: *const fn (*const SimpleNetwork, usize, usize) callconv(cc) Status, | |
| 13 | _reset: *const fn (*const SimpleNetwork, bool) callconv(cc) Status, | |
| 14 | _shutdown: *const fn (*const SimpleNetwork) callconv(cc) Status, | |
| 15 | _receive_filters: *const fn (*const SimpleNetwork, ReceiveFilter, ReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status, | |
| 16 | _station_address: *const fn (*const SimpleNetwork, bool, ?*const MacAddress) callconv(cc) Status, | |
| 11 | _start: *const fn (*SimpleNetwork) callconv(cc) Status, | |
| 12 | _stop: *const fn (*SimpleNetwork) callconv(cc) Status, | |
| 13 | _initialize: *const fn (*SimpleNetwork, usize, usize) callconv(cc) Status, | |
| 14 | _reset: *const fn (*SimpleNetwork, bool) callconv(cc) Status, | |
| 15 | _shutdown: *const fn (*SimpleNetwork) callconv(cc) Status, | |
| 16 | _receive_filters: *const fn (*SimpleNetwork, ReceiveFilter, ReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status, | |
| 17 | _station_address: *const fn (*SimpleNetwork, bool, ?*const MacAddress) callconv(cc) Status, | |
| 17 | 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 | _nvdata: *const fn (*const SimpleNetwork, bool, usize, usize, [*]u8) callconv(cc) Status, | |
| 20 | _get_status: *const fn (*const 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 | _receive: *const fn (*const SimpleNetwork, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status, | |
| 19 | _mcast_ip_to_mac: *const fn (*SimpleNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status, | |
| 20 | _nvdata: *const fn (*SimpleNetwork, bool, usize, usize, [*]u8) callconv(cc) Status, | |
| 21 | _get_status: *const fn (*SimpleNetwork, ?*InterruptStatus, ?*?[*]u8) callconv(cc) Status, | |
| 22 | _transmit: *const fn (*SimpleNetwork, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(cc) Status, | |
| 23 | _receive: *const fn (*SimpleNetwork, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status, | |
| 23 | 24 | wait_for_packet: Event, |
| 24 | 25 | mode: *Mode, |
| 25 | 26 | |
| 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 | 109 | /// Changes the state of a network interface from "stopped" to "started". |
| 27 | pub fn start(self: *const SimpleNetwork) Status { | |
| 28 | return self._start(self); | |
| 110 | pub fn start(self: *SimpleNetwork) StartError!void { | |
| 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 | } |
| 30 | 120 | |
| 31 | 121 | /// Changes the state of a network interface from "started" to "stopped". |
| 32 | pub fn stop(self: *const SimpleNetwork) Status { | |
| 33 | return self._stop(self); | |
| 122 | pub fn stop(self: *SimpleNetwork) StopError!void { | |
| 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 | } |
| 35 | 132 | |
| 36 | 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 { | |
| 38 | return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size); | |
| 134 | pub fn initialize( | |
| 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 | } |
| 40 | 149 | |
| 41 | 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 { | |
| 43 | return self._reset(self, extended_verification); | |
| 151 | pub fn reset(self: *SimpleNetwork, extended_verification: bool) ResetError!void { | |
| 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 | } |
| 45 | 161 | |
| 46 | 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 { | |
| 48 | return self._shutdown(self); | |
| 163 | pub fn shutdown(self: *SimpleNetwork) ShutdownError!void { | |
| 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 | } |
| 50 | 172 | |
| 51 | 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 { | |
| 53 | return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter); | |
| 174 | pub fn receiveFilters( | |
| 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 | } |
| 55 | 196 | |
| 56 | 197 | /// Modifies or resets the current station address, if supported. |
| 57 | pub fn stationAddress(self: *const SimpleNetwork, reset_flag: bool, new: ?*const MacAddress) Status { | |
| 58 | return self._station_address(self, reset_flag, new); | |
| 198 | pub fn stationAddress( | |
| 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 | } |
| 60 | 223 | |
| 61 | 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 { | |
| 63 | return self._statistics(self, reset_flag, statistics_size, statistics_table); | |
| 225 | pub fn statistics(self: *SimpleNetwork, reset_flag: bool) StatisticsError!Statistics { | |
| 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 | } |
| 65 | 242 | |
| 66 | 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 { | |
| 68 | return self._mcast_ip_to_mac(self, ipv6, ip, mac); | |
| 244 | pub fn mcastIpToMac( | |
| 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 | } |
| 70 | 259 | |
| 71 | 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 { | |
| 73 | return self._nvdata(self, read_write, offset, buffer_size, buffer); | |
| 261 | pub fn nvData( | |
| 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 | } |
| 75 | 283 | |
| 76 | 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 { | |
| 78 | return self._get_status(self, interrupt_status, tx_buf); | |
| 285 | pub fn getStatus( | |
| 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 | } |
| 80 | 298 | |
| 81 | 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 { | |
| 83 | return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); | |
| 300 | pub fn transmit( | |
| 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 | } |
| 85 | 327 | |
| 86 | 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 { | |
| 88 | return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol); | |
| 329 | pub fn receive(self: *SimpleNetwork, buffer: []u8) ReceiveError!Packet { | |
| 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 | } |
| 90 | 351 | |
| 91 | 352 | pub const guid align(8) = Guid{ |
| ... | ... | @@ -97,6 +358,11 @@ pub const SimpleNetwork = extern struct { |
| 97 | 358 | .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, |
| 98 | 359 | }; |
| 99 | 360 | |
| 361 | pub const NvDataOperation = enum { | |
| 362 | read, | |
| 363 | write, | |
| 364 | }; | |
| 365 | ||
| 100 | 366 | pub const MacAddress = [32]u8; |
| 101 | 367 | |
| 102 | 368 | pub const Mode = extern struct { |
| ... | ... | @@ -172,4 +438,12 @@ pub const SimpleNetwork = extern struct { |
| 172 | 438 | software_interrupt: bool, |
| 173 | 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 | 4 | const Guid = uefi.Guid; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Protocol for mice. |
| 9 | 10 | pub const SimplePointer = struct { |
| 10 | _reset: *const fn (*const SimplePointer, bool) callconv(cc) Status, | |
| 11 | _reset: *const fn (*SimplePointer, bool) callconv(cc) Status, | |
| 11 | 12 | _get_state: *const fn (*const SimplePointer, *State) callconv(cc) Status, |
| 12 | 13 | wait_for_input: Event, |
| 13 | 14 | mode: *Mode, |
| 14 | 15 | |
| 16 | pub const ResetError = uefi.UnexpectedError || error{DeviceError}; | |
| 17 | pub const GetStateError = uefi.UnexpectedError || error{ | |
| 18 | NotReady, | |
| 19 | DeviceError, | |
| 20 | }; | |
| 21 | ||
| 15 | 22 | /// Resets the pointer device hardware. |
| 16 | pub fn reset(self: *const SimplePointer, verify: bool) Status { | |
| 17 | return self._reset(self, verify); | |
| 23 | pub fn reset(self: *SimplePointer, verify: bool) ResetError!void { | |
| 24 | switch (self._reset(self, verify)) { | |
| 25 | .success => {}, | |
| 26 | .device_error => return Error.DeviceError, | |
| 27 | else => |status| return uefi.unexpectedStatus(status), | |
| 28 | } | |
| 18 | 29 | } |
| 19 | 30 | |
| 20 | 31 | /// Retrieves the current state of a pointer device. |
| 21 | pub fn getState(self: *const SimplePointer, state: *State) Status { | |
| 22 | return self._get_state(self, state); | |
| 32 | pub fn getState(self: *const SimplePointer) GetStateError!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 | } |
| 24 | 41 | |
| 25 | 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 | 4 | const Guid = uefi.Guid; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Character input devices, e.g. Keyboard |
| 9 | 10 | pub const SimpleTextInput = extern struct { |
| 10 | _reset: *const fn (*const SimpleTextInput, bool) callconv(cc) Status, | |
| 11 | _read_key_stroke: *const fn (*const SimpleTextInput, *Key.Input) callconv(cc) Status, | |
| 11 | _reset: *const fn (*SimpleTextInput, bool) callconv(cc) Status, | |
| 12 | _read_key_stroke: *const fn (*SimpleTextInput, *Key.Input) callconv(cc) Status, | |
| 12 | 13 | wait_for_key: Event, |
| 13 | 14 | |
| 15 | pub const ResetError = uefi.UnexpectedError || error{DeviceError}; | |
| 16 | pub const ReadKeyStrokeError = uefi.UnexpectedError || error{ | |
| 17 | NotReady, | |
| 18 | DeviceError, | |
| 19 | Unsupported, | |
| 20 | }; | |
| 21 | ||
| 14 | 22 | /// Resets the input device hardware. |
| 15 | pub fn reset(self: *const SimpleTextInput, verify: bool) Status { | |
| 16 | return self._reset(self, verify); | |
| 23 | pub fn reset(self: *SimpleTextInput, verify: bool) ResetError!void { | |
| 24 | switch (self._reset(self, verify)) { | |
| 25 | .success => {}, | |
| 26 | .device_error => return Error.DeviceError, | |
| 27 | else => |status| return uefi.unexpectedStatus(status), | |
| 28 | } | |
| 17 | 29 | } |
| 18 | 30 | |
| 19 | 31 | /// Reads the next keystroke from the input device. |
| 20 | pub fn readKeyStroke(self: *const SimpleTextInput, input_key: *Key.Input) Status { | |
| 21 | return self._read_key_stroke(self, input_key); | |
| 32 | pub fn readKeyStroke(self: *SimpleTextInput) ReadKeyStrokeError!Key.Input { | |
| 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 | } |
| 23 | 42 | |
| 24 | 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 | 4 | const Guid = uefi.Guid; |
| 5 | 5 | const Status = uefi.Status; |
| 6 | 6 | const cc = uefi.cc; |
| 7 | const Error = Status.Error; | |
| 7 | 8 | |
| 8 | 9 | /// Character input devices, e.g. Keyboard |
| 9 | 10 | pub const SimpleTextInputEx = extern struct { |
| 10 | _reset: *const fn (*const SimpleTextInputEx, bool) callconv(cc) Status, | |
| 11 | _read_key_stroke_ex: *const fn (*const SimpleTextInputEx, *Key) callconv(cc) Status, | |
| 11 | _reset: *const fn (*SimpleTextInputEx, bool) callconv(cc) Status, | |
| 12 | _read_key_stroke_ex: *const fn (*SimpleTextInputEx, *Key) callconv(cc) Status, | |
| 12 | 13 | wait_for_key_ex: Event, |
| 13 | _set_state: *const fn (*const 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 | _unregister_key_notify: *const fn (*const SimpleTextInputEx, *const anyopaque) callconv(cc) Status, | |
| 14 | _set_state: *const fn (*SimpleTextInputEx, *const u8) callconv(cc) Status, | |
| 15 | _register_key_notify: *const fn (*SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) Status, **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}; | |
| 16 | 30 | |
| 17 | 31 | /// Resets the input device hardware. |
| 18 | pub fn reset(self: *const SimpleTextInputEx, verify: bool) Status { | |
| 19 | return self._reset(self, verify); | |
| 32 | pub fn reset(self: *SimpleTextInputEx, verify: bool) ResetError!void { | |
| 33 | switch (self._reset(self, verify)) { | |
| 34 | .success => {}, | |
| 35 | .device_error => return Error.DeviceError, | |
| 36 | else => |status| return uefi.unexpectedStatus(status), | |
| 37 | } | |
| 20 | 38 | } |
| 21 | 39 | |
| 22 | 40 | /// Reads the next keystroke from the input device. |
| 23 | pub fn readKeyStrokeEx(self: *const SimpleTextInputEx, key_data: *Key) Status { | |
| 24 | return self._read_key_stroke_ex(self, key_data); | |
| 41 | pub fn readKeyStroke(self: *SimpleTextInputEx) ReadKeyStrokeError!Key { | |
| 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 | } |
| 26 | 51 | |
| 27 | 52 | /// Set certain state for the input device. |
| 28 | pub fn setState(self: *const SimpleTextInputEx, state: *const u8) Status { | |
| 29 | return self._set_state(self, state); | |
| 53 | pub fn setState(self: *SimpleTextInputEx, state: *const Key.State.Toggle) SetStateError!void { | |
| 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 | } |
| 31 | 61 | |
| 32 | 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 { | |
| 34 | return self._register_key_notify(self, key_data, notify, handle); | |
| 63 | pub fn registerKeyNotify( | |
| 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 | } |
| 36 | 75 | |
| 37 | 76 | /// Remove the notification that was previously registered. |
| 38 | pub fn unregisterKeyNotify(self: *const SimpleTextInputEx, handle: *const anyopaque) Status { | |
| 39 | return self._unregister_key_notify(self, handle); | |
| 77 | pub fn unregisterKeyNotify( | |
| 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 | } |
| 41 | 87 | |
| 42 | 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 | 3 | const Guid = uefi.Guid; |
| 4 | 4 | const Status = uefi.Status; |
| 5 | 5 | const cc = uefi.cc; |
| 6 | const Error = Status.Error; | |
| 6 | 7 | |
| 7 | 8 | /// Character output devices |
| 8 | 9 | pub const SimpleTextOutput = extern struct { |
| 9 | _reset: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status, | |
| 10 | _output_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status, | |
| 10 | _reset: *const fn (*SimpleTextOutput, bool) callconv(cc) Status, | |
| 11 | _output_string: *const fn (*SimpleTextOutput, [*:0]const u16) callconv(cc) Status, | |
| 11 | 12 | _test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status, |
| 12 | 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_attribute: *const fn (*const SimpleTextOutput, usize) callconv(cc) Status, | |
| 15 | _clear_screen: *const fn (*const SimpleTextOutput) callconv(cc) Status, | |
| 16 | _set_cursor_position: *const fn (*const SimpleTextOutput, usize, usize) callconv(cc) Status, | |
| 17 | _enable_cursor: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status, | |
| 14 | _set_mode: *const fn (*SimpleTextOutput, usize) callconv(cc) Status, | |
| 15 | _set_attribute: *const fn (*SimpleTextOutput, usize) callconv(cc) Status, | |
| 16 | _clear_screen: *const fn (*SimpleTextOutput) callconv(cc) Status, | |
| 17 | _set_cursor_position: *const fn (*SimpleTextOutput, usize, usize) callconv(cc) Status, | |
| 18 | _enable_cursor: *const fn (*SimpleTextOutput, bool) callconv(cc) Status, | |
| 18 | 19 | mode: *Mode, |
| 19 | 20 | |
| 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 | 48 | /// Resets the text output device hardware. |
| 21 | pub fn reset(self: *const SimpleTextOutput, verify: bool) Status { | |
| 22 | return self._reset(self, verify); | |
| 49 | pub fn reset(self: *SimpleTextOutput, verify: bool) ResetError!void { | |
| 50 | switch (self._reset(self, verify)) { | |
| 51 | .success => {}, | |
| 52 | .device_error => return Error.DeviceError, | |
| 53 | else => |status| return uefi.unexpectedStatus(status), | |
| 54 | } | |
| 23 | 55 | } |
| 24 | 56 | |
| 25 | 57 | /// Writes a string to the output device. |
| 26 | pub fn outputString(self: *const SimpleTextOutput, msg: [*:0]const u16) Status { | |
| 27 | return self._output_string(self, msg); | |
| 58 | /// | |
| 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 | } |
| 29 | 69 | |
| 30 | 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 { | |
| 32 | return self._test_string(self, msg); | |
| 71 | pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) uefi.UnexpectedError!bool { | |
| 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 | } |
| 34 | 78 | |
| 35 | 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 { | |
| 37 | return self._query_mode(self, mode_number, columns, rows); | |
| 80 | pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize) QueryModeError!Geometry { | |
| 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 | } |
| 39 | 89 | |
| 40 | 90 | /// Sets the output device(s) to a specified mode. |
| 41 | pub fn setMode(self: *const SimpleTextOutput, mode_number: usize) Status { | |
| 42 | return self._set_mode(self, mode_number); | |
| 91 | pub fn setMode(self: *SimpleTextOutput, mode_number: usize) SetModeError!void { | |
| 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 | } |
| 44 | 99 | |
| 45 | 100 | /// Sets the background and foreground colors for the outputString() and clearScreen() functions. |
| 46 | pub fn setAttribute(self: *const SimpleTextOutput, attribute: usize) Status { | |
| 47 | return self._set_attribute(self, attribute); | |
| 101 | pub fn setAttribute(self: *SimpleTextOutput, attribute: Attribute) SetAttributeError!void { | |
| 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 | } |
| 49 | 109 | |
| 50 | 110 | /// Clears the output device(s) display to the currently selected background color. |
| 51 | pub fn clearScreen(self: *const SimpleTextOutput) Status { | |
| 52 | return self._clear_screen(self); | |
| 111 | pub fn clearScreen(self: *SimpleTextOutput) ClearScreenError!void { | |
| 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 | } |
| 54 | 119 | |
| 55 | 120 | /// Sets the current coordinates of the cursor position. |
| 56 | pub fn setCursorPosition(self: *const SimpleTextOutput, column: usize, row: usize) Status { | |
| 57 | return self._set_cursor_position(self, column, row); | |
| 121 | pub fn setCursorPosition( | |
| 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 | } |
| 59 | 133 | |
| 60 | 134 | /// Makes the cursor visible or invisible. |
| 61 | pub fn enableCursor(self: *const SimpleTextOutput, visible: bool) Status { | |
| 62 | return self._enable_cursor(self, visible); | |
| 135 | pub fn enableCursor(self: *SimpleTextOutput, visible: bool) EnableCursorError!void { | |
| 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 | } |
| 64 | 143 | |
| 65 | 144 | pub const guid align(8) = Guid{ |
| ... | ... | @@ -118,31 +197,41 @@ pub const SimpleTextOutput = extern struct { |
| 118 | 197 | pub const geometricshape_left_triangle: u16 = 0x25c4; |
| 119 | 198 | pub const arrow_up: u16 = 0x2591; |
| 120 | 199 | pub const arrow_down: u16 = 0x2593; |
| 121 | pub const black: u8 = 0x00; | |
| 122 | pub const blue: u8 = 0x01; | |
| 123 | pub const green: u8 = 0x02; | |
| 124 | pub const cyan: u8 = 0x03; | |
| 125 | pub const red: u8 = 0x04; | |
| 126 | pub const magenta: u8 = 0x05; | |
| 127 | pub const brown: u8 = 0x06; | |
| 128 | pub const lightgray: u8 = 0x07; | |
| 129 | pub const bright: u8 = 0x08; | |
| 130 | pub const darkgray: u8 = 0x08; | |
| 131 | pub const lightblue: u8 = 0x09; | |
| 132 | pub const lightgreen: u8 = 0x0a; | |
| 133 | pub const lightcyan: u8 = 0x0b; | |
| 134 | pub const lightred: u8 = 0x0c; | |
| 135 | pub const lightmagenta: u8 = 0x0d; | |
| 136 | pub const yellow: u8 = 0x0e; | |
| 137 | pub const white: u8 = 0x0f; | |
| 138 | pub const background_black: u8 = 0x00; | |
| 139 | pub const background_blue: u8 = 0x10; | |
| 140 | pub const background_green: u8 = 0x20; | |
| 141 | pub const background_cyan: u8 = 0x30; | |
| 142 | pub const background_red: u8 = 0x40; | |
| 143 | pub const background_magenta: u8 = 0x50; | |
| 144 | pub const background_brown: u8 = 0x60; | |
| 145 | pub const background_lightgray: u8 = 0x70; | |
| 200 | ||
| 201 | pub const Attribute = packed struct(u8) { | |
| 202 | foreground: ForegroundColor = .white, | |
| 203 | background: BackgroundColor = .black, | |
| 204 | ||
| 205 | pub const ForegroundColor = enum(u4) { | |
| 206 | black, | |
| 207 | blue, | |
| 208 | green, | |
| 209 | cyan, | |
| 210 | red, | |
| 211 | magenta, | |
| 212 | brown, | |
| 213 | lightgray, | |
| 214 | darkgray, | |
| 215 | lightblue, | |
| 216 | lightgreen, | |
| 217 | lightcyan, | |
| 218 | lightred, | |
| 219 | lightmagenta, | |
| 220 | yellow, | |
| 221 | white, | |
| 222 | }; | |
| 223 | ||
| 224 | pub const BackgroundColor = enum(u4) { | |
| 225 | black, | |
| 226 | blue, | |
| 227 | green, | |
| 228 | cyan, | |
| 229 | red, | |
| 230 | magenta, | |
| 231 | brown, | |
| 232 | lightgray, | |
| 233 | }; | |
| 234 | }; | |
| 146 | 235 | |
| 147 | 236 | pub const Mode = extern struct { |
| 148 | 237 | max_mode: u32, // specified as signed |
| ... | ... | @@ -152,4 +241,9 @@ pub const SimpleTextOutput = extern struct { |
| 152 | 241 | cursor_row: i32, |
| 153 | 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 | 8 | const ManagedNetworkConfigData = uefi.protocol.ManagedNetwork.Config; |
| 9 | 9 | const SimpleNetwork = uefi.protocol.SimpleNetwork; |
| 10 | 10 | const cc = uefi.cc; |
| 11 | const Error = Status.Error; | |
| 11 | 12 | |
| 12 | 13 | pub const Udp6 = extern struct { |
| 13 | 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 | 19 | _cancel: *const fn (*const Udp6, ?*CompletionToken) callconv(cc) Status, |
| 19 | 20 | _poll: *const fn (*const Udp6) callconv(cc) Status, |
| 20 | 21 | |
| 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 | return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data); | |
| 22 | pub const GetModeDataError = uefi.UnexpectedError || error{ | |
| 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 | } |
| 24 | 89 | |
| 25 | pub fn configure(self: *const Udp6, udp6_config_data: ?*const Config) Status { | |
| 26 | return self._configure(self, udp6_config_data); | |
| 90 | pub fn configure(self: *Udp6, udp6_config_data: ?*const Config) ConfigureError!void { | |
| 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 | } |
| 28 | 102 | |
| 29 | pub fn groups(self: *const Udp6, join_flag: bool, multicast_address: ?*const Ip6.Address) Status { | |
| 30 | return self._groups(self, join_flag, multicast_address); | |
| 103 | pub fn groups( | |
| 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 | } |
| 32 | 124 | |
| 33 | pub fn transmit(self: *const Udp6, token: *CompletionToken) Status { | |
| 34 | return self._transmit(self, token); | |
| 125 | pub fn transmit(self: *Udp6, token: *CompletionToken) TransmitError!void { | |
| 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 | } |
| 36 | 140 | |
| 37 | pub fn receive(self: *const Udp6, token: *CompletionToken) Status { | |
| 38 | return self._receive(self, token); | |
| 141 | pub fn receive(self: *Udp6, token: *CompletionToken) ReceiveError!void { | |
| 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 | } |
| 40 | 155 | |
| 41 | pub fn cancel(self: *const Udp6, token: ?*CompletionToken) Status { | |
| 42 | return self._cancel(self, token); | |
| 156 | pub fn cancel(self: *Udp6, token: ?*CompletionToken) CancelError!void { | |
| 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 | } |
| 44 | 165 | |
| 45 | pub fn poll(self: *const Udp6) Status { | |
| 46 | return self._poll(self); | |
| 166 | pub fn poll(self: *Udp6) PollError!void { | |
| 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 | } |
| 48 | 175 | |
| 49 | 176 | pub const guid align(8) = uefi.Guid{ |
| ... | ... | @@ -55,6 +182,18 @@ pub const Udp6 = extern struct { |
| 55 | 182 | .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 }, |
| 56 | 183 | }; |
| 57 | 184 | |
| 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 | 197 | pub const Config = extern struct { |
| 59 | 198 | accept_promiscuous: bool, |
| 60 | 199 | accept_any_port: bool, |
lib/std/os/uefi/protocol/udp6_service_binding.zig deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | const uefi = std.os.uefi; | |
| 3 | const Handle = uefi.Handle; | |
| 4 | const Guid = uefi.Guid; | |
| 5 | const Status = uefi.Status; | |
| 6 | const cc = uefi.cc; | |
| 7 | ||
| 8 | pub 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 | }; |