From: Ronald Cron Date: Tue, 5 May 2015 15:23:02 +0000 (+0000) Subject: ArmPlatformPkg/FdtPlatformDxe: 'setfdt' command, add display of FDT device paths. X-Git-Tag: edk2-stable201903~9953 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=4589ffaa85551193ef541fc31dc436281005f0d5 ArmPlatformPkg/FdtPlatformDxe: 'setfdt' command, add display of FDT device paths. Add the display of the device paths that the FDT installation process goes through when the 'setfdt' EFI Shell command is called without any parameter. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron Reviewed-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17299 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c index 8702765c6a..b5ae8c0bb5 100644 --- a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c +++ b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c @@ -50,6 +50,10 @@ STATIC CHAR16* EFIAPI ShellDynCmdSetFdtGetHelp ( IN CONST CHAR8 *Language ); +STATIC VOID DisplayFdtDevicePaths ( + VOID + ); + STATIC SHELL_STATUS UpdateFdtTextDevicePath ( IN EFI_SHELL_PROTOCOL *Shell, IN CONST CHAR16 *FilePath @@ -478,10 +482,10 @@ ShellDynCmdSetFdtHandler ( switch (ShellCommandLineGetCount (ParamPackage)) { case 1: // - // Case "setfdt -i" + // Case "setfdt" or "setfdt -i" // if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) { - Status = EFI_INVALID_PARAMETER; + DisplayFdtDevicePaths (); } break; @@ -557,6 +561,7 @@ ShellDynCmdSetFdtHandler ( Status ); } + DisplayFdtDevicePaths (); } } @@ -601,6 +606,109 @@ ShellDynCmdSetFdtGetHelp ( ); } +/** + Display FDT device paths. + + Display in text form the device paths used to install the FDT from the + highest to the lowest priority. + +**/ +STATIC +VOID +DisplayFdtDevicePaths ( + VOID + ) +{ + EFI_STATUS Status; + UINTN DataSize; + CHAR16 *TextDevicePath; + CHAR16 *TextDevicePaths; + CHAR16 *TextDevicePathSeparator; + + ShellPrintHiiEx ( + -1, -1, NULL, + STRING_TOKEN (STR_SETFDT_DEVICE_PATH_LIST), + mFdtPlatformDxeHiiHandle + ); + + if (FeaturePcdGet (PcdOverridePlatformFdt)) { + DataSize = 0; + Status = gRT->GetVariable ( + L"Fdt", + &gFdtVariableGuid, + NULL, + &DataSize, + NULL + ); + + // + // Keep going only if the "Fdt" variable is defined. + // + + if (Status == EFI_BUFFER_TOO_SMALL) { + TextDevicePath = AllocatePool (DataSize); + if (TextDevicePath == NULL) { + return; + } + + Status = gRT->GetVariable ( + L"Fdt", + &gFdtVariableGuid, + NULL, + &DataSize, + TextDevicePath + ); + if (!EFI_ERROR (Status)) { + ShellPrintHiiEx ( + -1, -1, NULL, + STRING_TOKEN (STR_SETFDT_DEVICE_PATH), + mFdtPlatformDxeHiiHandle, + TextDevicePath + ); + } + + FreePool (TextDevicePath); + } + } + + // + // Loop over the device path list provided by "PcdFdtDevicePaths". The device + // paths are in text form and separated by a semi-colon. + // + + TextDevicePaths = AllocateCopyPool ( + StrSize ((CHAR16*)PcdGetPtr (PcdFdtDevicePaths)), + (CHAR16*)PcdGetPtr (PcdFdtDevicePaths) + ); + if (TextDevicePaths == NULL) { + return; + } + + for (TextDevicePath = TextDevicePaths; + *TextDevicePath != L'\0' ; ) { + TextDevicePathSeparator = StrStr (TextDevicePath, L";"); + + if (TextDevicePathSeparator != NULL) { + *TextDevicePathSeparator = L'\0'; + } + + ShellPrintHiiEx ( + -1, -1, NULL, + STRING_TOKEN (STR_SETFDT_DEVICE_PATH), + mFdtPlatformDxeHiiHandle, + TextDevicePath + ); + + if (TextDevicePathSeparator == NULL) { + break; + } + TextDevicePath = TextDevicePathSeparator + 1; + } + + FreePool (TextDevicePaths); + +} + /** Update the text device path stored in the "Fdt" UEFI variable given an EFI Shell file path or a text device path.