1 #ifndef _EFILIB_INCLUDE_ 2 #define _EFILIB_INCLUDE_ 3 4 /*++ 5 6 Copyright (c) 2000 Intel Corporation 7 8 Module Name: 9 10 efilib.h 11 12 Abstract: 13 14 EFI library functions 15 16 17 18 Revision History 19 20 --*/ 21 22 #include "efidebug.h" 23 #include "efipart.h" 24 #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) 25 #include "x86_64/efilibplat.h" 26 #elif defined(_M_IX86) || defined(__i386__) 27 #include "ia32/efilibplat.h" 28 #elif defined(_M_IA64) || defined(__ia64__) 29 #include "ia64/efilibplat.h" 30 #elif defined (_M_ARM64) || defined(__aarch64__) 31 #include "aarch64/efilibplat.h" 32 #elif defined (_M_ARM) || defined(__arm__) 33 #include "arm/efilibplat.h" 34 #elif defined (_M_MIPS64) || defined(__mips64__) 35 #include "mips64el/efilibplat.h" 36 #elif defined (__riscv) && __riscv_xlen == 64 37 #include "riscv64/efilibplat.h" 38 #elif defined (__loongarch64) 39 #include "loongarch64/efilibplat.h" 40 #endif 41 #include "efilink.h" 42 #include "efirtlib.h" 43 #include "efistdarg.h" 44 #include "pci22.h" 45 #include "libsmbios.h" 46 47 // 48 // Public read-only data in the EFI library 49 // 50 51 extern EFI_SYSTEM_TABLE *ST; 52 #define gST ST 53 extern EFI_BOOT_SERVICES *BS; 54 #define gBS BS 55 extern EFI_RUNTIME_SERVICES *RT; 56 #define gRT RT 57 58 extern EFI_GUID gEfiDevicePathProtocolGuid; 59 #define DevicePathProtocol gEfiDevicePathProtocolGuid 60 extern EFI_GUID gEfiDevicePathToTextProtocolGuid; 61 #define DevicePathToTextProtocol gEfiDevicePathToTextProtocolGuid 62 extern EFI_GUID gEfiDevicePathFromTextProtocolGuid; 63 #define DevicePathFromTextProtocol gEfiDevicePathFromTextProtocolGuid 64 extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid; 65 #define DevicePathUtilitiesProtocol gEfiDevicePathUtilitiesProtocolGuid 66 extern EFI_GUID gEfiLoadedImageProtocolGuid; 67 #define LoadedImageProtocol gEfiLoadedImageProtocolGuid 68 extern EFI_GUID gEfiSimpleTextInProtocolGuid; 69 #define TextInProtocol gEfiSimpleTextInProtocolGuid 70 extern EFI_GUID gEfiSimpleTextOutProtocolGuid; 71 #define TextOutProtocol gEfiSimpleTextOutProtocolGuid 72 extern EFI_GUID gEfiGraphicsOutputProtocolGuid; 73 #define GraphicsOutputProtocol gEfiGraphicsOutputProtocolGuid 74 extern EFI_GUID gEfiEdidDiscoveredProtocolGuid; 75 #define EdidDiscoveredProtocol gEfiEdidDiscoveredProtocolGuid 76 extern EFI_GUID gEfiEdidActiveProtocolGuid; 77 #define EdidActiveProtocol gEfiEdidActiveProtocolGuid 78 extern EFI_GUID gEfiEdidOverrideProtocolGuid; 79 #define EdidOverrideProtocol gEfiEdidOverrideProtocolGuid 80 extern EFI_GUID gEfiBlockIoProtocolGuid; 81 #define BlockIoProtocol gEfiBlockIoProtocolGuid 82 extern EFI_GUID gEfiBlockIo2ProtocolGuid; 83 #define BlockIo2Protocol gEfiBlockIo2ProtocolGuid 84 extern EFI_GUID gEfiDiskIoProtocolGuid; 85 #define DiskIoProtocol gEfiDiskIoProtocolGuid 86 extern EFI_GUID gEfiDiskIo2ProtocolGuid; 87 #define DiskIo2Protocol gEfiDiskIo2ProtocolGuid 88 extern EFI_GUID gEfiSimpleFileSystemProtocolGuid; 89 #define FileSystemProtocol gEfiSimpleFileSystemProtocolGuid 90 extern EFI_GUID gEfiLoadFileProtocolGuid; 91 #define LoadFileProtocol gEfiLoadFileProtocolGuid 92 extern EFI_GUID gEfiDeviceIoProtocolGuid; 93 #define DeviceIoProtocol gEfiDeviceIoProtocolGuid 94 extern EFI_GUID VariableStoreProtocol; 95 extern EFI_GUID LegacyBootProtocol; 96 extern EFI_GUID gEfiUnicodeCollationProtocolGuid; 97 #define UnicodeCollationProtocol gEfiUnicodeCollationProtocolGuid 98 extern EFI_GUID gEfiSerialIoProtocolGuid; 99 #define SerialIoProtocol gEfiSerialIoProtocolGuid 100 extern EFI_GUID VgaClassProtocol; 101 extern EFI_GUID TextOutSpliterProtocol; 102 extern EFI_GUID ErrorOutSpliterProtocol; 103 extern EFI_GUID TextInSpliterProtocol; 104 extern EFI_GUID gEfiSimpleNetworkProtocolGuid; 105 #define SimpleNetworkProtocol gEfiSimpleNetworkProtocolGuid 106 extern EFI_GUID gEfiPxeBaseCodeProtocolGuid; 107 #define PxeBaseCodeProtocol gEfiPxeBaseCodeProtocolGuid 108 extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid; 109 #define PxeCallbackProtocol gEfiPxeBaseCodeCallbackProtocolGuid 110 extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid; 111 #define NetworkInterfaceIdentifierProtocol gEfiNetworkInterfaceIdentifierProtocolGuid 112 extern EFI_GUID gEFiUiInterfaceProtocolGuid; 113 #define UiProtocol gEFiUiInterfaceProtocolGuid 114 extern EFI_GUID InternalShellProtocol; 115 extern EFI_GUID gEfiPciIoProtocolGuid; 116 #define PciIoProtocol gEfiPciIoProtocolGuid 117 extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid; 118 extern EFI_GUID gEfiDriverBindingProtocolGuid; 119 #define DriverBindingProtocol gEfiDriverBindingProtocolGuid 120 extern EFI_GUID gEfiComponentNameProtocolGuid; 121 #define ComponentNameProtocol gEfiComponentNameProtocolGuid 122 extern EFI_GUID gEfiComponentName2ProtocolGuid; 123 #define ComponentName2Protocol gEfiComponentName2ProtocolGuid 124 extern EFI_GUID gEfiHashProtocolGuid; 125 #define HashProtocol gEfiHashProtocolGuid 126 extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid; 127 #define PlatformDriverOverrideProtocol gEfiPlatformDriverOverrideProtocolGuid 128 extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid; 129 #define BusSpecificDriverOverrideProtocol gEfiBusSpecificDriverOverrideProtocolGuid 130 extern EFI_GUID gEfiDriverFamilyOverrideProtocolGuid; 131 #define DriverFamilyOverrideProtocol gEfiDriverFamilyOverrideProtocolGuid 132 extern EFI_GUID gEfiEbcProtocolGuid; 133 134 extern EFI_GUID gEfiGlobalVariableGuid; 135 #define EfiGlobalVariable gEfiGlobalVariableGuid 136 extern EFI_GUID gEfiFileInfoGuid; 137 #define GenericFileInfo gEfiFileInfoGuid 138 extern EFI_GUID gEfiFileSystemInfoGuid; 139 #define FileSystemInfo gEfiFileSystemInfoGuid 140 extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid; 141 #define FileSystemVolumeLabelInfo gEfiFileSystemVolumeLabelInfoIdGuid 142 extern EFI_GUID gEfiPcAnsiGuid; 143 #define PcAnsiProtocol gEfiPcAnsiGuid 144 extern EFI_GUID gEfiVT100Guid; 145 #define Vt100Protocol gEfiVT100Guid 146 extern EFI_GUID gEfiVT100PlusGuid; 147 extern EFI_GUID gEfiVTUTF8Guid; 148 149 extern EFI_GUID NullGuid; 150 extern EFI_GUID UnknownDevice; 151 152 extern EFI_GUID EfiPartTypeSystemPartitionGuid; 153 extern EFI_GUID EfiPartTypeLegacyMbrGuid; 154 155 extern EFI_GUID MpsTableGuid; 156 extern EFI_GUID AcpiTableGuid; 157 extern EFI_GUID SMBIOSTableGuid; 158 extern EFI_GUID SMBIOS3TableGuid; 159 extern EFI_GUID SalSystemTableGuid; 160 extern EFI_GUID EfiDtbTableGuid; 161 162 extern EFI_GUID SimplePointerProtocol; 163 extern EFI_GUID AbsolutePointerProtocol; 164 165 extern EFI_GUID gEfiDebugImageInfoTableGuid; 166 extern EFI_GUID gEfiDebugSupportProtocolGuid; 167 168 extern EFI_GUID SimpleTextInputExProtocol; 169 170 extern EFI_GUID ShellProtocolGuid; 171 extern EFI_GUID ShellParametersProtocolGuid; 172 extern EFI_GUID ShellDynamicCommandProtocolGuid; 173 174 // 175 // EFI Variable strings 176 // 177 #define LOAD_OPTION_ACTIVE 0x00000001 178 179 #define VarLanguageCodes L"LangCodes" 180 #define VarLanguage L"Lang" 181 #define VarTimeout L"Timeout" 182 #define VarConsoleInp L"ConIn" 183 #define VarConsoleOut L"ConOut" 184 #define VarErrorOut L"ErrOut" 185 #define VarBootOption L"Boot%04x" 186 #define VarBootOrder L"BootOrder" 187 #define VarBootNext L"BootNext" 188 #define VarBootCurrent L"BootCurrent" 189 #define VarDriverOption L"Driver%04x" 190 #define VarDriverOrder L"DriverOrder" 191 #define VarConsoleInpDev L"ConInDev" 192 #define VarConsoleOutDev L"ConOutDev" 193 #define VarErrorOutDev L"ErrOutDev" 194 195 #define LanguageCodeEnglish "eng" 196 197 extern EFI_DEVICE_PATH RootDevicePath[]; 198 extern EFI_DEVICE_PATH EndDevicePath[]; 199 extern EFI_DEVICE_PATH EndInstanceDevicePath[]; 200 201 // 202 // Other public data in the EFI library 203 // 204 205 extern EFI_MEMORY_TYPE PoolAllocationType; 206 207 // 208 // STATIC - Name is internal to the module 209 // INTERNAL - Name is internal to the component (i.e., directory) 210 // BOOTSERVCE - Name of a boot service function 211 // 212 213 #define STATIC 214 #define INTERNAL 215 #define BOOTSERVICE 216 217 // 218 // Prototypes 219 // 220 221 VOID 222 InitializeLib ( 223 IN EFI_HANDLE ImageHandle, 224 IN EFI_SYSTEM_TABLE *SystemTable 225 ); 226 227 VOID 228 InitializeUnicodeSupport ( 229 CHAR8 *LangCode 230 ); 231 232 VOID 233 EFIDebugVariable ( 234 VOID 235 ); 236 237 VOID 238 Exit( 239 IN EFI_STATUS ExitStatus, 240 IN UINTN ExitDataSize, 241 IN CHAR16 *ExitData OPTIONAL 242 ); 243 244 INTN 245 GetShellArgcArgv( 246 EFI_HANDLE ImageHandle, 247 CHAR16 **Argv[] /* Statically allocated */ 248 ); 249 250 VOID 251 SetCrc ( 252 IN OUT EFI_TABLE_HEADER *Hdr 253 ); 254 255 VOID 256 SetCrcAltSize ( 257 IN UINTN Size, 258 IN OUT EFI_TABLE_HEADER *Hdr 259 ); 260 261 BOOLEAN 262 CheckCrc ( 263 IN UINTN MaxSize, 264 IN OUT EFI_TABLE_HEADER *Hdr 265 ); 266 267 BOOLEAN 268 CheckCrcAltSize ( 269 IN UINTN MaxSize, 270 IN UINTN Size, 271 IN OUT EFI_TABLE_HEADER *Hdr 272 ); 273 274 UINT32 275 CalculateCrc ( 276 UINT8 *pt, 277 UINTN Size 278 ); 279 280 VOID 281 ZeroMem ( 282 IN VOID *Buffer, 283 IN UINTN Size 284 ); 285 286 VOID 287 SetMem ( 288 IN VOID *Buffer, 289 IN UINTN Size, 290 IN UINT8 Value 291 ); 292 293 VOID 294 CopyMem ( 295 IN VOID *Dest, 296 IN CONST VOID *Src, 297 IN UINTN len 298 ); 299 300 INTN 301 CompareMem ( 302 IN CONST VOID *Dest, 303 IN CONST VOID *Src, 304 IN UINTN len 305 ); 306 307 INTN 308 StrCmp ( 309 IN CONST CHAR16 *s1, 310 IN CONST CHAR16 *s2 311 ); 312 313 INTN 314 StrnCmp ( 315 IN CONST CHAR16 *s1, 316 IN CONST CHAR16 *s2, 317 IN UINTN len 318 ); 319 320 INTN 321 StriCmp ( 322 IN CONST CHAR16 *s1, 323 IN CONST CHAR16 *s2 324 ); 325 326 VOID 327 StrLwr ( 328 IN CHAR16 *Str 329 ); 330 331 VOID 332 StrUpr ( 333 IN CHAR16 *Str 334 ); 335 336 VOID 337 StrCpy ( 338 IN CHAR16 *Dest, 339 IN CONST CHAR16 *Src 340 ); 341 342 VOID 343 StrnCpy ( 344 IN CHAR16 *Dest, 345 IN CONST CHAR16 *Src, 346 IN UINTN Len 347 ); 348 349 CHAR16 * 350 StpCpy ( 351 IN CHAR16 *Dest, 352 IN CONST CHAR16 *Src 353 ); 354 355 CHAR16 * 356 StpnCpy ( 357 IN CHAR16 *Dest, 358 IN CONST CHAR16 *Src, 359 IN UINTN Len 360 ); 361 362 VOID 363 StrCat ( 364 IN CHAR16 *Dest, 365 IN CONST CHAR16 *Src 366 ); 367 368 VOID 369 StrnCat ( 370 IN CHAR16 *Dest, 371 IN CONST CHAR16 *Src, 372 IN UINTN Len 373 ); 374 375 UINTN 376 StrLen ( 377 IN CONST CHAR16 *s1 378 ); 379 380 UINTN 381 StrnLen ( 382 IN CONST CHAR16 *s1, 383 IN UINTN Len 384 ); 385 386 UINTN 387 StrSize ( 388 IN CONST CHAR16 *s1 389 ); 390 391 CHAR16 * 392 StrDuplicate ( 393 IN CONST CHAR16 *Src 394 ); 395 396 UINTN 397 strlena ( 398 IN CONST CHAR8 *s1 399 ); 400 401 UINTN 402 strcmpa ( 403 IN CONST CHAR8 *s1, 404 IN CONST CHAR8 *s2 405 ); 406 407 UINTN 408 strncmpa ( 409 IN CONST CHAR8 *s1, 410 IN CONST CHAR8 *s2, 411 IN UINTN len 412 ); 413 414 UINTN 415 xtoi ( 416 CONST CHAR16 *str 417 ); 418 419 UINTN 420 Atoi ( 421 CONST CHAR16 *str 422 ); 423 424 BOOLEAN 425 MetaMatch ( 426 IN CHAR16 *String, 427 IN CHAR16 *Pattern 428 ); 429 430 BOOLEAN 431 MetaiMatch ( 432 IN CHAR16 *String, 433 IN CHAR16 *Pattern 434 ); 435 436 UINT64 437 LShiftU64 ( 438 IN UINT64 Operand, 439 IN UINTN Count 440 ); 441 442 UINT64 443 RShiftU64 ( 444 IN UINT64 Operand, 445 IN UINTN Count 446 ); 447 448 UINT64 449 MultU64x32 ( 450 IN UINT64 Multiplicand, 451 IN UINTN Multiplier 452 ); 453 454 UINT64 455 DivU64x32 ( 456 IN UINT64 Dividend, 457 IN UINTN Divisor, 458 OUT UINTN *Remainder OPTIONAL 459 ); 460 461 VOID 462 InitializeLock ( 463 IN OUT FLOCK *Lock, 464 IN EFI_TPL Priority 465 ); 466 467 VOID 468 AcquireLock ( 469 IN FLOCK *Lock 470 ); 471 472 VOID 473 ReleaseLock ( 474 IN FLOCK *Lock 475 ); 476 477 478 INTN 479 CompareGuid( 480 IN EFI_GUID *Guid1, 481 IN EFI_GUID *Guid2 482 ); 483 484 VOID * 485 AllocatePool ( 486 IN UINTN Size 487 ); 488 489 VOID * 490 AllocateZeroPool ( 491 IN UINTN Size 492 ); 493 494 VOID * 495 ReallocatePool ( 496 IN VOID *OldPool, 497 IN UINTN OldSize, 498 IN UINTN NewSize 499 ); 500 501 VOID 502 FreePool ( 503 IN VOID *p 504 ); 505 506 507 VOID 508 Output ( 509 IN CHAR16 *Str 510 ); 511 512 VOID 513 Input ( 514 IN CHAR16 *Prompt OPTIONAL, 515 OUT CHAR16 *InStr, 516 IN UINTN StrLen 517 ); 518 519 VOID 520 IInput ( 521 IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut, 522 IN SIMPLE_INPUT_INTERFACE *ConIn, 523 IN CHAR16 *Prompt OPTIONAL, 524 OUT CHAR16 *InStr, 525 IN UINTN StrLen 526 ); 527 528 UINTN 529 Print ( 530 IN CONST CHAR16 *fmt, 531 ... 532 ); 533 534 UINTN 535 VPrint ( 536 IN CONST CHAR16 *fmt, 537 va_list args 538 ); 539 540 UINTN 541 UnicodeSPrint ( 542 OUT CHAR16 *Str, 543 IN UINTN StrSize, 544 IN CONST CHAR16 *fmt, 545 ... 546 ); 547 548 UINTN 549 UnicodeVSPrint ( 550 OUT CHAR16 *Str, 551 IN UINTN StrSize, 552 IN CONST CHAR16 *fmt, 553 va_list args 554 ); 555 556 CHAR16 * 557 VPoolPrint ( 558 IN CONST CHAR16 *fmt, 559 va_list args 560 ); 561 562 CHAR16 * 563 PoolPrint ( 564 IN CONST CHAR16 *fmt, 565 ... 566 ); 567 568 typedef struct { 569 CHAR16 *str; 570 UINTN len; 571 UINTN maxlen; 572 } POOL_PRINT; 573 574 CHAR16 * 575 CatPrint ( 576 IN OUT POOL_PRINT *Str, 577 IN CONST CHAR16 *fmt, 578 ... 579 ); 580 581 UINTN 582 PrintAt ( 583 IN UINTN Column, 584 IN UINTN Row, 585 IN CONST CHAR16 *fmt, 586 ... 587 ); 588 589 UINTN 590 IPrint ( 591 IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, 592 IN CONST CHAR16 *fmt, 593 ... 594 ); 595 596 UINTN 597 IPrintAt ( 598 IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, 599 IN UINTN Column, 600 IN UINTN Row, 601 IN CONST CHAR16 *fmt, 602 ... 603 ); 604 605 UINTN 606 AsciiPrint ( 607 IN CONST CHAR8 *fmt, 608 ... 609 ); 610 611 UINTN 612 AsciiVSPrint( 613 OUT CHAR8 *Str, 614 IN UINTN StrSize, 615 IN CONST CHAR8 *fmt, 616 va_list args 617 ); 618 619 // 620 // For compatibility with previous gnu-efi versions 621 // 622 #define SPrint UnicodeSPrint 623 #define VSPrint UnicodeVSPrint 624 #define APrint AsciiPrint 625 626 VOID 627 ValueToHex ( 628 IN CHAR16 *Buffer, 629 IN UINT64 v 630 ); 631 632 VOID 633 ValueToString ( 634 IN CHAR16 *Buffer, 635 IN BOOLEAN Comma, 636 IN INT64 v 637 ); 638 639 VOID 640 FloatToString ( 641 IN CHAR16 *Buffer, 642 IN BOOLEAN Comma, 643 IN double v 644 ); 645 646 VOID 647 TimeToString ( 648 OUT CHAR16 *Buffer, 649 IN EFI_TIME *Time 650 ); 651 652 VOID 653 GuidToString ( 654 OUT CHAR16 *Buffer, 655 IN EFI_GUID *Guid 656 ); 657 658 VOID 659 StatusToString ( 660 OUT CHAR16 *Buffer, 661 EFI_STATUS Status 662 ); 663 664 VOID 665 DumpHex ( 666 IN UINTN Indent, 667 IN UINTN Offset, 668 IN UINTN DataSize, 669 IN VOID *UserData 670 ); 671 672 BOOLEAN 673 GrowBuffer( 674 IN OUT EFI_STATUS *Status, 675 IN OUT VOID **Buffer, 676 IN UINTN BufferSize 677 ); 678 679 EFI_MEMORY_DESCRIPTOR * 680 LibMemoryMap ( 681 OUT UINTN *NoEntries, 682 OUT UINTN *MapKey, 683 OUT UINTN *DescriptorSize, 684 OUT UINT32 *DescriptorVersion 685 ); 686 687 VOID * 688 LibGetVariable ( 689 IN CHAR16 *Name, 690 IN EFI_GUID *VendorGuid 691 ); 692 693 VOID * 694 LibGetVariableAndSize ( 695 IN CHAR16 *Name, 696 IN EFI_GUID *VendorGuid, 697 OUT UINTN *VarSize 698 ); 699 700 EFI_STATUS 701 LibDeleteVariable ( 702 IN CHAR16 *VarName, 703 IN EFI_GUID *VarGuid 704 ); 705 706 EFI_STATUS 707 LibSetNVVariable ( 708 IN CHAR16 *VarName, 709 IN EFI_GUID *VarGuid, 710 IN UINTN DataSize, 711 IN VOID *Data 712 ); 713 714 EFI_STATUS 715 LibSetVariable ( 716 IN CHAR16 *VarName, 717 IN EFI_GUID *VarGuid, 718 IN UINTN DataSize, 719 IN VOID *Data 720 ); 721 EFI_STATUS 722 LibInsertToTailOfBootOrder ( 723 IN UINT16 BootOption, 724 IN BOOLEAN OnlyInsertIfEmpty 725 ); 726 727 EFI_STATUS 728 LibLocateProtocol ( 729 IN EFI_GUID *ProtocolGuid, 730 OUT VOID **Interface 731 ); 732 733 EFI_STATUS 734 LibLocateHandle ( 735 IN EFI_LOCATE_SEARCH_TYPE SearchType, 736 IN EFI_GUID *Protocol OPTIONAL, 737 IN VOID *SearchKey OPTIONAL, 738 IN OUT UINTN *NoHandles, 739 OUT EFI_HANDLE **Buffer 740 ); 741 742 EFI_STATUS 743 LibLocateHandleByDiskSignature ( 744 IN UINT8 MBRType, 745 IN UINT8 SignatureType, 746 IN VOID *Signature, 747 IN OUT UINTN *NoHandles, 748 OUT EFI_HANDLE **Buffer 749 ); 750 751 EFI_STATUS 752 LibInstallProtocolInterfaces ( 753 IN OUT EFI_HANDLE *Handle, 754 ... 755 ); 756 757 VOID 758 LibUninstallProtocolInterfaces ( 759 IN EFI_HANDLE Handle, 760 ... 761 ); 762 763 EFI_STATUS 764 LibReinstallProtocolInterfaces ( 765 IN OUT EFI_HANDLE *Handle, 766 ... 767 ); 768 769 EFI_EVENT 770 LibCreateProtocolNotifyEvent ( 771 IN EFI_GUID *ProtocolGuid, 772 IN EFI_TPL NotifyTpl, 773 IN EFI_EVENT_NOTIFY NotifyFunction, 774 IN VOID *NotifyContext, 775 OUT VOID *Registration 776 ); 777 778 EFI_STATUS 779 WaitForSingleEvent ( 780 IN EFI_EVENT Event, 781 IN UINT64 Timeout OPTIONAL 782 ); 783 784 VOID 785 WaitForEventWithTimeout ( 786 IN EFI_EVENT Event, 787 IN UINTN Timeout, 788 IN UINTN Row, 789 IN UINTN Column, 790 IN CHAR16 *String, 791 IN EFI_INPUT_KEY TimeoutKey, 792 OUT EFI_INPUT_KEY *Key 793 ); 794 795 EFI_FILE_HANDLE 796 LibOpenRoot ( 797 IN EFI_HANDLE DeviceHandle 798 ); 799 800 EFI_FILE_INFO * 801 LibFileInfo ( 802 IN EFI_FILE_HANDLE FHand 803 ); 804 805 EFI_FILE_SYSTEM_INFO * 806 LibFileSystemInfo ( 807 IN EFI_FILE_HANDLE FHand 808 ); 809 810 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO * 811 LibFileSystemVolumeLabelInfo ( 812 IN EFI_FILE_HANDLE FHand 813 ); 814 815 BOOLEAN 816 ValidMBR( 817 IN MASTER_BOOT_RECORD *Mbr, 818 IN EFI_BLOCK_IO *BlkIo 819 ); 820 821 BOOLEAN 822 LibMatchDevicePaths ( 823 IN EFI_DEVICE_PATH *Multi, 824 IN EFI_DEVICE_PATH *Single 825 ); 826 827 EFI_DEVICE_PATH * 828 LibDuplicateDevicePathInstance ( 829 IN EFI_DEVICE_PATH *DevPath 830 ); 831 832 EFI_DEVICE_PATH * 833 DevicePathFromHandle ( 834 IN EFI_HANDLE Handle 835 ); 836 837 EFI_DEVICE_PATH * 838 DevicePathInstance ( 839 IN OUT EFI_DEVICE_PATH **DevicePath, 840 OUT UINTN *Size 841 ); 842 843 UINTN 844 DevicePathInstanceCount ( 845 IN EFI_DEVICE_PATH *DevicePath 846 ); 847 848 EFI_DEVICE_PATH * 849 AppendDevicePath ( 850 IN EFI_DEVICE_PATH *Src1, 851 IN EFI_DEVICE_PATH *Src2 852 ); 853 854 EFI_DEVICE_PATH * 855 AppendDevicePathNode ( 856 IN EFI_DEVICE_PATH *Src1, 857 IN EFI_DEVICE_PATH *Src2 858 ); 859 860 EFI_DEVICE_PATH* 861 AppendDevicePathInstance ( 862 IN EFI_DEVICE_PATH *Src, 863 IN EFI_DEVICE_PATH *Instance 864 ); 865 866 EFI_DEVICE_PATH * 867 FileDevicePath ( 868 IN EFI_HANDLE Device OPTIONAL, 869 IN CHAR16 *FileName 870 ); 871 872 UINTN 873 DevicePathSize ( 874 IN EFI_DEVICE_PATH *DevPath 875 ); 876 877 EFI_DEVICE_PATH * 878 DuplicateDevicePath ( 879 IN EFI_DEVICE_PATH *DevPath 880 ); 881 882 EFI_DEVICE_PATH * 883 UnpackDevicePath ( 884 IN EFI_DEVICE_PATH *DevPath 885 ); 886 887 EFI_STATUS 888 LibDevicePathToInterface ( 889 IN EFI_GUID *Protocol, 890 IN EFI_DEVICE_PATH *FilePath, 891 OUT VOID **Interface 892 ); 893 894 CHAR16 * 895 DevicePathToStr ( 896 EFI_DEVICE_PATH *DevPath 897 ); 898 899 // 900 // BugBug: I need my own include files 901 // 902 typedef struct { 903 UINT8 Register; 904 UINT8 Function; 905 UINT8 Device; 906 UINT8 Bus; 907 UINT32 Reserved; 908 } EFI_ADDRESS; 909 910 typedef union { 911 UINT64 Address; 912 EFI_ADDRESS EfiAddress; 913 } EFI_PCI_ADDRESS_UNION; 914 915 916 EFI_STATUS 917 PciFindDeviceClass ( 918 IN OUT EFI_PCI_ADDRESS_UNION *Address, 919 IN UINT8 BaseClass, 920 IN UINT8 SubClass 921 ); 922 923 EFI_STATUS 924 PciFindDevice ( 925 IN OUT EFI_PCI_ADDRESS_UNION *DeviceAddress, 926 IN UINT16 VendorId, 927 IN UINT16 DeviceId, 928 IN OUT PCI_TYPE00 *Pci 929 ); 930 931 // 932 // SIMPLE_READ_FILE object used to access files 933 // 934 935 typedef VOID *SIMPLE_READ_FILE; 936 937 EFI_STATUS 938 OpenSimpleReadFile ( 939 IN BOOLEAN BootPolicy, 940 IN VOID *SourceBuffer OPTIONAL, 941 IN UINTN SourceSize, 942 IN OUT EFI_DEVICE_PATH **FilePath, 943 OUT EFI_HANDLE *DeviceHandle, 944 OUT SIMPLE_READ_FILE *SimpleReadHandle 945 ); 946 947 EFI_STATUS 948 ReadSimpleReadFile ( 949 IN SIMPLE_READ_FILE SimpleReadHandle, 950 IN UINTN Offset, 951 IN OUT UINTN *ReadSize, 952 OUT VOID *Buffer 953 ); 954 955 956 VOID 957 CloseSimpleReadFile ( 958 IN SIMPLE_READ_FILE SimpleReadHandle 959 ); 960 961 VOID 962 InitializeGuid ( 963 VOID 964 ); 965 966 UINT8 967 DecimaltoBCD( 968 IN UINT8 DecValue 969 ); 970 971 UINT8 972 BCDtoDecimal( 973 IN UINT8 BcdValue 974 ); 975 976 EFI_STATUS 977 LibGetSystemConfigurationTable( 978 IN EFI_GUID *TableGuid, 979 IN OUT VOID **Table 980 ); 981 982 BOOLEAN 983 LibIsValidTextGraphics ( 984 IN CHAR16 Graphic, 985 OUT CHAR8 *PcAnsi, OPTIONAL 986 OUT CHAR8 *Ascii OPTIONAL 987 ); 988 989 BOOLEAN 990 IsValidAscii ( 991 IN CHAR16 Ascii 992 ); 993 994 BOOLEAN 995 IsValidEfiCntlChar ( 996 IN CHAR16 c 997 ); 998 999 CHAR16 * 1000 LibGetUiString ( 1001 IN EFI_HANDLE Handle, 1002 IN UI_STRING_TYPE StringType, 1003 IN ISO_639_2 *LangCode, 1004 IN BOOLEAN ReturnDevicePathStrOnMismatch 1005 ); 1006 1007 CHAR8* 1008 LibGetSmbiosString ( 1009 IN SMBIOS_STRUCTURE_POINTER *Smbios, 1010 IN UINT16 StringNumber 1011 ); 1012 1013 EFI_STATUS 1014 LibGetSmbiosSystemGuidAndSerialNumber ( 1015 IN EFI_GUID *SystemGuid, 1016 OUT CHAR8 **SystemSerialNumber 1017 ); 1018 1019 1020 EFI_STATUS 1021 InitializeGlobalIoDevice ( 1022 IN EFI_DEVICE_PATH *DevicePath, 1023 IN EFI_GUID *Protocol, 1024 IN CHAR8 *ErrorStr, 1025 OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs 1026 ); 1027 1028 UINT32 1029 ReadPort ( 1030 IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, 1031 IN EFI_IO_WIDTH Width, 1032 IN UINTN Port 1033 ); 1034 1035 UINT32 1036 WritePort ( 1037 IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, 1038 IN EFI_IO_WIDTH Width, 1039 IN UINTN Port, 1040 IN UINTN Data 1041 ); 1042 1043 UINT32 1044 ReadPciConfig ( 1045 IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, 1046 IN EFI_IO_WIDTH Width, 1047 IN UINTN Port 1048 ); 1049 1050 UINT32 1051 WritePciConfig ( 1052 IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, 1053 IN EFI_IO_WIDTH Width, 1054 IN UINTN Port, 1055 IN UINTN Data 1056 ); 1057 1058 VOID 1059 Pause ( 1060 VOID 1061 ); 1062 1063 extern EFI_DEVICE_IO_INTERFACE *GlobalIoFncs; 1064 1065 #define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte) 1066 #define inp(_Port) (UINT8)ReadPort(GlobalIoFncs, IO_UINT8, (UINTN)_Port) 1067 #define outpw(_Port, _DataByte) (UINT16)WritePort(GlobalIoFncs, IO_UINT16, (UINTN)_Port, (UINTN)_DataByte) 1068 #define inpw(_Port) (UINT16)ReadPort(GlobalIoFncs, IO_UINT16, (UINTN)_Port) 1069 #define outpd(_Port, _DataByte) (UINT32)WritePort(GlobalIoFncs, IO_UINT32, (UINTN)_Port, (UINTN)_DataByte) 1070 #define inpd(_Port) (UINT32)ReadPort(GlobalIoFncs, IO_UINT32, (UINTN)_Port) 1071 1072 #define writepci8(_Addr, _DataByte) (UINT8)WritePciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr, (UINTN)_DataByte) 1073 #define readpci8(_Addr) (UINT8)ReadPciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr) 1074 #define writepci16(_Addr, _DataByte) (UINT16)WritePciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr, (UINTN)_DataByte) 1075 #define readpci16(_Addr) (UINT16)ReadPciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr) 1076 #define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte) 1077 #define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr) 1078 1079 #define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode)) 1080 1081 #endif 1082