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