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.z...@intel.com>
Reviewed-by: Jiewen Yao <jiewen....@intel.com>
---
 Core/PiSmmCore/PiSmmCore.c             | 115 ++++++++++++++++++++++++++++++---
 Core/PiSmmCore/PiSmmCore.h             |  47 ++++++++++++++
 Core/PiSmmCore/PiSmmCore.inf           |   5 ++
 Core/PiSmmCore/PiSmmIpl.c              |  11 ++++
 Core/PiSmmCore/PiSmmIpl.inf            |   8 ++-
 Include/Protocol/SmmExitBootServices.h |  29 +++++++++
 Include/Protocol/SmmLegacyBoot.h       |  28 ++++++++
 Include/Protocol/SmmReadyToBoot.h      |  29 +++++++++
 MdeModulePkg.dec                       |   9 +++
 9 files changed, 271 insertions(+), 10 deletions(-)
 create mode 100644 Include/Protocol/SmmExitBootServices.h
 create mode 100644 Include/Protocol/SmmLegacyBoot.h
 create mode 100644 Include/Protocol/SmmReadyToBoot.h

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


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to