//\r
// The current monotonic counter value\r
//\r
-UINT64 mEfiMtc;\r
+UINT64 mEfiMtc;\r
\r
//\r
// Event to update the monotonic Counter's high part when low part overflows.\r
//\r
-EFI_EVENT mEfiMtcEvent;\r
+EFI_EVENT mEfiMtcEvent;\r
\r
/**\r
Returns a monotonically increasing count for the platform.\r
OUT UINT64 *Count\r
)\r
{\r
- EFI_TPL OldTpl;\r
+ EFI_TPL OldTpl;\r
\r
//\r
// Cannot be called after ExitBootServices()\r
if (EfiAtRuntime ()) {\r
return EFI_UNSUPPORTED;\r
}\r
+\r
//\r
// Check input parameters\r
//\r
if (Count == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
+\r
//\r
// Update the monotonic counter with a lock\r
//\r
- OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
- *Count = mEfiMtc;\r
+ OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+ *Count = mEfiMtc;\r
mEfiMtc++;\r
gBS->RestoreTPL (OldTpl);\r
\r
// If the low 32-bit counter overflows (MSB bit toggled),\r
// then signal that the high part needs update now.\r
//\r
- if ((((UINT32) mEfiMtc) ^ ((UINT32) *Count)) & BIT31) {\r
+ if ((((UINT32)mEfiMtc) ^ ((UINT32)*Count)) & BIT31) {\r
gBS->SignalEvent (mEfiMtcEvent);\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Returns the next high 32 bits of the platform's monotonic counter.\r
\r
OUT UINT32 *HighCount\r
)\r
{\r
- EFI_TPL OldTpl;\r
+ EFI_TPL OldTpl;\r
\r
//\r
// Check input parameters\r
//\r
// Use a lock if called before ExitBootServices()\r
//\r
- OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
- *HighCount = (UINT32) RShiftU64 (mEfiMtc, 32) + 1;\r
- mEfiMtc = LShiftU64 (*HighCount, 32);\r
+ OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+ *HighCount = (UINT32)RShiftU64 (mEfiMtc, 32) + 1;\r
+ mEfiMtc = LShiftU64 (*HighCount, 32);\r
gBS->RestoreTPL (OldTpl);\r
} else {\r
- *HighCount = (UINT32) RShiftU64 (mEfiMtc, 32) + 1;\r
- mEfiMtc = LShiftU64 (*HighCount, 32);\r
+ *HighCount = (UINT32)RShiftU64 (mEfiMtc, 32) + 1;\r
+ mEfiMtc = LShiftU64 (*HighCount, 32);\r
}\r
+\r
//\r
// Update the NV variable to match the new high part\r
//\r
sizeof (UINT32),\r
HighCount\r
);\r
-\r
}\r
\r
/**\r
VOID\r
EFIAPI\r
EfiMtcEventHandler (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
)\r
{\r
UINT32 HighCount;\r
// Read the last high part\r
//\r
BufferSize = sizeof (UINT32);\r
- Status = EfiGetVariable (\r
- MTC_VARIABLE_NAME,\r
- &gMtcVendorGuid,\r
- NULL,\r
- &BufferSize,\r
- &HighCount\r
- );\r
+ Status = EfiGetVariable (\r
+ MTC_VARIABLE_NAME,\r
+ &gMtcVendorGuid,\r
+ NULL,\r
+ &BufferSize,\r
+ &HighCount\r
+ );\r
if (EFI_ERROR (Status)) {\r
HighCount = 0;\r
}\r
+\r
//\r
// Set the current value\r
//\r
//\r
// Fill in the EFI Boot Services and EFI Runtime Services Monotonic Counter Fields\r
//\r
- gBS->GetNextMonotonicCount = MonotonicCounterDriverGetNextMonotonicCount;\r
- gRT->GetNextHighMonotonicCount = MonotonicCounterDriverGetNextHighMonotonicCount;\r
+ gBS->GetNextMonotonicCount = MonotonicCounterDriverGetNextMonotonicCount;\r
+ gRT->GetNextHighMonotonicCount = MonotonicCounterDriverGetNextHighMonotonicCount;\r
\r
//\r
// Install the Monotonic Counter Architctural Protocol onto a new handle\r