]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix help command scroll issue. Also add FV space used, and free space to dir command.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 12 Feb 2010 20:13:55 +0000 (20:13 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 12 Feb 2010 20:13:55 +0000 (20:13 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9996 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Ebl/Command.c
EmbeddedPkg/Ebl/Dir.c
EmbeddedPkg/Ebl/HwDebug.c
EmbeddedPkg/Include/Library/EfiFileLib.h
EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c

index 3efe6ee671e6e6e1376055d374eb9c59b165024e..9527cfea81a092dea5a49a9e5ee6f16a8d643347 100644 (file)
@@ -220,6 +220,26 @@ EblGetCommand (
 }\r
 \r
 \r
+UINTN\r
+CountNewLines (\r
+  IN CHAR8  *Str\r
+  )\r
+{\r
+  UINTN Count;\r
+  \r
+  if (Str == NULL) {\r
+    return 0;\r
+  }\r
+  \r
+  for (Count = 0; *Str != '\0'; Str++) {\r
+    if (Str[Count] == '\n') {\r
+      Count++;\r
+    }\r
+  }\r
+  \r
+  return Count;\r
+}\r
+\r
 \r
 /**\r
   List out help information on all the commands or print extended information \r
@@ -243,16 +263,22 @@ EblHelpCmd (
 {\r
   UINTN   Index;\r
   CHAR8   *Ptr;\r
-  UINTN   CurrentRow;\r
+  UINTN   CurrentRow = 0;\r
 \r
   if (Argc == 1) {\r
     // Print all the commands\r
     AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for more info):\n");\r
+    CurrentRow++;\r
     for (Index = 0; Index < mCmdTableNextFreeIndex; Index++) {\r
       EblSetTextColor (EFI_YELLOW);\r
       AsciiPrint (" %a", mCmdTable[Index]->Name);\r
       EblSetTextColor (0);\r
       AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary);\r
+      // Handle multi line help summaries\r
+      CurrentRow += CountNewLines (mCmdTable[Index]->HelpSummary);\r
+      if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
+        break;\r
+      }\r
     }\r
   } else if (Argv[1] != NULL) {\r
     // Print specific help \r
@@ -260,6 +286,8 @@ EblHelpCmd (
       if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) == 0) {\r
         Ptr = (mCmdTable[Index]->Help == NULL) ? mCmdTable[Index]->HelpSummary : mCmdTable[Index]->Help;\r
         AsciiPrint ("%a%a\n", Argv[1], Ptr);\r
+        // Handle multi line help summaries\r
+        CurrentRow += CountNewLines (Ptr);\r
         if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
           break;\r
         }\r
@@ -847,7 +875,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdTemplate[] =
   },\r
   {\r
     "hexdump",\r
-    "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex bytes at a given width",\r
+    "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex .width",\r
     NULL,\r
     EblHexdumpCmd\r
   }\r
index 126ef5d7c78ca802e01b8a96a1c821b9bb7a043a..2920d6a8e1c9eac2eade26289f609e072e546fae 100644 (file)
@@ -90,6 +90,7 @@ EblDirCmd (
   CHAR16                        UnicodeFileName[MAX_CMD_LINE];\r
   CHAR8                         *Path;\r
   CHAR8                         *TypeStr;\r
+  UINTN                         TotalSize;\r
 \r
 \r
   if (Argc <= 1) {\r
@@ -143,6 +144,7 @@ EblDirCmd (
       }\r
     }\r
 \r
+    TotalSize = 0;\r
     Fv = File->Fv;\r
     Key = 0;\r
     CurrentRow = 0;\r
@@ -157,6 +159,7 @@ EblDirCmd (
                                 &Size\r
                                 );\r
       if (!EFI_ERROR (GetNextFileStatus)) {\r
+        TotalSize += Size;\r
         // Calculate size of entire file\r
         Section = NULL;\r
         Size = 0;\r
@@ -170,8 +173,8 @@ EblDirCmd (
                       &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
+          // 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
@@ -189,7 +192,7 @@ EblDirCmd (
                         );\r
         if (!EFI_ERROR (Status)) {\r
           if (StrStr (Section, MatchSubString) != NULL) {\r
-            AsciiPrint ("%,6d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);\r
+            AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -197,7 +200,7 @@ EblDirCmd (
           FreePool (Section);\r
         } else {\r
           if (*MatchSubString == '\0') {\r
-            AsciiPrint ("%,6d %7a %g\n", Size, TypeStr, &NameGuid);\r
+            AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);\r
             if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
               break;\r
             }\r
@@ -206,6 +209,11 @@ EblDirCmd (
       }\r
     } while (!EFI_ERROR (GetNextFileStatus));\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
index b2ea9af64b3b18c00d56497310d80f679bf52a7d..20f0a72d95bebc7f3e9011f90c6d875f528ca3fe 100644 (file)
@@ -314,7 +314,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwDebugTemplate[] =
   },\r
   {\r
     "mfill",\r
-    "[.{1|2|4}] Addr Len [data] [1|2|4]; Memory Fill Addr Len*(1|2|4) bytes of data(0)",\r
+    "[.{1|2|4}] Addr Len [data]; Memory Fill Addr Len*(1|2|4) bytes of data(0)",\r
     NULL,\r
     EblMfillCmd\r
   },\r
index 4bbb1b26f138dddc279ed6e42b7c970a5d210f7a..1ea8324b6248852f8483a71935a429dd6645810d 100644 (file)
@@ -87,7 +87,8 @@ typedef struct {
   EFI_FV_FILE_ATTRIBUTES        FvAttributes;     \r
 \r
   EFI_PHYSICAL_ADDRESS          FvStart;          \r
-  UINTN                         FvSize;           \r
+  UINTN                         FvSize;      \r
+  UINTN                         FvHeaderSize;\r
 \r
   EFI_FILE                      *FsFileHandle;    // Information valid for Fs#:\r
   EFI_FILE_SYSTEM_INFO          *FsInfo;\r
index d3d959641346081e669b2aadcf7e128c707ff67a..8d51fcf9c31306c34bbf63922aa1a55d17ce4eec 100644 (file)
@@ -519,6 +519,8 @@ EblFvFileDevicePath (
   EFI_LBA                             Lba;
   UINTN                               BlockSize;
   UINTN                               NumberOfBlocks;
+  EFI_FIRMWARE_VOLUME_HEADER          *FvHeader = NULL;
+  UINTN                               Index;
 
 
   Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv);
@@ -531,7 +533,13 @@ EblFvFileDevicePath (
   if (!EFI_ERROR (Status)) {
     Status = Fvb->GetPhysicalAddress (Fvb, &File->FvStart);
     if (!EFI_ERROR (Status)) {
-      for (Lba = 0, File->FvSize = 0; ; File->FvSize += (BlockSize * NumberOfBlocks), Lba += NumberOfBlocks) {
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)File->FvStart;
+      File->FvHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_HEADER);
+      for (Index = 0; FvHeader->BlockMap[Index].Length !=0; Index++) {
+        File->FvHeaderSize += sizeof (EFI_FV_BLOCK_MAP_ENTRY);
+      }
+      
+      for (Lba = 0, File->FvSize = 0, NumberOfBlocks = 0; ; File->FvSize += (BlockSize * NumberOfBlocks), Lba += NumberOfBlocks) {
         Status = Fvb->GetBlockSize (Fvb, Lba, &BlockSize, &NumberOfBlocks);
         if (EFI_ERROR (Status)) {
           break;