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