summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core/PiSmmCore/Dispatcher.c
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-24 06:49:21 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-24 06:49:21 +0000
commit5657b268e71cd78ddbdfd2be7774289bfab03ea6 (patch)
treeec766cbceb4cec68586f8b4c98a70557bdabb490 /MdeModulePkg/Core/PiSmmCore/Dispatcher.c
parentad9aa87b5604cb17da688d5672b1e72e6ccde3b6 (diff)
downloadedk2-platforms-5657b268e71cd78ddbdfd2be7774289bfab03ea6.tar.xz
Update SMM Core to use SMM Mode as soon as SMM Mode is available
Signed-off-by: mdkinney Reviewed-by: rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12190 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/PiSmmCore/Dispatcher.c')
-rw-r--r--MdeModulePkg/Core/PiSmmCore/Dispatcher.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c
index 78c29ffe22..53eedbbf61 100644
--- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c
+++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c
@@ -743,13 +743,15 @@ SmmGetDepexSectionAndPreProccess (
drivers to run. Drain the mScheduledQueue and load and start a PE
image for each driver. Search the mDiscoveredList to see if any driver can
be placed on the mScheduledQueue. If no drivers are placed on the
- mScheduledQueue exit the function. On exit it is assumed the Bds()
- will be called, and when the Bds() exits the Dispatcher will be called
- again.
-
+ mScheduledQueue exit the function.
+
+ @retval EFI_SUCCESS All of the SMM Drivers that could be dispatched
+ have been run and the SMM Entry Point has been
+ registered.
+ @retval EFI_NOT_READY The SMM Driver that registered the SMM Entry Point
+ was just dispatched.
+ @retval EFI_NOT_FOUND There are no SMM Drivers available to be dispatched.
@retval EFI_ALREADY_STARTED The SMM Dispatcher is already running
- @retval EFI_NOT_FOUND No SMM Drivers were dispatched
- @retval EFI_SUCCESS One or more SMM Drivers were dispatched
**/
EFI_STATUS
@@ -758,10 +760,10 @@ SmmDispatcher (
)
{
EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
LIST_ENTRY *Link;
EFI_SMM_DRIVER_ENTRY *DriverEntry;
BOOLEAN ReadyToRun;
+ BOOLEAN PreviousSmmEntryPointRegistered;
if (!gRequestDispatch) {
return EFI_NOT_FOUND;
@@ -776,7 +778,6 @@ SmmDispatcher (
gDispatcherRunning = TRUE;
- ReturnStatus = EFI_NOT_FOUND;
do {
//
// Drain the Scheduled Queue
@@ -828,6 +829,11 @@ SmmDispatcher (
);
//
+ // Cache state of SmmEntryPointRegistered before calling entry point
+ //
+ PreviousSmmEntryPointRegistered = gSmmCorePrivate->SmmEntryPointRegistered;
+
+ //
// For each SMM driver, pass NULL as ImageHandle
//
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, gST);
@@ -842,7 +848,19 @@ SmmDispatcher (
sizeof (DriverEntry->ImageHandle)
);
- ReturnStatus = EFI_SUCCESS;
+ if (!PreviousSmmEntryPointRegistered && gSmmCorePrivate->SmmEntryPointRegistered) {
+ //
+ // Return immediately if the SMM Entry Point was registered by the SMM
+ // Driver that was just dispatched. The SMM IPL will reinvoke the SMM
+ // Core Dispatcher. This is required so SMM Mode may be enabled as soon
+ // as all the dependent SMM Drivers for SMM Mode have been dispatched.
+ // Once the SMM Entry Point has been registered, then SMM Mode will be
+ // used.
+ //
+ gRequestDispatch = TRUE;
+ gDispatcherRunning = FALSE;
+ return EFI_NOT_READY;
+ }
}
//
@@ -886,7 +904,7 @@ SmmDispatcher (
gDispatcherRunning = FALSE;
- return ReturnStatus;
+ return EFI_SUCCESS;
}
/**
@@ -1309,7 +1327,34 @@ SmmDriverDispatchHandler (
// Execute the SMM Dispatcher on any newly discovered FVs and previously
// discovered SMM drivers that have been discovered but not dispatched.
//
- return SmmDispatcher ();
+ Status = SmmDispatcher ();
+
+ //
+ // Check to see if CommBuffer and CommBufferSize are valid
+ //
+ if (CommBuffer != NULL && CommBufferSize != NULL) {
+ if (*CommBufferSize > 0) {
+ if (Status == EFI_NOT_READY) {
+ //
+ // If a the SMM Core Entry Point was just registered, then set flag to
+ // request the SMM Dispatcher to be restarted.
+ //
+ *(UINT8 *)CommBuffer = COMM_BUFFER_SMM_DISPATCH_RESTART;
+ } else if (!EFI_ERROR (Status)) {
+ //
+ // Set the flag to show that the SMM Dispatcher executed without errors
+ //
+ *(UINT8 *)CommBuffer = COMM_BUFFER_SMM_DISPATCH_SUCCESS;
+ } else {
+ //
+ // Set the flag to show that the SMM Dispatcher encountered an error
+ //
+ *(UINT8 *)CommBuffer = COMM_BUFFER_SMM_DISPATCH_ERROR;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
}
/**