]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/FdtPlatformDxe: 'setfdt' command, add deletion of the UEFI variable ...
authorRonald Cron <Ronald.Cron@arm.com>
Tue, 5 May 2015 15:24:17 +0000 (15:24 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 5 May 2015 15:24:17 +0000 (15:24 +0000)
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

EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c

index b5ae8c0bb5bd3a7b4e8ed9da17d8f8289e6262af..eb4f5546218bfa710c519d69697907ea2cefc644 100644 (file)
@@ -747,52 +747,55 @@ UpdateFdtTextDevicePath (
   SHELL_STATUS                        ShellStatus;\r
 \r
   ASSERT (FilePath != NULL);\r
+  DevicePath       = NULL;\r
   TextDevicePath   = NULL;\r
   FdtVariableValue = NULL;\r
 \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
+  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
+      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
+      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
-    FdtVariableValue = (CHAR16*)FilePath;\r
   }\r
 \r
   Status = gRT->SetVariable (\r
@@ -801,19 +804,29 @@ UpdateFdtTextDevicePath (
                   EFI_VARIABLE_RUNTIME_ACCESS    |\r
                   EFI_VARIABLE_NON_VOLATILE      |\r
                   EFI_VARIABLE_BOOTSERVICE_ACCESS ,\r
-                  StrSize (FdtVariableValue),\r
+                  (FdtVariableValue != NULL) ?\r
+                  StrSize (FdtVariableValue) : 0,\r
                   FdtVariableValue\r
                   );\r
 \r
 Error:\r
   ShellStatus = EfiCodeToShellCode (Status);\r
   if (!EFI_ERROR (Status)) {\r
-    ShellPrintHiiEx (\r
-      -1, -1, NULL,\r
-      STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),\r
-      mFdtPlatformDxeHiiHandle,\r
-      FdtVariableValue\r
-      );\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
+        FdtVariableValue\r
+        );\r
+    }\r
   } else {\r
     if (Status == EFI_INVALID_PARAMETER) {\r
       ShellPrintHiiEx (\r