]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Ebl/Dir.c
EmbeddedPkg: Add EFIAPI to several Ebl functions
[mirror_edk2.git] / EmbeddedPkg / Ebl / Dir.c
index ff1b557ed18a20e2d954e54dda9714f3b9adbd1e..36095b6330194d47c0e4b599151f0dcb6e21b8d0 100644 (file)
@@ -1,11 +1,12 @@
 /** @file\r
   Dir for EBL (Embedded Boot Loader)\r
 \r
-  Copyright (c) 2007, Intel Corporation<BR>\r
-  Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
+  Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 \r
 \r
-  All rights reserved. This program and the accompanying materials\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
 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
@@ -40,28 +41,29 @@ GLOBAL_REMOVE_IF_UNREFERENCED   CHAR8 *gFvFileType[] = {
 \r
 /**\r
   Perform a dir on a device. The device must support Simple File System Protocol\r
-  or the FV protocol. \r
+  or the FV protocol.\r
 \r
   Argv[0] - "dir"\r
-  Argv[1] - Device Name:path. Path is optional \r
+  Argv[1] - Device Name:path. Path is optional\r
   Argv[2] - Optional filename to match on. A leading * means match substring\r
   Argv[3] - Optional FV file type\r
 \r
   dir fs1:\efi      ; perform a dir on fs1: device in the efi directory\r
-  dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but \r
+  dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but\r
                       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:\         ; perform a dir on fv1: device in the efi directory\r
+                    NOTE: fv devices do not contain subdirs\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
-                 Argv[0] is the comamnd name\r
+  @param  Argv   Array of strings that represent the parsed command line.\r
+                 Argv[0] is the command name\r
 \r
   @return EFI_SUCCESS\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 EblDirCmd (\r
   IN UINTN  Argc,\r
   IN CHAR8  **Argv\r
@@ -71,7 +73,7 @@ EblDirCmd (
   EFI_OPEN_FILE                 *File;\r
   EFI_FILE_INFO                 *DirInfo;\r
   UINTN                         ReadSize;\r
-  UINTN                         CurrentRow;  \r
+  UINTN                         CurrentRow;\r
   CHAR16                        *MatchSubString;\r
   EFI_STATUS                    GetNextFileStatus;\r
   UINTN                         Key;\r
@@ -89,6 +91,8 @@ EblDirCmd (
   UINTN                         BestMatchCount;\r
   CHAR16                        UnicodeFileName[MAX_CMD_LINE];\r
   CHAR8                         *Path;\r
+  CHAR8                         *TypeStr;\r
+  UINTN                         TotalSize;\r
 \r
 \r
   if (Argc <= 1) {\r
@@ -142,36 +146,40 @@ EblDirCmd (
       }\r
     }\r
 \r
+    TotalSize = 0;\r
     Fv = File->Fv;\r
     Key = 0;\r
     CurrentRow = 0;\r
     do {\r
       Type = SearchType;\r
       GetNextFileStatus = Fv->GetNextFile (\r
-                                Fv, \r
+                                Fv,\r
                                 &Key,\r
-                                &Type,  \r
-                                &NameGuid, \r
-                                &Attributes, \r
+                                &Type,\r
+                                &NameGuid,\r
+                                &Attributes,\r
                                 &Size\r
                                 );\r
       if (!EFI_ERROR (GetNextFileStatus)) {\r
-         // Calculate size of entire file\r
-         Section = NULL;\r
-         Size = 0;\r
-         Status = Fv->ReadFile (\r
+        TotalSize += Size;\r
+        // Calculate size of entire file\r
+        Section = NULL;\r
+        Size = 0;\r
+        Status = Fv->ReadFile (\r
                       Fv,\r
-                      &NameGuid, \r
+                      &NameGuid,\r
                       Section,\r
                       &Size,\r
                       &Type,\r
                       &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
+        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
+\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
@@ -186,7 +194,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 ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -194,7 +202,7 @@ EblDirCmd (
           FreePool (Section);\r
         } else {\r
           if (*MatchSubString == '\0') {\r
-            AsciiPrint ("  %g %a %,d\n", &NameGuid, gFvFileType[Type], Size);\r
+            AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -202,7 +210,12 @@ EblDirCmd (
         }\r
       }\r
     } while (!EFI_ERROR (GetNextFileStatus));\r
-       \r
+\r
+    if (SearchType == EFI_FV_FILETYPE_ALL) {\r
+      AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize);\r
+    }\r
+\r
+\r
   } else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) {\r
     // Simple File System DIR\r
 \r
@@ -222,7 +235,7 @@ EblDirCmd (
       if (UnicodeFileName[0] == '*') {\r
         MatchSubString = &UnicodeFileName[1];\r
       }\r
-    } \r
+    }\r
 \r
     File->FsFileHandle->SetPosition (File->FsFileHandle, 0);\r
     for (CurrentRow = 0;;) {\r
@@ -236,7 +249,7 @@ EblDirCmd (
         if (DirInfo == NULL) {\r
           goto Done;\r
         }\r
-        \r
+\r
         // Read the data\r
         Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo);\r
         if ((EFI_ERROR (Status)) || (ReadSize == 0)) {\r
@@ -245,7 +258,7 @@ EblDirCmd (
       } else {\r
         break;\r
       }\r
-      \r
+\r
       if (MatchSubString != NULL) {\r
         if (StrStr (&DirInfo->FileName[0], MatchSubString) == NULL) {\r
           // does not match *name argument, so skip\r
@@ -267,7 +280,7 @@ EblDirCmd (
       if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
         break;\r
       }\r
-      \r
+\r
       FreePool (DirInfo);\r
     }\r
 \r
@@ -286,16 +299,17 @@ Done:
   Change the Current Working Directory\r
 \r
   Argv[0] - "cd"\r
-  Argv[1] - Device Name:path. Path is optional \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
+  @param  Argv   Array of strings that represent the parsed command line.\r
+                 Argv[0] is the command name\r
 \r
   @return EFI_SUCCESS\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 EblCdCmd (\r
   IN UINTN  Argc,\r
   IN CHAR8  **Argv\r
@@ -303,8 +317,8 @@ EblCdCmd (
 {\r
   if (Argc <= 1) {\r
     return EFI_SUCCESS;\r
-  } \r
-  \r
+  }\r
+\r
   return EfiSetCwd (Argv[1]);\r
 }\r
 \r
@@ -334,7 +348,7 @@ VOID
 EblInitializeDirCmd (\r
   VOID\r
   )\r
-{  \r
+{\r
   if (FeaturePcdGet (PcdEmbeddedDirCmd)) {\r
     EblAddCommands (mCmdDirTemplate, sizeof (mCmdDirTemplate)/sizeof (EBL_COMMAND_TABLE));\r
   }\r