• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   The device path protocol as defined in UEFI 2.0.
3 
4   The device path represents a programatic path to a device. It's the view
5   from a software point of view. It also must persist from boot to boot, so
6   it can not contain things like PCI bus numbers that change from boot to boot.
7 
8   Copyright (c) 2006 - 2008, Intel Corporation
9   All rights reserved. This program and the accompanying materials
10   are licensed and made available under the terms and conditions of the BSD License
11   which accompanies this distribution.  The full text of the license may be found at
12   http://opensource.org/licenses/bsd-license.php
13 
14   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 
17 **/
18 
19 #ifndef __EFI_DEVICE_PATH_PROTOCOL_H__
20 #define __EFI_DEVICE_PATH_PROTOCOL_H__
21 
22 #include <gpxe/efi/Guid/PcAnsi.h>
23 
24 ///
25 /// Device Path protocol
26 ///
27 #define EFI_DEVICE_PATH_PROTOCOL_GUID \
28   { \
29     0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
30   }
31 
32 //
33 // Protocol GUID defined in EFI1.1.
34 //
35 
36 ///
37 /// Device Path information
38 ///
39 #define DEVICE_PATH_PROTOCOL  EFI_DEVICE_PATH_PROTOCOL_GUID
40 
41 #pragma pack(1)
42 
43 /**
44   This protocol can be used on any device handle to obtain generic path/location
45   information concerning the physical device or logical device. If the handle does
46   not logically map to a physical device, the handle may not necessarily support
47   the device path protocol. The device path describes the location of the device
48   the handle is for. The size of the Device Path can be determined from the structures
49   that make up the Device Path.
50 **/
51 typedef struct {
52   UINT8 Type;       ///< 0x01 Hardware Device Path
53                     ///< 0x02 ACPI Device Path
54                     ///< 0x03 Messaging Device Path
55                     ///< 0x04 Media Device Path
56                     ///< 0x05 BIOS Boot Specification Device Path
57                     ///< 0x7F End of Hardware Device Path
58 
59   UINT8 SubType;    ///< Varies by Type
60                     ///< 0xFF End Entire Device Path, or
61                     ///< 0x01 End This Instance of a Device Path and start a new
62                     ///< Device Path
63 
64   UINT8 Length[2];  ///< Specific Device Path data. Type and Sub-Type define
65                     ///< type of data. Size of data is included in Length.
66 
67 } EFI_DEVICE_PATH_PROTOCOL;
68 
69 ///
70 /// For backward-compatible with EFI1.1.
71 ///
72 typedef EFI_DEVICE_PATH_PROTOCOL  EFI_DEVICE_PATH;
73 
74 ///
75 /// Hardware Device Paths
76 ///
77 #define HARDWARE_DEVICE_PATH      0x01
78 
79 #define HW_PCI_DP                 0x01
80 typedef struct {
81   EFI_DEVICE_PATH_PROTOCOL        Header;
82   UINT8                           Function;
83   UINT8                           Device;
84 } PCI_DEVICE_PATH;
85 
86 #define HW_PCCARD_DP              0x02
87 typedef struct {
88   EFI_DEVICE_PATH_PROTOCOL        Header;
89   UINT8                           FunctionNumber;
90 } PCCARD_DEVICE_PATH;
91 
92 #define HW_MEMMAP_DP              0x03
93 typedef struct {
94   EFI_DEVICE_PATH_PROTOCOL        Header;
95   UINT32                          MemoryType;
96   EFI_PHYSICAL_ADDRESS            StartingAddress;
97   EFI_PHYSICAL_ADDRESS            EndingAddress;
98 } MEMMAP_DEVICE_PATH;
99 
100 #define HW_VENDOR_DP              0x04
101 typedef struct {
102   EFI_DEVICE_PATH_PROTOCOL        Header;
103   EFI_GUID                        Guid;
104 } VENDOR_DEVICE_PATH;
105 
106 #define HW_CONTROLLER_DP          0x05
107 typedef struct {
108   EFI_DEVICE_PATH_PROTOCOL        Header;
109   UINT32                          ControllerNumber;
110 } CONTROLLER_DEVICE_PATH;
111 
112 ///
113 /// ACPI Device Paths
114 ///
115 #define ACPI_DEVICE_PATH          0x02
116 
117 #define ACPI_DP                   0x01
118 typedef struct {
119   EFI_DEVICE_PATH_PROTOCOL        Header;
120   UINT32                          HID;
121   UINT32                          UID;
122 } ACPI_HID_DEVICE_PATH;
123 
124 #define ACPI_EXTENDED_DP          0x02
125 typedef struct {
126   EFI_DEVICE_PATH_PROTOCOL        Header;
127   UINT32                          HID;
128   UINT32                          UID;
129   UINT32                          CID;
130   ///
131   /// Optional variable length _HIDSTR
132   /// Optional variable length _UIDSTR
133   /// Optional variable length _CIDSTR
134   ///
135 } ACPI_EXTENDED_HID_DEVICE_PATH;
136 
137 //
138 //  EISA ID Macro
139 //  EISA ID Definition 32-bits
140 //   bits[15:0] - three character compressed ASCII EISA ID.
141 //   bits[31:16] - binary number
142 //    Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
143 //
144 #define PNP_EISA_ID_CONST         0x41d0
145 #define EISA_ID(_Name, _Num)      ((UINT32)((_Name) | (_Num) << 16))
146 #define EISA_PNP_ID(_PNPId)       (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
147 #define EFI_PNP_ID(_PNPId)        (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
148 
149 #define PNP_EISA_ID_MASK          0xffff
150 #define EISA_ID_TO_NUM(_Id)       ((_Id) >> 16)
151 
152 
153 #define ACPI_ADR_DP               0x03
154 typedef struct {
155   EFI_DEVICE_PATH_PROTOCOL        Header;
156   UINT32                          ADR;
157 } ACPI_ADR_DEVICE_PATH;
158 
159 #define ACPI_ADR_DISPLAY_TYPE_OTHER             0
160 #define ACPI_ADR_DISPLAY_TYPE_VGA               1
161 #define ACPI_ADR_DISPLAY_TYPE_TV                2
162 #define ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL  3
163 #define ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL  4
164 
165 #define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \
166           ((UINT32)( (((_DeviceIdScheme) & 0x1) << 31) |  \
167                       (((_HeadId)         & 0x7) << 18) |  \
168                       (((_NonVgaOutput)   & 0x1) << 17) |  \
169                       (((_BiosCanDetect)  & 0x1) << 16) |  \
170                       (((_VendorInfo)     & 0xf) << 12) |  \
171                       (((_Type)           & 0xf) << 8)  |  \
172                       (((_Port)           & 0xf) << 4)  |  \
173                        ((_Index)          & 0xf) ))
174 
175 ///
176 /// Messaging Device Paths
177 ///
178 #define MESSAGING_DEVICE_PATH     0x03
179 
180 #define MSG_ATAPI_DP              0x01
181 typedef struct {
182   EFI_DEVICE_PATH_PROTOCOL        Header;
183   UINT8                           PrimarySecondary;
184   UINT8                           SlaveMaster;
185   UINT16                          Lun;
186 } ATAPI_DEVICE_PATH;
187 
188 #define MSG_SCSI_DP               0x02
189 typedef struct {
190   EFI_DEVICE_PATH_PROTOCOL        Header;
191   UINT16                          Pun;
192   UINT16                          Lun;
193 } SCSI_DEVICE_PATH;
194 
195 #define MSG_FIBRECHANNEL_DP       0x03
196 typedef struct {
197   EFI_DEVICE_PATH_PROTOCOL        Header;
198   UINT32                          Reserved;
199   UINT64                          WWN;
200   UINT64                          Lun;
201 } FIBRECHANNEL_DEVICE_PATH;
202 
203 #define MSG_1394_DP               0x04
204 typedef struct {
205   EFI_DEVICE_PATH_PROTOCOL        Header;
206   UINT32                          Reserved;
207   UINT64                          Guid;
208 } F1394_DEVICE_PATH;
209 
210 #define MSG_USB_DP                0x05
211 typedef struct {
212     EFI_DEVICE_PATH_PROTOCOL      Header;
213     UINT8                         ParentPortNumber;
214     UINT8                         InterfaceNumber;
215 } USB_DEVICE_PATH;
216 
217 #define MSG_USB_CLASS_DP          0x0f
218 typedef struct {
219     EFI_DEVICE_PATH_PROTOCOL      Header;
220     UINT16                        VendorId;
221     UINT16                        ProductId;
222     UINT8                         DeviceClass;
223     UINT8                         DeviceSubClass;
224     UINT8                         DeviceProtocol;
225 } USB_CLASS_DEVICE_PATH;
226 
227 #define MSG_USB_WWID_DP           0x10
228 typedef struct {
229     EFI_DEVICE_PATH_PROTOCOL      Header;
230     UINT16                        InterfaceNumber;
231     UINT16                        VendorId;
232     UINT16                        ProductId;
233     // CHAR16                     SerialNumber[...];
234 } USB_WWID_DEVICE_PATH;
235 
236 
237 #define MSG_DEVICE_LOGICAL_UNIT_DP  0x11
238 typedef struct {
239     EFI_DEVICE_PATH_PROTOCOL      Header;
240     UINT8                         Lun;
241 } DEVICE_LOGICAL_UNIT_DEVICE_PATH;
242 
243 #define MSG_SATA_DP               0x12
244 typedef struct {
245   EFI_DEVICE_PATH_PROTOCOL        Header;
246   UINT16                          HBAPortNumber;
247   UINT16                          PortMultiplierPortNumber;
248   UINT16                          Lun;
249 } SATA_DEVICE_PATH;
250 
251 #define MSG_I2O_DP                0x06
252 typedef struct {
253   EFI_DEVICE_PATH_PROTOCOL        Header;
254   UINT32                          Tid;
255 } I2O_DEVICE_PATH;
256 
257 #define MSG_MAC_ADDR_DP           0x0b
258 typedef struct {
259   EFI_DEVICE_PATH_PROTOCOL        Header;
260   EFI_MAC_ADDRESS                 MacAddress;
261   UINT8                           IfType;
262 } MAC_ADDR_DEVICE_PATH;
263 
264 #define MSG_IPv4_DP               0x0c
265 typedef struct {
266   EFI_DEVICE_PATH_PROTOCOL        Header;
267   EFI_IPv4_ADDRESS                LocalIpAddress;
268   EFI_IPv4_ADDRESS                RemoteIpAddress;
269   UINT16                          LocalPort;
270   UINT16                          RemotePort;
271   UINT16                          Protocol;
272   BOOLEAN                         StaticIpAddress;
273 } IPv4_DEVICE_PATH;
274 
275 #define MSG_IPv6_DP               0x0d
276 typedef struct {
277   EFI_DEVICE_PATH_PROTOCOL        Header;
278   EFI_IPv6_ADDRESS                LocalIpAddress;
279   EFI_IPv6_ADDRESS                RemoteIpAddress;
280   UINT16                          LocalPort;
281   UINT16                          RemotePort;
282   UINT16                          Protocol;
283   BOOLEAN                         StaticIpAddress;
284 } IPv6_DEVICE_PATH;
285 
286 #define MSG_INFINIBAND_DP         0x09
287 typedef struct {
288   EFI_DEVICE_PATH_PROTOCOL        Header;
289   UINT32                          ResourceFlags;
290   UINT8                           PortGid[16];
291   UINT64                          ServiceId;
292   UINT64                          TargetPortId;
293   UINT64                          DeviceId;
294 } INFINIBAND_DEVICE_PATH;
295 
296 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE                0x01
297 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT  0x02
298 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL           0x04
299 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL           0x08
300 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL           0x10
301 
302 #define MSG_UART_DP               0x0e
303 typedef struct {
304   EFI_DEVICE_PATH_PROTOCOL        Header;
305   UINT32                          Reserved;
306   UINT64                          BaudRate;
307   UINT8                           DataBits;
308   UINT8                           Parity;
309   UINT8                           StopBits;
310 } UART_DEVICE_PATH;
311 
312 //
313 // Use VENDOR_DEVICE_PATH struct
314 //
315 #define MSG_VENDOR_DP             0x0a
316 typedef VENDOR_DEVICE_PATH        VENDOR_DEFINED_DEVICE_PATH;
317 
318 #define DEVICE_PATH_MESSAGING_PC_ANSI     EFI_PC_ANSI_GUID
319 #define DEVICE_PATH_MESSAGING_VT_100      EFI_VT_100_GUID
320 #define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID
321 #define DEVICE_PATH_MESSAGING_VT_UTF8     EFI_VT_UTF8_GUID
322 
323 #define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL   EFI_UART_DEVICE_PATH_GUID
324 
325 typedef struct {
326   EFI_DEVICE_PATH_PROTOCOL        Header;
327   EFI_GUID                        Guid;
328   UINT32                          FlowControlMap;
329 } UART_FLOW_CONTROL_DEVICE_PATH;
330 
331 #define DEVICE_PATH_MESSAGING_SAS                 EFI_SAS_DEVICE_PATH_GUID
332 
333 typedef struct {
334   EFI_DEVICE_PATH_PROTOCOL        Header;
335   EFI_GUID                        Guid;
336   UINT32                          Reserved;
337   UINT64                          SasAddress;
338   UINT64                          Lun;
339   UINT16                          DeviceTopology;
340   UINT16                          RelativeTargetPort;
341 } SAS_DEVICE_PATH;
342 
343 #define MSG_ISCSI_DP              0x13
344 typedef struct {
345   EFI_DEVICE_PATH_PROTOCOL        Header;
346   UINT16                          NetworkProtocol;
347   UINT16                          LoginOption;
348   UINT64                          Lun;
349   UINT16                          TargetPortalGroupTag;
350   // CHAR8                        iSCSI Target Name
351 } ISCSI_DEVICE_PATH;
352 
353 #define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST             0x0000
354 #define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C   0x0002
355 #define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST               0x0000
356 #define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C     0x0008
357 #define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP              0x0000
358 #define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON               0x1000
359 #define ISCSI_LOGIN_OPTION_CHAP_BI                      0x0000
360 #define ISCSI_LOGIN_OPTION_CHAP_UNI                     0x2000
361 
362 //
363 // Media Device Path
364 //
365 #define MEDIA_DEVICE_PATH         0x04
366 
367 #define MEDIA_HARDDRIVE_DP        0x01
368 typedef struct {
369   EFI_DEVICE_PATH_PROTOCOL        Header;
370   UINT32                          PartitionNumber;
371   UINT64                          PartitionStart;
372   UINT64                          PartitionSize;
373   UINT8                           Signature[16];
374   UINT8                           MBRType;
375   UINT8                           SignatureType;
376 } HARDDRIVE_DEVICE_PATH;
377 
378 #define MBR_TYPE_PCAT             0x01
379 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
380 
381 #define SIGNATURE_TYPE_MBR        0x01
382 #define SIGNATURE_TYPE_GUID       0x02
383 
384 #define MEDIA_CDROM_DP            0x02
385 typedef struct {
386   EFI_DEVICE_PATH_PROTOCOL        Header;
387   UINT32                          BootEntry;
388   UINT64                          PartitionStart;
389   UINT64                          PartitionSize;
390 } CDROM_DEVICE_PATH;
391 
392 //
393 // Use VENDOR_DEVICE_PATH struct
394 //
395 #define MEDIA_VENDOR_DP           0x03
396 
397 #define MEDIA_FILEPATH_DP         0x04
398 typedef struct {
399   EFI_DEVICE_PATH_PROTOCOL        Header;
400   CHAR16                          PathName[1];
401 } FILEPATH_DEVICE_PATH;
402 
403 #define SIZE_OF_FILEPATH_DEVICE_PATH  EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
404 
405 #define MEDIA_PROTOCOL_DP         0x05
406 typedef struct {
407   EFI_DEVICE_PATH_PROTOCOL        Header;
408   EFI_GUID                        Protocol;
409 } MEDIA_PROTOCOL_DEVICE_PATH;
410 
411 
412 #define MEDIA_PIWG_FW_VOL_DP      0x7
413 typedef struct {
414   EFI_DEVICE_PATH_PROTOCOL        Header;
415   EFI_GUID                        FvName;
416 } MEDIA_FW_VOL_DEVICE_PATH;
417 
418 
419 #define MEDIA_PIWG_FW_FILE_DP     0x6
420 typedef struct {
421   EFI_DEVICE_PATH_PROTOCOL        Header;
422   EFI_GUID                        FvFileName;
423 } MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;
424 
425 //
426 // BBS Device Path
427 //
428 #define BBS_DEVICE_PATH           0x05
429 #define BBS_BBS_DP                0x01
430 typedef struct {
431   EFI_DEVICE_PATH_PROTOCOL        Header;
432   UINT16                          DeviceType;
433   UINT16                          StatusFlag;
434   CHAR8                           String[1];
435 } BBS_BBS_DEVICE_PATH;
436 
437 //
438 // DeviceType definitions - from BBS specification
439 //
440 #define BBS_TYPE_FLOPPY           0x01
441 #define BBS_TYPE_HARDDRIVE        0x02
442 #define BBS_TYPE_CDROM            0x03
443 #define BBS_TYPE_PCMCIA           0x04
444 #define BBS_TYPE_USB              0x05
445 #define BBS_TYPE_EMBEDDED_NETWORK 0x06
446 #define BBS_TYPE_BEV              0x80
447 #define BBS_TYPE_UNKNOWN          0xFF
448 
449 
450 ///
451 /// Union of all possible Device Paths and pointers to Device Paths
452 ///
453 
454 typedef union {
455   EFI_DEVICE_PATH_PROTOCOL             DevPath;
456   PCI_DEVICE_PATH                      Pci;
457   PCCARD_DEVICE_PATH                   PcCard;
458   MEMMAP_DEVICE_PATH                   MemMap;
459   VENDOR_DEVICE_PATH                   Vendor;
460 
461   CONTROLLER_DEVICE_PATH               Controller;
462   ACPI_HID_DEVICE_PATH                 Acpi;
463 
464   ATAPI_DEVICE_PATH                    Atapi;
465   SCSI_DEVICE_PATH                     Scsi;
466   ISCSI_DEVICE_PATH                    Iscsi;
467   FIBRECHANNEL_DEVICE_PATH             FibreChannel;
468 
469   F1394_DEVICE_PATH                    F1394;
470   USB_DEVICE_PATH                      Usb;
471   SATA_DEVICE_PATH                     Sata;
472   USB_CLASS_DEVICE_PATH                UsbClass;
473   I2O_DEVICE_PATH                      I2O;
474   MAC_ADDR_DEVICE_PATH                 MacAddr;
475   IPv4_DEVICE_PATH                     Ipv4;
476   IPv6_DEVICE_PATH                     Ipv6;
477   INFINIBAND_DEVICE_PATH               InfiniBand;
478   UART_DEVICE_PATH                     Uart;
479 
480   HARDDRIVE_DEVICE_PATH                HardDrive;
481   CDROM_DEVICE_PATH                    CD;
482 
483   FILEPATH_DEVICE_PATH                 FilePath;
484   MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;
485 
486   BBS_BBS_DEVICE_PATH                  Bbs;
487 } EFI_DEV_PATH;
488 
489 
490 
491 typedef union {
492   EFI_DEVICE_PATH_PROTOCOL             *DevPath;
493   PCI_DEVICE_PATH                      *Pci;
494   PCCARD_DEVICE_PATH                   *PcCard;
495   MEMMAP_DEVICE_PATH                   *MemMap;
496   VENDOR_DEVICE_PATH                   *Vendor;
497 
498   CONTROLLER_DEVICE_PATH               *Controller;
499   ACPI_HID_DEVICE_PATH                 *Acpi;
500   ACPI_EXTENDED_HID_DEVICE_PATH        *ExtendedAcpi;
501 
502   ATAPI_DEVICE_PATH                    *Atapi;
503   SCSI_DEVICE_PATH                     *Scsi;
504   FIBRECHANNEL_DEVICE_PATH             *FibreChannel;
505 
506   F1394_DEVICE_PATH                    *F1394;
507   USB_DEVICE_PATH                      *Usb;
508   SATA_DEVICE_PATH                     *Sata;
509   USB_CLASS_DEVICE_PATH                *UsbClass;
510   I2O_DEVICE_PATH                      *I2O;
511   MAC_ADDR_DEVICE_PATH                 *MacAddr;
512   IPv4_DEVICE_PATH                     *Ipv4;
513   IPv6_DEVICE_PATH                     *Ipv6;
514   INFINIBAND_DEVICE_PATH               *InfiniBand;
515   UART_DEVICE_PATH                     *Uart;
516 
517   HARDDRIVE_DEVICE_PATH                *HardDrive;
518   CDROM_DEVICE_PATH                    *CD;
519 
520   FILEPATH_DEVICE_PATH                 *FilePath;
521   MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;
522 
523   BBS_BBS_DEVICE_PATH                  *Bbs;
524   UINT8                                *Raw;
525 } EFI_DEV_PATH_PTR;
526 
527 #pragma pack()
528 
529 #define END_DEVICE_PATH_TYPE                 0x7f
530 #define END_ENTIRE_DEVICE_PATH_SUBTYPE       0xFF
531 #define END_INSTANCE_DEVICE_PATH_SUBTYPE     0x01
532 
533 extern EFI_GUID gEfiDevicePathProtocolGuid;
534 
535 #endif
536