]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/MonotonicCounter/RuntimeDxe/MonotonicCounter.c
All runtime driver should use functions provided by UefiRuntimeLib library class...
[mirror_edk2.git] / EdkModulePkg / Universal / MonotonicCounter / RuntimeDxe / MonotonicCounter.c
index 4a79e54a00fffc90d4cb1ce627b6a428723d9cb7..f79038657ae6aed4ae7c13a1d4698e1b009830f2 100644 (file)
@@ -100,41 +100,38 @@ Returns:
 }\r
 \r
 \r
-\r
 /**\r
-  Call back function on EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
-\r
-  Fixup internal data so that the driver is callable in EFI  runtime \r
-  in virtual mode. Convert gRT to virtual address. gRT is from \r
-  UefiRuntimeServicesTableLib class. It is not fixed up by \r
-  UefiRuntimeServicesTableLib instance.\r
-\r
-  @param  Event     Event whose notification function is being invoked.\r
-  @param  Context   The context of the Notification context. Not used in\r
-                    this call back function.\r
+  Returns the next high 32 bits of the platform's monotonic counter.\r
+\r
+  The GetNextHighMonotonicCount() function returns the next high 32 bits \r
+  of the platform's monotonic counter. The platform's monotonic counter is \r
+  comprised of two 32 bit quantities:  the high 32 bits and the low 32 bits.  \r
+  During boot service time the low 32 bit value is volatile:  it is reset to \r
+  zero on every system reset and is increased by 1 on every call to GetNextMonotonicCount().\r
+  The high 32 bit value is non-volatile and is increased by 1 whenever the system resets \r
+  or whenever the low 32 bit count [returned by GetNextMonoticCount()] overflows.\r
+  The GetNextMonotonicCount() function is only available at boot services time.  \r
+  If the operating system wishes to extend the platform monotonic counter to runtime, \r
+  it may do so by utilizing GetNextHighMonotonicCount().  To do this, before calling \r
+  ExitBootServices() the operating system would call GetNextMonotonicCount() to obtain \r
+  the current platform monotonic count.  The operating system would then provide an \r
+  interface that returns the next count by:  \r
+    Adding 1 to the last count.\r
+    Before the lower 32 bits of the count overflows, call GetNextHighMonotonicCount().  \r
+    This will increase the high 32 bits of the platform's non-volatile portion of the monotonic \r
+    count by 1.\r
+\r
+  This function may only be called at Runtime.\r
+\r
+  @param[out]   HighCount      Pointer to returned value.\r
+\r
+  @retval EFI_INVALID_PARAMETER If HighCount is NULL.\r
+  @retval EFI_SUCCESS           Operation is successful.\r
+  @retval EFI_OUT_OF_RESOURCES  If variable service reports that not enough storage \r
+                                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
 \r
 **/\r
-VOID\r
-EFIAPI\r
-MonotonicCounterDriverSetVirtualAddressMap (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  gRT->ConvertPointer (0, (VOID **) &gRT);\r
-}\r
-\r
-\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 MonotonicCounterDriverGetNextHighMonotonicCount (\r
@@ -150,7 +147,6 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS  Status;\r
   EFI_TPL     OldTpl;\r
 \r
   //\r
@@ -175,15 +171,14 @@ Returns:
   //\r
   // Update the NvRam store to match the new high part\r
   //\r
-  Status = gRT->SetVariable (\r
-                  mEfiMtcName,\r
-                  &mEfiMtcGuid,\r
-                  EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                  sizeof (UINT32),\r
-                  HighCount\r
-                  );\r
+  return EfiSetVariable (\r
+           mEfiMtcName,\r
+           &mEfiMtcGuid,\r
+           EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+           sizeof (UINT32),\r
+           HighCount\r
+           );\r
 \r
-  return Status;\r
 }\r
 \r
 VOID\r