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 typedef struct _EFI_DEVICE_PATH { 35 UINT8 Type; 36 UINT8 SubType; 37 UINT8 Length[2]; 38 } EFI_DEVICE_PATH; 39 40 #define EFI_DP_TYPE_MASK 0x7F 41 #define EFI_DP_TYPE_UNPACKED 0x80 42 43 #define END_DEVICE_PATH_TYPE 0x7f 44 45 #define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff 46 #define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 47 #define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH)) 48 49 50 #define DP_IS_END_TYPE(a) 51 #define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) 52 53 #define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) 54 #define DevicePathSubType(a) ( (a)->SubType ) 55 #define DevicePathNodeLength(a) ((size_t)(((a)->Length[0]) | ((a)->Length[1] << 8))) 56 #define NextDevicePathNode(a) ( (EFI_DEVICE_PATH *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) 57 #define IsDevicePathType(a, t) ( DevicePathType(a) == t ) 58 #define IsDevicePathEndType(a) IsDevicePathType(a, END_DEVICE_PATH_TYPE) 59 #define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) 60 #define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) ) 61 #define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED ) 62 63 64 #define SetDevicePathNodeLength(a,l) { \ 65 (a)->Length[0] = (UINT8) (l); \ 66 (a)->Length[1] = (UINT8) ((l) >> 8); \ 67 } 68 69 #define SetDevicePathEndNode(a) { \ 70 (a)->Type = END_DEVICE_PATH_TYPE; \ 71 (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ 72 (a)->Length[0] = sizeof(EFI_DEVICE_PATH); \ 73 (a)->Length[1] = 0; \ 74 } 75 76 /* 77 * 78 */ 79 #define HARDWARE_DEVICE_PATH 0x01 80 81 #define HW_PCI_DP 0x01 82 typedef struct _PCI_DEVICE_PATH { 83 EFI_DEVICE_PATH Header; 84 UINT8 Function; 85 UINT8 Device; 86 } PCI_DEVICE_PATH; 87 88 #define HW_PCCARD_DP 0x02 89 typedef struct _PCCARD_DEVICE_PATH { 90 EFI_DEVICE_PATH Header; 91 UINT8 FunctionNumber; 92 } PCCARD_DEVICE_PATH; 93 94 #define HW_MEMMAP_DP 0x03 95 typedef struct _MEMMAP_DEVICE_PATH { 96 EFI_DEVICE_PATH Header; 97 UINT32 MemoryType; 98 EFI_PHYSICAL_ADDRESS StartingAddress; 99 EFI_PHYSICAL_ADDRESS EndingAddress; 100 } MEMMAP_DEVICE_PATH; 101 102 #define HW_VENDOR_DP 0x04 103 typedef struct _VENDOR_DEVICE_PATH { 104 EFI_DEVICE_PATH Header; 105 EFI_GUID Guid; 106 } VENDOR_DEVICE_PATH; 107 108 #define UNKNOWN_DEVICE_GUID \ 109 { 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } 110 111 typedef struct _UKNOWN_DEVICE_VENDOR_DP { 112 VENDOR_DEVICE_PATH DevicePath; 113 UINT8 LegacyDriveLetter; 114 } UNKNOWN_DEVICE_VENDOR_DEVICE_PATH; 115 116 #define HW_CONTROLLER_DP 0x05 117 typedef struct _CONTROLLER_DEVICE_PATH { 118 EFI_DEVICE_PATH Header; 119 UINT32 Controller; 120 } CONTROLLER_DEVICE_PATH; 121 122 /* 123 * 124 */ 125 #define ACPI_DEVICE_PATH 0x02 126 127 #define ACPI_DP 0x01 128 typedef struct _ACPI_HID_DEVICE_PATH { 129 EFI_DEVICE_PATH Header; 130 UINT32 HID; 131 UINT32 UID; 132 } ACPI_HID_DEVICE_PATH; 133 134 #define ACPI_EXTENDED_DP 0x02 135 typedef struct _ACPI_EXTENDED_HID_DEVICE_PATH { 136 EFI_DEVICE_PATH Header; 137 UINT32 HID; 138 UINT32 UID; 139 UINT32 CID; 140 } ACPI_EXTENDED_HID_DEVICE_PATH; 141 142 // 143 // EISA ID Macro 144 // EISA ID Definition 32-bits 145 // bits[15:0] - three character compressed ASCII EISA ID. 146 // bits[31:16] - binary number 147 // Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z' 148 // 149 #define PNP_EISA_ID_CONST 0x41d0 150 #define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16)) 151 #define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) 152 #define EFI_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) 153 154 #define PNP_EISA_ID_MASK 0xffff 155 #define EISA_ID_TO_NUM(_Id) ((_Id) >> 16) 156 /* 157 * 158 */ 159 #define MESSAGING_DEVICE_PATH 0x03 160 161 #define MSG_ATAPI_DP 0x01 162 typedef struct _ATAPI_DEVICE_PATH { 163 EFI_DEVICE_PATH Header; 164 UINT8 PrimarySecondary; 165 UINT8 SlaveMaster; 166 UINT16 Lun; 167 } ATAPI_DEVICE_PATH; 168 169 #define MSG_SCSI_DP 0x02 170 typedef struct _SCSI_DEVICE_PATH { 171 EFI_DEVICE_PATH Header; 172 UINT16 Pun; 173 UINT16 Lun; 174 } SCSI_DEVICE_PATH; 175 176 #define MSG_FIBRECHANNEL_DP 0x03 177 typedef struct _FIBRECHANNEL_DEVICE_PATH { 178 EFI_DEVICE_PATH Header; 179 UINT32 Reserved; 180 UINT64 WWN; 181 UINT64 Lun; 182 } FIBRECHANNEL_DEVICE_PATH; 183 184 #define MSG_1394_DP 0x04 185 typedef struct _F1394_DEVICE_PATH { 186 EFI_DEVICE_PATH Header; 187 UINT32 Reserved; 188 UINT64 Guid; 189 } F1394_DEVICE_PATH; 190 191 #define MSG_USB_DP 0x05 192 typedef struct _USB_DEVICE_PATH { 193 EFI_DEVICE_PATH Header; 194 UINT8 ParentPortNumber; 195 UINT8 InterfaceNumber; 196 } USB_DEVICE_PATH; 197 198 #define MSG_USB_CLASS_DP 0x0F 199 typedef struct _USB_CLASS_DEVICE_PATH { 200 EFI_DEVICE_PATH Header; 201 UINT16 VendorId; 202 UINT16 ProductId; 203 UINT8 DeviceClass; 204 UINT8 DeviceSubClass; 205 UINT8 DeviceProtocol; 206 } USB_CLASS_DEVICE_PATH; 207 208 #define MSG_I2O_DP 0x06 209 typedef struct _I2O_DEVICE_PATH { 210 EFI_DEVICE_PATH Header; 211 UINT32 Tid; 212 } I2O_DEVICE_PATH; 213 214 #define MSG_MAC_ADDR_DP 0x0b 215 typedef struct _MAC_ADDR_DEVICE_PATH { 216 EFI_DEVICE_PATH Header; 217 EFI_MAC_ADDRESS MacAddress; 218 UINT8 IfType; 219 } MAC_ADDR_DEVICE_PATH; 220 221 #define MSG_IPv4_DP 0x0c 222 typedef struct _IPv4_DEVICE_PATH { 223 EFI_DEVICE_PATH Header; 224 EFI_IPv4_ADDRESS LocalIpAddress; 225 EFI_IPv4_ADDRESS RemoteIpAddress; 226 UINT16 LocalPort; 227 UINT16 RemotePort; 228 UINT16 Protocol; 229 BOOLEAN StaticIpAddress; 230 } IPv4_DEVICE_PATH; 231 232 #define MSG_IPv6_DP 0x0d 233 typedef struct _IPv6_DEVICE_PATH { 234 EFI_DEVICE_PATH Header; 235 EFI_IPv6_ADDRESS LocalIpAddress; 236 EFI_IPv6_ADDRESS RemoteIpAddress; 237 UINT16 LocalPort; 238 UINT16 RemotePort; 239 UINT16 Protocol; 240 BOOLEAN StaticIpAddress; 241 } IPv6_DEVICE_PATH; 242 243 #define MSG_INFINIBAND_DP 0x09 244 typedef struct _INFINIBAND_DEVICE_PATH { 245 EFI_DEVICE_PATH Header; 246 UINT32 ResourceFlags; 247 UINT8 PortGid[16]; 248 UINT64 ServiceId; 249 UINT64 TargetPortId; 250 UINT64 DeviceId; 251 } INFINIBAND_DEVICE_PATH; 252 253 #define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE 0x01 254 #define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT 0x02 255 #define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL 0x04 256 #define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL 0x08 257 #define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL 0x10 258 259 #define MSG_UART_DP 0x0e 260 typedef struct _UART_DEVICE_PATH { 261 EFI_DEVICE_PATH Header; 262 UINT32 Reserved; 263 UINT64 BaudRate; 264 UINT8 DataBits; 265 UINT8 Parity; 266 UINT8 StopBits; 267 } UART_DEVICE_PATH; 268 269 #define MSG_VENDOR_DP 0x0A 270 /* Use VENDOR_DEVICE_PATH struct */ 271 272 #define DEVICE_PATH_MESSAGING_PC_ANSI \ 273 { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 274 275 #define DEVICE_PATH_MESSAGING_VT_100 \ 276 { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 277 278 #define DEVICE_PATH_MESSAGING_VT_100_PLUS \ 279 { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} } 280 281 #define DEVICE_PATH_MESSAGING_VT_UTF8 \ 282 { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} } 283 284 #define MSG_SATA_DP 0x12 285 typedef struct _SATA_DEVICE_PATH { 286 EFI_DEVICE_PATH Header; 287 UINT16 HBAPortNumber; 288 UINT16 PortMultiplierPortNumber; 289 UINT16 Lun; 290 } SATA_DEVICE_PATH; 291 292 #define MEDIA_DEVICE_PATH 0x04 293 294 #define MEDIA_HARDDRIVE_DP 0x01 295 typedef struct _HARDDRIVE_DEVICE_PATH { 296 EFI_DEVICE_PATH Header; 297 UINT32 PartitionNumber; 298 UINT64 PartitionStart; 299 UINT64 PartitionSize; 300 UINT8 Signature[16]; 301 UINT8 MBRType; 302 UINT8 SignatureType; 303 } HARDDRIVE_DEVICE_PATH; 304 305 #define MBR_TYPE_PCAT 0x01 306 #define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 307 308 #define SIGNATURE_TYPE_MBR 0x01 309 #define SIGNATURE_TYPE_GUID 0x02 310 311 #define MEDIA_CDROM_DP 0x02 312 typedef struct _CDROM_DEVICE_PATH { 313 EFI_DEVICE_PATH Header; 314 UINT32 BootEntry; 315 UINT64 PartitionStart; 316 UINT64 PartitionSize; 317 } CDROM_DEVICE_PATH; 318 319 #define MEDIA_VENDOR_DP 0x03 320 /* Use VENDOR_DEVICE_PATH struct */ 321 322 #define MEDIA_FILEPATH_DP 0x04 323 typedef struct _FILEPATH_DEVICE_PATH { 324 EFI_DEVICE_PATH Header; 325 CHAR16 PathName[1]; 326 } FILEPATH_DEVICE_PATH; 327 328 #define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) 329 330 #define MEDIA_PROTOCOL_DP 0x05 331 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { 332 EFI_DEVICE_PATH Header; 333 EFI_GUID Protocol; 334 } MEDIA_PROTOCOL_DEVICE_PATH; 335 336 337 #define BBS_DEVICE_PATH 0x05 338 #define BBS_BBS_DP 0x01 339 typedef struct _BBS_BBS_DEVICE_PATH { 340 EFI_DEVICE_PATH Header; 341 UINT16 DeviceType; 342 UINT16 StatusFlag; 343 CHAR8 String[1]; 344 } BBS_BBS_DEVICE_PATH; 345 346 /* DeviceType definitions - from BBS specification */ 347 #define BBS_TYPE_FLOPPY 0x01 348 #define BBS_TYPE_HARDDRIVE 0x02 349 #define BBS_TYPE_CDROM 0x03 350 #define BBS_TYPE_PCMCIA 0x04 351 #define BBS_TYPE_USB 0x05 352 #define BBS_TYPE_EMBEDDED_NETWORK 0x06 353 #define BBS_TYPE_DEV 0x80 354 #define BBS_TYPE_UNKNOWN 0xFF 355 356 typedef union { 357 EFI_DEVICE_PATH DevPath; 358 PCI_DEVICE_PATH Pci; 359 PCCARD_DEVICE_PATH PcCard; 360 MEMMAP_DEVICE_PATH MemMap; 361 VENDOR_DEVICE_PATH Vendor; 362 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; 363 CONTROLLER_DEVICE_PATH Controller; 364 ACPI_HID_DEVICE_PATH Acpi; 365 366 ATAPI_DEVICE_PATH Atapi; 367 SCSI_DEVICE_PATH Scsi; 368 FIBRECHANNEL_DEVICE_PATH FibreChannel; 369 370 F1394_DEVICE_PATH F1394; 371 USB_DEVICE_PATH Usb; 372 USB_CLASS_DEVICE_PATH UsbClass; 373 I2O_DEVICE_PATH I2O; 374 MAC_ADDR_DEVICE_PATH MacAddr; 375 IPv4_DEVICE_PATH Ipv4; 376 IPv6_DEVICE_PATH Ipv6; 377 INFINIBAND_DEVICE_PATH InfiniBand; 378 UART_DEVICE_PATH Uart; 379 380 HARDDRIVE_DEVICE_PATH HardDrive; 381 CDROM_DEVICE_PATH CD; 382 383 FILEPATH_DEVICE_PATH FilePath; 384 MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; 385 386 BBS_BBS_DEVICE_PATH Bbs; 387 388 } EFI_DEV_PATH; 389 390 typedef union { 391 EFI_DEVICE_PATH *DevPath; 392 PCI_DEVICE_PATH *Pci; 393 PCCARD_DEVICE_PATH *PcCard; 394 MEMMAP_DEVICE_PATH *MemMap; 395 VENDOR_DEVICE_PATH *Vendor; 396 UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; 397 CONTROLLER_DEVICE_PATH *Controller; 398 ACPI_HID_DEVICE_PATH *Acpi; 399 ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; 400 401 ATAPI_DEVICE_PATH *Atapi; 402 SCSI_DEVICE_PATH *Scsi; 403 FIBRECHANNEL_DEVICE_PATH *FibreChannel; 404 405 F1394_DEVICE_PATH *F1394; 406 USB_DEVICE_PATH *Usb; 407 USB_CLASS_DEVICE_PATH *UsbClass; 408 I2O_DEVICE_PATH *I2O; 409 MAC_ADDR_DEVICE_PATH *MacAddr; 410 IPv4_DEVICE_PATH *Ipv4; 411 IPv6_DEVICE_PATH *Ipv6; 412 INFINIBAND_DEVICE_PATH *InfiniBand; 413 UART_DEVICE_PATH *Uart; 414 415 HARDDRIVE_DEVICE_PATH *HardDrive; 416 417 FILEPATH_DEVICE_PATH *FilePath; 418 MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; 419 420 CDROM_DEVICE_PATH *CD; 421 BBS_BBS_DEVICE_PATH *Bbs; 422 423 } EFI_DEV_PATH_PTR; 424 425 #define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ 426 { 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } } 427 428 #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ 429 { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } } 430 431 INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL); 432 433 typedef 434 CHAR16* 435 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) ( 436 IN struct _EFI_DEVICE_PATH *This, 437 IN BOOLEAN DisplayOnly, 438 IN BOOLEAN AllowShortCuts 439 ); 440 441 typedef 442 CHAR16* 443 (EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) ( 444 IN struct _EFI_DEVICE_PATH *This, 445 IN BOOLEAN DisplayOnly, 446 IN BOOLEAN AllowShortCuts 447 ); 448 449 typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL { 450 EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; 451 EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; 452 } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; 453 454 #endif 455