union Acpi [src]

Fields

acpi: *const BaseAcpiDevicePath
expanded_acpi: *const ExpandedAcpiDevicePath
adr: *const AdrDevicePath

Members

Source

pub const Acpi = union(Subtype) { acpi: *const BaseAcpiDevicePath, expanded_acpi: *const ExpandedAcpiDevicePath, adr: *const AdrDevicePath, pub const Subtype = enum(u8) { acpi = 1, expanded_acpi = 2, adr = 3, _, }; pub const BaseAcpiDevicePath = extern struct { type: DevicePath.Type, subtype: Subtype, length: u16 align(1), hid: u32 align(1), uid: u32 align(1), }; comptime { assert(12 == @sizeOf(BaseAcpiDevicePath)); assert(1 == @alignOf(BaseAcpiDevicePath)); assert(0 == @offsetOf(BaseAcpiDevicePath, "type")); assert(1 == @offsetOf(BaseAcpiDevicePath, "subtype")); assert(2 == @offsetOf(BaseAcpiDevicePath, "length")); assert(4 == @offsetOf(BaseAcpiDevicePath, "hid")); assert(8 == @offsetOf(BaseAcpiDevicePath, "uid")); } pub const ExpandedAcpiDevicePath = extern struct { type: DevicePath.Type, subtype: Subtype, length: u16 align(1), hid: u32 align(1), uid: u32 align(1), cid: u32 align(1), // variable length u16[*:0] strings // hid_str, uid_str, cid_str }; comptime { assert(16 == @sizeOf(ExpandedAcpiDevicePath)); assert(1 == @alignOf(ExpandedAcpiDevicePath)); assert(0 == @offsetOf(ExpandedAcpiDevicePath, "type")); assert(1 == @offsetOf(ExpandedAcpiDevicePath, "subtype")); assert(2 == @offsetOf(ExpandedAcpiDevicePath, "length")); assert(4 == @offsetOf(ExpandedAcpiDevicePath, "hid")); assert(8 == @offsetOf(ExpandedAcpiDevicePath, "uid")); assert(12 == @offsetOf(ExpandedAcpiDevicePath, "cid")); } pub const AdrDevicePath = extern struct { type: DevicePath.Type, subtype: Subtype, length: u16 align(1), adr: u32 align(1), // multiple adr entries can optionally follow pub fn adrs(self: *const AdrDevicePath) []align(1) const u32 { // self.length is a minimum of 8 with one adr which is size 4. const entries = (self.length - 4) / @sizeOf(u32); return @as([*]align(1) const u32, @ptrCast(&self.adr))[0..entries]; } }; comptime { assert(8 == @sizeOf(AdrDevicePath)); assert(1 == @alignOf(AdrDevicePath)); assert(0 == @offsetOf(AdrDevicePath, "type")); assert(1 == @offsetOf(AdrDevicePath, "subtype")); assert(2 == @offsetOf(AdrDevicePath, "length")); assert(4 == @offsetOf(AdrDevicePath, "adr")); } }