]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PiSmmCore: Introduce SMM Exit Boot Services and Legacy Boot.
authorStar Zeng <star.zeng@intel.com>
Thu, 18 Jun 2015 09:26:41 +0000 (09:26 +0000)
committerlzeng14 <lzeng14@Edk2>
Thu, 18 Jun 2015 09:26:41 +0000 (09:26 +0000)
And also SMM Ready To Boot.

The SMM Exit Boot Service protocol is to be published by the SMM
Foundation code to associate with EFI_EVENT_GROUP_EXIT_BOOT_SERVICES
to notify SMM driver that system enter exit boot services.

The SMM Legacy Boot protocol is to be published by the SMM
Foundation code to associate with EFI_EVENT_LEGACY_BOOT_GUID
to notify SMM driver that system enter legacy boot.

The SMM Ready To Boot protocol is to be published by the SMM
Foundation code to associate with EFI_EVENT_GROUP_READY_TO_BOOT
to notify SMM driver that system enter ready to boot.

After them, any SMM drivers can get protocol notify on what happened
in DXE phase, then there is no need to let each individual SMM driver
to register SMM Communication Handler for that.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17657 6f19259b-4bc3-4df7-8a09-765794883524

Include/Protocol/SmmExitBootServices.h [new file with mode: 0644]
Include/Protocol/SmmLegacyBoot.h [new file with mode: 0644]
Include/Protocol/SmmReadyToBoot.h [new file with mode: 0644]
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
MdeModulePkg/MdeModulePkg.dec

diff --git a/Include/Protocol/SmmExitBootServices.h b/Include/Protocol/SmmExitBootServices.h
new file mode 100644 (file)
index 0000000..f343767
--- /dev/null
@@ -0,0 +1,29 @@
+/** @file\r
+  EDKII SMM Exit Boot Services protocol.\r
+\r
+  This SMM protocol is to be published by the SMM Foundation code to associate\r
+  with EFI_EVENT_GROUP_EXIT_BOOT_SERVICES to notify SMM driver that system enter\r
+  exit boot services.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_EXIT_BOOT_SERVICES_H_\r
+#define _SMM_EXIT_BOOT_SERVICES_H_\r
+\r
+#define EDKII_SMM_EXIT_BOOT_SERVICES_PROTOCOL_GUID \\r
+  { \\r
+    0x296eb418, 0xc4c8, 0x4e05, { 0xab, 0x59, 0x39, 0xe8, 0xaf, 0x56, 0xf0, 0xa } \\r
+  }\r
+\r
+extern EFI_GUID gEdkiiSmmExitBootServicesProtocolGuid;\r
+\r
+#endif\r
diff --git a/Include/Protocol/SmmLegacyBoot.h b/Include/Protocol/SmmLegacyBoot.h
new file mode 100644 (file)
index 0000000..854c34a
--- /dev/null
@@ -0,0 +1,28 @@
+/** @file\r
+  EDKII SMM Legacy Boot protocol.\r
+\r
+  This SMM protocol is to be published by the SMM Foundation code to associate\r
+  with EFI_EVENT_LEGACY_BOOT_GUID to notify SMM driver that system enter legacy boot.\r
+\r
+  Copyright (c) 2015 Intel Corporation. All rights reserved.<BR>\r
+  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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_LEGACY_BOOT_H_\r
+#define _SMM_LEGACY_BOOT_H_\r
+\r
+#define EDKII_SMM_LEGACY_BOOT_PROTOCOL_GUID \\r
+  { \\r
+    0x85a8ab57, 0x644, 0x4110, { 0x85, 0xf, 0x98, 0x13, 0x22, 0x4, 0x70, 0x70 } \\r
+  }\r
+\r
+extern EFI_GUID gEdkiiSmmLegacyBootProtocolGuid;\r
+\r
+#endif\r
diff --git a/Include/Protocol/SmmReadyToBoot.h b/Include/Protocol/SmmReadyToBoot.h
new file mode 100644 (file)
index 0000000..b6867f5
--- /dev/null
@@ -0,0 +1,29 @@
+/** @file\r
+  EDKII SMM Ready To Boot protocol.\r
+\r
+  This SMM protocol is to be published by the SMM Foundation code to associate\r
+  with EFI_EVENT_GROUP_READY_TO_BOOT to notify SMM driver that system enter\r
+  ready to boot.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_READY_TO_BOOT_H_\r
+#define _SMM_READY_TO_BOOT_H_\r
+\r
+#define EDKII_SMM_READY_TO_BOOT_PROTOCOL_GUID \\r
+  { \\r
+    0x6e057ecf, 0xfa99, 0x4f39, { 0x95, 0xbc, 0x59, 0xf9, 0x92, 0x1d, 0x17, 0xe4 } \\r
+  }\r
+\r
+extern EFI_GUID gEdkiiSmmReadyToBootProtocolGuid;\r
+\r
+#endif\r
index 187cb8e68e4870322c22cff6e3c6f127424f20e1..852f8b90f687d0426a870daa96929a92d2cc68cb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Core Main Entry Point\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -66,7 +66,7 @@ EFI_SMM_SYSTEM_TABLE2  gSmmCoreSmst = {
 //\r
 // Flag to determine if the platform has performed a legacy boot.\r
 // If this flag is TRUE, then the runtime code and runtime data associated with the \r
-// SMM IPL are converted to free memory, so the SMM COre must guarantee that is\r
+// SMM IPL are converted to free memory, so the SMM Core must guarantee that is\r
 // does not touch of the code/data associated with the SMM IPL if this flag is TRUE.\r
 //\r
 BOOLEAN  mInLegacyBoot = FALSE;\r
@@ -75,11 +75,13 @@ BOOLEAN  mInLegacyBoot = FALSE;
 // Table of SMI Handlers that are registered by the SMM Core when it is initialized\r
 //\r
 SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {\r
-  { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid,          NULL, TRUE  },\r
-  { SmmReadyToLockHandler,    &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, \r
-  { SmmLegacyBootHandler,     &gEfiEventLegacyBootGuid,           NULL, FALSE },\r
-  { SmmEndOfDxeHandler,       &gEfiEndOfDxeEventGroupGuid,        NULL, FALSE },\r
-  { NULL,                     NULL,                               NULL, FALSE }\r
+  { SmmDriverDispatchHandler,   &gEfiEventDxeDispatchGuid,          NULL, TRUE  },\r
+  { SmmReadyToLockHandler,      &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, \r
+  { SmmLegacyBootHandler,       &gEfiEventLegacyBootGuid,           NULL, FALSE },\r
+  { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,     NULL, FALSE },\r
+  { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,          NULL, FALSE },\r
+  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,        NULL, FALSE },\r
+  { NULL,                       NULL,                               NULL, FALSE }\r
 };\r
 \r
 UINTN                           mFullSmramRangeCount;\r
@@ -121,7 +123,8 @@ SmmEfiNotAvailableYetArg5 (
   Core uses this signal to know that a Legacy Boot has been performed and that \r
   gSmmCorePrivate that is shared between the UEFI and SMM execution environments can\r
   not be accessed from SMM anymore since that structure is considered free memory by\r
-  a legacy OS.\r
+  a legacy OS. Then the SMM Core also install SMM Legacy Boot protocol to notify SMM\r
+  driver that system enter legacy boot.\r
 \r
   @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
   @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
@@ -141,8 +144,109 @@ SmmLegacyBootHandler (
   IN OUT UINTN       *CommBufferSize  OPTIONAL\r
   )\r
 {\r
+  EFI_STATUS    Status;\r
+  EFI_HANDLE    SmmHandle;\r
+\r
+  //\r
+  // Install SMM Legacy Boot protocol.\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEdkiiSmmLegacyBootProtocolGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+\r
   mInLegacyBoot = TRUE;\r
-  return EFI_SUCCESS;\r
+\r
+  SmiHandlerUnRegister (DispatchHandle);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Software SMI handler that is called when an Exit Boot Services event is signalled.\r
+  Then the SMM Core also install SMM Exit Boot Services protocol to notify SMM driver\r
+  that system enter exit boot services.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmExitBootServicesHandler (\r
+  IN     EFI_HANDLE  DispatchHandle,\r
+  IN     CONST VOID  *Context,        OPTIONAL\r
+  IN OUT VOID        *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN       *CommBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_HANDLE    SmmHandle;\r
+\r
+  //\r
+  // Install SMM Exit Boot Services protocol.\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEdkiiSmmExitBootServicesProtocolGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+\r
+  SmiHandlerUnRegister (DispatchHandle);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Software SMI handler that is called when an Ready To Boot event is signalled.\r
+  Then the SMM Core also install SMM Ready To Boot protocol to notify SMM driver\r
+  that system enter ready to boot.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmReadyToBootHandler (\r
+  IN     EFI_HANDLE  DispatchHandle,\r
+  IN     CONST VOID  *Context,        OPTIONAL\r
+  IN OUT VOID        *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN       *CommBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_HANDLE    SmmHandle;\r
+\r
+  //\r
+  // Install SMM Ready To Boot protocol.\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEdkiiSmmReadyToBootProtocolGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+\r
+  SmiHandlerUnRegister (DispatchHandle);\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
index afac9e2db37c0f7dcfdb9b375f4041a553daa5ed..e34bd8a640f3a1261eac452cdb8c6d3e078c1047 100644 (file)
@@ -29,6 +29,9 @@
 #include <Protocol/DevicePath.h>        \r
 #include <Protocol/Security.h>          \r
 #include <Protocol/Security2.h>\r
+#include <Protocol/SmmExitBootServices.h>\r
+#include <Protocol/SmmLegacyBoot.h>\r
+#include <Protocol/SmmReadyToBoot.h>\r
 \r
 #include <Guid/Apriori.h>\r
 #include <Guid/EventGroup.h>\r
@@ -692,6 +695,50 @@ SmmEndOfDxeHandler (
   IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
   );\r
 \r
+/**\r
+  This function is the main entry point for an SMM handler dispatch\r
+  or communicate-based callback.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmExitBootServicesHandler (\r
+  IN     EFI_HANDLE               DispatchHandle,\r
+  IN     CONST VOID               *Context,        OPTIONAL\r
+  IN OUT VOID                     *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function is the main entry point for an SMM handler dispatch\r
+  or communicate-based callback.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmReadyToBootHandler (\r
+  IN     EFI_HANDLE               DispatchHandle,\r
+  IN     CONST VOID               *Context,        OPTIONAL\r
+  IN OUT VOID                     *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
+  );\r
+\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
index 784dea64a5799bcc5dfae4e011c71c9c928560f3..9c06b2ac2fd7e45540d5792cb08e636ab4fdef5a 100644 (file)
@@ -72,6 +72,9 @@
   gEfiSecurity2ArchProtocolGuid                 ## SOMETIMES_CONSUMES\r
   gEfiLoadedImageProtocolGuid                   ## PRODUCES\r
   gEfiDevicePathProtocolGuid                    ## CONSUMES\r
+  gEdkiiSmmExitBootServicesProtocolGuid         ## SOMETIMES_PRODUCES\r
+  gEdkiiSmmLegacyBootProtocolGuid               ## SOMETIMES_PRODUCES\r
+  gEdkiiSmmReadyToBootProtocolGuid              ## PRODUCES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber     ## SOMETIMES_CONSUMES\r
@@ -83,6 +86,8 @@
   gAprioriGuid                                  ## SOMETIMES_CONSUMES   ## File\r
   gEfiEventDxeDispatchGuid                      ## PRODUCES             ## GUID # SmiHandlerRegister\r
   gEfiEventLegacyBootGuid                       ## PRODUCES             ## GUID # SmiHandlerRegister\r
+  gEfiEventExitBootServicesGuid                 ## PRODUCES             ## GUID # SmiHandlerRegister\r
+  gEfiEventReadyToBootGuid                      ## PRODUCES             ## GUID # SmiHandlerRegister\r
   gEfiEndOfDxeEventGroupGuid                    ## PRODUCES             ## GUID # SmiHandlerRegister\r
   ## SOMETIMES_CONSUMES   ## GUID # Locate protocol\r
   ## SOMETIMES_PRODUCES   ## GUID # SmiHandlerRegister\r
index ba596cd1b7efd7c937fba74eff79fdce82caa9a1..4dd13529716cb8a69d2e2e00bc48246313a26df1 100644 (file)
@@ -283,9 +283,20 @@ SMM_IPL_EVENT_NOTIFICATION  mSmmIplEvents[] = {
   // Declare event notification on Legacy Boot Event Group.  This is used to inform the SMM Core that the platform \r
   // is performing a legacy boot operation, and that the UEFI environment is no longer available and the SMM Core \r
   // must guarantee that it does not access any UEFI related structures outside of SMRAM.\r
+  // It is also to inform the SMM Core to notify SMM driver that system enter legacy boot.\r
   //\r
   { FALSE, FALSE, &gEfiEventLegacyBootGuid,           SmmIplGuidedEventNotify,           &gEfiEventLegacyBootGuid,           TPL_CALLBACK, NULL },\r
   //\r
+  // Declare event notification on Exit Boot Services Event Group.  This is used to inform the SMM Core\r
+  // to notify SMM driver that system enter exit boot services.\r
+  //\r
+  { FALSE, FALSE, &gEfiEventExitBootServicesGuid,     SmmIplGuidedEventNotify,           &gEfiEventExitBootServicesGuid,     TPL_CALLBACK, NULL },\r
+  //\r
+  // Declare event notification on Ready To Boot Event Group.  This is used to inform the SMM Core\r
+  // to notify SMM driver that system enter ready to boot.\r
+  //\r
+  { FALSE, FALSE, &gEfiEventReadyToBootGuid,          SmmIplGuidedEventNotify,           &gEfiEventReadyToBootGuid,          TPL_CALLBACK, NULL },\r
+  //\r
   // Declare event notification on SetVirtualAddressMap() Event Group.  This is used to convert gSmmCorePrivate \r
   // and mSmmControl2 from physical addresses to virtual addresses.\r
   //\r
index 236ffa5d6455c0c5881db032f850ae8a614e3d99..6f027a6056a378cc4d3cb2db3bb59251a28a6b2c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  This module provide an SMM CIS compliant implementation of SMM IPL.\r
 #\r
-#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   ## SOMETIMES_CONSUMES ## Event\r
   ## SOMETIMES_PRODUCES ## UNDEFINED # Used to do smm communcation\r
   gEfiEventLegacyBootGuid\r
+  ## SOMETIMES_CONSUMES ## Event\r
+  ## SOMETIMES_PRODUCES ## UNDEFINED # Used to do smm communcation\r
+  gEfiEventExitBootServicesGuid\r
+  ## SOMETIMES_CONSUMES ## Event\r
+  ## SOMETIMES_PRODUCES ## UNDEFINED # Used to do smm communcation\r
+  gEfiEventReadyToBootGuid\r
   gEfiEventVirtualAddressChangeGuid             ## CONSUMES             ## Event\r
   gEfiEndOfDxeEventGroupGuid                    ## CONSUMES             ## Event\r
   gLoadFixedAddressConfigurationTableGuid       ## SOMETIMES_CONSUMES   ## SystemTable\r
index 75e37df805e358bcc8b25c56fb9cd77f29c00de8..14e27a27702e31cf43e4b10ab23ab7e016707fcb 100644 (file)
   ## Include/Protocol/EsrtManagement.h\r
   gEsrtManagementProtocolGuid         = { 0xa340c064, 0x723c, 0x4a9c, { 0xa4, 0xdd, 0xd5, 0xb4, 0x7a, 0x26, 0xfb, 0xb0 }}\r
 \r
+  ## Include/Protocol/SmmExitBootServices.h\r
+  gEdkiiSmmExitBootServicesProtocolGuid = { 0x296eb418, 0xc4c8, 0x4e05, { 0xab, 0x59, 0x39, 0xe8, 0xaf, 0x56, 0xf0, 0xa } }\r
+\r
+  ## Include/Protocol/SmmLegacyBoot.h\r
+  gEdkiiSmmLegacyBootProtocolGuid = { 0x85a8ab57, 0x644, 0x4110, { 0x85, 0xf, 0x98, 0x13, 0x22, 0x4, 0x70, 0x70 } }\r
+\r
+  ## Include/Protocol/SmmReadyToBoot.h\r
+  gEdkiiSmmReadyToBootProtocolGuid = { 0x6e057ecf, 0xfa99, 0x4f39, { 0x95, 0xbc, 0x59, 0xf9, 0x92, 0x1d, 0x17, 0xe4 } }\r
+\r
 #\r
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]\r
 #   0x80000001 | Invalid value provided.\r