Fix help command scroll issue. Also add FV space used, and free space to dir command.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9996 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2010-02-12 20:13:55 +00:00
parent 135ec2db42
commit 60428d0000
5 changed files with 54 additions and 9 deletions

View File

@ -220,6 +220,26 @@ EblGetCommand (
} }
UINTN
CountNewLines (
IN CHAR8 *Str
)
{
UINTN Count;
if (Str == NULL) {
return 0;
}
for (Count = 0; *Str != '\0'; Str++) {
if (Str[Count] == '\n') {
Count++;
}
}
return Count;
}
/** /**
List out help information on all the commands or print extended information List out help information on all the commands or print extended information
@ -243,16 +263,22 @@ EblHelpCmd (
{ {
UINTN Index; UINTN Index;
CHAR8 *Ptr; CHAR8 *Ptr;
UINTN CurrentRow; UINTN CurrentRow = 0;
if (Argc == 1) { if (Argc == 1) {
// Print all the commands // Print all the commands
AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for more info):\n"); AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for more info):\n");
CurrentRow++;
for (Index = 0; Index < mCmdTableNextFreeIndex; Index++) { for (Index = 0; Index < mCmdTableNextFreeIndex; Index++) {
EblSetTextColor (EFI_YELLOW); EblSetTextColor (EFI_YELLOW);
AsciiPrint (" %a", mCmdTable[Index]->Name); AsciiPrint (" %a", mCmdTable[Index]->Name);
EblSetTextColor (0); EblSetTextColor (0);
AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary); AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary);
// Handle multi line help summaries
CurrentRow += CountNewLines (mCmdTable[Index]->HelpSummary);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break;
}
} }
} else if (Argv[1] != NULL) { } else if (Argv[1] != NULL) {
// Print specific help // Print specific help
@ -260,6 +286,8 @@ EblHelpCmd (
if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) == 0) { if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) == 0) {
Ptr = (mCmdTable[Index]->Help == NULL) ? mCmdTable[Index]->HelpSummary : mCmdTable[Index]->Help; Ptr = (mCmdTable[Index]->Help == NULL) ? mCmdTable[Index]->HelpSummary : mCmdTable[Index]->Help;
AsciiPrint ("%a%a\n", Argv[1], Ptr); AsciiPrint ("%a%a\n", Argv[1], Ptr);
// Handle multi line help summaries
CurrentRow += CountNewLines (Ptr);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break; break;
} }
@ -847,7 +875,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdTemplate[] =
}, },
{ {
"hexdump", "hexdump",
"[.{1|2|4}] filename [Offset] [Size]; dump a file as hex bytes at a given width", "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex .width",
NULL, NULL,
EblHexdumpCmd EblHexdumpCmd
} }

View File

@ -90,6 +90,7 @@ EblDirCmd (
CHAR16 UnicodeFileName[MAX_CMD_LINE]; CHAR16 UnicodeFileName[MAX_CMD_LINE];
CHAR8 *Path; CHAR8 *Path;
CHAR8 *TypeStr; CHAR8 *TypeStr;
UINTN TotalSize;
if (Argc <= 1) { if (Argc <= 1) {
@ -143,6 +144,7 @@ EblDirCmd (
} }
} }
TotalSize = 0;
Fv = File->Fv; Fv = File->Fv;
Key = 0; Key = 0;
CurrentRow = 0; CurrentRow = 0;
@ -157,6 +159,7 @@ EblDirCmd (
&Size &Size
); );
if (!EFI_ERROR (GetNextFileStatus)) { if (!EFI_ERROR (GetNextFileStatus)) {
TotalSize += Size;
// Calculate size of entire file // Calculate size of entire file
Section = NULL; Section = NULL;
Size = 0; Size = 0;
@ -170,8 +173,8 @@ EblDirCmd (
&AuthenticationStatus &AuthenticationStatus
); );
if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) { if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {
// EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid
Size = 0; Size = 0;
} }
TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN"; TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN";
@ -189,7 +192,7 @@ EblDirCmd (
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (StrStr (Section, MatchSubString) != NULL) { if (StrStr (Section, MatchSubString) != NULL) {
AsciiPrint ("%,6d %7a %g %s\n", Size, TypeStr, &NameGuid, Section); AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break; break;
} }
@ -197,7 +200,7 @@ EblDirCmd (
FreePool (Section); FreePool (Section);
} else { } else {
if (*MatchSubString == '\0') { if (*MatchSubString == '\0') {
AsciiPrint ("%,6d %7a %g\n", Size, TypeStr, &NameGuid); AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break; break;
} }
@ -206,6 +209,11 @@ EblDirCmd (
} }
} while (!EFI_ERROR (GetNextFileStatus)); } while (!EFI_ERROR (GetNextFileStatus));
if (SearchType == EFI_FV_FILETYPE_ALL) {
AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize);
}
} else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) { } else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) {
// Simple File System DIR // Simple File System DIR

View File

@ -314,7 +314,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwDebugTemplate[] =
}, },
{ {
"mfill", "mfill",
"[.{1|2|4}] Addr Len [data] [1|2|4]; Memory Fill Addr Len*(1|2|4) bytes of data(0)", "[.{1|2|4}] Addr Len [data]; Memory Fill Addr Len*(1|2|4) bytes of data(0)",
NULL, NULL,
EblMfillCmd EblMfillCmd
}, },

View File

@ -88,6 +88,7 @@ typedef struct {
EFI_PHYSICAL_ADDRESS FvStart; EFI_PHYSICAL_ADDRESS FvStart;
UINTN FvSize; UINTN FvSize;
UINTN FvHeaderSize;
EFI_FILE *FsFileHandle; // Information valid for Fs#: EFI_FILE *FsFileHandle; // Information valid for Fs#:
EFI_FILE_SYSTEM_INFO *FsInfo; EFI_FILE_SYSTEM_INFO *FsInfo;

View File

@ -519,6 +519,8 @@ EblFvFileDevicePath (
EFI_LBA Lba; EFI_LBA Lba;
UINTN BlockSize; UINTN BlockSize;
UINTN NumberOfBlocks; UINTN NumberOfBlocks;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader = NULL;
UINTN Index;
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv); Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv);
@ -531,7 +533,13 @@ EblFvFileDevicePath (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = Fvb->GetPhysicalAddress (Fvb, &File->FvStart); Status = Fvb->GetPhysicalAddress (Fvb, &File->FvStart);
if (!EFI_ERROR (Status)) { 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); Status = Fvb->GetBlockSize (Fvb, Lba, &BlockSize, &NumberOfBlocks);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
break; break;