Simplify the SmmPeriodicSmiLib to call AllocatePool() for every entry in the SMI...
[mirror_edk2.git] / BaseTools / Source / C / Include / Protocol / DevicePath.h
1 /** @file
2 The device path protocol as defined in UEFI 2.0.
3
4 The device path represents a programatic path to a device. It's the view
5 from a software point of view. It also must persist from boot to boot, so
6 it can not contain things like PCI bus numbers that change from boot to boot.
7
8 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
9
10 This program and the accompanying materials are licensed and made available
11 under the terms and conditions of the BSD License which accompanies this
12 distribution. The full text of the license may be found at:
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 File Name: DevicePath.h
19
20 **/
21
22 #ifndef __EFI_DEVICE_PATH_PROTOCOL_H__
23 #define __EFI_DEVICE_PATH_PROTOCOL_H__
24
25 #include <Guid/PcAnsi.h>
26
27 //
28 // Device Path protocol
29 //
30 #define EFI_DEVICE_PATH_PROTOCOL_GUID \
31 { \
32 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
33 }
34
35 //
36 // Protocol GUID defined in EFI1.1.
37 //
38
39 //
40 // Device Path information
41 //
42 #define DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL_GUID
43
44 #pragma pack(1)
45
46 typedef struct {
47 UINT8 Type;
48 UINT8 SubType;
49 UINT8 Length[2];
50 } EFI_DEVICE_PATH_PROTOCOL;
51
52 //
53 // For backward-compatible with EFI1.1.
54 //
55 typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH;
56
57 //
58 // Hardware Device Paths
59 //
60 #define HARDWARE_DEVICE_PATH 0x01
61
62 #define HW_PCI_DP 0x01
63 typedef struct {
64 EFI_DEVICE_PATH_PROTOCOL Header;
65 UINT8 Function;
66 UINT8 Device;
67 } PCI_DEVICE_PATH;
68
69 #define HW_PCCARD_DP 0x02
70 typedef struct {
71 EFI_DEVICE_PATH_PROTOCOL Header;
72 UINT8 FunctionNumber;
73 } PCCARD_DEVICE_PATH;
74
75 #define HW_MEMMAP_DP 0x03
76 typedef struct {
77 EFI_DEVICE_PATH_PROTOCOL Header;
78 UINT32 MemoryType;
79 EFI_PHYSICAL_ADDRESS StartingAddress;
80 EFI_PHYSICAL_ADDRESS EndingAddress;
81 } MEMMAP_DEVICE_PATH;
82
83 #define HW_VENDOR_DP 0x04
84 typedef struct {
85 EFI_DEVICE_PATH_PROTOCOL Header;
86 EFI_GUID Guid;
87 } VENDOR_DEVICE_PATH;
88
89 #define HW_CONTROLLER_DP 0x05
90 typedef struct {
91 EFI_DEVICE_PATH_PROTOCOL Header;
92 UINT32 ControllerNumber;
93 } CONTROLLER_DEVICE_PATH;
94
95 //
96 // ACPI Device Paths
97 //
98 #define ACPI_DEVICE_PATH 0x02
99
100 #define ACPI_DP 0x01
101 typedef struct {
102 EFI_DEVICE_PATH_PROTOCOL Header;
103 UINT32 HID;
104 UINT32 UID;
105 } ACPI_HID_DEVICE_PATH;
106
107 #define ACPI_EXTENDED_DP 0x02
108 typedef struct {
109 EFI_DEVICE_PATH_PROTOCOL Header;
110 UINT32 HID;
111 UINT32 UID;
112 UINT32 CID;
113 //
114 // Optional variable length _HIDSTR
115 // Optional variable length _UIDSTR
116 //
117 } ACPI_EXTENDED_HID_DEVICE_PATH;
118
119 //
120 // EISA ID Macro
121 // EISA ID Definition 32-bits
122 // bits[15:0] - three character compressed ASCII EISA ID.
123 // bits[31:16] - binary number
124 // Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
125 //
126 #define PNP_EISA_ID_CONST 0x41d0
127 #define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16))
128 #define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
129 #define EFI_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
130
131 #define PNP_EISA_ID_MASK 0xffff
132 #define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
133
134
135 #define ACPI_ADR_DP 0x03
136 typedef struct {
137 EFI_DEVICE_PATH_PROTOCOL Header;
138 UINT32 ADR;
139 } ACPI_ADR_DEVICE_PATH;
140
141
142 //
143 // Messaging Device Paths
144 //
145 #define MESSAGING_DEVICE_PATH 0x03
146
147 #define MSG_ATAPI_DP 0x01
148 typedef struct {
149 EFI_DEVICE_PATH_PROTOCOL Header;
150 UINT8 PrimarySecondary;
151 UINT8 SlaveMaster;
152 UINT16 Lun;
153 } ATAPI_DEVICE_PATH;
154
155 #define MSG_SCSI_DP 0x02
156 typedef struct {
157 EFI_DEVICE_PATH_PROTOCOL Header;
158 UINT16 Pun;
159 UINT16 Lun;
160 } SCSI_DEVICE_PATH;
161
162 #define MSG_FIBRECHANNEL_DP 0x03
163 typedef struct {
164 EFI_DEVICE_PATH_PROTOCOL Header;
165 UINT32 Reserved;
166 UINT64 WWN;
167 UINT64 Lun;
168 } FIBRECHANNEL_DEVICE_PATH;
169
170 #define MSG_1394_DP 0x04
171 typedef struct {
172 EFI_DEVICE_PATH_PROTOCOL Header;
173 UINT32 Reserved;
174 UINT64 Guid;
175 } F1394_DEVICE_PATH;
176
177 #define MSG_USB_DP 0x05
178 typedef struct {
179 EFI_DEVICE_PATH_PROTOCOL Header;
180 UINT8 ParentPortNumber;
181 UINT8 InterfaceNumber;
182 } USB_DEVICE_PATH;
183
184 #define MSG_USB_CLASS_DP 0x0f
185 typedef struct {
186 EFI_DEVICE_PATH_PROTOCOL Header;
187 UINT16 VendorId;
188 UINT16 ProductId;
189 UINT8 DeviceClass;
190 UINT8 DeviceSubClass;
191 UINT8 DeviceProtocol;
192 } USB_CLASS_DEVICE_PATH;
193
194 #define MSG_USB_WWID_DP 0x10
195 typedef struct {
196 EFI_DEVICE_PATH_PROTOCOL Header;
197 UINT16 InterfaceNumber;
198 UINT16 VendorId;
199 UINT16 ProductId;
200 // CHAR16 SerialNumber[...];
201 } USB_WWID_DEVICE_PATH;
202
203
204 #define MSG_DEVICE_LOGICAL_UNIT_DP 0x11
205 typedef struct {
206 EFI_DEVICE_PATH_PROTOCOL Header;
207 UINT8 Lun;
208 } DEVICE_LOGICAL_UNIT_DEVICE_PATH;
209
210 #define MSG_SATA_DP 0x12
211 typedef struct {
212 EFI_DEVICE_PATH_PROTOCOL Header;
213 UINT16 HBAPortNumber;
214 UINT16 PortMultiplierPortNumber;
215 UINT16 Lun;
216 } SATA_DEVICE_PATH;
217
218 #define MSG_I2O_DP 0x06
219 typedef struct {
220 EFI_DEVICE_PATH_PROTOCOL Header;
221 UINT32 Tid;
222 } I2O_DEVICE_PATH;
223
224 #define MSG_MAC_ADDR_DP 0x0b
225 typedef struct {
226 EFI_DEVICE_PATH_PROTOCOL Header;
227 EFI_MAC_ADDRESS MacAddress;
228 UINT8 IfType;
229 } MAC_ADDR_DEVICE_PATH;
230
231 #define MSG_IPv4_DP 0x0c
232 typedef struct {
233 EFI_DEVICE_PATH_PROTOCOL Header;
234 EFI_IPv4_ADDRESS LocalIpAddress;
235 EFI_IPv4_ADDRESS RemoteIpAddress;
236 UINT16 LocalPort;
237 UINT16 RemotePort;
238 UINT16 Protocol;
239 BOOLEAN StaticIpAddress;
240 } IPv4_DEVICE_PATH;
241
242 #define MSG_IPv6_DP 0x0d
243 typedef struct {
244 EFI_DEVICE_PATH_PROTOCOL Header;
245 EFI_IPv6_ADDRESS LocalIpAddress;
246 EFI_IPv6_ADDRESS RemoteIpAddress;
247 UINT16 LocalPort;
248 UINT16 RemotePort;
249 UINT16 Protocol;
250 BOOLEAN StaticIpAddress;
251 } IPv6_DEVICE_PATH;
252
253 #define MSG_INFINIBAND_DP 0x09
254 typedef struct {
255 EFI_DEVICE_PATH_PROTOCOL Header;
256 UINT32 ResourceFlags;
257 UINT8 PortGid[16];
258 UINT64 ServiceId;
259 UINT64 TargetPortId;
260 UINT64 DeviceId;
261 } INFINIBAND_DEVICE_PATH;
262
263 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE 0x01
264 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT 0x02
265 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL 0x04
266 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL 0x08
267 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL 0x10
268
269 #define MSG_UART_DP 0x0e
270 typedef struct {
271 EFI_DEVICE_PATH_PROTOCOL Header;
272 UINT32 Reserved;
273 UINT64 BaudRate;
274 UINT8 DataBits;
275 UINT8 Parity;
276 UINT8 StopBits;
277 } UART_DEVICE_PATH;
278
279 //
280 // Use VENDOR_DEVICE_PATH struct
281 //
282 #define MSG_VENDOR_DP 0x0a
283 typedef VENDOR_DEVICE_PATH VENDOR_DEFINED_DEVICE_PATH;
284
285 #define DEVICE_PATH_MESSAGING_PC_ANSI EFI_PC_ANSI_GUID
286 #define DEVICE_PATH_MESSAGING_VT_100 EFI_VT_100_GUID
287 #define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID
288 #define DEVICE_PATH_MESSAGING_VT_UTF8 EFI_VT_UTF8_GUID
289
290 #define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL EFI_UART_DEVICE_PATH_GUID
291
292 typedef struct {
293 EFI_DEVICE_PATH_PROTOCOL Header;
294 EFI_GUID Guid;
295 UINT32 FlowControlMap;
296 } UART_FLOW_CONTROL_DEVICE_PATH;
297
298 #define DEVICE_PATH_MESSAGING_SAS EFI_SAS_DEVICE_PATH_GUID
299
300 typedef struct {
301 EFI_DEVICE_PATH_PROTOCOL Header;
302 EFI_GUID Guid;
303 UINT32 Reserved;
304 UINT64 SasAddress;
305 UINT64 Lun;
306 UINT16 DeviceTopology;
307 UINT16 RelativeTargetPort;
308 } SAS_DEVICE_PATH;
309
310 #define MSG_ISCSI_DP 0x13
311 typedef struct {
312 EFI_DEVICE_PATH_PROTOCOL Header;
313 UINT16 NetworkProtocol;
314 UINT16 LoginOption;
315 UINT64 Lun;
316 UINT16 TargetPortalGroupTag;
317 // CHAR8 iSCSI Target Name
318 } ISCSI_DEVICE_PATH;
319
320 #define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST 0x0000
321 #define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C 0x0002
322 #define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST 0x0000
323 #define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C 0x0008
324 #define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP 0x0000
325 #define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON 0x1000
326 #define ISCSI_LOGIN_OPTION_CHAP_BI 0x0000
327 #define ISCSI_LOGIN_OPTION_CHAP_UNI 0x2000
328
329 //
330 // Media Device Path
331 //
332 #define MEDIA_DEVICE_PATH 0x04
333
334 #define MEDIA_HARDDRIVE_DP 0x01
335 typedef struct {
336 EFI_DEVICE_PATH_PROTOCOL Header;
337 UINT32 PartitionNumber;
338 UINT64 PartitionStart;
339 UINT64 PartitionSize;
340 UINT8 Signature[16];
341 UINT8 MBRType;
342 UINT8 SignatureType;
343 } HARDDRIVE_DEVICE_PATH;
344
345 #define MBR_TYPE_PCAT 0x01
346 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
347
348 #define SIGNATURE_TYPE_MBR 0x01
349 #define SIGNATURE_TYPE_GUID 0x02
350
351 #define MEDIA_CDROM_DP 0x02
352 typedef struct {
353 EFI_DEVICE_PATH_PROTOCOL Header;
354 UINT32 BootEntry;
355 UINT64 PartitionStart;
356 UINT64 PartitionSize;
357 } CDROM_DEVICE_PATH;
358
359 //
360 // Use VENDOR_DEVICE_PATH struct
361 //
362 #define MEDIA_VENDOR_DP 0x03
363
364 #define MEDIA_FILEPATH_DP 0x04
365 typedef struct {
366 EFI_DEVICE_PATH_PROTOCOL Header;
367 CHAR16 PathName[1];
368 } FILEPATH_DEVICE_PATH;
369
370 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
371
372 #define MEDIA_PROTOCOL_DP 0x05
373 typedef struct {
374 EFI_DEVICE_PATH_PROTOCOL Header;
375 EFI_GUID Protocol;
376 } MEDIA_PROTOCOL_DEVICE_PATH;
377
378
379 #define MEDIA_PIWG_FW_VOL_DP 0x7
380 typedef struct {
381 EFI_DEVICE_PATH_PROTOCOL Header;
382 EFI_GUID FvName;
383 } MEDIA_FW_VOL_DEVICE_PATH;
384
385
386 #define MEDIA_PIWG_FW_FILE_DP 0x6
387 typedef struct {
388 EFI_DEVICE_PATH_PROTOCOL Header;
389 EFI_GUID FvFileName;
390 } MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;
391
392 //
393 // BBS Device Path
394 //
395 #define BBS_DEVICE_PATH 0x05
396 #define BBS_BBS_DP 0x01
397 typedef struct {
398 EFI_DEVICE_PATH_PROTOCOL Header;
399 UINT16 DeviceType;
400 UINT16 StatusFlag;
401 CHAR8 String[1];
402 } BBS_BBS_DEVICE_PATH;
403
404 //
405 // DeviceType definitions - from BBS specification
406 //
407 #define BBS_TYPE_FLOPPY 0x01
408 #define BBS_TYPE_HARDDRIVE 0x02
409 #define BBS_TYPE_CDROM 0x03
410 #define BBS_TYPE_PCMCIA 0x04
411 #define BBS_TYPE_USB 0x05
412 #define BBS_TYPE_EMBEDDED_NETWORK 0x06
413 #define BBS_TYPE_BEV 0x80
414 #define BBS_TYPE_UNKNOWN 0xFF
415
416
417 //
418 // Union of all possible Device Paths and pointers to Device Paths
419 //
420
421 typedef union {
422 EFI_DEVICE_PATH_PROTOCOL DevPath;
423 PCI_DEVICE_PATH Pci;
424 PCCARD_DEVICE_PATH PcCard;
425 MEMMAP_DEVICE_PATH MemMap;
426 VENDOR_DEVICE_PATH Vendor;
427
428 CONTROLLER_DEVICE_PATH Controller;
429 ACPI_HID_DEVICE_PATH Acpi;
430
431 ATAPI_DEVICE_PATH Atapi;
432 SCSI_DEVICE_PATH Scsi;
433 ISCSI_DEVICE_PATH Iscsi;
434 FIBRECHANNEL_DEVICE_PATH FibreChannel;
435
436 F1394_DEVICE_PATH F1394;
437 USB_DEVICE_PATH Usb;
438 SATA_DEVICE_PATH Sata;
439 USB_CLASS_DEVICE_PATH UsbClass;
440 I2O_DEVICE_PATH I2O;
441 MAC_ADDR_DEVICE_PATH MacAddr;
442 IPv4_DEVICE_PATH Ipv4;
443 IPv6_DEVICE_PATH Ipv6;
444 INFINIBAND_DEVICE_PATH InfiniBand;
445 UART_DEVICE_PATH Uart;
446
447 HARDDRIVE_DEVICE_PATH HardDrive;
448 CDROM_DEVICE_PATH CD;
449
450 FILEPATH_DEVICE_PATH FilePath;
451 MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol;
452
453 BBS_BBS_DEVICE_PATH Bbs;
454 } EFI_DEV_PATH;
455
456
457
458 typedef union {
459 EFI_DEVICE_PATH_PROTOCOL *DevPath;
460 PCI_DEVICE_PATH *Pci;
461 PCCARD_DEVICE_PATH *PcCard;
462 MEMMAP_DEVICE_PATH *MemMap;
463 VENDOR_DEVICE_PATH *Vendor;
464
465 CONTROLLER_DEVICE_PATH *Controller;
466 ACPI_HID_DEVICE_PATH *Acpi;
467 ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi;
468
469 ATAPI_DEVICE_PATH *Atapi;
470 SCSI_DEVICE_PATH *Scsi;
471 FIBRECHANNEL_DEVICE_PATH *FibreChannel;
472
473 F1394_DEVICE_PATH *F1394;
474 USB_DEVICE_PATH *Usb;
475 SATA_DEVICE_PATH *Sata;
476 USB_CLASS_DEVICE_PATH *UsbClass;
477 I2O_DEVICE_PATH *I2O;
478 MAC_ADDR_DEVICE_PATH *MacAddr;
479 IPv4_DEVICE_PATH *Ipv4;
480 IPv6_DEVICE_PATH *Ipv6;
481 INFINIBAND_DEVICE_PATH *InfiniBand;
482 UART_DEVICE_PATH *Uart;
483
484 HARDDRIVE_DEVICE_PATH *HardDrive;
485 CDROM_DEVICE_PATH *CD;
486
487 FILEPATH_DEVICE_PATH *FilePath;
488 MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol;
489
490 BBS_BBS_DEVICE_PATH *Bbs;
491 UINT8 *Raw;
492 } EFI_DEV_PATH_PTR;
493
494 #pragma pack()
495
496 #define EFI_DP_TYPE_MASK 0x7F
497 #define EFI_DP_TYPE_UNPACKED 0x80
498 #define END_DEVICE_PATH_TYPE 0x7f
499
500 #define EFI_END_ENTIRE_DEVICE_PATH 0xff
501 #define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
502 #define EFI_END_INSTANCE_DEVICE_PATH 0x01
503 #define END_ENTIRE_DEVICE_PATH_SUBTYPE EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE
504 #define END_INSTANCE_DEVICE_PATH_SUBTYPE EFI_END_INSTANCE_DEVICE_PATH
505
506 #define EFI_END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))
507 #define END_DEVICE_PATH_LENGTH EFI_END_DEVICE_PATH_LENGTH
508
509 #define DP_IS_END_TYPE(a)
510 #define DP_IS_END_SUBTYPE(a) (((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
511 #define DevicePathSubType(a) ((a)->SubType)
512 #define IsDevicePathUnpacked(a) ((a)->Type & EFI_DP_TYPE_UNPACKED)
513
514 #define EfiDevicePathNodeLength(a) (((a)->Length[0]) | ((a)->Length[1] << 8))
515 #define DevicePathNodeLength(a) (EfiDevicePathNodeLength(a))
516 #define EfiNextDevicePathNode(a) ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))
517 #define NextDevicePathNode(a) (EfiNextDevicePathNode(a))
518
519 #define EfiDevicePathType(a) (((a)->Type) & EFI_DP_TYPE_MASK)
520 #define DevicePathType(a) (EfiDevicePathType(a))
521 #define EfiIsDevicePathEndType(a) (EfiDevicePathType (a) == END_DEVICE_PATH_TYPE)
522 #define IsDevicePathEndType(a) (EfiIsDevicePathEndType(a))
523
524
525 #define EfiIsDevicePathEndSubType(a) ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
526 #define IsDevicePathEndSubType(a) (EfiIsDevicePathEndSubType(a))
527 #define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)
528
529 #define EfiIsDevicePathEnd(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))
530 #define IsDevicePathEnd(a) (EfiIsDevicePathEnd(a))
531 #define EfiIsDevicePathEndInstance(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))
532
533
534 #define SetDevicePathNodeLength(a,l) { \
535 (a)->Length[0] = (UINT8) (l); \
536 (a)->Length[1] = (UINT8) ((l) >> 8); \
537 }
538
539 #define SetDevicePathEndNode(a) { \
540 (a)->Type = END_DEVICE_PATH_TYPE; \
541 (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
542 (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
543 (a)->Length[1] = 0; \
544 }
545
546 extern EFI_GUID gEfiDevicePathProtocolGuid;
547
548 #endif