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 #define MSG_SATA_DP 0x12 292 typedef struct _SATA_DEVICE_PATH { 293 EFI_DEVICE_PATH Header; 294 UINT16 HBAPortNumber; 295 UINT16 PortMultiplierPortNumber; 296 UINT16 Lun; 297 } SATA_DEVICE_PATH; 298 299 300 /* DNS Device Path SubType */ 301 #define MSG_DNS_DP 0x1F 302 typedef struct { 303 EFI_DEVICE_PATH Header; 304 /* Indicates the DNS server address is IPv4 or IPv6 address. */ 305 UINT8 IsIPv6; 306 /* Instance of the DNS server address. */ 307 /* XXX: actually EFI_IP_ADDRESS */ 308 EFI_IPv4_ADDRESS DnsServerIp[]; 309 } DNS_DEVICE_PATH; 310 311 /* Uniform Resource Identifiers (URI) Device Path SubType */ 312 #define MSG_URI_DP 0x18 313 typedef struct { 314 EFI_DEVICE_PATH Header; 315 /* Instance of the URI pursuant to RFC 3986. */ 316 CHAR8 Uri[]; 317 } URI_DEVICE_PATH; 318 319 #define MEDIA_DEVICE_PATH 0x04 320 321 #define MEDIA_HARDDRIVE_DP 0x01 322 typedef struct _HARDDRIVE_DEVICE_PATH { 323 EFI_DEVICE_PATH Header; 324 UINT32 PartitionNumber; 325 UINT64 PartitionStart; 326 UINT64 PartitionSize; 327 UINT8 Signature[16]; 328 UINT8 MBRType; 329 UINT8 SignatureType; 330 } HARDDRIVE_DEVICE_PATH; 331 332 #define MBR_TYPE_PCAT 0x01 333 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 334 335 #define SIGNATURE_TYPE_MBR 0x01 336 #define SIGNATURE_TYPE_GUID 0x02 337 338 #define MEDIA_CDROM_DP 0x02 339 typedef struct _CDROM_DEVICE_PATH { 340 EFI_DEVICE_PATH Header; 341 UINT32 BootEntry; 342 UINT64 PartitionStart; 343 UINT64 PartitionSize; 344 } CDROM_DEVICE_PATH; 345 346 #define MEDIA_VENDOR_DP 0x03 347 /* Use VENDOR_DEVICE_PATH struct */ 348 349 #define MEDIA_FILEPATH_DP 0x04 350 typedef struct _FILEPATH_DEVICE_PATH { 351 EFI_DEVICE_PATH Header; 352 CHAR16 PathName[1]; 353 } FILEPATH_DEVICE_PATH; 354 355 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) 356 357 #define MEDIA_PROTOCOL_DP 0x05 358 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { 359 EFI_DEVICE_PATH Header; 360 EFI_GUID Protocol; 361 } MEDIA_PROTOCOL_DEVICE_PATH; 362 363 364 #define BBS_DEVICE_PATH 0x05 365 #define BBS_BBS_DP 0x01 366 typedef struct _BBS_BBS_DEVICE_PATH { 367 EFI_DEVICE_PATH Header; 368 UINT16 DeviceType; 369 UINT16 StatusFlag; 370 CHAR8 String[1]; 371 } BBS_BBS_DEVICE_PATH; 372 373 /* DeviceType definitions - from BBS specification */ 374 #define BBS_TYPE_FLOPPY 0x01 375 #define BBS_TYPE_HARDDRIVE 0x02 376 #define BBS_TYPE_CDROM 0x03 377 #define BBS_TYPE_PCMCIA 0x04 378 #define BBS_TYPE_USB 0x05 379 #define BBS_TYPE_EMBEDDED_NETWORK 0x06 380 #define BBS_TYPE_DEV 0x80 381 #define BBS_TYPE_UNKNOWN 0xFF 382 383 typedef union { 384 EFI_DEVICE_PATH DevPath; 385 PCI_DEVICE_PATH Pci; 386 PCCARD_DEVICE_PATH PcCard; 387 MEMMAP_DEVICE_PATH MemMap; 388 VENDOR_DEVICE_PATH Vendor; 389 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; 390 CONTROLLER_DEVICE_PATH Controller; 391 ACPI_HID_DEVICE_PATH Acpi; 392 393 ATAPI_DEVICE_PATH Atapi; 394 SCSI_DEVICE_PATH Scsi; 395 FIBRECHANNEL_DEVICE_PATH FibreChannel; 396 397 F1394_DEVICE_PATH F1394; 398 USB_DEVICE_PATH Usb; 399 USB_CLASS_DEVICE_PATH UsbClass; 400 I2O_DEVICE_PATH I2O; 401 MAC_ADDR_DEVICE_PATH MacAddr; 402 IPv4_DEVICE_PATH Ipv4; 403 IPv6_DEVICE_PATH Ipv6; 404 INFINIBAND_DEVICE_PATH InfiniBand; 405 UART_DEVICE_PATH Uart; 406 407 HARDDRIVE_DEVICE_PATH HardDrive; 408 CDROM_DEVICE_PATH CD; 409 410 FILEPATH_DEVICE_PATH FilePath; 411 MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; 412 413 BBS_BBS_DEVICE_PATH Bbs; 414 415 } EFI_DEV_PATH; 416 417 typedef union { 418 EFI_DEVICE_PATH *DevPath; 419 PCI_DEVICE_PATH *Pci; 420 PCCARD_DEVICE_PATH *PcCard; 421 MEMMAP_DEVICE_PATH *MemMap; 422 VENDOR_DEVICE_PATH *Vendor; 423 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; 424 CONTROLLER_DEVICE_PATH *Controller; 425 ACPI_HID_DEVICE_PATH *Acpi; 426 ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; 427 428 ATAPI_DEVICE_PATH *Atapi; 429 SCSI_DEVICE_PATH *Scsi; 430 FIBRECHANNEL_DEVICE_PATH *FibreChannel; 431 432 F1394_DEVICE_PATH *F1394; 433 USB_DEVICE_PATH *Usb; 434 USB_CLASS_DEVICE_PATH *UsbClass; 435 I2O_DEVICE_PATH *I2O; 436 MAC_ADDR_DEVICE_PATH *MacAddr; 437 IPv4_DEVICE_PATH *Ipv4; 438 IPv6_DEVICE_PATH *Ipv6; 439 INFINIBAND_DEVICE_PATH *InfiniBand; 440 UART_DEVICE_PATH *Uart; 441 442 HARDDRIVE_DEVICE_PATH *HardDrive; 443 444 FILEPATH_DEVICE_PATH *FilePath; 445 MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; 446 447 CDROM_DEVICE_PATH *CD; 448 BBS_BBS_DEVICE_PATH *Bbs; 449 450 } EFI_DEV_PATH_PTR; 451 452 #define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ 453 { 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } } 454 455 #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ 456 { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } } 457 458 #define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ 459 { 0x05c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } } 460 461 INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL); 462 463 typedef 464 CHAR16* 465 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) ( 466 IN struct _EFI_DEVICE_PATH *This, 467 IN BOOLEAN DisplayOnly, 468 IN BOOLEAN AllowShortCuts 469 ); 470 471 typedef 472 CHAR16* 473 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) ( 474 IN struct _EFI_DEVICE_PATH *This, 475 IN BOOLEAN DisplayOnly, 476 IN BOOLEAN AllowShortCuts 477 ); 478 479 typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL { 480 EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; 481 EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; 482 } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; 483 484 typedef 485 struct _EFI_DEVICE_PATH* 486 (EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) ( 487 IN CONST CHAR16* TextDeviceNode 488 ); 489 typedef 490 struct _EFI_DEVICE_PATH* 491 (EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) ( 492 IN CONST CHAR16* TextDevicePath 493 ); 494 495 496 typedef struct _EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL { 497 EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode; 498 EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath; 499 } EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL; 500 501 #pragma pack() 502 503 #endif 504