1 #ifndef _DEVPATH_H
2 #define _DEVPATH_H
3 
4 /*++
5 
6 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
7 This software and associated documentation (if any) is furnished
8 under a license and may only be used or copied in accordance
9 with the terms of the license. Except as permitted by such
10 license, no part of this software or documentation may be
11 reproduced, stored in a retrieval system, or transmitted in any
12 form or by any means without the express written consent of
13 Intel Corporation.
14 
15 Module Name:
16 
17     devpath.h
18 
19 Abstract:
20 
21     Defines for parsing the EFI Device Path structures
22 
23 
24 
25 Revision History
26 
27 --*/
28 
29 //
30 // Device Path structures - Section C
31 //
32 
33 #pragma pack(1)
34 
35 typedef struct _EFI_DEVICE_PATH {
36         UINT8                           Type;
37         UINT8                           SubType;
38         UINT8                           Length[2];
39 } EFI_DEVICE_PATH;
40 
41 #define EFI_DP_TYPE_MASK                    0x7F
42 #define EFI_DP_TYPE_UNPACKED                0x80
43 
44 #define END_DEVICE_PATH_TYPE                0x7f
45 
46 #define END_ENTIRE_DEVICE_PATH_SUBTYPE      0xff
47 #define END_INSTANCE_DEVICE_PATH_SUBTYPE    0x01
48 #define END_DEVICE_PATH_LENGTH              (sizeof(EFI_DEVICE_PATH))
49 
50 
51 #define DP_IS_END_TYPE(a)
52 #define DP_IS_END_SUBTYPE(a)        ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
53 
54 #define DevicePathType(a)           ( ((a)->Type) & EFI_DP_TYPE_MASK )
55 #define DevicePathSubType(a)        ( (a)->SubType )
56 #define DevicePathNodeLength(a)     ((size_t)(((a)->Length[0]) | ((a)->Length[1] << 8)))
57 #define NextDevicePathNode(a)       ( (EFI_DEVICE_PATH *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))
58 #define IsDevicePathType(a, t)      ( DevicePathType(a) == t )
59 #define IsDevicePathEndType(a)      IsDevicePathType(a, END_DEVICE_PATH_TYPE)
60 #define IsDevicePathEndSubType(a)   ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
61 #define IsDevicePathEnd(a)          ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )
62 #define IsDevicePathUnpacked(a)     ( (a)->Type & EFI_DP_TYPE_UNPACKED )
63 
64 
65 #define SetDevicePathNodeLength(a,l) {                  \
66             (a)->Length[0] = (UINT8) (l);               \
67             (a)->Length[1] = (UINT8) ((l) >> 8);        \
68             }
69 
70 #define SetDevicePathEndNode(a)  {                      \
71             (a)->Type = END_DEVICE_PATH_TYPE;           \
72             (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;     \
73             (a)->Length[0] = sizeof(EFI_DEVICE_PATH);   \
74             (a)->Length[1] = 0;                         \
75             }
76 
77 /*
78  *
79  */
80 #define HARDWARE_DEVICE_PATH            0x01
81 
82 #define HW_PCI_DP                       0x01
83 typedef struct _PCI_DEVICE_PATH {
84         EFI_DEVICE_PATH                 Header;
85         UINT8                           Function;
86         UINT8                           Device;
87 } PCI_DEVICE_PATH;
88 
89 #define HW_PCCARD_DP                    0x02
90 typedef struct _PCCARD_DEVICE_PATH {
91         EFI_DEVICE_PATH                 Header;
92         UINT8                           FunctionNumber;
93 } PCCARD_DEVICE_PATH;
94 
95 #define HW_MEMMAP_DP                    0x03
96 typedef struct _MEMMAP_DEVICE_PATH {
97         EFI_DEVICE_PATH                 Header;
98         UINT32                          MemoryType;
99         EFI_PHYSICAL_ADDRESS            StartingAddress;
100         EFI_PHYSICAL_ADDRESS            EndingAddress;
101 } MEMMAP_DEVICE_PATH;
102 
103 #define HW_VENDOR_DP                    0x04
104 typedef struct _VENDOR_DEVICE_PATH {
105         EFI_DEVICE_PATH                 Header;
106         EFI_GUID                        Guid;
107 } VENDOR_DEVICE_PATH;
108 
109 #define UNKNOWN_DEVICE_GUID \
110     { 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} }
111 
112 typedef struct _UKNOWN_DEVICE_VENDOR_DP {
113     VENDOR_DEVICE_PATH      DevicePath;
114     UINT8                   LegacyDriveLetter;
115 } UNKNOWN_DEVICE_VENDOR_DEVICE_PATH;
116 
117 #define HW_CONTROLLER_DP            0x05
118 typedef struct _CONTROLLER_DEVICE_PATH {
119         EFI_DEVICE_PATH     Header;
120         UINT32              Controller;
121 } CONTROLLER_DEVICE_PATH;
122 
123 /*
124  *
125  */
126 #define ACPI_DEVICE_PATH                 0x02
127 
128 #define ACPI_DP                         0x01
129 typedef struct _ACPI_HID_DEVICE_PATH {
130         EFI_DEVICE_PATH                 Header;
131         UINT32                          HID;
132         UINT32                          UID;
133 } ACPI_HID_DEVICE_PATH;
134 
135 #define ACPI_EXTENDED_DP          0x02
136 typedef struct _ACPI_EXTENDED_HID_DEVICE_PATH {
137   EFI_DEVICE_PATH                 Header;
138   UINT32                          HID;
139   UINT32                          UID;
140   UINT32                          CID;
141 } ACPI_EXTENDED_HID_DEVICE_PATH;
142 
143 //
144 // EISA ID Macro
145 // EISA ID Definition 32-bits
146 //  bits[15:0] - three character compressed ASCII EISA ID.
147 //  bits[31:16] - binary number
148 //   Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
149 //
150 #define PNP_EISA_ID_CONST       0x41d0
151 #define EISA_ID(_Name, _Num)    ((UINT32) ((_Name) | (_Num) << 16))
152 #define EISA_PNP_ID(_PNPId)     (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
153 #define EFI_PNP_ID(_PNPId)      (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
154 
155 #define PNP_EISA_ID_MASK        0xffff
156 #define EISA_ID_TO_NUM(_Id)     ((_Id) >> 16)
157 /*
158  *
159  */
160 #define MESSAGING_DEVICE_PATH           0x03
161 
162 #define MSG_ATAPI_DP                    0x01
163 typedef struct _ATAPI_DEVICE_PATH {
164         EFI_DEVICE_PATH                 Header;
165         UINT8                           PrimarySecondary;
166         UINT8                           SlaveMaster;
167         UINT16                          Lun;
168 } ATAPI_DEVICE_PATH;
169 
170 #define MSG_SCSI_DP                     0x02
171 typedef struct _SCSI_DEVICE_PATH {
172         EFI_DEVICE_PATH                 Header;
173         UINT16                          Pun;
174         UINT16                          Lun;
175 } SCSI_DEVICE_PATH;
176 
177 #define MSG_FIBRECHANNEL_DP             0x03
178 typedef struct _FIBRECHANNEL_DEVICE_PATH {
179         EFI_DEVICE_PATH                 Header;
180         UINT32                          Reserved;
181         UINT64                          WWN;
182         UINT64                          Lun;
183 } FIBRECHANNEL_DEVICE_PATH;
184 
185 #define MSG_1394_DP                     0x04
186 typedef struct _F1394_DEVICE_PATH {
187         EFI_DEVICE_PATH                 Header;
188         UINT32                          Reserved;
189         UINT64                          Guid;
190 } F1394_DEVICE_PATH;
191 
192 #define MSG_USB_DP                      0x05
193 typedef struct _USB_DEVICE_PATH {
194     EFI_DEVICE_PATH                     Header;
195     UINT8					                      ParentPortNumber;
196     UINT8					                      InterfaceNumber;
197 } USB_DEVICE_PATH;
198 
199 #define MSG_USB_CLASS_DP                0x0F
200 typedef struct _USB_CLASS_DEVICE_PATH {
201         EFI_DEVICE_PATH                 Header;
202         UINT16                          VendorId;
203         UINT16                          ProductId;
204         UINT8                           DeviceClass;
205         UINT8                           DeviceSubClass;
206         UINT8                           DeviceProtocol;
207 } USB_CLASS_DEVICE_PATH;
208 
209 #define MSG_I2O_DP                      0x06
210 typedef struct _I2O_DEVICE_PATH {
211         EFI_DEVICE_PATH                 Header;
212         UINT32                          Tid;
213 } I2O_DEVICE_PATH;
214 
215 #define MSG_MAC_ADDR_DP                 0x0b
216 typedef struct _MAC_ADDR_DEVICE_PATH {
217         EFI_DEVICE_PATH                 Header;
218         EFI_MAC_ADDRESS                 MacAddress;
219         UINT8                           IfType;
220 } MAC_ADDR_DEVICE_PATH;
221 
222 #define MSG_IPv4_DP                     0x0c
223 typedef struct _IPv4_DEVICE_PATH {
224         EFI_DEVICE_PATH                 Header;
225         EFI_IPv4_ADDRESS                LocalIpAddress;
226         EFI_IPv4_ADDRESS                RemoteIpAddress;
227         UINT16                          LocalPort;
228         UINT16                          RemotePort;
229         UINT16                          Protocol;
230         BOOLEAN                         StaticIpAddress;
231 } IPv4_DEVICE_PATH;
232 
233 #define MSG_IPv6_DP                     0x0d
234 typedef struct _IPv6_DEVICE_PATH {
235         EFI_DEVICE_PATH                 Header;
236         EFI_IPv6_ADDRESS                LocalIpAddress;
237         EFI_IPv6_ADDRESS                RemoteIpAddress;
238         UINT16                          LocalPort;
239         UINT16                          RemotePort;
240         UINT16                          Protocol;
241         BOOLEAN                         StaticIpAddress;
242 } IPv6_DEVICE_PATH;
243 
244 #define MSG_INFINIBAND_DP               0x09
245 typedef struct _INFINIBAND_DEVICE_PATH {
246   EFI_DEVICE_PATH                       Header;
247   UINT32                                ResourceFlags;
248   UINT8                                 PortGid[16];
249   UINT64                                ServiceId;
250   UINT64                                TargetPortId;
251   UINT64                                DeviceId;
252 } INFINIBAND_DEVICE_PATH;
253 
254 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE                0x01
255 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT  0x02
256 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL           0x04
257 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL           0x08
258 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL           0x10
259 
260 #define MSG_UART_DP                     0x0e
261 typedef struct _UART_DEVICE_PATH {
262         EFI_DEVICE_PATH                 Header;
263         UINT32                          Reserved;
264         UINT64                          BaudRate;
265         UINT8                           DataBits;
266         UINT8                           Parity;
267         UINT8                           StopBits;
268 } UART_DEVICE_PATH;
269 
270 #define MSG_VENDOR_DP                   0x0A
271 /* Use VENDOR_DEVICE_PATH struct */
272 
273 #define DEVICE_PATH_MESSAGING_PC_ANSI \
274     { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
275 
276 #define DEVICE_PATH_MESSAGING_VT_100 \
277     { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
278 
279 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \
280     { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} }
281 
282 #define DEVICE_PATH_MESSAGING_VT_UTF8 \
283     { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} }
284 
285 /* Device Logical Unit SubType. */
286 #define	MSG_DEVICE_LOGICAL_UNIT_DP	0x11
287 typedef struct {
288 	EFI_DEVICE_PATH			Header;
289 	/* Logical Unit Number for the interface. */
290 	UINT8				Lun;
291 } DEVICE_LOGICAL_UNIT_DEVICE_PATH;
292 
293 #define MSG_SATA_DP			0x12
294 typedef struct _SATA_DEVICE_PATH {
295 	EFI_DEVICE_PATH			Header;
296 	UINT16				HBAPortNumber;
297 	UINT16				PortMultiplierPortNumber;
298 	UINT16				Lun;
299 } SATA_DEVICE_PATH;
300 
301 #define MEDIA_DEVICE_PATH               0x04
302 
303 #define MEDIA_HARDDRIVE_DP              0x01
304 typedef struct _HARDDRIVE_DEVICE_PATH {
305         EFI_DEVICE_PATH                 Header;
306         UINT32                          PartitionNumber;
307         UINT64                          PartitionStart;
308         UINT64                          PartitionSize;
309         UINT8                           Signature[16];
310         UINT8                           MBRType;
311         UINT8                           SignatureType;
312 } HARDDRIVE_DEVICE_PATH;
313 
314 #define MBR_TYPE_PCAT                       0x01
315 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
316 
317 #define SIGNATURE_TYPE_MBR                  0x01
318 #define SIGNATURE_TYPE_GUID                 0x02
319 
320 #define MEDIA_CDROM_DP                  0x02
321 typedef struct _CDROM_DEVICE_PATH {
322         EFI_DEVICE_PATH                 Header;
323         UINT32                          BootEntry;
324         UINT64                          PartitionStart;
325         UINT64                          PartitionSize;
326 } CDROM_DEVICE_PATH;
327 
328 #define MEDIA_VENDOR_DP                 0x03
329 /* Use VENDOR_DEVICE_PATH struct */
330 
331 #define MEDIA_FILEPATH_DP               0x04
332 typedef struct _FILEPATH_DEVICE_PATH {
333         EFI_DEVICE_PATH                 Header;
334         CHAR16                          PathName[1];
335 } FILEPATH_DEVICE_PATH;
336 
337 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
338 
339 #define MEDIA_PROTOCOL_DP               0x05
340 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH {
341         EFI_DEVICE_PATH                 Header;
342         EFI_GUID                        Protocol;
343 } MEDIA_PROTOCOL_DEVICE_PATH;
344 
345 
346 #define BBS_DEVICE_PATH                 0x05
347 #define BBS_BBS_DP                      0x01
348 typedef struct _BBS_BBS_DEVICE_PATH {
349         EFI_DEVICE_PATH                 Header;
350         UINT16                          DeviceType;
351         UINT16                          StatusFlag;
352         CHAR8                           String[1];
353 } BBS_BBS_DEVICE_PATH;
354 
355 /* DeviceType definitions - from BBS specification */
356 #define BBS_TYPE_FLOPPY                 0x01
357 #define BBS_TYPE_HARDDRIVE              0x02
358 #define BBS_TYPE_CDROM                  0x03
359 #define BBS_TYPE_PCMCIA                 0x04
360 #define BBS_TYPE_USB                    0x05
361 #define BBS_TYPE_EMBEDDED_NETWORK       0x06
362 #define BBS_TYPE_DEV                    0x80
363 #define BBS_TYPE_UNKNOWN                0xFF
364 
365 typedef union {
366     EFI_DEVICE_PATH                      DevPath;
367     PCI_DEVICE_PATH                      Pci;
368     PCCARD_DEVICE_PATH                   PcCard;
369     MEMMAP_DEVICE_PATH                   MemMap;
370     VENDOR_DEVICE_PATH                   Vendor;
371     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    UnknownVendor;
372     CONTROLLER_DEVICE_PATH               Controller;
373     ACPI_HID_DEVICE_PATH                 Acpi;
374 
375     ATAPI_DEVICE_PATH                    Atapi;
376     SCSI_DEVICE_PATH                     Scsi;
377     FIBRECHANNEL_DEVICE_PATH             FibreChannel;
378 
379     F1394_DEVICE_PATH                    F1394;
380     USB_DEVICE_PATH                      Usb;
381     USB_CLASS_DEVICE_PATH                UsbClass;
382     I2O_DEVICE_PATH                      I2O;
383     MAC_ADDR_DEVICE_PATH                 MacAddr;
384     IPv4_DEVICE_PATH                     Ipv4;
385     IPv6_DEVICE_PATH                     Ipv6;
386     INFINIBAND_DEVICE_PATH               InfiniBand;
387     UART_DEVICE_PATH                     Uart;
388 
389     HARDDRIVE_DEVICE_PATH                HardDrive;
390     CDROM_DEVICE_PATH                    CD;
391 
392     FILEPATH_DEVICE_PATH                 FilePath;
393     MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;
394 
395     BBS_BBS_DEVICE_PATH                  Bbs;
396 
397 } EFI_DEV_PATH;
398 
399 typedef union {
400     EFI_DEVICE_PATH                      *DevPath;
401     PCI_DEVICE_PATH                      *Pci;
402     PCCARD_DEVICE_PATH                   *PcCard;
403     MEMMAP_DEVICE_PATH                   *MemMap;
404     VENDOR_DEVICE_PATH                   *Vendor;
405     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    *UnknownVendor;
406     CONTROLLER_DEVICE_PATH               *Controller;
407     ACPI_HID_DEVICE_PATH                 *Acpi;
408     ACPI_EXTENDED_HID_DEVICE_PATH        *ExtendedAcpi;
409 
410     ATAPI_DEVICE_PATH                    *Atapi;
411     SCSI_DEVICE_PATH                     *Scsi;
412     FIBRECHANNEL_DEVICE_PATH             *FibreChannel;
413 
414     F1394_DEVICE_PATH                    *F1394;
415     USB_DEVICE_PATH                      *Usb;
416     USB_CLASS_DEVICE_PATH                *UsbClass;
417     I2O_DEVICE_PATH                      *I2O;
418     MAC_ADDR_DEVICE_PATH                 *MacAddr;
419     IPv4_DEVICE_PATH                     *Ipv4;
420     IPv6_DEVICE_PATH                     *Ipv6;
421     INFINIBAND_DEVICE_PATH               *InfiniBand;
422     UART_DEVICE_PATH                     *Uart;
423 
424     HARDDRIVE_DEVICE_PATH                *HardDrive;
425 
426     FILEPATH_DEVICE_PATH                 *FilePath;
427     MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;
428 
429     CDROM_DEVICE_PATH                    *CD;
430     BBS_BBS_DEVICE_PATH                  *Bbs;
431 
432 } EFI_DEV_PATH_PTR;
433 
434 #define	EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID	\
435     { 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } }
436 
437 #define	EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID		\
438     { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }
439 
440 #define	EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID		\
441     { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }
442 
443 #define	EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID		\
444     { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }
445 
446 INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL);
447 
448 typedef
449 CHAR16*
450 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) (
451     IN struct _EFI_DEVICE_PATH *This,
452     IN BOOLEAN			DisplayOnly,
453     IN BOOLEAN			AllowShortCuts
454     );
455 
456 typedef
457 CHAR16*
458 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) (
459     IN struct _EFI_DEVICE_PATH *This,
460     IN BOOLEAN			DisplayOnly,
461     IN BOOLEAN			AllowShortCuts
462     );
463 
464 typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL {
465 	EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText;
466 	EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText;
467 } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
468 
469 #pragma pack()
470 
471 #endif
472