X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EmbeddedPkg%2FEbl%2FDir.c;h=2920d6a8e1c9eac2eade26289f609e072e546fae;hp=4e9f7b98b2928d98d2c37e49fd813f9533fc1cee;hb=60428d0000da41bb55b41984f785761fcd6320be;hpb=2ef2b01e07c02db339f34004445734a2dbdd80e1 diff --git a/EmbeddedPkg/Ebl/Dir.c b/EmbeddedPkg/Ebl/Dir.c index 4e9f7b98b2..2920d6a8e1 100644 --- a/EmbeddedPkg/Ebl/Dir.c +++ b/EmbeddedPkg/Ebl/Dir.c @@ -24,15 +24,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] = { "All", - "Raw", - "Freeform", + "Bin", + "section", "SEC", "PeiCore", "DxeCore", "PEIM", "Driver", - "Combo Driver", - "Application", + "Combo", + "App", "NULL", "FV" }; @@ -52,7 +52,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] = { only print out files that contain the string *.efi dir fv1:\ ; perform a dir on fv1: device in the efi directory NOTE: fv devices do not contian subdirs - dir fv1:\ * PEIM ; will match all files of type SEC + dir fv1:\ * PEIM ; will match all files of type PEIM @param Argc Number of command arguments in Argv @param Argv Array of strings that represent the parsed command line. @@ -88,14 +88,21 @@ EblDirCmd ( UINTN Length; UINTN BestMatchCount; CHAR16 UnicodeFileName[MAX_CMD_LINE]; + CHAR8 *Path; + CHAR8 *TypeStr; + UINTN TotalSize; if (Argc <= 1) { - // CWD not currently supported - return EFI_SUCCESS; + Path = EfiGetCwd (); + if (Path == NULL) { + return EFI_SUCCESS; + } + } else { + Path = Argv[1]; } - File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); + File = EfiOpen (Path, EFI_FILE_MODE_READ, 0); if (File == NULL) { return EFI_SUCCESS; } @@ -137,6 +144,7 @@ EblDirCmd ( } } + TotalSize = 0; Fv = File->Fv; Key = 0; CurrentRow = 0; @@ -151,10 +159,11 @@ EblDirCmd ( &Size ); if (!EFI_ERROR (GetNextFileStatus)) { - // Calculate size of entire file - Section = NULL; - Size = 0; - Status = Fv->ReadFile ( + TotalSize += Size; + // Calculate size of entire file + Section = NULL; + Size = 0; + Status = Fv->ReadFile ( Fv, &NameGuid, Section, @@ -163,10 +172,12 @@ EblDirCmd ( &Attributes, &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 Size = 0; - } + } + + TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN"; // read the UI seciton to do a name match. Section = NULL; @@ -181,7 +192,7 @@ EblDirCmd ( ); if (!EFI_ERROR (Status)) { if (StrStr (Section, MatchSubString) != NULL) { - AsciiPrint (" %g %s %a %,d\n", &NameGuid, Section, gFvFileType[Type], Size); + AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section); if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { break; } @@ -189,7 +200,7 @@ EblDirCmd ( FreePool (Section); } else { if (*MatchSubString == '\0') { - AsciiPrint (" %g %a %,d\n", &NameGuid, gFvFileType[Type], Size); + AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid); if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { break; } @@ -198,6 +209,11 @@ EblDirCmd ( } } 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)) { // Simple File System DIR @@ -277,6 +293,32 @@ Done: return EFI_SUCCESS; } +/** + Change the Current Working Directory + + Argv[0] - "cd" + Argv[1] - Device Name:path. Path is optional + + @param Argc Number of command arguments in Argv + @param Argv Array of strings that represent the parsed command line. + Argv[0] is the comamnd name + + @return EFI_SUCCESS + +**/ +EFI_STATUS +EblCdCmd ( + IN UINTN Argc, + IN CHAR8 **Argv + ) +{ + if (Argc <= 1) { + return EFI_SUCCESS; + } + + return EfiSetCwd (Argv[1]); +} + GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] = @@ -286,6 +328,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] = " dirdev [*match]; directory listing of dirdev. opt match a substring", NULL, EblDirCmd + }, + { + "cd", + " device - set the current working directory", + NULL, + EblCdCmd } };