std.os.uefi: reorganize namespaces

This is a breaking change.

This commit applies the following rules to std.os.uefi:
* avoid redundant names in the namespace such as "protocol.FooProtocol"
* don't initialize struct field to undefined. do that at the
  initialization site if you want that, or create a named constant that
  sets all the fields to undefined.
* avoid the word "data", "info", "context", "state", "details", or
  "config" in the type name, especially if a word from that category is
  already in the type name.
* embrace tree structure

After following these rules, `usingnamespace` disappeared naturally.
This commit eliminates 26/53 (49%) instances of `usingnamespace` in the
standard library. All these uses were due to not understanding how
to properly use namespaces.

I did not test this commit. The standard library UEFI code is
experimental and pull requests have been accepted with minimal vetting.
Users of std.os.uefi will need to submit follow-up pull requests to fix
up whatever regressions this commit introduces, this time without
abusing namespaces (pun intended).
This commit is contained in:
Andrew Kelley 2023-08-24 19:44:27 -07:00
parent dd6a9caeaf
commit a31748b29e
48 changed files with 2573 additions and 2590 deletions

View File

@ -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);
}
}

View File

@ -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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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,

View File

@ -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());
}

View File

@ -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,
};
};
};

View File

@ -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,
};
};

View File

@ -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"));
}

View File

@ -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,
};
};

View File

@ -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;
};

View File

@ -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,
};
};

View File

@ -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);
}

View File

@ -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,
};
};

View File

@ -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
};
};

View File

@ -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,
};
};

View File

@ -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);
}

View File

@ -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 },
};
};

View File

@ -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,
};
};

View File

@ -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);
}

View File

@ -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,

View File

@ -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);
}

View File

@ -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,
};
};

View File

@ -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,
};
};

View File

@ -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;
};

View File

@ -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,
};
};
};

View File

@ -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,
};
};

View File

@ -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,
};
};

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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,
};

View File

@ -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 },
};
};

File diff suppressed because it is too large Load Diff

View File

@ -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 },
};
};

View File

@ -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 },
};
};

View File

@ -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,
};

View File

@ -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 },
};
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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
};

View File

@ -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,
};

View File

@ -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 },
};
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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

View File

@ -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.