+UINT8 mMorControl;\r
+\r
+/**\r
+ Ready to Boot Event notification handler.\r
+\r
+ Sequence of OS boot events is measured in this event notification handler.\r
+\r
+ @param[in] Event Event whose notification function is being invoked\r
+ @param[in] Context Pointer to the notification function's context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+OnReadyToBoot (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ UINTN DataSize;\r
+ \r
+ if (MOR_CLEAR_MEMORY_VALUE (mMorControl) == 0x0) {\r
+ //\r
+ // MorControl is expected, directly return to avoid unnecessary variable operation\r
+ //\r
+ return ;\r
+ }\r
+ //\r
+ // Clear MOR_CLEAR_MEMORY_BIT\r
+ //\r
+ DEBUG ((EFI_D_INFO, "TcgMor: Clear MorClearMemory bit\n"));\r
+ mMorControl &= 0xFE; \r
+\r
+ DataSize = sizeof (mMorControl);\r
+ gRT->SetVariable (\r
+ MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
+ &gEfiMemoryOverwriteControlDataGuid, \r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize, \r
+ &mMorControl\r
+ );\r
+\r
+}\r
+\r
+\r