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