Update PEI/DXE/SMM dispatchers to include DEBUG ((DEBUG_DISPATCH, )) macros to log the evaluation of all dependency expressions.

This logging can be enabled by setting the DEBUG_DISPATCH bit(0x80) of the PCD gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel.





git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11117 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
mdkinney 2010-12-04 20:05:09 +00:00
parent 852b634128
commit 6a55eea3eb
6 changed files with 153 additions and 9 deletions

View File

@ -5,7 +5,7 @@
if a driver can be scheduled for execution. The criteria for if a driver can be scheduled for execution. The criteria for
schedulability is that the dependency expression is satisfied. schedulability is that the dependency expression is satisfied.
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -220,6 +220,8 @@ CoreIsSchedulable (
EFI_GUID DriverGuid; EFI_GUID DriverGuid;
VOID *Interface; VOID *Interface;
DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));
Operator = FALSE; Operator = FALSE;
Operator2 = FALSE; Operator2 = FALSE;
@ -236,9 +238,12 @@ CoreIsSchedulable (
// A NULL Depex means treat the driver like an UEFI 2.0 thing. // A NULL Depex means treat the driver like an UEFI 2.0 thing.
// //
Status = CoreAllEfiServicesAvailable (); Status = CoreAllEfiServicesAvailable ();
DEBUG ((DEBUG_DISPATCH, " All UEFI Services Available = "));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, "FALSE\n RESULT = FALSE\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, "TRUE\n RESULT = TRUE\n"));
return TRUE; return TRUE;
} }
@ -257,6 +262,7 @@ CoreIsSchedulable (
// past the end of the dependency expression. // past the end of the dependency expression.
// //
if (((UINTN)Iterator - (UINTN)DriverEntry->Depex) >= DriverEntry->DepexSize) { if (((UINTN)Iterator - (UINTN)DriverEntry->Depex) >= DriverEntry->DepexSize) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Attempt to fetch past end of depex)\n"));
return FALSE; return FALSE;
} }
@ -272,6 +278,7 @@ CoreIsSchedulable (
// If the code flow arrives at this point, there was a BEFORE or AFTER // If the code flow arrives at this point, there was a BEFORE or AFTER
// that were not the first opcodes. // that were not the first opcodes.
// //
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));
ASSERT (FALSE); ASSERT (FALSE);
case EFI_DEP_SOR: case EFI_DEP_SOR:
// //
@ -279,8 +286,11 @@ CoreIsSchedulable (
// at any other location, then the dependency expression evaluates to FALSE // at any other location, then the dependency expression evaluates to FALSE
// //
if (Iterator != DriverEntry->Depex) { if (Iterator != DriverEntry->Depex) {
DEBUG ((DEBUG_DISPATCH, " SOR\n"));
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected SOR opcode)\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, " SOR = Requested\n"));
// //
// Otherwise, it is the first opcode and should be treated as a NOP. // Otherwise, it is the first opcode and should be treated as a NOP.
// //
@ -296,12 +306,15 @@ CoreIsSchedulable (
Status = CoreLocateProtocol (&DriverGuid, NULL, &Interface); Status = CoreLocateProtocol (&DriverGuid, NULL, &Interface);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
Status = PushBool (FALSE); Status = PushBool (FALSE);
} else { } else {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
*Iterator = EFI_DEP_REPLACE_TRUE; *Iterator = EFI_DEP_REPLACE_TRUE;
Status = PushBool (TRUE); Status = PushBool (TRUE);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
@ -309,75 +322,97 @@ CoreIsSchedulable (
break; break;
case EFI_DEP_AND: case EFI_DEP_AND:
DEBUG ((DEBUG_DISPATCH, " AND\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PopBool (&Operator2); Status = PopBool (&Operator2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(Operator && Operator2)); Status = PushBool ((BOOLEAN)(Operator && Operator2));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_OR: case EFI_DEP_OR:
DEBUG ((DEBUG_DISPATCH, " OR\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PopBool (&Operator2); Status = PopBool (&Operator2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(Operator || Operator2)); Status = PushBool ((BOOLEAN)(Operator || Operator2));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_NOT: case EFI_DEP_NOT:
DEBUG ((DEBUG_DISPATCH, " NOT\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(!Operator)); Status = PushBool ((BOOLEAN)(!Operator));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_TRUE: case EFI_DEP_TRUE:
DEBUG ((DEBUG_DISPATCH, " TRUE\n"));
Status = PushBool (TRUE); Status = PushBool (TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_FALSE: case EFI_DEP_FALSE:
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
Status = PushBool (FALSE); Status = PushBool (FALSE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_END: case EFI_DEP_END:
DEBUG ((DEBUG_DISPATCH, " END\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
return Operator; return Operator;
case EFI_DEP_REPLACE_TRUE: case EFI_DEP_REPLACE_TRUE:
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
Status = PushBool (TRUE); Status = PushBool (TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
@ -385,6 +420,7 @@ CoreIsSchedulable (
break; break;
default: default:
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unknown opcode)\n"));
goto Done; goto Done;
} }

View File

@ -333,9 +333,14 @@ CoreSchedule (
DriverEntry->Dependent = TRUE; DriverEntry->Dependent = TRUE;
CoreReleaseDispatcherLock (); CoreReleaseDispatcherLock ();
DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_SUCCESS\n", DriverName));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_NOT_FOUND\n", DriverName));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -572,6 +577,12 @@ CoreDispatcher (
CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
ReadyToRun = TRUE; ReadyToRun = TRUE;
} }
} else {
if (DriverEntry->Unrequested) {
DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " SOR = Not Requested\n"));
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE\n"));
}
} }
} }
} while (ReadyToRun); } while (ReadyToRun);
@ -611,12 +622,17 @@ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
// //
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE); DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->Before && DriverEntry->Dependent) { if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) { if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
// //
// Recursively process BEFORE // Recursively process BEFORE
// //
DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));
CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
} else {
DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));
} }
} }
} }
@ -637,12 +653,17 @@ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
// //
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE); DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->After && DriverEntry->Dependent) { if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) { if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
// //
// Recursively process AFTER // Recursively process AFTER
// //
DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));
CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
} else {
DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));
} }
} }
} }
@ -1139,23 +1160,24 @@ CoreFwVolEventProtocolNotify (
// drivers not in the current FV and these must be skipped since the a priori list // drivers not in the current FV and these must be skipped since the a priori list
// is only valid for the FV that it resided in. // is only valid for the FV that it resided in.
// //
CoreAcquireDispatcherLock ();
for (Index = 0; Index < AprioriEntryCount; Index++) { for (Index = 0; Index < AprioriEntryCount; Index++) {
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE); DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
if (CompareGuid (&DriverEntry->FileName, &AprioriFile[Index]) && if (CompareGuid (&DriverEntry->FileName, &AprioriFile[Index]) &&
(FvHandle == DriverEntry->FvHandle)) { (FvHandle == DriverEntry->FvHandle)) {
CoreAcquireDispatcherLock ();
DriverEntry->Dependent = FALSE; DriverEntry->Dependent = FALSE;
DriverEntry->Scheduled = TRUE; DriverEntry->Scheduled = TRUE;
InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink); InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);
CoreReleaseDispatcherLock ();
DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
break; break;
} }
} }
} }
CoreReleaseDispatcherLock ();
// //
// Free data allocated by Fv->ReadSection () // Free data allocated by Fv->ReadSection ()
// //

View File

@ -5,7 +5,7 @@
if a driver can be scheduled for execution. The criteria for if a driver can be scheduled for execution. The criteria for
schedulability is that the dependency expression is satisfied. schedulability is that the dependency expression is satisfied.
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -123,6 +123,7 @@ PeimDispatchReadiness (
// EvalStack on the push // EvalStack on the push
// //
if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) { if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE; return FALSE;
} }
@ -132,11 +133,17 @@ PeimDispatchReadiness (
// //
StackPtr->Operator = (VOID *) Iterator; StackPtr->Operator = (VOID *) Iterator;
Iterator = Iterator + sizeof (EFI_GUID); Iterator = Iterator + sizeof (EFI_GUID);
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = %a\n", StackPtr->Operator, IsPpiInstalled (PeiServices, StackPtr) ? "TRUE" : "FALSE"));
StackPtr++; StackPtr++;
break; break;
case (EFI_DEP_AND): case (EFI_DEP_AND):
case (EFI_DEP_OR): case (EFI_DEP_OR):
if (*(Iterator - 1) == EFI_DEP_AND) {
DEBUG ((DEBUG_DISPATCH, " AND\n"));
} else {
DEBUG ((DEBUG_DISPATCH, " OR\n"));
}
// //
// Check to make sure the dependency grammar doesn't underflow the // Check to make sure the dependency grammar doesn't underflow the
// EvalStack on the two POPs for the AND operation. Don't need to // EvalStack on the two POPs for the AND operation. Don't need to
@ -144,6 +151,7 @@ PeimDispatchReadiness (
// did two POPs. // did two POPs.
// //
if (StackPtr < &EvalStack[2]) { if (StackPtr < &EvalStack[2]) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE; return FALSE;
} }
@ -176,18 +184,22 @@ PeimDispatchReadiness (
break; break;
case (EFI_DEP_END): case (EFI_DEP_END):
DEBUG ((DEBUG_DISPATCH, " END\n"));
StackPtr--; StackPtr--;
// //
// Check to make sure EvalStack is balanced. If not, then there is // Check to make sure EvalStack is balanced. If not, then there is
// an error in the dependency grammar, so return EFI_INVALID_PARAMETER. // an error in the dependency grammar, so return EFI_INVALID_PARAMETER.
// //
if (StackPtr != &EvalStack[0]) { if (StackPtr != &EvalStack[0]) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", IsPpiInstalled (PeiServices, StackPtr) ? "TRUE" : "FALSE"));
return IsPpiInstalled (PeiServices, StackPtr); return IsPpiInstalled (PeiServices, StackPtr);
break; break;
case (EFI_DEP_NOT): case (EFI_DEP_NOT):
DEBUG ((DEBUG_DISPATCH, " NOT\n"));
// //
// Check to make sure the dependency grammar doesn't underflow the // Check to make sure the dependency grammar doesn't underflow the
// EvalStack on the POP for the NOT operation. Don't need to // EvalStack on the POP for the NOT operation. Don't need to
@ -195,6 +207,7 @@ PeimDispatchReadiness (
// did a POP. // did a POP.
// //
if (StackPtr < &EvalStack[1]) { if (StackPtr < &EvalStack[1]) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE; return FALSE;
} }
(StackPtr-1)->Result = (BOOLEAN) !IsPpiInstalled (PeiServices, (StackPtr-1)); (StackPtr-1)->Result = (BOOLEAN) !IsPpiInstalled (PeiServices, (StackPtr-1));
@ -203,11 +216,17 @@ PeimDispatchReadiness (
case (EFI_DEP_TRUE): case (EFI_DEP_TRUE):
case (EFI_DEP_FALSE): case (EFI_DEP_FALSE):
if (*(Iterator - 1) == EFI_DEP_TRUE) {
DEBUG ((DEBUG_DISPATCH, " TRUE\n"));
} else {
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
}
// //
// Check to make sure the dependency grammar doesn't overflow the // Check to make sure the dependency grammar doesn't overflow the
// EvalStack on the push // EvalStack on the push
// //
if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) { if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE; return FALSE;
} }
// //
@ -225,6 +244,7 @@ PeimDispatchReadiness (
break; break;
default: default:
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Invalid opcode)\n"));
// //
// The grammar should never arrive here // The grammar should never arrive here
// //

View File

@ -1078,11 +1078,20 @@ DepexSatisfied (
{ {
EFI_STATUS Status; EFI_STATUS Status;
VOID *DepexData; VOID *DepexData;
EFI_FV_FILE_INFO FileInfo;
Status = PeiServicesFfsGetFileInfo (FileHandle, &FileInfo);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, "Evaluate PEI DEPEX for FFS(Unknown)\n"));
} else {
DEBUG ((DEBUG_DISPATCH, "Evaluate PEI DEPEX for FFS(%g)\n", &FileInfo.FileName));
}
if (PeimCount < Private->AprioriCount) { if (PeimCount < Private->AprioriCount) {
// //
// If its in the A priori file then we set Depex to TRUE // If its in the A priori file then we set Depex to TRUE
// //
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
return TRUE; return TRUE;
} }
@ -1099,6 +1108,7 @@ DepexSatisfied (
// //
// If there is no DEPEX, assume the module can be executed // If there is no DEPEX, assume the module can be executed
// //
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (No DEPEX)\n"));
return TRUE; return TRUE;
} }

View File

@ -183,6 +183,8 @@ SmmIsSchedulable (
EFI_GUID DriverGuid; EFI_GUID DriverGuid;
VOID *Interface; VOID *Interface;
DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
Operator = FALSE; Operator = FALSE;
Operator2 = FALSE; Operator2 = FALSE;
@ -199,6 +201,7 @@ SmmIsSchedulable (
// A NULL Depex means that the SMM driver is not built correctly. // A NULL Depex means that the SMM driver is not built correctly.
// All SMM drivers must have a valid depex expressiion. // All SMM drivers must have a valid depex expressiion.
// //
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Depex is empty)\n"));
ASSERT (FALSE); ASSERT (FALSE);
return FALSE; return FALSE;
} }
@ -218,6 +221,7 @@ SmmIsSchedulable (
// past the end of the dependency expression. // past the end of the dependency expression.
// //
if (((UINTN)Iterator - (UINTN)DriverEntry->Depex) >= DriverEntry->DepexSize) { if (((UINTN)Iterator - (UINTN)DriverEntry->Depex) >= DriverEntry->DepexSize) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Attempt to fetch past end of depex)\n"));
return FALSE; return FALSE;
} }
@ -233,6 +237,7 @@ SmmIsSchedulable (
// If the code flow arrives at this point, there was a BEFORE or AFTER // If the code flow arrives at this point, there was a BEFORE or AFTER
// that were not the first opcodes. // that were not the first opcodes.
// //
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));
ASSERT (FALSE); ASSERT (FALSE);
case EFI_DEP_SOR: case EFI_DEP_SOR:
// //
@ -240,8 +245,11 @@ SmmIsSchedulable (
// at any other location, then the dependency expression evaluates to FALSE // at any other location, then the dependency expression evaluates to FALSE
// //
if (Iterator != DriverEntry->Depex) { if (Iterator != DriverEntry->Depex) {
DEBUG ((DEBUG_DISPATCH, " SOR\n"));
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected SOR opcode)\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, " SOR = Requested\n"));
// //
// Otherwise, it is the first opcode and should be treated as a NOP. // Otherwise, it is the first opcode and should be treated as a NOP.
// //
@ -263,12 +271,15 @@ SmmIsSchedulable (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
Status = PushBool (FALSE); Status = PushBool (FALSE);
} else { } else {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
*Iterator = EFI_DEP_REPLACE_TRUE; *Iterator = EFI_DEP_REPLACE_TRUE;
Status = PushBool (TRUE); Status = PushBool (TRUE);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
@ -276,75 +287,96 @@ SmmIsSchedulable (
break; break;
case EFI_DEP_AND: case EFI_DEP_AND:
DEBUG ((DEBUG_DISPATCH, " AND\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PopBool (&Operator2); Status = PopBool (&Operator2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(Operator && Operator2)); Status = PushBool ((BOOLEAN)(Operator && Operator2));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_OR: case EFI_DEP_OR:
DEBUG ((DEBUG_DISPATCH, " OR\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PopBool (&Operator2); Status = PopBool (&Operator2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(Operator || Operator2)); Status = PushBool ((BOOLEAN)(Operator || Operator2));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_NOT: case EFI_DEP_NOT:
DEBUG ((DEBUG_DISPATCH, " NOT\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
Status = PushBool ((BOOLEAN)(!Operator)); Status = PushBool ((BOOLEAN)(!Operator));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_TRUE: case EFI_DEP_TRUE:
DEBUG ((DEBUG_DISPATCH, " TRUE\n"));
Status = PushBool (TRUE); Status = PushBool (TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_FALSE: case EFI_DEP_FALSE:
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
Status = PushBool (FALSE); Status = PushBool (FALSE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
break; break;
case EFI_DEP_END: case EFI_DEP_END:
DEBUG ((DEBUG_DISPATCH, " END\n"));
Status = PopBool (&Operator); Status = PopBool (&Operator);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
return Operator; return Operator;
case EFI_DEP_REPLACE_TRUE: case EFI_DEP_REPLACE_TRUE:
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
Status = PushBool (TRUE); Status = PushBool (TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
return FALSE; return FALSE;
} }
@ -352,6 +384,7 @@ SmmIsSchedulable (
break; break;
default: default:
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unknown opcode)\n"));
goto Done; goto Done;
} }

View File

@ -782,9 +782,14 @@ SmmSchedule (
DriverEntry->Unrequested = FALSE; DriverEntry->Unrequested = FALSE;
DriverEntry->Dependent = TRUE; DriverEntry->Dependent = TRUE;
DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_SUCCESS\n", DriverName));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_NOT_FOUND\n", DriverName));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -925,6 +930,12 @@ SmmDispatcher (
SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
ReadyToRun = TRUE; ReadyToRun = TRUE;
} }
} else {
if (DriverEntry->Unrequested) {
DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " SOR = Not Requested\n"));
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE\n"));
}
} }
} }
} while (ReadyToRun); } while (ReadyToRun);
@ -974,12 +985,17 @@ SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
// //
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE); DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->Before && DriverEntry->Dependent) { if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) { if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
// //
// Recursively process BEFORE // Recursively process BEFORE
// //
DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));
SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
} else {
DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));
} }
} }
} }
@ -998,12 +1014,17 @@ SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
// //
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE); DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->After && DriverEntry->Dependent) { if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) { if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
// //
// Recursively process AFTER // Recursively process AFTER
// //
DEBUG ((DEBUG_DISPATCH, "TRUE\n END\n RESULT = TRUE\n"));
SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
} else {
DEBUG ((DEBUG_DISPATCH, "FALSE\n END\n RESULT = FALSE\n"));
} }
} }
} }
@ -1340,6 +1361,8 @@ SmmDriverDispatchHandler (
DriverEntry->Dependent = FALSE; DriverEntry->Dependent = FALSE;
DriverEntry->Scheduled = TRUE; DriverEntry->Scheduled = TRUE;
InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink); InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);
DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
break; break;
} }
} }