]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg PiSmmCore: Unregister each other for LegacyBoot and EBS
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.c
index 4aef9b70a1d0111b1fbdf8d3602996ab44ab74c6..dbb89932e75bd074e459987914e533369293f0ea 100644 (file)
@@ -157,6 +157,7 @@ SmmLegacyBootHandler (
 {\r
   EFI_STATUS    Status;\r
   EFI_HANDLE    SmmHandle;\r
+  UINTN         Index;\r
 \r
   //\r
   // Install SMM Legacy Boot protocol.\r
@@ -173,6 +174,16 @@ SmmLegacyBootHandler (
 \r
   SmiHandlerUnRegister (DispatchHandle);\r
 \r
+  //\r
+  // It is legacy boot, unregister ExitBootService SMI handler.\r
+  //\r
+  for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {\r
+    if (CompareGuid (mSmmCoreSmiHandlers[Index].HandlerType, &gEfiEventExitBootServicesGuid)) {\r
+      SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);\r
+      break;\r
+    }\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
@@ -201,6 +212,7 @@ SmmExitBootServicesHandler (
 {\r
   EFI_STATUS    Status;\r
   EFI_HANDLE    SmmHandle;\r
+  UINTN         Index;\r
 \r
   //\r
   // Install SMM Exit Boot Services protocol.\r
@@ -215,6 +227,16 @@ SmmExitBootServicesHandler (
 \r
   SmiHandlerUnRegister (DispatchHandle);\r
 \r
+  //\r
+  // It is UEFI boot, unregister LegacyBoot SMI handler.\r
+  //\r
+  for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {\r
+    if (CompareGuid (mSmmCoreSmiHandlers[Index].HandlerType, &gEfiEventLegacyBootGuid)) {\r
+      SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);\r
+      break;\r
+    }\r
+  }\r
+\r
   return Status;\r
 }\r
 \r