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