Commit a31748b29e
Changed files (48)
lib
std
os
uefi
protocol
protocols
lib/std/os/uefi/protocol/absolute_pointer.zig
@@ -0,0 +1,62 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Event = uefi.Event;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+/// Protocol for touchscreens.
+pub const AbsolutePointer = extern struct {
+ _reset: *const fn (*const AbsolutePointer, bool) callconv(cc) Status,
+ _get_state: *const fn (*const AbsolutePointer, *State) callconv(cc) Status,
+ wait_for_input: Event,
+ mode: *Mode,
+
+ /// Resets the pointer device hardware.
+ pub fn reset(self: *const AbsolutePointer, verify: bool) Status {
+ return self._reset(self, verify);
+ }
+
+ /// Retrieves the current state of a pointer device.
+ pub fn getState(self: *const AbsolutePointer, state: *State) Status {
+ return self._get_state(self, state);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x8d59d32b,
+ .time_mid = 0xc655,
+ .time_high_and_version = 0x4ae9,
+ .clock_seq_high_and_reserved = 0x9b,
+ .clock_seq_low = 0x15,
+ .node = [_]u8{ 0xf2, 0x59, 0x04, 0x99, 0x2a, 0x43 },
+ };
+
+ pub const Mode = extern struct {
+ absolute_min_x: u64,
+ absolute_min_y: u64,
+ absolute_min_z: u64,
+ absolute_max_x: u64,
+ absolute_max_y: u64,
+ absolute_max_z: u64,
+ attributes: Attributes,
+
+ pub const Attributes = packed struct(u32) {
+ supports_alt_active: bool,
+ supports_pressure_as_z: bool,
+ _pad: u30 = 0,
+ };
+ };
+
+ pub const State = extern struct {
+ current_x: u64,
+ current_y: u64,
+ current_z: u64,
+ active_buttons: ActiveButtons,
+
+ pub const ActiveButtons = packed struct(u32) {
+ touch_active: bool,
+ alt_active: bool,
+ _pad: u30 = 0,
+ };
+ };
+};
lib/std/os/uefi/protocol/block_io.zig
@@ -0,0 +1,81 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+pub const BlockIo = extern struct {
+ const Self = @This();
+
+ revision: u64,
+ media: *EfiBlockMedia,
+
+ _reset: *const fn (*BlockIo, extended_verification: bool) callconv(cc) Status,
+ _read_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
+ _write_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
+ _flush_blocks: *const fn (*BlockIo) callconv(cc) Status,
+
+ /// Resets the block device hardware.
+ pub fn reset(self: *Self, extended_verification: bool) Status {
+ return self._reset(self, extended_verification);
+ }
+
+ /// Reads the number of requested blocks from the device.
+ pub fn readBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {
+ return self._read_blocks(self, media_id, lba, buffer_size, buf);
+ }
+
+ /// Writes a specified number of blocks to the device.
+ pub fn writeBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {
+ return self._write_blocks(self, media_id, lba, buffer_size, buf);
+ }
+
+ /// Flushes all modified data to a physical block device.
+ pub fn flushBlocks(self: *Self) Status {
+ return self._flush_blocks(self);
+ }
+
+ pub const guid align(8) = uefi.Guid{
+ .time_low = 0x964e5b21,
+ .time_mid = 0x6459,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+
+ pub const EfiBlockMedia = extern struct {
+ /// The current media ID. If the media changes, this value is changed.
+ media_id: u32,
+
+ /// `true` if the media is removable; otherwise, `false`.
+ removable_media: bool,
+ /// `true` if there is a media currently present in the device
+ media_present: bool,
+ /// `true` if the `BlockIo` was produced to abstract
+ /// partition structures on the disk. `false` if the `BlockIo` was
+ /// produced to abstract the logical blocks on a hardware device.
+ logical_partition: bool,
+ /// `true` if the media is marked read-only otherwise, `false`. This field
+ /// shows the read-only status as of the most recent `WriteBlocks()`
+ read_only: bool,
+ /// `true` if the WriteBlocks() function caches write data.
+ write_caching: bool,
+
+ /// The intrinsic block size of the device. If the media changes, then this
+ // field is updated. Returns the number of bytes per logical block.
+ block_size: u32,
+ /// Supplies the alignment requirement for any buffer used in a data
+ /// transfer. IoAlign values of 0 and 1 mean that the buffer can be
+ /// placed anywhere in memory. Otherwise, IoAlign must be a power of
+ /// 2, and the requirement is that the start address of a buffer must be
+ /// evenly divisible by IoAlign with no remainder.
+ io_align: u32,
+ /// The last LBA on the device. If the media changes, then this field is updated.
+ last_block: u64,
+
+ // Revision 2
+ lowest_aligned_lba: u64,
+ logical_blocks_per_physical_block: u32,
+ optimal_transfer_length_granularity: u32,
+ };
+};
lib/std/os/uefi/protocol/device_path.zig
@@ -0,0 +1,122 @@
+const std = @import("../../../std.zig");
+const mem = std.mem;
+const uefi = std.os.uefi;
+const Allocator = mem.Allocator;
+const Guid = uefi.Guid;
+const assert = std.debug.assert;
+
+// All Device Path Nodes are byte-packed and may appear on any byte boundary.
+// All code references to device path nodes must assume all fields are unaligned.
+
+pub const DevicePath = extern struct {
+ type: uefi.DevicePath.Type,
+ subtype: u8,
+ length: u16 align(1),
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x09576e91,
+ .time_mid = 0x6d3f,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+
+ /// Returns the next DevicePath node in the sequence, if any.
+ pub fn next(self: *DevicePath) ?*DevicePath {
+ if (self.type == .End and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .EndEntire)
+ return null;
+
+ return @as(*DevicePath, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length));
+ }
+
+ /// Calculates the total length of the device path structure in bytes, including the end of device path node.
+ pub fn size(self: *DevicePath) usize {
+ var node = self;
+
+ while (node.next()) |next_node| {
+ node = next_node;
+ }
+
+ return (@intFromPtr(node) + node.length) - @intFromPtr(self);
+ }
+
+ /// Creates a file device path from the existing device path and a file path.
+ pub fn create_file_device_path(self: *DevicePath, allocator: Allocator, path: [:0]align(1) const u16) !*DevicePath {
+ var path_size = self.size();
+
+ // 2 * (path.len + 1) for the path and its null terminator, which are u16s
+ // DevicePath for the extra node before the end
+ var buf = try allocator.alloc(u8, path_size + 2 * (path.len + 1) + @sizeOf(DevicePath));
+
+ @memcpy(buf[0..path_size], @as([*]const u8, @ptrCast(self))[0..path_size]);
+
+ // Pointer to the copy of the end node of the current chain, which is - 4 from the buffer
+ // as the end node itself is 4 bytes (type: u8 + subtype: u8 + length: u16).
+ var new = @as(*uefi.DevicePath.Media.FilePathDevicePath, @ptrCast(buf.ptr + path_size - 4));
+
+ new.type = .Media;
+ new.subtype = .FilePath;
+ new.length = @sizeOf(uefi.DevicePath.Media.FilePathDevicePath) + 2 * (@as(u16, @intCast(path.len)) + 1);
+
+ // The same as new.getPath(), but not const as we're filling it in.
+ var ptr = @as([*:0]align(1) u16, @ptrCast(@as([*]u8, @ptrCast(new)) + @sizeOf(uefi.DevicePath.Media.FilePathDevicePath)));
+
+ for (path, 0..) |s, i|
+ ptr[i] = s;
+
+ ptr[path.len] = 0;
+
+ var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@as(*DevicePath, @ptrCast(new)).next().?));
+ end.type = .End;
+ end.subtype = .EndEntire;
+ end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath);
+
+ return @as(*DevicePath, @ptrCast(buf.ptr));
+ }
+
+ pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
+ inline for (@typeInfo(uefi.DevicePath).Union.fields) |ufield| {
+ const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);
+
+ // Got the associated union type for self.type, now
+ // we need to initialize it and its subtype
+ if (self.type == enum_value) {
+ var subtype = self.initSubtype(ufield.type);
+
+ if (subtype) |sb| {
+ // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } }
+ return @unionInit(uefi.DevicePath, ufield.name, sb);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion {
+ const type_info = @typeInfo(TUnion).Union;
+ const TTag = type_info.tag_type.?;
+
+ inline for (type_info.fields) |subtype| {
+ // The tag names match the union names, so just grab that off the enum
+ const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name));
+
+ if (self.subtype == tag_val) {
+ // e.g. expr = .{ .Pci = @ptrCast(...) }
+ return @unionInit(TUnion, subtype.name, @as(subtype.type, @ptrCast(self)));
+ }
+ }
+
+ return null;
+ }
+};
+
+comptime {
+ assert(4 == @sizeOf(DevicePath));
+ assert(1 == @alignOf(DevicePath));
+
+ assert(0 == @offsetOf(DevicePath, "type"));
+ assert(1 == @offsetOf(DevicePath, "subtype"));
+ assert(2 == @offsetOf(DevicePath, "length"));
+}
lib/std/os/uefi/protocol/edid.zig
@@ -0,0 +1,67 @@
+const std = @import("../../../std.zig");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Handle = uefi.Handle;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+/// EDID information for an active video output device
+pub const Active = extern struct {
+ size_of_edid: u32,
+ edid: ?[*]u8,
+
+ pub const guid align(8) = Guid{
+ .time_low = 0xbd8c1056,
+ .time_mid = 0x9f36,
+ .time_high_and_version = 0x44ec,
+ .clock_seq_high_and_reserved = 0x92,
+ .clock_seq_low = 0xa8,
+ .node = [_]u8{ 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 },
+ };
+};
+
+/// EDID information for a video output device
+pub const Discovered = extern struct {
+ size_of_edid: u32,
+ edid: ?[*]u8,
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x1c0c34f6,
+ .time_mid = 0xd380,
+ .time_high_and_version = 0x41fa,
+ .clock_seq_high_and_reserved = 0xa0,
+ .clock_seq_low = 0x49,
+ .node = [_]u8{ 0x8a, 0xd0, 0x6c, 0x1a, 0x66, 0xaa },
+ };
+};
+
+/// Override EDID information
+pub const Override = extern struct {
+ _get_edid: *const fn (*const Override, Handle, *Attributes, *usize, *?[*]u8) callconv(cc) Status,
+
+ /// Returns policy information and potentially a replacement EDID for the specified video output device.
+ pub fn getEdid(
+ self: *const Override,
+ handle: Handle,
+ attributes: *Attributes,
+ edid_size: *usize,
+ edid: *?[*]u8,
+ ) Status {
+ return self._get_edid(self, handle, attributes, edid_size, edid);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x48ecb431,
+ .time_mid = 0xfb72,
+ .time_high_and_version = 0x45c0,
+ .clock_seq_high_and_reserved = 0xa9,
+ .clock_seq_low = 0x22,
+ .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },
+ };
+
+ pub const Attributes = packed struct(u32) {
+ dont_override: bool,
+ enable_hot_plug: bool,
+ _pad: u30 = 0,
+ };
+};
lib/std/os/uefi/protocol/file.zig
@@ -0,0 +1,144 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const io = std.io;
+const Guid = uefi.Guid;
+const Time = uefi.Time;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+pub const File = extern struct {
+ revision: u64,
+ _open: *const fn (*const File, **const File, [*:0]const u16, u64, u64) callconv(cc) Status,
+ _close: *const fn (*const File) callconv(cc) Status,
+ _delete: *const fn (*const File) callconv(cc) Status,
+ _read: *const fn (*const File, *usize, [*]u8) callconv(cc) Status,
+ _write: *const fn (*const File, *usize, [*]const u8) callconv(cc) Status,
+ _get_position: *const fn (*const File, *u64) callconv(cc) Status,
+ _set_position: *const fn (*const File, u64) callconv(cc) Status,
+ _get_info: *const fn (*const File, *align(8) const Guid, *const usize, [*]u8) callconv(cc) Status,
+ _set_info: *const fn (*const File, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status,
+ _flush: *const fn (*const File) callconv(cc) Status,
+
+ pub const SeekError = error{SeekError};
+ pub const GetSeekPosError = error{GetSeekPosError};
+ pub const ReadError = error{ReadError};
+ pub const WriteError = error{WriteError};
+
+ pub const SeekableStream = io.SeekableStream(*const File, SeekError, GetSeekPosError, seekTo, seekBy, getPos, getEndPos);
+ pub const Reader = io.Reader(*const File, ReadError, readFn);
+ pub const Writer = io.Writer(*const File, WriteError, writeFn);
+
+ pub fn seekableStream(self: *File) SeekableStream {
+ return .{ .context = self };
+ }
+
+ pub fn reader(self: *File) Reader {
+ return .{ .context = self };
+ }
+
+ pub fn writer(self: *File) Writer {
+ return .{ .context = self };
+ }
+
+ pub fn open(self: *const File, new_handle: **const File, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {
+ return self._open(self, new_handle, file_name, open_mode, attributes);
+ }
+
+ pub fn close(self: *const File) Status {
+ return self._close(self);
+ }
+
+ pub fn delete(self: *const File) Status {
+ return self._delete(self);
+ }
+
+ pub fn read(self: *const File, buffer_size: *usize, buffer: [*]u8) Status {
+ return self._read(self, buffer_size, buffer);
+ }
+
+ fn readFn(self: *const File, buffer: []u8) ReadError!usize {
+ var size: usize = buffer.len;
+ if (.Success != self.read(&size, buffer.ptr)) return ReadError.ReadError;
+ return size;
+ }
+
+ pub fn write(self: *const File, buffer_size: *usize, buffer: [*]const u8) Status {
+ return self._write(self, buffer_size, buffer);
+ }
+
+ fn writeFn(self: *const File, bytes: []const u8) WriteError!usize {
+ var size: usize = bytes.len;
+ if (.Success != self.write(&size, bytes.ptr)) return WriteError.WriteError;
+ return size;
+ }
+
+ pub fn getPosition(self: *const File, position: *u64) Status {
+ return self._get_position(self, position);
+ }
+
+ fn getPos(self: *const File) GetSeekPosError!u64 {
+ var pos: u64 = undefined;
+ if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
+ return pos;
+ }
+
+ fn getEndPos(self: *const File) GetSeekPosError!u64 {
+ // preserve the old file position
+ var pos: u64 = undefined;
+ if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
+ // seek to end of file to get position = file size
+ if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError;
+ // restore the old position
+ if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError;
+ // return the file size = position
+ return pos;
+ }
+
+ pub fn setPosition(self: *const File, position: u64) Status {
+ return self._set_position(self, position);
+ }
+
+ fn seekTo(self: *const File, pos: u64) SeekError!void {
+ if (.Success != self.setPosition(pos)) return SeekError.SeekError;
+ }
+
+ fn seekBy(self: *const File, offset: i64) SeekError!void {
+ // save the old position and calculate the delta
+ var pos: u64 = undefined;
+ if (.Success != self.getPosition(&pos)) return SeekError.SeekError;
+ const seek_back = offset < 0;
+ const amt = std.math.absCast(offset);
+ if (seek_back) {
+ pos += amt;
+ } else {
+ pos -= amt;
+ }
+ if (.Success != self.setPosition(pos)) return SeekError.SeekError;
+ }
+
+ pub fn getInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: *usize, buffer: [*]u8) Status {
+ return self._get_info(self, information_type, buffer_size, buffer);
+ }
+
+ pub fn setInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: usize, buffer: [*]const u8) Status {
+ return self._set_info(self, information_type, buffer_size, buffer);
+ }
+
+ pub fn flush(self: *const File) Status {
+ return self._flush(self);
+ }
+
+ pub const efi_file_mode_read: u64 = 0x0000000000000001;
+ pub const efi_file_mode_write: u64 = 0x0000000000000002;
+ pub const efi_file_mode_create: u64 = 0x8000000000000000;
+
+ pub const efi_file_read_only: u64 = 0x0000000000000001;
+ pub const efi_file_hidden: u64 = 0x0000000000000002;
+ pub const efi_file_system: u64 = 0x0000000000000004;
+ pub const efi_file_reserved: u64 = 0x0000000000000008;
+ pub const efi_file_directory: u64 = 0x0000000000000010;
+ pub const efi_file_archive: u64 = 0x0000000000000020;
+ pub const efi_file_valid_attr: u64 = 0x0000000000000037;
+
+ pub const efi_file_position_end_of_file: u64 = 0xffffffffffffffff;
+};
lib/std/os/uefi/protocol/graphics_output.zig
@@ -0,0 +1,83 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+pub const GraphicsOutput = extern struct {
+ _query_mode: *const fn (*const GraphicsOutput, u32, *usize, **Mode.Info) callconv(cc) Status,
+ _set_mode: *const fn (*const GraphicsOutput, u32) callconv(cc) Status,
+ _blt: *const fn (*const GraphicsOutput, ?[*]BltPixel, BltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status,
+ mode: *Mode,
+
+ /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
+ pub fn queryMode(self: *const GraphicsOutput, mode: u32, size_of_info: *usize, info: **Mode.Info) Status {
+ return self._query_mode(self, mode, size_of_info, info);
+ }
+
+ /// Set the video device into the specified mode and clears the visible portions of the output display to black.
+ pub fn setMode(self: *const GraphicsOutput, mode: u32) Status {
+ return self._set_mode(self, mode);
+ }
+
+ /// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
+ 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 {
+ return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x9042a9de,
+ .time_mid = 0x23dc,
+ .time_high_and_version = 0x4a38,
+ .clock_seq_high_and_reserved = 0x96,
+ .clock_seq_low = 0xfb,
+ .node = [_]u8{ 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a },
+ };
+
+ pub const Mode = extern struct {
+ max_mode: u32,
+ mode: u32,
+ info: *Info,
+ size_of_info: usize,
+ frame_buffer_base: u64,
+ frame_buffer_size: usize,
+
+ pub const Info = extern struct {
+ version: u32,
+ horizontal_resolution: u32,
+ vertical_resolution: u32,
+ pixel_format: PixelFormat,
+ pixel_information: PixelBitmask,
+ pixels_per_scan_line: u32,
+ };
+ };
+
+ pub const PixelFormat = enum(u32) {
+ RedGreenBlueReserved8BitPerColor,
+ BlueGreenRedReserved8BitPerColor,
+ BitMask,
+ BltOnly,
+ };
+
+ pub const PixelBitmask = extern struct {
+ red_mask: u32,
+ green_mask: u32,
+ blue_mask: u32,
+ reserved_mask: u32,
+ };
+
+ pub const BltPixel = extern struct {
+ blue: u8,
+ green: u8,
+ red: u8,
+ reserved: u8 = undefined,
+ };
+
+ pub const BltOperation = enum(u32) {
+ BltVideoFill,
+ BltVideoToBltBuffer,
+ BltBufferToVideo,
+ BltVideoToVideo,
+ GraphicsOutputBltOperationMax,
+ };
+};
lib/std/os/uefi/protocols/hii_database_protocol.zig → lib/std/os/uefi/protocol/hii_database.zig
@@ -2,16 +2,16 @@ const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
-const hii = uefi.protocols.hii;
+const hii = uefi.hii;
const cc = uefi.cc;
/// Database manager for HII-related data structures.
-pub const HIIDatabaseProtocol = extern struct {
+pub const HIIDatabase = extern struct {
_new_package_list: Status, // TODO
- _remove_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(cc) Status,
- _update_package_list: *const fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(cc) Status,
- _list_package_lists: *const fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(cc) Status,
- _export_package_lists: *const fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(cc) Status,
+ _remove_package_list: *const fn (*const HIIDatabase, hii.Handle) callconv(cc) Status,
+ _update_package_list: *const fn (*const HIIDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status,
+ _list_package_lists: *const fn (*const HIIDatabase, u8, ?*const Guid, *usize, [*]hii.Handle) callconv(cc) Status,
+ _export_package_lists: *const fn (*const HIIDatabase, ?hii.Handle, *usize, *hii.PackageList) callconv(cc) Status,
_register_package_notify: Status, // TODO
_unregister_package_notify: Status, // TODO
_find_keyboard_layouts: Status, // TODO
@@ -20,22 +20,22 @@ pub const HIIDatabaseProtocol = extern struct {
_get_package_list_handle: Status, // TODO
/// Removes a package list from the HII database.
- pub fn removePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle) Status {
+ pub fn removePackageList(self: *const HIIDatabase, handle: hii.Handle) Status {
return self._remove_package_list(self, handle);
}
/// Update a package list in the HII database.
- pub fn updatePackageList(self: *const HIIDatabaseProtocol, handle: hii.HIIHandle, buffer: *const hii.HIIPackageList) Status {
+ pub fn updatePackageList(self: *const HIIDatabase, handle: hii.Handle, buffer: *const hii.PackageList) Status {
return self._update_package_list(self, handle, buffer);
}
/// Determines the handles that are currently active in the database.
- pub fn listPackageLists(self: *const HIIDatabaseProtocol, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.HIIHandle) Status {
+ pub fn listPackageLists(self: *const HIIDatabase, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.Handle) Status {
return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
}
/// Exports the contents of one or all package lists in the HII database into a buffer.
- pub fn exportPackageLists(self: *const HIIDatabaseProtocol, handle: ?hii.HIIHandle, buffer_size: *usize, buffer: *hii.HIIPackageList) Status {
+ pub fn exportPackageLists(self: *const HIIDatabase, handle: ?hii.Handle, buffer_size: *usize, buffer: *hii.PackageList) Status {
return self._export_package_lists(self, handle, buffer_size, buffer);
}
lib/std/os/uefi/protocol/hii_popup.zig
@@ -0,0 +1,46 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const hii = uefi.hii;
+const cc = uefi.cc;
+
+/// Display a popup window
+pub const HIIPopup = extern struct {
+ revision: u64,
+ _create_popup: *const fn (*const HIIPopup, PopupStyle, PopupType, hii.HIIHandle, u16, ?*PopupSelection) callconv(cc) Status,
+
+ /// Displays a popup window.
+ pub fn createPopup(self: *const HIIPopup, style: PopupStyle, popup_type: PopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*PopupSelection) Status {
+ return self._create_popup(self, style, popup_type, handle, msg, user_selection);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x4311edc0,
+ .time_mid = 0x6054,
+ .time_high_and_version = 0x46d4,
+ .clock_seq_high_and_reserved = 0x9e,
+ .clock_seq_low = 0x40,
+ .node = [_]u8{ 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc },
+ };
+
+ pub const PopupStyle = enum(u32) {
+ Info,
+ Warning,
+ Error,
+ };
+
+ pub const PopupType = enum(u32) {
+ Ok,
+ Cancel,
+ YesNo,
+ YesNoCancel,
+ };
+
+ pub const PopupSelection = enum(u32) {
+ Ok,
+ Cancel,
+ Yes,
+ No,
+ };
+};
lib/std/os/uefi/protocol/ip6.zig
@@ -0,0 +1,146 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Event = uefi.Event;
+const Status = uefi.Status;
+const MacAddress = uefi.protocol.MacAddress;
+const ManagedNetworkConfigData = uefi.protocol.ManagedNetworkConfigData;
+const SimpleNetworkMode = uefi.protocol.SimpleNetworkMode;
+const cc = uefi.cc;
+
+pub const Ip6 = extern struct {
+ _get_mode_data: *const fn (*const Ip6, ?*Mode, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
+ _configure: *const fn (*const Ip6, ?*const Config) callconv(cc) Status,
+ _groups: *const fn (*const Ip6, bool, ?*const Address) callconv(cc) Status,
+ _routes: *const fn (*const Ip6, bool, ?*const Address, u8, ?*const Address) callconv(cc) Status,
+ _neighbors: *const fn (*const Ip6, bool, *const Address, ?*const MacAddress, u32, bool) callconv(cc) Status,
+ _transmit: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status,
+ _receive: *const fn (*const Ip6, *CompletionToken) callconv(cc) Status,
+ _cancel: *const fn (*const Ip6, ?*CompletionToken) callconv(cc) Status,
+ _poll: *const fn (*const Ip6) callconv(cc) Status,
+
+ /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
+ pub fn getModeData(self: *const Ip6, ip6_mode_data: ?*Mode, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
+ return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);
+ }
+
+ /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
+ pub fn configure(self: *const Ip6, ip6_config_data: ?*const Config) Status {
+ return self._configure(self, ip6_config_data);
+ }
+
+ /// Joins and leaves multicast groups.
+ pub fn groups(self: *const Ip6, join_flag: bool, group_address: ?*const Address) Status {
+ return self._groups(self, join_flag, group_address);
+ }
+
+ /// Adds and deletes routing table entries.
+ pub fn routes(self: *const Ip6, delete_route: bool, destination: ?*const Address, prefix_length: u8, gateway_address: ?*const Address) Status {
+ return self._routes(self, delete_route, destination, prefix_length, gateway_address);
+ }
+
+ /// Add or delete Neighbor cache entries.
+ pub fn neighbors(self: *const Ip6, delete_flag: bool, target_ip6_address: *const Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) Status {
+ return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);
+ }
+
+ /// Places outgoing data packets into the transmit queue.
+ pub fn transmit(self: *const Ip6, token: *CompletionToken) Status {
+ return self._transmit(self, token);
+ }
+
+ /// Places a receiving request into the receiving queue.
+ pub fn receive(self: *const Ip6, token: *CompletionToken) Status {
+ return self._receive(self, token);
+ }
+
+ /// Abort an asynchronous transmits or receive request.
+ pub fn cancel(self: *const Ip6, token: ?*CompletionToken) Status {
+ return self._cancel(self, token);
+ }
+
+ /// Polls for incoming data packets and processes outgoing data packets.
+ pub fn poll(self: *const Ip6) Status {
+ return self._poll(self);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x2c8759d5,
+ .time_mid = 0x5c2d,
+ .time_high_and_version = 0x66ef,
+ .clock_seq_high_and_reserved = 0x92,
+ .clock_seq_low = 0x5f,
+ .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },
+ };
+
+ pub const Mode = extern struct {
+ is_started: bool,
+ max_packet_size: u32,
+ config_data: Config,
+ is_configured: bool,
+ address_count: u32,
+ address_list: [*]AddressInfo,
+ group_count: u32,
+ group_table: [*]Address,
+ route_count: u32,
+ route_table: [*]RouteTable,
+ neighbor_count: u32,
+ neighbor_cache: [*]NeighborCache,
+ prefix_count: u32,
+ prefix_table: [*]AddressInfo,
+ icmp_type_count: u32,
+ icmp_type_list: [*]IcmpType,
+ };
+
+ pub const Config = extern struct {
+ default_protocol: u8,
+ accept_any_protocol: bool,
+ accept_icmp_errors: bool,
+ accept_promiscuous: bool,
+ destination_address: Address,
+ station_address: Address,
+ traffic_class: u8,
+ hop_limit: u8,
+ flow_label: u32,
+ receive_timeout: u32,
+ transmit_timeout: u32,
+ };
+
+ pub const Address = [16]u8;
+
+ pub const AddressInfo = extern struct {
+ address: Address,
+ prefix_length: u8,
+ };
+
+ pub const RouteTable = extern struct {
+ gateway: Address,
+ destination: Address,
+ prefix_length: u8,
+ };
+
+ pub const NeighborState = enum(u32) {
+ Incomplete,
+ Reachable,
+ Stale,
+ Delay,
+ Probe,
+ };
+
+ pub const NeighborCache = extern struct {
+ neighbor: Address,
+ link_address: MacAddress,
+ state: NeighborState,
+ };
+
+ pub const IcmpType = extern struct {
+ type: u8,
+ code: u8,
+ };
+
+ pub const CompletionToken = extern struct {
+ event: Event,
+ status: Status,
+ packet: *anyopaque, // union TODO
+ };
+};
lib/std/os/uefi/protocol/ip6_config.zig
@@ -0,0 +1,48 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Event = uefi.Event;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+pub const Ip6Config = extern struct {
+ _set_data: *const fn (*const Ip6Config, DataType, usize, *const anyopaque) callconv(cc) Status,
+ _get_data: *const fn (*const Ip6Config, DataType, *usize, ?*const anyopaque) callconv(cc) Status,
+ _register_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,
+ _unregister_data_notify: *const fn (*const Ip6Config, DataType, Event) callconv(cc) Status,
+
+ pub fn setData(self: *const Ip6Config, data_type: DataType, data_size: usize, data: *const anyopaque) Status {
+ return self._set_data(self, data_type, data_size, data);
+ }
+
+ pub fn getData(self: *const Ip6Config, data_type: DataType, data_size: *usize, data: ?*const anyopaque) Status {
+ return self._get_data(self, data_type, data_size, data);
+ }
+
+ pub fn registerDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status {
+ return self._register_data_notify(self, data_type, event);
+ }
+
+ pub fn unregisterDataNotify(self: *const Ip6Config, data_type: DataType, event: Event) Status {
+ return self._unregister_data_notify(self, data_type, event);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x937fe521,
+ .time_mid = 0x95ae,
+ .time_high_and_version = 0x4d1a,
+ .clock_seq_high_and_reserved = 0x89,
+ .clock_seq_low = 0x29,
+ .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a },
+ };
+
+ pub const DataType = enum(u32) {
+ InterfaceInfo,
+ AltInterfaceId,
+ Policy,
+ DupAddrDetectTransmits,
+ ManualAddress,
+ Gateway,
+ DnsServer,
+ };
+};
lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig → lib/std/os/uefi/protocol/ip6_service_binding.zig
@@ -5,15 +5,15 @@ const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;
-pub const Ip6ServiceBindingProtocol = extern struct {
- _create_child: *const fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(cc) Status,
- _destroy_child: *const fn (*const Ip6ServiceBindingProtocol, Handle) callconv(cc) Status,
+pub const Ip6ServiceBinding = extern struct {
+ _create_child: *const fn (*const Ip6ServiceBinding, *?Handle) callconv(cc) Status,
+ _destroy_child: *const fn (*const Ip6ServiceBinding, Handle) callconv(cc) Status,
- pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {
+ pub fn createChild(self: *const Ip6ServiceBinding, handle: *?Handle) Status {
return self._create_child(self, handle);
}
- pub fn destroyChild(self: *const Ip6ServiceBindingProtocol, handle: Handle) Status {
+ pub fn destroyChild(self: *const Ip6ServiceBinding, handle: Handle) Status {
return self._destroy_child(self, handle);
}
lib/std/os/uefi/protocols/loaded_image_protocol.zig → lib/std/os/uefi/protocol/loaded_image.zig
@@ -5,15 +5,15 @@ const Handle = uefi.Handle;
const Status = uefi.Status;
const SystemTable = uefi.tables.SystemTable;
const MemoryType = uefi.tables.MemoryType;
-const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
+const DevicePath = uefi.protocol.DevicePath;
const cc = uefi.cc;
-pub const LoadedImageProtocol = extern struct {
+pub const LoadedImage = extern struct {
revision: u32,
parent_handle: Handle,
system_table: *SystemTable,
device_handle: ?Handle,
- file_path: *DevicePathProtocol,
+ file_path: *DevicePath,
reserved: *anyopaque,
load_options_size: u32,
load_options: ?*anyopaque,
@@ -21,10 +21,10 @@ pub const LoadedImageProtocol = extern struct {
image_size: u64,
image_code_type: MemoryType,
image_data_type: MemoryType,
- _unload: *const fn (*const LoadedImageProtocol, Handle) callconv(cc) Status,
+ _unload: *const fn (*const LoadedImage, Handle) callconv(cc) Status,
/// Unloads an image from memory.
- pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status {
+ pub fn unload(self: *const LoadedImage, handle: Handle) Status {
return self._unload(self, handle);
}
@@ -36,13 +36,13 @@ pub const LoadedImageProtocol = extern struct {
.clock_seq_low = 0x3f,
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
};
-};
-pub const loaded_image_device_path_protocol_guid align(8) = Guid{
- .time_low = 0xbc62157e,
- .time_mid = 0x3e33,
- .time_high_and_version = 0x4fec,
- .clock_seq_high_and_reserved = 0x99,
- .clock_seq_low = 0x20,
- .node = [_]u8{ 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf },
+ pub const device_path_guid align(8) = Guid{
+ .time_low = 0xbc62157e,
+ .time_mid = 0x3e33,
+ .time_high_and_version = 0x4fec,
+ .clock_seq_high_and_reserved = 0x99,
+ .clock_seq_low = 0x20,
+ .node = [_]u8{ 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf },
+ };
};
lib/std/os/uefi/protocol/managed_network.zig
@@ -0,0 +1,152 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Event = uefi.Event;
+const Handle = uefi.Handle;
+const Status = uefi.Status;
+const Time = uefi.Time;
+const SimpleNetworkMode = uefi.protocol.SimpleNetworkMode;
+const MacAddress = uefi.protocol.MacAddress;
+const cc = uefi.cc;
+
+pub const ManagedNetwork = extern struct {
+ _get_mode_data: *const fn (*const ManagedNetwork, ?*Config, ?*SimpleNetworkMode) callconv(cc) Status,
+ _configure: *const fn (*const ManagedNetwork, ?*const Config) callconv(cc) Status,
+ _mcast_ip_to_mac: *const fn (*const ManagedNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
+ _groups: *const fn (*const ManagedNetwork, bool, ?*const MacAddress) callconv(cc) Status,
+ _transmit: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status,
+ _receive: *const fn (*const ManagedNetwork, *const CompletionToken) callconv(cc) Status,
+ _cancel: *const fn (*const ManagedNetwork, ?*const CompletionToken) callconv(cc) Status,
+ _poll: *const fn (*const ManagedNetwork) callconv(cc) Status,
+
+ /// Returns the operational parameters for the current MNP child driver.
+ /// May also support returning the underlying SNP driver mode data.
+ pub fn getModeData(self: *const ManagedNetwork, mnp_config_data: ?*Config, snp_mode_data: ?*SimpleNetworkMode) Status {
+ return self._get_mode_data(self, mnp_config_data, snp_mode_data);
+ }
+
+ /// Sets or clears the operational parameters for the MNP child driver.
+ pub fn configure(self: *const ManagedNetwork, mnp_config_data: ?*const Config) Status {
+ return self._configure(self, mnp_config_data);
+ }
+
+ /// Translates an IP multicast address to a hardware (MAC) multicast address.
+ /// This function may be unsupported in some MNP implementations.
+ pub fn mcastIpToMac(self: *const ManagedNetwork, ipv6flag: bool, ipaddress: *const anyopaque, mac_address: *MacAddress) Status {
+ return self._mcast_ip_to_mac(self, ipv6flag, ipaddress, mac_address);
+ }
+
+ /// Enables and disables receive filters for multicast address.
+ /// This function may be unsupported in some MNP implementations.
+ pub fn groups(self: *const ManagedNetwork, join_flag: bool, mac_address: ?*const MacAddress) Status {
+ return self._groups(self, join_flag, mac_address);
+ }
+
+ /// Places asynchronous outgoing data packets into the transmit queue.
+ pub fn transmit(self: *const ManagedNetwork, token: *const CompletionToken) Status {
+ return self._transmit(self, token);
+ }
+
+ /// Places an asynchronous receiving request into the receiving queue.
+ pub fn receive(self: *const ManagedNetwork, token: *const CompletionToken) Status {
+ return self._receive(self, token);
+ }
+
+ /// Aborts an asynchronous transmit or receive request.
+ pub fn cancel(self: *const ManagedNetwork, token: ?*const CompletionToken) Status {
+ return self._cancel(self, token);
+ }
+
+ /// Polls for incoming data packets and processes outgoing data packets.
+ pub fn poll(self: *const ManagedNetwork) Status {
+ return self._poll(self);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x7ab33a91,
+ .time_mid = 0xace5,
+ .time_high_and_version = 0x4326,
+ .clock_seq_high_and_reserved = 0xb5,
+ .clock_seq_low = 0x72,
+ .node = [_]u8{ 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 },
+ };
+
+ pub const ServiceBinding = extern struct {
+ _create_child: *const fn (*const ServiceBinding, *?Handle) callconv(cc) Status,
+ _destroy_child: *const fn (*const ServiceBinding, Handle) callconv(cc) Status,
+
+ pub fn createChild(self: *const ServiceBinding, handle: *?Handle) Status {
+ return self._create_child(self, handle);
+ }
+
+ pub fn destroyChild(self: *const ServiceBinding, handle: Handle) Status {
+ return self._destroy_child(self, handle);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0xf36ff770,
+ .time_mid = 0xa7e1,
+ .time_high_and_version = 0x42cf,
+ .clock_seq_high_and_reserved = 0x9e,
+ .clock_seq_low = 0xd2,
+ .node = [_]u8{ 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c },
+ };
+ };
+
+ pub const Config = extern struct {
+ received_queue_timeout_value: u32,
+ transmit_queue_timeout_value: u32,
+ protocol_type_filter: u16,
+ enable_unicast_receive: bool,
+ enable_multicast_receive: bool,
+ enable_broadcast_receive: bool,
+ enable_promiscuous_receive: bool,
+ flush_queues_on_reset: bool,
+ enable_receive_timestamps: bool,
+ disable_background_polling: bool,
+ };
+
+ pub const CompletionToken = extern struct {
+ event: Event,
+ status: Status,
+ packet: extern union {
+ RxData: *ReceiveData,
+ TxData: *TransmitData,
+ },
+ };
+
+ pub const ReceiveData = extern struct {
+ timestamp: Time,
+ recycle_event: Event,
+ packet_length: u32,
+ header_length: u32,
+ address_length: u32,
+ data_length: u32,
+ broadcast_flag: bool,
+ multicast_flag: bool,
+ promiscuous_flag: bool,
+ protocol_type: u16,
+ destination_address: [*]u8,
+ source_address: [*]u8,
+ media_header: [*]u8,
+ packet_data: [*]u8,
+ };
+
+ pub const TransmitData = extern struct {
+ destination_address: ?*MacAddress,
+ source_address: ?*MacAddress,
+ protocol_type: u16,
+ data_length: u32,
+ header_length: u16,
+ fragment_count: u16,
+
+ pub fn getFragments(self: *TransmitData) []Fragment {
+ return @as([*]Fragment, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(TransmitData))))[0..self.fragment_count];
+ }
+ };
+
+ pub const Fragment = extern struct {
+ fragment_length: u32,
+ fragment_buffer: [*]u8,
+ };
+};
lib/std/os/uefi/protocols/rng_protocol.zig → lib/std/os/uefi/protocol/rng.zig
@@ -5,17 +5,17 @@ const Status = uefi.Status;
const cc = uefi.cc;
/// Random Number Generator protocol
-pub const RNGProtocol = extern struct {
- _get_info: *const fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(cc) Status,
- _get_rng: *const fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,
+pub const Rng = extern struct {
+ _get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status,
+ _get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,
/// Returns information about the random number generation implementation.
- pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status {
+ pub fn getInfo(self: *const Rng, list_size: *usize, list: [*]align(8) Guid) Status {
return self._get_info(self, list_size, list);
}
/// Produces and returns an RNG value using either the default or specified RNG algorithm.
- pub fn getRNG(self: *const RNGProtocol, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) Status {
+ pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value_length: usize, value: [*]u8) Status {
return self._get_rng(self, algo, value_length, value);
}
lib/std/os/uefi/protocols/shell_parameters_protocol.zig → lib/std/os/uefi/protocol/shell_parameters.zig
@@ -2,7 +2,7 @@ const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const FileHandle = uefi.FileHandle;
-pub const ShellParametersProtocol = extern struct {
+pub const ShellParameters = extern struct {
argv: [*][*:0]const u16,
argc: usize,
stdin: FileHandle,
lib/std/os/uefi/protocols/simple_file_system_protocol.zig → lib/std/os/uefi/protocol/simple_file_system.zig
@@ -1,15 +1,15 @@
const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
-const FileProtocol = uefi.protocols.FileProtocol;
+const FileProtocol = uefi.protocol.File;
const Status = uefi.Status;
const cc = uefi.cc;
-pub const SimpleFileSystemProtocol = extern struct {
+pub const SimpleFileSystem = extern struct {
revision: u64,
- _open_volume: *const fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(cc) Status,
+ _open_volume: *const fn (*const SimpleFileSystem, **const FileProtocol) callconv(cc) Status,
- pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {
+ pub fn openVolume(self: *const SimpleFileSystem, root: **const FileProtocol) Status {
return self._open_volume(self, root);
}
lib/std/os/uefi/protocol/simple_network.zig
@@ -0,0 +1,175 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Event = uefi.Event;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+pub const SimpleNetwork = extern struct {
+ revision: u64,
+ _start: *const fn (*const SimpleNetwork) callconv(cc) Status,
+ _stop: *const fn (*const SimpleNetwork) callconv(cc) Status,
+ _initialize: *const fn (*const SimpleNetwork, usize, usize) callconv(cc) Status,
+ _reset: *const fn (*const SimpleNetwork, bool) callconv(cc) Status,
+ _shutdown: *const fn (*const SimpleNetwork) callconv(cc) Status,
+ _receive_filters: *const fn (*const SimpleNetwork, ReceiveFilter, ReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status,
+ _station_address: *const fn (*const SimpleNetwork, bool, ?*const MacAddress) callconv(cc) Status,
+ _statistics: *const fn (*const SimpleNetwork, bool, ?*usize, ?*Statistics) callconv(cc) Status,
+ _mcast_ip_to_mac: *const fn (*const SimpleNetwork, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
+ _nvdata: *const fn (*const SimpleNetwork, bool, usize, usize, [*]u8) callconv(cc) Status,
+ _get_status: *const fn (*const SimpleNetwork, *InterruptStatus, ?*?[*]u8) callconv(cc) Status,
+ _transmit: *const fn (*const SimpleNetwork, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(cc) Status,
+ _receive: *const fn (*const SimpleNetwork, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status,
+ wait_for_packet: Event,
+ mode: *Mode,
+
+ /// Changes the state of a network interface from "stopped" to "started".
+ pub fn start(self: *const SimpleNetwork) Status {
+ return self._start(self);
+ }
+
+ /// Changes the state of a network interface from "started" to "stopped".
+ pub fn stop(self: *const SimpleNetwork) Status {
+ return self._stop(self);
+ }
+
+ /// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.
+ pub fn initialize(self: *const SimpleNetwork, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) Status {
+ return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size);
+ }
+
+ /// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().
+ pub fn reset(self: *const SimpleNetwork, extended_verification: bool) Status {
+ return self._reset(self, extended_verification);
+ }
+
+ /// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.
+ pub fn shutdown(self: *const SimpleNetwork) Status {
+ return self._shutdown(self);
+ }
+
+ /// Manages the multicast receive filters of a network interface.
+ pub fn receiveFilters(self: *const SimpleNetwork, enable: ReceiveFilter, disable: ReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) Status {
+ return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter);
+ }
+
+ /// Modifies or resets the current station address, if supported.
+ pub fn stationAddress(self: *const SimpleNetwork, reset_flag: bool, new: ?*const MacAddress) Status {
+ return self._station_address(self, reset_flag, new);
+ }
+
+ /// Resets or collects the statistics on a network interface.
+ pub fn statistics(self: *const SimpleNetwork, reset_flag: bool, statistics_size: ?*usize, statistics_table: ?*Statistics) Status {
+ return self._statistics(self, reset_flag, statistics_size, statistics_table);
+ }
+
+ /// Converts a multicast IP address to a multicast HW MAC address.
+ pub fn mcastIpToMac(self: *const SimpleNetwork, ipv6: bool, ip: *const anyopaque, mac: *MacAddress) Status {
+ return self._mcast_ip_to_mac(self, ipv6, ip, mac);
+ }
+
+ /// Performs read and write operations on the NVRAM device attached to a network interface.
+ pub fn nvdata(self: *const SimpleNetwork, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) Status {
+ return self._nvdata(self, read_write, offset, buffer_size, buffer);
+ }
+
+ /// Reads the current interrupt status and recycled transmit buffer status from a network interface.
+ pub fn getStatus(self: *const SimpleNetwork, interrupt_status: *InterruptStatus, tx_buf: ?*?[*]u8) Status {
+ return self._get_status(self, interrupt_status, tx_buf);
+ }
+
+ /// Places a packet in the transmit queue of a network interface.
+ 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 {
+ return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
+ }
+
+ /// Receives a packet from a network interface.
+ pub fn receive(self: *const SimpleNetwork, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) Status {
+ return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0xa19832b9,
+ .time_mid = 0xac25,
+ .time_high_and_version = 0x11d3,
+ .clock_seq_high_and_reserved = 0x9a,
+ .clock_seq_low = 0x2d,
+ .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
+ };
+
+ pub const MacAddress = [32]u8;
+
+ pub const Mode = extern struct {
+ state: State,
+ hw_address_size: u32,
+ media_header_size: u32,
+ max_packet_size: u32,
+ nvram_size: u32,
+ nvram_access_size: u32,
+ receive_filter_mask: ReceiveFilter,
+ receive_filter_setting: ReceiveFilter,
+ max_mcast_filter_count: u32,
+ mcast_filter_count: u32,
+ mcast_filter: [16]MacAddress,
+ current_address: MacAddress,
+ broadcast_address: MacAddress,
+ permanent_address: MacAddress,
+ if_type: u8,
+ mac_address_changeable: bool,
+ multiple_tx_supported: bool,
+ media_present_supported: bool,
+ media_present: bool,
+ };
+
+ pub const ReceiveFilter = packed struct(u32) {
+ receive_unicast: bool,
+ receive_multicast: bool,
+ receive_broadcast: bool,
+ receive_promiscuous: bool,
+ receive_promiscuous_multicast: bool,
+ _pad: u27 = 0,
+ };
+
+ pub const State = enum(u32) {
+ Stopped,
+ Started,
+ Initialized,
+ };
+
+ pub const Statistics = extern struct {
+ rx_total_frames: u64,
+ rx_good_frames: u64,
+ rx_undersize_frames: u64,
+ rx_oversize_frames: u64,
+ rx_dropped_frames: u64,
+ rx_unicast_frames: u64,
+ rx_broadcast_frames: u64,
+ rx_multicast_frames: u64,
+ rx_crc_error_frames: u64,
+ rx_total_bytes: u64,
+ tx_total_frames: u64,
+ tx_good_frames: u64,
+ tx_undersize_frames: u64,
+ tx_oversize_frames: u64,
+ tx_dropped_frames: u64,
+ tx_unicast_frames: u64,
+ tx_broadcast_frames: u64,
+ tx_multicast_frames: u64,
+ tx_crc_error_frames: u64,
+ tx_total_bytes: u64,
+ collisions: u64,
+ unsupported_protocol: u64,
+ rx_duplicated_frames: u64,
+ rx_decryptError_frames: u64,
+ tx_error_frames: u64,
+ tx_retry_frames: u64,
+ };
+
+ pub const InterruptStatus = packed struct(u32) {
+ receive_interrupt: bool,
+ transmit_interrupt: bool,
+ command_interrupt: bool,
+ software_interrupt: bool,
+ _pad: u28 = 0,
+ };
+};
lib/std/os/uefi/protocol/simple_pointer.zig
@@ -0,0 +1,49 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Event = uefi.Event;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+/// Protocol for mice.
+pub const SimplePointer = struct {
+ _reset: *const fn (*const SimplePointer, bool) callconv(cc) Status,
+ _get_state: *const fn (*const SimplePointer, *State) callconv(cc) Status,
+ wait_for_input: Event,
+ mode: *Mode,
+
+ /// Resets the pointer device hardware.
+ pub fn reset(self: *const SimplePointer, verify: bool) Status {
+ return self._reset(self, verify);
+ }
+
+ /// Retrieves the current state of a pointer device.
+ pub fn getState(self: *const SimplePointer, state: *State) Status {
+ return self._get_state(self, state);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x31878c87,
+ .time_mid = 0x0b75,
+ .time_high_and_version = 0x11d5,
+ .clock_seq_high_and_reserved = 0x9a,
+ .clock_seq_low = 0x4f,
+ .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
+ };
+
+ pub const Mode = struct {
+ resolution_x: u64,
+ resolution_y: u64,
+ resolution_z: u64,
+ left_button: bool,
+ right_button: bool,
+ };
+
+ pub const State = struct {
+ relative_movement_x: i32,
+ relative_movement_y: i32,
+ relative_movement_z: i32,
+ left_button: bool,
+ right_button: bool,
+ };
+};
lib/std/os/uefi/protocols/simple_text_input_protocol.zig → lib/std/os/uefi/protocol/simple_text_input.zig
@@ -2,23 +2,22 @@ const std = @import("std");
const uefi = std.os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
-const InputKey = uefi.protocols.InputKey;
const Status = uefi.Status;
const cc = uefi.cc;
/// Character input devices, e.g. Keyboard
-pub const SimpleTextInputProtocol = extern struct {
- _reset: *const fn (*const SimpleTextInputProtocol, bool) callconv(cc) Status,
- _read_key_stroke: *const fn (*const SimpleTextInputProtocol, *InputKey) callconv(cc) Status,
+pub const SimpleTextInput = extern struct {
+ _reset: *const fn (*const SimpleTextInput, bool) callconv(cc) Status,
+ _read_key_stroke: *const fn (*const SimpleTextInput, *Key.Input) callconv(cc) Status,
wait_for_key: Event,
/// Resets the input device hardware.
- pub fn reset(self: *const SimpleTextInputProtocol, verify: bool) Status {
+ pub fn reset(self: *const SimpleTextInput, verify: bool) Status {
return self._reset(self, verify);
}
/// Reads the next keystroke from the input device.
- pub fn readKeyStroke(self: *const SimpleTextInputProtocol, input_key: *InputKey) Status {
+ pub fn readKeyStroke(self: *const SimpleTextInput, input_key: *Key.Input) Status {
return self._read_key_stroke(self, input_key);
}
@@ -30,4 +29,6 @@ pub const SimpleTextInputProtocol = extern struct {
.clock_seq_low = 0x39,
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
};
+
+ pub const Key = uefi.protocol.SimpleTextInputEx.Key;
};
lib/std/os/uefi/protocol/simple_text_input_ex.zig
@@ -0,0 +1,89 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Event = uefi.Event;
+const Guid = uefi.Guid;
+const Status = uefi.Status;
+const cc = uefi.cc;
+
+/// Character input devices, e.g. Keyboard
+pub const SimpleTextInputEx = extern struct {
+ _reset: *const fn (*const SimpleTextInputEx, bool) callconv(cc) Status,
+ _read_key_stroke_ex: *const fn (*const SimpleTextInputEx, *Key) callconv(cc) Status,
+ wait_for_key_ex: Event,
+ _set_state: *const fn (*const SimpleTextInputEx, *const u8) callconv(cc) Status,
+ _register_key_notify: *const fn (*const SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) usize, **anyopaque) callconv(cc) Status,
+ _unregister_key_notify: *const fn (*const SimpleTextInputEx, *const anyopaque) callconv(cc) Status,
+
+ /// Resets the input device hardware.
+ pub fn reset(self: *const SimpleTextInputEx, verify: bool) Status {
+ return self._reset(self, verify);
+ }
+
+ /// Reads the next keystroke from the input device.
+ pub fn readKeyStrokeEx(self: *const SimpleTextInputEx, key_data: *Key) Status {
+ return self._read_key_stroke_ex(self, key_data);
+ }
+
+ /// Set certain state for the input device.
+ pub fn setState(self: *const SimpleTextInputEx, state: *const u8) Status {
+ return self._set_state(self, state);
+ }
+
+ /// Register a notification function for a particular keystroke for the input device.
+ pub fn registerKeyNotify(self: *const SimpleTextInputEx, key_data: *const Key, notify: *const fn (*const Key) callconv(cc) usize, handle: **anyopaque) Status {
+ return self._register_key_notify(self, key_data, notify, handle);
+ }
+
+ /// Remove the notification that was previously registered.
+ pub fn unregisterKeyNotify(self: *const SimpleTextInputEx, handle: *const anyopaque) Status {
+ return self._unregister_key_notify(self, handle);
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0xdd9e7534,
+ .time_mid = 0x7762,
+ .time_high_and_version = 0x4698,
+ .clock_seq_high_and_reserved = 0x8c,
+ .clock_seq_low = 0x14,
+ .node = [_]u8{ 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa },
+ };
+
+ pub const Key = extern struct {
+ input: Input,
+ state: State,
+
+ pub const State = extern struct {
+ shift: Shift,
+ toggle: Toggle,
+
+ pub const Shift = packed struct(u32) {
+ right_shift_pressed: bool,
+ left_shift_pressed: bool,
+ right_control_pressed: bool,
+ left_control_pressed: bool,
+ right_alt_pressed: bool,
+ left_alt_pressed: bool,
+ right_logo_pressed: bool,
+ left_logo_pressed: bool,
+ menu_key_pressed: bool,
+ sys_req_pressed: bool,
+ _pad: u21 = 0,
+ shift_state_valid: bool,
+ };
+
+ pub const Toggle = packed struct(u8) {
+ scroll_lock_active: bool,
+ num_lock_active: bool,
+ caps_lock_active: bool,
+ _pad: u3 = 0,
+ key_state_exposed: bool,
+ toggle_state_valid: bool,
+ };
+ };
+
+ pub const Input = extern struct {
+ scan_code: u16,
+ unicode_char: u16,
+ };
+ };
+};
lib/std/os/uefi/protocols/simple_text_output_protocol.zig → lib/std/os/uefi/protocol/simple_text_output.zig
@@ -5,60 +5,60 @@ const Status = uefi.Status;
const cc = uefi.cc;
/// Character output devices
-pub const SimpleTextOutputProtocol = extern struct {
- _reset: *const fn (*const SimpleTextOutputProtocol, bool) callconv(cc) Status,
- _output_string: *const fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(cc) Status,
- _test_string: *const fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(cc) Status,
- _query_mode: *const fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) callconv(cc) Status,
- _set_mode: *const fn (*const SimpleTextOutputProtocol, usize) callconv(cc) Status,
- _set_attribute: *const fn (*const SimpleTextOutputProtocol, usize) callconv(cc) Status,
- _clear_screen: *const fn (*const SimpleTextOutputProtocol) callconv(cc) Status,
- _set_cursor_position: *const fn (*const SimpleTextOutputProtocol, usize, usize) callconv(cc) Status,
- _enable_cursor: *const fn (*const SimpleTextOutputProtocol, bool) callconv(cc) Status,
- mode: *SimpleTextOutputMode,
+pub const SimpleTextOutput = extern struct {
+ _reset: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status,
+ _output_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
+ _test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
+ _query_mode: *const fn (*const SimpleTextOutput, usize, *usize, *usize) callconv(cc) Status,
+ _set_mode: *const fn (*const SimpleTextOutput, usize) callconv(cc) Status,
+ _set_attribute: *const fn (*const SimpleTextOutput, usize) callconv(cc) Status,
+ _clear_screen: *const fn (*const SimpleTextOutput) callconv(cc) Status,
+ _set_cursor_position: *const fn (*const SimpleTextOutput, usize, usize) callconv(cc) Status,
+ _enable_cursor: *const fn (*const SimpleTextOutput, bool) callconv(cc) Status,
+ mode: *Mode,
/// Resets the text output device hardware.
- pub fn reset(self: *const SimpleTextOutputProtocol, verify: bool) Status {
+ pub fn reset(self: *const SimpleTextOutput, verify: bool) Status {
return self._reset(self, verify);
}
/// Writes a string to the output device.
- pub fn outputString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) Status {
+ pub fn outputString(self: *const SimpleTextOutput, msg: [*:0]const u16) Status {
return self._output_string(self, msg);
}
/// Verifies that all characters in a string can be output to the target device.
- pub fn testString(self: *const SimpleTextOutputProtocol, msg: [*:0]const u16) Status {
+ pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) Status {
return self._test_string(self, msg);
}
/// Returns information for an available text mode that the output device(s) supports.
- pub fn queryMode(self: *const SimpleTextOutputProtocol, mode_number: usize, columns: *usize, rows: *usize) Status {
+ pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize, columns: *usize, rows: *usize) Status {
return self._query_mode(self, mode_number, columns, rows);
}
/// Sets the output device(s) to a specified mode.
- pub fn setMode(self: *const SimpleTextOutputProtocol, mode_number: usize) Status {
+ pub fn setMode(self: *const SimpleTextOutput, mode_number: usize) Status {
return self._set_mode(self, mode_number);
}
/// Sets the background and foreground colors for the outputString() and clearScreen() functions.
- pub fn setAttribute(self: *const SimpleTextOutputProtocol, attribute: usize) Status {
+ pub fn setAttribute(self: *const SimpleTextOutput, attribute: usize) Status {
return self._set_attribute(self, attribute);
}
/// Clears the output device(s) display to the currently selected background color.
- pub fn clearScreen(self: *const SimpleTextOutputProtocol) Status {
+ pub fn clearScreen(self: *const SimpleTextOutput) Status {
return self._clear_screen(self);
}
/// Sets the current coordinates of the cursor position.
- pub fn setCursorPosition(self: *const SimpleTextOutputProtocol, column: usize, row: usize) Status {
+ pub fn setCursorPosition(self: *const SimpleTextOutput, column: usize, row: usize) Status {
return self._set_cursor_position(self, column, row);
}
/// Makes the cursor visible or invisible.
- pub fn enableCursor(self: *const SimpleTextOutputProtocol, visible: bool) Status {
+ pub fn enableCursor(self: *const SimpleTextOutput, visible: bool) Status {
return self._enable_cursor(self, visible);
}
@@ -143,13 +143,13 @@ pub const SimpleTextOutputProtocol = extern struct {
pub const background_magenta: u8 = 0x50;
pub const background_brown: u8 = 0x60;
pub const background_lightgray: u8 = 0x70;
-};
-pub const SimpleTextOutputMode = extern struct {
- max_mode: u32, // specified as signed
- mode: u32, // specified as signed
- attribute: i32,
- cursor_column: i32,
- cursor_row: i32,
- cursor_visible: bool,
+ pub const Mode = extern struct {
+ max_mode: u32, // specified as signed
+ mode: u32, // specified as signed
+ attribute: i32,
+ cursor_column: i32,
+ cursor_row: i32,
+ cursor_visible: bool,
+ };
};
lib/std/os/uefi/protocol/udp6.zig
@@ -0,0 +1,114 @@
+const std = @import("std");
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+const Event = uefi.Event;
+const Status = uefi.Status;
+const Time = uefi.Time;
+const Ip6 = uefi.protocol.Ip6;
+const ManagedNetworkConfigData = uefi.protocol.ManagedNetworkConfigData;
+const SimpleNetworkMode = uefi.protocol.SimpleNetworkMode;
+const cc = uefi.cc;
+
+pub const Udp6 = extern struct {
+ _get_mode_data: *const fn (*const Udp6, ?*Config, ?*Ip6.ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
+ _configure: *const fn (*const Udp6, ?*const Config) callconv(cc) Status,
+ _groups: *const fn (*const Udp6, bool, ?*const Ip6.Address) callconv(cc) Status,
+ _transmit: *const fn (*const Udp6, *CompletionToken) callconv(cc) Status,
+ _receive: *const fn (*const Udp6, *CompletionToken) callconv(cc) Status,
+ _cancel: *const fn (*const Udp6, ?*CompletionToken) callconv(cc) Status,
+ _poll: *const fn (*const Udp6) callconv(cc) Status,
+
+ pub fn getModeData(self: *const Udp6, udp6_config_data: ?*Config, ip6_mode_data: ?*Ip6.ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
+ return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);
+ }
+
+ pub fn configure(self: *const Udp6, udp6_config_data: ?*const Config) Status {
+ return self._configure(self, udp6_config_data);
+ }
+
+ pub fn groups(self: *const Udp6, join_flag: bool, multicast_address: ?*const Ip6.Address) Status {
+ return self._groups(self, join_flag, multicast_address);
+ }
+
+ pub fn transmit(self: *const Udp6, token: *CompletionToken) Status {
+ return self._transmit(self, token);
+ }
+
+ pub fn receive(self: *const Udp6, token: *CompletionToken) Status {
+ return self._receive(self, token);
+ }
+
+ pub fn cancel(self: *const Udp6, token: ?*CompletionToken) Status {
+ return self._cancel(self, token);
+ }
+
+ pub fn poll(self: *const Udp6) Status {
+ return self._poll(self);
+ }
+
+ pub const guid align(8) = uefi.Guid{
+ .time_low = 0x4f948815,
+ .time_mid = 0xb4b9,
+ .time_high_and_version = 0x43cb,
+ .clock_seq_high_and_reserved = 0x8a,
+ .clock_seq_low = 0x33,
+ .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 },
+ };
+
+ pub const Config = extern struct {
+ accept_promiscuous: bool,
+ accept_any_port: bool,
+ allow_duplicate_port: bool,
+ traffic_class: u8,
+ hop_limit: u8,
+ receive_timeout: u32,
+ transmit_timeout: u32,
+ station_address: Ip6.Address,
+ station_port: u16,
+ remote_address: Ip6.Address,
+ remote_port: u16,
+ };
+
+ pub const CompletionToken = extern struct {
+ event: Event,
+ Status: usize,
+ packet: extern union {
+ RxData: *ReceiveData,
+ TxData: *TransmitData,
+ },
+ };
+
+ pub const ReceiveData = extern struct {
+ timestamp: Time,
+ recycle_signal: Event,
+ udp6_session: SessionData,
+ data_length: u32,
+ fragment_count: u32,
+
+ pub fn getFragments(self: *ReceiveData) []Fragment {
+ return @as([*]Fragment, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(ReceiveData))))[0..self.fragment_count];
+ }
+ };
+
+ pub const TransmitData = extern struct {
+ udp6_session_data: ?*SessionData,
+ data_length: u32,
+ fragment_count: u32,
+
+ pub fn getFragments(self: *TransmitData) []Fragment {
+ return @as([*]Fragment, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(TransmitData))))[0..self.fragment_count];
+ }
+ };
+
+ pub const SessionData = extern struct {
+ source_address: Ip6.Address,
+ source_port: u16,
+ destination_address: Ip6.Address,
+ destination_port: u16,
+ };
+
+ pub const Fragment = extern struct {
+ fragment_length: u32,
+ fragment_buffer: [*]u8,
+ };
+};
lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig → lib/std/os/uefi/protocol/udp6_service_binding.zig
@@ -5,15 +5,15 @@ const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;
-pub const Udp6ServiceBindingProtocol = extern struct {
- _create_child: *const fn (*const Udp6ServiceBindingProtocol, *?Handle) callconv(cc) Status,
- _destroy_child: *const fn (*const Udp6ServiceBindingProtocol, Handle) callconv(cc) Status,
+pub const Udp6ServiceBinding = extern struct {
+ _create_child: *const fn (*const Udp6ServiceBinding, *?Handle) callconv(cc) Status,
+ _destroy_child: *const fn (*const Udp6ServiceBinding, Handle) callconv(cc) Status,
- pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status {
+ pub fn createChild(self: *const Udp6ServiceBinding, handle: *?Handle) Status {
return self._create_child(self, handle);
}
- pub fn destroyChild(self: *const Udp6ServiceBindingProtocol, handle: Handle) Status {
+ pub fn destroyChild(self: *const Udp6ServiceBinding, handle: Handle) Status {
return self._destroy_child(self, handle);
}
lib/std/os/uefi/protocols/absolute_pointer_protocol.zig
@@ -1,62 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Event = uefi.Event;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-/// Protocol for touchscreens
-pub const AbsolutePointerProtocol = extern struct {
- _reset: *const fn (*const AbsolutePointerProtocol, bool) callconv(cc) Status,
- _get_state: *const fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(cc) Status,
- wait_for_input: Event,
- mode: *AbsolutePointerMode,
-
- /// Resets the pointer device hardware.
- pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) Status {
- return self._reset(self, verify);
- }
-
- /// Retrieves the current state of a pointer device.
- pub fn getState(self: *const AbsolutePointerProtocol, state: *AbsolutePointerState) Status {
- return self._get_state(self, state);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x8d59d32b,
- .time_mid = 0xc655,
- .time_high_and_version = 0x4ae9,
- .clock_seq_high_and_reserved = 0x9b,
- .clock_seq_low = 0x15,
- .node = [_]u8{ 0xf2, 0x59, 0x04, 0x99, 0x2a, 0x43 },
- };
-};
-
-pub const AbsolutePointerModeAttributes = packed struct(u32) {
- supports_alt_active: bool,
- supports_pressure_as_z: bool,
- _pad: u30 = 0,
-};
-
-pub const AbsolutePointerMode = extern struct {
- absolute_min_x: u64,
- absolute_min_y: u64,
- absolute_min_z: u64,
- absolute_max_x: u64,
- absolute_max_y: u64,
- absolute_max_z: u64,
- attributes: AbsolutePointerModeAttributes,
-};
-
-pub const AbsolutePointerStateActiveButtons = packed struct(u32) {
- touch_active: bool,
- alt_active: bool,
- _pad: u30 = 0,
-};
-
-pub const AbsolutePointerState = extern struct {
- current_x: u64,
- current_y: u64,
- current_z: u64,
- active_buttons: AbsolutePointerStateActiveButtons,
-};
lib/std/os/uefi/protocols/block_io_protocol.zig
@@ -1,81 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-pub const EfiBlockMedia = extern struct {
- /// The current media ID. If the media changes, this value is changed.
- media_id: u32,
-
- /// `true` if the media is removable; otherwise, `false`.
- removable_media: bool,
- /// `true` if there is a media currently present in the device
- media_present: bool,
- /// `true` if the `BlockIoProtocol` was produced to abstract
- /// partition structures on the disk. `false` if the `BlockIoProtocol` was
- /// produced to abstract the logical blocks on a hardware device.
- logical_partition: bool,
- /// `true` if the media is marked read-only otherwise, `false`. This field
- /// shows the read-only status as of the most recent `WriteBlocks()`
- read_only: bool,
- /// `true` if the WriteBlocks() function caches write data.
- write_caching: bool,
-
- /// The intrinsic block size of the device. If the media changes, then this
- // field is updated. Returns the number of bytes per logical block.
- block_size: u32,
- /// Supplies the alignment requirement for any buffer used in a data
- /// transfer. IoAlign values of 0 and 1 mean that the buffer can be
- /// placed anywhere in memory. Otherwise, IoAlign must be a power of
- /// 2, and the requirement is that the start address of a buffer must be
- /// evenly divisible by IoAlign with no remainder.
- io_align: u32,
- /// The last LBA on the device. If the media changes, then this field is updated.
- last_block: u64,
-
- // Revision 2
- lowest_aligned_lba: u64,
- logical_blocks_per_physical_block: u32,
- optimal_transfer_length_granularity: u32,
-};
-
-pub const BlockIoProtocol = extern struct {
- const Self = @This();
-
- revision: u64,
- media: *EfiBlockMedia,
-
- _reset: *const fn (*BlockIoProtocol, extended_verification: bool) callconv(cc) Status,
- _read_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
- _write_blocks: *const fn (*BlockIoProtocol, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
- _flush_blocks: *const fn (*BlockIoProtocol) callconv(cc) Status,
-
- /// Resets the block device hardware.
- pub fn reset(self: *Self, extended_verification: bool) Status {
- return self._reset(self, extended_verification);
- }
-
- /// Reads the number of requested blocks from the device.
- pub fn readBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {
- return self._read_blocks(self, media_id, lba, buffer_size, buf);
- }
-
- /// Writes a specified number of blocks to the device.
- pub fn writeBlocks(self: *Self, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) Status {
- return self._write_blocks(self, media_id, lba, buffer_size, buf);
- }
-
- /// Flushes all modified data to a physical block device.
- pub fn flushBlocks(self: *Self) Status {
- return self._flush_blocks(self);
- }
-
- pub const guid align(8) = uefi.Guid{
- .time_low = 0x964e5b21,
- .time_mid = 0x6459,
- .time_high_and_version = 0x11d2,
- .clock_seq_high_and_reserved = 0x8e,
- .clock_seq_low = 0x39,
- .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
- };
-};
lib/std/os/uefi/protocols/device_path_protocol.zig
@@ -1,1126 +0,0 @@
-const std = @import("std");
-const mem = std.mem;
-const uefi = std.os.uefi;
-const Allocator = mem.Allocator;
-const Guid = uefi.Guid;
-
-// All Device Path Nodes are byte-packed and may appear on any byte boundary.
-// All code references to device path nodes must assume all fields are unaligned.
-
-pub const DevicePathProtocol = extern struct {
- type: DevicePathType,
- subtype: u8,
- length: u16 align(1),
-
- pub const guid align(8) = Guid{
- .time_low = 0x09576e91,
- .time_mid = 0x6d3f,
- .time_high_and_version = 0x11d2,
- .clock_seq_high_and_reserved = 0x8e,
- .clock_seq_low = 0x39,
- .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
- };
-
- /// Returns the next DevicePathProtocol node in the sequence, if any.
- pub fn next(self: *DevicePathProtocol) ?*DevicePathProtocol {
- if (self.type == .End and @as(EndDevicePath.Subtype, @enumFromInt(self.subtype)) == .EndEntire)
- return null;
-
- return @as(*DevicePathProtocol, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length));
- }
-
- /// Calculates the total length of the device path structure in bytes, including the end of device path node.
- pub fn size(self: *DevicePathProtocol) usize {
- var node = self;
-
- while (node.next()) |next_node| {
- node = next_node;
- }
-
- return (@intFromPtr(node) + node.length) - @intFromPtr(self);
- }
-
- /// Creates a file device path from the existing device path and a file path.
- pub fn create_file_device_path(self: *DevicePathProtocol, allocator: Allocator, path: [:0]align(1) const u16) !*DevicePathProtocol {
- var path_size = self.size();
-
- // 2 * (path.len + 1) for the path and its null terminator, which are u16s
- // DevicePathProtocol for the extra node before the end
- var buf = try allocator.alloc(u8, path_size + 2 * (path.len + 1) + @sizeOf(DevicePathProtocol));
-
- @memcpy(buf[0..path_size], @as([*]const u8, @ptrCast(self))[0..path_size]);
-
- // Pointer to the copy of the end node of the current chain, which is - 4 from the buffer
- // as the end node itself is 4 bytes (type: u8 + subtype: u8 + length: u16).
- var new = @as(*MediaDevicePath.FilePathDevicePath, @ptrCast(buf.ptr + path_size - 4));
-
- new.type = .Media;
- new.subtype = .FilePath;
- new.length = @sizeOf(MediaDevicePath.FilePathDevicePath) + 2 * (@as(u16, @intCast(path.len)) + 1);
-
- // The same as new.getPath(), but not const as we're filling it in.
- var ptr = @as([*:0]align(1) u16, @ptrCast(@as([*]u8, @ptrCast(new)) + @sizeOf(MediaDevicePath.FilePathDevicePath)));
-
- for (path, 0..) |s, i|
- ptr[i] = s;
-
- ptr[path.len] = 0;
-
- var end = @as(*EndDevicePath.EndEntireDevicePath, @ptrCast(@as(*DevicePathProtocol, @ptrCast(new)).next().?));
- end.type = .End;
- end.subtype = .EndEntire;
- end.length = @sizeOf(EndDevicePath.EndEntireDevicePath);
-
- return @as(*DevicePathProtocol, @ptrCast(buf.ptr));
- }
-
- pub fn getDevicePath(self: *const DevicePathProtocol) ?DevicePath {
- inline for (@typeInfo(DevicePath).Union.fields) |ufield| {
- const enum_value = std.meta.stringToEnum(DevicePathType, ufield.name);
-
- // Got the associated union type for self.type, now
- // we need to initialize it and its subtype
- if (self.type == enum_value) {
- var subtype = self.initSubtype(ufield.type);
-
- if (subtype) |sb| {
- // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } }
- return @unionInit(DevicePath, ufield.name, sb);
- }
- }
- }
-
- return null;
- }
-
- pub fn initSubtype(self: *const DevicePathProtocol, comptime TUnion: type) ?TUnion {
- const type_info = @typeInfo(TUnion).Union;
- const TTag = type_info.tag_type.?;
-
- inline for (type_info.fields) |subtype| {
- // The tag names match the union names, so just grab that off the enum
- const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name));
-
- if (self.subtype == tag_val) {
- // e.g. expr = .{ .Pci = @ptrCast(...) }
- return @unionInit(TUnion, subtype.name, @as(subtype.type, @ptrCast(self)));
- }
- }
-
- return null;
- }
-};
-
-comptime {
- std.debug.assert(4 == @sizeOf(DevicePathProtocol));
- std.debug.assert(1 == @alignOf(DevicePathProtocol));
-
- std.debug.assert(0 == @offsetOf(DevicePathProtocol, "type"));
- std.debug.assert(1 == @offsetOf(DevicePathProtocol, "subtype"));
- std.debug.assert(2 == @offsetOf(DevicePathProtocol, "length"));
-}
-
-pub const DevicePath = union(DevicePathType) {
- Hardware: HardwareDevicePath,
- Acpi: AcpiDevicePath,
- Messaging: MessagingDevicePath,
- Media: MediaDevicePath,
- BiosBootSpecification: BiosBootSpecificationDevicePath,
- End: EndDevicePath,
-};
-
-pub const DevicePathType = enum(u8) {
- Hardware = 0x01,
- Acpi = 0x02,
- Messaging = 0x03,
- Media = 0x04,
- BiosBootSpecification = 0x05,
- End = 0x7f,
- _,
-};
-
-pub const HardwareDevicePath = union(Subtype) {
- Pci: *const PciDevicePath,
- PcCard: *const PcCardDevicePath,
- MemoryMapped: *const MemoryMappedDevicePath,
- Vendor: *const VendorDevicePath,
- Controller: *const ControllerDevicePath,
- Bmc: *const BmcDevicePath,
-
- pub const Subtype = enum(u8) {
- Pci = 1,
- PcCard = 2,
- MemoryMapped = 3,
- Vendor = 4,
- Controller = 5,
- Bmc = 6,
- _,
- };
-
- pub const PciDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- function: u8,
- device: u8,
- };
-
- comptime {
- std.debug.assert(6 == @sizeOf(PciDevicePath));
- std.debug.assert(1 == @alignOf(PciDevicePath));
-
- std.debug.assert(0 == @offsetOf(PciDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(PciDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(PciDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(PciDevicePath, "function"));
- std.debug.assert(5 == @offsetOf(PciDevicePath, "device"));
- }
-
- pub const PcCardDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- function_number: u8,
- };
-
- comptime {
- std.debug.assert(5 == @sizeOf(PcCardDevicePath));
- std.debug.assert(1 == @alignOf(PcCardDevicePath));
-
- std.debug.assert(0 == @offsetOf(PcCardDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(PcCardDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(PcCardDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(PcCardDevicePath, "function_number"));
- }
-
- pub const MemoryMappedDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- memory_type: u32 align(1),
- start_address: u64 align(1),
- end_address: u64 align(1),
- };
-
- comptime {
- std.debug.assert(24 == @sizeOf(MemoryMappedDevicePath));
- std.debug.assert(1 == @alignOf(MemoryMappedDevicePath));
-
- std.debug.assert(0 == @offsetOf(MemoryMappedDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(MemoryMappedDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(MemoryMappedDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(MemoryMappedDevicePath, "memory_type"));
- std.debug.assert(8 == @offsetOf(MemoryMappedDevicePath, "start_address"));
- std.debug.assert(16 == @offsetOf(MemoryMappedDevicePath, "end_address"));
- }
-
- pub const VendorDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- vendor_guid: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(VendorDevicePath));
- std.debug.assert(1 == @alignOf(VendorDevicePath));
-
- std.debug.assert(0 == @offsetOf(VendorDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(VendorDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(VendorDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(VendorDevicePath, "vendor_guid"));
- }
-
- pub const ControllerDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- controller_number: u32 align(1),
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(ControllerDevicePath));
- std.debug.assert(1 == @alignOf(ControllerDevicePath));
-
- std.debug.assert(0 == @offsetOf(ControllerDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(ControllerDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(ControllerDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(ControllerDevicePath, "controller_number"));
- }
-
- pub const BmcDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- interface_type: u8,
- base_address: u64 align(1),
- };
-
- comptime {
- std.debug.assert(13 == @sizeOf(BmcDevicePath));
- std.debug.assert(1 == @alignOf(BmcDevicePath));
-
- std.debug.assert(0 == @offsetOf(BmcDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(BmcDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(BmcDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(BmcDevicePath, "interface_type"));
- std.debug.assert(5 == @offsetOf(BmcDevicePath, "base_address"));
- }
-};
-
-pub const AcpiDevicePath = union(Subtype) {
- Acpi: *const BaseAcpiDevicePath,
- ExpandedAcpi: *const ExpandedAcpiDevicePath,
- Adr: *const AdrDevicePath,
-
- pub const Subtype = enum(u8) {
- Acpi = 1,
- ExpandedAcpi = 2,
- Adr = 3,
- _,
- };
-
- pub const BaseAcpiDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- hid: u32 align(1),
- uid: u32 align(1),
- };
-
- comptime {
- std.debug.assert(12 == @sizeOf(BaseAcpiDevicePath));
- std.debug.assert(1 == @alignOf(BaseAcpiDevicePath));
-
- std.debug.assert(0 == @offsetOf(BaseAcpiDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(BaseAcpiDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(BaseAcpiDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(BaseAcpiDevicePath, "hid"));
- std.debug.assert(8 == @offsetOf(BaseAcpiDevicePath, "uid"));
- }
-
- pub const ExpandedAcpiDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- hid: u32 align(1),
- uid: u32 align(1),
- cid: u32 align(1),
- // variable length u16[*:0] strings
- // hid_str, uid_str, cid_str
- };
-
- comptime {
- std.debug.assert(16 == @sizeOf(ExpandedAcpiDevicePath));
- std.debug.assert(1 == @alignOf(ExpandedAcpiDevicePath));
-
- std.debug.assert(0 == @offsetOf(ExpandedAcpiDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(ExpandedAcpiDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(ExpandedAcpiDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(ExpandedAcpiDevicePath, "hid"));
- std.debug.assert(8 == @offsetOf(ExpandedAcpiDevicePath, "uid"));
- std.debug.assert(12 == @offsetOf(ExpandedAcpiDevicePath, "cid"));
- }
-
- pub const AdrDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- adr: u32 align(1),
-
- // multiple adr entries can optionally follow
- pub fn adrs(self: *const AdrDevicePath) []align(1) const u32 {
- // self.length is a minimum of 8 with one adr which is size 4.
- var entries = (self.length - 4) / @sizeOf(u32);
- return @as([*]align(1) const u32, @ptrCast(&self.adr))[0..entries];
- }
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(AdrDevicePath));
- std.debug.assert(1 == @alignOf(AdrDevicePath));
-
- std.debug.assert(0 == @offsetOf(AdrDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(AdrDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(AdrDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(AdrDevicePath, "adr"));
- }
-};
-
-pub const MessagingDevicePath = union(Subtype) {
- Atapi: *const AtapiDevicePath,
- Scsi: *const ScsiDevicePath,
- FibreChannel: *const FibreChannelDevicePath,
- FibreChannelEx: *const FibreChannelExDevicePath,
- @"1394": *const F1394DevicePath,
- Usb: *const UsbDevicePath,
- Sata: *const SataDevicePath,
- UsbWwid: *const UsbWwidDevicePath,
- Lun: *const DeviceLogicalUnitDevicePath,
- UsbClass: *const UsbClassDevicePath,
- I2o: *const I2oDevicePath,
- MacAddress: *const MacAddressDevicePath,
- Ipv4: *const Ipv4DevicePath,
- Ipv6: *const Ipv6DevicePath,
- Vlan: *const VlanDevicePath,
- InfiniBand: *const InfiniBandDevicePath,
- Uart: *const UartDevicePath,
- Vendor: *const VendorDefinedDevicePath,
-
- pub const Subtype = enum(u8) {
- Atapi = 1,
- Scsi = 2,
- FibreChannel = 3,
- FibreChannelEx = 21,
- @"1394" = 4,
- Usb = 5,
- Sata = 18,
- UsbWwid = 16,
- Lun = 17,
- UsbClass = 15,
- I2o = 6,
- MacAddress = 11,
- Ipv4 = 12,
- Ipv6 = 13,
- Vlan = 20,
- InfiniBand = 9,
- Uart = 14,
- Vendor = 10,
- _,
- };
-
- pub const AtapiDevicePath = extern struct {
- const Role = enum(u8) {
- Master = 0,
- Slave = 1,
- };
-
- const Rank = enum(u8) {
- Primary = 0,
- Secondary = 1,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- primary_secondary: Rank,
- slave_master: Role,
- logical_unit_number: u16 align(1),
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(AtapiDevicePath));
- std.debug.assert(1 == @alignOf(AtapiDevicePath));
-
- std.debug.assert(0 == @offsetOf(AtapiDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(AtapiDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(AtapiDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(AtapiDevicePath, "primary_secondary"));
- std.debug.assert(5 == @offsetOf(AtapiDevicePath, "slave_master"));
- std.debug.assert(6 == @offsetOf(AtapiDevicePath, "logical_unit_number"));
- }
-
- pub const ScsiDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- target_id: u16 align(1),
- logical_unit_number: u16 align(1),
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(ScsiDevicePath));
- std.debug.assert(1 == @alignOf(ScsiDevicePath));
-
- std.debug.assert(0 == @offsetOf(ScsiDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(ScsiDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(ScsiDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(ScsiDevicePath, "target_id"));
- std.debug.assert(6 == @offsetOf(ScsiDevicePath, "logical_unit_number"));
- }
-
- pub const FibreChannelDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- reserved: u32 align(1),
- world_wide_name: u64 align(1),
- logical_unit_number: u64 align(1),
- };
-
- comptime {
- std.debug.assert(24 == @sizeOf(FibreChannelDevicePath));
- std.debug.assert(1 == @alignOf(FibreChannelDevicePath));
-
- std.debug.assert(0 == @offsetOf(FibreChannelDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(FibreChannelDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(FibreChannelDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(FibreChannelDevicePath, "reserved"));
- std.debug.assert(8 == @offsetOf(FibreChannelDevicePath, "world_wide_name"));
- std.debug.assert(16 == @offsetOf(FibreChannelDevicePath, "logical_unit_number"));
- }
-
- pub const FibreChannelExDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- reserved: u32 align(1),
- world_wide_name: u64 align(1),
- logical_unit_number: u64 align(1),
- };
-
- comptime {
- std.debug.assert(24 == @sizeOf(FibreChannelExDevicePath));
- std.debug.assert(1 == @alignOf(FibreChannelExDevicePath));
-
- std.debug.assert(0 == @offsetOf(FibreChannelExDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(FibreChannelExDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(FibreChannelExDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(FibreChannelExDevicePath, "reserved"));
- std.debug.assert(8 == @offsetOf(FibreChannelExDevicePath, "world_wide_name"));
- std.debug.assert(16 == @offsetOf(FibreChannelExDevicePath, "logical_unit_number"));
- }
-
- pub const F1394DevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- reserved: u32 align(1),
- guid: u64 align(1),
- };
-
- comptime {
- std.debug.assert(16 == @sizeOf(F1394DevicePath));
- std.debug.assert(1 == @alignOf(F1394DevicePath));
-
- std.debug.assert(0 == @offsetOf(F1394DevicePath, "type"));
- std.debug.assert(1 == @offsetOf(F1394DevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(F1394DevicePath, "length"));
- std.debug.assert(4 == @offsetOf(F1394DevicePath, "reserved"));
- std.debug.assert(8 == @offsetOf(F1394DevicePath, "guid"));
- }
-
- pub const UsbDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- parent_port_number: u8,
- interface_number: u8,
- };
-
- comptime {
- std.debug.assert(6 == @sizeOf(UsbDevicePath));
- std.debug.assert(1 == @alignOf(UsbDevicePath));
-
- std.debug.assert(0 == @offsetOf(UsbDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(UsbDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(UsbDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(UsbDevicePath, "parent_port_number"));
- std.debug.assert(5 == @offsetOf(UsbDevicePath, "interface_number"));
- }
-
- pub const SataDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- hba_port_number: u16 align(1),
- port_multiplier_port_number: u16 align(1),
- logical_unit_number: u16 align(1),
- };
-
- comptime {
- std.debug.assert(10 == @sizeOf(SataDevicePath));
- std.debug.assert(1 == @alignOf(SataDevicePath));
-
- std.debug.assert(0 == @offsetOf(SataDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(SataDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(SataDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(SataDevicePath, "hba_port_number"));
- std.debug.assert(6 == @offsetOf(SataDevicePath, "port_multiplier_port_number"));
- std.debug.assert(8 == @offsetOf(SataDevicePath, "logical_unit_number"));
- }
-
- pub const UsbWwidDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- interface_number: u16 align(1),
- device_vendor_id: u16 align(1),
- device_product_id: u16 align(1),
-
- pub fn serial_number(self: *const UsbWwidDevicePath) []align(1) const u16 {
- var serial_len = (self.length - @sizeOf(UsbWwidDevicePath)) / @sizeOf(u16);
- return @as([*]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(UsbWwidDevicePath)))[0..serial_len];
- }
- };
-
- comptime {
- std.debug.assert(10 == @sizeOf(UsbWwidDevicePath));
- std.debug.assert(1 == @alignOf(UsbWwidDevicePath));
-
- std.debug.assert(0 == @offsetOf(UsbWwidDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(UsbWwidDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(UsbWwidDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(UsbWwidDevicePath, "interface_number"));
- std.debug.assert(6 == @offsetOf(UsbWwidDevicePath, "device_vendor_id"));
- std.debug.assert(8 == @offsetOf(UsbWwidDevicePath, "device_product_id"));
- }
-
- pub const DeviceLogicalUnitDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- lun: u8,
- };
-
- comptime {
- std.debug.assert(5 == @sizeOf(DeviceLogicalUnitDevicePath));
- std.debug.assert(1 == @alignOf(DeviceLogicalUnitDevicePath));
-
- std.debug.assert(0 == @offsetOf(DeviceLogicalUnitDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(DeviceLogicalUnitDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(DeviceLogicalUnitDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(DeviceLogicalUnitDevicePath, "lun"));
- }
-
- pub const UsbClassDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- vendor_id: u16 align(1),
- product_id: u16 align(1),
- device_class: u8,
- device_subclass: u8,
- device_protocol: u8,
- };
-
- comptime {
- std.debug.assert(11 == @sizeOf(UsbClassDevicePath));
- std.debug.assert(1 == @alignOf(UsbClassDevicePath));
-
- std.debug.assert(0 == @offsetOf(UsbClassDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(UsbClassDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(UsbClassDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(UsbClassDevicePath, "vendor_id"));
- std.debug.assert(6 == @offsetOf(UsbClassDevicePath, "product_id"));
- std.debug.assert(8 == @offsetOf(UsbClassDevicePath, "device_class"));
- std.debug.assert(9 == @offsetOf(UsbClassDevicePath, "device_subclass"));
- std.debug.assert(10 == @offsetOf(UsbClassDevicePath, "device_protocol"));
- }
-
- pub const I2oDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- tid: u32 align(1),
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(I2oDevicePath));
- std.debug.assert(1 == @alignOf(I2oDevicePath));
-
- std.debug.assert(0 == @offsetOf(I2oDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(I2oDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(I2oDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(I2oDevicePath, "tid"));
- }
-
- pub const MacAddressDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- mac_address: uefi.MacAddress,
- if_type: u8,
- };
-
- comptime {
- std.debug.assert(37 == @sizeOf(MacAddressDevicePath));
- std.debug.assert(1 == @alignOf(MacAddressDevicePath));
-
- std.debug.assert(0 == @offsetOf(MacAddressDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(MacAddressDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(MacAddressDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(MacAddressDevicePath, "mac_address"));
- std.debug.assert(36 == @offsetOf(MacAddressDevicePath, "if_type"));
- }
-
- pub const Ipv4DevicePath = extern struct {
- pub const IpType = enum(u8) {
- Dhcp = 0,
- Static = 1,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- local_ip_address: uefi.Ipv4Address align(1),
- remote_ip_address: uefi.Ipv4Address align(1),
- local_port: u16 align(1),
- remote_port: u16 align(1),
- network_protocol: u16 align(1),
- static_ip_address: IpType,
- gateway_ip_address: u32 align(1),
- subnet_mask: u32 align(1),
- };
-
- comptime {
- std.debug.assert(27 == @sizeOf(Ipv4DevicePath));
- std.debug.assert(1 == @alignOf(Ipv4DevicePath));
-
- std.debug.assert(0 == @offsetOf(Ipv4DevicePath, "type"));
- std.debug.assert(1 == @offsetOf(Ipv4DevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(Ipv4DevicePath, "length"));
- std.debug.assert(4 == @offsetOf(Ipv4DevicePath, "local_ip_address"));
- std.debug.assert(8 == @offsetOf(Ipv4DevicePath, "remote_ip_address"));
- std.debug.assert(12 == @offsetOf(Ipv4DevicePath, "local_port"));
- std.debug.assert(14 == @offsetOf(Ipv4DevicePath, "remote_port"));
- std.debug.assert(16 == @offsetOf(Ipv4DevicePath, "network_protocol"));
- std.debug.assert(18 == @offsetOf(Ipv4DevicePath, "static_ip_address"));
- std.debug.assert(19 == @offsetOf(Ipv4DevicePath, "gateway_ip_address"));
- std.debug.assert(23 == @offsetOf(Ipv4DevicePath, "subnet_mask"));
- }
-
- pub const Ipv6DevicePath = extern struct {
- pub const Origin = enum(u8) {
- Manual = 0,
- AssignedStateless = 1,
- AssignedStateful = 2,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- local_ip_address: uefi.Ipv6Address,
- remote_ip_address: uefi.Ipv6Address,
- local_port: u16 align(1),
- remote_port: u16 align(1),
- protocol: u16 align(1),
- ip_address_origin: Origin,
- prefix_length: u8,
- gateway_ip_address: uefi.Ipv6Address,
- };
-
- comptime {
- std.debug.assert(60 == @sizeOf(Ipv6DevicePath));
- std.debug.assert(1 == @alignOf(Ipv6DevicePath));
-
- std.debug.assert(0 == @offsetOf(Ipv6DevicePath, "type"));
- std.debug.assert(1 == @offsetOf(Ipv6DevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(Ipv6DevicePath, "length"));
- std.debug.assert(4 == @offsetOf(Ipv6DevicePath, "local_ip_address"));
- std.debug.assert(20 == @offsetOf(Ipv6DevicePath, "remote_ip_address"));
- std.debug.assert(36 == @offsetOf(Ipv6DevicePath, "local_port"));
- std.debug.assert(38 == @offsetOf(Ipv6DevicePath, "remote_port"));
- std.debug.assert(40 == @offsetOf(Ipv6DevicePath, "protocol"));
- std.debug.assert(42 == @offsetOf(Ipv6DevicePath, "ip_address_origin"));
- std.debug.assert(43 == @offsetOf(Ipv6DevicePath, "prefix_length"));
- std.debug.assert(44 == @offsetOf(Ipv6DevicePath, "gateway_ip_address"));
- }
-
- pub const VlanDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- vlan_id: u16 align(1),
- };
-
- comptime {
- std.debug.assert(6 == @sizeOf(VlanDevicePath));
- std.debug.assert(1 == @alignOf(VlanDevicePath));
-
- std.debug.assert(0 == @offsetOf(VlanDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(VlanDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(VlanDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(VlanDevicePath, "vlan_id"));
- }
-
- pub const InfiniBandDevicePath = extern struct {
- pub const ResourceFlags = packed struct(u32) {
- pub const ControllerType = enum(u1) {
- Ioc = 0,
- Service = 1,
- };
-
- ioc_or_service: ControllerType,
- extend_boot_environment: bool,
- console_protocol: bool,
- storage_protocol: bool,
- network_protocol: bool,
-
- // u1 + 4 * bool = 5 bits, we need a total of 32 bits
- reserved: u27,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- resource_flags: ResourceFlags align(1),
- port_gid: [16]u8,
- service_id: u64 align(1),
- target_port_id: u64 align(1),
- device_id: u64 align(1),
- };
-
- comptime {
- std.debug.assert(48 == @sizeOf(InfiniBandDevicePath));
- std.debug.assert(1 == @alignOf(InfiniBandDevicePath));
-
- std.debug.assert(0 == @offsetOf(InfiniBandDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(InfiniBandDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(InfiniBandDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(InfiniBandDevicePath, "resource_flags"));
- std.debug.assert(8 == @offsetOf(InfiniBandDevicePath, "port_gid"));
- std.debug.assert(24 == @offsetOf(InfiniBandDevicePath, "service_id"));
- std.debug.assert(32 == @offsetOf(InfiniBandDevicePath, "target_port_id"));
- std.debug.assert(40 == @offsetOf(InfiniBandDevicePath, "device_id"));
- }
-
- pub const UartDevicePath = extern struct {
- pub const Parity = enum(u8) {
- Default = 0,
- None = 1,
- Even = 2,
- Odd = 3,
- Mark = 4,
- Space = 5,
- _,
- };
-
- pub const StopBits = enum(u8) {
- Default = 0,
- One = 1,
- OneAndAHalf = 2,
- Two = 3,
- _,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- reserved: u32 align(1),
- baud_rate: u64 align(1),
- data_bits: u8,
- parity: Parity,
- stop_bits: StopBits,
- };
-
- comptime {
- std.debug.assert(19 == @sizeOf(UartDevicePath));
- std.debug.assert(1 == @alignOf(UartDevicePath));
-
- std.debug.assert(0 == @offsetOf(UartDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(UartDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(UartDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(UartDevicePath, "reserved"));
- std.debug.assert(8 == @offsetOf(UartDevicePath, "baud_rate"));
- std.debug.assert(16 == @offsetOf(UartDevicePath, "data_bits"));
- std.debug.assert(17 == @offsetOf(UartDevicePath, "parity"));
- std.debug.assert(18 == @offsetOf(UartDevicePath, "stop_bits"));
- }
-
- pub const VendorDefinedDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- vendor_guid: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(VendorDefinedDevicePath));
- std.debug.assert(1 == @alignOf(VendorDefinedDevicePath));
-
- std.debug.assert(0 == @offsetOf(VendorDefinedDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(VendorDefinedDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(VendorDefinedDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(VendorDefinedDevicePath, "vendor_guid"));
- }
-};
-
-pub const MediaDevicePath = union(Subtype) {
- HardDrive: *const HardDriveDevicePath,
- Cdrom: *const CdromDevicePath,
- Vendor: *const VendorDevicePath,
- FilePath: *const FilePathDevicePath,
- MediaProtocol: *const MediaProtocolDevicePath,
- PiwgFirmwareFile: *const PiwgFirmwareFileDevicePath,
- PiwgFirmwareVolume: *const PiwgFirmwareVolumeDevicePath,
- RelativeOffsetRange: *const RelativeOffsetRangeDevicePath,
- RamDisk: *const RamDiskDevicePath,
-
- pub const Subtype = enum(u8) {
- HardDrive = 1,
- Cdrom = 2,
- Vendor = 3,
- FilePath = 4,
- MediaProtocol = 5,
- PiwgFirmwareFile = 6,
- PiwgFirmwareVolume = 7,
- RelativeOffsetRange = 8,
- RamDisk = 9,
- _,
- };
-
- pub const HardDriveDevicePath = extern struct {
- pub const Format = enum(u8) {
- LegacyMbr = 0x01,
- GuidPartitionTable = 0x02,
- };
-
- pub const SignatureType = enum(u8) {
- NoSignature = 0x00,
- /// "32-bit signature from address 0x1b8 of the type 0x01 MBR"
- MbrSignature = 0x01,
- GuidSignature = 0x02,
- };
-
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- partition_number: u32 align(1),
- partition_start: u64 align(1),
- partition_size: u64 align(1),
- partition_signature: [16]u8,
- partition_format: Format,
- signature_type: SignatureType,
- };
-
- comptime {
- std.debug.assert(42 == @sizeOf(HardDriveDevicePath));
- std.debug.assert(1 == @alignOf(HardDriveDevicePath));
-
- std.debug.assert(0 == @offsetOf(HardDriveDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(HardDriveDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(HardDriveDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(HardDriveDevicePath, "partition_number"));
- std.debug.assert(8 == @offsetOf(HardDriveDevicePath, "partition_start"));
- std.debug.assert(16 == @offsetOf(HardDriveDevicePath, "partition_size"));
- std.debug.assert(24 == @offsetOf(HardDriveDevicePath, "partition_signature"));
- std.debug.assert(40 == @offsetOf(HardDriveDevicePath, "partition_format"));
- std.debug.assert(41 == @offsetOf(HardDriveDevicePath, "signature_type"));
- }
-
- pub const CdromDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- boot_entry: u32 align(1),
- partition_start: u64 align(1),
- partition_size: u64 align(1),
- };
-
- comptime {
- std.debug.assert(24 == @sizeOf(CdromDevicePath));
- std.debug.assert(1 == @alignOf(CdromDevicePath));
-
- std.debug.assert(0 == @offsetOf(CdromDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(CdromDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(CdromDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(CdromDevicePath, "boot_entry"));
- std.debug.assert(8 == @offsetOf(CdromDevicePath, "partition_start"));
- std.debug.assert(16 == @offsetOf(CdromDevicePath, "partition_size"));
- }
-
- pub const VendorDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- guid: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(VendorDevicePath));
- std.debug.assert(1 == @alignOf(VendorDevicePath));
-
- std.debug.assert(0 == @offsetOf(VendorDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(VendorDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(VendorDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(VendorDevicePath, "guid"));
- }
-
- pub const FilePathDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
-
- pub fn getPath(self: *const FilePathDevicePath) [*:0]align(1) const u16 {
- return @as([*:0]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FilePathDevicePath)));
- }
- };
-
- comptime {
- std.debug.assert(4 == @sizeOf(FilePathDevicePath));
- std.debug.assert(1 == @alignOf(FilePathDevicePath));
-
- std.debug.assert(0 == @offsetOf(FilePathDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(FilePathDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(FilePathDevicePath, "length"));
- }
-
- pub const MediaProtocolDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- guid: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(MediaProtocolDevicePath));
- std.debug.assert(1 == @alignOf(MediaProtocolDevicePath));
-
- std.debug.assert(0 == @offsetOf(MediaProtocolDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(MediaProtocolDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(MediaProtocolDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(MediaProtocolDevicePath, "guid"));
- }
-
- pub const PiwgFirmwareFileDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- fv_filename: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(PiwgFirmwareFileDevicePath));
- std.debug.assert(1 == @alignOf(PiwgFirmwareFileDevicePath));
-
- std.debug.assert(0 == @offsetOf(PiwgFirmwareFileDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(PiwgFirmwareFileDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(PiwgFirmwareFileDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(PiwgFirmwareFileDevicePath, "fv_filename"));
- }
-
- pub const PiwgFirmwareVolumeDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- fv_name: Guid align(1),
- };
-
- comptime {
- std.debug.assert(20 == @sizeOf(PiwgFirmwareVolumeDevicePath));
- std.debug.assert(1 == @alignOf(PiwgFirmwareVolumeDevicePath));
-
- std.debug.assert(0 == @offsetOf(PiwgFirmwareVolumeDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(PiwgFirmwareVolumeDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(PiwgFirmwareVolumeDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(PiwgFirmwareVolumeDevicePath, "fv_name"));
- }
-
- pub const RelativeOffsetRangeDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- reserved: u32 align(1),
- start: u64 align(1),
- end: u64 align(1),
- };
-
- comptime {
- std.debug.assert(24 == @sizeOf(RelativeOffsetRangeDevicePath));
- std.debug.assert(1 == @alignOf(RelativeOffsetRangeDevicePath));
-
- std.debug.assert(0 == @offsetOf(RelativeOffsetRangeDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(RelativeOffsetRangeDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(RelativeOffsetRangeDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(RelativeOffsetRangeDevicePath, "reserved"));
- std.debug.assert(8 == @offsetOf(RelativeOffsetRangeDevicePath, "start"));
- std.debug.assert(16 == @offsetOf(RelativeOffsetRangeDevicePath, "end"));
- }
-
- pub const RamDiskDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- start: u64 align(1),
- end: u64 align(1),
- disk_type: Guid align(1),
- instance: u16 align(1),
- };
-
- comptime {
- std.debug.assert(38 == @sizeOf(RamDiskDevicePath));
- std.debug.assert(1 == @alignOf(RamDiskDevicePath));
-
- std.debug.assert(0 == @offsetOf(RamDiskDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(RamDiskDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(RamDiskDevicePath, "length"));
- std.debug.assert(4 == @offsetOf(RamDiskDevicePath, "start"));
- std.debug.assert(12 == @offsetOf(RamDiskDevicePath, "end"));
- std.debug.assert(20 == @offsetOf(RamDiskDevicePath, "disk_type"));
- std.debug.assert(36 == @offsetOf(RamDiskDevicePath, "instance"));
- }
-};
-
-pub const BiosBootSpecificationDevicePath = union(Subtype) {
- BBS101: *const BBS101DevicePath,
-
- pub const Subtype = enum(u8) {
- BBS101 = 1,
- _,
- };
-
- pub const BBS101DevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- device_type: u16 align(1),
- status_flag: u16 align(1),
-
- pub fn getDescription(self: *const BBS101DevicePath) [*:0]const u8 {
- return @as([*:0]const u8, @ptrCast(self)) + @sizeOf(BBS101DevicePath);
- }
- };
-
- comptime {
- std.debug.assert(8 == @sizeOf(BBS101DevicePath));
- std.debug.assert(1 == @alignOf(BBS101DevicePath));
-
- std.debug.assert(0 == @offsetOf(BBS101DevicePath, "type"));
- std.debug.assert(1 == @offsetOf(BBS101DevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(BBS101DevicePath, "length"));
- std.debug.assert(4 == @offsetOf(BBS101DevicePath, "device_type"));
- std.debug.assert(6 == @offsetOf(BBS101DevicePath, "status_flag"));
- }
-};
-
-pub const EndDevicePath = union(Subtype) {
- EndEntire: *const EndEntireDevicePath,
- EndThisInstance: *const EndThisInstanceDevicePath,
-
- pub const Subtype = enum(u8) {
- EndEntire = 0xff,
- EndThisInstance = 0x01,
- _,
- };
-
- pub const EndEntireDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- };
-
- comptime {
- std.debug.assert(4 == @sizeOf(EndEntireDevicePath));
- std.debug.assert(1 == @alignOf(EndEntireDevicePath));
-
- std.debug.assert(0 == @offsetOf(EndEntireDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(EndEntireDevicePath, "length"));
- }
-
- pub const EndThisInstanceDevicePath = extern struct {
- type: DevicePathType,
- subtype: Subtype,
- length: u16 align(1),
- };
-
- comptime {
- std.debug.assert(4 == @sizeOf(EndEntireDevicePath));
- std.debug.assert(1 == @alignOf(EndEntireDevicePath));
-
- std.debug.assert(0 == @offsetOf(EndEntireDevicePath, "type"));
- std.debug.assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
- std.debug.assert(2 == @offsetOf(EndEntireDevicePath, "length"));
- }
-};
lib/std/os/uefi/protocols/edid_active_protocol.zig
@@ -1,17 +0,0 @@
-const uefi = @import("std").os.uefi;
-const Guid = uefi.Guid;
-
-/// EDID information for an active video output device
-pub const EdidActiveProtocol = extern struct {
- size_of_edid: u32,
- edid: ?[*]u8,
-
- pub const guid align(8) = Guid{
- .time_low = 0xbd8c1056,
- .time_mid = 0x9f36,
- .time_high_and_version = 0x44ec,
- .clock_seq_high_and_reserved = 0x92,
- .clock_seq_low = 0xa8,
- .node = [_]u8{ 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 },
- };
-};
lib/std/os/uefi/protocols/edid_discovered_protocol.zig
@@ -1,17 +0,0 @@
-const uefi = @import("std").os.uefi;
-const Guid = uefi.Guid;
-
-/// EDID information for a video output device
-pub const EdidDiscoveredProtocol = extern struct {
- size_of_edid: u32,
- edid: ?[*]u8,
-
- pub const guid align(8) = Guid{
- .time_low = 0x1c0c34f6,
- .time_mid = 0xd380,
- .time_high_and_version = 0x41fa,
- .clock_seq_high_and_reserved = 0xa0,
- .clock_seq_low = 0x49,
- .node = [_]u8{ 0x8a, 0xd0, 0x6c, 0x1a, 0x66, 0xaa },
- };
-};
lib/std/os/uefi/protocols/edid_override_protocol.zig
@@ -1,37 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Handle = uefi.Handle;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-/// Override EDID information
-pub const EdidOverrideProtocol = extern struct {
- _get_edid: *const fn (*const EdidOverrideProtocol, Handle, *EdidOverrideProtocolAttributes, *usize, *?[*]u8) callconv(cc) Status,
-
- /// Returns policy information and potentially a replacement EDID for the specified video output device.
- pub fn getEdid(
- self: *const EdidOverrideProtocol,
- handle: Handle,
- attributes: *EdidOverrideProtocolAttributes,
- edid_size: *usize,
- edid: *?[*]u8,
- ) Status {
- return self._get_edid(self, handle, attributes, edid_size, edid);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x48ecb431,
- .time_mid = 0xfb72,
- .time_high_and_version = 0x45c0,
- .clock_seq_high_and_reserved = 0xa9,
- .clock_seq_low = 0x22,
- .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },
- };
-};
-
-pub const EdidOverrideProtocolAttributes = packed struct(u32) {
- dont_override: bool,
- enable_hot_plug: bool,
- _pad: u30 = 0,
-};
lib/std/os/uefi/protocols/file_protocol.zig
@@ -1,197 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const io = std.io;
-const Guid = uefi.Guid;
-const Time = uefi.Time;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-pub const FileProtocol = extern struct {
- revision: u64,
- _open: *const fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(cc) Status,
- _close: *const fn (*const FileProtocol) callconv(cc) Status,
- _delete: *const fn (*const FileProtocol) callconv(cc) Status,
- _read: *const fn (*const FileProtocol, *usize, [*]u8) callconv(cc) Status,
- _write: *const fn (*const FileProtocol, *usize, [*]const u8) callconv(cc) Status,
- _get_position: *const fn (*const FileProtocol, *u64) callconv(cc) Status,
- _set_position: *const fn (*const FileProtocol, u64) callconv(cc) Status,
- _get_info: *const fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(cc) Status,
- _set_info: *const fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(cc) Status,
- _flush: *const fn (*const FileProtocol) callconv(cc) Status,
-
- pub const SeekError = error{SeekError};
- pub const GetSeekPosError = error{GetSeekPosError};
- pub const ReadError = error{ReadError};
- pub const WriteError = error{WriteError};
-
- pub const SeekableStream = io.SeekableStream(*const FileProtocol, SeekError, GetSeekPosError, seekTo, seekBy, getPos, getEndPos);
- pub const Reader = io.Reader(*const FileProtocol, ReadError, readFn);
- pub const Writer = io.Writer(*const FileProtocol, WriteError, writeFn);
-
- pub fn seekableStream(self: *FileProtocol) SeekableStream {
- return .{ .context = self };
- }
-
- pub fn reader(self: *FileProtocol) Reader {
- return .{ .context = self };
- }
-
- pub fn writer(self: *FileProtocol) Writer {
- return .{ .context = self };
- }
-
- pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {
- return self._open(self, new_handle, file_name, open_mode, attributes);
- }
-
- pub fn close(self: *const FileProtocol) Status {
- return self._close(self);
- }
-
- pub fn delete(self: *const FileProtocol) Status {
- return self._delete(self);
- }
-
- pub fn read(self: *const FileProtocol, buffer_size: *usize, buffer: [*]u8) Status {
- return self._read(self, buffer_size, buffer);
- }
-
- fn readFn(self: *const FileProtocol, buffer: []u8) ReadError!usize {
- var size: usize = buffer.len;
- if (.Success != self.read(&size, buffer.ptr)) return ReadError.ReadError;
- return size;
- }
-
- pub fn write(self: *const FileProtocol, buffer_size: *usize, buffer: [*]const u8) Status {
- return self._write(self, buffer_size, buffer);
- }
-
- fn writeFn(self: *const FileProtocol, bytes: []const u8) WriteError!usize {
- var size: usize = bytes.len;
- if (.Success != self.write(&size, bytes.ptr)) return WriteError.WriteError;
- return size;
- }
-
- pub fn getPosition(self: *const FileProtocol, position: *u64) Status {
- return self._get_position(self, position);
- }
-
- fn getPos(self: *const FileProtocol) GetSeekPosError!u64 {
- var pos: u64 = undefined;
- if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
- return pos;
- }
-
- fn getEndPos(self: *const FileProtocol) GetSeekPosError!u64 {
- // preserve the old file position
- var pos: u64 = undefined;
- if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
- // seek to end of file to get position = file size
- if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError;
- // restore the old position
- if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError;
- // return the file size = position
- return pos;
- }
-
- pub fn setPosition(self: *const FileProtocol, position: u64) Status {
- return self._set_position(self, position);
- }
-
- fn seekTo(self: *const FileProtocol, pos: u64) SeekError!void {
- if (.Success != self.setPosition(pos)) return SeekError.SeekError;
- }
-
- fn seekBy(self: *const FileProtocol, offset: i64) SeekError!void {
- // save the old position and calculate the delta
- var pos: u64 = undefined;
- if (.Success != self.getPosition(&pos)) return SeekError.SeekError;
- const seek_back = offset < 0;
- const amt = std.math.absCast(offset);
- if (seek_back) {
- pos += amt;
- } else {
- pos -= amt;
- }
- if (.Success != self.setPosition(pos)) return SeekError.SeekError;
- }
-
- pub fn getInfo(self: *const FileProtocol, information_type: *align(8) const Guid, buffer_size: *usize, buffer: [*]u8) Status {
- return self._get_info(self, information_type, buffer_size, buffer);
- }
-
- pub fn setInfo(self: *const FileProtocol, information_type: *align(8) const Guid, buffer_size: usize, buffer: [*]const u8) Status {
- return self._set_info(self, information_type, buffer_size, buffer);
- }
-
- pub fn flush(self: *const FileProtocol) Status {
- return self._flush(self);
- }
-
- pub const efi_file_mode_read: u64 = 0x0000000000000001;
- pub const efi_file_mode_write: u64 = 0x0000000000000002;
- pub const efi_file_mode_create: u64 = 0x8000000000000000;
-
- pub const efi_file_read_only: u64 = 0x0000000000000001;
- pub const efi_file_hidden: u64 = 0x0000000000000002;
- pub const efi_file_system: u64 = 0x0000000000000004;
- pub const efi_file_reserved: u64 = 0x0000000000000008;
- pub const efi_file_directory: u64 = 0x0000000000000010;
- pub const efi_file_archive: u64 = 0x0000000000000020;
- pub const efi_file_valid_attr: u64 = 0x0000000000000037;
-
- pub const efi_file_position_end_of_file: u64 = 0xffffffffffffffff;
-};
-
-pub const FileInfo = extern struct {
- size: u64,
- file_size: u64,
- physical_size: u64,
- create_time: Time,
- last_access_time: Time,
- modification_time: Time,
- attribute: u64,
-
- pub fn getFileName(self: *const FileInfo) [*:0]const u16 {
- return @ptrCast(@alignCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FileInfo)));
- }
-
- pub const efi_file_read_only: u64 = 0x0000000000000001;
- pub const efi_file_hidden: u64 = 0x0000000000000002;
- pub const efi_file_system: u64 = 0x0000000000000004;
- pub const efi_file_reserved: u64 = 0x0000000000000008;
- pub const efi_file_directory: u64 = 0x0000000000000010;
- pub const efi_file_archive: u64 = 0x0000000000000020;
- pub const efi_file_valid_attr: u64 = 0x0000000000000037;
-
- pub const guid align(8) = Guid{
- .time_low = 0x09576e92,
- .time_mid = 0x6d3f,
- .time_high_and_version = 0x11d2,
- .clock_seq_high_and_reserved = 0x8e,
- .clock_seq_low = 0x39,
- .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
- };
-};
-
-pub const FileSystemInfo = extern struct {
- size: u64,
- read_only: bool,
- volume_size: u64,
- free_space: u64,
- block_size: u32,
- _volume_label: u16,
-
- pub fn getVolumeLabel(self: *const FileSystemInfo) [*:0]const u16 {
- return @as([*:0]const u16, @ptrCast(&self._volume_label));
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x09576e93,
- .time_mid = 0x6d3f,
- .time_high_and_version = 0x11d2,
- .clock_seq_high_and_reserved = 0x8e,
- .clock_seq_low = 0x39,
- .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
- };
-};
lib/std/os/uefi/protocols/graphics_output_protocol.zig
@@ -1,85 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-/// Graphics output
-pub const GraphicsOutputProtocol = extern struct {
- _query_mode: *const fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(cc) Status,
- _set_mode: *const fn (*const GraphicsOutputProtocol, u32) callconv(cc) Status,
- _blt: *const fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(cc) Status,
- mode: *GraphicsOutputProtocolMode,
-
- /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
- pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) Status {
- return self._query_mode(self, mode, size_of_info, info);
- }
-
- /// Set the video device into the specified mode and clears the visible portions of the output display to black.
- pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) Status {
- return self._set_mode(self, mode);
- }
-
- /// Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
- pub fn blt(self: *const GraphicsOutputProtocol, blt_buffer: ?[*]GraphicsOutputBltPixel, blt_operation: GraphicsOutputBltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) Status {
- return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x9042a9de,
- .time_mid = 0x23dc,
- .time_high_and_version = 0x4a38,
- .clock_seq_high_and_reserved = 0x96,
- .clock_seq_low = 0xfb,
- .node = [_]u8{ 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a },
- };
-};
-
-pub const GraphicsOutputProtocolMode = extern struct {
- max_mode: u32,
- mode: u32,
- info: *GraphicsOutputModeInformation,
- size_of_info: usize,
- frame_buffer_base: u64,
- frame_buffer_size: usize,
-};
-
-pub const GraphicsOutputModeInformation = extern struct {
- version: u32 = undefined,
- horizontal_resolution: u32 = undefined,
- vertical_resolution: u32 = undefined,
- pixel_format: GraphicsPixelFormat = undefined,
- pixel_information: PixelBitmask = undefined,
- pixels_per_scan_line: u32 = undefined,
-};
-
-pub const GraphicsPixelFormat = enum(u32) {
- PixelRedGreenBlueReserved8BitPerColor,
- PixelBlueGreenRedReserved8BitPerColor,
- PixelBitMask,
- PixelBltOnly,
- PixelFormatMax,
-};
-
-pub const PixelBitmask = extern struct {
- red_mask: u32,
- green_mask: u32,
- blue_mask: u32,
- reserved_mask: u32,
-};
-
-pub const GraphicsOutputBltPixel = extern struct {
- blue: u8,
- green: u8,
- red: u8,
- reserved: u8 = undefined,
-};
-
-pub const GraphicsOutputBltOperation = enum(u32) {
- BltVideoFill,
- BltVideoToBltBuffer,
- BltBufferToVideo,
- BltVideoToVideo,
- GraphicsOutputBltOperationMax,
-};
lib/std/os/uefi/protocols/hii_popup_protocol.zig
@@ -1,46 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const hii = uefi.protocols.hii;
-const cc = uefi.cc;
-
-/// Display a popup window
-pub const HIIPopupProtocol = extern struct {
- revision: u64,
- _create_popup: *const fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) callconv(cc) Status,
-
- /// Displays a popup window.
- pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status {
- return self._create_popup(self, style, popup_type, handle, msg, user_selection);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x4311edc0,
- .time_mid = 0x6054,
- .time_high_and_version = 0x46d4,
- .clock_seq_high_and_reserved = 0x9e,
- .clock_seq_low = 0x40,
- .node = [_]u8{ 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc },
- };
-};
-
-pub const HIIPopupStyle = enum(u32) {
- Info,
- Warning,
- Error,
-};
-
-pub const HIIPopupType = enum(u32) {
- Ok,
- Cancel,
- YesNo,
- YesNoCancel,
-};
-
-pub const HIIPopupSelection = enum(u32) {
- Ok,
- Cancel,
- Yes,
- No,
-};
lib/std/os/uefi/protocols/ip6_config_protocol.zig
@@ -1,48 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Event = uefi.Event;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-pub const Ip6ConfigProtocol = extern struct {
- _set_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const anyopaque) callconv(cc) Status,
- _get_data: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const anyopaque) callconv(cc) Status,
- _register_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(cc) Status,
- _unregister_data_notify: *const fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(cc) Status,
-
- pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const anyopaque) Status {
- return self._set_data(self, data_type, data_size, data);
- }
-
- pub fn getData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: *usize, data: ?*const anyopaque) Status {
- return self._get_data(self, data_type, data_size, data);
- }
-
- pub fn registerDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) Status {
- return self._register_data_notify(self, data_type, event);
- }
-
- pub fn unregisterDataNotify(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, event: Event) Status {
- return self._unregister_data_notify(self, data_type, event);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x937fe521,
- .time_mid = 0x95ae,
- .time_high_and_version = 0x4d1a,
- .clock_seq_high_and_reserved = 0x89,
- .clock_seq_low = 0x29,
- .node = [_]u8{ 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a },
- };
-};
-
-pub const Ip6ConfigDataType = enum(u32) {
- InterfaceInfo,
- AltInterfaceId,
- Policy,
- DupAddrDetectTransmits,
- ManualAddress,
- Gateway,
- DnsServer,
-};
lib/std/os/uefi/protocols/ip6_protocol.zig
@@ -1,146 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Event = uefi.Event;
-const Status = uefi.Status;
-const MacAddress = uefi.protocols.MacAddress;
-const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
-const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
-const cc = uefi.cc;
-
-pub const Ip6Protocol = extern struct {
- _get_mode_data: *const fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
- _configure: *const fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(cc) Status,
- _groups: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(cc) Status,
- _routes: *const fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(cc) Status,
- _neighbors: *const fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(cc) Status,
- _transmit: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(cc) Status,
- _receive: *const fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(cc) Status,
- _cancel: *const fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(cc) Status,
- _poll: *const fn (*const Ip6Protocol) callconv(cc) Status,
-
- /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
- pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
- return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);
- }
-
- /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
- pub fn configure(self: *const Ip6Protocol, ip6_config_data: ?*const Ip6ConfigData) Status {
- return self._configure(self, ip6_config_data);
- }
-
- /// Joins and leaves multicast groups.
- pub fn groups(self: *const Ip6Protocol, join_flag: bool, group_address: ?*const Ip6Address) Status {
- return self._groups(self, join_flag, group_address);
- }
-
- /// Adds and deletes routing table entries.
- pub fn routes(self: *const Ip6Protocol, delete_route: bool, destination: ?*const Ip6Address, prefix_length: u8, gateway_address: ?*const Ip6Address) Status {
- return self._routes(self, delete_route, destination, prefix_length, gateway_address);
- }
-
- /// Add or delete Neighbor cache entries.
- pub fn neighbors(self: *const Ip6Protocol, delete_flag: bool, target_ip6_address: *const Ip6Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) Status {
- return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);
- }
-
- /// Places outgoing data packets into the transmit queue.
- pub fn transmit(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
- return self._transmit(self, token);
- }
-
- /// Places a receiving request into the receiving queue.
- pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
- return self._receive(self, token);
- }
-
- /// Abort an asynchronous transmits or receive request.
- pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) Status {
- return self._cancel(self, token);
- }
-
- /// Polls for incoming data packets and processes outgoing data packets.
- pub fn poll(self: *const Ip6Protocol) Status {
- return self._poll(self);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x2c8759d5,
- .time_mid = 0x5c2d,
- .time_high_and_version = 0x66ef,
- .clock_seq_high_and_reserved = 0x92,
- .clock_seq_low = 0x5f,
- .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },
- };
-};
-
-pub const Ip6ModeData = extern struct {
- is_started: bool,
- max_packet_size: u32,
- config_data: Ip6ConfigData,
- is_configured: bool,
- address_count: u32,
- address_list: [*]Ip6AddressInfo,
- group_count: u32,
- group_table: [*]Ip6Address,
- route_count: u32,
- route_table: [*]Ip6RouteTable,
- neighbor_count: u32,
- neighbor_cache: [*]Ip6NeighborCache,
- prefix_count: u32,
- prefix_table: [*]Ip6AddressInfo,
- icmp_type_count: u32,
- icmp_type_list: [*]Ip6IcmpType,
-};
-
-pub const Ip6ConfigData = extern struct {
- default_protocol: u8,
- accept_any_protocol: bool,
- accept_icmp_errors: bool,
- accept_promiscuous: bool,
- destination_address: Ip6Address,
- station_address: Ip6Address,
- traffic_class: u8,
- hop_limit: u8,
- flow_label: u32,
- receive_timeout: u32,
- transmit_timeout: u32,
-};
-
-pub const Ip6Address = [16]u8;
-
-pub const Ip6AddressInfo = extern struct {
- address: Ip6Address,
- prefix_length: u8,
-};
-
-pub const Ip6RouteTable = extern struct {
- gateway: Ip6Address,
- destination: Ip6Address,
- prefix_length: u8,
-};
-
-pub const Ip6NeighborState = enum(u32) {
- Incomplete,
- Reachable,
- Stale,
- Delay,
- Probe,
-};
-
-pub const Ip6NeighborCache = extern struct {
- neighbor: Ip6Address,
- link_address: MacAddress,
- state: Ip6NeighborState,
-};
-
-pub const Ip6IcmpType = extern struct {
- type: u8,
- code: u8,
-};
-
-pub const Ip6CompletionToken = extern struct {
- event: Event,
- status: Status,
- packet: *anyopaque, // union TODO
-};
lib/std/os/uefi/protocols/managed_network_protocol.zig
@@ -1,129 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Event = uefi.Event;
-const Status = uefi.Status;
-const Time = uefi.Time;
-const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
-const MacAddress = uefi.protocols.MacAddress;
-const cc = uefi.cc;
-
-pub const ManagedNetworkProtocol = extern struct {
- _get_mode_data: *const fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
- _configure: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(cc) Status,
- _mcast_ip_to_mac: *const fn (*const ManagedNetworkProtocol, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
- _groups: *const fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(cc) Status,
- _transmit: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(cc) Status,
- _receive: *const fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(cc) Status,
- _cancel: *const fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(cc) Status,
- _poll: *const fn (*const ManagedNetworkProtocol) callconv(cc) Status,
-
- /// Returns the operational parameters for the current MNP child driver.
- /// May also support returning the underlying SNP driver mode data.
- pub fn getModeData(self: *const ManagedNetworkProtocol, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
- return self._get_mode_data(self, mnp_config_data, snp_mode_data);
- }
-
- /// Sets or clears the operational parameters for the MNP child driver.
- pub fn configure(self: *const ManagedNetworkProtocol, mnp_config_data: ?*const ManagedNetworkConfigData) Status {
- return self._configure(self, mnp_config_data);
- }
-
- /// Translates an IP multicast address to a hardware (MAC) multicast address.
- /// This function may be unsupported in some MNP implementations.
- pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const anyopaque, mac_address: *MacAddress) Status {
- return self._mcast_ip_to_mac(self, ipv6flag, ipaddress, mac_address);
- }
-
- /// Enables and disables receive filters for multicast address.
- /// This function may be unsupported in some MNP implementations.
- pub fn groups(self: *const ManagedNetworkProtocol, join_flag: bool, mac_address: ?*const MacAddress) Status {
- return self._groups(self, join_flag, mac_address);
- }
-
- /// Places asynchronous outgoing data packets into the transmit queue.
- pub fn transmit(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) Status {
- return self._transmit(self, token);
- }
-
- /// Places an asynchronous receiving request into the receiving queue.
- pub fn receive(self: *const ManagedNetworkProtocol, token: *const ManagedNetworkCompletionToken) Status {
- return self._receive(self, token);
- }
-
- /// Aborts an asynchronous transmit or receive request.
- pub fn cancel(self: *const ManagedNetworkProtocol, token: ?*const ManagedNetworkCompletionToken) Status {
- return self._cancel(self, token);
- }
-
- /// Polls for incoming data packets and processes outgoing data packets.
- pub fn poll(self: *const ManagedNetworkProtocol) Status {
- return self._poll(self);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x7ab33a91,
- .time_mid = 0xace5,
- .time_high_and_version = 0x4326,
- .clock_seq_high_and_reserved = 0xb5,
- .clock_seq_low = 0x72,
- .node = [_]u8{ 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 },
- };
-};
-
-pub const ManagedNetworkConfigData = extern struct {
- received_queue_timeout_value: u32,
- transmit_queue_timeout_value: u32,
- protocol_type_filter: u16,
- enable_unicast_receive: bool,
- enable_multicast_receive: bool,
- enable_broadcast_receive: bool,
- enable_promiscuous_receive: bool,
- flush_queues_on_reset: bool,
- enable_receive_timestamps: bool,
- disable_background_polling: bool,
-};
-
-pub const ManagedNetworkCompletionToken = extern struct {
- event: Event,
- status: Status,
- packet: extern union {
- RxData: *ManagedNetworkReceiveData,
- TxData: *ManagedNetworkTransmitData,
- },
-};
-
-pub const ManagedNetworkReceiveData = extern struct {
- timestamp: Time,
- recycle_event: Event,
- packet_length: u32,
- header_length: u32,
- address_length: u32,
- data_length: u32,
- broadcast_flag: bool,
- multicast_flag: bool,
- promiscuous_flag: bool,
- protocol_type: u16,
- destination_address: [*]u8,
- source_address: [*]u8,
- media_header: [*]u8,
- packet_data: [*]u8,
-};
-
-pub const ManagedNetworkTransmitData = extern struct {
- destination_address: ?*MacAddress,
- source_address: ?*MacAddress,
- protocol_type: u16,
- data_length: u32,
- header_length: u16,
- fragment_count: u16,
-
- pub fn getFragments(self: *ManagedNetworkTransmitData) []ManagedNetworkFragmentData {
- return @as([*]ManagedNetworkFragmentData, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(ManagedNetworkTransmitData))))[0..self.fragment_count];
- }
-};
-
-pub const ManagedNetworkFragmentData = extern struct {
- fragment_length: u32,
- fragment_buffer: [*]u8,
-};
lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig
@@ -1,28 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Handle = uefi.Handle;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-pub const ManagedNetworkServiceBindingProtocol = extern struct {
- _create_child: *const fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(cc) Status,
- _destroy_child: *const fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(cc) Status,
-
- pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {
- return self._create_child(self, handle);
- }
-
- pub fn destroyChild(self: *const ManagedNetworkServiceBindingProtocol, handle: Handle) Status {
- return self._destroy_child(self, handle);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0xf36ff770,
- .time_mid = 0xa7e1,
- .time_high_and_version = 0x42cf,
- .clock_seq_high_and_reserved = 0x9e,
- .clock_seq_low = 0xd2,
- .node = [_]u8{ 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c },
- };
-};
lib/std/os/uefi/protocols/simple_network_protocol.zig
@@ -1,175 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Event = uefi.Event;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-pub const SimpleNetworkProtocol = extern struct {
- revision: u64,
- _start: *const fn (*const SimpleNetworkProtocol) callconv(cc) Status,
- _stop: *const fn (*const SimpleNetworkProtocol) callconv(cc) Status,
- _initialize: *const fn (*const SimpleNetworkProtocol, usize, usize) callconv(cc) Status,
- _reset: *const fn (*const SimpleNetworkProtocol, bool) callconv(cc) Status,
- _shutdown: *const fn (*const SimpleNetworkProtocol) callconv(cc) Status,
- _receive_filters: *const fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(cc) Status,
- _station_address: *const fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) callconv(cc) Status,
- _statistics: *const fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) callconv(cc) Status,
- _mcast_ip_to_mac: *const fn (*const SimpleNetworkProtocol, bool, *const anyopaque, *MacAddress) callconv(cc) Status,
- _nvdata: *const fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) callconv(cc) Status,
- _get_status: *const fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) callconv(cc) Status,
- _transmit: *const fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(cc) Status,
- _receive: *const fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(cc) Status,
- wait_for_packet: Event,
- mode: *SimpleNetworkMode,
-
- /// Changes the state of a network interface from "stopped" to "started".
- pub fn start(self: *const SimpleNetworkProtocol) Status {
- return self._start(self);
- }
-
- /// Changes the state of a network interface from "started" to "stopped".
- pub fn stop(self: *const SimpleNetworkProtocol) Status {
- return self._stop(self);
- }
-
- /// Resets a network adapter and allocates the transmit and receive buffers required by the network interface.
- pub fn initialize(self: *const SimpleNetworkProtocol, extra_rx_buffer_size: usize, extra_tx_buffer_size: usize) Status {
- return self._initialize(self, extra_rx_buffer_size, extra_tx_buffer_size);
- }
-
- /// Resets a network adapter and reinitializes it with the parameters that were provided in the previous call to initialize().
- pub fn reset(self: *const SimpleNetworkProtocol, extended_verification: bool) Status {
- return self._reset(self, extended_verification);
- }
-
- /// Resets a network adapter and leaves it in a state that is safe for another driver to initialize.
- pub fn shutdown(self: *const SimpleNetworkProtocol) Status {
- return self._shutdown(self);
- }
-
- /// Manages the multicast receive filters of a network interface.
- pub fn receiveFilters(self: *const SimpleNetworkProtocol, enable: SimpleNetworkReceiveFilter, disable: SimpleNetworkReceiveFilter, reset_mcast_filter: bool, mcast_filter_cnt: usize, mcast_filter: ?[*]const MacAddress) Status {
- return self._receive_filters(self, enable, disable, reset_mcast_filter, mcast_filter_cnt, mcast_filter);
- }
-
- /// Modifies or resets the current station address, if supported.
- pub fn stationAddress(self: *const SimpleNetworkProtocol, reset_flag: bool, new: ?*const MacAddress) Status {
- return self._station_address(self, reset_flag, new);
- }
-
- /// Resets or collects the statistics on a network interface.
- pub fn statistics(self: *const SimpleNetworkProtocol, reset_flag: bool, statistics_size: ?*usize, statistics_table: ?*NetworkStatistics) Status {
- return self._statistics(self, reset_flag, statistics_size, statistics_table);
- }
-
- /// Converts a multicast IP address to a multicast HW MAC address.
- pub fn mcastIpToMac(self: *const SimpleNetworkProtocol, ipv6: bool, ip: *const anyopaque, mac: *MacAddress) Status {
- return self._mcast_ip_to_mac(self, ipv6, ip, mac);
- }
-
- /// Performs read and write operations on the NVRAM device attached to a network interface.
- pub fn nvdata(self: *const SimpleNetworkProtocol, read_write: bool, offset: usize, buffer_size: usize, buffer: [*]u8) Status {
- return self._nvdata(self, read_write, offset, buffer_size, buffer);
- }
-
- /// Reads the current interrupt status and recycled transmit buffer status from a network interface.
- pub fn getStatus(self: *const SimpleNetworkProtocol, interrupt_status: *SimpleNetworkInterruptStatus, tx_buf: ?*?[*]u8) Status {
- return self._get_status(self, interrupt_status, tx_buf);
- }
-
- /// Places a packet in the transmit queue of a network interface.
- pub fn transmit(self: *const SimpleNetworkProtocol, header_size: usize, buffer_size: usize, buffer: [*]const u8, src_addr: ?*const MacAddress, dest_addr: ?*const MacAddress, protocol: ?*const u16) Status {
- return self._transmit(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
- }
-
- /// Receives a packet from a network interface.
- pub fn receive(self: *const SimpleNetworkProtocol, header_size: ?*usize, buffer_size: *usize, buffer: [*]u8, src_addr: ?*MacAddress, dest_addr: ?*MacAddress, protocol: ?*u16) Status {
- return self._receive(self, header_size, buffer_size, buffer, src_addr, dest_addr, protocol);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0xa19832b9,
- .time_mid = 0xac25,
- .time_high_and_version = 0x11d3,
- .clock_seq_high_and_reserved = 0x9a,
- .clock_seq_low = 0x2d,
- .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
- };
-};
-
-pub const MacAddress = [32]u8;
-
-pub const SimpleNetworkMode = extern struct {
- state: SimpleNetworkState,
- hw_address_size: u32,
- media_header_size: u32,
- max_packet_size: u32,
- nvram_size: u32,
- nvram_access_size: u32,
- receive_filter_mask: SimpleNetworkReceiveFilter,
- receive_filter_setting: SimpleNetworkReceiveFilter,
- max_mcast_filter_count: u32,
- mcast_filter_count: u32,
- mcast_filter: [16]MacAddress,
- current_address: MacAddress,
- broadcast_address: MacAddress,
- permanent_address: MacAddress,
- if_type: u8,
- mac_address_changeable: bool,
- multiple_tx_supported: bool,
- media_present_supported: bool,
- media_present: bool,
-};
-
-pub const SimpleNetworkReceiveFilter = packed struct(u32) {
- receive_unicast: bool,
- receive_multicast: bool,
- receive_broadcast: bool,
- receive_promiscuous: bool,
- receive_promiscuous_multicast: bool,
- _pad: u27 = 0,
-};
-
-pub const SimpleNetworkState = enum(u32) {
- Stopped,
- Started,
- Initialized,
-};
-
-pub const NetworkStatistics = extern struct {
- rx_total_frames: u64,
- rx_good_frames: u64,
- rx_undersize_frames: u64,
- rx_oversize_frames: u64,
- rx_dropped_frames: u64,
- rx_unicast_frames: u64,
- rx_broadcast_frames: u64,
- rx_multicast_frames: u64,
- rx_crc_error_frames: u64,
- rx_total_bytes: u64,
- tx_total_frames: u64,
- tx_good_frames: u64,
- tx_undersize_frames: u64,
- tx_oversize_frames: u64,
- tx_dropped_frames: u64,
- tx_unicast_frames: u64,
- tx_broadcast_frames: u64,
- tx_multicast_frames: u64,
- tx_crc_error_frames: u64,
- tx_total_bytes: u64,
- collisions: u64,
- unsupported_protocol: u64,
- rx_duplicated_frames: u64,
- rx_decryptError_frames: u64,
- tx_error_frames: u64,
- tx_retry_frames: u64,
-};
-
-pub const SimpleNetworkInterruptStatus = packed struct(u32) {
- receive_interrupt: bool,
- transmit_interrupt: bool,
- command_interrupt: bool,
- software_interrupt: bool,
- _pad: u28 = 0,
-};
lib/std/os/uefi/protocols/simple_pointer_protocol.zig
@@ -1,49 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Event = uefi.Event;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-/// Protocol for mice
-pub const SimplePointerProtocol = struct {
- _reset: *const fn (*const SimplePointerProtocol, bool) callconv(cc) Status,
- _get_state: *const fn (*const SimplePointerProtocol, *SimplePointerState) callconv(cc) Status,
- wait_for_input: Event,
- mode: *SimplePointerMode,
-
- /// Resets the pointer device hardware.
- pub fn reset(self: *const SimplePointerProtocol, verify: bool) Status {
- return self._reset(self, verify);
- }
-
- /// Retrieves the current state of a pointer device.
- pub fn getState(self: *const SimplePointerProtocol, state: *SimplePointerState) Status {
- return self._get_state(self, state);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0x31878c87,
- .time_mid = 0x0b75,
- .time_high_and_version = 0x11d5,
- .clock_seq_high_and_reserved = 0x9a,
- .clock_seq_low = 0x4f,
- .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
- };
-};
-
-pub const SimplePointerMode = struct {
- resolution_x: u64,
- resolution_y: u64,
- resolution_z: u64,
- left_button: bool,
- right_button: bool,
-};
-
-pub const SimplePointerState = struct {
- relative_movement_x: i32 = undefined,
- relative_movement_y: i32 = undefined,
- relative_movement_z: i32 = undefined,
- left_button: bool = undefined,
- right_button: bool = undefined,
-};
lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig
@@ -1,89 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Event = uefi.Event;
-const Guid = uefi.Guid;
-const Status = uefi.Status;
-const cc = uefi.cc;
-
-/// Character input devices, e.g. Keyboard
-pub const SimpleTextInputExProtocol = extern struct {
- _reset: *const fn (*const SimpleTextInputExProtocol, bool) callconv(cc) Status,
- _read_key_stroke_ex: *const fn (*const SimpleTextInputExProtocol, *KeyData) callconv(cc) Status,
- wait_for_key_ex: Event,
- _set_state: *const fn (*const SimpleTextInputExProtocol, *const u8) callconv(cc) Status,
- _register_key_notify: *const fn (*const SimpleTextInputExProtocol, *const KeyData, *const fn (*const KeyData) callconv(cc) usize, **anyopaque) callconv(cc) Status,
- _unregister_key_notify: *const fn (*const SimpleTextInputExProtocol, *const anyopaque) callconv(cc) Status,
-
- /// Resets the input device hardware.
- pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {
- return self._reset(self, verify);
- }
-
- /// Reads the next keystroke from the input device.
- pub fn readKeyStrokeEx(self: *const SimpleTextInputExProtocol, key_data: *KeyData) Status {
- return self._read_key_stroke_ex(self, key_data);
- }
-
- /// Set certain state for the input device.
- pub fn setState(self: *const SimpleTextInputExProtocol, state: *const u8) Status {
- return self._set_state(self, state);
- }
-
- /// Register a notification function for a particular keystroke for the input device.
- pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: *const fn (*const KeyData) callconv(cc) usize, handle: **anyopaque) Status {
- return self._register_key_notify(self, key_data, notify, handle);
- }
-
- /// Remove the notification that was previously registered.
- pub fn unregisterKeyNotify(self: *const SimpleTextInputExProtocol, handle: *const anyopaque) Status {
- return self._unregister_key_notify(self, handle);
- }
-
- pub const guid align(8) = Guid{
- .time_low = 0xdd9e7534,
- .time_mid = 0x7762,
- .time_high_and_version = 0x4698,
- .clock_seq_high_and_reserved = 0x8c,
- .clock_seq_low = 0x14,
- .node = [_]u8{ 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa },
- };
-};
-
-pub const KeyData = extern struct {
- key: InputKey = undefined,
- key_state: KeyState = undefined,
-};
-
-pub const KeyShiftState = packed struct(u32) {
- right_shift_pressed: bool,
- left_shift_pressed: bool,
- right_control_pressed: bool,
- left_control_pressed: bool,
- right_alt_pressed: bool,
- left_alt_pressed: bool,
- right_logo_pressed: bool,
- left_logo_pressed: bool,
- menu_key_pressed: bool,
- sys_req_pressed: bool,
- _pad: u21 = 0,
- shift_state_valid: bool,
-};
-
-pub const KeyToggleState = packed struct(u8) {
- scroll_lock_active: bool,
- num_lock_active: bool,
- caps_lock_active: bool,
- _pad: u3 = 0,
- key_state_exposed: bool,
- toggle_state_valid: bool,
-};
-
-pub const KeyState = extern struct {
- key_shift_state: KeyShiftState,
- key_toggle_state: KeyToggleState,
-};
-
-pub const InputKey = extern struct {
- scan_code: u16,
- unicode_char: u16,
-};
lib/std/os/uefi/protocols/udp6_protocol.zig
@@ -1,115 +0,0 @@
-const std = @import("std");
-const uefi = std.os.uefi;
-const Guid = uefi.Guid;
-const Event = uefi.Event;
-const Status = uefi.Status;
-const Time = uefi.Time;
-const Ip6ModeData = uefi.protocols.Ip6ModeData;
-const Ip6Address = uefi.protocols.Ip6Address;
-const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
-const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
-const cc = uefi.cc;
-
-pub const Udp6Protocol = extern struct {
- _get_mode_data: *const fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(cc) Status,
- _configure: *const fn (*const Udp6Protocol, ?*const Udp6ConfigData) callconv(cc) Status,
- _groups: *const fn (*const Udp6Protocol, bool, ?*const Ip6Address) callconv(cc) Status,
- _transmit: *const fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(cc) Status,
- _receive: *const fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(cc) Status,
- _cancel: *const fn (*const Udp6Protocol, ?*Udp6CompletionToken) callconv(cc) Status,
- _poll: *const fn (*const Udp6Protocol) callconv(cc) Status,
-
- pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
- return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);
- }
-
- pub fn configure(self: *const Udp6Protocol, udp6_config_data: ?*const Udp6ConfigData) Status {
- return self._configure(self, udp6_config_data);
- }
-
- pub fn groups(self: *const Udp6Protocol, join_flag: bool, multicast_address: ?*const Ip6Address) Status {
- return self._groups(self, join_flag, multicast_address);
- }
-
- pub fn transmit(self: *const Udp6Protocol, token: *Udp6CompletionToken) Status {
- return self._transmit(self, token);
- }
-
- pub fn receive(self: *const Udp6Protocol, token: *Udp6CompletionToken) Status {
- return self._receive(self, token);
- }
-
- pub fn cancel(self: *const Udp6Protocol, token: ?*Udp6CompletionToken) Status {
- return self._cancel(self, token);
- }
-
- pub fn poll(self: *const Udp6Protocol) Status {
- return self._poll(self);
- }
-
- pub const guid align(8) = uefi.Guid{
- .time_low = 0x4f948815,
- .time_mid = 0xb4b9,
- .time_high_and_version = 0x43cb,
- .clock_seq_high_and_reserved = 0x8a,
- .clock_seq_low = 0x33,
- .node = [_]u8{ 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 },
- };
-};
-
-pub const Udp6ConfigData = extern struct {
- accept_promiscuous: bool,
- accept_any_port: bool,
- allow_duplicate_port: bool,
- traffic_class: u8,
- hop_limit: u8,
- receive_timeout: u32,
- transmit_timeout: u32,
- station_address: Ip6Address,
- station_port: u16,
- remote_address: Ip6Address,
- remote_port: u16,
-};
-
-pub const Udp6CompletionToken = extern struct {
- event: Event,
- Status: usize,
- packet: extern union {
- RxData: *Udp6ReceiveData,
- TxData: *Udp6TransmitData,
- },
-};
-
-pub const Udp6ReceiveData = extern struct {
- timestamp: Time,
- recycle_signal: Event,
- udp6_session: Udp6SessionData,
- data_length: u32,
- fragment_count: u32,
-
- pub fn getFragments(self: *Udp6ReceiveData) []Udp6FragmentData {
- return @as([*]Udp6FragmentData, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(Udp6ReceiveData))))[0..self.fragment_count];
- }
-};
-
-pub const Udp6TransmitData = extern struct {
- udp6_session_data: ?*Udp6SessionData,
- data_length: u32,
- fragment_count: u32,
-
- pub fn getFragments(self: *Udp6TransmitData) []Udp6FragmentData {
- return @as([*]Udp6FragmentData, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(Udp6TransmitData))))[0..self.fragment_count];
- }
-};
-
-pub const Udp6SessionData = extern struct {
- source_address: Ip6Address,
- source_port: u16,
- destination_address: Ip6Address,
- destination_port: u16,
-};
-
-pub const Udp6FragmentData = extern struct {
- fragment_length: u32,
- fragment_buffer: [*]u8,
-};
lib/std/os/uefi/tables/boot_services.zig
@@ -5,7 +5,7 @@ const Guid = uefi.Guid;
const Handle = uefi.Handle;
const Status = uefi.Status;
const TableHeader = uefi.tables.TableHeader;
-const DevicePathProtocol = uefi.protocols.DevicePathProtocol;
+const DevicePathProtocol = uefi.protocol.DevicePath;
const cc = uefi.cc;
/// Boot services are services provided by the system's firmware until the operating system takes
lib/std/os/uefi/tables/system_table.zig
@@ -3,8 +3,8 @@ const BootServices = uefi.tables.BootServices;
const ConfigurationTable = uefi.tables.ConfigurationTable;
const Handle = uefi.Handle;
const RuntimeServices = uefi.tables.RuntimeServices;
-const SimpleTextInputProtocol = uefi.protocols.SimpleTextInputProtocol;
-const SimpleTextOutputProtocol = uefi.protocols.SimpleTextOutputProtocol;
+const SimpleTextInputProtocol = uefi.protocol.SimpleTextInput;
+const SimpleTextOutputProtocol = uefi.protocol.SimpleTextOutput;
const TableHeader = uefi.tables.TableHeader;
/// The EFI System Table contains pointers to the runtime and boot services tables.
lib/std/os/uefi/device_path.zig
@@ -0,0 +1,1009 @@
+const std = @import("../../std.zig");
+const assert = std.debug.assert;
+const uefi = std.os.uefi;
+const Guid = uefi.Guid;
+
+pub const DevicePath = union(Type) {
+ Hardware: Hardware,
+ Acpi: Acpi,
+ Messaging: Messaging,
+ Media: Media,
+ BiosBootSpecification: BiosBootSpecification,
+ End: End,
+
+ pub const Type = enum(u8) {
+ Hardware = 0x01,
+ Acpi = 0x02,
+ Messaging = 0x03,
+ Media = 0x04,
+ BiosBootSpecification = 0x05,
+ End = 0x7f,
+ _,
+ };
+
+ pub const Hardware = union(Subtype) {
+ Pci: *const PciDevicePath,
+ PcCard: *const PcCardDevicePath,
+ MemoryMapped: *const MemoryMappedDevicePath,
+ Vendor: *const VendorDevicePath,
+ Controller: *const ControllerDevicePath,
+ Bmc: *const BmcDevicePath,
+
+ pub const Subtype = enum(u8) {
+ Pci = 1,
+ PcCard = 2,
+ MemoryMapped = 3,
+ Vendor = 4,
+ Controller = 5,
+ Bmc = 6,
+ _,
+ };
+
+ pub const PciDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ function: u8,
+ device: u8,
+ };
+
+ comptime {
+ assert(6 == @sizeOf(PciDevicePath));
+ assert(1 == @alignOf(PciDevicePath));
+
+ assert(0 == @offsetOf(PciDevicePath, "type"));
+ assert(1 == @offsetOf(PciDevicePath, "subtype"));
+ assert(2 == @offsetOf(PciDevicePath, "length"));
+ assert(4 == @offsetOf(PciDevicePath, "function"));
+ assert(5 == @offsetOf(PciDevicePath, "device"));
+ }
+
+ pub const PcCardDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ function_number: u8,
+ };
+
+ comptime {
+ assert(5 == @sizeOf(PcCardDevicePath));
+ assert(1 == @alignOf(PcCardDevicePath));
+
+ assert(0 == @offsetOf(PcCardDevicePath, "type"));
+ assert(1 == @offsetOf(PcCardDevicePath, "subtype"));
+ assert(2 == @offsetOf(PcCardDevicePath, "length"));
+ assert(4 == @offsetOf(PcCardDevicePath, "function_number"));
+ }
+
+ pub const MemoryMappedDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ memory_type: u32 align(1),
+ start_address: u64 align(1),
+ end_address: u64 align(1),
+ };
+
+ comptime {
+ assert(24 == @sizeOf(MemoryMappedDevicePath));
+ assert(1 == @alignOf(MemoryMappedDevicePath));
+
+ assert(0 == @offsetOf(MemoryMappedDevicePath, "type"));
+ assert(1 == @offsetOf(MemoryMappedDevicePath, "subtype"));
+ assert(2 == @offsetOf(MemoryMappedDevicePath, "length"));
+ assert(4 == @offsetOf(MemoryMappedDevicePath, "memory_type"));
+ assert(8 == @offsetOf(MemoryMappedDevicePath, "start_address"));
+ assert(16 == @offsetOf(MemoryMappedDevicePath, "end_address"));
+ }
+
+ pub const VendorDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ vendor_guid: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(VendorDevicePath));
+ assert(1 == @alignOf(VendorDevicePath));
+
+ assert(0 == @offsetOf(VendorDevicePath, "type"));
+ assert(1 == @offsetOf(VendorDevicePath, "subtype"));
+ assert(2 == @offsetOf(VendorDevicePath, "length"));
+ assert(4 == @offsetOf(VendorDevicePath, "vendor_guid"));
+ }
+
+ pub const ControllerDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ controller_number: u32 align(1),
+ };
+
+ comptime {
+ assert(8 == @sizeOf(ControllerDevicePath));
+ assert(1 == @alignOf(ControllerDevicePath));
+
+ assert(0 == @offsetOf(ControllerDevicePath, "type"));
+ assert(1 == @offsetOf(ControllerDevicePath, "subtype"));
+ assert(2 == @offsetOf(ControllerDevicePath, "length"));
+ assert(4 == @offsetOf(ControllerDevicePath, "controller_number"));
+ }
+
+ pub const BmcDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ interface_type: u8,
+ base_address: u64 align(1),
+ };
+
+ comptime {
+ assert(13 == @sizeOf(BmcDevicePath));
+ assert(1 == @alignOf(BmcDevicePath));
+
+ assert(0 == @offsetOf(BmcDevicePath, "type"));
+ assert(1 == @offsetOf(BmcDevicePath, "subtype"));
+ assert(2 == @offsetOf(BmcDevicePath, "length"));
+ assert(4 == @offsetOf(BmcDevicePath, "interface_type"));
+ assert(5 == @offsetOf(BmcDevicePath, "base_address"));
+ }
+ };
+
+ pub const Acpi = union(Subtype) {
+ Acpi: *const BaseAcpiDevicePath,
+ ExpandedAcpi: *const ExpandedAcpiDevicePath,
+ Adr: *const AdrDevicePath,
+
+ pub const Subtype = enum(u8) {
+ Acpi = 1,
+ ExpandedAcpi = 2,
+ Adr = 3,
+ _,
+ };
+
+ pub const BaseAcpiDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ hid: u32 align(1),
+ uid: u32 align(1),
+ };
+
+ comptime {
+ assert(12 == @sizeOf(BaseAcpiDevicePath));
+ assert(1 == @alignOf(BaseAcpiDevicePath));
+
+ assert(0 == @offsetOf(BaseAcpiDevicePath, "type"));
+ assert(1 == @offsetOf(BaseAcpiDevicePath, "subtype"));
+ assert(2 == @offsetOf(BaseAcpiDevicePath, "length"));
+ assert(4 == @offsetOf(BaseAcpiDevicePath, "hid"));
+ assert(8 == @offsetOf(BaseAcpiDevicePath, "uid"));
+ }
+
+ pub const ExpandedAcpiDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ hid: u32 align(1),
+ uid: u32 align(1),
+ cid: u32 align(1),
+ // variable length u16[*:0] strings
+ // hid_str, uid_str, cid_str
+ };
+
+ comptime {
+ assert(16 == @sizeOf(ExpandedAcpiDevicePath));
+ assert(1 == @alignOf(ExpandedAcpiDevicePath));
+
+ assert(0 == @offsetOf(ExpandedAcpiDevicePath, "type"));
+ assert(1 == @offsetOf(ExpandedAcpiDevicePath, "subtype"));
+ assert(2 == @offsetOf(ExpandedAcpiDevicePath, "length"));
+ assert(4 == @offsetOf(ExpandedAcpiDevicePath, "hid"));
+ assert(8 == @offsetOf(ExpandedAcpiDevicePath, "uid"));
+ assert(12 == @offsetOf(ExpandedAcpiDevicePath, "cid"));
+ }
+
+ pub const AdrDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ adr: u32 align(1),
+
+ // multiple adr entries can optionally follow
+ pub fn adrs(self: *const AdrDevicePath) []align(1) const u32 {
+ // self.length is a minimum of 8 with one adr which is size 4.
+ var entries = (self.length - 4) / @sizeOf(u32);
+ return @as([*]align(1) const u32, @ptrCast(&self.adr))[0..entries];
+ }
+ };
+
+ comptime {
+ assert(8 == @sizeOf(AdrDevicePath));
+ assert(1 == @alignOf(AdrDevicePath));
+
+ assert(0 == @offsetOf(AdrDevicePath, "type"));
+ assert(1 == @offsetOf(AdrDevicePath, "subtype"));
+ assert(2 == @offsetOf(AdrDevicePath, "length"));
+ assert(4 == @offsetOf(AdrDevicePath, "adr"));
+ }
+ };
+
+ pub const Messaging = union(Subtype) {
+ Atapi: *const AtapiDevicePath,
+ Scsi: *const ScsiDevicePath,
+ FibreChannel: *const FibreChannelDevicePath,
+ FibreChannelEx: *const FibreChannelExDevicePath,
+ @"1394": *const F1394DevicePath,
+ Usb: *const UsbDevicePath,
+ Sata: *const SataDevicePath,
+ UsbWwid: *const UsbWwidDevicePath,
+ Lun: *const DeviceLogicalUnitDevicePath,
+ UsbClass: *const UsbClassDevicePath,
+ I2o: *const I2oDevicePath,
+ MacAddress: *const MacAddressDevicePath,
+ Ipv4: *const Ipv4DevicePath,
+ Ipv6: *const Ipv6DevicePath,
+ Vlan: *const VlanDevicePath,
+ InfiniBand: *const InfiniBandDevicePath,
+ Uart: *const UartDevicePath,
+ Vendor: *const VendorDefinedDevicePath,
+
+ pub const Subtype = enum(u8) {
+ Atapi = 1,
+ Scsi = 2,
+ FibreChannel = 3,
+ FibreChannelEx = 21,
+ @"1394" = 4,
+ Usb = 5,
+ Sata = 18,
+ UsbWwid = 16,
+ Lun = 17,
+ UsbClass = 15,
+ I2o = 6,
+ MacAddress = 11,
+ Ipv4 = 12,
+ Ipv6 = 13,
+ Vlan = 20,
+ InfiniBand = 9,
+ Uart = 14,
+ Vendor = 10,
+ _,
+ };
+
+ pub const AtapiDevicePath = extern struct {
+ const Role = enum(u8) {
+ Master = 0,
+ Slave = 1,
+ };
+
+ const Rank = enum(u8) {
+ Primary = 0,
+ Secondary = 1,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ primary_secondary: Rank,
+ slave_master: Role,
+ logical_unit_number: u16 align(1),
+ };
+
+ comptime {
+ assert(8 == @sizeOf(AtapiDevicePath));
+ assert(1 == @alignOf(AtapiDevicePath));
+
+ assert(0 == @offsetOf(AtapiDevicePath, "type"));
+ assert(1 == @offsetOf(AtapiDevicePath, "subtype"));
+ assert(2 == @offsetOf(AtapiDevicePath, "length"));
+ assert(4 == @offsetOf(AtapiDevicePath, "primary_secondary"));
+ assert(5 == @offsetOf(AtapiDevicePath, "slave_master"));
+ assert(6 == @offsetOf(AtapiDevicePath, "logical_unit_number"));
+ }
+
+ pub const ScsiDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ target_id: u16 align(1),
+ logical_unit_number: u16 align(1),
+ };
+
+ comptime {
+ assert(8 == @sizeOf(ScsiDevicePath));
+ assert(1 == @alignOf(ScsiDevicePath));
+
+ assert(0 == @offsetOf(ScsiDevicePath, "type"));
+ assert(1 == @offsetOf(ScsiDevicePath, "subtype"));
+ assert(2 == @offsetOf(ScsiDevicePath, "length"));
+ assert(4 == @offsetOf(ScsiDevicePath, "target_id"));
+ assert(6 == @offsetOf(ScsiDevicePath, "logical_unit_number"));
+ }
+
+ pub const FibreChannelDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ reserved: u32 align(1),
+ world_wide_name: u64 align(1),
+ logical_unit_number: u64 align(1),
+ };
+
+ comptime {
+ assert(24 == @sizeOf(FibreChannelDevicePath));
+ assert(1 == @alignOf(FibreChannelDevicePath));
+
+ assert(0 == @offsetOf(FibreChannelDevicePath, "type"));
+ assert(1 == @offsetOf(FibreChannelDevicePath, "subtype"));
+ assert(2 == @offsetOf(FibreChannelDevicePath, "length"));
+ assert(4 == @offsetOf(FibreChannelDevicePath, "reserved"));
+ assert(8 == @offsetOf(FibreChannelDevicePath, "world_wide_name"));
+ assert(16 == @offsetOf(FibreChannelDevicePath, "logical_unit_number"));
+ }
+
+ pub const FibreChannelExDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ reserved: u32 align(1),
+ world_wide_name: u64 align(1),
+ logical_unit_number: u64 align(1),
+ };
+
+ comptime {
+ assert(24 == @sizeOf(FibreChannelExDevicePath));
+ assert(1 == @alignOf(FibreChannelExDevicePath));
+
+ assert(0 == @offsetOf(FibreChannelExDevicePath, "type"));
+ assert(1 == @offsetOf(FibreChannelExDevicePath, "subtype"));
+ assert(2 == @offsetOf(FibreChannelExDevicePath, "length"));
+ assert(4 == @offsetOf(FibreChannelExDevicePath, "reserved"));
+ assert(8 == @offsetOf(FibreChannelExDevicePath, "world_wide_name"));
+ assert(16 == @offsetOf(FibreChannelExDevicePath, "logical_unit_number"));
+ }
+
+ pub const F1394DevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ reserved: u32 align(1),
+ guid: u64 align(1),
+ };
+
+ comptime {
+ assert(16 == @sizeOf(F1394DevicePath));
+ assert(1 == @alignOf(F1394DevicePath));
+
+ assert(0 == @offsetOf(F1394DevicePath, "type"));
+ assert(1 == @offsetOf(F1394DevicePath, "subtype"));
+ assert(2 == @offsetOf(F1394DevicePath, "length"));
+ assert(4 == @offsetOf(F1394DevicePath, "reserved"));
+ assert(8 == @offsetOf(F1394DevicePath, "guid"));
+ }
+
+ pub const UsbDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ parent_port_number: u8,
+ interface_number: u8,
+ };
+
+ comptime {
+ assert(6 == @sizeOf(UsbDevicePath));
+ assert(1 == @alignOf(UsbDevicePath));
+
+ assert(0 == @offsetOf(UsbDevicePath, "type"));
+ assert(1 == @offsetOf(UsbDevicePath, "subtype"));
+ assert(2 == @offsetOf(UsbDevicePath, "length"));
+ assert(4 == @offsetOf(UsbDevicePath, "parent_port_number"));
+ assert(5 == @offsetOf(UsbDevicePath, "interface_number"));
+ }
+
+ pub const SataDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ hba_port_number: u16 align(1),
+ port_multiplier_port_number: u16 align(1),
+ logical_unit_number: u16 align(1),
+ };
+
+ comptime {
+ assert(10 == @sizeOf(SataDevicePath));
+ assert(1 == @alignOf(SataDevicePath));
+
+ assert(0 == @offsetOf(SataDevicePath, "type"));
+ assert(1 == @offsetOf(SataDevicePath, "subtype"));
+ assert(2 == @offsetOf(SataDevicePath, "length"));
+ assert(4 == @offsetOf(SataDevicePath, "hba_port_number"));
+ assert(6 == @offsetOf(SataDevicePath, "port_multiplier_port_number"));
+ assert(8 == @offsetOf(SataDevicePath, "logical_unit_number"));
+ }
+
+ pub const UsbWwidDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ interface_number: u16 align(1),
+ device_vendor_id: u16 align(1),
+ device_product_id: u16 align(1),
+
+ pub fn serial_number(self: *const UsbWwidDevicePath) []align(1) const u16 {
+ var serial_len = (self.length - @sizeOf(UsbWwidDevicePath)) / @sizeOf(u16);
+ return @as([*]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(UsbWwidDevicePath)))[0..serial_len];
+ }
+ };
+
+ comptime {
+ assert(10 == @sizeOf(UsbWwidDevicePath));
+ assert(1 == @alignOf(UsbWwidDevicePath));
+
+ assert(0 == @offsetOf(UsbWwidDevicePath, "type"));
+ assert(1 == @offsetOf(UsbWwidDevicePath, "subtype"));
+ assert(2 == @offsetOf(UsbWwidDevicePath, "length"));
+ assert(4 == @offsetOf(UsbWwidDevicePath, "interface_number"));
+ assert(6 == @offsetOf(UsbWwidDevicePath, "device_vendor_id"));
+ assert(8 == @offsetOf(UsbWwidDevicePath, "device_product_id"));
+ }
+
+ pub const DeviceLogicalUnitDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ lun: u8,
+ };
+
+ comptime {
+ assert(5 == @sizeOf(DeviceLogicalUnitDevicePath));
+ assert(1 == @alignOf(DeviceLogicalUnitDevicePath));
+
+ assert(0 == @offsetOf(DeviceLogicalUnitDevicePath, "type"));
+ assert(1 == @offsetOf(DeviceLogicalUnitDevicePath, "subtype"));
+ assert(2 == @offsetOf(DeviceLogicalUnitDevicePath, "length"));
+ assert(4 == @offsetOf(DeviceLogicalUnitDevicePath, "lun"));
+ }
+
+ pub const UsbClassDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ vendor_id: u16 align(1),
+ product_id: u16 align(1),
+ device_class: u8,
+ device_subclass: u8,
+ device_protocol: u8,
+ };
+
+ comptime {
+ assert(11 == @sizeOf(UsbClassDevicePath));
+ assert(1 == @alignOf(UsbClassDevicePath));
+
+ assert(0 == @offsetOf(UsbClassDevicePath, "type"));
+ assert(1 == @offsetOf(UsbClassDevicePath, "subtype"));
+ assert(2 == @offsetOf(UsbClassDevicePath, "length"));
+ assert(4 == @offsetOf(UsbClassDevicePath, "vendor_id"));
+ assert(6 == @offsetOf(UsbClassDevicePath, "product_id"));
+ assert(8 == @offsetOf(UsbClassDevicePath, "device_class"));
+ assert(9 == @offsetOf(UsbClassDevicePath, "device_subclass"));
+ assert(10 == @offsetOf(UsbClassDevicePath, "device_protocol"));
+ }
+
+ pub const I2oDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ tid: u32 align(1),
+ };
+
+ comptime {
+ assert(8 == @sizeOf(I2oDevicePath));
+ assert(1 == @alignOf(I2oDevicePath));
+
+ assert(0 == @offsetOf(I2oDevicePath, "type"));
+ assert(1 == @offsetOf(I2oDevicePath, "subtype"));
+ assert(2 == @offsetOf(I2oDevicePath, "length"));
+ assert(4 == @offsetOf(I2oDevicePath, "tid"));
+ }
+
+ pub const MacAddressDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ mac_address: uefi.MacAddress,
+ if_type: u8,
+ };
+
+ comptime {
+ assert(37 == @sizeOf(MacAddressDevicePath));
+ assert(1 == @alignOf(MacAddressDevicePath));
+
+ assert(0 == @offsetOf(MacAddressDevicePath, "type"));
+ assert(1 == @offsetOf(MacAddressDevicePath, "subtype"));
+ assert(2 == @offsetOf(MacAddressDevicePath, "length"));
+ assert(4 == @offsetOf(MacAddressDevicePath, "mac_address"));
+ assert(36 == @offsetOf(MacAddressDevicePath, "if_type"));
+ }
+
+ pub const Ipv4DevicePath = extern struct {
+ pub const IpType = enum(u8) {
+ Dhcp = 0,
+ Static = 1,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ local_ip_address: uefi.Ipv4Address align(1),
+ remote_ip_address: uefi.Ipv4Address align(1),
+ local_port: u16 align(1),
+ remote_port: u16 align(1),
+ network_protocol: u16 align(1),
+ static_ip_address: IpType,
+ gateway_ip_address: u32 align(1),
+ subnet_mask: u32 align(1),
+ };
+
+ comptime {
+ assert(27 == @sizeOf(Ipv4DevicePath));
+ assert(1 == @alignOf(Ipv4DevicePath));
+
+ assert(0 == @offsetOf(Ipv4DevicePath, "type"));
+ assert(1 == @offsetOf(Ipv4DevicePath, "subtype"));
+ assert(2 == @offsetOf(Ipv4DevicePath, "length"));
+ assert(4 == @offsetOf(Ipv4DevicePath, "local_ip_address"));
+ assert(8 == @offsetOf(Ipv4DevicePath, "remote_ip_address"));
+ assert(12 == @offsetOf(Ipv4DevicePath, "local_port"));
+ assert(14 == @offsetOf(Ipv4DevicePath, "remote_port"));
+ assert(16 == @offsetOf(Ipv4DevicePath, "network_protocol"));
+ assert(18 == @offsetOf(Ipv4DevicePath, "static_ip_address"));
+ assert(19 == @offsetOf(Ipv4DevicePath, "gateway_ip_address"));
+ assert(23 == @offsetOf(Ipv4DevicePath, "subnet_mask"));
+ }
+
+ pub const Ipv6DevicePath = extern struct {
+ pub const Origin = enum(u8) {
+ Manual = 0,
+ AssignedStateless = 1,
+ AssignedStateful = 2,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ local_ip_address: uefi.Ipv6Address,
+ remote_ip_address: uefi.Ipv6Address,
+ local_port: u16 align(1),
+ remote_port: u16 align(1),
+ protocol: u16 align(1),
+ ip_address_origin: Origin,
+ prefix_length: u8,
+ gateway_ip_address: uefi.Ipv6Address,
+ };
+
+ comptime {
+ assert(60 == @sizeOf(Ipv6DevicePath));
+ assert(1 == @alignOf(Ipv6DevicePath));
+
+ assert(0 == @offsetOf(Ipv6DevicePath, "type"));
+ assert(1 == @offsetOf(Ipv6DevicePath, "subtype"));
+ assert(2 == @offsetOf(Ipv6DevicePath, "length"));
+ assert(4 == @offsetOf(Ipv6DevicePath, "local_ip_address"));
+ assert(20 == @offsetOf(Ipv6DevicePath, "remote_ip_address"));
+ assert(36 == @offsetOf(Ipv6DevicePath, "local_port"));
+ assert(38 == @offsetOf(Ipv6DevicePath, "remote_port"));
+ assert(40 == @offsetOf(Ipv6DevicePath, "protocol"));
+ assert(42 == @offsetOf(Ipv6DevicePath, "ip_address_origin"));
+ assert(43 == @offsetOf(Ipv6DevicePath, "prefix_length"));
+ assert(44 == @offsetOf(Ipv6DevicePath, "gateway_ip_address"));
+ }
+
+ pub const VlanDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ vlan_id: u16 align(1),
+ };
+
+ comptime {
+ assert(6 == @sizeOf(VlanDevicePath));
+ assert(1 == @alignOf(VlanDevicePath));
+
+ assert(0 == @offsetOf(VlanDevicePath, "type"));
+ assert(1 == @offsetOf(VlanDevicePath, "subtype"));
+ assert(2 == @offsetOf(VlanDevicePath, "length"));
+ assert(4 == @offsetOf(VlanDevicePath, "vlan_id"));
+ }
+
+ pub const InfiniBandDevicePath = extern struct {
+ pub const ResourceFlags = packed struct(u32) {
+ pub const ControllerType = enum(u1) {
+ Ioc = 0,
+ Service = 1,
+ };
+
+ ioc_or_service: ControllerType,
+ extend_boot_environment: bool,
+ console_protocol: bool,
+ storage_protocol: bool,
+ network_protocol: bool,
+
+ // u1 + 4 * bool = 5 bits, we need a total of 32 bits
+ reserved: u27,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ resource_flags: ResourceFlags align(1),
+ port_gid: [16]u8,
+ service_id: u64 align(1),
+ target_port_id: u64 align(1),
+ device_id: u64 align(1),
+ };
+
+ comptime {
+ assert(48 == @sizeOf(InfiniBandDevicePath));
+ assert(1 == @alignOf(InfiniBandDevicePath));
+
+ assert(0 == @offsetOf(InfiniBandDevicePath, "type"));
+ assert(1 == @offsetOf(InfiniBandDevicePath, "subtype"));
+ assert(2 == @offsetOf(InfiniBandDevicePath, "length"));
+ assert(4 == @offsetOf(InfiniBandDevicePath, "resource_flags"));
+ assert(8 == @offsetOf(InfiniBandDevicePath, "port_gid"));
+ assert(24 == @offsetOf(InfiniBandDevicePath, "service_id"));
+ assert(32 == @offsetOf(InfiniBandDevicePath, "target_port_id"));
+ assert(40 == @offsetOf(InfiniBandDevicePath, "device_id"));
+ }
+
+ pub const UartDevicePath = extern struct {
+ pub const Parity = enum(u8) {
+ Default = 0,
+ None = 1,
+ Even = 2,
+ Odd = 3,
+ Mark = 4,
+ Space = 5,
+ _,
+ };
+
+ pub const StopBits = enum(u8) {
+ Default = 0,
+ One = 1,
+ OneAndAHalf = 2,
+ Two = 3,
+ _,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ reserved: u32 align(1),
+ baud_rate: u64 align(1),
+ data_bits: u8,
+ parity: Parity,
+ stop_bits: StopBits,
+ };
+
+ comptime {
+ assert(19 == @sizeOf(UartDevicePath));
+ assert(1 == @alignOf(UartDevicePath));
+
+ assert(0 == @offsetOf(UartDevicePath, "type"));
+ assert(1 == @offsetOf(UartDevicePath, "subtype"));
+ assert(2 == @offsetOf(UartDevicePath, "length"));
+ assert(4 == @offsetOf(UartDevicePath, "reserved"));
+ assert(8 == @offsetOf(UartDevicePath, "baud_rate"));
+ assert(16 == @offsetOf(UartDevicePath, "data_bits"));
+ assert(17 == @offsetOf(UartDevicePath, "parity"));
+ assert(18 == @offsetOf(UartDevicePath, "stop_bits"));
+ }
+
+ pub const VendorDefinedDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ vendor_guid: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(VendorDefinedDevicePath));
+ assert(1 == @alignOf(VendorDefinedDevicePath));
+
+ assert(0 == @offsetOf(VendorDefinedDevicePath, "type"));
+ assert(1 == @offsetOf(VendorDefinedDevicePath, "subtype"));
+ assert(2 == @offsetOf(VendorDefinedDevicePath, "length"));
+ assert(4 == @offsetOf(VendorDefinedDevicePath, "vendor_guid"));
+ }
+ };
+
+ pub const Media = union(Subtype) {
+ HardDrive: *const HardDriveDevicePath,
+ Cdrom: *const CdromDevicePath,
+ Vendor: *const VendorDevicePath,
+ FilePath: *const FilePathDevicePath,
+ MediaProtocol: *const MediaProtocolDevicePath,
+ PiwgFirmwareFile: *const PiwgFirmwareFileDevicePath,
+ PiwgFirmwareVolume: *const PiwgFirmwareVolumeDevicePath,
+ RelativeOffsetRange: *const RelativeOffsetRangeDevicePath,
+ RamDisk: *const RamDiskDevicePath,
+
+ pub const Subtype = enum(u8) {
+ HardDrive = 1,
+ Cdrom = 2,
+ Vendor = 3,
+ FilePath = 4,
+ MediaProtocol = 5,
+ PiwgFirmwareFile = 6,
+ PiwgFirmwareVolume = 7,
+ RelativeOffsetRange = 8,
+ RamDisk = 9,
+ _,
+ };
+
+ pub const HardDriveDevicePath = extern struct {
+ pub const Format = enum(u8) {
+ LegacyMbr = 0x01,
+ GuidPartitionTable = 0x02,
+ };
+
+ pub const SignatureType = enum(u8) {
+ NoSignature = 0x00,
+ /// "32-bit signature from address 0x1b8 of the type 0x01 MBR"
+ MbrSignature = 0x01,
+ GuidSignature = 0x02,
+ };
+
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ partition_number: u32 align(1),
+ partition_start: u64 align(1),
+ partition_size: u64 align(1),
+ partition_signature: [16]u8,
+ partition_format: Format,
+ signature_type: SignatureType,
+ };
+
+ comptime {
+ assert(42 == @sizeOf(HardDriveDevicePath));
+ assert(1 == @alignOf(HardDriveDevicePath));
+
+ assert(0 == @offsetOf(HardDriveDevicePath, "type"));
+ assert(1 == @offsetOf(HardDriveDevicePath, "subtype"));
+ assert(2 == @offsetOf(HardDriveDevicePath, "length"));
+ assert(4 == @offsetOf(HardDriveDevicePath, "partition_number"));
+ assert(8 == @offsetOf(HardDriveDevicePath, "partition_start"));
+ assert(16 == @offsetOf(HardDriveDevicePath, "partition_size"));
+ assert(24 == @offsetOf(HardDriveDevicePath, "partition_signature"));
+ assert(40 == @offsetOf(HardDriveDevicePath, "partition_format"));
+ assert(41 == @offsetOf(HardDriveDevicePath, "signature_type"));
+ }
+
+ pub const CdromDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ boot_entry: u32 align(1),
+ partition_start: u64 align(1),
+ partition_size: u64 align(1),
+ };
+
+ comptime {
+ assert(24 == @sizeOf(CdromDevicePath));
+ assert(1 == @alignOf(CdromDevicePath));
+
+ assert(0 == @offsetOf(CdromDevicePath, "type"));
+ assert(1 == @offsetOf(CdromDevicePath, "subtype"));
+ assert(2 == @offsetOf(CdromDevicePath, "length"));
+ assert(4 == @offsetOf(CdromDevicePath, "boot_entry"));
+ assert(8 == @offsetOf(CdromDevicePath, "partition_start"));
+ assert(16 == @offsetOf(CdromDevicePath, "partition_size"));
+ }
+
+ pub const VendorDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ guid: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(VendorDevicePath));
+ assert(1 == @alignOf(VendorDevicePath));
+
+ assert(0 == @offsetOf(VendorDevicePath, "type"));
+ assert(1 == @offsetOf(VendorDevicePath, "subtype"));
+ assert(2 == @offsetOf(VendorDevicePath, "length"));
+ assert(4 == @offsetOf(VendorDevicePath, "guid"));
+ }
+
+ pub const FilePathDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+
+ pub fn getPath(self: *const FilePathDevicePath) [*:0]align(1) const u16 {
+ return @as([*:0]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FilePathDevicePath)));
+ }
+ };
+
+ comptime {
+ assert(4 == @sizeOf(FilePathDevicePath));
+ assert(1 == @alignOf(FilePathDevicePath));
+
+ assert(0 == @offsetOf(FilePathDevicePath, "type"));
+ assert(1 == @offsetOf(FilePathDevicePath, "subtype"));
+ assert(2 == @offsetOf(FilePathDevicePath, "length"));
+ }
+
+ pub const MediaProtocolDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ guid: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(MediaProtocolDevicePath));
+ assert(1 == @alignOf(MediaProtocolDevicePath));
+
+ assert(0 == @offsetOf(MediaProtocolDevicePath, "type"));
+ assert(1 == @offsetOf(MediaProtocolDevicePath, "subtype"));
+ assert(2 == @offsetOf(MediaProtocolDevicePath, "length"));
+ assert(4 == @offsetOf(MediaProtocolDevicePath, "guid"));
+ }
+
+ pub const PiwgFirmwareFileDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ fv_filename: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(PiwgFirmwareFileDevicePath));
+ assert(1 == @alignOf(PiwgFirmwareFileDevicePath));
+
+ assert(0 == @offsetOf(PiwgFirmwareFileDevicePath, "type"));
+ assert(1 == @offsetOf(PiwgFirmwareFileDevicePath, "subtype"));
+ assert(2 == @offsetOf(PiwgFirmwareFileDevicePath, "length"));
+ assert(4 == @offsetOf(PiwgFirmwareFileDevicePath, "fv_filename"));
+ }
+
+ pub const PiwgFirmwareVolumeDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ fv_name: Guid align(1),
+ };
+
+ comptime {
+ assert(20 == @sizeOf(PiwgFirmwareVolumeDevicePath));
+ assert(1 == @alignOf(PiwgFirmwareVolumeDevicePath));
+
+ assert(0 == @offsetOf(PiwgFirmwareVolumeDevicePath, "type"));
+ assert(1 == @offsetOf(PiwgFirmwareVolumeDevicePath, "subtype"));
+ assert(2 == @offsetOf(PiwgFirmwareVolumeDevicePath, "length"));
+ assert(4 == @offsetOf(PiwgFirmwareVolumeDevicePath, "fv_name"));
+ }
+
+ pub const RelativeOffsetRangeDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ reserved: u32 align(1),
+ start: u64 align(1),
+ end: u64 align(1),
+ };
+
+ comptime {
+ assert(24 == @sizeOf(RelativeOffsetRangeDevicePath));
+ assert(1 == @alignOf(RelativeOffsetRangeDevicePath));
+
+ assert(0 == @offsetOf(RelativeOffsetRangeDevicePath, "type"));
+ assert(1 == @offsetOf(RelativeOffsetRangeDevicePath, "subtype"));
+ assert(2 == @offsetOf(RelativeOffsetRangeDevicePath, "length"));
+ assert(4 == @offsetOf(RelativeOffsetRangeDevicePath, "reserved"));
+ assert(8 == @offsetOf(RelativeOffsetRangeDevicePath, "start"));
+ assert(16 == @offsetOf(RelativeOffsetRangeDevicePath, "end"));
+ }
+
+ pub const RamDiskDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ start: u64 align(1),
+ end: u64 align(1),
+ disk_type: Guid align(1),
+ instance: u16 align(1),
+ };
+
+ comptime {
+ assert(38 == @sizeOf(RamDiskDevicePath));
+ assert(1 == @alignOf(RamDiskDevicePath));
+
+ assert(0 == @offsetOf(RamDiskDevicePath, "type"));
+ assert(1 == @offsetOf(RamDiskDevicePath, "subtype"));
+ assert(2 == @offsetOf(RamDiskDevicePath, "length"));
+ assert(4 == @offsetOf(RamDiskDevicePath, "start"));
+ assert(12 == @offsetOf(RamDiskDevicePath, "end"));
+ assert(20 == @offsetOf(RamDiskDevicePath, "disk_type"));
+ assert(36 == @offsetOf(RamDiskDevicePath, "instance"));
+ }
+ };
+
+ pub const BiosBootSpecification = union(Subtype) {
+ BBS101: *const BBS101DevicePath,
+
+ pub const Subtype = enum(u8) {
+ BBS101 = 1,
+ _,
+ };
+
+ pub const BBS101DevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ device_type: u16 align(1),
+ status_flag: u16 align(1),
+
+ pub fn getDescription(self: *const BBS101DevicePath) [*:0]const u8 {
+ return @as([*:0]const u8, @ptrCast(self)) + @sizeOf(BBS101DevicePath);
+ }
+ };
+
+ comptime {
+ assert(8 == @sizeOf(BBS101DevicePath));
+ assert(1 == @alignOf(BBS101DevicePath));
+
+ assert(0 == @offsetOf(BBS101DevicePath, "type"));
+ assert(1 == @offsetOf(BBS101DevicePath, "subtype"));
+ assert(2 == @offsetOf(BBS101DevicePath, "length"));
+ assert(4 == @offsetOf(BBS101DevicePath, "device_type"));
+ assert(6 == @offsetOf(BBS101DevicePath, "status_flag"));
+ }
+ };
+
+ pub const End = union(Subtype) {
+ EndEntire: *const EndEntireDevicePath,
+ EndThisInstance: *const EndThisInstanceDevicePath,
+
+ pub const Subtype = enum(u8) {
+ EndEntire = 0xff,
+ EndThisInstance = 0x01,
+ _,
+ };
+
+ pub const EndEntireDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ };
+
+ comptime {
+ assert(4 == @sizeOf(EndEntireDevicePath));
+ assert(1 == @alignOf(EndEntireDevicePath));
+
+ assert(0 == @offsetOf(EndEntireDevicePath, "type"));
+ assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
+ assert(2 == @offsetOf(EndEntireDevicePath, "length"));
+ }
+
+ pub const EndThisInstanceDevicePath = extern struct {
+ type: DevicePath.Type,
+ subtype: Subtype,
+ length: u16 align(1),
+ };
+
+ comptime {
+ assert(4 == @sizeOf(EndEntireDevicePath));
+ assert(1 == @alignOf(EndEntireDevicePath));
+
+ assert(0 == @offsetOf(EndEntireDevicePath, "type"));
+ assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
+ assert(2 == @offsetOf(EndEntireDevicePath, "length"));
+ }
+ };
+};
lib/std/os/uefi/protocols/hii.zig → lib/std/os/uefi/hii.zig
@@ -1,10 +1,10 @@
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
-pub const HIIHandle = *opaque {};
+pub const Handle = *opaque {};
/// The header found at the start of each package.
-pub const HIIPackageHeader = packed struct(u32) {
+pub const PackageHeader = packed struct(u32) {
length: u24,
type: u8,
@@ -24,7 +24,7 @@ pub const HIIPackageHeader = packed struct(u32) {
};
/// The header found at the start of each package list.
-pub const HIIPackageList = extern struct {
+pub const PackageList = extern struct {
package_list_guid: Guid,
/// The size of the package list (in bytes), including the header.
@@ -33,13 +33,13 @@ pub const HIIPackageList = extern struct {
// TODO implement iterator
};
-pub const HIISimplifiedFontPackage = extern struct {
- header: HIIPackageHeader,
+pub const SimplifiedFontPackage = extern struct {
+ header: PackageHeader,
number_of_narrow_glyphs: u16,
number_of_wide_glyphs: u16,
- pub fn getNarrowGlyphs(self: *HIISimplifiedFontPackage) []NarrowGlyph {
- return @as([*]NarrowGlyph, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(HIISimplifiedFontPackage))))[0..self.number_of_narrow_glyphs];
+ pub fn getNarrowGlyphs(self: *SimplifiedFontPackage) []NarrowGlyph {
+ return @as([*]NarrowGlyph, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(SimplifiedFontPackage))))[0..self.number_of_narrow_glyphs];
}
};
@@ -69,8 +69,8 @@ pub const WideGlyph = extern struct {
_pad: [3]u8 = [_]u8{0} ** 3,
};
-pub const HIIStringPackage = extern struct {
- header: HIIPackageHeader,
+pub const StringPackage = extern struct {
+ header: PackageHeader,
hdr_size: u32,
string_info_offset: u32,
language_window: [16]u16,
lib/std/os/uefi/protocol.zig
@@ -0,0 +1,37 @@
+pub const LoadedImage = @import("protocol/loaded_image.zig").LoadedImage;
+pub const DevicePath = @import("protocol/device_path.zig").DevicePath;
+pub const Rng = @import("protocol/rng.zig").Rng;
+pub const ShellParameters = @import("protocol/shell_parameters.zig").ShellParameters;
+
+pub const SimpleFileSystem = @import("protocol/simple_file_system.zig").SimpleFileSystem;
+pub const File = @import("protocol/file.zig").File;
+pub const BlockIo = @import("protocol/block_io.zig").BlockIo;
+
+pub const SimpleTextInput = @import("protocol/simple_text_input.zig").SimpleTextInput;
+pub const SimpleTextInputEx = @import("protocol/simple_text_input_ex.zig").SimpleTextInputEx;
+pub const SimpleTextOutput = @import("protocol/simple_text_output.zig").SimpleTextOutput;
+
+pub const SimplePointer = @import("protocol/simple_pointer.zig").SimplePointer;
+pub const AbsolutePointer = @import("protocol/absolute_pointer.zig").AbsolutePointer;
+
+pub const GraphicsOutput = @import("protocol/graphics_output.zig").GraphicsOutput;
+
+pub const edid = @import("protocol/edid.zig");
+
+pub const SimpleNetwork = @import("protocol/simple_network.zig").SimpleNetwork;
+pub const ManagedNetwork = @import("protocol/managed_network.zig").ManagedNetwork;
+
+pub const Ip6ServiceBinding = @import("protocol/ip6_service_binding.zig").Ip6ServiceBinding;
+pub const Ip6 = @import("protocol/ip6.zig").Ip6;
+pub const Ip6Config = @import("protocol/ip6_config.zig").Ip6Config;
+
+pub const Udp6ServiceBinding = @import("protocol/udp6_service_binding.zig").Udp6ServiceBinding;
+pub const Udp6 = @import("protocol/udp6.zig").Udp6;
+
+pub const HiiDatabase = @import("protocol/hii_database.zig").HiiDatabase;
+pub const HiiPopup = @import("protocol/hii_popup.zig").HiiPopup;
+
+test {
+ @setEvalBranchQuota(2000);
+ @import("std").testing.refAllDeclsRecursive(@This());
+}
lib/std/os/uefi/protocols.zig
@@ -1,50 +0,0 @@
-// Misc
-pub usingnamespace @import("protocols/loaded_image_protocol.zig");
-pub usingnamespace @import("protocols/device_path_protocol.zig");
-pub usingnamespace @import("protocols/rng_protocol.zig");
-pub usingnamespace @import("protocols/shell_parameters_protocol.zig");
-
-// Files / IO
-pub usingnamespace @import("protocols/simple_file_system_protocol.zig");
-pub usingnamespace @import("protocols/file_protocol.zig");
-pub usingnamespace @import("protocols/block_io_protocol.zig");
-
-// Text
-pub usingnamespace @import("protocols/simple_text_input_protocol.zig");
-pub usingnamespace @import("protocols/simple_text_input_ex_protocol.zig");
-pub usingnamespace @import("protocols/simple_text_output_protocol.zig");
-
-// Pointer
-pub usingnamespace @import("protocols/simple_pointer_protocol.zig");
-pub usingnamespace @import("protocols/absolute_pointer_protocol.zig");
-
-pub usingnamespace @import("protocols/graphics_output_protocol.zig");
-
-// edid
-pub usingnamespace @import("protocols/edid_discovered_protocol.zig");
-pub usingnamespace @import("protocols/edid_active_protocol.zig");
-pub usingnamespace @import("protocols/edid_override_protocol.zig");
-
-// Network
-pub usingnamespace @import("protocols/simple_network_protocol.zig");
-pub usingnamespace @import("protocols/managed_network_service_binding_protocol.zig");
-pub usingnamespace @import("protocols/managed_network_protocol.zig");
-
-// ip6
-pub usingnamespace @import("protocols/ip6_service_binding_protocol.zig");
-pub usingnamespace @import("protocols/ip6_protocol.zig");
-pub usingnamespace @import("protocols/ip6_config_protocol.zig");
-
-// udp6
-pub usingnamespace @import("protocols/udp6_service_binding_protocol.zig");
-pub usingnamespace @import("protocols/udp6_protocol.zig");
-
-// hii
-pub const hii = @import("protocols/hii.zig");
-pub usingnamespace @import("protocols/hii_database_protocol.zig");
-pub usingnamespace @import("protocols/hii_popup_protocol.zig");
-
-test {
- @setEvalBranchQuota(2000);
- @import("std").testing.refAllDeclsRecursive(@This());
-}
lib/std/os/uefi.zig
@@ -1,7 +1,9 @@
const std = @import("../std.zig");
/// A protocol is an interface identified by a GUID.
-pub const protocols = @import("uefi/protocols.zig");
+pub const protocol = @import("uefi/protocol.zig");
+pub const DevicePath = @import("uefi/device_path.zig").DevicePath;
+pub const hii = @import("uefi/hii.zig");
/// Status codes returned by EFI interfaces
pub const Status = @import("uefi/status.zig").Status;
@@ -157,7 +159,60 @@ test "GUID formatting" {
try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));
}
+pub const FileInfo = extern struct {
+ size: u64,
+ file_size: u64,
+ physical_size: u64,
+ create_time: Time,
+ last_access_time: Time,
+ modification_time: Time,
+ attribute: u64,
+
+ pub fn getFileName(self: *const FileInfo) [*:0]const u16 {
+ return @ptrCast(@alignCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FileInfo)));
+ }
+
+ pub const efi_file_read_only: u64 = 0x0000000000000001;
+ pub const efi_file_hidden: u64 = 0x0000000000000002;
+ pub const efi_file_system: u64 = 0x0000000000000004;
+ pub const efi_file_reserved: u64 = 0x0000000000000008;
+ pub const efi_file_directory: u64 = 0x0000000000000010;
+ pub const efi_file_archive: u64 = 0x0000000000000020;
+ pub const efi_file_valid_attr: u64 = 0x0000000000000037;
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x09576e92,
+ .time_mid = 0x6d3f,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+};
+
+pub const FileSystemInfo = extern struct {
+ size: u64,
+ read_only: bool,
+ volume_size: u64,
+ free_space: u64,
+ block_size: u32,
+ _volume_label: u16,
+
+ pub fn getVolumeLabel(self: *const FileSystemInfo) [*:0]const u16 {
+ return @as([*:0]const u16, @ptrCast(&self._volume_label));
+ }
+
+ pub const guid align(8) = Guid{
+ .time_low = 0x09576e93,
+ .time_mid = 0x6d3f,
+ .time_high_and_version = 0x11d2,
+ .clock_seq_high_and_reserved = 0x8e,
+ .clock_seq_low = 0x39,
+ .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
+ };
+};
+
test {
_ = tables;
- _ = protocols;
+ _ = protocol;
}
lib/std/builtin.zig
@@ -794,9 +794,9 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr
if (exit_data) |data| {
if (uefi.system_table.std_err) |out| {
- _ = out.setAttribute(uefi.protocols.SimpleTextOutputProtocol.red);
+ _ = out.setAttribute(uefi.protocol.SimpleTextOutput.red);
_ = out.outputString(data);
- _ = out.setAttribute(uefi.protocols.SimpleTextOutputProtocol.white);
+ _ = out.setAttribute(uefi.protocol.SimpleTextOutput.white);
}
}