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