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