}\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
{\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
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
},\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
CHAR16 UnicodeFileName[MAX_CMD_LINE];\r
CHAR8 *Path;\r
CHAR8 *TypeStr;\r
+ UINTN TotalSize;\r
\r
\r
if (Argc <= 1) {\r
}\r
}\r
\r
+ TotalSize = 0;\r
Fv = File->Fv;\r
Key = 0;\r
CurrentRow = 0;\r
&Size\r
);\r
if (!EFI_ERROR (GetNextFileStatus)) {\r
+ TotalSize += Size;\r
// Calculate size of entire file\r
Section = NULL;\r
Size = 0;\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
+ // 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
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
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
}\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
},\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
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
EFI_LBA Lba;
UINTN BlockSize;
UINTN NumberOfBlocks;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader = NULL;
+ UINTN Index;
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv);
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;