summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2015-06-18 09:26:41 +0000
committerlzeng14 <lzeng14@Edk2>2015-06-18 09:26:41 +0000
commit53ec4d7f98a6af8b00c891c3f13791967e52b6a3 (patch)
treefd2b0b4d2b8949f0bd39cd05c46be7501b073bdd /MdeModulePkg/Core
parent93e8630a8debe1bd76c175370acf684bda69d558 (diff)
downloadedk2-platforms-53ec4d7f98a6af8b00c891c3f13791967e52b6a3.tar.xz
MdeModulePkg PiSmmCore: Introduce SMM Exit Boot Services and Legacy Boot.
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
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/PiSmmCore/PiSmmCore.c122
-rw-r--r--MdeModulePkg/Core/PiSmmCore/PiSmmCore.h47
-rw-r--r--MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf5
-rw-r--r--MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c11
-rw-r--r--MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf8
5 files changed, 183 insertions, 10 deletions
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 187cb8e68e..852f8b90f6 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/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,109 @@ 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;
+
+ SmiHandlerUnRegister (DispatchHandle);
+
+ 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
+ );
+
+ SmiHandlerUnRegister (DispatchHandle);
+
+ 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
+ );
+
+ SmiHandlerUnRegister (DispatchHandle);
+
+ return Status;
}
/**
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
index afac9e2db3..e34bd8a640 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
+++ b/MdeModulePkg/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/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index 784dea64a5..9c06b2ac2f 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/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/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index ba596cd1b7..4dd1352971 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/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/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
index 236ffa5d64..6f027a6056 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+++ b/MdeModulePkg/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