| author | |
| committer | |
| log | 8944935499ee6cdbce6e0384efb32e75753adcbd |
| tree | 11394e6151a7ba58156d2f69e30f9aa107303b62 |
| parent | 776cd673f206099012d789fd5d05d49dd72b9faa |
This eliminates some simple usages of `usingnamespace` in the standard
library. This construct may in future be removed from the language, and
is generally an inappropriate way to formulate code. It is also
problematic for incremental compilation, which may not initially support
projects using it.
I wasn't entirely sure what the appropriate namespacing for the types in
`std.os.uefi.tables` would be, so I ofted to preserve the current
namespacing, meaning this is not a breaking change. It's possible some
of the moved types should instead be namespaced under `BootServices`
etc, but this can be a future enhancement.7 files changed, 226 insertions(+), 210 deletions(-)
lib/std/fifo.zig+34-31| ... | @@ -46,39 +46,42 @@ pub fn LinearFifo( | ... | @@ -46,39 +46,42 @@ pub fn LinearFifo( |
| 46 | // returned a slice into a copy on the stack | 46 | // returned a slice into a copy on the stack |
| 47 | const SliceSelfArg = if (buffer_type == .Static) *Self else Self; | 47 | const SliceSelfArg = if (buffer_type == .Static) *Self else Self; |
| 48 | 48 | ||
| 49 | pub usingnamespace switch (buffer_type) { | 49 | pub const init = switch (buffer_type) { |
| 50 | .Static => struct { | 50 | .Static => initStatic, |
| 51 | pub fn init() Self { | 51 | .Slice => initSlice, |
| 52 | return .{ | 52 | .Dynamic => initDynamic, |
| 53 | .allocator = {}, | ||
| 54 | .buf = undefined, | ||
| 55 | .head = 0, | ||
| 56 | .count = 0, | ||
| 57 | }; | ||
| 58 | } | ||
| 59 | }, | ||
| 60 | .Slice => struct { | ||
| 61 | pub fn init(buf: []T) Self { | ||
| 62 | return .{ | ||
| 63 | .allocator = {}, | ||
| 64 | .buf = buf, | ||
| 65 | .head = 0, | ||
| 66 | .count = 0, | ||
| 67 | }; | ||
| 68 | } | ||
| 69 | }, | ||
| 70 | .Dynamic => struct { | ||
| 71 | pub fn init(allocator: Allocator) Self { | ||
| 72 | return .{ | ||
| 73 | .allocator = allocator, | ||
| 74 | .buf = &[_]T{}, | ||
| 75 | .head = 0, | ||
| 76 | .count = 0, | ||
| 77 | }; | ||
| 78 | } | ||
| 79 | }, | ||
| 80 | }; | 53 | }; |
| 81 | 54 | ||
| 55 | fn initStatic() Self { | ||
| 56 | comptime assert(buffer_type == .Static); | ||
| 57 | return .{ | ||
| 58 | .allocator = {}, | ||
| 59 | .buf = undefined, | ||
| 60 | .head = 0, | ||
| 61 | .count = 0, | ||
| 62 | }; | ||
| 63 | } | ||
| 64 | |||
| 65 | fn initSlice(buf: []T) Self { | ||
| 66 | comptime assert(buffer_type == .Slice); | ||
| 67 | return .{ | ||
| 68 | .allocator = {}, | ||
| 69 | .buf = buf, | ||
| 70 | .head = 0, | ||
| 71 | .count = 0, | ||
| 72 | }; | ||
| 73 | } | ||
| 74 | |||
| 75 | fn initDynamic(allocator: Allocator) Self { | ||
| 76 | comptime assert(buffer_type == .Dynamic); | ||
| 77 | return .{ | ||
| 78 | .allocator = allocator, | ||
| 79 | .buf = &.{}, | ||
| 80 | .head = 0, | ||
| 81 | .count = 0, | ||
| 82 | }; | ||
| 83 | } | ||
| 84 | |||
| 82 | pub fn deinit(self: Self) void { | 85 | pub fn deinit(self: Self) void { |
| 83 | if (buffer_type == .Dynamic) self.allocator.free(self.buf); | 86 | if (buffer_type == .Dynamic) self.allocator.free(self.buf); |
| 84 | } | 87 | } |
lib/std/heap.zig+6-17| ... | @@ -38,25 +38,14 @@ const CAllocator = struct { | ... | @@ -38,25 +38,14 @@ const CAllocator = struct { |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | usingnamespace if (@hasDecl(c, "malloc_size")) | 41 | pub const supports_malloc_size = @TypeOf(malloc_size) != void; |
| 42 | struct { | 42 | pub const malloc_size = if (@hasDecl(c, "malloc_size")) |
| 43 | pub const supports_malloc_size = true; | 43 | c.malloc_size |
| 44 | pub const malloc_size = c.malloc_size; | ||
| 45 | } | ||
| 46 | else if (@hasDecl(c, "malloc_usable_size")) | 44 | else if (@hasDecl(c, "malloc_usable_size")) |
| 47 | struct { | 45 | c.malloc_usable_size |
| 48 | pub const supports_malloc_size = true; | ||
| 49 | pub const malloc_size = c.malloc_usable_size; | ||
| 50 | } | ||
| 51 | else if (@hasDecl(c, "_msize")) | 46 | else if (@hasDecl(c, "_msize")) |
| 52 | struct { | 47 | c._msize |
| 53 | pub const supports_malloc_size = true; | 48 | else {}; |
| 54 | pub const malloc_size = c._msize; | ||
| 55 | } | ||
| 56 | else | ||
| 57 | struct { | ||
| 58 | pub const supports_malloc_size = false; | ||
| 59 | }; | ||
| 60 | 49 | ||
| 61 | pub const supports_posix_memalign = @hasDecl(c, "posix_memalign"); | 50 | pub const supports_posix_memalign = @hasDecl(c, "posix_memalign"); |
| 62 | 51 |
lib/std/heap/general_purpose_allocator.zig+11-10| ... | @@ -454,18 +454,19 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -454,18 +454,19 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 454 | } | 454 | } |
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | pub usingnamespace if (config.retain_metadata) struct { | 457 | pub fn flushRetainedMetadata(self: *Self) void { |
| 458 | pub fn flushRetainedMetadata(self: *Self) void { | 458 | if (!config.retain_metadata) { |
| 459 | self.freeRetainedMetadata(); | 459 | @compileError("'flushRetainedMetadata' requires 'config.retain_metadata = true'"); |
| 460 | // also remove entries from large_allocations | 460 | } |
| 461 | var it = self.large_allocations.iterator(); | 461 | self.freeRetainedMetadata(); |
| 462 | while (it.next()) |large| { | 462 | // also remove entries from large_allocations |
| 463 | if (large.value_ptr.freed) { | 463 | var it = self.large_allocations.iterator(); |
| 464 | _ = self.large_allocations.remove(@intFromPtr(large.value_ptr.bytes.ptr)); | 464 | while (it.next()) |large| { |
| 465 | } | 465 | if (large.value_ptr.freed) { |
| 466 | _ = self.large_allocations.remove(@intFromPtr(large.value_ptr.bytes.ptr)); | ||
| 466 | } | 467 | } |
| 467 | } | 468 | } |
| 468 | } else struct {}; | 469 | } |
| 469 | 470 | ||
| 470 | /// Returns `Check.leak` if there were leaks; `Check.ok` otherwise. | 471 | /// Returns `Check.leak` if there were leaks; `Check.ok` otherwise. |
| 471 | pub fn deinit(self: *Self) Check { | 472 | pub fn deinit(self: *Self) Check { |
lib/std/io/peek_stream.zig+29-25| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const assert = std.debug.assert; | ||
| 2 | const io = std.io; | 3 | const io = std.io; |
| 3 | const mem = std.mem; | 4 | const mem = std.mem; |
| 4 | const testing = std.testing; | 5 | const testing = std.testing; |
| ... | @@ -20,33 +21,36 @@ pub fn PeekStream( | ... | @@ -20,33 +21,36 @@ pub fn PeekStream( |
| 20 | const Self = @This(); | 21 | const Self = @This(); |
| 21 | const FifoType = std.fifo.LinearFifo(u8, buffer_type); | 22 | const FifoType = std.fifo.LinearFifo(u8, buffer_type); |
| 22 | 23 | ||
| 23 | pub usingnamespace switch (buffer_type) { | 24 | pub const init = switch (buffer_type) { |
| 24 | .Static => struct { | 25 | .Static => initStatic, |
| 25 | pub fn init(base: ReaderType) Self { | 26 | .Slice => initSlice, |
| 26 | return .{ | 27 | .Dynamic => initDynamic, |
| 27 | .unbuffered_reader = base, | ||
| 28 | .fifo = FifoType.init(), | ||
| 29 | }; | ||
| 30 | } | ||
| 31 | }, | ||
| 32 | .Slice => struct { | ||
| 33 | pub fn init(base: ReaderType, buf: []u8) Self { | ||
| 34 | return .{ | ||
| 35 | .unbuffered_reader = base, | ||
| 36 | .fifo = FifoType.init(buf), | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | }, | ||
| 40 | .Dynamic => struct { | ||
| 41 | pub fn init(base: ReaderType, allocator: mem.Allocator) Self { | ||
| 42 | return .{ | ||
| 43 | .unbuffered_reader = base, | ||
| 44 | .fifo = FifoType.init(allocator), | ||
| 45 | }; | ||
| 46 | } | ||
| 47 | }, | ||
| 48 | }; | 28 | }; |
| 49 | 29 | ||
| 30 | fn initStatic(base: ReaderType) Self { | ||
| 31 | comptime assert(buffer_type == .Static); | ||
| 32 | return .{ | ||
| 33 | .unbuffered_reader = base, | ||
| 34 | .fifo = FifoType.init(), | ||
| 35 | }; | ||
| 36 | } | ||
| 37 | |||
| 38 | fn initSlice(base: ReaderType, buf: []u8) Self { | ||
| 39 | comptime assert(buffer_type == .Slice); | ||
| 40 | return .{ | ||
| 41 | .unbuffered_reader = base, | ||
| 42 | .fifo = FifoType.init(buf), | ||
| 43 | }; | ||
| 44 | } | ||
| 45 | |||
| 46 | fn initDynamic(base: ReaderType, allocator: mem.Allocator) Self { | ||
| 47 | comptime assert(buffer_type == .Dynamic); | ||
| 48 | return .{ | ||
| 49 | .unbuffered_reader = base, | ||
| 50 | .fifo = FifoType.init(allocator), | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 50 | pub fn putBackByte(self: *Self, byte: u8) !void { | 54 | pub fn putBackByte(self: *Self, byte: u8) !void { |
| 51 | try self.putBack(&[_]u8{byte}); | 55 | try self.putBack(&[_]u8{byte}); |
| 52 | } | 56 | } |
lib/std/os/uefi/tables.zig+134-6| ... | @@ -1,9 +1,137 @@ | ... | @@ -1,9 +1,137 @@ |
| 1 | pub usingnamespace @import("tables/boot_services.zig"); | 1 | pub const BootServices = @import("tables/boot_services.zig").BootServices; |
| 2 | pub usingnamespace @import("tables/runtime_services.zig"); | 2 | pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices; |
| 3 | pub usingnamespace @import("tables/configuration_table.zig"); | 3 | pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable; |
| 4 | pub usingnamespace @import("tables/system_table.zig"); | 4 | pub const SystemTable = @import("tables/system_table.zig").SystemTable; |
| 5 | pub usingnamespace @import("tables/table_header.zig"); | 5 | pub const TableHeader = @import("tables/table_header.zig").TableHeader; |
| 6 | |||
| 7 | pub const EfiEventNotify = *const fn (event: Event, ctx: *anyopaque) callconv(cc) void; | ||
| 8 | |||
| 9 | pub const TimerDelay = enum(u32) { | ||
| 10 | TimerCancel, | ||
| 11 | TimerPeriodic, | ||
| 12 | TimerRelative, | ||
| 13 | }; | ||
| 14 | |||
| 15 | pub const MemoryType = enum(u32) { | ||
| 16 | ReservedMemoryType, | ||
| 17 | LoaderCode, | ||
| 18 | LoaderData, | ||
| 19 | BootServicesCode, | ||
| 20 | BootServicesData, | ||
| 21 | RuntimeServicesCode, | ||
| 22 | RuntimeServicesData, | ||
| 23 | ConventionalMemory, | ||
| 24 | UnusableMemory, | ||
| 25 | ACPIReclaimMemory, | ||
| 26 | ACPIMemoryNVS, | ||
| 27 | MemoryMappedIO, | ||
| 28 | MemoryMappedIOPortSpace, | ||
| 29 | PalCode, | ||
| 30 | PersistentMemory, | ||
| 31 | MaxMemoryType, | ||
| 32 | _, | ||
| 33 | }; | ||
| 34 | |||
| 35 | pub const MemoryDescriptorAttribute = packed struct(u64) { | ||
| 36 | uc: bool, | ||
| 37 | wc: bool, | ||
| 38 | wt: bool, | ||
| 39 | wb: bool, | ||
| 40 | uce: bool, | ||
| 41 | _pad1: u7 = 0, | ||
| 42 | wp: bool, | ||
| 43 | rp: bool, | ||
| 44 | xp: bool, | ||
| 45 | nv: bool, | ||
| 46 | more_reliable: bool, | ||
| 47 | ro: bool, | ||
| 48 | sp: bool, | ||
| 49 | cpu_crypto: bool, | ||
| 50 | _pad2: u43 = 0, | ||
| 51 | memory_runtime: bool, | ||
| 52 | }; | ||
| 53 | |||
| 54 | pub const MemoryDescriptor = extern struct { | ||
| 55 | type: MemoryType, | ||
| 56 | physical_start: u64, | ||
| 57 | virtual_start: u64, | ||
| 58 | number_of_pages: u64, | ||
| 59 | attribute: MemoryDescriptorAttribute, | ||
| 60 | }; | ||
| 61 | |||
| 62 | pub const LocateSearchType = enum(u32) { | ||
| 63 | AllHandles, | ||
| 64 | ByRegisterNotify, | ||
| 65 | ByProtocol, | ||
| 66 | }; | ||
| 67 | |||
| 68 | pub const OpenProtocolAttributes = packed struct(u32) { | ||
| 69 | by_handle_protocol: bool = false, | ||
| 70 | get_protocol: bool = false, | ||
| 71 | test_protocol: bool = false, | ||
| 72 | by_child_controller: bool = false, | ||
| 73 | by_driver: bool = false, | ||
| 74 | exclusive: bool = false, | ||
| 75 | reserved: u26 = 0, | ||
| 76 | }; | ||
| 77 | |||
| 78 | pub const ProtocolInformationEntry = extern struct { | ||
| 79 | agent_handle: ?Handle, | ||
| 80 | controller_handle: ?Handle, | ||
| 81 | attributes: OpenProtocolAttributes, | ||
| 82 | open_count: u32, | ||
| 83 | }; | ||
| 84 | |||
| 85 | pub const EfiInterfaceType = enum(u32) { | ||
| 86 | EfiNativeInterface, | ||
| 87 | }; | ||
| 88 | |||
| 89 | pub const AllocateType = enum(u32) { | ||
| 90 | AllocateAnyPages, | ||
| 91 | AllocateMaxAddress, | ||
| 92 | AllocateAddress, | ||
| 93 | }; | ||
| 94 | |||
| 95 | const EfiPhysicalAddress = u64; | ||
| 96 | |||
| 97 | pub const CapsuleHeader = extern struct { | ||
| 98 | capsuleGuid: Guid align(8), | ||
| 99 | headerSize: u32, | ||
| 100 | flags: u32, | ||
| 101 | capsuleImageSize: u32, | ||
| 102 | }; | ||
| 103 | |||
| 104 | pub const UefiCapsuleBlockDescriptor = extern struct { | ||
| 105 | length: u64, | ||
| 106 | address: extern union { | ||
| 107 | dataBlock: EfiPhysicalAddress, | ||
| 108 | continuationPointer: EfiPhysicalAddress, | ||
| 109 | }, | ||
| 110 | }; | ||
| 111 | |||
| 112 | pub const ResetType = enum(u32) { | ||
| 113 | ResetCold, | ||
| 114 | ResetWarm, | ||
| 115 | ResetShutdown, | ||
| 116 | ResetPlatformSpecific, | ||
| 117 | }; | ||
| 118 | |||
| 119 | pub const global_variable align(8) = Guid{ | ||
| 120 | .time_low = 0x8be4df61, | ||
| 121 | .time_mid = 0x93ca, | ||
| 122 | .time_high_and_version = 0x11d2, | ||
| 123 | .clock_seq_high_and_reserved = 0xaa, | ||
| 124 | .clock_seq_low = 0x0d, | ||
| 125 | .node = [_]u8{ 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c }, | ||
| 126 | }; | ||
| 6 | 127 | ||
| 7 | test { | 128 | test { |
| 8 | @import("std").testing.refAllDeclsRecursive(@This()); | 129 | std.testing.refAllDeclsRecursive(@This()); |
| 9 | } | 130 | } |
| 131 | |||
| 132 | const std = @import("std"); | ||
| 133 | const uefi = std.os.uefi; | ||
| 134 | const Handle = uefi.Handle; | ||
| 135 | const Event = uefi.Event; | ||
| 136 | const Guid = uefi.Guid; | ||
| 137 | const cc = uefi.cc; |
lib/std/os/uefi/tables/boot_services.zig+9-88| ... | @@ -6,6 +6,15 @@ const Handle = uefi.Handle; | ... | @@ -6,6 +6,15 @@ const Handle = uefi.Handle; |
| 6 | const Status = uefi.Status; | 6 | const Status = uefi.Status; |
| 7 | const TableHeader = uefi.tables.TableHeader; | 7 | const TableHeader = uefi.tables.TableHeader; |
| 8 | const DevicePathProtocol = uefi.protocol.DevicePath; | 8 | const DevicePathProtocol = uefi.protocol.DevicePath; |
| 9 | const AllocateType = uefi.tables.AllocateType; | ||
| 10 | const MemoryType = uefi.tables.MemoryType; | ||
| 11 | const MemoryDescriptor = uefi.tables.MemoryDescriptor; | ||
| 12 | const TimerDelay = uefi.tables.TimerDelay; | ||
| 13 | const EfiInterfaceType = uefi.tables.EfiInterfaceType; | ||
| 14 | const LocateSearchType = uefi.tables.LocateSearchType; | ||
| 15 | const OpenProtocolAttributes = uefi.tables.OpenProtocolAttributes; | ||
| 16 | const ProtocolInformationEntry = uefi.tables.ProtocolInformationEntry; | ||
| 17 | const EfiEventNotify = uefi.tables.EfiEventNotify; | ||
| 9 | const cc = uefi.cc; | 18 | const cc = uefi.cc; |
| 10 | 19 | ||
| 11 | /// Boot services are services provided by the system's firmware until the operating system takes | 20 | /// Boot services are services provided by the system's firmware until the operating system takes |
| ... | @@ -193,91 +202,3 @@ pub const BootServices = extern struct { | ... | @@ -193,91 +202,3 @@ pub const BootServices = extern struct { |
| 193 | pub const tpl_notify: usize = 16; | 202 | pub const tpl_notify: usize = 16; |
| 194 | pub const tpl_high_level: usize = 31; | 203 | pub const tpl_high_level: usize = 31; |
| 195 | }; | 204 | }; |
| 196 | |||
| 197 | pub const EfiEventNotify = *const fn (event: Event, ctx: *anyopaque) callconv(cc) void; | ||
| 198 | |||
| 199 | pub const TimerDelay = enum(u32) { | ||
| 200 | TimerCancel, | ||
| 201 | TimerPeriodic, | ||
| 202 | TimerRelative, | ||
| 203 | }; | ||
| 204 | |||
| 205 | pub const MemoryType = enum(u32) { | ||
| 206 | ReservedMemoryType, | ||
| 207 | LoaderCode, | ||
| 208 | LoaderData, | ||
| 209 | BootServicesCode, | ||
| 210 | BootServicesData, | ||
| 211 | RuntimeServicesCode, | ||
| 212 | RuntimeServicesData, | ||
| 213 | ConventionalMemory, | ||
| 214 | UnusableMemory, | ||
| 215 | ACPIReclaimMemory, | ||
| 216 | ACPIMemoryNVS, | ||
| 217 | MemoryMappedIO, | ||
| 218 | MemoryMappedIOPortSpace, | ||
| 219 | PalCode, | ||
| 220 | PersistentMemory, | ||
| 221 | MaxMemoryType, | ||
| 222 | _, | ||
| 223 | }; | ||
| 224 | |||
| 225 | pub const MemoryDescriptorAttribute = packed struct(u64) { | ||
| 226 | uc: bool, | ||
| 227 | wc: bool, | ||
| 228 | wt: bool, | ||
| 229 | wb: bool, | ||
| 230 | uce: bool, | ||
| 231 | _pad1: u7 = 0, | ||
| 232 | wp: bool, | ||
| 233 | rp: bool, | ||
| 234 | xp: bool, | ||
| 235 | nv: bool, | ||
| 236 | more_reliable: bool, | ||
| 237 | ro: bool, | ||
| 238 | sp: bool, | ||
| 239 | cpu_crypto: bool, | ||
| 240 | _pad2: u43 = 0, | ||
| 241 | memory_runtime: bool, | ||
| 242 | }; | ||
| 243 | |||
| 244 | pub const MemoryDescriptor = extern struct { | ||
| 245 | type: MemoryType, | ||
| 246 | physical_start: u64, | ||
| 247 | virtual_start: u64, | ||
| 248 | number_of_pages: u64, | ||
| 249 | attribute: MemoryDescriptorAttribute, | ||
| 250 | }; | ||
| 251 | |||
| 252 | pub const LocateSearchType = enum(u32) { | ||
| 253 | AllHandles, | ||
| 254 | ByRegisterNotify, | ||
| 255 | ByProtocol, | ||
| 256 | }; | ||
| 257 | |||
| 258 | pub const OpenProtocolAttributes = packed struct(u32) { | ||
| 259 | by_handle_protocol: bool = false, | ||
| 260 | get_protocol: bool = false, | ||
| 261 | test_protocol: bool = false, | ||
| 262 | by_child_controller: bool = false, | ||
| 263 | by_driver: bool = false, | ||
| 264 | exclusive: bool = false, | ||
| 265 | reserved: u26 = 0, | ||
| 266 | }; | ||
| 267 | |||
| 268 | pub const ProtocolInformationEntry = extern struct { | ||
| 269 | agent_handle: ?Handle, | ||
| 270 | controller_handle: ?Handle, | ||
| 271 | attributes: OpenProtocolAttributes, | ||
| 272 | open_count: u32, | ||
| 273 | }; | ||
| 274 | |||
| 275 | pub const EfiInterfaceType = enum(u32) { | ||
| 276 | EfiNativeInterface, | ||
| 277 | }; | ||
| 278 | |||
| 279 | pub const AllocateType = enum(u32) { | ||
| 280 | AllocateAnyPages, | ||
| 281 | AllocateMaxAddress, | ||
| 282 | AllocateAddress, | ||
| 283 | }; |
lib/std/os/uefi/tables/runtime_services.zig+3-33| ... | @@ -6,6 +6,9 @@ const Time = uefi.Time; | ... | @@ -6,6 +6,9 @@ const Time = uefi.Time; |
| 6 | const TimeCapabilities = uefi.TimeCapabilities; | 6 | const TimeCapabilities = uefi.TimeCapabilities; |
| 7 | const Status = uefi.Status; | 7 | const Status = uefi.Status; |
| 8 | const MemoryDescriptor = uefi.tables.MemoryDescriptor; | 8 | const MemoryDescriptor = uefi.tables.MemoryDescriptor; |
| 9 | const ResetType = uefi.tables.ResetType; | ||
| 10 | const CapsuleHeader = uefi.tables.CapsuleHeader; | ||
| 11 | const EfiPhysicalAddress = uefi.tables.EfiPhysicalAddress; | ||
| 9 | const cc = uefi.cc; | 12 | const cc = uefi.cc; |
| 10 | 13 | ||
| 11 | /// Runtime services are provided by the firmware before and after exitBootServices has been called. | 14 | /// Runtime services are provided by the firmware before and after exitBootServices has been called. |
| ... | @@ -67,36 +70,3 @@ pub const RuntimeServices = extern struct { | ... | @@ -67,36 +70,3 @@ pub const RuntimeServices = extern struct { |
| 67 | 70 | ||
| 68 | pub const signature: u64 = 0x56524553544e5552; | 71 | pub const signature: u64 = 0x56524553544e5552; |
| 69 | }; | 72 | }; |
| 70 | |||
| 71 | const EfiPhysicalAddress = u64; | ||
| 72 | |||
| 73 | pub const CapsuleHeader = extern struct { | ||
| 74 | capsuleGuid: Guid align(8), | ||
| 75 | headerSize: u32, | ||
| 76 | flags: u32, | ||
| 77 | capsuleImageSize: u32, | ||
| 78 | }; | ||
| 79 | |||
| 80 | pub const UefiCapsuleBlockDescriptor = extern struct { | ||
| 81 | length: u64, | ||
| 82 | address: extern union { | ||
| 83 | dataBlock: EfiPhysicalAddress, | ||
| 84 | continuationPointer: EfiPhysicalAddress, | ||
| 85 | }, | ||
| 86 | }; | ||
| 87 | |||
| 88 | pub const ResetType = enum(u32) { | ||
| 89 | ResetCold, | ||
| 90 | ResetWarm, | ||
| 91 | ResetShutdown, | ||
| 92 | ResetPlatformSpecific, | ||
| 93 | }; | ||
| 94 | |||
| 95 | pub const global_variable align(8) = Guid{ | ||
| 96 | .time_low = 0x8be4df61, | ||
| 97 | .time_mid = 0x93ca, | ||
| 98 | .time_high_and_version = 0x11d2, | ||
| 99 | .clock_seq_high_and_reserved = 0xaa, | ||
| 100 | .clock_seq_low = 0x0d, | ||
| 101 | .node = [_]u8{ 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c }, | ||
| 102 | }; |