Subversion Repositories HelenOS

Rev

Rev 2726 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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