xref: /freebsd/stand/efi/include/efidevp.h (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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 #define ACPI_ADR_DP                         0x03
144 /* ACPI_ADR_DEVICE_PATH not defined */
145 
146 //
147 // EISA ID Macro
148 // EISA ID Definition 32-bits
149 //  bits[15:0] - three character compressed ASCII EISA ID.
150 //  bits[31:16] - binary number
151 //   Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
152 //
153 #define PNP_EISA_ID_CONST       0x41d0
154 #define EISA_ID(_Name, _Num)    ((UINT32) ((_Name) | (_Num) << 16))
155 #define EISA_PNP_ID(_PNPId)     (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
156 #define EFI_PNP_ID(_PNPId)      (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
157 
158 #define PNP_EISA_ID_MASK        0xffff
159 #define EISA_ID_TO_NUM(_Id)     ((_Id) >> 16)
160 /*
161  *
162  */
163 #define MESSAGING_DEVICE_PATH           0x03
164 
165 #define MSG_ATAPI_DP                    0x01
166 typedef struct _ATAPI_DEVICE_PATH {
167         EFI_DEVICE_PATH                 Header;
168         UINT8                           PrimarySecondary;
169         UINT8                           SlaveMaster;
170         UINT16                          Lun;
171 } ATAPI_DEVICE_PATH;
172 
173 #define MSG_SCSI_DP                     0x02
174 typedef struct _SCSI_DEVICE_PATH {
175         EFI_DEVICE_PATH                 Header;
176         UINT16                          Pun;
177         UINT16                          Lun;
178 } SCSI_DEVICE_PATH;
179 
180 #define MSG_FIBRECHANNEL_DP             0x03
181 typedef struct _FIBRECHANNEL_DEVICE_PATH {
182         EFI_DEVICE_PATH                 Header;
183         UINT32                          Reserved;
184         UINT64                          WWN;
185         UINT64                          Lun;
186 } FIBRECHANNEL_DEVICE_PATH;
187 
188 #define MSG_1394_DP                     0x04
189 typedef struct _F1394_DEVICE_PATH {
190         EFI_DEVICE_PATH                 Header;
191         UINT32                          Reserved;
192         UINT64                          Guid;
193 } F1394_DEVICE_PATH;
194 
195 #define MSG_USB_DP                      0x05
196 typedef struct _USB_DEVICE_PATH {
197     EFI_DEVICE_PATH                     Header;
198     UINT8					                      ParentPortNumber;
199     UINT8					                      InterfaceNumber;
200 } USB_DEVICE_PATH;
201 
202 #define MSG_USB_CLASS_DP                0x0F
203 typedef struct _USB_CLASS_DEVICE_PATH {
204         EFI_DEVICE_PATH                 Header;
205         UINT16                          VendorId;
206         UINT16                          ProductId;
207         UINT8                           DeviceClass;
208         UINT8                           DeviceSubClass;
209         UINT8                           DeviceProtocol;
210 } USB_CLASS_DEVICE_PATH;
211 
212 #define MSG_I2O_DP                      0x06
213 typedef struct _I2O_DEVICE_PATH {
214         EFI_DEVICE_PATH                 Header;
215         UINT32                          Tid;
216 } I2O_DEVICE_PATH;
217 
218 #define MSG_MAC_ADDR_DP                 0x0b
219 typedef struct _MAC_ADDR_DEVICE_PATH {
220         EFI_DEVICE_PATH                 Header;
221         EFI_MAC_ADDRESS                 MacAddress;
222         UINT8                           IfType;
223 } MAC_ADDR_DEVICE_PATH;
224 
225 #define MSG_IPv4_DP                     0x0c
226 typedef struct _IPv4_DEVICE_PATH {
227         EFI_DEVICE_PATH                 Header;
228         EFI_IPv4_ADDRESS                LocalIpAddress;
229         EFI_IPv4_ADDRESS                RemoteIpAddress;
230         UINT16                          LocalPort;
231         UINT16                          RemotePort;
232         UINT16                          Protocol;
233         BOOLEAN                         StaticIpAddress;
234         EFI_IPv4_ADDRESS                GatewayIpAddress;
235         EFI_IPv4_ADDRESS                SubnetMask;
236 } IPv4_DEVICE_PATH;
237 
238 #define MSG_IPv6_DP                     0x0d
239 typedef struct _IPv6_DEVICE_PATH {
240         EFI_DEVICE_PATH                 Header;
241         EFI_IPv6_ADDRESS                LocalIpAddress;
242         EFI_IPv6_ADDRESS                RemoteIpAddress;
243         UINT16                          LocalPort;
244         UINT16                          RemotePort;
245         UINT16                          Protocol;
246         BOOLEAN                         StaticIpAddress;
247 } IPv6_DEVICE_PATH;
248 
249 #define MSG_INFINIBAND_DP               0x09
250 typedef struct _INFINIBAND_DEVICE_PATH {
251   EFI_DEVICE_PATH                       Header;
252   UINT32                                ResourceFlags;
253   UINT8                                 PortGid[16];
254   UINT64                                ServiceId;
255   UINT64                                TargetPortId;
256   UINT64                                DeviceId;
257 } INFINIBAND_DEVICE_PATH;
258 
259 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE                0x01
260 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT  0x02
261 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL           0x04
262 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL           0x08
263 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL           0x10
264 
265 #define MSG_UART_DP                     0x0e
266 typedef struct _UART_DEVICE_PATH {
267         EFI_DEVICE_PATH                 Header;
268         UINT32                          Reserved;
269         UINT64                          BaudRate;
270         UINT8                           DataBits;
271         UINT8                           Parity;
272         UINT8                           StopBits;
273 } UART_DEVICE_PATH;
274 
275 #define MSG_VENDOR_DP                   0x0A
276 /* Use VENDOR_DEVICE_PATH struct */
277 
278 #define DEVICE_PATH_MESSAGING_PC_ANSI \
279     { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
280 
281 #define DEVICE_PATH_MESSAGING_VT_100 \
282     { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
283 
284 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \
285     { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} }
286 
287 #define DEVICE_PATH_MESSAGING_VT_UTF8 \
288     { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} }
289 
290 /* Device Logical Unit SubType. */
291 #define	MSG_DEVICE_LOGICAL_UNIT_DP	0x11
292 typedef struct {
293 	EFI_DEVICE_PATH			Header;
294 	/* Logical Unit Number for the interface. */
295 	UINT8				Lun;
296 } DEVICE_LOGICAL_UNIT_DEVICE_PATH;
297 
298 #define MSG_SATA_DP			0x12
299 typedef struct _SATA_DEVICE_PATH {
300 	EFI_DEVICE_PATH			Header;
301 	UINT16				HBAPortNumber;
302 	UINT16				PortMultiplierPortNumber;
303 	UINT16				Lun;
304 } SATA_DEVICE_PATH;
305 
306 
307 /* DNS Device Path SubType */
308 #define MSG_DNS_DP                0x1F
309 typedef struct {
310   EFI_DEVICE_PATH                 Header;
311   /* Indicates the DNS server address is IPv4 or IPv6 address. */
312   UINT8                           IsIPv6;
313   /* Instance of the DNS server address. */
314   /* XXX: actually EFI_IP_ADDRESS */
315   EFI_IPv4_ADDRESS                DnsServerIp[];
316 } DNS_DEVICE_PATH;
317 
318 /* Uniform Resource Identifiers (URI) Device Path SubType */
319 #define MSG_URI_DP                0x18
320 typedef struct {
321   EFI_DEVICE_PATH                 Header;
322   /* Instance of the URI pursuant to RFC 3986. */
323   CHAR8                           Uri[];
324 } URI_DEVICE_PATH;
325 
326 #define MEDIA_DEVICE_PATH               0x04
327 
328 #define MEDIA_HARDDRIVE_DP              0x01
329 typedef struct _HARDDRIVE_DEVICE_PATH {
330         EFI_DEVICE_PATH                 Header;
331         UINT32                          PartitionNumber;
332         UINT64                          PartitionStart;
333         UINT64                          PartitionSize;
334         UINT8                           Signature[16];
335         UINT8                           MBRType;
336         UINT8                           SignatureType;
337 } HARDDRIVE_DEVICE_PATH;
338 
339 #define MBR_TYPE_PCAT                       0x01
340 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
341 
342 #define SIGNATURE_TYPE_MBR                  0x01
343 #define SIGNATURE_TYPE_GUID                 0x02
344 
345 #define MEDIA_CDROM_DP                  0x02
346 typedef struct _CDROM_DEVICE_PATH {
347         EFI_DEVICE_PATH                 Header;
348         UINT32                          BootEntry;
349         UINT64                          PartitionStart;
350         UINT64                          PartitionSize;
351 } CDROM_DEVICE_PATH;
352 
353 #define MEDIA_VENDOR_DP                 0x03
354 /* Use VENDOR_DEVICE_PATH struct */
355 
356 #define MEDIA_FILEPATH_DP               0x04
357 typedef struct _FILEPATH_DEVICE_PATH {
358         EFI_DEVICE_PATH                 Header;
359         CHAR16                          PathName[1];
360 } FILEPATH_DEVICE_PATH;
361 
362 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
363 
364 #define MEDIA_PROTOCOL_DP               0x05
365 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH {
366         EFI_DEVICE_PATH                 Header;
367         EFI_GUID                        Protocol;
368 } MEDIA_PROTOCOL_DEVICE_PATH;
369 
370 
371 #define BBS_DEVICE_PATH                 0x05
372 #define BBS_BBS_DP                      0x01
373 typedef struct _BBS_BBS_DEVICE_PATH {
374         EFI_DEVICE_PATH                 Header;
375         UINT16                          DeviceType;
376         UINT16                          StatusFlag;
377         CHAR8                           String[1];
378 } BBS_BBS_DEVICE_PATH;
379 
380 /* DeviceType definitions - from BBS specification */
381 #define BBS_TYPE_FLOPPY                 0x01
382 #define BBS_TYPE_HARDDRIVE              0x02
383 #define BBS_TYPE_CDROM                  0x03
384 #define BBS_TYPE_PCMCIA                 0x04
385 #define BBS_TYPE_USB                    0x05
386 #define BBS_TYPE_EMBEDDED_NETWORK       0x06
387 #define BBS_TYPE_DEV                    0x80
388 #define BBS_TYPE_UNKNOWN                0xFF
389 
390 typedef union {
391     EFI_DEVICE_PATH                      DevPath;
392     PCI_DEVICE_PATH                      Pci;
393     PCCARD_DEVICE_PATH                   PcCard;
394     MEMMAP_DEVICE_PATH                   MemMap;
395     VENDOR_DEVICE_PATH                   Vendor;
396     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    UnknownVendor;
397     CONTROLLER_DEVICE_PATH               Controller;
398     ACPI_HID_DEVICE_PATH                 Acpi;
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     CDROM_DEVICE_PATH                    CD;
416 
417     FILEPATH_DEVICE_PATH                 FilePath;
418     MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;
419 
420     BBS_BBS_DEVICE_PATH                  Bbs;
421 
422 } EFI_DEV_PATH;
423 
424 typedef union {
425     EFI_DEVICE_PATH                      *DevPath;
426     PCI_DEVICE_PATH                      *Pci;
427     PCCARD_DEVICE_PATH                   *PcCard;
428     MEMMAP_DEVICE_PATH                   *MemMap;
429     VENDOR_DEVICE_PATH                   *Vendor;
430     UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    *UnknownVendor;
431     CONTROLLER_DEVICE_PATH               *Controller;
432     ACPI_HID_DEVICE_PATH                 *Acpi;
433     ACPI_EXTENDED_HID_DEVICE_PATH        *ExtendedAcpi;
434 
435     ATAPI_DEVICE_PATH                    *Atapi;
436     SCSI_DEVICE_PATH                     *Scsi;
437     FIBRECHANNEL_DEVICE_PATH             *FibreChannel;
438 
439     F1394_DEVICE_PATH                    *F1394;
440     USB_DEVICE_PATH                      *Usb;
441     USB_CLASS_DEVICE_PATH                *UsbClass;
442     I2O_DEVICE_PATH                      *I2O;
443     MAC_ADDR_DEVICE_PATH                 *MacAddr;
444     IPv4_DEVICE_PATH                     *Ipv4;
445     IPv6_DEVICE_PATH                     *Ipv6;
446     INFINIBAND_DEVICE_PATH               *InfiniBand;
447     UART_DEVICE_PATH                     *Uart;
448 
449     HARDDRIVE_DEVICE_PATH                *HardDrive;
450 
451     FILEPATH_DEVICE_PATH                 *FilePath;
452     MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;
453 
454     CDROM_DEVICE_PATH                    *CD;
455     BBS_BBS_DEVICE_PATH                  *Bbs;
456 
457 } EFI_DEV_PATH_PTR;
458 
459 #define	EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID			\
460     { 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } }
461 
462 #define	EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID				\
463     { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }
464 
465 #define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID				\
466     { 0x05c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }
467 
468 INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL);
469 
470 typedef
471 CHAR16*
472 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) (
473     IN struct _EFI_DEVICE_PATH *This,
474     IN BOOLEAN                 DisplayOnly,
475     IN BOOLEAN                 AllowShortCuts
476     );
477 
478 typedef
479 CHAR16*
480 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) (
481     IN struct _EFI_DEVICE_PATH *This,
482     IN BOOLEAN                 DisplayOnly,
483     IN BOOLEAN                 AllowShortCuts
484     );
485 
486 typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL {
487 	EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText;
488 	EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText;
489 } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
490 
491 typedef
492 struct _EFI_DEVICE_PATH*
493 (EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) (
494     IN CONST CHAR16* TextDeviceNode
495     );
496 typedef
497 struct _EFI_DEVICE_PATH*
498 (EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) (
499     IN CONST CHAR16* TextDevicePath
500     );
501 
502 
503 typedef struct _EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL {
504 	EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode;
505 	EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath;
506 } EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
507 
508 #pragma pack()
509 
510 #endif
511