]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c
EmbeddedPkg/FdtPlatformDxe: Introduce EFI Shell command 'dumfdt'
[mirror_edk2.git] / EmbeddedPkg / Drivers / FdtPlatformDxe / FdtPlatform.c
index 38f31005f3a59d790a23f9828fa823f5d079d98a..b6f5c3e58d3ae1e20b2e5d0d2e932419f4bc01ba 100644 (file)
@@ -20,8 +20,6 @@
 \r
 #include <Protocol/DevicePath.h>\r
 \r
 \r
 #include <Protocol/DevicePath.h>\r
 \r
-#include <libfdt.h>\r
-\r
 //\r
 // Internal variables\r
 //\r
 //\r
 // Internal variables\r
 //\r
@@ -32,6 +30,12 @@ STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolSetFdt = {
     ShellDynCmdSetFdtGetHelp  // GetHelp\r
 };\r
 \r
     ShellDynCmdSetFdtGetHelp  // GetHelp\r
 };\r
 \r
+STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolDumpFdt = {\r
+    L"dumpfdt",                // Name of the command\r
+    ShellDynCmdDumpFdtHandler, // Handler\r
+    ShellDynCmdDumpFdtGetHelp  // GetHelp\r
+};\r
+\r
 STATIC CONST EFI_GUID  mFdtPlatformDxeHiiGuid = {\r
                          0x8afa7610, 0x62b1, 0x46aa,\r
                          {0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}\r
 STATIC CONST EFI_GUID  mFdtPlatformDxeHiiGuid = {\r
                          0x8afa7610, 0x62b1, 0x46aa,\r
                          {0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}\r
@@ -159,6 +163,7 @@ FdtPlatformEntryPoint (
   )\r
 {\r
   EFI_STATUS  Status;\r
   )\r
 {\r
   EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
 \r
   //\r
   // Install the Device Tree from its expected location\r
 \r
   //\r
   // Install the Device Tree from its expected location\r
@@ -168,14 +173,7 @@ FdtPlatformEntryPoint (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-  //\r
-  // If the development features are enabled, install the dynamic shell\r
-  // command "setfdt" to be able to define a device path for the FDT\r
-  // that has precedence over the device paths defined by\r
-  // "PcdFdtDevicePaths".\r
-  //\r
-\r
-  if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
+  if (FeaturePcdGet (PcdOverridePlatformFdt) || FeaturePcdGet (PcdDumpFdtShellCommand)) {\r
     //\r
     // Register the strings for the user interface in the HII Database.\r
     // This shows the way to the multi-language support, even if\r
     //\r
     // Register the strings for the user interface in the HII Database.\r
     // This shows the way to the multi-language support, even if\r
@@ -192,10 +190,22 @@ FdtPlatformEntryPoint (
                                  FdtPlatformDxeStrings,\r
                                  NULL\r
                                  );\r
                                  FdtPlatformDxeStrings,\r
                                  NULL\r
                                  );\r
+  }\r
+\r
+  //\r
+  // If the development features are enabled, install the dynamic shell\r
+  // command "setfdt" to be able to define a device path for the FDT\r
+  // that has precedence over the device paths defined by\r
+  // "PcdFdtDevicePaths".\r
+  //\r
 \r
 \r
+  if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
     if (mFdtPlatformDxeHiiHandle != NULL) {\r
     if (mFdtPlatformDxeHiiHandle != NULL) {\r
+      // We install dynamic EFI command on separate handles as we cannot register\r
+      // more than one protocol of the same protocol interface on the same handle.\r
+      Handle = NULL;\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &ImageHandle,\r
+                      &Handle,\r
                       &gEfiShellDynamicCommandProtocolGuid,\r
                       &mShellDynCmdProtocolSetFdt,\r
                       NULL\r
                       &gEfiShellDynamicCommandProtocolGuid,\r
                       &mShellDynCmdProtocolSetFdt,\r
                       NULL\r
@@ -215,6 +225,32 @@ FdtPlatformEntryPoint (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
+  if (FeaturePcdGet (PcdDumpFdtShellCommand)) {\r
+    if (mFdtPlatformDxeHiiHandle != NULL) {\r
+      // We install dynamic EFI command on separate handles as we cannot register\r
+      // more than one protocol of the same protocol interface on the same handle.\r
+      Handle = NULL;\r
+      Status = gBS->InstallMultipleProtocolInterfaces (\r
+                      &Handle,\r
+                      &gEfiShellDynamicCommandProtocolGuid,\r
+                      &mShellDynCmdProtocolDumpFdt,\r
+                      NULL\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+        HiiRemovePackages (mFdtPlatformDxeHiiHandle);\r
+      }\r
+    } else {\r
+      Status = EFI_LOAD_ERROR;\r
+    }\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((\r
+        EFI_D_WARN,\r
+        "Unable to install \"dumpfdt\" EFI Shell command - %r \n",\r
+        Status\r
+        ));\r
+    }\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r