| ... | ... | @@ -4,10 +4,13 @@ const uefi = std.os.uefi; |
| 4 | 4 | const Allocator = mem.Allocator; |
| 5 | 5 | const Guid = uefi.Guid; |
| 6 | 6 | |
| 7 | | pub const DevicePathProtocol = packed struct { |
| 7 | // All Device Path Nodes are byte-packed and may appear on any byte boundary. |
| 8 | // All code references to device path nodes must assume all fields are unaligned. |
| 9 | |
| 10 | pub const DevicePathProtocol = extern struct { |
| 8 | 11 | type: DevicePathType, |
| 9 | 12 | subtype: u8, |
| 10 | | length: u16, |
| 13 | length: u16 align(1), |
| 11 | 14 | |
| 12 | 15 | pub const guid align(8) = Guid{ |
| 13 | 16 | .time_low = 0x09576e91, |
| ... | ... | @@ -38,7 +41,7 @@ pub const DevicePathProtocol = packed struct { |
| 38 | 41 | } |
| 39 | 42 | |
| 40 | 43 | /// Creates a file device path from the existing device path and a file path. |
| 41 | | pub fn create_file_device_path(self: *DevicePathProtocol, allocator: Allocator, path: [:0]const u16) !*DevicePathProtocol { |
| 44 | pub fn create_file_device_path(self: *DevicePathProtocol, allocator: Allocator, path: [:0]align(1) const u16) !*DevicePathProtocol { |
| 42 | 45 | var path_size = self.size(); |
| 43 | 46 | |
| 44 | 47 | // 2 * (path.len + 1) for the path and its null terminator, which are u16s |
| ... | ... | @@ -56,7 +59,7 @@ pub const DevicePathProtocol = packed struct { |
| 56 | 59 | new.length = @sizeOf(MediaDevicePath.FilePathDevicePath) + 2 * (@intCast(u16, path.len) + 1); |
| 57 | 60 | |
| 58 | 61 | // The same as new.getPath(), but not const as we're filling it in. |
| 59 | | var ptr = @ptrCast([*:0]u16, @alignCast(2, @ptrCast([*]u8, new)) + @sizeOf(MediaDevicePath.FilePathDevicePath)); |
| 62 | var ptr = @ptrCast([*:0]align(1) u16, @ptrCast([*]u8, new) + @sizeOf(MediaDevicePath.FilePathDevicePath)); |
| 60 | 63 | |
| 61 | 64 | for (path) |s, i| |
| 62 | 65 | ptr[i] = s; |
| ... | ... | @@ -108,6 +111,15 @@ pub const DevicePathProtocol = packed struct { |
| 108 | 111 | } |
| 109 | 112 | }; |
| 110 | 113 | |
| 114 | comptime { |
| 115 | std.debug.assert(4 == @sizeOf(DevicePathProtocol)); |
| 116 | std.debug.assert(1 == @alignOf(DevicePathProtocol)); |
| 117 | |
| 118 | std.debug.assert(0 == @offsetOf(DevicePathProtocol, "type")); |
| 119 | std.debug.assert(1 == @offsetOf(DevicePathProtocol, "subtype")); |
| 120 | std.debug.assert(2 == @offsetOf(DevicePathProtocol, "length")); |
| 121 | } |
| 122 | |
| 111 | 123 | pub const DevicePath = union(DevicePathType) { |
| 112 | 124 | Hardware: HardwareDevicePath, |
| 113 | 125 | Acpi: AcpiDevicePath, |
| ... | ... | @@ -145,51 +157,115 @@ pub const HardwareDevicePath = union(Subtype) { |
| 145 | 157 | _, |
| 146 | 158 | }; |
| 147 | 159 | |
| 148 | | pub const PciDevicePath = packed struct { |
| 160 | pub const PciDevicePath = extern struct { |
| 149 | 161 | type: DevicePathType, |
| 150 | 162 | subtype: Subtype, |
| 151 | | length: u16, |
| 163 | length: u16 align(1), |
| 152 | 164 | function: u8, |
| 153 | 165 | device: u8, |
| 154 | 166 | }; |
| 155 | 167 | |
| 156 | | pub const PcCardDevicePath = packed struct { |
| 168 | comptime { |
| 169 | std.debug.assert(6 == @sizeOf(PciDevicePath)); |
| 170 | std.debug.assert(1 == @alignOf(PciDevicePath)); |
| 171 | |
| 172 | std.debug.assert(0 == @offsetOf(PciDevicePath, "type")); |
| 173 | std.debug.assert(1 == @offsetOf(PciDevicePath, "subtype")); |
| 174 | std.debug.assert(2 == @offsetOf(PciDevicePath, "length")); |
| 175 | std.debug.assert(4 == @offsetOf(PciDevicePath, "function")); |
| 176 | std.debug.assert(5 == @offsetOf(PciDevicePath, "device")); |
| 177 | } |
| 178 | |
| 179 | pub const PcCardDevicePath = extern struct { |
| 157 | 180 | type: DevicePathType, |
| 158 | 181 | subtype: Subtype, |
| 159 | | length: u16, |
| 182 | length: u16 align(1), |
| 160 | 183 | function_number: u8, |
| 161 | 184 | }; |
| 162 | 185 | |
| 163 | | pub const MemoryMappedDevicePath = packed struct { |
| 186 | comptime { |
| 187 | std.debug.assert(5 == @sizeOf(PcCardDevicePath)); |
| 188 | std.debug.assert(1 == @alignOf(PcCardDevicePath)); |
| 189 | |
| 190 | std.debug.assert(0 == @offsetOf(PcCardDevicePath, "type")); |
| 191 | std.debug.assert(1 == @offsetOf(PcCardDevicePath, "subtype")); |
| 192 | std.debug.assert(2 == @offsetOf(PcCardDevicePath, "length")); |
| 193 | std.debug.assert(4 == @offsetOf(PcCardDevicePath, "function_number")); |
| 194 | } |
| 195 | |
| 196 | pub const MemoryMappedDevicePath = extern struct { |
| 164 | 197 | type: DevicePathType, |
| 165 | 198 | subtype: Subtype, |
| 166 | | length: u16, |
| 167 | | memory_type: u32, |
| 168 | | start_address: u64, |
| 169 | | end_address: u64, |
| 199 | length: u16 align(1), |
| 200 | memory_type: u32 align(1), |
| 201 | start_address: u64 align(1), |
| 202 | end_address: u64 align(1), |
| 170 | 203 | }; |
| 171 | 204 | |
| 172 | | pub const VendorDevicePath = packed struct { |
| 205 | comptime { |
| 206 | std.debug.assert(24 == @sizeOf(MemoryMappedDevicePath)); |
| 207 | std.debug.assert(1 == @alignOf(MemoryMappedDevicePath)); |
| 208 | |
| 209 | std.debug.assert(0 == @offsetOf(MemoryMappedDevicePath, "type")); |
| 210 | std.debug.assert(1 == @offsetOf(MemoryMappedDevicePath, "subtype")); |
| 211 | std.debug.assert(2 == @offsetOf(MemoryMappedDevicePath, "length")); |
| 212 | std.debug.assert(4 == @offsetOf(MemoryMappedDevicePath, "memory_type")); |
| 213 | std.debug.assert(8 == @offsetOf(MemoryMappedDevicePath, "start_address")); |
| 214 | std.debug.assert(16 == @offsetOf(MemoryMappedDevicePath, "end_address")); |
| 215 | } |
| 216 | |
| 217 | pub const VendorDevicePath = extern struct { |
| 173 | 218 | type: DevicePathType, |
| 174 | 219 | subtype: Subtype, |
| 175 | | length: u16, |
| 176 | | vendor_guid: Guid, |
| 220 | length: u16 align(1), |
| 221 | vendor_guid: Guid align(1), |
| 177 | 222 | }; |
| 178 | 223 | |
| 179 | | pub const ControllerDevicePath = packed struct { |
| 224 | comptime { |
| 225 | std.debug.assert(20 == @sizeOf(VendorDevicePath)); |
| 226 | std.debug.assert(1 == @alignOf(VendorDevicePath)); |
| 227 | |
| 228 | std.debug.assert(0 == @offsetOf(VendorDevicePath, "type")); |
| 229 | std.debug.assert(1 == @offsetOf(VendorDevicePath, "subtype")); |
| 230 | std.debug.assert(2 == @offsetOf(VendorDevicePath, "length")); |
| 231 | std.debug.assert(4 == @offsetOf(VendorDevicePath, "vendor_guid")); |
| 232 | } |
| 233 | |
| 234 | pub const ControllerDevicePath = extern struct { |
| 180 | 235 | type: DevicePathType, |
| 181 | 236 | subtype: Subtype, |
| 182 | | length: u16, |
| 183 | | controller_number: u32, |
| 237 | length: u16 align(1), |
| 238 | controller_number: u32 align(1), |
| 184 | 239 | }; |
| 185 | 240 | |
| 186 | | pub const BmcDevicePath = packed struct { |
| 241 | comptime { |
| 242 | std.debug.assert(8 == @sizeOf(ControllerDevicePath)); |
| 243 | std.debug.assert(1 == @alignOf(ControllerDevicePath)); |
| 244 | |
| 245 | std.debug.assert(0 == @offsetOf(ControllerDevicePath, "type")); |
| 246 | std.debug.assert(1 == @offsetOf(ControllerDevicePath, "subtype")); |
| 247 | std.debug.assert(2 == @offsetOf(ControllerDevicePath, "length")); |
| 248 | std.debug.assert(4 == @offsetOf(ControllerDevicePath, "controller_number")); |
| 249 | } |
| 250 | |
| 251 | pub const BmcDevicePath = extern struct { |
| 187 | 252 | type: DevicePathType, |
| 188 | 253 | subtype: Subtype, |
| 189 | | length: u16, |
| 254 | length: u16 align(1), |
| 190 | 255 | interface_type: u8, |
| 191 | | base_address: usize, |
| 256 | base_address: u64 align(1), |
| 192 | 257 | }; |
| 258 | |
| 259 | comptime { |
| 260 | std.debug.assert(13 == @sizeOf(BmcDevicePath)); |
| 261 | std.debug.assert(1 == @alignOf(BmcDevicePath)); |
| 262 | |
| 263 | std.debug.assert(0 == @offsetOf(BmcDevicePath, "type")); |
| 264 | std.debug.assert(1 == @offsetOf(BmcDevicePath, "subtype")); |
| 265 | std.debug.assert(2 == @offsetOf(BmcDevicePath, "length")); |
| 266 | std.debug.assert(4 == @offsetOf(BmcDevicePath, "interface_type")); |
| 267 | std.debug.assert(5 == @offsetOf(BmcDevicePath, "base_address")); |
| 268 | } |
| 193 | 269 | }; |
| 194 | 270 | |
| 195 | 271 | pub const AcpiDevicePath = union(Subtype) { |
| ... | ... | @@ -204,37 +280,71 @@ pub const AcpiDevicePath = union(Subtype) { |
| 204 | 280 | _, |
| 205 | 281 | }; |
| 206 | 282 | |
| 207 | | pub const BaseAcpiDevicePath = packed struct { |
| 283 | pub const BaseAcpiDevicePath = extern struct { |
| 208 | 284 | type: DevicePathType, |
| 209 | 285 | subtype: Subtype, |
| 210 | | length: u16, |
| 211 | | hid: u32, |
| 212 | | uid: u32, |
| 286 | length: u16 align(1), |
| 287 | hid: u32 align(1), |
| 288 | uid: u32 align(1), |
| 213 | 289 | }; |
| 214 | 290 | |
| 215 | | pub const ExpandedAcpiDevicePath = packed struct { |
| 291 | comptime { |
| 292 | std.debug.assert(12 == @sizeOf(BaseAcpiDevicePath)); |
| 293 | std.debug.assert(1 == @alignOf(BaseAcpiDevicePath)); |
| 294 | |
| 295 | std.debug.assert(0 == @offsetOf(BaseAcpiDevicePath, "type")); |
| 296 | std.debug.assert(1 == @offsetOf(BaseAcpiDevicePath, "subtype")); |
| 297 | std.debug.assert(2 == @offsetOf(BaseAcpiDevicePath, "length")); |
| 298 | std.debug.assert(4 == @offsetOf(BaseAcpiDevicePath, "hid")); |
| 299 | std.debug.assert(8 == @offsetOf(BaseAcpiDevicePath, "uid")); |
| 300 | } |
| 301 | |
| 302 | pub const ExpandedAcpiDevicePath = extern struct { |
| 216 | 303 | type: DevicePathType, |
| 217 | 304 | subtype: Subtype, |
| 218 | | length: u16, |
| 219 | | hid: u32, |
| 220 | | uid: u32, |
| 221 | | cid: u32, |
| 305 | length: u16 align(1), |
| 306 | hid: u32 align(1), |
| 307 | uid: u32 align(1), |
| 308 | cid: u32 align(1), |
| 222 | 309 | // variable length u16[*:0] strings |
| 223 | 310 | // hid_str, uid_str, cid_str |
| 224 | 311 | }; |
| 225 | 312 | |
| 226 | | pub const AdrDevicePath = packed struct { |
| 313 | comptime { |
| 314 | std.debug.assert(16 == @sizeOf(ExpandedAcpiDevicePath)); |
| 315 | std.debug.assert(1 == @alignOf(ExpandedAcpiDevicePath)); |
| 316 | |
| 317 | std.debug.assert(0 == @offsetOf(ExpandedAcpiDevicePath, "type")); |
| 318 | std.debug.assert(1 == @offsetOf(ExpandedAcpiDevicePath, "subtype")); |
| 319 | std.debug.assert(2 == @offsetOf(ExpandedAcpiDevicePath, "length")); |
| 320 | std.debug.assert(4 == @offsetOf(ExpandedAcpiDevicePath, "hid")); |
| 321 | std.debug.assert(8 == @offsetOf(ExpandedAcpiDevicePath, "uid")); |
| 322 | std.debug.assert(12 == @offsetOf(ExpandedAcpiDevicePath, "cid")); |
| 323 | } |
| 324 | |
| 325 | pub const AdrDevicePath = extern struct { |
| 227 | 326 | type: DevicePathType, |
| 228 | 327 | subtype: Subtype, |
| 229 | | length: u16, |
| 230 | | adr: u32, |
| 328 | length: u16 align(1), |
| 329 | adr: u32 align(1), |
| 330 | |
| 231 | 331 | // multiple adr entries can optionally follow |
| 232 | | pub fn adrs(self: *const AdrDevicePath) []const u32 { |
| 332 | pub fn adrs(self: *const AdrDevicePath) []align(1) const u32 { |
| 233 | 333 | // self.length is a minimum of 8 with one adr which is size 4. |
| 234 | 334 | var entries = (self.length - 4) / @sizeOf(u32); |
| 235 | | return @ptrCast([*]const u32, &self.adr)[0..entries]; |
| 335 | return @ptrCast([*]align(1) const u32, &self.adr)[0..entries]; |
| 236 | 336 | } |
| 237 | 337 | }; |
| 338 | |
| 339 | comptime { |
| 340 | std.debug.assert(8 == @sizeOf(AdrDevicePath)); |
| 341 | std.debug.assert(1 == @alignOf(AdrDevicePath)); |
| 342 | |
| 343 | std.debug.assert(0 == @offsetOf(AdrDevicePath, "type")); |
| 344 | std.debug.assert(1 == @offsetOf(AdrDevicePath, "subtype")); |
| 345 | std.debug.assert(2 == @offsetOf(AdrDevicePath, "length")); |
| 346 | std.debug.assert(4 == @offsetOf(AdrDevicePath, "adr")); |
| 347 | } |
| 238 | 348 | }; |
| 239 | 349 | |
| 240 | 350 | pub const MessagingDevicePath = union(Subtype) { |
| ... | ... | @@ -279,7 +389,7 @@ pub const MessagingDevicePath = union(Subtype) { |
| 279 | 389 | _, |
| 280 | 390 | }; |
| 281 | 391 | |
| 282 | | pub const AtapiDevicePath = packed struct { |
| 392 | pub const AtapiDevicePath = extern struct { |
| 283 | 393 | const Role = enum(u8) { |
| 284 | 394 | Master = 0, |
| 285 | 395 | Slave = 1, |
| ... | ... | @@ -292,111 +402,249 @@ pub const MessagingDevicePath = union(Subtype) { |
| 292 | 402 | |
| 293 | 403 | type: DevicePathType, |
| 294 | 404 | subtype: Subtype, |
| 295 | | length: u16, |
| 405 | length: u16 align(1), |
| 296 | 406 | primary_secondary: Rank, |
| 297 | 407 | slave_master: Role, |
| 298 | | logical_unit_number: u16, |
| 408 | logical_unit_number: u16 align(1), |
| 299 | 409 | }; |
| 300 | 410 | |
| 301 | | pub const ScsiDevicePath = packed struct { |
| 411 | comptime { |
| 412 | std.debug.assert(8 == @sizeOf(AtapiDevicePath)); |
| 413 | std.debug.assert(1 == @alignOf(AtapiDevicePath)); |
| 414 | |
| 415 | std.debug.assert(0 == @offsetOf(AtapiDevicePath, "type")); |
| 416 | std.debug.assert(1 == @offsetOf(AtapiDevicePath, "subtype")); |
| 417 | std.debug.assert(2 == @offsetOf(AtapiDevicePath, "length")); |
| 418 | std.debug.assert(4 == @offsetOf(AtapiDevicePath, "primary_secondary")); |
| 419 | std.debug.assert(5 == @offsetOf(AtapiDevicePath, "slave_master")); |
| 420 | std.debug.assert(6 == @offsetOf(AtapiDevicePath, "logical_unit_number")); |
| 421 | } |
| 422 | |
| 423 | pub const ScsiDevicePath = extern struct { |
| 302 | 424 | type: DevicePathType, |
| 303 | 425 | subtype: Subtype, |
| 304 | | length: u16, |
| 305 | | target_id: u16, |
| 306 | | logical_unit_number: u16, |
| 426 | length: u16 align(1), |
| 427 | target_id: u16 align(1), |
| 428 | logical_unit_number: u16 align(1), |
| 307 | 429 | }; |
| 308 | 430 | |
| 309 | | pub const FibreChannelDevicePath = packed struct { |
| 431 | comptime { |
| 432 | std.debug.assert(8 == @sizeOf(ScsiDevicePath)); |
| 433 | std.debug.assert(1 == @alignOf(ScsiDevicePath)); |
| 434 | |
| 435 | std.debug.assert(0 == @offsetOf(ScsiDevicePath, "type")); |
| 436 | std.debug.assert(1 == @offsetOf(ScsiDevicePath, "subtype")); |
| 437 | std.debug.assert(2 == @offsetOf(ScsiDevicePath, "length")); |
| 438 | std.debug.assert(4 == @offsetOf(ScsiDevicePath, "target_id")); |
| 439 | std.debug.assert(6 == @offsetOf(ScsiDevicePath, "logical_unit_number")); |
| 440 | } |
| 441 | |
| 442 | pub const FibreChannelDevicePath = extern struct { |
| 310 | 443 | type: DevicePathType, |
| 311 | 444 | subtype: Subtype, |
| 312 | | length: u16, |
| 313 | | reserved: u32, |
| 314 | | world_wide_name: u64, |
| 315 | | logical_unit_number: u64, |
| 445 | length: u16 align(1), |
| 446 | reserved: u32 align(1), |
| 447 | world_wide_name: u64 align(1), |
| 448 | logical_unit_number: u64 align(1), |
| 316 | 449 | }; |
| 317 | 450 | |
| 318 | | pub const FibreChannelExDevicePath = packed struct { |
| 451 | comptime { |
| 452 | std.debug.assert(24 == @sizeOf(FibreChannelDevicePath)); |
| 453 | std.debug.assert(1 == @alignOf(FibreChannelDevicePath)); |
| 454 | |
| 455 | std.debug.assert(0 == @offsetOf(FibreChannelDevicePath, "type")); |
| 456 | std.debug.assert(1 == @offsetOf(FibreChannelDevicePath, "subtype")); |
| 457 | std.debug.assert(2 == @offsetOf(FibreChannelDevicePath, "length")); |
| 458 | std.debug.assert(4 == @offsetOf(FibreChannelDevicePath, "reserved")); |
| 459 | std.debug.assert(8 == @offsetOf(FibreChannelDevicePath, "world_wide_name")); |
| 460 | std.debug.assert(16 == @offsetOf(FibreChannelDevicePath, "logical_unit_number")); |
| 461 | } |
| 462 | |
| 463 | pub const FibreChannelExDevicePath = extern struct { |
| 319 | 464 | type: DevicePathType, |
| 320 | 465 | subtype: Subtype, |
| 321 | | length: u16, |
| 322 | | reserved: u32, |
| 323 | | world_wide_name: [8]u8, |
| 324 | | logical_unit_number: [8]u8, |
| 466 | length: u16 align(1), |
| 467 | reserved: u32 align(1), |
| 468 | world_wide_name: u64 align(1), |
| 469 | logical_unit_number: u64 align(1), |
| 325 | 470 | }; |
| 326 | 471 | |
| 327 | | pub const F1394DevicePath = packed struct { |
| 472 | comptime { |
| 473 | std.debug.assert(24 == @sizeOf(FibreChannelExDevicePath)); |
| 474 | std.debug.assert(1 == @alignOf(FibreChannelExDevicePath)); |
| 475 | |
| 476 | std.debug.assert(0 == @offsetOf(FibreChannelExDevicePath, "type")); |
| 477 | std.debug.assert(1 == @offsetOf(FibreChannelExDevicePath, "subtype")); |
| 478 | std.debug.assert(2 == @offsetOf(FibreChannelExDevicePath, "length")); |
| 479 | std.debug.assert(4 == @offsetOf(FibreChannelExDevicePath, "reserved")); |
| 480 | std.debug.assert(8 == @offsetOf(FibreChannelExDevicePath, "world_wide_name")); |
| 481 | std.debug.assert(16 == @offsetOf(FibreChannelExDevicePath, "logical_unit_number")); |
| 482 | } |
| 483 | |
| 484 | pub const F1394DevicePath = extern struct { |
| 328 | 485 | type: DevicePathType, |
| 329 | 486 | subtype: Subtype, |
| 330 | | length: u16, |
| 331 | | reserved: u32, |
| 332 | | guid: u64, |
| 487 | length: u16 align(1), |
| 488 | reserved: u32 align(1), |
| 489 | guid: u64 align(1), |
| 333 | 490 | }; |
| 334 | 491 | |
| 335 | | pub const UsbDevicePath = packed struct { |
| 492 | comptime { |
| 493 | std.debug.assert(16 == @sizeOf(F1394DevicePath)); |
| 494 | std.debug.assert(1 == @alignOf(F1394DevicePath)); |
| 495 | |
| 496 | std.debug.assert(0 == @offsetOf(F1394DevicePath, "type")); |
| 497 | std.debug.assert(1 == @offsetOf(F1394DevicePath, "subtype")); |
| 498 | std.debug.assert(2 == @offsetOf(F1394DevicePath, "length")); |
| 499 | std.debug.assert(4 == @offsetOf(F1394DevicePath, "reserved")); |
| 500 | std.debug.assert(8 == @offsetOf(F1394DevicePath, "guid")); |
| 501 | } |
| 502 | |
| 503 | pub const UsbDevicePath = extern struct { |
| 336 | 504 | type: DevicePathType, |
| 337 | 505 | subtype: Subtype, |
| 338 | | length: u16, |
| 506 | length: u16 align(1), |
| 339 | 507 | parent_port_number: u8, |
| 340 | 508 | interface_number: u8, |
| 341 | 509 | }; |
| 342 | 510 | |
| 343 | | pub const SataDevicePath = packed struct { |
| 511 | comptime { |
| 512 | std.debug.assert(6 == @sizeOf(UsbDevicePath)); |
| 513 | std.debug.assert(1 == @alignOf(UsbDevicePath)); |
| 514 | |
| 515 | std.debug.assert(0 == @offsetOf(UsbDevicePath, "type")); |
| 516 | std.debug.assert(1 == @offsetOf(UsbDevicePath, "subtype")); |
| 517 | std.debug.assert(2 == @offsetOf(UsbDevicePath, "length")); |
| 518 | std.debug.assert(4 == @offsetOf(UsbDevicePath, "parent_port_number")); |
| 519 | std.debug.assert(5 == @offsetOf(UsbDevicePath, "interface_number")); |
| 520 | } |
| 521 | |
| 522 | pub const SataDevicePath = extern struct { |
| 344 | 523 | type: DevicePathType, |
| 345 | 524 | subtype: Subtype, |
| 346 | | length: u16, |
| 347 | | hba_port_number: u16, |
| 348 | | port_multiplier_port_number: u16, |
| 349 | | logical_unit_number: u16, |
| 525 | length: u16 align(1), |
| 526 | hba_port_number: u16 align(1), |
| 527 | port_multiplier_port_number: u16 align(1), |
| 528 | logical_unit_number: u16 align(1), |
| 350 | 529 | }; |
| 351 | 530 | |
| 352 | | pub const UsbWwidDevicePath = packed struct { |
| 531 | comptime { |
| 532 | std.debug.assert(10 == @sizeOf(SataDevicePath)); |
| 533 | std.debug.assert(1 == @alignOf(SataDevicePath)); |
| 534 | |
| 535 | std.debug.assert(0 == @offsetOf(SataDevicePath, "type")); |
| 536 | std.debug.assert(1 == @offsetOf(SataDevicePath, "subtype")); |
| 537 | std.debug.assert(2 == @offsetOf(SataDevicePath, "length")); |
| 538 | std.debug.assert(4 == @offsetOf(SataDevicePath, "hba_port_number")); |
| 539 | std.debug.assert(6 == @offsetOf(SataDevicePath, "port_multiplier_port_number")); |
| 540 | std.debug.assert(8 == @offsetOf(SataDevicePath, "logical_unit_number")); |
| 541 | } |
| 542 | |
| 543 | pub const UsbWwidDevicePath = extern struct { |
| 353 | 544 | type: DevicePathType, |
| 354 | 545 | subtype: Subtype, |
| 355 | | length: u16, |
| 356 | | interface_number: u16, |
| 357 | | device_vendor_id: u16, |
| 358 | | device_product_id: u16, |
| 546 | length: u16 align(1), |
| 547 | interface_number: u16 align(1), |
| 548 | device_vendor_id: u16 align(1), |
| 549 | device_product_id: u16 align(1), |
| 359 | 550 | |
| 360 | | pub fn serial_number(self: *const UsbWwidDevicePath) []const u16 { |
| 551 | pub fn serial_number(self: *const UsbWwidDevicePath) []align(1) const u16 { |
| 361 | 552 | var serial_len = (self.length - @sizeOf(UsbWwidDevicePath)) / @sizeOf(u16); |
| 362 | | return @ptrCast([*]u16, @ptrCast([*]u8, self) + @sizeOf(UsbWwidDevicePath))[0..serial_len]; |
| 553 | return @ptrCast([*]align(1) const u16, @ptrCast([*]const u8, self) + @sizeOf(UsbWwidDevicePath))[0..serial_len]; |
| 363 | 554 | } |
| 364 | 555 | }; |
| 365 | 556 | |
| 366 | | pub const DeviceLogicalUnitDevicePath = packed struct { |
| 557 | comptime { |
| 558 | std.debug.assert(10 == @sizeOf(UsbWwidDevicePath)); |
| 559 | std.debug.assert(1 == @alignOf(UsbWwidDevicePath)); |
| 560 | |
| 561 | std.debug.assert(0 == @offsetOf(UsbWwidDevicePath, "type")); |
| 562 | std.debug.assert(1 == @offsetOf(UsbWwidDevicePath, "subtype")); |
| 563 | std.debug.assert(2 == @offsetOf(UsbWwidDevicePath, "length")); |
| 564 | std.debug.assert(4 == @offsetOf(UsbWwidDevicePath, "interface_number")); |
| 565 | std.debug.assert(6 == @offsetOf(UsbWwidDevicePath, "device_vendor_id")); |
| 566 | std.debug.assert(8 == @offsetOf(UsbWwidDevicePath, "device_product_id")); |
| 567 | } |
| 568 | |
| 569 | pub const DeviceLogicalUnitDevicePath = extern struct { |
| 367 | 570 | type: DevicePathType, |
| 368 | 571 | subtype: Subtype, |
| 369 | | length: u16, |
| 572 | length: u16 align(1), |
| 370 | 573 | lun: u8, |
| 371 | 574 | }; |
| 372 | 575 | |
| 373 | | pub const UsbClassDevicePath = packed struct { |
| 576 | comptime { |
| 577 | std.debug.assert(5 == @sizeOf(DeviceLogicalUnitDevicePath)); |
| 578 | std.debug.assert(1 == @alignOf(DeviceLogicalUnitDevicePath)); |
| 579 | |
| 580 | std.debug.assert(0 == @offsetOf(DeviceLogicalUnitDevicePath, "type")); |
| 581 | std.debug.assert(1 == @offsetOf(DeviceLogicalUnitDevicePath, "subtype")); |
| 582 | std.debug.assert(2 == @offsetOf(DeviceLogicalUnitDevicePath, "length")); |
| 583 | std.debug.assert(4 == @offsetOf(DeviceLogicalUnitDevicePath, "lun")); |
| 584 | } |
| 585 | |
| 586 | pub const UsbClassDevicePath = extern struct { |
| 374 | 587 | type: DevicePathType, |
| 375 | 588 | subtype: Subtype, |
| 376 | | length: u16, |
| 377 | | vendor_id: u16, |
| 378 | | product_id: u16, |
| 589 | length: u16 align(1), |
| 590 | vendor_id: u16 align(1), |
| 591 | product_id: u16 align(1), |
| 379 | 592 | device_class: u8, |
| 380 | 593 | device_subclass: u8, |
| 381 | 594 | device_protocol: u8, |
| 382 | 595 | }; |
| 383 | 596 | |
| 384 | | pub const I2oDevicePath = packed struct { |
| 597 | comptime { |
| 598 | std.debug.assert(11 == @sizeOf(UsbClassDevicePath)); |
| 599 | std.debug.assert(1 == @alignOf(UsbClassDevicePath)); |
| 600 | |
| 601 | std.debug.assert(0 == @offsetOf(UsbClassDevicePath, "type")); |
| 602 | std.debug.assert(1 == @offsetOf(UsbClassDevicePath, "subtype")); |
| 603 | std.debug.assert(2 == @offsetOf(UsbClassDevicePath, "length")); |
| 604 | std.debug.assert(4 == @offsetOf(UsbClassDevicePath, "vendor_id")); |
| 605 | std.debug.assert(6 == @offsetOf(UsbClassDevicePath, "product_id")); |
| 606 | std.debug.assert(8 == @offsetOf(UsbClassDevicePath, "device_class")); |
| 607 | std.debug.assert(9 == @offsetOf(UsbClassDevicePath, "device_subclass")); |
| 608 | std.debug.assert(10 == @offsetOf(UsbClassDevicePath, "device_protocol")); |
| 609 | } |
| 610 | |
| 611 | pub const I2oDevicePath = extern struct { |
| 385 | 612 | type: DevicePathType, |
| 386 | 613 | subtype: Subtype, |
| 387 | | length: u16, |
| 388 | | tid: u32, |
| 614 | length: u16 align(1), |
| 615 | tid: u32 align(1), |
| 389 | 616 | }; |
| 390 | 617 | |
| 391 | | pub const MacAddressDevicePath = packed struct { |
| 618 | comptime { |
| 619 | std.debug.assert(8 == @sizeOf(I2oDevicePath)); |
| 620 | std.debug.assert(1 == @alignOf(I2oDevicePath)); |
| 621 | |
| 622 | std.debug.assert(0 == @offsetOf(I2oDevicePath, "type")); |
| 623 | std.debug.assert(1 == @offsetOf(I2oDevicePath, "subtype")); |
| 624 | std.debug.assert(2 == @offsetOf(I2oDevicePath, "length")); |
| 625 | std.debug.assert(4 == @offsetOf(I2oDevicePath, "tid")); |
| 626 | } |
| 627 | |
| 628 | pub const MacAddressDevicePath = extern struct { |
| 392 | 629 | type: DevicePathType, |
| 393 | 630 | subtype: Subtype, |
| 394 | | length: u16, |
| 631 | length: u16 align(1), |
| 395 | 632 | mac_address: uefi.MacAddress, |
| 396 | 633 | if_type: u8, |
| 397 | 634 | }; |
| 398 | 635 | |
| 399 | | pub const Ipv4DevicePath = packed struct { |
| 636 | comptime { |
| 637 | std.debug.assert(37 == @sizeOf(MacAddressDevicePath)); |
| 638 | std.debug.assert(1 == @alignOf(MacAddressDevicePath)); |
| 639 | |
| 640 | std.debug.assert(0 == @offsetOf(MacAddressDevicePath, "type")); |
| 641 | std.debug.assert(1 == @offsetOf(MacAddressDevicePath, "subtype")); |
| 642 | std.debug.assert(2 == @offsetOf(MacAddressDevicePath, "length")); |
| 643 | std.debug.assert(4 == @offsetOf(MacAddressDevicePath, "mac_address")); |
| 644 | std.debug.assert(36 == @offsetOf(MacAddressDevicePath, "if_type")); |
| 645 | } |
| 646 | |
| 647 | pub const Ipv4DevicePath = extern struct { |
| 400 | 648 | pub const IpType = enum(u8) { |
| 401 | 649 | Dhcp = 0, |
| 402 | 650 | Static = 1, |
| ... | ... | @@ -404,18 +652,35 @@ pub const MessagingDevicePath = union(Subtype) { |
| 404 | 652 | |
| 405 | 653 | type: DevicePathType, |
| 406 | 654 | subtype: Subtype, |
| 407 | | length: u16, |
| 408 | | local_ip_address: uefi.Ipv4Address, |
| 409 | | remote_ip_address: uefi.Ipv4Address, |
| 410 | | local_port: u16, |
| 411 | | remote_port: u16, |
| 412 | | network_protocol: u16, |
| 655 | length: u16 align(1), |
| 656 | local_ip_address: uefi.Ipv4Address align(1), |
| 657 | remote_ip_address: uefi.Ipv4Address align(1), |
| 658 | local_port: u16 align(1), |
| 659 | remote_port: u16 align(1), |
| 660 | network_protocol: u16 align(1), |
| 413 | 661 | static_ip_address: IpType, |
| 414 | | gateway_ip_address: u32, |
| 415 | | subnet_mask: u32, |
| 662 | gateway_ip_address: u32 align(1), |
| 663 | subnet_mask: u32 align(1), |
| 416 | 664 | }; |
| 417 | 665 | |
| 418 | | pub const Ipv6DevicePath = packed struct { |
| 666 | comptime { |
| 667 | std.debug.assert(27 == @sizeOf(Ipv4DevicePath)); |
| 668 | std.debug.assert(1 == @alignOf(Ipv4DevicePath)); |
| 669 | |
| 670 | std.debug.assert(0 == @offsetOf(Ipv4DevicePath, "type")); |
| 671 | std.debug.assert(1 == @offsetOf(Ipv4DevicePath, "subtype")); |
| 672 | std.debug.assert(2 == @offsetOf(Ipv4DevicePath, "length")); |
| 673 | std.debug.assert(4 == @offsetOf(Ipv4DevicePath, "local_ip_address")); |
| 674 | std.debug.assert(8 == @offsetOf(Ipv4DevicePath, "remote_ip_address")); |
| 675 | std.debug.assert(12 == @offsetOf(Ipv4DevicePath, "local_port")); |
| 676 | std.debug.assert(14 == @offsetOf(Ipv4DevicePath, "remote_port")); |
| 677 | std.debug.assert(16 == @offsetOf(Ipv4DevicePath, "network_protocol")); |
| 678 | std.debug.assert(18 == @offsetOf(Ipv4DevicePath, "static_ip_address")); |
| 679 | std.debug.assert(19 == @offsetOf(Ipv4DevicePath, "gateway_ip_address")); |
| 680 | std.debug.assert(23 == @offsetOf(Ipv4DevicePath, "subnet_mask")); |
| 681 | } |
| 682 | |
| 683 | pub const Ipv6DevicePath = extern struct { |
| 419 | 684 | pub const Origin = enum(u8) { |
| 420 | 685 | Manual = 0, |
| 421 | 686 | AssignedStateless = 1, |
| ... | ... | @@ -424,26 +689,53 @@ pub const MessagingDevicePath = union(Subtype) { |
| 424 | 689 | |
| 425 | 690 | type: DevicePathType, |
| 426 | 691 | subtype: Subtype, |
| 427 | | length: u16, |
| 692 | length: u16 align(1), |
| 428 | 693 | local_ip_address: uefi.Ipv6Address, |
| 429 | 694 | remote_ip_address: uefi.Ipv6Address, |
| 430 | | local_port: u16, |
| 431 | | remote_port: u16, |
| 432 | | protocol: u16, |
| 695 | local_port: u16 align(1), |
| 696 | remote_port: u16 align(1), |
| 697 | protocol: u16 align(1), |
| 433 | 698 | ip_address_origin: Origin, |
| 434 | 699 | prefix_length: u8, |
| 435 | 700 | gateway_ip_address: uefi.Ipv6Address, |
| 436 | 701 | }; |
| 437 | 702 | |
| 438 | | pub const VlanDevicePath = packed struct { |
| 703 | comptime { |
| 704 | std.debug.assert(60 == @sizeOf(Ipv6DevicePath)); |
| 705 | std.debug.assert(1 == @alignOf(Ipv6DevicePath)); |
| 706 | |
| 707 | std.debug.assert(0 == @offsetOf(Ipv6DevicePath, "type")); |
| 708 | std.debug.assert(1 == @offsetOf(Ipv6DevicePath, "subtype")); |
| 709 | std.debug.assert(2 == @offsetOf(Ipv6DevicePath, "length")); |
| 710 | std.debug.assert(4 == @offsetOf(Ipv6DevicePath, "local_ip_address")); |
| 711 | std.debug.assert(20 == @offsetOf(Ipv6DevicePath, "remote_ip_address")); |
| 712 | std.debug.assert(36 == @offsetOf(Ipv6DevicePath, "local_port")); |
| 713 | std.debug.assert(38 == @offsetOf(Ipv6DevicePath, "remote_port")); |
| 714 | std.debug.assert(40 == @offsetOf(Ipv6DevicePath, "protocol")); |
| 715 | std.debug.assert(42 == @offsetOf(Ipv6DevicePath, "ip_address_origin")); |
| 716 | std.debug.assert(43 == @offsetOf(Ipv6DevicePath, "prefix_length")); |
| 717 | std.debug.assert(44 == @offsetOf(Ipv6DevicePath, "gateway_ip_address")); |
| 718 | } |
| 719 | |
| 720 | pub const VlanDevicePath = extern struct { |
| 439 | 721 | type: DevicePathType, |
| 440 | 722 | subtype: Subtype, |
| 441 | | length: u16, |
| 442 | | vlan_id: u16, |
| 723 | length: u16 align(1), |
| 724 | vlan_id: u16 align(1), |
| 443 | 725 | }; |
| 444 | 726 | |
| 445 | | pub const InfiniBandDevicePath = packed struct { |
| 446 | | pub const ResourceFlags = packed struct { |
| 727 | comptime { |
| 728 | std.debug.assert(6 == @sizeOf(VlanDevicePath)); |
| 729 | std.debug.assert(1 == @alignOf(VlanDevicePath)); |
| 730 | |
| 731 | std.debug.assert(0 == @offsetOf(VlanDevicePath, "type")); |
| 732 | std.debug.assert(1 == @offsetOf(VlanDevicePath, "subtype")); |
| 733 | std.debug.assert(2 == @offsetOf(VlanDevicePath, "length")); |
| 734 | std.debug.assert(4 == @offsetOf(VlanDevicePath, "vlan_id")); |
| 735 | } |
| 736 | |
| 737 | pub const InfiniBandDevicePath = extern struct { |
| 738 | pub const ResourceFlags = packed struct(u32) { |
| 447 | 739 | pub const ControllerType = enum(u1) { |
| 448 | 740 | Ioc = 0, |
| 449 | 741 | Service = 1, |
| ... | ... | @@ -461,15 +753,29 @@ pub const MessagingDevicePath = union(Subtype) { |
| 461 | 753 | |
| 462 | 754 | type: DevicePathType, |
| 463 | 755 | subtype: Subtype, |
| 464 | | length: u16, |
| 465 | | resource_flags: ResourceFlags, |
| 756 | length: u16 align(1), |
| 757 | resource_flags: ResourceFlags align(1), |
| 466 | 758 | port_gid: [16]u8, |
| 467 | | service_id: u64, |
| 468 | | target_port_id: u64, |
| 469 | | device_id: u64, |
| 759 | service_id: u64 align(1), |
| 760 | target_port_id: u64 align(1), |
| 761 | device_id: u64 align(1), |
| 470 | 762 | }; |
| 471 | 763 | |
| 472 | | pub const UartDevicePath = packed struct { |
| 764 | comptime { |
| 765 | std.debug.assert(48 == @sizeOf(InfiniBandDevicePath)); |
| 766 | std.debug.assert(1 == @alignOf(InfiniBandDevicePath)); |
| 767 | |
| 768 | std.debug.assert(0 == @offsetOf(InfiniBandDevicePath, "type")); |
| 769 | std.debug.assert(1 == @offsetOf(InfiniBandDevicePath, "subtype")); |
| 770 | std.debug.assert(2 == @offsetOf(InfiniBandDevicePath, "length")); |
| 771 | std.debug.assert(4 == @offsetOf(InfiniBandDevicePath, "resource_flags")); |
| 772 | std.debug.assert(8 == @offsetOf(InfiniBandDevicePath, "port_gid")); |
| 773 | std.debug.assert(24 == @offsetOf(InfiniBandDevicePath, "service_id")); |
| 774 | std.debug.assert(32 == @offsetOf(InfiniBandDevicePath, "target_port_id")); |
| 775 | std.debug.assert(40 == @offsetOf(InfiniBandDevicePath, "device_id")); |
| 776 | } |
| 777 | |
| 778 | pub const UartDevicePath = extern struct { |
| 473 | 779 | pub const Parity = enum(u8) { |
| 474 | 780 | Default = 0, |
| 475 | 781 | None = 1, |
| ... | ... | @@ -490,20 +796,44 @@ pub const MessagingDevicePath = union(Subtype) { |
| 490 | 796 | |
| 491 | 797 | type: DevicePathType, |
| 492 | 798 | subtype: Subtype, |
| 493 | | length: u16, |
| 494 | | reserved: u16, |
| 495 | | baud_rate: u32, |
| 799 | length: u16 align(1), |
| 800 | reserved: u32 align(1), |
| 801 | baud_rate: u64 align(1), |
| 496 | 802 | data_bits: u8, |
| 497 | 803 | parity: Parity, |
| 498 | 804 | stop_bits: StopBits, |
| 499 | 805 | }; |
| 500 | 806 | |
| 501 | | pub const VendorDefinedDevicePath = packed struct { |
| 807 | comptime { |
| 808 | std.debug.assert(19 == @sizeOf(UartDevicePath)); |
| 809 | std.debug.assert(1 == @alignOf(UartDevicePath)); |
| 810 | |
| 811 | std.debug.assert(0 == @offsetOf(UartDevicePath, "type")); |
| 812 | std.debug.assert(1 == @offsetOf(UartDevicePath, "subtype")); |
| 813 | std.debug.assert(2 == @offsetOf(UartDevicePath, "length")); |
| 814 | std.debug.assert(4 == @offsetOf(UartDevicePath, "reserved")); |
| 815 | std.debug.assert(8 == @offsetOf(UartDevicePath, "baud_rate")); |
| 816 | std.debug.assert(16 == @offsetOf(UartDevicePath, "data_bits")); |
| 817 | std.debug.assert(17 == @offsetOf(UartDevicePath, "parity")); |
| 818 | std.debug.assert(18 == @offsetOf(UartDevicePath, "stop_bits")); |
| 819 | } |
| 820 | |
| 821 | pub const VendorDefinedDevicePath = extern struct { |
| 502 | 822 | type: DevicePathType, |
| 503 | 823 | subtype: Subtype, |
| 504 | | length: u16, |
| 505 | | vendor_guid: Guid, |
| 824 | length: u16 align(1), |
| 825 | vendor_guid: Guid align(1), |
| 506 | 826 | }; |
| 827 | |
| 828 | comptime { |
| 829 | std.debug.assert(20 == @sizeOf(VendorDefinedDevicePath)); |
| 830 | std.debug.assert(1 == @alignOf(VendorDefinedDevicePath)); |
| 831 | |
| 832 | std.debug.assert(0 == @offsetOf(VendorDefinedDevicePath, "type")); |
| 833 | std.debug.assert(1 == @offsetOf(VendorDefinedDevicePath, "subtype")); |
| 834 | std.debug.assert(2 == @offsetOf(VendorDefinedDevicePath, "length")); |
| 835 | std.debug.assert(4 == @offsetOf(VendorDefinedDevicePath, "vendor_guid")); |
| 836 | } |
| 507 | 837 | }; |
| 508 | 838 | |
| 509 | 839 | pub const MediaDevicePath = union(Subtype) { |
| ... | ... | @@ -530,7 +860,7 @@ pub const MediaDevicePath = union(Subtype) { |
| 530 | 860 | _, |
| 531 | 861 | }; |
| 532 | 862 | |
| 533 | | pub const HardDriveDevicePath = packed struct { |
| 863 | pub const HardDriveDevicePath = extern struct { |
| 534 | 864 | pub const Format = enum(u8) { |
| 535 | 865 | LegacyMbr = 0x01, |
| 536 | 866 | GuidPartitionTable = 0x02, |
| ... | ... | @@ -545,81 +875,181 @@ pub const MediaDevicePath = union(Subtype) { |
| 545 | 875 | |
| 546 | 876 | type: DevicePathType, |
| 547 | 877 | subtype: Subtype, |
| 548 | | length: u16, |
| 549 | | partition_number: u32, |
| 550 | | partition_start: u64, |
| 551 | | partition_size: u64, |
| 878 | length: u16 align(1), |
| 879 | partition_number: u32 align(1), |
| 880 | partition_start: u64 align(1), |
| 881 | partition_size: u64 align(1), |
| 552 | 882 | partition_signature: [16]u8, |
| 553 | 883 | partition_format: Format, |
| 554 | 884 | signature_type: SignatureType, |
| 555 | 885 | }; |
| 556 | 886 | |
| 557 | | pub const CdromDevicePath = packed struct { |
| 887 | comptime { |
| 888 | std.debug.assert(42 == @sizeOf(HardDriveDevicePath)); |
| 889 | std.debug.assert(1 == @alignOf(HardDriveDevicePath)); |
| 890 | |
| 891 | std.debug.assert(0 == @offsetOf(HardDriveDevicePath, "type")); |
| 892 | std.debug.assert(1 == @offsetOf(HardDriveDevicePath, "subtype")); |
| 893 | std.debug.assert(2 == @offsetOf(HardDriveDevicePath, "length")); |
| 894 | std.debug.assert(4 == @offsetOf(HardDriveDevicePath, "partition_number")); |
| 895 | std.debug.assert(8 == @offsetOf(HardDriveDevicePath, "partition_start")); |
| 896 | std.debug.assert(16 == @offsetOf(HardDriveDevicePath, "partition_size")); |
| 897 | std.debug.assert(24 == @offsetOf(HardDriveDevicePath, "partition_signature")); |
| 898 | std.debug.assert(40 == @offsetOf(HardDriveDevicePath, "partition_format")); |
| 899 | std.debug.assert(41 == @offsetOf(HardDriveDevicePath, "signature_type")); |
| 900 | } |
| 901 | |
| 902 | pub const CdromDevicePath = extern struct { |
| 558 | 903 | type: DevicePathType, |
| 559 | 904 | subtype: Subtype, |
| 560 | | length: u16, |
| 561 | | boot_entry: u32, |
| 562 | | partition_start: u64, |
| 563 | | partition_size: u64, |
| 905 | length: u16 align(1), |
| 906 | boot_entry: u32 align(1), |
| 907 | partition_start: u64 align(1), |
| 908 | partition_size: u64 align(1), |
| 564 | 909 | }; |
| 565 | 910 | |
| 566 | | pub const VendorDevicePath = packed struct { |
| 911 | comptime { |
| 912 | std.debug.assert(24 == @sizeOf(CdromDevicePath)); |
| 913 | std.debug.assert(1 == @alignOf(CdromDevicePath)); |
| 914 | |
| 915 | std.debug.assert(0 == @offsetOf(CdromDevicePath, "type")); |
| 916 | std.debug.assert(1 == @offsetOf(CdromDevicePath, "subtype")); |
| 917 | std.debug.assert(2 == @offsetOf(CdromDevicePath, "length")); |
| 918 | std.debug.assert(4 == @offsetOf(CdromDevicePath, "boot_entry")); |
| 919 | std.debug.assert(8 == @offsetOf(CdromDevicePath, "partition_start")); |
| 920 | std.debug.assert(16 == @offsetOf(CdromDevicePath, "partition_size")); |
| 921 | } |
| 922 | |
| 923 | pub const VendorDevicePath = extern struct { |
| 567 | 924 | type: DevicePathType, |
| 568 | 925 | subtype: Subtype, |
| 569 | | length: u16, |
| 570 | | guid: Guid, |
| 571 | | // vendor-defined variable data |
| 926 | length: u16 align(1), |
| 927 | guid: Guid align(1), |
| 572 | 928 | }; |
| 573 | 929 | |
| 574 | | pub const FilePathDevicePath = packed struct { |
| 930 | comptime { |
| 931 | std.debug.assert(20 == @sizeOf(VendorDevicePath)); |
| 932 | std.debug.assert(1 == @alignOf(VendorDevicePath)); |
| 933 | |
| 934 | std.debug.assert(0 == @offsetOf(VendorDevicePath, "type")); |
| 935 | std.debug.assert(1 == @offsetOf(VendorDevicePath, "subtype")); |
| 936 | std.debug.assert(2 == @offsetOf(VendorDevicePath, "length")); |
| 937 | std.debug.assert(4 == @offsetOf(VendorDevicePath, "guid")); |
| 938 | } |
| 939 | |
| 940 | pub const FilePathDevicePath = extern struct { |
| 575 | 941 | type: DevicePathType, |
| 576 | 942 | subtype: Subtype, |
| 577 | | length: u16, |
| 943 | length: u16 align(1), |
| 578 | 944 | |
| 579 | | pub fn getPath(self: *const FilePathDevicePath) [*:0]const u16 { |
| 580 | | return @ptrCast([*:0]const u16, @alignCast(2, @ptrCast([*]const u8, self)) + @sizeOf(FilePathDevicePath)); |
| 945 | pub fn getPath(self: *const FilePathDevicePath) [*:0]align(1) const u16 { |
| 946 | return @ptrCast([*:0]align(1) const u16, @ptrCast([*]const u8, self) + @sizeOf(FilePathDevicePath)); |
| 581 | 947 | } |
| 582 | 948 | }; |
| 583 | 949 | |
| 584 | | pub const MediaProtocolDevicePath = packed struct { |
| 950 | comptime { |
| 951 | std.debug.assert(4 == @sizeOf(FilePathDevicePath)); |
| 952 | std.debug.assert(1 == @alignOf(FilePathDevicePath)); |
| 953 | |
| 954 | std.debug.assert(0 == @offsetOf(FilePathDevicePath, "type")); |
| 955 | std.debug.assert(1 == @offsetOf(FilePathDevicePath, "subtype")); |
| 956 | std.debug.assert(2 == @offsetOf(FilePathDevicePath, "length")); |
| 957 | } |
| 958 | |
| 959 | pub const MediaProtocolDevicePath = extern struct { |
| 585 | 960 | type: DevicePathType, |
| 586 | 961 | subtype: Subtype, |
| 587 | | length: u16, |
| 588 | | guid: Guid, |
| 962 | length: u16 align(1), |
| 963 | guid: Guid align(1), |
| 589 | 964 | }; |
| 590 | 965 | |
| 591 | | pub const PiwgFirmwareFileDevicePath = packed struct { |
| 966 | comptime { |
| 967 | std.debug.assert(20 == @sizeOf(MediaProtocolDevicePath)); |
| 968 | std.debug.assert(1 == @alignOf(MediaProtocolDevicePath)); |
| 969 | |
| 970 | std.debug.assert(0 == @offsetOf(MediaProtocolDevicePath, "type")); |
| 971 | std.debug.assert(1 == @offsetOf(MediaProtocolDevicePath, "subtype")); |
| 972 | std.debug.assert(2 == @offsetOf(MediaProtocolDevicePath, "length")); |
| 973 | std.debug.assert(4 == @offsetOf(MediaProtocolDevicePath, "guid")); |
| 974 | } |
| 975 | |
| 976 | pub const PiwgFirmwareFileDevicePath = extern struct { |
| 592 | 977 | type: DevicePathType, |
| 593 | 978 | subtype: Subtype, |
| 594 | | length: u16, |
| 595 | | fv_filename: Guid, |
| 979 | length: u16 align(1), |
| 980 | fv_filename: Guid align(1), |
| 596 | 981 | }; |
| 597 | 982 | |
| 598 | | pub const PiwgFirmwareVolumeDevicePath = packed struct { |
| 983 | comptime { |
| 984 | std.debug.assert(20 == @sizeOf(PiwgFirmwareFileDevicePath)); |
| 985 | std.debug.assert(1 == @alignOf(PiwgFirmwareFileDevicePath)); |
| 986 | |
| 987 | std.debug.assert(0 == @offsetOf(PiwgFirmwareFileDevicePath, "type")); |
| 988 | std.debug.assert(1 == @offsetOf(PiwgFirmwareFileDevicePath, "subtype")); |
| 989 | std.debug.assert(2 == @offsetOf(PiwgFirmwareFileDevicePath, "length")); |
| 990 | std.debug.assert(4 == @offsetOf(PiwgFirmwareFileDevicePath, "fv_filename")); |
| 991 | } |
| 992 | |
| 993 | pub const PiwgFirmwareVolumeDevicePath = extern struct { |
| 599 | 994 | type: DevicePathType, |
| 600 | 995 | subtype: Subtype, |
| 601 | | length: u16, |
| 602 | | fv_name: Guid, |
| 996 | length: u16 align(1), |
| 997 | fv_name: Guid align(1), |
| 603 | 998 | }; |
| 604 | 999 | |
| 605 | | pub const RelativeOffsetRangeDevicePath = packed struct { |
| 1000 | comptime { |
| 1001 | std.debug.assert(20 == @sizeOf(PiwgFirmwareVolumeDevicePath)); |
| 1002 | std.debug.assert(1 == @alignOf(PiwgFirmwareVolumeDevicePath)); |
| 1003 | |
| 1004 | std.debug.assert(0 == @offsetOf(PiwgFirmwareVolumeDevicePath, "type")); |
| 1005 | std.debug.assert(1 == @offsetOf(PiwgFirmwareVolumeDevicePath, "subtype")); |
| 1006 | std.debug.assert(2 == @offsetOf(PiwgFirmwareVolumeDevicePath, "length")); |
| 1007 | std.debug.assert(4 == @offsetOf(PiwgFirmwareVolumeDevicePath, "fv_name")); |
| 1008 | } |
| 1009 | |
| 1010 | pub const RelativeOffsetRangeDevicePath = extern struct { |
| 606 | 1011 | type: DevicePathType, |
| 607 | 1012 | subtype: Subtype, |
| 608 | | length: u16, |
| 609 | | reserved: u32, |
| 610 | | start: u64, |
| 611 | | end: u64, |
| 1013 | length: u16 align(1), |
| 1014 | reserved: u32 align(1), |
| 1015 | start: u64 align(1), |
| 1016 | end: u64 align(1), |
| 612 | 1017 | }; |
| 613 | 1018 | |
| 614 | | pub const RamDiskDevicePath = packed struct { |
| 1019 | comptime { |
| 1020 | std.debug.assert(24 == @sizeOf(RelativeOffsetRangeDevicePath)); |
| 1021 | std.debug.assert(1 == @alignOf(RelativeOffsetRangeDevicePath)); |
| 1022 | |
| 1023 | std.debug.assert(0 == @offsetOf(RelativeOffsetRangeDevicePath, "type")); |
| 1024 | std.debug.assert(1 == @offsetOf(RelativeOffsetRangeDevicePath, "subtype")); |
| 1025 | std.debug.assert(2 == @offsetOf(RelativeOffsetRangeDevicePath, "length")); |
| 1026 | std.debug.assert(4 == @offsetOf(RelativeOffsetRangeDevicePath, "reserved")); |
| 1027 | std.debug.assert(8 == @offsetOf(RelativeOffsetRangeDevicePath, "start")); |
| 1028 | std.debug.assert(16 == @offsetOf(RelativeOffsetRangeDevicePath, "end")); |
| 1029 | } |
| 1030 | |
| 1031 | pub const RamDiskDevicePath = extern struct { |
| 615 | 1032 | type: DevicePathType, |
| 616 | 1033 | subtype: Subtype, |
| 617 | | length: u16, |
| 618 | | start: u64, |
| 619 | | end: u64, |
| 620 | | disk_type: Guid, |
| 621 | | instance: u16, |
| 1034 | length: u16 align(1), |
| 1035 | start: u64 align(1), |
| 1036 | end: u64 align(1), |
| 1037 | disk_type: Guid align(1), |
| 1038 | instance: u16 align(1), |
| 622 | 1039 | }; |
| 1040 | |
| 1041 | comptime { |
| 1042 | std.debug.assert(38 == @sizeOf(RamDiskDevicePath)); |
| 1043 | std.debug.assert(1 == @alignOf(RamDiskDevicePath)); |
| 1044 | |
| 1045 | std.debug.assert(0 == @offsetOf(RamDiskDevicePath, "type")); |
| 1046 | std.debug.assert(1 == @offsetOf(RamDiskDevicePath, "subtype")); |
| 1047 | std.debug.assert(2 == @offsetOf(RamDiskDevicePath, "length")); |
| 1048 | std.debug.assert(4 == @offsetOf(RamDiskDevicePath, "start")); |
| 1049 | std.debug.assert(12 == @offsetOf(RamDiskDevicePath, "end")); |
| 1050 | std.debug.assert(20 == @offsetOf(RamDiskDevicePath, "disk_type")); |
| 1051 | std.debug.assert(36 == @offsetOf(RamDiskDevicePath, "instance")); |
| 1052 | } |
| 623 | 1053 | }; |
| 624 | 1054 | |
| 625 | 1055 | pub const BiosBootSpecificationDevicePath = union(Subtype) { |
| ... | ... | @@ -630,17 +1060,28 @@ pub const BiosBootSpecificationDevicePath = union(Subtype) { |
| 630 | 1060 | _, |
| 631 | 1061 | }; |
| 632 | 1062 | |
| 633 | | pub const BBS101DevicePath = packed struct { |
| 1063 | pub const BBS101DevicePath = extern struct { |
| 634 | 1064 | type: DevicePathType, |
| 635 | 1065 | subtype: Subtype, |
| 636 | | length: u16, |
| 637 | | device_type: u16, |
| 638 | | status_flag: u16, |
| 1066 | length: u16 align(1), |
| 1067 | device_type: u16 align(1), |
| 1068 | status_flag: u16 align(1), |
| 639 | 1069 | |
| 640 | 1070 | pub fn getDescription(self: *const BBS101DevicePath) [*:0]const u8 { |
| 641 | 1071 | return @ptrCast([*:0]const u8, self) + @sizeOf(BBS101DevicePath); |
| 642 | 1072 | } |
| 643 | 1073 | }; |
| 1074 | |
| 1075 | comptime { |
| 1076 | std.debug.assert(8 == @sizeOf(BBS101DevicePath)); |
| 1077 | std.debug.assert(1 == @alignOf(BBS101DevicePath)); |
| 1078 | |
| 1079 | std.debug.assert(0 == @offsetOf(BBS101DevicePath, "type")); |
| 1080 | std.debug.assert(1 == @offsetOf(BBS101DevicePath, "subtype")); |
| 1081 | std.debug.assert(2 == @offsetOf(BBS101DevicePath, "length")); |
| 1082 | std.debug.assert(4 == @offsetOf(BBS101DevicePath, "device_type")); |
| 1083 | std.debug.assert(6 == @offsetOf(BBS101DevicePath, "status_flag")); |
| 1084 | } |
| 644 | 1085 | }; |
| 645 | 1086 | |
| 646 | 1087 | pub const EndDevicePath = union(Subtype) { |
| ... | ... | @@ -653,15 +1094,33 @@ pub const EndDevicePath = union(Subtype) { |
| 653 | 1094 | _, |
| 654 | 1095 | }; |
| 655 | 1096 | |
| 656 | | pub const EndEntireDevicePath = packed struct { |
| 1097 | pub const EndEntireDevicePath = extern struct { |
| 657 | 1098 | type: DevicePathType, |
| 658 | 1099 | subtype: Subtype, |
| 659 | | length: u16, |
| 1100 | length: u16 align(1), |
| 660 | 1101 | }; |
| 661 | 1102 | |
| 662 | | pub const EndThisInstanceDevicePath = packed struct { |
| 1103 | comptime { |
| 1104 | std.debug.assert(4 == @sizeOf(EndEntireDevicePath)); |
| 1105 | std.debug.assert(1 == @alignOf(EndEntireDevicePath)); |
| 1106 | |
| 1107 | std.debug.assert(0 == @offsetOf(EndEntireDevicePath, "type")); |
| 1108 | std.debug.assert(1 == @offsetOf(EndEntireDevicePath, "subtype")); |
| 1109 | std.debug.assert(2 == @offsetOf(EndEntireDevicePath, "length")); |
| 1110 | } |
| 1111 | |
| 1112 | pub const EndThisInstanceDevicePath = extern struct { |
| 663 | 1113 | type: DevicePathType, |
| 664 | 1114 | subtype: Subtype, |
| 665 | | length: u16, |
| 1115 | length: u16 align(1), |
| 666 | 1116 | }; |
| 1117 | |
| 1118 | comptime { |
| 1119 | std.debug.assert(4 == @sizeOf(EndEntireDevicePath)); |
| 1120 | std.debug.assert(1 == @alignOf(EndEntireDevicePath)); |
| 1121 | |
| 1122 | std.debug.assert(0 == @offsetOf(EndEntireDevicePath, "type")); |
| 1123 | std.debug.assert(1 == @offsetOf(EndEntireDevicePath, "subtype")); |
| 1124 | std.debug.assert(2 == @offsetOf(EndEntireDevicePath, "length")); |
| 1125 | } |
| 667 | 1126 | }; |