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.

Cc: Jiewen Yao <jiewen....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@intel.com>
---
 Core/PiSmmCore/PiSmmCore.c             | 74 +++++++++++++++++++++++++++++-----
 Core/PiSmmCore/PiSmmCore.h             | 24 +++++++++++
 Core/PiSmmCore/PiSmmCore.inf           |  3 ++
 Core/PiSmmCore/PiSmmIpl.c              |  6 +++
 Core/PiSmmCore/PiSmmIpl.inf            |  5 ++-
 Include/Protocol/SmmExitBootServices.h | 29 +++++++++++++
 Include/Protocol/SmmLegacyBoot.h       | 28 +++++++++++++
 MdeModulePkg.dec                       |  6 +++
 8 files changed, 165 insertions(+), 10 deletions(-)
 create mode 100644 Include/Protocol/SmmExitBootServices.h
 create mode 100644 Include/Protocol/SmmLegacyBoot.h

diff --git a/Core/PiSmmCore/PiSmmCore.c b/Core/PiSmmCore/PiSmmCore.c
index 187cb8e..f80f9ad 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,12 @@ 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 },
+  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,        NULL, 
FALSE },
+  { NULL,                       NULL,                               NULL, 
FALSE }
 };
 
 UINTN                           mFullSmramRangeCount;
@@ -121,7 +122,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 +143,62 @@ 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 Service event is 
signalled.
+  Then the SMM Core also install SMM Exit Boot Service 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;
 }
 
 /**
diff --git a/Core/PiSmmCore/PiSmmCore.h b/Core/PiSmmCore/PiSmmCore.h
index afac9e2..b224fa7 100644
--- a/Core/PiSmmCore/PiSmmCore.h
+++ b/Core/PiSmmCore/PiSmmCore.h
@@ -29,6 +29,8 @@
 #include <Protocol/DevicePath.h>        
 #include <Protocol/Security.h>          
 #include <Protocol/Security2.h>
+#include <Protocol/SmmExitBootServices.h>
+#include <Protocol/SmmLegacyBoot.h>
 
 #include <Guid/Apriori.h>
 #include <Guid/EventGroup.h>
@@ -693,6 +695,28 @@ 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
+  );
+
+/**
   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..c88416e 100644
--- a/Core/PiSmmCore/PiSmmCore.inf
+++ b/Core/PiSmmCore/PiSmmCore.inf
@@ -72,6 +72,8 @@
   gEfiSecurity2ArchProtocolGuid                 ## SOMETIMES_CONSUMES
   gEfiLoadedImageProtocolGuid                   ## PRODUCES
   gEfiDevicePathProtocolGuid                    ## CONSUMES
+  gEdkiiSmmExitBootServicesProtocolGuid         ## SOMETIMES_PRODUCES
+  gEdkiiSmmLegacyBootProtocolGuid               ## SOMETIMES_PRODUCES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber     ## 
SOMETIMES_CONSUMES
@@ -83,6 +85,7 @@
   gAprioriGuid                                  ## SOMETIMES_CONSUMES   ## File
   gEfiEventDxeDispatchGuid                      ## PRODUCES             ## 
GUID # SmiHandlerRegister
   gEfiEventLegacyBootGuid                       ## PRODUCES             ## 
GUID # SmiHandlerRegister
+  gEfiEventExitBootServicesGuid                 ## 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..f91f4b6 100644
--- a/Core/PiSmmCore/PiSmmIpl.c
+++ b/Core/PiSmmCore/PiSmmIpl.c
@@ -283,9 +283,15 @@ 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 Service 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 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..7267fc3 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,9 @@
   ## SOMETIMES_CONSUMES ## Event
   ## SOMETIMES_PRODUCES ## UNDEFINED # Used to do smm communcation
   gEfiEventLegacyBootGuid
+  ## SOMETIMES_CONSUMES ## Event
+  ## SOMETIMES_PRODUCES ## UNDEFINED # Used to do smm communcation
+  gEfiEventExitBootServicesGuid
   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/MdeModulePkg.dec b/MdeModulePkg.dec
index 75e37df..b402a27 100644
--- a/MdeModulePkg.dec
+++ b/MdeModulePkg.dec
@@ -413,6 +413,12 @@
   ## 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 } }
+
 #
 # [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