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