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