1 #ifndef _EFI_PROT_H 2 #define _EFI_PROT_H 3 4 /*++ 5 6 Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved 7 This software and associated documentation (if any) is furnished 8 under a license and may only be used or copied in accordance 9 with the terms of the license. Except as permitted by such 10 license, no part of this software or documentation may be 11 reproduced, stored in a retrieval system, or transmitted in any 12 form or by any means without the express written consent of 13 Intel Corporation. 14 15 Module Name: 16 17 efiprot.h 18 19 Abstract: 20 21 EFI Protocols 22 23 24 25 Revision History 26 27 --*/ 28 29 #include <efidef.h> 30 31 // 32 // Device Path protocol 33 // 34 35 #define DEVICE_PATH_PROTOCOL \ 36 { 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 37 38 39 // 40 // Block IO protocol 41 // 42 43 #define BLOCK_IO_PROTOCOL \ 44 { 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 45 #define EFI_BLOCK_IO_INTERFACE_REVISION 0x00010000 46 47 INTERFACE_DECL(_EFI_BLOCK_IO); 48 49 typedef 50 EFI_STATUS 51 (EFIAPI *EFI_BLOCK_RESET) ( 52 IN struct _EFI_BLOCK_IO *This, 53 IN BOOLEAN ExtendedVerification 54 ); 55 56 typedef 57 EFI_STATUS 58 (EFIAPI *EFI_BLOCK_READ) ( 59 IN struct _EFI_BLOCK_IO *This, 60 IN UINT32 MediaId, 61 IN EFI_LBA LBA, 62 IN UINTN BufferSize, 63 OUT VOID *Buffer 64 ); 65 66 67 typedef 68 EFI_STATUS 69 (EFIAPI *EFI_BLOCK_WRITE) ( 70 IN struct _EFI_BLOCK_IO *This, 71 IN UINT32 MediaId, 72 IN EFI_LBA LBA, 73 IN UINTN BufferSize, 74 IN VOID *Buffer 75 ); 76 77 78 typedef 79 EFI_STATUS 80 (EFIAPI *EFI_BLOCK_FLUSH) ( 81 IN struct _EFI_BLOCK_IO *This 82 ); 83 84 85 86 typedef struct { 87 UINT32 MediaId; 88 BOOLEAN RemovableMedia; 89 BOOLEAN MediaPresent; 90 91 BOOLEAN LogicalPartition; 92 BOOLEAN ReadOnly; 93 BOOLEAN WriteCaching; 94 95 UINT32 BlockSize; 96 UINT32 IoAlign; 97 98 EFI_LBA LastBlock; 99 } EFI_BLOCK_IO_MEDIA; 100 101 typedef struct _EFI_BLOCK_IO { 102 UINT64 Revision; 103 104 EFI_BLOCK_IO_MEDIA *Media; 105 106 EFI_BLOCK_RESET Reset; 107 EFI_BLOCK_READ ReadBlocks; 108 EFI_BLOCK_WRITE WriteBlocks; 109 EFI_BLOCK_FLUSH FlushBlocks; 110 111 } EFI_BLOCK_IO; 112 113 114 115 // 116 // Disk Block IO protocol 117 // 118 119 #define DISK_IO_PROTOCOL \ 120 { 0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 121 #define EFI_DISK_IO_INTERFACE_REVISION 0x00010000 122 123 INTERFACE_DECL(_EFI_DISK_IO); 124 125 typedef 126 EFI_STATUS 127 (EFIAPI *EFI_DISK_READ) ( 128 IN struct _EFI_DISK_IO *This, 129 IN UINT32 MediaId, 130 IN UINT64 Offset, 131 IN UINTN BufferSize, 132 OUT VOID *Buffer 133 ); 134 135 136 typedef 137 EFI_STATUS 138 (EFIAPI *EFI_DISK_WRITE) ( 139 IN struct _EFI_DISK_IO *This, 140 IN UINT32 MediaId, 141 IN UINT64 Offset, 142 IN UINTN BufferSize, 143 IN VOID *Buffer 144 ); 145 146 147 typedef struct _EFI_DISK_IO { 148 UINT64 Revision; 149 EFI_DISK_READ ReadDisk; 150 EFI_DISK_WRITE WriteDisk; 151 } EFI_DISK_IO; 152 153 154 // 155 // Simple file system protocol 156 // 157 158 #define SIMPLE_FILE_SYSTEM_PROTOCOL \ 159 { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 160 161 INTERFACE_DECL(_EFI_FILE_IO_INTERFACE); 162 INTERFACE_DECL(_EFI_FILE_HANDLE); 163 164 typedef 165 EFI_STATUS 166 (EFIAPI *EFI_VOLUME_OPEN) ( 167 IN struct _EFI_FILE_IO_INTERFACE *This, 168 OUT struct _EFI_FILE_HANDLE **Root 169 ); 170 171 #define EFI_FILE_IO_INTERFACE_REVISION 0x00010000 172 173 typedef struct _EFI_FILE_IO_INTERFACE { 174 UINT64 Revision; 175 EFI_VOLUME_OPEN OpenVolume; 176 } EFI_FILE_IO_INTERFACE; 177 178 // 179 // 180 // 181 182 typedef 183 EFI_STATUS 184 (EFIAPI *EFI_FILE_OPEN) ( 185 IN struct _EFI_FILE_HANDLE *File, 186 OUT struct _EFI_FILE_HANDLE **NewHandle, 187 IN CHAR16 *FileName, 188 IN UINT64 OpenMode, 189 IN UINT64 Attributes 190 ); 191 192 // Open modes 193 #define EFI_FILE_MODE_READ 0x0000000000000001 194 #define EFI_FILE_MODE_WRITE 0x0000000000000002 195 #define EFI_FILE_MODE_CREATE 0x8000000000000000 196 197 // File attributes 198 #define EFI_FILE_READ_ONLY 0x0000000000000001 199 #define EFI_FILE_HIDDEN 0x0000000000000002 200 #define EFI_FILE_SYSTEM 0x0000000000000004 201 #define EFI_FILE_RESERVIED 0x0000000000000008 202 #define EFI_FILE_DIRECTORY 0x0000000000000010 203 #define EFI_FILE_ARCHIVE 0x0000000000000020 204 #define EFI_FILE_VALID_ATTR 0x0000000000000037 205 206 typedef 207 EFI_STATUS 208 (EFIAPI *EFI_FILE_CLOSE) ( 209 IN struct _EFI_FILE_HANDLE *File 210 ); 211 212 typedef 213 EFI_STATUS 214 (EFIAPI *EFI_FILE_DELETE) ( 215 IN struct _EFI_FILE_HANDLE *File 216 ); 217 218 typedef 219 EFI_STATUS 220 (EFIAPI *EFI_FILE_READ) ( 221 IN struct _EFI_FILE_HANDLE *File, 222 IN OUT UINTN *BufferSize, 223 OUT VOID *Buffer 224 ); 225 226 typedef 227 EFI_STATUS 228 (EFIAPI *EFI_FILE_WRITE) ( 229 IN struct _EFI_FILE_HANDLE *File, 230 IN OUT UINTN *BufferSize, 231 IN VOID *Buffer 232 ); 233 234 typedef 235 EFI_STATUS 236 (EFIAPI *EFI_FILE_SET_POSITION) ( 237 IN struct _EFI_FILE_HANDLE *File, 238 IN UINT64 Position 239 ); 240 241 typedef 242 EFI_STATUS 243 (EFIAPI *EFI_FILE_GET_POSITION) ( 244 IN struct _EFI_FILE_HANDLE *File, 245 OUT UINT64 *Position 246 ); 247 248 typedef 249 EFI_STATUS 250 (EFIAPI *EFI_FILE_GET_INFO) ( 251 IN struct _EFI_FILE_HANDLE *File, 252 IN EFI_GUID *InformationType, 253 IN OUT UINTN *BufferSize, 254 OUT VOID *Buffer 255 ); 256 257 typedef 258 EFI_STATUS 259 (EFIAPI *EFI_FILE_SET_INFO) ( 260 IN struct _EFI_FILE_HANDLE *File, 261 IN EFI_GUID *InformationType, 262 IN UINTN BufferSize, 263 IN VOID *Buffer 264 ); 265 266 typedef 267 EFI_STATUS 268 (EFIAPI *EFI_FILE_FLUSH) ( 269 IN struct _EFI_FILE_HANDLE *File 270 ); 271 272 273 274 #define EFI_FILE_HANDLE_REVISION 0x00010000 275 typedef struct _EFI_FILE_HANDLE { 276 UINT64 Revision; 277 EFI_FILE_OPEN Open; 278 EFI_FILE_CLOSE Close; 279 EFI_FILE_DELETE Delete; 280 EFI_FILE_READ Read; 281 EFI_FILE_WRITE Write; 282 EFI_FILE_GET_POSITION GetPosition; 283 EFI_FILE_SET_POSITION SetPosition; 284 EFI_FILE_GET_INFO GetInfo; 285 EFI_FILE_SET_INFO SetInfo; 286 EFI_FILE_FLUSH Flush; 287 } EFI_FILE, *EFI_FILE_HANDLE; 288 289 290 // 291 // File information types 292 // 293 294 #define EFI_FILE_INFO_ID \ 295 { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 296 297 typedef struct { 298 UINT64 Size; 299 UINT64 FileSize; 300 UINT64 PhysicalSize; 301 EFI_TIME CreateTime; 302 EFI_TIME LastAccessTime; 303 EFI_TIME ModificationTime; 304 UINT64 Attribute; 305 CHAR16 FileName[1]; 306 } EFI_FILE_INFO; 307 308 // 309 // The FileName field of the EFI_FILE_INFO data structure is variable length. 310 // Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to 311 // be the size of the data structure without the FileName field. The following macro 312 // computes this size correctly no matter how big the FileName array is declared. 313 // This is required to make the EFI_FILE_INFO data structure ANSI compilant. 314 // 315 316 #define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET(EFI_FILE_INFO,FileName) 317 318 #define EFI_FILE_SYSTEM_INFO_ID \ 319 { 0x9576e93, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 320 321 typedef struct { 322 UINT64 Size; 323 BOOLEAN ReadOnly; 324 UINT64 VolumeSize; 325 UINT64 FreeSpace; 326 UINT32 BlockSize; 327 CHAR16 VolumeLabel[1]; 328 } EFI_FILE_SYSTEM_INFO; 329 330 // 331 // The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length. 332 // Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs 333 // to be the size of the data structure without the VolumeLable field. The following macro 334 // computes this size correctly no matter how big the VolumeLable array is declared. 335 // This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant. 336 // 337 338 #define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_INFO,VolumeLabel) 339 340 #define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID \ 341 { 0xDB47D7D3,0xFE81, 0x11d3, {0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } 342 343 typedef struct { 344 CHAR16 VolumeLabel[1]; 345 } EFI_FILE_SYSTEM_VOLUME_LABEL_INFO; 346 347 #define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL_INFO,VolumeLabel) 348 349 // 350 // Load file protocol 351 // 352 353 354 #define LOAD_FILE_PROTOCOL \ 355 { 0x56EC3091, 0x954C, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } 356 357 INTERFACE_DECL(_EFI_LOAD_FILE_INTERFACE); 358 359 typedef 360 EFI_STATUS 361 (EFIAPI *EFI_LOAD_FILE) ( 362 IN struct _EFI_LOAD_FILE_INTERFACE *This, 363 IN EFI_DEVICE_PATH *FilePath, 364 IN BOOLEAN BootPolicy, 365 IN OUT UINTN *BufferSize, 366 IN VOID *Buffer OPTIONAL 367 ); 368 369 typedef struct _EFI_LOAD_FILE_INTERFACE { 370 EFI_LOAD_FILE LoadFile; 371 } EFI_LOAD_FILE_INTERFACE; 372 373 374 // 375 // Device IO protocol 376 // 377 378 #define DEVICE_IO_PROTOCOL \ 379 { 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 380 381 INTERFACE_DECL(_EFI_DEVICE_IO_INTERFACE); 382 383 typedef enum { 384 IO_UINT8, 385 IO_UINT16, 386 IO_UINT32, 387 IO_UINT64, 388 // 389 // Specification Change: Copy from MMIO to MMIO vs. MMIO to buffer, buffer to MMIO 390 // 391 MMIO_COPY_UINT8, 392 MMIO_COPY_UINT16, 393 MMIO_COPY_UINT32, 394 MMIO_COPY_UINT64 395 } EFI_IO_WIDTH; 396 397 #define EFI_PCI_ADDRESS(bus,dev,func,reg) \ 398 ( (UINT64) ( (((UINTN)bus) << 24) + (((UINTN)dev) << 16) + (((UINTN)func) << 8) + ((UINTN)reg) )) 399 400 typedef 401 EFI_STATUS 402 (EFIAPI *EFI_DEVICE_IO) ( 403 IN struct _EFI_DEVICE_IO_INTERFACE *This, 404 IN EFI_IO_WIDTH Width, 405 IN UINT64 Address, 406 IN UINTN Count, 407 IN OUT VOID *Buffer 408 ); 409 410 typedef struct { 411 EFI_DEVICE_IO Read; 412 EFI_DEVICE_IO Write; 413 } EFI_IO_ACCESS; 414 415 typedef 416 EFI_STATUS 417 (EFIAPI *EFI_PCI_DEVICE_PATH) ( 418 IN struct _EFI_DEVICE_IO_INTERFACE *This, 419 IN UINT64 Address, 420 IN OUT EFI_DEVICE_PATH **PciDevicePath 421 ); 422 423 typedef enum { 424 EfiBusMasterRead, 425 EfiBusMasterWrite, 426 EfiBusMasterCommonBuffer 427 } EFI_IO_OPERATION_TYPE; 428 429 typedef 430 EFI_STATUS 431 (EFIAPI *EFI_IO_MAP) ( 432 IN struct _EFI_DEVICE_IO_INTERFACE *This, 433 IN EFI_IO_OPERATION_TYPE Operation, 434 IN EFI_PHYSICAL_ADDRESS *HostAddress, 435 IN OUT UINTN *NumberOfBytes, 436 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, 437 OUT VOID **Mapping 438 ); 439 440 typedef 441 EFI_STATUS 442 (EFIAPI *EFI_IO_UNMAP) ( 443 IN struct _EFI_DEVICE_IO_INTERFACE *This, 444 IN VOID *Mapping 445 ); 446 447 typedef 448 EFI_STATUS 449 (EFIAPI *EFI_IO_ALLOCATE_BUFFER) ( 450 IN struct _EFI_DEVICE_IO_INTERFACE *This, 451 IN EFI_ALLOCATE_TYPE Type, 452 IN EFI_MEMORY_TYPE MemoryType, 453 IN UINTN Pages, 454 IN OUT EFI_PHYSICAL_ADDRESS *HostAddress 455 ); 456 457 typedef 458 EFI_STATUS 459 (EFIAPI *EFI_IO_FLUSH) ( 460 IN struct _EFI_DEVICE_IO_INTERFACE *This 461 ); 462 463 typedef 464 EFI_STATUS 465 (EFIAPI *EFI_IO_FREE_BUFFER) ( 466 IN struct _EFI_DEVICE_IO_INTERFACE *This, 467 IN UINTN Pages, 468 IN EFI_PHYSICAL_ADDRESS HostAddress 469 ); 470 471 typedef struct _EFI_DEVICE_IO_INTERFACE { 472 EFI_IO_ACCESS Mem; 473 EFI_IO_ACCESS Io; 474 EFI_IO_ACCESS Pci; 475 EFI_IO_MAP Map; 476 EFI_PCI_DEVICE_PATH PciDevicePath; 477 EFI_IO_UNMAP Unmap; 478 EFI_IO_ALLOCATE_BUFFER AllocateBuffer; 479 EFI_IO_FLUSH Flush; 480 EFI_IO_FREE_BUFFER FreeBuffer; 481 } EFI_DEVICE_IO_INTERFACE; 482 483 484 // 485 // Unicode Collation protocol 486 // 487 488 #define UNICODE_COLLATION_PROTOCOL \ 489 { 0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 490 491 #define UNICODE_BYTE_ORDER_MARK (CHAR16)(0xfeff) 492 493 INTERFACE_DECL(_EFI_UNICODE_COLLATION_INTERFACE); 494 495 typedef 496 INTN 497 (EFIAPI *EFI_UNICODE_COLLATION_STRICOLL) ( 498 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 499 IN CHAR16 *s1, 500 IN CHAR16 *s2 501 ); 502 503 typedef 504 BOOLEAN 505 (EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH) ( 506 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 507 IN CHAR16 *String, 508 IN CHAR16 *Pattern 509 ); 510 511 typedef 512 VOID 513 (EFIAPI *EFI_UNICODE_COLLATION_STRLWR) ( 514 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 515 IN OUT CHAR16 *Str 516 ); 517 518 typedef 519 VOID 520 (EFIAPI *EFI_UNICODE_COLLATION_STRUPR) ( 521 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 522 IN OUT CHAR16 *Str 523 ); 524 525 typedef 526 VOID 527 (EFIAPI *EFI_UNICODE_COLLATION_FATTOSTR) ( 528 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 529 IN UINTN FatSize, 530 IN CHAR8 *Fat, 531 OUT CHAR16 *String 532 ); 533 534 typedef 535 BOOLEAN 536 (EFIAPI *EFI_UNICODE_COLLATION_STRTOFAT) ( 537 IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, 538 IN CHAR16 *String, 539 IN UINTN FatSize, 540 OUT CHAR8 *Fat 541 ); 542 543 544 typedef struct _EFI_UNICODE_COLLATION_INTERFACE { 545 546 // general 547 EFI_UNICODE_COLLATION_STRICOLL StriColl; 548 EFI_UNICODE_COLLATION_METAIMATCH MetaiMatch; 549 EFI_UNICODE_COLLATION_STRLWR StrLwr; 550 EFI_UNICODE_COLLATION_STRUPR StrUpr; 551 552 // for supporting fat volumes 553 EFI_UNICODE_COLLATION_FATTOSTR FatToStr; 554 EFI_UNICODE_COLLATION_STRTOFAT StrToFat; 555 556 CHAR8 *SupportedLanguages; 557 } EFI_UNICODE_COLLATION_INTERFACE; 558 559 // 560 // Driver Binding protocol 561 // 562 563 #define DRIVER_BINDING_PROTOCOL \ 564 { 0x18a031ab, 0xb443, 0x4d1a, {0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71} } 565 566 INTERFACE_DECL(_EFI_DRIVER_BINDING); 567 568 typedef 569 EFI_STATUS 570 (EFIAPI *EFI_DRIVER_BINDING_SUPPORTED) ( 571 IN struct _EFI_DRIVER_BINDING *This, 572 IN EFI_HANDLE ControllerHandle, 573 IN EFI_DEVICE_PATH *RemainingPath 574 ); 575 576 typedef 577 EFI_STATUS 578 (EFIAPI *EFI_DRIVER_BINDING_START) ( 579 IN struct _EFI_DRIVER_BINDING *This, 580 IN EFI_HANDLE ControllerHandle, 581 IN EFI_DEVICE_PATH *RemainingPath 582 ); 583 584 typedef 585 EFI_STATUS 586 (EFIAPI *EFI_DRIVER_BINDING_STOP) ( 587 IN struct _EFI_DRIVER_BINDING *This, 588 IN EFI_HANDLE ControllerHandle, 589 IN UINTN NumberOfChildren, 590 IN EFI_HANDLE *ChildHandleBuffer 591 ); 592 593 typedef struct _EFI_DRIVER_BINDING { 594 EFI_DRIVER_BINDING_SUPPORTED Supported; 595 EFI_DRIVER_BINDING_START Start; 596 EFI_DRIVER_BINDING_STOP Stop; 597 UINT32 Version; 598 EFI_HANDLE ImageHandle; 599 EFI_HANDLE DriverBindingHandle; 600 } EFI_DRIVER_BINDING; 601 602 // 603 // Component Name Protocol 2 604 // 605 606 #define COMPONENT_NAME2_PROTOCOL \ 607 { 0x6a7a5cff, 0xe8d9, 0x4f70, {0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14 } } 608 609 INTERFACE_DECL(_EFI_COMPONENT_NAME2); 610 611 typedef 612 EFI_STATUS 613 (EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) ( 614 IN struct _EFI_COMPONENT_NAME2 *This, 615 IN CHAR8 * Language, 616 OUT CHAR16 **DriverName 617 ); 618 619 typedef 620 EFI_STATUS 621 (EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) ( 622 IN struct _EFI_COMPONENT_NAME2 *This, 623 IN EFI_HANDLE ControllerHandle, 624 IN EFI_HANDLE ChildHandle OPTIONAL, 625 IN CHAR8 *Language, 626 OUT CHAR16 **ControllerName 627 ); 628 629 typedef struct _EFI_COMPONENT_NAME2 { 630 EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName; 631 EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName; 632 CHAR8 **SupportedLanguages; 633 } EFI_COMPONENT_NAME2; 634 635 #endif 636