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