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