unionstd.os.uefi.device_path.DevicePath.Hardware[src]

Fields

pci: *const PciDevicePath
pc_card: *const PcCardDevicePath
memory_mapped: *const MemoryMappedDevicePath
vendor: *const VendorDevicePath
controller: *const ControllerDevicePath
bmc: *const BmcDevicePath

Source Code

Source code
pub const Hardware = union(Subtype) {
    pci: *const PciDevicePath,
    pc_card: *const PcCardDevicePath,
    memory_mapped: *const MemoryMappedDevicePath,
    vendor: *const VendorDevicePath,
    controller: *const ControllerDevicePath,
    bmc: *const BmcDevicePath,

    pub const Subtype = enum(u8) {
        pci = 1,
        pc_card = 2,
        memory_mapped = 3,
        vendor = 4,
        controller = 5,
        bmc = 6,
        _,
    };

    pub const PciDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        function: u8,
        device: u8,
    };

    comptime {
        assert(6 == @sizeOf(PciDevicePath));
        assert(1 == @alignOf(PciDevicePath));

        assert(0 == @offsetOf(PciDevicePath, "type"));
        assert(1 == @offsetOf(PciDevicePath, "subtype"));
        assert(2 == @offsetOf(PciDevicePath, "length"));
        assert(4 == @offsetOf(PciDevicePath, "function"));
        assert(5 == @offsetOf(PciDevicePath, "device"));
    }

    pub const PcCardDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        function_number: u8,
    };

    comptime {
        assert(5 == @sizeOf(PcCardDevicePath));
        assert(1 == @alignOf(PcCardDevicePath));

        assert(0 == @offsetOf(PcCardDevicePath, "type"));
        assert(1 == @offsetOf(PcCardDevicePath, "subtype"));
        assert(2 == @offsetOf(PcCardDevicePath, "length"));
        assert(4 == @offsetOf(PcCardDevicePath, "function_number"));
    }

    pub const MemoryMappedDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        memory_type: u32 align(1),
        start_address: u64 align(1),
        end_address: u64 align(1),
    };

    comptime {
        assert(24 == @sizeOf(MemoryMappedDevicePath));
        assert(1 == @alignOf(MemoryMappedDevicePath));

        assert(0 == @offsetOf(MemoryMappedDevicePath, "type"));
        assert(1 == @offsetOf(MemoryMappedDevicePath, "subtype"));
        assert(2 == @offsetOf(MemoryMappedDevicePath, "length"));
        assert(4 == @offsetOf(MemoryMappedDevicePath, "memory_type"));
        assert(8 == @offsetOf(MemoryMappedDevicePath, "start_address"));
        assert(16 == @offsetOf(MemoryMappedDevicePath, "end_address"));
    }

    pub const VendorDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        vendor_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, "vendor_guid"));
    }

    pub const ControllerDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        controller_number: u32 align(1),
    };

    comptime {
        assert(8 == @sizeOf(ControllerDevicePath));
        assert(1 == @alignOf(ControllerDevicePath));

        assert(0 == @offsetOf(ControllerDevicePath, "type"));
        assert(1 == @offsetOf(ControllerDevicePath, "subtype"));
        assert(2 == @offsetOf(ControllerDevicePath, "length"));
        assert(4 == @offsetOf(ControllerDevicePath, "controller_number"));
    }

    pub const BmcDevicePath = extern struct {
        type: DevicePath.Type,
        subtype: Subtype,
        length: u16 align(1),
        interface_type: u8,
        base_address: u64 align(1),
    };

    comptime {
        assert(13 == @sizeOf(BmcDevicePath));
        assert(1 == @alignOf(BmcDevicePath));

        assert(0 == @offsetOf(BmcDevicePath, "type"));
        assert(1 == @offsetOf(BmcDevicePath, "subtype"));
        assert(2 == @offsetOf(BmcDevicePath, "length"));
        assert(4 == @offsetOf(BmcDevicePath, "interface_type"));
        assert(5 == @offsetOf(BmcDevicePath, "base_address"));
    }
}