]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Ebl/Dir.c
Change UI for dir of FV to make it less confusing.
[mirror_edk2.git] / EmbeddedPkg / Ebl / Dir.c
index 4e9f7b98b2928d98d2c37e49fd813f9533fc1cee..126ef5d7c78ca802e01b8a96a1c821b9bb7a043a 100644 (file)
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED   CHAR8 *gFvFileType[] = {\r
   "All",\r
-  "Raw",\r
-  "Freeform",\r
+  "Bin",\r
+  "section",\r
   "SEC",\r
   "PeiCore",\r
   "DxeCore",\r
   "PEIM",\r
   "Driver",\r
-  "Combo Driver",\r
-  "Application",\r
+  "Combo",\r
+  "App",\r
   "NULL",\r
   "FV"\r
 };\r
@@ -52,7 +52,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED   CHAR8 *gFvFileType[] = {
                       only print out files that contain the string *.efi\r
   dir fv1:\         ; perform a dir on fv1: device in the efi directory \r
                     NOTE: fv devices do not contian subdirs \r
-  dir fv1:\ * PEIM  ; will match all files of type SEC\r
+  dir fv1:\ * PEIM  ; will match all files of type PEIM\r
 \r
   @param  Argc   Number of command arguments in Argv\r
   @param  Argv   Array of strings that represent the parsed command line. \r
@@ -88,14 +88,20 @@ EblDirCmd (
   UINTN                         Length;\r
   UINTN                         BestMatchCount;\r
   CHAR16                        UnicodeFileName[MAX_CMD_LINE];\r
+  CHAR8                         *Path;\r
+  CHAR8                         *TypeStr;\r
 \r
 \r
   if (Argc <= 1) {\r
-    // CWD not currently supported \r
-    return EFI_SUCCESS;\r
+    Path = EfiGetCwd ();\r
+    if (Path == NULL) {\r
+      return EFI_SUCCESS;\r
+    }\r
+  } else {\r
+    Path = Argv[1];\r
   }\r
 \r
-  File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
+  File = EfiOpen (Path, EFI_FILE_MODE_READ, 0);\r
   if (File == NULL) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -151,10 +157,10 @@ EblDirCmd (
                                 &Size\r
                                 );\r
       if (!EFI_ERROR (GetNextFileStatus)) {\r
-         // Calculate size of entire file\r
-         Section = NULL;\r
-         Size = 0;\r
-         Status = Fv->ReadFile (\r
+        // Calculate size of entire file\r
+        Section = NULL;\r
+        Size = 0;\r
+        Status = Fv->ReadFile (\r
                       Fv,\r
                       &NameGuid, \r
                       Section,\r
@@ -163,10 +169,12 @@ EblDirCmd (
                       &Attributes,\r
                       &AuthenticationStatus\r
                       );\r
-         if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {\r
-          // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid \r
-          Size = 0;\r
-         }\r
+        if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {\r
+           // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid \r
+            Size = 0;\r
+        }\r
+        \r
+        TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN";\r
 \r
         // read the UI seciton to do a name match.\r
         Section = NULL;\r
@@ -181,7 +189,7 @@ EblDirCmd (
                         );\r
         if (!EFI_ERROR (Status)) {\r
           if (StrStr (Section, MatchSubString) != NULL) {\r
-            AsciiPrint ("  %g %s %a %,d\n", &NameGuid, Section, gFvFileType[Type], Size);\r
+            AsciiPrint ("%,6d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -189,7 +197,7 @@ EblDirCmd (
           FreePool (Section);\r
         } else {\r
           if (*MatchSubString == '\0') {\r
-            AsciiPrint ("  %g %a %,d\n", &NameGuid, gFvFileType[Type], Size);\r
+            AsciiPrint ("%,6d %7a %g\n", Size, TypeStr, &NameGuid);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -277,6 +285,32 @@ Done:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Change the Current Working Directory\r
+\r
+  Argv[0] - "cd"\r
+  Argv[1] - Device Name:path. Path is optional \r
+\r
+  @param  Argc   Number of command arguments in Argv\r
+  @param  Argv   Array of strings that represent the parsed command line. \r
+                 Argv[0] is the comamnd name\r
+\r
+  @return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EblCdCmd (\r
+  IN UINTN  Argc,\r
+  IN CHAR8  **Argv\r
+  )\r
+{\r
+  if (Argc <= 1) {\r
+    return EFI_SUCCESS;\r
+  } \r
+  \r
+  return EfiSetCwd (Argv[1]);\r
+}\r
+\r
 \r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] =\r
@@ -286,6 +320,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] =
     " dirdev [*match]; directory listing of dirdev. opt match a substring",\r
     NULL,\r
     EblDirCmd\r
+  },\r
+  {\r
+    "cd",\r
+    " device - set the current working directory",\r
+    NULL,\r
+    EblCdCmd\r
   }\r
 };\r
 \r