]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/FdtPlatformDxe: 'setfdt' command, add display of FDT device paths.
authorRonald Cron <Ronald.Cron@arm.com>
Tue, 5 May 2015 15:23:02 +0000 (15:23 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 5 May 2015 15:23:02 +0000 (15:23 +0000)
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 <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@17299 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c

index 8702765c6a1eb2c1b92fa3e9eb21aa424a1958eb..b5ae8c0bb5bd3a7b4e8ed9da17d8f8289e6262af 100644 (file)
@@ -50,6 +50,10 @@ STATIC CHAR16* EFIAPI ShellDynCmdSetFdtGetHelp (
   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
@@ -478,10 +482,10 @@ ShellDynCmdSetFdtHandler (
     switch (ShellCommandLineGetCount (ParamPackage)) {\r
     case 1:\r
       //\r
-      // Case "setfdt -i"\r
+      // Case "setfdt" or "setfdt -i"\r
       //\r
       if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
-        Status = EFI_INVALID_PARAMETER;\r
+        DisplayFdtDevicePaths ();\r
       }\r
       break;\r
 \r
@@ -557,6 +561,7 @@ ShellDynCmdSetFdtHandler (
           Status\r
           );\r
       }\r
+      DisplayFdtDevicePaths ();\r
     }\r
   }\r
 \r
@@ -601,6 +606,109 @@ ShellDynCmdSetFdtGetHelp (
                 );\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