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/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/serial_io.zig b/lib/std/os/uefi/protocol/serial_io.zig index 3f193d70e7..3df3687db5 100644 --- a/lib/std/os/uefi/protocol/serial_io.zig +++ b/lib/std/os/uefi/protocol/serial_io.zig @@ -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/status.zig b/lib/std/os/uefi/status.zig index 79a939e6b9..5d81a86f24 100644 --- a/lib/std/os/uefi/status.zig +++ b/lib/std/os/uefi/status.zig @@ -4,141 +4,141 @@ 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, _, @@ -186,19 +186,60 @@ pub const Status = enum(usize) { }; 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); - } + 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 494f72895f..fb5c8f232d 100644 --- a/lib/std/os/uefi/tables.zig +++ b/lib/std/os/uefi/tables.zig @@ -7,28 +7,28 @@ pub const TableHeader = @import("tables/table_header.zig").TableHeader; pub const EfiEventNotify = *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) { @@ -83,13 +83,13 @@ pub const ProtocolInformationEntry = extern struct { }; pub const EfiInterfaceType = enum(u32) { - EfiNativeInterface, + efi_native_interface, }; pub const AllocateType = enum(u32) { - AllocateAnyPages, - AllocateMaxAddress, - AllocateAddress, + allocate_any_pages, + allocate_max_address, + allocate_address, }; pub const EfiPhysicalAddress = u64; @@ -110,10 +110,10 @@ pub const UefiCapsuleBlockDescriptor = extern struct { }; 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/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