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