]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h
ef47929196f8b79a0a7ed0ba3370248f694124e2
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Include / EfiRuntimeLib.h
1 /*++
2
3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 EfiRuntimeLib.h
15
16 Abstract:
17
18 Light weight lib to support EFI drivers.
19
20 --*/
21
22 #ifndef _EFI_RUNTIME_LIB_H_
23 #define _EFI_RUNTIME_LIB_H_
24 #define MAX_FVB_COUNT 16
25 #include "EfiStatusCode.h"
26 #include "EfiCommonLib.h"
27
28 #include "LinkedList.h"
29 #include "GetImage.h"
30 #include "RtDevicePath.h"
31
32 #include EFI_GUID_DEFINITION (DxeServices)
33 #include EFI_GUID_DEFINITION (EventGroup)
34 #include EFI_GUID_DEFINITION (EventLegacyBios)
35 #include EFI_PROTOCOL_DEFINITION (CpuIo)
36 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
37 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)
38 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
39 #include EFI_PROTOCOL_DEFINITION (FvbExtension)
40 #include "ProcDep.h"
41
42 typedef struct {
43 EFI_HANDLE Handle;
44 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
45 EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
46 } FVB_ENTRY;
47
48 //
49 // Driver Lib Globals.
50 //
51 extern EFI_BOOT_SERVICES *gBS;
52 extern EFI_SYSTEM_TABLE *gST;
53 extern EFI_DXE_SERVICES *gDS;
54 extern UINTN gRtErrorLevel;
55 extern FVB_ENTRY *mFvbEntry;
56
57 #if defined(__GNUC__) && defined(ECP_CPU_IPF)
58
59 VOID
60 EFIAPI
61 EcpEfiBreakPoint (
62 VOID
63 )
64 /*++
65
66 Routine Description:
67
68 Generates a breakpoint on the CPU.
69
70 Generates a breakpoint on the CPU. The breakpoint must be implemented such
71 that code can resume normal execution after the breakpoint.
72
73 Arguments:
74
75 VOID
76
77 Returns:
78
79 VOID
80
81 --*/
82 ;
83
84 VOID
85 EFIAPI
86 EcpMemoryFence (
87 VOID
88 )
89 /*++
90
91 Routine Description:
92
93 Used to serialize load and store operations.
94
95 All loads and stores that proceed calls to this function are guaranteed to be
96 globally visible when this function returns.
97
98 Arguments:
99
100 VOID
101
102 Returns:
103
104 VOID
105
106 --*/
107 ;
108
109 #endif
110
111 VOID
112 EFIAPI
113 EfiRuntimeLibFvbVirtualNotifyEvent (
114 IN EFI_EVENT Event,
115 IN VOID *Context
116 )
117 /*++
118
119 Routine Description:
120
121 Notify function to convert pointers to Fvb functions after ExitBootServices
122
123 Arguments:
124
125 Event - Event whose notification function is being invoked.
126 Context - Pointer to the notification function's context, which is
127 implementation-dependent.
128
129 Returns:
130
131 None
132
133 --*/
134 ;
135
136 EFI_STATUS
137 EfiInitializeRuntimeDriverLib (
138 IN EFI_HANDLE ImageHandle,
139 IN EFI_SYSTEM_TABLE *SystemTable,
140 IN EFI_EVENT_NOTIFY RuntimeNotifyEventHandler
141 )
142 /*++
143
144 Routine Description:
145
146 Intialize Runtime Driver Lib if it has not yet been initialized.
147
148 Arguments:
149
150 ImageHandle - The firmware allocated handle for the EFI image.
151
152 SystemTable - A pointer to the EFI System Table.
153
154 RuntimeNotifyEventHandler - Virtual address change notification event
155
156 Returns:
157
158 EFI_STATUS always returns EFI_SUCCESS
159
160 --*/
161 ;
162
163 EFI_STATUS
164 EfiShutdownRuntimeDriverLib (
165 VOID
166 )
167 /*++
168
169 Routine Description:
170
171 This routine will free some resources which have been allocated in
172 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
173 it must call this routine to free the allocated resource before the exiting.
174
175 Arguments:
176
177 None
178
179 Returns:
180
181 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
182 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
183
184 --*/
185 ;
186
187 EFI_STATUS
188 EfiInitializeSmmDriverLib (
189 IN EFI_HANDLE ImageHandle,
190 IN EFI_SYSTEM_TABLE *SystemTable
191 )
192 /*++
193
194 Routine Description:
195
196 Intialize Smm Driver Lib if it has not yet been initialized.
197
198 Arguments:
199
200 ImageHandle - The firmware allocated handle for the EFI image.
201
202 SystemTable - A pointer to the EFI System Table.
203
204 Returns:
205
206 EFI_STATUS always returns EFI_SUCCESS
207
208 --*/
209 ;
210
211 EFI_STATUS
212 EfiLibGetSystemConfigurationTable (
213 IN EFI_GUID *TableGuid,
214 IN OUT VOID **Table
215 )
216 /*++
217
218 Routine Description:
219
220 Return the EFI 1.0 System Tabl entry with TableGuid
221
222 Arguments:
223
224 TableGuid - Name of entry to return in the system table
225 Table - Pointer in EFI system table associated with TableGuid
226
227 Returns:
228
229 EFI_SUCCESS - Table returned;
230 EFI_NOT_FOUND - TableGuid not in EFI system table
231
232 --*/
233 ;
234
235 BOOLEAN
236 EfiAtRuntime (
237 VOID
238 )
239 /*++
240
241 Routine Description:
242
243 Am I at runtime?
244
245 Arguments:
246
247 None
248
249 Returns:
250
251 TRUE - At runtime
252 FALSE - Not at runtime
253
254 --*/
255 ;
256
257 BOOLEAN
258 EfiGoneVirtual (
259 VOID
260 )
261 /*++
262
263 Routine Description:
264 Return TRUE if SetVirtualAddressMap () has been called
265
266 Arguments:
267 NONE
268
269 Returns:
270 TRUE - If SetVirtualAddressMap () has been called
271 FALSE - If SetVirtualAddressMap () has not been called
272
273 --*/
274 ;
275
276 EFI_STATUS
277 EfiLibGetSystemConfigurationTable (
278 IN EFI_GUID *TableGuid,
279 IN OUT VOID **Table
280 )
281 /*++
282
283
284
285 Routine Description:
286
287
288
289 Get table from configuration table by name
290
291
292
293 Arguments:
294
295
296
297 TableGuid - Table name to search
298
299
300
301 Table - Pointer to the table caller wants
302
303
304
305 Returns:
306
307
308
309 EFI_NOT_FOUND - Not found the table
310
311
312
313 EFI_SUCCESS - Found the table
314
315
316
317 --*/
318
319 ;
320
321 EFI_EVENT
322 RtEfiLibCreateProtocolNotifyEvent (
323 IN EFI_GUID *ProtocolGuid,
324 IN EFI_TPL NotifyTpl,
325 IN EFI_EVENT_NOTIFY NotifyFunction,
326 IN VOID *NotifyContext,
327 OUT VOID **Registration
328 )
329 /*++
330
331 Routine Description:
332
333 Create a protocol notification event and return it.
334
335 Arguments:
336
337 ProtocolGuid - Protocol to register notification event on.
338
339 NotifyTpl - Maximum TPL to single the NotifyFunction.
340
341 NotifyFunction - EFI notification routine.
342
343 NotifyContext - Context passed into Event when it is created.
344
345 Registration - Registration key returned from RegisterProtocolNotify().
346
347 Returns:
348
349 The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
350 is added to the system.
351
352 --*/
353 ;
354
355 //
356 // Lock.c
357 //
358 typedef struct {
359 EFI_TPL Tpl;
360 EFI_TPL OwnerTpl;
361 UINTN Lock;
362 } EFI_LOCK;
363
364 VOID
365 EfiInitializeLock (
366 IN OUT EFI_LOCK *Lock,
367 IN EFI_TPL Priority
368 )
369 /*++
370
371 Routine Description:
372
373 Initialize a basic mutual exclusion lock. Each lock
374 provides mutual exclusion access at it's task priority
375 level. Since there is no-premption (at any TPL) or
376 multiprocessor support, acquiring the lock only consists
377 of raising to the locks TPL.
378
379 Note on a check build ASSERT()s are used to ensure proper
380 lock usage.
381
382 Arguments:
383
384 Lock - The EFI_LOCK structure to initialize
385
386 Priority - The task priority level of the lock
387
388
389 Returns:
390
391 An initialized Efi Lock structure.
392
393 --*/
394 ;
395
396 //
397 // Macro to initialize the state of a lock when a lock variable is declared
398 //
399 #define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}
400
401
402 VOID
403 EfiAcquireLock (
404 IN EFI_LOCK *Lock
405 )
406 /*++
407
408 Routine Description:
409
410 Raising to the task priority level of the mutual exclusion
411 lock, and then acquires ownership of the lock.
412
413 Arguments:
414
415 Lock - The lock to acquire
416
417 Returns:
418
419 Lock owned
420
421 --*/
422 ;
423
424 EFI_STATUS
425 EfiAcquireLockOrFail (
426 IN EFI_LOCK *Lock
427 )
428 /*++
429
430 Routine Description:
431
432 Initialize a basic mutual exclusion lock. Each lock
433 provides mutual exclusion access at it's task priority
434 level. Since there is no-premption (at any TPL) or
435 multiprocessor support, acquiring the lock only consists
436 of raising to the locks TPL.
437
438 Arguments:
439
440 Lock - The EFI_LOCK structure to initialize
441
442 Returns:
443
444 EFI_SUCCESS - Lock Owned.
445 EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
446
447 --*/
448 ;
449
450 VOID
451 EfiReleaseLock (
452 IN EFI_LOCK *Lock
453 )
454 /*++
455
456 Routine Description:
457
458 Releases ownership of the mutual exclusion lock, and
459 restores the previous task priority level.
460
461 Arguments:
462
463 Lock - The lock to release
464
465 Returns:
466
467 None
468
469 --*/
470 ;
471
472 #define EfiCopyMem EfiCommonLibCopyMem
473 #define EfiSetMem EfiCommonLibSetMem
474 #define EfiZeroMem EfiCommonLibZeroMem
475
476 INTN
477 EfiCompareMem (
478 IN VOID *MemOne,
479 IN VOID *MemTwo,
480 IN UINTN Len
481 )
482 /*++
483
484 Routine Description:
485
486 Compares two memory buffers of a given length.
487
488 Arguments:
489
490 MemOne - First memory buffer
491
492 MemTwo - Second memory buffer
493
494 Len - Length of Mem1 and Mem2 memory regions to compare
495
496 Returns:
497
498 = 0 if MemOne == MemTwo
499
500 > 0 if MemOne > MemTwo
501
502 < 0 if MemOne < MemTwo
503
504 --*/
505 ;
506
507 //
508 // Debug.c init
509 //
510 EFI_STATUS
511 EfiDebugAssertInit (
512 VOID
513 )
514 /*++
515
516 Routine Description:
517
518 Locate Debug Assert Protocol and set as mDebugAssert
519
520 Arguments:
521
522 None
523
524 Returns:
525
526 Status code
527
528 --*/
529 ;
530
531 //
532 // Wrapper for EFI runtime functions
533 //
534 VOID
535 EfiResetSystem (
536 IN EFI_RESET_TYPE ResetType,
537 IN EFI_STATUS ResetStatus,
538 IN UINTN DataSize,
539 IN CHAR16 *ResetData
540 )
541 /*++
542
543 Routine Description:
544
545 Resets the entire platform.
546
547 Arguments:
548
549 ResetType - The type of reset to perform.
550 ResetStatus - The status code for the reset.
551 DataSize - The size, in bytes, of ResetData.
552 ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
553 followed by additional binary data.
554
555 Returns:
556
557 None
558
559 --*/
560 ;
561
562 EFI_STATUS
563 EfiGetNextHighMonotonicCount (
564 OUT UINT32 *HighCount
565 )
566 /*++
567
568 Routine Description:
569
570 Returns the next high 32 bits of the platform's monotonic counter.
571
572 Arguments:
573
574 HighCount - Pointer to returned value.
575
576 Returns:
577
578 Status code
579
580 --*/
581 ;
582
583 EFI_STATUS
584 EfiGetTime (
585 OUT EFI_TIME *Time,
586 OUT EFI_TIME_CAPABILITIES *Capabilities
587 )
588 /*++
589
590 Routine Description:
591
592 Returns the current time and date information, and the time-keeping
593 capabilities of the hardware platform.
594
595 Arguments:
596
597 Time - A pointer to storage to receive a snapshot of the current time.
598 Capabilities - An optional pointer to a buffer to receive the real time clock device's
599 capabilities.
600
601 Returns:
602
603 Status code
604
605 --*/
606 ;
607
608 EFI_STATUS
609 EfiSetTime (
610 OUT EFI_TIME *Time
611 )
612 /*++
613
614 Routine Description:
615
616 Sets the current local time and date information.
617
618 Arguments:
619
620 Time - A pointer to the current time.
621
622 Returns:
623
624 Status code
625
626 --*/
627 ;
628
629 EFI_STATUS
630 EfiGetWakeupTime (
631 OUT BOOLEAN *Enabled,
632 OUT BOOLEAN *Pending,
633 OUT EFI_TIME *Time
634 )
635 /*++
636
637 Routine Description:
638
639 Returns the current wakeup alarm clock setting.
640
641 Arguments:
642
643 Enabled - Indicates if the alarm is currently enabled or disabled.
644 Pending - Indicates if the alarm signal is pending and requires acknowledgement.
645 Time - The current alarm setting.
646
647 Returns:
648
649 Status code
650
651 --*/
652 ;
653
654 EFI_STATUS
655 EfiSetWakeupTime (
656 IN BOOLEAN Enable,
657 IN EFI_TIME *Time
658 )
659 /*++
660
661 Routine Description:
662
663 Sets the system wakeup alarm clock time.
664
665 Arguments:
666
667 Enable - Enable or disable the wakeup alarm.
668 Time - If Enable is TRUE, the time to set the wakeup alarm for.
669 If Enable is FALSE, then this parameter is optional, and may be NULL.
670
671 Returns:
672
673 Status code
674
675 --*/
676 ;
677
678 EFI_STATUS
679 EfiGetVariable (
680 IN CHAR16 *VariableName,
681 IN EFI_GUID * VendorGuid,
682 OUT UINT32 *Attributes OPTIONAL,
683 IN OUT UINTN *DataSize,
684 OUT VOID *Data
685 )
686 /*++
687
688 Routine Description:
689
690 Returns the value of a variable.
691
692 Arguments:
693
694 VariableName - A Null-terminated Unicode string that is the name of the
695 vendor's variable.
696 VendorGuid - A unique identifier for the vendor.
697 Attributes - If not NULL, a pointer to the memory location to return the
698 attributes bitmask for the variable.
699 DataSize - On input, the size in bytes of the return Data buffer.
700 On output the size of data returned in Data.
701 Data - The buffer to return the contents of the variable.
702
703 Returns:
704
705 Status code
706
707 --*/
708 ;
709
710 EFI_STATUS
711 EfiGetNextVariableName (
712 IN OUT UINTN *VariableNameSize,
713 IN OUT CHAR16 *VariableName,
714 IN OUT EFI_GUID *VendorGuid
715 )
716 /*++
717
718 Routine Description:
719
720 Enumerates the current variable names.
721
722 Arguments:
723
724 VariableNameSize - The size of the VariableName buffer.
725 VariableName - On input, supplies the last VariableName that was returned
726 by GetNextVariableName().
727 On output, returns the Nullterminated Unicode string of the
728 current variable.
729 VendorGuid - On input, supplies the last VendorGuid that was returned by
730 GetNextVariableName().
731 On output, returns the VendorGuid of the current variable.
732
733 Returns:
734
735 Status code
736
737 --*/
738 ;
739
740 EFI_STATUS
741 EfiSetVariable (
742 IN CHAR16 *VariableName,
743 IN EFI_GUID *VendorGuid,
744 IN UINT32 Attributes,
745 IN UINTN DataSize,
746 IN VOID *Data
747 )
748 /*++
749
750 Routine Description:
751
752 Sets the value of a variable.
753
754 Arguments:
755
756 VariableName - A Null-terminated Unicode string that is the name of the
757 vendor's variable.
758 VendorGuid - A unique identifier for the vendor.
759 Attributes - Attributes bitmask to set for the variable.
760 DataSize - The size in bytes of the Data buffer.
761 Data - The contents for the variable.
762
763 Returns:
764
765 Status code
766
767 --*/
768 ;
769
770 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
771
772 EFI_STATUS
773 EfiQueryVariableInfo (
774 IN UINT32 Attributes,
775 OUT UINT64 *MaximumVariableStorageSize,
776 OUT UINT64 *RemainingVariableStorageSize,
777 OUT UINT64 *MaximumVariableSize
778 )
779 /*++
780
781 Routine Description:
782
783 This code returns information about the EFI variables.
784
785 Arguments:
786
787 Attributes Attributes bitmask to specify the type of variables
788 on which to return information.
789 MaximumVariableStorageSize Pointer to the maximum size of the storage space available
790 for the EFI variables associated with the attributes specified.
791 RemainingVariableStorageSize Pointer to the remaining size of the storage space available
792 for the EFI variables associated with the attributes specified.
793 MaximumVariableSize Pointer to the maximum size of the individual EFI variables
794 associated with the attributes specified.
795
796 Returns:
797
798 Status code
799
800 --*/
801 ;
802 #endif
803
804
805 EFI_STATUS
806 EfiReportStatusCode (
807 IN EFI_STATUS_CODE_TYPE CodeType,
808 IN EFI_STATUS_CODE_VALUE Value,
809 IN UINT32 Instance,
810 IN EFI_GUID * CallerId,
811 IN EFI_STATUS_CODE_DATA * Data OPTIONAL
812 )
813 /*++
814
815 Routine Description:
816
817 Status Code reporter
818
819 Arguments:
820
821 CodeType - Type of Status Code.
822
823 Value - Value to output for Status Code.
824
825 Instance - Instance Number of this status code.
826
827 CallerId - ID of the caller of this status code.
828
829 Data - Optional data associated with this status code.
830
831 Returns:
832
833 Status code
834
835 --*/
836 ;
837
838 EFI_STATUS
839 EfiConvertPointer (
840 IN UINTN DebugDisposition,
841 IN OUT VOID *Address
842 )
843 /*++
844
845 Routine Description:
846
847 Determines the new virtual address that is to be used on subsequent memory accesses.
848
849 Arguments:
850
851 DebugDisposition - Supplies type information for the pointer being converted.
852 Address - A pointer to a pointer that is to be fixed to be the value needed
853 for the new virtual address mappings being applied.
854
855 Returns:
856
857 Status code
858
859 --*/
860 ;
861
862 EFI_STATUS
863 EfiConvertList (
864 IN UINTN DebugDisposition,
865 IN OUT EFI_LIST_ENTRY *ListHead
866 )
867 /*++
868
869 Routine Description:
870
871 Conver the standard Lib double linked list to a virtual mapping.
872
873 Arguments:
874
875 DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
876
877 ListHead - Head of linked list to convert
878
879 Returns:
880
881 EFI_SUCCESS
882
883 --*/
884 ;
885
886 //
887 // Base IO Class Functions
888 //
889 EFI_STATUS
890 EfiIoRead (
891 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
892 IN UINT64 Address,
893 IN UINTN Count,
894 IN OUT VOID *Buffer
895 )
896 /*++
897
898 Routine Description:
899 Perform an IO read into Buffer.
900
901 Arguments:
902 Width - Width of read transaction, and repeat operation to use
903 Address - IO address to read
904 Count - Number of times to read the IO address.
905 Buffer - Buffer to read data into. size is Width * Count
906
907 Returns:
908 Status code
909
910 --*/
911 ;
912
913 UINT8
914 IoRead8 (
915 IN UINT64 Address
916 )
917 /*++
918
919 Routine Description:
920 Do a one byte IO read
921
922 Arguments:
923 Address - IO address to read
924
925 Returns:
926 Data read
927
928 --*/
929 ;
930
931 UINT16
932 IoRead16 (
933 IN UINT64 Address
934 )
935 /*++
936
937 Routine Description:
938 Do a two byte IO read
939
940 Arguments:
941 Address - IO address to read
942
943 Returns:
944 Data read
945
946 --*/
947 ;
948
949 UINT32
950 IoRead32 (
951 IN UINT64 Address
952 )
953 /*++
954
955 Routine Description:
956 Do a four byte IO read
957
958 Arguments:
959 Address - IO address to read
960
961 Returns:
962 Data read
963
964 --*/
965 ;
966
967 EFI_STATUS
968 EfiIoWrite (
969 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
970 IN UINT64 Address,
971 IN UINTN Count,
972 IN OUT VOID *Buffer
973 )
974 /*++
975
976 Routine Description:
977 Perform an IO write into Buffer.
978
979 Arguments:
980 Width - Width of write transaction, and repeat operation to use
981 Address - IO address to write
982 Count - Number of times to write the IO address.
983 Buffer - Buffer to write data from. size is Width * Count
984
985 Returns:
986 Status code
987
988 --*/
989 ;
990
991 VOID
992 IoWrite8 (
993 IN UINT64 Address,
994 IN UINT8 Data
995 )
996 /*++
997
998 Routine Description:
999 Do a one byte IO write
1000
1001 Arguments:
1002 Address - IO address to write
1003 Data - Data to write to Address
1004
1005 Returns:
1006 NONE
1007
1008 --*/
1009 ;
1010
1011 VOID
1012 IoWrite16 (
1013 IN UINT64 Address,
1014 IN UINT16 Data
1015 )
1016 /*++
1017
1018 Routine Description:
1019 Do a two byte IO write
1020
1021 Arguments:
1022 Address - IO address to write
1023 Data - Data to write to Address
1024
1025 Returns:
1026 NONE
1027
1028 --*/
1029 ;
1030
1031 VOID
1032 IoWrite32 (
1033 IN UINT64 Address,
1034 IN UINT32 Data
1035 )
1036 /*++
1037
1038 Routine Description:
1039 Do a four byte IO write
1040
1041 Arguments:
1042 Address - IO address to write
1043 Data - Data to write to Address
1044
1045 Returns:
1046 NONE
1047
1048 --*/
1049 ;
1050
1051 EFI_STATUS
1052 EfiMemRead (
1053 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
1054 IN UINT64 Address,
1055 IN UINTN Count,
1056 IN OUT VOID *Buffer
1057 )
1058 /*++
1059
1060 Routine Description:
1061 Perform a Memory mapped IO read into Buffer.
1062
1063 Arguments:
1064 Width - Width of each read transaction.
1065 Address - Memory mapped IO address to read
1066 Count - Number of Width quanta to read
1067 Buffer - Buffer to read data into. size is Width * Count
1068
1069 Returns:
1070 Status code
1071
1072 --*/
1073 ;
1074
1075 UINT8
1076 MemRead8 (
1077 IN UINT64 Address
1078 )
1079 /*++
1080
1081 Routine Description:
1082 Do a one byte Memory mapped IO read
1083
1084 Arguments:
1085 Address - Memory mapped IO address to read
1086
1087 Returns:
1088 Data read
1089
1090 --*/
1091 ;
1092
1093 UINT16
1094 MemRead16 (
1095 IN UINT64 Address
1096 )
1097 /*++
1098
1099 Routine Description:
1100 Do a two byte Memory mapped IO read
1101
1102 Arguments:
1103 Address - Memory mapped IO address to read
1104
1105 Returns:
1106 Data read
1107
1108 --*/
1109 ;
1110
1111 UINT32
1112 MemRead32 (
1113 IN UINT64 Address
1114 )
1115 /*++
1116
1117 Routine Description:
1118 Do a four byte Memory mapped IO read
1119
1120 Arguments:
1121 Address - Memory mapped IO address to read
1122
1123 Returns:
1124 Data read
1125
1126 --*/
1127 ;
1128
1129 UINT64
1130 MemRead64 (
1131 IN UINT64 Address
1132 )
1133 /*++
1134
1135 Routine Description:
1136 Do a eight byte Memory mapped IO read
1137
1138 Arguments:
1139 Address - Memory mapped IO address to read
1140
1141 Returns:
1142 Data read
1143
1144 --*/
1145 ;
1146
1147 EFI_STATUS
1148 EfiMemWrite (
1149 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
1150 IN UINT64 Address,
1151 IN UINTN Count,
1152 IN OUT VOID *Buffer
1153 )
1154 /*++
1155
1156 Routine Description:
1157 Perform a memory mapped IO write into Buffer.
1158
1159 Arguments:
1160 Width - Width of write transaction, and repeat operation to use
1161 Address - IO address to write
1162 Count - Number of times to write the IO address.
1163 Buffer - Buffer to write data from. size is Width * Count
1164
1165 Returns:
1166 Status code
1167
1168 --*/
1169 ;
1170
1171 VOID
1172 MemWrite8 (
1173 IN UINT64 Address,
1174 IN UINT8 Data
1175 )
1176 /*++
1177
1178 Routine Description:
1179 Do a one byte Memory mapped IO write
1180
1181 Arguments:
1182 Address - Memory mapped IO address to write
1183 Data - Data to write to Address
1184
1185 Returns:
1186 NONE
1187
1188 --*/
1189 ;
1190
1191 VOID
1192 MemWrite16 (
1193 IN UINT64 Address,
1194 IN UINT16 Data
1195 )
1196 /*++
1197
1198 Routine Description:
1199 Do a two byte Memory mapped IO write
1200
1201 Arguments:
1202 Address - Memory mapped IO address to write
1203 Data - Data to write to Address
1204
1205 Returns:
1206 NONE
1207
1208 --*/
1209 ;
1210
1211 VOID
1212 MemWrite32 (
1213 IN UINT64 Address,
1214 IN UINT32 Data
1215 )
1216 /*++
1217
1218 Routine Description:
1219 Do a four byte Memory mapped IO write
1220
1221 Arguments:
1222 Address - Memory mapped IO address to write
1223 Data - Data to write to Address
1224
1225 Returns:
1226 NONE
1227
1228 --*/
1229 ;
1230
1231 VOID
1232 MemWrite64 (
1233 IN UINT64 Address,
1234 IN UINT64 Data
1235 )
1236 /*++
1237
1238 Routine Description:
1239 Do a eight byte Memory mapped IO write
1240
1241 Arguments:
1242 Address - Memory mapped IO address to write
1243 Data - Data to write to Address
1244
1245 Returns:
1246 NONE
1247
1248 --*/
1249 ;
1250
1251 //
1252 // Platform specific functions
1253 //
1254 UINT8
1255 PciRead8 (
1256 UINT8 Segment,
1257 UINT8 Bus,
1258 UINT8 DevFunc,
1259 UINT8 Register
1260 )
1261 /*++
1262
1263 Routine Description:
1264 Perform an one byte PCI config cycle read
1265
1266 Arguments:
1267 Segment - PCI Segment ACPI _SEG
1268 Bus - PCI Bus
1269 DevFunc - PCI Device(7:3) and Func(2:0)
1270 Register - PCI config space register
1271
1272 Returns:
1273 Data read from PCI config space
1274
1275 --*/
1276 ;
1277
1278 UINT16
1279 PciRead16 (
1280 UINT8 Segment,
1281 UINT8 Bus,
1282 UINT8 DevFunc,
1283 UINT8 Register
1284 )
1285 /*++
1286
1287 Routine Description:
1288 Perform an two byte PCI config cycle read
1289
1290 Arguments:
1291 Segment - PCI Segment ACPI _SEG
1292 Bus - PCI Bus
1293 DevFunc - PCI Device(7:3) and Func(2:0)
1294 Register - PCI config space register
1295
1296 Returns:
1297 Data read from PCI config space
1298
1299 --*/
1300 ;
1301
1302 UINT32
1303 PciRead32 (
1304 UINT8 Segment,
1305 UINT8 Bus,
1306 UINT8 DevFunc,
1307 UINT8 Register
1308 )
1309 /*++
1310
1311 Routine Description:
1312 Perform an four byte PCI config cycle read
1313
1314 Arguments:
1315 Segment - PCI Segment ACPI _SEG
1316 Bus - PCI Bus
1317 DevFunc - PCI Device(7:3) and Func(2:0)
1318 Register - PCI config space register
1319
1320 Returns:
1321 Data read from PCI config space
1322
1323 --*/
1324 ;
1325
1326 VOID
1327 PciWrite8 (
1328 UINT8 Segment,
1329 UINT8 Bus,
1330 UINT8 DevFunc,
1331 UINT8 Register,
1332 UINT8 Data
1333 )
1334 /*++
1335
1336 Routine Description:
1337 Perform an one byte PCI config cycle write
1338
1339 Arguments:
1340 Segment - PCI Segment ACPI _SEG
1341 Bus - PCI Bus
1342 DevFunc - PCI Device(7:3) and Func(2:0)
1343 Register - PCI config space register
1344 Data - Data to write
1345
1346 Returns:
1347 NONE
1348
1349 --*/
1350 ;
1351
1352 VOID
1353 PciWrite16 (
1354 UINT8 Segment,
1355 UINT8 Bus,
1356 UINT8 DevFunc,
1357 UINT8 Register,
1358 UINT16 Data
1359 )
1360 /*++
1361
1362 Routine Description:
1363 Perform an two byte PCI config cycle write
1364
1365 Arguments:
1366 Segment - PCI Segment ACPI _SEG
1367 Bus - PCI Bus
1368 DevFunc - PCI Device(7:3) and Func(2:0)
1369 Register - PCI config space register
1370 Data - Data to write
1371
1372 Returns:
1373 NONE
1374
1375 --*/
1376 ;
1377
1378 VOID
1379 PciWrite32 (
1380 UINT8 Segment,
1381 UINT8 Bus,
1382 UINT8 DevFunc,
1383 UINT8 Register,
1384 UINT32 Data
1385 )
1386 /*++
1387
1388 Routine Description:
1389 Perform an four byte PCI config cycle write
1390
1391 Arguments:
1392 Segment - PCI Segment ACPI _SEG
1393 Bus - PCI Bus
1394 DevFunc - PCI Device(7:3) and Func(2:0)
1395 Register - PCI config space register
1396 Data - Data to write
1397
1398 Returns:
1399 NONE
1400
1401 --*/
1402 ;
1403
1404 VOID
1405 EfiStall (
1406 IN UINTN Microseconds
1407 )
1408 /*++
1409
1410 Routine Description:
1411 Delay for at least the request number of microseconds
1412
1413 Arguments:
1414 Microseconds - Number of microseconds to delay.
1415
1416 Returns:
1417 NONE
1418
1419 --*/
1420 ;
1421
1422 //
1423 // FVB Services.
1424 //
1425 EFI_STATUS
1426 EfiFvbInitialize (
1427 VOID
1428 )
1429 /*++
1430
1431 Routine Description:
1432 Initialize globals and register Fvb Protocol notification function.
1433
1434 Arguments:
1435 None
1436
1437 Returns:
1438 EFI_SUCCESS
1439
1440 --*/
1441 ;
1442
1443 EFI_STATUS
1444 EfiFvbShutdown (
1445 VOID
1446 )
1447 /*++
1448
1449 Routine Description:
1450 Release resources allocated in EfiFvbInitialize.
1451
1452 Arguments:
1453 None
1454
1455 Returns:
1456 EFI_SUCCESS
1457
1458 --*/
1459 ;
1460
1461 EFI_STATUS
1462 EfiFvbReadBlock (
1463 IN UINTN Instance,
1464 IN EFI_LBA Lba,
1465 IN UINTN Offset,
1466 IN OUT UINTN *NumBytes,
1467 IN UINT8 *Buffer
1468 )
1469 /*++
1470
1471 Routine Description:
1472 Reads specified number of bytes into a buffer from the specified block
1473
1474 Arguments:
1475 Instance - The FV instance to be read from
1476 Lba - The logical block address to be read from
1477 Offset - Offset into the block at which to begin reading
1478 NumBytes - Pointer that on input contains the total size of
1479 the buffer. On output, it contains the total number
1480 of bytes read
1481 Buffer - Pointer to a caller allocated buffer that will be
1482 used to hold the data read
1483
1484 Returns:
1485 Status code
1486
1487 --*/
1488 ;
1489
1490 EFI_STATUS
1491 EfiFvbWriteBlock (
1492 IN UINTN Instance,
1493 IN EFI_LBA Lba,
1494 IN UINTN Offset,
1495 IN OUT UINTN *NumBytes,
1496 IN UINT8 *Buffer
1497 )
1498 /*++
1499
1500 Routine Description:
1501 Writes specified number of bytes from the input buffer to the block
1502
1503 Arguments:
1504 Instance - The FV instance to be written to
1505 Lba - The starting logical block index to write to
1506 Offset - Offset into the block at which to begin writing
1507 NumBytes - Pointer that on input contains the total size of
1508 the buffer. On output, it contains the total number
1509 of bytes actually written
1510 Buffer - Pointer to a caller allocated buffer that contains
1511 the source for the write
1512
1513 Returns:
1514 Status code
1515
1516 --*/
1517 ;
1518
1519 EFI_STATUS
1520 EfiFvbEraseBlock (
1521 IN UINTN Instance,
1522 IN EFI_LBA Lba
1523 )
1524 /*++
1525
1526 Routine Description:
1527 Erases and initializes a firmware volume block
1528
1529 Arguments:
1530 Instance - The FV instance to be erased
1531 Lba - The logical block index to be erased
1532
1533 Returns:
1534 Status code
1535
1536 --*/
1537 ;
1538
1539 EFI_STATUS
1540 EfiFvbGetVolumeAttributes (
1541 IN UINTN Instance,
1542 OUT EFI_FVB_ATTRIBUTES *Attributes
1543 )
1544 /*++
1545
1546 Routine Description:
1547 Retrieves attributes, insures positive polarity of attribute bits, returns
1548 resulting attributes in output parameter
1549
1550 Arguments:
1551 Instance - The FV instance whose attributes is going to be
1552 returned
1553 Attributes - Output buffer which contains attributes
1554
1555 Returns:
1556 Status code
1557
1558 --*/
1559 ;
1560
1561 EFI_STATUS
1562 EfiFvbSetVolumeAttributes (
1563 IN UINTN Instance,
1564 IN EFI_FVB_ATTRIBUTES Attributes
1565 )
1566 /*++
1567
1568 Routine Description:
1569 Modifies the current settings of the firmware volume according to the
1570 input parameter.
1571
1572 Arguments:
1573 Instance - The FV instance whose attributes is going to be
1574 modified
1575 Attributes - It is a pointer to EFI_FVB_ATTRIBUTES
1576 containing the desired firmware volume settings.
1577
1578 Returns:
1579 Status code
1580
1581 --*/
1582 ;
1583
1584 EFI_STATUS
1585 EfiFvbGetPhysicalAddress (
1586 IN UINTN Instance,
1587 OUT EFI_PHYSICAL_ADDRESS *Address
1588 )
1589 /*++
1590
1591 Routine Description:
1592 Retrieves the physical address of a memory mapped FV
1593
1594 Arguments:
1595 Instance - The FV instance whose base address is going to be
1596 returned
1597 Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
1598 that on successful return, contains the base address
1599 of the firmware volume.
1600
1601 Returns:
1602 Status code
1603
1604 --*/
1605 ;
1606
1607 EFI_STATUS
1608 EfiFvbGetBlockSize (
1609 IN UINTN Instance,
1610 IN EFI_LBA Lba,
1611 OUT UINTN *BlockSize,
1612 OUT UINTN *NumOfBlocks
1613 )
1614 /*++
1615
1616 Routine Description:
1617 Retrieve the size of a logical block
1618
1619 Arguments:
1620 Instance - The FV instance whose block size is going to be
1621 returned
1622 Lba - Indicates which block to return the size for.
1623 BlockSize - A pointer to a caller allocated UINTN in which
1624 the size of the block is returned
1625 NumOfBlocks - a pointer to a caller allocated UINTN in which the
1626 number of consecutive blocks starting with Lba is
1627 returned. All blocks in this range have a size of
1628 BlockSize
1629
1630 Returns:
1631 EFI_SUCCESS - The firmware volume was read successfully and
1632 contents are in Buffer
1633
1634 --*/
1635 ;
1636 EFI_STATUS
1637 EfiFvbEraseCustomBlockRange (
1638 IN UINTN Instance,
1639 IN EFI_LBA StartLba,
1640 IN UINTN OffsetStartLba,
1641 IN EFI_LBA LastLba,
1642 IN UINTN OffsetLastLba
1643 )
1644 /*++
1645
1646 Routine Description:
1647 Erases and initializes a specified range of a firmware volume
1648
1649 Arguments:
1650 Instance - The FV instance to be erased
1651 StartLba - The starting logical block index to be erased
1652 OffsetStartLba - Offset into the starting block at which to
1653 begin erasing
1654 LastLba - The last logical block index to be erased
1655 OffsetLastLba - Offset into the last block at which to end erasing
1656
1657 Returns:
1658 Status code
1659
1660 --*/
1661 ;
1662
1663 EFI_STATUS
1664 EfiCpuFlushCache (
1665 IN EFI_PHYSICAL_ADDRESS Start,
1666 IN UINT64 Length
1667 )
1668 /*++
1669
1670 Routine Description:
1671
1672 Flush cache with specified range.
1673
1674 Arguments:
1675
1676 Start - Start address
1677 Length - Length in bytes
1678
1679 Returns:
1680
1681 Status code
1682
1683 --*/
1684 ;
1685
1686 EFI_STATUS
1687 EFIAPI
1688 RtEfiCreateEventLegacyBoot (
1689 IN EFI_TPL NotifyTpl,
1690 IN EFI_EVENT_NOTIFY NotifyFunction,
1691 IN VOID *NotifyContext,
1692 OUT EFI_EVENT *LegacyBootEvent
1693 )
1694 /*++
1695
1696 Routine Description:
1697 Create a Legacy Boot Event.
1698 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
1699 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
1700 added and now it's possible to not voilate the UEFI specification by
1701 declaring a GUID for the legacy boot event class. This library supports
1702 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
1703 work both ways.
1704
1705 Arguments:
1706 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
1707
1708 Returns:
1709 EFI_SUCCESS Event was created.
1710 Other Event was not created.
1711
1712 --*/
1713 ;
1714
1715 EFI_STATUS
1716 EFIAPI
1717 RtEfiCreateEventReadyToBoot (
1718 IN EFI_TPL NotifyTpl,
1719 IN EFI_EVENT_NOTIFY NotifyFunction,
1720 IN VOID *NotifyContext,
1721 OUT EFI_EVENT *ReadyToBootEvent
1722 )
1723 /*++
1724
1725 Routine Description:
1726 Create a Read to Boot Event.
1727
1728 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
1729 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
1730 added and now it's possible to not voilate the UEFI specification and use
1731 the ready to boot event class defined in UEFI 2.0. This library supports
1732 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
1733 work both ways.
1734
1735 Arguments:
1736 ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
1737
1738 Return:
1739 EFI_SUCCESS - Event was created.
1740 Other - Event was not created.
1741
1742 --*/
1743 ;
1744
1745 #endif