EndThisInstanceDevicePath
|
pub fn serial_number(self: *const UsbWwidDevicePath) []align(1) const u16 {
const serial_len = (self.length - @sizeOf(UsbWwidDevicePath)) / @sizeOf(u16);
return @as([*]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(UsbWwidDevicePath)))[0..serial_len];
}
};
comptime {
assert(10 == @sizeOf(UsbWwidDevicePath));
assert(1 == @alignOf(UsbWwidDevicePath));
assert(0 == @offsetOf(UsbWwidDevicePath, "type"));
assert(1 == @offsetOf(UsbWwidDevicePath, "subtype"));
assert(2 == @offsetOf(UsbWwidDevicePath, "length"));
assert(4 == @offsetOf(UsbWwidDevicePath, "interface_number"));
assert(6 == @offsetOf(UsbWwidDevicePath, "device_vendor_id"));
assert(8 == @offsetOf(UsbWwidDevicePath, "device_product_id"));
}
pub const DeviceLogicalUnitDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
lun: u8,
};
comptime {
assert(5 == @sizeOf(DeviceLogicalUnitDevicePath));
assert(1 == @alignOf(DeviceLogicalUnitDevicePath));
assert(0 == @offsetOf(DeviceLogicalUnitDevicePath, "type"));
assert(1 == @offsetOf(DeviceLogicalUnitDevicePath, "subtype"));
assert(2 == @offsetOf(DeviceLogicalUnitDevicePath, "length"));
assert(4 == @offsetOf(DeviceLogicalUnitDevicePath, "lun"));
}
pub const UsbClassDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
vendor_id: u16 align(1),
product_id: u16 align(1),
device_class: u8,
device_subclass: u8,
device_protocol: u8,
};
comptime {
assert(11 == @sizeOf(UsbClassDevicePath));
assert(1 == @alignOf(UsbClassDevicePath));
assert(0 == @offsetOf(UsbClassDevicePath, "type"));
assert(1 == @offsetOf(UsbClassDevicePath, "subtype"));
assert(2 == @offsetOf(UsbClassDevicePath, "length"));
assert(4 == @offsetOf(UsbClassDevicePath, "vendor_id"));
assert(6 == @offsetOf(UsbClassDevicePath, "product_id"));
assert(8 == @offsetOf(UsbClassDevicePath, "device_class"));
assert(9 == @offsetOf(UsbClassDevicePath, "device_subclass"));
assert(10 == @offsetOf(UsbClassDevicePath, "device_protocol"));
}
pub const I2oDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
tid: u32 align(1),
};
comptime {
assert(8 == @sizeOf(I2oDevicePath));
assert(1 == @alignOf(I2oDevicePath));
assert(0 == @offsetOf(I2oDevicePath, "type"));
assert(1 == @offsetOf(I2oDevicePath, "subtype"));
assert(2 == @offsetOf(I2oDevicePath, "length"));
assert(4 == @offsetOf(I2oDevicePath, "tid"));
}
pub const MacAddressDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
mac_address: uefi.MacAddress,
if_type: u8,
};
comptime {
assert(37 == @sizeOf(MacAddressDevicePath));
assert(1 == @alignOf(MacAddressDevicePath));
assert(0 == @offsetOf(MacAddressDevicePath, "type"));
assert(1 == @offsetOf(MacAddressDevicePath, "subtype"));
assert(2 == @offsetOf(MacAddressDevicePath, "length"));
assert(4 == @offsetOf(MacAddressDevicePath, "mac_address"));
assert(36 == @offsetOf(MacAddressDevicePath, "if_type"));
}
pub const Ipv4DevicePath = extern struct {
pub const IpType = enum(u8) {
Dhcp = 0,
Static = 1,
};
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
local_ip_address: uefi.Ipv4Address align(1),
remote_ip_address: uefi.Ipv4Address align(1),
local_port: u16 align(1),
remote_port: u16 align(1),
network_protocol: u16 align(1),
static_ip_address: IpType,
gateway_ip_address: u32 align(1),
subnet_mask: u32 align(1),
};
comptime {
assert(27 == @sizeOf(Ipv4DevicePath));
assert(1 == @alignOf(Ipv4DevicePath));
assert(0 == @offsetOf(Ipv4DevicePath, "type"));
assert(1 == @offsetOf(Ipv4DevicePath, "subtype"));
assert(2 == @offsetOf(Ipv4DevicePath, "length"));
assert(4 == @offsetOf(Ipv4DevicePath, "local_ip_address"));
assert(8 == @offsetOf(Ipv4DevicePath, "remote_ip_address"));
assert(12 == @offsetOf(Ipv4DevicePath, "local_port"));
assert(14 == @offsetOf(Ipv4DevicePath, "remote_port"));
assert(16 == @offsetOf(Ipv4DevicePath, "network_protocol"));
assert(18 == @offsetOf(Ipv4DevicePath, "static_ip_address"));
assert(19 == @offsetOf(Ipv4DevicePath, "gateway_ip_address"));
assert(23 == @offsetOf(Ipv4DevicePath, "subnet_mask"));
}
pub const Ipv6DevicePath = extern struct {
pub const Origin = enum(u8) {
Manual = 0,
AssignedStateless = 1,
AssignedStateful = 2,
};
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
local_ip_address: uefi.Ipv6Address,
remote_ip_address: uefi.Ipv6Address,
local_port: u16 align(1),
remote_port: u16 align(1),
protocol: u16 align(1),
ip_address_origin: Origin,
prefix_length: u8,
gateway_ip_address: uefi.Ipv6Address,
};
comptime {
assert(60 == @sizeOf(Ipv6DevicePath));
assert(1 == @alignOf(Ipv6DevicePath));
assert(0 == @offsetOf(Ipv6DevicePath, "type"));
assert(1 == @offsetOf(Ipv6DevicePath, "subtype"));
assert(2 == @offsetOf(Ipv6DevicePath, "length"));
assert(4 == @offsetOf(Ipv6DevicePath, "local_ip_address"));
assert(20 == @offsetOf(Ipv6DevicePath, "remote_ip_address"));
assert(36 == @offsetOf(Ipv6DevicePath, "local_port"));
assert(38 == @offsetOf(Ipv6DevicePath, "remote_port"));
assert(40 == @offsetOf(Ipv6DevicePath, "protocol"));
assert(42 == @offsetOf(Ipv6DevicePath, "ip_address_origin"));
assert(43 == @offsetOf(Ipv6DevicePath, "prefix_length"));
assert(44 == @offsetOf(Ipv6DevicePath, "gateway_ip_address"));
}
pub const VlanDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
vlan_id: u16 align(1),
};
comptime {
assert(6 == @sizeOf(VlanDevicePath));
assert(1 == @alignOf(VlanDevicePath));
assert(0 == @offsetOf(VlanDevicePath, "type"));
assert(1 == @offsetOf(VlanDevicePath, "subtype"));
assert(2 == @offsetOf(VlanDevicePath, "length"));
assert(4 == @offsetOf(VlanDevicePath, "vlan_id"));
}
pub const InfiniBandDevicePath = extern struct {
pub const ResourceFlags = packed struct(u32) {
pub const ControllerType = enum(u1) {
Ioc = 0,
Service = 1,
};
ioc_or_service: ControllerType,
extend_boot_environment: bool,
console_protocol: bool,
storage_protocol: bool,
network_protocol: bool,
// u1 + 4 * bool = 5 bits, we need a total of 32 bits
reserved: u27,
};
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
resource_flags: ResourceFlags align(1),
port_gid: [16]u8,
service_id: u64 align(1),
target_port_id: u64 align(1),
device_id: u64 align(1),
};
comptime {
assert(48 == @sizeOf(InfiniBandDevicePath));
assert(1 == @alignOf(InfiniBandDevicePath));
assert(0 == @offsetOf(InfiniBandDevicePath, "type"));
assert(1 == @offsetOf(InfiniBandDevicePath, "subtype"));
assert(2 == @offsetOf(InfiniBandDevicePath, "length"));
assert(4 == @offsetOf(InfiniBandDevicePath, "resource_flags"));
assert(8 == @offsetOf(InfiniBandDevicePath, "port_gid"));
assert(24 == @offsetOf(InfiniBandDevicePath, "service_id"));
assert(32 == @offsetOf(InfiniBandDevicePath, "target_port_id"));
assert(40 == @offsetOf(InfiniBandDevicePath, "device_id"));
}
pub const UartDevicePath = extern struct {
pub const Parity = enum(u8) {
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,
_,
};
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
reserved: u32 align(1),
baud_rate: u64 align(1),
data_bits: u8,
parity: Parity,
stop_bits: StopBits,
};
comptime {
assert(19 == @sizeOf(UartDevicePath));
assert(1 == @alignOf(UartDevicePath));
assert(0 == @offsetOf(UartDevicePath, "type"));
assert(1 == @offsetOf(UartDevicePath, "subtype"));
assert(2 == @offsetOf(UartDevicePath, "length"));
assert(4 == @offsetOf(UartDevicePath, "reserved"));
assert(8 == @offsetOf(UartDevicePath, "baud_rate"));
assert(16 == @offsetOf(UartDevicePath, "data_bits"));
assert(17 == @offsetOf(UartDevicePath, "parity"));
assert(18 == @offsetOf(UartDevicePath, "stop_bits"));
}
pub const VendorDefinedDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
vendor_guid: Guid align(1),
};
comptime {
assert(20 == @sizeOf(VendorDefinedDevicePath));
assert(1 == @alignOf(VendorDefinedDevicePath));
assert(0 == @offsetOf(VendorDefinedDevicePath, "type"));
assert(1 == @offsetOf(VendorDefinedDevicePath, "subtype"));
assert(2 == @offsetOf(VendorDefinedDevicePath, "length"));
assert(4 == @offsetOf(VendorDefinedDevicePath, "vendor_guid"));
}
};
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,
pub const Subtype = enum(u8) {
HardDrive = 1,
Cdrom = 2,
Vendor = 3,
FilePath = 4,
MediaProtocol = 5,
PiwgFirmwareFile = 6,
PiwgFirmwareVolume = 7,
RelativeOffsetRange = 8,
RamDisk = 9,
_,
};
pub const HardDriveDevicePath = extern struct {
pub const Format = enum(u8) {
LegacyMbr = 0x01,
GuidPartitionTable = 0x02,
};
pub const SignatureType = enum(u8) {
NoSignature = 0x00,
/// "32-bit signature from address 0x1b8 of the type 0x01 MBR"
MbrSignature = 0x01,
GuidSignature = 0x02,
};
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
partition_number: u32 align(1),
partition_start: u64 align(1),
partition_size: u64 align(1),
partition_signature: [16]u8,
partition_format: Format,
signature_type: SignatureType,
};
comptime {
assert(42 == @sizeOf(HardDriveDevicePath));
assert(1 == @alignOf(HardDriveDevicePath));
assert(0 == @offsetOf(HardDriveDevicePath, "type"));
assert(1 == @offsetOf(HardDriveDevicePath, "subtype"));
assert(2 == @offsetOf(HardDriveDevicePath, "length"));
assert(4 == @offsetOf(HardDriveDevicePath, "partition_number"));
assert(8 == @offsetOf(HardDriveDevicePath, "partition_start"));
assert(16 == @offsetOf(HardDriveDevicePath, "partition_size"));
assert(24 == @offsetOf(HardDriveDevicePath, "partition_signature"));
assert(40 == @offsetOf(HardDriveDevicePath, "partition_format"));
assert(41 == @offsetOf(HardDriveDevicePath, "signature_type"));
}
pub const CdromDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
boot_entry: u32 align(1),
partition_start: u64 align(1),
partition_size: u64 align(1),
};
comptime {
assert(24 == @sizeOf(CdromDevicePath));
assert(1 == @alignOf(CdromDevicePath));
assert(0 == @offsetOf(CdromDevicePath, "type"));
assert(1 == @offsetOf(CdromDevicePath, "subtype"));
assert(2 == @offsetOf(CdromDevicePath, "length"));
assert(4 == @offsetOf(CdromDevicePath, "boot_entry"));
assert(8 == @offsetOf(CdromDevicePath, "partition_start"));
assert(16 == @offsetOf(CdromDevicePath, "partition_size"));
}
pub const VendorDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
guid: Guid align(1),
};
comptime {
assert(20 == @sizeOf(VendorDevicePath));
assert(1 == @alignOf(VendorDevicePath));
assert(0 == @offsetOf(VendorDevicePath, "type"));
assert(1 == @offsetOf(VendorDevicePath, "subtype"));
assert(2 == @offsetOf(VendorDevicePath, "length"));
assert(4 == @offsetOf(VendorDevicePath, "guid"));
}
pub const FilePathDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
pub fn getPath(self: *const FilePathDevicePath) [*:0]align(1) const u16 {
return @as([*:0]align(1) const u16, @ptrCast(@as([*]const u8, @ptrCast(self)) + @sizeOf(FilePathDevicePath)));
}
};
comptime {
assert(4 == @sizeOf(FilePathDevicePath));
assert(1 == @alignOf(FilePathDevicePath));
assert(0 == @offsetOf(FilePathDevicePath, "type"));
assert(1 == @offsetOf(FilePathDevicePath, "subtype"));
assert(2 == @offsetOf(FilePathDevicePath, "length"));
}
pub const MediaProtocolDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
guid: Guid align(1),
};
comptime {
assert(20 == @sizeOf(MediaProtocolDevicePath));
assert(1 == @alignOf(MediaProtocolDevicePath));
assert(0 == @offsetOf(MediaProtocolDevicePath, "type"));
assert(1 == @offsetOf(MediaProtocolDevicePath, "subtype"));
assert(2 == @offsetOf(MediaProtocolDevicePath, "length"));
assert(4 == @offsetOf(MediaProtocolDevicePath, "guid"));
}
pub const PiwgFirmwareFileDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
fv_filename: Guid align(1),
};
comptime {
assert(20 == @sizeOf(PiwgFirmwareFileDevicePath));
assert(1 == @alignOf(PiwgFirmwareFileDevicePath));
assert(0 == @offsetOf(PiwgFirmwareFileDevicePath, "type"));
assert(1 == @offsetOf(PiwgFirmwareFileDevicePath, "subtype"));
assert(2 == @offsetOf(PiwgFirmwareFileDevicePath, "length"));
assert(4 == @offsetOf(PiwgFirmwareFileDevicePath, "fv_filename"));
}
pub const PiwgFirmwareVolumeDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
fv_name: Guid align(1),
};
comptime {
assert(20 == @sizeOf(PiwgFirmwareVolumeDevicePath));
assert(1 == @alignOf(PiwgFirmwareVolumeDevicePath));
assert(0 == @offsetOf(PiwgFirmwareVolumeDevicePath, "type"));
assert(1 == @offsetOf(PiwgFirmwareVolumeDevicePath, "subtype"));
assert(2 == @offsetOf(PiwgFirmwareVolumeDevicePath, "length"));
assert(4 == @offsetOf(PiwgFirmwareVolumeDevicePath, "fv_name"));
}
pub const RelativeOffsetRangeDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
reserved: u32 align(1),
start: u64 align(1),
end: u64 align(1),
};
comptime {
assert(24 == @sizeOf(RelativeOffsetRangeDevicePath));
assert(1 == @alignOf(RelativeOffsetRangeDevicePath));
assert(0 == @offsetOf(RelativeOffsetRangeDevicePath, "type"));
assert(1 == @offsetOf(RelativeOffsetRangeDevicePath, "subtype"));
assert(2 == @offsetOf(RelativeOffsetRangeDevicePath, "length"));
assert(4 == @offsetOf(RelativeOffsetRangeDevicePath, "reserved"));
assert(8 == @offsetOf(RelativeOffsetRangeDevicePath, "start"));
assert(16 == @offsetOf(RelativeOffsetRangeDevicePath, "end"));
}
pub const RamDiskDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
start: u64 align(1),
end: u64 align(1),
disk_type: Guid align(1),
instance: u16 align(1),
};
comptime {
assert(38 == @sizeOf(RamDiskDevicePath));
assert(1 == @alignOf(RamDiskDevicePath));
assert(0 == @offsetOf(RamDiskDevicePath, "type"));
assert(1 == @offsetOf(RamDiskDevicePath, "subtype"));
assert(2 == @offsetOf(RamDiskDevicePath, "length"));
assert(4 == @offsetOf(RamDiskDevicePath, "start"));
assert(12 == @offsetOf(RamDiskDevicePath, "end"));
assert(20 == @offsetOf(RamDiskDevicePath, "disk_type"));
assert(36 == @offsetOf(RamDiskDevicePath, "instance"));
}
};
pub const BiosBootSpecification = union(Subtype) {
BBS101: *const BBS101DevicePath,
pub const Subtype = enum(u8) {
BBS101 = 1,
_,
};
pub const BBS101DevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
device_type: u16 align(1),
status_flag: u16 align(1),
pub fn getDescription(self: *const BBS101DevicePath) [*:0]const u8 {
return @as([*:0]const u8, @ptrCast(self)) + @sizeOf(BBS101DevicePath);
}
};
comptime {
assert(8 == @sizeOf(BBS101DevicePath));
assert(1 == @alignOf(BBS101DevicePath));
assert(0 == @offsetOf(BBS101DevicePath, "type"));
assert(1 == @offsetOf(BBS101DevicePath, "subtype"));
assert(2 == @offsetOf(BBS101DevicePath, "length"));
assert(4 == @offsetOf(BBS101DevicePath, "device_type"));
assert(6 == @offsetOf(BBS101DevicePath, "status_flag"));
}
};
pub const End = union(Subtype) {
EndEntire: *const EndEntireDevicePath,
EndThisInstance: *const EndThisInstanceDevicePath,
pub const Subtype = enum(u8) {
EndEntire = 0xff,
EndThisInstance = 0x01,
_,
};
pub const EndEntireDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
};
comptime {
assert(4 == @sizeOf(EndEntireDevicePath));
assert(1 == @alignOf(EndEntireDevicePath));
assert(0 == @offsetOf(EndEntireDevicePath, "type"));
assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
assert(2 == @offsetOf(EndEntireDevicePath, "length"));
}
pub const EndThisInstanceDevicePath = extern struct {
type: DevicePath.Type,
subtype: Subtype,
length: u16 align(1),
};
comptime {
assert(4 == @sizeOf(EndEntireDevicePath));
assert(1 == @alignOf(EndEntireDevicePath));
assert(0 == @offsetOf(EndEntireDevicePath, "type"));
assert(1 == @offsetOf(EndEntireDevicePath, "subtype"));
assert(2 == @offsetOf(EndEntireDevicePath, "length"));
}
};
};
|