Sync the fix for recovery mode from MdeModulePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12290 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
gdong1 2011-09-07 10:10:11 +00:00
parent ae5dc79532
commit 1f58a5dcd4
1 changed files with 45 additions and 16 deletions

View File

@ -32,6 +32,32 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
}; };
/**
Check if it runs in Recovery mode.
@param PeiServices General purpose services available to every PEIM.
@retval TRUE It's in Recovery mode.
@retval FALSE It's not in Recovery mode.
**/
BOOLEAN
IsInRecoveryMode (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_IN_RECOVERY_MODE) {
return TRUE;
}
return FALSE;
}
/** /**
Provide the functionality of the variable services. Provide the functionality of the variable services.
@ -50,23 +76,7 @@ PeimInitializeVariableServices (
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
{ {
EFI_BOOT_MODE BootMode;
EFI_STATUS Status;
//
// Check if this is recovery boot path. If no, publish the variable access capability
// to other modules. If yes, the content of variable area is not reliable. Therefore,
// in this case we should not provide variable service to other pei modules.
//
Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_IN_RECOVERY_MODE) {
return EFI_UNSUPPORTED;
}
return PeiServicesInstallPpi (&mPpiListVariable); return PeiServicesInstallPpi (&mPpiListVariable);
} }
/** /**
@ -548,6 +558,16 @@ PeiGetVariable (
if (VariableName == NULL || VariableGuid == NULL || DataSize == NULL) { if (VariableName == NULL || VariableGuid == NULL || DataSize == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
//
// Check if this is recovery boot path.
// If yes, the content of variable area is not reliable. Therefore we directly
// return EFI_NOT_FOUND.
//
if (IsInRecoveryMode(PeiServices)) {
return EFI_NOT_FOUND;
}
// //
// Find existing variable // Find existing variable
// //
@ -626,6 +646,15 @@ PeiGetNextVariableName (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
//
// Check if this is recovery boot path.
// If yes, the content of variable area is not reliable. Therefore we directly
// return EFI_NOT_FOUND.
//
if (IsInRecoveryMode(PeiServices)) {
return EFI_NOT_FOUND;
}
Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable); Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);
if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) { if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {
return Status; return Status;