]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiRuntimeLib/RuntimeLib.c
MdePkg: Update the comments of IsLanguageSupported
[mirror_edk2.git] / MdePkg / Library / UefiRuntimeLib / RuntimeLib.c
index 2b0155e6911ce3a01c5f4d460ec63069726931ba..933e0099ceed1e07ca9263707b0c9f1d876302fa 100644 (file)
@@ -1,36 +1,39 @@
-/**@file\r
-  Library utility functions for Runtime driver.\r
+/** @file\r
+  UEFI Runtime Library implementation for non IPF processor types.\r
 \r
-Copyright (c) 2006 Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+  This library hides the global variable for the EFI Runtime Services so the\r
+  caller does not need to deal with the possibility of being called from an\r
+  OS virtual address space. All pointer values are different for a virtual\r
+  mapping than from the normal physical mapping at boot services time.\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-#include <RuntimeLibInternal.h>\r
+#include <Uefi.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Guid/EventGroup.h>\r
 \r
 ///\r
 /// Driver Lib Module Globals\r
 ///\r
-\r
-STATIC EFI_EVENT              mEfiVirtualNotifyEvent;\r
-STATIC EFI_EVENT              mEfiExitBootServicesEvent;\r
-STATIC BOOLEAN                mEfiGoneVirtual         = FALSE;\r
-STATIC BOOLEAN                mEfiAtRuntime           = FALSE;\r
-EFI_RUNTIME_SERVICES          *mRT;\r
+EFI_EVENT              mEfiVirtualNotifyEvent;\r
+EFI_EVENT              mEfiExitBootServicesEvent;\r
+BOOLEAN                mEfiGoneVirtual         = FALSE;\r
+BOOLEAN                mEfiAtRuntime           = FALSE;\r
+EFI_RUNTIME_SERVICES   *mInternalRT;\r
 \r
 /**\r
-  Set AtRuntime flag as TRUE after ExitBootServices\r
+  Set AtRuntime flag as TRUE after ExitBootServices.\r
+\r
+  @param[in]  Event   The Event that is being processed.\r
+  @param[in]  Context The Event Context.\r
 \r
-  @param[in]  Event   The Event that is being processed\r
-  @param[in]  Context Event Context\r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 RuntimeLibExitBootServicesEvent (\r
@@ -38,11 +41,6 @@ RuntimeLibExitBootServicesEvent (
   IN VOID             *Context\r
   )\r
 {\r
-  //\r
-  // Clear out BootService globals\r
-  //\r
-  gBS             = NULL;\r
-\r
   mEfiAtRuntime = TRUE;\r
 }\r
 \r
@@ -51,10 +49,9 @@ RuntimeLibExitBootServicesEvent (
   Call the passed in Child Notify event and convert any pointers in\r
   lib to virtual mode.\r
 \r
-  @param[in]    Event   The Event that is being processed\r
-  @param[in]    Context Event Context\r
+  @param[in]    Event   The Event that is being processed.\r
+  @param[in]    Context The Event Context.\r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 RuntimeLibVirtualNotifyEvent (\r
@@ -65,13 +62,15 @@ RuntimeLibVirtualNotifyEvent (
   //\r
   // Update global for Runtime Services Table and IO\r
   //\r
-  EfiConvertPointer (0, (VOID **) &mRT);\r
+  EfiConvertPointer (0, (VOID **) &mInternalRT);\r
 \r
   mEfiGoneVirtual = TRUE;\r
 }\r
 \r
 /**\r
-  Intialize runtime Driver Lib if it has not yet been initialized.\r
+  Initialize runtime Driver Lib if it has not yet been initialized.\r
+  It will ASSERT() if gRT is NULL or gBS is NULL.\r
+  It will ASSERT() if that operation fails.\r
 \r
   @param[in]  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param[in]  SystemTable   A pointer to the EFI System Table.\r
@@ -87,29 +86,30 @@ RuntimeDriverLibConstruct (
 {\r
   EFI_STATUS  Status;\r
 \r
-  ASSERT (SystemTable != NULL);\r
-  mRT = SystemTable->RuntimeServices;\r
-  ASSERT (mRT != NULL);\r
-  \r
+  ASSERT (gRT != NULL);\r
+  ASSERT (gBS != NULL);\r
+\r
+  mInternalRT = gRT;\r
   //\r
   // Register SetVirtualAddressMap () notify function\r
   //\r
-  ASSERT (gBS != NULL);\r
-  Status = gBS->CreateEvent (\r
-                  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
                   RuntimeLibVirtualNotifyEvent,\r
                   NULL,\r
+                  &gEfiEventVirtualAddressChangeGuid,\r
                   &mEfiVirtualNotifyEvent\r
                   );\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = gBS->CreateEvent (\r
-                  EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
                   RuntimeLibExitBootServicesEvent,\r
                   NULL,\r
+                  &gEfiEventExitBootServicesGuid,\r
                   &mEfiExitBootServicesEvent\r
                   );\r
 \r
@@ -119,12 +119,16 @@ RuntimeDriverLibConstruct (
 }\r
 \r
 /**\r
-  This routine will free some resources which have been allocated in\r
-  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,\r
-  it must call this routine to free the allocated resource before the exiting.\r
+  If a runtime driver exits with an error, it must call this routine\r
+  to free the allocated resource before the exiting.\r
+  It will ASSERT() if gBS is NULL.\r
+  It will ASSERT() if that operation fails.\r
 \r
-  @retval     EFI_SUCCESS       Shutdown the Runtime Driver Lib successfully\r
-  @retval     EFI_UNSUPPORTED   Runtime Driver lib was not initialized at all\r
+  @param[in]  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param[in]  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval     EFI_SUCCESS       The Runtime Driver Lib shutdown successfully.\r
+  @retval     EFI_UNSUPPORTED   Runtime Driver lib was not initialized.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -149,9 +153,16 @@ RuntimeDriverLibDeconstruct (
 }\r
 \r
 /**\r
-  Return TRUE if ExitBootServices () has been called\r
+  This function allows the caller to determine if UEFI ExitBootServices() has been called.\r
+\r
+  This function returns TRUE after all the EVT_SIGNAL_EXIT_BOOT_SERVICES functions have\r
+  executed as a result of the OS calling ExitBootServices().  Prior to this time FALSE\r
+  is returned. This function is used by runtime code to decide it is legal to access\r
+  services that go away after ExitBootServices().\r
+\r
+  @retval  TRUE  The system has finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.\r
+  @retval  FALSE The system has not finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.\r
 \r
-  @retval TRUE If ExitBootServices () has been called\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -163,9 +174,16 @@ EfiAtRuntime (
 }\r
 \r
 /**\r
-  Return TRUE if SetVirtualAddressMap () has been called\r
+  This function allows the caller to determine if UEFI SetVirtualAddressMap() has been called.\r
+\r
+  This function returns TRUE after all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE functions have\r
+  executed as a result of the OS calling SetVirtualAddressMap(). Prior to this time FALSE\r
+  is returned. This function is used by runtime code to decide it is legal to access services\r
+  that go away after SetVirtualAddressMap().\r
+\r
+  @retval  TRUE  The system has finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
+  @retval  FALSE The system has not finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
 \r
-  @retval TRUE  If SetVirtualAddressMap () has been called\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -176,3 +194,644 @@ EfiGoneVirtual (
   return mEfiGoneVirtual;\r
 }\r
 \r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service ResetSystem().\r
+\r
+  The ResetSystem()function resets the entire platform, including all processors and devices,and reboots the system.\r
+  Calling this interface with ResetType of EfiResetCold causes a system-wide reset. This sets all circuitry within\r
+  the system to its initial state. This type of reset is asynchronous to system operation and operates without regard\r
+  to cycle boundaries. EfiResetCold is tantamount to a system power cycle.\r
+  Calling this interface with ResetType of EfiResetWarm causes a system-wide initialization. The processors are set to\r
+  their initial state, and pending cycles are not corrupted. If the system does not support this reset type, then an\r
+  EfiResetCold must be performed.\r
+  Calling this interface with ResetType of EfiResetShutdown causes the system to enter a power state equivalent to the\r
+  ACPI G2/S5 or G3 states. If the system does not support this reset type, then when the system is rebooted, it should\r
+  exhibit the EfiResetCold attributes.\r
+  The platform may optionally log the parameters from any non-normal reset that occurs.\r
+  The ResetSystem() function does not return.\r
+\r
+  @param  ResetType   The type of reset to perform.\r
+  @param  ResetStatus The status code for the reset. If the system reset is part of a normal operation, the status code\r
+                      would be EFI_SUCCESS. If the system reset is due to some type of failure the most appropriate EFI\r
+                      Status code would be used.\r
+  @param  DataSizeThe size, in bytes, of ResetData.\r
+  @param  ResetData   For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a\r
+                      Null-terminated Unicode string, optionally followed by additional binary data. The string is a\r
+                      description that the caller may use to further indicate the reason for the system reset. ResetData\r
+                      is only valid if ResetStatus is something other then EFI_SUCCESS. This pointer must be a physical\r
+                      address. For a ResetType of EfiRestUpdate the data buffer also starts with a Null-terminated string\r
+                      that is followed by a physical VOID * to an EFI_CAPSULE_HEADER.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *ResetData OPTIONAL\r
+  )\r
+{\r
+  mInternalRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetTime().\r
+\r
+  The GetTime() function returns a time that was valid sometime during the call to the function.\r
+  While the returned EFI_TIME structure contains TimeZone and Daylight savings time information,\r
+  the actual clock does not maintain these values. The current time zone and daylight saving time\r
+  information returned by GetTime() are the values that were last set via SetTime().\r
+  The GetTime() function should take approximately the same amount of time to read the time each\r
+  time it is called. All reported device capabilities are to be rounded up.\r
+  During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r
+  access to the device before calling GetTime().\r
+\r
+  @param  Time         A pointer to storage to receive a snapshot of the current time.\r
+  @param  Capabilities An optional pointer to a buffer to receive the real time clock device's\r
+                       capabilities.\r
+\r
+  @retval  EFI_SUCCESS            The operation completed successfully.\r
+  @retval  EFI_INVALID_PARAMETER  Time is NULL.\r
+  @retval  EFI_DEVICE_ERROR       The time could not be retrieved due to a hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities  OPTIONAL\r
+  )\r
+{\r
+  return mInternalRT->GetTime (Time, Capabilities);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service SetTime().\r
+\r
+  The SetTime() function sets the real time clock device to the supplied time, and records the\r
+  current time zone and daylight savings time information. The SetTime() function is not allowed\r
+  to loop based on the current time. For example, if the device does not support a hardware reset\r
+  for the sub-resolution time, the code is not to implement the feature by waiting for the time to\r
+  wrap.\r
+  During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r
+  access to the device before calling SetTime().\r
+\r
+  @param  Time  A pointer to the current time. Type EFI_TIME is defined in the GetTime()\r
+                function description. Full error checking is performed on the different\r
+                fields of the EFI_TIME structure (refer to the EFI_TIME definition in the\r
+                GetTime() function description for full details), and EFI_INVALID_PARAMETER\r
+                is returned if any field is out of range.\r
+\r
+  @retval  EFI_SUCCESS            The operation completed successfully.\r
+  @retval  EFI_INVALID_PARAMETER  A time field is out of range.\r
+  @retval  EFI_DEVICE_ERROR       The time could not be set due to a hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  )\r
+{\r
+  return mInternalRT->SetTime (Time);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetWakeupTime().\r
+\r
+  The alarm clock time may be rounded from the set alarm clock time to be within the resolution\r
+  of the alarm clock device. The resolution of the alarm clock device is defined to be one second.\r
+  During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r
+  access to the device before calling GetWakeupTime().\r
+\r
+  @param  Enabled  Indicates if the alarm is currently enabled or disabled.\r
+  @param  Pending  Indicates if the alarm signal is pending and requires acknowledgement.\r
+  @param  Time     The current alarm setting. Type EFI_TIME is defined in the GetTime()\r
+                   function description.\r
+\r
+  @retval  EFI_SUCCESS            The alarm settings were returned.\r
+  @retval  EFI_INVALID_PARAMETER  Enabled is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  Pending is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  Time is NULL.\r
+  @retval  EFI_DEVICE_ERROR       The wakeup time could not be retrieved due to a hardware error.\r
+  @retval  EFI_UNSUPPORTED        A wakeup timer is not supported on this platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+{\r
+  return mInternalRT->GetWakeupTime (Enabled, Pending, Time);\r
+}\r
+\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service SetWakeupTime()\r
+\r
+  Setting a system wakeup alarm causes the system to wake up or power on at the set time.\r
+  When the alarm fires, the alarm signal is latched until it is acknowledged by calling SetWakeupTime()\r
+  to disable the alarm. If the alarm fires before the system is put into a sleeping or off state,\r
+  since the alarm signal is latched the system will immediately wake up. If the alarm fires while\r
+  the system is off and there is insufficient power to power on the system, the system is powered\r
+  on when power is restored.\r
+\r
+  @param  Enable  Enable or disable the wakeup alarm.\r
+  @param  Time    If Enable is TRUE, the time to set the wakeup alarm for. Type EFI_TIME\r
+                  is defined in the GetTime() function description. If Enable is FALSE,\r
+                  then this parameter is optional, and may be NULL.\r
+\r
+  @retval  EFI_SUCCESS            If Enable is TRUE, then the wakeup alarm was enabled.\r
+                                  If Enable is FALSE, then the wakeup alarm was disabled.\r
+  @retval  EFI_INVALID_PARAMETER  A time field is out of range.\r
+  @retval  EFI_DEVICE_ERROR       The wakeup time could not be set due to a hardware error.\r
+  @retval  EFI_UNSUPPORTED        A wakeup timer is not supported on this platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time   OPTIONAL\r
+  )\r
+{\r
+  return mInternalRT->SetWakeupTime (Enable, Time);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetVariable().\r
+\r
+  Each vendor may create and manage its own variables without the risk of name conflicts by\r
+  using a unique VendorGuid. When a variable is set its Attributes are supplied to indicate\r
+  how the data variable should be stored and maintained by the system. The attributes affect\r
+  when the variable may be accessed and volatility of the data. Any attempts to access a variable\r
+  that does not have the attribute set for runtime access will yield the EFI_NOT_FOUND error.\r
+  If the Data buffer is too small to hold the contents of the variable, the error EFI_BUFFER_TOO_SMALL\r
+  is returned and DataSize is set to the required buffer size to obtain the data.\r
+\r
+  @param  VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String\r
+  @param  VendorGuid   Unify identifier for vendor.\r
+  @param  Attributes   Point to memory location to return the attributes of variable. If the point\r
+                       is NULL, the parameter would be ignored.\r
+  @param  DataSize     As input, point to the maximum size of return Data-Buffer.\r
+                       As output, point to the actual size of the returned Data-Buffer.\r
+  @param  Data         Point to return Data-Buffer.\r
+\r
+  @retval  EFI_SUCCESS            The function completed successfully.\r
+  @retval  EFI_NOT_FOUND          The variable was not found.\r
+  @retval  EFI_BUFFER_TOO_SMALL   The DataSize is too small for the result. DataSize has\r
+                                  been updated with the size needed to complete the request.\r
+  @retval  EFI_INVALID_PARAMETER  VariableName is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  VendorGuid is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  DataSize is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  The DataSize is not too small and Data is NULL.\r
+  @retval  EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
+  @retval  EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetVariable (\r
+  IN      CHAR16                   *VariableName,\r
+  IN      EFI_GUID                 *VendorGuid,\r
+  OUT     UINT32                   *Attributes OPTIONAL,\r
+  IN OUT  UINTN                    *DataSize,\r
+  OUT     VOID                     *Data\r
+  )\r
+{\r
+  return mInternalRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetNextVariableName().\r
+\r
+  GetNextVariableName() is called multiple times to retrieve the VariableName and VendorGuid of\r
+  all variables currently available in the system. On each call to GetNextVariableName() the\r
+  previous results are passed into the interface, and on output the interface returns the next\r
+  variable name data. When the entire variable list has been returned, the error EFI_NOT_FOUND\r
+  is returned.\r
+\r
+  @param  VariableNameSize As input, point to maximum size of variable name.\r
+                           As output, point to actual size of variable name.\r
+  @param  VariableName     As input, supplies the last VariableName that was returned by\r
+                           GetNextVariableName().\r
+                           As output, returns the name of variable. The name\r
+                           string is Null-Terminated Unicode string.\r
+  @param  VendorGuid       As input, supplies the last VendorGuid that was returned by\r
+                           GetNextVriableName().\r
+                           As output, returns the VendorGuid of the current variable.\r
+\r
+  @retval  EFI_SUCCESS           The function completed successfully.\r
+  @retval  EFI_NOT_FOUND         The next variable was not found.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The VariableNameSize is too small for the result.\r
+                                 VariableNameSize has been updated with the size needed\r
+                                 to complete the request.\r
+  @retval  EFI_INVALID_PARAMETER VariableNameSize is NULL.\r
+  @retval  EFI_INVALID_PARAMETER VariableName is NULL.\r
+  @retval  EFI_INVALID_PARAMETER VendorGuid is NULL.\r
+  @retval  EFI_DEVICE_ERROR      The variable name could not be retrieved due to a hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+{\r
+  return mInternalRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetNextVariableName()\r
+\r
+  Variables are stored by the firmware and may maintain their values across power cycles. Each vendor\r
+  may create and manage its own variables without the risk of name conflicts by using a unique VendorGuid.\r
+\r
+  @param  VariableName The name of the vendor's variable; it's a Null-Terminated\r
+                       Unicode String\r
+  @param  VendorGuid   Unify identifier for vendor.\r
+  @param  Attributes   Points to a memory location to return the attributes of variable. If the point\r
+                       is NULL, the parameter would be ignored.\r
+  @param  DataSize     The size in bytes of Data-Buffer.\r
+  @param  Data         Points to the content of the variable.\r
+\r
+  @retval  EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
+                                  defined by the Attributes.\r
+  @retval  EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the\r
+                                  DataSize exceeds the maximum allowed.\r
+  @retval  EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.\r
+  @retval  EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
+  @retval  EFI_DEVICE_ERROR       The variable could not be saved due to a hardware failure.\r
+  @retval  EFI_WRITE_PROTECTED    The variable in question is read-only.\r
+  @retval  EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
+  @retval  EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\r
+                                  set but the AuthInfo does NOT pass the validation check carried\r
+                                  out by the firmware.\r
+  @retval  EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+{\r
+  return mInternalRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service GetNextHighMonotonicCount().\r
+\r
+  The platform's monotonic counter is comprised of two 32-bit quantities: the high 32 bits and\r
+  the low 32 bits. During boot service time the low 32-bit value is volatile: it is reset to zero\r
+  on every system reset and is increased by 1 on every call to GetNextMonotonicCount(). The high\r
+  32-bit value is nonvolatile and is increased by 1 whenever the system resets or whenever the low\r
+  32-bit count (returned by GetNextMonoticCount()) overflows.\r
+\r
+  @param  HighCount The pointer to returned value.\r
+\r
+  @retval  EFI_SUCCESS           The next high monotonic count was returned.\r
+  @retval  EFI_DEVICE_ERROR      The device is not functioning properly.\r
+  @retval  EFI_INVALID_PARAMETER HighCount is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+{\r
+  return mInternalRT->GetNextHighMonotonicCount (HighCount);\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service ConvertPointer().\r
+\r
+  The ConvertPointer() function is used by an EFI component during the SetVirtualAddressMap() operation.\r
+  ConvertPointer()must be called using physical address pointers during the execution of SetVirtualAddressMap().\r
+\r
+  @param  DebugDisposition   Supplies type information for the pointer being converted.\r
+  @param  Address            The pointer to a pointer that is to be fixed to be the\r
+                             value needed for the new virtual address mapping being\r
+                             applied.\r
+\r
+  @retval  EFI_SUCCESS            The pointer pointed to by Address was modified.\r
+  @retval  EFI_NOT_FOUND          The pointer pointed to by Address was not found to be part of\r
+                                  the current memory map. This is normally fatal.\r
+  @retval  EFI_INVALID_PARAMETER  Address is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  *Address is NULL and DebugDispositio\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertPointer (\r
+  IN UINTN                  DebugDisposition,\r
+  IN OUT VOID               **Address\r
+  )\r
+{\r
+  return gRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+\r
+/**\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+  For IA32, x64, and EBC, this service is a wrapper for the UEFI Runtime Service\r
+  ConvertPointer().  See the UEFI Specification for details.\r
+  For IPF, this function interprets Address as a pointer to an EFI_PLABEL structure\r
+  and both the EntryPoint and GP fields of an EFI_PLABEL are converted from physical\r
+  to virtiual addressing.  Since IPF allows the GP to point to an address outside\r
+  a PE/COFF image, the physical to virtual offset for the EntryPoint field is used\r
+  to adjust the GP field.  The UEFI Runtime Service ConvertPointer() is used to convert\r
+  EntryPoint and the status code for this conversion is always returned.   If the convertion\r
+  of EntryPoint fails, then neither EntryPoint nor GP are modified.  See the UEFI\r
+  Specification for details on the UEFI Runtime Service ConvertPointer().\r
+\r
+  @param  DebugDisposition   Supplies type information for the pointer being converted.\r
+  @param  Address            The pointer to a pointer that is to be fixed to be the\r
+                             value needed for the new virtual address mapping being\r
+                             applied.\r
+\r
+  @return  EFI_STATUS value from EfiConvertPointer().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertFunctionPointer (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT VOID             **Address\r
+  )\r
+{\r
+  return EfiConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+\r
+/**\r
+  Convert the standard Lib double linked list to a virtual mapping.\r
+\r
+  This service uses EfiConvertPointer() to walk a double linked list and convert all the link\r
+  pointers to their virtual mappings. This function is only guaranteed to work during the\r
+  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event and calling it at other times has undefined results.\r
+\r
+  @param  DebugDisposition   Supplies type information for the pointer being converted.\r
+  @param  ListHead           Head of linked list to convert.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT LIST_ENTRY       *ListHead\r
+  )\r
+{\r
+  LIST_ENTRY  *Link;\r
+  LIST_ENTRY  *NextLink;\r
+\r
+  //\r
+  // For NULL List, return EFI_SUCCESS\r
+  //\r
+  if (ListHead == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Convert all the ForwardLink & BackLink pointers in the list\r
+  //\r
+  Link = ListHead;\r
+  do {\r
+    NextLink = Link->ForwardLink;\r
+\r
+    EfiConvertPointer (\r
+      Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->ForwardLink\r
+      );\r
+\r
+    EfiConvertPointer (\r
+      Link->BackLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->BackLink\r
+      );\r
+\r
+    Link = NextLink;\r
+  } while (Link != ListHead);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service SetVirtualAddressMap().\r
+\r
+  The SetVirtualAddressMap() function is used by the OS loader. The function can only be called\r
+  at runtime, and is called by the owner of the system's memory map. I.e., the component which\r
+  called ExitBootServices(). All events of type EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE must be signaled\r
+  before SetVirtualAddressMap() returns.\r
+\r
+  @param  MemoryMapSize         The size in bytes of VirtualMap.\r
+  @param  DescriptorSize        The size in bytes of an entry in the VirtualMap.\r
+  @param  DescriptorVersion     The version of the structure entries in VirtualMap.\r
+  @param  VirtualMap            An array of memory descriptors which contain new virtual\r
+                                address mapping information for all runtime ranges. Type\r
+                                EFI_MEMORY_DESCRIPTOR is defined in the\r
+                                GetMemoryMap() function description.\r
+\r
+  @retval EFI_SUCCESS           The virtual address map has been applied.\r
+  @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in\r
+                                virtual address mapped mode.\r
+  @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r
+                                invalid.\r
+  @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory\r
+                                map that requires a mapping.\r
+  @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found\r
+                                in the memory map.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVirtualAddressMap (\r
+  IN UINTN                          MemoryMapSize,\r
+  IN UINTN                          DescriptorSize,\r
+  IN UINT32                         DescriptorVersion,\r
+  IN CONST EFI_MEMORY_DESCRIPTOR    *VirtualMap\r
+  )\r
+{\r
+  return mInternalRT->SetVirtualAddressMap (\r
+                        MemoryMapSize,\r
+                        DescriptorSize,\r
+                        DescriptorVersion,\r
+                        (EFI_MEMORY_DESCRIPTOR *) VirtualMap\r
+                        );\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service UpdateCapsule().\r
+\r
+  Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended\r
+  consumption, the firmware may process the capsule immediately. If the payload should persist across a\r
+  system reset, the reset value returned from EFI_QueryCapsuleCapabilities must be passed into ResetSystem()\r
+  and will cause the capsule to be processed by the firmware as part of the reset process.\r
+\r
+  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules\r
+                                being passed into update capsule. Each capsules is assumed to\r
+                                stored in contiguous virtual memory. The capsules in the\r
+                                CapsuleHeaderArray must be the same capsules as the\r
+                                ScatterGatherList. The CapsuleHeaderArray must\r
+                                have the capsules in the same order as the ScatterGatherList.\r
+  @param  CapsuleCount          The number of pointers to EFI_CAPSULE_HEADER in\r
+                                CaspuleHeaderArray.\r
+  @param  ScatterGatherList     Physical pointer to a set of\r
+                                EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the\r
+                                location in physical memory of a set of capsules. See Related\r
+                                Definitions for an explanation of how more than one capsule is\r
+                                passed via this interface. The capsules in the\r
+                                ScatterGatherList must be in the same order as the\r
+                                CapsuleHeaderArray. This parameter is only referenced if\r
+                                the capsules are defined to persist across system reset.\r
+\r
+  @retval EFI_SUCCESS           Valid capsule was passed. If CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set,\r
+                                the capsule has been successfully processed by the firmware.\r
+  @retval EFI_INVALID_PARAMETER CapsuleSize or HeaderSize is NULL.\r
+  @retval EFI_INVALID_PARAMETER CapsuleCount is 0\r
+  @retval EFI_DEVICE_ERROR      The capsule update was started, but failed due to a device error.\r
+  @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform.\r
+  @retval EFI_OUT_OF_RESOURCES  There were insufficient resources to process the capsule.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiUpdateCapsule (\r
+  IN EFI_CAPSULE_HEADER       **CapsuleHeaderArray,\r
+  IN UINTN                    CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS     ScatterGatherList OPTIONAL\r
+  )\r
+{\r
+  return mInternalRT->UpdateCapsule (\r
+                        CapsuleHeaderArray,\r
+                        CapsuleCount,\r
+                        ScatterGatherList\r
+                        );\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service QueryCapsuleCapabilities().\r
+\r
+  The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or\r
+  capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and\r
+  size of the entire capsule is checked.\r
+  If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be\r
+  constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof\r
+  (EFI_CAPSULE_HEADER). To determine reset requirements,\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the\r
+  EFI_CAPSULE_HEADER.\r
+  The firmware must support any capsule that has the\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The\r
+  firmware sets the policy for what capsules are supported that do not have the\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.\r
+\r
+  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules\r
+                                being passed into update capsule. The capsules are assumed to\r
+                                stored in contiguous virtual memory.\r
+  @param  CapsuleCount          The number of pointers to EFI_CAPSULE_HEADER in\r
+                                CaspuleHeaderArray.\r
+  @param  MaximumCapsuleSize     On output the maximum size that UpdateCapsule() can\r
+                                support as an argument to UpdateCapsule() via\r
+                                CapsuleHeaderArray and ScatterGatherList.\r
+                                Undefined on input.\r
+  @param  ResetType             Returns the type of reset required for the capsule update.\r
+\r
+  @retval EFI_SUCCESS           A valid answer was returned.\r
+  @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.\r
+  @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform, and\r
+                                MaximumCapsuleSize and ResetType are undefined.\r
+  @retval EFI_OUT_OF_RESOURCES  There were insufficient resources to process the query request.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryCapsuleCapabilities (\r
+  IN  EFI_CAPSULE_HEADER       **CapsuleHeaderArray,\r
+  IN  UINTN                    CapsuleCount,\r
+  OUT UINT64                   *MaximumCapsuleSize,\r
+  OUT EFI_RESET_TYPE           *ResetType\r
+  )\r
+{\r
+  return mInternalRT->QueryCapsuleCapabilities (\r
+                        CapsuleHeaderArray,\r
+                        CapsuleCount,\r
+                        MaximumCapsuleSize,\r
+                        ResetType\r
+                        );\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the UEFI Runtime Service QueryVariableInfo().\r
+\r
+  The QueryVariableInfo() function allows a caller to obtain the information about the\r
+  maximum size of the storage space available for the EFI variables, the remaining size of the storage\r
+  space available for the EFI variables and the maximum size of each individual EFI variable,\r
+  associated with the attributes specified.\r
+  The returned MaximumVariableStorageSize, RemainingVariableStorageSize,\r
+  MaximumVariableSize information may change immediately after the call based on other\r
+  runtime activities including asynchronous error events. Also, these values associated with different\r
+  attributes are not additive in nature.\r
+\r
+  @param  Attributes            Attributes bitmask to specify the type of variables on\r
+                                which to return information. Refer to the\r
+                                GetVariable() function description.\r
+  @param  MaximumVariableStorageSize\r
+                                On output the maximum size of the storage space\r
+                                available for the EFI variables associated with the\r
+                                attributes specified.\r
+  @param  RemainingVariableStorageSize\r
+                                Returns the remaining size of the storage space\r
+                                available for the EFI variables associated with the\r
+                                attributes specified..\r
+  @param  MaximumVariableSize   Returns the maximum size of the individual EFI\r
+                                variables associated with the attributes specified.\r
+\r
+  @retval EFI_SUCCESS           A valid answer was returned.\r
+  @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r
+  @retval EFI_UNSUPPORTED       EFI_UNSUPPORTED The attribute is not supported on this platform, and the\r
+                                MaximumVariableStorageSize,\r
+                                RemainingVariableStorageSize, MaximumVariableSize\r
+                                are undefined.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryVariableInfo (\r
+  IN UINT32   Attributes,\r
+  OUT UINT64  *MaximumVariableStorageSize,\r
+  OUT UINT64  *RemainingVariableStorageSize,\r
+  OUT UINT64  *MaximumVariableSize\r
+  )\r
+{\r
+  return mInternalRT->QueryVariableInfo (\r
+                        Attributes,\r
+                        MaximumVariableStorageSize,\r
+                        RemainingVariableStorageSize,\r
+                        MaximumVariableSize\r
+                        );\r
+}\r