Merge pull request #22820 from linusg/uefi-tweaks

This commit is contained in:
Linus Groh 2025-02-09 08:03:54 +00:00 committed by GitHub
commit 0af492a272
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 324 additions and 280 deletions

View File

@ -597,7 +597,7 @@ pub const Os = struct {
.uefi => .{ .uefi => .{
.semver = .{ .semver = .{
.min = .{ .major = 2, .minor = 0, .patch = 0 }, .min = .{ .major = 2, .minor = 0, .patch = 0 },
.max = .{ .major = 2, .minor = 9, .patch = 0 }, .max = .{ .major = 2, .minor = 11, .patch = 0 },
}, },
}, },

View File

@ -611,7 +611,7 @@ pub fn defaultPanic(
// ExitData buffer must be allocated using boot_services.allocatePool (spec: page 220) // ExitData buffer must be allocated using boot_services.allocatePool (spec: page 220)
const exit_data: []u16 = uefi.raw_pool_allocator.alloc(u16, exit_msg.len + 1) catch @trap(); const exit_data: []u16 = uefi.raw_pool_allocator.alloc(u16, exit_msg.len + 1) catch @trap();
@memcpy(exit_data, exit_msg[0..exit_data.len]); // Includes null terminator. @memcpy(exit_data, exit_msg[0..exit_data.len]); // Includes null terminator.
_ = bs.exit(uefi.handle, .Aborted, exit_data.len, exit_data.ptr); _ = bs.exit(uefi.handle, .aborted, exit_data.len, exit_data.ptr);
} }
@trap(); @trap();
}, },

View File

@ -9,10 +9,10 @@ pub const hii = @import("uefi/hii.zig");
pub const Status = @import("uefi/status.zig").Status; pub const Status = @import("uefi/status.zig").Status;
pub const tables = @import("uefi/tables.zig"); pub const tables = @import("uefi/tables.zig");
/// The memory type to allocate when using the pool /// The memory type to allocate when using the pool.
/// Defaults to .LoaderData, the default data allocation type /// Defaults to `.loader_data`, the default data allocation type
/// used by UEFI applications to allocate pool memory. /// used by UEFI applications to allocate pool memory.
pub var efi_pool_memory_type: tables.MemoryType = .LoaderData; pub var efi_pool_memory_type: tables.MemoryType = .loader_data;
pub const pool_allocator = @import("uefi/pool_allocator.zig").pool_allocator; pub const pool_allocator = @import("uefi/pool_allocator.zig").pool_allocator;
pub const raw_pool_allocator = @import("uefi/pool_allocator.zig").raw_pool_allocator; pub const raw_pool_allocator = @import("uefi/pool_allocator.zig").raw_pool_allocator;

View File

@ -230,56 +230,56 @@ pub const DevicePath = union(Type) {
}; };
pub const Messaging = union(Subtype) { pub const Messaging = union(Subtype) {
Atapi: *const AtapiDevicePath, atapi: *const AtapiDevicePath,
Scsi: *const ScsiDevicePath, scsi: *const ScsiDevicePath,
FibreChannel: *const FibreChannelDevicePath, fibre_channel: *const FibreChannelDevicePath,
FibreChannelEx: *const FibreChannelExDevicePath, fibre_channel_ex: *const FibreChannelExDevicePath,
@"1394": *const F1394DevicePath, @"1394": *const F1394DevicePath,
Usb: *const UsbDevicePath, usb: *const UsbDevicePath,
Sata: *const SataDevicePath, sata: *const SataDevicePath,
UsbWwid: *const UsbWwidDevicePath, usb_wwid: *const UsbWwidDevicePath,
Lun: *const DeviceLogicalUnitDevicePath, lun: *const DeviceLogicalUnitDevicePath,
UsbClass: *const UsbClassDevicePath, usb_class: *const UsbClassDevicePath,
I2o: *const I2oDevicePath, i2o: *const I2oDevicePath,
MacAddress: *const MacAddressDevicePath, mac_address: *const MacAddressDevicePath,
Ipv4: *const Ipv4DevicePath, ipv4: *const Ipv4DevicePath,
Ipv6: *const Ipv6DevicePath, ipv6: *const Ipv6DevicePath,
Vlan: *const VlanDevicePath, vlan: *const VlanDevicePath,
InfiniBand: *const InfiniBandDevicePath, infini_band: *const InfiniBandDevicePath,
Uart: *const UartDevicePath, uart: *const UartDevicePath,
Vendor: *const VendorDefinedDevicePath, vendor: *const VendorDefinedDevicePath,
pub const Subtype = enum(u8) { pub const Subtype = enum(u8) {
Atapi = 1, atapi = 1,
Scsi = 2, scsi = 2,
FibreChannel = 3, fibre_channel = 3,
FibreChannelEx = 21, fibre_channel_ex = 21,
@"1394" = 4, @"1394" = 4,
Usb = 5, usb = 5,
Sata = 18, sata = 18,
UsbWwid = 16, usb_wwid = 16,
Lun = 17, lun = 17,
UsbClass = 15, usb_class = 15,
I2o = 6, i2o = 6,
MacAddress = 11, mac_address = 11,
Ipv4 = 12, ipv4 = 12,
Ipv6 = 13, ipv6 = 13,
Vlan = 20, vlan = 20,
InfiniBand = 9, infini_band = 9,
Uart = 14, uart = 14,
Vendor = 10, vendor = 10,
_, _,
}; };
pub const AtapiDevicePath = extern struct { pub const AtapiDevicePath = extern struct {
const Role = enum(u8) { pub const Role = enum(u8) {
Master = 0, master = 0,
Slave = 1, slave = 1,
}; };
const Rank = enum(u8) { pub const Rank = enum(u8) {
Primary = 0, primary = 0,
Secondary = 1, secondary = 1,
}; };
type: DevicePath.Type, type: DevicePath.Type,
@ -528,8 +528,8 @@ pub const DevicePath = union(Type) {
pub const Ipv4DevicePath = extern struct { pub const Ipv4DevicePath = extern struct {
pub const IpType = enum(u8) { pub const IpType = enum(u8) {
Dhcp = 0, dhcp = 0,
Static = 1, static = 1,
}; };
type: DevicePath.Type, type: DevicePath.Type,
@ -564,9 +564,9 @@ pub const DevicePath = union(Type) {
pub const Ipv6DevicePath = extern struct { pub const Ipv6DevicePath = extern struct {
pub const Origin = enum(u8) { pub const Origin = enum(u8) {
Manual = 0, manual = 0,
AssignedStateless = 1, assigned_stateless = 1,
AssignedStateful = 2, assigned_stateful = 2,
}; };
type: DevicePath.Type, type: DevicePath.Type,
@ -619,8 +619,8 @@ pub const DevicePath = union(Type) {
pub const InfiniBandDevicePath = extern struct { pub const InfiniBandDevicePath = extern struct {
pub const ResourceFlags = packed struct(u32) { pub const ResourceFlags = packed struct(u32) {
pub const ControllerType = enum(u1) { pub const ControllerType = enum(u1) {
Ioc = 0, ioc = 0,
Service = 1, service = 1,
}; };
ioc_or_service: ControllerType, ioc_or_service: ControllerType,
@ -659,20 +659,20 @@ pub const DevicePath = union(Type) {
pub const UartDevicePath = extern struct { pub const UartDevicePath = extern struct {
pub const Parity = enum(u8) { pub const Parity = enum(u8) {
Default = 0, default = 0,
None = 1, none = 1,
Even = 2, even = 2,
Odd = 3, odd = 3,
Mark = 4, mark = 4,
Space = 5, space = 5,
_, _,
}; };
pub const StopBits = enum(u8) { pub const StopBits = enum(u8) {
Default = 0, default = 0,
One = 1, one = 1,
OneAndAHalf = 2, one_and_a_half = 2,
Two = 3, two = 3,
_, _,
}; };
@ -719,40 +719,40 @@ pub const DevicePath = union(Type) {
}; };
pub const Media = union(Subtype) { pub const Media = union(Subtype) {
HardDrive: *const HardDriveDevicePath, hard_drive: *const HardDriveDevicePath,
Cdrom: *const CdromDevicePath, cdrom: *const CdromDevicePath,
Vendor: *const VendorDevicePath, vendor: *const VendorDevicePath,
FilePath: *const FilePathDevicePath, file_path: *const FilePathDevicePath,
MediaProtocol: *const MediaProtocolDevicePath, media_protocol: *const MediaProtocolDevicePath,
PiwgFirmwareFile: *const PiwgFirmwareFileDevicePath, piwg_firmware_file: *const PiwgFirmwareFileDevicePath,
PiwgFirmwareVolume: *const PiwgFirmwareVolumeDevicePath, piwg_firmware_volume: *const PiwgFirmwareVolumeDevicePath,
RelativeOffsetRange: *const RelativeOffsetRangeDevicePath, relative_offset_range: *const RelativeOffsetRangeDevicePath,
RamDisk: *const RamDiskDevicePath, ram_disk: *const RamDiskDevicePath,
pub const Subtype = enum(u8) { pub const Subtype = enum(u8) {
HardDrive = 1, hard_drive = 1,
Cdrom = 2, cdrom = 2,
Vendor = 3, vendor = 3,
FilePath = 4, file_path = 4,
MediaProtocol = 5, media_protocol = 5,
PiwgFirmwareFile = 6, piwg_firmware_file = 6,
PiwgFirmwareVolume = 7, piwg_firmware_volume = 7,
RelativeOffsetRange = 8, relative_offset_range = 8,
RamDisk = 9, ram_disk = 9,
_, _,
}; };
pub const HardDriveDevicePath = extern struct { pub const HardDriveDevicePath = extern struct {
pub const Format = enum(u8) { pub const Format = enum(u8) {
LegacyMbr = 0x01, legacy_mbr = 0x01,
GuidPartitionTable = 0x02, guid_partition_table = 0x02,
}; };
pub const SignatureType = enum(u8) { pub const SignatureType = enum(u8) {
NoSignature = 0x00, no_signature = 0x00,
/// "32-bit signature from address 0x1b8 of the type 0x01 MBR" /// "32-bit signature from address 0x1b8 of the type 0x01 MBR"
MbrSignature = 0x01, mbr_signature = 0x01,
GuidSignature = 0x02, guid_signature = 0x02,
}; };
type: DevicePath.Type, type: DevicePath.Type,
@ -935,10 +935,10 @@ pub const DevicePath = union(Type) {
}; };
pub const BiosBootSpecification = union(Subtype) { pub const BiosBootSpecification = union(Subtype) {
BBS101: *const BBS101DevicePath, bbs101: *const BBS101DevicePath,
pub const Subtype = enum(u8) { pub const Subtype = enum(u8) {
BBS101 = 1, bbs101 = 1,
_, _,
}; };
@ -967,12 +967,12 @@ pub const DevicePath = union(Type) {
}; };
pub const End = union(Subtype) { pub const End = union(Subtype) {
EndEntire: *const EndEntireDevicePath, end_entire: *const EndEntireDevicePath,
EndThisInstance: *const EndThisInstanceDevicePath, end_this_instance: *const EndThisInstanceDevicePath,
pub const Subtype = enum(u8) { pub const Subtype = enum(u8) {
EndEntire = 0xff, end_entire = 0xff,
EndThisInstance = 0x01, end_this_instance = 0x01,
_, _,
}; };

View File

@ -29,7 +29,7 @@ const UefiPoolAllocator = struct {
const full_len = metadata_len + len; const full_len = metadata_len + len;
var unaligned_ptr: [*]align(8) u8 = undefined; var unaligned_ptr: [*]align(8) u8 = undefined;
if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, full_len, &unaligned_ptr) != .Success) return null; if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, full_len, &unaligned_ptr) != .success) return null;
const unaligned_addr = @intFromPtr(unaligned_ptr); const unaligned_addr = @intFromPtr(unaligned_ptr);
const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), ptr_align); const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), ptr_align);
@ -118,7 +118,7 @@ fn uefi_alloc(
std.debug.assert(@intFromEnum(alignment) <= 3); std.debug.assert(@intFromEnum(alignment) <= 3);
var ptr: [*]align(8) u8 = undefined; var ptr: [*]align(8) u8 = undefined;
if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, len, &ptr) != .Success) return null; if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, len, &ptr) != .success) return null;
return ptr; return ptr;
} }

View File

@ -7,7 +7,7 @@ pub const BlockIo = extern struct {
const Self = @This(); const Self = @This();
revision: u64, revision: u64,
media: *EfiBlockMedia, media: *BlockMedia,
_reset: *const fn (*BlockIo, extended_verification: bool) callconv(cc) Status, _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, _read_blocks: *const fn (*BlockIo, media_id: u32, lba: u64, buffer_size: usize, buf: [*]u8) callconv(cc) Status,
@ -43,7 +43,7 @@ pub const BlockIo = extern struct {
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
}; };
pub const EfiBlockMedia = extern struct { pub const BlockMedia = extern struct {
/// The current media ID. If the media changes, this value is changed. /// The current media ID. If the media changes, this value is changed.
media_id: u32, media_id: u32,

View File

@ -24,7 +24,7 @@ pub const DevicePath = extern struct {
/// Returns the next DevicePath node in the sequence, if any. /// Returns the next DevicePath node in the sequence, if any.
pub fn next(self: *DevicePath) ?*DevicePath { pub fn next(self: *DevicePath) ?*DevicePath {
if (self.type == .End and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .EndEntire) if (self.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .end_entire)
return null; return null;
return @as(*DevicePath, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length)); return @as(*DevicePath, @ptrCast(@as([*]u8, @ptrCast(self)) + self.length));
@ -55,8 +55,8 @@ pub const DevicePath = extern struct {
// as the end node itself is 4 bytes (type: u8 + subtype: u8 + length: u16). // 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)); var new = @as(*uefi.DevicePath.Media.FilePathDevicePath, @ptrCast(buf.ptr + path_size - 4));
new.type = .Media; new.type = .media;
new.subtype = .FilePath; new.subtype = .file_path;
new.length = @sizeOf(uefi.DevicePath.Media.FilePathDevicePath) + 2 * (@as(u16, @intCast(path.len)) + 1); 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. // The same as new.getPath(), but not const as we're filling it in.
@ -68,8 +68,8 @@ pub const DevicePath = extern struct {
ptr[path.len] = 0; ptr[path.len] = 0;
var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@as(*DevicePath, @ptrCast(new)).next().?)); var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@as(*DevicePath, @ptrCast(new)).next().?));
end.type = .End; end.type = .end;
end.subtype = .EndEntire; end.subtype = .end_entire;
end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath); end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath);
return @as(*DevicePath, @ptrCast(buf.ptr)); return @as(*DevicePath, @ptrCast(buf.ptr));
@ -84,7 +84,7 @@ pub const DevicePath = extern struct {
if (self.type == enum_value) { if (self.type == enum_value) {
const subtype = self.initSubtype(ufield.type); const subtype = self.initSubtype(ufield.type);
if (subtype) |sb| { if (subtype) |sb| {
// e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } // e.g. return .{ .hardware = .{ .pci = @ptrCast(...) } }
return @unionInit(uefi.DevicePath, ufield.name, sb); return @unionInit(uefi.DevicePath, ufield.name, sb);
} }
} }
@ -102,7 +102,7 @@ pub const DevicePath = extern struct {
const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name)); const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name));
if (self.subtype == tag_val) { if (self.subtype == tag_val) {
// e.g. expr = .{ .Pci = @ptrCast(...) } // e.g. expr = .{ .pci = @ptrCast(...) }
return @unionInit(TUnion, subtype.name, @as(subtype.type, @ptrCast(self))); return @unionInit(TUnion, subtype.name, @as(subtype.type, @ptrCast(self)));
} }
} }

View File

@ -58,7 +58,7 @@ pub const File = extern struct {
fn readFn(self: *const File, buffer: []u8) ReadError!usize { fn readFn(self: *const File, buffer: []u8) ReadError!usize {
var size: usize = buffer.len; var size: usize = buffer.len;
if (.Success != self.read(&size, buffer.ptr)) return ReadError.ReadError; if (.success != self.read(&size, buffer.ptr)) return ReadError.ReadError;
return size; return size;
} }
@ -68,7 +68,7 @@ pub const File = extern struct {
fn writeFn(self: *const File, bytes: []const u8) WriteError!usize { fn writeFn(self: *const File, bytes: []const u8) WriteError!usize {
var size: usize = bytes.len; var size: usize = bytes.len;
if (.Success != self.write(&size, bytes.ptr)) return WriteError.WriteError; if (.success != self.write(&size, bytes.ptr)) return WriteError.WriteError;
return size; return size;
} }
@ -78,7 +78,7 @@ pub const File = extern struct {
fn getPos(self: *const File) GetSeekPosError!u64 { fn getPos(self: *const File) GetSeekPosError!u64 {
var pos: u64 = undefined; var pos: u64 = undefined;
if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
return pos; return pos;
} }
@ -86,13 +86,13 @@ pub const File = extern struct {
// preserve the old file position // preserve the old file position
var pos: u64 = undefined; var pos: u64 = undefined;
var end_pos: u64 = undefined; var end_pos: u64 = undefined;
if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
// seek to end of file to get position = file size // seek to end of file to get position = file size
if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError; if (.success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError;
// get the position // get the position
if (.Success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError; if (.success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError;
// restore the old position // restore the old position
if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError; if (.success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError;
// return the file size = position // return the file size = position
return end_pos; return end_pos;
} }
@ -102,13 +102,13 @@ pub const File = extern struct {
} }
fn seekTo(self: *const File, pos: u64) SeekError!void { fn seekTo(self: *const File, pos: u64) SeekError!void {
if (.Success != self.setPosition(pos)) return SeekError.SeekError; if (.success != self.setPosition(pos)) return SeekError.SeekError;
} }
fn seekBy(self: *const File, offset: i64) SeekError!void { fn seekBy(self: *const File, offset: i64) SeekError!void {
// save the old position and calculate the delta // save the old position and calculate the delta
var pos: u64 = undefined; var pos: u64 = undefined;
if (.Success != self.getPosition(&pos)) return SeekError.SeekError; if (.success != self.getPosition(&pos)) return SeekError.SeekError;
const seek_back = offset < 0; const seek_back = offset < 0;
const amt = @abs(offset); const amt = @abs(offset);
if (seek_back) { if (seek_back) {
@ -116,7 +116,7 @@ pub const File = extern struct {
} else { } else {
pos -= amt; pos -= amt;
} }
if (.Success != self.setPosition(pos)) return SeekError.SeekError; 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 { pub fn getInfo(self: *const File, information_type: *align(8) const Guid, buffer_size: *usize, buffer: [*]u8) Status {

View File

@ -53,10 +53,10 @@ pub const GraphicsOutput = extern struct {
}; };
pub const PixelFormat = enum(u32) { pub const PixelFormat = enum(u32) {
RedGreenBlueReserved8BitPerColor, red_green_blue_reserved_8_bit_per_color,
BlueGreenRedReserved8BitPerColor, blue_green_red_reserved_8_bit_per_color,
BitMask, bit_mask,
BltOnly, blt_only,
}; };
pub const PixelBitmask = extern struct { pub const PixelBitmask = extern struct {
@ -74,10 +74,10 @@ pub const GraphicsOutput = extern struct {
}; };
pub const BltOperation = enum(u32) { pub const BltOperation = enum(u32) {
BltVideoFill, blt_video_fill,
BltVideoToBltBuffer, blt_video_to_blt_buffer,
BltBufferToVideo, blt_buffer_to_video,
BltVideoToVideo, blt_video_to_video,
GraphicsOutputBltOperationMax, graphics_output_blt_operation_max,
}; };
}; };

View File

@ -25,22 +25,22 @@ pub const HiiPopup = extern struct {
}; };
pub const PopupStyle = enum(u32) { pub const PopupStyle = enum(u32) {
Info, info,
Warning, warning,
Error, @"error",
}; };
pub const PopupType = enum(u32) { pub const PopupType = enum(u32) {
Ok, ok,
Cancel, cancel,
YesNo, yes_no,
YesNoCancel, yes_no_cancel,
}; };
pub const PopupSelection = enum(u32) { pub const PopupSelection = enum(u32) {
Ok, ok,
Cancel, cancel,
Yes, yes,
No, no,
}; };
}; };

View File

@ -120,11 +120,11 @@ pub const Ip6 = extern struct {
}; };
pub const NeighborState = enum(u32) { pub const NeighborState = enum(u32) {
Incomplete, incomplete,
Reachable, reachable,
Stale, stale,
Delay, delay,
Probe, probe,
}; };
pub const NeighborCache = extern struct { pub const NeighborCache = extern struct {

View File

@ -37,12 +37,12 @@ pub const Ip6Config = extern struct {
}; };
pub const DataType = enum(u32) { pub const DataType = enum(u32) {
InterfaceInfo, interface_info,
AltInterfaceId, alt_interface_id,
Policy, policy,
DupAddrDetectTransmits, dup_addr_detect_transmits,
ManualAddress, manual_address,
Gateway, gateway,
DnsServer, dns_server,
}; };
}; };

View File

@ -110,8 +110,8 @@ pub const ManagedNetwork = extern struct {
event: Event, event: Event,
status: Status, status: Status,
packet: extern union { packet: extern union {
RxData: *ReceiveData, rx_data: *ReceiveData,
TxData: *TransmitData, tx_data: *TransmitData,
}, },
}; };

View File

@ -21,8 +21,8 @@ pub const SerialIo = extern struct {
} }
/// Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device. /// Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data bits, and stop bits on a serial device.
pub fn setAttribute(self: *const SerialIo, baudRate: u64, receiverFifoDepth: u32, timeout: u32, parity: ParityType, dataBits: u8, stopBits: StopBitsType) Status { pub fn setAttribute(self: *const SerialIo, baud_rate: u64, receiver_fifo_depth: u32, timeout: u32, parity: ParityType, data_bits: u8, stop_bits: StopBitsType) Status {
return self._set_attribute(self, baudRate, receiverFifoDepth, timeout, parity, dataBits, stopBits); return self._set_attribute(self, baud_rate, receiver_fifo_depth, timeout, parity, data_bits, stop_bits);
} }
/// Sets the control bits on a serial device. /// Sets the control bits on a serial device.
@ -36,13 +36,13 @@ pub const SerialIo = extern struct {
} }
/// Writes data to a serial device. /// Writes data to a serial device.
pub fn write(self: *const SerialIo, bufferSize: *usize, buffer: *anyopaque) Status { pub fn write(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status {
return self._write(self, bufferSize, buffer); return self._write(self, buffer_size, buffer);
} }
/// Reads data from a serial device. /// Reads data from a serial device.
pub fn read(self: *const SerialIo, bufferSize: *usize, buffer: *anyopaque) Status { pub fn read(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status {
return self._read(self, bufferSize, buffer); return self._read(self, buffer_size, buffer);
} }
pub const guid align(8) = Guid{ pub const guid align(8) = Guid{
@ -55,19 +55,19 @@ pub const SerialIo = extern struct {
}; };
pub const ParityType = enum(u32) { pub const ParityType = enum(u32) {
DefaultParity, default_parity,
NoParity, no_parity,
EvenParity, even_parity,
OddParity, odd_parity,
MarkParity, mark_parity,
SpaceParity, space_parity,
}; };
pub const StopBitsType = enum(u32) { pub const StopBitsType = enum(u32) {
DefaultStopBits, default_stop_bits,
OneStopBit, one_stop_bit,
OneFiveStopBits, one_five_stop_bits,
TwoStopBits, two_stop_bits,
}; };
pub const Mode = extern struct { pub const Mode = extern struct {

View File

@ -131,9 +131,9 @@ pub const SimpleNetwork = extern struct {
}; };
pub const State = enum(u32) { pub const State = enum(u32) {
Stopped, stopped,
Started, started,
Initialized, initialized,
}; };
pub const Statistics = extern struct { pub const Statistics = extern struct {

View File

@ -71,10 +71,10 @@ pub const Udp6 = extern struct {
pub const CompletionToken = extern struct { pub const CompletionToken = extern struct {
event: Event, event: Event,
Status: usize, status: usize,
packet: extern union { packet: extern union {
RxData: *ReceiveData, rx_data: *ReceiveData,
TxData: *TransmitData, tx_data: *TransmitData,
}, },
}; };

View File

@ -4,145 +4,145 @@ const high_bit = 1 << @typeInfo(usize).int.bits - 1;
pub const Status = enum(usize) { pub const Status = enum(usize) {
/// The operation completed successfully. /// The operation completed successfully.
Success = 0, success = 0,
/// The image failed to load. /// The image failed to load.
LoadError = high_bit | 1, load_error = high_bit | 1,
/// A parameter was incorrect. /// A parameter was incorrect.
InvalidParameter = high_bit | 2, invalid_parameter = high_bit | 2,
/// The operation is not supported. /// The operation is not supported.
Unsupported = high_bit | 3, unsupported = high_bit | 3,
/// The buffer was not the proper size for the request. /// The buffer was not the proper size for the request.
BadBufferSize = high_bit | 4, bad_buffer_size = high_bit | 4,
/// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs. /// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
BufferTooSmall = high_bit | 5, buffer_too_small = high_bit | 5,
/// There is no data pending upon return. /// There is no data pending upon return.
NotReady = high_bit | 6, not_ready = high_bit | 6,
/// The physical device reported an error while attempting the operation. /// The physical device reported an error while attempting the operation.
DeviceError = high_bit | 7, device_error = high_bit | 7,
/// The device cannot be written to. /// The device cannot be written to.
WriteProtected = high_bit | 8, write_protected = high_bit | 8,
/// A resource has run out. /// A resource has run out.
OutOfResources = high_bit | 9, out_of_resources = high_bit | 9,
/// An inconstancy was detected on the file system causing the operating to fail. /// An inconstancy was detected on the file system causing the operating to fail.
VolumeCorrupted = high_bit | 10, volume_corrupted = high_bit | 10,
/// There is no more space on the file system. /// There is no more space on the file system.
VolumeFull = high_bit | 11, volume_full = high_bit | 11,
/// The device does not contain any medium to perform the operation. /// The device does not contain any medium to perform the operation.
NoMedia = high_bit | 12, no_media = high_bit | 12,
/// The medium in the device has changed since the last access. /// The medium in the device has changed since the last access.
MediaChanged = high_bit | 13, media_changed = high_bit | 13,
/// The item was not found. /// The item was not found.
NotFound = high_bit | 14, not_found = high_bit | 14,
/// Access was denied. /// Access was denied.
AccessDenied = high_bit | 15, access_denied = high_bit | 15,
/// The server was not found or did not respond to the request. /// The server was not found or did not respond to the request.
NoResponse = high_bit | 16, no_response = high_bit | 16,
/// A mapping to a device does not exist. /// A mapping to a device does not exist.
NoMapping = high_bit | 17, no_mapping = high_bit | 17,
/// The timeout time expired. /// The timeout time expired.
Timeout = high_bit | 18, timeout = high_bit | 18,
/// The protocol has not been started. /// The protocol has not been started.
NotStarted = high_bit | 19, not_started = high_bit | 19,
/// The protocol has already been started. /// The protocol has already been started.
AlreadyStarted = high_bit | 20, already_started = high_bit | 20,
/// The operation was aborted. /// The operation was aborted.
Aborted = high_bit | 21, aborted = high_bit | 21,
/// An ICMP error occurred during the network operation. /// An ICMP error occurred during the network operation.
IcmpError = high_bit | 22, icmp_error = high_bit | 22,
/// A TFTP error occurred during the network operation. /// A TFTP error occurred during the network operation.
TftpError = high_bit | 23, tftp_error = high_bit | 23,
/// A protocol error occurred during the network operation. /// A protocol error occurred during the network operation.
ProtocolError = high_bit | 24, protocol_error = high_bit | 24,
/// The function encountered an internal version that was incompatible with a version requested by the caller. /// The function encountered an internal version that was incompatible with a version requested by the caller.
IncompatibleVersion = high_bit | 25, incompatible_version = high_bit | 25,
/// The function was not performed due to a security violation. /// The function was not performed due to a security violation.
SecurityViolation = high_bit | 26, security_violation = high_bit | 26,
/// A CRC error was detected. /// A CRC error was detected.
CrcError = high_bit | 27, crc_error = high_bit | 27,
/// Beginning or end of media was reached /// Beginning or end of media was reached
EndOfMedia = high_bit | 28, end_of_media = high_bit | 28,
/// The end of the file was reached. /// The end of the file was reached.
EndOfFile = high_bit | 31, end_of_file = high_bit | 31,
/// The language specified was invalid. /// The language specified was invalid.
InvalidLanguage = high_bit | 32, invalid_language = high_bit | 32,
/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status. /// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
CompromisedData = high_bit | 33, compromised_data = high_bit | 33,
/// There is an address conflict address allocation /// There is an address conflict address allocation
IpAddressConflict = high_bit | 34, ip_address_conflict = high_bit | 34,
/// A HTTP error occurred during the network operation. /// A HTTP error occurred during the network operation.
HttpError = high_bit | 35, http_error = high_bit | 35,
NetworkUnreachable = high_bit | 100, network_unreachable = high_bit | 100,
HostUnreachable = high_bit | 101, host_unreachable = high_bit | 101,
ProtocolUnreachable = high_bit | 102, protocol_unreachable = high_bit | 102,
PortUnreachable = high_bit | 103, port_unreachable = high_bit | 103,
ConnectionFin = high_bit | 104, connection_fin = high_bit | 104,
ConnectionReset = high_bit | 105, connection_reset = high_bit | 105,
ConnectionRefused = high_bit | 106, connection_refused = high_bit | 106,
/// The string contained one or more characters that the device could not render and were skipped. /// The string contained one or more characters that the device could not render and were skipped.
WarnUnknownGlyph = 1, warn_unknown_glyph = 1,
/// The handle was closed, but the file was not deleted. /// The handle was closed, but the file was not deleted.
WarnDeleteFailure = 2, warn_delete_failure = 2,
/// The handle was closed, but the data to the file was not flushed properly. /// The handle was closed, but the data to the file was not flushed properly.
WarnWriteFailure = 3, warn_write_failure = 3,
/// The resulting buffer was too small, and the data was truncated to the buffer size. /// The resulting buffer was too small, and the data was truncated to the buffer size.
WarnBufferTooSmall = 4, warn_buffer_too_small = 4,
/// The data has not been updated within the timeframe set by localpolicy for this type of data. /// The data has not been updated within the timeframe set by localpolicy for this type of data.
WarnStaleData = 5, warn_stale_data = 5,
/// The resulting buffer contains UEFI-compliant file system. /// The resulting buffer contains UEFI-compliant file system.
WarnFileSystem = 6, warn_file_system = 6,
/// The operation will be processed across a system reset. /// The operation will be processed across a system reset.
WarnResetRequired = 7, warn_reset_required = 7,
_, _,
pub const EfiError = error{ pub const Error = error{
LoadError, LoadError,
InvalidParameter, InvalidParameter,
Unsupported, Unsupported,
@ -185,20 +185,61 @@ pub const Status = enum(usize) {
ConnectionRefused, ConnectionRefused,
}; };
pub fn err(self: Status) EfiError!void { pub fn err(self: Status) Error!void {
inline for (@typeInfo(EfiError).error_set.?) |efi_err| { switch (self) {
if (self == @field(Status, efi_err.name)) { .load_error => return error.LoadError,
return @field(EfiError, efi_err.name); .invalid_parameter => return error.InvalidParameter,
.unsupported => return error.Unsupported,
.bad_buffer_size => return error.BadBufferSize,
.buffer_too_small => return error.BufferTooSmall,
.not_ready => return error.NotReady,
.device_error => return error.DeviceError,
.write_protected => return error.WriteProtected,
.out_of_resources => return error.OutOfResources,
.volume_corrupted => return error.VolumeCorrupted,
.volume_full => return error.VolumeFull,
.no_media => return error.NoMedia,
.media_changed => return error.MediaChanged,
.not_found => return error.NotFound,
.access_denied => return error.AccessDenied,
.no_response => return error.NoResponse,
.no_mapping => return error.NoMapping,
.timeout => return error.Timeout,
.not_started => return error.NotStarted,
.already_started => return error.AlreadyStarted,
.aborted => return error.Aborted,
.icmp_error => return error.IcmpError,
.tftp_error => return error.TftpError,
.protocol_error => return error.ProtocolError,
.incompatible_version => return error.IncompatibleVersion,
.security_violation => return error.SecurityViolation,
.crc_error => return error.CrcError,
.end_of_media => return error.EndOfMedia,
.end_of_file => return error.EndOfFile,
.invalid_language => return error.InvalidLanguage,
.compromised_data => return error.CompromisedData,
.ip_address_conflict => return error.IpAddressConflict,
.http_error => return error.HttpError,
.network_unreachable => return error.NetworkUnreachable,
.host_unreachable => return error.HostUnreachable,
.protocol_unreachable => return error.ProtocolUnreachable,
.port_unreachable => return error.PortUnreachable,
.connection_fin => return error.ConnectionFin,
.connection_reset => return error.ConnectionReset,
.connection_refused => return error.ConnectionRefused,
// success, warn_*, _
else => {},
} }
} }
// self is .Success or Warning
}
}; };
test "status" { test "status" {
var st: Status = .DeviceError; var st: Status = .device_error;
try testing.expectError(error.DeviceError, st.err()); try testing.expectError(error.DeviceError, st.err());
st = .Success; st = .success;
try st.err();
st = .warn_unknown_glyph;
try st.err(); try st.err();
} }

View File

@ -4,31 +4,31 @@ pub const ConfigurationTable = @import("tables/configuration_table.zig").Configu
pub const SystemTable = @import("tables/system_table.zig").SystemTable; pub const SystemTable = @import("tables/system_table.zig").SystemTable;
pub const TableHeader = @import("tables/table_header.zig").TableHeader; pub const TableHeader = @import("tables/table_header.zig").TableHeader;
pub const EfiEventNotify = *const fn (event: Event, ctx: *anyopaque) callconv(cc) void; pub const EventNotify = *const fn (event: Event, ctx: *anyopaque) callconv(cc) void;
pub const TimerDelay = enum(u32) { pub const TimerDelay = enum(u32) {
TimerCancel, timer_cancel,
TimerPeriodic, timer_periodic,
TimerRelative, timer_relative,
}; };
pub const MemoryType = enum(u32) { pub const MemoryType = enum(u32) {
ReservedMemoryType, reserved_memory_type,
LoaderCode, loader_code,
LoaderData, loader_data,
BootServicesCode, boot_services_code,
BootServicesData, boot_services_data,
RuntimeServicesCode, runtime_services_code,
RuntimeServicesData, runtime_services_data,
ConventionalMemory, conventional_memory,
UnusableMemory, unusable_memory,
ACPIReclaimMemory, acpi_reclaim_memory,
ACPIMemoryNVS, acpi_memory_nvs,
MemoryMappedIO, memory_mapped_io,
MemoryMappedIOPortSpace, memory_mapped_io_port_space,
PalCode, pal_code,
PersistentMemory, persistent_memory,
MaxMemoryType, max_memory_type,
_, _,
}; };
@ -60,9 +60,9 @@ pub const MemoryDescriptor = extern struct {
}; };
pub const LocateSearchType = enum(u32) { pub const LocateSearchType = enum(u32) {
AllHandles, all_handles,
ByRegisterNotify, by_register_notify,
ByProtocol, by_protocol,
}; };
pub const OpenProtocolAttributes = packed struct(u32) { pub const OpenProtocolAttributes = packed struct(u32) {
@ -82,38 +82,38 @@ pub const ProtocolInformationEntry = extern struct {
open_count: u32, open_count: u32,
}; };
pub const EfiInterfaceType = enum(u32) { pub const InterfaceType = enum(u32) {
EfiNativeInterface, efi_native_interface,
}; };
pub const AllocateType = enum(u32) { pub const AllocateType = enum(u32) {
AllocateAnyPages, allocate_any_pages,
AllocateMaxAddress, allocate_max_address,
AllocateAddress, allocate_address,
}; };
pub const EfiPhysicalAddress = u64; pub const PhysicalAddress = u64;
pub const CapsuleHeader = extern struct { pub const CapsuleHeader = extern struct {
capsuleGuid: Guid align(8), capsule_guid: Guid align(8),
headerSize: u32, header_size: u32,
flags: u32, flags: u32,
capsuleImageSize: u32, capsule_image_size: u32,
}; };
pub const UefiCapsuleBlockDescriptor = extern struct { pub const UefiCapsuleBlockDescriptor = extern struct {
length: u64, length: u64,
address: extern union { address: extern union {
dataBlock: EfiPhysicalAddress, data_block: PhysicalAddress,
continuationPointer: EfiPhysicalAddress, continuation_pointer: PhysicalAddress,
}, },
}; };
pub const ResetType = enum(u32) { pub const ResetType = enum(u32) {
ResetCold, reset_cold,
ResetWarm, reset_warm,
ResetShutdown, reset_shutdown,
ResetPlatformSpecific, reset_platform_specific,
}; };
pub const global_variable align(8) = Guid{ pub const global_variable align(8) = Guid{

View File

@ -10,11 +10,11 @@ const AllocateType = uefi.tables.AllocateType;
const MemoryType = uefi.tables.MemoryType; const MemoryType = uefi.tables.MemoryType;
const MemoryDescriptor = uefi.tables.MemoryDescriptor; const MemoryDescriptor = uefi.tables.MemoryDescriptor;
const TimerDelay = uefi.tables.TimerDelay; const TimerDelay = uefi.tables.TimerDelay;
const EfiInterfaceType = uefi.tables.EfiInterfaceType; const InterfaceType = uefi.tables.InterfaceType;
const LocateSearchType = uefi.tables.LocateSearchType; const LocateSearchType = uefi.tables.LocateSearchType;
const OpenProtocolAttributes = uefi.tables.OpenProtocolAttributes; const OpenProtocolAttributes = uefi.tables.OpenProtocolAttributes;
const ProtocolInformationEntry = uefi.tables.ProtocolInformationEntry; const ProtocolInformationEntry = uefi.tables.ProtocolInformationEntry;
const EfiEventNotify = uefi.tables.EfiEventNotify; const EventNotify = uefi.tables.EventNotify;
const cc = uefi.cc; const cc = uefi.cc;
/// Boot services are services provided by the system's firmware until the operating system takes /// Boot services are services provided by the system's firmware until the operating system takes
@ -44,7 +44,7 @@ pub const BootServices = extern struct {
freePages: *const fn (memory: [*]align(4096) u8, pages: usize) callconv(cc) Status, freePages: *const fn (memory: [*]align(4096) u8, pages: usize) callconv(cc) Status,
/// Returns the current memory map. /// Returns the current memory map.
getMemoryMap: *const fn (mmap_size: *usize, mmap: ?[*]MemoryDescriptor, mapKey: *usize, descriptor_size: *usize, descriptor_version: *u32) callconv(cc) Status, getMemoryMap: *const fn (mmap_size: *usize, mmap: ?[*]MemoryDescriptor, map_key: *usize, descriptor_size: *usize, descriptor_version: *u32) callconv(cc) Status,
/// Allocates pool memory. /// Allocates pool memory.
allocatePool: *const fn (pool_type: MemoryType, size: usize, buffer: *[*]align(8) u8) callconv(cc) Status, allocatePool: *const fn (pool_type: MemoryType, size: usize, buffer: *[*]align(8) u8) callconv(cc) Status,
@ -53,10 +53,10 @@ pub const BootServices = extern struct {
freePool: *const fn (buffer: [*]align(8) u8) callconv(cc) Status, freePool: *const fn (buffer: [*]align(8) u8) callconv(cc) Status,
/// Creates an event. /// Creates an event.
createEvent: *const fn (type: u32, notify_tpl: usize, notify_func: ?*const fn (Event, ?*anyopaque) callconv(cc) void, notifyCtx: ?*const anyopaque, event: *Event) callconv(cc) Status, createEvent: *const fn (type: u32, notify_tpl: usize, notify_func: ?*const fn (Event, ?*anyopaque) callconv(cc) void, notify_ctx: ?*const anyopaque, event: *Event) callconv(cc) Status,
/// Sets the type of timer and the trigger time for a timer event. /// Sets the type of timer and the trigger time for a timer event.
setTimer: *const fn (event: Event, type: TimerDelay, triggerTime: u64) callconv(cc) Status, setTimer: *const fn (event: Event, type: TimerDelay, trigger_time: u64) callconv(cc) Status,
/// Stops execution until an event is signaled. /// Stops execution until an event is signaled.
waitForEvent: *const fn (event_len: usize, events: [*]const Event, index: *usize) callconv(cc) Status, waitForEvent: *const fn (event_len: usize, events: [*]const Event, index: *usize) callconv(cc) Status,
@ -73,7 +73,7 @@ pub const BootServices = extern struct {
/// Installs a protocol interface on a device handle. If the handle does not exist, it is created /// Installs a protocol interface on a device handle. If the handle does not exist, it is created
/// and added to the list of handles in the system. installMultipleProtocolInterfaces() /// and added to the list of handles in the system. installMultipleProtocolInterfaces()
/// performs more error checking than installProtocolInterface(), so its use is recommended over this. /// performs more error checking than installProtocolInterface(), so its use is recommended over this.
installProtocolInterface: *const fn (handle: Handle, protocol: *align(8) const Guid, interface_type: EfiInterfaceType, interface: *anyopaque) callconv(cc) Status, installProtocolInterface: *const fn (handle: Handle, protocol: *align(8) const Guid, interface_type: InterfaceType, interface: *anyopaque) callconv(cc) Status,
/// Reinstalls a protocol interface on a device handle /// Reinstalls a protocol interface on a device handle
reinstallProtocolInterface: *const fn (handle: Handle, protocol: *align(8) const Guid, old_interface: *anyopaque, new_interface: *anyopaque) callconv(cc) Status, reinstallProtocolInterface: *const fn (handle: Handle, protocol: *align(8) const Guid, old_interface: *anyopaque, new_interface: *anyopaque) callconv(cc) Status,
@ -91,7 +91,7 @@ pub const BootServices = extern struct {
registerProtocolNotify: *const fn (protocol: *align(8) const Guid, event: Event, registration: **anyopaque) callconv(cc) Status, registerProtocolNotify: *const fn (protocol: *align(8) const Guid, event: Event, registration: **anyopaque) callconv(cc) Status,
/// Returns an array of handles that support a specified protocol. /// Returns an array of handles that support a specified protocol.
locateHandle: *const fn (search_type: LocateSearchType, protocol: ?*align(8) const Guid, search_key: ?*const anyopaque, bufferSize: *usize, buffer: [*]Handle) callconv(cc) Status, locateHandle: *const fn (search_type: LocateSearchType, protocol: ?*align(8) const Guid, search_key: ?*const anyopaque, buffer_size: *usize, buffer: [*]Handle) callconv(cc) Status,
/// Locates the handle to a device on the device path that supports the specified protocol /// Locates the handle to a device on the device path that supports the specified protocol
locateDevicePath: *const fn (protocols: *align(8) const Guid, device_path: **const DevicePathProtocol, device: *?Handle) callconv(cc) Status, locateDevicePath: *const fn (protocols: *align(8) const Guid, device_path: **const DevicePathProtocol, device: *?Handle) callconv(cc) Status,
@ -100,7 +100,7 @@ pub const BootServices = extern struct {
installConfigurationTable: *const fn (guid: *align(8) const Guid, table: ?*anyopaque) callconv(cc) Status, installConfigurationTable: *const fn (guid: *align(8) const Guid, table: ?*anyopaque) callconv(cc) Status,
/// Loads an EFI image into memory. /// Loads an EFI image into memory.
loadImage: *const fn (boot_policy: bool, parent_image_handle: Handle, device_path: ?*const DevicePathProtocol, source_buffer: ?[*]const u8, source_size: usize, imageHandle: *?Handle) callconv(cc) Status, loadImage: *const fn (boot_policy: bool, parent_image_handle: Handle, device_path: ?*const DevicePathProtocol, source_buffer: ?[*]const u8, source_size: usize, image_handle: *?Handle) callconv(cc) Status,
/// Transfers control to a loaded image's entry point. /// Transfers control to a loaded image's entry point.
startImage: *const fn (image_handle: Handle, exit_data_size: ?*usize, exit_data: ?*[*]u16) callconv(cc) Status, startImage: *const fn (image_handle: Handle, exit_data_size: ?*usize, exit_data: ?*[*]u16) callconv(cc) Status,
@ -121,7 +121,7 @@ pub const BootServices = extern struct {
stall: *const fn (microseconds: usize) callconv(cc) Status, stall: *const fn (microseconds: usize) callconv(cc) Status,
/// Sets the system's watchdog timer. /// Sets the system's watchdog timer.
setWatchdogTimer: *const fn (timeout: usize, watchdogCode: u64, data_size: usize, watchdog_data: ?[*]const u16) callconv(cc) Status, setWatchdogTimer: *const fn (timeout: usize, watchdog_code: u64, data_size: usize, watchdog_data: ?[*]const u16) callconv(cc) Status,
/// Connects one or more drives to a controller. /// Connects one or more drives to a controller.
connectController: *const fn (controller_handle: Handle, driver_image_handle: ?Handle, remaining_device_path: ?*DevicePathProtocol, recursive: bool) callconv(cc) Status, connectController: *const fn (controller_handle: Handle, driver_image_handle: ?Handle, remaining_device_path: ?*DevicePathProtocol, recursive: bool) callconv(cc) Status,
@ -133,7 +133,7 @@ pub const BootServices = extern struct {
openProtocol: *const fn (handle: Handle, protocol: *align(8) const Guid, interface: *?*anyopaque, agent_handle: ?Handle, controller_handle: ?Handle, attributes: OpenProtocolAttributes) callconv(cc) Status, openProtocol: *const fn (handle: Handle, protocol: *align(8) const Guid, interface: *?*anyopaque, agent_handle: ?Handle, controller_handle: ?Handle, attributes: OpenProtocolAttributes) callconv(cc) Status,
/// Closes a protocol on a handle that was opened using openProtocol(). /// Closes a protocol on a handle that was opened using openProtocol().
closeProtocol: *const fn (handle: Handle, protocol: *align(8) const Guid, agentHandle: Handle, controller_handle: ?Handle) callconv(cc) Status, closeProtocol: *const fn (handle: Handle, protocol: *align(8) const Guid, agent_handle: Handle, controller_handle: ?Handle) callconv(cc) Status,
/// Retrieves the list of agents that currently have a protocol interface opened. /// Retrieves the list of agents that currently have a protocol interface opened.
openProtocolInformation: *const fn (handle: Handle, protocol: *align(8) const Guid, entry_buffer: *[*]ProtocolInformationEntry, entry_count: *usize) callconv(cc) Status, openProtocolInformation: *const fn (handle: Handle, protocol: *align(8) const Guid, entry_buffer: *[*]ProtocolInformationEntry, entry_count: *usize) callconv(cc) Status,
@ -165,7 +165,7 @@ pub const BootServices = extern struct {
setMem: *const fn (buffer: [*]u8, size: usize, value: u8) callconv(cc) void, setMem: *const fn (buffer: [*]u8, size: usize, value: u8) callconv(cc) void,
/// Creates an event in a group. /// Creates an event in a group.
createEventEx: *const fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(cc) Status, createEventEx: *const fn (type: u32, notify_tpl: usize, notify_func: EventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(cc) Status,
/// Opens a protocol with a structure as the loaded image for a UEFI application /// Opens a protocol with a structure as the loaded image for a UEFI application
pub fn openProtocolSt(self: *BootServices, comptime protocol: type, handle: Handle) !*protocol { pub fn openProtocolSt(self: *BootServices, comptime protocol: type, handle: Handle) !*protocol {

View File

@ -8,7 +8,7 @@ const Status = uefi.Status;
const MemoryDescriptor = uefi.tables.MemoryDescriptor; const MemoryDescriptor = uefi.tables.MemoryDescriptor;
const ResetType = uefi.tables.ResetType; const ResetType = uefi.tables.ResetType;
const CapsuleHeader = uefi.tables.CapsuleHeader; const CapsuleHeader = uefi.tables.CapsuleHeader;
const EfiPhysicalAddress = uefi.tables.EfiPhysicalAddress; const PhysicalAddress = uefi.tables.PhysicalAddress;
const cc = uefi.cc; const cc = uefi.cc;
/// Runtime services are provided by the firmware before and after exitBootServices has been called. /// Runtime services are provided by the firmware before and after exitBootServices has been called.
@ -60,10 +60,10 @@ pub const RuntimeServices = extern struct {
/// If the payload should persist across a system reset, the reset value returned from /// If the payload should persist across a system reset, the reset value returned from
/// `queryCapsuleCapabilities` must be passed into resetSystem and will cause the capsule /// `queryCapsuleCapabilities` must be passed into resetSystem and will cause the capsule
/// to be processed by the firmware as part of the reset process. /// to be processed by the firmware as part of the reset process.
updateCapsule: *const fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, scatter_gather_list: EfiPhysicalAddress) callconv(cc) Status, updateCapsule: *const fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, scatter_gather_list: PhysicalAddress) callconv(cc) Status,
/// Returns if the capsule can be supported via `updateCapsule` /// Returns if the capsule can be supported via `updateCapsule`
queryCapsuleCapabilities: *const fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, maximum_capsule_size: *usize, resetType: ResetType) callconv(cc) Status, queryCapsuleCapabilities: *const fn (capsule_header_array: **CapsuleHeader, capsule_count: usize, maximum_capsule_size: *usize, reset_type: ResetType) callconv(cc) Status,
/// Returns information about the EFI variables /// Returns information about the EFI variables
queryVariableInfo: *const fn (attributes: *u32, maximum_variable_storage_size: *u64, remaining_variable_storage_size: *u64, maximum_variable_size: *u64) callconv(cc) Status, queryVariableInfo: *const fn (attributes: *u32, maximum_variable_storage_size: *u64, remaining_variable_storage_size: *u64, maximum_variable_size: *u64) callconv(cc) Status,

View File

@ -45,4 +45,7 @@ pub const SystemTable = extern struct {
pub const revision_2_60: u32 = (2 << 16) | 60; pub const revision_2_60: u32 = (2 << 16) | 60;
pub const revision_2_70: u32 = (2 << 16) | 70; pub const revision_2_70: u32 = (2 << 16) | 70;
pub const revision_2_80: u32 = (2 << 16) | 80; pub const revision_2_80: u32 = (2 << 16) | 80;
pub const revision_2_90: u32 = (2 << 16) | 90;
pub const revision_2_100: u32 = (2 << 16) | 100;
pub const revision_2_110: u32 = (2 << 16) | 110;
}; };

View File

@ -775,7 +775,7 @@ pub fn exit(status: u8) noreturn {
_ = bs.exit(uefi.handle, @enumFromInt(status), 0, null); _ = bs.exit(uefi.handle, @enumFromInt(status), 0, null);
} }
// If we can't exit, reboot the system instead. // If we can't exit, reboot the system instead.
uefi.system_table.runtime_services.resetSystem(.ResetCold, @enumFromInt(status), 0, null); uefi.system_table.runtime_services.resetSystem(.reset_cold, @enumFromInt(status), 0, null);
} }
system.exit(status); system.exit(status);
} }

View File

@ -64,7 +64,7 @@ pub fn nanoTimestamp() i128 {
.uefi => { .uefi => {
var value: std.os.uefi.Time = undefined; var value: std.os.uefi.Time = undefined;
const status = std.os.uefi.system_table.runtime_services.getTime(&value, null); const status = std.os.uefi.system_table.runtime_services.getTime(&value, null);
assert(status == .Success); assert(status == .success);
return value.toEpoch(); return value.toEpoch();
}, },
else => { else => {
@ -153,7 +153,7 @@ pub const Instant = struct {
.uefi => { .uefi => {
var value: std.os.uefi.Time = undefined; var value: std.os.uefi.Time = undefined;
const status = std.os.uefi.system_table.runtime_services.getTime(&value, null); const status = std.os.uefi.system_table.runtime_services.getTime(&value, null);
if (status != .Success) return error.Unsupported; if (status != .success) return error.Unsupported;
return Instant{ .timestamp = value.toEpoch() }; return Instant{ .timestamp = value.toEpoch() };
}, },
// On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while