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