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