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