]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/FdtPlatformDxe: Move 'setfdt' Shell command into a separate file
authorOlivier Martin <olivier.martin@arm.com>
Tue, 5 May 2015 15:27:41 +0000 (15:27 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 5 May 2015 15:27:41 +0000 (15:27 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17302 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c
EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h [new file with mode: 0644]
EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c [new file with mode: 0644]

index 35a5fbacc2b2598a4ee2c9f782e16c4be30f8f69..38f31005f3a59d790a23f9828fa823f5d079d98a 100644 (file)
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
-#include <Uefi.h>\r
 \r
-#include <Library/UefiLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include "FdtPlatform.h"\r
+\r
 #include <Library/PcdLib.h>\r
 #include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/HiiLib.h>\r
 #include <Library/BdsLib.h>\r
-#include <Library/ShellLib.h>\r
 \r
-#include <Protocol/DevicePathToText.h>\r
-#include <Protocol/DevicePathFromText.h>\r
 #include <Protocol/DevicePath.h>\r
-#include <Protocol/EfiShell.h>\r
-#include <Protocol/EfiShellDynamicCommand.h>\r
-\r
-#include <Guid/Fdt.h>\r
 \r
 #include <libfdt.h>\r
 \r
-//\r
-// Internal types\r
-//\r
-\r
-STATIC SHELL_STATUS EFIAPI ShellDynCmdSetFdtHandler (\r
-  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
-  IN EFI_SYSTEM_TABLE                    *SystemTable,\r
-  IN EFI_SHELL_PARAMETERS_PROTOCOL       *ShellParameters,\r
-  IN EFI_SHELL_PROTOCOL                  *Shell\r
-  );\r
-\r
-STATIC CHAR16* EFIAPI ShellDynCmdSetFdtGetHelp (\r
-  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
-  IN CONST CHAR8                         *Language\r
-  );\r
-\r
-STATIC VOID DisplayFdtDevicePaths (\r
-  VOID\r
-  );\r
-\r
-STATIC SHELL_STATUS UpdateFdtTextDevicePath (\r
-  IN EFI_SHELL_PROTOCOL  *Shell,\r
-  IN CONST CHAR16        *FilePath\r
-  );\r
-\r
-STATIC SHELL_STATUS EfiCodeToShellCode (\r
-  IN EFI_STATUS  Status\r
-  );\r
-\r
 //\r
 // Internal variables\r
 //\r
@@ -77,12 +36,8 @@ STATIC CONST EFI_GUID  mFdtPlatformDxeHiiGuid = {
                          0x8afa7610, 0x62b1, 0x46aa,\r
                          {0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}\r
                          };\r
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
-  {L"-i", TypeFlag },\r
-  {NULL , TypeMax  }\r
-};\r
 \r
-STATIC EFI_HANDLE  mFdtPlatformDxeHiiHandle;\r
+EFI_HANDLE mFdtPlatformDxeHiiHandle;\r
 \r
 /**\r
   Install the FDT specified by its device path in text form.\r
@@ -225,7 +180,7 @@ FdtPlatformEntryPoint (
     // Register the strings for the user interface in the HII Database.\r
     // This shows the way to the multi-language support, even if\r
     // only the English language is actually supported. The strings to register\r
-    // are stored in the "FdtPlatformDxeStrings[]" array. This array is\r
+    // are stored in the "ShellSetFdtStrings[]" array. This array is\r
     // built by the building process from the "*.uni" file associated to\r
     // the present driver (cf. FdtPlatfromDxe.inf). Examine your Build\r
     // folder under your package's DEBUG folder and you will find the array\r
@@ -285,7 +240,6 @@ FdtPlatformEntryPoint (
   @retval  EFI_OUT_OF_RESOURCES   An allocation failed.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 RunFdtInstallation (\r
   OUT CHAR16  **SuccessfullDevicePath\r
@@ -420,457 +374,6 @@ Done:
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  This is the shell command "setfdt" handler function. This function handles\r
-  the command when it is invoked in the shell.\r
-\r
-  @param[in]  This             The instance of the\r
-                               EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
-  @param[in]  SystemTable      The pointer to the UEFI system table.\r
-  @param[in]  ShellParameters  The parameters associated with the command.\r
-  @param[in]  Shell            The instance of the shell protocol used in the\r
-                               context of processing this command.\r
-\r
-  @return  SHELL_SUCCESS            The operation was successful.\r
-  @return  SHELL_ABORTED            Operation aborted due to internal error.\r
-  @return  SHELL_INVALID_PARAMETER  The parameters of the command are not valid.\r
-  @return  SHELL_INVALID_PARAMETER  The EFI Shell file path is not valid.\r
-  @return  SHELL_NOT_FOUND          Failed to locate a protocol or a file.\r
-  @return  SHELL_UNSUPPORTED        Device path not supported.\r
-  @return  SHELL_OUT_OF_RESOURCES   A memory allocation failed.\r
-  @return  SHELL_DEVICE_ERROR       The "Fdt" variable could not be saved due to a hardware failure.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable is read-only.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable cannot be deleted.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable could not be written due to security violation.\r
-\r
-**/\r
-STATIC\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellDynCmdSetFdtHandler (\r
-  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
-  IN EFI_SYSTEM_TABLE                    *SystemTable,\r
-  IN EFI_SHELL_PARAMETERS_PROTOCOL       *ShellParameters,\r
-  IN EFI_SHELL_PROTOCOL                  *Shell\r
-  )\r
-{\r
-  SHELL_STATUS  ShellStatus;\r
-  EFI_STATUS    Status;\r
-  LIST_ENTRY    *ParamPackage;\r
-  BOOLEAN       FilePath;\r
-  CONST CHAR16  *ValueStr;\r
-  CHAR16        *TextDevicePath;\r
-\r
-  ShellStatus  = SHELL_SUCCESS;\r
-  ParamPackage = NULL;\r
-  FilePath     = FALSE;\r
-\r
-  //\r
-  // Install the Shell and Shell Parameters Protocols on the driver\r
-  // image. This is necessary for the initialisation of the Shell\r
-  // Library to succeed in the next step.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gImageHandle,\r
-                  &gEfiShellProtocolGuid, Shell,\r
-                  &gEfiShellParametersProtocolGuid, ShellParameters,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return SHELL_ABORTED;\r
-  }\r
-\r
-  //\r
-  // Initialise the Shell Library as we are going to use it.\r
-  // Assert that the return code is EFI_SUCCESS as it should.\r
-  // To anticipate any change is the codes returned by\r
-  // ShellInitialize(), leave in case of error.\r
-  //\r
-  Status = ShellInitialize ();\r
-  if (EFI_ERROR (Status)) {\r
-    ASSERT_EFI_ERROR (Status);\r
-    return SHELL_ABORTED;\r
-  }\r
-\r
-  Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);\r
-  if (!EFI_ERROR (Status)) {\r
-    switch (ShellCommandLineGetCount (ParamPackage)) {\r
-    case 1:\r
-      //\r
-      // Case "setfdt" or "setfdt -i"\r
-      //\r
-      if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
-        DisplayFdtDevicePaths ();\r
-      }\r
-      break;\r
-\r
-    case 2:\r
-      //\r
-      // Case "setfdt file_path"    or\r
-      //      "setfdt -i file_path" or\r
-      //      "setfdt file_path -i"\r
-      //\r
-      FilePath = TRUE;\r
-      break;\r
-\r
-    default:\r
-      Status = EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    ShellStatus = EfiCodeToShellCode (Status);\r
-    ShellPrintHiiEx (\r
-      -1, -1, NULL,\r
-      STRING_TOKEN (STR_SETFDT_ERROR),\r
-      mFdtPlatformDxeHiiHandle,\r
-      Status\r
-      );\r
-    goto Error;\r
-  }\r
-\r
-  //\r
-  // Update the preferred device path for the FDT if asked for.\r
-  //\r
-  if (FilePath) {\r
-    ValueStr = ShellCommandLineGetRawValue (ParamPackage, 1);\r
-    ShellPrintHiiEx (\r
-      -1, -1, NULL,\r
-      STRING_TOKEN (STR_SETFDT_UPDATING),\r
-      mFdtPlatformDxeHiiHandle\r
-      );\r
-    ShellStatus = UpdateFdtTextDevicePath (Shell, ValueStr);\r
-    if (ShellStatus != SHELL_SUCCESS) {\r
-      goto Error;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Run the FDT installation process if asked for.\r
-  //\r
-  if (ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
-    ShellPrintHiiEx (\r
-      -1, -1, NULL,\r
-      STRING_TOKEN (STR_SETFDT_INSTALLING),\r
-      mFdtPlatformDxeHiiHandle\r
-      );\r
-    Status = RunFdtInstallation (&TextDevicePath);\r
-    ShellStatus = EfiCodeToShellCode (Status);\r
-    if (!EFI_ERROR (Status)) {\r
-      ShellPrintHiiEx (\r
-        -1, -1, NULL,\r
-        STRING_TOKEN (STR_SETFDT_INSTALL_SUCCEEDED),\r
-        mFdtPlatformDxeHiiHandle,\r
-        TextDevicePath\r
-        );\r
-      FreePool (TextDevicePath);\r
-    } else {\r
-      if (Status == EFI_INVALID_PARAMETER) {\r
-        ShellPrintHiiEx (\r
-          -1, -1, NULL,\r
-          STRING_TOKEN (STR_SETFDT_INVALID_DEVICE_PATH),\r
-          mFdtPlatformDxeHiiHandle\r
-          );\r
-      } else {\r
-        ShellPrintHiiEx (\r
-          -1, -1, NULL,\r
-          STRING_TOKEN (STR_SETFDT_ERROR),\r
-          mFdtPlatformDxeHiiHandle,\r
-          Status\r
-          );\r
-      }\r
-      DisplayFdtDevicePaths ();\r
-    }\r
-  }\r
-\r
-Error:\r
-  gBS->UninstallMultipleProtocolInterfaces (\r
-         gImageHandle,\r
-         &gEfiShellProtocolGuid, Shell,\r
-         &gEfiShellParametersProtocolGuid, ShellParameters,\r
-         NULL\r
-         );\r
-  ShellCommandLineFreeVarList (ParamPackage);\r
-\r
-  return ShellStatus;\r
-}\r
-\r
-/**\r
-  This is the shell command "setfdt" help handler function. This\r
-  function returns the formatted help for the "setfdt" command.\r
-  The format matchs that in Appendix B of the revision 2.1 of the\r
-  UEFI Shell Specification.\r
-\r
-  @param[in]  This      The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
-  @param[in]  Language  The pointer to the language string to use.\r
-\r
-  @return  CHAR16*  Pool allocated help string, must be freed by caller.\r
-**/\r
-STATIC\r
-CHAR16*\r
-EFIAPI\r
-ShellDynCmdSetFdtGetHelp (\r
-  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
-  IN CONST CHAR8                         *Language\r
-  )\r
-{\r
-  //\r
-  // This allocates memory. The caller has to free the allocated memory.\r
-  //\r
-  return HiiGetString (\r
-                mFdtPlatformDxeHiiHandle,\r
-                STRING_TOKEN (STR_GET_HELP_SETFDT),\r
-                Language\r
-                );\r
-}\r
-\r
-/**\r
-  Display FDT device paths.\r
-\r
-  Display in text form the device paths used to install the FDT from the\r
-  highest to the lowest priority.\r
-\r
-**/\r
-STATIC\r
-VOID\r
-DisplayFdtDevicePaths (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       DataSize;\r
-  CHAR16      *TextDevicePath;\r
-  CHAR16      *TextDevicePaths;\r
-  CHAR16      *TextDevicePathSeparator;\r
-\r
-  ShellPrintHiiEx (\r
-    -1, -1, NULL,\r
-    STRING_TOKEN (STR_SETFDT_DEVICE_PATH_LIST),\r
-    mFdtPlatformDxeHiiHandle\r
-    );\r
-\r
-  if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
-    DataSize = 0;\r
-    Status = gRT->GetVariable (\r
-                    L"Fdt",\r
-                    &gFdtVariableGuid,\r
-                    NULL,\r
-                    &DataSize,\r
-                    NULL\r
-                    );\r
-\r
-    //\r
-    // Keep going only if the "Fdt" variable is defined.\r
-    //\r
-\r
-    if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      TextDevicePath = AllocatePool (DataSize);\r
-      if (TextDevicePath == NULL) {\r
-        return;\r
-      }\r
-\r
-      Status = gRT->GetVariable (\r
-                      L"Fdt",\r
-                      &gFdtVariableGuid,\r
-                      NULL,\r
-                      &DataSize,\r
-                      TextDevicePath\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        ShellPrintHiiEx (\r
-          -1, -1, NULL,\r
-          STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
-          mFdtPlatformDxeHiiHandle,\r
-          TextDevicePath\r
-          );\r
-      }\r
-\r
-      FreePool (TextDevicePath);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Loop over the device path list provided by "PcdFdtDevicePaths". The device\r
-  // paths are in text form and separated by a semi-colon.\r
-  //\r
-\r
-  TextDevicePaths = AllocateCopyPool (\r
-                      StrSize ((CHAR16*)PcdGetPtr (PcdFdtDevicePaths)),\r
-                      (CHAR16*)PcdGetPtr (PcdFdtDevicePaths)\r
-                      );\r
-  if (TextDevicePaths == NULL) {\r
-    return;\r
-  }\r
-\r
-  for (TextDevicePath = TextDevicePaths;\r
-       *TextDevicePath != L'\0'        ; ) {\r
-    TextDevicePathSeparator = StrStr (TextDevicePath, L";");\r
-\r
-    if (TextDevicePathSeparator != NULL) {\r
-      *TextDevicePathSeparator = L'\0';\r
-    }\r
-\r
-    ShellPrintHiiEx (\r
-      -1, -1, NULL,\r
-      STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
-      mFdtPlatformDxeHiiHandle,\r
-      TextDevicePath\r
-      );\r
-\r
-    if (TextDevicePathSeparator == NULL) {\r
-      break;\r
-    }\r
-    TextDevicePath = TextDevicePathSeparator + 1;\r
-  }\r
-\r
-  FreePool (TextDevicePaths);\r
-\r
-}\r
-\r
-/**\r
-  Update the text device path stored in the "Fdt" UEFI variable given\r
-  an EFI Shell file path or a text device path.\r
-\r
-  This function is a subroutine of the ShellDynCmdSetFdtHandler() function\r
-  to make its code easier to read.\r
-\r
-  @param[in]  Shell          The instance of the shell protocol used in the\r
-                             context of processing the "setfdt" command.\r
-  @param[in]  FilePath       EFI Shell path or the device path to the FDT file.\r
-\r
-  @return  SHELL_SUCCESS            The text device path was succesfully updated.\r
-  @return  SHELL_INVALID_PARAMETER  The Shell file path is not valid.\r
-  @return  SHELL_OUT_OF_RESOURCES   A memory allocation failed.\r
-  @return  SHELL_DEVICE_ERROR       The "Fdt" variable could not be saved due to a hardware failure.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable is read-only.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable cannot be deleted.\r
-  @return  SHELL_ACCESS_DENIED      The "Fdt" variable could not be written due to security violation.\r
-  @return  SHELL_NOT_FOUND          Device path to text protocol not found.\r
-  @return  SHELL_ABORTED            Operation aborted.\r
-\r
-**/\r
-STATIC\r
-SHELL_STATUS\r
-UpdateFdtTextDevicePath (\r
-  IN EFI_SHELL_PROTOCOL  *Shell,\r
-  IN CONST CHAR16        *FilePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_DEVICE_PATH                     *DevicePath;\r
-  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL    *EfiDevicePathToTextProtocol;\r
-  CHAR16                              *TextDevicePath;\r
-  CHAR16                              *FdtVariableValue;\r
-  EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL  *EfiDevicePathFromTextProtocol;\r
-  SHELL_STATUS                        ShellStatus;\r
-\r
-  ASSERT (FilePath != NULL);\r
-  DevicePath       = NULL;\r
-  TextDevicePath   = NULL;\r
-  FdtVariableValue = NULL;\r
-\r
-  if (*FilePath != L'\0') {\r
-    DevicePath = Shell->GetDevicePathFromFilePath (FilePath);\r
-    if (DevicePath != NULL) {\r
-      Status = gBS->LocateProtocol (\r
-                      &gEfiDevicePathToTextProtocolGuid,\r
-                      NULL,\r
-                      (VOID **)&EfiDevicePathToTextProtocol\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Error;\r
-      }\r
-\r
-      TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText (\r
-                                                      DevicePath,\r
-                                                      FALSE,\r
-                                                      FALSE\r
-                                                      );\r
-      if (TextDevicePath == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Error;\r
-      }\r
-      FdtVariableValue = TextDevicePath;\r
-    } else {\r
-      //\r
-      // Try to convert back the EFI Device Path String into a EFI device Path\r
-      // to ensure the format is valid\r
-      //\r
-      Status = gBS->LocateProtocol (\r
-                      &gEfiDevicePathFromTextProtocolGuid,\r
-                      NULL,\r
-                      (VOID **)&EfiDevicePathFromTextProtocol\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Error;\r
-      }\r
-\r
-      DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (\r
-                                                    FilePath\r
-                                                    );\r
-      if (DevicePath == NULL) {\r
-        Status = EFI_INVALID_PARAMETER;\r
-        goto Error;\r
-      }\r
-      FdtVariableValue = (CHAR16*)FilePath;\r
-    }\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  (CHAR16*)L"Fdt",\r
-                  &gFdtVariableGuid,\r
-                  EFI_VARIABLE_RUNTIME_ACCESS    |\r
-                  EFI_VARIABLE_NON_VOLATILE      |\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS ,\r
-                  (FdtVariableValue != NULL) ?\r
-                  StrSize (FdtVariableValue) : 0,\r
-                  FdtVariableValue\r
-                  );\r
-\r
-Error:\r
-  ShellStatus = EfiCodeToShellCode (Status);\r
-  if (!EFI_ERROR (Status)) {\r
-    if (FdtVariableValue != NULL) {\r
-      ShellPrintHiiEx (\r
-        -1, -1, NULL,\r
-        STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),\r
-        mFdtPlatformDxeHiiHandle,\r
-        FdtVariableValue\r
-        );\r
-    } else {\r
-      ShellPrintHiiEx (\r
-        -1, -1, NULL,\r
-        STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),\r
-        mFdtPlatformDxeHiiHandle\r
-        );\r
-    }\r
-  } else {\r
-    if (Status == EFI_INVALID_PARAMETER) {\r
-      ShellPrintHiiEx (\r
-        -1, -1, NULL,\r
-        STRING_TOKEN (STR_SETFDT_INVALID_PATH),\r
-        mFdtPlatformDxeHiiHandle,\r
-        FilePath\r
-        );\r
-    } else {\r
-      ShellPrintHiiEx (\r
-        -1, -1, NULL,\r
-        STRING_TOKEN (STR_SETFDT_ERROR),\r
-        mFdtPlatformDxeHiiHandle,\r
-        Status\r
-        );\r
-    }\r
-  }\r
-\r
-  if (DevicePath != NULL) {\r
-    FreePool (DevicePath);\r
-  }\r
-  if (TextDevicePath != NULL) {\r
-    FreePool (TextDevicePath);\r
-  }\r
-\r
-  return ShellStatus;\r
-}\r
-\r
 /**\r
   Transcode one of the EFI return code used by the model into an EFI Shell return code.\r
 \r
@@ -879,7 +382,6 @@ Error:
   @return  Transcoded EFI Shell return code.\r
 \r
 **/\r
-STATIC\r
 SHELL_STATUS\r
 EfiCodeToShellCode (\r
   IN EFI_STATUS  Status\r
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h
new file mode 100644 (file)
index 0000000..297927a
--- /dev/null
@@ -0,0 +1,130 @@
+/** @file\r
+\r
+  Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __FDT_PLATFORM_DXE_H__\r
+#define __FDT_PLATFORM_DXE_H__\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/DevicePathFromText.h>\r
+#include <Protocol/EfiShell.h>\r
+#include <Protocol/EfiShellDynamicCommand.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/ShellLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+\r
+#include <Guid/Fdt.h>\r
+\r
+#include <libfdt.h>\r
+\r
+extern EFI_HANDLE mFdtPlatformDxeHiiHandle;\r
+\r
+/**\r
+  Transcode one of the EFI return code used by the model into an EFI Shell return code.\r
+\r
+  @param[in]  Status  EFI return code.\r
+\r
+  @return  Transcoded EFI Shell return code.\r
+\r
+**/\r
+SHELL_STATUS\r
+EfiCodeToShellCode (\r
+  IN EFI_STATUS  Status\r
+  );\r
+\r
+/**\r
+  Run the FDT installation process.\r
+\r
+  Loop in priority order over the device paths from which the FDT has\r
+  been asked to be retrieved for. For each device path, try to install\r
+  the FDT. Stop as soon as an installation succeeds.\r
+\r
+  @param[in]  SuccessfullDevicePath  If not NULL, address where to store the\r
+                                     pointer to the text device path from\r
+                                     which the FDT was successfully retrieved.\r
+                                     Not used if the FDT installation failed.\r
+                                     The returned address is the address of\r
+                                     an allocated buffer that has to be\r
+                                     freed by the caller.\r
+\r
+  @retval  EFI_SUCCESS            The FDT was installed.\r
+  @retval  EFI_NOT_FOUND          Failed to locate a protocol or a file.\r
+  @retval  EFI_INVALID_PARAMETER  Invalid device path.\r
+  @retval  EFI_UNSUPPORTED        Device path not supported.\r
+  @retval  EFI_OUT_OF_RESOURCES   An allocation failed.\r
+\r
+**/\r
+EFI_STATUS\r
+RunFdtInstallation (\r
+  OUT CHAR16  **SuccessfullDevicePath\r
+  );\r
+\r
+/**\r
+  This is the shell command "setfdt" handler function. This function handles\r
+  the command when it is invoked in the shell.\r
+\r
+  @param[in]  This             The instance of the\r
+                               EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in]  SystemTable      The pointer to the UEFI system table.\r
+  @param[in]  ShellParameters  The parameters associated with the command.\r
+  @param[in]  Shell            The instance of the shell protocol used in the\r
+                               context of processing this command.\r
+\r
+  @return  SHELL_SUCCESS            The operation was successful.\r
+  @return  SHELL_ABORTED            Operation aborted due to internal error.\r
+  @return  SHELL_INVALID_PARAMETER  The parameters of the command are not valid.\r
+  @return  SHELL_INVALID_PARAMETER  The EFI Shell file path is not valid.\r
+  @return  SHELL_NOT_FOUND          Failed to locate a protocol or a file.\r
+  @return  SHELL_UNSUPPORTED        Device path not supported.\r
+  @return  SHELL_OUT_OF_RESOURCES   A memory allocation failed.\r
+  @return  SHELL_DEVICE_ERROR       The "Fdt" variable could not be saved due to a hardware failure.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable is read-only.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable cannot be deleted.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable could not be written due to security violation.\r
+\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellDynCmdSetFdtHandler (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN EFI_SYSTEM_TABLE                    *SystemTable,\r
+  IN EFI_SHELL_PARAMETERS_PROTOCOL       *ShellParameters,\r
+  IN EFI_SHELL_PROTOCOL                  *Shell\r
+  );\r
+\r
+/**\r
+  This is the shell command "setfdt" help handler function. This\r
+  function returns the formatted help for the "setfdt" command.\r
+  The format matchs that in Appendix B of the revision 2.1 of the\r
+  UEFI Shell Specification.\r
+\r
+  @param[in]  This      The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in]  Language  The pointer to the language string to use.\r
+\r
+  @return  CHAR16*  Pool allocated help string, must be freed by caller.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ShellDynCmdSetFdtGetHelp (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN CONST CHAR8                         *Language\r
+  );\r
+\r
+#endif /* __FDT_PLATFORM_DXE_H__ */\r
index 64d14a26e748cdfd3f6a102302a4cfb30cda9d23..3558958f841c7e13a9881c65aa5c386cfe401820 100644 (file)
@@ -24,6 +24,7 @@
 [Sources.common]\r
   FdtPlatform.c\r
   FdtPlatformDxe.uni\r
+  ShellSetFdt.c\r
 \r
 [Packages]\r
   EmbeddedPkg/EmbeddedPkg.dec\r
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c b/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c
new file mode 100644 (file)
index 0000000..9be23c8
--- /dev/null
@@ -0,0 +1,468 @@
+/** @file\r
+\r
+  Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "FdtPlatform.h"\r
+\r
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
+  {L"-i", TypeFlag },\r
+  {NULL , TypeMax  }\r
+};\r
+\r
+/**\r
+  Display FDT device paths.\r
+\r
+  Display in text form the device paths used to install the FDT from the\r
+  highest to the lowest priority.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+DisplayFdtDevicePaths (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       DataSize;\r
+  CHAR16      *TextDevicePath;\r
+  CHAR16      *TextDevicePaths;\r
+  CHAR16      *TextDevicePathSeparator;\r
+\r
+  ShellPrintHiiEx (\r
+    -1, -1, NULL,\r
+    STRING_TOKEN (STR_SETFDT_DEVICE_PATH_LIST),\r
+    mFdtPlatformDxeHiiHandle\r
+    );\r
+\r
+  if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
+    DataSize = 0;\r
+    Status = gRT->GetVariable (\r
+                    L"Fdt",\r
+                    &gFdtVariableGuid,\r
+                    NULL,\r
+                    &DataSize,\r
+                    NULL\r
+                    );\r
+\r
+    //\r
+    // Keep going only if the "Fdt" variable is defined.\r
+    //\r
+\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      TextDevicePath = AllocatePool (DataSize);\r
+      if (TextDevicePath == NULL) {\r
+        return;\r
+      }\r
+\r
+      Status = gRT->GetVariable (\r
+                      L"Fdt",\r
+                      &gFdtVariableGuid,\r
+                      NULL,\r
+                      &DataSize,\r
+                      TextDevicePath\r
+                      );\r
+      if (!EFI_ERROR (Status)) {\r
+        ShellPrintHiiEx (\r
+          -1, -1, NULL,\r
+          STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
+          mFdtPlatformDxeHiiHandle,\r
+          TextDevicePath\r
+          );\r
+      }\r
+\r
+      FreePool (TextDevicePath);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Loop over the device path list provided by "PcdFdtDevicePaths". The device\r
+  // paths are in text form and separated by a semi-colon.\r
+  //\r
+\r
+  TextDevicePaths = AllocateCopyPool (\r
+                      StrSize ((CHAR16*)PcdGetPtr (PcdFdtDevicePaths)),\r
+                      (CHAR16*)PcdGetPtr (PcdFdtDevicePaths)\r
+                      );\r
+  if (TextDevicePaths == NULL) {\r
+    return;\r
+  }\r
+\r
+  for (TextDevicePath = TextDevicePaths;\r
+       *TextDevicePath != L'\0'        ; ) {\r
+    TextDevicePathSeparator = StrStr (TextDevicePath, L";");\r
+\r
+    if (TextDevicePathSeparator != NULL) {\r
+      *TextDevicePathSeparator = L'\0';\r
+    }\r
+\r
+    ShellPrintHiiEx (\r
+      -1, -1, NULL,\r
+      STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
+      mFdtPlatformDxeHiiHandle,\r
+      TextDevicePath\r
+      );\r
+\r
+    if (TextDevicePathSeparator == NULL) {\r
+      break;\r
+    }\r
+    TextDevicePath = TextDevicePathSeparator + 1;\r
+  }\r
+\r
+  FreePool (TextDevicePaths);\r
+}\r
+\r
+/**\r
+  Update the text device path stored in the "Fdt" UEFI variable given\r
+  an EFI Shell file path or a text device path.\r
+\r
+  This function is a subroutine of the ShellDynCmdSetFdtHandler() function\r
+  to make its code easier to read.\r
+\r
+  @param[in]  Shell          The instance of the shell protocol used in the\r
+                             context of processing the "setfdt" command.\r
+  @param[in]  FilePath       EFI Shell path or the device path to the FDT file.\r
+\r
+  @return  SHELL_SUCCESS            The text device path was succesfully updated.\r
+  @return  SHELL_INVALID_PARAMETER  The Shell file path is not valid.\r
+  @return  SHELL_OUT_OF_RESOURCES   A memory allocation failed.\r
+  @return  SHELL_DEVICE_ERROR       The "Fdt" variable could not be saved due to a hardware failure.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable is read-only.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable cannot be deleted.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable could not be written due to security violation.\r
+  @return  SHELL_NOT_FOUND          Device path to text protocol not found.\r
+  @return  SHELL_ABORTED            Operation aborted.\r
+\r
+**/\r
+STATIC\r
+SHELL_STATUS\r
+UpdateFdtTextDevicePath (\r
+  IN EFI_SHELL_PROTOCOL  *Shell,\r
+  IN CONST CHAR16        *FilePath\r
+  )\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_DEVICE_PATH                     *DevicePath;\r
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL    *EfiDevicePathToTextProtocol;\r
+  CHAR16                              *TextDevicePath;\r
+  CHAR16                              *FdtVariableValue;\r
+  EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL  *EfiDevicePathFromTextProtocol;\r
+  SHELL_STATUS                        ShellStatus;\r
+\r
+  ASSERT (FilePath != NULL);\r
+  DevicePath       = NULL;\r
+  TextDevicePath   = NULL;\r
+  FdtVariableValue = NULL;\r
+\r
+  if (*FilePath != L'\0') {\r
+    DevicePath = Shell->GetDevicePathFromFilePath (FilePath);\r
+    if (DevicePath != NULL) {\r
+      Status = gBS->LocateProtocol (\r
+                      &gEfiDevicePathToTextProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&EfiDevicePathToTextProtocol\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+        goto Error;\r
+      }\r
+\r
+      TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText (\r
+                                                      DevicePath,\r
+                                                      FALSE,\r
+                                                      FALSE\r
+                                                      );\r
+      if (TextDevicePath == NULL) {\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        goto Error;\r
+      }\r
+      FdtVariableValue = TextDevicePath;\r
+    } else {\r
+      //\r
+      // Try to convert back the EFI Device Path String into a EFI device Path\r
+      // to ensure the format is valid\r
+      //\r
+      Status = gBS->LocateProtocol (\r
+                      &gEfiDevicePathFromTextProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&EfiDevicePathFromTextProtocol\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+        goto Error;\r
+      }\r
+\r
+      DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (\r
+                                                    FilePath\r
+                                                    );\r
+      if (DevicePath == NULL) {\r
+        Status = EFI_INVALID_PARAMETER;\r
+        goto Error;\r
+      }\r
+      FdtVariableValue = (CHAR16*)FilePath;\r
+    }\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  (CHAR16*)L"Fdt",\r
+                  &gFdtVariableGuid,\r
+                  EFI_VARIABLE_RUNTIME_ACCESS    |\r
+                  EFI_VARIABLE_NON_VOLATILE      |\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS ,\r
+                  (FdtVariableValue != NULL) ?\r
+                  StrSize (FdtVariableValue) : 0,\r
+                  FdtVariableValue\r
+                  );\r
+\r
+Error:\r
+  ShellStatus = EfiCodeToShellCode (Status);\r
+  if (!EFI_ERROR (Status)) {\r
+    if (FdtVariableValue != NULL) {\r
+      ShellPrintHiiEx (\r
+        -1, -1, NULL,\r
+        STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),\r
+        mFdtPlatformDxeHiiHandle,\r
+        FdtVariableValue\r
+        );\r
+    } else {\r
+      ShellPrintHiiEx (\r
+        -1, -1, NULL,\r
+        STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),\r
+        mFdtPlatformDxeHiiHandle\r
+        );\r
+    }\r
+  } else {\r
+    if (Status == EFI_INVALID_PARAMETER) {\r
+      ShellPrintHiiEx (\r
+        -1, -1, NULL,\r
+        STRING_TOKEN (STR_SETFDT_INVALID_PATH),\r
+        mFdtPlatformDxeHiiHandle,\r
+        FilePath\r
+        );\r
+    } else {\r
+      ShellPrintHiiEx (\r
+        -1, -1, NULL,\r
+        STRING_TOKEN (STR_SETFDT_ERROR),\r
+        mFdtPlatformDxeHiiHandle,\r
+        Status\r
+        );\r
+    }\r
+  }\r
+\r
+  if (DevicePath != NULL) {\r
+    FreePool (DevicePath);\r
+  }\r
+  if (TextDevicePath != NULL) {\r
+    FreePool (TextDevicePath);\r
+  }\r
+\r
+  return ShellStatus;\r
+}\r
+\r
+/**\r
+  This is the shell command "setfdt" handler function. This function handles\r
+  the command when it is invoked in the shell.\r
+\r
+  @param[in]  This             The instance of the\r
+                               EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in]  SystemTable      The pointer to the UEFI system table.\r
+  @param[in]  ShellParameters  The parameters associated with the command.\r
+  @param[in]  Shell            The instance of the shell protocol used in the\r
+                               context of processing this command.\r
+\r
+  @return  SHELL_SUCCESS            The operation was successful.\r
+  @return  SHELL_ABORTED            Operation aborted due to internal error.\r
+  @return  SHELL_INVALID_PARAMETER  The parameters of the command are not valid.\r
+  @return  SHELL_INVALID_PARAMETER  The EFI Shell file path is not valid.\r
+  @return  SHELL_NOT_FOUND          Failed to locate a protocol or a file.\r
+  @return  SHELL_UNSUPPORTED        Device path not supported.\r
+  @return  SHELL_OUT_OF_RESOURCES   A memory allocation failed.\r
+  @return  SHELL_DEVICE_ERROR       The "Fdt" variable could not be saved due to a hardware failure.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable is read-only.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable cannot be deleted.\r
+  @return  SHELL_ACCESS_DENIED      The "Fdt" variable could not be written due to security violation.\r
+\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellDynCmdSetFdtHandler (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN EFI_SYSTEM_TABLE                    *SystemTable,\r
+  IN EFI_SHELL_PARAMETERS_PROTOCOL       *ShellParameters,\r
+  IN EFI_SHELL_PROTOCOL                  *Shell\r
+  )\r
+{\r
+  SHELL_STATUS  ShellStatus;\r
+  EFI_STATUS    Status;\r
+  LIST_ENTRY    *ParamPackage;\r
+  BOOLEAN       FilePath;\r
+  CONST CHAR16  *ValueStr;\r
+  CHAR16        *TextDevicePath;\r
+\r
+  ShellStatus  = SHELL_SUCCESS;\r
+  ParamPackage = NULL;\r
+  FilePath     = FALSE;\r
+\r
+  //\r
+  // Install the Shell and Shell Parameters Protocols on the driver\r
+  // image. This is necessary for the initialisation of the Shell\r
+  // Library to succeed in the next step.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &gImageHandle,\r
+                  &gEfiShellProtocolGuid, Shell,\r
+                  &gEfiShellParametersProtocolGuid, ShellParameters,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return SHELL_ABORTED;\r
+  }\r
+\r
+  //\r
+  // Initialise the Shell Library as we are going to use it.\r
+  // Assert that the return code is EFI_SUCCESS as it should.\r
+  // To anticipate any change is the codes returned by\r
+  // ShellInitialize(), leave in case of error.\r
+  //\r
+  Status = ShellInitialize ();\r
+  if (EFI_ERROR (Status)) {\r
+    ASSERT_EFI_ERROR (Status);\r
+    return SHELL_ABORTED;\r
+  }\r
+\r
+  Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);\r
+  if (!EFI_ERROR (Status)) {\r
+    switch (ShellCommandLineGetCount (ParamPackage)) {\r
+    case 1:\r
+      //\r
+      // Case "setfdt" or "setfdt -i"\r
+      //\r
+      if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
+        DisplayFdtDevicePaths ();\r
+      }\r
+      break;\r
+\r
+    case 2:\r
+      //\r
+      // Case "setfdt file_path"    or\r
+      //      "setfdt -i file_path" or\r
+      //      "setfdt file_path -i"\r
+      //\r
+      FilePath = TRUE;\r
+      break;\r
+\r
+    default:\r
+      Status = EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    ShellStatus = EfiCodeToShellCode (Status);\r
+    ShellPrintHiiEx (\r
+      -1, -1, NULL,\r
+      STRING_TOKEN (STR_SETFDT_ERROR),\r
+      mFdtPlatformDxeHiiHandle,\r
+      Status\r
+      );\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Update the preferred device path for the FDT if asked for.\r
+  //\r
+  if (FilePath) {\r
+    ValueStr = ShellCommandLineGetRawValue (ParamPackage, 1);\r
+    ShellPrintHiiEx (\r
+      -1, -1, NULL,\r
+      STRING_TOKEN (STR_SETFDT_UPDATING),\r
+      mFdtPlatformDxeHiiHandle\r
+      );\r
+    ShellStatus = UpdateFdtTextDevicePath (Shell, ValueStr);\r
+    if (ShellStatus != SHELL_SUCCESS) {\r
+      goto Error;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Run the FDT installation process if asked for.\r
+  //\r
+  if (ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
+    ShellPrintHiiEx (\r
+      -1, -1, NULL,\r
+      STRING_TOKEN (STR_SETFDT_INSTALLING),\r
+      mFdtPlatformDxeHiiHandle\r
+      );\r
+    Status = RunFdtInstallation (&TextDevicePath);\r
+    ShellStatus = EfiCodeToShellCode (Status);\r
+    if (!EFI_ERROR (Status)) {\r
+      ShellPrintHiiEx (\r
+        -1, -1, NULL,\r
+        STRING_TOKEN (STR_SETFDT_INSTALL_SUCCEEDED),\r
+        mFdtPlatformDxeHiiHandle,\r
+        TextDevicePath\r
+        );\r
+      FreePool (TextDevicePath);\r
+    } else {\r
+      if (Status == EFI_INVALID_PARAMETER) {\r
+        ShellPrintHiiEx (\r
+          -1, -1, NULL,\r
+          STRING_TOKEN (STR_SETFDT_INVALID_DEVICE_PATH),\r
+          mFdtPlatformDxeHiiHandle\r
+          );\r
+      } else {\r
+        ShellPrintHiiEx (\r
+          -1, -1, NULL,\r
+          STRING_TOKEN (STR_SETFDT_ERROR),\r
+          mFdtPlatformDxeHiiHandle,\r
+          Status\r
+          );\r
+      }\r
+      DisplayFdtDevicePaths ();\r
+    }\r
+  }\r
+\r
+Error:\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+         gImageHandle,\r
+         &gEfiShellProtocolGuid, Shell,\r
+         &gEfiShellParametersProtocolGuid, ShellParameters,\r
+         NULL\r
+         );\r
+  ShellCommandLineFreeVarList (ParamPackage);\r
+\r
+  return ShellStatus;\r
+}\r
+\r
+/**\r
+  This is the shell command "setfdt" help handler function. This\r
+  function returns the formatted help for the "setfdt" command.\r
+  The format matchs that in Appendix B of the revision 2.1 of the\r
+  UEFI Shell Specification.\r
+\r
+  @param[in]  This      The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in]  Language  The pointer to the language string to use.\r
+\r
+  @return  CHAR16*  Pool allocated help string, must be freed by caller.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ShellDynCmdSetFdtGetHelp (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN CONST CHAR8                         *Language\r
+  )\r
+{\r
+  //\r
+  // This allocates memory. The caller has to free the allocated memory.\r
+  //\r
+  return HiiGetString (\r
+                mFdtPlatformDxeHiiHandle,\r
+                STRING_TOKEN (STR_GET_HELP_SETFDT),\r
+                Language\r
+                );\r
+}\r