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