]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
Update DXE Core to be compatible with PI 1.2 SMM Drivers.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain / DxeProtocolNotify.c
index 1bad3a3f7303140f0e721d7ed9ecccdd55d40832..3b805a9f9d5573bc3c0250e1a5b3fafa8e7731f5 100644 (file)
@@ -3,7 +3,7 @@
   the Dxe Core. The mArchProtocols[] array represents a list of\r
   events that represent the Architectural Protocols.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <DxeMain.h>\r
+#include "DxeMain.h"\r
 \r
 \r
 //\r
@@ -27,28 +27,50 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 \r
 ARCHITECTURAL_PROTOCOL_ENTRY  mArchProtocols[] = {\r
-  { &gEfiSecurityArchProtocolGuid,         (VOID **)&gSecurity,      NULL, NULL, FALSE },\r
-  { &gEfiCpuArchProtocolGuid,              (VOID **)&gCpu,           NULL, NULL, FALSE },\r
-  { &gEfiMetronomeArchProtocolGuid,        (VOID **)&gMetronome,     NULL, NULL, FALSE },\r
-  { &gEfiTimerArchProtocolGuid,            (VOID **)&gTimer,         NULL, NULL, FALSE },\r
-  { &gEfiBdsArchProtocolGuid,              (VOID **)&gBds,           NULL, NULL, FALSE },\r
-  { &gEfiWatchdogTimerArchProtocolGuid,    (VOID **)&gWatchdogTimer, NULL, NULL, FALSE },\r
-  { &gEfiRuntimeArchProtocolGuid,          (VOID **)&gRuntime,       NULL, NULL, FALSE },\r
-  { &gEfiVariableArchProtocolGuid,         (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { &gEfiVariableWriteArchProtocolGuid,    (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { &gEfiCapsuleArchProtocolGuid,          (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { &gEfiResetArchProtocolGuid,            (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { &gEfiRealTimeClockArchProtocolGuid,    (VOID **)NULL,            NULL, NULL, FALSE },\r
-  { NULL,                                  (VOID **)NULL,            NULL, NULL, FALSE }\r
+  { &gEfiSecurityArchProtocolGuid,         (VOID **)&gSecurity,      NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiCpuArchProtocolGuid,              (VOID **)&gCpu,           NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiMetronomeArchProtocolGuid,        (VOID **)&gMetronome,     NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiTimerArchProtocolGuid,            (VOID **)&gTimer,         NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiBdsArchProtocolGuid,              (VOID **)&gBds,           NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiWatchdogTimerArchProtocolGuid,    (VOID **)&gWatchdogTimer, NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiRuntimeArchProtocolGuid,          (VOID **)&gRuntime,       NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiVariableArchProtocolGuid,         (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiVariableWriteArchProtocolGuid,    (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiCapsuleArchProtocolGuid,          (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiResetArchProtocolGuid,            (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiRealTimeClockArchProtocolGuid,    (VOID **)NULL,            NULL, NULL, FALSE, TRUE  },\r
+  { &gEfiSmmBase2ProtocolGuid,             (VOID **)&gSmmBase2,      NULL, NULL, FALSE, FALSE }\r
 };\r
 \r
+//\r
+// Following is needed to display missing architectural protocols in debug builds\r
+//\r
+typedef struct {\r
+  EFI_GUID                     *ProtocolGuid;\r
+  CHAR8                        *GuidString;\r
+} GUID_TO_STRING_PROTOCOL_ENTRY;\r
 \r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {\r
+  { &gEfiSecurityArchProtocolGuid,         "Security"           },\r
+  { &gEfiCpuArchProtocolGuid,              "CPU"                },\r
+  { &gEfiMetronomeArchProtocolGuid,        "Metronome"          },\r
+  { &gEfiTimerArchProtocolGuid,            "Timer"              },\r
+  { &gEfiBdsArchProtocolGuid,              "Bds"                },\r
+  { &gEfiWatchdogTimerArchProtocolGuid,    "Watchdog Timer"     },\r
+  { &gEfiRuntimeArchProtocolGuid,          "Runtime"            },\r
+  { &gEfiVariableArchProtocolGuid,         "Variable"           },\r
+  { &gEfiVariableWriteArchProtocolGuid,    "Variable Write"     },\r
+  { &gEfiCapsuleArchProtocolGuid,          "Capsule"            },\r
+  { &gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter"  },\r
+  { &gEfiResetArchProtocolGuid,            "Reset"              },\r
+  { &gEfiRealTimeClockArchProtocolGuid,    "Real Time Clock"    }\r
+};\r
 \r
 /**\r
   Return TRUE if all AP services are availible.\r
 \r
-  @retval EFI_SUCCESS    All AP services are available \r
+  @retval EFI_SUCCESS    All AP services are available\r
   @retval EFI_NOT_FOUND  At least one AP service is not available\r
 \r
 **/\r
@@ -57,10 +79,10 @@ CoreAllEfiServicesAvailable (
   VOID\r
   )\r
 {\r
-  ARCHITECTURAL_PROTOCOL_ENTRY  *Entry;\r
+  UINTN        Index;\r
 \r
-  for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
-    if (!Entry->Present) {\r
+  for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) {\r
+    if (mArchProtocols[Index].ArchitecturalProtocol && !mArchProtocols[Index].Present) {\r
       return EFI_NOT_FOUND;\r
     }\r
   }\r
@@ -76,7 +98,7 @@ CoreAllEfiServicesAvailable (
   present flag to TRUE. If any constructor is required it is executed. The EFI\r
   System Table headers are updated.\r
 \r
-  @param  Event          The Event that is being processed, not used. \r
+  @param  Event          The Event that is being processed, not used.\r
   @param  Context        Event Context, not used.\r
 \r
 **/\r
@@ -93,9 +115,11 @@ GenericArchProtocolNotify (
   BOOLEAN                         Found;\r
   LIST_ENTRY                      *Link;\r
   LIST_ENTRY                      TempLinkNode;\r
+  UINTN                           Index;\r
 \r
   Found = FALSE;\r
-  for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
+  for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) {\r
+    Entry = &mArchProtocols[Index];\r
 \r
     Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol);\r
     if (EFI_ERROR (Status)) {\r
@@ -161,7 +185,7 @@ GenericArchProtocolNotify (
   //\r
   if (Found) {\r
     CalculateEfiHdrCrc (&gDxeCoreRT->Hdr);\r
-    CalculateEfiHdrCrc (&gDxeCoreBS->Hdr);\r
+    CalculateEfiHdrCrc (&gBS->Hdr);\r
     CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
     CalculateEfiHdrCrc (&gDxeCoreDS->Hdr);\r
   }\r
@@ -180,8 +204,10 @@ CoreNotifyOnArchProtocolInstallation (
 {\r
   EFI_STATUS                      Status;\r
   ARCHITECTURAL_PROTOCOL_ENTRY    *Entry;\r
+  UINTN                           Index;\r
 \r
-  for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
+  for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) {\r
+    Entry = &mArchProtocols[Index];\r
 \r
     //\r
     // Create the event\r
@@ -208,30 +234,6 @@ CoreNotifyOnArchProtocolInstallation (
   }\r
 }\r
 \r
-//\r
-// Following is needed to display missing architectural protocols in debug builds\r
-//\r
-typedef struct {\r
-  EFI_GUID                    *ProtocolGuid;\r
-  CHAR16                       *GuidString;\r
-} GUID_TO_STRING_PROTOCOL_ENTRY;\r
-\r
-CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {\r
-  { &gEfiSecurityArchProtocolGuid,         (CHAR16 *)L"Security"           },\r
-  { &gEfiCpuArchProtocolGuid,              (CHAR16 *)L"CPU"                },\r
-  { &gEfiMetronomeArchProtocolGuid,        (CHAR16 *)L"Metronome"          },\r
-  { &gEfiTimerArchProtocolGuid,            (CHAR16 *)L"Timer"              },\r
-  { &gEfiBdsArchProtocolGuid,              (CHAR16 *)L"Bds"                },\r
-  { &gEfiWatchdogTimerArchProtocolGuid,    (CHAR16 *)L"Watchdog Timer"     },\r
-  { &gEfiRuntimeArchProtocolGuid,          (CHAR16 *)L"Runtime"            },\r
-  { &gEfiVariableArchProtocolGuid,         (CHAR16 *)L"Variable"           },\r
-  { &gEfiVariableWriteArchProtocolGuid,    (CHAR16 *)L"Variable Write"     },\r
-  { &gEfiCapsuleArchProtocolGuid,          (CHAR16 *)L"Capsule"            },\r
-  { &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter"  },\r
-  { &gEfiResetArchProtocolGuid,            (CHAR16 *)L"Reset"              },\r
-  { &gEfiRealTimeClockArchProtocolGuid,    (CHAR16 *)L"Real Time Clock"    }\r
-};\r
-\r
 \r
 /**\r
   Displays Architectural protocols that were not loaded and are required for DXE\r
@@ -245,13 +247,14 @@ CoreDisplayMissingArchProtocols (
 {\r
   CONST GUID_TO_STRING_PROTOCOL_ENTRY  *MissingEntry;\r
   ARCHITECTURAL_PROTOCOL_ENTRY         *Entry;\r
+  UINTN                                Index;\r
 \r
-  for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
+  for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) {\r
+    Entry = &mArchProtocols[Index];\r
     if (!Entry->Present) {\r
-      MissingEntry = MissingProtocols;\r
       for (MissingEntry = MissingProtocols; TRUE ; MissingEntry++) {\r
         if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {\r
-          DEBUG ((DEBUG_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));\r
+          DEBUG ((DEBUG_ERROR, "\n%a Arch Protocol not present!!\n", MissingEntry->GuidString));\r
           break;\r
         }\r
       }\r