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