diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 9e5cd44513..75bad7d585 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -597,7 +597,7 @@ pub const Os = struct { .uefi => .{ .semver = .{ .min = .{ .major = 2, .minor = 0, .patch = 0 }, - .max = .{ .major = 2, .minor = 9, .patch = 0 }, + .max = .{ .major = 2, .minor = 11, .patch = 0 }, }, }, diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 9deca6de49..c36c89b206 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -611,7 +611,7 @@ pub fn defaultPanic( // 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(); @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(); }, diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig index 91f3678b26..f67fe5623e 100644 --- a/lib/std/os/uefi.zig +++ b/lib/std/os/uefi.zig @@ -9,10 +9,10 @@ pub const hii = @import("uefi/hii.zig"); pub const Status = @import("uefi/status.zig").Status; pub const tables = @import("uefi/tables.zig"); -/// The memory type to allocate when using the pool -/// Defaults to .LoaderData, the default data allocation type +/// The memory type to allocate when using the pool. +/// Defaults to `.loader_data`, the default data allocation type /// 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 raw_pool_allocator = @import("uefi/pool_allocator.zig").raw_pool_allocator; diff --git a/lib/std/os/uefi/device_path.zig b/lib/std/os/uefi/device_path.zig index e02d452b09..049084c0f7 100644 --- a/lib/std/os/uefi/device_path.zig +++ b/lib/std/os/uefi/device_path.zig @@ -230,56 +230,56 @@ pub const DevicePath = union(Type) { }; pub const Messaging = union(Subtype) { - Atapi: *const AtapiDevicePath, - Scsi: *const ScsiDevicePath, - FibreChannel: *const FibreChannelDevicePath, - FibreChannelEx: *const FibreChannelExDevicePath, + atapi: *const AtapiDevicePath, + scsi: *const ScsiDevicePath, + fibre_channel: *const FibreChannelDevicePath, + fibre_channel_ex: *const FibreChannelExDevicePath, @"1394": *const F1394DevicePath, - Usb: *const UsbDevicePath, - Sata: *const SataDevicePath, - UsbWwid: *const UsbWwidDevicePath, - Lun: *const DeviceLogicalUnitDevicePath, - UsbClass: *const UsbClassDevicePath, - I2o: *const I2oDevicePath, - MacAddress: *const MacAddressDevicePath, - Ipv4: *const Ipv4DevicePath, - Ipv6: *const Ipv6DevicePath, - Vlan: *const VlanDevicePath, - InfiniBand: *const InfiniBandDevicePath, - Uart: *const UartDevicePath, - Vendor: *const VendorDefinedDevicePath, + usb: *const UsbDevicePath, + sata: *const SataDevicePath, + usb_wwid: *const UsbWwidDevicePath, + lun: *const DeviceLogicalUnitDevicePath, + usb_class: *const UsbClassDevicePath, + i2o: *const I2oDevicePath, + mac_address: *const MacAddressDevicePath, + ipv4: *const Ipv4DevicePath, + ipv6: *const Ipv6DevicePath, + vlan: *const VlanDevicePath, + infini_band: *const InfiniBandDevicePath, + uart: *const UartDevicePath, + vendor: *const VendorDefinedDevicePath, pub const Subtype = enum(u8) { - Atapi = 1, - Scsi = 2, - FibreChannel = 3, - FibreChannelEx = 21, + atapi = 1, + scsi = 2, + fibre_channel = 3, + fibre_channel_ex = 21, @"1394" = 4, - Usb = 5, - Sata = 18, - UsbWwid = 16, - Lun = 17, - UsbClass = 15, - I2o = 6, - MacAddress = 11, - Ipv4 = 12, - Ipv6 = 13, - Vlan = 20, - InfiniBand = 9, - Uart = 14, - Vendor = 10, + usb = 5, + sata = 18, + usb_wwid = 16, + lun = 17, + usb_class = 15, + i2o = 6, + mac_address = 11, + ipv4 = 12, + ipv6 = 13, + vlan = 20, + infini_band = 9, + uart = 14, + vendor = 10, _, }; pub const AtapiDevicePath = extern struct { - const Role = enum(u8) { - Master = 0, - Slave = 1, + pub const Role = enum(u8) { + master = 0, + slave = 1, }; - const Rank = enum(u8) { - Primary = 0, - Secondary = 1, + pub const Rank = enum(u8) { + primary = 0, + secondary = 1, }; type: DevicePath.Type, @@ -528,8 +528,8 @@ pub const DevicePath = union(Type) { pub const Ipv4DevicePath = extern struct { pub const IpType = enum(u8) { - Dhcp = 0, - Static = 1, + dhcp = 0, + static = 1, }; type: DevicePath.Type, @@ -564,9 +564,9 @@ pub const DevicePath = union(Type) { pub const Ipv6DevicePath = extern struct { pub const Origin = enum(u8) { - Manual = 0, - AssignedStateless = 1, - AssignedStateful = 2, + manual = 0, + assigned_stateless = 1, + assigned_stateful = 2, }; type: DevicePath.Type, @@ -619,8 +619,8 @@ pub const DevicePath = union(Type) { pub const InfiniBandDevicePath = extern struct { pub const ResourceFlags = packed struct(u32) { pub const ControllerType = enum(u1) { - Ioc = 0, - Service = 1, + ioc = 0, + service = 1, }; ioc_or_service: ControllerType, @@ -659,20 +659,20 @@ pub const DevicePath = union(Type) { pub const UartDevicePath = extern struct { pub const Parity = enum(u8) { - Default = 0, - None = 1, - Even = 2, - Odd = 3, - Mark = 4, - Space = 5, + default = 0, + none = 1, + even = 2, + odd = 3, + mark = 4, + space = 5, _, }; pub const StopBits = enum(u8) { - Default = 0, - One = 1, - OneAndAHalf = 2, - Two = 3, + default = 0, + one = 1, + one_and_a_half = 2, + two = 3, _, }; @@ -719,40 +719,40 @@ pub const DevicePath = union(Type) { }; pub const Media = union(Subtype) { - HardDrive: *const HardDriveDevicePath, - Cdrom: *const CdromDevicePath, - Vendor: *const VendorDevicePath, - FilePath: *const FilePathDevicePath, - MediaProtocol: *const MediaProtocolDevicePath, - PiwgFirmwareFile: *const PiwgFirmwareFileDevicePath, - PiwgFirmwareVolume: *const PiwgFirmwareVolumeDevicePath, - RelativeOffsetRange: *const RelativeOffsetRangeDevicePath, - RamDisk: *const RamDiskDevicePath, + hard_drive: *const HardDriveDevicePath, + cdrom: *const CdromDevicePath, + vendor: *const VendorDevicePath, + file_path: *const FilePathDevicePath, + media_protocol: *const MediaProtocolDevicePath, + piwg_firmware_file: *const PiwgFirmwareFileDevicePath, + piwg_firmware_volume: *const PiwgFirmwareVolumeDevicePath, + relative_offset_range: *const RelativeOffsetRangeDevicePath, + ram_disk: *const RamDiskDevicePath, pub const Subtype = enum(u8) { - HardDrive = 1, - Cdrom = 2, - Vendor = 3, - FilePath = 4, - MediaProtocol = 5, - PiwgFirmwareFile = 6, - PiwgFirmwareVolume = 7, - RelativeOffsetRange = 8, - RamDisk = 9, + hard_drive = 1, + cdrom = 2, + vendor = 3, + file_path = 4, + media_protocol = 5, + piwg_firmware_file = 6, + piwg_firmware_volume = 7, + relative_offset_range = 8, + ram_disk = 9, _, }; pub const HardDriveDevicePath = extern struct { pub const Format = enum(u8) { - LegacyMbr = 0x01, - GuidPartitionTable = 0x02, + legacy_mbr = 0x01, + guid_partition_table = 0x02, }; pub const SignatureType = enum(u8) { - NoSignature = 0x00, + no_signature = 0x00, /// "32-bit signature from address 0x1b8 of the type 0x01 MBR" - MbrSignature = 0x01, - GuidSignature = 0x02, + mbr_signature = 0x01, + guid_signature = 0x02, }; type: DevicePath.Type, @@ -935,10 +935,10 @@ pub const DevicePath = union(Type) { }; pub const BiosBootSpecification = union(Subtype) { - BBS101: *const BBS101DevicePath, + bbs101: *const BBS101DevicePath, pub const Subtype = enum(u8) { - BBS101 = 1, + bbs101 = 1, _, }; @@ -967,12 +967,12 @@ pub const DevicePath = union(Type) { }; pub const End = union(Subtype) { - EndEntire: *const EndEntireDevicePath, - EndThisInstance: *const EndThisInstanceDevicePath, + end_entire: *const EndEntireDevicePath, + end_this_instance: *const EndThisInstanceDevicePath, pub const Subtype = enum(u8) { - EndEntire = 0xff, - EndThisInstance = 0x01, + end_entire = 0xff, + end_this_instance = 0x01, _, }; diff --git a/lib/std/os/uefi/pool_allocator.zig b/lib/std/os/uefi/pool_allocator.zig index 06b427e6a2..0508ad0312 100644 --- a/lib/std/os/uefi/pool_allocator.zig +++ b/lib/std/os/uefi/pool_allocator.zig @@ -29,7 +29,7 @@ const UefiPoolAllocator = struct { const full_len = metadata_len + len; 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 aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), ptr_align); @@ -118,7 +118,7 @@ fn uefi_alloc( std.debug.assert(@intFromEnum(alignment) <= 3); 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; } diff --git a/lib/std/os/uefi/protocol/block_io.zig b/lib/std/os/uefi/protocol/block_io.zig index 8e749ac949..eb204eabc5 100644 --- a/lib/std/os/uefi/protocol/block_io.zig +++ b/lib/std/os/uefi/protocol/block_io.zig @@ -7,7 +7,7 @@ pub const BlockIo = extern struct { const Self = @This(); revision: u64, - media: *EfiBlockMedia, + media: *BlockMedia, _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, @@ -43,7 +43,7 @@ pub const BlockIo = extern struct { .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. media_id: u32, diff --git a/lib/std/os/uefi/protocol/device_path.zig b/lib/std/os/uefi/protocol/device_path.zig index b59ebb7be0..49e1dc13b4 100644 --- a/lib/std/os/uefi/protocol/device_path.zig +++ b/lib/std/os/uefi/protocol/device_path.zig @@ -24,7 +24,7 @@ pub const DevicePath = extern struct { /// 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) + if (self.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(self.subtype)) == .end_entire) return null; 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). var new = @as(*uefi.DevicePath.Media.FilePathDevicePath, @ptrCast(buf.ptr + path_size - 4)); - new.type = .Media; - new.subtype = .FilePath; + new.type = .media; + new.subtype = .file_path; 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. @@ -68,8 +68,8 @@ pub const DevicePath = extern struct { ptr[path.len] = 0; var end = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@as(*DevicePath, @ptrCast(new)).next().?)); - end.type = .End; - end.subtype = .EndEntire; + end.type = .end; + end.subtype = .end_entire; end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath); return @as(*DevicePath, @ptrCast(buf.ptr)); @@ -84,7 +84,7 @@ pub const DevicePath = extern struct { if (self.type == enum_value) { const subtype = self.initSubtype(ufield.type); if (subtype) |sb| { - // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } + // e.g. return .{ .hardware = .{ .pci = @ptrCast(...) } } 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)); 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))); } } diff --git a/lib/std/os/uefi/protocol/file.zig b/lib/std/os/uefi/protocol/file.zig index 861a62880a..d69ae14ce6 100644 --- a/lib/std/os/uefi/protocol/file.zig +++ b/lib/std/os/uefi/protocol/file.zig @@ -58,7 +58,7 @@ pub const File = extern struct { fn readFn(self: *const File, buffer: []u8) ReadError!usize { 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; } @@ -68,7 +68,7 @@ pub const File = extern struct { 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; + if (.success != self.write(&size, bytes.ptr)) return WriteError.WriteError; return size; } @@ -78,7 +78,7 @@ pub const File = extern struct { fn getPos(self: *const File) GetSeekPosError!u64 { var pos: u64 = undefined; - if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; + if (.success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; return pos; } @@ -86,13 +86,13 @@ pub const File = extern struct { // preserve the old file position var 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 - 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 - if (.Success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError; + if (.success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError; // 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 end_pos; } @@ -102,13 +102,13 @@ pub const File = extern struct { } 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 { // save the old position and calculate the delta 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 amt = @abs(offset); if (seek_back) { @@ -116,7 +116,7 @@ pub const File = extern struct { } else { 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 { diff --git a/lib/std/os/uefi/protocol/graphics_output.zig b/lib/std/os/uefi/protocol/graphics_output.zig index 155428c107..dd0c248253 100644 --- a/lib/std/os/uefi/protocol/graphics_output.zig +++ b/lib/std/os/uefi/protocol/graphics_output.zig @@ -53,10 +53,10 @@ pub const GraphicsOutput = extern struct { }; pub const PixelFormat = enum(u32) { - RedGreenBlueReserved8BitPerColor, - BlueGreenRedReserved8BitPerColor, - BitMask, - BltOnly, + red_green_blue_reserved_8_bit_per_color, + blue_green_red_reserved_8_bit_per_color, + bit_mask, + blt_only, }; pub const PixelBitmask = extern struct { @@ -74,10 +74,10 @@ pub const GraphicsOutput = extern struct { }; pub const BltOperation = enum(u32) { - BltVideoFill, - BltVideoToBltBuffer, - BltBufferToVideo, - BltVideoToVideo, - GraphicsOutputBltOperationMax, + blt_video_fill, + blt_video_to_blt_buffer, + blt_buffer_to_video, + blt_video_to_video, + graphics_output_blt_operation_max, }; }; diff --git a/lib/std/os/uefi/protocol/hii_popup.zig b/lib/std/os/uefi/protocol/hii_popup.zig index bf9862658f..eac5745630 100644 --- a/lib/std/os/uefi/protocol/hii_popup.zig +++ b/lib/std/os/uefi/protocol/hii_popup.zig @@ -25,22 +25,22 @@ pub const HiiPopup = extern struct { }; pub const PopupStyle = enum(u32) { - Info, - Warning, - Error, + info, + warning, + @"error", }; pub const PopupType = enum(u32) { - Ok, - Cancel, - YesNo, - YesNoCancel, + ok, + cancel, + yes_no, + yes_no_cancel, }; pub const PopupSelection = enum(u32) { - Ok, - Cancel, - Yes, - No, + ok, + cancel, + yes, + no, }; }; diff --git a/lib/std/os/uefi/protocol/ip6.zig b/lib/std/os/uefi/protocol/ip6.zig index c2ddf9c3d2..ebb28b97c8 100644 --- a/lib/std/os/uefi/protocol/ip6.zig +++ b/lib/std/os/uefi/protocol/ip6.zig @@ -120,11 +120,11 @@ pub const Ip6 = extern struct { }; pub const NeighborState = enum(u32) { - Incomplete, - Reachable, - Stale, - Delay, - Probe, + incomplete, + reachable, + stale, + delay, + probe, }; pub const NeighborCache = extern struct { diff --git a/lib/std/os/uefi/protocol/ip6_config.zig b/lib/std/os/uefi/protocol/ip6_config.zig index 2226783fa7..ddf1d02887 100644 --- a/lib/std/os/uefi/protocol/ip6_config.zig +++ b/lib/std/os/uefi/protocol/ip6_config.zig @@ -37,12 +37,12 @@ pub const Ip6Config = extern struct { }; pub const DataType = enum(u32) { - InterfaceInfo, - AltInterfaceId, - Policy, - DupAddrDetectTransmits, - ManualAddress, - Gateway, - DnsServer, + interface_info, + alt_interface_id, + policy, + dup_addr_detect_transmits, + manual_address, + gateway, + dns_server, }; }; diff --git a/lib/std/os/uefi/protocol/managed_network.zig b/lib/std/os/uefi/protocol/managed_network.zig index e0c5dc66f4..9ea5951660 100644 --- a/lib/std/os/uefi/protocol/managed_network.zig +++ b/lib/std/os/uefi/protocol/managed_network.zig @@ -110,8 +110,8 @@ pub const ManagedNetwork = extern struct { event: Event, status: Status, packet: extern union { - RxData: *ReceiveData, - TxData: *TransmitData, + rx_data: *ReceiveData, + tx_data: *TransmitData, }, }; diff --git a/lib/std/os/uefi/protocol/serial_io.zig b/lib/std/os/uefi/protocol/serial_io.zig index c29732561f..3df3687db5 100644 --- a/lib/std/os/uefi/protocol/serial_io.zig +++ b/lib/std/os/uefi/protocol/serial_io.zig @@ -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. - pub fn setAttribute(self: *const SerialIo, baudRate: u64, receiverFifoDepth: u32, timeout: u32, parity: ParityType, dataBits: u8, stopBits: StopBitsType) Status { - return self._set_attribute(self, baudRate, receiverFifoDepth, timeout, parity, dataBits, stopBits); + 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, baud_rate, receiver_fifo_depth, timeout, parity, data_bits, stop_bits); } /// Sets the control bits on a serial device. @@ -36,13 +36,13 @@ pub const SerialIo = extern struct { } /// Writes data to a serial device. - pub fn write(self: *const SerialIo, bufferSize: *usize, buffer: *anyopaque) Status { - return self._write(self, bufferSize, buffer); + pub fn write(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status { + return self._write(self, buffer_size, buffer); } /// Reads data from a serial device. - pub fn read(self: *const SerialIo, bufferSize: *usize, buffer: *anyopaque) Status { - return self._read(self, bufferSize, buffer); + pub fn read(self: *const SerialIo, buffer_size: *usize, buffer: *anyopaque) Status { + return self._read(self, buffer_size, buffer); } pub const guid align(8) = Guid{ @@ -55,19 +55,19 @@ pub const SerialIo = extern struct { }; pub const ParityType = enum(u32) { - DefaultParity, - NoParity, - EvenParity, - OddParity, - MarkParity, - SpaceParity, + default_parity, + no_parity, + even_parity, + odd_parity, + mark_parity, + space_parity, }; pub const StopBitsType = enum(u32) { - DefaultStopBits, - OneStopBit, - OneFiveStopBits, - TwoStopBits, + default_stop_bits, + one_stop_bit, + one_five_stop_bits, + two_stop_bits, }; pub const Mode = extern struct { diff --git a/lib/std/os/uefi/protocol/simple_network.zig b/lib/std/os/uefi/protocol/simple_network.zig index 015addad81..e126576966 100644 --- a/lib/std/os/uefi/protocol/simple_network.zig +++ b/lib/std/os/uefi/protocol/simple_network.zig @@ -131,9 +131,9 @@ pub const SimpleNetwork = extern struct { }; pub const State = enum(u32) { - Stopped, - Started, - Initialized, + stopped, + started, + initialized, }; pub const Statistics = extern struct { diff --git a/lib/std/os/uefi/protocol/udp6.zig b/lib/std/os/uefi/protocol/udp6.zig index 683ec9bb01..b1623d8330 100644 --- a/lib/std/os/uefi/protocol/udp6.zig +++ b/lib/std/os/uefi/protocol/udp6.zig @@ -71,10 +71,10 @@ pub const Udp6 = extern struct { pub const CompletionToken = extern struct { event: Event, - Status: usize, + status: usize, packet: extern union { - RxData: *ReceiveData, - TxData: *TransmitData, + rx_data: *ReceiveData, + tx_data: *TransmitData, }, }; diff --git a/lib/std/os/uefi/status.zig b/lib/std/os/uefi/status.zig index 79a939e6b9..5c86520194 100644 --- a/lib/std/os/uefi/status.zig +++ b/lib/std/os/uefi/status.zig @@ -4,145 +4,145 @@ const high_bit = 1 << @typeInfo(usize).int.bits - 1; pub const Status = enum(usize) { /// The operation completed successfully. - Success = 0, + success = 0, /// The image failed to load. - LoadError = high_bit | 1, + load_error = high_bit | 1, /// A parameter was incorrect. - InvalidParameter = high_bit | 2, + invalid_parameter = high_bit | 2, /// The operation is not supported. - Unsupported = high_bit | 3, + unsupported = high_bit | 3, /// 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. - BufferTooSmall = high_bit | 5, + buffer_too_small = high_bit | 5, /// 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. - DeviceError = high_bit | 7, + device_error = high_bit | 7, /// The device cannot be written to. - WriteProtected = high_bit | 8, + write_protected = high_bit | 8, /// 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. - VolumeCorrupted = high_bit | 10, + volume_corrupted = high_bit | 10, /// 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. - NoMedia = high_bit | 12, + no_media = high_bit | 12, /// 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. - NotFound = high_bit | 14, + not_found = high_bit | 14, /// Access was denied. - AccessDenied = high_bit | 15, + access_denied = high_bit | 15, /// 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. - NoMapping = high_bit | 17, + no_mapping = high_bit | 17, /// The timeout time expired. - Timeout = high_bit | 18, + timeout = high_bit | 18, /// The protocol has not been started. - NotStarted = high_bit | 19, + not_started = high_bit | 19, /// The protocol has already been started. - AlreadyStarted = high_bit | 20, + already_started = high_bit | 20, /// The operation was aborted. - Aborted = high_bit | 21, + aborted = high_bit | 21, /// 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. - TftpError = high_bit | 23, + tftp_error = high_bit | 23, /// 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. - IncompatibleVersion = high_bit | 25, + incompatible_version = high_bit | 25, /// The function was not performed due to a security violation. - SecurityViolation = high_bit | 26, + security_violation = high_bit | 26, /// A CRC error was detected. - CrcError = high_bit | 27, + crc_error = high_bit | 27, /// Beginning or end of media was reached - EndOfMedia = high_bit | 28, + end_of_media = high_bit | 28, /// The end of the file was reached. - EndOfFile = high_bit | 31, + end_of_file = high_bit | 31, /// 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. - CompromisedData = high_bit | 33, + compromised_data = high_bit | 33, /// 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. - 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. - WarnUnknownGlyph = 1, + warn_unknown_glyph = 1, /// 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. - WarnWriteFailure = 3, + warn_write_failure = 3, /// 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. - WarnStaleData = 5, + warn_stale_data = 5, /// The resulting buffer contains UEFI-compliant file system. - WarnFileSystem = 6, + warn_file_system = 6, /// The operation will be processed across a system reset. - WarnResetRequired = 7, + warn_reset_required = 7, _, - pub const EfiError = error{ + pub const Error = error{ LoadError, InvalidParameter, Unsupported, @@ -185,20 +185,61 @@ pub const Status = enum(usize) { ConnectionRefused, }; - pub fn err(self: Status) EfiError!void { - inline for (@typeInfo(EfiError).error_set.?) |efi_err| { - if (self == @field(Status, efi_err.name)) { - return @field(EfiError, efi_err.name); - } + pub fn err(self: Status) Error!void { + switch (self) { + .load_error => return error.LoadError, + .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" { - var st: Status = .DeviceError; + var st: Status = .device_error; try testing.expectError(error.DeviceError, st.err()); - st = .Success; + st = .success; + try st.err(); + + st = .warn_unknown_glyph; try st.err(); } diff --git a/lib/std/os/uefi/tables.zig b/lib/std/os/uefi/tables.zig index e4f651104c..0e0a1e0aa8 100644 --- a/lib/std/os/uefi/tables.zig +++ b/lib/std/os/uefi/tables.zig @@ -4,31 +4,31 @@ pub const ConfigurationTable = @import("tables/configuration_table.zig").Configu pub const SystemTable = @import("tables/system_table.zig").SystemTable; 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) { - TimerCancel, - TimerPeriodic, - TimerRelative, + timer_cancel, + timer_periodic, + timer_relative, }; pub const MemoryType = enum(u32) { - ReservedMemoryType, - LoaderCode, - LoaderData, - BootServicesCode, - BootServicesData, - RuntimeServicesCode, - RuntimeServicesData, - ConventionalMemory, - UnusableMemory, - ACPIReclaimMemory, - ACPIMemoryNVS, - MemoryMappedIO, - MemoryMappedIOPortSpace, - PalCode, - PersistentMemory, - MaxMemoryType, + reserved_memory_type, + loader_code, + loader_data, + boot_services_code, + boot_services_data, + runtime_services_code, + runtime_services_data, + conventional_memory, + unusable_memory, + acpi_reclaim_memory, + acpi_memory_nvs, + memory_mapped_io, + memory_mapped_io_port_space, + pal_code, + persistent_memory, + max_memory_type, _, }; @@ -60,9 +60,9 @@ pub const MemoryDescriptor = extern struct { }; pub const LocateSearchType = enum(u32) { - AllHandles, - ByRegisterNotify, - ByProtocol, + all_handles, + by_register_notify, + by_protocol, }; pub const OpenProtocolAttributes = packed struct(u32) { @@ -82,38 +82,38 @@ pub const ProtocolInformationEntry = extern struct { open_count: u32, }; -pub const EfiInterfaceType = enum(u32) { - EfiNativeInterface, +pub const InterfaceType = enum(u32) { + efi_native_interface, }; pub const AllocateType = enum(u32) { - AllocateAnyPages, - AllocateMaxAddress, - AllocateAddress, + allocate_any_pages, + allocate_max_address, + allocate_address, }; -pub const EfiPhysicalAddress = u64; +pub const PhysicalAddress = u64; pub const CapsuleHeader = extern struct { - capsuleGuid: Guid align(8), - headerSize: u32, + capsule_guid: Guid align(8), + header_size: u32, flags: u32, - capsuleImageSize: u32, + capsule_image_size: u32, }; pub const UefiCapsuleBlockDescriptor = extern struct { length: u64, address: extern union { - dataBlock: EfiPhysicalAddress, - continuationPointer: EfiPhysicalAddress, + data_block: PhysicalAddress, + continuation_pointer: PhysicalAddress, }, }; pub const ResetType = enum(u32) { - ResetCold, - ResetWarm, - ResetShutdown, - ResetPlatformSpecific, + reset_cold, + reset_warm, + reset_shutdown, + reset_platform_specific, }; pub const global_variable align(8) = Guid{ diff --git a/lib/std/os/uefi/tables/boot_services.zig b/lib/std/os/uefi/tables/boot_services.zig index 4ef346db41..c889ce3ffe 100644 --- a/lib/std/os/uefi/tables/boot_services.zig +++ b/lib/std/os/uefi/tables/boot_services.zig @@ -10,11 +10,11 @@ const AllocateType = uefi.tables.AllocateType; const MemoryType = uefi.tables.MemoryType; const MemoryDescriptor = uefi.tables.MemoryDescriptor; const TimerDelay = uefi.tables.TimerDelay; -const EfiInterfaceType = uefi.tables.EfiInterfaceType; +const InterfaceType = uefi.tables.InterfaceType; const LocateSearchType = uefi.tables.LocateSearchType; const OpenProtocolAttributes = uefi.tables.OpenProtocolAttributes; const ProtocolInformationEntry = uefi.tables.ProtocolInformationEntry; -const EfiEventNotify = uefi.tables.EfiEventNotify; +const EventNotify = uefi.tables.EventNotify; const cc = uefi.cc; /// 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, /// 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. 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, /// 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. - 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. 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 /// and added to the list of handles in the system. installMultipleProtocolInterfaces() /// 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 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, /// 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 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, /// 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. 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, /// 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. 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, /// 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. 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, /// 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 pub fn openProtocolSt(self: *BootServices, comptime protocol: type, handle: Handle) !*protocol { diff --git a/lib/std/os/uefi/tables/runtime_services.zig b/lib/std/os/uefi/tables/runtime_services.zig index 264bfa0813..2beae3b5c5 100644 --- a/lib/std/os/uefi/tables/runtime_services.zig +++ b/lib/std/os/uefi/tables/runtime_services.zig @@ -8,7 +8,7 @@ const Status = uefi.Status; const MemoryDescriptor = uefi.tables.MemoryDescriptor; const ResetType = uefi.tables.ResetType; const CapsuleHeader = uefi.tables.CapsuleHeader; -const EfiPhysicalAddress = uefi.tables.EfiPhysicalAddress; +const PhysicalAddress = uefi.tables.PhysicalAddress; const cc = uefi.cc; /// 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 /// `queryCapsuleCapabilities` must be passed into resetSystem and will cause the capsule /// 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` - 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 queryVariableInfo: *const fn (attributes: *u32, maximum_variable_storage_size: *u64, remaining_variable_storage_size: *u64, maximum_variable_size: *u64) callconv(cc) Status, diff --git a/lib/std/os/uefi/tables/system_table.zig b/lib/std/os/uefi/tables/system_table.zig index 9a70618730..25240680ca 100644 --- a/lib/std/os/uefi/tables/system_table.zig +++ b/lib/std/os/uefi/tables/system_table.zig @@ -45,4 +45,7 @@ pub const SystemTable = extern struct { pub const revision_2_60: u32 = (2 << 16) | 60; pub const revision_2_70: u32 = (2 << 16) | 70; 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; }; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index a1409705bf..9249691950 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -775,7 +775,7 @@ pub fn exit(status: u8) noreturn { _ = bs.exit(uefi.handle, @enumFromInt(status), 0, null); } // 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); } diff --git a/lib/std/time.zig b/lib/std/time.zig index 3dbe2e837b..9db28e0076 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -64,7 +64,7 @@ pub fn nanoTimestamp() i128 { .uefi => { var value: std.os.uefi.Time = undefined; const status = std.os.uefi.system_table.runtime_services.getTime(&value, null); - assert(status == .Success); + assert(status == .success); return value.toEpoch(); }, else => { @@ -153,7 +153,7 @@ pub const Instant = struct { .uefi => { var value: std.os.uefi.Time = undefined; 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() }; }, // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while