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