1 /**
2 	Based on Protocol/DevicePath.h, original notice:
3 
4 	The device path protocol as defined in UEFI 2.0.
5 	
6 	The device path represents a programmatic path to a device,
7 	from a software point of view. The path must persist from boot to boot, so
8 	it can not contain things like PCI bus numbers that change from boot to boot.
9 	
10 	Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
11 	This program and the accompanying materials are licensed and made available under
12 	the terms and conditions of the BSD License that accompanies this distribution.
13 	The full text of the license may be found at
14 	http://opensource.org/licenses/bsd-license.php.
15 	
16 	THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 	WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 	
19 **/
20 module uefi.protocols.devicepath;
21 import uefi.base;
22 import uefi.base_type;
23 
24 public:
25 extern (C):
26 // FIXME: INCLUDE <Guid/PcAnsi.h>
27 // FIXME: INCLUDE <IndustryStandard/Bluetooth.h>
28 // FIXME: INCLUDE <IndustryStandard/Acpi60.h>
29 /// Device Path protocol.
30 enum EFI_GUID EFI_DEVICE_PATH_PROTOCOL_GUID = EFI_GUID(0x9576e91, 0x6d3f,
31         0x11d2, [0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b]);
32 /// Device Path guid definition for backward-compatible with EFI1.1.
33 enum DEVICE_PATH_PROTOCOL = EFI_DEVICE_PATH_PROTOCOL_GUID;
34 /**
35 	This protocol can be used on any device handle to obtain generic path/location
36 	information concerning the physical device or logical device. If the handle does
37 	not logically map to a physical device, the handle may not necessarily support
38 	the device path protocol. The device path describes the location of the device
39 	the handle is for. The size of the Device Path can be determined from the structures
40 	that make up the Device Path.
41 **/
42 struct EFI_DEVICE_PATH_PROTOCOL
43 {
44     UINT8 Type; ///< 0x01 Hardware Device Path.
45     ///< 0x02 ACPI Device Path.
46     ///< 0x03 Messaging Device Path.
47     ///< 0x04 Media Device Path.
48     ///< 0x05 BIOS Boot Specification Device Path.
49     ///< 0x7F End of Hardware Device Path.
50 
51     UINT8 SubType; ///< Varies by Type
52     ///< 0xFF End Entire Device Path, or
53     ///< 0x01 End This Instance of a Device Path and start a new
54     ///< Device Path.
55 
56     UINT8[2] Length; ///< Specific Device Path data. Type and Sub-Type define
57     ///< type of data. Size of data is included in Length.
58 
59 }
60 /// Device Path protocol definition for backward-compatible with EFI1.1.
61 alias EFI_DEVICE_PATH = EFI_DEVICE_PATH_PROTOCOL;
62 /// Hardware Device Paths.
63 enum HARDWARE_DEVICE_PATH = 0x01;
64 /// PCI Device Path SubType.
65 enum HW_PCI_DP = 0x01;
66 /// PCI Device Path.
67 struct PCI_DEVICE_PATH
68 {
69     EFI_DEVICE_PATH_PROTOCOL Header;
70     ///
71     /// PCI Function Number.
72     ///
73     UINT8 Function;
74     ///
75     /// PCI Device Number.
76     ///
77     UINT8 Device;
78 }
79 /// PCCARD Device Path SubType.
80 enum HW_PCCARD_DP = 0x02;
81 /// PCCARD Device Path.
82 struct PCCARD_DEVICE_PATH
83 {
84     EFI_DEVICE_PATH_PROTOCOL Header;
85     ///
86     /// Function Number (0 = First Function).
87     ///
88     UINT8 FunctionNumber;
89 }
90 /// Memory Mapped Device Path SubType.
91 enum HW_MEMMAP_DP = 0x03;
92 /// Memory Mapped Device Path.
93 struct MEMMAP_DEVICE_PATH
94 {
95     EFI_DEVICE_PATH_PROTOCOL Header;
96     ///
97     /// EFI_MEMORY_TYPE
98     ///
99     UINT32 MemoryType;
100     ///
101     /// Starting Memory Address.
102     ///
103     EFI_PHYSICAL_ADDRESS StartingAddress;
104     ///
105     /// Ending Memory Address.
106     ///
107     EFI_PHYSICAL_ADDRESS EndingAddress;
108 }
109 /// Hardware Vendor Device Path SubType.
110 enum HW_VENDOR_DP = 0x04;
111 /// The Vendor Device Path allows the creation of vendor-defined Device Paths. A vendor must
112 /// allocate a Vendor GUID for a Device Path. The Vendor GUID can then be used to define the
113 /// contents on the n bytes that follow in the Vendor Device Path node.
114 struct VENDOR_DEVICE_PATH
115 {
116     EFI_DEVICE_PATH_PROTOCOL Header;
117     ///
118     /// Vendor-assigned GUID that defines the data that follows.
119     ///
120     EFI_GUID Guid;
121     ///
122     /// Vendor-defined variable size data.
123     ///
124 }
125 /// Controller Device Path SubType.
126 enum HW_CONTROLLER_DP = 0x05;
127 /// Controller Device Path.
128 struct CONTROLLER_DEVICE_PATH
129 {
130     EFI_DEVICE_PATH_PROTOCOL Header;
131     ///
132     /// Controller number.
133     ///
134     UINT32 ControllerNumber;
135 }
136 /// BMC Device Path SubType.
137 enum HW_BMC_DP = 0x06;
138 /// BMC Device Path.
139 struct BMC_DEVICE_PATH
140 {
141     EFI_DEVICE_PATH_PROTOCOL Header;
142     ///
143     /// Interface Type.
144     ///
145     UINT8 InterfaceType;
146     ///
147     /// Base Address.
148     ///
149     UINT8[8] BaseAddress;
150 }
151 /// ACPI Device Paths.
152 enum ACPI_DEVICE_PATH = 0x02;
153 /// ACPI Device Path SubType.
154 enum ACPI_DP = 0x01;
155 struct ACPI_HID_DEVICE_PATH
156 {
157     EFI_DEVICE_PATH_PROTOCOL Header;
158     ///
159     /// Device's PnP hardware ID stored in a numeric 32-bit
160     /// compressed EISA-type ID. This value must match the
161     /// corresponding _HID in the ACPI name space.
162     ///
163     UINT32 HID;
164     ///
165     /// Unique ID that is required by ACPI if two devices have the
166     /// same _HID. This value must also match the corresponding
167     /// _UID/_HID pair in the ACPI name space. Only the 32-bit
168     /// numeric value type of _UID is supported. Thus, strings must
169     /// not be used for the _UID in the ACPI name space.
170     ///
171     UINT32 UID;
172 }
173 /// Expanded ACPI Device Path SubType.
174 enum ACPI_EXTENDED_DP = 0x02;
175 struct ACPI_EXTENDED_HID_DEVICE_PATH
176 {
177     EFI_DEVICE_PATH_PROTOCOL Header;
178     ///
179     /// Device's PnP hardware ID stored in a numeric 32-bit
180     /// compressed EISA-type ID. This value must match the
181     /// corresponding _HID in the ACPI name space.
182     ///
183     UINT32 HID;
184     ///
185     /// Unique ID that is required by ACPI if two devices have the
186     /// same _HID. This value must also match the corresponding
187     /// _UID/_HID pair in the ACPI name space.
188     ///
189     UINT32 UID;
190     ///
191     /// Device's compatible PnP hardware ID stored in a numeric
192     /// 32-bit compressed EISA-type ID. This value must match at
193     /// least one of the compatible device IDs returned by the
194     /// corresponding _CID in the ACPI name space.
195     ///
196     UINT32 CID;
197     ///
198     /// Optional variable length _HIDSTR.
199     /// Optional variable length _UIDSTR.
200     /// Optional variable length _CIDSTR.
201     ///
202 }
203 
204 enum PNP_EISA_ID_CONST = 0x41d0;
205 // #define EISA_ID(_Name, _Num)      ((UINT32)((_Name) | (_Num) << 16))
206 // #define EISA_PNP_ID(_PNPId)       (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
207 // #define EFI_PNP_ID(_PNPId)        (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
208 enum PNP_EISA_ID_MASK = 0xffff;
209 // #define EISA_ID_TO_NUM(_Id)       ((_Id) >> 16)
210 /// ACPI _ADR Device Path SubType.
211 enum ACPI_ADR_DP = 0x03;
212 /// The _ADR device path is used to contain video output device attributes to support the Graphics
213 /// Output Protocol. The device path can contain multiple _ADR entries if multiple video output
214 /// devices are displaying the same output.
215 struct ACPI_ADR_DEVICE_PATH
216 {
217     EFI_DEVICE_PATH_PROTOCOL Header;
218     ///
219     /// _ADR value. For video output devices the value of this
220     /// field comes from Table B-2 of the ACPI 3.0 specification. At
221     /// least one _ADR value is required.
222     ///
223     UINT32 ADR;
224     //
225     // This device path may optionally contain more than one _ADR entry.
226     //
227 }
228 
229 enum ACPI_ADR_DISPLAY_TYPE_OTHER = 0;
230 enum ACPI_ADR_DISPLAY_TYPE_VGA = 1;
231 enum ACPI_ADR_DISPLAY_TYPE_TV = 2;
232 enum ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL = 3;
233 enum ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL = 4;
234 // #define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \
235 // ((UINT32)(  ((UINT32)((_DeviceIdScheme) & 0x1) << 31) |  \
236 // (((_HeadId)                 & 0x7) << 18) |  \
237 // (((_NonVgaOutput)           & 0x1) << 17) |  \
238 // (((_BiosCanDetect)          & 0x1) << 16) |  \
239 // (((_VendorInfo)             & 0xf) << 12) |  \
240 // (((_Type)                   & 0xf) << 8)  |  \
241 // (((_Port)                   & 0xf) << 4)  |  \
242 // ((_Index)                  & 0xf) ))
243 /// Messaging Device Paths.
244 /// This Device Path is used to describe the connection of devices outside the resource domain of the
245 /// system. This Device Path can describe physical messaging information like SCSI ID, or abstract
246 /// information like networking protocol IP addresses.
247 enum MESSAGING_DEVICE_PATH = 0x03;
248 /// ATAPI Device Path SubType
249 enum MSG_ATAPI_DP = 0x01;
250 struct ATAPI_DEVICE_PATH
251 {
252     EFI_DEVICE_PATH_PROTOCOL Header;
253     ///
254     /// Set to zero for primary, or one for secondary.
255     ///
256     UINT8 PrimarySecondary;
257     ///
258     /// Set to zero for master, or one for slave mode.
259     ///
260     UINT8 SlaveMaster;
261     ///
262     /// Logical Unit Number.
263     ///
264     UINT16 Lun;
265 }
266 /// SCSI Device Path SubType.
267 enum MSG_SCSI_DP = 0x02;
268 struct SCSI_DEVICE_PATH
269 {
270     EFI_DEVICE_PATH_PROTOCOL Header;
271     ///
272     /// Target ID on the SCSI bus (PUN).
273     ///
274     UINT16 Pun;
275     ///
276     /// Logical Unit Number (LUN).
277     ///
278     UINT16 Lun;
279 }
280 /// Fibre Channel SubType.
281 enum MSG_FIBRECHANNEL_DP = 0x03;
282 struct FIBRECHANNEL_DEVICE_PATH
283 {
284     EFI_DEVICE_PATH_PROTOCOL Header;
285     ///
286     /// Reserved for the future.
287     ///
288     UINT32 Reserved;
289     ///
290     /// Fibre Channel World Wide Number.
291     ///
292     UINT64 WWN;
293     ///
294     /// Fibre Channel Logical Unit Number.
295     ///
296     UINT64 Lun;
297 }
298 /// Fibre Channel Ex SubType.
299 enum MSG_FIBRECHANNELEX_DP = 0x15;
300 struct FIBRECHANNELEX_DEVICE_PATH
301 {
302     EFI_DEVICE_PATH_PROTOCOL Header;
303     ///
304     /// Reserved for the future.
305     ///
306     UINT32 Reserved;
307     ///
308     /// 8 byte array containing Fibre Channel End Device Port Name.
309     ///
310     UINT8[8] WWN;
311     ///
312     /// 8 byte array containing Fibre Channel Logical Unit Number.
313     ///
314     UINT8[8] Lun;
315 }
316 /// 1394 Device Path SubType
317 enum MSG_1394_DP = 0x04;
318 struct F1394_DEVICE_PATH
319 {
320     EFI_DEVICE_PATH_PROTOCOL Header;
321     ///
322     /// Reserved for the future.
323     ///
324     UINT32 Reserved;
325     ///
326     /// 1394 Global Unique ID (GUID).
327     ///
328     UINT64 Guid;
329 }
330 /// USB Device Path SubType.
331 enum MSG_USB_DP = 0x05;
332 struct USB_DEVICE_PATH
333 {
334     EFI_DEVICE_PATH_PROTOCOL Header;
335     ///
336     /// USB Parent Port Number.
337     ///
338     UINT8 ParentPortNumber;
339     ///
340     /// USB Interface Number.
341     ///
342     UINT8 InterfaceNumber;
343 }
344 /// USB Class Device Path SubType.
345 enum MSG_USB_CLASS_DP = 0x0f;
346 struct USB_CLASS_DEVICE_PATH
347 {
348     EFI_DEVICE_PATH_PROTOCOL Header;
349     ///
350     /// Vendor ID assigned by USB-IF. A value of 0xFFFF will
351     /// match any Vendor ID.
352     ///
353     UINT16 VendorId;
354     ///
355     /// Product ID assigned by USB-IF. A value of 0xFFFF will
356     /// match any Product ID.
357     ///
358     UINT16 ProductId;
359     ///
360     /// The class code assigned by the USB-IF. A value of 0xFF
361     /// will match any class code.
362     ///
363     UINT8 DeviceClass;
364     ///
365     /// The subclass code assigned by the USB-IF. A value of
366     /// 0xFF will match any subclass code.
367     ///
368     UINT8 DeviceSubClass;
369     ///
370     /// The protocol code assigned by the USB-IF. A value of
371     /// 0xFF will match any protocol code.
372     ///
373     UINT8 DeviceProtocol;
374 }
375 /// USB WWID Device Path SubType.
376 enum MSG_USB_WWID_DP = 0x10;
377 /// This device path describes a USB device using its serial number.
378 struct USB_WWID_DEVICE_PATH
379 {
380     EFI_DEVICE_PATH_PROTOCOL Header;
381     ///
382     /// USB interface number.
383     ///
384     UINT16 InterfaceNumber;
385     ///
386     /// USB vendor id of the device.
387     ///
388     UINT16 VendorId;
389     ///
390     /// USB product id of the device.
391     ///
392     UINT16 ProductId;
393     ///
394     /// Last 64-or-fewer UTF-16 characters of the USB
395     /// serial number. The length of the string is
396     /// determined by the Length field less the offset of the
397     /// Serial Number field (10)
398     ///
399     /// CHAR16                     SerialNumber[...];
400 }
401 /// Device Logical Unit SubType.
402 enum MSG_DEVICE_LOGICAL_UNIT_DP = 0x11;
403 struct DEVICE_LOGICAL_UNIT_DEVICE_PATH
404 {
405     EFI_DEVICE_PATH_PROTOCOL Header;
406     ///
407     /// Logical Unit Number for the interface.
408     ///
409     UINT8 Lun;
410 }
411 /// SATA Device Path SubType.
412 enum MSG_SATA_DP = 0x12;
413 struct SATA_DEVICE_PATH
414 {
415     EFI_DEVICE_PATH_PROTOCOL Header;
416     ///
417     /// The HBA port number that facilitates the connection to the
418     /// device or a port multiplier. The value 0xFFFF is reserved.
419     ///
420     UINT16 HBAPortNumber;
421     ///
422     /// The Port multiplier port number that facilitates the connection
423     /// to the device. Bit 15 should be set if the device is directly
424     /// connected to the HBA.
425     ///
426     UINT16 PortMultiplierPortNumber;
427     ///
428     /// Logical Unit Number.
429     ///
430     UINT16 Lun;
431 }
432 /// Flag for if the device is directly connected to the HBA.
433 enum SATA_HBA_DIRECT_CONNECT_FLAG = 0x8000;
434 /// I2O Device Path SubType.
435 enum MSG_I2O_DP = 0x06;
436 struct I2O_DEVICE_PATH
437 {
438     EFI_DEVICE_PATH_PROTOCOL Header;
439     ///
440     /// Target ID (TID) for a device.
441     ///
442     UINT32 Tid;
443 }
444 /// MAC Address Device Path SubType.
445 enum MSG_MAC_ADDR_DP = 0x0b;
446 struct MAC_ADDR_DEVICE_PATH
447 {
448     EFI_DEVICE_PATH_PROTOCOL Header;
449     ///
450     /// The MAC address for a network interface padded with 0s.
451     ///
452     EFI_MAC_ADDRESS MacAddress;
453     ///
454     /// Network interface type(i.e. 802.3, FDDI).
455     ///
456     UINT8 IfType;
457 }
458 /// IPv4 Device Path SubType
459 enum MSG_IPv4_DP = 0x0c;
460 struct IPv4_DEVICE_PATH
461 {
462     EFI_DEVICE_PATH_PROTOCOL Header;
463     ///
464     /// The local IPv4 address.
465     ///
466     EFI_IPv4_ADDRESS LocalIpAddress;
467     ///
468     /// The remote IPv4 address.
469     ///
470     EFI_IPv4_ADDRESS RemoteIpAddress;
471     ///
472     /// The local port number.
473     ///
474     UINT16 LocalPort;
475     ///
476     /// The remote port number.
477     ///
478     UINT16 RemotePort;
479     ///
480     /// The network protocol(i.e. UDP, TCP).
481     ///
482     UINT16 Protocol;
483     ///
484     /// 0x00 - The Source IP Address was assigned though DHCP.
485     /// 0x01 - The Source IP Address is statically bound.
486     ///
487     BOOLEAN StaticIpAddress;
488     ///
489     /// The gateway IP address
490     ///
491     EFI_IPv4_ADDRESS GatewayIpAddress;
492     ///
493     /// The subnet mask
494     ///
495     EFI_IPv4_ADDRESS SubnetMask;
496 }
497 /// IPv6 Device Path SubType.
498 enum MSG_IPv6_DP = 0x0d;
499 struct IPv6_DEVICE_PATH
500 {
501     EFI_DEVICE_PATH_PROTOCOL Header;
502     ///
503     /// The local IPv6 address.
504     ///
505     EFI_IPv6_ADDRESS LocalIpAddress;
506     ///
507     /// The remote IPv6 address.
508     ///
509     EFI_IPv6_ADDRESS RemoteIpAddress;
510     ///
511     /// The local port number.
512     ///
513     UINT16 LocalPort;
514     ///
515     /// The remote port number.
516     ///
517     UINT16 RemotePort;
518     ///
519     /// The network protocol(i.e. UDP, TCP).
520     ///
521     UINT16 Protocol;
522     ///
523     /// 0x00 - The Local IP Address was manually configured.
524     /// 0x01 - The Local IP Address is assigned through IPv6
525     /// stateless auto-configuration.
526     /// 0x02 - The Local IP Address is assigned through IPv6
527     /// stateful configuration.
528     ///
529     UINT8 IpAddressOrigin;
530     ///
531     /// The prefix length
532     ///
533     UINT8 PrefixLength;
534     ///
535     /// The gateway IP address
536     ///
537     EFI_IPv6_ADDRESS GatewayIpAddress;
538 }
539 /// InfiniBand Device Path SubType.
540 enum MSG_INFINIBAND_DP = 0x09;
541 struct INFINIBAND_DEVICE_PATH
542 {
543     EFI_DEVICE_PATH_PROTOCOL Header;
544     ///
545     /// Flags to help identify/manage InfiniBand device path elements:
546     /// Bit 0 - IOC/Service (0b = IOC, 1b = Service).
547     /// Bit 1 - Extend Boot Environment.
548     /// Bit 2 - Console Protocol.
549     /// Bit 3 - Storage Protocol.
550     /// Bit 4 - Network Protocol.
551     /// All other bits are reserved.
552     ///
553     UINT32 ResourceFlags;
554     ///
555     /// 128-bit Global Identifier for remote fabric port.
556     ///
557     UINT8[16] PortGid;
558     ///
559     /// 64-bit unique identifier to remote IOC or server process.
560     /// Interpretation of field specified by Resource Flags (bit 0).
561     ///
562     UINT64 ServiceId;
563     ///
564     /// 64-bit persistent ID of remote IOC port.
565     ///
566     UINT64 TargetPortId;
567     ///
568     /// 64-bit persistent ID of remote device.
569     ///
570     UINT64 DeviceId;
571 }
572 
573 enum INFINIBAND_RESOURCE_FLAG_IOC_SERVICE = 0x01;
574 enum INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT = 0x02;
575 enum INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL = 0x04;
576 enum INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL = 0x08;
577 enum INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL = 0x10;
578 /// UART Device Path SubType.
579 enum MSG_UART_DP = 0x0e;
580 struct UART_DEVICE_PATH
581 {
582     EFI_DEVICE_PATH_PROTOCOL Header;
583     ///
584     /// Reserved.
585     ///
586     UINT32 Reserved;
587     ///
588     /// The baud rate setting for the UART style device. A value of 0
589     /// means that the device's default baud rate will be used.
590     ///
591     UINT64 BaudRate;
592     ///
593     /// The number of data bits for the UART style device. A value
594     /// of 0 means that the device's default number of data bits will be used.
595     ///
596     UINT8 DataBits;
597     ///
598     /// The parity setting for the UART style device.
599     /// Parity 0x00 - Default Parity.
600     /// Parity 0x01 - No Parity.
601     /// Parity 0x02 - Even Parity.
602     /// Parity 0x03 - Odd Parity.
603     /// Parity 0x04 - Mark Parity.
604     /// Parity 0x05 - Space Parity.
605     ///
606     UINT8 Parity;
607     ///
608     /// The number of stop bits for the UART style device.
609     /// Stop Bits 0x00 - Default Stop Bits.
610     /// Stop Bits 0x01 - 1 Stop Bit.
611     /// Stop Bits 0x02 - 1.5 Stop Bits.
612     /// Stop Bits 0x03 - 2 Stop Bits.
613     ///
614     UINT8 StopBits;
615 }
616 
617 enum MSG_VENDOR_DP = 0x0a; /*
618 alias VENDOR_DEFINED_DEVICE_PATH = VENDOR_DEVICE_PATH;
619 enum DEVICE_PATH_MESSAGING_PC_ANSI = EFI_PC_ANSI_GUID;
620 enum DEVICE_PATH_MESSAGING_VT_100 = EFI_VT_100_GUID;
621 enum DEVICE_PATH_MESSAGING_VT_100_PLUS = EFI_VT_100_PLUS_GUID;
622 enum DEVICE_PATH_MESSAGING_VT_UTF8 = EFI_VT_UTF8_GUID;*/
623 /// A new device path node is defined to declare flow control characteristics.
624 /// UART Flow Control Messaging Device Path
625 struct UART_FLOW_CONTROL_DEVICE_PATH
626 {
627     EFI_DEVICE_PATH_PROTOCOL Header;
628     ///
629     /// DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL GUID.
630     ///
631     EFI_GUID Guid;
632     ///
633     /// Bitmap of supported flow control types.
634     /// Bit 0 set indicates hardware flow control.
635     /// Bit 1 set indicates Xon/Xoff flow control.
636     /// All other bits are reserved and are clear.
637     ///
638     UINT32 FlowControlMap;
639 }
640 
641 enum UART_FLOW_CONTROL_HARDWARE = 0x00000001;
642 enum UART_FLOW_CONTROL_XON_XOFF = 0x00000010;
643 //enum DEVICE_PATH_MESSAGING_SAS = EFI_SAS_DEVICE_PATH_GUID;
644 /// Serial Attached SCSI (SAS) Device Path.
645 struct SAS_DEVICE_PATH
646 {
647     EFI_DEVICE_PATH_PROTOCOL Header;
648     ///
649     /// DEVICE_PATH_MESSAGING_SAS GUID.
650     ///
651     EFI_GUID Guid;
652     ///
653     /// Reserved for future use.
654     ///
655     UINT32 Reserved;
656     ///
657     /// SAS Address for Serial Attached SCSI Target.
658     ///
659     UINT64 SasAddress;
660     ///
661     /// SAS Logical Unit Number.
662     ///
663     UINT64 Lun;
664     ///
665     /// More Information about the device and its interconnect.
666     ///
667     UINT16 DeviceTopology;
668     ///
669     /// Relative Target Port (RTP).
670     ///
671     UINT16 RelativeTargetPort;
672 }
673 /// Serial Attached SCSI (SAS) Ex Device Path SubType
674 enum MSG_SASEX_DP = 0x16;
675 struct SASEX_DEVICE_PATH
676 {
677     EFI_DEVICE_PATH_PROTOCOL Header;
678     ///
679     /// 8-byte array of the SAS Address for Serial Attached SCSI Target Port.
680     ///
681     UINT8[8] SasAddress;
682     ///
683     /// 8-byte array of the SAS Logical Unit Number.
684     ///
685     UINT8[8] Lun;
686     ///
687     /// More Information about the device and its interconnect.
688     ///
689     UINT16 DeviceTopology;
690     ///
691     /// Relative Target Port (RTP).
692     ///
693     UINT16 RelativeTargetPort;
694 }
695 /// NvmExpress Namespace Device Path SubType.
696 enum MSG_NVME_NAMESPACE_DP = 0x17;
697 struct NVME_NAMESPACE_DEVICE_PATH
698 {
699     EFI_DEVICE_PATH_PROTOCOL Header;
700     UINT32 NamespaceId;
701     UINT64 NamespaceUuid;
702 }
703 /// Uniform Resource Identifiers (URI) Device Path SubType
704 enum MSG_URI_DP = 0x18;
705 struct URI_DEVICE_PATH
706 {
707     EFI_DEVICE_PATH_PROTOCOL Header;
708     ///
709     /// Instance of the URI pursuant to RFC 3986.
710     ///
711     CHAR8[] Uri;
712 }
713 /// Universal Flash Storage (UFS) Device Path SubType.
714 enum MSG_UFS_DP = 0x19;
715 struct UFS_DEVICE_PATH
716 {
717     EFI_DEVICE_PATH_PROTOCOL Header;
718     ///
719     /// Target ID on the UFS bus (PUN).
720     ///
721     UINT8 Pun;
722     ///
723     /// Logical Unit Number (LUN).
724     ///
725     UINT8 Lun;
726 }
727 /// SD (Secure Digital) Device Path SubType.
728 enum MSG_SD_DP = 0x1A;
729 struct SD_DEVICE_PATH
730 {
731     EFI_DEVICE_PATH_PROTOCOL Header;
732     UINT8 SlotNumber;
733 }
734 /// iSCSI Device Path SubType
735 enum MSG_ISCSI_DP = 0x13;
736 struct ISCSI_DEVICE_PATH
737 {
738     EFI_DEVICE_PATH_PROTOCOL Header;
739     ///
740     /// Network Protocol (0 = TCP, 1+ = reserved).
741     ///
742     UINT16 NetworkProtocol;
743     ///
744     /// iSCSI Login Options.
745     ///
746     UINT16 LoginOption;
747     ///
748     /// iSCSI Logical Unit Number.
749     ///
750     UINT64 Lun;
751     ///
752     /// iSCSI Target Portal group tag the initiator intends
753     /// to establish a session with.
754     ///
755     UINT16 TargetPortalGroupTag;
756     ///
757     /// iSCSI NodeTarget Name. The length of the name
758     /// is determined by subtracting the offset of this field from Length.
759     ///
760     /// CHAR8                        iSCSI Target Name.
761 }
762 
763 enum ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST = 0x0000;
764 enum ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C = 0x0002;
765 enum ISCSI_LOGIN_OPTION_NO_DATA_DIGEST = 0x0000;
766 enum ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C = 0x0008;
767 enum ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP = 0x0000;
768 enum ISCSI_LOGIN_OPTION_AUTHMETHOD_NON = 0x1000;
769 enum ISCSI_LOGIN_OPTION_CHAP_BI = 0x0000;
770 enum ISCSI_LOGIN_OPTION_CHAP_UNI = 0x2000;
771 /// VLAN Device Path SubType.
772 enum MSG_VLAN_DP = 0x14;
773 struct VLAN_DEVICE_PATH
774 {
775     EFI_DEVICE_PATH_PROTOCOL Header;
776     ///
777     /// VLAN identifier (0-4094).
778     ///
779     UINT16 VlanId;
780 }
781 /// Bluetooth Device Path SubType.
782 enum MSG_BLUETOOTH_DP = 0x1b;
783 struct BLUETOOTH_DEVICE_PATH
784 {
785     EFI_DEVICE_PATH_PROTOCOL Header;
786     ///
787     /// 48bit Bluetooth device address.
788     ///
789     UINT16[3] BD_ADDR;
790 }
791 /// Wi-Fi Device Path SubType.
792 enum MSG_WIFI_DP = 0x1C;
793 struct WIFI_DEVICE_PATH
794 {
795     EFI_DEVICE_PATH_PROTOCOL Header;
796     ///
797     /// Service set identifier. A 32-byte octets string.
798     ///
799     UINT8[32] SSId;
800 }
801 
802 enum MEDIA_DEVICE_PATH = 0x04;
803 /// Hard Drive Media Device Path SubType.
804 enum MEDIA_HARDDRIVE_DP = 0x01;
805 /// The Hard Drive Media Device Path is used to represent a partition on a hard drive.
806 struct HARDDRIVE_DEVICE_PATH
807 {
808     EFI_DEVICE_PATH_PROTOCOL Header;
809     ///
810     /// Describes the entry in a partition table, starting with entry 1.
811     /// Partition number zero represents the entire device. Valid
812     /// partition numbers for a MBR partition are [1, 4]. Valid
813     /// partition numbers for a GPT partition are [1, NumberOfPartitionEntries].
814     ///
815     UINT32 PartitionNumber;
816     ///
817     /// Starting LBA of the partition on the hard drive.
818     ///
819     UINT64 PartitionStart;
820     ///
821     /// Size of the partition in units of Logical Blocks.
822     ///
823     UINT64 PartitionSize;
824     ///
825     /// Signature unique to this partition:
826     /// If SignatureType is 0, this field has to be initialized with 16 zeros.
827     /// If SignatureType is 1, the MBR signature is stored in the first 4 bytes of this field.
828     /// The other 12 bytes are initialized with zeros.
829     /// If SignatureType is 2, this field contains a 16 byte signature.
830     ///
831     UINT8[16] Signature;
832     ///
833     /// Partition Format: (Unused values reserved).
834     /// 0x01 - PC-AT compatible legacy MBR.
835     /// 0x02 - GUID Partition Table.
836     ///
837     UINT8 MBRType;
838     ///
839     /// Type of Disk Signature: (Unused values reserved).
840     /// 0x00 - No Disk Signature.
841     /// 0x01 - 32-bit signature from address 0x1b8 of the type 0x01 MBR.
842     /// 0x02 - GUID signature.
843     ///
844     UINT8 SignatureType;
845 }
846 
847 enum MBR_TYPE_PCAT = 0x01;
848 enum MBR_TYPE_EFI_PARTITION_TABLE_HEADER = 0x02;
849 enum NO_DISK_SIGNATURE = 0x00;
850 enum SIGNATURE_TYPE_MBR = 0x01;
851 enum SIGNATURE_TYPE_GUID = 0x02;
852 /// CD-ROM Media Device Path SubType.
853 enum MEDIA_CDROM_DP = 0x02;
854 /// The CD-ROM Media Device Path is used to define a system partition that exists on a CD-ROM.
855 struct CDROM_DEVICE_PATH
856 {
857     EFI_DEVICE_PATH_PROTOCOL Header;
858     ///
859     /// Boot Entry number from the Boot Catalog. The Initial/Default entry is defined as zero.
860     ///
861     UINT32 BootEntry;
862     ///
863     /// Starting RBA of the partition on the medium. CD-ROMs use Relative logical Block Addressing.
864     ///
865     UINT64 PartitionStart;
866     ///
867     /// Size of the partition in units of Blocks, also called Sectors.
868     ///
869     UINT64 PartitionSize;
870 }
871 
872 enum MEDIA_VENDOR_DP = 0x03; ///<Mediavendordevicepathsubtype.
873 /// File Path Media Device Path SubType
874 enum MEDIA_FILEPATH_DP = 0x04;
875 struct FILEPATH_DEVICE_PATH
876 {
877     EFI_DEVICE_PATH_PROTOCOL Header;
878     ///
879     /// A NULL-terminated Path string including directory and file names.
880     ///
881     CHAR16[1] PathName;
882 }
883 
884 //enum SIZE_OF_FILEPATH_DEVICE_PATH = OFFSET_OF(FILEPATH_DEVICE_PATH, PathName);
885 /// Media Protocol Device Path SubType.
886 enum MEDIA_PROTOCOL_DP = 0x05;
887 /// The Media Protocol Device Path is used to denote the protocol that is being
888 /// used in a device path at the location of the path specified.
889 /// Many protocols are inherent to the style of device path.
890 struct MEDIA_PROTOCOL_DEVICE_PATH
891 {
892     EFI_DEVICE_PATH_PROTOCOL Header;
893     ///
894     /// The ID of the protocol.
895     ///
896     EFI_GUID Protocol;
897 }
898 /// PIWG Firmware File SubType.
899 enum MEDIA_PIWG_FW_FILE_DP = 0x06;
900 /// This device path is used by systems implementing the UEFI PI Specification 1.0 to describe a firmware file.
901 struct MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
902 {
903     EFI_DEVICE_PATH_PROTOCOL Header;
904     ///
905     /// Firmware file name
906     ///
907     EFI_GUID FvFileName;
908 }
909 /// PIWG Firmware Volume Device Path SubType.
910 enum MEDIA_PIWG_FW_VOL_DP = 0x07;
911 /// This device path is used by systems implementing the UEFI PI Specification 1.0 to describe a firmware volume.
912 struct MEDIA_FW_VOL_DEVICE_PATH
913 {
914     EFI_DEVICE_PATH_PROTOCOL Header;
915     ///
916     /// Firmware volume name.
917     ///
918     EFI_GUID FvName;
919 }
920 /// Media relative offset range device path.
921 enum MEDIA_RELATIVE_OFFSET_RANGE_DP = 0x08;
922 /// Used to describe the offset range of media relative.
923 struct MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
924 {
925     EFI_DEVICE_PATH_PROTOCOL Header;
926     UINT32 Reserved;
927     UINT64 StartingOffset;
928     UINT64 EndingOffset;
929 }
930 /*/// This GUID defines a RAM Disk supporting a raw disk format in volatile memory.
931 enum EFI_VIRTUAL_DISK_GUID = EFI_ACPI_6_0_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_VOLATILE;
932 /// This GUID defines a RAM Disk supporting an ISO image in volatile memory.
933 enum EFI_VIRTUAL_CD_GUID = EFI_ACPI_6_0_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_VOLATILE;
934 /// This GUID defines a RAM Disk supporting a raw disk format in persistent memory.
935 enum EFI_PERSISTENT_VIRTUAL_DISK_GUID = EFI_ACPI_6_0_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_PERSISTENT;
936 /// This GUID defines a RAM Disk supporting an ISO image in persistent memory.
937 enum EFI_PERSISTENT_VIRTUAL_CD_GUID = EFI_ACPI_6_0_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_PERSISTENT;*/
938 /// Media ram disk device path.
939 enum MEDIA_RAM_DISK_DP = 0x09;
940 /// Used to describe the ram disk device path.
941 struct MEDIA_RAM_DISK_DEVICE_PATH
942 {
943     EFI_DEVICE_PATH_PROTOCOL Header;
944     ///
945     /// Starting Memory Address.
946     ///
947     UINT32[2] StartingAddr;
948     ///
949     /// Ending Memory Address.
950     ///
951     UINT32[2] EndingAddr;
952     ///
953     /// GUID that defines the type of the RAM Disk.
954     ///
955     EFI_GUID TypeGuid;
956     ///
957     /// RAM Diskinstance number, if supported. The default value is zero.
958     ///
959     UINT16 Instance;
960 }
961 /// BIOS Boot Specification Device Path.
962 enum BBS_DEVICE_PATH = 0x05;
963 /// BIOS Boot Specification Device Path SubType.
964 enum BBS_BBS_DP = 0x01;
965 /// This Device Path is used to describe the booting of non-EFI-aware operating systems.
966 struct BBS_BBS_DEVICE_PATH
967 {
968     EFI_DEVICE_PATH_PROTOCOL Header;
969     ///
970     /// Device Type as defined by the BIOS Boot Specification.
971     ///
972     UINT16 DeviceType;
973     ///
974     /// Status Flags as defined by the BIOS Boot Specification.
975     ///
976     UINT16 StatusFlag;
977     ///
978     /// Null-terminated ASCII string that describes the boot device to a user.
979     ///
980     CHAR8[1] String;
981 }
982 
983 enum BBS_TYPE_FLOPPY = 0x01;
984 enum BBS_TYPE_HARDDRIVE = 0x02;
985 enum BBS_TYPE_CDROM = 0x03;
986 enum BBS_TYPE_PCMCIA = 0x04;
987 enum BBS_TYPE_USB = 0x05;
988 enum BBS_TYPE_EMBEDDED_NETWORK = 0x06;
989 enum BBS_TYPE_BEV = 0x80;
990 enum BBS_TYPE_UNKNOWN = 0xFF;
991 /// Union of all possible Device Paths and pointers to Device Paths.
992 union EFI_DEV_PATH
993 {
994     EFI_DEVICE_PATH_PROTOCOL DevPath;
995     PCI_DEVICE_PATH Pci;
996     PCCARD_DEVICE_PATH PcCard;
997     MEMMAP_DEVICE_PATH MemMap;
998     VENDOR_DEVICE_PATH Vendor;
999 
1000     CONTROLLER_DEVICE_PATH Controller;
1001     BMC_DEVICE_PATH Bmc;
1002     ACPI_HID_DEVICE_PATH Acpi;
1003     ACPI_EXTENDED_HID_DEVICE_PATH ExtendedAcpi;
1004     ACPI_ADR_DEVICE_PATH AcpiAdr;
1005 
1006     ATAPI_DEVICE_PATH Atapi;
1007     SCSI_DEVICE_PATH Scsi;
1008     ISCSI_DEVICE_PATH Iscsi;
1009     FIBRECHANNEL_DEVICE_PATH FibreChannel;
1010     FIBRECHANNELEX_DEVICE_PATH FibreChannelEx;
1011 
1012     F1394_DEVICE_PATH F1394;
1013     USB_DEVICE_PATH Usb;
1014     SATA_DEVICE_PATH Sata;
1015     USB_CLASS_DEVICE_PATH UsbClass;
1016     USB_WWID_DEVICE_PATH UsbWwid;
1017     DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicUnit;
1018     I2O_DEVICE_PATH I2O;
1019     MAC_ADDR_DEVICE_PATH MacAddr;
1020     IPv4_DEVICE_PATH Ipv4;
1021     IPv6_DEVICE_PATH Ipv6;
1022     VLAN_DEVICE_PATH Vlan;
1023     INFINIBAND_DEVICE_PATH InfiniBand;
1024     UART_DEVICE_PATH Uart;
1025     UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl;
1026     SAS_DEVICE_PATH Sas;
1027     SASEX_DEVICE_PATH SasEx;
1028     NVME_NAMESPACE_DEVICE_PATH NvmeNamespace;
1029     URI_DEVICE_PATH Uri;
1030     BLUETOOTH_DEVICE_PATH Bluetooth;
1031     WIFI_DEVICE_PATH WiFi;
1032     UFS_DEVICE_PATH Ufs;
1033     SD_DEVICE_PATH Sd;
1034     HARDDRIVE_DEVICE_PATH HardDrive;
1035     CDROM_DEVICE_PATH CD;
1036 
1037     FILEPATH_DEVICE_PATH FilePath;
1038     MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol;
1039 
1040     MEDIA_FW_VOL_DEVICE_PATH FirmwareVolume;
1041     MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FirmwareFile;
1042     MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH Offset;
1043     MEDIA_RAM_DISK_DEVICE_PATH RamDisk;
1044     BBS_BBS_DEVICE_PATH Bbs;
1045 }
1046 
1047 union EFI_DEV_PATH_PTR
1048 {
1049     EFI_DEVICE_PATH_PROTOCOL* DevPath;
1050     PCI_DEVICE_PATH* Pci;
1051     PCCARD_DEVICE_PATH* PcCard;
1052     MEMMAP_DEVICE_PATH* MemMap;
1053     VENDOR_DEVICE_PATH* Vendor;
1054 
1055     CONTROLLER_DEVICE_PATH* Controller;
1056     BMC_DEVICE_PATH* Bmc;
1057     ACPI_HID_DEVICE_PATH* Acpi;
1058     ACPI_EXTENDED_HID_DEVICE_PATH* ExtendedAcpi;
1059     ACPI_ADR_DEVICE_PATH* AcpiAdr;
1060 
1061     ATAPI_DEVICE_PATH* Atapi;
1062     SCSI_DEVICE_PATH* Scsi;
1063     ISCSI_DEVICE_PATH* Iscsi;
1064     FIBRECHANNEL_DEVICE_PATH* FibreChannel;
1065     FIBRECHANNELEX_DEVICE_PATH* FibreChannelEx;
1066 
1067     F1394_DEVICE_PATH* F1394;
1068     USB_DEVICE_PATH* Usb;
1069     SATA_DEVICE_PATH* Sata;
1070     USB_CLASS_DEVICE_PATH* UsbClass;
1071     USB_WWID_DEVICE_PATH* UsbWwid;
1072     DEVICE_LOGICAL_UNIT_DEVICE_PATH* LogicUnit;
1073     I2O_DEVICE_PATH* I2O;
1074     MAC_ADDR_DEVICE_PATH* MacAddr;
1075     IPv4_DEVICE_PATH* Ipv4;
1076     IPv6_DEVICE_PATH* Ipv6;
1077     VLAN_DEVICE_PATH* Vlan;
1078     INFINIBAND_DEVICE_PATH* InfiniBand;
1079     UART_DEVICE_PATH* Uart;
1080     UART_FLOW_CONTROL_DEVICE_PATH* UartFlowControl;
1081     SAS_DEVICE_PATH* Sas;
1082     SASEX_DEVICE_PATH* SasEx;
1083     NVME_NAMESPACE_DEVICE_PATH* NvmeNamespace;
1084     URI_DEVICE_PATH* Uri;
1085     BLUETOOTH_DEVICE_PATH* Bluetooth;
1086     WIFI_DEVICE_PATH* WiFi;
1087     UFS_DEVICE_PATH* Ufs;
1088     SD_DEVICE_PATH* Sd;
1089     HARDDRIVE_DEVICE_PATH* HardDrive;
1090     CDROM_DEVICE_PATH* CD;
1091 
1092     FILEPATH_DEVICE_PATH* FilePath;
1093     MEDIA_PROTOCOL_DEVICE_PATH* MediaProtocol;
1094 
1095     MEDIA_FW_VOL_DEVICE_PATH* FirmwareVolume;
1096     MEDIA_FW_VOL_FILEPATH_DEVICE_PATH* FirmwareFile;
1097     MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH* Offset;
1098     MEDIA_RAM_DISK_DEVICE_PATH* RamDisk;
1099     BBS_BBS_DEVICE_PATH* Bbs;
1100     UINT8* Raw;
1101 }
1102 
1103 enum END_DEVICE_PATH_TYPE = 0x7f;
1104 enum END_ENTIRE_DEVICE_PATH_SUBTYPE = 0xFF;
1105 enum END_INSTANCE_DEVICE_PATH_SUBTYPE = 0x01;