uefi_raw/protocol/
device_path.rs1mod device_path_gen;
4
5use crate::{guid, Boolean, Char16, Guid};
6
7pub use device_path_gen::{acpi, bios_boot_spec, end, hardware, media, messaging};
8
9#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17#[repr(C)]
18pub struct DevicePathProtocol {
19 pub major_type: DeviceType,
20 pub sub_type: DeviceSubType,
21 pub length: [u8; 2],
23 }
25
26impl DevicePathProtocol {
27 pub const GUID: Guid = guid!("09576e91-6d3f-11d2-8e39-00a0c969723b");
28
29 #[must_use]
31 pub const fn length(&self) -> u16 {
32 u16::from_le_bytes(self.length)
33 }
34}
35
36newtype_enum! {
37pub enum DeviceType: u8 => {
39 HARDWARE = 0x01,
44 ACPI = 0x02,
50 MESSAGING = 0x03,
56 MEDIA = 0x04,
61 BIOS_BOOT_SPEC = 0x05,
66 END = 0x7F,
71}}
72
73#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
75#[repr(transparent)]
76pub struct DeviceSubType(pub u8);
77
78impl DeviceSubType {
79 pub const HARDWARE_PCI: Self = Self(1);
81 pub const HARDWARE_PCCARD: Self = Self(2);
83 pub const HARDWARE_MEMORY_MAPPED: Self = Self(3);
85 pub const HARDWARE_VENDOR: Self = Self(4);
87 pub const HARDWARE_CONTROLLER: Self = Self(5);
89 pub const HARDWARE_BMC: Self = Self(6);
91
92 pub const ACPI: Self = Self(1);
94 pub const ACPI_EXPANDED: Self = Self(2);
96 pub const ACPI_ADR: Self = Self(3);
98 pub const ACPI_NVDIMM: Self = Self(4);
100
101 pub const MESSAGING_ATAPI: Self = Self(1);
103 pub const MESSAGING_SCSI: Self = Self(2);
105 pub const MESSAGING_FIBRE_CHANNEL: Self = Self(3);
107 pub const MESSAGING_1394: Self = Self(4);
109 pub const MESSAGING_USB: Self = Self(5);
111 pub const MESSAGING_I2O: Self = Self(6);
113 pub const MESSAGING_INFINIBAND: Self = Self(9);
115 pub const MESSAGING_VENDOR: Self = Self(10);
117 pub const MESSAGING_MAC_ADDRESS: Self = Self(11);
119 pub const MESSAGING_IPV4: Self = Self(12);
121 pub const MESSAGING_IPV6: Self = Self(13);
123 pub const MESSAGING_UART: Self = Self(14);
125 pub const MESSAGING_USB_CLASS: Self = Self(15);
127 pub const MESSAGING_USB_WWID: Self = Self(16);
129 pub const MESSAGING_DEVICE_LOGICAL_UNIT: Self = Self(17);
131 pub const MESSAGING_SATA: Self = Self(18);
133 pub const MESSAGING_ISCSI: Self = Self(19);
135 pub const MESSAGING_VLAN: Self = Self(20);
137 pub const MESSAGING_FIBRE_CHANNEL_EX: Self = Self(21);
139 pub const MESSAGING_SCSI_SAS_EX: Self = Self(22);
141 pub const MESSAGING_NVME_NAMESPACE: Self = Self(23);
143 pub const MESSAGING_URI: Self = Self(24);
145 pub const MESSAGING_UFS: Self = Self(25);
147 pub const MESSAGING_SD: Self = Self(26);
149 pub const MESSAGING_BLUETOOTH: Self = Self(27);
151 pub const MESSAGING_WIFI: Self = Self(28);
153 pub const MESSAGING_EMMC: Self = Self(29);
155 pub const MESSAGING_BLUETOOTH_LE: Self = Self(30);
157 pub const MESSAGING_DNS: Self = Self(31);
159 pub const MESSAGING_NVDIMM_NAMESPACE: Self = Self(32);
161 pub const MESSAGING_REST_SERVICE: Self = Self(33);
163 pub const MESSAGING_NVME_OF_NAMESPACE: Self = Self(34);
165
166 pub const MEDIA_HARD_DRIVE: Self = Self(1);
168 pub const MEDIA_CD_ROM: Self = Self(2);
170 pub const MEDIA_VENDOR: Self = Self(3);
172 pub const MEDIA_FILE_PATH: Self = Self(4);
174 pub const MEDIA_PROTOCOL: Self = Self(5);
176 pub const MEDIA_PIWG_FIRMWARE_FILE: Self = Self(6);
178 pub const MEDIA_PIWG_FIRMWARE_VOLUME: Self = Self(7);
180 pub const MEDIA_RELATIVE_OFFSET_RANGE: Self = Self(8);
182 pub const MEDIA_RAM_DISK: Self = Self(9);
184
185 pub const BIOS_BOOT_SPECIFICATION: Self = Self(1);
187
188 pub const END_INSTANCE: Self = Self(0x01);
190 pub const END_ENTIRE: Self = Self(0xff);
192}
193
194#[derive(Debug)]
195#[repr(C)]
196pub struct DevicePathToTextProtocol {
197 pub convert_device_node_to_text: unsafe extern "efiapi" fn(
198 device_node: *const DevicePathProtocol,
199 display_only: Boolean,
200 allow_shortcuts: Boolean,
201 ) -> *const Char16,
202 pub convert_device_path_to_text: unsafe extern "efiapi" fn(
203 device_path: *const DevicePathProtocol,
204 display_only: Boolean,
205 allow_shortcuts: Boolean,
206 ) -> *const Char16,
207}
208
209impl DevicePathToTextProtocol {
210 pub const GUID: Guid = guid!("8b843e20-8132-4852-90cc-551a4e4a7f1c");
211}
212
213#[derive(Debug)]
214#[repr(C)]
215pub struct DevicePathFromTextProtocol {
216 pub convert_text_to_device_node:
217 unsafe extern "efiapi" fn(text_device_node: *const Char16) -> *const DevicePathProtocol,
218 pub convert_text_to_device_path:
219 unsafe extern "efiapi" fn(text_device_path: *const Char16) -> *const DevicePathProtocol,
220}
221
222impl DevicePathFromTextProtocol {
223 pub const GUID: Guid = guid!("05c99a21-c70f-4ad2-8a5f-35df3343f51e");
224}
225
226#[derive(Debug)]
227#[repr(C)]
228pub struct DevicePathUtilitiesProtocol {
229 pub get_device_path_size:
230 unsafe extern "efiapi" fn(device_path: *const DevicePathProtocol) -> usize,
231 pub duplicate_device_path: unsafe extern "efiapi" fn(
232 device_path: *const DevicePathProtocol,
233 ) -> *const DevicePathProtocol,
234 pub append_device_path: unsafe extern "efiapi" fn(
235 src1: *const DevicePathProtocol,
236 src2: *const DevicePathProtocol,
237 ) -> *const DevicePathProtocol,
238 pub append_device_node: unsafe extern "efiapi" fn(
239 device_path: *const DevicePathProtocol,
240 device_node: *const DevicePathProtocol,
241 ) -> *const DevicePathProtocol,
242 pub append_device_path_instance: unsafe extern "efiapi" fn(
243 device_path: *const DevicePathProtocol,
244 device_path_instance: *const DevicePathProtocol,
245 ) -> *const DevicePathProtocol,
246 pub get_next_device_path_instance: unsafe extern "efiapi" fn(
247 device_path_instance: *mut *const DevicePathProtocol,
248 device_path_instance_size: *mut usize,
249 ) -> *const DevicePathProtocol,
250 pub is_device_path_multi_instance:
251 unsafe extern "efiapi" fn(device_path: *const DevicePathProtocol) -> bool,
252 pub create_device_node: unsafe extern "efiapi" fn(
253 node_type: DeviceType,
254 node_sub_type: DeviceSubType,
255 node_length: u16,
256 ) -> *const DevicePathProtocol,
257}
258
259impl DevicePathUtilitiesProtocol {
260 pub const GUID: Guid = guid!("0379be4e-d706-437d-b037-edb82fb772a4");
261}
262
263#[cfg(test)]
264mod tests {
265 use super::*;
266 use core::mem;
267
268 #[test]
271 fn abi() {
272 assert_eq!(mem::size_of::<DevicePathProtocol>(), 4);
273 assert_eq!(mem::align_of::<DevicePathProtocol>(), 1);
274 }
275}