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