ShellPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ShellPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
c411b485b6
commit
47d20b54f9
@ -29,6 +29,7 @@ ConsoleLoggerInstall(
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (ConsoleInfo != NULL);
|
||||
|
||||
(*ConsoleInfo) = AllocateZeroPool (sizeof (CONSOLE_LOGGER_PRIVATE_DATA));
|
||||
@ -116,13 +117,22 @@ ConsoleLoggerUninstall(
|
||||
|
||||
if (ConsoleInfo->Buffer != NULL) {
|
||||
FreePool (ConsoleInfo->Buffer);
|
||||
DEBUG_CODE(ConsoleInfo->Buffer = NULL;);
|
||||
DEBUG_CODE(ConsoleInfo->BufferSize = 0;);
|
||||
DEBUG_CODE (
|
||||
ConsoleInfo->Buffer = NULL;
|
||||
);
|
||||
DEBUG_CODE (
|
||||
ConsoleInfo->BufferSize = 0;
|
||||
);
|
||||
}
|
||||
|
||||
if (ConsoleInfo->Attributes != NULL) {
|
||||
FreePool (ConsoleInfo->Attributes);
|
||||
DEBUG_CODE(ConsoleInfo->Attributes = NULL;);
|
||||
DEBUG_CODE(ConsoleInfo->AttribSize = 0;);
|
||||
DEBUG_CODE (
|
||||
ConsoleInfo->Attributes = NULL;
|
||||
);
|
||||
DEBUG_CODE (
|
||||
ConsoleInfo->AttribSize = 0;
|
||||
);
|
||||
}
|
||||
|
||||
gST->ConsoleOutHandle = ConsoleInfo->OldConHandle;
|
||||
@ -288,10 +298,11 @@ UpdateDisplayFromHistory(
|
||||
Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow];
|
||||
for ( CurrentRow = 0
|
||||
; CurrentRow < ConsoleInfo->RowsPerScreen
|
||||
; CurrentRow++
|
||||
, Screen += (ConsoleInfo->ColsPerScreen + 2)
|
||||
, Attributes += ConsoleInfo->ColsPerScreen
|
||||
){
|
||||
; CurrentRow++,
|
||||
Screen += (ConsoleInfo->ColsPerScreen + 2),
|
||||
Attributes += ConsoleInfo->ColsPerScreen
|
||||
)
|
||||
{
|
||||
//
|
||||
// dont use the last char - prevents screen scroll
|
||||
//
|
||||
@ -303,7 +314,8 @@ UpdateDisplayFromHistory(
|
||||
for ( Column = 0
|
||||
; Column < ConsoleInfo->ColsPerScreen
|
||||
; Column++
|
||||
){
|
||||
)
|
||||
{
|
||||
if (Screen[Column] != CHAR_NULL) {
|
||||
CurrentAttrib = Attributes[Column];
|
||||
CurrentColumn = Column;
|
||||
@ -317,9 +329,10 @@ UpdateDisplayFromHistory(
|
||||
StringSegmentEndChar = CHAR_NULL;
|
||||
for ( StringSegmentEnd = StringSegment
|
||||
; *StringSegmentEnd != CHAR_NULL
|
||||
; StringSegmentEnd++
|
||||
, Column++
|
||||
){
|
||||
; StringSegmentEnd++,
|
||||
Column++
|
||||
)
|
||||
{
|
||||
if (Attributes[Column] != CurrentAttrib) {
|
||||
StringSegmentEndChar = *StringSegmentEnd;
|
||||
*StringSegmentEnd = CHAR_NULL;
|
||||
@ -413,6 +426,7 @@ ConsoleLoggerReset (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
//
|
||||
@ -458,12 +472,14 @@ AppendStringToHistory(
|
||||
for ( Walker = String
|
||||
; Walker != NULL && *Walker != CHAR_NULL
|
||||
; Walker++
|
||||
){
|
||||
)
|
||||
{
|
||||
switch (*Walker) {
|
||||
case (CHAR_BACKSPACE):
|
||||
if (ConsoleInfo->HistoryMode.CursorColumn > 0) {
|
||||
ConsoleInfo->HistoryMode.CursorColumn--;
|
||||
}
|
||||
|
||||
break;
|
||||
case (CHAR_LINEFEED):
|
||||
if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) {
|
||||
@ -488,7 +504,8 @@ AppendStringToHistory(
|
||||
for ( Index = 0
|
||||
; Index < ConsoleInfo->ColsPerScreen
|
||||
; Index++
|
||||
){
|
||||
)
|
||||
{
|
||||
*(ConsoleInfo->Attributes + (CopySize/sizeof (ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute;
|
||||
}
|
||||
|
||||
@ -525,8 +542,10 @@ AppendStringToHistory(
|
||||
ConsoleInfo->OriginalStartRow++;
|
||||
ConsoleInfo->CurrentStartRow++;
|
||||
}
|
||||
|
||||
ConsoleInfo->HistoryMode.CursorRow++;
|
||||
}
|
||||
|
||||
break;
|
||||
case (CHAR_CARRIAGE_RETURN):
|
||||
//
|
||||
@ -543,18 +562,21 @@ AppendStringToHistory(
|
||||
|
||||
for ( // no initializer needed
|
||||
; ConsoleInfo->HistoryMode.CursorColumn < (INT32)ConsoleInfo->ColsPerScreen
|
||||
; ConsoleInfo->HistoryMode.CursorColumn++
|
||||
, PrintIndex++
|
||||
, Walker++
|
||||
){
|
||||
if (*Walker == CHAR_NULL
|
||||
||*Walker == CHAR_BACKSPACE
|
||||
||*Walker == CHAR_LINEFEED
|
||||
||*Walker == CHAR_CARRIAGE_RETURN
|
||||
){
|
||||
; ConsoleInfo->HistoryMode.CursorColumn++,
|
||||
PrintIndex++,
|
||||
Walker++
|
||||
)
|
||||
{
|
||||
if ( (*Walker == CHAR_NULL)
|
||||
|| (*Walker == CHAR_BACKSPACE)
|
||||
|| (*Walker == CHAR_LINEFEED)
|
||||
|| (*Walker == CHAR_CARRIAGE_RETURN)
|
||||
)
|
||||
{
|
||||
Walker--;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The buffer is 2*CursorRow more since it has that many \r\n characters at the end of each row.
|
||||
//
|
||||
@ -641,12 +663,15 @@ ConsoleLoggerDoPageBreak(
|
||||
if (Resp == NULL) {
|
||||
return (EFI_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Resp != NULL) {
|
||||
FreePool (Resp);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
if (*Resp == ShellPromptResponseContinue) {
|
||||
FreePool (Resp);
|
||||
ShellInfoObject.ConsoleInfo->RowCounter = 0;
|
||||
@ -665,8 +690,10 @@ ConsoleLoggerDoPageBreak(
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
Worker function to handle printing the output with page breaks.
|
||||
|
||||
@ -699,16 +726,18 @@ ConsoleLoggerPrintWithPageBreak(
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
for ( Walker = StringCopy
|
||||
, LineStart = StringCopy
|
||||
for ( Walker = StringCopy,
|
||||
LineStart = StringCopy
|
||||
; Walker != NULL && *Walker != CHAR_NULL
|
||||
; Walker++
|
||||
){
|
||||
)
|
||||
{
|
||||
switch (*Walker) {
|
||||
case (CHAR_BACKSPACE):
|
||||
if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) {
|
||||
ConsoleInfo->OurConOut.Mode->CursorColumn--;
|
||||
}
|
||||
|
||||
break;
|
||||
case (CHAR_LINEFEED):
|
||||
//
|
||||
@ -786,6 +815,7 @@ ConsoleLoggerPrintWithPageBreak(
|
||||
ConsoleInfo->OurConOut.Mode->CursorRow++;
|
||||
ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
|
||||
} // last column on line
|
||||
|
||||
break;
|
||||
} // switch for character
|
||||
|
||||
@ -803,7 +833,7 @@ ConsoleLoggerPrintWithPageBreak(
|
||||
}
|
||||
} // for loop
|
||||
|
||||
if (LineStart != NULL && *LineStart != CHAR_NULL) {
|
||||
if ((LineStart != NULL) && (*LineStart != CHAR_NULL)) {
|
||||
ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
|
||||
}
|
||||
|
||||
@ -844,12 +874,12 @@ ConsoleLoggerOutputString (
|
||||
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
|
||||
return (EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
ASSERT (ShellInfoObject.ConsoleInfo == ConsoleInfo);
|
||||
|
||||
Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
while (ShellInfoObject.HaltOutput) {
|
||||
|
||||
ShellInfoObject.HaltOutput = FALSE;
|
||||
//
|
||||
// just get some key
|
||||
@ -865,7 +895,8 @@ ConsoleLoggerOutputString (
|
||||
((KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED)) ||
|
||||
(KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED))
|
||||
)
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellInfoObject.HaltOutput = TRUE;
|
||||
}
|
||||
}
|
||||
@ -902,6 +933,7 @@ ConsoleLoggerTestString (
|
||||
)
|
||||
{
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
//
|
||||
// Forward the request to the original ConOut
|
||||
@ -933,6 +965,7 @@ ConsoleLoggerQueryMode (
|
||||
)
|
||||
{
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
//
|
||||
// Forward the request to the original ConOut
|
||||
@ -967,6 +1000,7 @@ ConsoleLoggerSetMode (
|
||||
EFI_STATUS Status;
|
||||
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
//
|
||||
@ -1013,6 +1047,7 @@ ConsoleLoggerSetAttribute (
|
||||
EFI_STATUS Status;
|
||||
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
//
|
||||
@ -1074,21 +1109,25 @@ ConsoleLoggerClearScreen (
|
||||
for ( Row = ConsoleInfo->OriginalStartRow
|
||||
; Row < (ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)
|
||||
; Row++
|
||||
){
|
||||
)
|
||||
{
|
||||
for ( Column = 0
|
||||
; Column < ConsoleInfo->ColsPerScreen
|
||||
; Column++
|
||||
, Screen++
|
||||
, Attributes++
|
||||
){
|
||||
; Column++,
|
||||
Screen++,
|
||||
Attributes++
|
||||
)
|
||||
{
|
||||
*Screen = L' ';
|
||||
*Attributes = ConsoleInfo->OldConOut->Mode->Attribute;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the NULL on each column end in text buffer only
|
||||
//
|
||||
Screen += 2;
|
||||
}
|
||||
|
||||
ConsoleInfo->HistoryMode.CursorColumn = 0;
|
||||
ConsoleInfo->HistoryMode.CursorRow = 0;
|
||||
}
|
||||
@ -1168,6 +1207,7 @@ ConsoleLoggerEnableCursor (
|
||||
EFI_STATUS Status;
|
||||
|
||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||
|
||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
|
||||
//
|
||||
// Forward the request to the original ConOut
|
||||
@ -1204,6 +1244,7 @@ ConsoleLoggerResetBuffers(
|
||||
ConsoleInfo->Buffer = NULL;
|
||||
ConsoleInfo->BufferSize = 0;
|
||||
}
|
||||
|
||||
if (ConsoleInfo->Attributes != NULL) {
|
||||
FreePool (ConsoleInfo->Attributes);
|
||||
ConsoleInfo->Attributes = NULL;
|
||||
|
@ -314,4 +314,3 @@ ConsoleLoggerResetBuffers(
|
||||
);
|
||||
|
||||
#endif //_CONSOLE_LOGGER_HEADER_
|
||||
|
||||
|
@ -82,7 +82,7 @@ FileBasedSimpleTextInReadKeyStroke(
|
||||
//
|
||||
// Verify the parameters
|
||||
//
|
||||
if (Key == NULL || This == NULL) {
|
||||
if ((Key == NULL) || (This == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -100,6 +100,7 @@ FileBasedSimpleTextInReadKeyStroke(
|
||||
} else {
|
||||
CharSize = sizeof (CHAR8);
|
||||
}
|
||||
|
||||
//
|
||||
// Decrement the amount of free space by Size or set to zero (for odd length files)
|
||||
//
|
||||
@ -113,7 +114,8 @@ FileBasedSimpleTextInReadKeyStroke(
|
||||
return (ShellInfoObject.NewEfiShellProtocol->ReadFile (
|
||||
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
|
||||
&Size,
|
||||
&Key->UnicodeChar));
|
||||
&Key->UnicodeChar
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +139,7 @@ CreateSimpleTextInOnFile(
|
||||
UINT64 CurrentPosition;
|
||||
UINT64 FileSize;
|
||||
|
||||
if (HandleLocation == NULL || FileHandleToUse == NULL) {
|
||||
if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -169,12 +171,14 @@ CreateSimpleTextInOnFile(
|
||||
FreePool (ProtocolToReturn);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/// @todo possibly also install SimpleTextInputEx on the handle at this point.
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&(ProtocolToReturn->TheHandle),
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&(ProtocolToReturn->SimpleTextIn));
|
||||
&(ProtocolToReturn->SimpleTextIn)
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*HandleLocation = ProtocolToReturn->TheHandle;
|
||||
return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)ProtocolToReturn);
|
||||
@ -209,7 +213,8 @@ CloseSimpleTextInOnFile(
|
||||
Status1 = gBS->UninstallProtocolInterface (
|
||||
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->TheHandle,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
&(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn));
|
||||
&(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn)
|
||||
);
|
||||
|
||||
FreePool (SimpleTextIn);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -285,7 +290,8 @@ FileBasedSimpleTextOutQueryMode (
|
||||
PassThruProtocol,
|
||||
ModeNumber,
|
||||
Columns,
|
||||
Rows));
|
||||
Rows
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -407,11 +413,13 @@ FileBasedSimpleTextOutOutputString (
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
|
||||
Size = StrLen (WString) * sizeof (CHAR16);
|
||||
return (ShellInfoObject.NewEfiShellProtocol->WriteFile (
|
||||
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
|
||||
&Size,
|
||||
WString));
|
||||
WString
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,7 +443,7 @@ CreateSimpleTextOutOnFile(
|
||||
SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (HandleLocation == NULL || FileHandleToUse == NULL) {
|
||||
if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -443,6 +451,7 @@ CreateSimpleTextOutOnFile(
|
||||
if (ProtocolToReturn == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ProtocolToReturn->FileHandle = FileHandleToUse;
|
||||
ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
|
||||
ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
|
||||
@ -459,6 +468,7 @@ CreateSimpleTextOutOnFile(
|
||||
FreePool (ProtocolToReturn);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
|
||||
ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
|
||||
ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
|
||||
@ -470,7 +480,8 @@ CreateSimpleTextOutOnFile(
|
||||
&(ProtocolToReturn->TheHandle),
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&(ProtocolToReturn->SimpleTextOut));
|
||||
&(ProtocolToReturn->SimpleTextOut)
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*HandleLocation = ProtocolToReturn->TheHandle;
|
||||
return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)ProtocolToReturn);
|
||||
@ -495,13 +506,16 @@ CloseSimpleTextOutOnFile(
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (SimpleTextOut == NULL) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->TheHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
&(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));
|
||||
&(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->SimpleTextOut)
|
||||
);
|
||||
FreePool (SimpleTextOut->Mode);
|
||||
FreePool (SimpleTextOut);
|
||||
return (Status);
|
||||
|
@ -71,4 +71,3 @@ CloseSimpleTextOutOnFile(
|
||||
);
|
||||
|
||||
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_
|
||||
|
||||
|
@ -56,4 +56,3 @@ PrintCommandHistory (
|
||||
);
|
||||
|
||||
#endif //_FILE_HANDLE_INTERNAL_HEADER_
|
||||
|
||||
|
@ -157,9 +157,11 @@ FileInterfaceStdOutWrite(
|
||||
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
|
||||
return (EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
if (*((CHAR16 *)Buffer) == gUnicodeFileTag) {
|
||||
return (gST->ConOut->OutputString (gST->ConOut, (CHAR16 *)Buffer + 1));
|
||||
}
|
||||
|
||||
return (gST->ConOut->OutputString (gST->ConOut, Buffer));
|
||||
}
|
||||
|
||||
@ -343,6 +345,7 @@ CreateTabCompletionList (
|
||||
TabPos = Index + 1;
|
||||
*TabUpdatePos = TabPos;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case L':':
|
||||
@ -382,6 +385,7 @@ CreateTabCompletionList (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), InputString + TabPos, StringLen - TabPos);
|
||||
StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), L"*", (BufferSize) / sizeof (CHAR16) - 1 - StrLen (TabStr));
|
||||
Status = ShellInfoObject.NewEfiShellProtocol->FindFiles (TabStr, &FileList);
|
||||
@ -390,7 +394,7 @@ CreateTabCompletionList (
|
||||
// Filter out the non-directory for "CD" command
|
||||
// Filter "." and ".." for all
|
||||
//
|
||||
if (!EFI_ERROR (Status) && FileList != NULL) {
|
||||
if (!EFI_ERROR (Status) && (FileList != NULL)) {
|
||||
//
|
||||
// Skip the spaces in the beginning
|
||||
//
|
||||
@ -400,8 +404,9 @@ CreateTabCompletionList (
|
||||
|
||||
for (FileInfo = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link); !IsNull (&FileList->Link, &FileInfo->Link); ) {
|
||||
if (((StrCmp (FileInfo->FileName, L".") == 0) || (StrCmp (FileInfo->FileName, L"..") == 0)) ||
|
||||
(((InputString[0] == L'c' || InputString[0] == L'C') && (InputString[1] == L'd' || InputString[1] == L'D')) &&
|
||||
(ShellIsDirectory (FileInfo->FullName) != EFI_SUCCESS))) {
|
||||
((((InputString[0] == L'c') || (InputString[0] == L'C')) && ((InputString[1] == L'd') || (InputString[1] == L'D'))) &&
|
||||
(ShellIsDirectory (FileInfo->FullName) != EFI_SUCCESS)))
|
||||
{
|
||||
TempFileInfo = FileInfo;
|
||||
FileInfo = (EFI_SHELL_FILE_INFO *)RemoveEntryList (&FileInfo->Link);
|
||||
InternalFreeShellFileInfoNode (TempFileInfo);
|
||||
@ -411,7 +416,7 @@ CreateTabCompletionList (
|
||||
}
|
||||
}
|
||||
|
||||
if (FileList != NULL && !IsListEmpty (&FileList->Link)) {
|
||||
if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&FileList);
|
||||
@ -524,6 +529,7 @@ FileInterfaceStdInRead(
|
||||
if (MaxStr > *BufferSize / sizeof (CHAR16)) {
|
||||
MaxStr = *BufferSize / sizeof (CHAR16);
|
||||
}
|
||||
|
||||
ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
|
||||
do {
|
||||
//
|
||||
@ -532,9 +538,9 @@ FileInterfaceStdInRead(
|
||||
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
|
||||
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
if (Status == EFI_NOT_READY)
|
||||
if (Status == EFI_NOT_READY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
|
||||
StringLen = 0;
|
||||
@ -545,7 +551,7 @@ FileInterfaceStdInRead(
|
||||
// Press PageUp or PageDown to scroll the history screen up or down.
|
||||
// Press any other key to quit scrolling.
|
||||
//
|
||||
if (Key.UnicodeChar == 0 && (Key.ScanCode == SCAN_PAGE_UP || Key.ScanCode == SCAN_PAGE_DOWN)) {
|
||||
if ((Key.UnicodeChar == 0) && ((Key.ScanCode == SCAN_PAGE_UP) || (Key.ScanCode == SCAN_PAGE_DOWN))) {
|
||||
if (Key.ScanCode == SCAN_PAGE_UP) {
|
||||
ConsoleLoggerDisplayHistory (FALSE, 0, ShellInfoObject.ConsoleInfo);
|
||||
} else if (Key.ScanCode == SCAN_PAGE_DOWN) {
|
||||
@ -563,11 +569,14 @@ FileInterfaceStdInRead(
|
||||
//
|
||||
// If we are quitting TAB scrolling...
|
||||
//
|
||||
if (InTabScrolling && Key.UnicodeChar != CHAR_TAB) {
|
||||
if (InTabScrolling && (Key.UnicodeChar != CHAR_TAB)) {
|
||||
if (TabCompleteList != NULL) {
|
||||
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
|
||||
DEBUG_CODE(TabCompleteList = NULL;);
|
||||
DEBUG_CODE (
|
||||
TabCompleteList = NULL;
|
||||
);
|
||||
}
|
||||
|
||||
InTabScrolling = FALSE;
|
||||
}
|
||||
|
||||
@ -598,6 +607,7 @@ FileInterfaceStdInRead(
|
||||
//
|
||||
MoveCursorBackward (TotalColumn, &Column, &Row);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CHAR_TAB:
|
||||
@ -636,6 +646,7 @@ FileInterfaceStdInRead(
|
||||
TabCurrent = (EFI_SHELL_FILE_INFO *)GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -643,9 +654,10 @@ FileInterfaceStdInRead(
|
||||
//
|
||||
// If we are at the buffer's end, drop the key
|
||||
//
|
||||
if (StringLen == MaxStr - 1 && (ShellInfoObject.ViewingSettings.InsertMode || StringCurPos == StringLen)) {
|
||||
if ((StringLen == MaxStr - 1) && (ShellInfoObject.ViewingSettings.InsertMode || (StringCurPos == StringLen))) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// If in insert mode, make space by moving each other character 1
|
||||
// space higher in the array
|
||||
@ -660,6 +672,7 @@ FileInterfaceStdInRead(
|
||||
StringCurPos += 1;
|
||||
OutputLength = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0:
|
||||
@ -673,6 +686,7 @@ FileInterfaceStdInRead(
|
||||
Delete = 1;
|
||||
CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCAN_UP:
|
||||
@ -683,6 +697,7 @@ FileInterfaceStdInRead(
|
||||
if (IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link)) {
|
||||
NewPos = (BUFFER_LIST *)GetPreviousNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCAN_DOWN:
|
||||
@ -693,6 +708,7 @@ FileInterfaceStdInRead(
|
||||
if (NewPos == (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
|
||||
NewPos = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCAN_LEFT:
|
||||
@ -703,6 +719,7 @@ FileInterfaceStdInRead(
|
||||
--StringCurPos;
|
||||
MoveCursorBackward (TotalColumn, &Column, &Row);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCAN_RIGHT:
|
||||
@ -713,6 +730,7 @@ FileInterfaceStdInRead(
|
||||
++StringCurPos;
|
||||
MoveCursorForward (TotalColumn, TotalRow, &Column, &Row);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCAN_HOME:
|
||||
@ -780,8 +798,7 @@ FileInterfaceStdInRead(
|
||||
}
|
||||
}
|
||||
|
||||
if (InTabScrolling && TabOutputStr != NULL) {
|
||||
|
||||
if (InTabScrolling && (TabOutputStr != NULL)) {
|
||||
//
|
||||
// Adjust the column and row to the start of TAB-completion string.
|
||||
//
|
||||
@ -801,6 +818,7 @@ FileInterfaceStdInRead(
|
||||
CopyMem (TabOutputStr, TabCurrent->FileName, OutputLength * sizeof (CHAR16));
|
||||
TabOutputStr[OutputLength] = CHAR_NULL;
|
||||
}
|
||||
|
||||
OutputLength = StrLen (TabOutputStr) < MaxStr - 1 ? StrLen (TabOutputStr) : MaxStr - 1;
|
||||
CopyMem (CurrentString + TabUpdatePos, TabOutputStr, OutputLength * sizeof (CHAR16));
|
||||
CurrentString[TabUpdatePos + OutputLength] = CHAR_NULL;
|
||||
@ -841,6 +859,7 @@ FileInterfaceStdInRead(
|
||||
Delete = StringLen - OutputLength;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we need to update the output do so now
|
||||
//
|
||||
@ -863,7 +882,7 @@ FileInterfaceStdInRead(
|
||||
// BACKSPACE and DELETE, we need to move the cursor position forward,
|
||||
// so adjust row and column here.
|
||||
//
|
||||
if (Key.UnicodeChar != CHAR_BACKSPACE && !(Key.UnicodeChar == 0 && Key.ScanCode == SCAN_DELETE)) {
|
||||
if ((Key.UnicodeChar != CHAR_BACKSPACE) && !((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_DELETE))) {
|
||||
//
|
||||
// Calculate row and column of the tail of current string
|
||||
//
|
||||
@ -877,9 +896,10 @@ FileInterfaceStdInRead(
|
||||
// (if we are recalling commands using UPPER and DOWN key, and if the
|
||||
// old command is too long to fit the screen, TailColumn must be 79.
|
||||
//
|
||||
if (TailColumn == 0 && TailRow >= TotalRow && Row != TailRow) {
|
||||
if ((TailColumn == 0) && (TailRow >= TotalRow) && (Row != TailRow)) {
|
||||
Row--;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate the cursor position after current operation. If cursor
|
||||
// reaches line end, update both row and column, otherwise, only
|
||||
@ -901,13 +921,14 @@ FileInterfaceStdInRead(
|
||||
|
||||
Delete = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the cursor position for this key
|
||||
//
|
||||
gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);
|
||||
} while (!Done);
|
||||
|
||||
if (CurrentString != NULL && StrLen(CurrentString) > 0) {
|
||||
if ((CurrentString != NULL) && (StrLen (CurrentString) > 0)) {
|
||||
//
|
||||
// add the line to the history buffer
|
||||
//
|
||||
@ -926,6 +947,7 @@ FileInterfaceStdInRead(
|
||||
if (TabCompleteList != NULL) {
|
||||
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
|
||||
}
|
||||
|
||||
ASSERT (TabCompleteList == NULL);
|
||||
|
||||
return Status;
|
||||
@ -990,9 +1012,6 @@ EFI_FILE_PROTOCOL FileInterfaceNulFile = {
|
||||
FileInterfaceNopGeneric
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// This is identical to EFI_FILE_PROTOCOL except for the additional member
|
||||
// for the name.
|
||||
@ -1058,15 +1077,16 @@ FileInterfaceEnvClose(
|
||||
if (NewBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && NewBuffer != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && (NewBuffer != NULL)) {
|
||||
if (TotalSize / sizeof (CHAR16) >= 3) {
|
||||
if ((((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 2] == CHAR_LINEFEED) &&
|
||||
(((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN)
|
||||
) {
|
||||
)
|
||||
{
|
||||
((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL;
|
||||
//
|
||||
// If the NewBuffer end with \r\n\0, We will replace '\r' by '\0' and then update TotalSize.
|
||||
@ -1170,6 +1190,7 @@ FileInterfaceEnvRead(
|
||||
//
|
||||
*BufferSize += sizeof (gUnicodeFileTag);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1219,7 +1240,7 @@ FileInterfaceEnvVolWrite(
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
||||
FreePool (NewBuffer);
|
||||
return Status;
|
||||
}
|
||||
@ -1249,7 +1270,6 @@ FileInterfaceEnvVolWrite(
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
File style interface for Non Volatile Environment Variable (Write).
|
||||
This function also caches the environment variable into gShellEnvVarList.
|
||||
@ -1296,7 +1316,7 @@ FileInterfaceEnvNonVolWrite(
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
||||
FreePool (NewBuffer);
|
||||
return Status;
|
||||
}
|
||||
@ -1387,6 +1407,7 @@ CreateFileInterfaceEnv(
|
||||
} else {
|
||||
EnvFileInterface->Write = FileInterfaceEnvNonVolWrite;
|
||||
}
|
||||
|
||||
return ((EFI_FILE_PROTOCOL *)EnvFileInterface);
|
||||
}
|
||||
|
||||
@ -1413,8 +1434,10 @@ MoveCursorBackward (
|
||||
if (*Row > 0) {
|
||||
(*Row)--;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
(*Column)--;
|
||||
}
|
||||
|
||||
@ -1478,7 +1501,8 @@ PrintCommandHistory (
|
||||
for ( Node = (BUFFER_LIST *)GetFirstNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link)
|
||||
; !IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
|
||||
; Node = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
Index++;
|
||||
LineCount = ((StrLen (Node->Buffer) + StartColumn + 1) / TotalCols) + 1;
|
||||
|
||||
@ -1491,16 +1515,12 @@ PrintCommandHistory (
|
||||
);
|
||||
LineNumber = 0;
|
||||
}
|
||||
|
||||
ShellPrintEx (-1, -1, L"%2d. %s\n", Index, Node->Buffer);
|
||||
LineNumber += LineCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// This is identical to EFI_FILE_PROTOCOL except for the additional members
|
||||
// for the buffer, size, and position.
|
||||
@ -1602,9 +1622,11 @@ FileInterfaceMemGetInfo(
|
||||
*BufferSize = sizeof (EFI_FILE_INFO);
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (Buffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FileInfo = (EFI_FILE_INFO *)Buffer;
|
||||
FileInfo->Size = sizeof (*FileInfo);
|
||||
ZeroMem (FileInfo, sizeof (*FileInfo));
|
||||
@ -1647,8 +1669,10 @@ FileInterfaceMemWrite(
|
||||
if (MemFile->Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
MemFile->BufferSize += (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD;
|
||||
}
|
||||
|
||||
CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
|
||||
MemFile->Position += (*BufferSize);
|
||||
MemFile->FileSize = MemFile->Position;
|
||||
@ -1661,6 +1685,7 @@ FileInterfaceMemWrite(
|
||||
if (AsciiBuffer == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
AsciiSPrint (AsciiBuffer, *BufferSize, "%S", Buffer);
|
||||
if ((UINTN)(MemFile->Position + AsciiStrSize (AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
|
||||
MemFile->Buffer = ReallocatePool ((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
|
||||
@ -1668,8 +1693,10 @@ FileInterfaceMemWrite(
|
||||
FreePool (AsciiBuffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
MemFile->BufferSize += AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
|
||||
}
|
||||
|
||||
CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize (AsciiBuffer));
|
||||
MemFile->Position += (*BufferSize / sizeof (CHAR16));
|
||||
MemFile->FileSize = MemFile->Position;
|
||||
@ -1701,6 +1728,7 @@ FileInterfaceMemRead(
|
||||
if (*BufferSize > (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position))) {
|
||||
(*BufferSize) = (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position));
|
||||
}
|
||||
|
||||
CopyMem (Buffer, ((UINT8 *)MemFile->Buffer) + MemFile->Position, (*BufferSize));
|
||||
MemFile->Position = MemFile->Position + (*BufferSize);
|
||||
return (EFI_SUCCESS);
|
||||
@ -1776,6 +1804,7 @@ CreateFileInterfaceMem(
|
||||
FreePool (FileInterface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*((CHAR16 *)(FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;
|
||||
FileInterface->BufferSize = 2;
|
||||
FileInterface->Position = 2;
|
||||
@ -1950,6 +1979,7 @@ FileInterfaceFileRead(
|
||||
CHAR8 *AsciiStrBuffer;
|
||||
CHAR16 *UscStrBuffer;
|
||||
UINTN Size;
|
||||
|
||||
if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
|
||||
//
|
||||
// Unicode
|
||||
@ -1965,10 +1995,12 @@ FileInterfaceFileRead(
|
||||
if (*BufferSize == 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Position);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Position == 0) {
|
||||
//
|
||||
// First two bytes in Buffer is for the Unicode file tag.
|
||||
@ -1979,21 +2011,25 @@ FileInterfaceFileRead(
|
||||
} else {
|
||||
Size = *BufferSize / sizeof (CHAR16);
|
||||
}
|
||||
|
||||
AsciiStrBuffer = AllocateZeroPool (Size + 1);
|
||||
if (AsciiStrBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
UscStrBuffer = AllocateZeroPool ((Size + 1) * sizeof (CHAR16));
|
||||
if (UscStrBuffer == NULL) {
|
||||
SHELL_FREE_NON_NULL (AsciiStrBuffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Size, AsciiStrBuffer);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
AsciiStrToUnicodeStrS (AsciiStrBuffer, UscStrBuffer, Size + 1);
|
||||
*BufferSize = Size * sizeof (CHAR16);
|
||||
CopyMem (Buffer, UscStrBuffer, *BufferSize);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (AsciiStrBuffer);
|
||||
SHELL_FREE_NON_NULL (UscStrBuffer);
|
||||
return Status;
|
||||
@ -2048,6 +2084,7 @@ FileInterfaceFileDelete(
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Delete (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
|
||||
FreePool (This);
|
||||
return (Status);
|
||||
@ -2067,6 +2104,7 @@ FileInterfaceFileClose(
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Close (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
|
||||
FreePool (This);
|
||||
return (Status);
|
||||
@ -2095,6 +2133,7 @@ FileInterfaceFileWrite(
|
||||
CHAR8 *AsciiBuffer;
|
||||
UINTN Size;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
|
||||
//
|
||||
// Unicode
|
||||
@ -2136,6 +2175,7 @@ CreateFileInterfaceFile(
|
||||
if (NewOne == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
CopyMem (NewOne, Template, sizeof (EFI_FILE_PROTOCOL_FILE));
|
||||
NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;
|
||||
NewOne->Unicode = Unicode;
|
||||
|
@ -84,4 +84,3 @@ CreateFileInterfaceFile(
|
||||
);
|
||||
|
||||
#endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -303,7 +303,6 @@ RunShellCommand(
|
||||
OUT EFI_STATUS *CommandStatus
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Function to process a NSH script file via SHELL_FILE_HANDLE.
|
||||
|
||||
@ -384,7 +383,4 @@ RestoreBufferList (
|
||||
IN OUT LIST_ENTRY *OldBufferList
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif //_SHELL_INTERNAL_HEADER_
|
||||
|
||||
|
@ -44,23 +44,29 @@ IsVolatileEnv (
|
||||
//
|
||||
// get the variable
|
||||
//
|
||||
Status = gRT->GetVariable((CHAR16*)EnvVarName,
|
||||
Status = gRT->GetVariable (
|
||||
(CHAR16 *)EnvVarName,
|
||||
&gShellVariableGuid,
|
||||
&Attribs,
|
||||
&Size,
|
||||
Buffer);
|
||||
Buffer
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
Buffer = AllocateZeroPool (Size);
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
Status = gRT->GetVariable((CHAR16*)EnvVarName,
|
||||
|
||||
Status = gRT->GetVariable (
|
||||
(CHAR16 *)EnvVarName,
|
||||
&gShellVariableGuid,
|
||||
&Attribs,
|
||||
&Size,
|
||||
Buffer);
|
||||
Buffer
|
||||
);
|
||||
FreePool (Buffer);
|
||||
}
|
||||
|
||||
//
|
||||
// not found means volatile
|
||||
//
|
||||
@ -68,6 +74,7 @@ IsVolatileEnv (
|
||||
*Volatile = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -99,15 +106,18 @@ FreeEnvironmentVariableList(
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (List)
|
||||
; !IsListEmpty (List)
|
||||
; Node = (ENV_VAR_LIST *)GetFirstNode (List)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node != NULL);
|
||||
RemoveEntryList (&Node->Link);
|
||||
if (Node->Key != NULL) {
|
||||
FreePool (Node->Key);
|
||||
}
|
||||
|
||||
if (Node->Val != NULL) {
|
||||
FreePool (Node->Val);
|
||||
}
|
||||
|
||||
FreePool (Node);
|
||||
}
|
||||
}
|
||||
@ -146,6 +156,7 @@ GetEnvironmentVariableList(
|
||||
if (VariableName == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
*VariableName = CHAR_NULL;
|
||||
|
||||
while (!EFI_ERROR (Status)) {
|
||||
@ -162,6 +173,7 @@ GetEnvironmentVariableList(
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
NameSize = NameBufferSize;
|
||||
Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
|
||||
}
|
||||
@ -181,6 +193,7 @@ GetEnvironmentVariableList(
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
ValBufferSize = ValSize > ValBufferSize * 2 ? ValSize : ValBufferSize * 2;
|
||||
@ -198,6 +211,7 @@ GetEnvironmentVariableList(
|
||||
ValSize = ValBufferSize;
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
VarList->Key = AllocateCopyPool (StrSize (VariableName), VariableName);
|
||||
if (VarList->Key == NULL) {
|
||||
@ -214,6 +228,7 @@ GetEnvironmentVariableList(
|
||||
} // if (VarList == NULL) ... else ...
|
||||
} // compare guid
|
||||
} // while
|
||||
|
||||
SHELL_FREE_NON_NULL (VariableName);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -256,10 +271,12 @@ SetEnvironmentVariableList(
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&VarList.Link)
|
||||
; !IsNull (&VarList.Link, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (&VarList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
if (Node->Key != NULL) {
|
||||
Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Node->Key);
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
@ -271,15 +288,18 @@ SetEnvironmentVariableList(
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
|
||||
; !IsNull (ListHead, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
Size = StrSize (Node->Val) - sizeof (CHAR16);
|
||||
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
|
||||
} else {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
FreeEnvironmentVariableList (ListHead);
|
||||
|
||||
return (Status);
|
||||
@ -320,11 +340,13 @@ SetEnvironmentVariables(
|
||||
for ( CurrentCount = 0
|
||||
;
|
||||
; CurrentCount++
|
||||
){
|
||||
)
|
||||
{
|
||||
CurrentString = Environment[CurrentCount];
|
||||
if (CurrentString == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT (StrStr (CurrentString, L"=") != NULL);
|
||||
Node = AllocateZeroPool (sizeof (ENV_VAR_LIST));
|
||||
if (Node == NULL) {
|
||||
@ -342,7 +364,8 @@ SetEnvironmentVariables(
|
||||
//
|
||||
// Copy the string into the Key, leaving the last character allocated as NULL to terminate
|
||||
//
|
||||
StrnCpyS( Node->Key,
|
||||
StrnCpyS (
|
||||
Node->Key,
|
||||
StrStr (CurrentString, L"=") - CurrentString + 1,
|
||||
CurrentString,
|
||||
StrStr (CurrentString, L"=") - CurrentString
|
||||
@ -369,10 +392,11 @@ SetEnvironmentVariables(
|
||||
SHELL_FREE_NON_NULL (Node);
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
InitializeListHead (&VarList->Link);
|
||||
}
|
||||
InsertTailList(&VarList->Link, &Node->Link);
|
||||
|
||||
InsertTailList (&VarList->Link, &Node->Link);
|
||||
} // for loop
|
||||
|
||||
//
|
||||
@ -408,20 +432,22 @@ ShellFindEnvVarInList (
|
||||
{
|
||||
ENV_VAR_LIST *Node;
|
||||
|
||||
if (Key == NULL || Value == NULL || ValueSize == NULL) {
|
||||
if ((Key == NULL) || (Value == NULL) || (ValueSize == NULL)) {
|
||||
return SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
|
||||
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
|
||||
){
|
||||
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
|
||||
)
|
||||
{
|
||||
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
|
||||
*Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
|
||||
*ValueSize = StrSize (Node->Val);
|
||||
if (Atts != NULL) {
|
||||
*Atts = Node->Atts;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -454,7 +480,7 @@ ShellAddEnvVarToList (
|
||||
CHAR16 *LocalKey;
|
||||
CHAR16 *LocalValue;
|
||||
|
||||
if (Key == NULL || Value == NULL || ValueSize == 0) {
|
||||
if ((Key == NULL) || (Value == NULL) || (ValueSize == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -469,8 +495,9 @@ ShellAddEnvVarToList (
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
|
||||
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
|
||||
){
|
||||
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
|
||||
)
|
||||
{
|
||||
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
|
||||
Node->Atts = Atts;
|
||||
SHELL_FREE_NON_NULL (Node->Val);
|
||||
Node->Val = LocalValue;
|
||||
@ -487,12 +514,14 @@ ShellAddEnvVarToList (
|
||||
FreePool (LocalValue);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node = (ENV_VAR_LIST *)AllocateZeroPool (sizeof (ENV_VAR_LIST));
|
||||
if (Node == NULL) {
|
||||
FreePool (LocalKey);
|
||||
FreePool (LocalValue);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->Key = LocalKey;
|
||||
Node->Val = LocalValue;
|
||||
Node->Atts = Atts;
|
||||
@ -524,8 +553,9 @@ ShellRemvoeEnvVarFromList (
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
|
||||
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
|
||||
){
|
||||
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
|
||||
)
|
||||
{
|
||||
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
|
||||
SHELL_FREE_NON_NULL (Node->Key);
|
||||
SHELL_FREE_NON_NULL (Node->Val);
|
||||
RemoveEntryList (&Node->Link);
|
||||
@ -569,4 +599,3 @@ ShellFreeEnvVarList (
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ typedef struct {
|
||||
//
|
||||
extern ENV_VAR_LIST gShellEnvVarList;
|
||||
|
||||
|
||||
/**
|
||||
Reports whether an environment variable is Volatile or Non-Volatile.
|
||||
|
||||
@ -279,4 +278,3 @@ ShellFreeEnvVarList (
|
||||
);
|
||||
|
||||
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
EFI_HII_HANDLE mShellManHiiHandle = NULL;
|
||||
EFI_HANDLE mShellManDriverHandle = NULL;
|
||||
|
||||
|
||||
SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
|
||||
{
|
||||
{
|
||||
@ -57,6 +56,7 @@ GetExecuatableFileName (
|
||||
{
|
||||
CHAR16 *Buffer;
|
||||
CHAR16 *SuffixStr;
|
||||
|
||||
if (NameString == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
@ -75,20 +75,22 @@ GetExecuatableFileName (
|
||||
} else {
|
||||
Buffer = AllocateZeroPool (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16));
|
||||
if (Buffer != NULL) {
|
||||
StrnCpyS( Buffer,
|
||||
StrnCpyS (
|
||||
Buffer,
|
||||
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
|
||||
NameString,
|
||||
StrLen (NameString)
|
||||
);
|
||||
StrnCatS( Buffer,
|
||||
StrnCatS (
|
||||
Buffer,
|
||||
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
|
||||
L".efi",
|
||||
StrLen (L".efi")
|
||||
);
|
||||
}
|
||||
}
|
||||
return (Buffer);
|
||||
|
||||
return (Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,9 +110,11 @@ GetManFileName(
|
||||
)
|
||||
{
|
||||
CHAR16 *Buffer;
|
||||
|
||||
if (ManFileName == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
//
|
||||
// Fix the file name
|
||||
//
|
||||
@ -119,18 +123,21 @@ GetManFileName(
|
||||
} else {
|
||||
Buffer = AllocateZeroPool (StrSize (ManFileName) + 4*sizeof (CHAR16));
|
||||
if (Buffer != NULL) {
|
||||
StrnCpyS( Buffer,
|
||||
StrnCpyS (
|
||||
Buffer,
|
||||
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
|
||||
ManFileName,
|
||||
StrLen (ManFileName)
|
||||
);
|
||||
StrnCatS( Buffer,
|
||||
StrnCatS (
|
||||
Buffer,
|
||||
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
|
||||
L".man",
|
||||
4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (Buffer);
|
||||
}
|
||||
|
||||
@ -157,10 +164,11 @@ SearchPathForFile(
|
||||
CHAR16 *FullFileName;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ( FileName == NULL
|
||||
|| Handle == NULL
|
||||
|| StrLen(FileName) == 0
|
||||
){
|
||||
if ( (FileName == NULL)
|
||||
|| (Handle == NULL)
|
||||
|| (StrLen (FileName) == 0)
|
||||
)
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -213,10 +221,11 @@ ManFileFindSections(
|
||||
UINTN SectionLen;
|
||||
BOOLEAN Found;
|
||||
|
||||
if ( Handle == NULL
|
||||
|| HelpText == NULL
|
||||
|| HelpSize == NULL
|
||||
){
|
||||
if ( (Handle == NULL)
|
||||
|| (HelpText == NULL)
|
||||
|| (HelpSize == NULL)
|
||||
)
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -238,12 +247,14 @@ ManFileFindSections(
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// ignore too small of buffer...
|
||||
//
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
} else if (StrnCmp (ReadLine, L".TH", 3) == 0) {
|
||||
@ -256,24 +267,30 @@ ManFileFindSections(
|
||||
CurrentlyReading = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// we found a section
|
||||
//
|
||||
if (CurrentlyReading) {
|
||||
CurrentlyReading = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// is this a section we want to read in?
|
||||
//
|
||||
for ( SectionName = ReadLine + 3
|
||||
; *SectionName == L' '
|
||||
; SectionName++);
|
||||
; SectionName++)
|
||||
{
|
||||
}
|
||||
|
||||
SectionLen = StrLen (SectionName);
|
||||
SectionName = StrStr (Sections, SectionName);
|
||||
if (SectionName == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {
|
||||
|
||||
if ((*(SectionName + SectionLen) == CHAR_NULL) || (*(SectionName + SectionLen) == L',')) {
|
||||
CurrentlyReading = TRUE;
|
||||
}
|
||||
} else if (CurrentlyReading) {
|
||||
@ -286,10 +303,12 @@ ManFileFindSections(
|
||||
StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (ReadLine);
|
||||
if (!Found && !EFI_ERROR (Status)) {
|
||||
return (EFI_NOT_FOUND);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
@ -340,28 +359,25 @@ IsTitleHeader(
|
||||
State = LookForThMacro;
|
||||
|
||||
do {
|
||||
|
||||
if (*Line == L'\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (State) {
|
||||
|
||||
// Handle "^\s*.TH\s"
|
||||
// Go to state LookForCommandName if the title header macro is present; otherwise,
|
||||
// eat white space. If we see something other than white space, this is not a
|
||||
// title header line.
|
||||
case LookForThMacro:
|
||||
if (StrnCmp (L".TH ", Line, 4) == 0 || StrnCmp (L".TH\t", Line, 4) == 0) {
|
||||
if ((StrnCmp (L".TH ", Line, 4) == 0) || (StrnCmp (L".TH\t", Line, 4) == 0)) {
|
||||
Line += 4;
|
||||
State = LookForCommandName;
|
||||
}
|
||||
else if (*Line == L' ' || *Line == L'\t') {
|
||||
} else if ((*Line == L' ') || (*Line == L'\t')) {
|
||||
Line++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
State = Final;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Handle "\s*"
|
||||
@ -369,15 +385,15 @@ IsTitleHeader(
|
||||
// at least one white space character). Go to state CompareCommands when a
|
||||
// non-white space is seen.
|
||||
case LookForCommandName:
|
||||
if (*Line == L' ' || *Line == L'\t') {
|
||||
if ((*Line == L' ') || (*Line == L'\t')) {
|
||||
Line++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ReturnValue = TRUE; // This is *some* command's title header line.
|
||||
State = CompareCommands;
|
||||
// Do not increment Line; it points to the first character of the command
|
||||
// name on the title header line.
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Handle "(\S)\s"
|
||||
@ -385,13 +401,13 @@ IsTitleHeader(
|
||||
// reach the end of the command (i.e. we see white space), the next state
|
||||
// depends on whether the caller wants a copy of the Brief Description.
|
||||
case CompareCommands:
|
||||
if (*Line == L' ' || *Line == L'\t') {
|
||||
if ((*Line == L' ') || (*Line == L'\t')) {
|
||||
ReturnFound = TRUE; // This is the desired command's title header line.
|
||||
State = (BriefDesc == NULL) ? Final : GetBriefDescription;
|
||||
}
|
||||
else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
|
||||
} else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
|
||||
State = Final;
|
||||
}
|
||||
|
||||
Line++;
|
||||
break;
|
||||
|
||||
@ -399,21 +415,22 @@ IsTitleHeader(
|
||||
// Skip whitespace, '0', and '1' characters, if any, prior to the brief description.
|
||||
// Return the description to the caller.
|
||||
case GetBriefDescription:
|
||||
if (*Line != L' ' && *Line != L'\t' && *Line != L'0' && *Line != L'1') {
|
||||
if ((*Line != L' ') && (*Line != L'\t') && (*Line != L'0') && (*Line != L'1')) {
|
||||
*BriefSize = StrSize (Line);
|
||||
*BriefDesc = AllocateZeroPool (*BriefSize);
|
||||
if (*BriefDesc != NULL) {
|
||||
StrCpyS (*BriefDesc, (*BriefSize)/sizeof (CHAR16), Line);
|
||||
}
|
||||
|
||||
State = Final;
|
||||
}
|
||||
|
||||
Line++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} while (State < Final);
|
||||
|
||||
*Found = ReturnFound;
|
||||
@ -455,10 +472,11 @@ ManFileFindTitleSection(
|
||||
BOOLEAN Found;
|
||||
UINTN Start;
|
||||
|
||||
if ( Handle == NULL
|
||||
|| Command == NULL
|
||||
|| (BriefDesc != NULL && BriefSize == NULL)
|
||||
){
|
||||
if ( (Handle == NULL)
|
||||
|| (Command == NULL)
|
||||
|| ((BriefDesc != NULL) && (BriefSize == NULL))
|
||||
)
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -478,7 +496,8 @@ ManFileFindTitleSection(
|
||||
while ( (Start != 0)
|
||||
&& (*(Command + Start - 1) != L'\\')
|
||||
&& (*(Command + Start - 1) != L'/')
|
||||
&& (*(Command + Start - 1) != L':')) {
|
||||
&& (*(Command + Start - 1) != L':'))
|
||||
{
|
||||
--Start;
|
||||
}
|
||||
|
||||
@ -487,7 +506,7 @@ ManFileFindTitleSection(
|
||||
//
|
||||
// ignore too small of buffer...
|
||||
//
|
||||
if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -555,10 +574,11 @@ ProcessManFile(
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
||||
|
||||
if ( ManFileName == NULL
|
||||
|| Command == NULL
|
||||
|| HelpText == NULL
|
||||
){
|
||||
if ( (ManFileName == NULL)
|
||||
|| (Command == NULL)
|
||||
|| (HelpText == NULL)
|
||||
)
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -586,9 +606,10 @@ ProcessManFile(
|
||||
HelpSize = 0;
|
||||
BriefSize = 0;
|
||||
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
|
||||
if (!EFI_ERROR(Status) && HelpText != NULL){
|
||||
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
|
||||
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
|
||||
}
|
||||
|
||||
ShellCloseFile (&FileHandle);
|
||||
} else {
|
||||
//
|
||||
@ -613,9 +634,10 @@ ProcessManFile(
|
||||
HelpSize = 0;
|
||||
BriefSize = 0;
|
||||
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
|
||||
if (!EFI_ERROR(Status) && HelpText != NULL){
|
||||
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
|
||||
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
|
||||
}
|
||||
|
||||
ShellInfoObject.NewEfiShellProtocol->CloseFile (FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
@ -633,6 +655,7 @@ ProcessManFile(
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// If the file in CWD then use the file name, else use the full
|
||||
// path name.
|
||||
@ -642,6 +665,7 @@ ProcessManFile(
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
|
||||
Status = gBS->LoadImage (FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -654,9 +678,11 @@ ProcessManFile(
|
||||
if (Status == EFI_SECURITY_VIOLATION) {
|
||||
gBS->UnloadImage (CmdFileImgHandle);
|
||||
}
|
||||
|
||||
*HelpText = NULL;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
CmdFileImgHandle,
|
||||
&gEfiHiiPackageListProtocolGuid,
|
||||
@ -699,11 +725,13 @@ ProcessManFile(
|
||||
if (BriefDesc != NULL) {
|
||||
SHELL_FREE_NON_NULL (*BriefDesc);
|
||||
}
|
||||
|
||||
TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
|
||||
if (TempString == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
|
||||
HelpSize = StrLen (TempString) * sizeof (CHAR16);
|
||||
ShellWriteFile (FileHandle, &HelpSize, TempString);
|
||||
@ -711,9 +739,10 @@ ProcessManFile(
|
||||
HelpSize = 0;
|
||||
BriefSize = 0;
|
||||
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
|
||||
if (!EFI_ERROR(Status) && HelpText != NULL){
|
||||
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
|
||||
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
|
||||
}
|
||||
|
||||
ShellCloseFile (&FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
@ -724,7 +753,6 @@ ProcessManFile(
|
||||
|
||||
StringIdWalker += 1;
|
||||
} while (StringIdWalker < 0xFFFF && TempString != NULL);
|
||||
|
||||
}
|
||||
|
||||
Done:
|
||||
@ -754,4 +782,3 @@ Done:
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
@ -75,4 +75,3 @@ ManFileFindSections(
|
||||
);
|
||||
|
||||
#endif //_SHELL_MAN_FILE_PARSER_HEADER_
|
||||
|
||||
|
@ -88,15 +88,15 @@ GetNextParameter(
|
||||
{
|
||||
CONST CHAR16 *NextDelim;
|
||||
|
||||
if (Walker == NULL
|
||||
||*Walker == NULL
|
||||
||TempParameter == NULL
|
||||
||*TempParameter == NULL
|
||||
){
|
||||
if ( (Walker == NULL)
|
||||
|| (*Walker == NULL)
|
||||
|| (TempParameter == NULL)
|
||||
|| (*TempParameter == NULL)
|
||||
)
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// make sure we dont have any leading spaces
|
||||
//
|
||||
@ -144,16 +144,15 @@ DEBUG_CODE_END();
|
||||
for (NextDelim = FindFirstCharacter (*TempParameter, L"\"^", CHAR_NULL)
|
||||
; *NextDelim != CHAR_NULL
|
||||
; NextDelim = FindFirstCharacter (NextDelim, L"\"^", CHAR_NULL)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (*NextDelim == L'^') {
|
||||
|
||||
//
|
||||
// eliminate the escape ^
|
||||
//
|
||||
CopyMem ((CHAR16 *)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
|
||||
NextDelim++;
|
||||
} else if (*NextDelim == L'\"') {
|
||||
|
||||
//
|
||||
// eliminate the unescaped quote
|
||||
//
|
||||
@ -207,7 +206,7 @@ ParseCommandLineToArgs(
|
||||
ASSERT (Argc != NULL);
|
||||
ASSERT (Argv != NULL);
|
||||
|
||||
if (CommandLine == NULL || StrLen(CommandLine)==0) {
|
||||
if ((CommandLine == NULL) || (StrLen (CommandLine) == 0)) {
|
||||
(*Argc) = 0;
|
||||
(*Argv) = NULL;
|
||||
return (EFI_SUCCESS);
|
||||
@ -226,11 +225,12 @@ ParseCommandLineToArgs(
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
for ( Count = 0
|
||||
, Walker = (CHAR16*)NewCommandLine
|
||||
for ( Count = 0,
|
||||
Walker = (CHAR16 *)NewCommandLine
|
||||
; Walker != NULL && *Walker != CHAR_NULL
|
||||
; Count++
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (EFI_ERROR (GetNextParameter (&Walker, &TempParameter, Size, TRUE))) {
|
||||
break;
|
||||
}
|
||||
@ -259,9 +259,11 @@ ParseCommandLineToArgs(
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
((CHAR16 **)(*Argv))[(*Argc)] = NewParam;
|
||||
(*Argc)++;
|
||||
}
|
||||
|
||||
ASSERT (Count >= (*Argc));
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@ -354,6 +356,7 @@ CreatePopulateInstallShellParametersProtocol (
|
||||
FullCommandLine = AllocateZeroPool (Size + LoadedImage->LoadOptionsSize);
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
|
||||
}
|
||||
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
//
|
||||
// no parameters via environment... ok
|
||||
@ -363,7 +366,8 @@ CreatePopulateInstallShellParametersProtocol (
|
||||
return (Status);
|
||||
}
|
||||
}
|
||||
if (Size == 0 && LoadedImage->LoadOptionsSize != 0) {
|
||||
|
||||
if ((Size == 0) && (LoadedImage->LoadOptionsSize != 0)) {
|
||||
ASSERT (FullCommandLine == NULL);
|
||||
//
|
||||
// Now we need to include a NULL terminator in the size.
|
||||
@ -371,15 +375,18 @@ CreatePopulateInstallShellParametersProtocol (
|
||||
Size = LoadedImage->LoadOptionsSize + sizeof (FullCommandLine[0]);
|
||||
FullCommandLine = AllocateZeroPool (Size);
|
||||
}
|
||||
|
||||
if (FullCommandLine != NULL) {
|
||||
CopyMem (FullCommandLine, LoadedImage->LoadOptions, LoadedImage->LoadOptionsSize);
|
||||
//
|
||||
// Populate Argc and Argv
|
||||
//
|
||||
Status = ParseCommandLineToArgs(FullCommandLine,
|
||||
Status = ParseCommandLineToArgs (
|
||||
FullCommandLine,
|
||||
TRUE,
|
||||
&(*NewShellParameters)->Argv,
|
||||
&(*NewShellParameters)->Argc);
|
||||
&(*NewShellParameters)->Argc
|
||||
);
|
||||
|
||||
FreePool (FullCommandLine);
|
||||
|
||||
@ -396,10 +403,12 @@ CreatePopulateInstallShellParametersProtocol (
|
||||
(*NewShellParameters)->StdIn = &FileInterfaceStdIn;
|
||||
(*NewShellParameters)->StdOut = &FileInterfaceStdOut;
|
||||
(*NewShellParameters)->StdErr = &FileInterfaceStdErr;
|
||||
Status = gBS->InstallProtocolInterface(&gImageHandle,
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
(VOID*)(*NewShellParameters));
|
||||
(VOID *)(*NewShellParameters)
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// copy from the existing ones
|
||||
@ -407,10 +416,12 @@ CreatePopulateInstallShellParametersProtocol (
|
||||
(*NewShellParameters)->StdIn = ShellInfoObject.OldShellParameters->StdIn;
|
||||
(*NewShellParameters)->StdOut = ShellInfoObject.OldShellParameters->StdOut;
|
||||
(*NewShellParameters)->StdErr = ShellInfoObject.OldShellParameters->StdErr;
|
||||
Status = gBS->ReinstallProtocolInterface(gImageHandle,
|
||||
Status = gBS->ReinstallProtocolInterface (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID *)ShellInfoObject.OldShellParameters,
|
||||
(VOID*)(*NewShellParameters));
|
||||
(VOID *)(*NewShellParameters)
|
||||
);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
@ -440,28 +451,38 @@ CleanUpShellParametersProtocol (
|
||||
// If the old exists we need to restore it
|
||||
//
|
||||
if (ShellInfoObject.OldShellParameters != NULL) {
|
||||
Status = gBS->ReinstallProtocolInterface(gImageHandle,
|
||||
Status = gBS->ReinstallProtocolInterface (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID *)NewShellParameters,
|
||||
(VOID*)ShellInfoObject.OldShellParameters);
|
||||
DEBUG_CODE(ShellInfoObject.OldShellParameters = NULL;);
|
||||
(VOID *)ShellInfoObject.OldShellParameters
|
||||
);
|
||||
DEBUG_CODE (
|
||||
ShellInfoObject.OldShellParameters = NULL;
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// No old one, just uninstall us...
|
||||
//
|
||||
Status = gBS->UninstallProtocolInterface(gImageHandle,
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID*)NewShellParameters);
|
||||
(VOID *)NewShellParameters
|
||||
);
|
||||
}
|
||||
|
||||
if (NewShellParameters->Argv != NULL) {
|
||||
for ( LoopCounter = 0
|
||||
; LoopCounter < NewShellParameters->Argc
|
||||
; LoopCounter++
|
||||
){
|
||||
)
|
||||
{
|
||||
FreePool (NewShellParameters->Argv[LoopCounter]);
|
||||
}
|
||||
|
||||
FreePool (NewShellParameters->Argv);
|
||||
}
|
||||
|
||||
FreePool (NewShellParameters);
|
||||
return (Status);
|
||||
}
|
||||
@ -489,13 +510,15 @@ IsUnicodeFile(
|
||||
if (EFI_ERROR (Status)) {
|
||||
return (Status);
|
||||
}
|
||||
|
||||
gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
|
||||
gEfiShellProtocol->SetFilePosition (Handle, 0);
|
||||
CharSize = sizeof (CHAR16);
|
||||
Status = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
|
||||
if (EFI_ERROR(Status) || CharBuffer != gUnicodeFileTag) {
|
||||
if (EFI_ERROR (Status) || (CharBuffer != gUnicodeFileTag)) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
gEfiShellProtocol->SetFilePosition (Handle, OriginalFilePosition);
|
||||
gEfiShellProtocol->CloseFile (Handle);
|
||||
return (Status);
|
||||
@ -516,7 +539,7 @@ StripQuotes (
|
||||
BOOLEAN RemoveNow;
|
||||
|
||||
for (RemoveNow = FALSE; TheString != NULL && *TheString != CHAR_NULL; TheString++) {
|
||||
if (*TheString == L'^' && *(TheString + 1) == L'\"') {
|
||||
if ((*TheString == L'^') && (*(TheString + 1) == L'\"')) {
|
||||
TheString++;
|
||||
} else if (*TheString == L'\"') {
|
||||
RemoveNow = (BOOLEAN) !RemoveNow;
|
||||
@ -581,6 +604,7 @@ FixFileName (
|
||||
while (Copy[0] == L' ') {
|
||||
Copy++;
|
||||
}
|
||||
|
||||
if ((TempLocation = StrStr (Copy, L" ")) != NULL) {
|
||||
TempLocation[0] = CHAR_NULL;
|
||||
}
|
||||
@ -621,7 +645,6 @@ FixVarName (
|
||||
return (FixFileName (Copy));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write the unicode file tag to the specified file.
|
||||
|
||||
@ -644,13 +667,15 @@ WriteFileTag (
|
||||
|
||||
FileTag = gUnicodeFileTag;
|
||||
Size = sizeof FileTag;
|
||||
Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,
|
||||
&FileTag);
|
||||
Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (
|
||||
FileHandle,
|
||||
&Size,
|
||||
&FileTag
|
||||
);
|
||||
ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Function will replace the current StdIn and StdOut in the ShellParameters protocol
|
||||
structure by parsing NewCommandLine. The current values are returned to the
|
||||
@ -714,7 +739,7 @@ UpdateStdInStdOutStdErr(
|
||||
CommandLineCopy = NULL;
|
||||
FirstLocation = NULL;
|
||||
|
||||
if (ShellParameters == NULL || SystemTableInfo == NULL || OldStdIn == NULL || OldStdOut == NULL || OldStdErr == NULL) {
|
||||
if ((ShellParameters == NULL) || (SystemTableInfo == NULL) || (OldStdIn == NULL) || (OldStdOut == NULL) || (OldStdErr == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -736,6 +761,7 @@ UpdateStdInStdOutStdErr(
|
||||
if (CommandLineCopy == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Split = NULL;
|
||||
FirstLocation = CommandLineCopy + StrLen (CommandLineCopy);
|
||||
@ -744,15 +770,16 @@ UpdateStdInStdOutStdErr(
|
||||
|
||||
if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
|
||||
Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
|
||||
if (Split != NULL && Split->SplitStdIn != NULL) {
|
||||
if ((Split != NULL) && (Split->SplitStdIn != NULL)) {
|
||||
ShellParameters->StdIn = Split->SplitStdIn;
|
||||
}
|
||||
if (Split != NULL && Split->SplitStdOut != NULL) {
|
||||
|
||||
if ((Split != NULL) && (Split->SplitStdOut != NULL)) {
|
||||
ShellParameters->StdOut = Split->SplitStdOut;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>>v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 12, L' ');
|
||||
StdErrVarName = CommandLineWalker += 6;
|
||||
@ -761,7 +788,8 @@ UpdateStdInStdOutStdErr(
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 12, L' ');
|
||||
StdOutVarName = CommandLineWalker += 6;
|
||||
@ -769,7 +797,7 @@ UpdateStdInStdOutStdErr(
|
||||
if (StrStr (CommandLineWalker, L" 1>>v ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
|
||||
} else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
StdOutVarName = CommandLineWalker += 5;
|
||||
@ -777,7 +805,7 @@ UpdateStdInStdOutStdErr(
|
||||
if (StrStr (CommandLineWalker, L" >>v ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
|
||||
} else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
StdOutVarName = CommandLineWalker += 4;
|
||||
@ -786,7 +814,8 @@ UpdateStdInStdOutStdErr(
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 12, L' ');
|
||||
StdOutFileName = CommandLineWalker += 6;
|
||||
@ -796,7 +825,8 @@ UpdateStdInStdOutStdErr(
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>> ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -805,11 +835,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdOutFileName = CommandLineWalker += 5;
|
||||
OutAppend = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 1>> ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >> ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -818,11 +850,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdOutFileName = CommandLineWalker += 4;
|
||||
OutAppend = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" >> ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -832,11 +866,13 @@ UpdateStdInStdOutStdErr(
|
||||
OutAppend = TRUE;
|
||||
OutUnicode = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" >>a ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -846,11 +882,13 @@ UpdateStdInStdOutStdErr(
|
||||
OutAppend = FALSE;
|
||||
OutUnicode = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 1>a ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -860,11 +898,13 @@ UpdateStdInStdOutStdErr(
|
||||
OutAppend = FALSE;
|
||||
OutUnicode = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" >a ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>> ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdErrFileName != NULL) {
|
||||
@ -873,12 +913,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdErrFileName = CommandLineWalker += 5;
|
||||
ErrAppend = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 2>> ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdErrVarName != NULL) {
|
||||
@ -887,11 +928,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdErrVarName = CommandLineWalker += 5;
|
||||
ErrAppend = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 2>v ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdOutVarName != NULL) {
|
||||
@ -900,11 +943,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdOutVarName = CommandLineWalker += 5;
|
||||
OutAppend = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 1>v ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 10, L' ');
|
||||
if (StdErrFileName != NULL) {
|
||||
@ -914,11 +959,13 @@ UpdateStdInStdOutStdErr(
|
||||
ErrAppend = FALSE;
|
||||
ErrUnicode = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 2>a ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2> ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdErrFileName != NULL) {
|
||||
@ -927,12 +974,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdErrFileName = CommandLineWalker += 4;
|
||||
ErrAppend = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 2> ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1> ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -941,12 +989,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdOutFileName = CommandLineWalker += 4;
|
||||
OutAppend = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" 1> ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" > ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 6, L' ');
|
||||
if (StdOutFileName != NULL) {
|
||||
@ -955,12 +1004,13 @@ UpdateStdInStdOutStdErr(
|
||||
StdOutFileName = CommandLineWalker += 3;
|
||||
OutAppend = FALSE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" > ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" < ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 6, L' ');
|
||||
if (StdInFileName != NULL) {
|
||||
@ -968,11 +1018,13 @@ UpdateStdInStdOutStdErr(
|
||||
} else {
|
||||
StdInFileName = CommandLineWalker += 3;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" < ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <a ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdInFileName != NULL) {
|
||||
@ -982,11 +1034,13 @@ UpdateStdInStdOutStdErr(
|
||||
InUnicode = FALSE;
|
||||
AsciiRedirection = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" <a ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <v ")) != NULL)) {
|
||||
FirstLocation = MIN (CommandLineWalker, FirstLocation);
|
||||
SetMem16 (CommandLineWalker, 8, L' ');
|
||||
if (StdInVarName != NULL) {
|
||||
@ -994,6 +1048,7 @@ UpdateStdInStdOutStdErr(
|
||||
} else {
|
||||
StdInVarName = CommandLineWalker += 4;
|
||||
}
|
||||
|
||||
if (StrStr (CommandLineWalker, L" <v ") != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
@ -1004,39 +1059,44 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
StrnCpyS (CommandLineCopy, StrSize (CommandLineCopy)/sizeof (CHAR16), NewCommandLine, StrLen (NewCommandLine));
|
||||
|
||||
if (FirstLocation != CommandLineCopy + StrLen(CommandLineCopy)
|
||||
if ( (FirstLocation != CommandLineCopy + StrLen (CommandLineCopy))
|
||||
&& (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16) < StrLen (NewCommandLine))
|
||||
){
|
||||
)
|
||||
{
|
||||
*(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16)) = CHAR_NULL;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
if (StdErrFileName != NULL) {
|
||||
if ((StdErrFileName = FixFileName (StdErrFileName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (StdOutFileName != NULL) {
|
||||
if ((StdOutFileName = FixFileName (StdOutFileName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (StdInFileName != NULL) {
|
||||
if ((StdInFileName = FixFileName (StdInFileName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (StdErrVarName != NULL) {
|
||||
if ((StdErrVarName = FixVarName (StdErrVarName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (StdOutVarName != NULL) {
|
||||
if ((StdOutVarName = FixVarName (StdOutVarName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (StdInVarName != NULL) {
|
||||
if ((StdInVarName = FixVarName (StdInVarName)) == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
@ -1050,44 +1110,45 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// Check that no 2 filenames are the same
|
||||
//
|
||||
(StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
|
||||
||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
|
||||
||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
|
||||
((StdErrFileName != NULL) && (StdOutFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdOutFileName) == 0))
|
||||
|| ((StdErrFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdInFileName) == 0))
|
||||
|| ((StdOutFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdOutFileName, &StdInFileName) == 0))
|
||||
//
|
||||
// Check that no 2 variable names are the same
|
||||
//
|
||||
||(StdErrVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdInVarName ) == 0)
|
||||
||(StdOutVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdOutVarName , &StdInVarName ) == 0)
|
||||
||(StdErrVarName != NULL && StdOutVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdOutVarName ) == 0)
|
||||
|| ((StdErrVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdInVarName) == 0))
|
||||
|| ((StdOutVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdOutVarName, &StdInVarName) == 0))
|
||||
|| ((StdErrVarName != NULL) && (StdOutVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdOutVarName) == 0))
|
||||
//
|
||||
// When a split (using | operator) is in place some are not allowed
|
||||
//
|
||||
||(Split != NULL && Split->SplitStdIn != NULL && (StdInVarName != NULL || StdInFileName != NULL))
|
||||
||(Split != NULL && Split->SplitStdOut != NULL && (StdOutVarName != NULL || StdOutFileName != NULL))
|
||||
|| ((Split != NULL) && (Split->SplitStdIn != NULL) && ((StdInVarName != NULL) || (StdInFileName != NULL)))
|
||||
|| ((Split != NULL) && (Split->SplitStdOut != NULL) && ((StdOutVarName != NULL) || (StdOutFileName != NULL)))
|
||||
//
|
||||
// Check that nothing is trying to be output to 2 locations.
|
||||
//
|
||||
||(StdErrFileName != NULL && StdErrVarName != NULL)
|
||||
||(StdOutFileName != NULL && StdOutVarName != NULL)
|
||||
||(StdInFileName != NULL && StdInVarName != NULL)
|
||||
|| ((StdErrFileName != NULL) && (StdErrVarName != NULL))
|
||||
|| ((StdOutFileName != NULL) && (StdOutVarName != NULL))
|
||||
|| ((StdInFileName != NULL) && (StdInVarName != NULL))
|
||||
//
|
||||
// Check for no volatile environment variables
|
||||
//
|
||||
||(StdErrVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
|
||||
||(StdOutVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
|
||||
|| ((StdErrVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
|
||||
|| ((StdOutVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
|
||||
//
|
||||
// Cant redirect during a reconnect operation.
|
||||
//
|
||||
||(StrStr(NewCommandLine, L"connect -r") != NULL
|
||||
&& (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
|
||||
|| ( (StrStr (NewCommandLine, L"connect -r") != NULL)
|
||||
&& ((StdOutVarName != NULL) || (StdOutFileName != NULL) || (StdErrFileName != NULL) || (StdErrVarName != NULL)))
|
||||
//
|
||||
// Check that filetypes (Unicode/Ascii) do not change during an append
|
||||
//
|
||||
||(StdOutFileName != NULL && OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && EFI_ERROR(IsUnicodeFile(StdOutFileName))))
|
||||
||(StdErrFileName != NULL && ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||||
||(StdOutFileName != NULL && !OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && !EFI_ERROR(IsUnicodeFile(StdOutFileName))))
|
||||
||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||||
){
|
||||
|| ((StdOutFileName != NULL) && OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && EFI_ERROR (IsUnicodeFile (StdOutFileName))))
|
||||
|| ((StdErrFileName != NULL) && ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && EFI_ERROR (IsUnicodeFile (StdErrFileName))))
|
||||
|| ((StdOutFileName != NULL) && !OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && !EFI_ERROR (IsUnicodeFile (StdOutFileName))))
|
||||
|| ((StdErrFileName != NULL) && !ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && !EFI_ERROR (IsUnicodeFile (StdErrFileName))))
|
||||
)
|
||||
{
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
ShellParameters->StdIn = *OldStdIn;
|
||||
ShellParameters->StdOut = *OldStdOut;
|
||||
@ -1107,14 +1168,17 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdErrFileName);
|
||||
}
|
||||
|
||||
Status = ShellOpenFileByName (StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
|
||||
if (!ErrAppend && ErrUnicode && !EFI_ERROR (Status)) {
|
||||
Status = WriteFileTag (TempHandle);
|
||||
}
|
||||
|
||||
if (!ErrUnicode && !EFI_ERROR (Status)) {
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
ASSERT (TempHandle != NULL);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ShellParameters->StdErr = TempHandle;
|
||||
gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
|
||||
@ -1124,13 +1188,14 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// StdOut to a file
|
||||
//
|
||||
if (!EFI_ERROR(Status) && StdOutFileName != NULL) {
|
||||
if (!EFI_ERROR (Status) && (StdOutFileName != NULL)) {
|
||||
if (!OutAppend) {
|
||||
//
|
||||
// delete existing file.
|
||||
//
|
||||
ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdOutFileName);
|
||||
}
|
||||
|
||||
Status = ShellOpenFileByName (StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
|
||||
if (TempHandle == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
@ -1151,13 +1216,16 @@ UpdateStdInStdOutStdErr(
|
||||
WriteFileTag (TempHandle) :
|
||||
ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
|
||||
TempHandle,
|
||||
FileSize);
|
||||
FileSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OutUnicode && !EFI_ERROR (Status)) {
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
ASSERT (TempHandle != NULL);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ShellParameters->StdOut = TempHandle;
|
||||
gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
|
||||
@ -1168,13 +1236,14 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// StdOut to a var
|
||||
//
|
||||
if (!EFI_ERROR(Status) && StdOutVarName != NULL) {
|
||||
if (!EFI_ERROR (Status) && (StdOutVarName != NULL)) {
|
||||
if (!OutAppend) {
|
||||
//
|
||||
// delete existing variable.
|
||||
//
|
||||
SHELL_SET_ENVIRONMENT_VARIABLE_V (StdOutVarName, 0, L"");
|
||||
}
|
||||
|
||||
TempHandle = CreateFileInterfaceEnv (StdOutVarName);
|
||||
ASSERT (TempHandle != NULL);
|
||||
ShellParameters->StdOut = TempHandle;
|
||||
@ -1184,13 +1253,14 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// StdErr to a var
|
||||
//
|
||||
if (!EFI_ERROR(Status) && StdErrVarName != NULL) {
|
||||
if (!EFI_ERROR (Status) && (StdErrVarName != NULL)) {
|
||||
if (!ErrAppend) {
|
||||
//
|
||||
// delete existing variable.
|
||||
//
|
||||
SHELL_SET_ENVIRONMENT_VARIABLE_V (StdErrVarName, 0, L"");
|
||||
}
|
||||
|
||||
TempHandle = CreateFileInterfaceEnv (StdErrVarName);
|
||||
ASSERT (TempHandle != NULL);
|
||||
ShellParameters->StdErr = TempHandle;
|
||||
@ -1200,7 +1270,7 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// StdIn from a var
|
||||
//
|
||||
if (!EFI_ERROR(Status) && StdInVarName != NULL) {
|
||||
if (!EFI_ERROR (Status) && (StdInVarName != NULL)) {
|
||||
TempHandle = CreateFileInterfaceEnv (StdInVarName);
|
||||
if (TempHandle == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1208,8 +1278,9 @@ UpdateStdInStdOutStdErr(
|
||||
if (!InUnicode) {
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
}
|
||||
|
||||
Size = 0;
|
||||
if (TempHandle == NULL || ((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
|
||||
if ((TempHandle == NULL) || (((EFI_FILE_PROTOCOL *)TempHandle)->Read (TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL)) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
ShellParameters->StdIn = TempHandle;
|
||||
@ -1221,12 +1292,13 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
// StdIn from a file
|
||||
//
|
||||
if (!EFI_ERROR(Status) && StdInFileName != NULL) {
|
||||
if (!EFI_ERROR (Status) && (StdInFileName != NULL)) {
|
||||
Status = ShellOpenFileByName (
|
||||
StdInFileName,
|
||||
&TempHandle,
|
||||
EFI_FILE_MODE_READ,
|
||||
0);
|
||||
0
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (!InUnicode) {
|
||||
//
|
||||
@ -1234,17 +1306,19 @@ UpdateStdInStdOutStdErr(
|
||||
//
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
}
|
||||
|
||||
ShellParameters->StdIn = TempHandle;
|
||||
gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (CommandLineCopy);
|
||||
|
||||
CalculateEfiHdrCrc (&gST->Hdr);
|
||||
|
||||
if (gST->ConIn == NULL ||gST->ConOut == NULL) {
|
||||
if ((gST->ConIn == NULL) || (gST->ConOut == NULL)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -1278,30 +1352,37 @@ RestoreStdInStdOutStdErr (
|
||||
{
|
||||
SPLIT_LIST *Split;
|
||||
|
||||
if (ShellParameters == NULL
|
||||
||OldStdIn == NULL
|
||||
||OldStdOut == NULL
|
||||
||OldStdErr == NULL
|
||||
||SystemTableInfo == NULL) {
|
||||
if ( (ShellParameters == NULL)
|
||||
|| (OldStdIn == NULL)
|
||||
|| (OldStdOut == NULL)
|
||||
|| (OldStdErr == NULL)
|
||||
|| (SystemTableInfo == NULL))
|
||||
{
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
|
||||
Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
|
||||
} else {
|
||||
Split = NULL;
|
||||
}
|
||||
|
||||
if (ShellParameters->StdIn != *OldStdIn) {
|
||||
if ((Split != NULL && Split->SplitStdIn != ShellParameters->StdIn) || Split == NULL) {
|
||||
if (((Split != NULL) && (Split->SplitStdIn != ShellParameters->StdIn)) || (Split == NULL)) {
|
||||
gEfiShellProtocol->CloseFile (ShellParameters->StdIn);
|
||||
}
|
||||
|
||||
ShellParameters->StdIn = *OldStdIn;
|
||||
}
|
||||
|
||||
if (ShellParameters->StdOut != *OldStdOut) {
|
||||
if ((Split != NULL && Split->SplitStdOut != ShellParameters->StdOut) || Split == NULL) {
|
||||
if (((Split != NULL) && (Split->SplitStdOut != ShellParameters->StdOut)) || (Split == NULL)) {
|
||||
gEfiShellProtocol->CloseFile (ShellParameters->StdOut);
|
||||
}
|
||||
|
||||
ShellParameters->StdOut = *OldStdOut;
|
||||
}
|
||||
|
||||
if (ShellParameters->StdErr != *OldStdErr) {
|
||||
gEfiShellProtocol->CloseFile (ShellParameters->StdErr);
|
||||
ShellParameters->StdErr = *OldStdErr;
|
||||
@ -1312,11 +1393,13 @@ RestoreStdInStdOutStdErr (
|
||||
gST->ConIn = SystemTableInfo->ConIn;
|
||||
gST->ConsoleInHandle = SystemTableInfo->ConInHandle;
|
||||
}
|
||||
|
||||
if (gST->ConOut != SystemTableInfo->ConOut) {
|
||||
CloseSimpleTextOutOnFile (gST->ConOut);
|
||||
gST->ConOut = SystemTableInfo->ConOut;
|
||||
gST->ConsoleOutHandle = SystemTableInfo->ConOutHandle;
|
||||
}
|
||||
|
||||
if (gST->StdErr != SystemTableInfo->ErrOut) {
|
||||
CloseSimpleTextOutOnFile (gST->StdErr);
|
||||
gST->StdErr = SystemTableInfo->ErrOut;
|
||||
@ -1327,6 +1410,7 @@ RestoreStdInStdOutStdErr (
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
Function will replace the current Argc and Argv in the ShellParameters protocol
|
||||
structure by parsing NewCommandLine. The current values are returned to the
|
||||
@ -1362,6 +1446,7 @@ UpdateArgcArgv(
|
||||
if (OldArgc != NULL) {
|
||||
*OldArgc = ShellParameters->Argc;
|
||||
}
|
||||
|
||||
if (OldArgc != NULL) {
|
||||
*OldArgv = ShellParameters->Argv;
|
||||
}
|
||||
@ -1370,7 +1455,8 @@ UpdateArgcArgv(
|
||||
StripParamQuotation = FALSE;
|
||||
}
|
||||
|
||||
return ParseCommandLineToArgs( NewCommandLine,
|
||||
return ParseCommandLineToArgs (
|
||||
NewCommandLine,
|
||||
StripParamQuotation,
|
||||
&(ShellParameters->Argv),
|
||||
&(ShellParameters->Argc)
|
||||
@ -1394,6 +1480,7 @@ RestoreArgcArgv(
|
||||
)
|
||||
{
|
||||
UINTN LoopCounter;
|
||||
|
||||
ASSERT (ShellParameters != NULL);
|
||||
ASSERT (OldArgv != NULL);
|
||||
ASSERT (OldArgc != NULL);
|
||||
@ -1402,11 +1489,14 @@ RestoreArgcArgv(
|
||||
for ( LoopCounter = 0
|
||||
; LoopCounter < ShellParameters->Argc
|
||||
; LoopCounter++
|
||||
){
|
||||
)
|
||||
{
|
||||
FreePool (ShellParameters->Argv[LoopCounter]);
|
||||
}
|
||||
|
||||
FreePool (ShellParameters->Argv);
|
||||
}
|
||||
|
||||
ShellParameters->Argv = *OldArgv;
|
||||
*OldArgv = NULL;
|
||||
ShellParameters->Argc = *OldArgc;
|
||||
|
@ -208,4 +208,3 @@ GetNextParameter(
|
||||
);
|
||||
|
||||
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -934,5 +934,5 @@ EFIAPI
|
||||
NotificationFunction (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
);
|
||||
#endif //_SHELL_PROTOCOL_HEADER_
|
||||
|
||||
#endif //_SHELL_PROTOCOL_HEADER_
|
||||
|
@ -34,9 +34,11 @@ ShellAppMain (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
if (Argc == 1) {
|
||||
Print (L"Argv[1] = NULL\n");
|
||||
}
|
||||
|
||||
for (Index = 1; Index < Argc; Index++) {
|
||||
Print (L"Argv[%d]: \"%s\"\n", Index, Argv[Index]);
|
||||
}
|
||||
|
@ -24,14 +24,19 @@
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
Test(CONST VOID *b1, CONST VOID *b2)
|
||||
Test (
|
||||
CONST VOID *b1,
|
||||
CONST VOID *b2
|
||||
)
|
||||
{
|
||||
if (*(INTN *)b1 == *(INTN *)b2) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (*(INTN *)b1 < *(INTN *)b2) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -93,14 +93,23 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
Display the trailing Verbose information.
|
||||
**/
|
||||
VOID
|
||||
DumpStatistics( void )
|
||||
DumpStatistics (
|
||||
void
|
||||
)
|
||||
{
|
||||
EFI_STRING StringPtr;
|
||||
EFI_STRING StringPtrUnknown;
|
||||
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle, SummaryData.NumTrace);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
|
||||
@ -153,6 +162,7 @@ GetHandleFormModuleGuid (
|
||||
if (IsZeroGuid (ModuleGuid)) {
|
||||
*Handle = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to get the Handle from the cached array.
|
||||
//
|
||||
@ -162,6 +172,7 @@ GetHandleFormModuleGuid (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= mCachePairCount) {
|
||||
*Handle = NULL;
|
||||
}
|
||||
@ -229,14 +240,15 @@ BuildCachedGuidHandleTable (
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) && LoadedImage != NULL) {
|
||||
if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
|
||||
//
|
||||
// Get Module Guid from DevicePath.
|
||||
//
|
||||
if (LoadedImage->FilePath != NULL &&
|
||||
LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
|
||||
LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
|
||||
) {
|
||||
if ((LoadedImage->FilePath != NULL) &&
|
||||
(LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
|
||||
(LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
|
||||
)
|
||||
{
|
||||
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
|
||||
TempGuid = &FvFilePath->FvFileName;
|
||||
|
||||
@ -246,10 +258,12 @@ BuildCachedGuidHandleTable (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
HandleBuffer = NULL;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -280,6 +294,7 @@ GetMeasurementInfo (
|
||||
} else {
|
||||
Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
|
||||
}
|
||||
|
||||
switch (Measurement->Identifier) {
|
||||
case MODULE_START_ID:
|
||||
case MODULE_END_ID:
|
||||
@ -290,12 +305,13 @@ GetMeasurementInfo (
|
||||
Measurement->Token = ALit_START_IMAGE;
|
||||
Measurement->Module = ALit_START_IMAGE;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
|
||||
if ((Measurement->Token != NULL) && (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
|
||||
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
||||
} else {
|
||||
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
|
||||
@ -305,7 +321,7 @@ GetMeasurementInfo (
|
||||
// For start image, we need detect the PEIM and non PEIM here.
|
||||
//
|
||||
if (Measurement->Token == NULL) {
|
||||
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
|
||||
if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
|
||||
Measurement->Token = ALit_PEIM;
|
||||
Measurement->Module = ALit_PEIM;
|
||||
Measurement->Handle = ModuleGuid;
|
||||
@ -315,6 +331,7 @@ GetMeasurementInfo (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FPDT_DYNAMIC_STRING_EVENT_TYPE:
|
||||
@ -325,6 +342,7 @@ GetMeasurementInfo (
|
||||
} else {
|
||||
Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
||||
}
|
||||
|
||||
switch (Measurement->Identifier) {
|
||||
case MODULE_START_ID:
|
||||
case MODULE_END_ID:
|
||||
@ -333,6 +351,7 @@ GetMeasurementInfo (
|
||||
} else if (mDxePhase) {
|
||||
Measurement->Token = ALit_START_IMAGE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MODULE_LOADIMAGE_START_ID:
|
||||
@ -362,7 +381,7 @@ GetMeasurementInfo (
|
||||
|
||||
Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
|
||||
|
||||
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
|
||||
if ((Measurement->Token != NULL) && (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
|
||||
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
||||
} else {
|
||||
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
|
||||
@ -371,8 +390,8 @@ GetMeasurementInfo (
|
||||
// When no perf entry to record the PEI and DXE phase,
|
||||
// For start image, we need detect the PEIM and non PEIM here.
|
||||
//
|
||||
if (Measurement->Token == NULL && (Measurement->Identifier == MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
|
||||
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
|
||||
if ((Measurement->Token == NULL) && ((Measurement->Identifier == MODULE_START_ID) || (Measurement->Identifier == MODULE_END_ID))) {
|
||||
if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
|
||||
Measurement->Token = ALit_PEIM;
|
||||
Measurement->Handle = ModuleGuid;
|
||||
} else {
|
||||
@ -380,6 +399,7 @@ GetMeasurementInfo (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FPDT_GUID_QWORD_EVENT_TYPE:
|
||||
@ -390,6 +410,7 @@ GetMeasurementInfo (
|
||||
} else {
|
||||
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
|
||||
}
|
||||
|
||||
switch (Measurement->Identifier) {
|
||||
case MODULE_DB_START_ID:
|
||||
Measurement->Token = ALit_DB_START;
|
||||
@ -417,6 +438,7 @@ GetMeasurementInfo (
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
|
||||
Measurement->Handle = StartHandle;
|
||||
break;
|
||||
@ -429,6 +451,7 @@ GetMeasurementInfo (
|
||||
} else {
|
||||
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
||||
}
|
||||
|
||||
//
|
||||
// Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.
|
||||
//
|
||||
@ -440,6 +463,7 @@ GetMeasurementInfo (
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
|
||||
Measurement->Handle = StartHandle;
|
||||
break;
|
||||
@ -452,6 +476,7 @@ GetMeasurementInfo (
|
||||
} else {
|
||||
Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
||||
}
|
||||
|
||||
Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
|
||||
Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
|
||||
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
|
||||
@ -478,25 +503,28 @@ SearchMeasurement (
|
||||
|
||||
for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
|
||||
if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {
|
||||
if (mMeasurementList[Index].EndTimeStamp == 0 && EndMeasureMent->Handle!= NULL && mMeasurementList[Index].Handle != NULL&&
|
||||
if ((mMeasurementList[Index].EndTimeStamp == 0) && (EndMeasureMent->Handle != NULL) && (mMeasurementList[Index].Handle != NULL) &&
|
||||
CompareGuid (mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
|
||||
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0))
|
||||
{
|
||||
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
||||
break;
|
||||
}
|
||||
} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
|
||||
if (mMeasurementList[Index].EndTimeStamp == 0 &&
|
||||
if ((mMeasurementList[Index].EndTimeStamp == 0) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&
|
||||
mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID) {
|
||||
(mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID))
|
||||
{
|
||||
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&
|
||||
if ((mMeasurementList[Index].EndTimeStamp == 0) && (mMeasurementList[Index].Handle == EndMeasureMent->Handle) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
||||
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
|
||||
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0))
|
||||
{
|
||||
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
||||
break;
|
||||
}
|
||||
@ -540,8 +568,9 @@ BuildMeasurementList (
|
||||
if (StartProgressId == 0) {
|
||||
GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));
|
||||
mMeasurementNum++;
|
||||
} else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||
|
||||
(StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {
|
||||
} else if ((((StartProgressId >= PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x000F) == 0)) ||
|
||||
((StartProgressId < PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x0001) != 0))))
|
||||
{
|
||||
//
|
||||
// Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE
|
||||
// So we need to identify these two kinds of record through different phase.
|
||||
@ -554,6 +583,7 @@ BuildMeasurementList (
|
||||
mPeiPhase = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Get measurement info form the start record to the mMeasurementList.
|
||||
GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));
|
||||
mMeasurementNum++;
|
||||
@ -562,9 +592,11 @@ BuildMeasurementList (
|
||||
GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
|
||||
SearchMeasurement (&MeasureMent);
|
||||
}
|
||||
|
||||
TableLength += RecordHeader->Length;
|
||||
PerformanceTablePtr += RecordHeader->Length;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -697,13 +729,14 @@ RunDp (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle);
|
||||
return SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ShellConvertStringToUint64 (CmdLineArg, &Intermediate, FALSE, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n");
|
||||
return SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Number2Display = (UINTN)Intermediate;
|
||||
if (Number2Display == 0 || Number2Display > MAXIMUM_DISPLAYCOUNT) {
|
||||
if ((Number2Display == 0) || (Number2Display > MAXIMUM_DISPLAYCOUNT)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);
|
||||
return SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -742,6 +775,7 @@ RunDp (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
CustomCumulativeData->MinDur = PERF_MAXDUR;
|
||||
CustomCumulativeData->MaxDur = 0;
|
||||
CustomCumulativeData->Count = 0;
|
||||
@ -752,6 +786,7 @@ RunDp (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
|
||||
}
|
||||
}
|
||||
@ -827,11 +862,19 @@ RunDp (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
|
||||
|
||||
if (VerboseMode && !RawMode) {
|
||||
StringPtr = HiiGetString (mDpHiiHandle,
|
||||
(EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
|
||||
StringPtr = HiiGetString (
|
||||
mDpHiiHandle,
|
||||
(EFI_STRING_ID)(TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)),
|
||||
NULL
|
||||
);
|
||||
ASSERT (StringPtr != NULL);
|
||||
// Print Timer count range and direction
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_TIMER_PROPERTIES),
|
||||
mDpHiiHandle,
|
||||
StringPtr,
|
||||
TimerInfo.StartCount,
|
||||
TimerInfo.EndCount
|
||||
@ -893,6 +936,7 @@ RunDp (
|
||||
ProcessCumulative (NULL);
|
||||
}
|
||||
} // ------------- End of Cooked Mode Processing
|
||||
|
||||
if ( VerboseMode || SummaryMode) {
|
||||
DumpStatistics ();
|
||||
}
|
||||
@ -901,10 +945,12 @@ Done:
|
||||
if (ParamPackage != NULL) {
|
||||
ShellCommandLineFreeVarList (ParamPackage);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (StringPtr);
|
||||
if (CustomCumulativeData != NULL) {
|
||||
SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (CustomCumulativeData);
|
||||
|
||||
SHELL_FREE_NON_NULL (mMeasurementList);
|
||||
@ -916,7 +962,6 @@ Done:
|
||||
return ShellStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve HII package list from ImageHandle and publish to HII database.
|
||||
|
||||
@ -962,5 +1007,6 @@ InitializeHiiPackage (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return HiiHandle;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#ifndef _DP_H_
|
||||
#define _DP_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Guid/Performance.h>
|
||||
@ -137,4 +136,5 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _DP_H_
|
||||
|
@ -36,6 +36,7 @@ DpAppInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||
if (mDpHiiHandle == NULL) {
|
||||
return EFI_ABORTED;
|
||||
|
@ -82,6 +82,7 @@ DpCommandInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||
if (mDpHiiHandle == NULL) {
|
||||
return EFI_ABORTED;
|
||||
@ -112,6 +113,7 @@ DpUnload (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
ImageHandle,
|
||||
&gEfiShellDynamicCommandProtocolGuid,
|
||||
@ -120,6 +122,7 @@ DpUnload (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
HiiRemovePackages (mDpHiiHandle);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef _DP_INTELNAL_H_
|
||||
#define _DP_INTELNAL_H_
|
||||
|
||||
@ -251,7 +252,6 @@ ProcessPhases(
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Gather and print Handle data.
|
||||
|
||||
@ -266,7 +266,6 @@ ProcessHandles(
|
||||
IN BOOLEAN ExcludeFlag
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Gather and print PEIM data.
|
||||
|
||||
|
@ -106,7 +106,8 @@ GatherStatistics(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
{
|
||||
++SummaryData.NumTrace; // Count the number of TRACE Measurement records
|
||||
if (Measurement.EndTimeStamp == 0) {
|
||||
@ -120,8 +121,8 @@ GatherStatistics(
|
||||
|
||||
if (IsPhase (&Measurement)) {
|
||||
++SummaryData.NumSummary; // Count the number of major phases
|
||||
}
|
||||
else { // !IsPhase
|
||||
} else {
|
||||
// !IsPhase
|
||||
if (Measurement.Handle == NULL) {
|
||||
++SummaryData.NumGlobal;
|
||||
}
|
||||
@ -139,6 +140,7 @@ GatherStatistics(
|
||||
if ( Duration < CumData[TIndex].MinDur ) {
|
||||
CumData[TIndex].MinDur = Duration;
|
||||
}
|
||||
|
||||
if ( Duration > CumData[TIndex].MaxDur ) {
|
||||
CumData[TIndex].MaxDur = Duration;
|
||||
}
|
||||
@ -153,6 +155,7 @@ GatherStatistics(
|
||||
if (Duration < CustomCumulativeData->MinDur) {
|
||||
CustomCumulativeData->MinDur = Duration;
|
||||
}
|
||||
|
||||
if (Duration > CustomCumulativeData->MaxDur) {
|
||||
CustomCumulativeData->MaxDur = Duration;
|
||||
}
|
||||
@ -203,8 +206,14 @@ DumpAllTrace(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(IncFlag == NULL) ? StringPtrUnknown : IncFlag);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(IncFlag == NULL) ? StringPtrUnknown : IncFlag
|
||||
);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
// Get Handle information
|
||||
@ -212,8 +221,7 @@ DumpAllTrace(
|
||||
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// We have successfully populated the HandleBuffer
|
||||
// Display ALL Measurement Records
|
||||
// Up to Limit lines displayed
|
||||
@ -239,7 +247,8 @@ DumpAllTrace(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
)
|
||||
{
|
||||
++Index; // Count every record. First record is 1.
|
||||
@ -249,15 +258,17 @@ DumpAllTrace(
|
||||
Duration = GetDuration (&Measurement);
|
||||
ElapsedTime = DurationInMicroSeconds (Duration);
|
||||
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
|
||||
}
|
||||
|
||||
if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
|
||||
((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
|
||||
) { // Ignore "uninteresting" or excluded records
|
||||
) // Ignore "uninteresting" or excluded records
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
++Count; // Count the number of records printed
|
||||
|
||||
// If Handle is non-zero, see if we can determine a name for the driver
|
||||
@ -282,7 +293,12 @@ DumpAllTrace(
|
||||
mUnicodeToken[13] = 0;
|
||||
|
||||
if (mShowId) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_ALL_VARS2),
|
||||
mDpHiiHandle,
|
||||
Index, // 1 based, Which measurement record is being printed
|
||||
IncFlag,
|
||||
Measurement.Handle,
|
||||
@ -292,7 +308,12 @@ DumpAllTrace(
|
||||
Measurement.Identifier
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_ALL_VARS),
|
||||
mDpHiiHandle,
|
||||
Index, // 1 based, Which measurement record is being printed
|
||||
IncFlag,
|
||||
Measurement.Handle,
|
||||
@ -301,15 +322,18 @@ DumpAllTrace(
|
||||
ElapsedTime
|
||||
);
|
||||
}
|
||||
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (IncFlag);
|
||||
|
||||
return Status;
|
||||
@ -356,8 +380,14 @@ DumpRawTrace(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
@ -380,7 +410,8 @@ DumpRawTrace(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
)
|
||||
{
|
||||
++Index; // Count every record. First record is 1.
|
||||
@ -389,15 +420,23 @@ DumpRawTrace(
|
||||
Duration = GetDuration (&Measurement);
|
||||
ElapsedTime = DurationInMicroSeconds (Duration);
|
||||
}
|
||||
|
||||
if ((ElapsedTime < mInterestThreshold) ||
|
||||
((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
|
||||
) { // Ignore "uninteresting" or Excluded records
|
||||
) // Ignore "uninteresting" or Excluded records
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
++Count; // Count the number of records printed
|
||||
|
||||
if (mShowId) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_RAW_VARS2),
|
||||
mDpHiiHandle,
|
||||
Index, // 1 based, Which measurement record is being printed
|
||||
Measurement.Handle,
|
||||
Measurement.StartTimeStamp,
|
||||
@ -407,7 +446,12 @@ DumpRawTrace(
|
||||
Measurement.Identifier
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_RAW_VARS),
|
||||
mDpHiiHandle,
|
||||
Index, // 1 based, Which measurement record is being printed
|
||||
Measurement.Handle,
|
||||
Measurement.StartTimeStamp,
|
||||
@ -416,11 +460,13 @@ DumpRawTrace(
|
||||
Measurement.Module
|
||||
);
|
||||
}
|
||||
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -456,8 +502,14 @@ ProcessPhases(
|
||||
//
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
@ -469,13 +521,16 @@ ProcessPhases(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
{
|
||||
if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
|
||||
if (Measurement.EndTimeStamp == 0) {
|
||||
// Skip "incomplete" records
|
||||
continue;
|
||||
}
|
||||
|
||||
Duration = GetDuration (&Measurement);
|
||||
if ( Measurement.Handle != NULL
|
||||
if ( (Measurement.Handle != NULL)
|
||||
&& (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
|
||||
)
|
||||
{
|
||||
@ -561,16 +616,21 @@ ProcessHandles(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if DP_DEBUG == 2
|
||||
Print (L"There are %,d Handles defined.\n", (Size / sizeof (HandleBuffer[0])));
|
||||
#endif
|
||||
@ -580,6 +640,7 @@ ProcessHandles(
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
||||
|
||||
LogEntryKey = 0;
|
||||
@ -591,7 +652,8 @@ ProcessHandles(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
{
|
||||
Count++;
|
||||
Duration = GetDuration (&Measurement);
|
||||
@ -600,9 +662,11 @@ ProcessHandles(
|
||||
(Measurement.EndTimeStamp == 0) ||
|
||||
(!IsCorePerf (&Measurement)) ||
|
||||
((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
|
||||
) { // Ignore "uninteresting" or excluded records
|
||||
) // Ignore "uninteresting" or excluded records
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
mGaugeString[0] = 0; // Empty driver name by default
|
||||
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
|
||||
// See if the Handle is in the HandleBuffer
|
||||
@ -612,13 +676,19 @@ ProcessHandles(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that the argument strings are not too long.
|
||||
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
|
||||
mUnicodeToken[11] = 0;
|
||||
if (mGaugeString[0] != 0) {
|
||||
// Display the record if it has a valid handle.
|
||||
if (mShowId) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_HANDLE_VARS2),
|
||||
mDpHiiHandle,
|
||||
Count, // 1 based, Which measurement record is being printed
|
||||
Index + 1, // 1 based, Which handle is being printed
|
||||
mGaugeString,
|
||||
@ -627,7 +697,12 @@ ProcessHandles(
|
||||
Measurement.Identifier
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_HANDLE_VARS),
|
||||
mDpHiiHandle,
|
||||
Count, // 1 based, Which measurement record is being printed
|
||||
Index + 1, // 1 based, Which handle is being printed
|
||||
mGaugeString,
|
||||
@ -636,15 +711,18 @@ ProcessHandles(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -674,8 +752,14 @@ ProcessPeims(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
@ -684,6 +768,7 @@ ProcessPeims(
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
||||
TIndex = 0;
|
||||
LogEntryKey = 0;
|
||||
@ -694,12 +779,14 @@ ProcessPeims(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
{
|
||||
TIndex++;
|
||||
if ((Measurement.EndTimeStamp == 0) ||
|
||||
(AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -708,25 +795,37 @@ ProcessPeims(
|
||||
if (ElapsedTime >= mInterestThreshold) {
|
||||
// PEIM FILE Handle is the start address of its FFS file that contains its file guid.
|
||||
if (mShowId) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_PEIM_VARS2),
|
||||
mDpHiiHandle,
|
||||
TIndex, // 1 based, Which measurement record is being printed
|
||||
Measurement.Handle, // file guid
|
||||
ElapsedTime,
|
||||
Measurement.Identifier
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_PEIM_VARS),
|
||||
mDpHiiHandle,
|
||||
TIndex, // 1 based, Which measurement record is being printed
|
||||
Measurement.Handle, // file guid
|
||||
ElapsedTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -759,8 +858,14 @@ ProcessGlobal(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown: StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
@ -769,6 +874,7 @@ ProcessGlobal(
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
||||
|
||||
Index = 1;
|
||||
@ -781,7 +887,8 @@ ProcessGlobal(
|
||||
&Measurement.Module,
|
||||
&Measurement.StartTimeStamp,
|
||||
&Measurement.EndTimeStamp,
|
||||
&Measurement.Identifier)) != 0)
|
||||
&Measurement.Identifier
|
||||
)) != 0)
|
||||
{
|
||||
AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
|
||||
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
|
||||
@ -796,7 +903,12 @@ ProcessGlobal(
|
||||
ElapsedTime = DurationInMicroSeconds (Duration);
|
||||
if (ElapsedTime >= mInterestThreshold) {
|
||||
if (mShowId) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_GLOBAL_VARS2),
|
||||
mDpHiiHandle,
|
||||
Index,
|
||||
mGaugeString,
|
||||
mUnicodeToken,
|
||||
@ -804,7 +916,12 @@ ProcessGlobal(
|
||||
Measurement.Identifier
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_GLOBAL_VARS),
|
||||
mDpHiiHandle,
|
||||
Index,
|
||||
mGaugeString,
|
||||
mUnicodeToken,
|
||||
@ -813,12 +930,15 @@ ProcessGlobal(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -848,8 +968,14 @@ ProcessCumulative(
|
||||
|
||||
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
||||
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown: StringPtr);
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_SECTION_HEADER),
|
||||
mDpHiiHandle,
|
||||
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
|
||||
);
|
||||
FreePool (StringPtr);
|
||||
FreePool (StringPtrUnknown);
|
||||
|
||||
@ -865,7 +991,12 @@ ProcessCumulative(
|
||||
MaxDur = DurationInMicroSeconds (CumData[TIndex].MaxDur);
|
||||
MinDur = DurationInMicroSeconds (CumData[TIndex].MinDur);
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
|
||||
mDpHiiHandle,
|
||||
CumData[TIndex].Name,
|
||||
CumData[TIndex].Count,
|
||||
Dur,
|
||||
@ -892,7 +1023,13 @@ ProcessCumulative(
|
||||
MaxDur = 0;
|
||||
MinDur = 0;
|
||||
}
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
|
||||
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
|
||||
mDpHiiHandle,
|
||||
CustomCumulativeData->Name,
|
||||
CustomCumulativeData->Count,
|
||||
Dur,
|
||||
|
@ -72,6 +72,7 @@ GetDuration (
|
||||
DEBUG ((DEBUG_ERROR, ALit_TimerLibError));
|
||||
Duration = 0;
|
||||
}
|
||||
|
||||
return Duration;
|
||||
}
|
||||
|
||||
@ -162,8 +163,9 @@ DpGetShortPdbFileName (
|
||||
StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);
|
||||
} else {
|
||||
StartIndex = 0;
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
|
||||
;
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
|
||||
}
|
||||
|
||||
for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
|
||||
if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
|
||||
StartIndex = IndexA + 1;
|
||||
@ -317,6 +319,7 @@ DpGetNameFromHandle (
|
||||
if (NameGuid != NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
}
|
||||
|
||||
@ -347,6 +350,7 @@ DpGetNameFromHandle (
|
||||
//
|
||||
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
//
|
||||
@ -417,6 +421,7 @@ GetCumulativeItem(
|
||||
return Index; // Exit, we found a match
|
||||
}
|
||||
}
|
||||
|
||||
// If the for loop exits, Token was not found.
|
||||
return -1; // Indicate failure
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#ifndef _LITERALS_H_
|
||||
#define _LITERALS_H_
|
||||
|
||||
|
@ -328,7 +328,7 @@ TrimSpaces (
|
||||
//
|
||||
do {
|
||||
Len = StrLen (Str);
|
||||
if (!Len || (Str[Len - 1] != L' ' && Str[Len - 1] != '\t')) {
|
||||
if (!Len || ((Str[Len - 1] != L' ') && (Str[Len - 1] != '\t'))) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -629,7 +629,8 @@ RunHttp (
|
||||
Walker = RemoteFilePath + StrLen (RemoteFilePath);
|
||||
while ((--Walker) >= RemoteFilePath) {
|
||||
if ((*Walker == L'\\') ||
|
||||
(*Walker == L'/' ) ) {
|
||||
(*Walker == L'/'))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -674,7 +675,7 @@ RunHttp (
|
||||
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-s");
|
||||
if (ValueStr != NULL) {
|
||||
Context.BufferSize = ShellStrToUintn (ValueStr);
|
||||
if (!Context.BufferSize || Context.BufferSize > MAX_BUF_SIZE) {
|
||||
if (!Context.BufferSize || (Context.BufferSize > MAX_BUF_SIZE)) {
|
||||
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV), ValueStr);
|
||||
goto Error;
|
||||
}
|
||||
@ -1023,7 +1024,7 @@ WaitForCompletion (
|
||||
{
|
||||
Status = Context->Http->Poll (Context->Http);
|
||||
if ( !Context->ContentDownloaded
|
||||
&& CallBackComplete == &gResponseCallbackComplete)
|
||||
&& (CallBackComplete == &gResponseCallbackComplete))
|
||||
{
|
||||
//
|
||||
// An HTTP server may just send a response redirection header.
|
||||
@ -1265,7 +1266,6 @@ SavePortion (
|
||||
NbOfKb
|
||||
);
|
||||
|
||||
|
||||
ShellPrintEx (-1, -1, L"%s", Progress);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -1476,7 +1476,6 @@ ParseMsg (
|
||||
return SavePortion (Context, Length, Data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get HTTP server response and collect the whole body as a file.
|
||||
Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR).
|
||||
@ -1642,7 +1641,7 @@ GetResponse (
|
||||
|
||||
HttpGetEntityLength (MsgParser, &Context->ContentLength);
|
||||
|
||||
if (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST
|
||||
if ( (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST)
|
||||
&& (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
|
||||
{
|
||||
//
|
||||
@ -1684,8 +1683,8 @@ GetResponse (
|
||||
&& !EFI_ERROR (Status)
|
||||
&& ResponseMessage.BodyLength);
|
||||
|
||||
if (Context->Status != REQ_NEED_REPEAT
|
||||
&& Status == EFI_SUCCESS
|
||||
if ( (Context->Status != REQ_NEED_REPEAT)
|
||||
&& (Status == EFI_SUCCESS)
|
||||
&& CanMeasureTime)
|
||||
{
|
||||
if (!EFI_ERROR (gRT->GetTime (&EndTime, NULL))) {
|
||||
@ -1814,7 +1813,8 @@ DownloadFile (
|
||||
&DownloadUrl,
|
||||
&UrlSize,
|
||||
Context->Uri,
|
||||
StrLen (Context->Uri));
|
||||
StrLen (Context->Uri)
|
||||
);
|
||||
|
||||
PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl);
|
||||
|
||||
@ -1828,7 +1828,6 @@ DownloadFile (
|
||||
if (Status) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
} while (Context->Status == REQ_NEED_REPEAT);
|
||||
|
||||
if (Context->Status) {
|
||||
|
@ -89,4 +89,5 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _HTTP_H_
|
||||
|
@ -208,11 +208,19 @@ CheckPacket (
|
||||
|
||||
EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
|
||||
TRUE, // Use default setting
|
||||
{ { 0, 0, 0, 0 } }, // StationIp - Not relevant as UseDefaultSetting=TRUE
|
||||
{ { 0, 0, 0, 0 } }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
|
||||
{
|
||||
{ 0, 0, 0, 0 }
|
||||
}, // StationIp - Not relevant as UseDefaultSetting=TRUE
|
||||
{
|
||||
{ 0, 0, 0, 0 }
|
||||
}, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
|
||||
0, // LocalPort - Automatically assigned port number.
|
||||
{ { 0, 0, 0, 0 } }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
|
||||
{ { 0, 0, 0, 0 } }, // ServerIp - Not known yet
|
||||
{
|
||||
{ 0, 0, 0, 0 }
|
||||
}, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
|
||||
{
|
||||
{ 0, 0, 0, 0 }
|
||||
}, // ServerIp - Not known yet
|
||||
69, // InitialServerPort - Standard TFTP server port
|
||||
6, // TryCount - The number of times to transmit request packets and wait for a response.
|
||||
4 // TimeoutValue - Retransmission timeout in seconds.
|
||||
@ -319,15 +327,22 @@ RunTftp (
|
||||
Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) &&
|
||||
(ProblemParam != NULL) ) {
|
||||
(ProblemParam != NULL))
|
||||
{
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), mTftpHiiHandle,
|
||||
L"tftp", ProblemParam
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ProblemParam
|
||||
);
|
||||
FreePool (ProblemParam);
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
goto Error;
|
||||
}
|
||||
|
||||
@ -337,15 +352,24 @@ RunTftp (
|
||||
ParamCount = ShellCommandLineGetCount (CheckPackage);
|
||||
if (ParamCount > 4) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
|
||||
mTftpHiiHandle, L"tftp"
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_TOO_MANY),
|
||||
mTftpHiiHandle,
|
||||
L"tftp"
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (ParamCount < 3) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
|
||||
mTftpHiiHandle, L"tftp"
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_TOO_FEW),
|
||||
mTftpHiiHandle,
|
||||
L"tftp"
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
@ -359,8 +383,13 @@ RunTftp (
|
||||
Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle, L"tftp", ValueStr
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ValueStr
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
@ -373,6 +402,7 @@ RunTftp (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
goto Error;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStrS (RemoteFilePath, AsciiRemoteFilePath, FilePathSize);
|
||||
|
||||
if (ParamCount == 4) {
|
||||
@ -381,10 +411,12 @@ RunTftp (
|
||||
Walker = RemoteFilePath + StrLen (RemoteFilePath);
|
||||
while ((--Walker) >= RemoteFilePath) {
|
||||
if ((*Walker == L'\\') ||
|
||||
(*Walker == L'/' ) ) {
|
||||
(*Walker == L'/'))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mLocalFilePath = Walker + 1;
|
||||
}
|
||||
|
||||
@ -423,10 +455,16 @@ RunTftp (
|
||||
if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (Mtftp4ConfigData.TimeoutValue == 0) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle, L"tftp", ValueStr
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ValueStr
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
@ -437,10 +475,16 @@ RunTftp (
|
||||
if (!StringToUint16 (ValueStr, &BlockSize)) {
|
||||
goto Error;
|
||||
}
|
||||
if (BlockSize < MTFTP_MIN_BLKSIZE || BlockSize > MTFTP_MAX_BLKSIZE) {
|
||||
|
||||
if ((BlockSize < MTFTP_MIN_BLKSIZE) || (BlockSize > MTFTP_MAX_BLKSIZE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle, L"tftp", ValueStr
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ValueStr
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
@ -451,10 +495,16 @@ RunTftp (
|
||||
if (!StringToUint16 (ValueStr, &WindowSize)) {
|
||||
goto Error;
|
||||
}
|
||||
if (WindowSize < MTFTP_MIN_WINDOWSIZE || WindowSize > MTFTP_MAX_WINDOWSIZE) {
|
||||
|
||||
if ((WindowSize < MTFTP_MIN_WINDOWSIZE) || (WindowSize > MTFTP_MAX_WINDOWSIZE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle, L"tftp", ValueStr
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ValueStr
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
@ -473,7 +523,10 @@ RunTftp (
|
||||
);
|
||||
if (EFI_ERROR (Status) || (HandleCount == 0)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
|
||||
mTftpHiiHandle
|
||||
);
|
||||
goto Error;
|
||||
@ -481,14 +534,20 @@ RunTftp (
|
||||
|
||||
for (NicNumber = 0;
|
||||
(NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS);
|
||||
NicNumber++) {
|
||||
NicNumber++)
|
||||
{
|
||||
ControllerHandle = Handles[NicNumber];
|
||||
|
||||
Status = GetNicName (ControllerHandle, NicNumber, NicName);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
|
||||
mTftpHiiHandle, NicNumber, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
|
||||
mTftpHiiHandle,
|
||||
NicNumber,
|
||||
Status
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@ -497,6 +556,7 @@ RunTftp (
|
||||
if (StrCmp (NicName, UserNicName) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NicFound = TRUE;
|
||||
}
|
||||
|
||||
@ -509,8 +569,13 @@ RunTftp (
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
|
||||
mTftpHiiHandle, NicName, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
|
||||
mTftpHiiHandle,
|
||||
NicName,
|
||||
Status
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@ -518,8 +583,13 @@ RunTftp (
|
||||
Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
|
||||
mTftpHiiHandle, NicName, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
|
||||
mTftpHiiHandle,
|
||||
NicName,
|
||||
Status
|
||||
);
|
||||
goto NextHandle;
|
||||
}
|
||||
@ -527,8 +597,14 @@ RunTftp (
|
||||
Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
|
||||
mTftpHiiHandle, RemoteFilePath, NicName, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
|
||||
mTftpHiiHandle,
|
||||
RemoteFilePath,
|
||||
NicName,
|
||||
Status
|
||||
);
|
||||
goto NextHandle;
|
||||
}
|
||||
@ -536,8 +612,14 @@ RunTftp (
|
||||
Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, WindowSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
|
||||
mTftpHiiHandle, RemoteFilePath, NicName, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
|
||||
mTftpHiiHandle,
|
||||
RemoteFilePath,
|
||||
NicName,
|
||||
Status
|
||||
);
|
||||
goto NextHandle;
|
||||
}
|
||||
@ -556,8 +638,12 @@ RunTftp (
|
||||
|
||||
if ((UserNicName != NULL) && (!NicFound)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
|
||||
mTftpHiiHandle, UserNicName
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
|
||||
mTftpHiiHandle,
|
||||
UserNicName
|
||||
);
|
||||
}
|
||||
|
||||
@ -567,6 +653,7 @@ RunTftp (
|
||||
if (AsciiRemoteFilePath != NULL) {
|
||||
FreePool (AsciiRemoteFilePath);
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
@ -599,8 +686,13 @@ StringToUint16 (
|
||||
Val = ShellStrToUintn (ValueStr);
|
||||
if (Val > MAX_UINT16) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle, L"tftp", ValueStr
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
ValueStr
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
@ -847,9 +939,11 @@ GetFileSize (
|
||||
*FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr);
|
||||
break;
|
||||
}
|
||||
|
||||
OptCnt--;
|
||||
Option++;
|
||||
}
|
||||
|
||||
FreePool (TableOfOptions);
|
||||
|
||||
if (OptCnt == 0) {
|
||||
@ -902,6 +996,7 @@ DownloadFile (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Error;
|
||||
}
|
||||
|
||||
TftpContext->FileSize = FileSize;
|
||||
TftpContext->DownloadedNbOfBytes = 0;
|
||||
TftpContext->LastReportedNbOfBytes = 0;
|
||||
@ -931,8 +1026,12 @@ DownloadFile (
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
|
||||
mTftpHiiHandle, FilePath
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_DOWNLOADING),
|
||||
mTftpHiiHandle,
|
||||
FilePath
|
||||
);
|
||||
|
||||
//
|
||||
@ -952,15 +1051,23 @@ DownloadFile (
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
|
||||
mTftpHiiHandle, L"tftp", mLocalFilePath
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
|
||||
mTftpHiiHandle,
|
||||
L"tftp",
|
||||
mLocalFilePath
|
||||
);
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_CRLF),
|
||||
mTftpHiiHandle
|
||||
);
|
||||
|
||||
@ -1030,13 +1137,22 @@ CheckPacket (
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Context->DownloadedNbOfBytes > 0) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_CRLF),
|
||||
mTftpHiiHandle
|
||||
);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE),
|
||||
mTftpHiiHandle, mLocalFilePath, Status
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_TFTP_ERR_WRITE),
|
||||
mTftpHiiHandle,
|
||||
mLocalFilePath,
|
||||
Status
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
@ -1062,9 +1178,11 @@ CheckPacket (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index = 1; Index < Step; Index++) {
|
||||
Progress[Index] = L'=';
|
||||
}
|
||||
|
||||
Progress[Step] = L'>';
|
||||
|
||||
UnicodeSPrint (
|
||||
@ -1125,5 +1243,6 @@ InitializeHiiPackage (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return HiiHandle;
|
||||
}
|
||||
|
@ -66,4 +66,5 @@ EFI_HII_HANDLE
|
||||
InitializeHiiPackage (
|
||||
EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#endif // _TFTP_H_
|
||||
|
@ -37,6 +37,7 @@ TftpAppInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||
if (mTftpHiiHandle == NULL) {
|
||||
return EFI_ABORTED;
|
||||
|
@ -83,6 +83,7 @@ TftpCommandInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||
if (mTftpHiiHandle == NULL) {
|
||||
return EFI_ABORTED;
|
||||
@ -113,6 +114,7 @@ TftpUnload (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
ImageHandle,
|
||||
&gEfiShellDynamicCommandProtocolGuid,
|
||||
@ -121,6 +123,7 @@ TftpUnload (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
HiiRemovePackages (mTftpHiiHandle);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -43,4 +43,3 @@ BcfgLibraryUnregisterBcfgCommand (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -315,7 +315,6 @@ ParseHandleDatabaseForChildControllers(
|
||||
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Function to retrieve the human-friendly index of a given handle. If the handle
|
||||
does not have a index one will be automatically assigned. The index value is valid
|
||||
@ -382,7 +381,6 @@ GetHandleListByProtocolList (
|
||||
IN CONST EFI_GUID **ProtocolGuids
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Return all supported GUIDs.
|
||||
|
||||
|
@ -31,4 +31,3 @@ ShellAppMain (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -191,7 +191,6 @@ ShellCommandGetManFileNameHandler (
|
||||
IN CONST CHAR16 *CommandString
|
||||
);
|
||||
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
CHAR16 *CommandString;
|
||||
@ -327,8 +326,6 @@ ShellCommandSetEchoState (
|
||||
IN BOOLEAN State
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Indicate that the current shell or script should exit.
|
||||
|
||||
@ -644,7 +641,6 @@ ShellFileHandleGetPath(
|
||||
IN CONST SHELL_FILE_HANDLE Handle
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Function to determine if a SHELL_FILE_HANDLE is at the end of the file.
|
||||
|
||||
@ -795,4 +791,5 @@ ShellSortFileList (
|
||||
OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL,
|
||||
IN SHELL_SORT_FILE_LIST Order
|
||||
);
|
||||
|
||||
#endif //_SHELL_COMMAND_LIB_
|
||||
|
@ -711,7 +711,6 @@ typedef struct {
|
||||
SHELL_PARAM_TYPE Type;
|
||||
} SHELL_PARAM_ITEM;
|
||||
|
||||
|
||||
/// Helper structure for no parameters (besides -? and -b)
|
||||
extern SHELL_PARAM_ITEM EmptyParamList[];
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _SHELL_ENVIRONMENT_2_PROTOCOL_H_
|
||||
#define _SHELL_ENVIRONMENT_2_PROTOCOL_H_
|
||||
|
||||
@ -486,6 +485,7 @@ VOID
|
||||
//
|
||||
// declarations of handle enumerator
|
||||
//
|
||||
|
||||
/**
|
||||
For ease of use the shell maps handle #'s to short numbers.
|
||||
This is only done on request for various internal commands and the references
|
||||
@ -621,12 +621,12 @@ typedef struct {
|
||||
//
|
||||
UINTN NoHandles; ///< The number of handles producing this protocol.
|
||||
EFI_HANDLE *Handles; ///< The array of handles.
|
||||
|
||||
} PROTOCOL_INFO;
|
||||
|
||||
//
|
||||
// Declarations of protocol info enumerator.
|
||||
//
|
||||
|
||||
/**
|
||||
This is an internal shell function to initialize the protocol enumerator.
|
||||
|
||||
@ -692,7 +692,6 @@ VOID
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function is an internal shell function for enumeration of protocols.
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -207,7 +207,6 @@ typedef struct {
|
||||
UINT64 Compatibilities;
|
||||
} EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1;
|
||||
|
||||
|
||||
///
|
||||
/// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec > 2.4a and < 2.5
|
||||
///
|
||||
@ -291,4 +290,3 @@ typedef struct _GUID_INFO_BLOCK{
|
||||
} GUID_INFO_BLOCK;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -140,22 +140,29 @@ VerifyChecksum (
|
||||
if (GetColourHighlighting ()) {
|
||||
gST->ConOut->SetAttribute (
|
||||
gST->ConOut,
|
||||
EFI_TEXT_ATTR (EFI_GREEN,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
|
||||
EFI_TEXT_ATTR (
|
||||
EFI_GREEN,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Print (L"Table Checksum : OK\n\n");
|
||||
} else {
|
||||
IncrementErrorCount ();
|
||||
if (GetColourHighlighting ()) {
|
||||
gST->ConOut->SetAttribute (
|
||||
gST->ConOut,
|
||||
EFI_TEXT_ATTR (EFI_RED,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
|
||||
EFI_TEXT_ATTR (
|
||||
EFI_RED,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum);
|
||||
}
|
||||
|
||||
if (GetColourHighlighting ()) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
|
||||
}
|
||||
@ -216,6 +223,7 @@ DumpRaw (
|
||||
if ((Length & 0x0F) <= 8) {
|
||||
PartLineChars += 2;
|
||||
}
|
||||
|
||||
while (PartLineChars > 0) {
|
||||
Print (L" ");
|
||||
PartLineChars--;
|
||||
@ -526,10 +534,13 @@ ParseAcpi (
|
||||
OriginalAttribute = gST->ConOut->Mode->Attribute;
|
||||
gST->ConOut->SetAttribute (
|
||||
gST->ConOut,
|
||||
EFI_TEXT_ATTR(EFI_YELLOW,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
|
||||
EFI_TEXT_ATTR (
|
||||
EFI_YELLOW,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Print (
|
||||
L"%*a%-*a :\n",
|
||||
gIndent,
|
||||
@ -544,7 +555,6 @@ ParseAcpi (
|
||||
|
||||
for (Index = 0; Index < ParserItems; Index++) {
|
||||
if ((Offset + Parser[Index].Length) > Length) {
|
||||
|
||||
// For fields outside the buffer length provided, reset any pointers
|
||||
// which were supposed to be updated by this function call
|
||||
if (Parser[Index].ItemPtr != NULL) {
|
||||
@ -556,7 +566,8 @@ ParseAcpi (
|
||||
}
|
||||
|
||||
if (GetConsistencyChecking () &&
|
||||
(Offset != Parser[Index].Offset)) {
|
||||
(Offset != Parser[Index].Offset))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"\nERROR: %a: Offset Mismatch for %s\n"
|
||||
@ -597,12 +608,15 @@ ParseAcpi (
|
||||
);
|
||||
} // switch
|
||||
}
|
||||
|
||||
// Validating only makes sense if we are tracing
|
||||
// the parsed table entries, to report by table name.
|
||||
if (GetConsistencyChecking () &&
|
||||
(Parser[Index].FieldValidator != NULL)) {
|
||||
(Parser[Index].FieldValidator != NULL))
|
||||
{
|
||||
Parser[Index].FieldValidator (Ptr, Parser[Index].Context);
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
} // if (Trace)
|
||||
|
||||
|
@ -258,7 +258,6 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8* Ptr, VOID* Context);
|
||||
representing the field data.
|
||||
**/
|
||||
typedef struct AcpiParser {
|
||||
|
||||
/// String describing the ACPI table field
|
||||
/// (Field column from ACPI table spec)
|
||||
CONST CHAR16 *NameStr;
|
||||
|
@ -231,6 +231,7 @@ ProcessAcpiTable (
|
||||
if (GetMandatoryTableValidate ()) {
|
||||
ArmSbbrIncrementTableCount (*AcpiTableSignature);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Status = GetParser (*AcpiTableSignature, &ParserProc);
|
||||
@ -239,6 +240,7 @@ ProcessAcpiTable (
|
||||
if (Trace) {
|
||||
DumpAcpiHeader (Ptr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,7 @@ ProcessTableReportOptions (
|
||||
Log = TRUE;
|
||||
SelectedTable->Found = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case ReportTableList:
|
||||
if (mTableCount == 0) {
|
||||
@ -113,15 +114,19 @@ ProcessTableReportOptions (
|
||||
OriginalAttribute = gST->ConOut->Mode->Attribute;
|
||||
gST->ConOut->SetAttribute (
|
||||
gST->ConOut,
|
||||
EFI_TEXT_ATTR(EFI_CYAN,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
|
||||
EFI_TEXT_ATTR (
|
||||
EFI_CYAN,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Print (L"\nInstalled Table(s):\n");
|
||||
if (HighLight) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
Print (
|
||||
L"\t%4d. %c%c%c%c\n",
|
||||
++mTableCount,
|
||||
@ -136,6 +141,7 @@ ProcessTableReportOptions (
|
||||
SelectedTable->Found = TRUE;
|
||||
DumpAcpiTableToFile (TablePtr, Length);
|
||||
}
|
||||
|
||||
break;
|
||||
case ReportMax:
|
||||
// We should never be here.
|
||||
@ -148,10 +154,13 @@ ProcessTableReportOptions (
|
||||
OriginalAttribute = gST->ConOut->Mode->Attribute;
|
||||
gST->ConOut->SetAttribute (
|
||||
gST->ConOut,
|
||||
EFI_TEXT_ATTR(EFI_LIGHTBLUE,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
|
||||
EFI_TEXT_ATTR (
|
||||
EFI_LIGHTBLUE,
|
||||
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Print (
|
||||
L"\n\n --------------- %c%c%c%c Table --------------- \n\n",
|
||||
SignaturePtr[0],
|
||||
@ -167,8 +176,6 @@ ProcessTableReportOptions (
|
||||
return Log;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function iterates the configuration table entries in the
|
||||
system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
|
||||
@ -219,8 +226,11 @@ AcpiView (
|
||||
// Search the table for an entry that matches the ACPI Table Guid
|
||||
FoundAcpiTable = FALSE;
|
||||
for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
|
||||
if (CompareGuid (&gEfiAcpiTableGuid,
|
||||
&(SystemTable->ConfigurationTable[Index].VendorGuid))) {
|
||||
if (CompareGuid (
|
||||
&gEfiAcpiTableGuid,
|
||||
&(SystemTable->ConfigurationTable[Index].VendorGuid)
|
||||
))
|
||||
{
|
||||
EfiConfigurationTable = &SystemTable->ConfigurationTable[Index];
|
||||
FoundAcpiTable = TRUE;
|
||||
break;
|
||||
@ -244,6 +254,7 @@ AcpiView (
|
||||
if (GetMandatoryTableValidate ()) {
|
||||
ArmSbbrResetTableCounts ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// The RSDP length is 4 bytes starting at offset 20
|
||||
@ -265,7 +276,6 @@ AcpiView (
|
||||
RsdpLength,
|
||||
RsdpRevision
|
||||
);
|
||||
|
||||
} else {
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
@ -278,16 +288,19 @@ AcpiView (
|
||||
if (GetMandatoryTableValidate ()) {
|
||||
ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ReportOption = GetReportOption ();
|
||||
if (ReportTableList != ReportOption) {
|
||||
if (((ReportSelected == ReportOption) ||
|
||||
(ReportDumpBinFile == ReportOption)) &&
|
||||
(!SelectedTable->Found)) {
|
||||
(!SelectedTable->Found))
|
||||
{
|
||||
Print (L"\nRequested ACPI Table not found.\n");
|
||||
} else if (GetConsistencyChecking () &&
|
||||
(ReportDumpBinFile != ReportOption)) {
|
||||
(ReportDumpBinFile != ReportOption))
|
||||
{
|
||||
OriginalAttribute = gST->ConOut->Mode->Attribute;
|
||||
|
||||
Print (L"\nTable Statistics:\n");
|
||||
@ -301,6 +314,7 @@ AcpiView (
|
||||
OriginalAttribute;
|
||||
gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
|
||||
}
|
||||
|
||||
Print (L"\t%d Error(s)\n", GetErrorCount ());
|
||||
|
||||
if (GetColourHighlighting ()) {
|
||||
@ -313,6 +327,7 @@ AcpiView (
|
||||
|
||||
gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
|
||||
}
|
||||
|
||||
Print (L"\t%d Warning(s)\n", GetWarningCount ());
|
||||
|
||||
if (GetColourHighlighting ()) {
|
||||
@ -320,5 +335,6 @@ AcpiView (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -60,13 +60,15 @@ ConvertStrToAcpiSignature (
|
||||
|
||||
// Convert to Upper case and convert to ASCII
|
||||
while ((Index < 4) && (Str[Index] != 0)) {
|
||||
if (Str[Index] >= L'a' && Str[Index] <= L'z') {
|
||||
if ((Str[Index] >= L'a') && (Str[Index] <= L'z')) {
|
||||
Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
|
||||
} else {
|
||||
Ptr[Index] = (CHAR8)Str[Index];
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
|
||||
return *(UINT32 *)Ptr;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,8 @@ ArmSbbrReqsValidate (
|
||||
// Locate the instance count for the table with the given signature
|
||||
Index = 0;
|
||||
while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) &&
|
||||
(ArmSbbrTableCounts[Index].Signature != MandatoryTable)) {
|
||||
(ArmSbbrTableCounts[Index].Signature != MandatoryTable))
|
||||
{
|
||||
Index++;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,10 @@ ValidateProcessorFlags (
|
||||
// field must be set to 0 and ignored.
|
||||
if (((*Ptr & 0x3) != 0) && (*ProcessorId != 0)) {
|
||||
IncrementErrorCount ();
|
||||
Print (L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
|
||||
L" or shared nodes.");
|
||||
Print (
|
||||
L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
|
||||
L" or shared nodes."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,7 +339,8 @@ DumpProcessorNode (
|
||||
// successfully read.
|
||||
if ((ProcessorId == NULL) ||
|
||||
(ProcessorResourceType == NULL) ||
|
||||
(ProcessorFlags == NULL)) {
|
||||
(ProcessorFlags == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient Processor Error Node length. Length = %d.\n",
|
||||
@ -716,7 +719,8 @@ ParseAcpiAest (
|
||||
(NodeDataOffset == NULL) ||
|
||||
(NodeInterfaceOffset == NULL) ||
|
||||
(NodeInterruptArrayOffset == NULL) ||
|
||||
(NodeInterruptCount == NULL)) {
|
||||
(NodeInterruptCount == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient length left for Node Structure.\n" \
|
||||
@ -728,7 +732,8 @@ ParseAcpiAest (
|
||||
|
||||
// Validate AEST Node length
|
||||
if ((*AestNodeLength == 0) ||
|
||||
((Offset + (*AestNodeLength)) > AcpiTableLength)) {
|
||||
((Offset + (*AestNodeLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid AEST Node length. " \
|
||||
|
@ -131,7 +131,8 @@ DumpDbgDeviceInfo (
|
||||
(OEMDataLength == NULL) ||
|
||||
(OEMDataOffset == NULL) ||
|
||||
(BaseAddrRegOffset == NULL) ||
|
||||
(AddrSizeOffset == NULL)) {
|
||||
(AddrSizeOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient Debug Device Information Structure length. " \
|
||||
@ -145,7 +146,8 @@ DumpDbgDeviceInfo (
|
||||
Index = 0;
|
||||
Offset = *BaseAddrRegOffset;
|
||||
while ((Index++ < *GasCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
PrintFieldName (4, L"BaseAddressRegister");
|
||||
Offset += (UINT16)DumpGasStruct (
|
||||
Ptr + Offset,
|
||||
@ -171,7 +173,8 @@ DumpDbgDeviceInfo (
|
||||
Index = 0;
|
||||
Offset = *AddrSizeOffset;
|
||||
while ((Index++ < *GasCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
PrintFieldName (4, L"Address Size");
|
||||
Print (L"0x%x\n", *((UINT32 *)(Ptr + Offset)));
|
||||
Offset += sizeof (UINT32);
|
||||
@ -182,10 +185,12 @@ DumpDbgDeviceInfo (
|
||||
Offset = *NameSpaceStringOffset;
|
||||
PrintFieldName (4, L"NameSpace String");
|
||||
while ((Index++ < *NameSpaceStringLength) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
Print (L"%c", *(Ptr + Offset));
|
||||
Offset++;
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
|
||||
// OEM Data
|
||||
@ -194,13 +199,16 @@ DumpDbgDeviceInfo (
|
||||
Offset = *OEMDataOffset;
|
||||
PrintFieldName (4, L"OEM Data");
|
||||
while ((Index++ < *OEMDataLength) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
Print (L"%x ", *(Ptr + Offset));
|
||||
if ((Index & 7) == 0) {
|
||||
Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L"");
|
||||
}
|
||||
|
||||
Offset++;
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
}
|
||||
}
|
||||
@ -245,7 +253,8 @@ ParseAcpiDbg2 (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((OffsetDbgDeviceInfo == NULL) ||
|
||||
(NumberDbgDeviceInfo == NULL)) {
|
||||
(NumberDbgDeviceInfo == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient table length. AcpiTableLength = %d\n",
|
||||
@ -258,7 +267,6 @@ ParseAcpiDbg2 (
|
||||
Index = 0;
|
||||
|
||||
while (Index++ < *NumberDbgDeviceInfo) {
|
||||
|
||||
// Parse the Debug Device Information Structure header to obtain Length
|
||||
ParseAcpi (
|
||||
FALSE,
|
||||
@ -284,7 +292,8 @@ ParseAcpiDbg2 (
|
||||
|
||||
// Validate Debug Device Information Structure length
|
||||
if ((*DbgDevInfoLen == 0) ||
|
||||
((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) {
|
||||
((Offset + (*DbgDevInfoLen)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Debug Device Information Structure length. " \
|
||||
|
@ -74,6 +74,7 @@ ValidateFirmwareCtrl (
|
||||
L"\nERROR: Firmware Control must be zero for ARM platforms."
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -99,6 +100,7 @@ ValidateXFirmwareCtrl (
|
||||
L"\nERROR: X Firmware Control must be zero for ARM platforms."
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -124,6 +126,7 @@ ValidateFlags (
|
||||
L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms."
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -255,10 +258,13 @@ ParseAcpiFadt (
|
||||
// present.
|
||||
if ((Trace) &&
|
||||
(Flags != NULL) &&
|
||||
((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI)) {
|
||||
((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (L"ERROR: No FACS table found, "
|
||||
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n");
|
||||
Print (
|
||||
L"ERROR: No FACS table found, "
|
||||
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,6 +317,7 @@ ParseAcpiFadt (
|
||||
IncrementErrorCount ();
|
||||
Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -193,7 +193,8 @@ DumpGTBlock (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((GtBlockTimerCount == NULL) ||
|
||||
(GtBlockTimerOffset == NULL)) {
|
||||
(GtBlockTimerOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient GT Block Structure length. Length = %d.\n",
|
||||
@ -208,7 +209,8 @@ DumpGTBlock (
|
||||
// Parse the specified number of GT Block Timer Structures or the GT Block
|
||||
// Structure buffer length. Whichever is minimum.
|
||||
while ((Index++ < *GtBlockTimerCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
Offset += ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -288,7 +290,8 @@ ParseAcpiGtdt (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((GtdtPlatformTimerCount == NULL) ||
|
||||
(GtdtPlatformTimerOffset == NULL)) {
|
||||
(GtdtPlatformTimerOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
|
||||
@ -304,7 +307,8 @@ ParseAcpiGtdt (
|
||||
// Parse the specified number of Platform Timer Structures or the GTDT
|
||||
// buffer length. Whichever is minimum.
|
||||
while ((Index++ < *GtdtPlatformTimerCount) &&
|
||||
(Offset < AcpiTableLength)) {
|
||||
(Offset < AcpiTableLength))
|
||||
{
|
||||
// Parse the Platform Timer Header to obtain Length and Type
|
||||
ParseAcpi (
|
||||
FALSE,
|
||||
@ -318,7 +322,8 @@ ParseAcpiGtdt (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((PlatformTimerType == NULL) ||
|
||||
(PlatformTimerLength == NULL)) {
|
||||
(PlatformTimerLength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -330,7 +335,8 @@ ParseAcpiGtdt (
|
||||
|
||||
// Validate Platform Timer Structure length
|
||||
if ((*PlatformTimerLength == 0) ||
|
||||
((Offset + (*PlatformTimerLength)) > AcpiTableLength)) {
|
||||
((Offset + (*PlatformTimerLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Platform Timer Structure length. " \
|
||||
|
@ -78,6 +78,7 @@ ValidateCacheAttributes (
|
||||
Attributes->TotalCacheLevels
|
||||
);
|
||||
}
|
||||
|
||||
if (Attributes->CacheLevel > 0x3) {
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
@ -85,6 +86,7 @@ ValidateCacheAttributes (
|
||||
Attributes->CacheLevel
|
||||
);
|
||||
}
|
||||
|
||||
if (Attributes->CacheAssociativity > 0x2) {
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
@ -92,6 +94,7 @@ ValidateCacheAttributes (
|
||||
Attributes->CacheAssociativity
|
||||
);
|
||||
}
|
||||
|
||||
if (Attributes->WritePolicy > 0x2) {
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
@ -278,7 +281,8 @@ DumpSllbi (
|
||||
if ((SllbiFlags == NULL) ||
|
||||
(SllbiDataType == NULL) ||
|
||||
(NumberInitiatorProximityDomain == NULL) ||
|
||||
(NumberTargetProximityDomain == NULL)) {
|
||||
(NumberTargetProximityDomain == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -350,6 +354,7 @@ DumpSllbi (
|
||||
Print (L"Error: Unkown Data Type. DataType = 0x%x.\n", *SllbiDataType);
|
||||
return;
|
||||
}
|
||||
|
||||
StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]);
|
||||
|
||||
// Adjust base name depending on Memory Hierarchy in this Structure
|
||||
@ -381,7 +386,6 @@ DumpSllbi (
|
||||
SllbiFlags->MemoryHierarchy
|
||||
);
|
||||
return;
|
||||
|
||||
} // switch
|
||||
|
||||
if (*NumberTargetProximityDomain <= MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX) {
|
||||
@ -400,34 +404,41 @@ DumpSllbi (
|
||||
|
||||
for (IndexTarget = 0;
|
||||
IndexTarget < *NumberTargetProximityDomain;
|
||||
IndexTarget++) {
|
||||
IndexTarget++)
|
||||
{
|
||||
Print (L" %2d", IndexTarget);
|
||||
}
|
||||
|
||||
Print (L"\n ---+");
|
||||
for (IndexTarget = 0;
|
||||
IndexTarget < *NumberTargetProximityDomain;
|
||||
IndexTarget++) {
|
||||
IndexTarget++)
|
||||
{
|
||||
Print (L"------");
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
|
||||
TargetStartOffset = 0;
|
||||
for (IndexInitiator = 0;
|
||||
IndexInitiator < *NumberInitiatorProximityDomain;
|
||||
IndexInitiator++) {
|
||||
IndexInitiator++)
|
||||
{
|
||||
Print (L" %2d |", IndexInitiator);
|
||||
for (IndexTarget = 0;
|
||||
IndexTarget < *NumberTargetProximityDomain;
|
||||
IndexTarget++) {
|
||||
IndexTarget++)
|
||||
{
|
||||
Print (
|
||||
L" %5d",
|
||||
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
|
||||
);
|
||||
} // for Target
|
||||
|
||||
Print (L"\n");
|
||||
TargetStartOffset += (*NumberTargetProximityDomain);
|
||||
} // for Initiator
|
||||
|
||||
Print (L"\n");
|
||||
} else {
|
||||
// Display the latency/bandwidth matrix as a list
|
||||
@ -441,10 +452,12 @@ DumpSllbi (
|
||||
TargetStartOffset = 0;
|
||||
for (IndexInitiator = 0;
|
||||
IndexInitiator < *NumberInitiatorProximityDomain;
|
||||
IndexInitiator++) {
|
||||
IndexInitiator++)
|
||||
{
|
||||
for (IndexTarget = 0;
|
||||
IndexTarget < *NumberTargetProximityDomain;
|
||||
IndexTarget++) {
|
||||
IndexTarget++)
|
||||
{
|
||||
UnicodeSPrint (
|
||||
SecondBuffer,
|
||||
sizeof (SecondBuffer),
|
||||
@ -459,6 +472,7 @@ DumpSllbi (
|
||||
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
|
||||
);
|
||||
} // for Target
|
||||
|
||||
TargetStartOffset += (*NumberTargetProximityDomain);
|
||||
} // for Initiator
|
||||
}
|
||||
@ -591,7 +605,8 @@ ParseAcpiHmat (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((HmatStructureType == NULL) ||
|
||||
(HmatStructureLength == NULL)) {
|
||||
(HmatStructureLength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -603,7 +618,8 @@ ParseAcpiHmat (
|
||||
|
||||
// Validate HMAT Structure length.
|
||||
if ((*HmatStructureLength == 0) ||
|
||||
((Offset + (*HmatStructureLength)) > AcpiTableLength)) {
|
||||
((Offset + (*HmatStructureLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid HMAT Structure length. " \
|
||||
|
@ -273,7 +273,8 @@ DumpIortNodeIdMappings (
|
||||
Offset = 0;
|
||||
|
||||
while ((Index < MappingCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
@ -328,7 +329,8 @@ DumpIortNodeSmmuV1V2 (
|
||||
if ((InterruptContextCount == NULL) ||
|
||||
(InterruptContextOffset == NULL) ||
|
||||
(PmuInterruptCount == NULL) ||
|
||||
(PmuInterruptOffset == NULL)) {
|
||||
(PmuInterruptOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient SMMUv1/2 node length. Length = %d\n",
|
||||
@ -341,7 +343,8 @@ DumpIortNodeSmmuV1V2 (
|
||||
Index = 0;
|
||||
|
||||
while ((Index < *InterruptContextCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
@ -363,7 +366,8 @@ DumpIortNodeSmmuV1V2 (
|
||||
Index = 0;
|
||||
|
||||
while ((Index < *PmuInterruptCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
@ -462,7 +466,8 @@ DumpIortNodeIts (
|
||||
Index = 0;
|
||||
|
||||
while ((Index < *ItsCount) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
@ -481,7 +486,6 @@ DumpIortNodeIts (
|
||||
}
|
||||
|
||||
// Note: ITS does not have the ID Mappings Array
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,10 +521,12 @@ DumpIortNodeNamedComponent (
|
||||
PrintFieldName (2, L"Device Object Name");
|
||||
|
||||
while ((*(Ptr + Offset) != 0) &&
|
||||
(Offset < Length)) {
|
||||
(Offset < Length))
|
||||
{
|
||||
Print (L"%c", *(Ptr + Offset));
|
||||
Offset++;
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
|
||||
DumpIortNodeIdMappings (
|
||||
@ -646,7 +652,8 @@ ParseAcpiIort (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((IortNodeCount == NULL) ||
|
||||
(IortNodeOffset == NULL)) {
|
||||
(IortNodeOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
|
||||
@ -662,7 +669,8 @@ ParseAcpiIort (
|
||||
// Parse the specified number of IORT nodes or the IORT table buffer length.
|
||||
// Whichever is minimum.
|
||||
while ((Index++ < *IortNodeCount) &&
|
||||
(Offset < AcpiTableLength)) {
|
||||
(Offset < AcpiTableLength))
|
||||
{
|
||||
// Parse the IORT Node Header
|
||||
ParseAcpi (
|
||||
FALSE,
|
||||
@ -678,7 +686,8 @@ ParseAcpiIort (
|
||||
if ((IortNodeType == NULL) ||
|
||||
(IortNodeLength == NULL) ||
|
||||
(IortIdMappingCount == NULL) ||
|
||||
(IortIdMappingOffset == NULL)) {
|
||||
(IortIdMappingOffset == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -690,7 +699,8 @@ ParseAcpiIort (
|
||||
|
||||
// Validate IORT Node length
|
||||
if ((*IortNodeLength == 0) ||
|
||||
((Offset + (*IortNodeLength)) > AcpiTableLength)) {
|
||||
((Offset + (*IortNodeLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid IORT Node length. " \
|
||||
|
@ -73,7 +73,8 @@ ValidateSpeOverflowInterrupt (
|
||||
if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) ||
|
||||
((SpeOverflowInterrupt > ARM_PPI_ID_MAX) &&
|
||||
(SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
|
||||
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) {
|
||||
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
|
||||
@ -205,7 +206,6 @@ STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
|
||||
{ L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
An ACPI_PARSER array describing the Processor Local x2APIC Structure.
|
||||
**/
|
||||
@ -315,7 +315,8 @@ ParseAcpiMadt (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((MadtInterruptControllerType == NULL) ||
|
||||
(MadtInterruptControllerLength == NULL)) {
|
||||
(MadtInterruptControllerLength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -327,7 +328,8 @@ ParseAcpiMadt (
|
||||
|
||||
// Validate Interrupt Controller Structure length
|
||||
if ((*MadtInterruptControllerLength == 0) ||
|
||||
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) {
|
||||
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Interrupt Controller Structure length. " \
|
||||
@ -340,7 +342,8 @@ ParseAcpiMadt (
|
||||
}
|
||||
|
||||
switch (*MadtInterruptControllerType) {
|
||||
case EFI_ACPI_6_3_GIC: {
|
||||
case EFI_ACPI_6_3_GIC:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -352,7 +355,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_GICD: {
|
||||
case EFI_ACPI_6_3_GICD:
|
||||
{
|
||||
if (++GICDCount > 1) {
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
@ -361,6 +365,7 @@ ParseAcpiMadt (
|
||||
GICDCount
|
||||
);
|
||||
}
|
||||
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -372,7 +377,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_GIC_MSI_FRAME: {
|
||||
case EFI_ACPI_6_3_GIC_MSI_FRAME:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -384,7 +390,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_GICR: {
|
||||
case EFI_ACPI_6_3_GICR:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -396,7 +403,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_GIC_ITS: {
|
||||
case EFI_ACPI_6_3_GIC_ITS:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -408,7 +416,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_IO_APIC: {
|
||||
case EFI_ACPI_6_3_IO_APIC:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -420,7 +429,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE: {
|
||||
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -432,7 +442,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC: {
|
||||
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -444,7 +455,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI: {
|
||||
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI:
|
||||
{
|
||||
ParseAcpi (
|
||||
TRUE,
|
||||
2,
|
||||
@ -456,7 +468,8 @@ ParseAcpiMadt (
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Unknown Interrupt Controller Structure,"
|
||||
|
@ -152,7 +152,8 @@ ValidatePccDoorbellGas (
|
||||
if (IsZeroBuffer (
|
||||
Ptr,
|
||||
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
|
||||
)) {
|
||||
))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -184,11 +185,13 @@ ValidatePccIntAckGas (
|
||||
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
|
||||
((*ExtendedPccSubspaceInterruptFlags &
|
||||
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
|
||||
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE)) {
|
||||
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE))
|
||||
{
|
||||
if (IsZeroBuffer (
|
||||
Ptr,
|
||||
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
|
||||
)) {
|
||||
))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -238,7 +241,8 @@ ValidatePlatInterrupt (
|
||||
// Interrupt flag must be set to 1.
|
||||
if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
|
||||
((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
|
||||
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT)) {
|
||||
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"\nError: Global Platform interrupt flag must be set to 1" \
|
||||
@ -584,7 +588,8 @@ ParseAcpiPcct (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((PccSubspaceType == NULL) ||
|
||||
(PccSubspaceLength == NULL)) {
|
||||
(PccSubspaceLength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -596,7 +601,8 @@ ParseAcpiPcct (
|
||||
|
||||
// Validate Structure length
|
||||
if ((*PccSubspaceLength == 0) ||
|
||||
((Offset + (*PccSubspaceLength)) > AcpiTableLength)) {
|
||||
((Offset + (*PccSubspaceLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Structure length. " \
|
||||
|
@ -39,6 +39,7 @@ ValidateCacheNumberOfSets (
|
||||
)
|
||||
{
|
||||
UINT32 NumberOfSets;
|
||||
|
||||
NumberOfSets = *(UINT32 *)Ptr;
|
||||
|
||||
if (NumberOfSets == 0) {
|
||||
@ -68,8 +69,8 @@ ValidateCacheNumberOfSets (
|
||||
);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +90,7 @@ ValidateCacheAssociativity (
|
||||
)
|
||||
{
|
||||
UINT8 Associativity;
|
||||
|
||||
Associativity = *(UINT8 *)Ptr;
|
||||
|
||||
if (Associativity == 0) {
|
||||
@ -123,7 +125,8 @@ ValidateCacheLineSize (
|
||||
LineSize = *(UINT16 *)Ptr;
|
||||
|
||||
if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) ||
|
||||
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) {
|
||||
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"\nERROR: The cache line size must be between %d and %d bytes"
|
||||
@ -138,6 +141,7 @@ ValidateCacheLineSize (
|
||||
IncrementErrorCount ();
|
||||
Print (L"\nERROR: The cache line size is not a power of 2.");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -160,6 +164,7 @@ ValidateCacheAttributes (
|
||||
// Version 6.2 Errata A, September 2017
|
||||
// Table 5-153: Cache Type Structure
|
||||
UINT8 Attributes;
|
||||
|
||||
Attributes = *(UINT8 *)Ptr;
|
||||
|
||||
if ((Attributes & 0xE0) != 0) {
|
||||
@ -416,7 +421,8 @@ ParseAcpiPptt (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((ProcessorTopologyStructureType == NULL) ||
|
||||
(ProcessorTopologyStructureLength == NULL)) {
|
||||
(ProcessorTopologyStructureLength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -428,7 +434,8 @@ ParseAcpiPptt (
|
||||
|
||||
// Validate Processor Topology Structure length
|
||||
if ((*ProcessorTopologyStructureLength == 0) ||
|
||||
((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)) {
|
||||
((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Processor Topology Structure length. " \
|
||||
|
@ -47,6 +47,7 @@ ValidateRsdtAddress (
|
||||
RsdtAddr
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -82,6 +83,7 @@ ValidateXsdtAddress (
|
||||
XsdtAddr
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -144,12 +144,14 @@ ParseAcpiSlit (
|
||||
for (Index = 0; Index < LocalityCount; Index++) {
|
||||
Print (L" (%3d) ", Index);
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
for (Count = 0; Count < LocalityCount; Count++) {
|
||||
Print (L" (%3d) ", Count);
|
||||
for (Index = 0; Index < LocalityCount; Index++) {
|
||||
Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index));
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
}
|
||||
}
|
||||
@ -168,9 +170,11 @@ ParseAcpiSlit (
|
||||
SLIT_ELEMENT (LocalityPtr, Count, Index)
|
||||
);
|
||||
}
|
||||
|
||||
// Element[i][j] must be equal to Element[j][i]
|
||||
if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
|
||||
SLIT_ELEMENT (LocalityPtr, Index, Count)) {
|
||||
SLIT_ELEMENT (LocalityPtr, Index, Count))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
|
||||
|
@ -39,13 +39,15 @@ ValidateInterruptType (
|
||||
InterruptType = *Ptr;
|
||||
|
||||
if (InterruptType !=
|
||||
EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
|
||||
EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC)
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
|
||||
InterruptType
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -76,6 +78,7 @@ ValidateIrq (
|
||||
Irq
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,8 @@ ParseAcpiSrat (
|
||||
// Check if the values used to control the parsing logic have been
|
||||
// successfully read.
|
||||
if ((SratRAType == NULL) ||
|
||||
(SratRALength == NULL)) {
|
||||
(SratRALength == NULL))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||
@ -415,7 +416,8 @@ ParseAcpiSrat (
|
||||
|
||||
// Validate Static Resource Allocation Structure length
|
||||
if ((*SratRALength == 0) ||
|
||||
((Offset + (*SratRALength)) > AcpiTableLength)) {
|
||||
((Offset + (*SratRALength)) > AcpiTableLength))
|
||||
{
|
||||
IncrementErrorCount ();
|
||||
Print (
|
||||
L"ERROR: Invalid Static Resource Allocation Structure length. " \
|
||||
|
@ -122,6 +122,7 @@ ParseAcpiXsdt (
|
||||
*TablePointer
|
||||
);
|
||||
}
|
||||
|
||||
Offset += sizeof (UINT64);
|
||||
TablePointer++;
|
||||
} // while
|
||||
@ -134,6 +135,7 @@ ParseAcpiXsdt (
|
||||
if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
|
||||
ProcessAcpiTable ((UINT8 *)(UINTN)(*TablePointer));
|
||||
}
|
||||
|
||||
Offset += sizeof (UINT64);
|
||||
TablePointer++;
|
||||
} // while
|
||||
|
@ -101,6 +101,7 @@ RegisterAllParsers (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -210,7 +211,7 @@ ShellCommandRunAcpiView (
|
||||
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -224,6 +225,7 @@ ShellCommandRunAcpiView (
|
||||
} else {
|
||||
Print (L"acpiview: Error processing input parameter(s)\n");
|
||||
}
|
||||
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (ShellCommandLineGetCount (Package) > 1) {
|
||||
@ -246,7 +248,8 @@ ShellCommandRunAcpiView (
|
||||
L"acpiview"
|
||||
);
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-s") &&
|
||||
ShellCommandLineGetValue (Package, L"-s") == NULL) {
|
||||
(ShellCommandLineGetValue (Package, L"-s") == NULL))
|
||||
{
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -258,7 +261,8 @@ ShellCommandRunAcpiView (
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-r") &&
|
||||
ShellCommandLineGetValue (Package, L"-r") == NULL) {
|
||||
(ShellCommandLineGetValue (Package, L"-r") == NULL))
|
||||
{
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -270,7 +274,8 @@ ShellCommandRunAcpiView (
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if ((ShellCommandLineGetFlag (Package, L"-s") &&
|
||||
ShellCommandLineGetFlag (Package, L"-l"))) {
|
||||
ShellCommandLineGetFlag (Package, L"-l")))
|
||||
{
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -281,7 +286,8 @@ ShellCommandRunAcpiView (
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-d") &&
|
||||
!ShellCommandLineGetFlag (Package, L"-s")) {
|
||||
!ShellCommandLineGetFlag (Package, L"-s"))
|
||||
{
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -349,6 +355,7 @@ ShellCommandRunAcpiView (
|
||||
);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
// Delete Temporary file.
|
||||
ShellDeleteFile (&TmpDumpFileHandle);
|
||||
} // -d
|
||||
@ -367,6 +374,7 @@ Done:
|
||||
if (Package != NULL) {
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return ShellStatus;
|
||||
}
|
||||
|
||||
@ -390,6 +398,7 @@ UefiShellAcpiViewCommandLibConstructor (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
gShellAcpiViewHiiHandle = NULL;
|
||||
|
||||
// Check Shell Profile Debug1 bit of the profiles mask
|
||||
@ -412,6 +421,7 @@ UefiShellAcpiViewCommandLibConstructor (
|
||||
if (gShellAcpiViewHiiHandle == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// Install our Shell command handler
|
||||
ShellCommandRegisterCommandName (
|
||||
L"acpiview",
|
||||
@ -443,5 +453,6 @@ UefiShellAcpiViewCommandLibDestructor (
|
||||
if (gShellAcpiViewHiiHandle != NULL) {
|
||||
HiiRemovePackages (gShellAcpiViewHiiHandle);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
@ -114,18 +113,21 @@ UpdateOptionalData(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&OriginalSize,
|
||||
OriginalData);
|
||||
OriginalData
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
OriginalData = AllocateZeroPool (OriginalSize);
|
||||
if (OriginalData == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
Status = gRT->GetVariable (
|
||||
VariableName,
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&OriginalSize,
|
||||
OriginalData);
|
||||
OriginalData
|
||||
);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -155,7 +157,8 @@ UpdateOptionalData(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
NewSize,
|
||||
NewData);
|
||||
NewData
|
||||
);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (OriginalData);
|
||||
@ -195,7 +198,8 @@ GetBootOptionCrc(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
Buffer = AllocateZeroPool (BufferSize);
|
||||
Status = gRT->GetVariable (
|
||||
@ -203,7 +207,8 @@ GetBootOptionCrc(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer);
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@ -263,14 +268,18 @@ GetDevicePathForDriverHandle (
|
||||
LoadedImage->DeviceHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
gImageHandle,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
TheHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
gImageHandle,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
@ -323,11 +332,12 @@ GetDevicePathByHandle(
|
||||
|
||||
Status = gBS->HandleProtocol (TheHandle, &gEfiDevicePathProtocolGuid, (VOID **)DevicePath);
|
||||
|
||||
if ( DriverBindingHandleCount > 0 ||
|
||||
ParentControllerHandleCount > 0 ||
|
||||
ChildControllerHandleCount > 0 ||
|
||||
if ((DriverBindingHandleCount > 0) ||
|
||||
(ParentControllerHandleCount > 0) ||
|
||||
(ChildControllerHandleCount > 0) ||
|
||||
!EFI_ERROR (Status)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// The handle points to a real controller which has a device path.
|
||||
//
|
||||
@ -335,7 +345,8 @@ GetDevicePathByHandle(
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PARAM_INV),
|
||||
gShellBcfgHiiHandle,
|
||||
L"bcfg",
|
||||
L"Handle should point to driver image."
|
||||
@ -401,12 +412,13 @@ BcfgMod (
|
||||
|
||||
ZeroMem (&LoadOption, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
|
||||
|
||||
if ( (BcfgOperation->Type == BcfgTypeMod && BcfgOperation->Description == NULL) ||
|
||||
(BcfgOperation->Type == BcfgTypeModf && BcfgOperation->FileName == NULL) ||
|
||||
(BcfgOperation->Type == BcfgTypeModp && BcfgOperation->FileName == NULL) ||
|
||||
(BcfgOperation->Type == BcfgTypeModh && BcfgOperation->HandleIndex == 0) ||
|
||||
if (((BcfgOperation->Type == BcfgTypeMod) && (BcfgOperation->Description == NULL)) ||
|
||||
((BcfgOperation->Type == BcfgTypeModf) && (BcfgOperation->FileName == NULL)) ||
|
||||
((BcfgOperation->Type == BcfgTypeModp) && (BcfgOperation->FileName == NULL)) ||
|
||||
((BcfgOperation->Type == BcfgTypeModh) && (BcfgOperation->HandleIndex == 0)) ||
|
||||
(BcfgOperation->Number1 > OrderCount)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@ -416,7 +428,7 @@ BcfgMod (
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
DevicePath = DuplicateDevicePath (DevicePathBuffer);
|
||||
}
|
||||
} else if (BcfgOperation->Type == BcfgTypeModf || BcfgOperation->Type == BcfgTypeModp) {
|
||||
} else if ((BcfgOperation->Type == BcfgTypeModf) || (BcfgOperation->Type == BcfgTypeModp)) {
|
||||
//
|
||||
// Get Device Path by FileName.
|
||||
//
|
||||
@ -427,8 +439,7 @@ BcfgMod (
|
||||
//
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellBcfgHiiHandle, L"bcfg", BcfgOperation->FileName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
else if (FileList->Link.ForwardLink != FileList->Link.BackLink) {
|
||||
} else if (FileList->Link.ForwardLink != FileList->Link.BackLink) {
|
||||
//
|
||||
// If the name of file expanded to multiple names, it's fail.
|
||||
//
|
||||
@ -453,9 +464,10 @@ BcfgMod (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
DevicePathWalker = DevicePathBuffer;
|
||||
while (!IsDevicePathEnd (DevicePathWalker)) {
|
||||
if ( DevicePathType (DevicePathWalker) == MEDIA_DEVICE_PATH &&
|
||||
DevicePathSubType (DevicePathWalker) == MEDIA_HARDDRIVE_DP
|
||||
) {
|
||||
if ((DevicePathType (DevicePathWalker) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType (DevicePathWalker) == MEDIA_HARDDRIVE_DP)
|
||||
)
|
||||
{
|
||||
//
|
||||
// We found the portion of device path starting with the hard driver partition.
|
||||
//
|
||||
@ -480,6 +492,7 @@ BcfgMod (
|
||||
} else {
|
||||
UnicodeSPrint (OptionStr, sizeof (OptionStr), L"Driver%04x", BcfgOperation->Order[BcfgOperation->Number1]);
|
||||
}
|
||||
|
||||
Status = EfiBootManagerVariableToLoadOption (OptionStr, &LoadOption);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_NONE), gShellBcfgHiiHandle);
|
||||
@ -568,7 +581,7 @@ BcfgAdd(
|
||||
UINT16 *NewOrder;
|
||||
|
||||
if (!UseHandle) {
|
||||
if (File == NULL || Desc == NULL) {
|
||||
if ((File == NULL) || (Desc == NULL)) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
} else {
|
||||
@ -601,27 +614,33 @@ BcfgAdd(
|
||||
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
|
||||
CurHandle,
|
||||
&DriverBindingHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
Status = PARSE_HANDLE_DATABASE_PARENTS (
|
||||
CurHandle,
|
||||
&ParentControllerHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
Status = ParseHandleDatabaseForChildControllers (
|
||||
CurHandle,
|
||||
&ChildControllerHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
if (DriverBindingHandleCount > 0
|
||||
|| ParentControllerHandleCount > 0
|
||||
|| ChildControllerHandleCount > 0) {
|
||||
if ( (DriverBindingHandleCount > 0)
|
||||
|| (ParentControllerHandleCount > 0)
|
||||
|| (ChildControllerHandleCount > 0))
|
||||
{
|
||||
FilePath = NULL;
|
||||
Status = gBS->HandleProtocol (
|
||||
CurHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID**)&FilePath);
|
||||
(VOID **)&FilePath
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellBcfgHiiHandle, L"bcfg", HandleNumber);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -633,27 +652,32 @@ BcfgAdd(
|
||||
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
|
||||
CurHandle,
|
||||
&DriverBindingHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
Status = PARSE_HANDLE_DATABASE_PARENTS (
|
||||
CurHandle,
|
||||
&ParentControllerHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
Status = ParseHandleDatabaseForChildControllers (
|
||||
CurHandle,
|
||||
&ChildControllerHandleCount,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
CurHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID**)&FilePath);
|
||||
(VOID **)&FilePath
|
||||
);
|
||||
|
||||
if (DriverBindingHandleCount > 0
|
||||
|| ParentControllerHandleCount > 0
|
||||
|| ChildControllerHandleCount > 0
|
||||
|| !EFI_ERROR(Status) ) {
|
||||
if ( (DriverBindingHandleCount > 0)
|
||||
|| (ParentControllerHandleCount > 0)
|
||||
|| (ChildControllerHandleCount > 0)
|
||||
|| !EFI_ERROR (Status))
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Handle Number");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -705,8 +729,8 @@ BcfgAdd(
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
while (!IsDevicePathEnd (DevPath)) {
|
||||
if ((DevicePathType (DevPath) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {
|
||||
|
||||
(DevicePathSubType (DevPath) == MEDIA_HARDDRIVE_DP))
|
||||
{
|
||||
//
|
||||
// If we find it use it instead
|
||||
//
|
||||
@ -714,18 +738,19 @@ BcfgAdd(
|
||||
FilePath = DuplicateDevicePath (DevPath);
|
||||
break;
|
||||
}
|
||||
|
||||
DevPath = NextDevicePathNode (DevPath);
|
||||
}
|
||||
} else {
|
||||
FilePath = DuplicateDevicePath (DevicePath);
|
||||
}
|
||||
|
||||
FreePool (DevicePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
//
|
||||
// Find a free target ,a brute force implementation
|
||||
@ -825,7 +850,7 @@ BcfgAdd(
|
||||
//
|
||||
// If always Free FilePath, will free devicepath in system when use "addh"
|
||||
//
|
||||
if (FilePath!=NULL && !UseHandle) {
|
||||
if ((FilePath != NULL) && !UseHandle) {
|
||||
FreePool (FilePath);
|
||||
}
|
||||
|
||||
@ -874,11 +899,13 @@ BcfgRemove(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
0,
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
NewOrder = AllocateZeroPool (OrderCount*sizeof (CurrentOrder[0]));
|
||||
if (NewOrder != NULL) {
|
||||
NewCount = OrderCount;
|
||||
@ -891,15 +918,18 @@ BcfgRemove(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
NewCount*sizeof (NewOrder[0]),
|
||||
NewOrder);
|
||||
NewOrder
|
||||
);
|
||||
FreePool (NewOrder);
|
||||
} else {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", Target == BcfgTargetBootOrder ? (CHAR16 *)L"BootOrder" : (CHAR16 *)L"DriverOrder");
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
@ -954,7 +984,8 @@ BcfgMove(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
OrderCount*sizeof (CurrentOrder[0]),
|
||||
NewOrder);
|
||||
NewOrder
|
||||
);
|
||||
|
||||
FreePool (NewOrder);
|
||||
|
||||
@ -962,6 +993,7 @@ BcfgMove(
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", Target == BcfgTargetBootOrder ? (CHAR16 *)L"BootOrder" : (CHAR16 *)L"DriverOrder");
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
@ -1020,17 +1052,19 @@ BcfgAddOpt(
|
||||
// Get the index of the variable we are changing.
|
||||
//
|
||||
Status = ShellConvertStringToUint64 (Walker, &Intermediate, TRUE, TRUE);
|
||||
if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL || ((UINT16)Intermediate) > ((UINT16)OrderCount)) {
|
||||
if (EFI_ERROR (Status) || (((UINT16)Intermediate) != Intermediate) || (StrStr (Walker, L" ") == NULL) || (((UINT16)Intermediate) > ((UINT16)OrderCount))) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Option Index");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
OptionIndex = (UINT16)Intermediate;
|
||||
|
||||
Temp = StrStr (Walker, L" ");
|
||||
if (Temp != NULL) {
|
||||
Walker = Temp;
|
||||
}
|
||||
|
||||
while (Walker[0] == L' ') {
|
||||
Walker++;
|
||||
}
|
||||
@ -1043,7 +1077,7 @@ BcfgAddOpt(
|
||||
// quoted filename or quoted information.
|
||||
//
|
||||
Temp = StrStr (Walker+1, L"\"");
|
||||
if (Temp == NULL || StrLen(Temp) != 1) {
|
||||
if ((Temp == NULL) || (StrLen (Temp) != 1)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1053,6 +1087,7 @@ BcfgAddOpt(
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
Temp2 = StrStr (FileName, L"\"");
|
||||
ASSERT (Temp2 != NULL);
|
||||
Temp2[0] = CHAR_NULL;
|
||||
@ -1061,6 +1096,7 @@ BcfgAddOpt(
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (ShellFileExists (Walker))) {
|
||||
//
|
||||
// Not a file. must be misc information.
|
||||
@ -1096,15 +1132,17 @@ BcfgAddOpt(
|
||||
// Get hot key information
|
||||
//
|
||||
Status = ShellConvertStringToUint64 (Walker, &Intermediate, FALSE, TRUE);
|
||||
if (EFI_ERROR(Status) || (((UINT32)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL) {
|
||||
if (EFI_ERROR (Status) || (((UINT32)Intermediate) != Intermediate) || (StrStr (Walker, L" ") == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate;
|
||||
Temp = StrStr (Walker, L" ");
|
||||
if (Temp != NULL) {
|
||||
Walker = Temp;
|
||||
}
|
||||
|
||||
while (Walker[0] == L' ') {
|
||||
Walker++;
|
||||
}
|
||||
@ -1121,22 +1159,26 @@ BcfgAddOpt(
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
return ShellStatus;
|
||||
}
|
||||
|
||||
CopyMem (KeyOptionBuffer, &NewKeyOption, sizeof (EFI_KEY_OPTION));
|
||||
}
|
||||
|
||||
for (LoopCounter = 0; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
|
||||
//
|
||||
// ScanCode
|
||||
//
|
||||
Status = ShellConvertStringToUint64 (Walker, &Intermediate, FALSE, TRUE);
|
||||
if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL) {
|
||||
if (EFI_ERROR (Status) || (((UINT16)Intermediate) != Intermediate) || (StrStr (Walker, L" ") == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
((EFI_INPUT_KEY *)(((UINT8 *)KeyOptionBuffer) + sizeof (EFI_KEY_OPTION)))[LoopCounter].ScanCode = (UINT16)Intermediate;
|
||||
Temp = StrStr (Walker, L" ");
|
||||
if (Temp != NULL) {
|
||||
Walker = Temp;
|
||||
}
|
||||
|
||||
while (Walker[0] == L' ') {
|
||||
Walker++;
|
||||
}
|
||||
@ -1149,11 +1191,13 @@ BcfgAddOpt(
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
((EFI_INPUT_KEY *)(((UINT8 *)KeyOptionBuffer) + sizeof (EFI_KEY_OPTION)))[LoopCounter].UnicodeChar = (UINT16)Intermediate;
|
||||
Temp = StrStr (Walker, L" ");
|
||||
if (Temp != NULL) {
|
||||
Walker = Temp;
|
||||
}
|
||||
|
||||
while (Walker[0] == L' ') {
|
||||
Walker++;
|
||||
}
|
||||
@ -1179,17 +1223,20 @@ BcfgAddOpt(
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SHELL_FREE_NON_NULL (VariableData);
|
||||
}
|
||||
}
|
||||
|
||||
if (KeyIndex <= 0xFFFF) {
|
||||
Status = gRT->SetVariable (
|
||||
VariableName,
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof (EFI_KEY_OPTION) + (sizeof (EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
|
||||
KeyOptionBuffer);
|
||||
KeyOptionBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -1198,6 +1245,7 @@ BcfgAddOpt(
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_VAR_NO_NUM), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ASSERT (FileName == NULL && Data == NULL);
|
||||
}
|
||||
}
|
||||
@ -1208,7 +1256,7 @@ BcfgAddOpt(
|
||||
//
|
||||
ASSERT (FileName == NULL || Data == NULL);
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS && (FileName != NULL || Data != NULL)) {
|
||||
if ((ShellStatus == SHELL_SUCCESS) && ((FileName != NULL) || (Data != NULL))) {
|
||||
if (FileName != NULL) {
|
||||
//
|
||||
// Open the file and populate the data buffer.
|
||||
@ -1217,15 +1265,18 @@ BcfgAddOpt(
|
||||
FileName,
|
||||
&FileHandle,
|
||||
EFI_FILE_MODE_READ,
|
||||
0);
|
||||
0
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = ShellGetFileSize (FileHandle, &Intermediate);
|
||||
}
|
||||
|
||||
Data = AllocateZeroPool ((UINTN)Intermediate);
|
||||
if (Data == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = ShellReadFile (FileHandle, (UINTN *)&Intermediate, Data);
|
||||
}
|
||||
@ -1233,14 +1284,15 @@ BcfgAddOpt(
|
||||
Intermediate = StrSize (Data);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS && Data != NULL) {
|
||||
if (!EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS) && (Data != NULL)) {
|
||||
Status = UpdateOptionalData (CurrentOrder[OptionIndex], (UINTN)Intermediate, (UINT8 *)Data, Target);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
|
||||
|
||||
if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -1303,7 +1355,8 @@ BcfgDisplayDump(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer);
|
||||
Buffer
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
Buffer = AllocateZeroPool (BufferSize);
|
||||
Status = gRT->GetVariable (
|
||||
@ -1311,10 +1364,11 @@ BcfgDisplayDump(
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer);
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status) || Buffer == NULL) {
|
||||
if (EFI_ERROR (Status) || (Buffer == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_READ_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
|
||||
++Errors;
|
||||
goto Cleanup;
|
||||
@ -1375,10 +1429,12 @@ Cleanup:
|
||||
if (Buffer != NULL) {
|
||||
FreePool (Buffer);
|
||||
}
|
||||
|
||||
if (DevPathString != NULL) {
|
||||
FreePool (DevPathString);
|
||||
}
|
||||
}
|
||||
|
||||
return (Errors > 0) ? SHELL_INVALID_PARAMETER : SHELL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1404,7 +1460,6 @@ InitBcfgStruct(
|
||||
Struct->OptData = NULL;
|
||||
}
|
||||
|
||||
|
||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
{ L"-v", TypeFlag },
|
||||
{ L"-opt", TypeMaxValue },
|
||||
@ -1456,7 +1511,7 @@ ShellCommandRunBcfg (
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellBcfgHiiHandle, L"bcfg", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -1473,15 +1528,17 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellBcfgHiiHandle, L"bcfg", L"-opt");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeOpt;
|
||||
}
|
||||
|
||||
//
|
||||
// small block to read the target of the operation
|
||||
//
|
||||
if ((ShellCommandLineGetCount(Package) < 3 && CurrentOperation.Type != BcfgTypeOpt) ||
|
||||
(ShellCommandLineGetCount(Package) < 2 && CurrentOperation.Type == BcfgTypeOpt)
|
||||
){
|
||||
if (((ShellCommandLineGetCount (Package) < 3) && (CurrentOperation.Type != BcfgTypeOpt)) ||
|
||||
((ShellCommandLineGetCount (Package) < 2) && (CurrentOperation.Type == BcfgTypeOpt))
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)ShellCommandLineGetRawValue (Package, 1), L"driver") == 0) {
|
||||
@ -1493,18 +1550,18 @@ ShellCommandRunBcfg (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Read in the boot or driver order environment variable (not needed for opt)
|
||||
//
|
||||
if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
|
||||
if ((ShellStatus == SHELL_SUCCESS) && (CurrentOperation.Target < BcfgTargetMax)) {
|
||||
Length = 0;
|
||||
Status = gRT->GetVariable (
|
||||
CurrentOperation.Target == BcfgTargetBootOrder ? (CHAR16 *)L"BootOrder" : (CHAR16 *)L"DriverOrder",
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&Length,
|
||||
CurrentOperation.Order);
|
||||
CurrentOperation.Order
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
CurrentOperation.Order = AllocateZeroPool (Length+(4*sizeof (CurrentOperation.Order[0])));
|
||||
if (CurrentOperation.Order == NULL) {
|
||||
@ -1515,7 +1572,8 @@ ShellCommandRunBcfg (
|
||||
(EFI_GUID *)&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&Length,
|
||||
CurrentOperation.Order);
|
||||
CurrentOperation.Order
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1525,7 +1583,7 @@ ShellCommandRunBcfg (
|
||||
//
|
||||
// large block to read the type of operation and verify parameter types for the info.
|
||||
//
|
||||
if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
|
||||
if ((ShellStatus == SHELL_SUCCESS) && (CurrentOperation.Target < BcfgTargetMax)) {
|
||||
for (ParamNumber = 2; ParamNumber < ShellCommandLineGetCount (Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) {
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ParamNumber);
|
||||
if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)CurrentParam, L"dump") == 0) {
|
||||
@ -1542,9 +1600,10 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeAdd;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1560,9 +1619,10 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeAddp;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1578,16 +1638,17 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeAddh;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64 (CurrentParam, &Intermediate, TRUE, FALSE);
|
||||
CurrentOperation.Number1 = (UINT16)Intermediate;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1602,9 +1663,10 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeRm;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1620,9 +1682,10 @@ ShellCommandRunBcfg (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentOperation.Type = BcfgTypeMv;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1633,30 +1696,31 @@ ShellCommandRunBcfg (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64 (CurrentParam, &Intermediate, TRUE, FALSE);
|
||||
CurrentOperation.Number2 = (UINT16)Intermediate;
|
||||
}
|
||||
if (CurrentOperation.Number2 == CurrentOperation.Number1
|
||||
||CurrentOperation.Number2 >= Count
|
||||
){
|
||||
|
||||
if ( (CurrentOperation.Number2 == CurrentOperation.Number1)
|
||||
|| (CurrentOperation.Number2 >= Count)
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellBcfgHiiHandle, L"bcfg", Count);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)CurrentParam, L"mod") == 0) {
|
||||
} else if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)CurrentParam, L"mod") == 0) {
|
||||
if ((ParamNumber + 2) >= ShellCommandLineGetCount (Package)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
CurrentOperation.Type = BcfgTypeMod;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1678,7 +1742,7 @@ ShellCommandRunBcfg (
|
||||
} else {
|
||||
CurrentOperation.Type = BcfgTypeModf;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1700,7 +1764,7 @@ ShellCommandRunBcfg (
|
||||
} else {
|
||||
CurrentOperation.Type = BcfgTypeModp;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1722,11 +1786,10 @@ ShellCommandRunBcfg (
|
||||
} else {
|
||||
CurrentOperation.Type = BcfgTypeModh;
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64 (CurrentParam, &Intermediate, TRUE, FALSE);
|
||||
CurrentOperation.Number1 = (UINT16)Intermediate;
|
||||
if (CurrentOperation.Number1 >= Count) {
|
||||
@ -1734,7 +1797,7 @@ ShellCommandRunBcfg (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
CurrentParam = ShellCommandLineGetRawValue (Package, ++ParamNumber);
|
||||
if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
if ((CurrentParam == NULL) || !ShellIsHexOrDecimalNumber (CurrentParam, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -1750,7 +1813,8 @@ ShellCommandRunBcfg (
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type < BcfgTypeMax) {
|
||||
|
||||
if ((ShellStatus == SHELL_SUCCESS) && (CurrentOperation.Target < BcfgTargetMax) && (CurrentOperation.Type < BcfgTypeMax)) {
|
||||
//
|
||||
// we have all the info. Do the work
|
||||
//
|
||||
@ -1760,7 +1824,8 @@ ShellCommandRunBcfg (
|
||||
CurrentOperation.Target == BcfgTargetBootOrder ? L"Boot" : L"Driver",
|
||||
Count,
|
||||
CurrentOperation.Order,
|
||||
ShellCommandLineGetFlag(Package, L"-v"));
|
||||
ShellCommandLineGetFlag (Package, L"-v")
|
||||
);
|
||||
break;
|
||||
case BcfgTypeMv:
|
||||
ShellStatus = BcfgMove (
|
||||
@ -1768,14 +1833,16 @@ ShellCommandRunBcfg (
|
||||
CurrentOperation.Order,
|
||||
Count,
|
||||
CurrentOperation.Number1,
|
||||
CurrentOperation.Number2);
|
||||
CurrentOperation.Number2
|
||||
);
|
||||
break;
|
||||
case BcfgTypeRm:
|
||||
ShellStatus = BcfgRemove (
|
||||
CurrentOperation.Target,
|
||||
CurrentOperation.Order,
|
||||
Count,
|
||||
CurrentOperation.Number1);
|
||||
CurrentOperation.Number1
|
||||
);
|
||||
break;
|
||||
case BcfgTypeAdd:
|
||||
case BcfgTypeAddp:
|
||||
@ -1789,7 +1856,8 @@ ShellCommandRunBcfg (
|
||||
CurrentOperation.Target,
|
||||
(BOOLEAN)(CurrentOperation.Type == BcfgTypeAddh),
|
||||
(BOOLEAN)(CurrentOperation.Type == BcfgTypeAddp),
|
||||
CurrentOperation.HandleIndex);
|
||||
CurrentOperation.HandleIndex
|
||||
);
|
||||
break;
|
||||
case BcfgTypeMod:
|
||||
case BcfgTypeModf:
|
||||
@ -1802,7 +1870,8 @@ ShellCommandRunBcfg (
|
||||
CurrentOperation.OptData,
|
||||
CurrentOperation.Order,
|
||||
Count,
|
||||
CurrentOperation.Target);
|
||||
CurrentOperation.Target
|
||||
);
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
@ -1813,12 +1882,15 @@ ShellCommandRunBcfg (
|
||||
if (Package != NULL) {
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
if (CurrentOperation.FileName != NULL) {
|
||||
FreePool (CurrentOperation.FileName);
|
||||
}
|
||||
|
||||
if (CurrentOperation.Description != NULL) {
|
||||
FreePool (CurrentOperation.Description);
|
||||
}
|
||||
|
||||
if (CurrentOperation.Order != NULL) {
|
||||
FreePool (CurrentOperation.Order);
|
||||
}
|
||||
@ -1826,7 +1898,6 @@ ShellCommandRunBcfg (
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Function to get the filename with help context if HII will not be used.
|
||||
|
||||
@ -1894,7 +1965,7 @@ BcfgLibraryUnregisterBcfgCommand (
|
||||
if (gShellBcfgHiiHandle != NULL) {
|
||||
HiiRemovePackages (gShellBcfgHiiHandle);
|
||||
}
|
||||
|
||||
gShellBcfgHiiHandle = NULL;
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,8 @@ ShellCEntryLib (
|
||||
EfiShellParametersProtocol = NULL;
|
||||
EfiShellInterface = NULL;
|
||||
|
||||
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
|
||||
Status = SystemTable->BootServices->OpenProtocol (
|
||||
ImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID **)&EfiShellParametersProtocol,
|
||||
ImageHandle,
|
||||
@ -70,7 +71,8 @@ ShellCEntryLib (
|
||||
//
|
||||
// try to get shell 1.0 interface instead.
|
||||
//
|
||||
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
|
||||
Status = SystemTable->BootServices->OpenProtocol (
|
||||
ImageHandle,
|
||||
&gEfiShellInterfaceGuid,
|
||||
(VOID **)&EfiShellInterface,
|
||||
ImageHandle,
|
||||
@ -89,5 +91,6 @@ ShellCEntryLib (
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnFromMain;
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
MTDTypeUnknown,
|
||||
MTDTypeFloppy,
|
||||
@ -65,7 +63,6 @@ typedef struct {
|
||||
INTN (EFIAPI *CompareFun)(EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);
|
||||
} DEV_PATH_CONSIST_MAPPING_TABLE;
|
||||
|
||||
|
||||
/**
|
||||
Concatenates a formatted unicode string to allocated pool.
|
||||
The caller must free the resulting buffer.
|
||||
@ -112,6 +109,7 @@ CatPrint (
|
||||
Str->Str
|
||||
);
|
||||
}
|
||||
|
||||
if (NewStr == NULL) {
|
||||
FreePool (AppendStr);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -197,6 +195,7 @@ AppendCSDNum (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (MappingItem != NULL);
|
||||
|
||||
if (MappingItem->Digital) {
|
||||
@ -288,11 +287,11 @@ AppendCSDStr (
|
||||
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
// a b c d e f g h i j k l m n o p
|
||||
//
|
||||
if (*Index >= '0' && *Index <= '9') {
|
||||
if ((*Index >= '0') && (*Index <= '9')) {
|
||||
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - '0' + 'a');
|
||||
} else if (*Index >= 'a' && *Index <= 'f') {
|
||||
} else if ((*Index >= 'a') && (*Index <= 'f')) {
|
||||
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'a' + 'k');
|
||||
} else if (*Index >= 'A' && *Index <= 'F') {
|
||||
} else if ((*Index >= 'A') && (*Index <= 'F')) {
|
||||
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');
|
||||
}
|
||||
|
||||
@ -355,17 +354,17 @@ DevPathCompareAcpi (
|
||||
ACPI_HID_DEVICE_PATH *Acpi1;
|
||||
ACPI_HID_DEVICE_PATH *Acpi2;
|
||||
|
||||
if (DevicePath1 == NULL || DevicePath2 == NULL) {
|
||||
if ((DevicePath1 == NULL) || (DevicePath2 == NULL)) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
Acpi1 = (ACPI_HID_DEVICE_PATH *)DevicePath1;
|
||||
Acpi2 = (ACPI_HID_DEVICE_PATH *)DevicePath2;
|
||||
if (Acpi1->HID > Acpi2->HID || (Acpi1->HID == Acpi2->HID && Acpi1->UID > Acpi2->UID)) {
|
||||
if ((Acpi1->HID > Acpi2->HID) || ((Acpi1->HID == Acpi2->HID) && (Acpi1->UID > Acpi2->UID))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Acpi1->HID == Acpi2->HID && Acpi1->UID == Acpi2->UID) {
|
||||
if ((Acpi1->HID == Acpi2->HID) && (Acpi1->UID == Acpi2->UID)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -396,11 +395,11 @@ DevPathComparePci (
|
||||
|
||||
Pci1 = (PCI_DEVICE_PATH *)DevicePath1;
|
||||
Pci2 = (PCI_DEVICE_PATH *)DevicePath2;
|
||||
if (Pci1->Device > Pci2->Device || (Pci1->Device == Pci2->Device && Pci1->Function > Pci2->Function)) {
|
||||
if ((Pci1->Device > Pci2->Device) || ((Pci1->Device == Pci2->Device) && (Pci1->Function > Pci2->Function))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Pci1->Device == Pci2->Device && Pci1->Function == Pci2->Function) {
|
||||
if ((Pci1->Device == Pci2->Device) && (Pci1->Function == Pci2->Function)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -552,6 +551,7 @@ DevPathSerialFibre (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Fibre->Lun);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -583,12 +583,15 @@ DevPathSerialUart (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Uart->DataBits);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Uart->Parity);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Uart->StopBits);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -615,7 +618,6 @@ DevPathSerialUsb (
|
||||
EFI_STATUS Status;
|
||||
USB_INTERFACE_DESCRIPTOR InterfaceDesc;
|
||||
|
||||
|
||||
ASSERT (DevicePathNode != NULL);
|
||||
ASSERT (MappingItem != NULL);
|
||||
|
||||
@ -640,7 +642,7 @@ DevPathSerialUsb (
|
||||
ASSERT (UsbIo != NULL);
|
||||
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS && MappingItem->Mtd == MTDTypeUnknown) {
|
||||
if ((InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS) && (MappingItem->Mtd == MTDTypeUnknown)) {
|
||||
switch (InterfaceDesc.InterfaceSubClass) {
|
||||
case USB_MASS_STORE_SCSI:
|
||||
MappingItem->Mtd = MTDTypeHardDisk;
|
||||
@ -657,6 +659,7 @@ DevPathSerialUsb (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -700,9 +703,11 @@ DevPathSerialVendor (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Sas->Lun);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Sas->DeviceTopology);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Sas->RelativeTargetPort);
|
||||
}
|
||||
@ -726,6 +731,7 @@ DevPathSerialVendor (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
Buffer = NewBuffer;
|
||||
}
|
||||
|
||||
@ -739,6 +745,7 @@ DevPathSerialVendor (
|
||||
FreePool (Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -796,9 +803,11 @@ DevPathSerialSata (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Sata->Lun);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -837,15 +846,19 @@ DevPathSerialIScsi (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, IScsi->LoginOption);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, IScsi->Lun);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
|
||||
if (TargetNameLength > 0) {
|
||||
TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
|
||||
@ -856,11 +869,13 @@ DevPathSerialIScsi (
|
||||
for (Index = 0; Index < TargetNameLength; Index++) {
|
||||
TargetName[Index] = (CHAR16)IScsiTargetName[Index];
|
||||
}
|
||||
|
||||
Status = AppendCSDStr (MappingItem, TargetName);
|
||||
FreePool (TargetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -919,7 +934,7 @@ DevPathSerialMacAddr (
|
||||
Mac = (MAC_ADDR_DEVICE_PATH *)DevicePathNode;
|
||||
|
||||
HwAddressSize = sizeof (EFI_MAC_ADDRESS);
|
||||
if (Mac->IfType == 0x01 || Mac->IfType == 0x00) {
|
||||
if ((Mac->IfType == 0x01) || (Mac->IfType == 0x00)) {
|
||||
HwAddressSize = 6;
|
||||
}
|
||||
|
||||
@ -965,12 +980,15 @@ DevPathSerialInfiniBand (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, InfiniBand->ServiceId);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, InfiniBand->TargetPortId);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, InfiniBand->DeviceId);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1012,6 +1030,7 @@ DevPathSerialIPv4 (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Ip->LocalPort);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
UnicodeSPrint (
|
||||
Buffer,
|
||||
@ -1024,9 +1043,11 @@ DevPathSerialIPv4 (
|
||||
);
|
||||
Status = AppendCSDStr (MappingItem, Buffer);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Ip->RemotePort);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1065,6 +1086,7 @@ DevPathSerialIPv6 (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Ip->LocalPort);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
|
||||
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Ip->RemoteIpAddress.Addr[Index]);
|
||||
@ -1072,9 +1094,11 @@ DevPathSerialIPv6 (
|
||||
|
||||
Status = AppendCSDStr (MappingItem, Buffer);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Ip->RemotePort);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1106,6 +1130,7 @@ DevPathSerialScsi (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = AppendCSDNum (MappingItem, Scsi->Lun);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1166,6 +1191,7 @@ DevPathSerialAcpi (
|
||||
return AppendCSDNum (MappingItem, Acpi->UID);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1399,6 +1425,7 @@ GetHIDevicePath (
|
||||
} else {
|
||||
NonHIDevicePathNodeCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Next device path node
|
||||
//
|
||||
@ -1439,10 +1466,10 @@ GetDeviceConsistMappingInfo (
|
||||
// initialize with generic function in case nothing is found
|
||||
//
|
||||
for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
|
||||
|
||||
if (DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type &&
|
||||
DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType
|
||||
) {
|
||||
if ((DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type) &&
|
||||
(DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType)
|
||||
)
|
||||
{
|
||||
SerialFun = DevPathConsistMappingTable[Index].SerialFun;
|
||||
break;
|
||||
}
|
||||
@ -1514,12 +1541,14 @@ ShellCommandConsistMappingInitialize (
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[HandleLoop],
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **)&BlockIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[HandleLoop],
|
||||
&gEfiSimpleFileSystemProtocolGuid,
|
||||
(VOID **)&SimpleFileSystem
|
||||
);
|
||||
@ -1541,7 +1570,9 @@ ShellCommandConsistMappingInitialize (
|
||||
}
|
||||
}
|
||||
|
||||
for (Index = 0; TempTable[Index] != NULL; Index++);
|
||||
for (Index = 0; TempTable[Index] != NULL; Index++) {
|
||||
}
|
||||
|
||||
PerformQuickSort (TempTable, Index, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
||||
*Table = TempTable;
|
||||
|
||||
@ -1647,14 +1678,16 @@ ShellCommandConsistMappingGenMappingName (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = CatPrint (&Str, L"%d", (UINTN)MappingInfo.Hi);
|
||||
}
|
||||
if (!EFI_ERROR (Status) && MappingInfo.Csd.Str != NULL) {
|
||||
|
||||
if (!EFI_ERROR (Status) && (MappingInfo.Csd.Str != NULL)) {
|
||||
Status = CatPrint (&Str, L"%s", MappingInfo.Csd.Str);
|
||||
FreePool (MappingInfo.Csd.Str);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) && Str.Str != NULL) {
|
||||
if (!EFI_ERROR (Status) && (Str.Str != NULL)) {
|
||||
Status = CatPrint (&Str, L":");
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
SHELL_FREE_NON_NULL (Str.Str);
|
||||
return NULL;
|
||||
@ -1681,12 +1714,12 @@ ShellCommandFindMapItem (
|
||||
for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
|
||||
; !IsNull (&gShellMapList.Link, &MapListItem->Link)
|
||||
; MapListItem = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListItem->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
if (gUnicodeCollation->StriColl (gUnicodeCollation, MapListItem->MapName, (CHAR16 *)MapKey) == 0) {
|
||||
return (MapListItem);
|
||||
}
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,6 @@ CommandInit(
|
||||
CHAR8 *PlatformLang;
|
||||
|
||||
if (gUnicodeCollation == NULL) {
|
||||
|
||||
GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME, (VOID **)&PlatformLang, NULL);
|
||||
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
@ -89,6 +88,7 @@ CommandInit(
|
||||
NumHandles = 0;
|
||||
Handles = NULL;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < NumHandles; Index++) {
|
||||
//
|
||||
// Open Unicode Collation Protocol
|
||||
@ -113,6 +113,7 @@ CommandInit(
|
||||
if (gUnicodeCollation == NULL) {
|
||||
gUnicodeCollation = Uc;
|
||||
}
|
||||
|
||||
if (PlatformLang == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -133,9 +134,11 @@ CommandInit(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
if (PlatformLang != NULL) {
|
||||
FreePool (PlatformLang);
|
||||
}
|
||||
@ -162,6 +165,7 @@ ShellCommandLibConstructor (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
InitializeListHead (&gShellMapList.Link);
|
||||
InitializeListHead (&mCommandList.Link);
|
||||
InitializeListHead (&mAliasList.Link);
|
||||
@ -197,13 +201,15 @@ FreeFileHandleList (
|
||||
if (List == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// enumerate through the buffer list and free all memory
|
||||
//
|
||||
for ( BufferListEntry = (BUFFER_LIST *)GetFirstNode (&List->Link)
|
||||
; !IsListEmpty (&List->Link)
|
||||
; BufferListEntry = (BUFFER_LIST *)GetFirstNode (&List->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
RemoveEntryList (&BufferListEntry->Link);
|
||||
ASSERT (BufferListEntry->Buffer != NULL);
|
||||
SHELL_FREE_NON_NULL (((SHELL_COMMAND_FILE_HANDLE *)(BufferListEntry->Buffer))->Path);
|
||||
@ -231,6 +237,7 @@ ShellCommandLibDestructor (
|
||||
ALIAS_LIST *Node2;
|
||||
SCRIPT_FILE_LIST *Node3;
|
||||
SHELL_MAP_LIST *MapNode;
|
||||
|
||||
//
|
||||
// enumerate throught the list and free all the memory
|
||||
//
|
||||
@ -239,7 +246,9 @@ ShellCommandLibDestructor (
|
||||
RemoveEntryList (&Node->Link);
|
||||
SHELL_FREE_NON_NULL (Node->CommandString);
|
||||
FreePool (Node);
|
||||
DEBUG_CODE(Node = NULL;);
|
||||
DEBUG_CODE (
|
||||
Node = NULL;
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@ -251,7 +260,9 @@ ShellCommandLibDestructor (
|
||||
SHELL_FREE_NON_NULL (Node2->CommandString);
|
||||
SHELL_FREE_NON_NULL (Node2->Alias);
|
||||
SHELL_FREE_NON_NULL (Node2);
|
||||
DEBUG_CODE(Node2 = NULL;);
|
||||
DEBUG_CODE (
|
||||
Node2 = NULL;
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@ -271,7 +282,8 @@ ShellCommandLibDestructor (
|
||||
for (MapNode = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
|
||||
; !IsListEmpty (&gShellMapList.Link)
|
||||
; MapNode = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (MapNode != NULL);
|
||||
RemoveEntryList (&MapNode->Link);
|
||||
SHELL_FREE_NON_NULL (MapNode->DevicePath);
|
||||
@ -280,6 +292,7 @@ ShellCommandLibDestructor (
|
||||
FreePool (MapNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsListEmpty (&mFileHandleList.Link)) {
|
||||
FreeFileHandleList (&mFileHandleList);
|
||||
}
|
||||
@ -334,8 +347,10 @@ ShellCommandFindDynamicCommand (
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
(CHAR16*)DynamicCommand->CommandName) == 0
|
||||
){
|
||||
(CHAR16 *)DynamicCommand->CommandName
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
FreePool (CommandHandleList);
|
||||
return (DynamicCommand);
|
||||
}
|
||||
@ -381,16 +396,20 @@ ShellCommandIsCommandOnInternalList(
|
||||
for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
|
||||
; !IsNull (&mCommandList.Link, &Node->Link)
|
||||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
Node->CommandString) == 0
|
||||
){
|
||||
Node->CommandString
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -464,16 +483,20 @@ ShellCommandGetInternalCommandHelp(
|
||||
for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
|
||||
; !IsNull (&mCommandList.Link, &Node->Link)
|
||||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
Node->CommandString) == 0
|
||||
){
|
||||
Node->CommandString
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
return (HiiGetString (Node->HiiHandle, Node->ManFormatHelp, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -492,6 +515,7 @@ ShellCommandGetCommandHelp (
|
||||
)
|
||||
{
|
||||
CHAR16 *HelpStr;
|
||||
|
||||
HelpStr = ShellCommandGetInternalCommandHelp (CommandString);
|
||||
|
||||
if (HelpStr == NULL) {
|
||||
@ -501,7 +525,6 @@ ShellCommandGetCommandHelp (
|
||||
return HelpStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Registers handlers of type SHELL_RUN_COMMAND and
|
||||
SHELL_GET_MAN_FILENAME for each shell command.
|
||||
@ -603,6 +626,7 @@ ShellCommandRegisterCommandName (
|
||||
if (Node == NULL) {
|
||||
return RETURN_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->CommandString = AllocateCopyPool (StrSize (CommandString), CommandString);
|
||||
if (Node->CommandString == NULL) {
|
||||
FreePool (Node);
|
||||
@ -615,10 +639,11 @@ ShellCommandRegisterCommandName (
|
||||
Node->HiiHandle = HiiHandle;
|
||||
Node->ManFormatHelp = ManFormatHelp;
|
||||
|
||||
if ( StrLen(ProfileName)>0
|
||||
&& ((mProfileList != NULL
|
||||
&& StrStr(mProfileList, ProfileName) == NULL) || mProfileList == NULL)
|
||||
){
|
||||
if ( (StrLen (ProfileName) > 0)
|
||||
&& (( (mProfileList != NULL)
|
||||
&& (StrStr (mProfileList, ProfileName) == NULL)) || (mProfileList == NULL))
|
||||
)
|
||||
{
|
||||
ASSERT ((mProfileList == NULL && mProfileListSize == 0) || (mProfileList != NULL));
|
||||
if (mProfileList == NULL) {
|
||||
//
|
||||
@ -626,6 +651,7 @@ ShellCommandRegisterCommandName (
|
||||
//
|
||||
StrnCatGrow (&mProfileList, &mProfileListSize, L";", 0);
|
||||
}
|
||||
|
||||
StrnCatGrow (&mProfileList, &mProfileListSize, ProfileName, 0);
|
||||
StrnCatGrow (&mProfileList, &mProfileListSize, L";", 0);
|
||||
}
|
||||
@ -641,8 +667,8 @@ ShellCommandRegisterCommandName (
|
||||
for (Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link),
|
||||
PrevCommand = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
|
||||
; !IsNull (&mCommandList.Link, &Command->Link)
|
||||
; Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Command->Link)) {
|
||||
|
||||
; Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Command->Link))
|
||||
{
|
||||
//
|
||||
// Get Lexical Comparison Value between PrevCommand and Command list entry
|
||||
//
|
||||
@ -730,21 +756,26 @@ ShellCommandRunCommandHandler (
|
||||
for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
|
||||
; !IsNull (&mCommandList.Link, &Node->Link)
|
||||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
Node->CommandString) == 0
|
||||
){
|
||||
Node->CommandString
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
if (CanAffectLE != NULL) {
|
||||
*CanAffectLE = Node->LastError;
|
||||
}
|
||||
|
||||
if (RetVal != NULL) {
|
||||
*RetVal = Node->CommandHandler (NULL, gST);
|
||||
} else {
|
||||
Node->CommandHandler (NULL, gST);
|
||||
}
|
||||
|
||||
return (RETURN_SUCCESS);
|
||||
}
|
||||
}
|
||||
@ -759,6 +790,7 @@ ShellCommandRunCommandHandler (
|
||||
} else {
|
||||
DynamicCommand->Handler (DynamicCommand, gST, gEfiShellParametersProtocol, gEfiShellProtocol);
|
||||
}
|
||||
|
||||
return (RETURN_SUCCESS);
|
||||
}
|
||||
|
||||
@ -797,16 +829,20 @@ ShellCommandGetManFileNameHandler (
|
||||
for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
|
||||
; !IsNull (&mCommandList.Link, &Node->Link)
|
||||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
Node->CommandString) == 0
|
||||
){
|
||||
Node->CommandString
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
return (Node->GetManFileName ());
|
||||
}
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -869,11 +905,13 @@ ShellCommandRegisterAlias (
|
||||
if (Node == NULL) {
|
||||
return RETURN_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->CommandString = AllocateCopyPool (StrSize (Command), Command);
|
||||
if (Node->CommandString == NULL) {
|
||||
FreePool (Node);
|
||||
return RETURN_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->Alias = AllocateCopyPool (StrSize (Alias), Alias);
|
||||
if (Node->Alias == NULL) {
|
||||
FreePool (Node->CommandString);
|
||||
@ -889,7 +927,8 @@ ShellCommandRegisterAlias (
|
||||
for ( CommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link),
|
||||
PrevCommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link)
|
||||
; !IsNull (&mAliasList.Link, &CommandAlias->Link)
|
||||
; CommandAlias = (ALIAS_LIST *) GetNextNode (&mAliasList.Link, &CommandAlias->Link) ) {
|
||||
; CommandAlias = (ALIAS_LIST *)GetNextNode (&mAliasList.Link, &CommandAlias->Link))
|
||||
{
|
||||
//
|
||||
// Get Lexical comparison value between PrevCommandAlias and CommandAlias List Entry
|
||||
//
|
||||
@ -959,24 +998,31 @@ ShellCommandIsOnAliasList(
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link)
|
||||
; !IsNull (&mAliasList.Link, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode (&mAliasList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
ASSERT (Node->Alias != NULL);
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)Alias,
|
||||
Node->CommandString) == 0
|
||||
){
|
||||
Node->CommandString
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)Alias,
|
||||
Node->Alias) == 0
|
||||
){
|
||||
Node->Alias
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -1033,6 +1079,7 @@ ShellCommandRegisterExit (
|
||||
} else {
|
||||
mExitScript = FALSE;
|
||||
}
|
||||
|
||||
mExitCode = ErrorCode;
|
||||
}
|
||||
|
||||
@ -1066,6 +1113,7 @@ ShellCommandGetExitCode (
|
||||
{
|
||||
return (mExitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieve the Exit script indicator.
|
||||
|
||||
@ -1103,9 +1151,11 @@ DeleteScriptFileStruct (
|
||||
for (LoopVar = 0; LoopVar < Script->Argc; LoopVar++) {
|
||||
SHELL_FREE_NON_NULL (Script->Argv[LoopVar]);
|
||||
}
|
||||
|
||||
if (Script->Argv != NULL) {
|
||||
SHELL_FREE_NON_NULL (Script->Argv);
|
||||
}
|
||||
|
||||
Script->CurrentCommand = NULL;
|
||||
while (!IsListEmpty (&Script->CommandList)) {
|
||||
Script->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetFirstNode (&Script->CommandList);
|
||||
@ -1114,12 +1164,15 @@ DeleteScriptFileStruct (
|
||||
if (Script->CurrentCommand->Cl != NULL) {
|
||||
SHELL_FREE_NON_NULL (Script->CurrentCommand->Cl);
|
||||
}
|
||||
|
||||
if (Script->CurrentCommand->Data != NULL) {
|
||||
SHELL_FREE_NON_NULL (Script->CurrentCommand->Data);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (Script->CurrentCommand);
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (Script->ScriptName);
|
||||
SHELL_FREE_NON_NULL (Script);
|
||||
}
|
||||
@ -1137,9 +1190,11 @@ ShellCommandGetCurrentScriptFile (
|
||||
)
|
||||
{
|
||||
SCRIPT_FILE_LIST *List;
|
||||
|
||||
if (IsListEmpty (&mScriptList.Link)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
List = ((SCRIPT_FILE_LIST *)GetFirstNode (&mScriptList.Link));
|
||||
return (List->Data);
|
||||
}
|
||||
@ -1162,10 +1217,12 @@ ShellCommandSetNewScript (
|
||||
)
|
||||
{
|
||||
SCRIPT_FILE_LIST *Node;
|
||||
|
||||
if (Script == NULL) {
|
||||
if (IsListEmpty (&mScriptList.Link)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Node = (SCRIPT_FILE_LIST *)GetFirstNode (&mScriptList.Link);
|
||||
RemoveEntryList (&Node->Link);
|
||||
DeleteScriptFileStruct (Node->Data);
|
||||
@ -1175,9 +1232,11 @@ ShellCommandSetNewScript (
|
||||
if (Node == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Node->Data = Script;
|
||||
InsertHeadList (&mScriptList.Link, &Node->Link);
|
||||
}
|
||||
|
||||
return (ShellCommandGetCurrentScriptFile ());
|
||||
}
|
||||
|
||||
@ -1198,6 +1257,7 @@ ShellCommandCreateNewMappingName(
|
||||
)
|
||||
{
|
||||
CHAR16 *String;
|
||||
|
||||
ASSERT (Type < MappingTypeMax);
|
||||
|
||||
String = NULL;
|
||||
@ -1207,7 +1267,8 @@ ShellCommandCreateNewMappingName(
|
||||
String,
|
||||
PcdGet8 (PcdShellMapNameLength) * sizeof (String[0]),
|
||||
Type == MappingTypeFileSystem ? L"FS%d:" : L"BLK%d:",
|
||||
Type == MappingTypeFileSystem?mFsMaxCount++:mBlkMaxCount++);
|
||||
Type == MappingTypeFileSystem ? mFsMaxCount++ : mBlkMaxCount++
|
||||
);
|
||||
|
||||
return (String);
|
||||
}
|
||||
@ -1262,14 +1323,17 @@ ShellCommandAddMapItemAndUpdatePath(
|
||||
InsertTailList (&gShellMapList.Link, &MapListNode->Link);
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (MapListNode != NULL) {
|
||||
if (MapListNode->DevicePath != NULL) {
|
||||
FreePool (MapListNode->DevicePath);
|
||||
}
|
||||
|
||||
if (MapListNode->MapName != NULL) {
|
||||
FreePool (MapListNode->MapName);
|
||||
}
|
||||
|
||||
FreePool (MapListNode);
|
||||
}
|
||||
} else if (Path) {
|
||||
@ -1283,6 +1347,7 @@ ShellCommandAddMapItemAndUpdatePath(
|
||||
StrnCatGrow (&NewPath, &NewPathSize, OriginalPath, 0);
|
||||
StrnCatGrow (&NewPath, &NewPathSize, L";", 0);
|
||||
}
|
||||
|
||||
StrnCatGrow (&NewPath, &NewPathSize, Name, 0);
|
||||
StrnCatGrow (&NewPath, &NewPathSize, L"\\efi\\tools\\;", 0);
|
||||
StrnCatGrow (&NewPath, &NewPathSize, Name, 0);
|
||||
@ -1294,6 +1359,7 @@ ShellCommandAddMapItemAndUpdatePath(
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (NewPath);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
@ -1353,7 +1419,8 @@ ShellCommandCreateInitialMappingsAndPaths(
|
||||
for ( MapListNode = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
|
||||
; !IsListEmpty (&gShellMapList.Link)
|
||||
; MapListNode = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
RemoveEntryList (&MapListNode->Link);
|
||||
SHELL_FREE_NON_NULL (MapListNode->DevicePath);
|
||||
SHELL_FREE_NON_NULL (MapListNode->MapName);
|
||||
@ -1370,7 +1437,8 @@ ShellCommandCreateInitialMappingsAndPaths(
|
||||
//
|
||||
// Do a count of the handles
|
||||
//
|
||||
for (Count = 0 ; HandleList[Count] != NULL ; Count++);
|
||||
for (Count = 0; HandleList[Count] != NULL; Count++) {
|
||||
}
|
||||
|
||||
//
|
||||
// Get all Device Paths
|
||||
@ -1435,16 +1503,19 @@ ShellCommandCreateInitialMappingsAndPaths(
|
||||
if (MapName == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
SplitCurDir = StrStr (MapName, L":");
|
||||
if (SplitCurDir == NULL) {
|
||||
SHELL_FREE_NON_NULL (MapName);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
*(SplitCurDir + 1) = CHAR_NULL;
|
||||
MapListItem = ShellCommandFindMapItem (MapName);
|
||||
if (MapListItem != NULL) {
|
||||
gShellCurMapping = MapListItem;
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (MapName);
|
||||
}
|
||||
}
|
||||
@ -1457,7 +1528,8 @@ ShellCommandCreateInitialMappingsAndPaths(
|
||||
//
|
||||
HandleList = GetHandleListByProtocol (&gEfiBlockIoProtocolGuid);
|
||||
if (HandleList != NULL) {
|
||||
for (Count = 0 ; HandleList[Count] != NULL ; Count++);
|
||||
for (Count = 0; HandleList[Count] != NULL; Count++) {
|
||||
}
|
||||
|
||||
//
|
||||
// Get all Device Paths
|
||||
@ -1534,7 +1606,8 @@ ShellCommandUpdateMapping (
|
||||
//
|
||||
// Do a count of the handles
|
||||
//
|
||||
for (Count = 0 ; HandleList[Count] != NULL ; Count++);
|
||||
for (Count = 0; HandleList[Count] != NULL; Count++) {
|
||||
}
|
||||
|
||||
//
|
||||
// Get all Device Paths
|
||||
@ -1565,6 +1638,7 @@ ShellCommandUpdateMapping (
|
||||
if (gEfiShellProtocol->GetMapFromDevicePath (&DevicePathList[Count]) != NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Get default name
|
||||
//
|
||||
@ -1592,6 +1666,7 @@ ShellCommandUpdateMapping (
|
||||
|
||||
FreePool (NewDefaultName);
|
||||
}
|
||||
|
||||
ShellCommandConsistMappingUnInitialize (ConsistMappingTable);
|
||||
SHELL_FREE_NON_NULL (HandleList);
|
||||
SHELL_FREE_NON_NULL (DevicePathList);
|
||||
@ -1600,6 +1675,7 @@ ShellCommandUpdateMapping (
|
||||
} else {
|
||||
Count = (UINTN)-1;
|
||||
}
|
||||
|
||||
//
|
||||
// Do it all over again for gEfiBlockIoProtocolGuid
|
||||
//
|
||||
@ -1647,11 +1723,13 @@ ConvertEfiFileProtocolToShellHandle(
|
||||
if (Buffer == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
NewNode = AllocateZeroPool (sizeof (BUFFER_LIST));
|
||||
if (NewNode == NULL) {
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Buffer->FileHandle = (EFI_FILE_PROTOCOL *)Handle;
|
||||
Buffer->Path = StrnCatGrow (&Buffer->Path, NULL, Path, 0);
|
||||
if (Buffer->Path == NULL) {
|
||||
@ -1659,10 +1737,12 @@ ConvertEfiFileProtocolToShellHandle(
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
NewNode->Buffer = Buffer;
|
||||
|
||||
InsertHeadList (&mFileHandleList.Link, &NewNode->Link);
|
||||
}
|
||||
|
||||
return ((SHELL_FILE_HANDLE)(Handle));
|
||||
}
|
||||
|
||||
@ -1684,11 +1764,13 @@ ShellFileHandleGetPath(
|
||||
for (Node = (BUFFER_LIST *)GetFirstNode (&mFileHandleList.Link)
|
||||
; !IsNull (&mFileHandleList.Link, &Node->Link)
|
||||
; Node = (BUFFER_LIST *)GetNextNode (&mFileHandleList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)) {
|
||||
return (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
|
||||
}
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -1711,7 +1793,8 @@ ShellFileHandleRemove(
|
||||
for (Node = (BUFFER_LIST *)GetFirstNode (&mFileHandleList.Link)
|
||||
; !IsNull (&mFileHandleList.Link, &Node->Link)
|
||||
; Node = (BUFFER_LIST *)GetNextNode (&mFileHandleList.Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)) {
|
||||
RemoveEntryList (&Node->Link);
|
||||
SHELL_FREE_NON_NULL (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
|
||||
@ -1720,6 +1803,7 @@ ShellFileHandleRemove(
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -1785,17 +1869,20 @@ FreeBufferList (
|
||||
if (List == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// enumerate through the buffer list and free all memory
|
||||
//
|
||||
for ( BufferListEntry = (BUFFER_LIST *)GetFirstNode (&List->Link)
|
||||
; !IsListEmpty (&List->Link)
|
||||
; BufferListEntry = (BUFFER_LIST *)GetFirstNode (&List->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
RemoveEntryList (&BufferListEntry->Link);
|
||||
if (BufferListEntry->Buffer != NULL) {
|
||||
FreePool (BufferListEntry->Buffer);
|
||||
}
|
||||
|
||||
FreePool (BufferListEntry);
|
||||
}
|
||||
}
|
||||
@ -2077,12 +2164,14 @@ ShellSortFileList (
|
||||
if (Duplicates != NULL) {
|
||||
*Duplicates = NULL;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (*FileList == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FilesHead = &(*FileList)->Link;
|
||||
|
||||
//
|
||||
@ -2104,6 +2193,7 @@ ShellSortFileList (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto UninitSort;
|
||||
}
|
||||
|
||||
Unique->Alias = ((Order == ShellSortFileListByFileName) ?
|
||||
FileInfo->FileName :
|
||||
FileInfo->FullName);
|
||||
@ -2124,6 +2214,7 @@ ShellSortFileList (
|
||||
if (Status == EFI_OUT_OF_RESOURCES) {
|
||||
goto UninitSort;
|
||||
}
|
||||
|
||||
ASSERT (Status == EFI_ALREADY_STARTED);
|
||||
}
|
||||
}
|
||||
@ -2143,6 +2234,7 @@ ShellSortFileList (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto UninitSort;
|
||||
}
|
||||
|
||||
InitializeListHead (&Dupes->Link);
|
||||
}
|
||||
|
||||
@ -2176,7 +2268,8 @@ ShellSortFileList (
|
||||
//
|
||||
for (SortEntry = OrderedCollectionMin (Sort);
|
||||
SortEntry != NULL;
|
||||
SortEntry = OrderedCollectionNext (SortEntry)) {
|
||||
SortEntry = OrderedCollectionNext (SortEntry))
|
||||
{
|
||||
Unique = OrderedCollectionUserStruct (SortEntry);
|
||||
//
|
||||
// The first FileInfo encountered for each unique name goes back on
|
||||
@ -2207,6 +2300,7 @@ ShellSortFileList (
|
||||
*Duplicates = Dupes;
|
||||
}
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
@ -2215,13 +2309,15 @@ ShellSortFileList (
|
||||
UninitSort:
|
||||
for (SortEntry = OrderedCollectionMin (Sort);
|
||||
SortEntry != NULL;
|
||||
SortEntry = NextSortEntry) {
|
||||
SortEntry = NextSortEntry)
|
||||
{
|
||||
NextSortEntry = OrderedCollectionNext (SortEntry);
|
||||
OrderedCollectionDelete (Sort, SortEntry, &UniqueAsVoid);
|
||||
Unique = UniqueAsVoid;
|
||||
ASSERT (IsListEmpty (&Unique->SameNameList));
|
||||
FreePool (Unique);
|
||||
}
|
||||
|
||||
OrderedCollectionUninit (Sort);
|
||||
|
||||
return Status;
|
||||
|
@ -81,4 +81,3 @@ typedef struct {
|
||||
} SHELL_SORT_UNIQUE_NAME;
|
||||
|
||||
#endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_
|
||||
|
||||
|
@ -73,7 +73,7 @@ PrintDifferentPoint(
|
||||
// Print data in char-format.
|
||||
//
|
||||
for (Index = 0; Index < BufferSize; Index++) {
|
||||
if (Buffer[Index] >= 0x20 && Buffer[Index] <= 0x7E) {
|
||||
if ((Buffer[Index] >= 0x20) && (Buffer[Index] <= 0x7E)) {
|
||||
ShellPrintEx (-1, -1, L"%c", Buffer[Index]);
|
||||
} else {
|
||||
//
|
||||
@ -165,15 +165,20 @@ FileBufferReadByte (
|
||||
|
||||
if (FileBuffer->Left == 0) {
|
||||
ReadSize = FileBuffer->Allocated;
|
||||
Status = gEfiShellProtocol->ReadFile (FileHandle, &ReadSize,
|
||||
FileBuffer->Data);
|
||||
Status = gEfiShellProtocol->ReadFile (
|
||||
FileHandle,
|
||||
&ReadSize,
|
||||
FileBuffer->Data
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (ReadSize == 0) {
|
||||
*BytesRead = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
FileBuffer->Next = 0;
|
||||
FileBuffer->Left = ReadSize;
|
||||
}
|
||||
@ -259,7 +264,7 @@ ShellCommandRunComp (
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"comp", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -287,6 +292,7 @@ ShellCommandRunComp (
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
TempParam = ShellCommandLineGetRawValue (Package, 2);
|
||||
ASSERT (TempParam != NULL);
|
||||
FileName2 = ShellFindFilePath (TempParam);
|
||||
@ -300,6 +306,7 @@ ShellCommandRunComp (
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
Status = gEfiShellProtocol->GetFileSize (FileHandle1, &Size1);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -316,7 +323,7 @@ ShellCommandRunComp (
|
||||
DifferentCount = MAX_UINTN;
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64 (TempParam, &DifferentCount, FALSE, TRUE);
|
||||
if (EFI_ERROR(Status) || DifferentCount == 0) {
|
||||
if (EFI_ERROR (Status) || (DifferentCount == 0)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-n");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -331,7 +338,7 @@ ShellCommandRunComp (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64 (TempParam, &DifferentBytes, FALSE, TRUE);
|
||||
if (EFI_ERROR(Status) || DifferentBytes == 0) {
|
||||
if (EFI_ERROR (Status) || (DifferentBytes == 0)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-s");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -348,8 +355,9 @@ ShellCommandRunComp (
|
||||
DataFromFile2 = AllocateZeroPool ((UINTN)DifferentBytes);
|
||||
FileBufferInit (&FileBuffer1);
|
||||
FileBufferInit (&FileBuffer2);
|
||||
if (DataFromFile1 == NULL || DataFromFile2 == NULL ||
|
||||
FileBuffer1.Data == NULL || FileBuffer2.Data == NULL) {
|
||||
if ((DataFromFile1 == NULL) || (DataFromFile2 == NULL) ||
|
||||
(FileBuffer1.Data == NULL) || (FileBuffer2.Data == NULL))
|
||||
{
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
SHELL_FREE_NON_NULL (DataFromFile1);
|
||||
SHELL_FREE_NON_NULL (DataFromFile2);
|
||||
@ -364,11 +372,19 @@ ShellCommandRunComp (
|
||||
DataSizeFromFile2 = 1;
|
||||
OneByteFromFile1 = 0;
|
||||
OneByteFromFile2 = 0;
|
||||
Status = FileBufferReadByte (FileHandle1, &FileBuffer1,
|
||||
&DataSizeFromFile1, &OneByteFromFile1);
|
||||
Status = FileBufferReadByte (
|
||||
FileHandle1,
|
||||
&FileBuffer1,
|
||||
&DataSizeFromFile1,
|
||||
&OneByteFromFile1
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = FileBufferReadByte (FileHandle2, &FileBuffer2,
|
||||
&DataSizeFromFile2, &OneByteFromFile2);
|
||||
Status = FileBufferReadByte (
|
||||
FileHandle2,
|
||||
&FileBuffer2,
|
||||
&DataSizeFromFile2,
|
||||
&OneByteFromFile2
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
TempAddress++;
|
||||
@ -378,9 +394,10 @@ ShellCommandRunComp (
|
||||
// 2.If no more char in File1 or File2, The ReadStatus is InPrevDiffPoint forever.
|
||||
// So the previous different point is the last one, then break the while block.
|
||||
//
|
||||
if ( (DataSizeFromFile1 == 0 && InsertPosition1 == 0 && DataSizeFromFile2 == 0 && InsertPosition2 == 0) ||
|
||||
(ReadStatus == InPrevDiffPoint && (DataSizeFromFile1 == 0 || DataSizeFromFile2 == 0))
|
||||
) {
|
||||
if (((DataSizeFromFile1 == 0) && (InsertPosition1 == 0) && (DataSizeFromFile2 == 0) && (InsertPosition2 == 0)) ||
|
||||
((ReadStatus == InPrevDiffPoint) && ((DataSizeFromFile1 == 0) || (DataSizeFromFile2 == 0)))
|
||||
)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -391,6 +408,7 @@ ShellCommandRunComp (
|
||||
if (DataSizeFromFile1 == 1) {
|
||||
DataFromFile1[InsertPosition1++] = OneByteFromFile1;
|
||||
}
|
||||
|
||||
if (DataSizeFromFile2 == 1) {
|
||||
DataFromFile2[InsertPosition2++] = OneByteFromFile2;
|
||||
}
|
||||
@ -399,6 +417,7 @@ ShellCommandRunComp (
|
||||
if (DataSizeFromFile1 == 1) {
|
||||
DataFromFile1[InsertPosition1++] = OneByteFromFile1;
|
||||
}
|
||||
|
||||
if (DataSizeFromFile2 == 1) {
|
||||
DataFromFile2[InsertPosition2++] = OneByteFromFile2;
|
||||
}
|
||||
@ -411,11 +430,11 @@ ShellCommandRunComp (
|
||||
//
|
||||
// ReadStatus should be always equal InDiffPoint.
|
||||
//
|
||||
if ( InsertPosition1 == DifferentBytes ||
|
||||
InsertPosition2 == DifferentBytes ||
|
||||
(DataSizeFromFile1 == 0 && DataSizeFromFile2 == 0)
|
||||
) {
|
||||
|
||||
if ((InsertPosition1 == DifferentBytes) ||
|
||||
(InsertPosition2 == DifferentBytes) ||
|
||||
((DataSizeFromFile1 == 0) && (DataSizeFromFile2 == 0))
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber);
|
||||
PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);
|
||||
PrintDifferentPoint (FileName2, L"File2", DataFromFile2, InsertPosition2, DiffPointAddress, DifferentBytes);
|
||||
@ -423,7 +442,7 @@ ShellCommandRunComp (
|
||||
//
|
||||
// One of two buffuers is empty, it means this is the last different point.
|
||||
//
|
||||
if (InsertPosition1 == 0 || InsertPosition2 == 0) {
|
||||
if ((InsertPosition1 == 0) || (InsertPosition2 == 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -479,12 +498,14 @@ ShellCommandRunComp (
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (FileName1);
|
||||
SHELL_FREE_NON_NULL (FileName2);
|
||||
|
||||
if (FileHandle1 != NULL) {
|
||||
gEfiShellProtocol->CloseFile (FileHandle1);
|
||||
}
|
||||
|
||||
if (FileHandle2 != NULL) {
|
||||
gEfiShellProtocol->CloseFile (FileHandle2);
|
||||
}
|
||||
|
@ -401,6 +401,7 @@ InsertNode (
|
||||
|
||||
mMatchLen = 2;
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse down the tree to find a match.
|
||||
// Update Position value along the route.
|
||||
@ -460,7 +461,6 @@ InsertNode (
|
||||
// Special usage of 'next'
|
||||
//
|
||||
mNext[LoopVar4] = mPos;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -609,6 +609,7 @@ GetNextMatch (
|
||||
if (Temp == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH);
|
||||
CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH);
|
||||
FreePool (Temp);
|
||||
@ -643,7 +644,7 @@ DownHeap (
|
||||
LoopVar2 = mHeap[i];
|
||||
LoopVar1 = 2 * i;
|
||||
while (LoopVar1 <= mHeapSize) {
|
||||
if (LoopVar1 < mHeapSize && mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]]) {
|
||||
if ((LoopVar1 < mHeapSize) && (mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]])) {
|
||||
LoopVar1++;
|
||||
}
|
||||
|
||||
@ -863,21 +864,21 @@ PutBits (
|
||||
if (LoopVar8 < mBitCount) {
|
||||
mSubBitBuf |= x << (mBitCount -= LoopVar8);
|
||||
} else {
|
||||
|
||||
Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount)));
|
||||
if (mDst < mDstUpperLimit) {
|
||||
*mDst++ = Temp;
|
||||
}
|
||||
|
||||
mCompSize++;
|
||||
|
||||
if (LoopVar8 < UINT8_BIT) {
|
||||
mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8);
|
||||
} else {
|
||||
|
||||
Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT));
|
||||
if (mDst < mDstUpperLimit) {
|
||||
*mDst++ = Temp;
|
||||
}
|
||||
|
||||
mCompSize++;
|
||||
|
||||
mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - LoopVar8);
|
||||
@ -1095,6 +1096,7 @@ SendBlock (
|
||||
UINT32 Pos;
|
||||
|
||||
UINT32 Size;
|
||||
|
||||
Flags = 0;
|
||||
|
||||
Root = MakeTree (NC, mCFreq, mCLen, mCCode);
|
||||
@ -1133,6 +1135,7 @@ SendBlock (
|
||||
} else {
|
||||
Flags <<= 1;
|
||||
}
|
||||
|
||||
if ((Flags & (1U << (UINT8_BIT - 1))) != 0) {
|
||||
EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));
|
||||
LoopVar3 = mBuf[Pos++] << UINT8_BIT;
|
||||
@ -1191,6 +1194,7 @@ CompressOutput (
|
||||
CPos = mOutputPos++;
|
||||
mBuf[CPos] = 0;
|
||||
}
|
||||
|
||||
mBuf[mOutputPos++] = (UINT8)LoopVar5;
|
||||
mCFreq[LoopVar5]++;
|
||||
if (LoopVar5 >= (1U << UINT8_BIT)) {
|
||||
@ -1202,6 +1206,7 @@ CompressOutput (
|
||||
LoopVar7 >>= 1;
|
||||
LoopVar5++;
|
||||
}
|
||||
|
||||
mPFreq[LoopVar5]++;
|
||||
}
|
||||
}
|
||||
@ -1263,11 +1268,12 @@ Encode (
|
||||
if (!GetNextMatch ()) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (mMatchLen > mRemainder) {
|
||||
mMatchLen = mRemainder;
|
||||
}
|
||||
|
||||
if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {
|
||||
if ((mMatchLen > LastMatchLen) || (LastMatchLen < THRESHOLD)) {
|
||||
//
|
||||
// Not enough benefits are gained by outputting a pointer,
|
||||
// so just output the original character
|
||||
@ -1278,13 +1284,16 @@ Encode (
|
||||
// Outputting a pointer is beneficial enough, do it.
|
||||
//
|
||||
|
||||
CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
|
||||
(mPos - LastMatchPos - 2) & (WNDSIZ - 1));
|
||||
CompressOutput (
|
||||
LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
|
||||
(mPos - LastMatchPos - 2) & (WNDSIZ - 1)
|
||||
);
|
||||
LastMatchLen--;
|
||||
while (LastMatchLen > 0) {
|
||||
if (!GetNextMatch ()) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
LastMatchLen--;
|
||||
}
|
||||
|
||||
@ -1354,12 +1363,14 @@ Compress (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Null terminate the compressed data
|
||||
//
|
||||
if (mDst < mDstUpperLimit) {
|
||||
*mDst++ = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill in compressed size and original size
|
||||
//
|
||||
@ -1377,6 +1388,4 @@ Compress (
|
||||
*DstSize = mCompSize + 1 + 8;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,3 @@ Compress (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -61,7 +61,7 @@ DisplayTheBlocks(
|
||||
}
|
||||
|
||||
Status = BlockIo->ReadBlocks (BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer);
|
||||
if (!EFI_ERROR(Status) && Buffer != NULL) {
|
||||
if (!EFI_ERROR (Status) && (Buffer != NULL)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
@ -128,7 +128,7 @@ ShellCommandRunDblk (
|
||||
//
|
||||
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dblk", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -157,6 +157,7 @@ ShellCommandRunDblk (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", LbaString);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ShellConvertStringToUint64 (LbaString, &Lba, TRUE, FALSE);
|
||||
}
|
||||
|
||||
@ -167,6 +168,7 @@ ShellCommandRunDblk (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ShellConvertStringToUint64 (BlockCountString, &BlockCount, TRUE, FALSE);
|
||||
if (BlockCount > 0x10) {
|
||||
BlockCount = 0x10;
|
||||
@ -197,5 +199,6 @@ ShellCommandRunDblk (
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
@ -28,9 +28,10 @@ MakePrintable(
|
||||
IN CONST CHAR16 Char
|
||||
)
|
||||
{
|
||||
if ((Char < 0x20 && Char > 0)||(Char > 126)) {
|
||||
if (((Char < 0x20) && (Char > 0)) || (Char > 126)) {
|
||||
return (L'?');
|
||||
}
|
||||
|
||||
return (Char);
|
||||
}
|
||||
|
||||
@ -58,6 +59,7 @@ DisplayMmioMemory(
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"dmem");
|
||||
return (SHELL_NOT_FOUND);
|
||||
}
|
||||
|
||||
Buffer = AllocateZeroPool (Size);
|
||||
if (Buffer == NULL) {
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
@ -127,7 +129,7 @@ ShellCommandRunDmem (
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmem", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -148,6 +150,7 @@ ShellCommandRunDmem (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Temp1 = ShellCommandLineGetRawValue (Package, 2);
|
||||
if (Temp1 == NULL) {
|
||||
Size = 512;
|
||||
@ -175,25 +178,34 @@ ShellCommandRunDmem (
|
||||
Acpi20TableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi10TableGuid)) {
|
||||
AcpiTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbiosTableGuid)) {
|
||||
SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbios3TableGuid)) {
|
||||
SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiMpsTableGuid)) {
|
||||
MpsTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_SYSTEM_TABLE), gShellDebug1HiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMEM_SYSTEM_TABLE),
|
||||
gShellDebug1HiiHandle,
|
||||
(UINT64)(UINTN)Address,
|
||||
gST->Hdr.HeaderSize,
|
||||
gST->Hdr.Revision,
|
||||
@ -214,7 +226,6 @@ ShellCommandRunDmem (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
|
@ -49,17 +49,21 @@ GetAttrType (
|
||||
if ((Atts & EFI_VARIABLE_NON_VOLATILE) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+NV", 0);
|
||||
}
|
||||
|
||||
if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0);
|
||||
} else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+BS", 0);
|
||||
}
|
||||
|
||||
if ((Atts & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+HR", 0);
|
||||
}
|
||||
|
||||
if ((Atts & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+AW", 0);
|
||||
}
|
||||
|
||||
if ((Atts & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
|
||||
StrnCatGrow (&RetString, &BufLen, L"+AT", 0);
|
||||
}
|
||||
@ -108,6 +112,7 @@ BinaryToHexString (
|
||||
((UINT8 *)Buffer)[Index]
|
||||
);
|
||||
}
|
||||
|
||||
return HexString;
|
||||
}
|
||||
|
||||
@ -188,6 +193,7 @@ LoadVariablesFromFile (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
BufferSize = RemainingSize;
|
||||
Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *)Buffer + 2);
|
||||
if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
|
||||
@ -221,6 +227,7 @@ LoadVariablesFromFile (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
|
||||
Variable->Name = (CHAR16 *)(Variable + 1);
|
||||
Variable->DataSize = DataSize;
|
||||
@ -244,16 +251,25 @@ LoadVariablesFromFile (
|
||||
for ( Link = GetFirstNode (&List)
|
||||
; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
|
||||
; Link = GetNextNode (&List, Link)
|
||||
) {
|
||||
)
|
||||
{
|
||||
Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
|
||||
|
||||
if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *)Name)) &&
|
||||
((Guid == NULL) || CompareGuid (&Variable->Guid, Guid))
|
||||
) {
|
||||
)
|
||||
{
|
||||
Attributes = GetAttrType (Variable->Attributes);
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
|
||||
Attributes, &Variable->Guid, Variable->Name, Variable->DataSize
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
|
||||
gShellDebug1HiiHandle,
|
||||
Attributes,
|
||||
&Variable->Guid,
|
||||
Variable->Name,
|
||||
Variable->DataSize
|
||||
);
|
||||
SHELL_FREE_NON_NULL (Attributes);
|
||||
|
||||
@ -365,7 +381,8 @@ AppendSingleVariableToFile (
|
||||
|
||||
if (!EFI_ERROR (Status) &&
|
||||
(BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32))
|
||||
) {
|
||||
)
|
||||
{
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -474,11 +491,12 @@ CascadeProcessVariables (
|
||||
// No matter what happened we process our own variable
|
||||
// Only continue if Guid and VariableName are each either NULL or a match
|
||||
//
|
||||
if ( ( Name == NULL
|
||||
if ( ( (Name == NULL)
|
||||
|| gUnicodeCollation->MetaiMatch (gUnicodeCollation, FoundVarName, (CHAR16 *)Name))
|
||||
&& ( Guid == NULL
|
||||
&& ( (Guid == NULL)
|
||||
|| CompareGuid (&FoundVarGuid, Guid))
|
||||
) {
|
||||
)
|
||||
{
|
||||
DataSize = 0;
|
||||
DataBuffer = NULL;
|
||||
//
|
||||
@ -495,6 +513,7 @@ CascadeProcessVariables (
|
||||
Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Last error check then print this variable out.
|
||||
//
|
||||
@ -505,10 +524,20 @@ CascadeProcessVariables (
|
||||
HexString = AllocatePool ((DataSize * 2 + 1) * sizeof (CHAR16));
|
||||
if (HexString != NULL) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_VAR_SFO), gShellDebug1HiiHandle,
|
||||
FoundVarName, &FoundVarGuid, Atts, DataSize,
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_VAR_SFO),
|
||||
gShellDebug1HiiHandle,
|
||||
FoundVarName,
|
||||
&FoundVarGuid,
|
||||
Atts,
|
||||
DataSize,
|
||||
BinaryToHexString (
|
||||
DataBuffer, DataSize, HexString, (DataSize * 2 + 1) * sizeof (CHAR16)
|
||||
DataBuffer,
|
||||
DataSize,
|
||||
HexString,
|
||||
(DataSize * 2 + 1) * sizeof (CHAR16)
|
||||
)
|
||||
);
|
||||
FreePool (HexString);
|
||||
@ -519,25 +548,48 @@ CascadeProcessVariables (
|
||||
Status = gEfiShellProtocol->GetGuidName (&FoundVarGuid, &GuidName);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
|
||||
AttrString, &FoundVarGuid, FoundVarName, DataSize
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
|
||||
gShellDebug1HiiHandle,
|
||||
AttrString,
|
||||
&FoundVarGuid,
|
||||
FoundVarName,
|
||||
DataSize
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2), gShellDebug1HiiHandle,
|
||||
AttrString, GuidName, FoundVarName, DataSize
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2),
|
||||
gShellDebug1HiiHandle,
|
||||
AttrString,
|
||||
GuidName,
|
||||
FoundVarName,
|
||||
DataSize
|
||||
);
|
||||
}
|
||||
|
||||
DumpHex (2, 0, DataSize, DataBuffer);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (AttrString);
|
||||
}
|
||||
} else if (Type == DmpStoreSave) {
|
||||
if (!EFI_ERROR (Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
|
||||
AttrString = GetAttrType (Atts);
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
|
||||
AttrString, &FoundVarGuid, FoundVarName, DataSize
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
|
||||
gShellDebug1HiiHandle,
|
||||
AttrString,
|
||||
&FoundVarGuid,
|
||||
FoundVarName,
|
||||
DataSize
|
||||
);
|
||||
Status = AppendSingleVariableToFile (
|
||||
FileHandle,
|
||||
@ -557,17 +609,29 @@ CascadeProcessVariables (
|
||||
if (StandardFormatOutput) {
|
||||
if (SetStatus == EFI_SUCCESS) {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO), gShellDebug1HiiHandle,
|
||||
FoundVarName, &FoundVarGuid
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO),
|
||||
gShellDebug1HiiHandle,
|
||||
FoundVarName,
|
||||
&FoundVarGuid
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ShellPrintHiiEx (
|
||||
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_DELETE_LINE), gShellDebug1HiiHandle,
|
||||
&FoundVarGuid, FoundVarName, SetStatus
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_DMPSTORE_DELETE_LINE),
|
||||
gShellDebug1HiiHandle,
|
||||
&FoundVarGuid,
|
||||
FoundVarName,
|
||||
SetStatus
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (DataBuffer);
|
||||
}
|
||||
|
||||
@ -630,29 +694,31 @@ ProcessVariables (
|
||||
if (ShellStatus == SHELL_OUT_OF_RESOURCES) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"dmpstore");
|
||||
return (ShellStatus);
|
||||
} else if (Name != NULL && Guid == NULL) {
|
||||
} else if ((Name != NULL) && (Guid == NULL)) {
|
||||
if (StandardFormatOutput) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N_SFO), gShellDebug1HiiHandle, Name);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, L"dmpstore", Name);
|
||||
}
|
||||
} else if (Name != NULL && Guid != NULL) {
|
||||
} else if ((Name != NULL) && (Guid != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, L"dmpstore", Guid, Name);
|
||||
} else if (Name == NULL && Guid == NULL) {
|
||||
} else if ((Name == NULL) && (Guid == NULL)) {
|
||||
if (StandardFormatOutput) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_SFO), gShellDebug1HiiHandle);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle, L"dmpstore");
|
||||
}
|
||||
} else if (Name == NULL && Guid != NULL) {
|
||||
} else if ((Name == NULL) && (Guid != NULL)) {
|
||||
if (StandardFormatOutput) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G_SFO), gShellDebug1HiiHandle, Guid);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid);
|
||||
}
|
||||
}
|
||||
|
||||
return (SHELL_NOT_FOUND);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
@ -703,7 +769,7 @@ ShellCommandRunDmpStore (
|
||||
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -738,6 +804,7 @@ ShellCommandRunDmpStore (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmpstore", GuidStr);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Guid = &GuidData;
|
||||
} else {
|
||||
Guid = &gEfiGlobalVariableGuid;
|
||||
@ -778,6 +845,7 @@ ShellCommandRunDmpStore (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (FileInfo);
|
||||
}
|
||||
} else if (Status == EFI_NOT_FOUND) {
|
||||
@ -824,6 +892,7 @@ ShellCommandRunDmpStore (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FreePool (FileInfo);
|
||||
}
|
||||
}
|
||||
@ -843,6 +912,7 @@ ShellCommandRunDmpStore (
|
||||
} else if (Type == DmpStoreLoad) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File);
|
||||
}
|
||||
|
||||
ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput);
|
||||
if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
|
||||
ShellCloseFile (&FileHandle);
|
||||
@ -854,6 +924,6 @@ ShellCommandRunDmpStore (
|
||||
if (Package != NULL) {
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return ShellStatus;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ ShellCommandRunEdit (
|
||||
CHAR16 *Nfs;
|
||||
CHAR16 *Spot;
|
||||
CONST CHAR16 *TempParam;
|
||||
|
||||
// SHELL_FILE_HANDLE TempHandle;
|
||||
|
||||
Buffer = NULL;
|
||||
@ -52,7 +53,7 @@ ShellCommandRunEdit (
|
||||
//
|
||||
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"edit", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -74,10 +75,12 @@ ShellCommandRunEdit (
|
||||
if (Spot != NULL) {
|
||||
*Spot = CHAR_NULL;
|
||||
}
|
||||
|
||||
Spot = StrStr (Nfs, L"\\");
|
||||
if (Spot != NULL) {
|
||||
Spot[1] = CHAR_NULL;
|
||||
}
|
||||
|
||||
gEfiShellProtocol->SetCurDir (NULL, Nfs);
|
||||
FreePool (Nfs);
|
||||
}
|
||||
@ -150,7 +153,9 @@ ShellCommandRunEdit (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return ShellStatus;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ InternalEditorMiscLineAdvance (
|
||||
UINTN Index;
|
||||
CONST EFI_EDITOR_LINE *Line;
|
||||
|
||||
if (CurrentLine == NULL || LineList == NULL) {
|
||||
if ((CurrentLine == NULL) || (LineList == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ InternalEditorMiscLineRetreat (
|
||||
UINTN Index;
|
||||
CONST EFI_EDITOR_LINE *Line;
|
||||
|
||||
if (CurrentLine == NULL || LineList == NULL) {
|
||||
if ((CurrentLine == NULL) || (LineList == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -271,20 +271,20 @@ FileBufferRestoreMousePosition (
|
||||
Line = NULL;
|
||||
|
||||
if (MainEditor.MouseSupported) {
|
||||
|
||||
if (FileBufferMouseNeedRefresh) {
|
||||
|
||||
FileBufferMouseNeedRefresh = FALSE;
|
||||
|
||||
//
|
||||
// if mouse position not moved and only mouse action
|
||||
// so do not need to refresh mouse position
|
||||
//
|
||||
if ((FileBuffer.MousePosition.Row == FileBufferBackupVar.MousePosition.Row &&
|
||||
FileBuffer.MousePosition.Column == FileBufferBackupVar.MousePosition.Column)
|
||||
&& EditorMouseAction) {
|
||||
if ( ((FileBuffer.MousePosition.Row == FileBufferBackupVar.MousePosition.Row) &&
|
||||
(FileBuffer.MousePosition.Column == FileBufferBackupVar.MousePosition.Column))
|
||||
&& EditorMouseAction)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// backup the old screen attributes
|
||||
//
|
||||
@ -307,7 +307,7 @@ FileBufferRestoreMousePosition (
|
||||
CurrentLine = FileBuffer.CurrentLine;
|
||||
Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
|
||||
|
||||
if (Line == NULL || FColumn > Line->Size) {
|
||||
if ((Line == NULL) || (FColumn > Line->Size)) {
|
||||
HasCharacter = FALSE;
|
||||
}
|
||||
|
||||
@ -329,6 +329,7 @@ FileBufferRestoreMousePosition (
|
||||
Value
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// set the new mouse position
|
||||
//
|
||||
@ -347,7 +348,7 @@ FileBufferRestoreMousePosition (
|
||||
CurrentLine = FileBuffer.CurrentLine;
|
||||
Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
|
||||
|
||||
if (Line == NULL || FColumn > Line->Size) {
|
||||
if ((Line == NULL) || (FColumn > Line->Size)) {
|
||||
HasCharacter = FALSE;
|
||||
}
|
||||
|
||||
@ -369,15 +370,18 @@ FileBufferRestoreMousePosition (
|
||||
Value
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// end of HasCharacter
|
||||
//
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
}
|
||||
|
||||
//
|
||||
// end of MouseNeedRefresh
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of MouseSupported
|
||||
//
|
||||
@ -406,7 +410,6 @@ FileBufferFreeLines (
|
||||
// free all the lines
|
||||
//
|
||||
if (FileBuffer.Lines != NULL) {
|
||||
|
||||
Line = FileBuffer.Lines;
|
||||
Link = &(Line->Link);
|
||||
do {
|
||||
@ -419,6 +422,7 @@ FileBufferFreeLines (
|
||||
LineFree (Line);
|
||||
} while (Link != FileBuffer.ListHead);
|
||||
}
|
||||
|
||||
//
|
||||
// clean the line list related structure
|
||||
//
|
||||
@ -456,7 +460,6 @@ FileBufferCleanup (
|
||||
|
||||
SHELL_FREE_NON_NULL (FileBufferBackupVar.FileName);
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -473,7 +476,6 @@ FileBufferPrintLine (
|
||||
IN CONST UINTN Row
|
||||
)
|
||||
{
|
||||
|
||||
CHAR16 *Buffer;
|
||||
UINTN Limit;
|
||||
CHAR16 *PrintLine;
|
||||
@ -512,6 +514,7 @@ FileBufferPrintLine (
|
||||
);
|
||||
FreePool (PrintLine2);
|
||||
}
|
||||
|
||||
FreePool (PrintLine);
|
||||
}
|
||||
|
||||
@ -563,10 +566,10 @@ FileBufferRefresh (
|
||||
//
|
||||
if (!FileBufferNeedRefresh &&
|
||||
!FileBufferOnlyLineNeedRefresh &&
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
|
||||
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
|
||||
) {
|
||||
|
||||
(FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row) &&
|
||||
(FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column)
|
||||
)
|
||||
{
|
||||
FileBufferRestoreMousePosition ();
|
||||
FileBufferRestorePosition ();
|
||||
|
||||
@ -580,10 +583,10 @@ FileBufferRefresh (
|
||||
// only need to refresh current line
|
||||
//
|
||||
if (FileBufferOnlyLineNeedRefresh &&
|
||||
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
|
||||
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
|
||||
) {
|
||||
|
||||
(FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row) &&
|
||||
(FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column)
|
||||
)
|
||||
{
|
||||
EditorClearLine (FileBuffer.DisplayPosition.Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
|
||||
FileBufferPrintLine (
|
||||
FileBuffer.CurrentLine,
|
||||
@ -604,6 +607,7 @@ FileBufferRefresh (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// get the first line that will be displayed
|
||||
//
|
||||
@ -627,6 +631,7 @@ FileBufferRefresh (
|
||||
Link = Link->ForwardLink;
|
||||
Row++;
|
||||
} while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1));
|
||||
|
||||
//
|
||||
// while not file end and not screen full
|
||||
//
|
||||
@ -669,6 +674,7 @@ FileBufferCreateLine (
|
||||
if (Line == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// initialize the structure
|
||||
//
|
||||
@ -720,6 +726,7 @@ FileBufferSetFileName (
|
||||
if (!IsValidFileName (Str)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
//
|
||||
// free the old file name
|
||||
//
|
||||
@ -735,6 +742,7 @@ FileBufferSetFileName (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Free the existing file lines and reset the modified flag.
|
||||
|
||||
@ -754,7 +762,6 @@ FileBufferFree (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read a file from disk into the FileBuffer.
|
||||
|
||||
@ -829,6 +836,7 @@ FileBufferRead (
|
||||
} else {
|
||||
FileBuffer.ReadOnly = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// get file size
|
||||
//
|
||||
@ -841,13 +849,14 @@ FileBufferRead (
|
||||
//
|
||||
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_WRITE_PROTECTED ||
|
||||
Status == EFI_ACCESS_DENIED ||
|
||||
Status == EFI_NO_MEDIA ||
|
||||
Status == EFI_MEDIA_CHANGED
|
||||
) {
|
||||
if ((Status == EFI_WRITE_PROTECTED) ||
|
||||
(Status == EFI_ACCESS_DENIED) ||
|
||||
(Status == EFI_NO_MEDIA) ||
|
||||
(Status == EFI_MEDIA_CHANGED)
|
||||
)
|
||||
{
|
||||
StatusBarSetStatusString (L"Access Denied");
|
||||
} else if (Status == EFI_DEVICE_ERROR || Status == EFI_VOLUME_CORRUPTED || Status == EFI_VOLUME_FULL) {
|
||||
} else if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_VOLUME_CORRUPTED) || (Status == EFI_VOLUME_FULL)) {
|
||||
StatusBarSetStatusString (L"Disk Error");
|
||||
} else {
|
||||
StatusBarSetStatusString (L"Invalid File Name or Current-working-directory");
|
||||
@ -862,12 +871,14 @@ FileBufferRead (
|
||||
if (Status == EFI_WARN_DELETE_FAILURE) {
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
FileHandle = NULL;
|
||||
if (EFI_ERROR (Status)) {
|
||||
StatusBarSetStatusString (L"Access Denied");
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// file doesn't exist, so set CreateFile to TRUE
|
||||
//
|
||||
@ -881,12 +892,13 @@ FileBufferRead (
|
||||
if (StrCmp (FileName, FileBuffer.FileName) != 0) {
|
||||
FileBufferSetFileName (FileName);
|
||||
}
|
||||
|
||||
//
|
||||
// free the old lines
|
||||
//
|
||||
FileBufferFree ();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// the file exists
|
||||
//
|
||||
@ -898,6 +910,7 @@ FileBufferRead (
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// read file into Buffer
|
||||
//
|
||||
@ -909,6 +922,7 @@ FileBufferRead (
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// nothing in this file
|
||||
//
|
||||
@ -956,10 +970,12 @@ FileBufferRead (
|
||||
} else {
|
||||
FileBuffer.FileType = FileTypeAscii;
|
||||
}
|
||||
|
||||
//
|
||||
// end of AsciiBuffer ==
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of FileSize < 2
|
||||
// all the check ends
|
||||
@ -1038,10 +1054,12 @@ FileBufferRead (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// endif == ASCII
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of for LineSize
|
||||
//
|
||||
@ -1064,6 +1082,7 @@ FileBufferRead (
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// calculate file length
|
||||
//
|
||||
@ -1079,6 +1098,7 @@ FileBufferRead (
|
||||
RemoveEntryList (&Line->Link);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// copy this line to Line->Buffer
|
||||
//
|
||||
@ -1091,6 +1111,7 @@ FileBufferRead (
|
||||
|
||||
LoopVar1++;
|
||||
}
|
||||
|
||||
//
|
||||
// LoopVar1 now points to where CHAR_CARRIAGE_RETURN or CHAR_LINEFEED;
|
||||
//
|
||||
@ -1100,32 +1121,35 @@ FileBufferRead (
|
||||
Line->TotalSize = LineSize;
|
||||
Line->Type = Type;
|
||||
|
||||
if (Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) {
|
||||
if ((Type == NewLineTypeCarriageReturnLineFeed) || (Type == NewLineTypeLineFeedCarriageReturn)) {
|
||||
LoopVar1++;
|
||||
}
|
||||
|
||||
//
|
||||
// last character is a return, SO create a new line
|
||||
//
|
||||
if (((Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) && LineSizeBackup == FileSize - 2) ||
|
||||
((Type == NewLineTypeLineFeed || Type == NewLineTypeCarriageReturn) && LineSizeBackup == FileSize - 1)
|
||||
) {
|
||||
if ((((Type == NewLineTypeCarriageReturnLineFeed) || (Type == NewLineTypeLineFeedCarriageReturn)) && (LineSizeBackup == FileSize - 2)) ||
|
||||
(((Type == NewLineTypeLineFeed) || (Type == NewLineTypeCarriageReturn)) && (LineSizeBackup == FileSize - 1))
|
||||
)
|
||||
{
|
||||
Line = FileBufferCreateLine ();
|
||||
if (Line == NULL) {
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// end of if
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of LoopVar1
|
||||
//
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of if CreateFile
|
||||
//
|
||||
@ -1149,6 +1173,7 @@ Done:
|
||||
StatusBarSetStatusString (UnicodeBuffer);
|
||||
FreePool (UnicodeBuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
//
|
||||
// check whether we have fs?: in filename
|
||||
@ -1248,7 +1273,6 @@ Done:
|
||||
FileBufferOnlyLineNeedRefresh = FALSE;
|
||||
FileBufferMouseNeedRefresh = TRUE;
|
||||
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1278,10 +1302,11 @@ GetNewLine (
|
||||
//
|
||||
// not legal new line type
|
||||
//
|
||||
if (Type != NewLineTypeLineFeed && Type != NewLineTypeCarriageReturn && Type != NewLineTypeCarriageReturnLineFeed && Type != NewLineTypeLineFeedCarriageReturn) {
|
||||
if ((Type != NewLineTypeLineFeed) && (Type != NewLineTypeCarriageReturn) && (Type != NewLineTypeCarriageReturnLineFeed) && (Type != NewLineTypeLineFeedCarriageReturn)) {
|
||||
*Size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// use_cr: give 0x0d
|
||||
//
|
||||
@ -1298,6 +1323,7 @@ GetNewLine (
|
||||
*Size = NewLineSize;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// use_lf: give 0x0a
|
||||
//
|
||||
@ -1314,6 +1340,7 @@ GetNewLine (
|
||||
*Size = NewLineSize;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// use_crlf: give 0x0d 0x0a
|
||||
//
|
||||
@ -1334,6 +1361,7 @@ GetNewLine (
|
||||
*Size = NewLineSize;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// use_lfcr: give 0x0a 0x0d
|
||||
//
|
||||
@ -1354,7 +1382,6 @@ GetNewLine (
|
||||
*Size = NewLineSize;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1433,12 +1460,10 @@ FileBufferSave (
|
||||
|
||||
Attribute = 0;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// if is the old file
|
||||
//
|
||||
if (FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) == 0) {
|
||||
if ((FileBuffer.FileName != NULL) && (StrCmp (FileName, FileBuffer.FileName) == 0)) {
|
||||
//
|
||||
// file has not been modified
|
||||
//
|
||||
@ -1460,7 +1485,7 @@ FileBufferSave (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Info = ShellGetFileInfo (FileHandle);
|
||||
|
||||
if (Info != NULL && Info->Attribute & EFI_FILE_DIRECTORY) {
|
||||
if ((Info != NULL) && Info->Attribute & EFI_FILE_DIRECTORY) {
|
||||
StatusBarSetStatusString (L"Directory Can Not Be Saved");
|
||||
ShellCloseFile (&FileHandle);
|
||||
FreePool (Info);
|
||||
@ -1476,7 +1501,7 @@ FileBufferSave (
|
||||
// if file exits, so delete it
|
||||
//
|
||||
Status = ShellDeleteFile (&FileHandle);
|
||||
if (EFI_ERROR (Status) || Status == EFI_WARN_DELETE_FAILURE) {
|
||||
if (EFI_ERROR (Status) || (Status == EFI_WARN_DELETE_FAILURE)) {
|
||||
StatusBarSetStatusString (L"Write File Failed");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
@ -1522,16 +1547,18 @@ FileBufferSave (
|
||||
if (Line->Type != NewLineTypeDefault) {
|
||||
Type = Line->Type;
|
||||
}
|
||||
|
||||
//
|
||||
// newline character is at most 4 bytes ( two Unicode characters )
|
||||
//
|
||||
Length = 4;
|
||||
if (Line->Buffer != NULL && Line->Size != 0) {
|
||||
if ((Line->Buffer != NULL) && (Line->Size != 0)) {
|
||||
if (FileBuffer.FileType == FileTypeAscii) {
|
||||
Length += Line->Size;
|
||||
} else {
|
||||
Length += (Line->Size * 2);
|
||||
}
|
||||
|
||||
//
|
||||
// end if FileTypeAscii
|
||||
//
|
||||
@ -1548,11 +1575,12 @@ FileBufferSave (
|
||||
FreePool (Cache);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
Ptr = Cache;
|
||||
LeftSize = TotalSize;
|
||||
}
|
||||
|
||||
if (Line->Buffer != NULL && Line->Size != 0) {
|
||||
if ((Line->Buffer != NULL) && (Line->Size != 0)) {
|
||||
if (FileBuffer.FileType == FileTypeAscii) {
|
||||
UnicodeToAscii (Line->Buffer, Line->Size, Ptr);
|
||||
Length = Line->Size;
|
||||
@ -1560,13 +1588,14 @@ FileBufferSave (
|
||||
Length = (Line->Size * 2);
|
||||
CopyMem (Ptr, (CHAR8 *)Line->Buffer, Length);
|
||||
}
|
||||
|
||||
//
|
||||
// end if FileTypeAscii
|
||||
//
|
||||
Ptr += Length;
|
||||
LeftSize -= Length;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of if Line -> Buffer != NULL && Line -> Size != 0
|
||||
//
|
||||
@ -1613,7 +1642,7 @@ FileBufferSave (
|
||||
//
|
||||
// now everything is ready , you can set the new file name to filebuffer
|
||||
//
|
||||
if (FileName != NULL && FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) != 0) {
|
||||
if ((FileName != NULL) && (FileBuffer.FileName != NULL) && (StrCmp (FileName, FileBuffer.FileName) != 0)) {
|
||||
//
|
||||
// not the same
|
||||
//
|
||||
@ -1781,6 +1810,7 @@ FileBufferDoBackspace (
|
||||
if (Line->Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// remove End from line list
|
||||
//
|
||||
@ -1791,7 +1821,6 @@ FileBufferDoBackspace (
|
||||
|
||||
FileBufferNeedRefresh = TRUE;
|
||||
FileBufferOnlyLineNeedRefresh = FALSE;
|
||||
|
||||
} else {
|
||||
//
|
||||
// just delete the previous character
|
||||
@ -1873,6 +1902,7 @@ FileBufferDoReturn (
|
||||
Line->Buffer[FileColumn - 1] = CHAR_NULL;
|
||||
Line->Size = FileColumn - 1;
|
||||
}
|
||||
|
||||
//
|
||||
// increase NumLines
|
||||
//
|
||||
@ -1933,6 +1963,7 @@ FileBufferDoDelete (
|
||||
if (Line->Link.ForwardLink == FileBuffer.ListHead) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// since last character,
|
||||
// so will add the next line to this line
|
||||
@ -1951,7 +1982,6 @@ FileBufferDoDelete (
|
||||
|
||||
FileBufferNeedRefresh = TRUE;
|
||||
FileBufferOnlyLineNeedRefresh = FALSE;
|
||||
|
||||
} else {
|
||||
//
|
||||
// just delete current character
|
||||
@ -2052,6 +2082,7 @@ LineStrInsert (
|
||||
|
||||
Line->TotalSize += 8;
|
||||
}
|
||||
|
||||
//
|
||||
// move the later part of the string one character right
|
||||
//
|
||||
@ -2059,6 +2090,7 @@ LineStrInsert (
|
||||
for (Index = StrSize; Index > Pos; Index--) {
|
||||
TempStringPtr[Index] = TempStringPtr[Index - 1];
|
||||
}
|
||||
|
||||
//
|
||||
// insert char into it.
|
||||
//
|
||||
@ -2098,11 +2130,12 @@ FileBufferAddChar (
|
||||
// or replace the character.
|
||||
//
|
||||
FilePos = FileBuffer.FilePosition.Column - 1;
|
||||
if (FileBuffer.ModeInsert || FilePos + 1 > Line->Size) {
|
||||
if (FileBuffer.ModeInsert || (FilePos + 1 > Line->Size)) {
|
||||
LineStrInsert (Line, Char, FilePos, Line->Size + 1);
|
||||
} else {
|
||||
Line->Buffer[FilePos] = Char;
|
||||
}
|
||||
|
||||
//
|
||||
// move cursor to right
|
||||
//
|
||||
@ -2156,14 +2189,13 @@ FileBufferDoCharInput (
|
||||
//
|
||||
// DEAL WITH ASCII CHAR, filter out thing like ctrl+f
|
||||
//
|
||||
if (Char > 127 || Char < 32) {
|
||||
if ((Char > 127) || (Char < 32)) {
|
||||
Status = StatusBarSetStatusString (L"Unknown Command");
|
||||
} else {
|
||||
Status = FileBufferAddChar (Char);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -2204,7 +2236,6 @@ FileBufferScrollDown (
|
||||
if (FCol > Line->Size) {
|
||||
FCol = Line->Size + 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -2246,7 +2277,6 @@ FileBufferScrollUp (
|
||||
if (FCol > Line->Size) {
|
||||
FCol = Line->Size + 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -2287,6 +2317,7 @@ FileBufferPageDown (
|
||||
//
|
||||
Gap = FileBuffer.NumLines - FRow;
|
||||
}
|
||||
|
||||
//
|
||||
// get correct line
|
||||
//
|
||||
@ -2295,7 +2326,7 @@ FileBufferPageDown (
|
||||
//
|
||||
// if that line, is not that long, so move to the end of that line
|
||||
//
|
||||
if (Line != NULL && FCol > Line->Size) {
|
||||
if ((Line != NULL) && (FCol > Line->Size)) {
|
||||
FCol = Line->Size + 1;
|
||||
}
|
||||
|
||||
@ -2350,7 +2381,7 @@ FileBufferPageUp (
|
||||
//
|
||||
// if that line is not that long, so move to the end of that line
|
||||
//
|
||||
if (Line != NULL && FCol > Line->Size) {
|
||||
if ((Line != NULL) && (FCol > Line->Size)) {
|
||||
FCol = Line->Size + 1;
|
||||
}
|
||||
|
||||
@ -2744,7 +2775,6 @@ FileBufferMovePosition (
|
||||
// let CurrentLine point to correct line;
|
||||
//
|
||||
FileBuffer.CurrentLine = MoveCurrentLine (RowGap);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2779,17 +2809,19 @@ FileBufferCutLine (
|
||||
//
|
||||
// if is the last dummy line, SO CAN not cut
|
||||
//
|
||||
if (StrCmp (Line->Buffer, L"\0") == 0 && Line->Link.ForwardLink == FileBuffer.ListHead
|
||||
if ((StrCmp (Line->Buffer, L"\0") == 0) && (Line->Link.ForwardLink == FileBuffer.ListHead)
|
||||
//
|
||||
// last line
|
||||
//
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// LAST LINE AND NOTHING ON THIS LINE, SO CUT NOTHING
|
||||
//
|
||||
StatusBarSetStatusString (L"Nothing to Cut");
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// if is the last line, so create a dummy line
|
||||
//
|
||||
@ -2855,6 +2887,7 @@ FileBufferPasteLine (
|
||||
if (MainEditor.CutLine == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// read only file can not be pasted on
|
||||
//
|
||||
@ -2867,6 +2900,7 @@ FileBufferPasteLine (
|
||||
if (NewLine == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// insert it above current line
|
||||
//
|
||||
@ -3051,6 +3085,7 @@ FileBufferReplace (
|
||||
if (FileBuffer.CurrentLine->Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// the end CHAR_NULL character;
|
||||
//
|
||||
@ -3064,6 +3099,7 @@ FileBufferReplace (
|
||||
*Buffer = *(Buffer - Gap);
|
||||
Buffer--;
|
||||
}
|
||||
|
||||
//
|
||||
// set replace into it
|
||||
//
|
||||
@ -3162,29 +3198,30 @@ FileBufferAdjustMousePosition (
|
||||
CoordinateY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check whether new mouse column position is beyond screen
|
||||
// if not, adjust it
|
||||
//
|
||||
if (CoordinateX >= 1 && CoordinateX <= MainEditor.ScreenSize.Column) {
|
||||
if ((CoordinateX >= 1) && (CoordinateX <= MainEditor.ScreenSize.Column)) {
|
||||
FileBuffer.MousePosition.Column = CoordinateX;
|
||||
} else if (CoordinateX < 1) {
|
||||
FileBuffer.MousePosition.Column = 1;
|
||||
} else if (CoordinateX > MainEditor.ScreenSize.Column) {
|
||||
FileBuffer.MousePosition.Column = MainEditor.ScreenSize.Column;
|
||||
}
|
||||
|
||||
//
|
||||
// check whether new mouse row position is beyond screen
|
||||
// if not, adjust it
|
||||
//
|
||||
if (CoordinateY >= 2 && CoordinateY <= (MainEditor.ScreenSize.Row - 1)) {
|
||||
if ((CoordinateY >= 2) && (CoordinateY <= (MainEditor.ScreenSize.Row - 1))) {
|
||||
FileBuffer.MousePosition.Row = CoordinateY;
|
||||
} else if (CoordinateY < 2) {
|
||||
FileBuffer.MousePosition.Row = 2;
|
||||
} else if (CoordinateY > (MainEditor.ScreenSize.Row - 1)) {
|
||||
FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3255,6 +3292,7 @@ FileBufferReplaceAll (
|
||||
if (Line->Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// the end CHAR_NULL character;
|
||||
//
|
||||
@ -3268,7 +3306,6 @@ FileBufferReplaceAll (
|
||||
*Buffer = *(Buffer - Gap);
|
||||
Buffer--;
|
||||
}
|
||||
|
||||
} else if (ReplaceLen < SearchLen) {
|
||||
Buffer = Line->Buffer + Position + ReplaceLen;
|
||||
Gap = SearchLen - ReplaceLen;
|
||||
@ -3280,6 +3317,7 @@ FileBufferReplaceAll (
|
||||
} else {
|
||||
ASSERT (ReplaceLen == SearchLen);
|
||||
}
|
||||
|
||||
//
|
||||
// set replace into it
|
||||
//
|
||||
@ -3298,6 +3336,7 @@ FileBufferReplaceAll (
|
||||
Link = Link->ForwardLink;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// call refresh to fresh edit area
|
||||
//
|
||||
@ -3318,4 +3357,3 @@ FileBufferSetModified (
|
||||
{
|
||||
FileBuffer.FileModified = TRUE;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
|
||||
|
||||
EFI_EDITOR_GLOBAL_EDITOR MainEditor;
|
||||
|
||||
|
||||
/**
|
||||
Load a file from disk to editor
|
||||
|
||||
@ -272,7 +271,6 @@ EDITOR_MENU_ITEM MainMenuItems[] = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Load a file from disk to editor
|
||||
|
||||
@ -317,11 +315,11 @@ MainCommandOpenFile (
|
||||
// whether to save it first.
|
||||
//
|
||||
if (MainEditor.FileBuffer->FileModified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// the answer is just one character
|
||||
//
|
||||
@ -329,6 +327,7 @@ MainCommandOpenFile (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// loop for user's answer
|
||||
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
|
||||
@ -375,6 +374,7 @@ MainCommandOpenFile (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TO get the open file name
|
||||
//
|
||||
@ -400,6 +400,7 @@ MainCommandOpenFile (
|
||||
if (Status == EFI_NOT_READY) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// The input string length should > 0
|
||||
//
|
||||
@ -416,6 +417,7 @@ MainCommandOpenFile (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// read from disk
|
||||
//
|
||||
@ -529,7 +531,6 @@ MainCommandPasteLine (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
search string in file buffer
|
||||
|
||||
@ -584,6 +585,7 @@ MainCommandSearch (
|
||||
if (Status == EFI_NOT_READY) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// just enter pressed
|
||||
//
|
||||
@ -595,6 +597,7 @@ MainCommandSearch (
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// the first time , search from current position
|
||||
//
|
||||
@ -611,6 +614,7 @@ MainCommandSearch (
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Find next
|
||||
//
|
||||
@ -649,19 +653,20 @@ MainCommandSearch (
|
||||
case L'N':
|
||||
FreePool (Buffer);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of which
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of while !Done
|
||||
// for search second, third time, search from current position + strlen
|
||||
//
|
||||
Offset = StrLen (Buffer);
|
||||
|
||||
} while (1);
|
||||
|
||||
//
|
||||
// end of do
|
||||
//
|
||||
@ -744,6 +749,7 @@ MainCommandSearchReplace (
|
||||
if (Status == EFI_NOT_READY) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// if just pressed enter
|
||||
//
|
||||
@ -815,6 +821,7 @@ MainCommandSearchReplace (
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// replace or not?
|
||||
//
|
||||
@ -872,12 +879,13 @@ MainCommandSearchReplace (
|
||||
FreePool (Search);
|
||||
FreePool (Replace);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of which
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of while !Done
|
||||
// Decide to Replace
|
||||
@ -890,6 +898,7 @@ MainCommandSearchReplace (
|
||||
StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// replace all
|
||||
//
|
||||
@ -899,6 +908,7 @@ MainCommandSearchReplace (
|
||||
FreePool (Replace);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// replace
|
||||
//
|
||||
@ -909,6 +919,7 @@ MainCommandSearchReplace (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Find next
|
||||
//
|
||||
@ -951,18 +962,19 @@ MainCommandSearchReplace (
|
||||
FreePool (Search);
|
||||
FreePool (Replace);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of which
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of while !Done
|
||||
//
|
||||
First = FALSE;
|
||||
|
||||
} while (1);
|
||||
|
||||
//
|
||||
// end of do
|
||||
//
|
||||
@ -1004,7 +1016,6 @@ MainCommandExit (
|
||||
// if file has been modified, so will prompt user whether to save the changes
|
||||
//
|
||||
if (MainEditor.FileBuffer->FileModified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -1047,14 +1058,12 @@ MainCommandExit (
|
||||
case L'c':
|
||||
case L'C':
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorExit = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1086,6 +1095,7 @@ MainCommandGotoLine (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// line number's digit <= 6
|
||||
//
|
||||
@ -1103,6 +1113,7 @@ MainCommandGotoLine (
|
||||
if (Status == EFI_NOT_READY) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// if JUST press enter
|
||||
//
|
||||
@ -1115,10 +1126,11 @@ MainCommandGotoLine (
|
||||
//
|
||||
// invalid line number
|
||||
//
|
||||
if (Row > MainEditor.FileBuffer->NumLines || Row <= 0) {
|
||||
if ((Row > MainEditor.FileBuffer->NumLines) || (Row <= 0)) {
|
||||
StatusBarSetStatusString (L"No Such Line");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// move cursor to that line's start
|
||||
//
|
||||
@ -1206,11 +1218,11 @@ MainCommandSaveFile (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = InputBarSetStringSize (100);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// get new file name
|
||||
//
|
||||
@ -1289,6 +1301,7 @@ MainCommandSaveFile (
|
||||
FreePool (FileName);
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
FreePool (Info);
|
||||
|
||||
//
|
||||
@ -1376,13 +1389,15 @@ MainCommandDisplayHelp (
|
||||
if (EFI_ERROR (Status) || (EventIndex != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
|
||||
(KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
|
||||
(KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID))
|
||||
{
|
||||
//
|
||||
// For consoles that don't support/report shift state,
|
||||
// CTRL+W is translated to L'W' - L'A' + 1.
|
||||
@ -1392,7 +1407,8 @@ MainCommandDisplayHelp (
|
||||
}
|
||||
} else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
|
||||
((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
|
||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
|
||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0))
|
||||
{
|
||||
//
|
||||
// For consoles that supports/reports shift state,
|
||||
// make sure that only CONTROL shift key is pressed.
|
||||
@ -1402,6 +1418,7 @@ MainCommandDisplayHelp (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// update screen with file buffer's info
|
||||
//
|
||||
@ -1416,7 +1433,6 @@ MainCommandDisplayHelp (
|
||||
EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
|
||||
INTN OriginalMode;
|
||||
|
||||
|
||||
//
|
||||
// basic initialization for MainEditor
|
||||
//
|
||||
@ -1510,7 +1526,7 @@ MainEditorInit (
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (!EFI_ERROR (Status) && HandleCount > 0) {
|
||||
if (!EFI_ERROR (Status) && (HandleCount > 0)) {
|
||||
//
|
||||
// Try to find the first available mouse device
|
||||
//
|
||||
@ -1525,12 +1541,13 @@ MainEditorInit (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) && MainEditor.MouseInterface != NULL) {
|
||||
if (!EFI_ERROR (Status) && (MainEditor.MouseInterface != NULL)) {
|
||||
MainEditor.MouseAccumulatorX = 0;
|
||||
MainEditor.MouseAccumulatorY = 0;
|
||||
MainEditor.MouseSupported = TRUE;
|
||||
@ -1565,6 +1582,7 @@ MainEditorInit (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), gShellDebug1HiiHandle);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// clear whole screen and enable cursor
|
||||
//
|
||||
@ -1608,12 +1626,14 @@ MainEditorCleanup (
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gShellDebug1HiiHandle);
|
||||
}
|
||||
|
||||
//
|
||||
// restore old mode
|
||||
//
|
||||
if (OriginalMode != gST->ConOut->Mode->Mode) {
|
||||
gST->ConOut->SetMode (gST->ConOut, OriginalMode);
|
||||
}
|
||||
|
||||
//
|
||||
// restore old screen color
|
||||
//
|
||||
@ -1644,21 +1664,21 @@ MainEditorRefresh (
|
||||
// call the components refresh function
|
||||
//
|
||||
if ( EditorFirst
|
||||
|| StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0
|
||||
|| FileBufferBackupVar.FileType != FileBuffer.FileType
|
||||
|| FileBufferBackupVar.FileModified != FileBuffer.FileModified
|
||||
|| FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly) {
|
||||
|
||||
|| (StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0)
|
||||
|| (FileBufferBackupVar.FileType != FileBuffer.FileType)
|
||||
|| (FileBufferBackupVar.FileModified != FileBuffer.FileModified)
|
||||
|| (FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly))
|
||||
{
|
||||
MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
|
||||
FileBufferRestorePosition ();
|
||||
}
|
||||
|
||||
if ( EditorFirst
|
||||
|| FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row
|
||||
|| FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column
|
||||
|| FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert
|
||||
|| StatusBarGetRefresh()) {
|
||||
|
||||
|| (FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row)
|
||||
|| (FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column)
|
||||
|| (FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert)
|
||||
|| StatusBarGetRefresh ())
|
||||
{
|
||||
StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert);
|
||||
FileBufferRestorePosition ();
|
||||
}
|
||||
@ -1731,7 +1751,6 @@ MainEditorHandleMouseInput (
|
||||
IN EFI_SIMPLE_POINTER_STATE MouseState
|
||||
)
|
||||
{
|
||||
|
||||
INT32 TextX;
|
||||
INT32 TextY;
|
||||
UINTN FRow;
|
||||
@ -1763,14 +1782,12 @@ MainEditorHandleMouseInput (
|
||||
FileBufferAdjustMousePosition (TextX, TextY);
|
||||
|
||||
Action = TRUE;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// if left button pushed down
|
||||
//
|
||||
if (MouseState.LeftButton) {
|
||||
|
||||
FCol = MainEditor.FileBuffer->MousePosition.Column - 1 + 1;
|
||||
|
||||
FRow = MainEditor.FileBuffer->FilePosition.Row +
|
||||
@ -1806,6 +1823,7 @@ MainEditorHandleMouseInput (
|
||||
|
||||
Action = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// mouse has action
|
||||
//
|
||||
@ -1837,7 +1855,6 @@ MainEditorKeyInput (
|
||||
BOOLEAN NoShiftState;
|
||||
|
||||
do {
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
EditorMouseAction = FALSE;
|
||||
|
||||
@ -1857,7 +1874,6 @@ MainEditorKeyInput (
|
||||
&MouseState
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
Status = MainEditorHandleMouseInput (MouseState);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -1903,22 +1919,21 @@ MainEditorKeyInput (
|
||||
FileBufferMouseNeedRefresh = FALSE;
|
||||
}
|
||||
|
||||
if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_OUT_OF_RESOURCES)) {
|
||||
//
|
||||
// not already has some error status
|
||||
//
|
||||
if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {
|
||||
if ((StatusBarGetString () != NULL) && (StrCmp (L"", StatusBarGetString ()) == 0)) {
|
||||
StatusBarSetStatusString (L"Disk Error. Try Again");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
// after handling, refresh editor
|
||||
//
|
||||
MainEditorRefresh ();
|
||||
|
||||
} while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
|
||||
|
||||
return Status;
|
||||
@ -1947,6 +1962,7 @@ MainEditorSetCutLine (
|
||||
//
|
||||
LineFree (MainEditor.CutLine);
|
||||
}
|
||||
|
||||
//
|
||||
// duplicate the line to clipboard
|
||||
//
|
||||
|
@ -31,6 +31,7 @@ LineDup (
|
||||
if (Dest == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// allocate and set the line buffer
|
||||
//
|
||||
@ -65,20 +66,10 @@ LineFree (
|
||||
if (Src == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// free the line buffer and then the line structure itself
|
||||
//
|
||||
SHELL_FREE_NON_NULL (Src->Buffer);
|
||||
SHELL_FREE_NON_NULL (Src);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include "TextEditorTypes.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Free a EFI_EDITOR_LINE structure.
|
||||
|
||||
@ -36,9 +34,4 @@ LineDup (
|
||||
IN EFI_EDITOR_LINE *Src
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -91,7 +91,6 @@ typedef struct {
|
||||
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
|
||||
INT32 MouseAccumulatorX;
|
||||
INT32 MouseAccumulatorY;
|
||||
|
||||
} EFI_EDITOR_GLOBAL_EDITOR;
|
||||
|
||||
#endif
|
||||
|
@ -106,7 +106,6 @@ typedef union {
|
||||
UINTN Data;
|
||||
} INPUT_BAR_COLOR_UNION;
|
||||
|
||||
|
||||
/**
|
||||
The refresh function for InputBar, it will wait for user input
|
||||
|
||||
@ -168,6 +167,7 @@ InputBarRefresh (
|
||||
} else {
|
||||
NoDisplay = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// wait for user input
|
||||
//
|
||||
@ -176,17 +176,21 @@ InputBarRefresh (
|
||||
if (EFI_ERROR (Status) || (EventIndex != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = mTextInEx->ReadKeyStrokeEx (mTextInEx, &KeyData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
|
||||
(KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID)) {
|
||||
(KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID))
|
||||
{
|
||||
//
|
||||
// Shift key pressed.
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// pressed ESC
|
||||
//
|
||||
@ -195,10 +199,11 @@ InputBarRefresh (
|
||||
Status = EFI_NOT_READY;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// return pressed
|
||||
//
|
||||
if (KeyData.Key.UnicodeChar == CHAR_LINEFEED || KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
|
||||
if ((KeyData.Key.UnicodeChar == CHAR_LINEFEED) || (KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {
|
||||
break;
|
||||
} else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {
|
||||
//
|
||||
@ -208,12 +213,10 @@ InputBarRefresh (
|
||||
Size--;
|
||||
mReturnString[Size] = CHAR_NULL;
|
||||
if (!NoDisplay) {
|
||||
|
||||
InputBarPrintInput (LastColumn, LastRow);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (KeyData.Key.UnicodeChar <= 127 && KeyData.Key.UnicodeChar >= 32) {
|
||||
} else if ((KeyData.Key.UnicodeChar <= 127) && (KeyData.Key.UnicodeChar >= 32)) {
|
||||
//
|
||||
// VALID ASCII char pressed
|
||||
//
|
||||
@ -231,22 +234,18 @@ InputBarRefresh (
|
||||
mReturnString[Size] = CHAR_NULL;
|
||||
|
||||
if (!NoDisplay) {
|
||||
|
||||
InputBarPrintInput (LastColumn, LastRow);
|
||||
|
||||
} else {
|
||||
//
|
||||
// if just choose yes/no
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mReturnString[Size] = CHAR_NULL;
|
||||
|
||||
|
||||
//
|
||||
// restore screen attributes
|
||||
//
|
||||
|
@ -40,12 +40,14 @@ MenuBarInit (
|
||||
{
|
||||
CONST EDITOR_MENU_ITEM *ItemsWalker;
|
||||
|
||||
for (NumItems = 0, ItemsWalker = Items ; ItemsWalker != NULL && ItemsWalker->Function != NULL ; ItemsWalker++,NumItems++);
|
||||
for (NumItems = 0, ItemsWalker = Items; ItemsWalker != NULL && ItemsWalker->Function != NULL; ItemsWalker++, NumItems++) {
|
||||
}
|
||||
|
||||
MenuItems = AllocateZeroPool ((NumItems+1) * sizeof (EDITOR_MENU_ITEM));
|
||||
if (MenuItems == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (MenuItems, Items, (NumItems+1) * sizeof (EDITOR_MENU_ITEM));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -65,6 +67,7 @@ ControlHotKeyInit (
|
||||
ControlBasedMenuFunctions = Items;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Refresh function for the menu bar.
|
||||
|
||||
@ -99,16 +102,12 @@ MenuBarRefresh (
|
||||
EditorClearLine (LastRow - 1, LastCol, LastRow);
|
||||
EditorClearLine (LastRow, LastCol, LastRow);
|
||||
|
||||
|
||||
//
|
||||
// print out the menu items
|
||||
//
|
||||
for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) {
|
||||
|
||||
|
||||
NameString = HiiGetString (gShellDebug1HiiHandle, Item->NameToken, NULL);
|
||||
|
||||
|
||||
Width = MAX ((StrLen (NameString) + 6), 20);
|
||||
if (((Col + Width) > LastCol)) {
|
||||
Row++;
|
||||
@ -178,7 +177,8 @@ MenuBarDispatchControlHotKey (
|
||||
ControlIndex = MAX_UINT16;
|
||||
|
||||
if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
|
||||
(KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
|
||||
(KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID))
|
||||
{
|
||||
//
|
||||
// For consoles that don't support/report shift state,
|
||||
// Ctrl+A is translated to 1 (UnicodeChar).
|
||||
@ -186,7 +186,8 @@ MenuBarDispatchControlHotKey (
|
||||
ControlIndex = KeyData->Key.UnicodeChar;
|
||||
} else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
|
||||
((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
|
||||
((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {
|
||||
((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0))
|
||||
{
|
||||
//
|
||||
// For consoles that supports/reports shift state,
|
||||
// make sure only CONTROL is pressed.
|
||||
@ -197,6 +198,7 @@ MenuBarDispatchControlHotKey (
|
||||
ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (SCAN_CONTROL_Z < ControlIndex)
|
||||
|| (NULL == ControlBasedMenuFunctions[ControlIndex]))
|
||||
{
|
||||
@ -206,5 +208,3 @@ MenuBarDispatchControlHotKey (
|
||||
ControlBasedMenuFunctions[ControlIndex]();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#define SCAN_CONTROL_W 23
|
||||
#define SCAN_CONTROL_Z 26
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*MENU_ITEM_FUNCTION) (
|
||||
|
@ -91,6 +91,7 @@ StatusBarRefresh (
|
||||
if (!StatusStringChanged && StatusBarNeedRefresh) {
|
||||
StatusBarSetStatusString (L"\0");
|
||||
}
|
||||
|
||||
//
|
||||
// when it's called first time after editor launch, so refresh is mandatory
|
||||
//
|
||||
@ -117,7 +118,7 @@ StatusBarRefresh (
|
||||
//
|
||||
// print row, column fields
|
||||
//
|
||||
if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) {
|
||||
if ((FileRow != (UINTN)(-1)) && (FileCol != (UINTN)(-1))) {
|
||||
ShellPrintEx (
|
||||
0,
|
||||
(INT32)(LastRow) - 1,
|
||||
@ -143,6 +144,7 @@ StatusBarRefresh (
|
||||
} else {
|
||||
ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
|
||||
}
|
||||
|
||||
//
|
||||
// restore the old screen attributes
|
||||
//
|
||||
|
@ -34,6 +34,7 @@ MainTitleBarInit (
|
||||
//
|
||||
Title = CatSPrint (NULL, L"%s", Prompt);
|
||||
}
|
||||
|
||||
if (Title == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -94,7 +95,6 @@ MainTitleBarRefresh (
|
||||
CONST CHAR16 *FileNameTmp;
|
||||
INTN TempInteger;
|
||||
|
||||
|
||||
//
|
||||
// backup the old screen attributes
|
||||
//
|
||||
@ -121,10 +121,12 @@ MainTitleBarRefresh (
|
||||
Title
|
||||
);
|
||||
}
|
||||
|
||||
if (FileName == NULL) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// First Extract the FileName from fullpath
|
||||
//
|
||||
@ -145,16 +147,17 @@ MainTitleBarRefresh (
|
||||
for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) {
|
||||
ShellPrintEx (-1, -1, L" ");
|
||||
}
|
||||
|
||||
} else {
|
||||
for (TempInteger = 0; TempInteger < 17; TempInteger++) {
|
||||
ShellPrintEx (-1, -1, L"%c", FileNameTmp[TempInteger]);
|
||||
}
|
||||
|
||||
//
|
||||
// print "..."
|
||||
//
|
||||
ShellPrintEx (-1, -1, L"... ");
|
||||
}
|
||||
|
||||
//
|
||||
// print file type field
|
||||
//
|
||||
@ -166,6 +169,7 @@ MainTitleBarRefresh (
|
||||
} else {
|
||||
ShellPrintEx (-1, -1, L" UNICODE ");
|
||||
}
|
||||
|
||||
//
|
||||
// print read-only field for text files
|
||||
//
|
||||
@ -174,6 +178,7 @@ MainTitleBarRefresh (
|
||||
} else {
|
||||
ShellPrintEx (-1, -1, L" ");
|
||||
}
|
||||
|
||||
break;
|
||||
case FileTypeDiskBuffer:
|
||||
case FileTypeMemBuffer:
|
||||
@ -186,12 +191,14 @@ MainTitleBarRefresh (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// print modified field
|
||||
//
|
||||
if (Modified) {
|
||||
ShellPrintEx (-1, -1, L"Modified");
|
||||
}
|
||||
|
||||
//
|
||||
// restore the old attribute
|
||||
//
|
||||
|
@ -63,7 +63,7 @@ ShellCommandRunEfiCompress (
|
||||
//
|
||||
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"eficompress", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -90,22 +90,26 @@ ShellCommandRunEfiCompress (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (ShellIsDirectory (OutFileName) == EFI_SUCCESS) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
Status = ShellOpenFileByName (InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue (Package, 1));
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
|
||||
Status = ShellOpenFileByName (OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue (Package, 2));
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
Status = gEfiShellProtocol->GetFileSize (InShellFileHandle, &InSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -127,6 +131,7 @@ ShellCommandRunEfiCompress (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status);
|
||||
ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : SHELL_DEVICE_ERROR);
|
||||
@ -144,12 +149,15 @@ ShellCommandRunEfiCompress (
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
if (InShellFileHandle != NULL) {
|
||||
gEfiShellProtocol->CloseFile (InShellFileHandle);
|
||||
}
|
||||
|
||||
if (OutShellFileHandle != NULL) {
|
||||
gEfiShellProtocol->CloseFile (OutShellFileHandle);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (InFileName);
|
||||
SHELL_FREE_NON_NULL (InBuffer);
|
||||
SHELL_FREE_NON_NULL (OutBuffer);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "UefiShellDebug1CommandsLib.h"
|
||||
#include <Protocol/Decompress.h>
|
||||
|
||||
|
||||
/**
|
||||
Function for 'decompress' command.
|
||||
|
||||
@ -70,7 +69,7 @@ ShellCommandRunEfiDecompress (
|
||||
//
|
||||
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"efidecompress", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -97,10 +96,12 @@ ShellCommandRunEfiDecompress (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", InFileName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (ShellIsDirectory (OutFileName) == EFI_SUCCESS) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", OutFileName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
Status = ShellOpenFileByName (InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -127,7 +128,7 @@ ShellCommandRunEfiDecompress (
|
||||
Status = Decompress->GetInfo (Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status) || OutSize == 0) {
|
||||
if (EFI_ERROR (Status) || (OutSize == 0)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
@ -138,7 +139,7 @@ ShellCommandRunEfiDecompress (
|
||||
} else {
|
||||
OutBuffer = AllocateZeroPool (OutSize);
|
||||
ScratchBuffer = AllocateZeroPool (ScratchSize);
|
||||
if (OutBuffer == NULL || ScratchBuffer == NULL) {
|
||||
if ((OutBuffer == NULL) || (ScratchBuffer == NULL)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
Status = Decompress->Decompress (Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
|
||||
@ -164,9 +165,11 @@ ShellCommandRunEfiDecompress (
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
if (InFileHandle != NULL) {
|
||||
gEfiShellProtocol->CloseFile (InFileHandle);
|
||||
}
|
||||
|
||||
if (OutFileHandle != NULL) {
|
||||
gEfiShellProtocol->CloseFile (OutFileHandle);
|
||||
}
|
||||
|
@ -226,7 +226,6 @@ HBufferImageCleanup (
|
||||
HDiskImageCleanup ();
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +249,6 @@ HBufferImagePrintLine (
|
||||
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Index;
|
||||
UINTN Pos;
|
||||
BOOLEAN Selected;
|
||||
@ -270,14 +268,14 @@ HBufferImagePrintLine (
|
||||
//
|
||||
// print the selected area in opposite color
|
||||
//
|
||||
if (HMainEditor.SelectStart != 0 && HMainEditor.SelectEnd != 0) {
|
||||
if ((HMainEditor.SelectStart != 0) && (HMainEditor.SelectEnd != 0)) {
|
||||
RowStart = (HMainEditor.SelectStart - 1) / 0x10 + 1;
|
||||
RowEnd = (HMainEditor.SelectEnd - 1) / 0x10 + 1;
|
||||
|
||||
ColStart = (HMainEditor.SelectStart - 1) % 0x10 + 1;
|
||||
ColEnd = (HMainEditor.SelectEnd - 1) % 0x10 + 1;
|
||||
|
||||
if (FRow >= RowStart && FRow <= RowEnd) {
|
||||
if ((FRow >= RowStart) && (FRow <= RowEnd)) {
|
||||
Selected = TRUE;
|
||||
}
|
||||
|
||||
@ -288,7 +286,6 @@ HBufferImagePrintLine (
|
||||
if (FRow < RowEnd) {
|
||||
ColEnd = 0x10;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!HEditorMouseAction) {
|
||||
@ -298,15 +295,13 @@ HBufferImagePrintLine (
|
||||
L"%8X ",
|
||||
((INT32)Row - 2 + HBufferImage.LowVisibleRow - 1) * 0x10
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
for (Index = 0; Index < 0x08 && Index < Line->Size; Index++) {
|
||||
|
||||
BeNewColor = FALSE;
|
||||
|
||||
if (Selected) {
|
||||
if (Index + 1 >= ColStart && Index + 1 <= ColEnd) {
|
||||
if ((Index + 1 >= ColStart) && (Index + 1 <= ColEnd)) {
|
||||
BeNewColor = TRUE;
|
||||
}
|
||||
}
|
||||
@ -328,7 +323,6 @@ HBufferImagePrintLine (
|
||||
} else {
|
||||
ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%x ", Line->Buffer[Index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
|
||||
@ -339,11 +333,10 @@ HBufferImagePrintLine (
|
||||
}
|
||||
|
||||
while (Index < 0x10 && Index < Line->Size) {
|
||||
|
||||
BeNewColor = FALSE;
|
||||
|
||||
if (Selected) {
|
||||
if (Index + 1 >= ColStart && Index + 1 <= ColEnd) {
|
||||
if ((Index + 1 >= ColStart) && (Index + 1 <= ColEnd)) {
|
||||
BeNewColor = TRUE;
|
||||
}
|
||||
}
|
||||
@ -370,6 +363,7 @@ HBufferImagePrintLine (
|
||||
ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
|
||||
Index++;
|
||||
}
|
||||
|
||||
//
|
||||
// restore the original color
|
||||
//
|
||||
@ -398,6 +392,7 @@ HBufferImagePrintLine (
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// restore the abundant blank in hex edit area to original color
|
||||
//
|
||||
@ -489,9 +484,10 @@ HBufferImageIsInSelectedArea (
|
||||
//
|
||||
// not select
|
||||
//
|
||||
if (HMainEditor.SelectStart == 0 || HMainEditor.SelectEnd == 0) {
|
||||
if ((HMainEditor.SelectStart == 0) || (HMainEditor.SelectEnd == 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// calculate the select area
|
||||
//
|
||||
@ -502,7 +498,7 @@ HBufferImageIsInSelectedArea (
|
||||
ColEnd = (HMainEditor.SelectEnd - 1) % 0x10 + 1;
|
||||
|
||||
FRow = HBufferImage.LowVisibleRow + MouseRow - 2;
|
||||
if (FRow < RowStart || FRow > RowEnd) {
|
||||
if ((FRow < RowStart) || (FRow > RowEnd)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -524,7 +520,7 @@ HBufferImageIsInSelectedArea (
|
||||
MouseColEnd++;
|
||||
}
|
||||
|
||||
if (MouseCol < MouseColStart || MouseCol > MouseColEnd) {
|
||||
if ((MouseCol < MouseColStart) || (MouseCol > MouseColEnd)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -553,9 +549,7 @@ HBufferImageRestoreMousePosition (
|
||||
|
||||
Line = NULL;
|
||||
if (HMainEditor.MouseSupported) {
|
||||
|
||||
if (HBufferImageMouseNeedRefresh) {
|
||||
|
||||
HBufferImageMouseNeedRefresh = FALSE;
|
||||
|
||||
//
|
||||
@ -563,13 +557,15 @@ HBufferImageRestoreMousePosition (
|
||||
// so do not need to refresh mouse position
|
||||
//
|
||||
if ((
|
||||
HBufferImage.MousePosition.Row == HBufferImageBackupVar.MousePosition.Row &&
|
||||
HBufferImage.MousePosition.Column == HBufferImageBackupVar.MousePosition.Column
|
||||
(HBufferImage.MousePosition.Row == HBufferImageBackupVar.MousePosition.Row) &&
|
||||
(HBufferImage.MousePosition.Column == HBufferImageBackupVar.MousePosition.Column)
|
||||
) &&
|
||||
HEditorMouseAction
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// backup the old screen attributes
|
||||
//
|
||||
@ -585,11 +581,13 @@ HBufferImageRestoreMousePosition (
|
||||
if (!HBufferImageIsInSelectedArea (
|
||||
HBufferImageBackupVar.MousePosition.Row,
|
||||
HBufferImageBackupVar.MousePosition.Column
|
||||
)) {
|
||||
))
|
||||
{
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
} else {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
}
|
||||
|
||||
//
|
||||
// clear the old mouse position
|
||||
//
|
||||
@ -601,13 +599,13 @@ HBufferImageRestoreMousePosition (
|
||||
);
|
||||
|
||||
HasCharacter = TRUE;
|
||||
if (FRow > HBufferImage.NumLines || FColumn == 0) {
|
||||
if ((FRow > HBufferImage.NumLines) || (FColumn == 0)) {
|
||||
HasCharacter = FALSE;
|
||||
} else {
|
||||
CurrentLine = HBufferImage.CurrentLine;
|
||||
Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);
|
||||
|
||||
if (Line == NULL || FColumn > Line->Size) {
|
||||
if ((Line == NULL) || (FColumn > Line->Size)) {
|
||||
HasCharacter = FALSE;
|
||||
}
|
||||
|
||||
@ -639,11 +637,13 @@ HBufferImageRestoreMousePosition (
|
||||
if (!HBufferImageIsInSelectedArea (
|
||||
HBufferImage.MousePosition.Row,
|
||||
HBufferImage.MousePosition.Column
|
||||
)) {
|
||||
))
|
||||
{
|
||||
gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
|
||||
} else {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
}
|
||||
|
||||
//
|
||||
// clear the old mouse position
|
||||
//
|
||||
@ -655,13 +655,13 @@ HBufferImageRestoreMousePosition (
|
||||
);
|
||||
|
||||
HasCharacter = TRUE;
|
||||
if (FRow > HBufferImage.NumLines || FColumn == 0) {
|
||||
if ((FRow > HBufferImage.NumLines) || (FColumn == 0)) {
|
||||
HasCharacter = FALSE;
|
||||
} else {
|
||||
CurrentLine = HBufferImage.CurrentLine;
|
||||
Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);
|
||||
|
||||
if (Line == NULL || FColumn > Line->Size) {
|
||||
if ((Line == NULL) || (FColumn > Line->Size)) {
|
||||
HasCharacter = FALSE;
|
||||
}
|
||||
|
||||
@ -689,15 +689,18 @@ HBufferImageRestoreMousePosition (
|
||||
Value
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// end of HasCharacter
|
||||
//
|
||||
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
|
||||
}
|
||||
|
||||
//
|
||||
// end of MouseNeedRefresh
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of MouseSupported
|
||||
//
|
||||
@ -764,8 +767,9 @@ HBufferImageRefresh (
|
||||
//
|
||||
if (!HBufferImageNeedRefresh &&
|
||||
!HBufferImageOnlyLineNeedRefresh &&
|
||||
HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow
|
||||
) {
|
||||
(HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow)
|
||||
)
|
||||
{
|
||||
HBufferImageRestoreMousePosition ();
|
||||
HBufferImageRestorePosition ();
|
||||
return EFI_SUCCESS;
|
||||
@ -777,8 +781,7 @@ HBufferImageRefresh (
|
||||
//
|
||||
// only need to refresh current line
|
||||
//
|
||||
if (HBufferImageOnlyLineNeedRefresh && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {
|
||||
|
||||
if (HBufferImageOnlyLineNeedRefresh && (HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow)) {
|
||||
HBufferImagePrintLine (
|
||||
HBufferImage.CurrentLine,
|
||||
HBufferImage.DisplayPosition.Row,
|
||||
@ -790,9 +793,9 @@ HBufferImageRefresh (
|
||||
//
|
||||
// the whole edit area need refresh
|
||||
//
|
||||
if (HEditorMouseAction && HMainEditor.SelectStart != 0 && HMainEditor.SelectEnd != 0) {
|
||||
if (HEditorMouseAction && (HMainEditor.SelectStart != 0) && (HMainEditor.SelectEnd != 0)) {
|
||||
if (HMainEditor.SelectStart != HMainEditorBackupVar.SelectStart) {
|
||||
if (HMainEditor.SelectStart >= HMainEditorBackupVar.SelectStart && HMainEditorBackupVar.SelectStart != 0) {
|
||||
if ((HMainEditor.SelectStart >= HMainEditorBackupVar.SelectStart) && (HMainEditorBackupVar.SelectStart != 0)) {
|
||||
StartRow = (HMainEditorBackupVar.SelectStart - 1) / 0x10 + 1;
|
||||
} else {
|
||||
StartRow = (HMainEditor.SelectStart - 1) / 0x10 + 1;
|
||||
@ -806,6 +809,7 @@ HBufferImageRefresh (
|
||||
} else {
|
||||
EndRow = (HMainEditor.SelectEnd - 1) / 0x10 + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// swap
|
||||
//
|
||||
@ -819,7 +823,6 @@ HBufferImageRefresh (
|
||||
|
||||
StartRow = 2 + StartRow - HBufferImage.LowVisibleRow;
|
||||
EndRow = 2 + EndRow - HBufferImage.LowVisibleRow;
|
||||
|
||||
} else {
|
||||
//
|
||||
// not mouse selection actions
|
||||
@ -828,6 +831,7 @@ HBufferImageRefresh (
|
||||
StartRow = 2;
|
||||
EndRow = (HMainEditor.ScreenSize.Row - 1);
|
||||
}
|
||||
|
||||
//
|
||||
// no line
|
||||
//
|
||||
@ -837,6 +841,7 @@ HBufferImageRefresh (
|
||||
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// get the first line that will be displayed
|
||||
//
|
||||
@ -870,6 +875,7 @@ HBufferImageRefresh (
|
||||
EditorClearLine (Row, HMainEditor.ScreenSize.Column, HMainEditor.ScreenSize.Row);
|
||||
Row++;
|
||||
}
|
||||
|
||||
//
|
||||
// while not file end and not screen full
|
||||
//
|
||||
@ -1101,15 +1107,15 @@ HBufferImageCharToHex (
|
||||
//
|
||||
// change the character to hex
|
||||
//
|
||||
if (Char >= L'0' && Char <= L'9') {
|
||||
if ((Char >= L'0') && (Char <= L'9')) {
|
||||
return (Char - L'0');
|
||||
}
|
||||
|
||||
if (Char >= L'a' && Char <= L'f') {
|
||||
if ((Char >= L'a') && (Char <= L'f')) {
|
||||
return (Char - L'a' + 10);
|
||||
}
|
||||
|
||||
if (Char >= L'A' && Char <= L'F') {
|
||||
if ((Char >= L'A') && (Char <= L'F')) {
|
||||
return (Char - L'A' + 10);
|
||||
}
|
||||
|
||||
@ -1168,7 +1174,6 @@ HBufferImageAddChar (
|
||||
Line->Size++;
|
||||
High = FALSE;
|
||||
} else {
|
||||
|
||||
Old = Line->Buffer[FCol - 1];
|
||||
|
||||
//
|
||||
@ -1183,8 +1188,7 @@ HBufferImageAddChar (
|
||||
// at the low 4 bits of the last character of a full line
|
||||
// so if no next line, need to create a new line
|
||||
//
|
||||
if (!High && FCol == 0x10) {
|
||||
|
||||
if (!High && (FCol == 0x10)) {
|
||||
HBufferImageOnlyLineNeedRefresh = FALSE;
|
||||
HBufferImageNeedRefresh = TRUE;
|
||||
|
||||
@ -1198,20 +1202,23 @@ HBufferImageAddChar (
|
||||
if (NewLine == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// end of NULL
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of == ListHead
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// end of == 0x10
|
||||
//
|
||||
// if already at end of this line, scroll it to the start of next line
|
||||
//
|
||||
if (FCol == 0x10 && !High) {
|
||||
if ((FCol == 0x10) && !High) {
|
||||
//
|
||||
// definitely has next line
|
||||
//
|
||||
@ -1231,12 +1238,13 @@ HBufferImageAddChar (
|
||||
} else {
|
||||
High = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// end of ==FALSE
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// move cursor to right
|
||||
//
|
||||
@ -1273,7 +1281,7 @@ HBufferImageDoBackspace (
|
||||
//
|
||||
// already the first character
|
||||
//
|
||||
if (HBufferImage.BufferPosition.Row == 1 && HBufferImage.BufferPosition.Column == 1) {
|
||||
if ((HBufferImage.BufferPosition.Row == 1) && (HBufferImage.BufferPosition.Column == 1)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1283,7 +1291,7 @@ HBufferImageDoBackspace (
|
||||
|
||||
Line = HBufferImage.CurrentLine;
|
||||
LastLine = FALSE;
|
||||
if (Line->Link.ForwardLink == HBufferImage.ListHead && FileColumn > 1) {
|
||||
if ((Line->Link.ForwardLink == HBufferImage.ListHead) && (FileColumn > 1)) {
|
||||
LastLine = TRUE;
|
||||
}
|
||||
|
||||
@ -1346,7 +1354,7 @@ HBufferImageDoCharInput (
|
||||
//
|
||||
// DEAL WITH ASCII CHAR, filter out thing like ctrl+f
|
||||
//
|
||||
if (Char > 127 || Char < 32) {
|
||||
if ((Char > 127) || (Char < 32)) {
|
||||
Status = StatusBarSetStatusString (L"Unknown Command");
|
||||
} else {
|
||||
Status = HBufferImageAddChar (Char);
|
||||
@ -1461,7 +1469,6 @@ HBufferImageMovePosition (
|
||||
} else {
|
||||
HBufferImage.DisplayPosition.Row += RowGap;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1487,7 +1494,6 @@ HBufferImageMovePosition (
|
||||
// let CurrentLine point to correct line;
|
||||
//
|
||||
HBufferImage.CurrentLine = HMoveCurrentLine (RowGap);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1521,6 +1527,7 @@ HBufferImageScrollRight (
|
||||
if (FCol > Line->Size) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// if already at end of this line, scroll it to the start of next line
|
||||
//
|
||||
@ -1531,7 +1538,6 @@ HBufferImageScrollRight (
|
||||
if (Line->Link.ForwardLink != HBufferImage.ListHead) {
|
||||
FRow++;
|
||||
FCol = 1;
|
||||
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1540,7 +1546,6 @@ HBufferImageScrollRight (
|
||||
// if not at end of this line, just move to next column
|
||||
//
|
||||
FCol++;
|
||||
|
||||
}
|
||||
|
||||
HBufferImageMovePosition (FRow, FCol, TRUE);
|
||||
@ -1558,7 +1563,6 @@ HBufferImageScrollLeft (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
HEFI_EDITOR_LINE *Line;
|
||||
UINTN FRow;
|
||||
UINTN FCol;
|
||||
@ -1632,7 +1636,6 @@ HBufferImageScrollDown (
|
||||
FCol = Line->Size + 1;
|
||||
HighBits = TRUE;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1666,7 +1669,6 @@ HBufferImageScrollUp (
|
||||
//
|
||||
if (Line->Link.BackLink != HBufferImage.ListHead) {
|
||||
FRow--;
|
||||
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1709,6 +1711,7 @@ HBufferImagePageDown (
|
||||
//
|
||||
Gap = HBufferImage.NumLines - FRow;
|
||||
}
|
||||
|
||||
//
|
||||
// get correct line
|
||||
//
|
||||
@ -1717,7 +1720,7 @@ HBufferImagePageDown (
|
||||
//
|
||||
// if that line, is not that long, so move to the end of that line
|
||||
//
|
||||
if (Line != NULL && FCol > Line->Size) {
|
||||
if ((Line != NULL) && (FCol > Line->Size)) {
|
||||
FCol = Line->Size + 1;
|
||||
HighBits = TRUE;
|
||||
}
|
||||
@ -1829,6 +1832,7 @@ HBufferImageEnd (
|
||||
FCol = Line->Size + 1;
|
||||
HighBits = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// move cursor position
|
||||
//
|
||||
@ -1928,7 +1932,6 @@ HBufferImageDeleteCharacterFromBuffer (
|
||||
// so locate according to block's previous character
|
||||
//
|
||||
NewPos = Pos - 1;
|
||||
|
||||
} else {
|
||||
//
|
||||
// has no character before it,
|
||||
@ -1956,6 +1959,7 @@ HBufferImageDeleteCharacterFromBuffer (
|
||||
DeleteBuffer[Index] = BufferPtr[Pos + Index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// delete the part from Pos
|
||||
//
|
||||
@ -1986,7 +1990,7 @@ HBufferImageDeleteCharacterFromBuffer (
|
||||
// if current cursor position if inside select area
|
||||
// then move it to the block's NEXT character
|
||||
//
|
||||
if (OldPos >= Pos && OldPos < (Pos + Count)) {
|
||||
if ((OldPos >= Pos) && (OldPos < (Pos + Count))) {
|
||||
NewPos = Pos;
|
||||
} else {
|
||||
if (OldPos < Pos) {
|
||||
@ -2068,6 +2072,7 @@ HBufferImageAddCharacterToBuffer (
|
||||
for (Index = (INTN)(Size + Count - 1); Index >= (INTN)Pos; Index--) {
|
||||
BufferPtr[Index] = BufferPtr[Index - Count];
|
||||
}
|
||||
|
||||
//
|
||||
// add the buffer
|
||||
//
|
||||
@ -2112,7 +2117,6 @@ HBufferImageDoDelete (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
HEFI_EDITOR_LINE *Line;
|
||||
|
||||
BOOLEAN LastLine;
|
||||
@ -2207,13 +2211,12 @@ HBufferImageBufferToList (
|
||||
Line->Buffer[TempJ] = BufferPtr[TempI];
|
||||
TempI++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// last line is a full line, SO create a new line
|
||||
//
|
||||
if (Left == 0x10 || Bytes == 0) {
|
||||
if ((Left == 0x10) || (Bytes == 0)) {
|
||||
Line = HBufferImageCreateLine ();
|
||||
if (Line == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -2258,7 +2261,6 @@ HBufferImageListToBuffer (
|
||||
// deal line by line
|
||||
//
|
||||
while (Link != HBufferImage.ListHead) {
|
||||
|
||||
Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
|
||||
|
||||
// @todo shouldn't this be an error???
|
||||
@ -2308,6 +2310,7 @@ HBufferImageAdjustMousePosition (
|
||||
} else {
|
||||
AbsX = -TextX;
|
||||
}
|
||||
|
||||
//
|
||||
// get absolute TempY value
|
||||
//
|
||||
@ -2339,29 +2342,30 @@ HBufferImageAdjustMousePosition (
|
||||
TempY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check whether new mouse column position is beyond screen
|
||||
// if not, adjust it
|
||||
//
|
||||
if (TempX >= 10 && TempX <= (10 + 0x10 * 3 - 1)) {
|
||||
if ((TempX >= 10) && (TempX <= (10 + 0x10 * 3 - 1))) {
|
||||
HBufferImage.MousePosition.Column = TempX;
|
||||
} else if (TempX < 10) {
|
||||
HBufferImage.MousePosition.Column = 10;
|
||||
} else if (TempX > (10 + 0x10 * 3 - 1)) {
|
||||
HBufferImage.MousePosition.Column = 10 + 0x10 * 3 - 1;
|
||||
}
|
||||
|
||||
//
|
||||
// check whether new mouse row position is beyond screen
|
||||
// if not, adjust it
|
||||
//
|
||||
if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 1)) {
|
||||
if ((TempY >= 2) && (TempY <= (HMainEditor.ScreenSize.Row - 1))) {
|
||||
HBufferImage.MousePosition.Row = TempY;
|
||||
} else if (TempY < 2) {
|
||||
HBufferImage.MousePosition.Row = 2;
|
||||
} else if (TempY > (HMainEditor.ScreenSize.Row - 1)) {
|
||||
HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2466,4 +2470,3 @@ HBufferImageHandleInput (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,6 @@ HBufferImageMovePosition (
|
||||
IN BOOLEAN HighBits
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create a new line and append it to the line list.
|
||||
Fields affected:
|
||||
|
@ -53,7 +53,6 @@ HClipBoardCleanup (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
SHELL_FREE_NON_NULL (HClipBoard.Buffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -178,6 +178,7 @@ HDiskImageRead (
|
||||
StatusBarSetStatusString (L"Cannot Find Device");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
DupDevicePath = DuplicateDevicePath (DevicePath);
|
||||
DupDevicePathForFree = DupDevicePath;
|
||||
//
|
||||
@ -189,16 +190,18 @@ HDiskImageRead (
|
||||
StatusBarSetStatusString (L"Read Disk Failed");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
StatusBarSetStatusString (L"Read Disk Failed");
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// if Offset exceeds LastBlock,
|
||||
// return error
|
||||
//
|
||||
if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) {
|
||||
if ((Offset > BlkIo->Media->LastBlock) || (Offset + Size > BlkIo->Media->LastBlock)) {
|
||||
StatusBarSetStatusString (L"Invalid Offset + Size");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
@ -246,6 +249,7 @@ HDiskImageRead (
|
||||
StatusBarSetStatusString (L"Read Disk Failed");
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// initialize some variables
|
||||
//
|
||||
@ -275,7 +279,6 @@ HDiskImageRead (
|
||||
|
||||
HMainEditor.SelectStart = 0;
|
||||
HMainEditor.SelectEnd = 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@ -329,7 +332,6 @@ HDiskImageSave (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
|
||||
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree;
|
||||
@ -353,6 +355,7 @@ HDiskImageSave (
|
||||
// StatusBarSetStatusString (L"Cannot Find Device");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
DupDevicePath = DuplicateDevicePath (DevicePath);
|
||||
DupDevicePathForFree = DupDevicePath;
|
||||
|
||||
@ -365,6 +368,7 @@ HDiskImageSave (
|
||||
// StatusBarSetStatusString (L"Read Disk Failed");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
// StatusBarSetStatusString (L"Read Disk Failed");
|
||||
@ -377,6 +381,7 @@ HDiskImageSave (
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// concatenate the line list to a buffer
|
||||
//
|
||||
@ -402,6 +407,7 @@ HDiskImageSave (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// now not modified
|
||||
//
|
||||
|
@ -84,7 +84,6 @@ HFileImageCleanup (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
SHELL_FREE_NON_NULL (HFileImage.FileName);
|
||||
SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
|
||||
|
||||
@ -111,6 +110,7 @@ HFileImageSetFileName (
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// free the old file name
|
||||
//
|
||||
@ -161,7 +161,7 @@ HFileImageRead (
|
||||
//
|
||||
// NULL pointer is only also a failure for a non-zero file size.
|
||||
//
|
||||
if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) {
|
||||
if ((EFI_ERROR (Status)) || ((Buffer == NULL) && (HFileImage.Size != 0))) {
|
||||
UnicodeBuffer = CatSPrint (NULL, L"Read error on file %s: %r", FileName, Status);
|
||||
if (UnicodeBuffer == NULL) {
|
||||
SHELL_FREE_NON_NULL (Buffer);
|
||||
@ -251,7 +251,6 @@ HFileImageSave (
|
||||
IN CHAR16 *FileName
|
||||
)
|
||||
{
|
||||
|
||||
LIST_ENTRY *Link;
|
||||
HEFI_EDITOR_LINE *Line;
|
||||
CHAR16 *Str;
|
||||
@ -269,7 +268,7 @@ HFileImageSave (
|
||||
//
|
||||
// if is the old file
|
||||
//
|
||||
if (HFileImage.FileName != NULL && FileName != NULL && StrCmp (FileName, HFileImage.FileName) == 0) {
|
||||
if ((HFileImage.FileName != NULL) && (FileName != NULL) && (StrCmp (FileName, HFileImage.FileName) == 0)) {
|
||||
//
|
||||
// check whether file exists on disk
|
||||
//
|
||||
@ -281,6 +280,7 @@ HFileImageSave (
|
||||
if (HBufferImage.Modified == FALSE) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// if file is read-only, set error
|
||||
//
|
||||
@ -303,7 +303,7 @@ HFileImageSave (
|
||||
// the file exits, delete it
|
||||
//
|
||||
Status = ShellDeleteFile (&FileHandle);
|
||||
if (EFI_ERROR (Status) || Status == EFI_WARN_DELETE_FAILURE) {
|
||||
if (EFI_ERROR (Status) || (Status == EFI_WARN_DELETE_FAILURE)) {
|
||||
StatusBarSetStatusString (L"Write File Failed");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
@ -320,11 +320,13 @@ HFileImageSave (
|
||||
if (Line->Size != 0) {
|
||||
TotalSize += Line->Size;
|
||||
}
|
||||
|
||||
//
|
||||
// end of if Line -> Size != 0
|
||||
//
|
||||
NumLines++;
|
||||
}
|
||||
|
||||
//
|
||||
// end of for Link
|
||||
//
|
||||
@ -341,12 +343,12 @@ HFileImageSave (
|
||||
CopyMem (Ptr, Line->Buffer, Line->Size);
|
||||
Ptr += Line->Size;
|
||||
}
|
||||
|
||||
//
|
||||
// end of if Line -> Size != 0
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -375,8 +377,9 @@ HFileImageSave (
|
||||
//
|
||||
// now everything is ready , you can set the new file name to filebuffer
|
||||
//
|
||||
if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||
|
||||
(FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){
|
||||
if (((BufferTypeBackup != FileTypeFileBuffer) && (FileName != NULL)) ||
|
||||
((FileName != NULL) && (HFileImage.FileName != NULL) && (StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)))
|
||||
{
|
||||
//
|
||||
// not the same
|
||||
//
|
||||
|
@ -67,7 +67,7 @@ ShellCommandRunHexEdit (
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"hexedit", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -91,7 +91,8 @@ ShellCommandRunHexEdit (
|
||||
Offset = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 2));
|
||||
Size = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 3));
|
||||
}
|
||||
if (Offset == (UINTN)-1 || Size == (UINTN)-1) {
|
||||
|
||||
if ((Offset == (UINTN)-1) || (Size == (UINTN)-1)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -109,7 +110,7 @@ ShellCommandRunHexEdit (
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Name = ShellCommandLineGetRawValue (Package, 1);
|
||||
if (Name == NULL || !IsValidFileName(Name)) {
|
||||
if ((Name == NULL) || !IsValidFileName (Name)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
@ -134,8 +135,9 @@ ShellCommandRunHexEdit (
|
||||
Size = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 2));
|
||||
}
|
||||
}
|
||||
|
||||
Name = ShellCommandLineGetRawValue (Package, 1);
|
||||
if (WhatToDo == FileTypeNone && Name != NULL) {
|
||||
if ((WhatToDo == FileTypeNone) && (Name != NULL)) {
|
||||
if (ShellCommandLineGetCount (Package) > 2) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -156,10 +158,10 @@ ShellCommandRunHexEdit (
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS && WhatToDo == FileTypeNone) {
|
||||
if ((ShellStatus == SHELL_SUCCESS) && (WhatToDo == FileTypeNone)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (WhatToDo == FileTypeFileBuffer && ShellGetCurrentDir(NULL) == NULL) {
|
||||
} else if ((WhatToDo == FileTypeFileBuffer) && (ShellGetCurrentDir (NULL) == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -219,10 +221,12 @@ ShellCommandRunHexEdit (
|
||||
Status = EFI_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
HMainEditorRefresh ();
|
||||
Status = HMainEditorKeyInput ();
|
||||
}
|
||||
|
||||
if (Status != EFI_OUT_OF_RESOURCES) {
|
||||
//
|
||||
// back up the status string
|
||||
@ -262,6 +266,7 @@ ShellCommandRunHexEdit (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#define ASCII_POSITION ((0x10 * 3) + 12)
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINTN Row;
|
||||
UINTN Column;
|
||||
@ -62,7 +61,6 @@ typedef struct {
|
||||
UINTN Rows;
|
||||
} HEFI_EDITOR_TEXT_MODE;
|
||||
|
||||
|
||||
typedef struct {
|
||||
CHAR16 *Name;
|
||||
|
||||
@ -99,7 +97,6 @@ typedef struct {
|
||||
HEFI_EDITOR_FILE_IMAGE *FileImage;
|
||||
HEFI_EDITOR_DISK_IMAGE *DiskImage;
|
||||
HEFI_EDITOR_MEM_IMAGE *MemImage;
|
||||
|
||||
} HEFI_EDITOR_BUFFER_IMAGE;
|
||||
|
||||
typedef struct {
|
||||
|
@ -89,7 +89,6 @@ EFI_STRING_ID HexMainMenuHelpInfo[] = {
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
show help menu.
|
||||
|
||||
@ -110,8 +109,12 @@ HMainCommandDisplayHelp (
|
||||
// print helpInfo
|
||||
//
|
||||
for (CurrentLine = 0; 0 != HexMainMenuHelpInfo[CurrentLine]; CurrentLine++) {
|
||||
InfoString = HiiGetString(gShellDebug1HiiHandle, HexMainMenuHelpInfo[CurrentLine]
|
||||
, NULL);
|
||||
InfoString = HiiGetString (
|
||||
gShellDebug1HiiHandle,
|
||||
HexMainMenuHelpInfo[CurrentLine]
|
||||
,
|
||||
NULL
|
||||
);
|
||||
ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString);
|
||||
}
|
||||
|
||||
@ -123,13 +126,15 @@ HMainCommandDisplayHelp (
|
||||
if (EFI_ERROR (Status) || (EventIndex != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = HMainEditor.TextInputEx->ReadKeyStrokeEx (HMainEditor.TextInputEx, &KeyData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
|
||||
(KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
|
||||
(KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID))
|
||||
{
|
||||
//
|
||||
// For consoles that don't support/report shift state,
|
||||
// CTRL+W is translated to L'W' - L'A' + 1.
|
||||
@ -139,7 +144,8 @@ HMainCommandDisplayHelp (
|
||||
}
|
||||
} else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
|
||||
((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
|
||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
|
||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0))
|
||||
{
|
||||
//
|
||||
// For consoles that supports/reports shift state,
|
||||
// make sure that only CONTROL shift key is pressed.
|
||||
@ -202,9 +208,9 @@ HMainCommandGoToOffset (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -268,6 +274,7 @@ HMainCommandSaveBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// the answer is just one character
|
||||
//
|
||||
@ -275,6 +282,7 @@ HMainCommandSaveBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// loop for user's answer
|
||||
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
|
||||
@ -323,14 +331,17 @@ HMainCommandSaveBuffer (
|
||||
case L'C':
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// end of switch
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// ENDOF WHILE
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// ENDOF != FILEBUFFER
|
||||
//
|
||||
@ -369,7 +380,8 @@ HMainCommandSaveBuffer (
|
||||
// 7. Update File Name field in Title Bar to B
|
||||
// and remove the Modified flag in Title Bar.
|
||||
//
|
||||
Str = CatSPrint(NULL,
|
||||
Str = CatSPrint (
|
||||
NULL,
|
||||
L"File to Save: [%s]",
|
||||
HMainEditor.BufferImage->FileImage->FileName
|
||||
);
|
||||
@ -397,6 +409,7 @@ HMainCommandSaveBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// get new file name
|
||||
//
|
||||
@ -416,7 +429,8 @@ HMainCommandSaveBuffer (
|
||||
// if just enter pressed, so think save to current file name
|
||||
//
|
||||
if (StrLen (InputBarGetString ()) == 0) {
|
||||
FileName = CatSPrint(NULL,
|
||||
FileName = CatSPrint (
|
||||
NULL,
|
||||
L"%s",
|
||||
HMainEditor.BufferImage->FileImage->FileName
|
||||
);
|
||||
@ -442,7 +456,8 @@ HMainCommandSaveBuffer (
|
||||
if (StringNoCaseCompare (
|
||||
&FileName,
|
||||
&HMainEditor.BufferImage->FileImage->FileName
|
||||
) == 0) {
|
||||
) == 0)
|
||||
{
|
||||
OldFile = TRUE;
|
||||
}
|
||||
|
||||
@ -459,7 +474,6 @@ HMainCommandSaveBuffer (
|
||||
Status = ShellOpenFileByName (FileName, &ShellFileHandle, EFI_FILE_MODE_READ, 0);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
Info = ShellGetFileInfo (ShellFileHandle);
|
||||
|
||||
ShellCloseFile (&ShellFileHandle);
|
||||
@ -562,7 +576,7 @@ HMainCommandSelectStart (
|
||||
}
|
||||
}
|
||||
|
||||
if (HMainEditor.SelectEnd != 0 && Start > HMainEditor.SelectEnd) {
|
||||
if ((HMainEditor.SelectEnd != 0) && (Start > HMainEditor.SelectEnd)) {
|
||||
StatusBarSetStatusString (L"Invalid Block Start");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
@ -600,7 +614,7 @@ HMainCommandSelectEnd (
|
||||
}
|
||||
}
|
||||
|
||||
if (HMainEditor.SelectStart != 0 && End < HMainEditor.SelectStart) {
|
||||
if ((HMainEditor.SelectStart != 0) && (End < HMainEditor.SelectStart)) {
|
||||
StatusBarSetStatusString (L"Invalid Block End");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -636,6 +650,7 @@ HMainCommandCut (
|
||||
StatusBarSetStatusString (L"No Block is Selected");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// not select, so not allowed to cut
|
||||
//
|
||||
@ -654,6 +669,7 @@ HMainCommandCut (
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// cut the selected area
|
||||
//
|
||||
@ -696,7 +712,6 @@ HMainCommandPaste (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
BOOLEAN OnlyLineRefresh;
|
||||
HEFI_EDITOR_LINE *Line;
|
||||
UINT8 *Buffer;
|
||||
@ -704,7 +719,7 @@ HMainCommandPaste (
|
||||
UINTN FPos;
|
||||
|
||||
Count = HClipBoardGet (&Buffer);
|
||||
if (Count == 0 || Buffer == NULL) {
|
||||
if ((Count == 0) || (Buffer == NULL)) {
|
||||
StatusBarSetStatusString (L"Nothing to Paste");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -712,7 +727,7 @@ HMainCommandPaste (
|
||||
Line = HMainEditor.BufferImage->CurrentLine;
|
||||
|
||||
OnlyLineRefresh = FALSE;
|
||||
if (Line->Link.ForwardLink == HMainEditor.BufferImage->ListHead && Line->Size + Count < 0x10) {
|
||||
if ((Line->Link.ForwardLink == HMainEditor.BufferImage->ListHead) && (Line->Size + Count < 0x10)) {
|
||||
//
|
||||
// is at last line, and after paste will not exceed
|
||||
// so only this line need to be refreshed
|
||||
@ -721,7 +736,6 @@ HMainCommandPaste (
|
||||
// so the whole page will need be refreshed
|
||||
//
|
||||
OnlyLineRefresh = TRUE;
|
||||
|
||||
}
|
||||
|
||||
FPos = 0x10 * (HMainEditor.BufferImage->BufferPosition.Row - 1) + HMainEditor.BufferImage->BufferPosition.Column - 1;
|
||||
@ -741,7 +755,6 @@ HMainCommandPaste (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -777,7 +790,6 @@ HMainCommandExit (
|
||||
// whether to save the changes
|
||||
//
|
||||
if (HMainEditor.BufferImage->Modified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -827,14 +839,12 @@ HMainCommandExit (
|
||||
case L'c':
|
||||
case L'C':
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HEditorExit = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -886,11 +896,11 @@ HMainCommandOpenFile (
|
||||
// save it first.
|
||||
//
|
||||
if (HMainEditor.BufferImage->Modified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// the answer is just one character
|
||||
//
|
||||
@ -898,6 +908,7 @@ HMainCommandOpenFile (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// loop for user's answer
|
||||
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
|
||||
@ -959,6 +970,7 @@ HMainCommandOpenFile (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TO get the open file name
|
||||
//
|
||||
@ -1012,6 +1024,7 @@ HMainCommandOpenFile (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1038,6 +1051,7 @@ HMainCommandOpenFile (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// read from disk
|
||||
//
|
||||
@ -1103,11 +1117,11 @@ HMainCommandOpenDisk (
|
||||
// whether to save it first.
|
||||
//
|
||||
if (HMainEditor.BufferImage->Modified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// the answer is just one character
|
||||
//
|
||||
@ -1115,6 +1129,7 @@ HMainCommandOpenDisk (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// loop for user's answer
|
||||
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
|
||||
@ -1176,6 +1191,7 @@ HMainCommandOpenDisk (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get disk block device name
|
||||
//
|
||||
@ -1196,9 +1212,9 @@ HMainCommandOpenDisk (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1211,6 +1227,7 @@ HMainCommandOpenDisk (
|
||||
if (DeviceName == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// get starting offset
|
||||
//
|
||||
@ -1231,9 +1248,9 @@ HMainCommandOpenDisk (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1246,6 +1263,7 @@ HMainCommandOpenDisk (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get Number of Blocks:
|
||||
//
|
||||
@ -1266,9 +1284,9 @@ HMainCommandOpenDisk (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1298,7 +1316,6 @@ HMainCommandOpenDisk (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
HBufferImageRead (
|
||||
HMainEditor.BufferImage->FileImage->FileName,
|
||||
HMainEditor.BufferImage->DiskImage->Name,
|
||||
@ -1346,11 +1363,11 @@ HMainCommandOpenMemory (
|
||||
// whether to save it first.
|
||||
//
|
||||
if (HMainEditor.BufferImage->Modified) {
|
||||
|
||||
Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// the answer is just one character
|
||||
//
|
||||
@ -1358,6 +1375,7 @@ HMainCommandOpenMemory (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// loop for user's answer
|
||||
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
|
||||
@ -1419,6 +1437,7 @@ HMainCommandOpenMemory (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get starting offset
|
||||
//
|
||||
@ -1439,9 +1458,9 @@ HMainCommandOpenMemory (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1454,6 +1473,7 @@ HMainCommandOpenMemory (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get Number of Blocks:
|
||||
//
|
||||
@ -1474,9 +1494,9 @@ HMainCommandOpenMemory (
|
||||
// ESC pressed
|
||||
//
|
||||
if (Status == EFI_NOT_READY) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// THE input string length should > 0
|
||||
//
|
||||
@ -1524,8 +1544,8 @@ HMainCommandOpenMemory (
|
||||
);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
MENU_ITEM_FUNCTION HexMainControlBasedMenuFunctions[] = {
|
||||
@ -1695,7 +1715,7 @@ HMainEditorInit (
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (!EFI_ERROR (Status) && HandleCount > 0) {
|
||||
if (!EFI_ERROR (Status) && (HandleCount > 0)) {
|
||||
//
|
||||
// Try to find the first available mouse device
|
||||
//
|
||||
@ -1710,12 +1730,13 @@ HMainEditorInit (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) && HMainEditor.MouseInterface != NULL) {
|
||||
if (!EFI_ERROR (Status) && (HMainEditor.MouseInterface != NULL)) {
|
||||
HMainEditor.MouseAccumulatorX = 0;
|
||||
HMainEditor.MouseAccumulatorY = 0;
|
||||
HMainEditor.MouseSupported = TRUE;
|
||||
@ -1735,6 +1756,7 @@ HMainEditorInit (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
Status = MenuBarInit (HexEditorMenuItems);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle);
|
||||
@ -1760,6 +1782,7 @@ HMainEditorInit (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_CLIPBOARD), gShellDebug1HiiHandle);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// clear whole screen and enable cursor
|
||||
//
|
||||
@ -1809,6 +1832,7 @@ HMainEditorCleanup (
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_CLIPBOARD_CLEAN), gShellDebug1HiiHandle);
|
||||
}
|
||||
|
||||
//
|
||||
// restore old mode
|
||||
//
|
||||
@ -1842,31 +1866,36 @@ HMainEditorRefresh (
|
||||
ReadChange = FALSE;
|
||||
|
||||
if (HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer) {
|
||||
if (HMainEditor.BufferImage->DiskImage != NULL &&
|
||||
HBufferImageBackupVar.DiskImage != NULL &&
|
||||
(HMainEditor.BufferImage->DiskImage->Offset != HBufferImageBackupVar.DiskImage->Offset ||
|
||||
HMainEditor.BufferImage->DiskImage->Size != HBufferImageBackupVar.DiskImage->Size) ){
|
||||
if ((HMainEditor.BufferImage->DiskImage != NULL) &&
|
||||
(HBufferImageBackupVar.DiskImage != NULL) &&
|
||||
((HMainEditor.BufferImage->DiskImage->Offset != HBufferImageBackupVar.DiskImage->Offset) ||
|
||||
(HMainEditor.BufferImage->DiskImage->Size != HBufferImageBackupVar.DiskImage->Size)))
|
||||
{
|
||||
NameChange = TRUE;
|
||||
}
|
||||
} else if (HMainEditor.BufferImage->BufferType == FileTypeMemBuffer) {
|
||||
if (HMainEditor.BufferImage->MemImage != NULL &&
|
||||
HBufferImageBackupVar.MemImage != NULL &&
|
||||
(HMainEditor.BufferImage->MemImage->Offset != HBufferImageBackupVar.MemImage->Offset ||
|
||||
HMainEditor.BufferImage->MemImage->Size != HBufferImageBackupVar.MemImage->Size) ){
|
||||
if ((HMainEditor.BufferImage->MemImage != NULL) &&
|
||||
(HBufferImageBackupVar.MemImage != NULL) &&
|
||||
((HMainEditor.BufferImage->MemImage->Offset != HBufferImageBackupVar.MemImage->Offset) ||
|
||||
(HMainEditor.BufferImage->MemImage->Size != HBufferImageBackupVar.MemImage->Size)))
|
||||
{
|
||||
NameChange = TRUE;
|
||||
}
|
||||
} else if (HMainEditor.BufferImage->BufferType == FileTypeFileBuffer) {
|
||||
if ( HMainEditor.BufferImage->FileImage != NULL &&
|
||||
HMainEditor.BufferImage->FileImage->FileName != NULL &&
|
||||
HBufferImageBackupVar.FileImage != NULL &&
|
||||
HBufferImageBackupVar.FileImage->FileName != NULL &&
|
||||
StrCmp (HMainEditor.BufferImage->FileImage->FileName, HBufferImageBackupVar.FileImage->FileName) != 0 ) {
|
||||
if ((HMainEditor.BufferImage->FileImage != NULL) &&
|
||||
(HMainEditor.BufferImage->FileImage->FileName != NULL) &&
|
||||
(HBufferImageBackupVar.FileImage != NULL) &&
|
||||
(HBufferImageBackupVar.FileImage->FileName != NULL) &&
|
||||
(StrCmp (HMainEditor.BufferImage->FileImage->FileName, HBufferImageBackupVar.FileImage->FileName) != 0))
|
||||
{
|
||||
NameChange = TRUE;
|
||||
}
|
||||
}
|
||||
if ( HMainEditor.BufferImage->FileImage != NULL &&
|
||||
HBufferImageBackupVar.FileImage != NULL &&
|
||||
HMainEditor.BufferImage->FileImage->ReadOnly != HBufferImageBackupVar.FileImage->ReadOnly ) {
|
||||
|
||||
if ((HMainEditor.BufferImage->FileImage != NULL) &&
|
||||
(HBufferImageBackupVar.FileImage != NULL) &&
|
||||
(HMainEditor.BufferImage->FileImage->ReadOnly != HBufferImageBackupVar.FileImage->ReadOnly))
|
||||
{
|
||||
ReadChange = TRUE;
|
||||
}
|
||||
|
||||
@ -1881,10 +1910,10 @@ HMainEditorRefresh (
|
||||
//
|
||||
if ( HEditorFirst
|
||||
|| NameChange
|
||||
|| HMainEditor.BufferImage->BufferType != HBufferImageBackupVar.BufferType
|
||||
|| HBufferImageBackupVar.Modified != HMainEditor.BufferImage->Modified
|
||||
|| ReadChange ) {
|
||||
|
||||
|| (HMainEditor.BufferImage->BufferType != HBufferImageBackupVar.BufferType)
|
||||
|| (HBufferImageBackupVar.Modified != HMainEditor.BufferImage->Modified)
|
||||
|| ReadChange )
|
||||
{
|
||||
MainTitleBarRefresh (
|
||||
HMainEditor.BufferImage->BufferType == FileTypeFileBuffer && HMainEditor.BufferImage->FileImage != NULL ? HMainEditor.BufferImage->FileImage->FileName : HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer && HMainEditor.BufferImage->DiskImage != NULL ? HMainEditor.BufferImage->DiskImage->Name : NULL,
|
||||
HMainEditor.BufferImage->BufferType,
|
||||
@ -1897,11 +1926,12 @@ HMainEditorRefresh (
|
||||
);
|
||||
HBufferImageRefresh ();
|
||||
}
|
||||
if (HEditorFirst
|
||||
|| HBufferImageBackupVar.DisplayPosition.Row != HMainEditor.BufferImage->DisplayPosition.Row
|
||||
|| HBufferImageBackupVar.DisplayPosition.Column != HMainEditor.BufferImage->DisplayPosition.Column
|
||||
|| StatusBarGetRefresh()) {
|
||||
|
||||
if ( HEditorFirst
|
||||
|| (HBufferImageBackupVar.DisplayPosition.Row != HMainEditor.BufferImage->DisplayPosition.Row)
|
||||
|| (HBufferImageBackupVar.DisplayPosition.Column != HMainEditor.BufferImage->DisplayPosition.Column)
|
||||
|| StatusBarGetRefresh ())
|
||||
{
|
||||
StatusBarRefresh (
|
||||
HEditorFirst,
|
||||
HMainEditor.ScreenSize.Row,
|
||||
@ -1942,7 +1972,6 @@ HMainEditorHandleMouseInput (
|
||||
OUT BOOLEAN *BeforeLeftButtonDown
|
||||
)
|
||||
{
|
||||
|
||||
INT32 TextX;
|
||||
INT32 TextY;
|
||||
UINTN FRow;
|
||||
@ -1968,7 +1997,6 @@ HMainEditorHandleMouseInput (
|
||||
HBufferImageAdjustMousePosition (TextX, TextY);
|
||||
|
||||
Action = TRUE;
|
||||
|
||||
}
|
||||
|
||||
if (MouseState.LeftButton) {
|
||||
@ -2003,7 +2031,6 @@ HMainEditorHandleMouseInput (
|
||||
}
|
||||
|
||||
HighBits = TRUE;
|
||||
|
||||
}
|
||||
|
||||
FRow = HMainEditor.BufferImage->BufferPosition.Row +
|
||||
@ -2046,7 +2073,6 @@ HMainEditorHandleMouseInput (
|
||||
FRow = 1;
|
||||
FCol = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
FCol = Line->Size;
|
||||
}
|
||||
@ -2074,6 +2100,7 @@ HMainEditorHandleMouseInput (
|
||||
if (*BeforeLeftButtonDown) {
|
||||
Action = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// mouse up
|
||||
//
|
||||
@ -2128,7 +2155,6 @@ HMainEditorKeyInput (
|
||||
MouseDrag = FALSE;
|
||||
|
||||
do {
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
HEditorMouseAction = FALSE;
|
||||
@ -2152,7 +2178,6 @@ HMainEditorKeyInput (
|
||||
&MouseState
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
BeforeMouseIsDown = MouseIsDown;
|
||||
|
||||
Status = HMainEditorHandleMouseInput (MouseState, &MouseIsDown);
|
||||
@ -2171,7 +2196,6 @@ HMainEditorKeyInput (
|
||||
FirstDown = TRUE;
|
||||
}
|
||||
} else {
|
||||
|
||||
SelectStartBackup = HMainEditor.SelectStart;
|
||||
SelectEndBackup = HMainEditor.SelectEnd;
|
||||
|
||||
@ -2194,7 +2218,8 @@ HMainEditorKeyInput (
|
||||
0x10 +
|
||||
HBufferImage.BufferPosition.Column
|
||||
) >= HMainEditor.SelectStart
|
||||
) {
|
||||
)
|
||||
{
|
||||
HMainEditor.SelectEnd = (HBufferImage.BufferPosition.Row - 1) *
|
||||
0x10 +
|
||||
HBufferImage.BufferPosition.Column;
|
||||
@ -2202,6 +2227,7 @@ HMainEditorKeyInput (
|
||||
HMainEditor.SelectEnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// end of if RelativeX/Y
|
||||
//
|
||||
@ -2222,7 +2248,8 @@ HMainEditorKeyInput (
|
||||
0x10 +
|
||||
HBufferImage.BufferPosition.Column
|
||||
) >= HMainEditor.SelectStart
|
||||
) {
|
||||
)
|
||||
{
|
||||
HMainEditor.SelectEnd = (HBufferImage.BufferPosition.Row - 1) *
|
||||
0x10 +
|
||||
HBufferImage.BufferPosition.Column;
|
||||
@ -2239,7 +2266,7 @@ HMainEditorKeyInput (
|
||||
MouseDrag = FALSE;
|
||||
}
|
||||
|
||||
if (SelectStartBackup != HMainEditor.SelectStart || SelectEndBackup != HMainEditor.SelectEnd) {
|
||||
if ((SelectStartBackup != HMainEditor.SelectStart) || (SelectEndBackup != HMainEditor.SelectEnd)) {
|
||||
if ((SelectStartBackup - 1) / 0x10 != (HMainEditor.SelectStart - 1) / 0x10) {
|
||||
HBufferImageNeedRefresh = TRUE;
|
||||
} else {
|
||||
@ -2254,7 +2281,6 @@ HMainEditorKeyInput (
|
||||
|
||||
HEditorMouseAction = TRUE;
|
||||
HBufferImageMouseNeedRefresh = TRUE;
|
||||
|
||||
} else if (Status == EFI_LOAD_ERROR) {
|
||||
StatusBarSetStatusString (L"Invalid Mouse Movement ");
|
||||
}
|
||||
@ -2287,11 +2313,11 @@ HMainEditorKeyInput (
|
||||
//
|
||||
if (EFI_SUCCESS == MenuBarDispatchControlHotKey (&KeyData)) {
|
||||
Status = EFI_SUCCESS;
|
||||
} else if (NoShiftState && KeyData.Key.ScanCode == SCAN_NULL) {
|
||||
} else if (NoShiftState && (KeyData.Key.ScanCode == SCAN_NULL)) {
|
||||
Status = HBufferImageHandleInput (&KeyData.Key);
|
||||
} else if (NoShiftState && ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN))) {
|
||||
Status = HBufferImageHandleInput (&KeyData.Key);
|
||||
} else if (NoShiftState && ((KeyData.Key.ScanCode >= SCAN_F1) && KeyData.Key.ScanCode <= SCAN_F12)) {
|
||||
} else if (NoShiftState && ((KeyData.Key.ScanCode >= SCAN_F1) && (KeyData.Key.ScanCode <= SCAN_F12))) {
|
||||
Status = MenuBarDispatchFunctionKey (&KeyData.Key);
|
||||
} else {
|
||||
StatusBarSetStatusString (L"Unknown Command");
|
||||
@ -2299,7 +2325,7 @@ HMainEditorKeyInput (
|
||||
HBufferImageMouseNeedRefresh = FALSE;
|
||||
}
|
||||
|
||||
if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_OUT_OF_RESOURCES)) {
|
||||
//
|
||||
// not already has some error status
|
||||
//
|
||||
@ -2308,6 +2334,7 @@ HMainEditorKeyInput (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// decide if has to set length warning
|
||||
//
|
||||
@ -2348,11 +2375,11 @@ HMainEditorKeyInput (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// after handling, refresh editor
|
||||
//
|
||||
HMainEditorRefresh ();
|
||||
|
||||
} while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);
|
||||
|
||||
return Status;
|
||||
|
@ -92,7 +92,6 @@ HMemImageSetMemOffsetSize (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
|
||||
HMemImage.Offset = Offset;
|
||||
HMemImage.Size = Size;
|
||||
|
||||
@ -117,7 +116,6 @@ HMemImageRead (
|
||||
IN BOOLEAN Recover
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
void *Buffer;
|
||||
CHAR16 *Str;
|
||||
@ -181,7 +179,6 @@ HMemImageRead (
|
||||
|
||||
HMainEditor.SelectStart = 0;
|
||||
HMainEditor.SelectEnd = 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@ -208,7 +205,6 @@ HMemImageRead (
|
||||
HBufferImageMouseNeedRefresh = TRUE;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +223,6 @@ HMemImageSave (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
VOID *Buffer;
|
||||
|
||||
@ -251,6 +246,7 @@ HMemImageSave (
|
||||
FreePool (Buffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// write back to memory
|
||||
//
|
||||
@ -267,6 +263,7 @@ HMemImageSave (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// now not modified
|
||||
//
|
||||
@ -274,5 +271,3 @@ HMemImageSave (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@ HLineFree (
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (Src);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,7 +168,6 @@ HMoveCurrentLine (
|
||||
return Line;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free all the lines in HBufferImage.
|
||||
Fields affected:
|
||||
@ -196,7 +194,6 @@ HFreeLines (
|
||||
// release all the lines
|
||||
//
|
||||
if (Lines != NULL) {
|
||||
|
||||
Line = Lines;
|
||||
Link = &(Line->Link);
|
||||
do {
|
||||
|
@ -73,6 +73,7 @@ ShellCommandRunLoadPciRom (
|
||||
CONST CHAR16 *Param;
|
||||
UINTN ParamCount;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
|
||||
//
|
||||
// Local variable initializations
|
||||
//
|
||||
@ -80,13 +81,12 @@ ShellCommandRunLoadPciRom (
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
FileList = NULL;
|
||||
|
||||
|
||||
//
|
||||
// verify number of arguments
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"loadpcirom", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -111,7 +111,8 @@ ShellCommandRunLoadPciRom (
|
||||
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue (Package, ParamCount)
|
||||
; Param != NULL
|
||||
; ParamCount++, Param = ShellCommandLineGetRawValue (Package, ParamCount)
|
||||
){
|
||||
)
|
||||
{
|
||||
Status = ShellOpenFileMetaArg ((CHAR16 *)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param);
|
||||
@ -119,24 +120,28 @@ ShellCommandRunLoadPciRom (
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ShellStatus == SHELL_SUCCESS && FileList != NULL) {
|
||||
|
||||
if ((ShellStatus == SHELL_SUCCESS) && (FileList != NULL)) {
|
||||
//
|
||||
// loop through the list and make sure we are not aborting...
|
||||
//
|
||||
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
|
||||
; !IsNull (&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag ()
|
||||
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
|
||||
){
|
||||
)
|
||||
{
|
||||
if (EFI_ERROR (Node->Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FileHandleIsDirectory (Node->Handle) == EFI_SUCCESS) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
continue;
|
||||
}
|
||||
|
||||
SourceSize = (UINTN)Node->Info->FileSize;
|
||||
File1Buffer = AllocateZeroPool (SourceSize);
|
||||
if (File1Buffer == NULL) {
|
||||
@ -144,6 +149,7 @@ ShellCommandRunLoadPciRom (
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = gEfiShellProtocol->ReadFile (Node->Handle, &SourceSize, File1Buffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
||||
@ -157,15 +163,18 @@ ShellCommandRunLoadPciRom (
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);
|
||||
}
|
||||
|
||||
FreePool (File1Buffer);
|
||||
}
|
||||
} else if (ShellStatus == SHELL_SUCCESS) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom");
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
|
||||
|
||||
if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
|
||||
Status = ShellCloseFileMetaArg (&FileList);
|
||||
}
|
||||
|
||||
FileList = NULL;
|
||||
|
||||
if (Connect) {
|
||||
@ -224,7 +233,6 @@ LoadEfiDriversFromRomImage (
|
||||
RomBarOffset = (UINTN)RomBar;
|
||||
|
||||
do {
|
||||
|
||||
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *)(UINTN)RomBarOffset;
|
||||
|
||||
if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
|
||||
@ -237,9 +245,10 @@ LoadEfiDriversFromRomImage (
|
||||
// If the pointer to the PCI Data Structure is invalid, no further images can be located.
|
||||
// The PCI Data Structure must be DWORD aligned.
|
||||
//
|
||||
if (EfiRomHeader->PcirOffset == 0 ||
|
||||
(EfiRomHeader->PcirOffset & 3) != 0 ||
|
||||
RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
|
||||
if ((EfiRomHeader->PcirOffset == 0) ||
|
||||
((EfiRomHeader->PcirOffset & 3) != 0) ||
|
||||
(RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -250,6 +259,7 @@ LoadEfiDriversFromRomImage (
|
||||
if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ImageSize = Pcir->ImageLength * 512;
|
||||
if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {
|
||||
break;
|
||||
@ -258,13 +268,12 @@ LoadEfiDriversFromRomImage (
|
||||
if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
|
||||
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
|
||||
((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
|
||||
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
|
||||
|
||||
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER)))
|
||||
{
|
||||
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
|
||||
InitializationSize = EfiRomHeader->InitializationSize * 512;
|
||||
|
||||
if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
|
||||
|
||||
if ((InitializationSize <= ImageSize) && (ImageOffset < InitializationSize)) {
|
||||
ImageBuffer = (VOID *)(UINTN)(RomBarOffset + ImageOffset);
|
||||
ImageLength = InitializationSize - ImageOffset;
|
||||
DecompressedImageBuffer = NULL;
|
||||
@ -343,6 +352,7 @@ LoadEfiDriversFromRomImage (
|
||||
if (Status == EFI_SECURITY_VIOLATION) {
|
||||
gBS->UnloadImage (ImageHandle);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
|
||||
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
|
||||
} else {
|
||||
@ -359,7 +369,6 @@ LoadEfiDriversFromRomImage (
|
||||
if (DecompressedImageBuffer != NULL) {
|
||||
FreePool (DecompressedImageBuffer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,11 +411,13 @@ LoadPciRomConnectAllDriversToAllControllers (
|
||||
Status = EFI_ABORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ AddMemoryLength (
|
||||
if (NewEntry == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
NewEntry->Type = Type;
|
||||
NewEntry->NumberOfPages = 0;
|
||||
InsertTailList (Link, &NewEntry->Link);
|
||||
@ -193,7 +194,7 @@ ShellCommandRunMemMap (
|
||||
//
|
||||
Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -211,6 +212,7 @@ ShellCommandRunMemMap (
|
||||
Descriptors = AllocateZeroPool (Size);
|
||||
Status = gBS->GetMemoryMap (&Size, Descriptors, &MapKey, &ItemSize, &Version);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
|
||||
ShellStatus = SHELL_ACCESS_DENIED;
|
||||
@ -227,7 +229,8 @@ ShellCommandRunMemMap (
|
||||
for ( Walker = Descriptors
|
||||
; (Walker < (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Descriptors + Size)) && (Walker != NULL)
|
||||
; Walker = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Walker + ItemSize)
|
||||
){
|
||||
)
|
||||
{
|
||||
switch (Walker->Type) {
|
||||
case EfiReservedMemoryType:
|
||||
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
|
||||
@ -308,11 +311,13 @@ ShellCommandRunMemMap (
|
||||
if (!Sfo) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_ITEM_OTHER), gShellDebug1HiiHandle, Walker->Type, Walker->PhysicalStart, Walker->PhysicalStart + MultU64x64 (SIZE_4KB, Walker->NumberOfPages) - 1, Walker->NumberOfPages, Walker->Attribute);
|
||||
}
|
||||
|
||||
TotalPages += Walker->NumberOfPages;
|
||||
AddMemoryLength (&MemoryList, Walker->Type, Walker->NumberOfPages);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// print the summary
|
||||
//
|
||||
@ -333,21 +338,40 @@ ShellCommandRunMemMap (
|
||||
PersistentPagesSize = MultU64x64 (SIZE_4KB, PersistentPages);
|
||||
UnusableMemoryPagesSize = MultU64x64 (SIZE_4KB, UnusableMemoryPages);
|
||||
if (!Sfo) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
|
||||
ReservedPages, ReservedPagesSize,
|
||||
LoadCodePages, LoadCodePagesSize,
|
||||
LoadDataPages, LoadDataPagesSize,
|
||||
BSCodePages, BSCodePagesSize,
|
||||
BSDataPages, BSDataPagesSize,
|
||||
RTCodePages, RTCodePagesSize,
|
||||
RTDataPages, RTDataPagesSize,
|
||||
AcpiReclaimPages, AcpiReclaimPagesSize,
|
||||
AcpiNvsPages, AcpiNvsPagesSize,
|
||||
MmioSpacePages, MmioSpacePagesSize,
|
||||
MmioPortPages, MmioPortPagesSize,
|
||||
PalCodePages, PalCodePagesSize,
|
||||
AvailPages, AvailPagesSize,
|
||||
PersistentPages, PersistentPagesSize
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_MEMMAP_LIST_SUMM),
|
||||
gShellDebug1HiiHandle,
|
||||
ReservedPages,
|
||||
ReservedPagesSize,
|
||||
LoadCodePages,
|
||||
LoadCodePagesSize,
|
||||
LoadDataPages,
|
||||
LoadDataPagesSize,
|
||||
BSCodePages,
|
||||
BSCodePagesSize,
|
||||
BSDataPages,
|
||||
BSDataPagesSize,
|
||||
RTCodePages,
|
||||
RTCodePagesSize,
|
||||
RTDataPages,
|
||||
RTDataPagesSize,
|
||||
AcpiReclaimPages,
|
||||
AcpiReclaimPagesSize,
|
||||
AcpiNvsPages,
|
||||
AcpiNvsPagesSize,
|
||||
MmioSpacePages,
|
||||
MmioSpacePagesSize,
|
||||
MmioPortPages,
|
||||
MmioPortPagesSize,
|
||||
PalCodePages,
|
||||
PalCodePagesSize,
|
||||
AvailPages,
|
||||
AvailPagesSize,
|
||||
PersistentPages,
|
||||
PersistentPagesSize
|
||||
);
|
||||
|
||||
//
|
||||
@ -355,16 +379,34 @@ ShellCommandRunMemMap (
|
||||
//
|
||||
for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); Link = GetNextNode (&MemoryList, Link)) {
|
||||
Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER), gShellDebug1HiiHandle,
|
||||
Entry->Type, Entry->NumberOfPages, MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER),
|
||||
gShellDebug1HiiHandle,
|
||||
Entry->Type,
|
||||
Entry->NumberOfPages,
|
||||
MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
|
||||
);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM2), gShellDebug1HiiHandle,
|
||||
DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_MEMMAP_LIST_SUMM2),
|
||||
gShellDebug1HiiHandle,
|
||||
DivU64x32 (MultU64x64 (SIZE_4KB, TotalPages), SIZE_1MB),
|
||||
TotalPagesSize
|
||||
);
|
||||
} else {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO),
|
||||
gShellDebug1HiiHandle,
|
||||
TotalPagesSize,
|
||||
ReservedPagesSize,
|
||||
BSCodePagesSize,
|
||||
@ -385,6 +427,7 @@ ShellCommandRunMemMap (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
@ -401,4 +444,3 @@ ShellCommandRunMemMap (
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,11 @@ ShellMmDecodePciAddress (
|
||||
if (Device != NULL) {
|
||||
*Device = (UINT8)(((UINT32)Address) >> 16);
|
||||
}
|
||||
|
||||
if (Function != NULL) {
|
||||
*Function = (UINT8)(((UINT32)Address) >> 8);
|
||||
}
|
||||
|
||||
if (Register != NULL) {
|
||||
*Register = (UINT8)Address;
|
||||
}
|
||||
@ -100,9 +102,11 @@ ShellMmDecodePciAddress (
|
||||
if (Device != NULL) {
|
||||
*Device = (UINT8)(((UINT32)Address) >> 20);
|
||||
}
|
||||
|
||||
if (Function != NULL) {
|
||||
*Function = (UINT8)(((UINT32)Address) >> 12);
|
||||
}
|
||||
|
||||
if (Register != NULL) {
|
||||
*Register = (UINT32)(Address & 0xFFF);
|
||||
}
|
||||
@ -156,17 +160,22 @@ ShellMmAccess (
|
||||
ShellMmDecodePciAddress ((BOOLEAN)(AccessType == ShellMmPci), Address, &Segment, &Bus, &Device, &Function, &Register);
|
||||
if (Read) {
|
||||
Status = PciRootBridgeIo->Pci.Read (
|
||||
PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size],
|
||||
PciRootBridgeIo,
|
||||
mShellMmRootBridgeIoWidth[Size],
|
||||
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
|
||||
1, Buffer
|
||||
1,
|
||||
Buffer
|
||||
);
|
||||
} else {
|
||||
Status = PciRootBridgeIo->Pci.Write (
|
||||
PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size],
|
||||
PciRootBridgeIo,
|
||||
mShellMmRootBridgeIoWidth[Size],
|
||||
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
|
||||
1, Buffer
|
||||
1,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return;
|
||||
|
||||
@ -174,18 +183,22 @@ ShellMmAccess (
|
||||
if (PciRootBridgeIo != NULL) {
|
||||
RootBridgeIoMem = Read ? PciRootBridgeIo->Mem.Read : PciRootBridgeIo->Mem.Write;
|
||||
}
|
||||
|
||||
if (CpuIo != NULL) {
|
||||
CpuIoMem = Read ? CpuIo->Mem.Read : CpuIo->Mem.Write;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ShellMmIo:
|
||||
if (PciRootBridgeIo != NULL) {
|
||||
RootBridgeIoMem = Read ? PciRootBridgeIo->Io.Read : PciRootBridgeIo->Io.Write;
|
||||
}
|
||||
|
||||
if (CpuIo != NULL) {
|
||||
CpuIoMem = Read ? CpuIo->Io.Read : CpuIo->Io.Write;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
@ -196,6 +209,7 @@ ShellMmAccess (
|
||||
if (RootBridgeIoMem != NULL) {
|
||||
Status = RootBridgeIoMem (PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size], Address, 1, Buffer);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status) && (CpuIoMem != NULL)) {
|
||||
Status = CpuIoMem (CpuIo, mShellMmCpuIoWidth[Size], Address, 1, Buffer);
|
||||
}
|
||||
@ -209,6 +223,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
IoWrite8 ((UINTN)Address, *(UINT8 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (Read) {
|
||||
@ -216,6 +231,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
IoWrite16 ((UINTN)Address, *(UINT16 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4:
|
||||
if (Read) {
|
||||
@ -223,6 +239,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
IoWrite32 ((UINTN)Address, *(UINT32 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 8:
|
||||
if (Read) {
|
||||
@ -230,6 +247,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
IoWrite64 ((UINTN)Address, *(UINT64 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
@ -243,6 +261,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
MmioWrite8 ((UINTN)Address, *(UINT8 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (Read) {
|
||||
@ -250,6 +269,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
MmioWrite16 ((UINTN)Address, *(UINT16 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4:
|
||||
if (Read) {
|
||||
@ -257,6 +277,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
MmioWrite32 ((UINTN)Address, *(UINT32 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
case 8:
|
||||
if (Read) {
|
||||
@ -264,6 +285,7 @@ ShellMmAccess (
|
||||
} else {
|
||||
MmioWrite64 ((UINTN)Address, *(UINT64 *)Buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
@ -343,7 +365,8 @@ ShellMmLocateIoProtocol (
|
||||
|
||||
if ((((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) && (Io->SegmentNumber == Segment)) ||
|
||||
((AccessType == ShellMmIo) || (AccessType == ShellMmMemoryMappedIo))
|
||||
) {
|
||||
)
|
||||
{
|
||||
Status = Io->Configuration (Io, (VOID **)&Descriptors);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {
|
||||
@ -353,7 +376,8 @@ ShellMmLocateIoProtocol (
|
||||
if ((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) &&
|
||||
((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) &&
|
||||
((Bus >= Descriptors->AddrRangeMin) && (Bus <= Descriptors->AddrRangeMax))
|
||||
) {
|
||||
)
|
||||
{
|
||||
*PciRootBridgeIo = Io;
|
||||
break;
|
||||
|
||||
@ -363,15 +387,18 @@ ShellMmLocateIoProtocol (
|
||||
} else if ((((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) && (AccessType == ShellMmIo)) ||
|
||||
((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && (AccessType == ShellMmMemoryMappedIo))
|
||||
) && ((Address >= Descriptors->AddrRangeMin) && (Address <= Descriptors->AddrRangeMax))
|
||||
) {
|
||||
)
|
||||
{
|
||||
*PciRootBridgeIo = Io;
|
||||
break;
|
||||
}
|
||||
|
||||
Descriptors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
@ -422,7 +449,7 @@ ShellCommandRunMm (
|
||||
//
|
||||
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mm", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -439,7 +466,7 @@ ShellCommandRunMm (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-w") && ShellCommandLineGetValue (Package, L"-w") == NULL) {
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-w") && (ShellCommandLineGetValue (Package, L"-w") == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"mm", L"-w");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
@ -450,7 +477,8 @@ ShellCommandRunMm (
|
||||
|| ShellCommandLineGetFlag (Package, L"-io")
|
||||
|| ShellCommandLineGetFlag (Package, L"-pci")
|
||||
|| ShellCommandLineGetFlag (Package, L"-pcie")
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
@ -460,7 +488,8 @@ ShellCommandRunMm (
|
||||
if ( ShellCommandLineGetFlag (Package, L"-io")
|
||||
|| ShellCommandLineGetFlag (Package, L"-pci")
|
||||
|| ShellCommandLineGetFlag (Package, L"-pcie")
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
@ -469,7 +498,8 @@ ShellCommandRunMm (
|
||||
AccessType = ShellMmIo;
|
||||
if ( ShellCommandLineGetFlag (Package, L"-pci")
|
||||
|| ShellCommandLineGetFlag (Package, L"-pcie")
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
@ -477,7 +507,8 @@ ShellCommandRunMm (
|
||||
} else if (ShellCommandLineGetFlag (Package, L"-pci")) {
|
||||
AccessType = ShellMmPci;
|
||||
if (ShellCommandLineGetFlag (Package, L"-pcie")
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
@ -499,6 +530,7 @@ ShellCommandRunMm (
|
||||
if (Temp != NULL) {
|
||||
Size = ShellStrToUintn (Temp);
|
||||
}
|
||||
|
||||
if ((Size != 1) && (Size != 2) && (Size != 4) && (Size != 8)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"mm", Temp, L"-w");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -529,6 +561,7 @@ ShellCommandRunMm (
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (PciRootBridgeIo == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE_ADDRESS_RANGE), gShellDebug1HiiHandle, L"mm", Address);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -565,11 +598,13 @@ ShellCommandRunMm (
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, mShellMmAccessTypeStr[AccessType], gShellDebug1HiiHandle);
|
||||
}
|
||||
|
||||
ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, TRUE, Address, Size, &Buffer);
|
||||
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_BUF), gShellDebug1HiiHandle, Size * 2, Buffer & mShellMmMaxNumber[Size]);
|
||||
ShellPrintEx (-1, -1, L"\r\n");
|
||||
goto Done;
|
||||
@ -592,20 +627,23 @@ ShellCommandRunMm (
|
||||
FreePool (InputStr);
|
||||
InputStr = NULL;
|
||||
}
|
||||
|
||||
ShellPromptForResponse (ShellPromptResponseTypeFreeform, NULL, (VOID **)&InputStr);
|
||||
|
||||
if (InputStr != NULL) {
|
||||
//
|
||||
// skip space characters
|
||||
//
|
||||
for (Index = 0; InputStr[Index] == ' '; Index++);
|
||||
for (Index = 0; InputStr[Index] == ' '; Index++) {
|
||||
}
|
||||
|
||||
if (InputStr[Index] != CHAR_NULL) {
|
||||
if ((InputStr[Index] == '.') || (InputStr[Index] == 'q') || (InputStr[Index] == 'Q')) {
|
||||
Complete = TRUE;
|
||||
} else if (!EFI_ERROR (ShellConvertStringToUint64 (InputStr + Index, &Buffer, TRUE, TRUE)) &&
|
||||
(Buffer <= mShellMmMaxNumber[Size])
|
||||
) {
|
||||
)
|
||||
{
|
||||
ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, FALSE, Address, Size, &Buffer);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle, L"mm");
|
||||
@ -618,14 +656,17 @@ ShellCommandRunMm (
|
||||
ShellPrintEx (-1, -1, L"\r\n");
|
||||
} while (!Complete);
|
||||
}
|
||||
|
||||
ASSERT (ShellStatus == SHELL_SUCCESS);
|
||||
|
||||
Done:
|
||||
if (InputStr != NULL) {
|
||||
FreePool (InputStr);
|
||||
}
|
||||
|
||||
if (Package != NULL) {
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return ShellStatus;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ ShellCommandRunMode (
|
||||
//
|
||||
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mode", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
@ -71,12 +71,14 @@ ShellCommandRunMode (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NewCol = ShellStrToUintn (Temp);
|
||||
Temp = ShellCommandLineGetRawValue (Package, 2);
|
||||
if (!ShellIsHexOrDecimalNumber (Temp, FALSE, FALSE)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NewRow = ShellStrToUintn (Temp);
|
||||
|
||||
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS; LoopVar++) {
|
||||
@ -84,7 +86,8 @@ ShellCommandRunMode (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
if (Col == NewCol && Row == NewRow) {
|
||||
|
||||
if ((Col == NewCol) && (Row == NewRow)) {
|
||||
Status = gST->ConOut->SetMode (gST->ConOut, LoopVar);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode");
|
||||
@ -93,6 +96,7 @@ ShellCommandRunMode (
|
||||
// worked fine...
|
||||
Done = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -101,7 +105,6 @@ ShellCommandRunMode (
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
} else if (ShellCommandLineGetCount (Package) == 1) {
|
||||
//
|
||||
// print out valid
|
||||
@ -112,9 +115,11 @@ ShellCommandRunMode (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode ? L'*' : L' ');
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user