1 #ifndef _DEVPATH_H 2 #define _DEVPATH_H 3 4 /*++ 5 6 Copyright (c) 1998 Intel Corporation 7 8 Module Name: 9 10 devpath.h 11 12 Abstract: 13 14 Defines for parsing the EFI Device Path structures 15 16 17 18 Revision History 19 20 --*/ 21 22 // 23 // Device Path structures - Section C 24 // 25 26 typedef struct _EFI_DEVICE_PATH { 27 UINT8 Type; 28 UINT8 SubType; 29 UINT8 Length[2]; 30 } EFI_DEVICE_PATH; 31 32 #define EFI_DP_TYPE_MASK 0x7F 33 #define EFI_DP_TYPE_UNPACKED 0x80 34 35 //#define END_DEVICE_PATH_TYPE 0xff 36 #define END_DEVICE_PATH_TYPE 0x7f 37 //#define END_DEVICE_PATH_TYPE_UNPACKED 0x7f 38 39 #define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff 40 #define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 41 #define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH)) 42 43 44 #define DP_IS_END_TYPE(a) 45 #define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) 46 47 #define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) 48 #define DevicePathSubType(a) ( (a)->SubType ) 49 #define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) 50 #define NextDevicePathNode(a) ( (EFI_DEVICE_PATH *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) 51 //#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE_UNPACKED ) 52 #define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) 53 #define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) 54 #define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) ) 55 #define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED ) 56 57 58 #define SetDevicePathNodeLength(a,l) { \ 59 (a)->Length[0] = (UINT8) (l); \ 60 (a)->Length[1] = (UINT8) ((l) >> 8); \ 61 } 62 63 #define SetDevicePathEndNode(a) { \ 64 (a)->Type = END_DEVICE_PATH_TYPE; \ 65 (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ 66 (a)->Length[0] = sizeof(EFI_DEVICE_PATH); \ 67 (a)->Length[1] = 0; \ 68 } 69 70 71 /* 72 * Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.) 73 */ 74 75 #define HARDWARE_DEVICE_PATH 0x01 76 77 #define HW_PCI_DP 0x01 78 typedef struct _PCI_DEVICE_PATH { 79 EFI_DEVICE_PATH Header; 80 UINT8 Function; 81 UINT8 Device; 82 } PCI_DEVICE_PATH; 83 84 #define HW_PCCARD_DP 0x02 85 typedef struct _PCCARD_DEVICE_PATH { 86 EFI_DEVICE_PATH Header; 87 UINT8 FunctionNumber ; 88 } PCCARD_DEVICE_PATH; 89 90 #define HW_MEMMAP_DP 0x03 91 typedef struct _MEMMAP_DEVICE_PATH { 92 EFI_DEVICE_PATH Header; 93 UINT32 MemoryType; 94 EFI_PHYSICAL_ADDRESS StartingAddress; 95 EFI_PHYSICAL_ADDRESS EndingAddress; 96 } MEMMAP_DEVICE_PATH; 97 98 #define HW_VENDOR_DP 0x04 99 typedef struct _VENDOR_DEVICE_PATH { 100 EFI_DEVICE_PATH Header; 101 EFI_GUID Guid; 102 } VENDOR_DEVICE_PATH; 103 104 #define UNKNOWN_DEVICE_GUID \ 105 { 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } 106 107 typedef struct _UKNOWN_DEVICE_VENDOR_DP { 108 VENDOR_DEVICE_PATH DevicePath; 109 UINT8 LegacyDriveLetter; 110 } UNKNOWN_DEVICE_VENDOR_DEVICE_PATH; 111 112 #define HW_CONTROLLER_DP 0x05 113 typedef struct _CONTROLLER_DEVICE_PATH { 114 EFI_DEVICE_PATH Header; 115 UINT32 Controller; 116 } CONTROLLER_DEVICE_PATH; 117 118 119 /* 120 * ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.) 121 */ 122 #define ACPI_DEVICE_PATH 0x02 123 124 #define ACPI_DP 0x01 125 typedef struct _ACPI_HID_DEVICE_PATH { 126 EFI_DEVICE_PATH Header; 127 UINT32 HID; 128 UINT32 UID; 129 } ACPI_HID_DEVICE_PATH; 130 131 #define EXPANDED_ACPI_DP 0x02 132 typedef struct _EXPANDED_ACPI_HID_DEVICE_PATH { 133 EFI_DEVICE_PATH Header; 134 UINT32 HID; 135 UINT32 UID; 136 UINT32 CID; 137 UINT8 HidStr[1]; 138 } EXPANDED_ACPI_HID_DEVICE_PATH; 139 140 #define ACPI_ADR_DP 3 141 typedef struct _ACPI_ADR_DEVICE_PATH { 142 EFI_DEVICE_PATH Header ; 143 UINT32 ADR ; 144 } ACPI_ADR_DEVICE_PATH ; 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 157 #define PNP_EISA_ID_MASK 0xffff 158 #define EISA_ID_TO_NUM(_Id) ((_Id) >> 16) 159 160 161 /* 162 * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.) 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 /** 190 * Fibre Channel Ex SubType. 191 * UEFI 2.0 specification version 2.4 § 9.3.5.6. 192 */ 193 #define MSG_FIBRECHANNELEX_DP 21 194 typedef struct _FIBRECHANNELEX_DEVICE_PATH { 195 EFI_DEVICE_PATH Header ; 196 UINT32 Reserved ; 197 UINT8 WWN[ 8 ] ; /* World Wide Name */ 198 UINT8 Lun[ 8 ] ; /* Logical unit, T-10 SCSI Architecture Model 4 specification */ 199 } FIBRECHANNELEX_DEVICE_PATH ; 200 201 #define MSG_1394_DP 0x04 202 typedef struct _F1394_DEVICE_PATH { 203 EFI_DEVICE_PATH Header; 204 UINT32 Reserved; 205 UINT64 Guid; 206 } F1394_DEVICE_PATH; 207 208 #define MSG_USB_DP 0x05 209 typedef struct _USB_DEVICE_PATH { 210 EFI_DEVICE_PATH Header; 211 UINT8 Port; 212 UINT8 Endpoint; 213 } USB_DEVICE_PATH; 214 215 /** 216 * SATA Device Path SubType. 217 * UEFI 2.0 specification version 2.4 § 9.3.5.6. 218 */ 219 #define MSG_SATA_DP 18 220 typedef struct _SATA_DEVICE_PATH { 221 EFI_DEVICE_PATH Header ; 222 UINT16 HBAPortNumber ; 223 UINT16 PortMultiplierPortNumber ; 224 UINT16 Lun ; /* Logical Unit Number */ 225 } SATA_DEVICE_PATH ; 226 227 /** 228 * USB WWID Device Path SubType. 229 * UEFI 2.0 specification version 2.4 § 9.3.5.7. 230 */ 231 #define MSG_USB_WWID_DP 16 232 typedef struct _USB_WWID_DEVICE_PATH { 233 EFI_DEVICE_PATH Header ; 234 UINT16 InterfaceNumber ; 235 UINT16 VendorId ; 236 UINT16 ProductId ; 237 CHAR16 SerialNumber[ 1 ] ; /* UTF-16 characters of the USB serial number */ 238 } USB_WWID_DEVICE_PATH ; 239 240 /** 241 * Device Logical Unit SubType. 242 * UEFI 2.0 specification version 2.4 § 9.3.5.8. 243 */ 244 #define MSG_DEVICE_LOGICAL_UNIT_DP 17 245 typedef struct _DEVICE_LOGICAL_UNIT_DEVICE_PATH { 246 EFI_DEVICE_PATH Header ; 247 UINT8 Lun ; /* Logical Unit Number */ 248 } DEVICE_LOGICAL_UNIT_DEVICE_PATH ; 249 250 #define MSG_USB_CLASS_DP 0x0F 251 typedef struct _USB_CLASS_DEVICE_PATH { 252 EFI_DEVICE_PATH Header; 253 UINT16 VendorId; 254 UINT16 ProductId; 255 UINT8 DeviceClass; 256 UINT8 DeviceSubclass; 257 UINT8 DeviceProtocol; 258 } USB_CLASS_DEVICE_PATH; 259 260 #define MSG_I2O_DP 0x06 261 typedef struct _I2O_DEVICE_PATH { 262 EFI_DEVICE_PATH Header; 263 UINT32 Tid; 264 } I2O_DEVICE_PATH; 265 266 #define MSG_MAC_ADDR_DP 0x0b 267 typedef struct _MAC_ADDR_DEVICE_PATH { 268 EFI_DEVICE_PATH Header; 269 EFI_MAC_ADDRESS MacAddress; 270 UINT8 IfType; 271 } MAC_ADDR_DEVICE_PATH; 272 273 #define MSG_IPv4_DP 0x0c 274 typedef struct _IPv4_DEVICE_PATH { 275 EFI_DEVICE_PATH Header; 276 EFI_IPv4_ADDRESS LocalIpAddress; 277 EFI_IPv4_ADDRESS RemoteIpAddress; 278 UINT16 LocalPort; 279 UINT16 RemotePort; 280 UINT16 Protocol; 281 BOOLEAN StaticIpAddress; 282 /* new from UEFI version 2, code must check Length field in Header */ 283 EFI_IPv4_ADDRESS GatewayIpAddress ; 284 EFI_IPv4_ADDRESS SubnetMask ; 285 } IPv4_DEVICE_PATH; 286 287 #define MSG_IPv6_DP 0x0d 288 typedef struct _IPv6_DEVICE_PATH { 289 EFI_DEVICE_PATH Header; 290 EFI_IPv6_ADDRESS LocalIpAddress; 291 EFI_IPv6_ADDRESS RemoteIpAddress; 292 UINT16 LocalPort; 293 UINT16 RemotePort; 294 UINT16 Protocol; 295 BOOLEAN IPAddressOrigin ; 296 /* new from UEFI version 2, code must check Length field in Header */ 297 UINT8 PrefixLength ; 298 EFI_IPv6_ADDRESS GatewayIpAddress ; 299 } IPv6_DEVICE_PATH; 300 301 302 /** 303 * Uniform Resource Identifiers SubType. 304 * UEFI 2.0 specification version 2.4C § 9.3.5.23. 305 */ 306 #define MSG_URI_DP 24 307 typedef struct _URI_DEVICE_PATH { 308 EFI_DEVICE_PATH Header; 309 CHAR8 Uri[1]; 310 } URI_DEVICE_PATH; 311 312 /** 313 * Device Logical Unit SubType. 314 * UEFI 2.0 specification version 2.4 § 9.3.5.8. 315 */ 316 #define MSG_VLAN_DP 20 317 typedef struct _VLAN_DEVICE_PATH { 318 EFI_DEVICE_PATH Header ; 319 UINT16 VlanId ; 320 } VLAN_DEVICE_PATH; 321 322 #define MSG_INFINIBAND_DP 0x09 323 typedef struct _INFINIBAND_DEVICE_PATH { 324 EFI_DEVICE_PATH Header; 325 UINT32 ResourceFlags ; 326 UINT64 PortGid ; 327 UINT64 ServiceId ; 328 UINT64 TargetPortId ; 329 UINT64 DeviceId ; 330 } INFINIBAND_DEVICE_PATH; 331 332 #define MSG_UART_DP 0x0e 333 typedef struct _UART_DEVICE_PATH { 334 EFI_DEVICE_PATH Header; 335 UINT32 Reserved; 336 UINT64 BaudRate; 337 UINT8 DataBits; 338 UINT8 Parity; 339 UINT8 StopBits; 340 } UART_DEVICE_PATH; 341 342 #define MSG_VENDOR_DP 0x0A 343 /* Use VENDOR_DEVICE_PATH struct */ 344 345 #define DEVICE_PATH_MESSAGING_PC_ANSI \ 346 { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 347 348 #define DEVICE_PATH_MESSAGING_VT_100 \ 349 { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 350 351 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \ 352 { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } } 353 354 #define DEVICE_PATH_MESSAGING_VT_UTF8 \ 355 { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } } 356 357 #define EFI_PC_ANSI_GUID \ 358 { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } 359 360 #define EFI_VT_100_GUID \ 361 { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } 362 363 #define EFI_VT_100_PLUS_GUID \ 364 { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } 365 366 #define EFI_VT_UTF8_GUID \ 367 { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } 368 369 370 /* 371 * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.) 372 */ 373 #define MEDIA_DEVICE_PATH 0x04 374 375 #define MEDIA_HARDDRIVE_DP 0x01 376 typedef struct _HARDDRIVE_DEVICE_PATH { 377 EFI_DEVICE_PATH Header; 378 UINT32 PartitionNumber; 379 UINT64 PartitionStart; 380 UINT64 PartitionSize; 381 UINT8 Signature[16]; 382 UINT8 MBRType; 383 UINT8 SignatureType; 384 } HARDDRIVE_DEVICE_PATH; 385 386 #define MBR_TYPE_PCAT 0x01 387 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 388 389 #define SIGNATURE_TYPE_MBR 0x01 390 #define SIGNATURE_TYPE_GUID 0x02 391 392 #define MEDIA_CDROM_DP 0x02 393 typedef struct _CDROM_DEVICE_PATH { 394 EFI_DEVICE_PATH Header; 395 UINT32 BootEntry; 396 UINT64 PartitionStart; 397 UINT64 PartitionSize; 398 } CDROM_DEVICE_PATH; 399 400 #define MEDIA_VENDOR_DP 0x03 401 /* Use VENDOR_DEVICE_PATH struct */ 402 403 #define MEDIA_FILEPATH_DP 0x04 404 typedef struct _FILEPATH_DEVICE_PATH { 405 EFI_DEVICE_PATH Header; 406 CHAR16 PathName[1]; 407 } FILEPATH_DEVICE_PATH; 408 409 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) 410 411 #define MEDIA_PROTOCOL_DP 0x05 412 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { 413 EFI_DEVICE_PATH Header; 414 EFI_GUID Protocol; 415 } MEDIA_PROTOCOL_DEVICE_PATH; 416 417 /** 418 * PIWG Firmware File SubType. 419 * UEFI 2.0 specification version 2.4 § 9.3.6.6. 420 */ 421 #define MEDIA_PIWG_FW_FILE_DP 6 422 typedef struct _MEDIA_FW_VOL_FILEPATH_DEVICE_PATH { 423 EFI_DEVICE_PATH Header ; 424 EFI_GUID FvFileName ; 425 } MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ; 426 427 /** 428 * PIWG Firmware Volume Device Path SubType. 429 * UEFI 2.0 specification version 2.4 § 9.3.6.7. 430 */ 431 #define MEDIA_PIWG_FW_VOL_DP 7 432 typedef struct _MEDIA_FW_VOL_DEVICE_PATH { 433 EFI_DEVICE_PATH Header ; 434 EFI_GUID FvName ; 435 } MEDIA_FW_VOL_DEVICE_PATH ; 436 437 /** 438 * Media relative offset range device path. 439 * UEFI 2.0 specification version 2.4 § 9.3.6.8. 440 */ 441 #define MEDIA_RELATIVE_OFFSET_RANGE_DP 8 442 typedef struct _MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH { 443 EFI_DEVICE_PATH Header ; 444 UINT32 Reserved ; 445 UINT64 StartingOffset ; 446 UINT64 EndingOffset ; 447 } MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH ; 448 449 450 /* 451 * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.) 452 */ 453 #define BBS_DEVICE_PATH 0x05 454 455 #define BBS_BBS_DP 0x01 456 typedef struct _BBS_BBS_DEVICE_PATH { 457 EFI_DEVICE_PATH Header; 458 UINT16 DeviceType; 459 UINT16 StatusFlag; 460 CHAR8 String[1]; 461 } BBS_BBS_DEVICE_PATH; 462 463 /* DeviceType definitions - from BBS specification */ 464 #define BBS_TYPE_FLOPPY 0x01 465 #define BBS_TYPE_HARDDRIVE 0x02 466 #define BBS_TYPE_CDROM 0x03 467 #define BBS_TYPE_PCMCIA 0x04 468 #define BBS_TYPE_USB 0x05 469 #define BBS_TYPE_EMBEDDED_NETWORK 0x06 470 #define BBS_TYPE_DEV 0x80 471 #define BBS_TYPE_UNKNOWN 0xFF 472 473 typedef union { 474 EFI_DEVICE_PATH DevPath; 475 PCI_DEVICE_PATH Pci; 476 PCCARD_DEVICE_PATH PcCard; 477 MEMMAP_DEVICE_PATH MemMap; 478 VENDOR_DEVICE_PATH Vendor; 479 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; 480 CONTROLLER_DEVICE_PATH Controller; 481 ACPI_HID_DEVICE_PATH Acpi; 482 483 ATAPI_DEVICE_PATH Atapi; 484 SCSI_DEVICE_PATH Scsi; 485 FIBRECHANNEL_DEVICE_PATH FibreChannel; 486 487 F1394_DEVICE_PATH F1394; 488 USB_DEVICE_PATH Usb; 489 USB_CLASS_DEVICE_PATH UsbClass; 490 I2O_DEVICE_PATH I2O; 491 MAC_ADDR_DEVICE_PATH MacAddr; 492 IPv4_DEVICE_PATH Ipv4; 493 IPv6_DEVICE_PATH Ipv6; 494 URI_DEVICE_PATH Uri; 495 INFINIBAND_DEVICE_PATH InfiniBand; 496 UART_DEVICE_PATH Uart; 497 498 HARDDRIVE_DEVICE_PATH HardDrive; 499 CDROM_DEVICE_PATH CD; 500 501 FILEPATH_DEVICE_PATH FilePath; 502 MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; 503 504 BBS_BBS_DEVICE_PATH Bbs; 505 506 } EFI_DEV_PATH; 507 508 typedef union { 509 EFI_DEVICE_PATH *DevPath; 510 PCI_DEVICE_PATH *Pci; 511 PCCARD_DEVICE_PATH *PcCard; 512 MEMMAP_DEVICE_PATH *MemMap; 513 VENDOR_DEVICE_PATH *Vendor; 514 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; 515 CONTROLLER_DEVICE_PATH *Controller; 516 ACPI_HID_DEVICE_PATH *Acpi; 517 518 ATAPI_DEVICE_PATH *Atapi; 519 SCSI_DEVICE_PATH *Scsi; 520 FIBRECHANNEL_DEVICE_PATH *FibreChannel; 521 522 F1394_DEVICE_PATH *F1394; 523 USB_DEVICE_PATH *Usb; 524 USB_CLASS_DEVICE_PATH *UsbClass; 525 I2O_DEVICE_PATH *I2O; 526 MAC_ADDR_DEVICE_PATH *MacAddr; 527 IPv4_DEVICE_PATH *Ipv4; 528 IPv6_DEVICE_PATH *Ipv6; 529 URI_DEVICE_PATH *Uri; 530 INFINIBAND_DEVICE_PATH *InfiniBand; 531 UART_DEVICE_PATH *Uart; 532 533 HARDDRIVE_DEVICE_PATH *HardDrive; 534 535 FILEPATH_DEVICE_PATH *FilePath; 536 MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; 537 538 CDROM_DEVICE_PATH *CD; 539 BBS_BBS_DEVICE_PATH *Bbs; 540 541 } EFI_DEV_PATH_PTR; 542 543 544 #endif 545