EmbeddedPkg/FdtPlatformDxe: 'setfdt' command, add deletion of the UEFI variable "Fdt"

Add deletion of the "Fdt" UEFI variable used to specify
a development FDT device path when the 'setfdt' command
is called with an empty string as file path.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <Ronald.Cron@arm.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17300 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ronald Cron 2015-05-05 15:24:17 +00:00 committed by oliviermartin
parent 4589ffaa85
commit bbd6a1617f
1 changed files with 60 additions and 47 deletions

View File

@ -747,52 +747,55 @@ UpdateFdtTextDevicePath (
SHELL_STATUS ShellStatus; SHELL_STATUS ShellStatus;
ASSERT (FilePath != NULL); ASSERT (FilePath != NULL);
DevicePath = NULL;
TextDevicePath = NULL; TextDevicePath = NULL;
FdtVariableValue = NULL; FdtVariableValue = NULL;
DevicePath = Shell->GetDevicePathFromFilePath (FilePath); if (*FilePath != L'\0') {
if (DevicePath != NULL) { DevicePath = Shell->GetDevicePathFromFilePath (FilePath);
Status = gBS->LocateProtocol ( if (DevicePath != NULL) {
&gEfiDevicePathToTextProtocolGuid, Status = gBS->LocateProtocol (
NULL, &gEfiDevicePathToTextProtocolGuid,
(VOID **)&EfiDevicePathToTextProtocol NULL,
); (VOID **)&EfiDevicePathToTextProtocol
if (EFI_ERROR (Status)) { );
goto Error; if (EFI_ERROR (Status)) {
} goto Error;
}
TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText ( TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText (
DevicePath, DevicePath,
FALSE, FALSE,
FALSE FALSE
);
if (TextDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
FdtVariableValue = TextDevicePath;
} else {
//
// Try to convert back the EFI Device Path String into a EFI device Path
// to ensure the format is valid
//
Status = gBS->LocateProtocol (
&gEfiDevicePathFromTextProtocolGuid,
NULL,
(VOID **)&EfiDevicePathFromTextProtocol
);
if (EFI_ERROR (Status)) {
goto Error;
}
DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (
FilePath
); );
if (TextDevicePath == NULL) { if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_INVALID_PARAMETER;
goto Error; goto Error;
}
FdtVariableValue = (CHAR16*)FilePath;
} }
FdtVariableValue = TextDevicePath;
} else {
//
// Try to convert back the EFI Device Path String into a EFI device Path
// to ensure the format is valid
//
Status = gBS->LocateProtocol (
&gEfiDevicePathFromTextProtocolGuid,
NULL,
(VOID **)&EfiDevicePathFromTextProtocol
);
if (EFI_ERROR (Status)) {
goto Error;
}
DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (
FilePath
);
if (DevicePath == NULL) {
Status = EFI_INVALID_PARAMETER;
goto Error;
}
FdtVariableValue = (CHAR16*)FilePath;
} }
Status = gRT->SetVariable ( Status = gRT->SetVariable (
@ -801,19 +804,29 @@ UpdateFdtTextDevicePath (
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS , EFI_VARIABLE_BOOTSERVICE_ACCESS ,
StrSize (FdtVariableValue), (FdtVariableValue != NULL) ?
StrSize (FdtVariableValue) : 0,
FdtVariableValue FdtVariableValue
); );
Error: Error:
ShellStatus = EfiCodeToShellCode (Status); ShellStatus = EfiCodeToShellCode (Status);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ShellPrintHiiEx ( if (FdtVariableValue != NULL) {
-1, -1, NULL, ShellPrintHiiEx (
STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED), -1, -1, NULL,
mFdtPlatformDxeHiiHandle, STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),
FdtVariableValue mFdtPlatformDxeHiiHandle,
); FdtVariableValue
);
} else {
ShellPrintHiiEx (
-1, -1, NULL,
STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),
mFdtPlatformDxeHiiHandle,
FdtVariableValue
);
}
} else { } else {
if (Status == EFI_INVALID_PARAMETER) { if (Status == EFI_INVALID_PARAMETER) {
ShellPrintHiiEx ( ShellPrintHiiEx (