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 * Device Logical Unit SubType. 303 * UEFI 2.0 specification version 2.4 § 9.3.5.8. 304 */ 305 #define MSG_VLAN_DP 20 306 typedef struct _VLAN_DEVICE_PATH { 307 EFI_DEVICE_PATH Header ; 308 UINT16 VlanId ; 309 } VLAN_DEVICE_PATH; 310 311 #define MSG_INFINIBAND_DP 0x09 312 typedef struct _INFINIBAND_DEVICE_PATH { 313 EFI_DEVICE_PATH Header; 314 UINT32 ResourceFlags ; 315 UINT64 PortGid ; 316 UINT64 ServiceId ; 317 UINT64 TargetPortId ; 318 UINT64 DeviceId ; 319 } INFINIBAND_DEVICE_PATH; 320 321 #define MSG_UART_DP 0x0e 322 typedef struct _UART_DEVICE_PATH { 323 EFI_DEVICE_PATH Header; 324 UINT32 Reserved; 325 UINT64 BaudRate; 326 UINT8 DataBits; 327 UINT8 Parity; 328 UINT8 StopBits; 329 } UART_DEVICE_PATH; 330 331 #define MSG_VENDOR_DP 0x0A 332 /* Use VENDOR_DEVICE_PATH struct */ 333 334 #define DEVICE_PATH_MESSAGING_PC_ANSI \ 335 { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 336 337 #define DEVICE_PATH_MESSAGING_VT_100 \ 338 { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 339 340 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \ 341 { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } } 342 343 #define DEVICE_PATH_MESSAGING_VT_UTF8 \ 344 { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } } 345 346 #define EFI_PC_ANSI_GUID \ 347 { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } 348 349 #define EFI_VT_100_GUID \ 350 { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } 351 352 #define EFI_VT_100_PLUS_GUID \ 353 { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } 354 355 #define EFI_VT_UTF8_GUID \ 356 { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } 357 358 359 /* 360 * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.) 361 */ 362 #define MEDIA_DEVICE_PATH 0x04 363 364 #define MEDIA_HARDDRIVE_DP 0x01 365 typedef struct _HARDDRIVE_DEVICE_PATH { 366 EFI_DEVICE_PATH Header; 367 UINT32 PartitionNumber; 368 UINT64 PartitionStart; 369 UINT64 PartitionSize; 370 UINT8 Signature[16]; 371 UINT8 MBRType; 372 UINT8 SignatureType; 373 } HARDDRIVE_DEVICE_PATH; 374 375 #define MBR_TYPE_PCAT 0x01 376 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 377 378 #define SIGNATURE_TYPE_MBR 0x01 379 #define SIGNATURE_TYPE_GUID 0x02 380 381 #define MEDIA_CDROM_DP 0x02 382 typedef struct _CDROM_DEVICE_PATH { 383 EFI_DEVICE_PATH Header; 384 UINT32 BootEntry; 385 UINT64 PartitionStart; 386 UINT64 PartitionSize; 387 } CDROM_DEVICE_PATH; 388 389 #define MEDIA_VENDOR_DP 0x03 390 /* Use VENDOR_DEVICE_PATH struct */ 391 392 #define MEDIA_FILEPATH_DP 0x04 393 typedef struct _FILEPATH_DEVICE_PATH { 394 EFI_DEVICE_PATH Header; 395 CHAR16 PathName[1]; 396 } FILEPATH_DEVICE_PATH; 397 398 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) 399 400 #define MEDIA_PROTOCOL_DP 0x05 401 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { 402 EFI_DEVICE_PATH Header; 403 EFI_GUID Protocol; 404 } MEDIA_PROTOCOL_DEVICE_PATH; 405 406 /** 407 * PIWG Firmware File SubType. 408 * UEFI 2.0 specification version 2.4 § 9.3.6.6. 409 */ 410 #define MEDIA_PIWG_FW_FILE_DP 6 411 typedef struct _MEDIA_FW_VOL_FILEPATH_DEVICE_PATH { 412 EFI_DEVICE_PATH Header ; 413 EFI_GUID FvFileName ; 414 } MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ; 415 416 /** 417 * PIWG Firmware Volume Device Path SubType. 418 * UEFI 2.0 specification version 2.4 § 9.3.6.7. 419 */ 420 #define MEDIA_PIWG_FW_VOL_DP 7 421 typedef struct _MEDIA_FW_VOL_DEVICE_PATH { 422 EFI_DEVICE_PATH Header ; 423 EFI_GUID FvName ; 424 } MEDIA_FW_VOL_DEVICE_PATH ; 425 426 /** 427 * Media relative offset range device path. 428 * UEFI 2.0 specification version 2.4 § 9.3.6.8. 429 */ 430 #define MEDIA_RELATIVE_OFFSET_RANGE_DP 8 431 typedef struct _MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH { 432 EFI_DEVICE_PATH Header ; 433 UINT32 Reserved ; 434 UINT64 StartingOffset ; 435 UINT64 EndingOffset ; 436 } MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH ; 437 438 439 /* 440 * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.) 441 */ 442 #define BBS_DEVICE_PATH 0x05 443 444 #define BBS_BBS_DP 0x01 445 typedef struct _BBS_BBS_DEVICE_PATH { 446 EFI_DEVICE_PATH Header; 447 UINT16 DeviceType; 448 UINT16 StatusFlag; 449 CHAR8 String[1]; 450 } BBS_BBS_DEVICE_PATH; 451 452 /* DeviceType definitions - from BBS specification */ 453 #define BBS_TYPE_FLOPPY 0x01 454 #define BBS_TYPE_HARDDRIVE 0x02 455 #define BBS_TYPE_CDROM 0x03 456 #define BBS_TYPE_PCMCIA 0x04 457 #define BBS_TYPE_USB 0x05 458 #define BBS_TYPE_EMBEDDED_NETWORK 0x06 459 #define BBS_TYPE_DEV 0x80 460 #define BBS_TYPE_UNKNOWN 0xFF 461 462 typedef union { 463 EFI_DEVICE_PATH DevPath; 464 PCI_DEVICE_PATH Pci; 465 PCCARD_DEVICE_PATH PcCard; 466 MEMMAP_DEVICE_PATH MemMap; 467 VENDOR_DEVICE_PATH Vendor; 468 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; 469 CONTROLLER_DEVICE_PATH Controller; 470 ACPI_HID_DEVICE_PATH Acpi; 471 472 ATAPI_DEVICE_PATH Atapi; 473 SCSI_DEVICE_PATH Scsi; 474 FIBRECHANNEL_DEVICE_PATH FibreChannel; 475 476 F1394_DEVICE_PATH F1394; 477 USB_DEVICE_PATH Usb; 478 USB_CLASS_DEVICE_PATH UsbClass; 479 I2O_DEVICE_PATH I2O; 480 MAC_ADDR_DEVICE_PATH MacAddr; 481 IPv4_DEVICE_PATH Ipv4; 482 IPv6_DEVICE_PATH Ipv6; 483 INFINIBAND_DEVICE_PATH InfiniBand; 484 UART_DEVICE_PATH Uart; 485 486 HARDDRIVE_DEVICE_PATH HardDrive; 487 CDROM_DEVICE_PATH CD; 488 489 FILEPATH_DEVICE_PATH FilePath; 490 MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; 491 492 BBS_BBS_DEVICE_PATH Bbs; 493 494 } EFI_DEV_PATH; 495 496 typedef union { 497 EFI_DEVICE_PATH *DevPath; 498 PCI_DEVICE_PATH *Pci; 499 PCCARD_DEVICE_PATH *PcCard; 500 MEMMAP_DEVICE_PATH *MemMap; 501 VENDOR_DEVICE_PATH *Vendor; 502 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; 503 CONTROLLER_DEVICE_PATH *Controller; 504 ACPI_HID_DEVICE_PATH *Acpi; 505 506 ATAPI_DEVICE_PATH *Atapi; 507 SCSI_DEVICE_PATH *Scsi; 508 FIBRECHANNEL_DEVICE_PATH *FibreChannel; 509 510 F1394_DEVICE_PATH *F1394; 511 USB_DEVICE_PATH *Usb; 512 USB_CLASS_DEVICE_PATH *UsbClass; 513 I2O_DEVICE_PATH *I2O; 514 MAC_ADDR_DEVICE_PATH *MacAddr; 515 IPv4_DEVICE_PATH *Ipv4; 516 IPv6_DEVICE_PATH *Ipv6; 517 INFINIBAND_DEVICE_PATH *InfiniBand; 518 UART_DEVICE_PATH *Uart; 519 520 HARDDRIVE_DEVICE_PATH *HardDrive; 521 522 FILEPATH_DEVICE_PATH *FilePath; 523 MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; 524 525 CDROM_DEVICE_PATH *CD; 526 BBS_BBS_DEVICE_PATH *Bbs; 527 528 } EFI_DEV_PATH_PTR; 529 530 531 #endif 532