]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / RuntimeDxe / EfiRuntimeLib / Ia32 / RuntimeLib.c
1 /*++
2
3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 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 RuntimeLib.c
15
16 Abstract:
17
18 Light weight lib to support Tiano drivers.
19
20 --*/
21
22 #include "Tiano.h"
23 #include "EfiRuntimeLib.h"
24 #include "PeiHob.h"
25 #include EFI_PROTOCOL_DEFINITION (CpuIo)
26 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
27 #include EFI_GUID_DEFINITION (StatusCodeCallerId)
28 #include EFI_GUID_DEFINITION (Hob)
29 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
30
31 //
32 // Driver Lib Module Globals
33 //
34 static EFI_RUNTIME_SERVICES *mRT;
35 static EFI_EVENT mRuntimeNotifyEvent = NULL;
36 static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
37 static BOOLEAN mRuntimeLibInitialized = FALSE;
38 static BOOLEAN mEfiGoneVirtual = FALSE;
39
40 //
41 // Runtime Global, but you should use the Lib functions
42 //
43 EFI_CPU_IO_PROTOCOL *gCpuIo;
44 BOOLEAN mEfiAtRuntime = FALSE;
45 FVB_ENTRY *mFvbEntry;
46
47 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
48
49 EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
50 EFI_EVENT gEfiStatusCodeNotifyEvent = NULL;
51
52 VOID
53 EFIAPI
54 OnStatusCodeInstall (
55 IN EFI_EVENT Event,
56 IN VOID *Context
57 )
58 {
59 EFI_STATUS Status;
60 EFI_STATUS_CODE_PROTOCOL *StatusCode;
61
62 Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
63 if (!EFI_ERROR (Status)) {
64 gReportStatusCode = StatusCode->ReportStatusCode;
65 }
66 }
67
68 EFI_STATUS
69 GetPeiProtocol (
70 IN EFI_GUID *ProtocolGuid,
71 IN VOID **Interface
72 )
73 /*++
74
75 Routine Description:
76
77 Searches for a Protocol Interface passed from PEI through a HOB
78
79 Arguments:
80
81 ProtocolGuid - The Protocol GUID to search for in the HOB List
82
83 Interface - A pointer to the interface for the Protocol GUID
84
85 Returns:
86
87 EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
88
89 EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
90
91 --*/
92 {
93 EFI_STATUS Status;
94 EFI_PEI_HOB_POINTERS GuidHob;
95
96 //
97 // Get Hob list
98 //
99 Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
100 if (EFI_ERROR (Status)) {
101 return Status;
102 }
103
104 for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
105 if (END_OF_HOB_LIST (GuidHob)) {
106 Status = EFI_NOT_FOUND;
107 break;
108 }
109
110 if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
111 if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
112 Status = EFI_SUCCESS;
113 *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
114 }
115 }
116
117 GuidHob.Raw = GET_NEXT_HOB (GuidHob);
118 }
119
120 return Status;
121 }
122
123 #endif
124
125 EFI_STATUS
126 EfiConvertPointer (
127 IN UINTN DebugDisposition,
128 IN OUT VOID *Address
129 )
130 /*++
131
132 Routine Description:
133
134 Determines the new virtual address that is to be used on subsequent memory accesses.
135
136 Arguments:
137
138 DebugDisposition - Supplies type information for the pointer being converted.
139 Address - A pointer to a pointer that is to be fixed to be the value needed
140 for the new virtual address mappings being applied.
141
142 Returns:
143
144 Status code
145
146 --*/
147 {
148 return mRT->ConvertPointer (DebugDisposition, Address);
149 }
150
151 EFI_STATUS
152 EfiConvertInternalPointer (
153 IN OUT VOID *Address
154 )
155 /*++
156
157 Routine Description:
158
159 Call EfiConvertPointer() to convert internal pointer.
160
161 Arguments:
162
163 Address - A pointer to a pointer that is to be fixed to be the value needed
164 for the new virtual address mappings being applied.
165
166 Returns:
167
168 Status code
169
170 --*/
171 {
172 return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);
173 }
174
175 VOID
176 EFIAPI
177 EfiRuntimeLibFvbVirtualNotifyEvent (
178 IN EFI_EVENT Event,
179 IN VOID *Context
180 )
181 /*++
182
183 Routine Description:
184
185 Convert all pointers in mFvbEntry after ExitBootServices.
186
187 Arguments:
188
189 Event - The Event that is being processed
190
191 Context - Event Context
192
193 Returns:
194
195 None
196
197 --*/
198 {
199 UINTN Index;
200 if (mFvbEntry != NULL) {
201 for (Index = 0; Index < MAX_FVB_COUNT; Index++) {
202 if (NULL != mFvbEntry[Index].Fvb) {
203 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);
204 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);
205 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);
206 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);
207 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);
208 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);
209 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);
210 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);
211 }
212
213 if (NULL != mFvbEntry[Index].FvbExtension) {
214 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);
215 EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);
216 }
217 }
218
219 EfiConvertInternalPointer ((VOID **) &mFvbEntry);
220 }
221 }
222
223 VOID
224 EFIAPI
225 RuntimeDriverExitBootServices (
226 IN EFI_EVENT Event,
227 IN VOID *Context
228 )
229 /*++
230
231 Routine Description:
232
233 Set AtRuntime flag as TRUE after ExitBootServices
234
235 Arguments:
236
237 Event - The Event that is being processed
238
239 Context - Event Context
240
241 Returns:
242
243 None
244
245 --*/
246 {
247 mEfiAtRuntime = TRUE;
248 }
249
250 extern BOOLEAN gEfiFvbInitialized;
251
252 VOID
253 EFIAPI
254 EfiRuntimeLibVirtualNotifyEvent (
255 IN EFI_EVENT Event,
256 IN VOID *Context
257 )
258 /*++
259
260 Routine Description:
261
262 Fixup internal data so that EFI can be call in virtual mode.
263 Call the passed in Child Notify event and convert any pointers in
264 lib to virtual mode.
265
266 Arguments:
267
268 Event - The Event that is being processed
269
270 Context - Event Context
271
272 Returns:
273
274 None
275
276 --*/
277 {
278 EFI_EVENT_NOTIFY ChildNotifyEventHandler;
279
280 if (Context != NULL) {
281 ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;
282 ChildNotifyEventHandler (Event, NULL);
283 }
284
285 if (gEfiFvbInitialized) {
286 EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);
287 }
288 //
289 // Update global for Runtime Services Table and IO
290 //
291 EfiConvertInternalPointer ((VOID **) &gCpuIo);
292 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
293 if (gReportStatusCode != NULL) {
294 EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
295 }
296 #endif
297 EfiConvertInternalPointer ((VOID **) &mRT);
298
299 //
300 // Clear out BootService globals
301 //
302 gBS = NULL;
303 gST = NULL;
304 mEfiGoneVirtual = TRUE;
305 }
306
307 EFI_STATUS
308 EfiInitializeRuntimeDriverLib (
309 IN EFI_HANDLE ImageHandle,
310 IN EFI_SYSTEM_TABLE *SystemTable,
311 IN EFI_EVENT_NOTIFY GoVirtualChildEvent
312 )
313 /*++
314
315 Routine Description:
316
317 Intialize runtime Driver Lib if it has not yet been initialized.
318
319 Arguments:
320
321 ImageHandle - The firmware allocated handle for the EFI image.
322
323 SystemTable - A pointer to the EFI System Table.
324
325 GoVirtualChildEvent - Caller can register a virtual notification event.
326
327 Returns:
328
329 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
330
331 --*/
332 {
333 EFI_STATUS Status;
334 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
335 VOID *Registration;
336 #endif
337
338 if (mRuntimeLibInitialized) {
339 return EFI_ALREADY_STARTED;
340 }
341
342 mRuntimeLibInitialized = TRUE;
343
344 gST = SystemTable;
345 ASSERT (gST != NULL);
346
347 gBS = SystemTable->BootServices;
348 ASSERT (gBS != NULL);
349 mRT = SystemTable->RuntimeServices;
350 ASSERT (mRT != NULL);
351
352 Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
353 ASSERT_EFI_ERROR (Status);
354
355 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
356 //
357 // Register EFI_STATUS_CODE_PROTOCOL notify function
358 //
359 Status = gBS->CreateEvent (
360 EFI_EVENT_NOTIFY_SIGNAL,
361 EFI_TPL_CALLBACK,
362 OnStatusCodeInstall,
363 NULL,
364 &gEfiStatusCodeNotifyEvent
365 );
366 ASSERT_EFI_ERROR (Status);
367
368 Status = gBS->RegisterProtocolNotify (
369 &gEfiStatusCodeRuntimeProtocolGuid,
370 gEfiStatusCodeNotifyEvent,
371 &Registration
372 );
373 ASSERT_EFI_ERROR (Status);
374
375 gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
376 #endif
377
378 Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
379 if (EFI_ERROR (Status)) {
380 gCpuIo = NULL;
381 }
382
383 //
384 // Register our ExitBootServices () notify function
385 //
386 Status = gBS->CreateEvent (
387 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
388 EFI_TPL_NOTIFY,
389 RuntimeDriverExitBootServices,
390 NULL,
391 &mRuntimeNotifyEvent
392 );
393 ASSERT_EFI_ERROR (Status);
394
395 //
396 // Register SetVirtualAddressMap () notify function
397 //
398 Status = gBS->CreateEvent (
399 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
400 EFI_TPL_NOTIFY,
401 EfiRuntimeLibVirtualNotifyEvent,
402 (VOID *) (UINTN) GoVirtualChildEvent,
403 &mEfiVirtualNotifyEvent
404 );
405 ASSERT_EFI_ERROR (Status);
406
407 return EFI_SUCCESS;
408 }
409
410 EFI_STATUS
411 EfiShutdownRuntimeDriverLib (
412 VOID
413 )
414 /*++
415
416 Routine Description:
417
418 This routine will free some resources which have been allocated in
419 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
420 it must call this routine to free the allocated resource before the exiting.
421
422 Arguments:
423
424 None
425
426 Returns:
427
428 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
429 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
430
431 --*/
432 {
433 EFI_STATUS Status;
434
435 if (!mRuntimeLibInitialized) {
436 //
437 // You must call EfiInitializeRuntimeDriverLib() first
438 //
439 return EFI_UNSUPPORTED;
440 }
441
442 mRuntimeLibInitialized = FALSE;
443
444 //
445 // Close our ExitBootServices () notify function
446 //
447 if (mRuntimeNotifyEvent != NULL) {
448 Status = gBS->CloseEvent (mRuntimeNotifyEvent);
449 ASSERT_EFI_ERROR (Status);
450 }
451
452 //
453 // Close SetVirtualAddressMap () notify function
454 //
455 if (mEfiVirtualNotifyEvent != NULL) {
456 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
457 ASSERT_EFI_ERROR (Status);
458 }
459
460 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
461 //
462 // Close EfiStatusCodeRuntimeProtocol notify function
463 //
464 if (gEfiStatusCodeNotifyEvent != NULL) {
465 Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
466 ASSERT_EFI_ERROR (Status);
467 }
468 #endif
469
470 return EFI_SUCCESS;
471 }
472
473 EFI_STATUS
474 EfiInitializeSmmDriverLib (
475 IN EFI_HANDLE ImageHandle,
476 IN EFI_SYSTEM_TABLE *SystemTable
477 )
478 /*++
479
480 Routine Description:
481
482 Intialize runtime Driver Lib if it has not yet been initialized.
483
484 Arguments:
485
486 ImageHandle - The firmware allocated handle for the EFI image.
487
488 SystemTable - A pointer to the EFI System Table.
489
490 Returns:
491
492 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
493
494 --*/
495 {
496 EFI_STATUS Status;
497 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
498 VOID *Registration;
499 #endif
500
501 if (mRuntimeLibInitialized) {
502 return EFI_ALREADY_STARTED;
503 }
504
505 mRuntimeLibInitialized = TRUE;
506
507 gST = SystemTable;
508 ASSERT (gST != NULL);
509
510 gBS = SystemTable->BootServices;
511 ASSERT (gBS != NULL);
512 mRT = SystemTable->RuntimeServices;
513 ASSERT (mRT != NULL);
514
515 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
516 //
517 // Register EFI_STATUS_CODE_PROTOCOL notify function
518 //
519 Status = gBS->CreateEvent (
520 EFI_EVENT_NOTIFY_SIGNAL,
521 EFI_TPL_CALLBACK,
522 OnStatusCodeInstall,
523 NULL,
524 &gEfiStatusCodeNotifyEvent
525 );
526 ASSERT_EFI_ERROR (Status);
527
528 Status = gBS->RegisterProtocolNotify (
529 &gEfiStatusCodeRuntimeProtocolGuid,
530 gEfiStatusCodeNotifyEvent,
531 &Registration
532 );
533 ASSERT_EFI_ERROR (Status);
534
535 gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
536 #endif
537
538 Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
539 if (EFI_ERROR (Status)) {
540 gCpuIo = NULL;
541 }
542
543 return EFI_SUCCESS;
544 }
545
546 BOOLEAN
547 EfiAtRuntime (
548 VOID
549 )
550 /*++
551
552 Routine Description:
553 Return TRUE if ExitBootServices () has been called
554
555 Arguments:
556 NONE
557
558 Returns:
559 TRUE - If ExitBootServices () has been called
560
561 --*/
562 {
563 return mEfiAtRuntime;
564 }
565
566 BOOLEAN
567 EfiGoneVirtual (
568 VOID
569 )
570 /*++
571
572 Routine Description:
573 Return TRUE if SetVirtualAddressMap () has been called
574
575 Arguments:
576 NONE
577
578 Returns:
579 TRUE - If SetVirtualAddressMap () has been called
580
581 --*/
582 {
583 return mEfiGoneVirtual;
584 }
585 //
586 // The following functions hide the mRT local global from the call to
587 // runtime service in the EFI system table.
588 //
589 EFI_STATUS
590 EfiGetTime (
591 OUT EFI_TIME *Time,
592 OUT EFI_TIME_CAPABILITIES *Capabilities
593 )
594 /*++
595
596 Routine Description:
597
598 Returns the current time and date information, and the time-keeping
599 capabilities of the hardware platform.
600
601 Arguments:
602
603 Time - A pointer to storage to receive a snapshot of the current time.
604 Capabilities - An optional pointer to a buffer to receive the real time clock device's
605 capabilities.
606
607 Returns:
608
609 Status code
610
611 --*/
612 {
613 return mRT->GetTime (Time, Capabilities);
614 }
615
616 EFI_STATUS
617 EfiSetTime (
618 IN EFI_TIME *Time
619 )
620 /*++
621
622 Routine Description:
623
624 Sets the current local time and date information.
625
626 Arguments:
627
628 Time - A pointer to the current time.
629
630 Returns:
631
632 Status code
633
634 --*/
635 {
636 return mRT->SetTime (Time);
637 }
638
639 EFI_STATUS
640 EfiGetWakeupTime (
641 OUT BOOLEAN *Enabled,
642 OUT BOOLEAN *Pending,
643 OUT EFI_TIME *Time
644 )
645 /*++
646
647 Routine Description:
648
649 Returns the current wakeup alarm clock setting.
650
651 Arguments:
652
653 Enabled - Indicates if the alarm is currently enabled or disabled.
654 Pending - Indicates if the alarm signal is pending and requires acknowledgement.
655 Time - The current alarm setting.
656
657 Returns:
658
659 Status code
660
661 --*/
662 {
663 return mRT->GetWakeupTime (Enabled, Pending, Time);
664 }
665
666 EFI_STATUS
667 EfiSetWakeupTime (
668 IN BOOLEAN Enable,
669 IN EFI_TIME *Time
670 )
671 /*++
672
673 Routine Description:
674
675 Sets the system wakeup alarm clock time.
676
677 Arguments:
678
679 Enable - Enable or disable the wakeup alarm.
680 Time - If Enable is TRUE, the time to set the wakeup alarm for.
681 If Enable is FALSE, then this parameter is optional, and may be NULL.
682
683 Returns:
684
685 Status code
686
687 --*/
688 {
689 return mRT->SetWakeupTime (Enable, Time);
690 }
691
692 EFI_STATUS
693 EfiGetVariable (
694 IN CHAR16 *VariableName,
695 IN EFI_GUID * VendorGuid,
696 OUT UINT32 *Attributes OPTIONAL,
697 IN OUT UINTN *DataSize,
698 OUT VOID *Data
699 )
700 /*++
701
702 Routine Description:
703
704 Returns the value of a variable.
705
706 Arguments:
707
708 VariableName - A Null-terminated Unicode string that is the name of the
709 vendor's variable.
710 VendorGuid - A unique identifier for the vendor.
711 Attributes - If not NULL, a pointer to the memory location to return the
712 attributes bitmask for the variable.
713 DataSize - On input, the size in bytes of the return Data buffer.
714 On output the size of data returned in Data.
715 Data - The buffer to return the contents of the variable.
716
717 Returns:
718
719 Status code
720
721 --*/
722 {
723 return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
724 }
725
726 EFI_STATUS
727 EfiGetNextVariableName (
728 IN OUT UINTN *VariableNameSize,
729 IN OUT CHAR16 *VariableName,
730 IN OUT EFI_GUID *VendorGuid
731 )
732 /*++
733
734 Routine Description:
735
736 Enumerates the current variable names.
737
738 Arguments:
739
740 VariableNameSize - The size of the VariableName buffer.
741 VariableName - On input, supplies the last VariableName that was returned
742 by GetNextVariableName().
743 On output, returns the Nullterminated Unicode string of the
744 current variable.
745 VendorGuid - On input, supplies the last VendorGuid that was returned by
746 GetNextVariableName().
747 On output, returns the VendorGuid of the current variable.
748
749 Returns:
750
751 Status code
752
753 --*/
754 {
755 return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
756 }
757
758 EFI_STATUS
759 EfiSetVariable (
760 IN CHAR16 *VariableName,
761 IN EFI_GUID *VendorGuid,
762 IN UINT32 Attributes,
763 IN UINTN DataSize,
764 IN VOID *Data
765 )
766 /*++
767
768 Routine Description:
769
770 Sets the value of a variable.
771
772 Arguments:
773
774 VariableName - A Null-terminated Unicode string that is the name of the
775 vendor's variable.
776 VendorGuid - A unique identifier for the vendor.
777 Attributes - Attributes bitmask to set for the variable.
778 DataSize - The size in bytes of the Data buffer.
779 Data - The contents for the variable.
780
781 Returns:
782
783 Status code
784
785 --*/
786 {
787 return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
788 }
789
790
791 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
792
793 EFI_STATUS
794 EfiQueryVariableInfo (
795 IN UINT32 Attributes,
796 OUT UINT64 *MaximumVariableStorageSize,
797 OUT UINT64 *RemainingVariableStorageSize,
798 OUT UINT64 *MaximumVariableSize
799 )
800
801 /*++
802
803 Routine Description:
804
805 This code returns information about the EFI variables.
806
807 Arguments:
808
809 Attributes Attributes bitmask to specify the type of variables
810 on which to return information.
811 MaximumVariableStorageSize Pointer to the maximum size of the storage space available
812 for the EFI variables associated with the attributes specified.
813 RemainingVariableStorageSize Pointer to the remaining size of the storage space available
814 for the EFI variables associated with the attributes specified.
815 MaximumVariableSize Pointer to the maximum size of the individual EFI variables
816 associated with the attributes specified.
817
818 Returns:
819
820 Status code
821
822 --*/
823 {
824 return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);
825 }
826
827 #endif
828
829 EFI_STATUS
830 EfiGetNextHighMonotonicCount (
831 OUT UINT32 *HighCount
832 )
833 /*++
834
835 Routine Description:
836
837 Returns the next high 32 bits of the platform's monotonic counter.
838
839 Arguments:
840
841 HighCount - Pointer to returned value.
842
843 Returns:
844
845 Status code
846
847 --*/
848 {
849 return mRT->GetNextHighMonotonicCount (HighCount);
850 }
851
852 VOID
853 EfiResetSystem (
854 IN EFI_RESET_TYPE ResetType,
855 IN EFI_STATUS ResetStatus,
856 IN UINTN DataSize,
857 IN CHAR16 *ResetData
858 )
859 /*++
860
861 Routine Description:
862
863 Resets the entire platform.
864
865 Arguments:
866
867 ResetType - The type of reset to perform.
868 ResetStatus - The status code for the reset.
869 DataSize - The size, in bytes, of ResetData.
870 ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
871 followed by additional binary data.
872
873 Returns:
874
875 None
876
877 --*/
878 {
879 mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
880 }
881
882 EFI_STATUS
883 EfiReportStatusCode (
884 IN EFI_STATUS_CODE_TYPE CodeType,
885 IN EFI_STATUS_CODE_VALUE Value,
886 IN UINT32 Instance,
887 IN EFI_GUID *CallerId OPTIONAL,
888 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
889 )
890 /*++
891
892 Routine Description:
893
894 Status Code reporter
895
896 Arguments:
897
898 CodeType - Type of Status Code.
899
900 Value - Value to output for Status Code.
901
902 Instance - Instance Number of this status code.
903
904 CallerId - ID of the caller of this status code.
905
906 Data - Optional data associated with this status code.
907
908 Returns:
909
910 Status code
911
912 --*/
913 {
914 EFI_STATUS Status;
915
916 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
917 if (gReportStatusCode == NULL) {
918 //
919 // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
920 // running here indicates that the StatusCode driver has not started yet.
921 //
922 if (EfiAtRuntime ()) {
923 //
924 // Running here only when StatusCode driver never starts.
925 //
926 return EFI_UNSUPPORTED;
927 }
928
929 //
930 // Try to get the PEI version of ReportStatusCode.
931 //
932 Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
933 if (EFI_ERROR (Status)) {
934 return EFI_UNSUPPORTED;
935 }
936 }
937 Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
938 #else
939 if (mRT == NULL) {
940 return EFI_UNSUPPORTED;
941 }
942 //
943 // Check whether EFI_RUNTIME_SERVICES has Tiano Extension
944 //
945 Status = EFI_UNSUPPORTED;
946 if (mRT->Hdr.Revision == EFI_SPECIFICATION_VERSION &&
947 mRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) &&
948 mRT->ReportStatusCode != NULL) {
949 Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
950 }
951 #endif
952 return Status;
953 }