mod device_path_gen;
use crate::{Boolean, Char16, Guid, guid, newtype_enum};
pub use device_path_gen::{acpi, bios_boot_spec, end, hardware, media, messaging};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(C)]
pub struct DevicePathProtocol {
pub major_type: DeviceType,
pub sub_type: DeviceSubType,
pub length: [u8; 2],
}
impl DevicePathProtocol {
pub const GUID: Guid = guid!("09576e91-6d3f-11d2-8e39-00a0c969723b");
#[must_use]
pub const fn length(&self) -> u16 {
u16::from_le_bytes(self.length)
}
}
newtype_enum! {
pub enum DeviceType: u8 => {
HARDWARE = 0x01,
ACPI = 0x02,
MESSAGING = 0x03,
MEDIA = 0x04,
BIOS_BOOT_SPEC = 0x05,
END = 0x7F,
}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
pub struct DeviceSubType(pub u8);
impl DeviceSubType {
pub const HARDWARE_PCI: Self = Self(1);
pub const HARDWARE_PCCARD: Self = Self(2);
pub const HARDWARE_MEMORY_MAPPED: Self = Self(3);
pub const HARDWARE_VENDOR: Self = Self(4);
pub const HARDWARE_CONTROLLER: Self = Self(5);
pub const HARDWARE_BMC: Self = Self(6);
pub const ACPI: Self = Self(1);
pub const ACPI_EXPANDED: Self = Self(2);
pub const ACPI_ADR: Self = Self(3);
pub const ACPI_NVDIMM: Self = Self(4);
pub const MESSAGING_ATAPI: Self = Self(1);
pub const MESSAGING_SCSI: Self = Self(2);
pub const MESSAGING_FIBRE_CHANNEL: Self = Self(3);
pub const MESSAGING_1394: Self = Self(4);
pub const MESSAGING_USB: Self = Self(5);
pub const MESSAGING_I2O: Self = Self(6);
pub const MESSAGING_INFINIBAND: Self = Self(9);
pub const MESSAGING_VENDOR: Self = Self(10);
pub const MESSAGING_MAC_ADDRESS: Self = Self(11);
pub const MESSAGING_IPV4: Self = Self(12);
pub const MESSAGING_IPV6: Self = Self(13);
pub const MESSAGING_UART: Self = Self(14);
pub const MESSAGING_USB_CLASS: Self = Self(15);
pub const MESSAGING_USB_WWID: Self = Self(16);
pub const MESSAGING_DEVICE_LOGICAL_UNIT: Self = Self(17);
pub const MESSAGING_SATA: Self = Self(18);
pub const MESSAGING_ISCSI: Self = Self(19);
pub const MESSAGING_VLAN: Self = Self(20);
pub const MESSAGING_FIBRE_CHANNEL_EX: Self = Self(21);
pub const MESSAGING_SCSI_SAS_EX: Self = Self(22);
pub const MESSAGING_NVME_NAMESPACE: Self = Self(23);
pub const MESSAGING_URI: Self = Self(24);
pub const MESSAGING_UFS: Self = Self(25);
pub const MESSAGING_SD: Self = Self(26);
pub const MESSAGING_BLUETOOTH: Self = Self(27);
pub const MESSAGING_WIFI: Self = Self(28);
pub const MESSAGING_EMMC: Self = Self(29);
pub const MESSAGING_BLUETOOTH_LE: Self = Self(30);
pub const MESSAGING_DNS: Self = Self(31);
pub const MESSAGING_NVDIMM_NAMESPACE: Self = Self(32);
pub const MESSAGING_REST_SERVICE: Self = Self(33);
pub const MESSAGING_NVME_OF_NAMESPACE: Self = Self(34);
pub const MEDIA_HARD_DRIVE: Self = Self(1);
pub const MEDIA_CD_ROM: Self = Self(2);
pub const MEDIA_VENDOR: Self = Self(3);
pub const MEDIA_FILE_PATH: Self = Self(4);
pub const MEDIA_PROTOCOL: Self = Self(5);
pub const MEDIA_PIWG_FIRMWARE_FILE: Self = Self(6);
pub const MEDIA_PIWG_FIRMWARE_VOLUME: Self = Self(7);
pub const MEDIA_RELATIVE_OFFSET_RANGE: Self = Self(8);
pub const MEDIA_RAM_DISK: Self = Self(9);
pub const BIOS_BOOT_SPECIFICATION: Self = Self(1);
pub const END_INSTANCE: Self = Self(0x01);
pub const END_ENTIRE: Self = Self(0xff);
}
#[derive(Debug)]
#[repr(C)]
pub struct DevicePathToTextProtocol {
pub convert_device_node_to_text: unsafe extern "efiapi" fn(
device_node: *const DevicePathProtocol,
display_only: Boolean,
allow_shortcuts: Boolean,
) -> *const Char16,
pub convert_device_path_to_text: unsafe extern "efiapi" fn(
device_path: *const DevicePathProtocol,
display_only: Boolean,
allow_shortcuts: Boolean,
) -> *const Char16,
}
impl DevicePathToTextProtocol {
pub const GUID: Guid = guid!("8b843e20-8132-4852-90cc-551a4e4a7f1c");
}
#[derive(Debug)]
#[repr(C)]
pub struct DevicePathFromTextProtocol {
pub convert_text_to_device_node:
unsafe extern "efiapi" fn(text_device_node: *const Char16) -> *const DevicePathProtocol,
pub convert_text_to_device_path:
unsafe extern "efiapi" fn(text_device_path: *const Char16) -> *const DevicePathProtocol,
}
impl DevicePathFromTextProtocol {
pub const GUID: Guid = guid!("05c99a21-c70f-4ad2-8a5f-35df3343f51e");
}
#[derive(Debug)]
#[repr(C)]
pub struct DevicePathUtilitiesProtocol {
pub get_device_path_size:
unsafe extern "efiapi" fn(device_path: *const DevicePathProtocol) -> usize,
pub duplicate_device_path: unsafe extern "efiapi" fn(
device_path: *const DevicePathProtocol,
) -> *const DevicePathProtocol,
pub append_device_path: unsafe extern "efiapi" fn(
src1: *const DevicePathProtocol,
src2: *const DevicePathProtocol,
) -> *const DevicePathProtocol,
pub append_device_node: unsafe extern "efiapi" fn(
device_path: *const DevicePathProtocol,
device_node: *const DevicePathProtocol,
) -> *const DevicePathProtocol,
pub append_device_path_instance: unsafe extern "efiapi" fn(
device_path: *const DevicePathProtocol,
device_path_instance: *const DevicePathProtocol,
) -> *const DevicePathProtocol,
pub get_next_device_path_instance: unsafe extern "efiapi" fn(
device_path_instance: *mut *const DevicePathProtocol,
device_path_instance_size: *mut usize,
) -> *const DevicePathProtocol,
pub is_device_path_multi_instance:
unsafe extern "efiapi" fn(device_path: *const DevicePathProtocol) -> Boolean,
pub create_device_node: unsafe extern "efiapi" fn(
node_type: DeviceType,
node_sub_type: DeviceSubType,
node_length: u16,
) -> *const DevicePathProtocol,
}
impl DevicePathUtilitiesProtocol {
pub const GUID: Guid = guid!("0379be4e-d706-437d-b037-edb82fb772a4");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn abi() {
assert_eq!(size_of::<DevicePathProtocol>(), 4);
assert_eq!(align_of::<DevicePathProtocol>(), 1);
}
}