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:
Michael Kubacki
2021-12-05 14:54:13 -08:00
committed by mergify[bot]
parent c411b485b6
commit 47d20b54f9
211 changed files with 30269 additions and 27004 deletions

View File

@ -23,15 +23,16 @@
@sa InstallProtocolInterface @sa InstallProtocolInterface
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerInstall( ConsoleLoggerInstall (
IN CONST UINTN ScreensToSave, IN CONST UINTN ScreensToSave,
OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ASSERT(ConsoleInfo != NULL);
(*ConsoleInfo) = AllocateZeroPool(sizeof(CONSOLE_LOGGER_PRIVATE_DATA)); ASSERT (ConsoleInfo != NULL);
(*ConsoleInfo) = AllocateZeroPool (sizeof (CONSOLE_LOGGER_PRIVATE_DATA));
if ((*ConsoleInfo) == NULL) { if ((*ConsoleInfo) == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
@ -66,18 +67,18 @@ ConsoleLoggerInstall(
(*ConsoleInfo)->OurConOut.Mode = gST->ConOut->Mode; (*ConsoleInfo)->OurConOut.Mode = gST->ConOut->Mode;
(*ConsoleInfo)->Enabled = TRUE; (*ConsoleInfo)->Enabled = TRUE;
Status = ConsoleLoggerResetBuffers(*ConsoleInfo); Status = ConsoleLoggerResetBuffers (*ConsoleInfo);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL((*ConsoleInfo)); SHELL_FREE_NON_NULL ((*ConsoleInfo));
*ConsoleInfo = NULL; *ConsoleInfo = NULL;
return (Status); return (Status);
} }
Status = gBS->InstallProtocolInterface(&gImageHandle, &gEfiSimpleTextOutProtocolGuid, EFI_NATIVE_INTERFACE, (VOID*)&((*ConsoleInfo)->OurConOut)); Status = gBS->InstallProtocolInterface (&gImageHandle, &gEfiSimpleTextOutProtocolGuid, EFI_NATIVE_INTERFACE, (VOID *)&((*ConsoleInfo)->OurConOut));
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL((*ConsoleInfo)->Buffer); SHELL_FREE_NON_NULL ((*ConsoleInfo)->Buffer);
SHELL_FREE_NON_NULL((*ConsoleInfo)->Attributes); SHELL_FREE_NON_NULL ((*ConsoleInfo)->Attributes);
SHELL_FREE_NON_NULL((*ConsoleInfo)); SHELL_FREE_NON_NULL ((*ConsoleInfo));
*ConsoleInfo = NULL; *ConsoleInfo = NULL;
return (Status); return (Status);
} }
@ -107,22 +108,31 @@ ConsoleLoggerInstall(
@return other The operation failed. This was from UninstallProtocolInterface. @return other The operation failed. This was from UninstallProtocolInterface.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerUninstall( ConsoleLoggerUninstall (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
{ {
ASSERT(ConsoleInfo != NULL); ASSERT (ConsoleInfo != NULL);
ASSERT(ConsoleInfo->OldConOut != NULL); ASSERT (ConsoleInfo->OldConOut != NULL);
if (ConsoleInfo->Buffer != NULL) { if (ConsoleInfo->Buffer != NULL) {
FreePool(ConsoleInfo->Buffer); FreePool (ConsoleInfo->Buffer);
DEBUG_CODE(ConsoleInfo->Buffer = NULL;); DEBUG_CODE (
DEBUG_CODE(ConsoleInfo->BufferSize = 0;); ConsoleInfo->Buffer = NULL;
);
DEBUG_CODE (
ConsoleInfo->BufferSize = 0;
);
} }
if (ConsoleInfo->Attributes != NULL) { if (ConsoleInfo->Attributes != NULL) {
FreePool(ConsoleInfo->Attributes); FreePool (ConsoleInfo->Attributes);
DEBUG_CODE(ConsoleInfo->Attributes = NULL;); DEBUG_CODE (
DEBUG_CODE(ConsoleInfo->AttribSize = 0;); ConsoleInfo->Attributes = NULL;
);
DEBUG_CODE (
ConsoleInfo->AttribSize = 0;
);
} }
gST->ConsoleOutHandle = ConsoleInfo->OldConHandle; gST->ConsoleOutHandle = ConsoleInfo->OldConHandle;
@ -138,7 +148,7 @@ ConsoleLoggerUninstall(
&gST->Hdr.CRC32 &gST->Hdr.CRC32
); );
return (gBS->UninstallProtocolInterface(gImageHandle, &gEfiSimpleTextOutProtocolGuid, (VOID*)&ConsoleInfo->OurConOut)); return (gBS->UninstallProtocolInterface (gImageHandle, &gEfiSimpleTextOutProtocolGuid, (VOID *)&ConsoleInfo->OurConOut));
} }
/** /**
@ -154,7 +164,7 @@ ConsoleLoggerUninstall(
@param[in] ConsoleInfo The pointer to the instance of the console logger information. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerDisplayHistory( ConsoleLoggerDisplayHistory (
IN CONST BOOLEAN Forward, IN CONST BOOLEAN Forward,
IN CONST UINTN Rows, IN CONST UINTN Rows,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
@ -162,7 +172,7 @@ ConsoleLoggerDisplayHistory(
{ {
UINTN RowChange; UINTN RowChange;
ASSERT(ConsoleInfo != NULL); ASSERT (ConsoleInfo != NULL);
// //
// Calculate the row number change // Calculate the row number change
@ -202,7 +212,7 @@ ConsoleLoggerDisplayHistory(
// //
// Clear the screen // Clear the screen
// //
ConsoleInfo->OldConOut->ClearScreen(ConsoleInfo->OldConOut); ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
// //
// Set the new start row // Set the new start row
@ -216,7 +226,7 @@ ConsoleLoggerDisplayHistory(
// //
// Change the screen // Change the screen
// //
return (UpdateDisplayFromHistory(ConsoleInfo)); return (UpdateDisplayFromHistory (ConsoleInfo));
} }
/** /**
@ -229,11 +239,11 @@ ConsoleLoggerDisplayHistory(
@sa UpdateDisplayFromHistory @sa UpdateDisplayFromHistory
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerStopHistory( ConsoleLoggerStopHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
{ {
ASSERT(ConsoleInfo != NULL); ASSERT (ConsoleInfo != NULL);
if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) { if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
return (EFI_SUCCESS); return (EFI_SUCCESS);
} }
@ -241,10 +251,10 @@ ConsoleLoggerStopHistory(
// //
// Clear the screen // Clear the screen
// //
ConsoleInfo->OldConOut->ClearScreen(ConsoleInfo->OldConOut); ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
ConsoleInfo->CurrentStartRow = ConsoleInfo->OriginalStartRow; ConsoleInfo->CurrentStartRow = ConsoleInfo->OriginalStartRow;
return (UpdateDisplayFromHistory(ConsoleInfo)); return (UpdateDisplayFromHistory (ConsoleInfo));
} }
/** /**
@ -255,7 +265,7 @@ ConsoleLoggerStopHistory(
@return other The operation failed. @return other The operation failed.
**/ **/
EFI_STATUS EFI_STATUS
UpdateDisplayFromHistory( UpdateDisplayFromHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
{ {
@ -273,7 +283,7 @@ UpdateDisplayFromHistory(
CHAR16 StringSegmentEndChar; CHAR16 StringSegmentEndChar;
INT32 OrigAttribute; INT32 OrigAttribute;
ASSERT(ConsoleInfo != NULL); ASSERT (ConsoleInfo != NULL);
TempCharHolder = CHAR_NULL; TempCharHolder = CHAR_NULL;
RetVal = EFI_SUCCESS; RetVal = EFI_SUCCESS;
OrigAttribute = ConsoleInfo->OldConOut->Mode->Attribute; OrigAttribute = ConsoleInfo->OldConOut->Mode->Attribute;
@ -288,14 +298,15 @@ UpdateDisplayFromHistory(
Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow]; Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow];
for ( CurrentRow = 0 for ( CurrentRow = 0
; CurrentRow < ConsoleInfo->RowsPerScreen ; CurrentRow < ConsoleInfo->RowsPerScreen
; CurrentRow++ ; CurrentRow++,
, Screen += (ConsoleInfo->ColsPerScreen + 2) Screen += (ConsoleInfo->ColsPerScreen + 2),
, Attributes += ConsoleInfo->ColsPerScreen Attributes += ConsoleInfo->ColsPerScreen
){ )
{
// //
// dont use the last char - prevents screen scroll // dont use the last char - prevents screen scroll
// //
if (CurrentRow == (ConsoleInfo->RowsPerScreen-1)){ if (CurrentRow == (ConsoleInfo->RowsPerScreen-1)) {
TempCharHolder = Screen[ConsoleInfo->ColsPerScreen - 1]; TempCharHolder = Screen[ConsoleInfo->ColsPerScreen - 1];
Screen[ConsoleInfo->ColsPerScreen - 1] = CHAR_NULL; Screen[ConsoleInfo->ColsPerScreen - 1] = CHAR_NULL;
} }
@ -303,7 +314,8 @@ UpdateDisplayFromHistory(
for ( Column = 0 for ( Column = 0
; Column < ConsoleInfo->ColsPerScreen ; Column < ConsoleInfo->ColsPerScreen
; Column++ ; Column++
){ )
{
if (Screen[Column] != CHAR_NULL) { if (Screen[Column] != CHAR_NULL) {
CurrentAttrib = Attributes[Column]; CurrentAttrib = Attributes[Column];
CurrentColumn = Column; CurrentColumn = Column;
@ -317,9 +329,10 @@ UpdateDisplayFromHistory(
StringSegmentEndChar = CHAR_NULL; StringSegmentEndChar = CHAR_NULL;
for ( StringSegmentEnd = StringSegment for ( StringSegmentEnd = StringSegment
; *StringSegmentEnd != CHAR_NULL ; *StringSegmentEnd != CHAR_NULL
; StringSegmentEnd++ ; StringSegmentEnd++,
, Column++ Column++
){ )
{
if (Attributes[Column] != CurrentAttrib) { if (Attributes[Column] != CurrentAttrib) {
StringSegmentEndChar = *StringSegmentEnd; StringSegmentEndChar = *StringSegmentEnd;
*StringSegmentEnd = CHAR_NULL; *StringSegmentEnd = CHAR_NULL;
@ -331,12 +344,12 @@ UpdateDisplayFromHistory(
// Now write out as much as had the same Attributes // Now write out as much as had the same Attributes
// //
ConsoleInfo->OldConOut->SetAttribute(ConsoleInfo->OldConOut, CurrentAttrib); ConsoleInfo->OldConOut->SetAttribute (ConsoleInfo->OldConOut, CurrentAttrib);
ConsoleInfo->OldConOut->SetCursorPosition(ConsoleInfo->OldConOut, CurrentColumn, CurrentRow); ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, CurrentColumn, CurrentRow);
Status = ConsoleInfo->OldConOut->OutputString(ConsoleInfo->OldConOut, StringSegment); Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, StringSegment);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ASSERT(FALSE); ASSERT (FALSE);
RetVal = Status; RetVal = Status;
} }
@ -413,7 +426,8 @@ ConsoleLoggerReset (
{ {
EFI_STATUS Status; EFI_STATUS Status;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
@ -424,7 +438,7 @@ ConsoleLoggerReset (
// Check that the buffers are still correct for logging // Check that the buffers are still correct for logging
// //
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ConsoleLoggerResetBuffers(ConsoleInfo); ConsoleLoggerResetBuffers (ConsoleInfo);
if (ExtendedVerification) { if (ExtendedVerification) {
ConsoleInfo->OriginalStartRow = 0; ConsoleInfo->OriginalStartRow = 0;
ConsoleInfo->CurrentStartRow = 0; ConsoleInfo->CurrentStartRow = 0;
@ -443,7 +457,7 @@ ConsoleLoggerReset (
@param[in] ConsoleInfo The pointer to the instance of the console logger information. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/ **/
EFI_STATUS EFI_STATUS
AppendStringToHistory( AppendStringToHistory (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
@ -453,33 +467,35 @@ AppendStringToHistory(
UINTN PrintIndex; UINTN PrintIndex;
UINTN Index; UINTN Index;
ASSERT(ConsoleInfo != NULL); ASSERT (ConsoleInfo != NULL);
for ( Walker = String for ( Walker = String
; Walker != NULL && *Walker != CHAR_NULL ; Walker != NULL && *Walker != CHAR_NULL
; Walker++ ; Walker++
){ )
{
switch (*Walker) { switch (*Walker) {
case (CHAR_BACKSPACE): case (CHAR_BACKSPACE):
if (ConsoleInfo->HistoryMode.CursorColumn > 0) { if (ConsoleInfo->HistoryMode.CursorColumn > 0) {
ConsoleInfo->HistoryMode.CursorColumn--; ConsoleInfo->HistoryMode.CursorColumn--;
} }
break; break;
case (CHAR_LINEFEED): case (CHAR_LINEFEED):
if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) { if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) {
// //
// Should never be bigger // Should never be bigger
// //
ASSERT(ConsoleInfo->HistoryMode.CursorRow == (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)); ASSERT (ConsoleInfo->HistoryMode.CursorRow == (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1));
// //
// scroll history attributes 'up' 1 row and set the last row to default attribute // scroll history attributes 'up' 1 row and set the last row to default attribute
// //
CopySize = ConsoleInfo->ColsPerScreen CopySize = ConsoleInfo->ColsPerScreen
* ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1) * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
* sizeof(ConsoleInfo->Attributes[0]); * sizeof (ConsoleInfo->Attributes[0]);
ASSERT(CopySize < ConsoleInfo->AttribSize); ASSERT (CopySize < ConsoleInfo->AttribSize);
CopyMem( CopyMem (
ConsoleInfo->Attributes, ConsoleInfo->Attributes,
ConsoleInfo->Attributes + ConsoleInfo->ColsPerScreen, ConsoleInfo->Attributes + ConsoleInfo->ColsPerScreen,
CopySize CopySize
@ -488,8 +504,9 @@ AppendStringToHistory(
for ( Index = 0 for ( Index = 0
; Index < ConsoleInfo->ColsPerScreen ; Index < ConsoleInfo->ColsPerScreen
; Index++ ; Index++
){ )
*(ConsoleInfo->Attributes + (CopySize/sizeof(ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute; {
*(ConsoleInfo->Attributes + (CopySize/sizeof (ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute;
} }
// //
@ -497,9 +514,9 @@ AppendStringToHistory(
// //
CopySize = (ConsoleInfo->ColsPerScreen + 2) CopySize = (ConsoleInfo->ColsPerScreen + 2)
* ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1) * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
* sizeof(ConsoleInfo->Buffer[0]); * sizeof (ConsoleInfo->Buffer[0]);
ASSERT(CopySize < ConsoleInfo->BufferSize); ASSERT (CopySize < ConsoleInfo->BufferSize);
CopyMem( CopyMem (
ConsoleInfo->Buffer, ConsoleInfo->Buffer,
ConsoleInfo->Buffer + (ConsoleInfo->ColsPerScreen + 2), ConsoleInfo->Buffer + (ConsoleInfo->ColsPerScreen + 2),
CopySize CopySize
@ -508,7 +525,7 @@ AppendStringToHistory(
// //
// Set that last row of chars to spaces // Set that last row of chars to spaces
// //
SetMem16(((UINT8*)ConsoleInfo->Buffer)+CopySize, ConsoleInfo->ColsPerScreen*sizeof(CHAR16), L' '); SetMem16 (((UINT8 *)ConsoleInfo->Buffer)+CopySize, ConsoleInfo->ColsPerScreen*sizeof (CHAR16), L' ');
} else { } else {
// //
// we are not on the last row // we are not on the last row
@ -521,12 +538,14 @@ AppendStringToHistory(
// //
// are we at the end of a row? // are we at the end of a row?
// //
if (ConsoleInfo->HistoryMode.CursorRow == (INT32) (ConsoleInfo->OriginalStartRow + ConsoleInfo->RowsPerScreen - 1)) { if (ConsoleInfo->HistoryMode.CursorRow == (INT32)(ConsoleInfo->OriginalStartRow + ConsoleInfo->RowsPerScreen - 1)) {
ConsoleInfo->OriginalStartRow++; ConsoleInfo->OriginalStartRow++;
ConsoleInfo->CurrentStartRow++; ConsoleInfo->CurrentStartRow++;
} }
ConsoleInfo->HistoryMode.CursorRow++; ConsoleInfo->HistoryMode.CursorRow++;
} }
break; break;
case (CHAR_CARRIAGE_RETURN): case (CHAR_CARRIAGE_RETURN):
// //
@ -542,26 +561,29 @@ AppendStringToHistory(
PrintIndex = ConsoleInfo->HistoryMode.CursorRow * ConsoleInfo->ColsPerScreen + ConsoleInfo->HistoryMode.CursorColumn; PrintIndex = ConsoleInfo->HistoryMode.CursorRow * ConsoleInfo->ColsPerScreen + ConsoleInfo->HistoryMode.CursorColumn;
for ( // no initializer needed for ( // no initializer needed
; ConsoleInfo->HistoryMode.CursorColumn < (INT32) ConsoleInfo->ColsPerScreen ; ConsoleInfo->HistoryMode.CursorColumn < (INT32)ConsoleInfo->ColsPerScreen
; ConsoleInfo->HistoryMode.CursorColumn++ ; ConsoleInfo->HistoryMode.CursorColumn++,
, PrintIndex++ PrintIndex++,
, Walker++ Walker++
){ )
if (*Walker == CHAR_NULL {
||*Walker == CHAR_BACKSPACE if ( (*Walker == CHAR_NULL)
||*Walker == CHAR_LINEFEED || (*Walker == CHAR_BACKSPACE)
||*Walker == CHAR_CARRIAGE_RETURN || (*Walker == CHAR_LINEFEED)
){ || (*Walker == CHAR_CARRIAGE_RETURN)
)
{
Walker--; Walker--;
break; break;
} }
// //
// The buffer is 2*CursorRow more since it has that many \r\n characters at the end of each row. // The buffer is 2*CursorRow more since it has that many \r\n characters at the end of each row.
// //
ASSERT(PrintIndex + ConsoleInfo->HistoryMode.CursorRow < ConsoleInfo->BufferSize); ASSERT (PrintIndex + ConsoleInfo->HistoryMode.CursorRow < ConsoleInfo->BufferSize);
ConsoleInfo->Buffer[PrintIndex + (2*ConsoleInfo->HistoryMode.CursorRow)] = *Walker; ConsoleInfo->Buffer[PrintIndex + (2*ConsoleInfo->HistoryMode.CursorRow)] = *Walker;
ASSERT(PrintIndex < ConsoleInfo->AttribSize); ASSERT (PrintIndex < ConsoleInfo->AttribSize);
ConsoleInfo->Attributes[PrintIndex] = ConsoleInfo->HistoryMode.Attribute; ConsoleInfo->Attributes[PrintIndex] = ConsoleInfo->HistoryMode.Attribute;
} // for loop } // for loop
@ -569,7 +591,7 @@ AppendStringToHistory(
// Add the carriage return and line feed at the end of the lines // Add the carriage return and line feed at the end of the lines
// //
if (ConsoleInfo->HistoryMode.CursorColumn >= (INT32)ConsoleInfo->ColsPerScreen) { if (ConsoleInfo->HistoryMode.CursorColumn >= (INT32)ConsoleInfo->ColsPerScreen) {
AppendStringToHistory(L"\r\n", ConsoleInfo); AppendStringToHistory (L"\r\n", ConsoleInfo);
Walker--; Walker--;
} }
@ -597,7 +619,7 @@ AppendStringToHistory(
rendered and were skipped. rendered and were skipped.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerOutputStringSplit( ConsoleLoggerOutputStringSplit (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
@ -607,13 +629,13 @@ ConsoleLoggerOutputStringSplit(
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
// //
Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, (CHAR16*)String); Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, (CHAR16 *)String);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return (Status); return (Status);
} }
return (AppendStringToHistory(String, ConsoleInfo)); return (AppendStringToHistory (String, ConsoleInfo));
} }
/** /**
@ -625,7 +647,7 @@ ConsoleLoggerOutputStringSplit(
@return other Break was choosen @return other Break was choosen
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerDoPageBreak( ConsoleLoggerDoPageBreak (
VOID VOID
) )
{ {
@ -633,29 +655,32 @@ ConsoleLoggerDoPageBreak(
EFI_STATUS Status; EFI_STATUS Status;
Resp = NULL; Resp = NULL;
ASSERT(ShellInfoObject.PageBreakEnabled); ASSERT (ShellInfoObject.PageBreakEnabled);
ShellInfoObject.PageBreakEnabled = FALSE; ShellInfoObject.PageBreakEnabled = FALSE;
Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN(STR_SHELL_QUIT_CONT), ShellInfoObject.HiiHandle, (VOID**)&Resp); Status = ShellPromptForResponseHii (ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_SHELL_QUIT_CONT), ShellInfoObject.HiiHandle, (VOID **)&Resp);
ShellInfoObject.PageBreakEnabled = TRUE; ShellInfoObject.PageBreakEnabled = TRUE;
ASSERT(Resp != NULL); ASSERT (Resp != NULL);
if (Resp == NULL) { if (Resp == NULL) {
return (EFI_NOT_FOUND); return (EFI_NOT_FOUND);
} }
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
if (Resp != NULL) { if (Resp != NULL) {
FreePool(Resp); FreePool (Resp);
} }
return (Status); return (Status);
} }
if (*Resp == ShellPromptResponseContinue) { if (*Resp == ShellPromptResponseContinue) {
FreePool(Resp); FreePool (Resp);
ShellInfoObject.ConsoleInfo->RowCounter = 0; ShellInfoObject.ConsoleInfo->RowCounter = 0;
// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorRow = 0; // ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorRow = 0;
// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorColumn = 0; // ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
return (EFI_SUCCESS); return (EFI_SUCCESS);
} else if (*Resp == ShellPromptResponseQuit) { } else if (*Resp == ShellPromptResponseQuit) {
FreePool(Resp); FreePool (Resp);
ShellInfoObject.ConsoleInfo->Enabled = FALSE; ShellInfoObject.ConsoleInfo->Enabled = FALSE;
// //
// When user wants to quit, the shell should stop running the command. // When user wants to quit, the shell should stop running the command.
@ -663,10 +688,12 @@ ConsoleLoggerDoPageBreak(
gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak); gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak);
return (EFI_DEVICE_ERROR); return (EFI_DEVICE_ERROR);
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
return (EFI_SUCCESS); return (EFI_SUCCESS);
} }
/** /**
Worker function to handle printing the output with page breaks. Worker function to handle printing the output with page breaks.
@ -683,7 +710,7 @@ ConsoleLoggerDoPageBreak(
rendered and were skipped. rendered and were skipped.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerPrintWithPageBreak( ConsoleLoggerPrintWithPageBreak (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
@ -694,28 +721,30 @@ ConsoleLoggerPrintWithPageBreak(
CHAR16 TempChar; CHAR16 TempChar;
StringCopy = NULL; StringCopy = NULL;
StringCopy = StrnCatGrow(&StringCopy, NULL, String, 0); StringCopy = StrnCatGrow (&StringCopy, NULL, String, 0);
if (StringCopy == NULL) { if (StringCopy == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
for ( Walker = StringCopy for ( Walker = StringCopy,
, LineStart = StringCopy LineStart = StringCopy
; Walker != NULL && *Walker != CHAR_NULL ; Walker != NULL && *Walker != CHAR_NULL
; Walker++ ; Walker++
){ )
{
switch (*Walker) { switch (*Walker) {
case (CHAR_BACKSPACE): case (CHAR_BACKSPACE):
if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) { if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) {
ConsoleInfo->OurConOut.Mode->CursorColumn--; ConsoleInfo->OurConOut.Mode->CursorColumn--;
} }
break; break;
case (CHAR_LINEFEED): case (CHAR_LINEFEED):
// //
// add a temp NULL terminator // add a temp NULL terminator
// //
TempChar = *(Walker + 1); TempChar = *(Walker + 1);
*((CHAR16*)(Walker+1)) = CHAR_NULL; *((CHAR16 *)(Walker+1)) = CHAR_NULL;
// //
// output the string // output the string
@ -725,7 +754,7 @@ ConsoleLoggerPrintWithPageBreak(
// //
// restore the temp NULL terminator to its original character // restore the temp NULL terminator to its original character
// //
*((CHAR16*)(Walker+1)) = TempChar; *((CHAR16 *)(Walker+1)) = TempChar;
// //
// Update LineStart Variable // Update LineStart Variable
@ -762,7 +791,7 @@ ConsoleLoggerPrintWithPageBreak(
// add a temp NULL terminator // add a temp NULL terminator
// //
TempChar = *(Walker + 1); TempChar = *(Walker + 1);
*((CHAR16*)(Walker+1)) = CHAR_NULL; *((CHAR16 *)(Walker+1)) = CHAR_NULL;
// //
// output the string // output the string
@ -772,7 +801,7 @@ ConsoleLoggerPrintWithPageBreak(
// //
// restore the temp NULL terminator to its original character // restore the temp NULL terminator to its original character
// //
*((CHAR16*)(Walker+1)) = TempChar; *((CHAR16 *)(Walker+1)) = TempChar;
// //
// Update LineStart Variable // Update LineStart Variable
@ -786,6 +815,7 @@ ConsoleLoggerPrintWithPageBreak(
ConsoleInfo->OurConOut.Mode->CursorRow++; ConsoleInfo->OurConOut.Mode->CursorRow++;
ConsoleInfo->OurConOut.Mode->CursorColumn = 0; ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
} // last column on line } // last column on line
break; break;
} // switch for character } // switch for character
@ -793,21 +823,21 @@ ConsoleLoggerPrintWithPageBreak(
// check if that was the last printable row. If yes handle PageBreak mode // check if that was the last printable row. If yes handle PageBreak mode
// //
if ((ConsoleInfo->RowsPerScreen) -1 == ShellInfoObject.ConsoleInfo->RowCounter) { if ((ConsoleInfo->RowsPerScreen) -1 == ShellInfoObject.ConsoleInfo->RowCounter) {
if (EFI_ERROR(ConsoleLoggerDoPageBreak())) { if (EFI_ERROR (ConsoleLoggerDoPageBreak ())) {
// //
// We got an error which means 'break' and halt the printing // We got an error which means 'break' and halt the printing
// //
SHELL_FREE_NON_NULL(StringCopy); SHELL_FREE_NON_NULL (StringCopy);
return (EFI_DEVICE_ERROR); return (EFI_DEVICE_ERROR);
} }
} }
} // for loop } // for loop
if (LineStart != NULL && *LineStart != CHAR_NULL) { if ((LineStart != NULL) && (*LineStart != CHAR_NULL)) {
ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo); ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
} }
SHELL_FREE_NON_NULL(StringCopy); SHELL_FREE_NON_NULL (StringCopy);
return (EFI_SUCCESS); return (EFI_SUCCESS);
} }
@ -840,16 +870,16 @@ ConsoleLoggerOutputString (
UINTN EventIndex; UINTN EventIndex;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This); ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) { if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED); return (EFI_UNSUPPORTED);
} }
ASSERT(ShellInfoObject.ConsoleInfo == ConsoleInfo);
Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx); ASSERT (ShellInfoObject.ConsoleInfo == ConsoleInfo);
Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
while (ShellInfoObject.HaltOutput) { while (ShellInfoObject.HaltOutput) {
ShellInfoObject.HaltOutput = FALSE; ShellInfoObject.HaltOutput = FALSE;
// //
// just get some key // just get some key
@ -857,7 +887,7 @@ ConsoleLoggerOutputString (
Status = gBS->WaitForEvent (1, &TxtInEx->WaitForKeyEx, &EventIndex); Status = gBS->WaitForEvent (1, &TxtInEx->WaitForKeyEx, &EventIndex);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData); Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
break; break;
} }
@ -865,7 +895,8 @@ ConsoleLoggerOutputString (
((KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED)) || ((KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED)) ||
(KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED)) (KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED))
) )
) { )
{
ShellInfoObject.HaltOutput = TRUE; ShellInfoObject.HaltOutput = TRUE;
} }
} }
@ -874,9 +905,9 @@ ConsoleLoggerOutputString (
if (!ShellInfoObject.ConsoleInfo->Enabled) { if (!ShellInfoObject.ConsoleInfo->Enabled) {
return (EFI_DEVICE_ERROR); return (EFI_DEVICE_ERROR);
} else if (ShellInfoObject.PageBreakEnabled) { } else if (ShellInfoObject.PageBreakEnabled) {
return (ConsoleLoggerPrintWithPageBreak(WString, ConsoleInfo)); return (ConsoleLoggerPrintWithPageBreak (WString, ConsoleInfo));
} else { } else {
return (ConsoleLoggerOutputStringSplit(WString, ConsoleInfo)); return (ConsoleLoggerOutputStringSplit (WString, ConsoleInfo));
} }
} }
@ -902,7 +933,8 @@ ConsoleLoggerTestString (
) )
{ {
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
// //
@ -933,7 +965,8 @@ ConsoleLoggerQueryMode (
) )
{ {
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
// //
@ -967,7 +1000,8 @@ ConsoleLoggerSetMode (
EFI_STATUS Status; EFI_STATUS Status;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
@ -979,7 +1013,7 @@ ConsoleLoggerSetMode (
// //
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ConsoleInfo->OurConOut.Mode = ConsoleInfo->OldConOut->Mode; ConsoleInfo->OurConOut.Mode = ConsoleInfo->OldConOut->Mode;
ConsoleLoggerResetBuffers(ConsoleInfo); ConsoleLoggerResetBuffers (ConsoleInfo);
ConsoleInfo->OriginalStartRow = 0; ConsoleInfo->OriginalStartRow = 0;
ConsoleInfo->CurrentStartRow = 0; ConsoleInfo->CurrentStartRow = 0;
ConsoleInfo->OurConOut.ClearScreen (&ConsoleInfo->OurConOut); ConsoleInfo->OurConOut.ClearScreen (&ConsoleInfo->OurConOut);
@ -1013,7 +1047,8 @@ ConsoleLoggerSetAttribute (
EFI_STATUS Status; EFI_STATUS Status;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
@ -1024,7 +1059,7 @@ ConsoleLoggerSetAttribute (
// Record console output history // Record console output history
// //
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ConsoleInfo->HistoryMode.Attribute = (INT32) Attribute; ConsoleInfo->HistoryMode.Attribute = (INT32)Attribute;
} }
return Status; return Status;
@ -1058,7 +1093,7 @@ ConsoleLoggerClearScreen (
return (EFI_UNSUPPORTED); return (EFI_UNSUPPORTED);
} }
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This); ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
@ -1074,21 +1109,25 @@ ConsoleLoggerClearScreen (
for ( Row = ConsoleInfo->OriginalStartRow for ( Row = ConsoleInfo->OriginalStartRow
; Row < (ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) ; Row < (ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)
; Row++ ; Row++
){ )
{
for ( Column = 0 for ( Column = 0
; Column < ConsoleInfo->ColsPerScreen ; Column < ConsoleInfo->ColsPerScreen
; Column++ ; Column++,
, Screen++ Screen++,
, Attributes++ Attributes++
){ )
{
*Screen = L' '; *Screen = L' ';
*Attributes = ConsoleInfo->OldConOut->Mode->Attribute; *Attributes = ConsoleInfo->OldConOut->Mode->Attribute;
} }
// //
// Skip the NULL on each column end in text buffer only // Skip the NULL on each column end in text buffer only
// //
Screen += 2; Screen += 2;
} }
ConsoleInfo->HistoryMode.CursorColumn = 0; ConsoleInfo->HistoryMode.CursorColumn = 0;
ConsoleInfo->HistoryMode.CursorRow = 0; ConsoleInfo->HistoryMode.CursorRow = 0;
} }
@ -1124,7 +1163,7 @@ ConsoleLoggerSetCursorPosition (
return (EFI_UNSUPPORTED); return (EFI_UNSUPPORTED);
} }
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This); ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
// //
@ -1168,7 +1207,8 @@ ConsoleLoggerEnableCursor (
EFI_STATUS Status; EFI_STATUS Status;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
// //
// Forward the request to the original ConOut // Forward the request to the original ConOut
// //
@ -1193,40 +1233,41 @@ ConsoleLoggerEnableCursor (
history buffers. history buffers.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerResetBuffers( ConsoleLoggerResetBuffers (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (ConsoleInfo->Buffer != NULL) { if (ConsoleInfo->Buffer != NULL) {
FreePool(ConsoleInfo->Buffer); FreePool (ConsoleInfo->Buffer);
ConsoleInfo->Buffer = NULL; ConsoleInfo->Buffer = NULL;
ConsoleInfo->BufferSize = 0; ConsoleInfo->BufferSize = 0;
} }
if (ConsoleInfo->Attributes != NULL) { if (ConsoleInfo->Attributes != NULL) {
FreePool(ConsoleInfo->Attributes); FreePool (ConsoleInfo->Attributes);
ConsoleInfo->Attributes = NULL; ConsoleInfo->Attributes = NULL;
ConsoleInfo->AttribSize = 0; ConsoleInfo->AttribSize = 0;
} }
Status = gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &ConsoleInfo->ColsPerScreen, &ConsoleInfo->RowsPerScreen); Status = gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &ConsoleInfo->ColsPerScreen, &ConsoleInfo->RowsPerScreen);
if (EFI_ERROR(Status)){ if (EFI_ERROR (Status)) {
return (Status); return (Status);
} }
ConsoleInfo->BufferSize = (ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof(ConsoleInfo->Buffer[0]); ConsoleInfo->BufferSize = (ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof (ConsoleInfo->Buffer[0]);
ConsoleInfo->AttribSize = ConsoleInfo->ColsPerScreen * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof(ConsoleInfo->Attributes[0]); ConsoleInfo->AttribSize = ConsoleInfo->ColsPerScreen * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof (ConsoleInfo->Attributes[0]);
ConsoleInfo->Buffer = (CHAR16*)AllocateZeroPool(ConsoleInfo->BufferSize); ConsoleInfo->Buffer = (CHAR16 *)AllocateZeroPool (ConsoleInfo->BufferSize);
if (ConsoleInfo->Buffer == NULL) { if (ConsoleInfo->Buffer == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
ConsoleInfo->Attributes = (INT32*)AllocateZeroPool(ConsoleInfo->AttribSize); ConsoleInfo->Attributes = (INT32 *)AllocateZeroPool (ConsoleInfo->AttribSize);
if (ConsoleInfo->Attributes == NULL) { if (ConsoleInfo->Attributes == NULL) {
FreePool(ConsoleInfo->Buffer); FreePool (ConsoleInfo->Buffer);
ConsoleInfo->Buffer = NULL; ConsoleInfo->Buffer = NULL;
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }

View File

@ -12,7 +12,7 @@
#define CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('c', 'o', 'P', 'D') #define CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('c', 'o', 'P', 'D')
typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{ typedef struct _CONSOLE_LOGGER_PRIVATE_DATA {
UINTN Signature; UINTN Signature;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut; ///< the protocol we installed onto the system table EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut; ///< the protocol we installed onto the system table
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OldConOut; ///< old protocol to reinstall upon exiting EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OldConOut; ///< old protocol to reinstall upon exiting
@ -52,7 +52,7 @@ typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{
@sa InstallProtocolInterface @sa InstallProtocolInterface
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerInstall( ConsoleLoggerInstall (
IN CONST UINTN ScreensToSave, IN CONST UINTN ScreensToSave,
OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
); );
@ -67,7 +67,7 @@ ConsoleLoggerInstall(
@return other The operation failed. This was from UninstallProtocolInterface. @return other The operation failed. This was from UninstallProtocolInterface.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerUninstall( ConsoleLoggerUninstall (
IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
); );
@ -84,7 +84,7 @@ ConsoleLoggerUninstall(
@param[in] ConsoleInfo The pointer to the instance of the console logger information. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerDisplayHistory( ConsoleLoggerDisplayHistory (
IN CONST BOOLEAN Forward, IN CONST BOOLEAN Forward,
IN CONST UINTN Rows, IN CONST UINTN Rows,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
@ -100,7 +100,7 @@ ConsoleLoggerDisplayHistory(
@sa UpdateDisplayFromHistory @sa UpdateDisplayFromHistory
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerStopHistory( ConsoleLoggerStopHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
); );
@ -112,7 +112,7 @@ ConsoleLoggerStopHistory(
@return other The operation failed. @return other The operation failed.
**/ **/
EFI_STATUS EFI_STATUS
UpdateDisplayFromHistory( UpdateDisplayFromHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
); );
@ -151,7 +151,7 @@ ConsoleLoggerReset (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ConsoleLoggerOutputString( ConsoleLoggerOutputString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString IN CHAR16 *WString
); );
@ -309,9 +309,8 @@ ConsoleLoggerEnableCursor (
history buffers. history buffers.
**/ **/
EFI_STATUS EFI_STATUS
ConsoleLoggerResetBuffers( ConsoleLoggerResetBuffers (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
); );
#endif //_CONSOLE_LOGGER_HEADER_ #endif //_CONSOLE_LOGGER_HEADER_

View File

@ -53,7 +53,7 @@ ConInWaitForKey (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FileBasedSimpleTextInReset( FileBasedSimpleTextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
) )
@ -71,7 +71,7 @@ FileBasedSimpleTextInReset(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FileBasedSimpleTextInReadKeyStroke( FileBasedSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN OUT EFI_INPUT_KEY *Key IN OUT EFI_INPUT_KEY *Key
) )
@ -82,7 +82,7 @@ FileBasedSimpleTextInReadKeyStroke(
// //
// Verify the parameters // Verify the parameters
// //
if (Key == NULL || This == NULL) { if ((Key == NULL) || (This == NULL)) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -93,13 +93,14 @@ FileBasedSimpleTextInReadKeyStroke(
return (EFI_NOT_READY); return (EFI_NOT_READY);
} }
Size = sizeof(CHAR16); Size = sizeof (CHAR16);
if(!AsciiRedirection) { if (!AsciiRedirection) {
CharSize = sizeof(CHAR16); CharSize = sizeof (CHAR16);
} else { } else {
CharSize = sizeof(CHAR8); CharSize = sizeof (CHAR8);
} }
// //
// Decrement the amount of free space by Size or set to zero (for odd length files) // Decrement the amount of free space by Size or set to zero (for odd length files)
// //
@ -110,10 +111,11 @@ FileBasedSimpleTextInReadKeyStroke(
} }
Key->ScanCode = 0; Key->ScanCode = 0;
return (ShellInfoObject.NewEfiShellProtocol->ReadFile( return (ShellInfoObject.NewEfiShellProtocol->ReadFile (
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle, ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
&Size, &Size,
&Key->UnicodeChar)); &Key->UnicodeChar
));
} }
/** /**
@ -126,8 +128,8 @@ FileBasedSimpleTextInReadKeyStroke(
@retval NULL There was insufficient memory available. @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure; @return A pointer to the allocated protocol structure;
**/ **/
EFI_SIMPLE_TEXT_INPUT_PROTOCOL* EFI_SIMPLE_TEXT_INPUT_PROTOCOL *
CreateSimpleTextInOnFile( CreateSimpleTextInOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse, IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation IN EFI_HANDLE *HandleLocation
) )
@ -137,17 +139,17 @@ CreateSimpleTextInOnFile(
UINT64 CurrentPosition; UINT64 CurrentPosition;
UINT64 FileSize; UINT64 FileSize;
if (HandleLocation == NULL || FileHandleToUse == NULL) { if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL); return (NULL);
} }
ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL)); ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
if (ProtocolToReturn == NULL) { if (ProtocolToReturn == NULL) {
return (NULL); return (NULL);
} }
ShellGetFileSize (FileHandleToUse, &FileSize); ShellGetFileSize (FileHandleToUse, &FileSize);
ShellGetFilePosition(FileHandleToUse, &CurrentPosition); ShellGetFilePosition (FileHandleToUse, &CurrentPosition);
// //
// Initialize the protocol members // Initialize the protocol members
@ -165,21 +167,23 @@ CreateSimpleTextInOnFile(
&ProtocolToReturn->SimpleTextIn.WaitForKey &ProtocolToReturn->SimpleTextIn.WaitForKey
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
FreePool(ProtocolToReturn); FreePool (ProtocolToReturn);
return (NULL); return (NULL);
} }
///@todo possibly also install SimpleTextInputEx on the handle at this point.
Status = gBS->InstallProtocolInterface( /// @todo possibly also install SimpleTextInputEx on the handle at this point.
Status = gBS->InstallProtocolInterface (
&(ProtocolToReturn->TheHandle), &(ProtocolToReturn->TheHandle),
&gEfiSimpleTextInProtocolGuid, &gEfiSimpleTextInProtocolGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextIn)); &(ProtocolToReturn->SimpleTextIn)
if (!EFI_ERROR(Status)) { );
if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle; *HandleLocation = ProtocolToReturn->TheHandle;
return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)ProtocolToReturn); return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)ProtocolToReturn);
} else { } else {
FreePool(ProtocolToReturn); FreePool (ProtocolToReturn);
return (NULL); return (NULL);
} }
} }
@ -193,7 +197,7 @@ CreateSimpleTextInOnFile(
@retval EFI_SUCCESS The object was closed. @retval EFI_SUCCESS The object was closed.
**/ **/
EFI_STATUS EFI_STATUS
CloseSimpleTextInOnFile( CloseSimpleTextInOnFile (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
) )
{ {
@ -204,15 +208,16 @@ CloseSimpleTextInOnFile(
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
Status = gBS->CloseEvent(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey); Status = gBS->CloseEvent (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);
Status1 = gBS->UninstallProtocolInterface( Status1 = gBS->UninstallProtocolInterface (
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle, ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->TheHandle,
&gEfiSimpleTextInProtocolGuid, &gEfiSimpleTextInProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn)); &(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn)
);
FreePool(SimpleTextIn); FreePool (SimpleTextIn);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
return (Status1); return (Status1);
} else { } else {
return (Status); return (Status);
@ -281,11 +286,12 @@ FileBasedSimpleTextOutQueryMode (
PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut; PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
// Pass the QueryMode call thru to the original SimpleTextOutProtocol // Pass the QueryMode call thru to the original SimpleTextOutProtocol
return (PassThruProtocol->QueryMode( return (PassThruProtocol->QueryMode (
PassThruProtocol, PassThruProtocol,
ModeNumber, ModeNumber,
Columns, Columns,
Rows)); Rows
));
} }
/** /**
@ -407,11 +413,13 @@ FileBasedSimpleTextOutOutputString (
) )
{ {
UINTN Size; UINTN Size;
Size = StrLen(WString) * sizeof(CHAR16);
return (ShellInfoObject.NewEfiShellProtocol->WriteFile( Size = StrLen (WString) * sizeof (CHAR16);
return (ShellInfoObject.NewEfiShellProtocol->WriteFile (
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle, ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
&Size, &Size,
WString)); WString
));
} }
/** /**
@ -425,8 +433,8 @@ FileBasedSimpleTextOutOutputString (
@retval NULL There was insufficient memory available. @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure; @return A pointer to the allocated protocol structure;
**/ **/
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *
CreateSimpleTextOutOnFile( CreateSimpleTextOutOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse, IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation, IN EFI_HANDLE *HandleLocation,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
@ -435,14 +443,15 @@ CreateSimpleTextOutOnFile(
SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn; SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
EFI_STATUS Status; EFI_STATUS Status;
if (HandleLocation == NULL || FileHandleToUse == NULL) { if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL); return (NULL);
} }
ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)); ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
if (ProtocolToReturn == NULL) { if (ProtocolToReturn == NULL) {
return (NULL); return (NULL);
} }
ProtocolToReturn->FileHandle = FileHandleToUse; ProtocolToReturn->FileHandle = FileHandleToUse;
ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol; ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset; ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
@ -454,11 +463,12 @@ CreateSimpleTextOutOnFile(
ProtocolToReturn->SimpleTextOut.SetCursorPosition = FileBasedSimpleTextOutSetCursorPosition; ProtocolToReturn->SimpleTextOut.SetCursorPosition = FileBasedSimpleTextOutSetCursorPosition;
ProtocolToReturn->SimpleTextOut.EnableCursor = FileBasedSimpleTextOutEnableCursor; ProtocolToReturn->SimpleTextOut.EnableCursor = FileBasedSimpleTextOutEnableCursor;
ProtocolToReturn->SimpleTextOut.OutputString = FileBasedSimpleTextOutOutputString; ProtocolToReturn->SimpleTextOut.OutputString = FileBasedSimpleTextOutOutputString;
ProtocolToReturn->SimpleTextOut.Mode = AllocateZeroPool(sizeof(EFI_SIMPLE_TEXT_OUTPUT_MODE)); ProtocolToReturn->SimpleTextOut.Mode = AllocateZeroPool (sizeof (EFI_SIMPLE_TEXT_OUTPUT_MODE));
if (ProtocolToReturn->SimpleTextOut.Mode == NULL) { if (ProtocolToReturn->SimpleTextOut.Mode == NULL) {
FreePool(ProtocolToReturn); FreePool (ProtocolToReturn);
return (NULL); return (NULL);
} }
ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode; ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode; ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute; ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
@ -466,17 +476,18 @@ CreateSimpleTextOutOnFile(
ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow; ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow;
ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible; ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;
Status = gBS->InstallProtocolInterface( Status = gBS->InstallProtocolInterface (
&(ProtocolToReturn->TheHandle), &(ProtocolToReturn->TheHandle),
&gEfiSimpleTextOutProtocolGuid, &gEfiSimpleTextOutProtocolGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextOut)); &(ProtocolToReturn->SimpleTextOut)
if (!EFI_ERROR(Status)) { );
if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle; *HandleLocation = ProtocolToReturn->TheHandle;
return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn); return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)ProtocolToReturn);
} else { } else {
SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode); SHELL_FREE_NON_NULL (ProtocolToReturn->SimpleTextOut.Mode);
SHELL_FREE_NON_NULL(ProtocolToReturn); SHELL_FREE_NON_NULL (ProtocolToReturn);
return (NULL); return (NULL);
} }
} }
@ -490,19 +501,22 @@ CreateSimpleTextOutOnFile(
@retval EFI_SUCCESS The object was closed. @retval EFI_SUCCESS The object was closed.
**/ **/
EFI_STATUS EFI_STATUS
CloseSimpleTextOutOnFile( CloseSimpleTextOutOnFile (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (SimpleTextOut == NULL) { if (SimpleTextOut == NULL) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
Status = gBS->UninstallProtocolInterface(
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle, Status = gBS->UninstallProtocolInterface (
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->TheHandle,
&gEfiSimpleTextOutProtocolGuid, &gEfiSimpleTextOutProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut)); &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->SimpleTextOut)
FreePool(SimpleTextOut->Mode); );
FreePool(SimpleTextOut); FreePool (SimpleTextOut->Mode);
FreePool (SimpleTextOut);
return (Status); return (Status);
} }

View File

@ -20,8 +20,8 @@
@retval NULL There was insufficient memory available. @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure; @return A pointer to the allocated protocol structure;
**/ **/
EFI_SIMPLE_TEXT_INPUT_PROTOCOL* EFI_SIMPLE_TEXT_INPUT_PROTOCOL *
CreateSimpleTextInOnFile( CreateSimpleTextInOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse, IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation IN EFI_HANDLE *HandleLocation
); );
@ -35,7 +35,7 @@ CreateSimpleTextInOnFile(
@retval EFI_SUCCESS The object was closed. @retval EFI_SUCCESS The object was closed.
**/ **/
EFI_STATUS EFI_STATUS
CloseSimpleTextInOnFile( CloseSimpleTextInOnFile (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
); );
@ -50,8 +50,8 @@ CloseSimpleTextInOnFile(
@retval NULL There was insufficient memory available. @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure; @return A pointer to the allocated protocol structure;
**/ **/
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *
CreateSimpleTextOutOnFile( CreateSimpleTextOutOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse, IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation, IN EFI_HANDLE *HandleLocation,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
@ -66,9 +66,8 @@ CreateSimpleTextOutOnFile(
@retval EFI_SUCCESS The object was closed. @retval EFI_SUCCESS The object was closed.
**/ **/
EFI_STATUS EFI_STATUS
CloseSimpleTextOutOnFile( CloseSimpleTextOutOnFile (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
); );
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_ #endif //_SHELL_CONSOLE_WRAPPERS_HEADER_

View File

@ -56,4 +56,3 @@ PrintCommandHistory (
); );
#endif //_FILE_HANDLE_INTERNAL_HEADER_ #endif //_FILE_HANDLE_INTERNAL_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
typedef struct { typedef struct {
LIST_ENTRY Link; LIST_ENTRY Link;
CHAR16* Buffer; CHAR16 *Buffer;
} SHELL_LINE_LIST; } SHELL_LINE_LIST;
typedef struct { typedef struct {
@ -48,8 +48,8 @@ extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
@retval NULL Memory could not be allocated. @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure @return other a pointer to an EFI_FILE_PROTOCOL structure
**/ **/
EFI_FILE_PROTOCOL* EFI_FILE_PROTOCOL *
CreateFileInterfaceEnv( CreateFileInterfaceEnv (
CONST CHAR16 *EnvName CONST CHAR16 *EnvName
); );
@ -62,8 +62,8 @@ CreateFileInterfaceEnv(
@retval NULL Memory could not be allocated. @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure @return other a pointer to an EFI_FILE_PROTOCOL structure
**/ **/
EFI_FILE_PROTOCOL* EFI_FILE_PROTOCOL *
CreateFileInterfaceMem( CreateFileInterfaceMem (
IN CONST BOOLEAN Unicode IN CONST BOOLEAN Unicode
); );
@ -77,11 +77,10 @@ CreateFileInterfaceMem(
@retval NULL Memory could not be allocated. @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure @return other a pointer to an EFI_FILE_PROTOCOL structure
**/ **/
EFI_FILE_PROTOCOL* EFI_FILE_PROTOCOL *
CreateFileInterfaceFile( CreateFileInterfaceFile (
IN CONST EFI_FILE_PROTOCOL *Template, IN CONST EFI_FILE_PROTOCOL *Template,
IN CONST BOOLEAN Unicode IN CONST BOOLEAN Unicode
); );
#endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_ #endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -62,17 +62,17 @@ typedef struct {
} SPLIT_LIST; } SPLIT_LIST;
typedef struct { typedef struct {
UINT32 Startup:1; ///< Was "-startup" found on command line. UINT32 Startup : 1; ///< Was "-startup" found on command line.
UINT32 NoStartup:1; ///< Was "-nostartup" found on command line. UINT32 NoStartup : 1; ///< Was "-nostartup" found on command line.
UINT32 NoConsoleOut:1; ///< Was "-noconsoleout" found on command line. UINT32 NoConsoleOut : 1; ///< Was "-noconsoleout" found on command line.
UINT32 NoConsoleIn:1; ///< Was "-noconsolein" found on command line. UINT32 NoConsoleIn : 1; ///< Was "-noconsolein" found on command line.
UINT32 NoInterrupt:1; ///< Was "-nointerrupt" found on command line. UINT32 NoInterrupt : 1; ///< Was "-nointerrupt" found on command line.
UINT32 NoMap:1; ///< Was "-nomap" found on command line. UINT32 NoMap : 1; ///< Was "-nomap" found on command line.
UINT32 NoVersion:1; ///< Was "-noversion" found on command line. UINT32 NoVersion : 1; ///< Was "-noversion" found on command line.
UINT32 Delay:1; ///< Was "-delay[:n] found on command line UINT32 Delay : 1; ///< Was "-delay[:n] found on command line
UINT32 Exit:1; ///< Was "-_exit" found on command line UINT32 Exit : 1; ///< Was "-_exit" found on command line
UINT32 NoNest:1; ///< Was "-nonest" found on command line UINT32 NoNest : 1; ///< Was "-nonest" found on command line
UINT32 Reserved:7; ///< Extra bits UINT32 Reserved : 7; ///< Extra bits
} SHELL_BITS; } SHELL_BITS;
typedef union { typedef union {
@ -144,7 +144,7 @@ extern SHELL_INFO ShellInfoObject;
@return some other error occurred @return some other error occurred
**/ **/
EFI_STATUS EFI_STATUS
ProcessCommandLineToFinal( ProcessCommandLineToFinal (
IN OUT CHAR16 **CmdLine IN OUT CHAR16 **CmdLine
); );
@ -154,7 +154,7 @@ ProcessCommandLineToFinal(
@param[in] ErrorCode the error code to put into lasterror @param[in] ErrorCode the error code to put into lasterror
**/ **/
EFI_STATUS EFI_STATUS
SetLastError( SetLastError (
IN CONST SHELL_STATUS ErrorCode IN CONST SHELL_STATUS ErrorCode
); );
@ -164,7 +164,7 @@ SetLastError(
@retval EFI_SUCCESS all init commands were run successfully. @retval EFI_SUCCESS all init commands were run successfully.
**/ **/
EFI_STATUS EFI_STATUS
SetBuiltInAlias( SetBuiltInAlias (
VOID VOID
); );
@ -216,7 +216,7 @@ GetDevicePathsForImageAndFile (
@retval EFI_SUCCESS the variable is initialized. @retval EFI_SUCCESS the variable is initialized.
**/ **/
EFI_STATUS EFI_STATUS
ProcessCommandLine( ProcessCommandLine (
VOID VOID
); );
@ -231,7 +231,7 @@ ProcessCommandLine(
@retval EFI_SUCCESS The variable is initialized. @retval EFI_SUCCESS The variable is initialized.
**/ **/
EFI_STATUS EFI_STATUS
DoStartupScript( DoStartupScript (
IN EFI_DEVICE_PATH_PROTOCOL *ImagePath, IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath IN EFI_DEVICE_PATH_PROTOCOL *FilePath
); );
@ -255,8 +255,8 @@ DoShellPrompt (
@param Buffer Something to pass to FreePool when the shell is exiting. @param Buffer Something to pass to FreePool when the shell is exiting.
**/ **/
VOID* VOID *
AddBufferToFreeList( AddBufferToFreeList (
VOID *Buffer VOID *Buffer
); );
@ -266,7 +266,7 @@ AddBufferToFreeList(
@param Buffer[in] The line buffer to add. @param Buffer[in] The line buffer to add.
**/ **/
VOID VOID
AddLineToCommandHistory( AddLineToCommandHistory (
IN CONST CHAR16 *Buffer IN CONST CHAR16 *Buffer
); );
@ -281,7 +281,7 @@ AddLineToCommandHistory(
@retval EFI_ABORTED the command's operation was aborted @retval EFI_ABORTED the command's operation was aborted
**/ **/
EFI_STATUS EFI_STATUS
RunCommand( RunCommand (
IN CONST CHAR16 *CmdLine IN CONST CHAR16 *CmdLine
); );
@ -298,12 +298,11 @@ RunCommand(
@retval EFI_ABORTED The command's operation was aborted. @retval EFI_ABORTED The command's operation was aborted.
**/ **/
EFI_STATUS EFI_STATUS
RunShellCommand( RunShellCommand (
IN CONST CHAR16 *CmdLine, IN CONST CHAR16 *CmdLine,
OUT EFI_STATUS *CommandStatus OUT EFI_STATUS *CommandStatus
); );
/** /**
Function to process a NSH script file via SHELL_FILE_HANDLE. Function to process a NSH script file via SHELL_FILE_HANDLE.
@ -346,8 +345,8 @@ RunScriptFile (
@return the location of the first character in the string @return the location of the first character in the string
@retval CHAR_NULL no instance of any character in CharacterList was found in String @retval CHAR_NULL no instance of any character in CharacterList was found in String
**/ **/
CONST CHAR16* CONST CHAR16 *
FindFirstCharacter( FindFirstCharacter (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
IN CONST CHAR16 *CharacterList, IN CONST CHAR16 *CharacterList,
IN CONST CHAR16 EscapeCharacter IN CONST CHAR16 EscapeCharacter
@ -359,7 +358,7 @@ FindFirstCharacter(
@param[in] String pointer to the string to trim them off. @param[in] String pointer to the string to trim them off.
**/ **/
EFI_STATUS EFI_STATUS
TrimSpaces( TrimSpaces (
IN CHAR16 **String IN CHAR16 **String
); );
@ -384,7 +383,4 @@ RestoreBufferList (
IN OUT LIST_ENTRY *OldBufferList IN OUT LIST_ENTRY *OldBufferList
); );
#endif //_SHELL_INTERNAL_HEADER_ #endif //_SHELL_INTERNAL_HEADER_

View File

@ -44,23 +44,29 @@ IsVolatileEnv (
// //
// get the variable // get the variable
// //
Status = gRT->GetVariable((CHAR16*)EnvVarName, Status = gRT->GetVariable (
(CHAR16 *)EnvVarName,
&gShellVariableGuid, &gShellVariableGuid,
&Attribs, &Attribs,
&Size, &Size,
Buffer); Buffer
);
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size); Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) { if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = gRT->GetVariable((CHAR16*)EnvVarName,
Status = gRT->GetVariable (
(CHAR16 *)EnvVarName,
&gShellVariableGuid, &gShellVariableGuid,
&Attribs, &Attribs,
&Size, &Size,
Buffer); Buffer
FreePool(Buffer); );
FreePool (Buffer);
} }
// //
// not found means volatile // not found means volatile
// //
@ -68,6 +74,7 @@ IsVolatileEnv (
*Volatile = TRUE; *Volatile = TRUE;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -75,7 +82,7 @@ IsVolatileEnv (
// //
// check for the Non Volatile bit // check for the Non Volatile bit
// //
*Volatile = !(BOOLEAN) ((Attribs & EFI_VARIABLE_NON_VOLATILE) == EFI_VARIABLE_NON_VOLATILE); *Volatile = !(BOOLEAN)((Attribs & EFI_VARIABLE_NON_VOLATILE) == EFI_VARIABLE_NON_VOLATILE);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -85,7 +92,7 @@ IsVolatileEnv (
@param[in] List The pointer to pointer to list. @param[in] List The pointer to pointer to list.
**/ **/
VOID VOID
FreeEnvironmentVariableList( FreeEnvironmentVariableList (
IN LIST_ENTRY *List IN LIST_ENTRY *List
) )
{ {
@ -96,19 +103,22 @@ FreeEnvironmentVariableList(
return; return;
} }
for ( Node = (ENV_VAR_LIST*)GetFirstNode(List) for ( Node = (ENV_VAR_LIST *)GetFirstNode (List)
; !IsListEmpty(List) ; !IsListEmpty (List)
; Node = (ENV_VAR_LIST*)GetFirstNode(List) ; Node = (ENV_VAR_LIST *)GetFirstNode (List)
){ )
ASSERT(Node != NULL); {
RemoveEntryList(&Node->Link); ASSERT (Node != NULL);
RemoveEntryList (&Node->Link);
if (Node->Key != NULL) { if (Node->Key != NULL) {
FreePool(Node->Key); FreePool (Node->Key);
} }
if (Node->Val != NULL) { if (Node->Val != NULL) {
FreePool(Node->Val); FreePool (Node->Val);
} }
FreePool(Node);
FreePool (Node);
} }
} }
@ -121,7 +131,7 @@ FreeEnvironmentVariableList(
@retval EFI_SUCCESS the list was created successfully. @retval EFI_SUCCESS the list was created successfully.
**/ **/
EFI_STATUS EFI_STATUS
GetEnvironmentVariableList( GetEnvironmentVariableList (
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *ListHead
) )
{ {
@ -142,32 +152,34 @@ GetEnvironmentVariableList(
ValBufferSize = INIT_DATA_BUFFER_SIZE; ValBufferSize = INIT_DATA_BUFFER_SIZE;
NameBufferSize = INIT_NAME_BUFFER_SIZE; NameBufferSize = INIT_NAME_BUFFER_SIZE;
VariableName = AllocateZeroPool(NameBufferSize); VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) { if (VariableName == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
*VariableName = CHAR_NULL; *VariableName = CHAR_NULL;
while (!EFI_ERROR(Status)) { while (!EFI_ERROR (Status)) {
NameSize = NameBufferSize; NameSize = NameBufferSize;
Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid); Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
if (Status == EFI_NOT_FOUND){ if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
break; break;
} else if (Status == EFI_BUFFER_TOO_SMALL) { } else if (Status == EFI_BUFFER_TOO_SMALL) {
NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2; NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
SHELL_FREE_NON_NULL(VariableName); SHELL_FREE_NON_NULL (VariableName);
VariableName = AllocateZeroPool(NameBufferSize); VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) { if (VariableName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
break; break;
} }
NameSize = NameBufferSize; NameSize = NameBufferSize;
Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid); Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
} }
if (!EFI_ERROR(Status) && CompareGuid(&Guid, &gShellVariableGuid)){ if (!EFI_ERROR (Status) && CompareGuid (&Guid, &gShellVariableGuid)) {
VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST)); VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) { if (VarList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} else { } else {
@ -177,12 +189,13 @@ GetEnvironmentVariableList(
// //
VarList->Val = AllocateZeroPool (ValSize + sizeof (CHAR16)); VarList->Val = AllocateZeroPool (ValSize + sizeof (CHAR16));
if (VarList->Val == NULL) { if (VarList->Val == NULL) {
SHELL_FREE_NON_NULL(VarList); SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
break; break;
} }
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
if (Status == EFI_BUFFER_TOO_SMALL){ 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; ValBufferSize = ValSize > ValBufferSize * 2 ? ValSize : ValBufferSize * 2;
SHELL_FREE_NON_NULL (VarList->Val); SHELL_FREE_NON_NULL (VarList->Val);
// //
@ -190,34 +203,36 @@ GetEnvironmentVariableList(
// //
VarList->Val = AllocateZeroPool (ValBufferSize + sizeof (CHAR16)); VarList->Val = AllocateZeroPool (ValBufferSize + sizeof (CHAR16));
if (VarList->Val == NULL) { if (VarList->Val == NULL) {
SHELL_FREE_NON_NULL(VarList); SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
break; break;
} }
ValSize = ValBufferSize; ValSize = ValBufferSize;
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val); Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (VariableName, &VarList->Atts, &ValSize, VarList->Val);
} }
if (!EFI_ERROR(Status)) {
VarList->Key = AllocateCopyPool(StrSize(VariableName), VariableName); if (!EFI_ERROR (Status)) {
VarList->Key = AllocateCopyPool (StrSize (VariableName), VariableName);
if (VarList->Key == NULL) { if (VarList->Key == NULL) {
SHELL_FREE_NON_NULL(VarList->Val); SHELL_FREE_NON_NULL (VarList->Val);
SHELL_FREE_NON_NULL(VarList); SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} else { } else {
InsertTailList(ListHead, &VarList->Link); InsertTailList (ListHead, &VarList->Link);
} }
} else { } else {
SHELL_FREE_NON_NULL(VarList->Val); SHELL_FREE_NON_NULL (VarList->Val);
SHELL_FREE_NON_NULL(VarList); SHELL_FREE_NON_NULL (VarList);
} }
} // if (VarList == NULL) ... else ... } // if (VarList == NULL) ... else ...
} // compare guid } // compare guid
} // while } // while
SHELL_FREE_NON_NULL (VariableName); SHELL_FREE_NON_NULL (VariableName);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
FreeEnvironmentVariableList(ListHead); FreeEnvironmentVariableList (ListHead);
} }
return (Status); return (Status);
@ -236,7 +251,7 @@ GetEnvironmentVariableList(
@retval EFI_SUCCESS the list was Set successfully. @retval EFI_SUCCESS the list was Set successfully.
**/ **/
EFI_STATUS EFI_STATUS
SetEnvironmentVariableList( SetEnvironmentVariableList (
IN LIST_ENTRY *ListHead IN LIST_ENTRY *ListHead
) )
{ {
@ -245,42 +260,47 @@ SetEnvironmentVariableList(
EFI_STATUS Status; EFI_STATUS Status;
UINTN Size; UINTN Size;
InitializeListHead(&VarList.Link); InitializeListHead (&VarList.Link);
// //
// Delete all the current environment variables // Delete all the current environment variables
// //
Status = GetEnvironmentVariableList(&VarList.Link); Status = GetEnvironmentVariableList (&VarList.Link);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&VarList.Link) for ( Node = (ENV_VAR_LIST *)GetFirstNode (&VarList.Link)
; !IsNull(&VarList.Link, &Node->Link) ; !IsNull (&VarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&VarList.Link, &Node->Link) ; Node = (ENV_VAR_LIST *)GetNextNode (&VarList.Link, &Node->Link)
){ )
{
if (Node->Key != NULL) { if (Node->Key != NULL) {
Status = SHELL_DELETE_ENVIRONMENT_VARIABLE(Node->Key); Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Node->Key);
}
ASSERT_EFI_ERROR(Status);
} }
FreeEnvironmentVariableList(&VarList.Link); ASSERT_EFI_ERROR (Status);
}
FreeEnvironmentVariableList (&VarList.Link);
// //
// set all the variables from the list // set all the variables from the list
// //
for ( Node = (ENV_VAR_LIST*)GetFirstNode(ListHead) for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
; !IsNull(ListHead, &Node->Link) ; !IsNull (ListHead, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(ListHead, &Node->Link) ; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
){ )
{
Size = StrSize (Node->Val) - sizeof (CHAR16); Size = StrSize (Node->Val) - sizeof (CHAR16);
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) { if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(Node->Key, Size, Node->Val); Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
} else { } else {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val); Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
} }
ASSERT_EFI_ERROR(Status);
ASSERT_EFI_ERROR (Status);
} }
FreeEnvironmentVariableList(ListHead);
FreeEnvironmentVariableList (ListHead);
return (Status); return (Status);
} }
@ -299,7 +319,7 @@ SetEnvironmentVariableList(
@sa SetEnvironmentVariableList @sa SetEnvironmentVariableList
**/ **/
EFI_STATUS EFI_STATUS
SetEnvironmentVariables( SetEnvironmentVariables (
IN CONST CHAR16 **Environment IN CONST CHAR16 **Environment
) )
{ {
@ -320,59 +340,63 @@ SetEnvironmentVariables(
for ( CurrentCount = 0 for ( CurrentCount = 0
; ;
; CurrentCount++ ; CurrentCount++
){ )
{
CurrentString = Environment[CurrentCount]; CurrentString = Environment[CurrentCount];
if (CurrentString == NULL) { if (CurrentString == NULL) {
break; break;
} }
ASSERT(StrStr(CurrentString, L"=") != NULL);
Node = AllocateZeroPool(sizeof(ENV_VAR_LIST)); ASSERT (StrStr (CurrentString, L"=") != NULL);
Node = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (Node == NULL) { if (Node == NULL) {
SetEnvironmentVariableList(&VarList->Link); SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
Node->Key = AllocateZeroPool((StrStr(CurrentString, L"=") - CurrentString + 1) * sizeof(CHAR16)); Node->Key = AllocateZeroPool ((StrStr (CurrentString, L"=") - CurrentString + 1) * sizeof (CHAR16));
if (Node->Key == NULL) { if (Node->Key == NULL) {
SHELL_FREE_NON_NULL(Node); SHELL_FREE_NON_NULL (Node);
SetEnvironmentVariableList(&VarList->Link); SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
// //
// Copy the string into the Key, leaving the last character allocated as NULL to terminate // Copy the string into the Key, leaving the last character allocated as NULL to terminate
// //
StrnCpyS( Node->Key, StrnCpyS (
StrStr(CurrentString, L"=") - CurrentString + 1, Node->Key,
StrStr (CurrentString, L"=") - CurrentString + 1,
CurrentString, CurrentString,
StrStr(CurrentString, L"=") - CurrentString StrStr (CurrentString, L"=") - CurrentString
); );
// //
// ValueSize = TotalSize - already removed size - size for '=' + size for terminator (the last 2 items cancel each other) // ValueSize = TotalSize - already removed size - size for '=' + size for terminator (the last 2 items cancel each other)
// //
Node->Val = AllocateCopyPool(StrSize(CurrentString) - StrSize(Node->Key), CurrentString + StrLen(Node->Key) + 1); Node->Val = AllocateCopyPool (StrSize (CurrentString) - StrSize (Node->Key), CurrentString + StrLen (Node->Key) + 1);
if (Node->Val == NULL) { if (Node->Val == NULL) {
SHELL_FREE_NON_NULL(Node->Key); SHELL_FREE_NON_NULL (Node->Key);
SHELL_FREE_NON_NULL(Node); SHELL_FREE_NON_NULL (Node);
SetEnvironmentVariableList(&VarList->Link); SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
Node->Atts = EFI_VARIABLE_BOOTSERVICE_ACCESS; Node->Atts = EFI_VARIABLE_BOOTSERVICE_ACCESS;
if (VarList == NULL) { if (VarList == NULL) {
VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST)); VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) { if (VarList == NULL) {
SHELL_FREE_NON_NULL(Node->Key); SHELL_FREE_NON_NULL (Node->Key);
SHELL_FREE_NON_NULL(Node->Val); SHELL_FREE_NON_NULL (Node->Val);
SHELL_FREE_NON_NULL(Node); SHELL_FREE_NON_NULL (Node);
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
InitializeListHead(&VarList->Link);
}
InsertTailList(&VarList->Link, &Node->Link);
InitializeListHead (&VarList->Link);
}
InsertTailList (&VarList->Link, &Node->Link);
} // for loop } // for loop
// //
@ -380,7 +404,7 @@ SetEnvironmentVariables(
// this function also frees the memory and deletes all pre-existing // this function also frees the memory and deletes all pre-existing
// shell-guid based environment variables. // shell-guid based environment variables.
// //
return (SetEnvironmentVariableList(&VarList->Link)); return (SetEnvironmentVariableList (&VarList->Link));
} }
/** /**
@ -408,20 +432,22 @@ ShellFindEnvVarInList (
{ {
ENV_VAR_LIST *Node; ENV_VAR_LIST *Node;
if (Key == NULL || Value == NULL || ValueSize == NULL) { if ((Key == NULL) || (Value == NULL) || (ValueSize == NULL)) {
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} }
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link) for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link) ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link) ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
){ )
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) { {
*Value = AllocateCopyPool(StrSize(Node->Val), Node->Val); if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
*ValueSize = StrSize(Node->Val); *Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
*ValueSize = StrSize (Node->Val);
if (Atts != NULL) { if (Atts != NULL) {
*Atts = Node->Atts; *Atts = Node->Atts;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
@ -454,7 +480,7 @@ ShellAddEnvVarToList (
CHAR16 *LocalKey; CHAR16 *LocalKey;
CHAR16 *LocalValue; CHAR16 *LocalValue;
if (Key == NULL || Value == NULL || ValueSize == 0) { if ((Key == NULL) || (Value == NULL) || (ValueSize == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -466,13 +492,14 @@ ShellAddEnvVarToList (
// //
// Update the variable value if it exists in gShellEnvVarList. // Update the variable value if it exists in gShellEnvVarList.
// //
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link) for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link) ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&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; Node->Atts = Atts;
SHELL_FREE_NON_NULL(Node->Val); SHELL_FREE_NON_NULL (Node->Val);
Node->Val = LocalValue; Node->Val = LocalValue;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -482,21 +509,23 @@ ShellAddEnvVarToList (
// If the environment variable key doesn't exist in list just insert // If the environment variable key doesn't exist in list just insert
// a new node. // a new node.
// //
LocalKey = AllocateCopyPool (StrSize(Key), Key); LocalKey = AllocateCopyPool (StrSize (Key), Key);
if (LocalKey == NULL) { if (LocalKey == NULL) {
FreePool (LocalValue); FreePool (LocalValue);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node = (ENV_VAR_LIST*)AllocateZeroPool (sizeof(ENV_VAR_LIST));
Node = (ENV_VAR_LIST *)AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (Node == NULL) { if (Node == NULL) {
FreePool (LocalKey); FreePool (LocalKey);
FreePool (LocalValue); FreePool (LocalValue);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node->Key = LocalKey; Node->Key = LocalKey;
Node->Val = LocalValue; Node->Val = LocalValue;
Node->Atts = Atts; Node->Atts = Atts;
InsertTailList(&gShellEnvVarList.Link, &Node->Link); InsertTailList (&gShellEnvVarList.Link, &Node->Link);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -521,15 +550,16 @@ ShellRemvoeEnvVarFromList (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link) for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link) ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link) ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
){ )
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) { {
SHELL_FREE_NON_NULL(Node->Key); if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
SHELL_FREE_NON_NULL(Node->Val); SHELL_FREE_NON_NULL (Node->Key);
RemoveEntryList(&Node->Link); SHELL_FREE_NON_NULL (Node->Val);
SHELL_FREE_NON_NULL(Node); RemoveEntryList (&Node->Link);
SHELL_FREE_NON_NULL (Node);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
@ -549,7 +579,7 @@ ShellInitEnvVarList (
{ {
EFI_STATUS Status; EFI_STATUS Status;
InitializeListHead(&gShellEnvVarList.Link); InitializeListHead (&gShellEnvVarList.Link);
Status = GetEnvironmentVariableList (&gShellEnvVarList.Link); Status = GetEnvironmentVariableList (&gShellEnvVarList.Link);
return Status; return Status;
@ -565,8 +595,7 @@ ShellFreeEnvVarList (
) )
{ {
FreeEnvironmentVariableList (&gShellEnvVarList.Link); FreeEnvironmentVariableList (&gShellEnvVarList.Link);
InitializeListHead(&gShellEnvVarList.Link); InitializeListHead (&gShellEnvVarList.Link);
return; return;
} }

View File

@ -26,7 +26,6 @@ typedef struct {
// //
extern ENV_VAR_LIST gShellEnvVarList; extern ENV_VAR_LIST gShellEnvVarList;
/** /**
Reports whether an environment variable is Volatile or Non-Volatile. Reports whether an environment variable is Volatile or Non-Volatile.
@ -73,7 +72,7 @@ IsVolatileEnv (
@retval other An error occurred @retval other An error occurred
@sa SetVariable @sa SetVariable
**/ **/
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \ #define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \ (gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \ &gShellVariableGuid, \
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@ -93,7 +92,7 @@ IsVolatileEnv (
@retval other An error occurred @retval other An error occurred
@sa SetVariable @sa SetVariable
**/ **/
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \ #define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer) \
(gRT->GetVariable((CHAR16*)EnvVarName, \ (gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \ &gShellVariableGuid, \
0, \ 0, \
@ -114,7 +113,7 @@ IsVolatileEnv (
@retval other An error occurred @retval other An error occurred
@sa SetVariable @sa SetVariable
**/ **/
#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer) \ #define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName, Atts, BufferSize, Buffer) \
(gRT->GetVariable((CHAR16*)EnvVarName, \ (gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \ &gShellVariableGuid, \
Atts, \ Atts, \
@ -134,7 +133,7 @@ IsVolatileEnv (
@retval other An error occurred @retval other An error occurred
@sa SetVariable @sa SetVariable
**/ **/
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \ #define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \ (gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \ &gShellVariableGuid, \
EFI_VARIABLE_BOOTSERVICE_ACCESS, \ EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@ -150,7 +149,7 @@ IsVolatileEnv (
@retval EFI_SUCCESS the list was created successfully. @retval EFI_SUCCESS the list was created successfully.
**/ **/
EFI_STATUS EFI_STATUS
GetEnvironmentVariableList( GetEnvironmentVariableList (
IN OUT LIST_ENTRY *List IN OUT LIST_ENTRY *List
); );
@ -167,7 +166,7 @@ GetEnvironmentVariableList(
@retval EFI_SUCCESS The list was Set successfully. @retval EFI_SUCCESS The list was Set successfully.
**/ **/
EFI_STATUS EFI_STATUS
SetEnvironmentVariableList( SetEnvironmentVariableList (
IN LIST_ENTRY *List IN LIST_ENTRY *List
); );
@ -187,7 +186,7 @@ SetEnvironmentVariableList(
@sa SetEnvironmentVariableList @sa SetEnvironmentVariableList
**/ **/
EFI_STATUS EFI_STATUS
SetEnvironmentVariables( SetEnvironmentVariables (
IN CONST CHAR16 **Environment IN CONST CHAR16 **Environment
); );
@ -197,7 +196,7 @@ SetEnvironmentVariables(
@param[in] List The pointer to pointer to list. @param[in] List The pointer to pointer to list.
**/ **/
VOID VOID
FreeEnvironmentVariableList( FreeEnvironmentVariableList (
IN LIST_ENTRY *List IN LIST_ENTRY *List
); );
@ -279,4 +278,3 @@ ShellFreeEnvVarList (
); );
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_ #endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_

View File

@ -17,15 +17,14 @@
EFI_HII_HANDLE mShellManHiiHandle = NULL; EFI_HII_HANDLE mShellManHiiHandle = NULL;
EFI_HANDLE mShellManDriverHandle = NULL; EFI_HANDLE mShellManDriverHandle = NULL;
SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = { SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
{ {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (VENDOR_DEVICE_PATH)), (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
} }
}, },
SHELL_MAN_HII_GUID SHELL_MAN_HII_GUID
@ -34,8 +33,8 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
END_DEVICE_PATH_TYPE, END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ {
(UINT8) (END_DEVICE_PATH_LENGTH), (UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
} }
} }
}; };
@ -57,6 +56,7 @@ GetExecuatableFileName (
{ {
CHAR16 *Buffer; CHAR16 *Buffer;
CHAR16 *SuffixStr; CHAR16 *SuffixStr;
if (NameString == NULL) { if (NameString == NULL) {
return (NULL); return (NULL);
} }
@ -64,31 +64,33 @@ GetExecuatableFileName (
// //
// Fix the file name // Fix the file name
// //
if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".efi"), L".efi", StrLen(L".efi"))==0) { if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".efi"), L".efi", StrLen (L".efi")) == 0) {
Buffer = AllocateCopyPool(StrSize(NameString), NameString); Buffer = AllocateCopyPool (StrSize (NameString), NameString);
} else if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".man"), L".man", StrLen(L".man"))==0) { } else if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".man"), L".man", StrLen (L".man")) == 0) {
Buffer = AllocateCopyPool(StrSize(NameString), NameString); Buffer = AllocateCopyPool (StrSize (NameString), NameString);
if (Buffer != NULL) { if (Buffer != NULL) {
SuffixStr = Buffer+StrLen(Buffer)-StrLen(L".man"); SuffixStr = Buffer+StrLen (Buffer)-StrLen (L".man");
StrnCpyS (SuffixStr, StrSize(L".man")/sizeof(CHAR16), L".efi", StrLen(L".efi")); StrnCpyS (SuffixStr, StrSize (L".man")/sizeof (CHAR16), L".efi", StrLen (L".efi"));
} }
} else { } else {
Buffer = AllocateZeroPool(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16)); Buffer = AllocateZeroPool (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16));
if (Buffer != NULL) { if (Buffer != NULL) {
StrnCpyS( Buffer, StrnCpyS (
(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16), Buffer,
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
NameString, NameString,
StrLen(NameString) StrLen (NameString)
); );
StrnCatS( Buffer, StrnCatS (
(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16), Buffer,
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
L".efi", L".efi",
StrLen(L".efi") StrLen (L".efi")
); );
} }
} }
return (Buffer);
return (Buffer);
} }
/** /**
@ -103,34 +105,39 @@ GetExecuatableFileName (
@return the new filename with .man as the extension. @return the new filename with .man as the extension.
**/ **/
CHAR16 * CHAR16 *
GetManFileName( GetManFileName (
IN CONST CHAR16 *ManFileName IN CONST CHAR16 *ManFileName
) )
{ {
CHAR16 *Buffer; CHAR16 *Buffer;
if (ManFileName == NULL) { if (ManFileName == NULL) {
return (NULL); return (NULL);
} }
// //
// Fix the file name // Fix the file name
// //
if (StrnCmp(ManFileName+StrLen(ManFileName)-4, L".man", 4)==0) { if (StrnCmp (ManFileName+StrLen (ManFileName)-4, L".man", 4) == 0) {
Buffer = AllocateCopyPool(StrSize(ManFileName), ManFileName); Buffer = AllocateCopyPool (StrSize (ManFileName), ManFileName);
} else { } else {
Buffer = AllocateZeroPool(StrSize(ManFileName) + 4*sizeof(CHAR16)); Buffer = AllocateZeroPool (StrSize (ManFileName) + 4*sizeof (CHAR16));
if (Buffer != NULL) { if (Buffer != NULL) {
StrnCpyS( Buffer, StrnCpyS (
(StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16), Buffer,
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
ManFileName, ManFileName,
StrLen(ManFileName) StrLen (ManFileName)
); );
StrnCatS( Buffer, StrnCatS (
(StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16), Buffer,
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
L".man", L".man",
4 4
); );
} }
} }
return (Buffer); return (Buffer);
} }
@ -149,7 +156,7 @@ GetManFileName(
@retval EFI_NOT_FOUND The file was not found. @retval EFI_NOT_FOUND The file was not found.
**/ **/
EFI_STATUS EFI_STATUS
SearchPathForFile( SearchPathForFile (
IN CONST CHAR16 *FileName, IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *Handle OUT SHELL_FILE_HANDLE *Handle
) )
@ -157,14 +164,15 @@ SearchPathForFile(
CHAR16 *FullFileName; CHAR16 *FullFileName;
EFI_STATUS Status; EFI_STATUS Status;
if ( FileName == NULL if ( (FileName == NULL)
|| Handle == NULL || (Handle == NULL)
|| StrLen(FileName) == 0 || (StrLen (FileName) == 0)
){ )
{
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
FullFileName = ShellFindFilePath(FileName); FullFileName = ShellFindFilePath (FileName);
if (FullFileName == NULL) { if (FullFileName == NULL) {
return (EFI_NOT_FOUND); return (EFI_NOT_FOUND);
} }
@ -172,8 +180,8 @@ SearchPathForFile(
// //
// now open that file // now open that file
// //
Status = EfiShellOpenFileByName(FullFileName, Handle, EFI_FILE_MODE_READ); Status = EfiShellOpenFileByName (FullFileName, Handle, EFI_FILE_MODE_READ);
FreePool(FullFileName); FreePool (FullFileName);
return (Status); return (Status);
} }
@ -197,7 +205,7 @@ SearchPathForFile(
an allocated buffer. an allocated buffer.
**/ **/
EFI_STATUS EFI_STATUS
ManFileFindSections( ManFileFindSections (
IN SHELL_FILE_HANDLE Handle, IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections, IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText, OUT CHAR16 **HelpText,
@ -213,10 +221,11 @@ ManFileFindSections(
UINTN SectionLen; UINTN SectionLen;
BOOLEAN Found; BOOLEAN Found;
if ( Handle == NULL if ( (Handle == NULL)
|| HelpText == NULL || (HelpText == NULL)
|| HelpSize == NULL || (HelpSize == NULL)
){ )
{
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -225,55 +234,63 @@ ManFileFindSections(
Size = 1024; Size = 1024;
Found = FALSE; Found = FALSE;
ReadLine = AllocateZeroPool(Size); ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) { if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
for (;!ShellFileHandleEof(Handle);Size = 1024) { for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, &Ascii); Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, &Ascii);
if (ReadLine[0] == L'#') { if (ReadLine[0] == L'#') {
// //
// Skip comment lines // Skip comment lines
// //
continue; continue;
} }
// //
// ignore too small of buffer... // ignore too small of buffer...
// //
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status == EFI_BUFFER_TOO_SMALL) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
break; break;
} else if (StrnCmp(ReadLine, L".TH", 3) == 0) { } else if (StrnCmp (ReadLine, L".TH", 3) == 0) {
// //
// we hit the end of this commands section so stop. // we hit the end of this commands section so stop.
// //
break; break;
} else if (StrnCmp(ReadLine, L".SH", 3) == 0) { } else if (StrnCmp (ReadLine, L".SH", 3) == 0) {
if (Sections == NULL) { if (Sections == NULL) {
CurrentlyReading = TRUE; CurrentlyReading = TRUE;
continue; continue;
} }
// //
// we found a section // we found a section
// //
if (CurrentlyReading) { if (CurrentlyReading) {
CurrentlyReading = FALSE; CurrentlyReading = FALSE;
} }
// //
// is this a section we want to read in? // is this a section we want to read in?
// //
for ( SectionName = ReadLine + 3 for ( SectionName = ReadLine + 3
; *SectionName == L' ' ; *SectionName == L' '
; SectionName++); ; SectionName++)
SectionLen = StrLen(SectionName); {
SectionName = StrStr(Sections, SectionName); }
SectionLen = StrLen (SectionName);
SectionName = StrStr (Sections, SectionName);
if (SectionName == NULL) { if (SectionName == NULL) {
continue; continue;
} }
if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {
if ((*(SectionName + SectionLen) == CHAR_NULL) || (*(SectionName + SectionLen) == L',')) {
CurrentlyReading = TRUE; CurrentlyReading = TRUE;
} }
} else if (CurrentlyReading) { } else if (CurrentlyReading) {
@ -281,15 +298,17 @@ ManFileFindSections(
// //
// copy and save the current line. // copy and save the current line.
// //
ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL)); ASSERT ((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));
StrnCatGrow (HelpText, HelpSize, ReadLine, 0); StrnCatGrow (HelpText, HelpSize, ReadLine, 0);
StrnCatGrow (HelpText, HelpSize, L"\r\n", 0); StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);
} }
} }
FreePool(ReadLine);
if (!Found && !EFI_ERROR(Status)) { FreePool (ReadLine);
if (!Found && !EFI_ERROR (Status)) {
return (EFI_NOT_FOUND); return (EFI_NOT_FOUND);
} }
return (Status); return (Status);
} }
@ -315,7 +334,7 @@ ManFileFindSections(
@retval FALSE Line did not contain the Title Header @retval FALSE Line did not contain the Title Header
**/ **/
BOOLEAN BOOLEAN
IsTitleHeader( IsTitleHeader (
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CHAR16 *Line, IN CHAR16 *Line,
OUT CHAR16 **BriefDesc OPTIONAL, OUT CHAR16 **BriefDesc OPTIONAL,
@ -340,28 +359,25 @@ IsTitleHeader(
State = LookForThMacro; State = LookForThMacro;
do { do {
if (*Line == L'\0') { if (*Line == L'\0') {
break; break;
} }
switch (State) { switch (State) {
// Handle "^\s*.TH\s" // Handle "^\s*.TH\s"
// Go to state LookForCommandName if the title header macro is present; otherwise, // 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 // eat white space. If we see something other than white space, this is not a
// title header line. // title header line.
case LookForThMacro: 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; Line += 4;
State = LookForCommandName; State = LookForCommandName;
} } else if ((*Line == L' ') || (*Line == L'\t')) {
else if (*Line == L' ' || *Line == L'\t') {
Line++; Line++;
} } else {
else {
State = Final; State = Final;
} }
break; break;
// Handle "\s*" // Handle "\s*"
@ -369,15 +385,15 @@ IsTitleHeader(
// at least one white space character). Go to state CompareCommands when a // at least one white space character). Go to state CompareCommands when a
// non-white space is seen. // non-white space is seen.
case LookForCommandName: case LookForCommandName:
if (*Line == L' ' || *Line == L'\t') { if ((*Line == L' ') || (*Line == L'\t')) {
Line++; Line++;
} } else {
else {
ReturnValue = TRUE; // This is *some* command's title header line. ReturnValue = TRUE; // This is *some* command's title header line.
State = CompareCommands; State = CompareCommands;
// Do not increment Line; it points to the first character of the command // Do not increment Line; it points to the first character of the command
// name on the title header line. // name on the title header line.
} }
break; break;
// Handle "(\S)\s" // Handle "(\S)\s"
@ -385,13 +401,13 @@ IsTitleHeader(
// reach the end of the command (i.e. we see white space), the next state // 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. // depends on whether the caller wants a copy of the Brief Description.
case CompareCommands: 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. ReturnFound = TRUE; // This is the desired command's title header line.
State = (BriefDesc == NULL) ? Final : GetBriefDescription; State = (BriefDesc == NULL) ? Final : GetBriefDescription;
} } else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
State = Final; State = Final;
} }
Line++; Line++;
break; break;
@ -399,21 +415,22 @@ IsTitleHeader(
// Skip whitespace, '0', and '1' characters, if any, prior to the brief description. // Skip whitespace, '0', and '1' characters, if any, prior to the brief description.
// Return the description to the caller. // Return the description to the caller.
case GetBriefDescription: 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); *BriefSize = StrSize (Line);
*BriefDesc = AllocateZeroPool(*BriefSize); *BriefDesc = AllocateZeroPool (*BriefSize);
if (*BriefDesc != NULL) { if (*BriefDesc != NULL) {
StrCpyS(*BriefDesc, (*BriefSize)/sizeof(CHAR16), Line); StrCpyS (*BriefDesc, (*BriefSize)/sizeof (CHAR16), Line);
} }
State = Final; State = Final;
} }
Line++; Line++;
break; break;
default: default:
break; break;
} }
} while (State < Final); } while (State < Final);
*Found = ReturnFound; *Found = ReturnFound;
@ -441,7 +458,7 @@ IsTitleHeader(
an allocated buffer if requested. an allocated buffer if requested.
**/ **/
EFI_STATUS EFI_STATUS
ManFileFindTitleSection( ManFileFindTitleSection (
IN SHELL_FILE_HANDLE Handle, IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
OUT CHAR16 **BriefDesc OPTIONAL, OUT CHAR16 **BriefDesc OPTIONAL,
@ -455,10 +472,11 @@ ManFileFindTitleSection(
BOOLEAN Found; BOOLEAN Found;
UINTN Start; UINTN Start;
if ( Handle == NULL if ( (Handle == NULL)
|| Command == NULL || (Command == NULL)
|| (BriefDesc != NULL && BriefSize == NULL) || ((BriefDesc != NULL) && (BriefSize == NULL))
){ )
{
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -466,7 +484,7 @@ ManFileFindTitleSection(
Size = 1024; Size = 1024;
Found = FALSE; Found = FALSE;
ReadLine = AllocateZeroPool(Size); ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) { if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES); return (EFI_OUT_OF_RESOURCES);
} }
@ -474,20 +492,21 @@ ManFileFindTitleSection(
// //
// Do not pass any leading path information that may be present to IsTitleHeader(). // Do not pass any leading path information that may be present to IsTitleHeader().
// //
Start = StrLen(Command); Start = StrLen (Command);
while ((Start != 0) while ( (Start != 0)
&& (*(Command + Start - 1) != L'\\') && (*(Command + Start - 1) != L'\\')
&& (*(Command + Start - 1) != L'/') && (*(Command + Start - 1) != L'/')
&& (*(Command + Start - 1) != L':')) { && (*(Command + Start - 1) != L':'))
{
--Start; --Start;
} }
for (;!ShellFileHandleEof(Handle);Size = 1024) { for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii); Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, Ascii);
// //
// ignore too small of buffer... // ignore too small of buffer...
// //
if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
break; break;
} }
@ -498,7 +517,7 @@ ManFileFindTitleSection(
} }
} }
FreePool(ReadLine); FreePool (ReadLine);
return (Status); return (Status);
} }
@ -533,7 +552,7 @@ ManFileFindTitleSection(
@retval EFI_NOT_FOUND There is no help text available for Command. @retval EFI_NOT_FOUND There is no help text available for Command.
**/ **/
EFI_STATUS EFI_STATUS
ProcessManFile( ProcessManFile (
IN CONST CHAR16 *ManFileName, IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL, IN CONST CHAR16 *Sections OPTIONAL,
@ -555,10 +574,11 @@ ProcessManFile(
EFI_DEVICE_PATH_PROTOCOL *DevPath; EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader; EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
if ( ManFileName == NULL if ( (ManFileName == NULL)
|| Command == NULL || (Command == NULL)
|| HelpText == NULL || (HelpText == NULL)
){ )
{
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -577,7 +597,7 @@ ProcessManFile(
// //
// See if it's in HII first // See if it's in HII first
// //
TempString = ShellCommandGetCommandHelp(Command); TempString = ShellCommandGetCommandHelp (Command);
if (TempString != NULL) { if (TempString != NULL) {
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL); FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16); HelpSize = StrLen (TempString) * sizeof (CHAR16);
@ -585,39 +605,41 @@ ProcessManFile(
ShellSetFilePosition (FileHandle, 0); ShellSetFilePosition (FileHandle, 0);
HelpSize = 0; HelpSize = 0;
BriefSize = 0; BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii); 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); Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
} }
ShellCloseFile (&FileHandle); ShellCloseFile (&FileHandle);
} else { } else {
// //
// If the image is a external app, check .MAN file first. // If the image is a external app, check .MAN file first.
// //
FileHandle = NULL; FileHandle = NULL;
TempString = GetManFileName(ManFileName); TempString = GetManFileName (ManFileName);
if (TempString == NULL) { if (TempString == NULL) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
Status = SearchPathForFile(TempString, &FileHandle); Status = SearchPathForFile (TempString, &FileHandle);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
FileDevPath = FileDevicePath(NULL, TempString); FileDevPath = FileDevicePath (NULL, TempString);
DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath); DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);
Status = InternalOpenFileDevicePath(DevPath, &FileHandle, EFI_FILE_MODE_READ, 0); Status = InternalOpenFileDevicePath (DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);
SHELL_FREE_NON_NULL(FileDevPath); SHELL_FREE_NON_NULL (FileDevPath);
SHELL_FREE_NON_NULL(DevPath); SHELL_FREE_NON_NULL (DevPath);
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
HelpSize = 0; HelpSize = 0;
BriefSize = 0; BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii); 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); Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
} }
ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);
if (!EFI_ERROR(Status)) { ShellInfoObject.NewEfiShellProtocol->CloseFile (FileHandle);
if (!EFI_ERROR (Status)) {
// //
// Get help text from .MAN file success. // Get help text from .MAN file success.
// //
@ -628,23 +650,25 @@ ProcessManFile(
// //
// Load the app image to check EFI_HII_PACKAGE_LIST_PROTOCOL. // Load the app image to check EFI_HII_PACKAGE_LIST_PROTOCOL.
// //
CmdFileName = GetExecuatableFileName(TempString); CmdFileName = GetExecuatableFileName (TempString);
if (CmdFileName == NULL) { if (CmdFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Done; goto Done;
} }
// //
// If the file in CWD then use the file name, else use the full // If the file in CWD then use the file name, else use the full
// path name. // path name.
// //
CmdFilePathName = ShellFindFilePath(CmdFileName); CmdFilePathName = ShellFindFilePath (CmdFileName);
if (CmdFilePathName == NULL) { if (CmdFilePathName == NULL) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
goto Done; goto Done;
} }
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CmdFilePathName);
Status = gBS->LoadImage(FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle); DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
if(EFI_ERROR(Status)) { Status = gBS->LoadImage (FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
if (EFI_ERROR (Status)) {
// //
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now. // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
@ -654,18 +678,20 @@ ProcessManFile(
if (Status == EFI_SECURITY_VIOLATION) { if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (CmdFileImgHandle); gBS->UnloadImage (CmdFileImgHandle);
} }
*HelpText = NULL; *HelpText = NULL;
goto Done; goto Done;
} }
Status = gBS->OpenProtocol(
Status = gBS->OpenProtocol (
CmdFileImgHandle, CmdFileImgHandle,
&gEfiHiiPackageListProtocolGuid, &gEfiHiiPackageListProtocolGuid,
(VOID**)&PackageListHeader, (VOID **)&PackageListHeader,
gImageHandle, gImageHandle,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if(EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
*HelpText = NULL; *HelpText = NULL;
goto Done; goto Done;
} }
@ -679,7 +705,7 @@ ProcessManFile(
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
&mShellManHiiDevicePath &mShellManHiiDevicePath
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
@ -695,27 +721,30 @@ ProcessManFile(
StringIdWalker = 1; StringIdWalker = 1;
do { do {
SHELL_FREE_NON_NULL(TempString); SHELL_FREE_NON_NULL (TempString);
if (BriefDesc != NULL) { if (BriefDesc != NULL) {
SHELL_FREE_NON_NULL(*BriefDesc); SHELL_FREE_NON_NULL (*BriefDesc);
} }
TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL); TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
if (TempString == NULL) { if (TempString == NULL) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
goto Done; goto Done;
} }
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL); FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16); HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString); ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0); ShellSetFilePosition (FileHandle, 0);
HelpSize = 0; HelpSize = 0;
BriefSize = 0; BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii); 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); Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
} }
ShellCloseFile (&FileHandle); ShellCloseFile (&FileHandle);
if (!EFI_ERROR(Status)){ if (!EFI_ERROR (Status)) {
// //
// Found what we need and return // Found what we need and return
// //
@ -724,7 +753,6 @@ ProcessManFile(
StringIdWalker += 1; StringIdWalker += 1;
} while (StringIdWalker < 0xFFFF && TempString != NULL); } while (StringIdWalker < 0xFFFF && TempString != NULL);
} }
Done: Done:
@ -746,12 +774,11 @@ Done:
Status = gBS->UnloadImage (CmdFileImgHandle); Status = gBS->UnloadImage (CmdFileImgHandle);
} }
SHELL_FREE_NON_NULL(TempString); SHELL_FREE_NON_NULL (TempString);
SHELL_FREE_NON_NULL(CmdFileName); SHELL_FREE_NON_NULL (CmdFileName);
SHELL_FREE_NON_NULL(CmdFilePathName); SHELL_FREE_NON_NULL (CmdFilePathName);
SHELL_FREE_NON_NULL(FileDevPath); SHELL_FREE_NON_NULL (FileDevPath);
SHELL_FREE_NON_NULL(DevPath); SHELL_FREE_NON_NULL (DevPath);
return (Status); return (Status);
} }

View File

@ -39,7 +39,7 @@
@retval EFI_NOT_FOUND There is no help text available for Command. @retval EFI_NOT_FOUND There is no help text available for Command.
**/ **/
EFI_STATUS EFI_STATUS
ProcessManFile( ProcessManFile (
IN CONST CHAR16 *ManFileName, IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL, IN CONST CHAR16 *Sections OPTIONAL,
@ -66,7 +66,7 @@ ProcessManFile(
an allocated buffer. an allocated buffer.
**/ **/
EFI_STATUS EFI_STATUS
ManFileFindSections( ManFileFindSections (
IN SHELL_FILE_HANDLE Handle, IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections, IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText, OUT CHAR16 **HelpText,
@ -75,4 +75,3 @@ ManFileFindSections(
); );
#endif //_SHELL_MAN_FILE_PARSER_HEADER_ #endif //_SHELL_MAN_FILE_PARSER_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,7 @@ CleanUpShellParametersProtocol (
@retval EFI_OUT_OF_RESOURCES a memory allocation failed. @retval EFI_OUT_OF_RESOURCES a memory allocation failed.
**/ **/
EFI_STATUS EFI_STATUS
UpdateArgcArgv( UpdateArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CONST CHAR16 *NewCommandLine, IN CONST CHAR16 *NewCommandLine,
IN SHELL_OPERATION_TYPES Type, IN SHELL_OPERATION_TYPES Type,
@ -93,7 +93,7 @@ UpdateArgcArgv(
@param[in] OldArgc pointer to old number of items in Argv list @param[in] OldArgc pointer to old number of items in Argv list
**/ **/
VOID VOID
RestoreArgcArgv( RestoreArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 ***OldArgv, IN CHAR16 ***OldArgv,
IN UINTN *OldArgc IN UINTN *OldArgc
@ -126,7 +126,7 @@ typedef struct {
@retval EFI_OUT_OF_RESOURCES A memory allocation failed. @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/ **/
EFI_STATUS EFI_STATUS
UpdateStdInStdOutStdErr( UpdateStdInStdOutStdErr (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 *NewCommandLine, IN CHAR16 *NewCommandLine,
OUT SHELL_FILE_HANDLE *OldStdIn, OUT SHELL_FILE_HANDLE *OldStdIn,
@ -172,7 +172,7 @@ RestoreStdInStdOutStdErr (
@return EFI_OUT_OF_RESOURCES a memory allocation failed. @return EFI_OUT_OF_RESOURCES a memory allocation failed.
**/ **/
EFI_STATUS EFI_STATUS
ParseCommandLineToArgs( ParseCommandLineToArgs (
IN CONST CHAR16 *CommandLine, IN CONST CHAR16 *CommandLine,
IN BOOLEAN StripQuotation, IN BOOLEAN StripQuotation,
IN OUT CHAR16 ***Argv, IN OUT CHAR16 ***Argv,
@ -200,7 +200,7 @@ ParseCommandLineToArgs(
@return EFI_NOT_FOUND A closing " could not be found on the specified string @return EFI_NOT_FOUND A closing " could not be found on the specified string
**/ **/
EFI_STATUS EFI_STATUS
GetNextParameter( GetNextParameter (
IN OUT CHAR16 **Walker, IN OUT CHAR16 **Walker,
IN OUT CHAR16 **TempParameter, IN OUT CHAR16 **TempParameter,
IN CONST UINTN Length, IN CONST UINTN Length,
@ -208,4 +208,3 @@ GetNextParameter(
); );
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_ #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -87,7 +87,7 @@ CleanUpShellEnvironment (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellSetMap( EfiShellSetMap (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
IN CONST CHAR16 *Mapping IN CONST CHAR16 *Mapping
); );
@ -107,7 +107,7 @@ EfiShellSetMap(
**/ **/
CONST EFI_DEVICE_PATH_PROTOCOL * CONST EFI_DEVICE_PATH_PROTOCOL *
EFIAPI EFIAPI
EfiShellGetDevicePathFromMap( EfiShellGetDevicePathFromMap (
IN CONST CHAR16 *Mapping IN CONST CHAR16 *Mapping
); );
@ -130,7 +130,7 @@ EfiShellGetDevicePathFromMap(
**/ **/
CONST CHAR16 * CONST CHAR16 *
EFIAPI EFIAPI
EfiShellGetMapFromDevicePath( EfiShellGetMapFromDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
); );
@ -149,7 +149,7 @@ EfiShellGetMapFromDevicePath(
**/ **/
CHAR16 * CHAR16 *
EFIAPI EFIAPI
EfiShellGetFilePathFromDevicePath( EfiShellGetFilePathFromDevicePath (
IN CONST EFI_DEVICE_PATH_PROTOCOL *Path IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
); );
@ -166,7 +166,7 @@ EfiShellGetFilePathFromDevicePath(
**/ **/
EFI_DEVICE_PATH_PROTOCOL * EFI_DEVICE_PATH_PROTOCOL *
EFIAPI EFIAPI
EfiShellGetDevicePathFromFilePath( EfiShellGetDevicePathFromFilePath (
IN CONST CHAR16 *Path IN CONST CHAR16 *Path
); );
@ -208,7 +208,7 @@ EfiShellGetDevicePathFromFilePath(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellGetDeviceName( EfiShellGetDeviceName (
IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE DeviceHandle,
IN EFI_SHELL_DEVICE_NAME_FLAGS Flags, IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
IN CHAR8 *Language, IN CHAR8 *Language,
@ -232,7 +232,7 @@ EfiShellGetDeviceName(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellOpenRootByHandle( EfiShellOpenRootByHandle (
IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE DeviceHandle,
OUT SHELL_FILE_HANDLE *FileHandle OUT SHELL_FILE_HANDLE *FileHandle
); );
@ -255,7 +255,7 @@ EfiShellOpenRootByHandle(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellOpenRoot( EfiShellOpenRoot (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT SHELL_FILE_HANDLE *FileHandle OUT SHELL_FILE_HANDLE *FileHandle
); );
@ -287,7 +287,7 @@ EfiShellBatchIsActive (
@retval other an error occurred. @retval other an error occurred.
**/ **/
EFI_STATUS EFI_STATUS
InternalOpenFileDevicePath( InternalOpenFileDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2, IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,
OUT SHELL_FILE_HANDLE *FileHandle, OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode, IN UINT64 OpenMode,
@ -332,7 +332,7 @@ InternalOpenFileDevicePath(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellCreateFile( EfiShellCreateFile (
IN CONST CHAR16 *FileName, IN CONST CHAR16 *FileName,
IN UINT64 FileAttribs, IN UINT64 FileAttribs,
OUT SHELL_FILE_HANDLE *FileHandle OUT SHELL_FILE_HANDLE *FileHandle
@ -392,7 +392,7 @@ EfiShellCreateFile(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellOpenFileByName( EfiShellOpenFileByName (
IN CONST CHAR16 *FileName, IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *FileHandle, OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode IN UINT64 OpenMode
@ -412,7 +412,7 @@ EfiShellOpenFileByName(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellDeleteFileByName( EfiShellDeleteFileByName (
IN CONST CHAR16 *FileName IN CONST CHAR16 *FileName
); );
@ -456,7 +456,7 @@ EfiShellEnablePageBreak (
@retval EFI_UNSUPPORTED Nested shell invocations are not allowed. @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/ **/
EFI_STATUS EFI_STATUS
InternalShellExecuteDevicePath( InternalShellExecuteDevicePath (
IN CONST EFI_HANDLE *ParentImageHandle, IN CONST EFI_HANDLE *ParentImageHandle,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST CHAR16 *CommandLine OPTIONAL, IN CONST CHAR16 *CommandLine OPTIONAL,
@ -497,7 +497,7 @@ InternalShellExecuteDevicePath(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellExecute( EfiShellExecute (
IN EFI_HANDLE *ParentImageHandle, IN EFI_HANDLE *ParentImageHandle,
IN CHAR16 *CommandLine OPTIONAL, IN CHAR16 *CommandLine OPTIONAL,
IN CHAR16 **Environment OPTIONAL, IN CHAR16 **Environment OPTIONAL,
@ -513,7 +513,7 @@ EfiShellExecute(
@param FileListNode pointer to the list node to free @param FileListNode pointer to the list node to free
**/ **/
VOID VOID
FreeShellFileInfoNode( FreeShellFileInfoNode (
IN EFI_SHELL_FILE_INFO *FileListNode IN EFI_SHELL_FILE_INFO *FileListNode
); );
@ -531,7 +531,7 @@ FreeShellFileInfoNode(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellFreeFileList( EfiShellFreeFileList (
IN EFI_SHELL_FILE_INFO **FileList IN EFI_SHELL_FILE_INFO **FileList
); );
@ -547,7 +547,7 @@ EfiShellFreeFileList(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellRemoveDupInFileList( EfiShellRemoveDupInFileList (
IN EFI_SHELL_FILE_INFO **FileList IN EFI_SHELL_FILE_INFO **FileList
); );
@ -563,7 +563,7 @@ EfiShellRemoveDupInFileList(
**/ **/
EFI_SHELL_FILE_INFO * EFI_SHELL_FILE_INFO *
CreateAndPopulateShellFileInfo( CreateAndPopulateShellFileInfo (
IN CONST CHAR16 *BasePath, IN CONST CHAR16 *BasePath,
IN CONST EFI_STATUS Status, IN CONST EFI_STATUS Status,
IN CONST CHAR16 *FileName, IN CONST CHAR16 *FileName,
@ -586,7 +586,7 @@ CreateAndPopulateShellFileInfo(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellFindFilesInDir( EfiShellFindFilesInDir (
IN SHELL_FILE_HANDLE FileDirHandle, IN SHELL_FILE_HANDLE FileDirHandle,
OUT EFI_SHELL_FILE_INFO **FileList OUT EFI_SHELL_FILE_INFO **FileList
); );
@ -619,7 +619,7 @@ EfiShellFindFilesInDir(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellFindFiles( EfiShellFindFiles (
IN CONST CHAR16 *FilePattern, IN CONST CHAR16 *FilePattern,
OUT EFI_SHELL_FILE_INFO **FileList OUT EFI_SHELL_FILE_INFO **FileList
); );
@ -641,7 +641,7 @@ EfiShellFindFiles(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellOpenFileList( EfiShellOpenFileList (
IN CHAR16 *Path, IN CHAR16 *Path,
IN UINT64 OpenMode, IN UINT64 OpenMode,
IN OUT EFI_SHELL_FILE_INFO **FileList IN OUT EFI_SHELL_FILE_INFO **FileList
@ -660,7 +660,7 @@ EfiShellOpenFileList(
**/ **/
CONST CHAR16 * CONST CHAR16 *
EFIAPI EFIAPI
EfiShellGetEnv( EfiShellGetEnv (
IN CONST CHAR16 *Name IN CONST CHAR16 *Name
); );
@ -687,7 +687,7 @@ EfiShellGetEnv(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellSetEnv( EfiShellSetEnv (
IN CONST CHAR16 *Name, IN CONST CHAR16 *Name,
IN CONST CHAR16 *Value, IN CONST CHAR16 *Value,
IN BOOLEAN Volatile IN BOOLEAN Volatile
@ -709,7 +709,7 @@ EfiShellSetEnv(
**/ **/
CONST CHAR16 * CONST CHAR16 *
EFIAPI EFIAPI
EfiShellGetCurDir( EfiShellGetCurDir (
IN CONST CHAR16 *FileSystemMapping OPTIONAL IN CONST CHAR16 *FileSystemMapping OPTIONAL
); );
@ -738,7 +738,7 @@ EfiShellGetCurDir(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellSetCurDir( EfiShellSetCurDir (
IN CONST CHAR16 *FileSystem OPTIONAL, IN CONST CHAR16 *FileSystem OPTIONAL,
IN CONST CHAR16 *Dir IN CONST CHAR16 *Dir
); );
@ -770,7 +770,7 @@ EfiShellSetCurDir(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellGetHelpText( EfiShellGetHelpText (
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL, IN CONST CHAR16 *Sections OPTIONAL,
OUT CHAR16 **HelpText OUT CHAR16 **HelpText
@ -786,7 +786,7 @@ EfiShellGetHelpText(
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
EfiShellGetPageBreak( EfiShellGetPageBreak (
VOID VOID
); );
@ -800,7 +800,7 @@ EfiShellGetPageBreak(
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
EfiShellIsRootShell( EfiShellIsRootShell (
VOID VOID
); );
@ -823,7 +823,7 @@ EfiShellIsRootShell(
**/ **/
CONST CHAR16 * CONST CHAR16 *
EFIAPI EFIAPI
EfiShellGetAlias( EfiShellGetAlias (
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
OUT BOOLEAN *Volatile OPTIONAL OUT BOOLEAN *Volatile OPTIONAL
); );
@ -845,7 +845,7 @@ EfiShellGetAlias(
@retval EFI_NOT_FOUND the Alias intended to be deleted was not found @retval EFI_NOT_FOUND the Alias intended to be deleted was not found
**/ **/
EFI_STATUS EFI_STATUS
InternalSetAlias( InternalSetAlias (
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CONST CHAR16 *Alias OPTIONAL, IN CONST CHAR16 *Alias OPTIONAL,
IN BOOLEAN Volatile IN BOOLEAN Volatile
@ -873,7 +873,7 @@ InternalSetAlias(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiShellSetAlias( EfiShellSetAlias (
IN CONST CHAR16 *Command, IN CONST CHAR16 *Command,
IN CONST CHAR16 *Alias OPTIONAL, IN CONST CHAR16 *Alias OPTIONAL,
IN BOOLEAN Replace, IN BOOLEAN Replace,
@ -889,7 +889,7 @@ EfiShellSetAlias(
@param FileListNode pointer to the list node to free @param FileListNode pointer to the list node to free
**/ **/
VOID VOID
InternalFreeShellFileInfoNode( InternalFreeShellFileInfoNode (
IN EFI_SHELL_FILE_INFO *FileListNode IN EFI_SHELL_FILE_INFO *FileListNode
); );
@ -904,7 +904,7 @@ InternalFreeShellFileInfoNode(
@retval EFI_SUCCESS The environment variable was successfully updated. @retval EFI_SUCCESS The environment variable was successfully updated.
**/ **/
EFI_STATUS EFI_STATUS
InternalEfiShellSetEnv( InternalEfiShellSetEnv (
IN CONST CHAR16 *Name, IN CONST CHAR16 *Name,
IN CONST CHAR16 *Value, IN CONST CHAR16 *Value,
IN BOOLEAN Volatile IN BOOLEAN Volatile
@ -918,7 +918,7 @@ InternalEfiShellSetEnv(
@retval EFI_OUT_OF_RESOURCES There is not enough memory available. @retval EFI_OUT_OF_RESOURCES There is not enough memory available.
**/ **/
EFI_STATUS EFI_STATUS
InernalEfiShellStartMonitor( InernalEfiShellStartMonitor (
VOID VOID
); );
@ -931,8 +931,8 @@ InernalEfiShellStartMonitor(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
NotificationFunction( NotificationFunction (
IN EFI_KEY_DATA *KeyData IN EFI_KEY_DATA *KeyData
); );
#endif //_SHELL_PROTOCOL_HEADER_
#endif //_SHELL_PROTOCOL_HEADER_

View File

@ -34,11 +34,13 @@ ShellAppMain (
) )
{ {
UINTN Index; UINTN Index;
if (Argc == 1) { if (Argc == 1) {
Print (L"Argv[1] = NULL\n"); Print (L"Argv[1] = NULL\n");
} }
for (Index = 1; Index < Argc; Index++) { for (Index = 1; Index < Argc; Index++) {
Print(L"Argv[%d]: \"%s\"\n", Index, Argv[Index]); Print (L"Argv[%d]: \"%s\"\n", Index, Argv[Index]);
} }
return 0; return 0;

View File

@ -27,6 +27,6 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
Print(L"ShellExecute - Pass"); Print (L"ShellExecute - Pass");
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -24,14 +24,19 @@
**/ **/
INTN INTN
EFIAPI EFIAPI
Test(CONST VOID *b1, CONST VOID *b2) Test (
CONST VOID *b1,
CONST VOID *b2
)
{ {
if (*(INTN*)b1 == *(INTN*)b2) { if (*(INTN *)b1 == *(INTN *)b2) {
return (0); return (0);
} }
if (*(INTN*)b1 < *(INTN*)b2) {
return(-1); if (*(INTN *)b1 < *(INTN *)b2) {
return (-1);
} }
return (1); return (1);
} }
@ -69,9 +74,9 @@ ShellAppMain (
Array[8] = 1; Array[8] = 1;
Array[9] = 5; Array[9] = 5;
Print(L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0],Array[1],Array[2],Array[3],Array[4],Array[5],Array[6],Array[7],Array[8],Array[9]); Print (L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0], Array[1], Array[2], Array[3], Array[4], Array[5], Array[6], Array[7], Array[8], Array[9]);
PerformQuickSort(Array, 10, sizeof(INTN), Test); PerformQuickSort (Array, 10, sizeof (INTN), Test);
Print(L"POST-SORT\r\n"); Print (L"POST-SORT\r\n");
Print(L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0],Array[1],Array[2],Array[3],Array[4],Array[5],Array[6],Array[7],Array[8],Array[9]); Print (L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0], Array[1], Array[2], Array[3], Array[4], Array[5], Array[6], Array[7], Array[8], Array[9]);
return 0; return 0;
} }

View File

@ -72,20 +72,20 @@ PERF_CUM_DATA CumData[] = {
}; };
/// Number of items for which we are gathering cumulative statistics. /// Number of items for which we are gathering cumulative statistics.
UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA); UINT32 const NumCum = sizeof (CumData) / sizeof (PERF_CUM_DATA);
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-v", TypeFlag}, // -v Verbose Mode { L"-v", TypeFlag }, // -v Verbose Mode
{L"-A", TypeFlag}, // -A All, Cooked { L"-A", TypeFlag }, // -A All, Cooked
{L"-R", TypeFlag}, // -R RAW All { L"-R", TypeFlag }, // -R RAW All
{L"-s", TypeFlag}, // -s Summary { L"-s", TypeFlag }, // -s Summary
{L"-x", TypeFlag}, // -x eXclude Cumulative Items { L"-x", TypeFlag }, // -x eXclude Cumulative Items
{L"-i", TypeFlag}, // -i Display Identifier { L"-i", TypeFlag }, // -i Display Identifier
{L"-c", TypeValue}, // -c Display cumulative data. { L"-c", TypeValue }, // -c Display cumulative data.
{L"-n", TypeValue}, // -n # Number of records to display for A and R { L"-n", TypeValue }, // -n # Number of records to display for A and R
{L"-t", TypeValue}, // -t # Threshold of interest { L"-t", TypeValue }, // -t # Threshold of interest
{NULL, TypeMax} { NULL, TypeMax }
}; };
///@} ///@}
@ -93,14 +93,23 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
Display the trailing Verbose information. Display the trailing Verbose information.
**/ **/
VOID VOID
DumpStatistics( void ) DumpStatistics (
void
)
{ {
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); -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_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_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
@ -121,7 +130,7 @@ GetBootPerformanceTable (
{ {
FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable; FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable;
FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *) EfiLocateFirstAcpiTable ( FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *)EfiLocateFirstAcpiTable (
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
); );
if (FirmwarePerformanceTable == NULL) { if (FirmwarePerformanceTable == NULL) {
@ -129,8 +138,8 @@ GetBootPerformanceTable (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
mBootPerformanceTable = (UINT8*) (UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer; mBootPerformanceTable = (UINT8 *)(UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) mBootPerformanceTable)->Header.Length; mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *)mBootPerformanceTable)->Header.Length;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -153,6 +162,7 @@ GetHandleFormModuleGuid (
if (IsZeroGuid (ModuleGuid)) { if (IsZeroGuid (ModuleGuid)) {
*Handle = NULL; *Handle = NULL;
} }
// //
// Try to get the Handle from the cached array. // Try to get the Handle from the cached array.
// //
@ -162,6 +172,7 @@ GetHandleFormModuleGuid (
break; break;
} }
} }
if (Index >= mCachePairCount) { if (Index >= mCachePairCount) {
*Handle = NULL; *Handle = NULL;
} }
@ -203,7 +214,7 @@ BuildCachedGuidHandleTable (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID**) &LoadedImage (VOID **)&LoadedImage
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -212,7 +223,7 @@ BuildCachedGuidHandleTable (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiDriverBindingProtocolGuid, &gEfiDriverBindingProtocolGuid,
(VOID **) &DriverBinding, (VOID **)&DriverBinding,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -224,32 +235,35 @@ BuildCachedGuidHandleTable (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
DriverBinding->ImageHandle, DriverBinding->ImageHandle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID**) &LoadedImage (VOID **)&LoadedImage
); );
} }
} }
if (!EFI_ERROR (Status) && LoadedImage != NULL) { if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
// //
// Get Module Guid from DevicePath. // Get Module Guid from DevicePath.
// //
if (LoadedImage->FilePath != NULL && if ((LoadedImage->FilePath != NULL) &&
LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH && (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP (LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
) { )
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath; {
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
TempGuid = &FvFilePath->FvFileName; TempGuid = &FvFilePath->FvFileName;
mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index]; mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];
CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid); CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid);
mCachePairCount ++; mCachePairCount++;
} }
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
HandleBuffer = NULL; HandleBuffer = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -280,6 +294,7 @@ GetMeasurementInfo (
} else { } else {
Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp; Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
} }
switch (Measurement->Identifier) { switch (Measurement->Identifier) {
case MODULE_START_ID: case MODULE_START_ID:
case MODULE_END_ID: case MODULE_END_ID:
@ -290,22 +305,23 @@ GetMeasurementInfo (
Measurement->Token = ALit_START_IMAGE; Measurement->Token = ALit_START_IMAGE;
Measurement->Module = ALit_START_IMAGE; Measurement->Module = ALit_START_IMAGE;
} }
break; break;
default: default:
ASSERT(FALSE); 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); Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
} else { } else {
GetHandleFormModuleGuid(ModuleGuid, &StartHandle); GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle; Measurement->Handle = StartHandle;
// //
// When no perf entry to record the PEI and DXE phase, // When no perf entry to record the PEI and DXE phase,
// For start image, we need detect the PEIM and non PEIM here. // For start image, we need detect the PEIM and non PEIM here.
// //
if (Measurement->Token == NULL) { if (Measurement->Token == NULL) {
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) { if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
Measurement->Token = ALit_PEIM; Measurement->Token = ALit_PEIM;
Measurement->Module = ALit_PEIM; Measurement->Module = ALit_PEIM;
Measurement->Handle = ModuleGuid; Measurement->Handle = ModuleGuid;
@ -315,6 +331,7 @@ GetMeasurementInfo (
} }
} }
} }
break; break;
case FPDT_DYNAMIC_STRING_EVENT_TYPE: case FPDT_DYNAMIC_STRING_EVENT_TYPE:
@ -325,6 +342,7 @@ GetMeasurementInfo (
} else { } else {
Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp; Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
} }
switch (Measurement->Identifier) { switch (Measurement->Identifier) {
case MODULE_START_ID: case MODULE_START_ID:
case MODULE_END_ID: case MODULE_END_ID:
@ -333,6 +351,7 @@ GetMeasurementInfo (
} else if (mDxePhase) { } else if (mDxePhase) {
Measurement->Token = ALit_START_IMAGE; Measurement->Token = ALit_START_IMAGE;
} }
break; break;
case MODULE_LOADIMAGE_START_ID: case MODULE_LOADIMAGE_START_ID:
@ -362,17 +381,17 @@ GetMeasurementInfo (
Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String; 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); Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
} else { } else {
GetHandleFormModuleGuid(ModuleGuid, &StartHandle); GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle; Measurement->Handle = StartHandle;
// //
// When no perf entry to record the PEI and DXE phase, // When no perf entry to record the PEI and DXE phase,
// For start image, we need detect the PEIM and non PEIM here. // 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 ((Measurement->Token == NULL) && ((Measurement->Identifier == MODULE_START_ID) || (Measurement->Identifier == MODULE_END_ID))) {
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) { if ((StartHandle == NULL) && !IsZeroGuid (ModuleGuid)) {
Measurement->Token = ALit_PEIM; Measurement->Token = ALit_PEIM;
Measurement->Handle = ModuleGuid; Measurement->Handle = ModuleGuid;
} else { } else {
@ -380,6 +399,7 @@ GetMeasurementInfo (
} }
} }
} }
break; break;
case FPDT_GUID_QWORD_EVENT_TYPE: case FPDT_GUID_QWORD_EVENT_TYPE:
@ -390,6 +410,7 @@ GetMeasurementInfo (
} else { } else {
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp; Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
} }
switch (Measurement->Identifier) { switch (Measurement->Identifier) {
case MODULE_DB_START_ID: case MODULE_DB_START_ID:
Measurement->Token = ALit_DB_START; Measurement->Token = ALit_DB_START;
@ -415,9 +436,10 @@ GetMeasurementInfo (
break; break;
default: default:
ASSERT(FALSE); ASSERT (FALSE);
} }
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle; Measurement->Handle = StartHandle;
break; break;
@ -425,10 +447,11 @@ GetMeasurementInfo (
ModuleGuid = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid); ModuleGuid = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid);
Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID); Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
if (IsStart) { if (IsStart) {
Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD*)RecordHeader)->Timestamp; Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
} else { } else {
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp; Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
} }
// //
// Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE. // Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.
// //
@ -438,9 +461,10 @@ GetMeasurementInfo (
Measurement->Module = ALit_DB_START; Measurement->Module = ALit_DB_START;
break; break;
default: default:
ASSERT(FALSE); ASSERT (FALSE);
} }
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle; Measurement->Handle = StartHandle;
break; break;
@ -452,9 +476,10 @@ GetMeasurementInfo (
} else { } else {
Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp; Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
} }
Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String; Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String; Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
GetHandleFormModuleGuid(ModuleGuid, &StartHandle); GetHandleFormModuleGuid (ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle; Measurement->Handle = StartHandle;
break; break;
@ -478,25 +503,28 @@ SearchMeasurement (
for (Index = mMeasurementNum - 1; Index >= 0; Index--) { for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) { 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) && CompareGuid (mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) && (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; mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break; break;
} }
} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) { } 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].Token, EndMeasureMent->Token) == 0) &&
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 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; mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break; break;
} }
} else { } 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].Token, EndMeasureMent->Token) == 0) &&
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) { (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0))
{
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp; mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break; break;
} }
@ -528,7 +556,7 @@ BuildMeasurementList (
PerformanceTablePtr = (mBootPerformanceTable + TableLength); PerformanceTablePtr = (mBootPerformanceTable + TableLength);
while (TableLength < mBootPerformanceTableSize) { while (TableLength < mBootPerformanceTableSize) {
RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) PerformanceTablePtr; RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)PerformanceTablePtr;
StartRecordEvent = (UINT8 *)RecordHeader; StartRecordEvent = (UINT8 *)RecordHeader;
StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID; StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;
@ -539,14 +567,15 @@ BuildMeasurementList (
// //
if (StartProgressId == 0) { if (StartProgressId == 0) {
GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum])); GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));
mMeasurementNum ++; mMeasurementNum++;
} else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) || } else if ((((StartProgressId >= PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x000F) == 0)) ||
(StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) { ((StartProgressId < PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x0001) != 0))))
{
// //
// Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE // 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. // So we need to identify these two kinds of record through different phase.
// //
if(StartProgressId == PERF_CROSSMODULE_START_ID ){ if (StartProgressId == PERF_CROSSMODULE_START_ID ) {
if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) { if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {
mPeiPhase = TRUE; mPeiPhase = TRUE;
} else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) { } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {
@ -554,17 +583,20 @@ BuildMeasurementList (
mPeiPhase = FALSE; mPeiPhase = FALSE;
} }
} }
// Get measurement info form the start record to the mMeasurementList. // Get measurement info form the start record to the mMeasurementList.
GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum])); GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));
mMeasurementNum ++; mMeasurementNum++;
} else { } else {
ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD)); ZeroMem (&MeasureMent, sizeof (MEASUREMENT_RECORD));
GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent); GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
SearchMeasurement (&MeasureMent); SearchMeasurement (&MeasureMent);
} }
TableLength += RecordHeader->Length; TableLength += RecordHeader->Length;
PerformanceTablePtr += RecordHeader->Length; PerformanceTablePtr += RecordHeader->Length;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -655,17 +687,17 @@ RunDp (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// Process Command Line arguments // Process Command Line arguments
// //
Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(ParamPackage) > 1){ } else if (ShellCommandLineGetCount (ParamPackage) > 1) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), mDpHiiHandle);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} }
@ -674,7 +706,7 @@ RunDp (
// Boolean options // Boolean options
// //
VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v"); VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s")); SummaryMode = (BOOLEAN)(ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A"); AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A");
RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R"); RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x"); ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
@ -697,13 +729,14 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} }
Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);
Status = ShellConvertStringToUint64 (CmdLineArg, &Intermediate, FALSE, TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n");
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} else { } else {
Number2Display = (UINTN)Intermediate; 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} }
@ -719,7 +752,7 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
} else { } else {
Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE); Status = ShellConvertStringToUint64 (CmdLineArg, &Intermediate, FALSE, TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-t"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-t");
return SHELL_INVALID_PARAMETER; return SHELL_INVALID_PARAMETER;
@ -742,6 +775,7 @@ RunDp (
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Done; goto Done;
} }
CustomCumulativeData->MinDur = PERF_MAXDUR; CustomCumulativeData->MinDur = PERF_MAXDUR;
CustomCumulativeData->MaxDur = 0; CustomCumulativeData->MaxDur = 0;
CustomCumulativeData->Count = 0; CustomCumulativeData->Count = 0;
@ -752,6 +786,7 @@ RunDp (
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Done; goto Done;
} }
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize); UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
} }
} }
@ -762,7 +797,7 @@ RunDp (
// //
// //
//1. Get FPDT from ACPI table. // 1. Get FPDT from ACPI table.
// //
Status = GetBootPerformanceTable (); Status = GetBootPerformanceTable ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -771,16 +806,16 @@ RunDp (
} }
// //
//2. Cache the ModuleGuid and hanlde mapping table. // 2. Cache the ModuleGuid and hanlde mapping table.
// //
Status = BuildCachedGuidHandleTable(); Status = BuildCachedGuidHandleTable ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellStatus = Status; ShellStatus = Status;
goto Done; goto Done;
} }
// //
//3. Build the measurement array form the FPDT records. // 3. Build the measurement array form the FPDT records.
// //
Status = BuildMeasurementList (); Status = BuildMeasurementList ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -806,7 +841,7 @@ RunDp (
// StartCount = Value loaded into the counter when it starts counting // StartCount = Value loaded into the counter when it starts counting
// EndCount = Value counter counts to before it needs to be reset // EndCount = Value counter counts to before it needs to be reset
// //
Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty); Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **)&PerformanceProperty);
if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) { if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
goto Done; goto Done;
@ -827,11 +862,19 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
if (VerboseMode && !RawMode) { if (VerboseMode && !RawMode) {
StringPtr = HiiGetString (mDpHiiHandle, StringPtr = HiiGetString (
(EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL); mDpHiiHandle,
(EFI_STRING_ID)(TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)),
NULL
);
ASSERT (StringPtr != NULL); ASSERT (StringPtr != NULL);
// Print Timer count range and direction // 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, StringPtr,
TimerInfo.StartCount, TimerInfo.StartCount,
TimerInfo.EndCount TimerInfo.EndCount
@ -839,40 +882,40 @@ RunDp (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);
} }
/**************************************************************************** /****************************************************************************
**** Print Sections based on command line options **** Print Sections based on command line options
**** ****
**** Option modes have the following priority: **** Option modes have the following priority:
**** v Verbose -- Valid in combination with any other options **** v Verbose -- Valid in combination with any other options
**** t Threshold -- Modifies All, Raw, and Cooked output **** t Threshold -- Modifies All, Raw, and Cooked output
**** Default is 0 for All and Raw mode **** Default is 0 for All and Raw mode
**** Default is DEFAULT_THRESHOLD for "Cooked" mode **** Default is DEFAULT_THRESHOLD for "Cooked" mode
**** n Number2Display Used by All and Raw mode. Otherwise ignored. **** n Number2Display Used by All and Raw mode. Otherwise ignored.
**** A All -- R and S options are ignored **** A All -- R and S options are ignored
**** R Raw -- S option is ignored **** R Raw -- S option is ignored
**** s Summary -- Modifies "Cooked" output only **** s Summary -- Modifies "Cooked" output only
**** Cooked (Default) **** Cooked (Default)
****************************************************************************/ ****************************************************************************/
GatherStatistics (CustomCumulativeData); GatherStatistics (CustomCumulativeData);
if (CumulativeMode) { if (CumulativeMode) {
ProcessCumulative (CustomCumulativeData); ProcessCumulative (CustomCumulativeData);
} else if (AllMode) { } else if (AllMode) {
Status = DumpAllTrace( Number2Display, ExcludeMode); Status = DumpAllTrace (Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) { if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED; ShellStatus = SHELL_ABORTED;
goto Done; goto Done;
} }
} else if (RawMode) { } else if (RawMode) {
Status = DumpRawTrace( Number2Display, ExcludeMode); Status = DumpRawTrace (Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) { if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED; ShellStatus = SHELL_ABORTED;
goto Done; goto Done;
} }
} else { } else {
//------------- Begin Cooked Mode Processing // ------------- Begin Cooked Mode Processing
ProcessPhases (); ProcessPhases ();
if ( ! SummaryMode) { if ( !SummaryMode) {
Status = ProcessHandles ( ExcludeMode); Status = ProcessHandles (ExcludeMode);
if (Status == EFI_ABORTED) { if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED; ShellStatus = SHELL_ABORTED;
goto Done; goto Done;
@ -892,19 +935,22 @@ RunDp (
ProcessCumulative (NULL); ProcessCumulative (NULL);
} }
} //------------- End of Cooked Mode Processing } // ------------- End of Cooked Mode Processing
if ( VerboseMode || SummaryMode) { if ( VerboseMode || SummaryMode) {
DumpStatistics(); DumpStatistics ();
} }
Done: Done:
if (ParamPackage != NULL) { if (ParamPackage != NULL) {
ShellCommandLineFreeVarList (ParamPackage); ShellCommandLineFreeVarList (ParamPackage);
} }
SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtr);
if (CustomCumulativeData != NULL) { if (CustomCumulativeData != NULL) {
SHELL_FREE_NON_NULL (CustomCumulativeData->Name); SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
} }
SHELL_FREE_NON_NULL (CustomCumulativeData); SHELL_FREE_NON_NULL (CustomCumulativeData);
SHELL_FREE_NON_NULL (mMeasurementList); SHELL_FREE_NON_NULL (mMeasurementList);
@ -916,7 +962,6 @@ Done:
return ShellStatus; return ShellStatus;
} }
/** /**
Retrieve HII package list from ImageHandle and publish to HII database. Retrieve HII package list from ImageHandle and publish to HII database.
@ -962,5 +1007,6 @@ InitializeHiiPackage (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
return HiiHandle; return HiiHandle;
} }

View File

@ -9,7 +9,6 @@
#ifndef _DP_H_ #ifndef _DP_H_
#define _DP_H_ #define _DP_H_
#include <Uefi.h> #include <Uefi.h>
#include <Guid/Performance.h> #include <Guid/Performance.h>
@ -54,7 +53,7 @@ extern EFI_HII_HANDLE mDpHiiHandle;
#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL #define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
/// Determine whether 0 <= C < L. If L == 0, return true regardless of C. /// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
#define WITHIN_LIMIT( C, L) ( ((L) == 0) || ((C) < (L)) ) #define WITHIN_LIMIT(C, L) ( ((L) == 0) || ((C) < (L)) )
/// Structure for storing Timer specific information. /// Structure for storing Timer specific information.
typedef struct { typedef struct {
@ -137,4 +136,5 @@ EFI_HII_HANDLE
InitializeHiiPackage ( InitializeHiiPackage (
EFI_HANDLE ImageHandle EFI_HANDLE ImageHandle
); );
#endif // _DP_H_ #endif // _DP_H_

View File

@ -36,6 +36,7 @@ DpAppInitialize (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle); mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) { if (mDpHiiHandle == NULL) {
return EFI_ABORTED; return EFI_ABORTED;

View File

@ -82,6 +82,7 @@ DpCommandInitialize (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle); mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) { if (mDpHiiHandle == NULL) {
return EFI_ABORTED; return EFI_ABORTED;
@ -109,9 +110,10 @@ EFI_STATUS
EFIAPI EFIAPI
DpUnload ( DpUnload (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface ( Status = gBS->UninstallProtocolInterface (
ImageHandle, ImageHandle,
&gEfiShellDynamicCommandProtocolGuid, &gEfiShellDynamicCommandProtocolGuid,
@ -120,6 +122,7 @@ DpUnload (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
HiiRemovePackages (mDpHiiHandle); HiiRemovePackages (mDpHiiHandle);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -10,6 +10,7 @@
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _DP_INTELNAL_H_ #ifndef _DP_INTELNAL_H_
#define _DP_INTELNAL_H_ #define _DP_INTELNAL_H_
@ -75,7 +76,7 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase. @retval FALSE The measurement record is NOT for an EFI Phase.
**/ **/
BOOLEAN BOOLEAN
IsPhase( IsPhase (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
); );
@ -89,7 +90,7 @@ IsPhase(
**/ **/
BOOLEAN BOOLEAN
IsCorePerf( IsCorePerf (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
); );
@ -164,7 +165,7 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found. @retval >=0 Return value is the index into CumData where Token is found.
**/ **/
INTN INTN
GetCumulativeItem( GetCumulativeItem (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
); );
@ -186,7 +187,7 @@ GetCumulativeItem(
**/ **/
VOID VOID
GatherStatistics( GatherStatistics (
IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
); );
@ -212,7 +213,7 @@ GatherStatistics(
@return Others from a call to gBS->LocateHandleBuffer(). @return Others from a call to gBS->LocateHandleBuffer().
**/ **/
EFI_STATUS EFI_STATUS
DumpAllTrace( DumpAllTrace (
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
); );
@ -237,7 +238,7 @@ DumpAllTrace(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
DumpRawTrace( DumpRawTrace (
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
); );
@ -247,11 +248,10 @@ DumpRawTrace(
**/ **/
VOID VOID
ProcessPhases( ProcessPhases (
VOID VOID
); );
/** /**
Gather and print Handle data. Gather and print Handle data.
@ -262,11 +262,10 @@ ProcessPhases(
@return Others from a call to gBS->LocateHandleBuffer(). @return Others from a call to gBS->LocateHandleBuffer().
**/ **/
EFI_STATUS EFI_STATUS
ProcessHandles( ProcessHandles (
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
); );
/** /**
Gather and print PEIM data. Gather and print PEIM data.
@ -276,7 +275,7 @@ ProcessHandles(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
ProcessPeims( ProcessPeims (
VOID VOID
); );
@ -292,7 +291,7 @@ ProcessPeims(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
ProcessGlobal( ProcessGlobal (
VOID VOID
); );
@ -308,7 +307,7 @@ ProcessGlobal(
**/ **/
VOID VOID
ProcessCumulative( ProcessCumulative (
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
); );

View File

@ -59,14 +59,14 @@ GetPerformanceMeasurementRecord (
return 0; return 0;
} }
*Handle = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle; *Handle = (VOID *)(UINTN)mMeasurementList[LogEntryKey].Handle;
*Token = mMeasurementList[LogEntryKey].Token; *Token = mMeasurementList[LogEntryKey].Token;
*Module = mMeasurementList[LogEntryKey].Module; *Module = mMeasurementList[LogEntryKey].Module;
*StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp; *StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;
*EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp; *EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp;
*Identifier = mMeasurementList[LogEntryKey].Identifier; *Identifier = mMeasurementList[LogEntryKey].Identifier;
LogEntryKey ++; LogEntryKey++;
return LogEntryKey; return LogEntryKey;
} }
@ -89,7 +89,7 @@ GetPerformanceMeasurementRecord (
**/ **/
VOID VOID
GatherStatistics( GatherStatistics (
IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
) )
{ {
@ -106,7 +106,8 @@ GatherStatistics(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
{ {
++SummaryData.NumTrace; // Count the number of TRACE Measurement records ++SummaryData.NumTrace; // Count the number of TRACE Measurement records
if (Measurement.EndTimeStamp == 0) { if (Measurement.EndTimeStamp == 0) {
@ -118,11 +119,11 @@ GatherStatistics(
++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles ++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles
} }
if (IsPhase( &Measurement)) { if (IsPhase (&Measurement)) {
++SummaryData.NumSummary; // Count the number of major phases ++SummaryData.NumSummary; // Count the number of major phases
} } else {
else { // !IsPhase // !IsPhase
if(Measurement.Handle == NULL) { if (Measurement.Handle == NULL) {
++SummaryData.NumGlobal; ++SummaryData.NumGlobal;
} }
} }
@ -139,6 +140,7 @@ GatherStatistics(
if ( Duration < CumData[TIndex].MinDur ) { if ( Duration < CumData[TIndex].MinDur ) {
CumData[TIndex].MinDur = Duration; CumData[TIndex].MinDur = Duration;
} }
if ( Duration > CumData[TIndex].MaxDur ) { if ( Duration > CumData[TIndex].MaxDur ) {
CumData[TIndex].MaxDur = Duration; CumData[TIndex].MaxDur = Duration;
} }
@ -153,6 +155,7 @@ GatherStatistics(
if (Duration < CustomCumulativeData->MinDur) { if (Duration < CustomCumulativeData->MinDur) {
CustomCumulativeData->MinDur = Duration; CustomCumulativeData->MinDur = Duration;
} }
if (Duration > CustomCumulativeData->MaxDur) { if (Duration > CustomCumulativeData->MaxDur) {
CustomCumulativeData->MaxDur = Duration; CustomCumulativeData->MaxDur = Duration;
} }
@ -182,7 +185,7 @@ GatherStatistics(
@return Others from a call to gBS->LocateHandleBuffer(). @return Others from a call to gBS->LocateHandleBuffer().
**/ **/
EFI_STATUS EFI_STATUS
DumpAllTrace( DumpAllTrace (
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
) )
@ -203,8 +206,14 @@ DumpAllTrace(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL); IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(IncFlag == NULL) ? StringPtrUnknown : IncFlag); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(IncFlag == NULL) ? StringPtrUnknown : IncFlag
);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
// Get Handle information // Get Handle information
@ -212,8 +221,7 @@ DumpAllTrace(
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
} } else {
else {
// We have successfully populated the HandleBuffer // We have successfully populated the HandleBuffer
// Display ALL Measurement Records // Display ALL Measurement Records
// Up to Limit lines displayed // Up to Limit lines displayed
@ -231,7 +239,7 @@ DumpAllTrace(
LogEntryKey = 0; LogEntryKey = 0;
Count = 0; Count = 0;
Index = 0; Index = 0;
while ( WITHIN_LIMIT(Count, Limit) && while ( WITHIN_LIMIT (Count, Limit) &&
((LogEntryKey = GetPerformanceMeasurementRecord ( ((LogEntryKey = GetPerformanceMeasurementRecord (
LogEntryKey, LogEntryKey,
&Measurement.Handle, &Measurement.Handle,
@ -239,7 +247,8 @@ DumpAllTrace(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
) )
{ {
++Index; // Count every record. First record is 1. ++Index; // Count every record. First record is 1.
@ -247,17 +256,19 @@ DumpAllTrace(
SHELL_FREE_NON_NULL (IncFlag); SHELL_FREE_NON_NULL (IncFlag);
if (Measurement.EndTimeStamp != 0) { if (Measurement.EndTimeStamp != 0) {
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds (Duration);
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL); IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
} } else {
else {
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
} }
if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) || if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
) { // Ignore "uninteresting" or excluded records ) // Ignore "uninteresting" or excluded records
{
continue; continue;
} }
++Count; // Count the number of records printed ++Count; // Count the number of records printed
// If Handle is non-zero, see if we can determine a name for the driver // If Handle is non-zero, see if we can determine a name for the driver
@ -282,7 +293,12 @@ DumpAllTrace(
mUnicodeToken[13] = 0; mUnicodeToken[13] = 0;
if (mShowId) { 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 Index, // 1 based, Which measurement record is being printed
IncFlag, IncFlag,
Measurement.Handle, Measurement.Handle,
@ -292,7 +308,12 @@ DumpAllTrace(
Measurement.Identifier Measurement.Identifier
); );
} else { } 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 Index, // 1 based, Which measurement record is being printed
IncFlag, IncFlag,
Measurement.Handle, Measurement.Handle,
@ -301,15 +322,18 @@ DumpAllTrace(
ElapsedTime ElapsedTime
); );
} }
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
break; break;
} }
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
SHELL_FREE_NON_NULL (IncFlag); SHELL_FREE_NON_NULL (IncFlag);
return Status; return Status;
@ -336,7 +360,7 @@ DumpAllTrace(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
DumpRawTrace( DumpRawTrace (
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
) )
@ -356,8 +380,14 @@ DumpRawTrace(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -372,7 +402,7 @@ DumpRawTrace(
LogEntryKey = 0; LogEntryKey = 0;
Count = 0; Count = 0;
Index = 0; Index = 0;
while ( WITHIN_LIMIT(Count, Limit) && while ( WITHIN_LIMIT (Count, Limit) &&
((LogEntryKey = GetPerformanceMeasurementRecord ( ((LogEntryKey = GetPerformanceMeasurementRecord (
LogEntryKey, LogEntryKey,
&Measurement.Handle, &Measurement.Handle,
@ -380,24 +410,33 @@ DumpRawTrace(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
) )
{ {
++Index; // Count every record. First record is 1. ++Index; // Count every record. First record is 1.
ElapsedTime = 0; ElapsedTime = 0;
if (Measurement.EndTimeStamp != 0) { if (Measurement.EndTimeStamp != 0) {
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds (Duration);
} }
if ((ElapsedTime < mInterestThreshold) || if ((ElapsedTime < mInterestThreshold) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
) { // Ignore "uninteresting" or Excluded records ) // Ignore "uninteresting" or Excluded records
{
continue; continue;
} }
++Count; // Count the number of records printed ++Count; // Count the number of records printed
if (mShowId) { 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 Index, // 1 based, Which measurement record is being printed
Measurement.Handle, Measurement.Handle,
Measurement.StartTimeStamp, Measurement.StartTimeStamp,
@ -407,7 +446,12 @@ DumpRawTrace(
Measurement.Identifier Measurement.Identifier
); );
} else { } 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 Index, // 1 based, Which measurement record is being printed
Measurement.Handle, Measurement.Handle,
Measurement.StartTimeStamp, Measurement.StartTimeStamp,
@ -416,11 +460,13 @@ DumpRawTrace(
Measurement.Module Measurement.Module
); );
} }
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
break; break;
} }
} }
return Status; return Status;
} }
@ -429,7 +475,7 @@ DumpRawTrace(
**/ **/
VOID VOID
ProcessPhases( ProcessPhases (
VOID VOID
) )
{ {
@ -456,8 +502,14 @@ ProcessPhases(
// //
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -469,13 +521,16 @@ ProcessPhases(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
{ {
if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records if (Measurement.EndTimeStamp == 0) {
// Skip "incomplete" records
continue; continue;
} }
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
if ( Measurement.Handle != NULL if ( (Measurement.Handle != NULL)
&& (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0) && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
) )
{ {
@ -496,7 +551,7 @@ ProcessPhases(
// print SEC phase duration time // print SEC phase duration time
// //
if (SecTime > 0) { if (SecTime > 0) {
ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds ElapsedTime = DurationInMicroSeconds (SecTime); // Calculate elapsed time in microseconds
Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
} }
@ -543,7 +598,7 @@ ProcessPhases(
@return Others from a call to gBS->LocateHandleBuffer(). @return Others from a call to gBS->LocateHandleBuffer().
**/ **/
EFI_STATUS EFI_STATUS
ProcessHandles( ProcessHandles (
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
) )
{ {
@ -561,25 +616,31 @@ ProcessHandles(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
} } else {
else { #if DP_DEBUG == 2
#if DP_DEBUG == 2 Print (L"There are %,d Handles defined.\n", (Size / sizeof (HandleBuffer[0])));
Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0]))); #endif
#endif
if (mShowId) { if (mShowId) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
LogEntryKey = 0; LogEntryKey = 0;
@ -591,18 +652,21 @@ ProcessHandles(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
{ {
Count++; Count++;
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds (Duration);
if ((ElapsedTime < mInterestThreshold) || if ((ElapsedTime < mInterestThreshold) ||
(Measurement.EndTimeStamp == 0) || (Measurement.EndTimeStamp == 0) ||
(!IsCorePerf (&Measurement)) || (!IsCorePerf (&Measurement)) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
) { // Ignore "uninteresting" or excluded records ) // Ignore "uninteresting" or excluded records
{
continue; continue;
} }
mGaugeString[0] = 0; // Empty driver name by default mGaugeString[0] = 0; // Empty driver name by default
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken)); AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
// See if the Handle is in the HandleBuffer // See if the Handle is in the HandleBuffer
@ -612,13 +676,19 @@ ProcessHandles(
break; break;
} }
} }
// Ensure that the argument strings are not too long. // Ensure that the argument strings are not too long.
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
mUnicodeToken[11] = 0; mUnicodeToken[11] = 0;
if (mGaugeString[0] != 0) { if (mGaugeString[0] != 0) {
// Display the record if it has a valid handle. // Display the record if it has a valid handle.
if (mShowId) { 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 Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed Index + 1, // 1 based, Which handle is being printed
mGaugeString, mGaugeString,
@ -627,7 +697,12 @@ ProcessHandles(
Measurement.Identifier Measurement.Identifier
); );
} else { } 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 Count, // 1 based, Which measurement record is being printed
Index + 1, // 1 based, Which handle is being printed Index + 1, // 1 based, Which handle is being printed
mGaugeString, mGaugeString,
@ -636,15 +711,18 @@ ProcessHandles(
); );
} }
} }
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
break; break;
} }
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
return Status; return Status;
} }
@ -657,9 +735,9 @@ ProcessHandles(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
ProcessPeims( ProcessPeims (
VOID VOID
) )
{ {
MEASUREMENT_RECORD Measurement; MEASUREMENT_RECORD Measurement;
UINT64 Duration; UINT64 Duration;
@ -674,8 +752,14 @@ ProcessPeims(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown : StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -684,6 +768,7 @@ ProcessPeims(
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
TIndex = 0; TIndex = 0;
LogEntryKey = 0; LogEntryKey = 0;
@ -694,39 +779,53 @@ ProcessPeims(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
{ {
TIndex++; TIndex++;
if ((Measurement.EndTimeStamp == 0) || if ((Measurement.EndTimeStamp == 0) ||
(AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0) (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
) { )
{
continue; continue;
} }
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds ElapsedTime = DurationInMicroSeconds (Duration); // Calculate elapsed time in microseconds
if (ElapsedTime >= mInterestThreshold) { if (ElapsedTime >= mInterestThreshold) {
// PEIM FILE Handle is the start address of its FFS file that contains its file guid. // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
if (mShowId) { 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 TIndex, // 1 based, Which measurement record is being printed
Measurement.Handle, // file guid Measurement.Handle, // file guid
ElapsedTime, ElapsedTime,
Measurement.Identifier Measurement.Identifier
); );
} else { } 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 TIndex, // 1 based, Which measurement record is being printed
Measurement.Handle, // file guid Measurement.Handle, // file guid
ElapsedTime ElapsedTime
); );
} }
} }
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
break; break;
} }
} }
return Status; return Status;
} }
@ -742,9 +841,9 @@ ProcessPeims(
@retval EFI_ABORTED The user aborts the operation. @retval EFI_ABORTED The user aborts the operation.
**/ **/
EFI_STATUS EFI_STATUS
ProcessGlobal( ProcessGlobal (
VOID VOID
) )
{ {
MEASUREMENT_RECORD Measurement; MEASUREMENT_RECORD Measurement;
UINT64 Duration; UINT64 Duration;
@ -759,8 +858,14 @@ ProcessGlobal(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -769,6 +874,7 @@ ProcessGlobal(
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
} }
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
Index = 1; Index = 1;
@ -781,22 +887,28 @@ ProcessGlobal(
&Measurement.Module, &Measurement.Module,
&Measurement.StartTimeStamp, &Measurement.StartTimeStamp,
&Measurement.EndTimeStamp, &Measurement.EndTimeStamp,
&Measurement.Identifier)) != 0) &Measurement.Identifier
)) != 0)
{ {
AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken)); AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
mGaugeString[25] = 0; mGaugeString[25] = 0;
mUnicodeToken[31] = 0; mUnicodeToken[31] = 0;
if ( ! ( IsPhase( &Measurement) || if ( !(IsPhase (&Measurement) ||
IsCorePerf (&Measurement) || IsCorePerf (&Measurement) ||
(Measurement.EndTimeStamp == 0) (Measurement.EndTimeStamp == 0)
)) ))
{ {
Duration = GetDuration (&Measurement); Duration = GetDuration (&Measurement);
ElapsedTime = DurationInMicroSeconds ( Duration ); ElapsedTime = DurationInMicroSeconds (Duration);
if (ElapsedTime >= mInterestThreshold) { if (ElapsedTime >= mInterestThreshold) {
if (mShowId) { 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, Index,
mGaugeString, mGaugeString,
mUnicodeToken, mUnicodeToken,
@ -804,7 +916,12 @@ ProcessGlobal(
Measurement.Identifier Measurement.Identifier
); );
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle, ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_DP_GLOBAL_VARS),
mDpHiiHandle,
Index, Index,
mGaugeString, mGaugeString,
mUnicodeToken, mUnicodeToken,
@ -813,12 +930,15 @@ ProcessGlobal(
} }
} }
} }
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
break; break;
} }
Index++; Index++;
} }
return Status; return Status;
} }
@ -834,7 +954,7 @@ ProcessGlobal(
**/ **/
VOID VOID
ProcessCumulative( ProcessCumulative (
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
) )
{ {
@ -848,8 +968,14 @@ ProcessCumulative(
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL); StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle, ShellPrintHiiEx (
(StringPtr == NULL) ? StringPtrUnknown: StringPtr); -1,
-1,
NULL,
STRING_TOKEN (STR_DP_SECTION_HEADER),
mDpHiiHandle,
(StringPtr == NULL) ? StringPtrUnknown : StringPtr
);
FreePool (StringPtr); FreePool (StringPtr);
FreePool (StringPtrUnknown); FreePool (StringPtrUnknown);
@ -860,12 +986,17 @@ ProcessCumulative(
for ( TIndex = 0; TIndex < NumCum; ++TIndex) { for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
if (CumData[TIndex].Count != 0) { if (CumData[TIndex].Count != 0) {
AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count); AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
AvgDur = DurationInMicroSeconds(AvgDur); AvgDur = DurationInMicroSeconds (AvgDur);
Dur = DurationInMicroSeconds(CumData[TIndex].Duration); Dur = DurationInMicroSeconds (CumData[TIndex].Duration);
MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur); MaxDur = DurationInMicroSeconds (CumData[TIndex].MaxDur);
MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur); 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].Name,
CumData[TIndex].Count, CumData[TIndex].Count,
Dur, Dur,
@ -892,7 +1023,13 @@ ProcessCumulative(
MaxDur = 0; MaxDur = 0;
MinDur = 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->Name,
CustomCumulativeData->Count, CustomCumulativeData->Count,
Dur, Dur,

View File

@ -72,6 +72,7 @@ GetDuration (
DEBUG ((DEBUG_ERROR, ALit_TimerLibError)); DEBUG ((DEBUG_ERROR, ALit_TimerLibError));
Duration = 0; Duration = 0;
} }
return Duration; return Duration;
} }
@ -87,7 +88,7 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase. @retval FALSE The measurement record is NOT for an EFI Phase.
**/ **/
BOOLEAN BOOLEAN
IsPhase( IsPhase (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
) )
{ {
@ -112,7 +113,7 @@ IsPhase(
**/ **/
BOOLEAN BOOLEAN
IsCorePerf( IsCorePerf (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
) )
{ {
@ -162,8 +163,9 @@ DpGetShortPdbFileName (
StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1); StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);
} else { } else {
StartIndex = 0; StartIndex = 0;
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
; }
for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) { for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) { if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
StartIndex = IndexA + 1; StartIndex = IndexA + 1;
@ -176,7 +178,7 @@ DpGetShortPdbFileName (
IndexU = 0; IndexU = 0;
for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) { for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {
UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA]; UnicodeBuffer[IndexU] = (CHAR16)PdbFileName[IndexA];
IndexU++; IndexU++;
if (IndexU >= DP_GAUGE_STRING_LENGTH) { if (IndexU >= DP_GAUGE_STRING_LENGTH) {
UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0; UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;
@ -231,14 +233,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Handle, Handle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID **) &Image (VOID **)&Image
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Handle, Handle,
&gEfiDriverBindingProtocolGuid, &gEfiDriverBindingProtocolGuid,
(VOID **) &DriverBinding, (VOID **)&DriverBinding,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -247,7 +249,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
DriverBinding->ImageHandle, DriverBinding->ImageHandle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID **) &Image (VOID **)&Image
); );
} }
} }
@ -267,14 +269,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Handle, Handle,
&gEfiComponentName2ProtocolGuid, &gEfiComponentName2ProtocolGuid,
(VOID **) &ComponentName2 (VOID **)&ComponentName2
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Firstly use platform language setting, secondly use driver's first supported language. // Firstly use platform language setting, secondly use driver's first supported language.
// //
GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL); GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID **)&PlatformLanguage, NULL);
BestLanguage = GetBestLanguage( BestLanguage = GetBestLanguage (
ComponentName2->SupportedLanguages, ComponentName2->SupportedLanguages,
FALSE, FALSE,
(PlatformLanguage != NULL) ? PlatformLanguage : "", (PlatformLanguage != NULL) ? PlatformLanguage : "",
@ -299,7 +301,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Handle, Handle,
&gEfiLoadedImageDevicePathProtocolGuid, &gEfiLoadedImageDevicePathProtocolGuid,
(VOID **) &LoadedImageDevicePath (VOID **)&LoadedImageDevicePath
); );
if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) { if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {
DevicePath = LoadedImageDevicePath; DevicePath = LoadedImageDevicePath;
@ -313,10 +315,11 @@ DpGetNameFromHandle (
// //
NameGuid = NULL; NameGuid = NULL;
while (!IsDevicePathEndType (DevicePath)) { while (!IsDevicePathEndType (DevicePath)) {
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath); NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
if (NameGuid != NULL) { if (NameGuid != NULL) {
break; break;
} }
DevicePath = NextDevicePathNode (DevicePath); DevicePath = NextDevicePathNode (DevicePath);
} }
@ -330,7 +333,7 @@ DpGetNameFromHandle (
NameGuid, NameGuid,
EFI_SECTION_USER_INTERFACE, EFI_SECTION_USER_INTERFACE,
0, 0,
(VOID **) &NameString, (VOID **)&NameString,
&StringSize &StringSize
); );
@ -347,6 +350,7 @@ DpGetNameFromHandle (
// //
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid); UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);
} }
return; return;
} else { } else {
// //
@ -406,17 +410,18 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found. @retval >=0 Return value is the index into CumData where Token is found.
**/ **/
INTN INTN
GetCumulativeItem( GetCumulativeItem (
IN MEASUREMENT_RECORD *Measurement IN MEASUREMENT_RECORD *Measurement
) )
{ {
INTN Index; INTN Index;
for( Index = 0; Index < (INTN)NumCum; ++Index) { for ( Index = 0; Index < (INTN)NumCum; ++Index) {
if (AsciiStrCmp (Measurement->Token, CumData[Index].Name) == 0) { if (AsciiStrCmp (Measurement->Token, CumData[Index].Name) == 0) {
return Index; // Exit, we found a match return Index; // Exit, we found a match
} }
} }
// If the for loop exits, Token was not found. // If the for loop exits, Token was not found.
return -1; // Indicate failure return -1; // Indicate failure
} }

View File

@ -4,6 +4,7 @@
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _LITERALS_H_ #ifndef _LITERALS_H_
#define _LITERALS_H_ #define _LITERALS_H_

View File

@ -47,7 +47,7 @@
&& (Code <= HTTP_STATUS_307_TEMPORARY_REDIRECT)) \ && (Code <= HTTP_STATUS_307_TEMPORARY_REDIRECT)) \
|| (Code == HTTP_STATUS_308_PERMANENT_REDIRECT)) || (Code == HTTP_STATUS_308_PERMANENT_REDIRECT))
#define CLOSE_HTTP_HANDLE(ControllerHandle,HttpChildHandle) \ #define CLOSE_HTTP_HANDLE(ControllerHandle, HttpChildHandle) \
do { \ do { \
if (HttpChildHandle) { \ if (HttpChildHandle) { \
CloseProtocolAndDestroyServiceChild ( \ CloseProtocolAndDestroyServiceChild ( \
@ -94,11 +94,11 @@ typedef enum {
// //
// Improve readability by using these macros. // Improve readability by using these macros.
// //
#define PRINT_HII(token,...) \ #define PRINT_HII(token, ...) \
ShellPrintHiiEx (\ ShellPrintHiiEx (\
-1, -1, NULL, token, mHttpHiiHandle, __VA_ARGS__) -1, -1, NULL, token, mHttpHiiHandle, __VA_ARGS__)
#define PRINT_HII_APP(token,value) \ #define PRINT_HII_APP(token, value) \
PRINT_HII (token, HTTP_APP_NAME, value) PRINT_HII (token, HTTP_APP_NAME, value)
// //
@ -150,13 +150,13 @@ STATIC CONST CHAR16 *ErrStatusDesc[] =
}; };
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-i", TypeValue}, { L"-i", TypeValue },
{L"-k", TypeFlag}, { L"-k", TypeFlag },
{L"-l", TypeValue}, { L"-l", TypeValue },
{L"-m", TypeFlag}, { L"-m", TypeFlag },
{L"-s", TypeValue}, { L"-s", TypeValue },
{L"-t", TypeValue}, { L"-t", TypeValue },
{NULL , TypeMax} { NULL, TypeMax }
}; };
// //
@ -328,7 +328,7 @@ TrimSpaces (
// //
do { do {
Len = StrLen (Str); Len = StrLen (Str);
if (!Len || (Str[Len - 1] != L' ' && Str[Len - 1] != '\t')) { if (!Len || ((Str[Len - 1] != L' ') && (Str[Len - 1] != '\t'))) {
break; break;
} }
@ -408,7 +408,7 @@ EfiGetEpochDays (
// //
UINTN EpochDays; UINTN EpochDays;
a = (14 - Time->Month) / 12 ; a = (14 - Time->Month) / 12;
y = Time->Year + 4800 - a; y = Time->Year + 4800 - a;
m = Time->Month + (12 * a) - 3; m = Time->Month + (12 * a) - 3;
@ -522,7 +522,7 @@ RunHttp (
TRUE TRUE
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) if ( (Status == EFI_VOLUME_CORRUPTED)
&& (ProblemParam != NULL)) && (ProblemParam != NULL))
{ {
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PROBLEM), ProblemParam); PRINT_HII_APP (STRING_TOKEN (STR_GEN_PROBLEM), ProblemParam);
@ -629,7 +629,8 @@ RunHttp (
Walker = RemoteFilePath + StrLen (RemoteFilePath); Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) { while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') || if ((*Walker == L'\\') ||
(*Walker == L'/' ) ) { (*Walker == L'/'))
{
break; break;
} }
} }
@ -659,7 +660,7 @@ RunHttp (
UserNicName = ShellCommandLineGetValue (CheckPackage, L"-i"); UserNicName = ShellCommandLineGetValue (CheckPackage, L"-i");
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-l"); ValueStr = ShellCommandLineGetValue (CheckPackage, L"-l");
if ((ValueStr != NULL) if ( (ValueStr != NULL)
&& (!StringToUint16 ( && (!StringToUint16 (
ValueStr, ValueStr,
&Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort &Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort
@ -674,7 +675,7 @@ RunHttp (
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-s"); ValueStr = ShellCommandLineGetValue (CheckPackage, L"-s");
if (ValueStr != NULL) { if (ValueStr != NULL) {
Context.BufferSize = ShellStrToUintn (ValueStr); 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); PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV), ValueStr);
goto Error; goto Error;
} }
@ -841,7 +842,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid, &gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
&MnpHandle, &MnpHandle,
(VOID**)&Mnp (VOID **)&Mnp
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Error; goto Error;
@ -1017,13 +1018,13 @@ WaitForCompletion (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
while (! *CallBackComplete while ( !*CallBackComplete
&& (!EFI_ERROR (Status)) && (!EFI_ERROR (Status))
&& EFI_ERROR (gBS->CheckEvent (WaitEvt))) && EFI_ERROR (gBS->CheckEvent (WaitEvt)))
{ {
Status = Context->Http->Poll (Context->Http); Status = Context->Http->Poll (Context->Http);
if (!Context->ContentDownloaded if ( !Context->ContentDownloaded
&& CallBackComplete == &gResponseCallbackComplete) && (CallBackComplete == &gResponseCallbackComplete))
{ {
// //
// An HTTP server may just send a response redirection header. // An HTTP server may just send a response redirection header.
@ -1032,7 +1033,7 @@ WaitForCompletion (
// Note that at this point Response may not has been populated, // Note that at this point Response may not has been populated,
// so it needs to be checked first. // so it needs to be checked first.
// //
if (Context->ResponseToken.Message if ( Context->ResponseToken.Message
&& Context->ResponseToken.Message->Data.Response && Context->ResponseToken.Message->Data.Response
&& (NEED_REDIRECTION ( && (NEED_REDIRECTION (
Context->ResponseToken.Message->Data.Response->StatusCode Context->ResponseToken.Message->Data.Response->StatusCode
@ -1265,7 +1266,6 @@ SavePortion (
NbOfKb NbOfKb
); );
ShellPrintEx (-1, -1, L"%s", Progress); ShellPrintEx (-1, -1, L"%s", Progress);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -1351,7 +1351,7 @@ SetHostURI (
Walker = Location; Walker = Location;
for (Step = FirstStep; Step < 2; Step++) { for (Step = FirstStep; Step < 2; Step++) {
for (; *Walker != '/' && *Walker != '\0'; Walker++) { for ( ; *Walker != '/' && *Walker != '\0'; Walker++) {
Idx++; Idx++;
} }
@ -1466,7 +1466,7 @@ ParseMsg (
IN VOID *Context IN VOID *Context
) )
{ {
if ((Data == NULL) if ( (Data == NULL)
|| (EventType == BodyParseEventOnComplete) || (EventType == BodyParseEventOnComplete)
|| (Context == NULL)) || (Context == NULL))
{ {
@ -1476,7 +1476,6 @@ ParseMsg (
return SavePortion (Context, Length, Data); return SavePortion (Context, Length, Data);
} }
/** /**
Get HTTP server response and collect the whole body as a file. Get HTTP server response and collect the whole body as a file.
Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR). Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR).
@ -1642,7 +1641,7 @@ GetResponse (
HttpGetEntityLength (MsgParser, &Context->ContentLength); 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)) && (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
{ {
// //
@ -1680,12 +1679,12 @@ GetResponse (
ResponseMessage.Body ResponseMessage.Body
); );
} }
} while (!HttpIsMessageComplete (MsgParser) } while ( !HttpIsMessageComplete (MsgParser)
&& !EFI_ERROR (Status) && !EFI_ERROR (Status)
&& ResponseMessage.BodyLength); && ResponseMessage.BodyLength);
if (Context->Status != REQ_NEED_REPEAT if ( (Context->Status != REQ_NEED_REPEAT)
&& Status == EFI_SUCCESS && (Status == EFI_SUCCESS)
&& CanMeasureTime) && CanMeasureTime)
{ {
if (!EFI_ERROR (gRT->GetTime (&EndTime, NULL))) { if (!EFI_ERROR (gRT->GetTime (&EndTime, NULL))) {
@ -1780,7 +1779,7 @@ DownloadFile (
&gEfiHttpServiceBindingProtocolGuid, &gEfiHttpServiceBindingProtocolGuid,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
&HttpChildHandle, &HttpChildHandle,
(VOID**)&Context->Http (VOID **)&Context->Http
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1814,7 +1813,8 @@ DownloadFile (
&DownloadUrl, &DownloadUrl,
&UrlSize, &UrlSize,
Context->Uri, Context->Uri,
StrLen (Context->Uri)); StrLen (Context->Uri)
);
PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl); PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl);
@ -1828,7 +1828,6 @@ DownloadFile (
if (Status) { if (Status) {
goto ON_EXIT; goto ON_EXIT;
} }
} while (Context->Status == REQ_NEED_REPEAT); } while (Context->Status == REQ_NEED_REPEAT);
if (Context->Status) { if (Context->Status) {

View File

@ -89,4 +89,5 @@ EFI_HII_HANDLE
InitializeHiiPackage ( InitializeHiiPackage (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
); );
#endif // _HTTP_H_ #endif // _HTTP_H_

View File

@ -118,7 +118,7 @@ EFI_STATUS
EFIAPI EFIAPI
HttpUnload ( HttpUnload (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;

View File

@ -208,26 +208,34 @@ CheckPacket (
EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = { EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
TRUE, // Use default setting 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, // 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 69, // InitialServerPort - Standard TFTP server port
6, // TryCount - The number of times to transmit request packets and wait for a response. 6, // TryCount - The number of times to transmit request packets and wait for a response.
4 // TimeoutValue - Retransmission timeout in seconds. 4 // TimeoutValue - Retransmission timeout in seconds.
}; };
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-i", TypeValue}, { L"-i", TypeValue },
{L"-l", TypeValue}, { L"-l", TypeValue },
{L"-r", TypeValue}, { L"-r", TypeValue },
{L"-c", TypeValue}, { L"-c", TypeValue },
{L"-t", TypeValue}, { L"-t", TypeValue },
{L"-s", TypeValue}, { L"-s", TypeValue },
{L"-w", TypeValue}, { L"-w", TypeValue },
{NULL , TypeMax} { NULL, TypeMax }
}; };
/// ///
/// The default block size (512) of tftp is defined in the RFC1350. /// The default block size (512) of tftp is defined in the RFC1350.
@ -319,15 +327,22 @@ RunTftp (
Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE); Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) && if ((Status == EFI_VOLUME_CORRUPTED) &&
(ProblemParam != NULL) ) { (ProblemParam != NULL))
{
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), mTftpHiiHandle, -1,
L"tftp", ProblemParam -1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM),
mTftpHiiHandle,
L"tftp",
ProblemParam
); );
FreePool (ProblemParam); FreePool (ProblemParam);
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }
goto Error; goto Error;
} }
@ -337,15 +352,24 @@ RunTftp (
ParamCount = ShellCommandLineGetCount (CheckPackage); ParamCount = ShellCommandLineGetCount (CheckPackage);
if (ParamCount > 4) { if (ParamCount > 4) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), -1,
mTftpHiiHandle, L"tftp" -1,
NULL,
STRING_TOKEN (STR_GEN_TOO_MANY),
mTftpHiiHandle,
L"tftp"
); );
goto Error; goto Error;
} }
if (ParamCount < 3) { if (ParamCount < 3) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), -1,
mTftpHiiHandle, L"tftp" -1,
NULL,
STRING_TOKEN (STR_GEN_TOO_FEW),
mTftpHiiHandle,
L"tftp"
); );
goto Error; goto Error;
} }
@ -359,20 +383,26 @@ RunTftp (
Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp); Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), -1,
mTftpHiiHandle, L"tftp", ValueStr -1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
); );
goto Error; goto Error;
} }
RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2); RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);
ASSERT(RemoteFilePath != NULL); ASSERT (RemoteFilePath != NULL);
FilePathSize = StrLen (RemoteFilePath) + 1; FilePathSize = StrLen (RemoteFilePath) + 1;
AsciiRemoteFilePath = AllocatePool (FilePathSize); AsciiRemoteFilePath = AllocatePool (FilePathSize);
if (AsciiRemoteFilePath == NULL) { if (AsciiRemoteFilePath == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Error; goto Error;
} }
UnicodeStrToAsciiStrS (RemoteFilePath, AsciiRemoteFilePath, FilePathSize); UnicodeStrToAsciiStrS (RemoteFilePath, AsciiRemoteFilePath, FilePathSize);
if (ParamCount == 4) { if (ParamCount == 4) {
@ -381,10 +411,12 @@ RunTftp (
Walker = RemoteFilePath + StrLen (RemoteFilePath); Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) { while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') || if ((*Walker == L'\\') ||
(*Walker == L'/' ) ) { (*Walker == L'/'))
{
break; break;
} }
} }
mLocalFilePath = Walker + 1; mLocalFilePath = Walker + 1;
} }
@ -423,10 +455,16 @@ RunTftp (
if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) { if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) {
goto Error; goto Error;
} }
if (Mtftp4ConfigData.TimeoutValue == 0) { if (Mtftp4ConfigData.TimeoutValue == 0) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), -1,
mTftpHiiHandle, L"tftp", ValueStr -1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
); );
goto Error; goto Error;
} }
@ -437,10 +475,16 @@ RunTftp (
if (!StringToUint16 (ValueStr, &BlockSize)) { if (!StringToUint16 (ValueStr, &BlockSize)) {
goto Error; goto Error;
} }
if (BlockSize < MTFTP_MIN_BLKSIZE || BlockSize > MTFTP_MAX_BLKSIZE) {
if ((BlockSize < MTFTP_MIN_BLKSIZE) || (BlockSize > MTFTP_MAX_BLKSIZE)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), -1,
mTftpHiiHandle, L"tftp", ValueStr -1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
); );
goto Error; goto Error;
} }
@ -451,10 +495,16 @@ RunTftp (
if (!StringToUint16 (ValueStr, &WindowSize)) { if (!StringToUint16 (ValueStr, &WindowSize)) {
goto Error; goto Error;
} }
if (WindowSize < MTFTP_MIN_WINDOWSIZE || WindowSize > MTFTP_MAX_WINDOWSIZE) {
if ((WindowSize < MTFTP_MIN_WINDOWSIZE) || (WindowSize > MTFTP_MAX_WINDOWSIZE)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), -1,
mTftpHiiHandle, L"tftp", ValueStr -1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
); );
goto Error; goto Error;
} }
@ -473,7 +523,10 @@ RunTftp (
); );
if (EFI_ERROR (Status) || (HandleCount == 0)) { if (EFI_ERROR (Status) || (HandleCount == 0)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC), -1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
mTftpHiiHandle mTftpHiiHandle
); );
goto Error; goto Error;
@ -481,14 +534,20 @@ RunTftp (
for (NicNumber = 0; for (NicNumber = 0;
(NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS); (NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS);
NicNumber++) { NicNumber++)
{
ControllerHandle = Handles[NicNumber]; ControllerHandle = Handles[NicNumber];
Status = GetNicName (ControllerHandle, NicNumber, NicName); Status = GetNicName (ControllerHandle, NicNumber, NicName);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME), -1,
mTftpHiiHandle, NicNumber, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
mTftpHiiHandle,
NicNumber,
Status
); );
continue; continue;
} }
@ -497,6 +556,7 @@ RunTftp (
if (StrCmp (NicName, UserNicName) != 0) { if (StrCmp (NicName, UserNicName) != 0) {
continue; continue;
} }
NicFound = TRUE; NicFound = TRUE;
} }
@ -505,12 +565,17 @@ RunTftp (
&gEfiMtftp4ServiceBindingProtocolGuid, &gEfiMtftp4ServiceBindingProtocolGuid,
&gEfiMtftp4ProtocolGuid, &gEfiMtftp4ProtocolGuid,
&Mtftp4ChildHandle, &Mtftp4ChildHandle,
(VOID**)&Mtftp4 (VOID **)&Mtftp4
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL), -1,
mTftpHiiHandle, NicName, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
mTftpHiiHandle,
NicName,
Status
); );
continue; continue;
} }
@ -518,8 +583,13 @@ RunTftp (
Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData); Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE), -1,
mTftpHiiHandle, NicName, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
mTftpHiiHandle,
NicName,
Status
); );
goto NextHandle; goto NextHandle;
} }
@ -527,8 +597,14 @@ RunTftp (
Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize); Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE), -1,
mTftpHiiHandle, RemoteFilePath, NicName, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
mTftpHiiHandle,
RemoteFilePath,
NicName,
Status
); );
goto NextHandle; goto NextHandle;
} }
@ -536,15 +612,21 @@ RunTftp (
Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, WindowSize); Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, WindowSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD), -1,
mTftpHiiHandle, RemoteFilePath, NicName, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
mTftpHiiHandle,
RemoteFilePath,
NicName,
Status
); );
goto NextHandle; goto NextHandle;
} }
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
NextHandle: NextHandle:
CloseProtocolAndDestroyServiceChild ( CloseProtocolAndDestroyServiceChild (
ControllerHandle, ControllerHandle,
@ -556,22 +638,27 @@ RunTftp (
if ((UserNicName != NULL) && (!NicFound)) { if ((UserNicName != NULL) && (!NicFound)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND), -1,
mTftpHiiHandle, UserNicName -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
mTftpHiiHandle,
UserNicName
); );
} }
Error: Error:
ShellCommandLineFreeVarList (CheckPackage); ShellCommandLineFreeVarList (CheckPackage);
if (AsciiRemoteFilePath != NULL) { if (AsciiRemoteFilePath != NULL) {
FreePool (AsciiRemoteFilePath); FreePool (AsciiRemoteFilePath);
} }
if (Handles != NULL) { if (Handles != NULL) {
FreePool (Handles); FreePool (Handles);
} }
if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR(Status))) { if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR (Status))) {
ShellStatus = Status & ~MAX_BIT; ShellStatus = Status & ~MAX_BIT;
} }
@ -599,8 +686,13 @@ StringToUint16 (
Val = ShellStrToUintn (ValueStr); Val = ShellStrToUintn (ValueStr);
if (Val > MAX_UINT16) { if (Val > MAX_UINT16) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), -1,
mTftpHiiHandle, L"tftp", ValueStr -1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
); );
return FALSE; return FALSE;
} }
@ -645,7 +737,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid, &gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
&MnpHandle, &MnpHandle,
(VOID**)&Mnp (VOID **)&Mnp
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Error; goto Error;
@ -661,7 +753,7 @@ GetNicName (
IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH, IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,
SnpMode.IfType == NET_IFTYPE_ETHERNET ? SnpMode.IfType == NET_IFTYPE_ETHERNET ?
L"eth%d" : L"eth%d" :
L"unk%d" , L"unk%d",
NicNumber NicNumber
); );
@ -810,7 +902,7 @@ GetFileSize (
UINT32 OptCnt; UINT32 OptCnt;
UINT8 OptBuf[128]; UINT8 OptBuf[128];
ReqOpt[0].OptionStr = (UINT8*)"tsize"; ReqOpt[0].OptionStr = (UINT8 *)"tsize";
OptBuf[0] = '0'; OptBuf[0] = '0';
OptBuf[1] = 0; OptBuf[1] = 0;
ReqOpt[0].ValueStr = OptBuf; ReqOpt[0].ValueStr = OptBuf;
@ -818,7 +910,7 @@ GetFileSize (
Status = Mtftp4->GetInfo ( Status = Mtftp4->GetInfo (
Mtftp4, Mtftp4,
NULL, NULL,
(UINT8*)FilePath, (UINT8 *)FilePath,
NULL, NULL,
1, 1,
ReqOpt, ReqOpt,
@ -834,7 +926,7 @@ GetFileSize (
Mtftp4, Mtftp4,
PktLen, PktLen,
Packet, Packet,
(UINT32 *) &OptCnt, (UINT32 *)&OptCnt,
&TableOfOptions &TableOfOptions
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -847,16 +939,18 @@ GetFileSize (
*FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr); *FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr);
break; break;
} }
OptCnt--; OptCnt--;
Option++; Option++;
} }
FreePool (TableOfOptions); FreePool (TableOfOptions);
if (OptCnt == 0) { if (OptCnt == 0) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
Error : Error:
return Status; return Status;
} }
@ -902,13 +996,14 @@ DownloadFile (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Error; goto Error;
} }
TftpContext->FileSize = FileSize; TftpContext->FileSize = FileSize;
TftpContext->DownloadedNbOfBytes = 0; TftpContext->DownloadedNbOfBytes = 0;
TftpContext->LastReportedNbOfBytes = 0; TftpContext->LastReportedNbOfBytes = 0;
Mtftp4Token.Filename = (UINT8*)AsciiFilePath; Mtftp4Token.Filename = (UINT8 *)AsciiFilePath;
Mtftp4Token.CheckPacket = CheckPacket; Mtftp4Token.CheckPacket = CheckPacket;
Mtftp4Token.Context = (VOID*)TftpContext; Mtftp4Token.Context = (VOID *)TftpContext;
Mtftp4Token.OptionCount = 0; Mtftp4Token.OptionCount = 0;
Mtftp4Token.OptionList = AllocatePool (sizeof (EFI_MTFTP4_OPTION) * 2); Mtftp4Token.OptionList = AllocatePool (sizeof (EFI_MTFTP4_OPTION) * 2);
if (Mtftp4Token.OptionList == NULL) { if (Mtftp4Token.OptionList == NULL) {
@ -917,22 +1012,26 @@ DownloadFile (
} }
if (BlockSize != MTFTP_DEFAULT_BLKSIZE) { if (BlockSize != MTFTP_DEFAULT_BLKSIZE) {
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "blksize"; Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"blksize";
AsciiSPrint ((CHAR8 *) BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize); AsciiSPrint ((CHAR8 *)BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf; Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf;
Mtftp4Token.OptionCount ++; Mtftp4Token.OptionCount++;
} }
if (WindowSize != MTFTP_DEFAULT_WINDOWSIZE) { if (WindowSize != MTFTP_DEFAULT_WINDOWSIZE) {
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "windowsize"; Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"windowsize";
AsciiSPrint ((CHAR8 *) WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize); AsciiSPrint ((CHAR8 *)WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf; Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf;
Mtftp4Token.OptionCount ++; Mtftp4Token.OptionCount++;
} }
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING), -1,
mTftpHiiHandle, FilePath -1,
NULL,
STRING_TOKEN (STR_TFTP_DOWNLOADING),
mTftpHiiHandle,
FilePath
); );
// //
@ -952,15 +1051,23 @@ DownloadFile (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), -1,
mTftpHiiHandle, L"tftp", mLocalFilePath -1,
NULL,
STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
mTftpHiiHandle,
L"tftp",
mLocalFilePath
); );
goto Error; goto Error;
} }
Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token); Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), -1,
-1,
NULL,
STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle mTftpHiiHandle
); );
@ -969,7 +1076,7 @@ DownloadFile (
// //
ShellCloseFile (&mFileHandle); ShellCloseFile (&mFileHandle);
Error : Error:
if (TftpContext != NULL) { if (TftpContext != NULL) {
FreePool (TftpContext); FreePool (TftpContext);
} }
@ -1016,7 +1123,7 @@ CheckPacket (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Context = (DOWNLOAD_CONTEXT*)Token->Context; Context = (DOWNLOAD_CONTEXT *)Token->Context;
// //
// The data in the packet are prepended with two UINT16 : // The data in the packet are prepended with two UINT16 :
@ -1025,18 +1132,27 @@ CheckPacket (
// //
DownloadLen = (UINTN)PacketLen - sizeof (Packet->OpCode) - sizeof (Packet->Data.Block); DownloadLen = (UINTN)PacketLen - sizeof (Packet->OpCode) - sizeof (Packet->Data.Block);
ShellSetFilePosition(mFileHandle, Context->DownloadedNbOfBytes); ShellSetFilePosition (mFileHandle, Context->DownloadedNbOfBytes);
Status = ShellWriteFile (mFileHandle, &DownloadLen, Packet->Data.Data); Status = ShellWriteFile (mFileHandle, &DownloadLen, Packet->Data.Data);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Context->DownloadedNbOfBytes > 0) { if (Context->DownloadedNbOfBytes > 0) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), -1,
-1,
NULL,
STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle mTftpHiiHandle
); );
} }
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE), -1,
mTftpHiiHandle, mLocalFilePath, Status -1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_WRITE),
mTftpHiiHandle,
mLocalFilePath,
Status
); );
return Status; return Status;
} }
@ -1059,12 +1175,14 @@ CheckPacket (
ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete); ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);
Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame); Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
for (Index = 1; Index < Step; Index++) { for (Index = 1; Index < Step; Index++) {
Progress[Index] = L'='; Progress[Index] = L'=';
} }
Progress[Step] = L'>'; Progress[Step] = L'>';
UnicodeSPrint ( UnicodeSPrint (
@ -1125,5 +1243,6 @@ InitializeHiiPackage (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
return HiiHandle; return HiiHandle;
} }

View File

@ -66,4 +66,5 @@ EFI_HII_HANDLE
InitializeHiiPackage ( InitializeHiiPackage (
EFI_HANDLE ImageHandle EFI_HANDLE ImageHandle
); );
#endif // _TFTP_H_ #endif // _TFTP_H_

View File

@ -37,6 +37,7 @@ TftpAppInitialize (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
mTftpHiiHandle = InitializeHiiPackage (ImageHandle); mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) { if (mTftpHiiHandle == NULL) {
return EFI_ABORTED; return EFI_ABORTED;

View File

@ -83,6 +83,7 @@ TftpCommandInitialize (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
mTftpHiiHandle = InitializeHiiPackage (ImageHandle); mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) { if (mTftpHiiHandle == NULL) {
return EFI_ABORTED; return EFI_ABORTED;
@ -110,9 +111,10 @@ EFI_STATUS
EFIAPI EFIAPI
TftpUnload ( TftpUnload (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface ( Status = gBS->UninstallProtocolInterface (
ImageHandle, ImageHandle,
&gEfiShellDynamicCommandProtocolGuid, &gEfiShellDynamicCommandProtocolGuid,
@ -121,6 +123,7 @@ TftpUnload (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
HiiRemovePackages (mTftpHiiHandle); HiiRemovePackages (mTftpHiiHandle);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -21,8 +21,8 @@
UINTN UINTN
EFIAPI EFIAPI
ShellDumpBufferToFile ( ShellDumpBufferToFile (
IN CONST CHAR16* FileNameBuffer, IN CONST CHAR16 *FileNameBuffer,
IN CONST VOID* Buffer, IN CONST VOID *Buffer,
IN CONST UINTN BufferSize IN CONST UINTN BufferSize
); );

View File

@ -43,4 +43,3 @@ BcfgLibraryUnregisterBcfgCommand (
); );
#endif #endif

View File

@ -26,7 +26,7 @@
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AddNewGuidNameMapping( AddNewGuidNameMapping (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN CONST CHAR16 *TheName, IN CONST CHAR16 *TheName,
IN CONST CHAR8 *Lang OPTIONAL IN CONST CHAR8 *Lang OPTIONAL
@ -43,9 +43,9 @@ AddNewGuidNameMapping(
@return The pointer to a string of the name. The caller @return The pointer to a string of the name. The caller
is responsible to free this memory. is responsible to free this memory.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
GetStringNameFromGuid( GetStringNameFromGuid (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN CONST CHAR8 *Lang OPTIONAL IN CONST CHAR8 *Lang OPTIONAL
); );
@ -63,7 +63,7 @@ GetStringNameFromGuid(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GetGuidFromStringName( GetGuidFromStringName (
IN CONST CHAR16 *Name, IN CONST CHAR16 *Name,
IN CONST CHAR8 *Lang OPTIONAL, IN CONST CHAR8 *Lang OPTIONAL,
OUT EFI_GUID **Guid OUT EFI_GUID **Guid
@ -85,9 +85,9 @@ GetGuidFromStringName(
@return The pointer to string. @return The pointer to string.
@retval NULL An error was encountered. @retval NULL An error was encountered.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
GetProtocolInformationDump( GetProtocolInformationDump (
IN CONST EFI_HANDLE TheHandle, IN CONST EFI_HANDLE TheHandle,
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN CONST BOOLEAN Verbose IN CONST BOOLEAN Verbose
@ -105,9 +105,9 @@ GetProtocolInformationDump(
@retval NULL The name could not be found. @retval NULL The name could not be found.
@return A pointer to the string name. Do not de-allocate the memory. @return A pointer to the string name. Do not de-allocate the memory.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
GetStringNameFromHandle( GetStringNameFromHandle (
IN CONST EFI_HANDLE TheHandle, IN CONST EFI_HANDLE TheHandle,
IN CONST CHAR8 *Language IN CONST CHAR8 *Language
); );
@ -290,7 +290,7 @@ ParseHandleDatabaseByRelationshipWithType (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ParseHandleDatabaseForChildDevices( ParseHandleDatabaseForChildDevices (
IN CONST EFI_HANDLE DriverHandle, IN CONST EFI_HANDLE DriverHandle,
IN UINTN *MatchingHandleCount, IN UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
@ -309,13 +309,12 @@ ParseHandleDatabaseForChildDevices(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ParseHandleDatabaseForChildControllers( ParseHandleDatabaseForChildControllers (
IN CONST EFI_HANDLE ControllerHandle, IN CONST EFI_HANDLE ControllerHandle,
OUT UINTN *MatchingHandleCount, OUT UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
); );
/** /**
Function to retrieve the human-friendly index of a given handle. If the handle 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 does not have a index one will be automatically assigned. The index value is valid
@ -329,7 +328,7 @@ ParseHandleDatabaseForChildControllers(
**/ **/
UINTN UINTN
EFIAPI EFIAPI
ConvertHandleToHandleIndex( ConvertHandleToHandleIndex (
IN CONST EFI_HANDLE TheHandle IN CONST EFI_HANDLE TheHandle
); );
@ -344,7 +343,7 @@ ConvertHandleToHandleIndex(
**/ **/
EFI_HANDLE EFI_HANDLE
EFIAPI EFIAPI
ConvertHandleIndexToHandle( ConvertHandleIndexToHandle (
IN CONST UINTN TheIndex IN CONST UINTN TheIndex
); );
@ -359,7 +358,7 @@ ConvertHandleIndexToHandle(
@retval NULL A memory allocation failed. @retval NULL A memory allocation failed.
@return A NULL terminated list of handles. @return A NULL terminated list of handles.
**/ **/
EFI_HANDLE* EFI_HANDLE *
EFIAPI EFIAPI
GetHandleListByProtocol ( GetHandleListByProtocol (
IN CONST EFI_GUID *ProtocolGuid OPTIONAL IN CONST EFI_GUID *ProtocolGuid OPTIONAL
@ -376,13 +375,12 @@ GetHandleListByProtocol (
@retval NULL ProtocolGuids was NULL. @retval NULL ProtocolGuids was NULL.
@return A NULL terminated list of EFI_HANDLEs. @return A NULL terminated list of EFI_HANDLEs.
**/ **/
EFI_HANDLE* EFI_HANDLE *
EFIAPI EFIAPI
GetHandleListByProtocolList ( GetHandleListByProtocolList (
IN CONST EFI_GUID **ProtocolGuids IN CONST EFI_GUID **ProtocolGuids
); );
/** /**
Return all supported GUIDs. Return all supported GUIDs.

View File

@ -31,4 +31,3 @@ ShellAppMain (
); );
#endif #endif

View File

@ -27,7 +27,7 @@
// The extern global protocol poionters. // The extern global protocol poionters.
// //
extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation; extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;
extern CONST CHAR16* SupportLevel[]; extern CONST CHAR16 *SupportLevel[];
// //
// The map list objects. // The map list objects.
@ -185,13 +185,12 @@ ShellCommandRunCommandHandler (
@retval other The name of the MAN file. @retval other The name of the MAN file.
@sa SHELL_GET_MAN_FILENAME @sa SHELL_GET_MAN_FILENAME
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellCommandGetManFileNameHandler ( ShellCommandGetManFileNameHandler (
IN CONST CHAR16 *CommandString IN CONST CHAR16 *CommandString
); );
typedef struct { typedef struct {
LIST_ENTRY Link; LIST_ENTRY Link;
CHAR16 *CommandString; CHAR16 *CommandString;
@ -206,7 +205,7 @@ typedef struct {
@return A linked list of all available shell commands. @return A linked list of all available shell commands.
**/ **/
CONST COMMAND_LIST* CONST COMMAND_LIST *
EFIAPI EFIAPI
ShellCommandGetCommandList ( ShellCommandGetCommandList (
IN CONST BOOLEAN Sort IN CONST BOOLEAN Sort
@ -245,7 +244,7 @@ ShellCommandRegisterAlias (
@return A linked list of all requested shell aliases. @return A linked list of all requested shell aliases.
**/ **/
CONST ALIAS_LIST* CONST ALIAS_LIST *
EFIAPI EFIAPI
ShellCommandGetInitAliasList ( ShellCommandGetInitAliasList (
VOID VOID
@ -287,7 +286,7 @@ ShellCommandIsCommandOnList (
@retval NULL No help text was found. @retval NULL No help text was found.
@return The string of the help text. The caller required to free. @return The string of the help text. The caller required to free.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
ShellCommandGetCommandHelp ( ShellCommandGetCommandHelp (
IN CONST CHAR16 *CommandString IN CONST CHAR16 *CommandString
@ -327,8 +326,6 @@ ShellCommandSetEchoState (
IN BOOLEAN State IN BOOLEAN State
); );
/** /**
Indicate that the current shell or script should exit. Indicate that the current shell or script should exit.
@ -402,7 +399,7 @@ typedef struct {
@retval NULL A script file is not currently running. @retval NULL A script file is not currently running.
@return A pointer to the current script file object. @return A pointer to the current script file object.
**/ **/
SCRIPT_FILE* SCRIPT_FILE *
EFIAPI EFIAPI
ShellCommandGetCurrentScriptFile ( ShellCommandGetCurrentScriptFile (
VOID VOID
@ -419,7 +416,7 @@ ShellCommandGetCurrentScriptFile (
@return A pointer to the current running script file after this @return A pointer to the current running script file after this
change. It is NULL if removing the final script. change. It is NULL if removing the final script.
**/ **/
SCRIPT_FILE* SCRIPT_FILE *
EFIAPI EFIAPI
ShellCommandSetNewScript ( ShellCommandSetNewScript (
IN SCRIPT_FILE *Script OPTIONAL IN SCRIPT_FILE *Script OPTIONAL
@ -466,9 +463,9 @@ typedef enum {
@retval NULL a memory allocation failed. @retval NULL a memory allocation failed.
@return a new map name string @return a new map name string
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
ShellCommandCreateNewMappingName( ShellCommandCreateNewMappingName (
IN CONST SHELL_MAPPING_TYPE Type IN CONST SHELL_MAPPING_TYPE Type
); );
@ -513,7 +510,7 @@ ShellCommandConsistMappingUnInitialize (
@retval NULL A consistent mapped name could not be created. @retval NULL A consistent mapped name could not be created.
@return A pointer to a string allocated from pool with the device name. @return A pointer to a string allocated from pool with the device name.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
ShellCommandConsistMappingGenMappingName ( ShellCommandConsistMappingGenMappingName (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
@ -528,7 +525,7 @@ ShellCommandConsistMappingGenMappingName (
@return the node on the list. @return the node on the list.
**/ **/
SHELL_MAP_LIST* SHELL_MAP_LIST *
EFIAPI EFIAPI
ShellCommandFindMapItem ( ShellCommandFindMapItem (
IN CONST CHAR16 *MapKey IN CONST CHAR16 *MapKey
@ -553,7 +550,7 @@ ShellCommandFindMapItem (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellCommandAddMapItemAndUpdatePath( ShellCommandAddMapItemAndUpdatePath (
IN CONST CHAR16 *Name, IN CONST CHAR16 *Name,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST UINT64 Flags, IN CONST UINT64 Flags,
@ -574,7 +571,7 @@ ShellCommandAddMapItemAndUpdatePath(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellCommandCreateInitialMappingsAndPaths( ShellCommandCreateInitialMappingsAndPaths (
VOID VOID
); );
@ -596,9 +593,9 @@ ShellCommandUpdateMapping (
@return a EFI_FILE_PROTOCOL* representing the same file. @return a EFI_FILE_PROTOCOL* representing the same file.
**/ **/
EFI_FILE_PROTOCOL* EFI_FILE_PROTOCOL *
EFIAPI EFIAPI
ConvertShellHandleToEfiFileProtocol( ConvertShellHandleToEfiFileProtocol (
IN CONST SHELL_FILE_HANDLE Handle IN CONST SHELL_FILE_HANDLE Handle
); );
@ -612,7 +609,7 @@ ConvertShellHandleToEfiFileProtocol(
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ShellFileHandleRemove( ShellFileHandleRemove (
IN CONST SHELL_FILE_HANDLE Handle IN CONST SHELL_FILE_HANDLE Handle
); );
@ -626,7 +623,7 @@ ShellFileHandleRemove(
**/ **/
SHELL_FILE_HANDLE SHELL_FILE_HANDLE
EFIAPI EFIAPI
ConvertEfiFileProtocolToShellHandle( ConvertEfiFileProtocolToShellHandle (
IN CONST EFI_FILE_PROTOCOL *Handle, IN CONST EFI_FILE_PROTOCOL *Handle,
IN CONST CHAR16 *Path IN CONST CHAR16 *Path
); );
@ -638,13 +635,12 @@ ConvertEfiFileProtocolToShellHandle(
@return A pointer to the path for the file. @return A pointer to the path for the file.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellFileHandleGetPath( ShellFileHandleGetPath (
IN CONST SHELL_FILE_HANDLE Handle IN CONST SHELL_FILE_HANDLE Handle
); );
/** /**
Function to determine if a SHELL_FILE_HANDLE is at the end of the file. Function to determine if a SHELL_FILE_HANDLE is at the end of the file.
@ -659,7 +655,7 @@ ShellFileHandleGetPath(
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ShellFileHandleEof( ShellFileHandleEof (
IN SHELL_FILE_HANDLE Handle IN SHELL_FILE_HANDLE Handle
); );
@ -705,7 +701,7 @@ DumpHex (
@param[in] DataSize The size in bytes of UserData. @param[in] DataSize The size in bytes of UserData.
@param[in] UserData The data to print out. @param[in] UserData The data to print out.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
CatSDumpHex ( CatSDumpHex (
IN CHAR16 *Buffer, IN CHAR16 *Buffer,
@ -795,4 +791,5 @@ ShellSortFileList (
OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL, OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL,
IN SHELL_SORT_FILE_LIST Order IN SHELL_SORT_FILE_LIST Order
); );
#endif //_SHELL_COMMAND_LIB_ #endif //_SHELL_COMMAND_LIB_

View File

@ -58,9 +58,9 @@ extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
Path. The caller must free this memory when it is no Path. The caller must free this memory when it is no
longer needed. longer needed.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
FullyQualifyPath( FullyQualifyPath (
IN CONST CHAR16 *Path IN CONST CHAR16 *Path
); );
@ -78,7 +78,7 @@ FullyQualifyPath(
@return The information about the file. @return The information about the file.
**/ **/
EFI_FILE_INFO* EFI_FILE_INFO *
EFIAPI EFIAPI
ShellGetFileInfo ( ShellGetFileInfo (
IN SHELL_FILE_HANDLE FileHandle IN SHELL_FILE_HANDLE FileHandle
@ -141,7 +141,7 @@ ShellSetFileInfo (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellOpenFileByDevicePath( ShellOpenFileByDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT SHELL_FILE_HANDLE *FileHandle, OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode, IN UINT64 OpenMode,
@ -179,7 +179,7 @@ ShellOpenFileByDevicePath(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellOpenFileByName( ShellOpenFileByName (
IN CONST CHAR16 *FileName, IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *FileHandle, OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode, IN UINT64 OpenMode,
@ -215,7 +215,7 @@ ShellOpenFileByName(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellCreateDirectory( ShellCreateDirectory (
IN CONST CHAR16 *DirectoryName, IN CONST CHAR16 *DirectoryName,
OUT SHELL_FILE_HANDLE *FileHandle OUT SHELL_FILE_HANDLE *FileHandle
); );
@ -251,7 +251,7 @@ ShellCreateDirectory(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellReadFile( ShellReadFile (
IN SHELL_FILE_HANDLE FileHandle, IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *ReadSize, IN OUT UINTN *ReadSize,
OUT VOID *Buffer OUT VOID *Buffer
@ -285,7 +285,7 @@ ShellReadFile(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellWriteFile( ShellWriteFile (
IN SHELL_FILE_HANDLE FileHandle, IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *BufferSize, IN OUT UINTN *BufferSize,
IN VOID *Buffer IN VOID *Buffer
@ -451,7 +451,7 @@ ShellFindFirstFile (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellFindNextFile( ShellFindNextFile (
IN SHELL_FILE_HANDLE DirHandle, IN SHELL_FILE_HANDLE DirHandle,
IN OUT EFI_FILE_INFO *Buffer, IN OUT EFI_FILE_INFO *Buffer,
IN OUT BOOLEAN *NoFile IN OUT BOOLEAN *NoFile
@ -486,7 +486,7 @@ ShellGetFileSize (
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ShellGetExecutionBreakFlag( ShellGetExecutionBreakFlag (
VOID VOID
); );
@ -501,7 +501,7 @@ ShellGetExecutionBreakFlag(
@retval NULL The named environment variable does not exist. @retval NULL The named environment variable does not exist.
@return != NULL The pointer to the value of the environment variable. @return != NULL The pointer to the value of the environment variable.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellGetEnvironmentVariable ( ShellGetEnvironmentVariable (
IN CONST CHAR16 *EnvKey IN CONST CHAR16 *EnvKey
@ -589,10 +589,10 @@ ShellExecute (
@retval NULL The directory does not exist. @retval NULL The directory does not exist.
@retval != NULL The directory. @retval != NULL The directory.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellGetCurrentDir ( ShellGetCurrentDir (
IN CHAR16 * CONST DeviceName OPTIONAL IN CHAR16 *CONST DeviceName OPTIONAL
); );
/** /**
@ -711,7 +711,6 @@ typedef struct {
SHELL_PARAM_TYPE Type; SHELL_PARAM_TYPE Type;
} SHELL_PARAM_ITEM; } SHELL_PARAM_ITEM;
/// Helper structure for no parameters (besides -? and -b) /// Helper structure for no parameters (besides -? and -b)
extern SHELL_PARAM_ITEM EmptyParamList[]; extern SHELL_PARAM_ITEM EmptyParamList[];
@ -753,7 +752,7 @@ ShellCommandLineParseEx (
); );
/// Make it easy to upgrade from older versions of the shell library. /// Make it easy to upgrade from older versions of the shell library.
#define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE) #define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)
/** /**
Frees shell variable list that was returned from ShellCommandLineParse. Frees shell variable list that was returned from ShellCommandLineParse.
@ -788,8 +787,8 @@ ShellCommandLineFreeVarList (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ShellCommandLineGetFlag ( ShellCommandLineGetFlag (
IN CONST LIST_ENTRY * CONST CheckPackage, IN CONST LIST_ENTRY *CONST CheckPackage,
IN CONST CHAR16 * CONST KeyString IN CONST CHAR16 *CONST KeyString
); );
/** /**
@ -805,7 +804,7 @@ ShellCommandLineGetFlag (
@retval NULL The flag is not on the command line. @retval NULL The flag is not on the command line.
@retval !=NULL The pointer to unicode string of the value. @retval !=NULL The pointer to unicode string of the value.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellCommandLineGetValue ( ShellCommandLineGetValue (
IN CONST LIST_ENTRY *CheckPackage, IN CONST LIST_ENTRY *CheckPackage,
@ -825,10 +824,10 @@ ShellCommandLineGetValue (
@retval NULL The flag is not on the command line. @retval NULL The flag is not on the command line.
@retval !=NULL The pointer to unicode string of the value. @retval !=NULL The pointer to unicode string of the value.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellCommandLineGetRawValue ( ShellCommandLineGetRawValue (
IN CONST LIST_ENTRY * CONST CheckPackage, IN CONST LIST_ENTRY *CONST CheckPackage,
IN UINTN Position IN UINTN Position
); );
@ -844,7 +843,7 @@ ShellCommandLineGetRawValue (
**/ **/
UINTN UINTN
EFIAPI EFIAPI
ShellCommandLineGetCount( ShellCommandLineGetCount (
IN CONST LIST_ENTRY *CheckPackage IN CONST LIST_ENTRY *CheckPackage
); );
@ -919,7 +918,7 @@ ShellInitialize (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellPrintEx( ShellPrintEx (
IN INT32 Col OPTIONAL, IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL, IN INT32 Row OPTIONAL,
IN CONST CHAR16 *Format, IN CONST CHAR16 *Format,
@ -960,7 +959,7 @@ ShellPrintEx(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellPrintHiiEx( ShellPrintHiiEx (
IN INT32 Col OPTIONAL, IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL, IN INT32 Row OPTIONAL,
IN CONST CHAR8 *Language OPTIONAL, IN CONST CHAR8 *Language OPTIONAL,
@ -982,7 +981,7 @@ ShellPrintHiiEx(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellIsDirectory( ShellIsDirectory (
IN CONST CHAR16 *DirName IN CONST CHAR16 *DirName
); );
@ -1001,7 +1000,7 @@ ShellIsDirectory(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellIsFile( ShellIsFile (
IN CONST CHAR16 *Name IN CONST CHAR16 *Name
); );
@ -1020,7 +1019,7 @@ ShellIsFile(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellIsFileInPath( ShellIsFileInPath (
IN CONST CHAR16 *Name IN CONST CHAR16 *Name
); );
@ -1038,7 +1037,7 @@ ShellIsFileInPath(
**/ **/
UINTN UINTN
EFIAPI EFIAPI
ShellStrToUintn( ShellStrToUintn (
IN CONST CHAR16 *String IN CONST CHAR16 *String
); );
@ -1055,7 +1054,7 @@ ShellStrToUintn(
**/ **/
UINTN UINTN
EFIAPI EFIAPI
ShellHexStrToUintn( ShellHexStrToUintn (
IN CONST CHAR16 *String IN CONST CHAR16 *String
); );
@ -1091,7 +1090,7 @@ ShellHexStrToUintn(
@return The Destination after appending the Source. @return The Destination after appending the Source.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
StrnCatGrow ( StrnCatGrow (
IN OUT CHAR16 **Destination, IN OUT CHAR16 **Destination,
@ -1129,7 +1128,7 @@ StrnCatGrow (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellCopySearchAndReplace( ShellCopySearchAndReplace (
IN CHAR16 CONST *SourceString, IN CHAR16 CONST *SourceString,
IN OUT CHAR16 *NewString, IN OUT CHAR16 *NewString,
IN UINTN NewSize, IN UINTN NewSize,
@ -1301,7 +1300,7 @@ ShellIsHexOrDecimalNumber (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellConvertStringToUint64( ShellConvertStringToUint64 (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
OUT UINT64 *Value, OUT UINT64 *Value,
IN CONST BOOLEAN ForceHex, IN CONST BOOLEAN ForceHex,
@ -1319,7 +1318,7 @@ ShellConvertStringToUint64(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellFileExists( ShellFileExists (
IN CONST CHAR16 *Name IN CONST CHAR16 *Name
); );
@ -1338,9 +1337,9 @@ ShellFileExists(
@sa ShellFileHandleReadLine @sa ShellFileHandleReadLine
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
ShellFileHandleReturnLine( ShellFileHandleReturnLine (
IN SHELL_FILE_HANDLE Handle, IN SHELL_FILE_HANDLE Handle,
IN OUT BOOLEAN *Ascii IN OUT BOOLEAN *Ascii
); );
@ -1373,7 +1372,7 @@ ShellFileHandleReturnLine(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellFileHandleReadLine( ShellFileHandleReadLine (
IN SHELL_FILE_HANDLE Handle, IN SHELL_FILE_HANDLE Handle,
IN OUT CHAR16 *Buffer, IN OUT CHAR16 *Buffer,
IN OUT UINTN *Size, IN OUT UINTN *Size,
@ -1406,7 +1405,7 @@ ShellFileHandleReadLine(
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
ShellDeleteFileByName( ShellDeleteFileByName (
IN CONST CHAR16 *FileName IN CONST CHAR16 *FileName
); );

View File

@ -6,7 +6,6 @@
**/ **/
#ifndef _SHELL_ENVIRONMENT_2_PROTOCOL_H_ #ifndef _SHELL_ENVIRONMENT_2_PROTOCOL_H_
#define _SHELL_ENVIRONMENT_2_PROTOCOL_H_ #define _SHELL_ENVIRONMENT_2_PROTOCOL_H_
@ -24,7 +23,7 @@
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO) ( (EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO)(
IN EFI_HANDLE Handle, IN EFI_HANDLE Handle,
IN VOID *Interface IN VOID *Interface
); );
@ -45,7 +44,7 @@ VOID
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_INTERNAL_COMMAND) ( (EFIAPI *SHELLENV_INTERNAL_COMMAND)(
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
); );
@ -62,7 +61,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLCMD_GET_LINE_HELP) ( (EFIAPI *SHELLCMD_GET_LINE_HELP)(
IN OUT CHAR16 **Str IN OUT CHAR16 **Str
); );
@ -129,7 +128,7 @@ GUID for the shell environment2 extension (main GUID above).
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_EXECUTE) ( (EFIAPI *SHELLENV_EXECUTE)(
IN EFI_HANDLE *ParentImageHandle, IN EFI_HANDLE *ParentImageHandle,
IN CHAR16 *CommandLine, IN CHAR16 *CommandLine,
IN BOOLEAN DebugOutput IN BOOLEAN DebugOutput
@ -147,7 +146,7 @@ EFI_STATUS
**/ **/
typedef typedef
CHAR16 * CHAR16 *
(EFIAPI *SHELLENV_GET_ENV) ( (EFIAPI *SHELLENV_GET_ENV)(
IN CHAR16 *Name IN CHAR16 *Name
); );
@ -163,7 +162,7 @@ CHAR16 *
**/ **/
typedef typedef
CHAR16 * CHAR16 *
(EFIAPI *SHELLENV_GET_MAP) ( (EFIAPI *SHELLENV_GET_MAP)(
IN CHAR16 *Name IN CHAR16 *Name
); );
@ -184,7 +183,7 @@ CHAR16 *
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_ADD_CMD) ( (EFIAPI *SHELLENV_ADD_CMD)(
IN SHELLENV_INTERNAL_COMMAND Handler, IN SHELLENV_INTERNAL_COMMAND Handler,
IN CHAR16 *Cmd, IN CHAR16 *Cmd,
IN SHELLCMD_GET_LINE_HELP GetLineHelp IN SHELLCMD_GET_LINE_HELP GetLineHelp
@ -206,7 +205,7 @@ EFI_STATUS
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_ADD_PROT) ( (EFIAPI *SHELLENV_ADD_PROT)(
IN EFI_GUID *Protocol, IN EFI_GUID *Protocol,
IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL, IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL,
IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL, IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL,
@ -227,8 +226,8 @@ VOID
@retval NULL The Name was not found, and GenId was not TRUE. @retval NULL The Name was not found, and GenId was not TRUE.
**/ **/
typedef typedef
CHAR16* CHAR16 *
(EFIAPI *SHELLENV_GET_PROT) ( (EFIAPI *SHELLENV_GET_PROT)(
IN EFI_GUID *Protocol, IN EFI_GUID *Protocol,
IN BOOLEAN GenId IN BOOLEAN GenId
); );
@ -249,8 +248,8 @@ CHAR16*
**/ **/
typedef typedef
CHAR16* CHAR16 *
(EFIAPI *SHELLENV_CUR_DIR) ( (EFIAPI *SHELLENV_CUR_DIR)(
IN CHAR16 *DeviceName OPTIONAL IN CHAR16 *DeviceName OPTIONAL
); );
@ -275,7 +274,7 @@ CHAR16*
@sa SHELLENV_FREE_FILE_LIST @sa SHELLENV_FREE_FILE_LIST
**/typedef **/typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_FILE_META_ARG) ( (EFIAPI *SHELLENV_FILE_META_ARG)(
IN CHAR16 *Arg, IN CHAR16 *Arg,
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *ListHead
); );
@ -289,7 +288,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_FREE_FILE_LIST) ( (EFIAPI *SHELLENV_FREE_FILE_LIST)(
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *ListHead
); );
@ -308,8 +307,8 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_SHELL_INTERFACE* EFI_SHELL_INTERFACE *
(EFIAPI *SHELLENV_NEW_SHELL) ( (EFIAPI *SHELLENV_NEW_SHELL)(
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
); );
@ -325,7 +324,7 @@ EFI_SHELL_INTERFACE*
**/ **/
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *SHELLENV_BATCH_IS_ACTIVE) ( (EFIAPI *SHELLENV_BATCH_IS_ACTIVE)(
VOID VOID
); );
@ -335,7 +334,7 @@ BOOLEAN
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_FREE_RESOURCES) ( (EFIAPI *SHELLENV_FREE_RESOURCES)(
VOID VOID
); );
@ -352,7 +351,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK) ( (EFIAPI *SHELLENV_ENABLE_PAGE_BREAK)(
IN INT32 StartRow, IN INT32 StartRow,
IN BOOLEAN AutoWrap IN BOOLEAN AutoWrap
); );
@ -365,7 +364,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK) ( (EFIAPI *SHELLENV_DISABLE_PAGE_BREAK)(
VOID VOID
); );
@ -377,7 +376,7 @@ VOID
**/ **/
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *SHELLENV_GET_PAGE_BREAK) ( (EFIAPI *SHELLENV_GET_PAGE_BREAK)(
VOID VOID
); );
@ -393,7 +392,7 @@ BOOLEAN
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_SET_KEY_FILTER) ( (EFIAPI *SHELLENV_SET_KEY_FILTER)(
IN UINT32 KeyFilter IN UINT32 KeyFilter
); );
@ -409,7 +408,7 @@ VOID
**/ **/
typedef typedef
UINT32 UINT32
(EFIAPI *SHELLENV_GET_KEY_FILTER) ( (EFIAPI *SHELLENV_GET_KEY_FILTER)(
VOID VOID
); );
@ -425,7 +424,7 @@ UINT32
**/ **/
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *SHELLENV_GET_EXECUTION_BREAK) ( (EFIAPI *SHELLENV_GET_EXECUTION_BREAK)(
VOID VOID
); );
@ -435,7 +434,7 @@ BOOLEAN
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) ( (EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL)(
VOID VOID
); );
@ -444,7 +443,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) ( (EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL)(
VOID VOID
); );
@ -457,7 +456,7 @@ VOID
**/ **/
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *SHELLENV_IS_ROOT_SHELL) ( (EFIAPI *SHELLENV_IS_ROOT_SHELL)(
VOID VOID
); );
@ -476,7 +475,7 @@ BOOLEAN
**/ **/
typedef typedef
VOID VOID
(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY) ( (EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY)(
IN EFI_HANDLE ConInHandle, IN EFI_HANDLE ConInHandle,
IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn, IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn,
IN EFI_HANDLE ConOutHandle, IN EFI_HANDLE ConOutHandle,
@ -486,6 +485,7 @@ VOID
// //
// declarations of handle enumerator // declarations of handle enumerator
// //
/** /**
For ease of use the shell maps handle #'s to short numbers. 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 This is only done on request for various internal commands and the references
@ -493,7 +493,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *INIT_HANDLE_ENUMERATOR) ( (EFIAPI *INIT_HANDLE_ENUMERATOR)(
VOID VOID
); );
@ -514,7 +514,7 @@ VOID
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *NEXT_HANDLE) ( (EFIAPI *NEXT_HANDLE)(
IN OUT EFI_HANDLE **Handle IN OUT EFI_HANDLE **Handle
); );
@ -534,7 +534,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SKIP_HANDLE) ( (EFIAPI *SKIP_HANDLE)(
IN UINTN SkipNum IN UINTN SkipNum
); );
@ -552,7 +552,7 @@ EFI_STATUS
**/ **/
typedef typedef
UINTN UINTN
(EFIAPI *RESET_HANDLE_ENUMERATOR) ( (EFIAPI *RESET_HANDLE_ENUMERATOR)(
IN UINTN EnumIndex IN UINTN EnumIndex
); );
@ -567,7 +567,7 @@ UINTN
**/ **/
typedef typedef
VOID VOID
(EFIAPI *CLOSE_HANDLE_ENUMERATOR) ( (EFIAPI *CLOSE_HANDLE_ENUMERATOR)(
VOID VOID
); );
@ -582,7 +582,7 @@ VOID
**/ **/
typedef typedef
UINTN UINTN
(EFIAPI *GET_NUM) ( (EFIAPI *GET_NUM)(
VOID VOID
); );
@ -621,12 +621,12 @@ typedef struct {
// //
UINTN NoHandles; ///< The number of handles producing this protocol. UINTN NoHandles; ///< The number of handles producing this protocol.
EFI_HANDLE *Handles; ///< The array of handles. EFI_HANDLE *Handles; ///< The array of handles.
} PROTOCOL_INFO; } PROTOCOL_INFO;
// //
// Declarations of protocol info enumerator. // Declarations of protocol info enumerator.
// //
/** /**
This is an internal shell function to initialize the protocol enumerator. This is an internal shell function to initialize the protocol enumerator.
@ -636,7 +636,7 @@ typedef struct {
**/ **/
typedef typedef
VOID VOID
(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR) ( (EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR)(
VOID VOID
); );
@ -657,7 +657,7 @@ VOID
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *NEXT_PROTOCOL_INFO) ( (EFIAPI *NEXT_PROTOCOL_INFO)(
IN OUT PROTOCOL_INFO **ProtocolInfo IN OUT PROTOCOL_INFO **ProtocolInfo
); );
@ -673,7 +673,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SKIP_PROTOCOL_INFO) ( (EFIAPI *SKIP_PROTOCOL_INFO)(
IN UINTN SkipNum IN UINTN SkipNum
); );
@ -688,11 +688,10 @@ EFI_STATUS
**/ **/
typedef typedef
VOID VOID
(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR) ( (EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR)(
VOID VOID
); );
/** /**
This function is an internal shell function for enumeration of protocols. This function is an internal shell function for enumeration of protocols.
@ -704,7 +703,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR) ( (EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR)(
VOID VOID
); );
@ -752,7 +751,7 @@ typedef struct {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *GET_DEVICE_NAME) ( (EFIAPI *GET_DEVICE_NAME)(
IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE DeviceHandle,
IN BOOLEAN UseComponentName, IN BOOLEAN UseComponentName,
IN BOOLEAN UseDevicePath, IN BOOLEAN UseDevicePath,
@ -778,7 +777,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *GET_SHELL_MODE) ( (EFIAPI *GET_SHELL_MODE)(
OUT CHAR16 **Mode OUT CHAR16 **Mode
); );
@ -798,8 +797,8 @@ EFI_STATUS
@retval NULL The operation could not be completed. @retval NULL The operation could not be completed.
**/ **/
typedef typedef
EFI_DEVICE_PATH_PROTOCOL* EFI_DEVICE_PATH_PROTOCOL *
(EFIAPI *SHELLENV_NAME_TO_PATH) ( (EFIAPI *SHELLENV_NAME_TO_PATH)(
IN CHAR16 *Path IN CHAR16 *Path
); );
@ -827,8 +826,8 @@ EFI_DEVICE_PATH_PROTOCOL*
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_GET_FS_NAME) ( (EFIAPI *SHELLENV_GET_FS_NAME)(
IN EFI_DEVICE_PATH_PROTOCOL * DevPath, IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
IN BOOLEAN ConsistMapping, IN BOOLEAN ConsistMapping,
OUT CHAR16 **Name OUT CHAR16 **Name
); );
@ -855,7 +854,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) ( (EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD)(
IN CHAR16 *Arg, IN CHAR16 *Arg,
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *ListHead
); );
@ -877,8 +876,8 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_DEL_DUP_FILE) ( (EFIAPI *SHELLENV_DEL_DUP_FILE)(
IN LIST_ENTRY * ListHead IN LIST_ENTRY *ListHead
); );
/** /**
@ -905,7 +904,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) ( (EFIAPI *SHELLENV_GET_FS_DEVICE_PATH)(
IN CHAR16 *Name, IN CHAR16 *Name,
OUT EFI_DEVICE_PATH_PROTOCOL **DevPath OUT EFI_DEVICE_PATH_PROTOCOL **DevPath
); );

File diff suppressed because it is too large Load Diff

View File

@ -99,8 +99,8 @@
#include <Protocol/DriverConfiguration.h> #include <Protocol/DriverConfiguration.h>
#include <Protocol/DriverConfiguration2.h> #include <Protocol/DriverConfiguration2.h>
#include <Protocol/DevicePathUtilities.h> #include <Protocol/DevicePathUtilities.h>
//#include <Protocol/FirmwareVolume.h> // #include <Protocol/FirmwareVolume.h>
//#include <Protocol/FirmwareVolume2.h> // #include <Protocol/FirmwareVolume2.h>
#include <Protocol/DriverFamilyOverride.h> #include <Protocol/DriverFamilyOverride.h>
#include <Protocol/Pcd.h> #include <Protocol/Pcd.h>
#include <Protocol/TcgService.h> #include <Protocol/TcgService.h>
@ -207,7 +207,6 @@ typedef struct {
UINT64 Compatibilities; UINT64 Compatibilities;
} EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1; } EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1;
/// ///
/// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec > 2.4a and < 2.5 /// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec > 2.4a and < 2.5
/// ///
@ -270,7 +269,7 @@ typedef struct {
LIST_ENTRY Link; LIST_ENTRY Link;
EFI_HANDLE TheHandle; EFI_HANDLE TheHandle;
UINTN TheIndex; UINTN TheIndex;
}HANDLE_LIST; } HANDLE_LIST;
typedef struct { typedef struct {
HANDLE_LIST List; HANDLE_LIST List;
@ -284,11 +283,10 @@ CHAR16 *
IN CONST BOOLEAN Verbose IN CONST BOOLEAN Verbose
); );
typedef struct _GUID_INFO_BLOCK{ typedef struct _GUID_INFO_BLOCK {
EFI_STRING_ID StringId; EFI_STRING_ID StringId;
EFI_GUID *GuidId; EFI_GUID *GuidId;
DUMP_PROTOCOL_INFO DumpInfo; DUMP_PROTOCOL_INFO DumpInfo;
} GUID_INFO_BLOCK; } GUID_INFO_BLOCK;
#endif #endif

View File

@ -114,7 +114,7 @@ BOOLEAN
EFIAPI EFIAPI
VerifyChecksum ( VerifyChecksum (
IN BOOLEAN Log, IN BOOLEAN Log,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -140,22 +140,29 @@ VerifyChecksum (
if (GetColourHighlighting ()) { if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute ( gST->ConOut->SetAttribute (
gST->ConOut, gST->ConOut,
EFI_TEXT_ATTR (EFI_GREEN, EFI_TEXT_ATTR (
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) EFI_GREEN,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
); );
} }
Print (L"Table Checksum : OK\n\n"); Print (L"Table Checksum : OK\n\n");
} else { } else {
IncrementErrorCount (); IncrementErrorCount ();
if (GetColourHighlighting ()) { if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute ( gST->ConOut->SetAttribute (
gST->ConOut, gST->ConOut,
EFI_TEXT_ATTR (EFI_RED, EFI_TEXT_ATTR (
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) EFI_RED,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
); );
} }
Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum); Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum);
} }
if (GetColourHighlighting ()) { if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
} }
@ -173,7 +180,7 @@ VerifyChecksum (
VOID VOID
EFIAPI EFIAPI
DumpRaw ( DumpRaw (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -216,6 +223,7 @@ DumpRaw (
if ((Length & 0x0F) <= 8) { if ((Length & 0x0F) <= 8) {
PartLineChars += 2; PartLineChars += 2;
} }
while (PartLineChars > 0) { while (PartLineChars > 0) {
Print (L" "); Print (L" ");
PartLineChars--; PartLineChars--;
@ -236,8 +244,8 @@ DumpRaw (
VOID VOID
EFIAPI EFIAPI
DumpUint8 ( DumpUint8 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print (Format, *Ptr); Print (Format, *Ptr);
@ -252,11 +260,11 @@ DumpUint8 (
VOID VOID
EFIAPI EFIAPI
DumpUint16 ( DumpUint16 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print (Format, *(UINT16*)Ptr); Print (Format, *(UINT16 *)Ptr);
} }
/** /**
@ -268,11 +276,11 @@ DumpUint16 (
VOID VOID
EFIAPI EFIAPI
DumpUint32 ( DumpUint32 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print (Format, *(UINT32*)Ptr); Print (Format, *(UINT32 *)Ptr);
} }
/** /**
@ -284,8 +292,8 @@ DumpUint32 (
VOID VOID
EFIAPI EFIAPI
DumpUint64 ( DumpUint64 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
// Some fields are not aligned and this causes alignment faults // Some fields are not aligned and this causes alignment faults
@ -293,10 +301,10 @@ DumpUint64 (
// Perform word access so that LDRD instructions are not generated. // Perform word access so that LDRD instructions are not generated.
UINT64 Val; UINT64 Val;
Val = *(UINT32*)(Ptr + sizeof (UINT32)); Val = *(UINT32 *)(Ptr + sizeof (UINT32));
Val = LShiftU64(Val,32); Val = LShiftU64 (Val, 32);
Val |= (UINT64)*(UINT32*)Ptr; Val |= (UINT64)*(UINT32 *)Ptr;
Print (Format, Val); Print (Format, Val);
} }
@ -313,8 +321,8 @@ DumpUint64 (
VOID VOID
EFIAPI EFIAPI
Dump3Chars ( Dump3Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -337,8 +345,8 @@ Dump3Chars (
VOID VOID
EFIAPI EFIAPI
Dump4Chars ( Dump4Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -362,8 +370,8 @@ Dump4Chars (
VOID VOID
EFIAPI EFIAPI
Dump6Chars ( Dump6Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -389,8 +397,8 @@ Dump6Chars (
VOID VOID
EFIAPI EFIAPI
Dump8Chars ( Dump8Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -418,8 +426,8 @@ Dump8Chars (
VOID VOID
EFIAPI EFIAPI
Dump12Chars ( Dump12Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -455,8 +463,8 @@ VOID
EFIAPI EFIAPI
PrintFieldName ( PrintFieldName (
IN UINT32 Indent, IN UINT32 Indent,
IN CONST CHAR16* FieldName IN CONST CHAR16 *FieldName
) )
{ {
Print ( Print (
L"%*a%-*s : ", L"%*a%-*s : ",
@ -498,12 +506,12 @@ EFIAPI
ParseAcpi ( ParseAcpi (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT32 Indent, IN UINT32 Indent,
IN CONST CHAR8* AsciiName OPTIONAL, IN CONST CHAR8 *AsciiName OPTIONAL,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length, IN UINT32 Length,
IN CONST ACPI_PARSER* Parser, IN CONST ACPI_PARSER *Parser,
IN UINT32 ParserItems IN UINT32 ParserItems
) )
{ {
UINT32 Index; UINT32 Index;
UINT32 Offset; UINT32 Offset;
@ -519,17 +527,20 @@ ParseAcpi (
// Increment the Indent // Increment the Indent
gIndent += Indent; gIndent += Indent;
if (Trace && (AsciiName != NULL)){ if (Trace && (AsciiName != NULL)) {
HighLight = GetColourHighlighting (); HighLight = GetColourHighlighting ();
if (HighLight) { if (HighLight) {
OriginalAttribute = gST->ConOut->Mode->Attribute; OriginalAttribute = gST->ConOut->Mode->Attribute;
gST->ConOut->SetAttribute ( gST->ConOut->SetAttribute (
gST->ConOut, gST->ConOut,
EFI_TEXT_ATTR(EFI_YELLOW, EFI_TEXT_ATTR (
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) EFI_YELLOW,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
); );
} }
Print ( Print (
L"%*a%-*a :\n", L"%*a%-*a :\n",
gIndent, gIndent,
@ -544,7 +555,6 @@ ParseAcpi (
for (Index = 0; Index < ParserItems; Index++) { for (Index = 0; Index < ParserItems; Index++) {
if ((Offset + Parser[Index].Length) > Length) { if ((Offset + Parser[Index].Length) > Length) {
// For fields outside the buffer length provided, reset any pointers // For fields outside the buffer length provided, reset any pointers
// which were supposed to be updated by this function call // which were supposed to be updated by this function call
if (Parser[Index].ItemPtr != NULL) { if (Parser[Index].ItemPtr != NULL) {
@ -556,7 +566,8 @@ ParseAcpi (
} }
if (GetConsistencyChecking () && if (GetConsistencyChecking () &&
(Offset != Parser[Index].Offset)) { (Offset != Parser[Index].Offset))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: %a: Offset Mismatch for %s\n" L"\nERROR: %a: Offset Mismatch for %s\n"
@ -597,17 +608,20 @@ ParseAcpi (
); );
} // switch } // switch
} }
// Validating only makes sense if we are tracing // Validating only makes sense if we are tracing
// the parsed table entries, to report by table name. // the parsed table entries, to report by table name.
if (GetConsistencyChecking () && if (GetConsistencyChecking () &&
(Parser[Index].FieldValidator != NULL)) { (Parser[Index].FieldValidator != NULL))
{
Parser[Index].FieldValidator (Ptr, Parser[Index].Context); Parser[Index].FieldValidator (Ptr, Parser[Index].Context);
} }
Print (L"\n"); Print (L"\n");
} // if (Trace) } // if (Trace)
if (Parser[Index].ItemPtr != NULL) { if (Parser[Index].ItemPtr != NULL) {
*Parser[Index].ItemPtr = (VOID*)Ptr; *Parser[Index].ItemPtr = (VOID *)Ptr;
} }
Ptr += Parser[Index].Length; Ptr += Parser[Index].Length;
@ -625,11 +639,11 @@ ParseAcpi (
the GAS structure. the GAS structure.
**/ **/
STATIC CONST ACPI_PARSER GasParser[] = { STATIC CONST ACPI_PARSER GasParser[] = {
{L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Access Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL}, { L"Access Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL} { L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -644,7 +658,7 @@ STATIC CONST ACPI_PARSER GasParser[] = {
UINT32 UINT32
EFIAPI EFIAPI
DumpGasStruct ( DumpGasStruct (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Indent, IN UINT32 Indent,
IN UINT32 Length IN UINT32 Length
) )
@ -669,8 +683,8 @@ DumpGasStruct (
VOID VOID
EFIAPI EFIAPI
DumpGas ( DumpGas (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)); DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE));
@ -686,7 +700,7 @@ DumpGas (
UINT32 UINT32
EFIAPI EFIAPI
DumpAcpiHeader ( DumpAcpiHeader (
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
return ParseAcpi ( return ParseAcpi (
@ -715,10 +729,10 @@ DumpAcpiHeader (
UINT32 UINT32
EFIAPI EFIAPI
ParseAcpiHeader ( ParseAcpiHeader (
IN UINT8* Ptr, IN UINT8 *Ptr,
OUT CONST UINT32** Signature, OUT CONST UINT32 **Signature,
OUT CONST UINT32** Length, OUT CONST UINT32 **Length,
OUT CONST UINT8** Revision OUT CONST UINT8 **Revision
) )
{ {
UINT32 BytesParsed; UINT32 BytesParsed;

View File

@ -51,7 +51,7 @@ BOOLEAN
EFIAPI EFIAPI
VerifyChecksum ( VerifyChecksum (
IN BOOLEAN Log, IN BOOLEAN Log,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
); );
@ -64,7 +64,7 @@ VerifyChecksum (
VOID VOID
EFIAPI EFIAPI
DumpRaw ( DumpRaw (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
); );
@ -77,8 +77,8 @@ DumpRaw (
VOID VOID
EFIAPI EFIAPI
DumpUint8 ( DumpUint8 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -90,8 +90,8 @@ DumpUint8 (
VOID VOID
EFIAPI EFIAPI
DumpUint16 ( DumpUint16 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -103,8 +103,8 @@ DumpUint16 (
VOID VOID
EFIAPI EFIAPI
DumpUint32 ( DumpUint32 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -116,8 +116,8 @@ DumpUint32 (
VOID VOID
EFIAPI EFIAPI
DumpUint64 ( DumpUint64 (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -132,8 +132,8 @@ DumpUint64 (
VOID VOID
EFIAPI EFIAPI
Dump3Chars ( Dump3Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -148,8 +148,8 @@ Dump3Chars (
VOID VOID
EFIAPI EFIAPI
Dump4Chars ( Dump4Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -164,8 +164,8 @@ Dump4Chars (
VOID VOID
EFIAPI EFIAPI
Dump6Chars ( Dump6Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -180,8 +180,8 @@ Dump6Chars (
VOID VOID
EFIAPI EFIAPI
Dump8Chars ( Dump8Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -196,8 +196,8 @@ Dump8Chars (
VOID VOID
EFIAPI EFIAPI
Dump12Chars ( Dump12Chars (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -216,7 +216,7 @@ VOID
EFIAPI EFIAPI
PrintFieldName ( PrintFieldName (
IN UINT32 Indent, IN UINT32 Indent,
IN CONST CHAR16* FieldName IN CONST CHAR16 *FieldName
); );
/** /**
@ -226,7 +226,7 @@ PrintFieldName (
the 'Format' member of ACPI_PARSER. the 'Format' member of ACPI_PARSER.
@param [in] Ptr Pointer to the start of the buffer. @param [in] Ptr Pointer to the start of the buffer.
**/ **/
typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16* Format, UINT8* Ptr); typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16 *Format, UINT8 *Ptr);
/** /**
This function pointer is the template for validating an ACPI table field. This function pointer is the template for validating an ACPI table field.
@ -236,7 +236,7 @@ typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16* Format, UINT8* Ptr);
the 'Context' member of the ACPI_PARSER. the 'Context' member of the ACPI_PARSER.
e.g. this could be a pointer to the ACPI table header. e.g. this could be a pointer to the ACPI table header.
**/ **/
typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8* Ptr, VOID* Context); typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8 *Ptr, VOID *Context);
/** /**
The ACPI_PARSER structure describes the fields of an ACPI table and The ACPI_PARSER structure describes the fields of an ACPI table and
@ -258,10 +258,9 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8* Ptr, VOID* Context);
representing the field data. representing the field data.
**/ **/
typedef struct AcpiParser { typedef struct AcpiParser {
/// String describing the ACPI table field /// String describing the ACPI table field
/// (Field column from ACPI table spec) /// (Field column from ACPI table spec)
CONST CHAR16* NameStr; CONST CHAR16 *NameStr;
/// The length of the field. /// The length of the field.
/// (Byte Length column from ACPI table spec) /// (Byte Length column from ACPI table spec)
@ -273,7 +272,7 @@ typedef struct AcpiParser {
/// Optional Print() style format string for tracing the data. If not /// Optional Print() style format string for tracing the data. If not
/// used this must be set to NULL. /// used this must be set to NULL.
CONST CHAR16* Format; CONST CHAR16 *Format;
/// Optional pointer to a print formatter function which /// Optional pointer to a print formatter function which
/// is typically used to trace complex field information. /// is typically used to trace complex field information.
@ -286,7 +285,7 @@ typedef struct AcpiParser {
/// a pointer to the field data. This value is set after the FieldValidator /// a pointer to the field data. This value is set after the FieldValidator
/// has been called and therefore should not be used by the FieldValidator. /// has been called and therefore should not be used by the FieldValidator.
/// If unused this must be set to NULL. /// If unused this must be set to NULL.
VOID** ItemPtr; VOID **ItemPtr;
/// Optional pointer to a field validator function. /// Optional pointer to a field validator function.
/// The function should directly report any appropriate error or warning /// The function should directly report any appropriate error or warning
@ -299,7 +298,7 @@ typedef struct AcpiParser {
/// additional information about the ACPI table and make /// additional information about the ACPI table and make
/// decisions about the field being validated. /// decisions about the field being validated.
/// e.g. this could be a pointer to the ACPI table header /// e.g. this could be a pointer to the ACPI table header
VOID* Context; VOID *Context;
} ACPI_PARSER; } ACPI_PARSER;
/** /**
@ -308,23 +307,23 @@ typedef struct AcpiParser {
**/ **/
typedef struct AcpiDescriptionHeaderInfo { typedef struct AcpiDescriptionHeaderInfo {
/// ACPI table signature /// ACPI table signature
UINT32* Signature; UINT32 *Signature;
/// Length of the ACPI table /// Length of the ACPI table
UINT32* Length; UINT32 *Length;
/// Revision /// Revision
UINT8* Revision; UINT8 *Revision;
/// Checksum /// Checksum
UINT8* Checksum; UINT8 *Checksum;
/// OEM Id - length is 6 bytes /// OEM Id - length is 6 bytes
UINT8* OemId; UINT8 *OemId;
/// OEM table Id /// OEM table Id
UINT64* OemTableId; UINT64 *OemTableId;
/// OEM revision Id /// OEM revision Id
UINT32* OemRevision; UINT32 *OemRevision;
/// Creator Id /// Creator Id
UINT32* CreatorId; UINT32 *CreatorId;
/// Creator revision /// Creator revision
UINT32* CreatorRevision; UINT32 *CreatorRevision;
} ACPI_DESCRIPTION_HEADER_INFO; } ACPI_DESCRIPTION_HEADER_INFO;
/** /**
@ -358,10 +357,10 @@ EFIAPI
ParseAcpi ( ParseAcpi (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT32 Indent, IN UINT32 Indent,
IN CONST CHAR8* AsciiName OPTIONAL, IN CONST CHAR8 *AsciiName OPTIONAL,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length, IN UINT32 Length,
IN CONST ACPI_PARSER* Parser, IN CONST ACPI_PARSER *Parser,
IN UINT32 ParserItems IN UINT32 ParserItems
); );
@ -410,7 +409,7 @@ ParseAcpi (
UINT32 UINT32
EFIAPI EFIAPI
DumpGasStruct ( DumpGasStruct (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Indent, IN UINT32 Indent,
IN UINT32 Length IN UINT32 Length
); );
@ -424,8 +423,8 @@ DumpGasStruct (
VOID VOID
EFIAPI EFIAPI
DumpGas ( DumpGas (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -438,7 +437,7 @@ DumpGas (
UINT32 UINT32
EFIAPI EFIAPI
DumpAcpiHeader ( DumpAcpiHeader (
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -457,10 +456,10 @@ DumpAcpiHeader (
UINT32 UINT32
EFIAPI EFIAPI
ParseAcpiHeader ( ParseAcpiHeader (
IN UINT8* Ptr, IN UINT8 *Ptr,
OUT CONST UINT32** Signature, OUT CONST UINT32 **Signature,
OUT CONST UINT32** Length, OUT CONST UINT32 **Length,
OUT CONST UINT8** Revision OUT CONST UINT8 **Revision
); );
/** /**
@ -479,7 +478,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiAest ( ParseAcpiAest (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -500,7 +499,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiBgrt ( ParseAcpiBgrt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -521,7 +520,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiDbg2 ( ParseAcpiDbg2 (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -542,7 +541,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiDsdt ( ParseAcpiDsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -563,7 +562,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiFacs ( ParseAcpiFacs (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -584,7 +583,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiFadt ( ParseAcpiFadt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -609,7 +608,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiGtdt ( ParseAcpiGtdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -635,7 +634,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiHmat ( ParseAcpiHmat (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -664,7 +663,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiIort ( ParseAcpiIort (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -693,7 +692,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiMadt ( ParseAcpiMadt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -714,7 +713,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiMcfg ( ParseAcpiMcfg (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -736,7 +735,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiPcct ( ParseAcpiPcct (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -757,7 +756,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiPptt ( ParseAcpiPptt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -780,7 +779,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiRsdp ( ParseAcpiRsdp (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -804,7 +803,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSlit ( ParseAcpiSlit (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -825,7 +824,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSpcr ( ParseAcpiSpcr (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -852,7 +851,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSrat ( ParseAcpiSrat (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -873,7 +872,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSsdt ( ParseAcpiSsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -893,7 +892,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiXsdt ( ParseAcpiXsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );

View File

@ -19,8 +19,8 @@
#include "AcpiView.h" #include "AcpiView.h"
#include "AcpiViewConfig.h" #include "AcpiViewConfig.h"
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
#include "Arm/SbbrValidator.h" #include "Arm/SbbrValidator.h"
#endif #endif
/** /**
@ -139,7 +139,7 @@ EFI_STATUS
EFIAPI EFIAPI
GetParser ( GetParser (
IN UINT32 Signature, IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC * ParserProc OUT PARSE_ACPI_TABLE_PROC *ParserProc
) )
{ {
UINT32 Index; UINT32 Index;
@ -179,15 +179,15 @@ GetParser (
VOID VOID
EFIAPI EFIAPI
ProcessAcpiTable ( ProcessAcpiTable (
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
BOOLEAN Trace; BOOLEAN Trace;
CONST UINT32* AcpiTableSignature; CONST UINT32 *AcpiTableSignature;
CONST UINT32* AcpiTableLength; CONST UINT32 *AcpiTableLength;
CONST UINT8* AcpiTableRevision; CONST UINT8 *AcpiTableRevision;
CONST UINT8* SignaturePtr; CONST UINT8 *SignaturePtr;
PARSE_ACPI_TABLE_PROC ParserProc; PARSE_ACPI_TABLE_PROC ParserProc;
ParseAcpiHeader ( ParseAcpiHeader (
@ -209,7 +209,7 @@ ProcessAcpiTable (
// Do not process the ACPI table any further if the table length read // Do not process the ACPI table any further if the table length read
// is invalid. The ACPI table should at least contain the table header. // is invalid. The ACPI table should at least contain the table header.
if (*AcpiTableLength < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) { if (*AcpiTableLength < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
SignaturePtr = (CONST UINT8*)AcpiTableSignature; SignaturePtr = (CONST UINT8 *)AcpiTableSignature;
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid %c%c%c%c table length. Length = %d\n", L"ERROR: Invalid %c%c%c%c table length. Length = %d\n",
@ -227,11 +227,12 @@ ProcessAcpiTable (
} }
} }
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (GetMandatoryTableValidate ()) { if (GetMandatoryTableValidate ()) {
ArmSbbrIncrementTableCount (*AcpiTableSignature); ArmSbbrIncrementTableCount (*AcpiTableSignature);
} }
#endif
#endif
Status = GetParser (*AcpiTableSignature, &ParserProc); Status = GetParser (*AcpiTableSignature, &ParserProc);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -239,6 +240,7 @@ ProcessAcpiTable (
if (Trace) { if (Trace) {
DumpAcpiHeader (Ptr); DumpAcpiHeader (Ptr);
} }
return; return;
} }

View File

@ -27,9 +27,9 @@
**/ **/
typedef typedef
VOID VOID
(EFIAPI * PARSE_ACPI_TABLE_PROC) ( (EFIAPI *PARSE_ACPI_TABLE_PROC)(
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
); );
@ -101,7 +101,7 @@ DeregisterParser (
VOID VOID
EFIAPI EFIAPI
ProcessAcpiTable ( ProcessAcpiTable (
IN UINT8* Ptr IN UINT8 *Ptr
); );
/** /**
@ -121,7 +121,7 @@ EFI_STATUS
EFIAPI EFIAPI
GetParser ( GetParser (
IN UINT32 Signature, IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC * ParserProc OUT PARSE_ACPI_TABLE_PROC *ParserProc
); );
#endif // ACPITABLEPARSER_H_ #endif // ACPITABLEPARSER_H_

View File

@ -23,8 +23,8 @@
#include "AcpiView.h" #include "AcpiView.h"
#include "AcpiViewConfig.h" #include "AcpiViewConfig.h"
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
#include "Arm/SbbrValidator.h" #include "Arm/SbbrValidator.h"
#endif #endif
STATIC UINT32 mTableCount; STATIC UINT32 mTableCount;
@ -42,7 +42,7 @@ STATIC UINT32 mBinTableCount;
STATIC STATIC
BOOLEAN BOOLEAN
DumpAcpiTableToFile ( DumpAcpiTableToFile (
IN CONST UINT8* Ptr, IN CONST UINT8 *Ptr,
IN CONST UINTN Length IN CONST UINTN Length
) )
{ {
@ -78,7 +78,7 @@ DumpAcpiTableToFile (
BOOLEAN BOOLEAN
ProcessTableReportOptions ( ProcessTableReportOptions (
IN CONST UINT32 Signature, IN CONST UINT32 Signature,
IN CONST UINT8* TablePtr, IN CONST UINT8 *TablePtr,
IN CONST UINT32 Length IN CONST UINT32 Length
) )
{ {
@ -92,7 +92,7 @@ ProcessTableReportOptions (
// set local variables to suppress incorrect compiler/analyzer warnings // set local variables to suppress incorrect compiler/analyzer warnings
// //
OriginalAttribute = 0; OriginalAttribute = 0;
SignaturePtr = (UINT8*)(UINTN)&Signature; SignaturePtr = (UINT8 *)(UINTN)&Signature;
Log = FALSE; Log = FALSE;
HighLight = GetColourHighlighting (); HighLight = GetColourHighlighting ();
GetSelectedAcpiTable (&SelectedTable); GetSelectedAcpiTable (&SelectedTable);
@ -106,6 +106,7 @@ ProcessTableReportOptions (
Log = TRUE; Log = TRUE;
SelectedTable->Found = TRUE; SelectedTable->Found = TRUE;
} }
break; break;
case ReportTableList: case ReportTableList:
if (mTableCount == 0) { if (mTableCount == 0) {
@ -113,15 +114,19 @@ ProcessTableReportOptions (
OriginalAttribute = gST->ConOut->Mode->Attribute; OriginalAttribute = gST->ConOut->Mode->Attribute;
gST->ConOut->SetAttribute ( gST->ConOut->SetAttribute (
gST->ConOut, gST->ConOut,
EFI_TEXT_ATTR(EFI_CYAN, EFI_TEXT_ATTR (
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) EFI_CYAN,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
); );
} }
Print (L"\nInstalled Table(s):\n"); Print (L"\nInstalled Table(s):\n");
if (HighLight) { if (HighLight) {
gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
} }
} }
Print ( Print (
L"\t%4d. %c%c%c%c\n", L"\t%4d. %c%c%c%c\n",
++mTableCount, ++mTableCount,
@ -136,6 +141,7 @@ ProcessTableReportOptions (
SelectedTable->Found = TRUE; SelectedTable->Found = TRUE;
DumpAcpiTableToFile (TablePtr, Length); DumpAcpiTableToFile (TablePtr, Length);
} }
break; break;
case ReportMax: case ReportMax:
// We should never be here. // We should never be here.
@ -148,10 +154,13 @@ ProcessTableReportOptions (
OriginalAttribute = gST->ConOut->Mode->Attribute; OriginalAttribute = gST->ConOut->Mode->Attribute;
gST->ConOut->SetAttribute ( gST->ConOut->SetAttribute (
gST->ConOut, gST->ConOut,
EFI_TEXT_ATTR(EFI_LIGHTBLUE, EFI_TEXT_ATTR (
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) EFI_LIGHTBLUE,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
); );
} }
Print ( Print (
L"\n\n --------------- %c%c%c%c Table --------------- \n\n", L"\n\n --------------- %c%c%c%c Table --------------- \n\n",
SignaturePtr[0], SignaturePtr[0],
@ -167,8 +176,6 @@ ProcessTableReportOptions (
return Log; return Log;
} }
/** /**
This function iterates the configuration table entries in the This function iterates the configuration table entries in the
system table, retrieves the RSDP pointer and starts parsing the ACPI tables. system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
@ -182,17 +189,17 @@ ProcessTableReportOptions (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AcpiView ( AcpiView (
IN EFI_SYSTEM_TABLE* SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Index; UINTN Index;
EFI_CONFIGURATION_TABLE* EfiConfigurationTable; EFI_CONFIGURATION_TABLE *EfiConfigurationTable;
BOOLEAN FoundAcpiTable; BOOLEAN FoundAcpiTable;
UINTN OriginalAttribute; UINTN OriginalAttribute;
UINTN PrintAttribute; UINTN PrintAttribute;
EREPORT_OPTION ReportOption; EREPORT_OPTION ReportOption;
UINT8* RsdpPtr; UINT8 *RsdpPtr;
UINT32 RsdpLength; UINT32 RsdpLength;
UINT8 RsdpRevision; UINT8 RsdpRevision;
PARSE_ACPI_TABLE_PROC RsdpParserProc; PARSE_ACPI_TABLE_PROC RsdpParserProc;
@ -219,8 +226,11 @@ AcpiView (
// Search the table for an entry that matches the ACPI Table Guid // Search the table for an entry that matches the ACPI Table Guid
FoundAcpiTable = FALSE; FoundAcpiTable = FALSE;
for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
if (CompareGuid (&gEfiAcpiTableGuid, if (CompareGuid (
&(SystemTable->ConfigurationTable[Index].VendorGuid))) { &gEfiAcpiTableGuid,
&(SystemTable->ConfigurationTable[Index].VendorGuid)
))
{
EfiConfigurationTable = &SystemTable->ConfigurationTable[Index]; EfiConfigurationTable = &SystemTable->ConfigurationTable[Index];
FoundAcpiTable = TRUE; FoundAcpiTable = TRUE;
break; break;
@ -228,7 +238,7 @@ AcpiView (
} }
if (FoundAcpiTable) { if (FoundAcpiTable) {
RsdpPtr = (UINT8*)EfiConfigurationTable->VendorTable; RsdpPtr = (UINT8 *)EfiConfigurationTable->VendorTable;
// The RSDP revision is 1 byte starting at offset 15 // The RSDP revision is 1 byte starting at offset 15
RsdpRevision = *(RsdpPtr + RSDP_REVISION_OFFSET); RsdpRevision = *(RsdpPtr + RSDP_REVISION_OFFSET);
@ -240,14 +250,15 @@ AcpiView (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (GetMandatoryTableValidate ()) { if (GetMandatoryTableValidate ()) {
ArmSbbrResetTableCounts (); ArmSbbrResetTableCounts ();
} }
#endif
#endif
// The RSDP length is 4 bytes starting at offset 20 // The RSDP length is 4 bytes starting at offset 20
RsdpLength = *(UINT32*)(RsdpPtr + RSDP_LENGTH_OFFSET); RsdpLength = *(UINT32 *)(RsdpPtr + RSDP_LENGTH_OFFSET);
Trace = ProcessTableReportOptions (RSDP_TABLE_INFO, RsdpPtr, RsdpLength); Trace = ProcessTableReportOptions (RSDP_TABLE_INFO, RsdpPtr, RsdpLength);
@ -265,7 +276,6 @@ AcpiView (
RsdpLength, RsdpLength,
RsdpRevision RsdpRevision
); );
} else { } else {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -274,20 +284,23 @@ AcpiView (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (GetMandatoryTableValidate ()) { if (GetMandatoryTableValidate ()) {
ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ()); ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ());
} }
#endif
#endif
ReportOption = GetReportOption (); ReportOption = GetReportOption ();
if (ReportTableList != ReportOption) { if (ReportTableList != ReportOption) {
if (((ReportSelected == ReportOption) || if (((ReportSelected == ReportOption) ||
(ReportDumpBinFile == ReportOption)) && (ReportDumpBinFile == ReportOption)) &&
(!SelectedTable->Found)) { (!SelectedTable->Found))
{
Print (L"\nRequested ACPI Table not found.\n"); Print (L"\nRequested ACPI Table not found.\n");
} else if (GetConsistencyChecking () && } else if (GetConsistencyChecking () &&
(ReportDumpBinFile != ReportOption)) { (ReportDumpBinFile != ReportOption))
{
OriginalAttribute = gST->ConOut->Mode->Attribute; OriginalAttribute = gST->ConOut->Mode->Attribute;
Print (L"\nTable Statistics:\n"); Print (L"\nTable Statistics:\n");
@ -301,6 +314,7 @@ AcpiView (
OriginalAttribute; OriginalAttribute;
gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
} }
Print (L"\t%d Error(s)\n", GetErrorCount ()); Print (L"\t%d Error(s)\n", GetErrorCount ());
if (GetColourHighlighting ()) { if (GetColourHighlighting ()) {
@ -313,6 +327,7 @@ AcpiView (
gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
} }
Print (L"\t%d Warning(s)\n", GetWarningCount ()); Print (L"\t%d Warning(s)\n", GetWarningCount ());
if (GetColourHighlighting ()) { if (GetColourHighlighting ()) {
@ -320,5 +335,6 @@ AcpiView (
} }
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -71,7 +71,7 @@ GetWarningCount (
BOOLEAN BOOLEAN
ProcessTableReportOptions ( ProcessTableReportOptions (
IN CONST UINT32 Signature, IN CONST UINT32 Signature,
IN CONST UINT8* TablePtr, IN CONST UINT8 *TablePtr,
IN CONST UINT32 Length IN CONST UINT32 Length
); );
@ -88,7 +88,7 @@ ProcessTableReportOptions (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AcpiView ( AcpiView (
IN EFI_SYSTEM_TABLE* SystemTable IN EFI_SYSTEM_TABLE *SystemTable
); );
#endif // ACPIVIEW_H_ #endif // ACPIVIEW_H_

View File

@ -60,14 +60,16 @@ ConvertStrToAcpiSignature (
// Convert to Upper case and convert to ASCII // Convert to Upper case and convert to ASCII
while ((Index < 4) && (Str[Index] != 0)) { 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')); Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
} else { } else {
Ptr[Index] = (CHAR8)Str[Index]; Ptr[Index] = (CHAR8)Str[Index];
} }
Index++; Index++;
} }
return *(UINT32 *) Ptr;
return *(UINT32 *)Ptr;
} }
/** /**

View File

@ -137,7 +137,7 @@ SetReportOption (
**/ **/
typedef struct { typedef struct {
UINT32 Type; ///< 32bit signature of the selected ACPI table. UINT32 Type; ///< 32bit signature of the selected ACPI table.
CONST CHAR16* Name; ///< User friendly name of the selected ACPI table. CONST CHAR16 *Name; ///< User friendly name of the selected ACPI table.
BOOLEAN Found; ///< The selected table has been found in the system. BOOLEAN Found; ///< The selected table has been found in the system.
} SELECTED_ACPI_TABLE; } SELECTED_ACPI_TABLE;
@ -149,7 +149,7 @@ typedef struct {
VOID VOID
EFIAPI EFIAPI
GetSelectedAcpiTable ( GetSelectedAcpiTable (
OUT SELECTED_ACPI_TABLE** SelectedAcpiTable OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
); );
/** /**
@ -162,7 +162,7 @@ GetSelectedAcpiTable (
VOID VOID
EFIAPI EFIAPI
SelectAcpiTable ( SelectAcpiTable (
CONST CHAR16* TableName CONST CHAR16 *TableName
); );
/** /**

View File

@ -23,7 +23,7 @@
/** /**
SBBR specification version strings SBBR specification version strings
**/ **/
STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] = { STATIC CONST CHAR8 *ArmSbbrVersions[ArmSbbrVersionMax] = {
"1.0", // ArmSbbrVersion_1_0 "1.0", // ArmSbbrVersion_1_0
"1.1", // ArmSbbrVersion_1_1 "1.1", // ArmSbbrVersion_1_1
"1.2" // ArmSbbrVersion_1_2 "1.2" // ArmSbbrVersion_1_2
@ -85,15 +85,15 @@ STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = {
defined as 'mandatory' in any SBBR version. defined as 'mandatory' in any SBBR version.
**/ **/
STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = { STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = {
{EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, 0}, { EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, 0 },
{EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0} { EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0 }
}; };
/** /**
@ -160,7 +160,7 @@ ArmSbbrReqsValidate (
UINT32 Table; UINT32 Table;
UINT32 Index; UINT32 Index;
UINT32 MandatoryTable; UINT32 MandatoryTable;
CONST UINT8* SignaturePtr; CONST UINT8 *SignaturePtr;
BOOLEAN IsArmSbbrViolated; BOOLEAN IsArmSbbrViolated;
if (Version >= ArmSbbrVersionMax) { if (Version >= ArmSbbrVersionMax) {
@ -172,12 +172,13 @@ ArmSbbrReqsValidate (
// Go through the list of mandatory tables for the input SBBR version // Go through the list of mandatory tables for the input SBBR version
for (Table = 0; Table < ArmSbbrReqs[Version].TableCount; Table++) { for (Table = 0; Table < ArmSbbrReqs[Version].TableCount; Table++) {
MandatoryTable = ArmSbbrReqs[Version].Tables[Table]; MandatoryTable = ArmSbbrReqs[Version].Tables[Table];
SignaturePtr = (CONST UINT8*)(UINTN)&MandatoryTable; SignaturePtr = (CONST UINT8 *)(UINTN)&MandatoryTable;
// Locate the instance count for the table with the given signature // Locate the instance count for the table with the given signature
Index = 0; Index = 0;
while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) && while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) &&
(ArmSbbrTableCounts[Index].Signature != MandatoryTable)) { (ArmSbbrTableCounts[Index].Signature != MandatoryTable))
{
Index++; Index++;
} }

View File

@ -42,7 +42,7 @@ typedef struct AcpiTableCounter {
ACPI table SBBR requirements. ACPI table SBBR requirements.
**/ **/
typedef struct AcpiSbbrReq { typedef struct AcpiSbbrReq {
CONST UINT32* Tables; /// List of required tables CONST UINT32 *Tables; /// List of required tables
CONST UINT32 TableCount; /// Number of elements in Tables CONST UINT32 TableCount; /// Number of elements in Tables
} ACPI_SBBR_REQ; } ACPI_SBBR_REQ;

View File

@ -19,15 +19,15 @@
// Local variables // Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC UINT8* AestNodeType; STATIC UINT8 *AestNodeType;
STATIC UINT16* AestNodeLength; STATIC UINT16 *AestNodeLength;
STATIC UINT32* NodeDataOffset; STATIC UINT32 *NodeDataOffset;
STATIC UINT32* NodeInterfaceOffset; STATIC UINT32 *NodeInterfaceOffset;
STATIC UINT32* NodeInterruptArrayOffset; STATIC UINT32 *NodeInterruptArrayOffset;
STATIC UINT32* NodeInterruptCount; STATIC UINT32 *NodeInterruptCount;
STATIC UINT32* ProcessorId; STATIC UINT32 *ProcessorId;
STATIC UINT8* ProcessorFlags; STATIC UINT8 *ProcessorFlags;
STATIC UINT8* ProcessorResourceType; STATIC UINT8 *ProcessorResourceType;
/** /**
Validate Processor Flags. Validate Processor Flags.
@ -40,16 +40,18 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateProcessorFlags ( ValidateProcessorFlags (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// If the global or shared node flag is set then the ACPI Processor ID // If the global or shared node flag is set then the ACPI Processor ID
// field must be set to 0 and ignored. // field must be set to 0 and ignored.
if (((*Ptr & 0x3) != 0) && (*ProcessorId != 0)) { if (((*Ptr & 0x3) != 0) && (*ProcessorId != 0)) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global" Print (
L" or shared nodes."); L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
L" or shared nodes."
);
} }
} }
@ -64,13 +66,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateGicInterfaceType ( ValidateGicInterfaceType (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT32 GicInterfaceType; UINT32 GicInterfaceType;
GicInterfaceType = *(UINT32*)Ptr; GicInterfaceType = *(UINT32 *)Ptr;
if (GicInterfaceType > 3) { if (GicInterfaceType > 3) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nError: Invalid GIC Interface type %d", GicInterfaceType); Print (L"\nError: Invalid GIC Interface type %d", GicInterfaceType);
@ -88,8 +90,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateInterfaceType ( ValidateInterfaceType (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*Ptr > 1) { if (*Ptr > 1) {
@ -109,8 +111,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateInterruptType ( ValidateInterruptType (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*Ptr > 1) { if (*Ptr > 1) {
@ -130,8 +132,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateInterruptFlags ( ValidateInterruptFlags (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if ((*Ptr & 0xfe) != 0) { if ((*Ptr & 0xfe) != 0) {
@ -149,8 +151,8 @@ ValidateInterruptFlags (
VOID VOID
EFIAPI EFIAPI
DumpVendorSpecificData ( DumpVendorSpecificData (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
Print ( Print (
@ -191,19 +193,19 @@ STATIC CONST ACPI_PARSER AestParser[] = {
An ACPI_PARSER array describing the AEST Node Header. An ACPI_PARSER array describing the AEST Node Header.
**/ **/
STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = { STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
{L"Type", 1, 0, L"%d", NULL, (VOID**)&AestNodeType, NULL, NULL}, { L"Type", 1, 0, L"%d", NULL, (VOID **)&AestNodeType, NULL, NULL },
{L"Length", 2, 1, L"%d", NULL, (VOID**)&AestNodeLength, NULL, NULL}, { L"Length", 2, 1, L"%d", NULL, (VOID **)&AestNodeLength, NULL, NULL },
{L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{L"Node Data Offset", 4, 4, L"%d", NULL, (VOID**)&NodeDataOffset, NULL, NULL}, { L"Node Data Offset", 4, 4, L"%d", NULL, (VOID **)&NodeDataOffset, NULL, NULL },
{L"Node Interface Offset", 4, 8, L"%d", NULL, { L"Node Interface Offset", 4, 8, L"%d", NULL,
(VOID**)&NodeInterfaceOffset, NULL, NULL}, (VOID **)&NodeInterfaceOffset, NULL, NULL },
{L"Node Interrupt Array Offset", 4, 12, L"%d", NULL, { L"Node Interrupt Array Offset", 4, 12, L"%d", NULL,
(VOID**)&NodeInterruptArrayOffset, NULL, NULL}, (VOID **)&NodeInterruptArrayOffset, NULL, NULL },
{L"Node Interrupt Count", 4, 16, L"%d", NULL, { L"Node Interrupt Count", 4, 16, L"%d", NULL,
(VOID**)&NodeInterruptCount, NULL, NULL}, (VOID **)&NodeInterruptCount, NULL, NULL },
{L"Timestamp Rate", 8, 20, L"%ld", NULL, NULL, NULL, NULL}, { L"Timestamp Rate", 8, 20, L"%ld", NULL, NULL, NULL, NULL },
{L"Reserved1", 8, 28, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Reserved1", 8, 28, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Error Injection Countdown Rate", 8, 36, L"%ld", NULL, NULL, NULL, NULL} { L"Error Injection Countdown Rate", 8, 36, L"%ld", NULL, NULL, NULL, NULL }
// Node specific data... // Node specific data...
// Node interface... // Node interface...
// Node interrupt array... // Node interrupt array...
@ -213,15 +215,15 @@ STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
An ACPI_PARSER array describing the Processor error node specific data. An ACPI_PARSER array describing the Processor error node specific data.
**/ **/
STATIC CONST ACPI_PARSER AestProcessorStructure[] = { STATIC CONST ACPI_PARSER AestProcessorStructure[] = {
{L"ACPI Processor ID", 4, 0, L"0x%x", NULL, (VOID**)&ProcessorId, NULL, NULL}, { L"ACPI Processor ID", 4, 0, L"0x%x", NULL, (VOID **)&ProcessorId, NULL, NULL },
{L"Resource Type", 1, 4, L"%d", NULL, (VOID**)&ProcessorResourceType, NULL, { L"Resource Type", 1, 4, L"%d", NULL, (VOID **)&ProcessorResourceType, NULL,
NULL}, NULL },
{L"Reserved", 1, 5, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 5, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 1, 6, L"0x%x", NULL, (VOID**)&ProcessorFlags, { L"Flags", 1, 6, L"0x%x", NULL, (VOID **)&ProcessorFlags,
ValidateProcessorFlags, NULL}, ValidateProcessorFlags, NULL },
{L"Revision", 1, 7, L"%d", NULL, NULL, NULL, NULL}, { L"Revision", 1, 7, L"%d", NULL, NULL, NULL, NULL },
{L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL, NULL, { L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL, NULL,
NULL}, NULL },
// Resource specific data... // Resource specific data...
}; };
@ -229,83 +231,83 @@ STATIC CONST ACPI_PARSER AestProcessorStructure[] = {
An ACPI_PARSER array describing the processor cache resource substructure. An ACPI_PARSER array describing the processor cache resource substructure.
**/ **/
STATIC CONST ACPI_PARSER AestProcessorCacheResourceSubstructure[] = { STATIC CONST ACPI_PARSER AestProcessorCacheResourceSubstructure[] = {
{L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL} { L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the processor TLB resource substructure. An ACPI_PARSER array describing the processor TLB resource substructure.
**/ **/
STATIC CONST ACPI_PARSER AestProcessorTlbResourceSubstructure[] = { STATIC CONST ACPI_PARSER AestProcessorTlbResourceSubstructure[] = {
{L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL} { L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the processor generic resource substructure. An ACPI_PARSER array describing the processor generic resource substructure.
**/ **/
STATIC CONST ACPI_PARSER AestProcessorGenericResourceSubstructure[] = { STATIC CONST ACPI_PARSER AestProcessorGenericResourceSubstructure[] = {
{L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL} { L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the memory controller structure. An ACPI_PARSER array describing the memory controller structure.
**/ **/
STATIC CONST ACPI_PARSER AestMemoryControllerStructure[] = { STATIC CONST ACPI_PARSER AestMemoryControllerStructure[] = {
{L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL} { L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the SMMU structure. An ACPI_PARSER array describing the SMMU structure.
**/ **/
STATIC CONST ACPI_PARSER AestSmmuStructure[] = { STATIC CONST ACPI_PARSER AestSmmuStructure[] = {
{L"IORT Node reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"IORT Node reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"SubComponent reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL} { L"SubComponent reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the vendor-defined structure. An ACPI_PARSER array describing the vendor-defined structure.
**/ **/
STATIC CONST ACPI_PARSER AestVendorDefinedStructure[] = { STATIC CONST ACPI_PARSER AestVendorDefinedStructure[] = {
{L"Hardware ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Hardware ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Unique ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Unique ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Vendor-specific data", 16, 8, NULL, DumpVendorSpecificData, NULL, NULL} { L"Vendor-specific data", 16, 8, NULL, DumpVendorSpecificData, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GIC structure. An ACPI_PARSER array describing the GIC structure.
**/ **/
STATIC CONST ACPI_PARSER AestGicStructure[] = { STATIC CONST ACPI_PARSER AestGicStructure[] = {
{L"GIC Interface Type", 4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType, { L"GIC Interface Type", 4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType,
NULL}, NULL },
{L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL} { L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
}; };
/** /**
An ACPI_PARSER array describing the node interface. An ACPI_PARSER array describing the node interface.
**/ **/
STATIC CONST ACPI_PARSER AestNodeInterface[] = { STATIC CONST ACPI_PARSER AestNodeInterface[] = {
{L"Interface Type", 1, 0, L"%d", NULL, NULL, ValidateInterfaceType, NULL}, { L"Interface Type", 1, 0, L"%d", NULL, NULL, ValidateInterfaceType, NULL },
{L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, { L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL },
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Start Error Record Index", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Start Error Record Index", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Number of Error Records", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Number of Error Records", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Error Records Implemented", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Error Records Implemented", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Error Records Support", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Error Records Support", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Addressing mode", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL} { L"Addressing mode", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the node interrupts. An ACPI_PARSER array describing the node interrupts.
**/ **/
STATIC CONST ACPI_PARSER AestNodeInterrupt[] = { STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
{L"Interrupt Type", 1, 0, L"%d", NULL, NULL, ValidateInterruptType, NULL}, { L"Interrupt Type", 1, 0, L"%d", NULL, NULL, ValidateInterruptType, NULL },
{L"Reserved", 2, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Interrupt Flags", 1, 3, L"0x%x", NULL, NULL, ValidateInterruptFlags, NULL}, { L"Interrupt Flags", 1, 3, L"0x%x", NULL, NULL, ValidateInterruptFlags, NULL },
{L"Interrupt GSIV", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Interrupt GSIV", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"ID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"ID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved1", 3, 9, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} { L"Reserved1", 3, 9, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
}; };
/** /**
@ -318,7 +320,7 @@ STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
STATIC STATIC
VOID VOID
DumpProcessorNode ( DumpProcessorNode (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -337,7 +339,8 @@ DumpProcessorNode (
// successfully read. // successfully read.
if ((ProcessorId == NULL) || if ((ProcessorId == NULL) ||
(ProcessorResourceType == NULL) || (ProcessorResourceType == NULL) ||
(ProcessorFlags == NULL)) { (ProcessorFlags == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient Processor Error Node length. Length = %d.\n", L"ERROR: Insufficient Processor Error Node length. Length = %d.\n",
@ -393,7 +396,7 @@ DumpProcessorNode (
STATIC STATIC
VOID VOID
DumpMemoryControllerNode ( DumpMemoryControllerNode (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -416,7 +419,7 @@ DumpMemoryControllerNode (
STATIC STATIC
VOID VOID
DumpSmmuNode ( DumpSmmuNode (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -439,7 +442,7 @@ DumpSmmuNode (
STATIC STATIC
VOID VOID
DumpVendorDefinedNode ( DumpVendorDefinedNode (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -462,7 +465,7 @@ DumpVendorDefinedNode (
STATIC STATIC
VOID VOID
DumpGicNode ( DumpGicNode (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -485,7 +488,7 @@ DumpGicNode (
STATIC STATIC
VOID VOID
DumpNodeInterface ( DumpNodeInterface (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -509,7 +512,7 @@ DumpNodeInterface (
STATIC STATIC
VOID VOID
DumpNodeInterrupts ( DumpNodeInterrupts (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length, IN UINT32 Length,
IN UINT32 InterruptCount IN UINT32 InterruptCount
) )
@ -521,7 +524,7 @@ DumpNodeInterrupts (
if (Length < (InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT))) { if (Length < (InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT))) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Node not long enough for Interrupt Array.\n"\ L"ERROR: Node not long enough for Interrupt Array.\n" \
L" Length left = %d, Required = %d, Interrupt Count = %d\n", L" Length left = %d, Required = %d, Interrupt Count = %d\n",
Length, Length,
(InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT)), (InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT)),
@ -547,7 +550,7 @@ DumpNodeInterrupts (
Length - Offset, Length - Offset,
PARSER_PARAMS (AestNodeInterrupt) PARSER_PARAMS (AestNodeInterrupt)
); );
} //for } // for
} }
/** /**
@ -564,7 +567,7 @@ DumpNodeInterrupts (
STATIC STATIC
VOID VOID
DumpAestNodeStructure ( DumpAestNodeStructure (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length, IN UINT32 Length,
IN UINT8 NodeType, IN UINT8 NodeType,
IN UINT32 DataOffset, IN UINT32 DataOffset,
@ -575,7 +578,7 @@ DumpAestNodeStructure (
{ {
UINT32 Offset; UINT32 Offset;
UINT32 RemainingLength; UINT32 RemainingLength;
UINT8* NodeDataPtr; UINT8 *NodeDataPtr;
Offset = ParseAcpi ( Offset = ParseAcpi (
TRUE, TRUE,
@ -589,7 +592,7 @@ DumpAestNodeStructure (
if ((Offset > DataOffset) || (DataOffset > Length)) { if ((Offset > DataOffset) || (DataOffset > Length)) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Node Data Offset: %d.\n"\ L"ERROR: Invalid Node Data Offset: %d.\n" \
L" It should be between %d and %d.\n", L" It should be between %d and %d.\n",
DataOffset, DataOffset,
Offset, Offset,
@ -600,7 +603,7 @@ DumpAestNodeStructure (
if ((Offset > InterfaceOffset) || (InterfaceOffset > Length)) { if ((Offset > InterfaceOffset) || (InterfaceOffset > Length)) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Node Interface Offset: %d.\n"\ L"ERROR: Invalid Node Interface Offset: %d.\n" \
L" It should be between %d and %d.\n", L" It should be between %d and %d.\n",
InterfaceOffset, InterfaceOffset,
Offset, Offset,
@ -611,7 +614,7 @@ DumpAestNodeStructure (
if ((Offset > InterruptArrayOffset) || (InterruptArrayOffset > Length)) { if ((Offset > InterruptArrayOffset) || (InterruptArrayOffset > Length)) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Node Interrupt Array Offset: %d.\n"\ L"ERROR: Invalid Node Interrupt Array Offset: %d.\n" \
L" It should be between %d and %d.\n", L" It should be between %d and %d.\n",
InterruptArrayOffset, InterruptArrayOffset,
Offset, Offset,
@ -676,13 +679,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiAest ( ParseAcpiAest (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* NodePtr; UINT8 *NodePtr;
if (!Trace) { if (!Trace) {
return; return;
@ -716,10 +719,11 @@ ParseAcpiAest (
(NodeDataOffset == NULL) || (NodeDataOffset == NULL) ||
(NodeInterfaceOffset == NULL) || (NodeInterfaceOffset == NULL) ||
(NodeInterruptArrayOffset == NULL) || (NodeInterruptArrayOffset == NULL) ||
(NodeInterruptCount == NULL)) { (NodeInterruptCount == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient length left for Node Structure.\n"\ L"ERROR: Insufficient length left for Node Structure.\n" \
L" Length left = %d.\n", L" Length left = %d.\n",
AcpiTableLength - Offset AcpiTableLength - Offset
); );
@ -728,7 +732,8 @@ ParseAcpiAest (
// Validate AEST Node length // Validate AEST Node length
if ((*AestNodeLength == 0) || if ((*AestNodeLength == 0) ||
((Offset + (*AestNodeLength)) > AcpiTableLength)) { ((Offset + (*AestNodeLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid AEST Node length. " \ L"ERROR: Invalid AEST Node length. " \

View File

@ -21,12 +21,12 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
**/ **/
STATIC CONST ACPI_PARSER BgrtParser[] = { STATIC CONST ACPI_PARSER BgrtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Version", 2, 36, L"0x%x", NULL, NULL, NULL, NULL}, { L"Version", 2, 36, L"0x%x", NULL, NULL, NULL, NULL },
{L"Status", 1, 38, L"0x%x", NULL, NULL, NULL, NULL}, { L"Status", 1, 38, L"0x%x", NULL, NULL, NULL, NULL },
{L"Image Type", 1, 39, L"0x%x", NULL, NULL, NULL, NULL}, { L"Image Type", 1, 39, L"0x%x", NULL, NULL, NULL, NULL },
{L"Image Address", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Image Address", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Image Offset X", 4, 48, L"%d", NULL, NULL, NULL, NULL}, { L"Image Offset X", 4, 48, L"%d", NULL, NULL, NULL, NULL },
{L"Image Offset Y", 4, 52, L"%d", NULL, NULL, NULL, NULL} { L"Image Offset Y", 4, 52, L"%d", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -45,7 +45,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiBgrt ( ParseAcpiBgrt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )

View File

@ -14,16 +14,16 @@
#include "AcpiTableParser.h" #include "AcpiTableParser.h"
// Local variables pointing to the table fields // Local variables pointing to the table fields
STATIC CONST UINT32* OffsetDbgDeviceInfo; STATIC CONST UINT32 *OffsetDbgDeviceInfo;
STATIC CONST UINT32* NumberDbgDeviceInfo; STATIC CONST UINT32 *NumberDbgDeviceInfo;
STATIC CONST UINT16* DbgDevInfoLen; STATIC CONST UINT16 *DbgDevInfoLen;
STATIC CONST UINT8* GasCount; STATIC CONST UINT8 *GasCount;
STATIC CONST UINT16* NameSpaceStringLength; STATIC CONST UINT16 *NameSpaceStringLength;
STATIC CONST UINT16* NameSpaceStringOffset; STATIC CONST UINT16 *NameSpaceStringOffset;
STATIC CONST UINT16* OEMDataLength; STATIC CONST UINT16 *OEMDataLength;
STATIC CONST UINT16* OEMDataOffset; STATIC CONST UINT16 *OEMDataOffset;
STATIC CONST UINT16* BaseAddrRegOffset; STATIC CONST UINT16 *BaseAddrRegOffset;
STATIC CONST UINT16* AddrSizeOffset; STATIC CONST UINT16 *AddrSizeOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -37,13 +37,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateNameSpaceStrLen ( ValidateNameSpaceStrLen (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT16 NameSpaceStrLen; UINT16 NameSpaceStrLen;
NameSpaceStrLen = *(UINT16*)Ptr; NameSpaceStrLen = *(UINT16 *)Ptr;
if (NameSpaceStrLen < 2) { if (NameSpaceStrLen < 2) {
IncrementErrorCount (); IncrementErrorCount ();
@ -58,43 +58,43 @@ ValidateNameSpaceStrLen (
/// An ACPI_PARSER array describing the ACPI DBG2 table. /// An ACPI_PARSER array describing the ACPI DBG2 table.
STATIC CONST ACPI_PARSER Dbg2Parser[] = { STATIC CONST ACPI_PARSER Dbg2Parser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"OffsetDbgDeviceInfo", 4, 36, L"0x%x", NULL, { L"OffsetDbgDeviceInfo", 4, 36, L"0x%x", NULL,
(VOID**)&OffsetDbgDeviceInfo, NULL, NULL}, (VOID **)&OffsetDbgDeviceInfo, NULL, NULL },
{L"NumberDbgDeviceInfo", 4, 40, L"%d", NULL, { L"NumberDbgDeviceInfo", 4, 40, L"%d", NULL,
(VOID**)&NumberDbgDeviceInfo, NULL, NULL} (VOID **)&NumberDbgDeviceInfo, NULL, NULL }
}; };
/// An ACPI_PARSER array describing the debug device information structure /// An ACPI_PARSER array describing the debug device information structure
/// header. /// header.
STATIC CONST ACPI_PARSER DbgDevInfoHeaderParser[] = { STATIC CONST ACPI_PARSER DbgDevInfoHeaderParser[] = {
{L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 2, 1, L"%d", NULL, (VOID**)&DbgDevInfoLen, NULL, NULL} { L"Length", 2, 1, L"%d", NULL, (VOID **)&DbgDevInfoLen, NULL, NULL }
}; };
/// An ACPI_PARSER array describing the debug device information. /// An ACPI_PARSER array describing the debug device information.
STATIC CONST ACPI_PARSER DbgDevInfoParser[] = { STATIC CONST ACPI_PARSER DbgDevInfoParser[] = {
{L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Generic Address Registers Count", 1, 3, L"0x%x", NULL, { L"Generic Address Registers Count", 1, 3, L"0x%x", NULL,
(VOID**)&GasCount, NULL, NULL}, (VOID **)&GasCount, NULL, NULL },
{L"NameSpace String Length", 2, 4, L"%d", NULL, { L"NameSpace String Length", 2, 4, L"%d", NULL,
(VOID**)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL}, (VOID **)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL },
{L"NameSpace String Offset", 2, 6, L"0x%x", NULL, { L"NameSpace String Offset", 2, 6, L"0x%x", NULL,
(VOID**)&NameSpaceStringOffset, NULL, NULL}, (VOID **)&NameSpaceStringOffset, NULL, NULL },
{L"OEM Data Length", 2, 8, L"%d", NULL, (VOID**)&OEMDataLength, { L"OEM Data Length", 2, 8, L"%d", NULL, (VOID **)&OEMDataLength,
NULL, NULL}, NULL, NULL },
{L"OEM Data Offset", 2, 10, L"0x%x", NULL, (VOID**)&OEMDataOffset, { L"OEM Data Offset", 2, 10, L"0x%x", NULL, (VOID **)&OEMDataOffset,
NULL, NULL}, NULL, NULL },
{L"Port Type", 2, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Port Type", 2, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Port SubType", 2, 14, L"0x%x", NULL, NULL, NULL, NULL}, { L"Port SubType", 2, 14, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 16, L"%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 16, L"%x", NULL, NULL, NULL, NULL },
{L"Base Address Register Offset", 2, 18, L"0x%x", NULL, { L"Base Address Register Offset", 2, 18, L"0x%x", NULL,
(VOID**)&BaseAddrRegOffset, NULL, NULL}, (VOID **)&BaseAddrRegOffset, NULL, NULL },
{L"Address Size Offset", 2, 20, L"0x%x", NULL, { L"Address Size Offset", 2, 20, L"0x%x", NULL,
(VOID**)&AddrSizeOffset, NULL, NULL} (VOID **)&AddrSizeOffset, NULL, NULL }
}; };
/** /**
@ -107,7 +107,7 @@ STATIC
VOID VOID
EFIAPI EFIAPI
DumpDbgDeviceInfo ( DumpDbgDeviceInfo (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length IN UINT16 Length
) )
{ {
@ -131,7 +131,8 @@ DumpDbgDeviceInfo (
(OEMDataLength == NULL) || (OEMDataLength == NULL) ||
(OEMDataOffset == NULL) || (OEMDataOffset == NULL) ||
(BaseAddrRegOffset == NULL) || (BaseAddrRegOffset == NULL) ||
(AddrSizeOffset == NULL)) { (AddrSizeOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient Debug Device Information Structure length. " \ L"ERROR: Insufficient Debug Device Information Structure length. " \
@ -145,7 +146,8 @@ DumpDbgDeviceInfo (
Index = 0; Index = 0;
Offset = *BaseAddrRegOffset; Offset = *BaseAddrRegOffset;
while ((Index++ < *GasCount) && while ((Index++ < *GasCount) &&
(Offset < Length)) { (Offset < Length))
{
PrintFieldName (4, L"BaseAddressRegister"); PrintFieldName (4, L"BaseAddressRegister");
Offset += (UINT16)DumpGasStruct ( Offset += (UINT16)DumpGasStruct (
Ptr + Offset, Ptr + Offset,
@ -171,9 +173,10 @@ DumpDbgDeviceInfo (
Index = 0; Index = 0;
Offset = *AddrSizeOffset; Offset = *AddrSizeOffset;
while ((Index++ < *GasCount) && while ((Index++ < *GasCount) &&
(Offset < Length)) { (Offset < Length))
{
PrintFieldName (4, L"Address Size"); PrintFieldName (4, L"Address Size");
Print (L"0x%x\n", *((UINT32*)(Ptr + Offset))); Print (L"0x%x\n", *((UINT32 *)(Ptr + Offset)));
Offset += sizeof (UINT32); Offset += sizeof (UINT32);
} }
@ -182,10 +185,12 @@ DumpDbgDeviceInfo (
Offset = *NameSpaceStringOffset; Offset = *NameSpaceStringOffset;
PrintFieldName (4, L"NameSpace String"); PrintFieldName (4, L"NameSpace String");
while ((Index++ < *NameSpaceStringLength) && while ((Index++ < *NameSpaceStringLength) &&
(Offset < Length)) { (Offset < Length))
{
Print (L"%c", *(Ptr + Offset)); Print (L"%c", *(Ptr + Offset));
Offset++; Offset++;
} }
Print (L"\n"); Print (L"\n");
// OEM Data // OEM Data
@ -194,13 +199,16 @@ DumpDbgDeviceInfo (
Offset = *OEMDataOffset; Offset = *OEMDataOffset;
PrintFieldName (4, L"OEM Data"); PrintFieldName (4, L"OEM Data");
while ((Index++ < *OEMDataLength) && while ((Index++ < *OEMDataLength) &&
(Offset < Length)) { (Offset < Length))
{
Print (L"%x ", *(Ptr + Offset)); Print (L"%x ", *(Ptr + Offset));
if ((Index & 7) == 0) { if ((Index & 7) == 0) {
Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L""); Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L"");
} }
Offset++; Offset++;
} }
Print (L"\n"); Print (L"\n");
} }
} }
@ -221,7 +229,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiDbg2 ( ParseAcpiDbg2 (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
@ -245,7 +253,8 @@ ParseAcpiDbg2 (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((OffsetDbgDeviceInfo == NULL) || if ((OffsetDbgDeviceInfo == NULL) ||
(NumberDbgDeviceInfo == NULL)) { (NumberDbgDeviceInfo == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d\n", L"ERROR: Insufficient table length. AcpiTableLength = %d\n",
@ -258,7 +267,6 @@ ParseAcpiDbg2 (
Index = 0; Index = 0;
while (Index++ < *NumberDbgDeviceInfo) { while (Index++ < *NumberDbgDeviceInfo) {
// Parse the Debug Device Information Structure header to obtain Length // Parse the Debug Device Information Structure header to obtain Length
ParseAcpi ( ParseAcpi (
FALSE, FALSE,
@ -284,7 +292,8 @@ ParseAcpiDbg2 (
// Validate Debug Device Information Structure length // Validate Debug Device Information Structure length
if ((*DbgDevInfoLen == 0) || if ((*DbgDevInfoLen == 0) ||
((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) { ((Offset + (*DbgDevInfoLen)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Debug Device Information Structure length. " \ L"ERROR: Invalid Debug Device Information Structure length. " \

View File

@ -29,7 +29,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiDsdt ( ParseAcpiDsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )

View File

@ -17,22 +17,22 @@
An ACPI_PARSER array describing the ACPI FACS Table. An ACPI_PARSER array describing the ACPI FACS Table.
**/ **/
STATIC CONST ACPI_PARSER FacsParser[] = { STATIC CONST ACPI_PARSER FacsParser[] = {
{L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, NULL, NULL, NULL}, { L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, NULL, NULL, NULL },
{L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL },
{L"Hardware Signature", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Hardware Signature", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Firmware Waking Vector", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Firmware Waking Vector", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Global Lock", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Global Lock", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"X Firmware Walking Vector", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, { L"X Firmware Walking Vector", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Version", 1, 32, L"%d", NULL, NULL, NULL, NULL}, { L"Version", 1, 32, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, { L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL },
{L"OSPM Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL}, { L"OSPM Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, { L"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL}, NULL },
{L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, { L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL}, NULL },
{L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, { L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL} NULL }
}; };
/** /**
@ -51,7 +51,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiFacs ( ParseAcpiFacs (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )

View File

@ -15,12 +15,12 @@
#include "AcpiView.h" #include "AcpiView.h"
// Local variables // Local variables
STATIC CONST UINT32* DsdtAddress; STATIC CONST UINT32 *DsdtAddress;
STATIC CONST UINT64* X_DsdtAddress; STATIC CONST UINT64 *X_DsdtAddress;
STATIC CONST UINT32* Flags; STATIC CONST UINT32 *Flags;
STATIC CONST UINT32* FirmwareCtrl; STATIC CONST UINT32 *FirmwareCtrl;
STATIC CONST UINT64* X_FirmwareCtrl; STATIC CONST UINT64 *X_FirmwareCtrl;
STATIC CONST UINT8* FadtMinorRevision; STATIC CONST UINT8 *FadtMinorRevision;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -63,18 +63,19 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateFirmwareCtrl ( ValidateFirmwareCtrl (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT32*)Ptr != 0) { if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: Firmware Control must be zero for ARM platforms." L"\nERROR: Firmware Control must be zero for ARM platforms."
); );
} }
#endif
#endif
} }
/** /**
@ -88,18 +89,19 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateXFirmwareCtrl ( ValidateXFirmwareCtrl (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT64*)Ptr != 0) { if (*(UINT64 *)Ptr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: X Firmware Control must be zero for ARM platforms." L"\nERROR: X Firmware Control must be zero for ARM platforms."
); );
} }
#endif
#endif
} }
/** /**
@ -113,18 +115,19 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateFlags ( ValidateFlags (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) == 0) { if (((*(UINT32 *)Ptr) & HW_REDUCED_ACPI) == 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms." L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms."
); );
} }
#endif
#endif
} }
/** /**
@ -132,64 +135,64 @@ ValidateFlags (
**/ **/
STATIC CONST ACPI_PARSER FadtParser[] = { STATIC CONST ACPI_PARSER FadtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID**)&FirmwareCtrl, { L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID **)&FirmwareCtrl,
ValidateFirmwareCtrl, NULL}, ValidateFirmwareCtrl, NULL },
{L"DSDT", 4, 40, L"0x%x", NULL, (VOID**)&DsdtAddress, NULL, NULL}, { L"DSDT", 4, 40, L"0x%x", NULL, (VOID **)&DsdtAddress, NULL, NULL },
{L"Reserved", 1, 44, L"%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 44, L"%x", NULL, NULL, NULL, NULL },
{L"Preferred_PM_Profile", 1, 45, L"0x%x", NULL, NULL, NULL, NULL}, { L"Preferred_PM_Profile", 1, 45, L"0x%x", NULL, NULL, NULL, NULL },
{L"SCI_INT", 2, 46, L"0x%x", NULL, NULL, NULL, NULL}, { L"SCI_INT", 2, 46, L"0x%x", NULL, NULL, NULL, NULL },
{L"SMI_CMD", 4, 48, L"0x%x", NULL, NULL, NULL, NULL}, { L"SMI_CMD", 4, 48, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI_ENABLE", 1, 52, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI_ENABLE", 1, 52, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI_DISABLE", 1, 53, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI_DISABLE", 1, 53, L"0x%x", NULL, NULL, NULL, NULL },
{L"S4BIOS_REQ", 1, 54, L"0x%x", NULL, NULL, NULL, NULL}, { L"S4BIOS_REQ", 1, 54, L"0x%x", NULL, NULL, NULL, NULL },
{L"PSTATE_CNT", 1, 55, L"0x%x", NULL, NULL, NULL, NULL}, { L"PSTATE_CNT", 1, 55, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1a_EVT_BLK", 4, 56, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1a_EVT_BLK", 4, 56, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1b_EVT_BLK", 4, 60, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1b_EVT_BLK", 4, 60, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1a_CNT_BLK", 4, 64, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1a_CNT_BLK", 4, 64, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1b_CNT_BLK", 4, 68, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1b_CNT_BLK", 4, 68, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM2_CNT_BLK", 4, 72, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM2_CNT_BLK", 4, 72, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM_TMR_BLK", 4, 76, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM_TMR_BLK", 4, 76, L"0x%x", NULL, NULL, NULL, NULL },
{L"GPE0_BLK", 4, 80, L"0x%x", NULL, NULL, NULL, NULL}, { L"GPE0_BLK", 4, 80, L"0x%x", NULL, NULL, NULL, NULL },
{L"GPE1_BLK", 4, 84, L"0x%x", NULL, NULL, NULL, NULL}, { L"GPE1_BLK", 4, 84, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1_EVT_LEN", 1, 88, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1_EVT_LEN", 1, 88, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM1_CNT_LEN", 1, 89, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM1_CNT_LEN", 1, 89, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM2_CNT_LEN", 1, 90, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM2_CNT_LEN", 1, 90, L"0x%x", NULL, NULL, NULL, NULL },
{L"PM_TMR_LEN", 1, 91, L"0x%x", NULL, NULL, NULL, NULL}, { L"PM_TMR_LEN", 1, 91, L"0x%x", NULL, NULL, NULL, NULL },
{L"GPE0_BLK_LEN", 1, 92, L"0x%x", NULL, NULL, NULL, NULL}, { L"GPE0_BLK_LEN", 1, 92, L"0x%x", NULL, NULL, NULL, NULL },
{L"GPE1_BLK_LEN", 1, 93, L"0x%x", NULL, NULL, NULL, NULL}, { L"GPE1_BLK_LEN", 1, 93, L"0x%x", NULL, NULL, NULL, NULL },
{L"GPE1_BASE", 1, 94, L"0x%x", NULL, NULL, NULL, NULL}, { L"GPE1_BASE", 1, 94, L"0x%x", NULL, NULL, NULL, NULL },
{L"CST_CNT", 1, 95, L"0x%x", NULL, NULL, NULL, NULL}, { L"CST_CNT", 1, 95, L"0x%x", NULL, NULL, NULL, NULL },
{L"P_LVL2_LAT", 2, 96, L"0x%x", NULL, NULL, NULL, NULL}, { L"P_LVL2_LAT", 2, 96, L"0x%x", NULL, NULL, NULL, NULL },
{L"P_LVL3_LAT", 2, 98, L"0x%x", NULL, NULL, NULL, NULL}, { L"P_LVL3_LAT", 2, 98, L"0x%x", NULL, NULL, NULL, NULL },
{L"FLUSH_SIZE", 2, 100, L"0x%x", NULL, NULL, NULL, NULL}, { L"FLUSH_SIZE", 2, 100, L"0x%x", NULL, NULL, NULL, NULL },
{L"FLUSH_STRIDE", 2, 102, L"0x%x", NULL, NULL, NULL, NULL}, { L"FLUSH_STRIDE", 2, 102, L"0x%x", NULL, NULL, NULL, NULL },
{L"DUTY_OFFSET", 1, 104, L"0x%x", NULL, NULL, NULL, NULL}, { L"DUTY_OFFSET", 1, 104, L"0x%x", NULL, NULL, NULL, NULL },
{L"DUTY_WIDTH", 1, 105, L"0x%x", NULL, NULL, NULL, NULL}, { L"DUTY_WIDTH", 1, 105, L"0x%x", NULL, NULL, NULL, NULL },
{L"DAY_ALRM", 1, 106, L"0x%x", NULL, NULL, NULL, NULL}, { L"DAY_ALRM", 1, 106, L"0x%x", NULL, NULL, NULL, NULL },
{L"MON_ALRM", 1, 107, L"0x%x", NULL, NULL, NULL, NULL}, { L"MON_ALRM", 1, 107, L"0x%x", NULL, NULL, NULL, NULL },
{L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL}, { L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL },
{L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL}, { L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 112, L"0x%x", NULL, (VOID**)&Flags, ValidateFlags, NULL}, { L"Flags", 4, 112, L"0x%x", NULL, (VOID **)&Flags, ValidateFlags, NULL },
{L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL}, { L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL },
{L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL}, { L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL },
{L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL}, { L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL },
{L"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID**)&FadtMinorRevision, { L"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID **)&FadtMinorRevision,
NULL, NULL}, NULL, NULL },
{L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID**)&X_FirmwareCtrl, { L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID **)&X_FirmwareCtrl,
ValidateXFirmwareCtrl, NULL}, ValidateXFirmwareCtrl, NULL },
{L"X_DSDT", 8, 140, L"0x%lx", NULL, (VOID**)&X_DsdtAddress, NULL, NULL}, { L"X_DSDT", 8, 140, L"0x%lx", NULL, (VOID **)&X_DsdtAddress, NULL, NULL },
{L"X_PM1a_EVT_BLK", 12, 148, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM1a_EVT_BLK", 12, 148, NULL, DumpGas, NULL, NULL, NULL },
{L"X_PM1b_EVT_BLK", 12, 160, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM1b_EVT_BLK", 12, 160, NULL, DumpGas, NULL, NULL, NULL },
{L"X_PM1a_CNT_BLK", 12, 172, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM1a_CNT_BLK", 12, 172, NULL, DumpGas, NULL, NULL, NULL },
{L"X_PM1b_CNT_BLK", 12, 184, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM1b_CNT_BLK", 12, 184, NULL, DumpGas, NULL, NULL, NULL },
{L"X_PM2_CNT_BLK", 12, 196, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM2_CNT_BLK", 12, 196, NULL, DumpGas, NULL, NULL, NULL },
{L"X_PM_TMR_BLK", 12, 208, NULL, DumpGas, NULL, NULL, NULL}, { L"X_PM_TMR_BLK", 12, 208, NULL, DumpGas, NULL, NULL, NULL },
{L"X_GPE0_BLK", 12, 220, NULL, DumpGas, NULL, NULL, NULL}, { L"X_GPE0_BLK", 12, 220, NULL, DumpGas, NULL, NULL, NULL },
{L"X_GPE1_BLK", 12, 232, NULL, DumpGas, NULL, NULL, NULL}, { L"X_GPE1_BLK", 12, 232, NULL, DumpGas, NULL, NULL, NULL },
{L"SLEEP_CONTROL_REG", 12, 244, NULL, DumpGas, NULL, NULL, NULL}, { L"SLEEP_CONTROL_REG", 12, 244, NULL, DumpGas, NULL, NULL, NULL },
{L"SLEEP_STATUS_REG", 12, 256, NULL, DumpGas, NULL, NULL, NULL}, { L"SLEEP_STATUS_REG", 12, 256, NULL, DumpGas, NULL, NULL, NULL },
{L"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL} { L"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -207,14 +210,14 @@ VOID
EFIAPI EFIAPI
ParseAcpiFadt ( ParseAcpiFadt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT8* DsdtPtr; UINT8 *DsdtPtr;
UINT8* FirmwareCtrlPtr; UINT8 *FirmwareCtrlPtr;
UINT32 FacsSignature; UINT32 FacsSignature;
UINT32 FacsLength; UINT32 FacsLength;
UINT8 FacsRevision; UINT8 FacsRevision;
@ -245,9 +248,9 @@ ParseAcpiFadt (
// If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore
// FIRMWARE_CTRL, else use FIRMWARE_CTRL. // FIRMWARE_CTRL, else use FIRMWARE_CTRL.
if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) { if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) {
FirmwareCtrlPtr = (UINT8*)(UINTN)(*X_FirmwareCtrl); FirmwareCtrlPtr = (UINT8 *)(UINTN)(*X_FirmwareCtrl);
} else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) { } else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) {
FirmwareCtrlPtr = (UINT8*)(UINTN)(*FirmwareCtrl); FirmwareCtrlPtr = (UINT8 *)(UINTN)(*FirmwareCtrl);
} else { } else {
FirmwareCtrlPtr = NULL; FirmwareCtrlPtr = NULL;
// if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and // if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and
@ -255,10 +258,13 @@ ParseAcpiFadt (
// present. // present.
if ((Trace) && if ((Trace) &&
(Flags != NULL) && (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 (); IncrementErrorCount ();
Print (L"ERROR: No FACS table found, " Print (
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"); L"ERROR: No FACS table found, "
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"
);
} }
} }
@ -266,13 +272,13 @@ ParseAcpiFadt (
// The FACS table does not have a standard ACPI table header. Therefore, // The FACS table does not have a standard ACPI table header. Therefore,
// the signature, length and version needs to be initially parsed. // the signature, length and version needs to be initially parsed.
// The FACS signature is 4 bytes starting at offset 0. // The FACS signature is 4 bytes starting at offset 0.
FacsSignature = *(UINT32*)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET); FacsSignature = *(UINT32 *)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET);
// The FACS length is 4 bytes starting at offset 4. // The FACS length is 4 bytes starting at offset 4.
FacsLength = *(UINT32*)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET); FacsLength = *(UINT32 *)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
// The FACS version is 1 byte starting at offset 32. // The FACS version is 1 byte starting at offset 32.
FacsRevision = *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET); FacsRevision = *(UINT8 *)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
Trace = ProcessTableReportOptions ( Trace = ProcessTableReportOptions (
FacsSignature, FacsSignature,
@ -298,12 +304,12 @@ ParseAcpiFadt (
// If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT. // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) { if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress); DsdtPtr = (UINT8 *)(UINTN)(*X_DsdtAddress);
} else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) { } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress); DsdtPtr = (UINT8 *)(UINTN)(*DsdtAddress);
} else { } else {
// Both DSDT and X_DSDT cannot be invalid. // Both DSDT and X_DSDT cannot be invalid.
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (Trace) { if (Trace) {
// The DSDT Table is mandatory for ARM systems // The DSDT Table is mandatory for ARM systems
// as the CPU information MUST be presented in // as the CPU information MUST be presented in
@ -311,7 +317,8 @@ ParseAcpiFadt (
IncrementErrorCount (); IncrementErrorCount ();
Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n"); Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
} }
#endif
#endif
return; return;
} }

View File

@ -18,12 +18,12 @@
#define GT_BLOCK_TIMER_COUNT_MAX 8 #define GT_BLOCK_TIMER_COUNT_MAX 8
// Local variables // Local variables
STATIC CONST UINT32* GtdtPlatformTimerCount; STATIC CONST UINT32 *GtdtPlatformTimerCount;
STATIC CONST UINT32* GtdtPlatformTimerOffset; STATIC CONST UINT32 *GtdtPlatformTimerOffset;
STATIC CONST UINT8* PlatformTimerType; STATIC CONST UINT8 *PlatformTimerType;
STATIC CONST UINT16* PlatformTimerLength; STATIC CONST UINT16 *PlatformTimerLength;
STATIC CONST UINT32* GtBlockTimerCount; STATIC CONST UINT32 *GtBlockTimerCount;
STATIC CONST UINT32* GtBlockTimerOffset; STATIC CONST UINT32 *GtBlockTimerOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -37,13 +37,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateGtBlockTimerCount ( ValidateGtBlockTimerCount (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT32 BlockTimerCount; UINT32 BlockTimerCount;
BlockTimerCount = *(UINT32*)Ptr; BlockTimerCount = *(UINT32 *)Ptr;
if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) { if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) {
IncrementErrorCount (); IncrementErrorCount ();
@ -66,13 +66,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateGtFrameNumber ( ValidateGtFrameNumber (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT8 FrameNumber; UINT8 FrameNumber;
FrameNumber = *(UINT8*)Ptr; FrameNumber = *(UINT8 *)Ptr;
if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) { if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) {
IncrementErrorCount (); IncrementErrorCount ();
@ -89,80 +89,80 @@ ValidateGtFrameNumber (
**/ **/
STATIC CONST ACPI_PARSER GtdtParser[] = { STATIC CONST ACPI_PARSER GtdtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"CntControlBase Physical Address", 8, 36, L"0x%lx", NULL, NULL, { L"CntControlBase Physical Address",8, 36, L"0x%lx", NULL, NULL,
NULL, NULL}, NULL, NULL },
{L"Reserved", 4, 44, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 44, L"0x%x", NULL, NULL,NULL, NULL },
{L"Secure EL1 timer GSIV", 4, 48, L"0x%x", NULL, NULL, NULL, NULL}, { L"Secure EL1 timer GSIV", 4, 48, L"0x%x", NULL, NULL,NULL, NULL },
{L"Secure EL1 timer FLAGS", 4, 52, L"0x%x", NULL, NULL, NULL, NULL}, { L"Secure EL1 timer FLAGS", 4, 52, L"0x%x", NULL, NULL,NULL, NULL },
{L"Non-Secure EL1 timer GSIV", 4, 56, L"0x%x", NULL, NULL, NULL, NULL}, { L"Non-Secure EL1 timer GSIV", 4, 56, L"0x%x", NULL, NULL,NULL, NULL },
{L"Non-Secure EL1 timer FLAGS", 4, 60, L"0x%x", NULL, NULL, NULL, NULL}, { L"Non-Secure EL1 timer FLAGS", 4, 60, L"0x%x", NULL, NULL,NULL, NULL },
{L"Virtual timer GSIV", 4, 64, L"0x%x", NULL, NULL, NULL, NULL}, { L"Virtual timer GSIV", 4, 64, L"0x%x", NULL, NULL,NULL, NULL },
{L"Virtual timer FLAGS", 4, 68, L"0x%x", NULL, NULL, NULL, NULL}, { L"Virtual timer FLAGS", 4, 68, L"0x%x", NULL, NULL,NULL, NULL },
{L"Non-Secure EL2 timer GSIV", 4, 72, L"0x%x", NULL, NULL, NULL, NULL}, { L"Non-Secure EL2 timer GSIV", 4, 72, L"0x%x", NULL, NULL,NULL, NULL },
{L"Non-Secure EL2 timer FLAGS", 4, 76, L"0x%x", NULL, NULL, NULL, NULL}, { L"Non-Secure EL2 timer FLAGS", 4, 76, L"0x%x", NULL, NULL,NULL, NULL },
{L"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL}, { L"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Platform Timer Count", 4, 88, L"%d", NULL, { L"Platform Timer Count", 4, 88, L"%d", NULL,
(VOID**)&GtdtPlatformTimerCount, NULL, NULL}, (VOID **)&GtdtPlatformTimerCount, NULL, NULL },
{L"Platform Timer Offset", 4, 92, L"0x%x", NULL, { L"Platform Timer Offset", 4, 92, L"0x%x", NULL,
(VOID**)&GtdtPlatformTimerOffset, NULL, NULL}, (VOID **)&GtdtPlatformTimerOffset,NULL, NULL },
{L"Virtual EL2 Timer GSIV", 4, 96, L"0x%x", NULL, NULL, NULL, NULL}, { L"Virtual EL2 Timer GSIV", 4, 96, L"0x%x", NULL, NULL,NULL, NULL },
{L"Virtual EL2 Timer Flags", 4, 100, L"0x%x", NULL, NULL, NULL, NULL} { L"Virtual EL2 Timer Flags", 4, 100, L"0x%x", NULL, NULL,NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Platform timer header. An ACPI_PARSER array describing the Platform timer header.
**/ **/
STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[] = { STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&PlatformTimerType, NULL, NULL}, { L"Type", 1, 0, NULL, NULL, (VOID **)&PlatformTimerType, NULL, NULL },
{L"Length", 2, 1, NULL, NULL, (VOID**)&PlatformTimerLength, NULL, NULL}, { L"Length", 2, 1, NULL, NULL, (VOID **)&PlatformTimerLength, NULL, NULL },
{L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL} { L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Platform GT Block. An ACPI_PARSER array describing the Platform GT Block.
**/ **/
STATIC CONST ACPI_PARSER GtBlockParser[] = { STATIC CONST ACPI_PARSER GtBlockParser[] = {
{L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL },
{L"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Timer Count", 4, 12, L"%d", NULL, (VOID**)&GtBlockTimerCount, { L"Timer Count", 4, 12, L"%d", NULL, (VOID **)&GtBlockTimerCount,
ValidateGtBlockTimerCount, NULL}, ValidateGtBlockTimerCount, NULL },
{L"Timer Offset", 4, 16, L"%d", NULL, (VOID**)&GtBlockTimerOffset, NULL, { L"Timer Offset", 4, 16, L"%d", NULL, (VOID **)&GtBlockTimerOffset, NULL,
NULL} NULL }
}; };
/** /**
An ACPI_PARSER array describing the GT Block timer. An ACPI_PARSER array describing the GT Block timer.
**/ **/
STATIC CONST ACPI_PARSER GtBlockTimerParser[] = { STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {
{L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL}, { L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL },
{L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, { L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL },
{L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL, { L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL,
NULL}, NULL },
{L"Physical Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Physical Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Physical Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"Physical Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"Virtual Timer GSIV", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"Virtual Timer GSIV", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"Virtual Timer Flags", 4, 32, L"0x%x", NULL, NULL, NULL, NULL}, { L"Virtual Timer Flags", 4, 32, L"0x%x", NULL, NULL, NULL, NULL },
{L"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL} { L"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Platform Watchdog. An ACPI_PARSER array describing the Platform Watchdog.
**/ **/
STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = { STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = {
{L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL },
{L"RefreshFrame Physical address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}, { L"RefreshFrame Physical address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{L"ControlFrame Physical address", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL}, { L"ControlFrame Physical address", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Watchdog Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Watchdog Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Watchdog Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL} { L"Watchdog Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -174,7 +174,7 @@ STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = {
STATIC STATIC
VOID VOID
DumpGTBlock ( DumpGTBlock (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length IN UINT16 Length
) )
{ {
@ -193,7 +193,8 @@ DumpGTBlock (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((GtBlockTimerCount == NULL) || if ((GtBlockTimerCount == NULL) ||
(GtBlockTimerOffset == NULL)) { (GtBlockTimerOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient GT Block Structure length. Length = %d.\n", 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 // Parse the specified number of GT Block Timer Structures or the GT Block
// Structure buffer length. Whichever is minimum. // Structure buffer length. Whichever is minimum.
while ((Index++ < *GtBlockTimerCount) && while ((Index++ < *GtBlockTimerCount) &&
(Offset < Length)) { (Offset < Length))
{
Offset += ParseAcpi ( Offset += ParseAcpi (
TRUE, TRUE,
2, 2,
@ -229,7 +231,7 @@ DumpGTBlock (
STATIC STATIC
VOID VOID
DumpWatchdogTimer ( DumpWatchdogTimer (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length IN UINT16 Length
) )
{ {
@ -263,14 +265,14 @@ VOID
EFIAPI EFIAPI
ParseAcpiGtdt ( ParseAcpiGtdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Index; UINT32 Index;
UINT32 Offset; UINT32 Offset;
UINT8* TimerPtr; UINT8 *TimerPtr;
if (!Trace) { if (!Trace) {
return; return;
@ -288,7 +290,8 @@ ParseAcpiGtdt (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((GtdtPlatformTimerCount == NULL) || if ((GtdtPlatformTimerCount == NULL) ||
(GtdtPlatformTimerOffset == NULL)) { (GtdtPlatformTimerOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
@ -304,7 +307,8 @@ ParseAcpiGtdt (
// Parse the specified number of Platform Timer Structures or the GTDT // Parse the specified number of Platform Timer Structures or the GTDT
// buffer length. Whichever is minimum. // buffer length. Whichever is minimum.
while ((Index++ < *GtdtPlatformTimerCount) && while ((Index++ < *GtdtPlatformTimerCount) &&
(Offset < AcpiTableLength)) { (Offset < AcpiTableLength))
{
// Parse the Platform Timer Header to obtain Length and Type // Parse the Platform Timer Header to obtain Length and Type
ParseAcpi ( ParseAcpi (
FALSE, FALSE,
@ -318,7 +322,8 @@ ParseAcpiGtdt (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((PlatformTimerType == NULL) || if ((PlatformTimerType == NULL) ||
(PlatformTimerLength == NULL)) { (PlatformTimerLength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -330,7 +335,8 @@ ParseAcpiGtdt (
// Validate Platform Timer Structure length // Validate Platform Timer Structure length
if ((*PlatformTimerLength == 0) || if ((*PlatformTimerLength == 0) ||
((Offset + (*PlatformTimerLength)) > AcpiTableLength)) { ((Offset + (*PlatformTimerLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Platform Timer Structure length. " \ L"ERROR: Invalid Platform Timer Structure length. " \

View File

@ -24,24 +24,24 @@
#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10 #define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10
// Local variables // Local variables
STATIC CONST UINT16* HmatStructureType; STATIC CONST UINT16 *HmatStructureType;
STATIC CONST UINT32* HmatStructureLength; STATIC CONST UINT32 *HmatStructureLength;
STATIC CONST UINT32* NumberInitiatorProximityDomain; STATIC CONST UINT32 *NumberInitiatorProximityDomain;
STATIC CONST UINT32* NumberTargetProximityDomain; STATIC CONST UINT32 *NumberTargetProximityDomain;
STATIC CONST STATIC CONST
EFI_ACPI_6_4_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS* EFI_ACPI_6_4_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS *
SllbiFlags; SllbiFlags;
STATIC CONST UINT8* SllbiDataType; STATIC CONST UINT8 *SllbiDataType;
STATIC CONST UINT16* NumberSMBIOSHandles; STATIC CONST UINT16 *NumberSMBIOSHandles;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
Names of System Locality Latency Bandwidth Information (SLLBI) data types Names of System Locality Latency Bandwidth Information (SLLBI) data types
**/ **/
STATIC CONST CHAR16* SllbiNames[] = { STATIC CONST CHAR16 *SllbiNames[] = {
L"Access %sLatency%s", L"Access %sLatency%s",
L"Read %sLatency%s", L"Read %sLatency%s",
L"Write %sLatency%s", L"Write %sLatency%s",
@ -61,15 +61,15 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateCacheAttributes ( ValidateCacheAttributes (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES* EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *
Attributes; Attributes;
Attributes = Attributes =
(EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)Ptr; (EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *)Ptr;
if (Attributes->TotalCacheLevels > 0x3) { if (Attributes->TotalCacheLevels > 0x3) {
IncrementErrorCount (); IncrementErrorCount ();
@ -78,6 +78,7 @@ ValidateCacheAttributes (
Attributes->TotalCacheLevels Attributes->TotalCacheLevels
); );
} }
if (Attributes->CacheLevel > 0x3) { if (Attributes->CacheLevel > 0x3) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -85,6 +86,7 @@ ValidateCacheAttributes (
Attributes->CacheLevel Attributes->CacheLevel
); );
} }
if (Attributes->CacheAssociativity > 0x2) { if (Attributes->CacheAssociativity > 0x2) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -92,6 +94,7 @@ ValidateCacheAttributes (
Attributes->CacheAssociativity Attributes->CacheAssociativity
); );
} }
if (Attributes->WritePolicy > 0x2) { if (Attributes->WritePolicy > 0x2) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -111,15 +114,15 @@ STATIC
VOID VOID
EFIAPI EFIAPI
DumpCacheAttributes ( DumpCacheAttributes (
IN CONST CHAR16* Format OPTIONAL, IN CONST CHAR16 *Format OPTIONAL,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES* EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *
Attributes; Attributes;
Attributes = Attributes =
(EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)Ptr; (EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *)Ptr;
Print (L"\n"); Print (L"\n");
PrintFieldName (4, L"Total Cache Levels"); PrintFieldName (4, L"Total Cache Levels");
@ -139,16 +142,16 @@ DumpCacheAttributes (
*/ */
STATIC CONST ACPI_PARSER HmatParser[] = { STATIC CONST ACPI_PARSER HmatParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Reserved", 4, 36, NULL, NULL, NULL, NULL, NULL} { L"Reserved", 4,36, NULL, NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the HMAT structure header. An ACPI_PARSER array describing the HMAT structure header.
*/ */
STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = { STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = {
{L"Type", 2, 0, NULL, NULL, (VOID**)&HmatStructureType, NULL, NULL}, { L"Type", 2, 0, NULL, NULL, (VOID **)&HmatStructureType, NULL, NULL },
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL },
{L"Length", 4, 4, NULL, NULL, (VOID**)&HmatStructureLength, NULL, NULL} { L"Length", 4, 4, NULL, NULL, (VOID **)&HmatStructureLength, NULL, NULL }
}; };
/** /**
@ -156,16 +159,16 @@ STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = {
Structure - Type 0. Structure - Type 0.
*/ */
STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = { STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = {
{L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL },
{L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Dom for initiator", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Dom for initiator", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Dom for memory", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Dom for memory", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Reserved", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL} { L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -173,19 +176,19 @@ STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = {
Information Structure - Type 1. Information Structure - Type 1.
*/ */
STATIC CONST ACPI_PARSER SllbiParser[] = { STATIC CONST ACPI_PARSER SllbiParser[] = {
{L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL },
{L"Flags", 1, 8, L"0x%x", NULL, (VOID**)&SllbiFlags, NULL, NULL}, { L"Flags", 1, 8, L"0x%x", NULL, (VOID **)&SllbiFlags, NULL, NULL },
{L"Data type", 1, 9, L"0x%x", NULL, (VOID**)&SllbiDataType, NULL, NULL}, { L"Data type", 1, 9, L"0x%x", NULL, (VOID **)&SllbiDataType, NULL, NULL },
{L"Min Transfer Size", 1, 10, L"%d", NULL, NULL, NULL, NULL}, { L"Min Transfer Size", 1, 10, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 11, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 11, L"0x%x", NULL, NULL, NULL, NULL },
{L"Initiator Proximity Dom Count", 4, 12, L"%d", NULL, { L"Initiator Proximity Dom Count", 4, 12, L"%d", NULL,
(VOID**)&NumberInitiatorProximityDomain, NULL, NULL}, (VOID **)&NumberInitiatorProximityDomain, NULL, NULL },
{L"Target Proximity Dom Count", 4, 16, L"%d", NULL, { L"Target Proximity Dom Count", 4, 16, L"%d", NULL,
(VOID**)&NumberTargetProximityDomain, NULL, NULL}, (VOID **)&NumberTargetProximityDomain, NULL, NULL },
{L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Entry Base Unit", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL} { L"Entry Base Unit", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL }
// initiator Proximity Domain list ... // initiator Proximity Domain list ...
// target Proximity Domain list ... // target Proximity Domain list ...
// Latency/Bandwidth matrix ... // Latency/Bandwidth matrix ...
@ -196,17 +199,17 @@ STATIC CONST ACPI_PARSER SllbiParser[] = {
Structure - Type 2. Structure - Type 2.
*/ */
STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = { STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
{L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL },
{L"Proximity Dom for memory", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Dom for memory", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL, { L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL,
ValidateCacheAttributes, NULL}, ValidateCacheAttributes, NULL },
{L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"SMBIOS Handle Count", 2, 30, L"%d", NULL, { L"SMBIOS Handle Count", 2, 30, L"%d", NULL,
(VOID**)&NumberSMBIOSHandles, NULL, NULL} (VOID **)&NumberSMBIOSHandles, NULL, NULL }
// SMBIOS handles List ... // SMBIOS handles List ...
}; };
@ -222,7 +225,7 @@ STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
STATIC STATIC
VOID VOID
DumpMpda ( DumpMpda (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
@ -248,13 +251,13 @@ DumpMpda (
STATIC STATIC
VOID VOID
DumpSllbi ( DumpSllbi (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
CONST UINT32* InitiatorProximityDomainList; CONST UINT32 *InitiatorProximityDomainList;
CONST UINT32* TargetProximityDomainList; CONST UINT32 *TargetProximityDomainList;
CONST UINT16* LatencyBandwidthMatrix; CONST UINT16 *LatencyBandwidthMatrix;
UINT32 Offset; UINT32 Offset;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
CHAR16 SecondBuffer[OUTPUT_FIELD_COLUMN_WIDTH]; CHAR16 SecondBuffer[OUTPUT_FIELD_COLUMN_WIDTH];
@ -278,7 +281,8 @@ DumpSllbi (
if ((SllbiFlags == NULL) || if ((SllbiFlags == NULL) ||
(SllbiDataType == NULL) || (SllbiDataType == NULL) ||
(NumberInitiatorProximityDomain == NULL) || (NumberInitiatorProximityDomain == NULL) ||
(NumberTargetProximityDomain == NULL)) { (NumberTargetProximityDomain == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -306,10 +310,10 @@ DumpSllbi (
return; return;
} }
InitiatorProximityDomainList = (UINT32*) (Ptr + Offset); InitiatorProximityDomainList = (UINT32 *)(Ptr + Offset);
TargetProximityDomainList = InitiatorProximityDomainList + TargetProximityDomainList = InitiatorProximityDomainList +
*NumberInitiatorProximityDomain; *NumberInitiatorProximityDomain;
LatencyBandwidthMatrix = (UINT16*) (TargetProximityDomainList + LatencyBandwidthMatrix = (UINT16 *)(TargetProximityDomainList +
*NumberTargetProximityDomain); *NumberTargetProximityDomain);
// Display each element of the Initiator Proximity Domain list // Display each element of the Initiator Proximity Domain list
@ -350,6 +354,7 @@ DumpSllbi (
Print (L"Error: Unkown Data Type. DataType = 0x%x.\n", *SllbiDataType); Print (L"Error: Unkown Data Type. DataType = 0x%x.\n", *SllbiDataType);
return; return;
} }
StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]); StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]);
// Adjust base name depending on Memory Hierarchy in this Structure // Adjust base name depending on Memory Hierarchy in this Structure
@ -381,7 +386,6 @@ DumpSllbi (
SllbiFlags->MemoryHierarchy SllbiFlags->MemoryHierarchy
); );
return; return;
} // switch } // switch
if (*NumberTargetProximityDomain <= MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX) { if (*NumberTargetProximityDomain <= MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX) {
@ -400,34 +404,41 @@ DumpSllbi (
for (IndexTarget = 0; for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain; IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) { IndexTarget++)
{
Print (L" %2d", IndexTarget); Print (L" %2d", IndexTarget);
} }
Print (L"\n ---+"); Print (L"\n ---+");
for (IndexTarget = 0; for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain; IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) { IndexTarget++)
{
Print (L"------"); Print (L"------");
} }
Print (L"\n"); Print (L"\n");
TargetStartOffset = 0; TargetStartOffset = 0;
for (IndexInitiator = 0; for (IndexInitiator = 0;
IndexInitiator < *NumberInitiatorProximityDomain; IndexInitiator < *NumberInitiatorProximityDomain;
IndexInitiator++) { IndexInitiator++)
{
Print (L" %2d |", IndexInitiator); Print (L" %2d |", IndexInitiator);
for (IndexTarget = 0; for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain; IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) { IndexTarget++)
{
Print ( Print (
L" %5d", L" %5d",
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget] LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
); );
} // for Target } // for Target
Print (L"\n"); Print (L"\n");
TargetStartOffset += (*NumberTargetProximityDomain); TargetStartOffset += (*NumberTargetProximityDomain);
} // for Initiator } // for Initiator
Print (L"\n"); Print (L"\n");
} else { } else {
// Display the latency/bandwidth matrix as a list // Display the latency/bandwidth matrix as a list
@ -441,10 +452,12 @@ DumpSllbi (
TargetStartOffset = 0; TargetStartOffset = 0;
for (IndexInitiator = 0; for (IndexInitiator = 0;
IndexInitiator < *NumberInitiatorProximityDomain; IndexInitiator < *NumberInitiatorProximityDomain;
IndexInitiator++) { IndexInitiator++)
{
for (IndexTarget = 0; for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain; IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) { IndexTarget++)
{
UnicodeSPrint ( UnicodeSPrint (
SecondBuffer, SecondBuffer,
sizeof (SecondBuffer), sizeof (SecondBuffer),
@ -459,6 +472,7 @@ DumpSllbi (
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget] LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
); );
} // for Target } // for Target
TargetStartOffset += (*NumberTargetProximityDomain); TargetStartOffset += (*NumberTargetProximityDomain);
} // for Initiator } // for Initiator
} }
@ -474,11 +488,11 @@ DumpSllbi (
STATIC STATIC
VOID VOID
DumpMsci ( DumpMsci (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length IN UINT32 Length
) )
{ {
CONST UINT16* SMBIOSHandlesList; CONST UINT16 *SMBIOSHandlesList;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
UINT32 Offset; UINT32 Offset;
UINT16 Index; UINT16 Index;
@ -515,7 +529,7 @@ DumpMsci (
return; return;
} }
SMBIOSHandlesList = (UINT16*) (Ptr + Offset); SMBIOSHandlesList = (UINT16 *)(Ptr + Offset);
for (Index = 0; Index < *NumberSMBIOSHandles; Index++) { for (Index = 0; Index < *NumberSMBIOSHandles; Index++) {
UnicodeSPrint ( UnicodeSPrint (
@ -554,13 +568,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiHmat ( ParseAcpiHmat (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* HmatStructurePtr; UINT8 *HmatStructurePtr;
if (!Trace) { if (!Trace) {
return; return;
@ -591,7 +605,8 @@ ParseAcpiHmat (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((HmatStructureType == NULL) || if ((HmatStructureType == NULL) ||
(HmatStructureLength == NULL)) { (HmatStructureLength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -603,7 +618,8 @@ ParseAcpiHmat (
// Validate HMAT Structure length. // Validate HMAT Structure length.
if ((*HmatStructureLength == 0) || if ((*HmatStructureLength == 0) ||
((Offset + (*HmatStructureLength)) > AcpiTableLength)) { ((Offset + (*HmatStructureLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid HMAT Structure length. " \ L"ERROR: Invalid HMAT Structure length. " \

View File

@ -18,20 +18,20 @@
// Local variables // Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT32* IortNodeCount; STATIC CONST UINT32 *IortNodeCount;
STATIC CONST UINT32* IortNodeOffset; STATIC CONST UINT32 *IortNodeOffset;
STATIC CONST UINT8* IortNodeType; STATIC CONST UINT8 *IortNodeType;
STATIC CONST UINT16* IortNodeLength; STATIC CONST UINT16 *IortNodeLength;
STATIC CONST UINT32* IortIdMappingCount; STATIC CONST UINT32 *IortIdMappingCount;
STATIC CONST UINT32* IortIdMappingOffset; STATIC CONST UINT32 *IortIdMappingOffset;
STATIC CONST UINT32* InterruptContextCount; STATIC CONST UINT32 *InterruptContextCount;
STATIC CONST UINT32* InterruptContextOffset; STATIC CONST UINT32 *InterruptContextOffset;
STATIC CONST UINT32* PmuInterruptCount; STATIC CONST UINT32 *PmuInterruptCount;
STATIC CONST UINT32* PmuInterruptOffset; STATIC CONST UINT32 *PmuInterruptOffset;
STATIC CONST UINT32* ItsCount; STATIC CONST UINT32 *ItsCount;
/** /**
This function validates the ID Mapping array count for the ITS node. This function validates the ID Mapping array count for the ITS node.
@ -44,11 +44,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateItsIdMappingCount ( ValidateItsIdMappingCount (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr != 0) { if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping count must be zero."); Print (L"\nERROR: IORT ID Mapping count must be zero.");
} }
@ -66,11 +66,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePmcgIdMappingCount ( ValidatePmcgIdMappingCount (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr > 1) { if (*(UINT32 *)Ptr > 1) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping count must not be greater than 1."); Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");
} }
@ -87,11 +87,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateItsIdArrayReference ( ValidateItsIdArrayReference (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr != 0) { if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping offset must be zero."); Print (L"\nERROR: IORT ID Mapping offset must be zero.");
} }
@ -121,11 +121,11 @@ ValidateItsIdArrayReference (
**/ **/
STATIC CONST ACPI_PARSER IortParser[] = { STATIC CONST ACPI_PARSER IortParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Number of IORT Nodes", 4, 36, L"%d", NULL, { L"Number of IORT Nodes", 4, 36, L"%d", NULL,
(VOID**)&IortNodeCount, NULL, NULL}, (VOID **)&IortNodeCount, NULL, NULL },
{L"Offset to Array of IORT Nodes", 4, 40, L"0x%x", NULL, { L"Offset to Array of IORT Nodes",4, 40, L"0x%x", NULL,
(VOID**)&IortNodeOffset, NULL, NULL}, (VOID **)&IortNodeOffset, NULL, NULL },
{L"Reserved", 4, 44, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 44, L"0x%x", NULL,NULL,NULL, NULL }
}; };
/** /**
@ -140,45 +140,45 @@ STATIC CONST ACPI_PARSER IortNodeHeaderParser[] = {
**/ **/
STATIC CONST ACPI_PARSER IortNodeSmmuV1V2Parser[] = { STATIC CONST ACPI_PARSER IortNodeSmmuV1V2Parser[] = {
PARSE_IORT_NODE_HEADER (NULL, NULL), PARSE_IORT_NODE_HEADER (NULL, NULL),
{L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Span", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Span", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Model", 4, 32, L"%d", NULL, NULL, NULL, NULL}, { L"Model", 4, 32, L"%d", NULL, NULL, NULL, NULL },
{L"Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reference to Global Interrupt Array", 4, 40, L"0x%x", NULL, NULL, NULL, { L"Reference to Global Interrupt Array",4, 40, L"0x%x", NULL, NULL, NULL,
NULL}, NULL },
{L"Number of context interrupts", 4, 44, L"%d", NULL, { L"Number of context interrupts", 4, 44, L"%d", NULL,
(VOID**)&InterruptContextCount, NULL, NULL}, (VOID **)&InterruptContextCount, NULL, NULL },
{L"Reference to Context Interrupt Array", 4, 48, L"0x%x", NULL, { L"Reference to Context Interrupt Array",4, 48, L"0x%x", NULL,
(VOID**)&InterruptContextOffset, NULL, NULL}, (VOID **)&InterruptContextOffset, NULL, NULL },
{L"Number of PMU Interrupts", 4, 52, L"%d", NULL, { L"Number of PMU Interrupts", 4, 52, L"%d", NULL,
(VOID**)&PmuInterruptCount, NULL, NULL}, (VOID **)&PmuInterruptCount, NULL, NULL },
{L"Reference to PMU Interrupt Array", 4, 56, L"0x%x", NULL, { L"Reference to PMU Interrupt Array",4, 56, L"0x%x", NULL,
(VOID**)&PmuInterruptOffset, NULL, NULL}, (VOID **)&PmuInterruptOffset, NULL, NULL },
// Interrupt Array // Interrupt Array
{L"SMMU_NSgIrpt", 4, 60, L"0x%x", NULL, NULL, NULL, NULL}, { L"SMMU_NSgIrpt", 4, 60, L"0x%x", NULL, NULL, NULL, NULL },
{L"SMMU_NSgIrpt interrupt flags", 4, 64, L"0x%x", NULL, NULL, NULL, NULL}, { L"SMMU_NSgIrpt interrupt flags", 4, 64, L"0x%x", NULL, NULL, NULL, NULL },
{L"SMMU_NSgCfgIrpt", 4, 68, L"0x%x", NULL, NULL, NULL, NULL}, { L"SMMU_NSgCfgIrpt", 4, 68, L"0x%x", NULL, NULL, NULL, NULL },
{L"SMMU_NSgCfgIrpt interrupt flags", 4, 72, L"0x%x", NULL, NULL, NULL, NULL} { L"SMMU_NSgCfgIrpt interrupt flags",4, 72, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the SMMUv1/2 Node Interrupt Array. An ACPI_PARSER array describing the SMMUv1/2 Node Interrupt Array.
**/ **/
STATIC CONST ACPI_PARSER InterruptArrayParser[] = { STATIC CONST ACPI_PARSER InterruptArrayParser[] = {
{L"Interrupt GSIV", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Interrupt GSIV", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL} { L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the IORT ID Mapping. An ACPI_PARSER array describing the IORT ID Mapping.
**/ **/
STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = { STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = {
{L"Input base", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Input base", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Number of IDs", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Number of IDs", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Output base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Output base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Output reference", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Output reference", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL} { L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -186,17 +186,17 @@ STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = {
**/ **/
STATIC CONST ACPI_PARSER IortNodeSmmuV3Parser[] = { STATIC CONST ACPI_PARSER IortNodeSmmuV3Parser[] = {
PARSE_IORT_NODE_HEADER (NULL, NULL), PARSE_IORT_NODE_HEADER (NULL, NULL),
{L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"VATOS Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, { L"VATOS Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Model", 4, 40, L"%d", NULL, NULL, NULL, NULL}, { L"Model", 4, 40, L"%d", NULL, NULL, NULL, NULL },
{L"Event", 4, 44, L"0x%x", NULL, NULL, NULL, NULL}, { L"Event", 4, 44, L"0x%x", NULL, NULL, NULL, NULL },
{L"PRI", 4, 48, L"0x%x", NULL, NULL, NULL, NULL}, { L"PRI", 4, 48, L"0x%x", NULL, NULL, NULL, NULL },
{L"GERR", 4, 52, L"0x%x", NULL, NULL, NULL, NULL}, { L"GERR", 4, 52, L"0x%x", NULL, NULL, NULL, NULL },
{L"Sync", 4, 56, L"0x%x", NULL, NULL, NULL, NULL}, { L"Sync", 4, 56, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity domain", 4, 60, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity domain", 4, 60, L"0x%x", NULL, NULL, NULL, NULL },
{L"Device ID mapping index", 4, 64, L"%d", NULL, NULL, NULL, NULL} { L"Device ID mapping index", 4, 64, L"%d", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -207,7 +207,7 @@ STATIC CONST ACPI_PARSER IortNodeItsParser[] = {
ValidateItsIdMappingCount, ValidateItsIdMappingCount,
ValidateItsIdArrayReference ValidateItsIdArrayReference
), ),
{L"Number of ITSs", 4, 16, L"%d", NULL, (VOID**)&ItsCount, NULL} { L"Number of ITSs", 4,16, L"%d", NULL, (VOID **)&ItsCount, NULL }
}; };
/** /**
@ -222,9 +222,9 @@ STATIC CONST ACPI_PARSER ItsIdParser[] = {
**/ **/
STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = { STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = {
PARSE_IORT_NODE_HEADER (NULL, NULL), PARSE_IORT_NODE_HEADER (NULL, NULL),
{L"Node Flags", 4, 16, L"%d", NULL, NULL, NULL, NULL}, { L"Node Flags", 4, 16, L"%d", NULL, NULL, NULL, NULL },
{L"Memory access properties", 8, 20, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Memory access properties",8, 20, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Device memory address size limit", 1, 28, L"%d", NULL, NULL, NULL, NULL} { L"Device memory address size limit",1, 28, L"%d", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -232,11 +232,11 @@ STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = {
**/ **/
STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = { STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
PARSE_IORT_NODE_HEADER (NULL, NULL), PARSE_IORT_NODE_HEADER (NULL, NULL),
{L"Memory access properties", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Memory access properties",8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{L"ATS Attribute", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"ATS Attribute", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Segment number", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Segment number", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"Memory access size limit", 1, 32, L"0x%x", NULL, NULL, NULL, NULL}, { L"Memory access size limit",1, 32, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} { L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
}; };
/** /**
@ -244,10 +244,10 @@ STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
**/ **/
STATIC CONST ACPI_PARSER IortNodePmcgParser[] = { STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL), PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL),
{L"Page 0 Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Page 0 Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"Page 1 Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL} { L"Page 1 Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -260,7 +260,7 @@ STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
STATIC STATIC
VOID VOID
DumpIortNodeIdMappings ( DumpIortNodeIdMappings (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 Length, IN UINT32 Length,
IN UINT32 MappingCount IN UINT32 MappingCount
) )
@ -273,7 +273,8 @@ DumpIortNodeIdMappings (
Offset = 0; Offset = 0;
while ((Index < MappingCount) && while ((Index < MappingCount) &&
(Offset < Length)) { (Offset < Length))
{
AsciiSPrint ( AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
@ -304,7 +305,7 @@ DumpIortNodeIdMappings (
STATIC STATIC
VOID VOID
DumpIortNodeSmmuV1V2 ( DumpIortNodeSmmuV1V2 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length, IN UINT16 Length,
IN UINT32 MappingCount, IN UINT32 MappingCount,
IN UINT32 MappingOffset IN UINT32 MappingOffset
@ -328,7 +329,8 @@ DumpIortNodeSmmuV1V2 (
if ((InterruptContextCount == NULL) || if ((InterruptContextCount == NULL) ||
(InterruptContextOffset == NULL) || (InterruptContextOffset == NULL) ||
(PmuInterruptCount == NULL) || (PmuInterruptCount == NULL) ||
(PmuInterruptOffset == NULL)) { (PmuInterruptOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient SMMUv1/2 node length. Length = %d\n", L"ERROR: Insufficient SMMUv1/2 node length. Length = %d\n",
@ -341,7 +343,8 @@ DumpIortNodeSmmuV1V2 (
Index = 0; Index = 0;
while ((Index < *InterruptContextCount) && while ((Index < *InterruptContextCount) &&
(Offset < Length)) { (Offset < Length))
{
AsciiSPrint ( AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
@ -363,7 +366,8 @@ DumpIortNodeSmmuV1V2 (
Index = 0; Index = 0;
while ((Index < *PmuInterruptCount) && while ((Index < *PmuInterruptCount) &&
(Offset < Length)) { (Offset < Length))
{
AsciiSPrint ( AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
@ -400,7 +404,7 @@ DumpIortNodeSmmuV1V2 (
STATIC STATIC
VOID VOID
DumpIortNodeSmmuV3 ( DumpIortNodeSmmuV3 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length, IN UINT16 Length,
IN UINT32 MappingCount, IN UINT32 MappingCount,
IN UINT32 MappingOffset IN UINT32 MappingOffset
@ -431,7 +435,7 @@ DumpIortNodeSmmuV3 (
STATIC STATIC
VOID VOID
DumpIortNodeIts ( DumpIortNodeIts (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length IN UINT16 Length
) )
{ {
@ -462,7 +466,8 @@ DumpIortNodeIts (
Index = 0; Index = 0;
while ((Index < *ItsCount) && while ((Index < *ItsCount) &&
(Offset < Length)) { (Offset < Length))
{
AsciiSPrint ( AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
@ -481,7 +486,6 @@ DumpIortNodeIts (
} }
// Note: ITS does not have the ID Mappings Array // Note: ITS does not have the ID Mappings Array
} }
/** /**
@ -496,7 +500,7 @@ DumpIortNodeIts (
STATIC STATIC
VOID VOID
DumpIortNodeNamedComponent ( DumpIortNodeNamedComponent (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length, IN UINT16 Length,
IN UINT32 MappingCount, IN UINT32 MappingCount,
IN UINT32 MappingOffset IN UINT32 MappingOffset
@ -517,10 +521,12 @@ DumpIortNodeNamedComponent (
PrintFieldName (2, L"Device Object Name"); PrintFieldName (2, L"Device Object Name");
while ((*(Ptr + Offset) != 0) && while ((*(Ptr + Offset) != 0) &&
(Offset < Length)) { (Offset < Length))
{
Print (L"%c", *(Ptr + Offset)); Print (L"%c", *(Ptr + Offset));
Offset++; Offset++;
} }
Print (L"\n"); Print (L"\n");
DumpIortNodeIdMappings ( DumpIortNodeIdMappings (
@ -542,7 +548,7 @@ DumpIortNodeNamedComponent (
STATIC STATIC
VOID VOID
DumpIortNodeRootComplex ( DumpIortNodeRootComplex (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length, IN UINT16 Length,
IN UINT32 MappingCount, IN UINT32 MappingCount,
IN UINT32 MappingOffset IN UINT32 MappingOffset
@ -576,11 +582,11 @@ DumpIortNodeRootComplex (
STATIC STATIC
VOID VOID
DumpIortNodePmcg ( DumpIortNodePmcg (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT16 Length, IN UINT16 Length,
IN UINT32 MappingCount, IN UINT32 MappingCount,
IN UINT32 MappingOffset IN UINT32 MappingOffset
) )
{ {
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
@ -621,14 +627,14 @@ VOID
EFIAPI EFIAPI
ParseAcpiIort ( ParseAcpiIort (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT32 Index; UINT32 Index;
UINT8* NodePtr; UINT8 *NodePtr;
if (!Trace) { if (!Trace) {
return; return;
@ -646,7 +652,8 @@ ParseAcpiIort (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((IortNodeCount == NULL) || if ((IortNodeCount == NULL) ||
(IortNodeOffset == NULL)) { (IortNodeOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", 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. // Parse the specified number of IORT nodes or the IORT table buffer length.
// Whichever is minimum. // Whichever is minimum.
while ((Index++ < *IortNodeCount) && while ((Index++ < *IortNodeCount) &&
(Offset < AcpiTableLength)) { (Offset < AcpiTableLength))
{
// Parse the IORT Node Header // Parse the IORT Node Header
ParseAcpi ( ParseAcpi (
FALSE, FALSE,
@ -678,7 +686,8 @@ ParseAcpiIort (
if ((IortNodeType == NULL) || if ((IortNodeType == NULL) ||
(IortNodeLength == NULL) || (IortNodeLength == NULL) ||
(IortIdMappingCount == NULL) || (IortIdMappingCount == NULL) ||
(IortIdMappingOffset == NULL)) { (IortIdMappingOffset == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -690,7 +699,8 @@ ParseAcpiIort (
// Validate IORT Node length // Validate IORT Node length
if ((*IortNodeLength == 0) || if ((*IortNodeLength == 0) ||
((Offset + (*IortNodeLength)) > AcpiTableLength)) { ((Offset + (*IortNodeLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid IORT Node length. " \ L"ERROR: Invalid IORT Node length. " \

View File

@ -19,8 +19,8 @@
#include "MadtParser.h" #include "MadtParser.h"
// Local Variables // Local Variables
STATIC CONST UINT8* MadtInterruptControllerType; STATIC CONST UINT8 *MadtInterruptControllerType;
STATIC CONST UINT8* MadtInterruptControllerLength; STATIC CONST UINT8 *MadtInterruptControllerLength;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -34,11 +34,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateGICDSystemVectorBase ( ValidateGICDSystemVectorBase (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr != 0) { if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: System Vector Base must be zero." L"\nERROR: System Vector Base must be zero."
@ -57,13 +57,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateSpeOverflowInterrupt ( ValidateSpeOverflowInterrupt (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT16 SpeOverflowInterrupt; UINT16 SpeOverflowInterrupt;
SpeOverflowInterrupt = *(UINT16*)Ptr; SpeOverflowInterrupt = *(UINT16 *)Ptr;
// SPE not supported by this processor // SPE not supported by this processor
if (SpeOverflowInterrupt == 0) { if (SpeOverflowInterrupt == 0) {
@ -73,7 +73,8 @@ ValidateSpeOverflowInterrupt (
if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) || if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) ||
((SpeOverflowInterrupt > ARM_PPI_ID_MAX) && ((SpeOverflowInterrupt > ARM_PPI_ID_MAX) &&
(SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) || (SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) { (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID " L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
@ -85,7 +86,7 @@ ValidateSpeOverflowInterrupt (
ARM_PPI_ID_EXTENDED_MAX ARM_PPI_ID_EXTENDED_MAX
); );
} else if (SpeOverflowInterrupt != ARM_PPI_ID_PMBIRQ) { } else if (SpeOverflowInterrupt != ARM_PPI_ID_PMBIRQ) {
IncrementWarningCount(); IncrementWarningCount ();
Print ( Print (
L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with SBSA " L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with SBSA "
L"Level 3 PPI ID assignment: %d.", L"Level 3 PPI ID assignment: %d.",
@ -99,137 +100,136 @@ ValidateSpeOverflowInterrupt (
An ACPI_PARSER array describing the GICC Interrupt Controller Structure. An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
**/ **/
STATIC CONST ACPI_PARSER GicCParser[] = { STATIC CONST ACPI_PARSER GicCParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"CPU Interface Number", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"CPU Interface Number", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI Processor UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI Processor UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Parking Protocol Version", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Parking Protocol Version", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Performance Interrupt GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Performance Interrupt GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Parked Address", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Parked Address", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Physical Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
{L"GICV", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}, { L"GICV", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL },
{L"GICH", 8, 48, L"0x%lx", NULL, NULL, NULL, NULL}, { L"GICH", 8, 48, L"0x%lx", NULL, NULL, NULL, NULL },
{L"VGIC Maintenance interrupt", 4, 56, L"0x%x", NULL, NULL, NULL, NULL}, { L"VGIC Maintenance interrupt", 4, 56, L"0x%x", NULL, NULL, NULL, NULL },
{L"GICR Base Address", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL}, { L"GICR Base Address", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL },
{L"MPIDR", 8, 68, L"0x%lx", NULL, NULL, NULL, NULL}, { L"MPIDR", 8, 68, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Processor Power Efficiency Class", 1, 76, L"0x%x", NULL, NULL, NULL, { L"Processor Power Efficiency Class", 1, 76, L"0x%x", NULL, NULL, NULL,
NULL}, NULL },
{L"Reserved", 1, 77, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 77, L"0x%x", NULL, NULL, NULL, NULL },
{L"SPE overflow Interrupt", 2, 78, L"0x%x", NULL, NULL, { L"SPE overflow Interrupt", 2, 78, L"0x%x", NULL, NULL,
ValidateSpeOverflowInterrupt, NULL} ValidateSpeOverflowInterrupt, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GICD Interrupt Controller Structure. An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
**/ **/
STATIC CONST ACPI_PARSER GicDParser[] = { STATIC CONST ACPI_PARSER GicDParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"GIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"GIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"System Vector Base", 4, 16, L"0x%x", NULL, NULL, { L"System Vector Base", 4, 16, L"0x%x", NULL, NULL,
ValidateGICDSystemVectorBase, NULL}, ValidateGICDSystemVectorBase, NULL },
{L"GIC Version", 1, 20, L"%d", NULL, NULL, NULL, NULL}, { L"GIC Version", 1, 20, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 21, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} { L"Reserved", 3, 21, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure. An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure.
**/ **/
STATIC CONST ACPI_PARSER GicMSIFrameParser[] = { STATIC CONST ACPI_PARSER GicMSIFrameParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"MSI Frame ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"MSI Frame ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"SPI Count", 2, 20, L"%d", NULL, NULL, NULL, NULL}, { L"SPI Count", 2, 20, L"%d", NULL, NULL, NULL, NULL },
{L"SPI Base", 2, 22, L"0x%x", NULL, NULL, NULL, NULL} { L"SPI Base", 2, 22, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GICR Interrupt Controller Structure. An ACPI_PARSER array describing the GICR Interrupt Controller Structure.
**/ **/
STATIC CONST ACPI_PARSER GicRParser[] = { STATIC CONST ACPI_PARSER GicRParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL, { L"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL,
NULL}, NULL },
{L"Discovery Range Length", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} { L"Discovery Range Length", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure. An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure.
**/ **/
STATIC CONST ACPI_PARSER GicITSParser[] = { STATIC CONST ACPI_PARSER GicITSParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"GIC ITS ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"GIC ITS ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the IO APIC Structure. An ACPI_PARSER array describing the IO APIC Structure.
**/ **/
STATIC CONST ACPI_PARSER IoApic[] = { STATIC CONST ACPI_PARSER IoApic[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"I/O APIC ID", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"I/O APIC ID", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{L"I/O APIC Address", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"I/O APIC Address", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL} { L"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Interrupt Source Override Structure. An ACPI_PARSER array describing the Interrupt Source Override Structure.
**/ **/
STATIC CONST ACPI_PARSER InterruptSourceOverride[] = { STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Bus", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Bus", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Source", 1, 3, L"0x%x", NULL, NULL, NULL, NULL}, { L"Source", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{L"Global System Interrupt", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Global System Interrupt", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL} { L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Processor Local x2APIC Structure. An ACPI_PARSER array describing the Processor Local x2APIC Structure.
**/ **/
STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = { STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"X2APIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"X2APIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI Processor UID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} { L"ACPI Processor UID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Local x2APIC NMI Structure. An ACPI_PARSER array describing the Local x2APIC NMI Structure.
**/ **/
STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = { STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Flags", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI Processor UID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI Processor UID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Local x2APIC LINT#", 1, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Local x2APIC LINT#", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL} { L"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL }
}; };
/** /**
@ -237,19 +237,19 @@ STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
**/ **/
STATIC CONST ACPI_PARSER MadtParser[] = { STATIC CONST ACPI_PARSER MadtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Local Interrupt Controller Address", 4, 36, L"0x%x", NULL, NULL, NULL, { L"Local Interrupt Controller Address",4, 36, L"0x%x", NULL, NULL, NULL,
NULL}, NULL },
{L"Flags", 4, 40, L"0x%x", NULL, NULL, NULL, NULL} { L"Flags", 4, 40, L"0x%x", NULL, NULL, NULL,NULL}
}; };
/** /**
An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure. An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure.
**/ **/
STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = { STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
{NULL, 1, 0, NULL, NULL, (VOID**)&MadtInterruptControllerType, NULL, NULL}, { NULL, 1, 0, NULL, NULL, (VOID **)&MadtInterruptControllerType, NULL, NULL },
{L"Length", 1, 1, NULL, NULL, (VOID**)&MadtInterruptControllerLength, NULL, { L"Length", 1, 1, NULL, NULL, (VOID **)&MadtInterruptControllerLength, NULL,
NULL}, NULL },
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL} { L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL }
}; };
/** /**
@ -276,13 +276,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiMadt ( ParseAcpiMadt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* InterruptContollerPtr; UINT8 *InterruptContollerPtr;
UINT32 GICDCount; UINT32 GICDCount;
GICDCount = 0; GICDCount = 0;
@ -315,7 +315,8 @@ ParseAcpiMadt (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((MadtInterruptControllerType == NULL) || if ((MadtInterruptControllerType == NULL) ||
(MadtInterruptControllerLength == NULL)) { (MadtInterruptControllerLength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -327,7 +328,8 @@ ParseAcpiMadt (
// Validate Interrupt Controller Structure length // Validate Interrupt Controller Structure length
if ((*MadtInterruptControllerLength == 0) || if ((*MadtInterruptControllerLength == 0) ||
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) { ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Interrupt Controller Structure length. " \ L"ERROR: Invalid Interrupt Controller Structure length. " \
@ -340,7 +342,8 @@ ParseAcpiMadt (
} }
switch (*MadtInterruptControllerType) { switch (*MadtInterruptControllerType) {
case EFI_ACPI_6_3_GIC: { case EFI_ACPI_6_3_GIC:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -352,7 +355,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_GICD: { case EFI_ACPI_6_3_GICD:
{
if (++GICDCount > 1) { if (++GICDCount > 1) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -361,6 +365,7 @@ ParseAcpiMadt (
GICDCount GICDCount
); );
} }
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -372,7 +377,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_GIC_MSI_FRAME: { case EFI_ACPI_6_3_GIC_MSI_FRAME:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -384,7 +390,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_GICR: { case EFI_ACPI_6_3_GICR:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -396,7 +403,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_GIC_ITS: { case EFI_ACPI_6_3_GIC_ITS:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -408,7 +416,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_IO_APIC: { case EFI_ACPI_6_3_IO_APIC:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -420,7 +429,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE: { case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -432,7 +442,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC: { case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -444,7 +455,8 @@ ParseAcpiMadt (
break; break;
} }
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI: { case EFI_ACPI_6_3_LOCAL_X2APIC_NMI:
{
ParseAcpi ( ParseAcpi (
TRUE, TRUE,
2, 2,
@ -456,7 +468,8 @@ ParseAcpiMadt (
break; break;
} }
default: { default:
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Unknown Interrupt Controller Structure," L"ERROR: Unknown Interrupt Controller Structure,"

View File

@ -21,18 +21,18 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
**/ **/
STATIC CONST ACPI_PARSER McfgParser[] = { STATIC CONST ACPI_PARSER McfgParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Reserved", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Reserved", 8,36, L"0x%lx", NULL, NULL, NULL, NULL },
}; };
/** /**
An ACPI_PARSER array describing the PCI configuration Space Base Address structure. An ACPI_PARSER array describing the PCI configuration Space Base Address structure.
**/ **/
STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = { STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
{L"Base Address", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL },
{L"PCI Segment Group No.", 2, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Segment Group No.", 2, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Start Bus No.", 1, 10, L"0x%x", NULL, NULL, NULL, NULL}, { L"Start Bus No.", 1, 10, L"0x%x", NULL, NULL, NULL, NULL },
{L"End Bus No.", 1, 11, L"0x%x", NULL, NULL, NULL, NULL}, { L"End Bus No.", 1, 11, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -51,14 +51,14 @@ VOID
EFIAPI EFIAPI
ParseAcpiMcfg ( ParseAcpiMcfg (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT32 PciCfgOffset; UINT32 PciCfgOffset;
UINT8* PciCfgSpacePtr; UINT8 *PciCfgSpacePtr;
if (!Trace) { if (!Trace) {
return; return;

View File

@ -19,10 +19,10 @@
// Local variables // Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC UINT32* PccGlobalFlags; STATIC UINT32 *PccGlobalFlags;
STATIC UINT8* PccSubspaceLength; STATIC UINT8 *PccSubspaceLength;
STATIC UINT8* PccSubspaceType; STATIC UINT8 *PccSubspaceType;
STATIC UINT8* ExtendedPccSubspaceInterruptFlags; STATIC UINT8 *ExtendedPccSubspaceInterruptFlags;
/** /**
This function validates the length coded on 4 bytes of a shared memory range This function validates the length coded on 4 bytes of a shared memory range
@ -35,16 +35,16 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateRangeLength4 ( ValidateRangeLength4 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) { if (*(UINT32 *)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nError: Shared memory range length is too short.\n" L"\nError: Shared memory range length is too short.\n"
L"Length is %u when it should be greater than or equal to %u", L"Length is %u when it should be greater than or equal to %u",
*(UINT32*)Ptr, *(UINT32 *)Ptr,
MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN
); );
} }
@ -61,16 +61,16 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateRangeLength8 ( ValidateRangeLength8 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT64*)Ptr <= MIN_MEMORY_RANGE_LENGTH) { if (*(UINT64 *)Ptr <= MIN_MEMORY_RANGE_LENGTH) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nError: Shared memory range length is too short.\n" L"\nError: Shared memory range length is too short.\n"
L"Length is %u when it should be greater than %u", L"Length is %u when it should be greater than %u",
*(UINT64*)Ptr, *(UINT64 *)Ptr,
MIN_MEMORY_RANGE_LENGTH MIN_MEMORY_RANGE_LENGTH
); );
} }
@ -87,14 +87,14 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePccMemoryIoGas ( ValidatePccMemoryIoGas (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
switch (*(UINT8*)Ptr) { switch (*(UINT8 *)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
case EFI_ACPI_6_4_SYSTEM_IO: case EFI_ACPI_6_4_SYSTEM_IO:
#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
case EFI_ACPI_6_4_SYSTEM_MEMORY: case EFI_ACPI_6_4_SYSTEM_MEMORY:
return; return;
default: default:
@ -114,14 +114,14 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePccGas ( ValidatePccGas (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
switch (*(UINT8*)Ptr) { switch (*(UINT8 *)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) #if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
case EFI_ACPI_6_4_SYSTEM_IO: case EFI_ACPI_6_4_SYSTEM_IO:
#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) #endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
case EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE: case EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE:
case EFI_ACPI_6_4_SYSTEM_MEMORY: case EFI_ACPI_6_4_SYSTEM_MEMORY:
return; return;
@ -142,8 +142,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePccDoorbellGas ( ValidatePccDoorbellGas (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// For slave subspaces this field is optional, if not present the field // For slave subspaces this field is optional, if not present the field
@ -152,7 +152,8 @@ ValidatePccDoorbellGas (
if (IsZeroBuffer ( if (IsZeroBuffer (
Ptr, Ptr,
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE) sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) { ))
{
return; return;
} }
} }
@ -172,8 +173,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePccIntAckGas ( ValidatePccIntAckGas (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// If the subspace does not support interrupts or the interrupt is // If the subspace does not support interrupts or the interrupt is
@ -184,11 +185,13 @@ ValidatePccIntAckGas (
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) || EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
((*ExtendedPccSubspaceInterruptFlags & ((*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)) { EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE))
{
if (IsZeroBuffer ( if (IsZeroBuffer (
Ptr, Ptr,
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE) sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) { ))
{
return; return;
} }
} }
@ -207,8 +210,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePccErrStatusGas ( ValidatePccErrStatusGas (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// This field is ignored by the OSPM on slave channels. // This field is ignored by the OSPM on slave channels.
@ -230,15 +233,16 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidatePlatInterrupt ( ValidatePlatInterrupt (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// If a slave subspace is present in the PCCT, then the global Platform // If a slave subspace is present in the PCCT, then the global Platform
// Interrupt flag must be set to 1. // Interrupt flag must be set to 1.
if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) && if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) != ((*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 (); IncrementErrorCount ();
Print ( Print (
L"\nError: Global Platform interrupt flag must be set to 1" \ L"\nError: Global Platform interrupt flag must be set to 1" \
@ -252,8 +256,8 @@ ValidatePlatInterrupt (
*/ */
STATIC CONST ACPI_PARSER PcctParser[] = { STATIC CONST ACPI_PARSER PcctParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Flags", 4, 36, NULL, NULL, (VOID**)&PccGlobalFlags, NULL, NULL}, { L"Flags", 4, 36, NULL, NULL, (VOID **)&PccGlobalFlags, NULL, NULL },
{L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL} { L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL }
}; };
/** /**
@ -270,17 +274,17 @@ STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = {
*/ */
STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = { STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
PCC_SUBSPACE_HEADER (), PCC_SUBSPACE_HEADER (),
{L"Reserved", 6, 2, L"%x %x %x %x %x %x", Dump6Chars, NULL, NULL, NULL}, { L"Reserved", 6, 2, L"%x %x %x %x %x %x", Dump6Chars, NULL, NULL, NULL },
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8, { L"Memory Range Length",8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL}, NULL },
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccMemoryIoGas, { L"Doorbell Register",12, 24, NULL, DumpGas, NULL, ValidatePccMemoryIoGas,
NULL}, NULL },
{L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Preserve",8, 36, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, { L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL },
{L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, { L"Maximum Periodic Access Rate",4, 56, L"%u", NULL, NULL, NULL, NULL },
{L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL} { L"Minimum Request Turnaround Time",2, 60, L"%u", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -289,19 +293,19 @@ STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
*/ */
STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = { STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = {
PCC_SUBSPACE_HEADER (), PCC_SUBSPACE_HEADER (),
{L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Platform Interrupt",4, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL}, { L"Platform Interrupt Flags",1, 6, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8, { L"Memory Range Length",8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL}, NULL },
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, { L"Doorbell Register",12, 24, NULL, DumpGas, NULL,
ValidatePccGas, NULL}, ValidatePccGas, NULL },
{L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Preserve",8, 36, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, { L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL },
{L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, { L"Maximum Periodic Access Rate",4, 56, L"%u", NULL, NULL, NULL, NULL },
{L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL} { L"Minimum Request Turnaround Time",2, 60, L"%u", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -310,24 +314,24 @@ STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = {
*/ */
STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = { STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = {
PCC_SUBSPACE_HEADER (), PCC_SUBSPACE_HEADER (),
{L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Platform Interrupt",4, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL}, { L"Platform Interrupt Flags",1, 6, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8, { L"Memory Range Length",8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL}, NULL },
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, { L"Doorbell Register",12, 24, NULL, DumpGas, NULL,
ValidatePccGas, NULL}, ValidatePccGas, NULL },
{L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Preserve",8, 36, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, { L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL },
{L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, { L"Maximum Periodic Access Rate",4, 56, L"%u", NULL, NULL, NULL, NULL },
{L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NULL}, { L"Minimum Request Turnaround Time",2, 60, L"%u", NULL, NULL, NULL, NULL },
{L"Platform Interrupt Ack Register", 12, 62, NULL, DumpGas, NULL, { L"Platform Interrupt Ack Register",12, 62, NULL, DumpGas, NULL,
ValidatePccGas, NULL}, ValidatePccGas, NULL },
{L"Platform Interrupt Ack Preserve", 8, 74, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Platform Interrupt Ack Preserve",8, 74, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Platform Interrupt Ack Write", 8, 82, L"0x%lx", NULL, NULL, { L"Platform Interrupt Ack Write",8, 82, L"0x%lx", NULL, NULL,
NULL, NULL}, NULL, NULL },
}; };
/** /**
@ -335,36 +339,36 @@ STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = {
*/ */
STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = { STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
PCC_SUBSPACE_HEADER (), PCC_SUBSPACE_HEADER (),
{L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, { L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL,
ValidatePlatInterrupt, NULL}, ValidatePlatInterrupt, NULL },
{L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, { L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL,
(VOID**)&ExtendedPccSubspaceInterruptFlags, NULL, NULL}, (VOID **)&ExtendedPccSubspaceInterruptFlags,NULL, NULL },
{L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 7, L"0x%x", NULL, NULL,NULL, NULL },
{L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 8, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Memory Range Length", 4, 16, L"0x%x", NULL, NULL, ValidateRangeLength4, { L"Memory Range Length", 4, 16, L"0x%x", NULL, NULL,ValidateRangeLength4,
NULL}, NULL },
{L"Doorbell Register", 12, 20, NULL, DumpGas, NULL, { L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccDoorbellGas, NULL}, ValidatePccDoorbellGas, NULL },
{L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Nominal Latency", 4, 48, L"%u", NULL, NULL, NULL, NULL}, { L"Nominal Latency", 4, 48, L"%u", NULL, NULL,NULL, NULL },
{L"Maximum Periodic Access Rate", 4, 52, L"%u", NULL, NULL, NULL, NULL}, { L"Maximum Periodic Access Rate", 4, 52, L"%u", NULL, NULL,NULL, NULL },
{L"Minimum Request Turnaround Time", 4, 56, L"%u", NULL, NULL, NULL, NULL}, { L"Minimum Request Turnaround Time", 4, 56, L"%u", NULL, NULL,NULL, NULL },
{L"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL, { L"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL,
ValidatePccIntAckGas, NULL}, ValidatePccIntAckGas, NULL },
{L"Platform Interrupt Ack Preserve", 8, 72, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Platform Interrupt Ack Preserve", 8, 72, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Platform Interrupt Ack Set", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Platform Interrupt Ack Set", 8, 80, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Reserved", 8, 88, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Reserved", 8, 88, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL, { L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL,
ValidatePccGas, NULL}, ValidatePccGas, NULL },
{L"Cmd Complete Check Mask", 8, 108, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Cmd Complete Check Mask", 8, 108, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Cmd Update Reg Addr", 12, 116, NULL, DumpGas, NULL, { L"Cmd Update Reg Addr", 12, 116, NULL, DumpGas, NULL,
ValidatePccGas, NULL}, ValidatePccGas, NULL },
{L"Cmd Update Preserve mask", 8, 128, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Cmd Update Preserve mask", 8, 128, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Cmd Update Set mask", 8, 136, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Cmd Update Set mask", 8, 136, L"0x%lx", NULL, NULL,NULL, NULL },
{L"Error Status Register", 12, 144, NULL, DumpGas, NULL, { L"Error Status Register", 12, 144, NULL, DumpGas, NULL,
ValidatePccErrStatusGas, NULL}, ValidatePccErrStatusGas, NULL },
{L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL,NULL, NULL },
}; };
/** /**
@ -373,21 +377,21 @@ STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
*/ */
STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = { STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
PCC_SUBSPACE_HEADER (), PCC_SUBSPACE_HEADER (),
{L"Version", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Version", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Shared Memory Range Length", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Shared Memory Range Length",8, 12, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Doorbell Register", 12, 20, NULL, DumpGas, NULL, { L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, NULL}, ValidatePccMemoryIoGas,NULL },
{L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Command Complete Check Register", 12, 48, NULL, DumpGas, NULL, { L"Command Complete Check Register",12, 48, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, NULL}, ValidatePccMemoryIoGas,NULL },
{L"Command Complete Check Mask", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Command Complete Check Mask",8, 60, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Error Status Register", 12, 68, NULL, DumpGas, NULL, { L"Error Status Register",12, 68, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, NULL}, ValidatePccMemoryIoGas,NULL },
{L"Error Status Mask", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL}, { L"Error Status Mask", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL },
{L"Nominal Latency", 4, 88, L"0x%x", NULL, NULL, NULL, NULL}, { L"Nominal Latency", 4, 88, L"0x%x", NULL, NULL, NULL, NULL },
{L"Minimum Request Turnaround Time", 4, 92, L"0x%x", NULL, NULL, NULL, NULL} { L"Minimum Request Turnaround Time",4, 92, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -399,7 +403,7 @@ STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
STATIC STATIC
VOID VOID
DumpPccSubspaceType0 ( DumpPccSubspaceType0 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -422,7 +426,7 @@ DumpPccSubspaceType0 (
STATIC STATIC
VOID VOID
DumpPccSubspaceType1 ( DumpPccSubspaceType1 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -445,7 +449,7 @@ DumpPccSubspaceType1 (
STATIC STATIC
VOID VOID
DumpPccSubspaceType2 ( DumpPccSubspaceType2 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -468,7 +472,7 @@ DumpPccSubspaceType2 (
STATIC STATIC
VOID VOID
DumpPccSubspaceType3 ( DumpPccSubspaceType3 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -491,7 +495,7 @@ DumpPccSubspaceType3 (
STATIC STATIC
VOID VOID
DumpPccSubspaceType4 ( DumpPccSubspaceType4 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -514,7 +518,7 @@ DumpPccSubspaceType4 (
STATIC STATIC
VOID VOID
DumpPccSubspaceType5 ( DumpPccSubspaceType5 (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -545,13 +549,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiPcct ( ParseAcpiPcct (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* PccSubspacePtr; UINT8 *PccSubspacePtr;
UINTN SubspaceCount; UINTN SubspaceCount;
if (!Trace) { if (!Trace) {
@ -584,7 +588,8 @@ ParseAcpiPcct (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((PccSubspaceType == NULL) || if ((PccSubspaceType == NULL) ||
(PccSubspaceLength == NULL)) { (PccSubspaceLength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -596,7 +601,8 @@ ParseAcpiPcct (
// Validate Structure length // Validate Structure length
if ((*PccSubspaceLength == 0) || if ((*PccSubspaceLength == 0) ||
((Offset + (*PccSubspaceLength)) > AcpiTableLength)) { ((Offset + (*PccSubspaceLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Structure length. " \ L"ERROR: Invalid Structure length. " \

View File

@ -17,9 +17,9 @@
#include "PpttParser.h" #include "PpttParser.h"
// Local variables // Local variables
STATIC CONST UINT8* ProcessorTopologyStructureType; STATIC CONST UINT8 *ProcessorTopologyStructureType;
STATIC CONST UINT8* ProcessorTopologyStructureLength; STATIC CONST UINT8 *ProcessorTopologyStructureLength;
STATIC CONST UINT32* NumberOfPrivateResources; STATIC CONST UINT32 *NumberOfPrivateResources;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -34,12 +34,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateCacheNumberOfSets ( ValidateCacheNumberOfSets (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT32 NumberOfSets; UINT32 NumberOfSets;
NumberOfSets = *(UINT32*)Ptr;
NumberOfSets = *(UINT32 *)Ptr;
if (NumberOfSets == 0) { if (NumberOfSets == 0) {
IncrementErrorCount (); IncrementErrorCount ();
@ -47,7 +48,7 @@ ValidateCacheNumberOfSets (
return; return;
} }
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) { if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
@ -68,8 +69,8 @@ ValidateCacheNumberOfSets (
); );
return; return;
} }
#endif
#endif
} }
/** /**
@ -84,12 +85,13 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateCacheAssociativity ( ValidateCacheAssociativity (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT8 Associativity; UINT8 Associativity;
Associativity = *(UINT8*)Ptr;
Associativity = *(UINT8 *)Ptr;
if (Associativity == 0) { if (Associativity == 0) {
IncrementErrorCount (); IncrementErrorCount ();
@ -109,21 +111,22 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateCacheLineSize ( ValidateCacheLineSize (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
// Reference: ARM Architecture Reference Manual ARMv8 (D.a) // Reference: ARM Architecture Reference Manual ARMv8 (D.a)
// Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register // Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register
// LineSize, bits [2:0] // LineSize, bits [2:0]
// (Log2(Number of bytes in cache line)) - 4. // (Log2(Number of bytes in cache line)) - 4.
UINT16 LineSize; UINT16 LineSize;
LineSize = *(UINT16*)Ptr; LineSize = *(UINT16 *)Ptr;
if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) || if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) ||
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) { (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: The cache line size must be between %d and %d bytes" L"\nERROR: The cache line size must be between %d and %d bytes"
@ -138,7 +141,8 @@ ValidateCacheLineSize (
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: The cache line size is not a power of 2."); Print (L"\nERROR: The cache line size is not a power of 2.");
} }
#endif
#endif
} }
/** /**
@ -152,15 +156,16 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateCacheAttributes ( ValidateCacheAttributes (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
// Reference: Advanced Configuration and Power Interface (ACPI) Specification // Reference: Advanced Configuration and Power Interface (ACPI) Specification
// Version 6.2 Errata A, September 2017 // Version 6.2 Errata A, September 2017
// Table 5-153: Cache Type Structure // Table 5-153: Cache Type Structure
UINT8 Attributes; UINT8 Attributes;
Attributes = *(UINT8*)Ptr;
Attributes = *(UINT8 *)Ptr;
if ((Attributes & 0xE0) != 0) { if ((Attributes & 0xE0) != 0) {
IncrementErrorCount (); IncrementErrorCount ();
@ -183,59 +188,59 @@ STATIC CONST ACPI_PARSER PpttParser[] = {
An ACPI_PARSER array describing the processor topology structure header. An ACPI_PARSER array describing the processor topology structure header.
**/ **/
STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser[] = { STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&ProcessorTopologyStructureType, { L"Type", 1, 0, NULL, NULL, (VOID **)&ProcessorTopologyStructureType,
NULL, NULL}, NULL, NULL },
{L"Length", 1, 1, NULL, NULL, (VOID**)&ProcessorTopologyStructureLength, { L"Length", 1, 1, NULL, NULL, (VOID **)&ProcessorTopologyStructureLength,
NULL, NULL}, NULL, NULL },
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL} { L"Reserved", 2, 2, NULL, NULL, NULL, NULL,NULL }
}; };
/** /**
An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0. An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
**/ **/
STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = { STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Number of private resources", 4, 16, L"%d", NULL, { L"Number of private resources", 4, 16, L"%d", NULL,
(VOID**)&NumberOfPrivateResources, NULL, NULL} (VOID **)&NumberOfPrivateResources, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Cache Type Structure - Type 1. An ACPI_PARSER array describing the Cache Type Structure - Type 1.
**/ **/
STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = { STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL}, { L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL },
{L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL}, { L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL },
{L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL}, { L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL },
{L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL} { L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL }
}; };
/** /**
An ACPI_PARSER array describing the ID Type Structure - Type 2. An ACPI_PARSER array describing the ID Type Structure - Type 2.
**/ **/
STATIC CONST ACPI_PARSER IdStructureParser[] = { STATIC CONST ACPI_PARSER IdStructureParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"VENDOR_ID", 4, 4, NULL, Dump4Chars, NULL, NULL, NULL}, { L"VENDOR_ID", 4, 4, NULL, Dump4Chars, NULL, NULL, NULL },
{L"LEVEL_1_ID", 8, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"LEVEL_1_ID", 8, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"LEVEL_2_ID", 8, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"LEVEL_2_ID", 8, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"MAJOR_REV", 2, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"MAJOR_REV", 2, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"MINOR_REV", 2, 26, L"0x%x", NULL, NULL, NULL, NULL}, { L"MINOR_REV", 2, 26, L"0x%x", NULL, NULL, NULL, NULL },
{L"SPIN_REV", 2, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"SPIN_REV", 2, 28, L"0x%x", NULL, NULL, NULL, NULL },
}; };
/** /**
@ -248,7 +253,7 @@ STATIC CONST ACPI_PARSER IdStructureParser[] = {
STATIC STATIC
VOID VOID
DumpProcessorHierarchyNodeStructure ( DumpProcessorHierarchyNodeStructure (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -304,7 +309,7 @@ DumpProcessorHierarchyNodeStructure (
PrintFieldName (4, Buffer); PrintFieldName (4, Buffer);
Print ( Print (
L"0x%x\n", L"0x%x\n",
*((UINT32*)(Ptr + Offset)) *((UINT32 *)(Ptr + Offset))
); );
Offset += sizeof (UINT32); Offset += sizeof (UINT32);
@ -321,7 +326,7 @@ DumpProcessorHierarchyNodeStructure (
STATIC STATIC
VOID VOID
DumpCacheTypeStructure ( DumpCacheTypeStructure (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -344,7 +349,7 @@ DumpCacheTypeStructure (
STATIC STATIC
VOID VOID
DumpIDStructure ( DumpIDStructure (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT8 Length IN UINT8 Length
) )
{ {
@ -379,13 +384,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiPptt ( ParseAcpiPptt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* ProcessorTopologyStructurePtr; UINT8 *ProcessorTopologyStructurePtr;
if (!Trace) { if (!Trace) {
return; return;
@ -416,7 +421,8 @@ ParseAcpiPptt (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((ProcessorTopologyStructureType == NULL) || if ((ProcessorTopologyStructureType == NULL) ||
(ProcessorTopologyStructureLength == NULL)) { (ProcessorTopologyStructureLength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -428,7 +434,8 @@ ParseAcpiPptt (
// Validate Processor Topology Structure length // Validate Processor Topology Structure length
if ((*ProcessorTopologyStructureLength == 0) || if ((*ProcessorTopologyStructureLength == 0) ||
((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)) { ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Processor Topology Structure length. " \ L"ERROR: Invalid Processor Topology Structure length. " \

View File

@ -13,7 +13,7 @@
#include "AcpiTableParser.h" #include "AcpiTableParser.h"
// Local Variables // Local Variables
STATIC CONST UINT64* XsdtAddress; STATIC CONST UINT64 *XsdtAddress;
/** /**
This function validates the RSDT Address. This function validates the RSDT Address.
@ -26,11 +26,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateRsdtAddress ( ValidateRsdtAddress (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
// Reference: Server Base Boot Requirements System Software on ARM Platforms // Reference: Server Base Boot Requirements System Software on ARM Platforms
// Section: 4.2.1.1 RSDP // Section: 4.2.1.1 RSDP
// Root System Description Pointer (RSDP), ACPI ? 5.2.5. // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
@ -38,7 +38,7 @@ ValidateRsdtAddress (
// XsdtAddresss MUST be a valid, non-null, 64-bit value. // XsdtAddresss MUST be a valid, non-null, 64-bit value.
UINT32 RsdtAddr; UINT32 RsdtAddr;
RsdtAddr = *(UINT32*)Ptr; RsdtAddr = *(UINT32 *)Ptr;
if (RsdtAddr != 0) { if (RsdtAddr != 0) {
IncrementErrorCount (); IncrementErrorCount ();
@ -47,7 +47,8 @@ ValidateRsdtAddress (
RsdtAddr RsdtAddr
); );
} }
#endif
#endif
} }
/** /**
@ -61,11 +62,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateXsdtAddress ( ValidateXsdtAddress (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
// Reference: Server Base Boot Requirements System Software on ARM Platforms // Reference: Server Base Boot Requirements System Software on ARM Platforms
// Section: 4.2.1.1 RSDP // Section: 4.2.1.1 RSDP
// Root System Description Pointer (RSDP), ACPI ? 5.2.5. // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
@ -73,7 +74,7 @@ ValidateXsdtAddress (
// XsdtAddresss MUST be a valid, non-null, 64-bit value. // XsdtAddresss MUST be a valid, non-null, 64-bit value.
UINT64 XsdtAddr; UINT64 XsdtAddr;
XsdtAddr = *(UINT64*)Ptr; XsdtAddr = *(UINT64 *)Ptr;
if (XsdtAddr == 0) { if (XsdtAddr == 0) {
IncrementErrorCount (); IncrementErrorCount ();
@ -82,23 +83,24 @@ ValidateXsdtAddress (
XsdtAddr XsdtAddr
); );
} }
#endif
#endif
} }
/** /**
An array describing the ACPI RSDP Table. An array describing the ACPI RSDP Table.
**/ **/
STATIC CONST ACPI_PARSER RsdpParser[] = { STATIC CONST ACPI_PARSER RsdpParser[] = {
{L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL}, { L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL },
{L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL}, { L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL },
{L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL}, { L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL },
{L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL}, { L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL },
{L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL}, { L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL },
{L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID**)&XsdtAddress, { L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID **)&XsdtAddress,
ValidateXsdtAddress, NULL}, ValidateXsdtAddress, NULL },
{L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL}, { L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} { L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
}; };
/** /**
@ -119,7 +121,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiRsdp ( ParseAcpiRsdp (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
@ -160,5 +162,5 @@ ParseAcpiRsdp (
return; return;
} }
ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress)); ProcessAcpiTable ((UINT8 *)(UINTN)(*XsdtAddress));
} }

View File

@ -15,7 +15,7 @@
#include "AcpiTableParser.h" #include "AcpiTableParser.h"
// Local Variables // Local Variables
STATIC CONST UINT64* SlitSystemLocalityCount; STATIC CONST UINT64 *SlitSystemLocalityCount;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -23,8 +23,8 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
**/ **/
STATIC CONST ACPI_PARSER SlitParser[] = { STATIC CONST ACPI_PARSER SlitParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Number of System Localities", 8, 36, L"0x%lx", NULL, { L"Number of System Localities", 8, 36, L"0x%lx", NULL,
(VOID**)&SlitSystemLocalityCount, NULL, NULL} (VOID **)&SlitSystemLocalityCount,NULL, NULL }
}; };
/** /**
@ -51,7 +51,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSlit ( ParseAcpiSlit (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
@ -60,7 +60,7 @@ ParseAcpiSlit (
UINT32 Count; UINT32 Count;
UINT32 Index; UINT32 Index;
UINT32 LocalityCount; UINT32 LocalityCount;
UINT8* LocalityPtr; UINT8 *LocalityPtr;
CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi
if (!Trace) { if (!Trace) {
@ -144,12 +144,14 @@ ParseAcpiSlit (
for (Index = 0; Index < LocalityCount; Index++) { for (Index = 0; Index < LocalityCount; Index++) {
Print (L" (%3d) ", Index); Print (L" (%3d) ", Index);
} }
Print (L"\n"); Print (L"\n");
for (Count = 0; Count< LocalityCount; Count++) { for (Count = 0; Count < LocalityCount; Count++) {
Print (L" (%3d) ", Count); Print (L" (%3d) ", Count);
for (Index = 0; Index < LocalityCount; Index++) { for (Index = 0; Index < LocalityCount; Index++) {
Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index)); Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index));
} }
Print (L"\n"); Print (L"\n");
} }
} }
@ -158,7 +160,7 @@ ParseAcpiSlit (
for (Count = 0; Count < LocalityCount; Count++) { for (Count = 0; Count < LocalityCount; Count++) {
for (Index = 0; Index < LocalityCount; Index++) { for (Index = 0; Index < LocalityCount; Index++) {
// Element[x][x] must be equal to 10 // Element[x][x] must be equal to 10
if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) { if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count, Index) != 10)) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)." L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
@ -168,9 +170,11 @@ ParseAcpiSlit (
SLIT_ELEMENT (LocalityPtr, Count, Index) SLIT_ELEMENT (LocalityPtr, Count, Index)
); );
} }
// Element[i][j] must be equal to Element[j][i] // Element[i][j] must be equal to Element[j][i]
if (SLIT_ELEMENT (LocalityPtr, Count, Index) != if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
SLIT_ELEMENT (LocalityPtr, Index, Count)) { SLIT_ELEMENT (LocalityPtr, Index, Count))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n" L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"

View File

@ -29,24 +29,26 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateInterruptType ( ValidateInterruptType (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 InterruptType; UINT8 InterruptType;
InterruptType = *Ptr; InterruptType = *Ptr;
if (InterruptType != if (InterruptType !=
EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) { EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC)
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms", L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
InterruptType InterruptType
); );
} }
#endif
#endif
} }
/** /**
@ -60,11 +62,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateIrq ( ValidateIrq (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 Irq; UINT8 Irq;
Irq = *Ptr; Irq = *Ptr;
@ -76,7 +78,8 @@ ValidateIrq (
Irq Irq
); );
} }
#endif
#endif
} }
/** /**
@ -84,27 +87,27 @@ ValidateIrq (
**/ **/
STATIC CONST ACPI_PARSER SpcrParser[] = { STATIC CONST ACPI_PARSER SpcrParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL}, { L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, { L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL },
{L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL}, { L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL },
{L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL}, { L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL },
{L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL}, { L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL },
{L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL}, { L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL },
{L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL}, { L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL },
{L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL}, { L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL },
{L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL}, { L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL },
{L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL },
{L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL}, { L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL },
{L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -123,7 +126,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSpcr ( ParseAcpiSpcr (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )

View File

@ -16,9 +16,9 @@
#include "AcpiViewConfig.h" #include "AcpiViewConfig.h"
// Local Variables // Local Variables
STATIC CONST UINT8* SratRAType; STATIC CONST UINT8 *SratRAType;
STATIC CONST UINT8* SratRALength; STATIC CONST UINT8 *SratRALength;
STATIC CONST UINT8* SratDeviceHandleType; STATIC CONST UINT8 *SratDeviceHandleType;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** /**
@ -32,11 +32,11 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateSratReserved ( ValidateSratReserved (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
if (*(UINT32*)Ptr != 1) { if (*(UINT32 *)Ptr != 1) {
IncrementErrorCount (); IncrementErrorCount ();
Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n"); Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n");
} }
@ -54,8 +54,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
ValidateSratDeviceHandleType ( ValidateSratDeviceHandleType (
IN UINT8* Ptr, IN UINT8 *Ptr,
IN VOID* Context IN VOID *Context
) )
{ {
UINT8 DeviceHandleType; UINT8 DeviceHandleType;
@ -82,8 +82,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
DumpSratPciBdfNumber ( DumpSratPciBdfNumber (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
@ -144,19 +144,19 @@ DumpSratPciBdfNumber (
An ACPI_PARSER array describing the Device Handle - ACPI An ACPI_PARSER array describing the Device Handle - ACPI
**/ **/
STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = { STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = {
{L"ACPI_HID", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL}, { L"ACPI_HID", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL },
{L"ACPI_UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI_UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Device Handle - PCI An ACPI_PARSER array describing the Device Handle - PCI
**/ **/
STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = { STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = {
{L"PCI Segment", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"PCI Segment", 2, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"PCI BDF Number", 2, 2, NULL, DumpSratPciBdfNumber, NULL, NULL, NULL}, { L"PCI BDF Number", 2, 2, NULL, DumpSratPciBdfNumber, NULL, NULL, NULL },
{L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12Chars, { L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12Chars,
NULL, NULL, NULL} NULL, NULL, NULL }
}; };
/** /**
@ -170,8 +170,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
DumpSratDeviceHandle ( DumpSratDeviceHandle (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
if (SratDeviceHandleType == NULL) { if (SratDeviceHandleType == NULL) {
@ -213,8 +213,8 @@ STATIC
VOID VOID
EFIAPI EFIAPI
DumpSratApicProximity ( DumpSratApicProximity (
IN CONST CHAR16* Format, IN CONST CHAR16 *Format,
IN UINT8* Ptr IN UINT8 *Ptr
) )
{ {
UINT32 ProximityDomain; UINT32 ProximityDomain;
@ -229,106 +229,106 @@ DumpSratApicProximity (
**/ **/
STATIC CONST ACPI_PARSER SratParser[] = { STATIC CONST ACPI_PARSER SratParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo), PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Reserved", 4, 36, L"0x%x", NULL, NULL, ValidateSratReserved, NULL}, { L"Reserved", 4, 36, L"0x%x", NULL, NULL, ValidateSratReserved, NULL },
{L"Reserved", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL} { L"Reserved", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Resource Allocation structure header. An ACPI_PARSER array describing the Resource Allocation structure header.
**/ **/
STATIC CONST ACPI_PARSER SratResourceAllocationParser[] = { STATIC CONST ACPI_PARSER SratResourceAllocationParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&SratRAType, NULL, NULL}, { L"Type", 1, 0, NULL, NULL, (VOID **)&SratRAType, NULL, NULL },
{L"Length", 1, 1, NULL, NULL, (VOID**)&SratRALength, NULL, NULL} { L"Length", 1, 1, NULL, NULL, (VOID **)&SratRALength, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GICC Affinity structure. An ACPI_PARSER array describing the GICC Affinity structure.
**/ **/
STATIC CONST ACPI_PARSER SratGicCAffinityParser[] = { STATIC CONST ACPI_PARSER SratGicCAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"ACPI Processor UID", 4, 6, L"0x%x", NULL, NULL, NULL, NULL}, { L"ACPI Processor UID", 4, 6, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 10, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 10, L"0x%x", NULL, NULL, NULL, NULL },
{L"Clock Domain", 4, 14, L"0x%x", NULL, NULL, NULL, NULL} { L"Clock Domain", 4, 14, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the GIC ITS Affinity structure. An ACPI_PARSER array describing the GIC ITS Affinity structure.
**/ **/
STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = { STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL },
{L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
}; };
/** /**
An ACPI_PARSER array describing the Generic Initiator Affinity Structure An ACPI_PARSER array describing the Generic Initiator Affinity Structure
**/ **/
STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = { STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Device Handle Type", 1, 3, L"%d", NULL, (VOID**)&SratDeviceHandleType, { L"Device Handle Type", 1, 3, L"%d", NULL, (VOID **)&SratDeviceHandleType,
ValidateSratDeviceHandleType, NULL}, ValidateSratDeviceHandleType, NULL },
{L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL, NULL}, { L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL, NULL },
{L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Memory Affinity structure. An ACPI_PARSER array describing the Memory Affinity structure.
**/ **/
STATIC CONST ACPI_PARSER SratMemAffinityParser[] = { STATIC CONST ACPI_PARSER SratMemAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain", 4, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address Low", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Base Address Low", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Base Address High", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Base Address High", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length Low", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length Low", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length High", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length High", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 28, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL} { L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the APIC/SAPIC Affinity structure. An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
**/ **/
STATIC CONST ACPI_PARSER SratApciSapicAffinityParser[] = { STATIC CONST ACPI_PARSER SratApciSapicAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain [7:0]", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain [7:0]", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"APIC ID", 1, 3, L"0x%x", NULL, NULL, NULL, NULL}, { L"APIC ID", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"Local SAPIC EID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"Local SAPIC EID", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity, { L"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity,
NULL, NULL, NULL}, NULL, NULL, NULL },
{L"Clock Domain", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} { L"Clock Domain", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure. An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure.
**/ **/
STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = { STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, { L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, { L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, { L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, { L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{L"X2APIC ID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, { L"X2APIC ID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, { L"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{L"Clock Domain", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, { L"Clock Domain", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL} { L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL }
}; };
/** /**
@ -353,13 +353,13 @@ VOID
EFIAPI EFIAPI
ParseAcpiSrat ( ParseAcpiSrat (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT8* ResourcePtr; UINT8 *ResourcePtr;
UINT32 GicCAffinityIndex; UINT32 GicCAffinityIndex;
UINT32 GicITSAffinityIndex; UINT32 GicITSAffinityIndex;
UINT32 GenericInitiatorAffinityIndex; UINT32 GenericInitiatorAffinityIndex;
@ -403,7 +403,8 @@ ParseAcpiSrat (
// Check if the values used to control the parsing logic have been // Check if the values used to control the parsing logic have been
// successfully read. // successfully read.
if ((SratRAType == NULL) || if ((SratRAType == NULL) ||
(SratRALength == NULL)) { (SratRALength == NULL))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Insufficient remaining table buffer length to read the " \ L"ERROR: Insufficient remaining table buffer length to read the " \
@ -415,7 +416,8 @@ ParseAcpiSrat (
// Validate Static Resource Allocation Structure length // Validate Static Resource Allocation Structure length
if ((*SratRALength == 0) || if ((*SratRALength == 0) ||
((Offset + (*SratRALength)) > AcpiTableLength)) { ((Offset + (*SratRALength)) > AcpiTableLength))
{
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid Static Resource Allocation Structure length. " \ L"ERROR: Invalid Static Resource Allocation Structure length. " \

View File

@ -29,7 +29,7 @@ VOID
EFIAPI EFIAPI
ParseAcpiSsdt ( ParseAcpiSsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )

View File

@ -30,7 +30,7 @@ CONST ACPI_DESCRIPTION_HEADER_INFO *
EFIAPI EFIAPI
GetAcpiXsdtHeaderInfo ( GetAcpiXsdtHeaderInfo (
VOID VOID
) )
{ {
return &AcpiHdrInfo; return &AcpiHdrInfo;
} }
@ -49,14 +49,14 @@ VOID
EFIAPI EFIAPI
ParseAcpiXsdt ( ParseAcpiXsdt (
IN BOOLEAN Trace, IN BOOLEAN Trace,
IN UINT8* Ptr, IN UINT8 *Ptr,
IN UINT32 AcpiTableLength, IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision IN UINT8 AcpiTableRevision
) )
{ {
UINT32 Offset; UINT32 Offset;
UINT32 TableOffset; UINT32 TableOffset;
UINT64* TablePointer; UINT64 *TablePointer;
UINTN EntryIndex; UINTN EntryIndex;
CHAR16 Buffer[32]; CHAR16 Buffer[32];
@ -73,23 +73,23 @@ ParseAcpiXsdt (
if (Trace) { if (Trace) {
EntryIndex = 0; EntryIndex = 0;
TablePointer = (UINT64*)(Ptr + TableOffset); TablePointer = (UINT64 *)(Ptr + TableOffset);
while (Offset < AcpiTableLength) { while (Offset < AcpiTableLength) {
CONST UINT32* Signature; CONST UINT32 *Signature;
CONST UINT32* Length; CONST UINT32 *Length;
CONST UINT8* Revision; CONST UINT8 *Revision;
if ((UINT64*)(UINTN)(*TablePointer) != NULL) { if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
UINT8* SignaturePtr; UINT8 *SignaturePtr;
ParseAcpiHeader ( ParseAcpiHeader (
(UINT8*)(UINTN)(*TablePointer), (UINT8 *)(UINTN)(*TablePointer),
&Signature, &Signature,
&Length, &Length,
&Revision &Revision
); );
SignaturePtr = (UINT8*)Signature; SignaturePtr = (UINT8 *)Signature;
UnicodeSPrint ( UnicodeSPrint (
Buffer, Buffer,
@ -114,7 +114,7 @@ ParseAcpiXsdt (
Print (L"0x%lx\n", *TablePointer); Print (L"0x%lx\n", *TablePointer);
// Validate the table pointers are not NULL // Validate the table pointers are not NULL
if ((UINT64*)(UINTN)(*TablePointer) == NULL) { if ((UINT64 *)(UINTN)(*TablePointer) == NULL) {
IncrementErrorCount (); IncrementErrorCount ();
Print ( Print (
L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n", L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n",
@ -122,6 +122,7 @@ ParseAcpiXsdt (
*TablePointer *TablePointer
); );
} }
Offset += sizeof (UINT64); Offset += sizeof (UINT64);
TablePointer++; TablePointer++;
} // while } // while
@ -129,11 +130,12 @@ ParseAcpiXsdt (
// Process the tables // Process the tables
Offset = TableOffset; Offset = TableOffset;
TablePointer = (UINT64*)(Ptr + TableOffset); TablePointer = (UINT64 *)(Ptr + TableOffset);
while (Offset < AcpiTableLength) { while (Offset < AcpiTableLength) {
if ((UINT64*)(UINTN)(*TablePointer) != NULL) { if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer)); ProcessAcpiTable ((UINT8 *)(UINTN)(*TablePointer));
} }
Offset += sizeof (UINT64); Offset += sizeof (UINT64);
TablePointer++; TablePointer++;
} // while } // while

View File

@ -32,13 +32,13 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
An array of acpiview command line parameters. An array of acpiview command line parameters.
**/ **/
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-q", TypeFlag}, { L"-q", TypeFlag },
{L"-d", TypeFlag}, { L"-d", TypeFlag },
{L"-h", TypeFlag}, { L"-h", TypeFlag },
{L"-l", TypeFlag}, { L"-l", TypeFlag },
{L"-s", TypeValue}, { L"-s", TypeValue },
{L"-r", TypeValue}, { L"-r", TypeValue },
{NULL, TypeMax} { NULL, TypeMax }
}; };
/** /**
@ -47,29 +47,29 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
STATIC STATIC
CONST CONST
ACPI_TABLE_PARSER ParserList[] = { ACPI_TABLE_PARSER ParserList[] = {
{EFI_ACPI_6_3_ARM_ERROR_SOURCE_TABLE_SIGNATURE, ParseAcpiAest}, { EFI_ACPI_6_3_ARM_ERROR_SOURCE_TABLE_SIGNATURE, ParseAcpiAest },
{EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, ParseAcpiBgrt}, { EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, ParseAcpiBgrt },
{EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2}, { EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2 },
{EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, { EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
ParseAcpiDsdt}, ParseAcpiDsdt },
{EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs}, { EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs },
{EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt}, { EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt },
{EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt}, { EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt },
{EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiHmat}, { EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiHmat },
{EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort}, { EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort },
{EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMadt}, { EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMadt },
{EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, { EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
ParseAcpiMcfg}, ParseAcpiMcfg },
{EFI_ACPI_6_4_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE, { EFI_ACPI_6_4_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE,
ParseAcpiPcct}, ParseAcpiPcct },
{EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, { EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
ParseAcpiPptt}, ParseAcpiPptt },
{RSDP_TABLE_INFO, ParseAcpiRsdp}, { RSDP_TABLE_INFO, ParseAcpiRsdp },
{EFI_ACPI_6_2_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE, ParseAcpiSlit}, { EFI_ACPI_6_2_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE, ParseAcpiSlit },
{EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, ParseAcpiSpcr}, { EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, ParseAcpiSpcr },
{EFI_ACPI_6_2_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat}, { EFI_ACPI_6_2_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat },
{EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt}, { EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt },
{EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiXsdt} { EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiXsdt }
}; };
/** /**
@ -101,6 +101,7 @@ RegisterAllParsers (
return Status; return Status;
} }
} }
return Status; return Status;
} }
@ -116,8 +117,8 @@ RegisterAllParsers (
UINTN UINTN
EFIAPI EFIAPI
ShellDumpBufferToFile ( ShellDumpBufferToFile (
IN CONST CHAR16* FileNameBuffer, IN CONST CHAR16 *FileNameBuffer,
IN CONST VOID* Buffer, IN CONST VOID *Buffer,
IN CONST UINTN BufferSize IN CONST UINTN BufferSize
) )
{ {
@ -148,7 +149,7 @@ ShellDumpBufferToFile (
Status = ShellWriteFile ( Status = ShellWriteFile (
DumpFileHandle, DumpFileHandle,
&TransferBytes, &TransferBytes,
(VOID *) Buffer (VOID *)Buffer
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -167,7 +168,7 @@ ShellDumpBufferToFile (
@return The string pointer to the file name. @return The string pointer to the file name.
**/ **/
CONST CHAR16* CONST CHAR16 *
EFIAPI EFIAPI
ShellCommandGetManFileNameAcpiView ( ShellCommandGetManFileNameAcpiView (
VOID VOID
@ -190,16 +191,16 @@ SHELL_STATUS
EFIAPI EFIAPI
ShellCommandRunAcpiView ( ShellCommandRunAcpiView (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE* SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
SHELL_STATUS ShellStatus; SHELL_STATUS ShellStatus;
LIST_ENTRY* Package; LIST_ENTRY *Package;
CHAR16* ProblemParam; CHAR16 *ProblemParam;
SHELL_FILE_HANDLE TmpDumpFileHandle; SHELL_FILE_HANDLE TmpDumpFileHandle;
CONST CHAR16* MandatoryTableSpecStr; CONST CHAR16 *MandatoryTableSpecStr;
CONST CHAR16* SelectedTableName; CONST CHAR16 *SelectedTableName;
// Set configuration defaults // Set configuration defaults
AcpiConfigSetDefaults (); AcpiConfigSetDefaults ();
@ -210,7 +211,7 @@ ShellCommandRunAcpiView (
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1,
-1, -1,
@ -224,6 +225,7 @@ ShellCommandRunAcpiView (
} else { } else {
Print (L"acpiview: Error processing input parameter(s)\n"); Print (L"acpiview: Error processing input parameter(s)\n");
} }
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (ShellCommandLineGetCount (Package) > 1) { if (ShellCommandLineGetCount (Package) > 1) {
@ -246,7 +248,8 @@ ShellCommandRunAcpiView (
L"acpiview" L"acpiview"
); );
} else if (ShellCommandLineGetFlag (Package, L"-s") && } else if (ShellCommandLineGetFlag (Package, L"-s") &&
ShellCommandLineGetValue (Package, L"-s") == NULL) { (ShellCommandLineGetValue (Package, L"-s") == NULL))
{
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1,
-1, -1,
@ -258,7 +261,8 @@ ShellCommandRunAcpiView (
); );
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag (Package, L"-r") && } else if (ShellCommandLineGetFlag (Package, L"-r") &&
ShellCommandLineGetValue (Package, L"-r") == NULL) { (ShellCommandLineGetValue (Package, L"-r") == NULL))
{
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1,
-1, -1,
@ -270,7 +274,8 @@ ShellCommandRunAcpiView (
); );
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if ((ShellCommandLineGetFlag (Package, L"-s") && } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
ShellCommandLineGetFlag (Package, L"-l"))) { ShellCommandLineGetFlag (Package, L"-l")))
{
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1,
-1, -1,
@ -281,7 +286,8 @@ ShellCommandRunAcpiView (
); );
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag (Package, L"-d") && } else if (ShellCommandLineGetFlag (Package, L"-d") &&
!ShellCommandLineGetFlag (Package, L"-s")) { !ShellCommandLineGetFlag (Package, L"-s"))
{
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1,
-1, -1,
@ -349,6 +355,7 @@ ShellCommandRunAcpiView (
); );
goto Done; goto Done;
} }
// Delete Temporary file. // Delete Temporary file.
ShellDeleteFile (&TmpDumpFileHandle); ShellDeleteFile (&TmpDumpFileHandle);
} // -d } // -d
@ -367,6 +374,7 @@ Done:
if (Package != NULL) { if (Package != NULL) {
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
return ShellStatus; return ShellStatus;
} }
@ -390,6 +398,7 @@ UefiShellAcpiViewCommandLibConstructor (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
gShellAcpiViewHiiHandle = NULL; gShellAcpiViewHiiHandle = NULL;
// Check Shell Profile Debug1 bit of the profiles mask // Check Shell Profile Debug1 bit of the profiles mask
@ -412,6 +421,7 @@ UefiShellAcpiViewCommandLibConstructor (
if (gShellAcpiViewHiiHandle == NULL) { if (gShellAcpiViewHiiHandle == NULL) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// Install our Shell command handler // Install our Shell command handler
ShellCommandRegisterCommandName ( ShellCommandRegisterCommandName (
L"acpiview", L"acpiview",
@ -443,5 +453,6 @@ UefiShellAcpiViewCommandLibDestructor (
if (gShellAcpiViewHiiHandle != NULL) { if (gShellAcpiViewHiiHandle != NULL) {
HiiRemovePackages (gShellAcpiViewHiiHandle); HiiRemovePackages (gShellAcpiViewHiiHandle);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -51,14 +51,15 @@ ShellCEntryLib (
EfiShellParametersProtocol = NULL; EfiShellParametersProtocol = NULL;
EfiShellInterface = NULL; EfiShellInterface = NULL;
Status = SystemTable->BootServices->OpenProtocol(ImageHandle, Status = SystemTable->BootServices->OpenProtocol (
ImageHandle,
&gEfiShellParametersProtocolGuid, &gEfiShellParametersProtocolGuid,
(VOID **)&EfiShellParametersProtocol, (VOID **)&EfiShellParametersProtocol,
ImageHandle, ImageHandle,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
// //
// use shell 2.0 interface // use shell 2.0 interface
// //
@ -70,14 +71,15 @@ ShellCEntryLib (
// //
// try to get shell 1.0 interface instead. // try to get shell 1.0 interface instead.
// //
Status = SystemTable->BootServices->OpenProtocol(ImageHandle, Status = SystemTable->BootServices->OpenProtocol (
ImageHandle,
&gEfiShellInterfaceGuid, &gEfiShellInterfaceGuid,
(VOID **)&EfiShellInterface, (VOID **)&EfiShellInterface,
ImageHandle, ImageHandle,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
// //
// use shell 1.0 interface // use shell 1.0 interface
// //
@ -86,8 +88,9 @@ ShellCEntryLib (
EfiShellInterface->Argv EfiShellInterface->Argv
); );
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} }
return ReturnFromMain; return ReturnFromMain;
} }

View File

@ -13,8 +13,6 @@
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Protocol/SimpleFileSystem.h> #include <Protocol/SimpleFileSystem.h>
typedef enum { typedef enum {
MTDTypeUnknown, MTDTypeUnknown,
MTDTypeFloppy, MTDTypeFloppy,
@ -62,10 +60,9 @@ typedef struct {
UINT8 Type; UINT8 Type;
UINT8 SubType; UINT8 SubType;
SERIAL_DECODE_FUNCTION SerialFun; SERIAL_DECODE_FUNCTION SerialFun;
INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2); INTN (EFIAPI *CompareFun)(EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);
} DEV_PATH_CONSIST_MAPPING_TABLE; } DEV_PATH_CONSIST_MAPPING_TABLE;
/** /**
Concatenates a formatted unicode string to allocated pool. Concatenates a formatted unicode string to allocated pool.
The caller must free the resulting buffer. The caller must free the resulting buffer.
@ -112,13 +109,14 @@ CatPrint (
Str->Str Str->Str
); );
} }
if (NewStr == NULL) { if (NewStr == NULL) {
FreePool (AppendStr); FreePool (AppendStr);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Str->Str = NewStr; Str->Str = NewStr;
StrCatS (Str->Str, StringSize/sizeof(CHAR16), AppendStr); StrCatS (Str->Str, StringSize/sizeof (CHAR16), AppendStr);
Str->Len = StringSize; Str->Len = StringSize;
FreePool (AppendStr); FreePool (AppendStr);
@ -197,6 +195,7 @@ AppendCSDNum (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (MappingItem != NULL); ASSERT (MappingItem != NULL);
if (MappingItem->Digital) { if (MappingItem->Digital) {
@ -288,11 +287,11 @@ AppendCSDStr (
// 0 1 2 3 4 5 6 7 8 9 a b c d e f // 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 // 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'); 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'); 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'); Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');
} }
@ -302,7 +301,7 @@ AppendCSDStr (
} }
} }
MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital); MappingItem->Digital = (BOOLEAN) !(MappingItem->Digital);
return (EFI_SUCCESS); return (EFI_SUCCESS);
} }
@ -355,17 +354,17 @@ DevPathCompareAcpi (
ACPI_HID_DEVICE_PATH *Acpi1; ACPI_HID_DEVICE_PATH *Acpi1;
ACPI_HID_DEVICE_PATH *Acpi2; ACPI_HID_DEVICE_PATH *Acpi2;
if (DevicePath1 == NULL || DevicePath2 == NULL) { if ((DevicePath1 == NULL) || (DevicePath2 == NULL)) {
return (-2); return (-2);
} }
Acpi1 = (ACPI_HID_DEVICE_PATH *) DevicePath1; Acpi1 = (ACPI_HID_DEVICE_PATH *)DevicePath1;
Acpi2 = (ACPI_HID_DEVICE_PATH *) DevicePath2; 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; return 1;
} }
if (Acpi1->HID == Acpi2->HID && Acpi1->UID == Acpi2->UID) { if ((Acpi1->HID == Acpi2->HID) && (Acpi1->UID == Acpi2->UID)) {
return 0; return 0;
} }
@ -391,16 +390,16 @@ DevPathComparePci (
PCI_DEVICE_PATH *Pci1; PCI_DEVICE_PATH *Pci1;
PCI_DEVICE_PATH *Pci2; PCI_DEVICE_PATH *Pci2;
ASSERT(DevicePath1 != NULL); ASSERT (DevicePath1 != NULL);
ASSERT(DevicePath2 != NULL); ASSERT (DevicePath2 != NULL);
Pci1 = (PCI_DEVICE_PATH *) DevicePath1; Pci1 = (PCI_DEVICE_PATH *)DevicePath1;
Pci2 = (PCI_DEVICE_PATH *) DevicePath2; 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; return 1;
} }
if (Pci1->Device == Pci2->Device && Pci1->Function == Pci2->Function) { if ((Pci1->Device == Pci2->Device) && (Pci1->Function == Pci2->Function)) {
return 0; return 0;
} }
@ -427,8 +426,8 @@ DevPathCompareDefault (
UINTN DevPathSize1; UINTN DevPathSize1;
UINTN DevPathSize2; UINTN DevPathSize2;
ASSERT(DevicePath1 != NULL); ASSERT (DevicePath1 != NULL);
ASSERT(DevicePath2 != NULL); ASSERT (DevicePath2 != NULL);
DevPathSize1 = DevicePathNodeLength (DevicePath1); DevPathSize1 = DevicePathNodeLength (DevicePath1);
DevPathSize2 = DevicePathNodeLength (DevicePath2); DevPathSize2 = DevicePathNodeLength (DevicePath2);
@ -460,10 +459,10 @@ DevPathSerialHardDrive (
{ {
HARDDRIVE_DEVICE_PATH *Hd; HARDDRIVE_DEVICE_PATH *Hd;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Hd = (HARDDRIVE_DEVICE_PATH *) DevicePathNode; Hd = (HARDDRIVE_DEVICE_PATH *)DevicePathNode;
if (MappingItem->Mtd == MTDTypeUnknown) { if (MappingItem->Mtd == MTDTypeUnknown) {
MappingItem->Mtd = MTDTypeHardDisk; MappingItem->Mtd = MTDTypeHardDisk;
} }
@ -490,10 +489,10 @@ DevPathSerialAtapi (
{ {
ATAPI_DEVICE_PATH *Atapi; ATAPI_DEVICE_PATH *Atapi;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Atapi = (ATAPI_DEVICE_PATH *) DevicePathNode; Atapi = (ATAPI_DEVICE_PATH *)DevicePathNode;
return AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster)); return AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster));
} }
@ -516,10 +515,10 @@ DevPathSerialCdRom (
{ {
CDROM_DEVICE_PATH *Cd; CDROM_DEVICE_PATH *Cd;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Cd = (CDROM_DEVICE_PATH *) DevicePathNode; Cd = (CDROM_DEVICE_PATH *)DevicePathNode;
MappingItem->Mtd = MTDTypeCDRom; MappingItem->Mtd = MTDTypeCDRom;
return AppendCSDNum (MappingItem, Cd->BootEntry); return AppendCSDNum (MappingItem, Cd->BootEntry);
} }
@ -544,14 +543,15 @@ DevPathSerialFibre (
EFI_STATUS Status; EFI_STATUS Status;
FIBRECHANNEL_DEVICE_PATH *Fibre; FIBRECHANNEL_DEVICE_PATH *Fibre;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Fibre = (FIBRECHANNEL_DEVICE_PATH *) DevicePathNode; Fibre = (FIBRECHANNEL_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, Fibre->WWN); Status = AppendCSDNum (MappingItem, Fibre->WWN);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Fibre->Lun); Status = AppendCSDNum (MappingItem, Fibre->Lun);
} }
return Status; return Status;
} }
@ -575,20 +575,23 @@ DevPathSerialUart (
EFI_STATUS Status; EFI_STATUS Status;
UART_DEVICE_PATH *Uart; UART_DEVICE_PATH *Uart;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Uart = (UART_DEVICE_PATH *) DevicePathNode; Uart = (UART_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, Uart->BaudRate); Status = AppendCSDNum (MappingItem, Uart->BaudRate);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Uart->DataBits); Status = AppendCSDNum (MappingItem, Uart->DataBits);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Uart->Parity); Status = AppendCSDNum (MappingItem, Uart->Parity);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Uart->StopBits); Status = AppendCSDNum (MappingItem, Uart->StopBits);
} }
return Status; return Status;
} }
@ -615,11 +618,10 @@ DevPathSerialUsb (
EFI_STATUS Status; EFI_STATUS Status;
USB_INTERFACE_DESCRIPTOR InterfaceDesc; USB_INTERFACE_DESCRIPTOR InterfaceDesc;
ASSERT (DevicePathNode != NULL);
ASSERT (MappingItem != NULL);
ASSERT(DevicePathNode != NULL); Usb = (USB_DEVICE_PATH *)DevicePathNode;
ASSERT(MappingItem != NULL);
Usb = (USB_DEVICE_PATH *) DevicePathNode;
Status = AppendCSDNum (MappingItem, Usb->ParentPortNumber); Status = AppendCSDNum (MappingItem, Usb->ParentPortNumber);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Usb->InterfaceNumber); Status = AppendCSDNum (MappingItem, Usb->InterfaceNumber);
@ -629,19 +631,19 @@ DevPathSerialUsb (
return Status; return Status;
} }
if (PcdGetBool(PcdUsbExtendedDecode)) { if (PcdGetBool (PcdUsbExtendedDecode)) {
Status = gBS->LocateDevicePath( &gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle ); Status = gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle);
UsbIo = NULL; UsbIo = NULL;
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol(TempHandle, &gEfiUsbIoProtocolGuid, (VOID**)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); Status = gBS->OpenProtocol (TempHandle, &gEfiUsbIoProtocolGuid, (VOID **)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
} }
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
ASSERT(UsbIo != NULL); ASSERT (UsbIo != NULL);
Status = UsbIo->UsbGetInterfaceDescriptor(UsbIo, &InterfaceDesc); Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);
if (!EFI_ERROR(Status)) { 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){ switch (InterfaceDesc.InterfaceSubClass) {
case USB_MASS_STORE_SCSI: case USB_MASS_STORE_SCSI:
MappingItem->Mtd = MTDTypeHardDisk; MappingItem->Mtd = MTDTypeHardDisk;
break; break;
@ -657,6 +659,7 @@ DevPathSerialUsb (
} }
} }
} }
return Status; return Status;
} }
@ -685,34 +688,36 @@ DevPathSerialVendor (
CHAR16 *Buffer; CHAR16 *Buffer;
CHAR16 *NewBuffer; CHAR16 *NewBuffer;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode; Vendor = (VENDOR_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDGuid (MappingItem, &Vendor->Guid); Status = AppendCSDGuid (MappingItem, &Vendor->Guid);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) { if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) {
Sas = (SAS_DEVICE_PATH *) Vendor; Sas = (SAS_DEVICE_PATH *)Vendor;
Status = AppendCSDNum (MappingItem, Sas->SasAddress); Status = AppendCSDNum (MappingItem, Sas->SasAddress);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Sas->Lun); Status = AppendCSDNum (MappingItem, Sas->Lun);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Sas->DeviceTopology); Status = AppendCSDNum (MappingItem, Sas->DeviceTopology);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Sas->RelativeTargetPort); Status = AppendCSDNum (MappingItem, Sas->RelativeTargetPort);
} }
} else { } else {
TargetNameLength = MIN(DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32(PcdShellVendorExtendedDecode)); TargetNameLength = MIN (DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32 (PcdShellVendorExtendedDecode));
if (TargetNameLength != 0) { if (TargetNameLength != 0) {
// //
// String is 2 chars per data byte, plus NULL terminator // String is 2 chars per data byte, plus NULL terminator
// //
Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof(CHAR16)); Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof (CHAR16));
if (Buffer == NULL) { if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -721,11 +726,12 @@ DevPathSerialVendor (
// Build the string data // Build the string data
// //
for (Index = 0; Index < TargetNameLength; Index++) { for (Index = 0; Index < TargetNameLength; Index++) {
NewBuffer = CatSPrint (Buffer, L"%02x", *((UINT8*)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index)); NewBuffer = CatSPrint (Buffer, L"%02x", *((UINT8 *)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index));
if (NewBuffer == NULL) { if (NewBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
break; break;
} }
Buffer = NewBuffer; Buffer = NewBuffer;
} }
@ -736,9 +742,10 @@ DevPathSerialVendor (
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
} }
FreePool(Buffer); FreePool (Buffer);
} }
} }
return Status; return Status;
} }
@ -761,10 +768,10 @@ DevPathSerialLun (
{ {
DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun; DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) DevicePathNode; Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *)DevicePathNode;
return AppendCSDNum (MappingItem, Lun->Lun); return AppendCSDNum (MappingItem, Lun->Lun);
} }
@ -788,17 +795,19 @@ DevPathSerialSata (
EFI_STATUS Status; EFI_STATUS Status;
SATA_DEVICE_PATH *Sata; SATA_DEVICE_PATH *Sata;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Sata = (SATA_DEVICE_PATH *) DevicePathNode; Sata = (SATA_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, Sata->HBAPortNumber); Status = AppendCSDNum (MappingItem, Sata->HBAPortNumber);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber); Status = AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Sata->Lun); Status = AppendCSDNum (MappingItem, Sata->Lun);
} }
return Status; return Status;
} }
@ -826,41 +835,47 @@ DevPathSerialIScsi (
UINTN TargetNameLength; UINTN TargetNameLength;
UINTN Index; UINTN Index;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (PcdGetBool(PcdShellDecodeIScsiMapNames)) { if (PcdGetBool (PcdShellDecodeIScsiMapNames)) {
IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode; IScsi = (ISCSI_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, IScsi->NetworkProtocol); Status = AppendCSDNum (MappingItem, IScsi->NetworkProtocol);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, IScsi->LoginOption); Status = AppendCSDNum (MappingItem, IScsi->LoginOption);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, IScsi->Lun); Status = AppendCSDNum (MappingItem, IScsi->Lun);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag); Status = AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH); TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
if (TargetNameLength > 0) { if (TargetNameLength > 0) {
TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16)); TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
if (TargetName == NULL) { if (TargetName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} else { } else {
IScsiTargetName = (UINT8 *) (IScsi + 1); IScsiTargetName = (UINT8 *)(IScsi + 1);
for (Index = 0; Index < TargetNameLength; Index++) { for (Index = 0; Index < TargetNameLength; Index++) {
TargetName[Index] = (CHAR16) IScsiTargetName[Index]; TargetName[Index] = (CHAR16)IScsiTargetName[Index];
} }
Status = AppendCSDStr (MappingItem, TargetName); Status = AppendCSDStr (MappingItem, TargetName);
FreePool (TargetName); FreePool (TargetName);
} }
} }
} }
return Status; return Status;
} }
@ -883,10 +898,10 @@ DevPathSerialI2O (
{ {
I2O_DEVICE_PATH *DevicePath_I20; I2O_DEVICE_PATH *DevicePath_I20;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
DevicePath_I20 = (I2O_DEVICE_PATH *) DevicePathNode; DevicePath_I20 = (I2O_DEVICE_PATH *)DevicePathNode;
return AppendCSDNum (MappingItem, DevicePath_I20->Tid); return AppendCSDNum (MappingItem, DevicePath_I20->Tid);
} }
@ -913,18 +928,18 @@ DevPathSerialMacAddr (
CHAR16 Buffer[64]; CHAR16 Buffer[64];
CHAR16 *PBuffer; CHAR16 *PBuffer;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Mac = (MAC_ADDR_DEVICE_PATH *) DevicePathNode; Mac = (MAC_ADDR_DEVICE_PATH *)DevicePathNode;
HwAddressSize = sizeof (EFI_MAC_ADDRESS); HwAddressSize = sizeof (EFI_MAC_ADDRESS);
if (Mac->IfType == 0x01 || Mac->IfType == 0x00) { if ((Mac->IfType == 0x01) || (Mac->IfType == 0x00)) {
HwAddressSize = 6; HwAddressSize = 6;
} }
for (Index = 0, PBuffer = Buffer; Index < HwAddressSize; Index++, PBuffer += 2) { for (Index = 0, PBuffer = Buffer; Index < HwAddressSize; Index++, PBuffer += 2) {
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Mac->MacAddress.Addr[Index]); UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Mac->MacAddress.Addr[Index]);
} }
return AppendCSDStr (MappingItem, Buffer); return AppendCSDStr (MappingItem, Buffer);
@ -953,24 +968,27 @@ DevPathSerialInfiniBand (
CHAR16 Buffer[64]; CHAR16 Buffer[64];
CHAR16 *PBuffer; CHAR16 *PBuffer;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
InfiniBand = (INFINIBAND_DEVICE_PATH *) DevicePathNode; InfiniBand = (INFINIBAND_DEVICE_PATH *)DevicePathNode;
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) { for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) InfiniBand->PortGid[Index]); UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)InfiniBand->PortGid[Index]);
} }
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, InfiniBand->ServiceId); Status = AppendCSDNum (MappingItem, InfiniBand->ServiceId);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, InfiniBand->TargetPortId); Status = AppendCSDNum (MappingItem, InfiniBand->TargetPortId);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, InfiniBand->DeviceId); Status = AppendCSDNum (MappingItem, InfiniBand->DeviceId);
} }
return Status; return Status;
} }
@ -995,38 +1013,41 @@ DevPathSerialIPv4 (
IPv4_DEVICE_PATH *Ip; IPv4_DEVICE_PATH *Ip;
CHAR16 Buffer[10]; CHAR16 Buffer[10];
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Ip = (IPv4_DEVICE_PATH *) DevicePathNode; Ip = (IPv4_DEVICE_PATH *)DevicePathNode;
UnicodeSPrint ( UnicodeSPrint (
Buffer, Buffer,
0, 0,
L"%02x%02x%02x%02x", L"%02x%02x%02x%02x",
(UINTN) Ip->LocalIpAddress.Addr[0], (UINTN)Ip->LocalIpAddress.Addr[0],
(UINTN) Ip->LocalIpAddress.Addr[1], (UINTN)Ip->LocalIpAddress.Addr[1],
(UINTN) Ip->LocalIpAddress.Addr[2], (UINTN)Ip->LocalIpAddress.Addr[2],
(UINTN) Ip->LocalIpAddress.Addr[3] (UINTN)Ip->LocalIpAddress.Addr[3]
); );
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Ip->LocalPort); Status = AppendCSDNum (MappingItem, Ip->LocalPort);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
UnicodeSPrint ( UnicodeSPrint (
Buffer, Buffer,
0, 0,
L"%02x%02x%02x%02x", L"%02x%02x%02x%02x",
(UINTN) Ip->RemoteIpAddress.Addr[0], (UINTN)Ip->RemoteIpAddress.Addr[0],
(UINTN) Ip->RemoteIpAddress.Addr[1], (UINTN)Ip->RemoteIpAddress.Addr[1],
(UINTN) Ip->RemoteIpAddress.Addr[2], (UINTN)Ip->RemoteIpAddress.Addr[2],
(UINTN) Ip->RemoteIpAddress.Addr[3] (UINTN)Ip->RemoteIpAddress.Addr[3]
); );
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Ip->RemotePort); Status = AppendCSDNum (MappingItem, Ip->RemotePort);
} }
return Status; return Status;
} }
@ -1053,28 +1074,31 @@ DevPathSerialIPv6 (
CHAR16 Buffer[64]; CHAR16 Buffer[64];
CHAR16 *PBuffer; CHAR16 *PBuffer;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Ip = (IPv6_DEVICE_PATH *) DevicePathNode; Ip = (IPv6_DEVICE_PATH *)DevicePathNode;
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) { for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->LocalIpAddress.Addr[Index]); UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Ip->LocalIpAddress.Addr[Index]);
} }
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Ip->LocalPort); Status = AppendCSDNum (MappingItem, Ip->LocalPort);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) { for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->RemoteIpAddress.Addr[Index]); UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Ip->RemoteIpAddress.Addr[Index]);
} }
Status = AppendCSDStr (MappingItem, Buffer); Status = AppendCSDStr (MappingItem, Buffer);
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Ip->RemotePort); Status = AppendCSDNum (MappingItem, Ip->RemotePort);
} }
return Status; return Status;
} }
@ -1098,14 +1122,15 @@ DevPathSerialScsi (
EFI_STATUS Status; EFI_STATUS Status;
SCSI_DEVICE_PATH *Scsi; SCSI_DEVICE_PATH *Scsi;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Scsi = (SCSI_DEVICE_PATH *) DevicePathNode; Scsi = (SCSI_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, Scsi->Pun); Status = AppendCSDNum (MappingItem, Scsi->Pun);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Scsi->Lun); Status = AppendCSDNum (MappingItem, Scsi->Lun);
} }
return Status; return Status;
} }
@ -1129,10 +1154,10 @@ DevPathSerial1394 (
F1394_DEVICE_PATH *DevicePath_F1394; F1394_DEVICE_PATH *DevicePath_F1394;
CHAR16 Buffer[20]; CHAR16 Buffer[20];
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
DevicePath_F1394 = (F1394_DEVICE_PATH *) DevicePathNode; DevicePath_F1394 = (F1394_DEVICE_PATH *)DevicePathNode;
UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid); UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid);
return AppendCSDStr (MappingItem, Buffer); return AppendCSDStr (MappingItem, Buffer);
} }
@ -1156,16 +1181,17 @@ DevPathSerialAcpi (
{ {
ACPI_HID_DEVICE_PATH *Acpi; ACPI_HID_DEVICE_PATH *Acpi;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode; Acpi = (ACPI_HID_DEVICE_PATH *)DevicePathNode;
if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) { if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
MappingItem->Mtd = MTDTypeFloppy; MappingItem->Mtd = MTDTypeFloppy;
return AppendCSDNum (MappingItem, Acpi->UID); return AppendCSDNum (MappingItem, Acpi->UID);
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1333,14 +1359,14 @@ IsHIDevicePathNode (
{ {
ACPI_HID_DEVICE_PATH *Acpi; ACPI_HID_DEVICE_PATH *Acpi;
ASSERT(DevicePathNode != NULL); ASSERT (DevicePathNode != NULL);
if (DevicePathNode->Type == HARDWARE_DEVICE_PATH) { if (DevicePathNode->Type == HARDWARE_DEVICE_PATH) {
return TRUE; return TRUE;
} }
if (DevicePathNode->Type == ACPI_DEVICE_PATH) { if (DevicePathNode->Type == ACPI_DEVICE_PATH) {
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode; Acpi = (ACPI_HID_DEVICE_PATH *)DevicePathNode;
switch (EISA_ID_TO_NUM (Acpi->HID)) { switch (EISA_ID_TO_NUM (Acpi->HID)) {
case 0x0301: case 0x0301:
case 0x0401: case 0x0401:
@ -1373,7 +1399,7 @@ GetHIDevicePath (
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath; EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
ASSERT(DevicePath != NULL); ASSERT (DevicePath != NULL);
NonHIDevicePathNodeCount = 0; NonHIDevicePathNodeCount = 0;
@ -1399,10 +1425,11 @@ GetHIDevicePath (
} else { } else {
NonHIDevicePathNodeCount++; NonHIDevicePathNodeCount++;
} }
// //
// Next device path node // Next device path node
// //
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath); DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)NextDevicePathNode (DevicePath);
} }
return HIDevicePath; return HIDevicePath;
@ -1427,8 +1454,8 @@ GetDeviceConsistMappingInfo (
UINTN Index; UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath; EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath;
ASSERT(DevicePath != NULL); ASSERT (DevicePath != NULL);
ASSERT(MappingItem != NULL); ASSERT (MappingItem != NULL);
SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0); SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);
OriginalDevicePath = DevicePath; OriginalDevicePath = DevicePath;
@ -1439,10 +1466,10 @@ GetDeviceConsistMappingInfo (
// initialize with generic function in case nothing is found // initialize with generic function in case nothing is found
// //
for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) { for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
if ((DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type) &&
if (DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type && (DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType)
DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType )
) { {
SerialFun = DevPathConsistMappingTable[Index].SerialFun; SerialFun = DevPathConsistMappingTable[Index].SerialFun;
break; break;
} }
@ -1457,7 +1484,7 @@ GetDeviceConsistMappingInfo (
// //
// Next device path node // Next device path node
// //
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath); DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)NextDevicePathNode (DevicePath);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -1496,14 +1523,14 @@ ShellCommandConsistMappingInitialize (
&HandleNum, &HandleNum,
&HandleBuffer &HandleBuffer
); );
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
TempTable = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL *)); TempTable = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL *));
if (TempTable == NULL) { if (TempTable == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
for (HandleLoop = 0 ; HandleLoop < HandleNum ; HandleLoop++) { for (HandleLoop = 0; HandleLoop < HandleNum; HandleLoop++) {
DevicePath = DevicePathFromHandle (HandleBuffer[HandleLoop]); DevicePath = DevicePathFromHandle (HandleBuffer[HandleLoop]);
if (DevicePath == NULL) { if (DevicePath == NULL) {
continue; continue;
@ -1514,16 +1541,18 @@ ShellCommandConsistMappingInitialize (
continue; continue;
} }
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop], Status = gBS->HandleProtocol (
HandleBuffer[HandleLoop],
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,
(VOID **)&BlockIo (VOID **)&BlockIo
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop], Status = gBS->HandleProtocol (
HandleBuffer[HandleLoop],
&gEfiSimpleFileSystemProtocolGuid, &gEfiSimpleFileSystemProtocolGuid,
(VOID **)&SimpleFileSystem (VOID **)&SimpleFileSystem
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
FreePool (HIDevicePath); FreePool (HIDevicePath);
continue; continue;
} }
@ -1541,8 +1570,10 @@ ShellCommandConsistMappingInitialize (
} }
} }
for (Index = 0; TempTable[Index] != NULL; Index++); for (Index = 0; TempTable[Index] != NULL; Index++) {
PerformQuickSort(TempTable, Index, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare); }
PerformQuickSort (TempTable, Index, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
*Table = TempTable; *Table = TempTable;
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
@ -1569,7 +1600,7 @@ ShellCommandConsistMappingUnInitialize (
{ {
UINTN Index; UINTN Index;
ASSERT(Table != NULL); ASSERT (Table != NULL);
for (Index = 0; Table[Index] != NULL; Index++) { for (Index = 0; Table[Index] != NULL; Index++) {
FreePool (Table[Index]); FreePool (Table[Index]);
@ -1605,8 +1636,8 @@ ShellCommandConsistMappingGenMappingName (
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath; EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
UINTN Index; UINTN Index;
ASSERT(DevicePath != NULL); ASSERT (DevicePath != NULL);
ASSERT(Table != NULL); ASSERT (Table != NULL);
HIDevicePath = GetHIDevicePath (DevicePath); HIDevicePath = GetHIDevicePath (DevicePath);
if (HIDevicePath == NULL) { if (HIDevicePath == NULL) {
@ -1645,16 +1676,18 @@ ShellCommandConsistMappingGenMappingName (
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = CatPrint (&Str, L"%d", (UINTN) MappingInfo.Hi); 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); Status = CatPrint (&Str, L"%s", MappingInfo.Csd.Str);
FreePool (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":"); Status = CatPrint (&Str, L":");
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL (Str.Str); SHELL_FREE_NON_NULL (Str.Str);
return NULL; return NULL;
@ -1678,15 +1711,15 @@ ShellCommandFindMapItem (
{ {
SHELL_MAP_LIST *MapListItem; SHELL_MAP_LIST *MapListItem;
for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link) for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
; !IsNull(&gShellMapList.Link, &MapListItem->Link) ; !IsNull (&gShellMapList.Link, &MapListItem->Link)
; MapListItem = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &MapListItem->Link) ; MapListItem = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListItem->Link)
){ )
if (gUnicodeCollation->StriColl(gUnicodeCollation,MapListItem->MapName,(CHAR16*)MapKey) == 0) { {
if (gUnicodeCollation->StriColl (gUnicodeCollation, MapListItem->MapName, (CHAR16 *)MapKey) == 0) {
return (MapListItem); return (MapListItem);
} }
} }
return (NULL); return (NULL);
} }

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/OrderedCollectionLib.h> #include <Library/OrderedCollectionLib.h>
typedef struct{ typedef struct {
LIST_ENTRY Link; LIST_ENTRY Link;
CHAR16 *CommandString; CHAR16 *CommandString;
SHELL_GET_MAN_FILENAME GetManFileName; SHELL_GET_MAN_FILENAME GetManFileName;
@ -81,4 +81,3 @@ typedef struct {
} SHELL_SORT_UNIQUE_NAME; } SHELL_SORT_UNIQUE_NAME;
#endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_ #endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_

View File

@ -10,10 +10,10 @@
#include "UefiShellDebug1CommandsLib.h" #include "UefiShellDebug1CommandsLib.h"
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-n", TypeValue}, { L"-n", TypeValue },
{L"-s", TypeValue}, { L"-s", TypeValue },
{NULL, TypeMax} { NULL, TypeMax }
}; };
typedef enum { typedef enum {
OutOfDiffPoint, OutOfDiffPoint,
@ -43,7 +43,7 @@ typedef struct {
**/ **/
VOID VOID
PrintDifferentPoint( PrintDifferentPoint (
CONST CHAR16 *FileName, CONST CHAR16 *FileName,
CHAR16 *FileTag, CHAR16 *FileTag,
UINT8 *Buffer, UINT8 *Buffer,
@ -73,7 +73,7 @@ PrintDifferentPoint(
// Print data in char-format. // Print data in char-format.
// //
for (Index = 0; Index < BufferSize; Index++) { 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]); ShellPrintEx (-1, -1, L"%c", Buffer[Index]);
} else { } else {
// //
@ -165,15 +165,20 @@ FileBufferReadByte (
if (FileBuffer->Left == 0) { if (FileBuffer->Left == 0) {
ReadSize = FileBuffer->Allocated; ReadSize = FileBuffer->Allocated;
Status = gEfiShellProtocol->ReadFile (FileHandle, &ReadSize, Status = gEfiShellProtocol->ReadFile (
FileBuffer->Data); FileHandle,
&ReadSize,
FileBuffer->Data
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (ReadSize == 0) { if (ReadSize == 0) {
*BytesRead = 0; *BytesRead = 0;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
FileBuffer->Next = 0; FileBuffer->Next = 0;
FileBuffer->Left = ReadSize; FileBuffer->Left = ReadSize;
} }
@ -248,63 +253,65 @@ ShellCommandRunComp (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = CommandInit(); Status = CommandInit ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// parse the command line // parse the command line
// //
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"comp", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 3) { if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"comp"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"comp");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) { } else if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"comp"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"comp");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
TempParam = ShellCommandLineGetRawValue(Package, 1); TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT(TempParam != NULL); ASSERT (TempParam != NULL);
FileName1 = ShellFindFilePath(TempParam); FileName1 = ShellFindFilePath (TempParam);
if (FileName1 == NULL) { if (FileName1 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} else { } else {
Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} }
} }
TempParam = ShellCommandLineGetRawValue(Package, 2);
ASSERT(TempParam != NULL); TempParam = ShellCommandLineGetRawValue (Package, 2);
FileName2 = ShellFindFilePath(TempParam); ASSERT (TempParam != NULL);
FileName2 = ShellFindFilePath (TempParam);
if (FileName2 == NULL) { if (FileName2 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} else { } else {
Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} }
} }
if (ShellStatus == SHELL_SUCCESS) { if (ShellStatus == SHELL_SUCCESS) {
Status = gEfiShellProtocol->GetFileSize(FileHandle1, &Size1); Status = gEfiShellProtocol->GetFileSize (FileHandle1, &Size1);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = gEfiShellProtocol->GetFileSize(FileHandle2, &Size2); Status = gEfiShellProtocol->GetFileSize (FileHandle2, &Size2);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
if (ShellCommandLineGetFlag (Package, L"-n")) { if (ShellCommandLineGetFlag (Package, L"-n")) {
TempParam = ShellCommandLineGetValue (Package, L"-n"); TempParam = ShellCommandLineGetValue (Package, L"-n");
@ -316,7 +323,7 @@ ShellCommandRunComp (
DifferentCount = MAX_UINTN; DifferentCount = MAX_UINTN;
} else { } else {
Status = ShellConvertStringToUint64 (TempParam, &DifferentCount, FALSE, TRUE); 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"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
@ -331,7 +338,7 @@ ShellCommandRunComp (
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
Status = ShellConvertStringToUint64 (TempParam, &DifferentBytes, FALSE, TRUE); 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"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-s");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
@ -348,8 +355,9 @@ ShellCommandRunComp (
DataFromFile2 = AllocateZeroPool ((UINTN)DifferentBytes); DataFromFile2 = AllocateZeroPool ((UINTN)DifferentBytes);
FileBufferInit (&FileBuffer1); FileBufferInit (&FileBuffer1);
FileBufferInit (&FileBuffer2); FileBufferInit (&FileBuffer2);
if (DataFromFile1 == NULL || DataFromFile2 == NULL || if ((DataFromFile1 == NULL) || (DataFromFile2 == NULL) ||
FileBuffer1.Data == NULL || FileBuffer2.Data == NULL) { (FileBuffer1.Data == NULL) || (FileBuffer2.Data == NULL))
{
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
SHELL_FREE_NON_NULL (DataFromFile1); SHELL_FREE_NON_NULL (DataFromFile1);
SHELL_FREE_NON_NULL (DataFromFile2); SHELL_FREE_NON_NULL (DataFromFile2);
@ -364,11 +372,19 @@ ShellCommandRunComp (
DataSizeFromFile2 = 1; DataSizeFromFile2 = 1;
OneByteFromFile1 = 0; OneByteFromFile1 = 0;
OneByteFromFile2 = 0; OneByteFromFile2 = 0;
Status = FileBufferReadByte (FileHandle1, &FileBuffer1, Status = FileBufferReadByte (
&DataSizeFromFile1, &OneByteFromFile1); FileHandle1,
&FileBuffer1,
&DataSizeFromFile1,
&OneByteFromFile1
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = FileBufferReadByte (FileHandle2, &FileBuffer2, Status = FileBufferReadByte (
&DataSizeFromFile2, &OneByteFromFile2); FileHandle2,
&FileBuffer2,
&DataSizeFromFile2,
&OneByteFromFile2
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
TempAddress++; TempAddress++;
@ -378,9 +394,10 @@ ShellCommandRunComp (
// 2.If no more char in File1 or File2, The ReadStatus is InPrevDiffPoint forever. // 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. // So the previous different point is the last one, then break the while block.
// //
if ( (DataSizeFromFile1 == 0 && InsertPosition1 == 0 && DataSizeFromFile2 == 0 && InsertPosition2 == 0) || if (((DataSizeFromFile1 == 0) && (InsertPosition1 == 0) && (DataSizeFromFile2 == 0) && (InsertPosition2 == 0)) ||
(ReadStatus == InPrevDiffPoint && (DataSizeFromFile1 == 0 || DataSizeFromFile2 == 0)) ((ReadStatus == InPrevDiffPoint) && ((DataSizeFromFile1 == 0) || (DataSizeFromFile2 == 0)))
) { )
{
break; break;
} }
@ -391,6 +408,7 @@ ShellCommandRunComp (
if (DataSizeFromFile1 == 1) { if (DataSizeFromFile1 == 1) {
DataFromFile1[InsertPosition1++] = OneByteFromFile1; DataFromFile1[InsertPosition1++] = OneByteFromFile1;
} }
if (DataSizeFromFile2 == 1) { if (DataSizeFromFile2 == 1) {
DataFromFile2[InsertPosition2++] = OneByteFromFile2; DataFromFile2[InsertPosition2++] = OneByteFromFile2;
} }
@ -399,6 +417,7 @@ ShellCommandRunComp (
if (DataSizeFromFile1 == 1) { if (DataSizeFromFile1 == 1) {
DataFromFile1[InsertPosition1++] = OneByteFromFile1; DataFromFile1[InsertPosition1++] = OneByteFromFile1;
} }
if (DataSizeFromFile2 == 1) { if (DataSizeFromFile2 == 1) {
DataFromFile2[InsertPosition2++] = OneByteFromFile2; DataFromFile2[InsertPosition2++] = OneByteFromFile2;
} }
@ -411,11 +430,11 @@ ShellCommandRunComp (
// //
// ReadStatus should be always equal InDiffPoint. // ReadStatus should be always equal InDiffPoint.
// //
if ( InsertPosition1 == DifferentBytes || if ((InsertPosition1 == DifferentBytes) ||
InsertPosition2 == DifferentBytes || (InsertPosition2 == DifferentBytes) ||
(DataSizeFromFile1 == 0 && DataSizeFromFile2 == 0) ((DataSizeFromFile1 == 0) && (DataSizeFromFile2 == 0))
) { )
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber);
PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes); PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);
PrintDifferentPoint (FileName2, L"File2", DataFromFile2, InsertPosition2, 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. // 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; break;
} }
@ -438,7 +457,7 @@ ShellCommandRunComp (
// //
// Try to find a new different point in the rest of DataFromFile. // Try to find a new different point in the rest of DataFromFile.
// //
for (; Index < MAX (InsertPosition1,InsertPosition2); Index++) { for ( ; Index < MAX (InsertPosition1, InsertPosition2); Index++) {
if (DataFromFile1[Index] != DataFromFile2[Index]) { if (DataFromFile1[Index] != DataFromFile2[Index]) {
ReadStatus = InDiffPoint; ReadStatus = InDiffPoint;
DiffPointAddress += Index; DiffPointAddress += Index;
@ -469,24 +488,26 @@ ShellCommandRunComp (
FileBufferUninit (&FileBuffer2); FileBufferUninit (&FileBuffer2);
if (DiffPointNumber == 0) { if (DiffPointNumber == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle);
} else { } else {
ShellStatus = SHELL_NOT_EQUAL; ShellStatus = SHELL_NOT_EQUAL;
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle);
} }
} }
} }
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
SHELL_FREE_NON_NULL(FileName1);
SHELL_FREE_NON_NULL(FileName2); SHELL_FREE_NON_NULL (FileName1);
SHELL_FREE_NON_NULL (FileName2);
if (FileHandle1 != NULL) { if (FileHandle1 != NULL) {
gEfiShellProtocol->CloseFile(FileHandle1); gEfiShellProtocol->CloseFile (FileHandle1);
} }
if (FileHandle2 != NULL) { if (FileHandle2 != NULL) {
gEfiShellProtocol->CloseFile(FileHandle2); gEfiShellProtocol->CloseFile (FileHandle2);
} }
return (ShellStatus); return (ShellStatus);

View File

@ -49,9 +49,9 @@ typedef INT16 NODE;
#define NT (CODE_BIT + 3) #define NT (CODE_BIT + 3)
#define TBIT 5 #define TBIT 5
#if NT > NP #if NT > NP
#define NPT NT #define NPT NT
#else #else
#define NPT NP #define NPT NP
#endif #endif
// //
// Function Prototypes // Function Prototypes
@ -63,7 +63,7 @@ typedef INT16 NODE;
@param[in] Data The dword to put. @param[in] Data The dword to put.
**/ **/
VOID VOID
PutDword( PutDword (
IN UINT32 Data IN UINT32 Data
); );
@ -142,7 +142,7 @@ MakeCrcTable (
} }
} }
mCrcTable[LoopVar1] = (UINT16) LoopVar4; mCrcTable[LoopVar1] = (UINT16)LoopVar4;
} }
} }
@ -157,19 +157,19 @@ PutDword (
) )
{ {
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = (UINT8) (((UINT8) (Data)) & 0xff); *mDst++ = (UINT8)(((UINT8)(Data)) & 0xff);
} }
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff); *mDst++ = (UINT8)(((UINT8)(Data >> 0x08)) & 0xff);
} }
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff); *mDst++ = (UINT8)(((UINT8)(Data >> 0x10)) & 0xff);
} }
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff); *mDst++ = (UINT8)(((UINT8)(Data >> 0x18)) & 0xff);
} }
} }
@ -244,7 +244,7 @@ InitSlide (
mAvail = 1; mAvail = 1;
for (LoopVar1 = 1; LoopVar1 < WNDSIZ - 1; LoopVar1++) { for (LoopVar1 = 1; LoopVar1 < WNDSIZ - 1; LoopVar1++) {
mNext[LoopVar1] = (NODE) (LoopVar1 + 1); mNext[LoopVar1] = (NODE)(LoopVar1 + 1);
} }
mNext[WNDSIZ - 1] = NIL; mNext[WNDSIZ - 1] = NIL;
@ -296,7 +296,7 @@ MakeChild (
NODE LoopVar10; NODE LoopVar10;
LoopVar12 = (NODE) HASH (LoopVar6, LoopVar5); LoopVar12 = (NODE)HASH (LoopVar6, LoopVar5);
LoopVar10 = mNext[LoopVar12]; LoopVar10 = mNext[LoopVar12];
mNext[LoopVar12] = LoopVar4; mNext[LoopVar12] = LoopVar4;
mNext[LoopVar4] = LoopVar10; mNext[LoopVar4] = LoopVar10;
@ -330,7 +330,7 @@ Split (
mNext[New] = LoopVar10; mNext[New] = LoopVar10;
mPrev[LoopVar10] = New; mPrev[LoopVar10] = New;
mParent[New] = mParent[Old]; mParent[New] = mParent[Old];
mLevel[New] = (UINT8) mMatchLen; mLevel[New] = (UINT8)mMatchLen;
mPosition[New] = mPos; mPosition[New] = mPos;
MakeChild (New, mText[mMatchPos + mMatchLen], Old); MakeChild (New, mText[mMatchPos + mMatchLen], Old);
MakeChild (New, mText[mPos + mMatchLen], mPos); MakeChild (New, mText[mPos + mMatchLen], mPos);
@ -365,7 +365,7 @@ InsertNode (
// in DeleteNode() later. // in DeleteNode() later.
// //
mMatchLen--; mMatchLen--;
LoopVar4 = (NODE) ((mMatchPos + 1) | WNDSIZ); LoopVar4 = (NODE)((mMatchPos + 1) | WNDSIZ);
LoopVar6 = mParent[LoopVar4]; LoopVar6 = mParent[LoopVar4];
while (LoopVar6 == NIL) { while (LoopVar6 == NIL) {
LoopVar4 = mNext[LoopVar4]; LoopVar4 = mNext[LoopVar4];
@ -384,35 +384,36 @@ InsertNode (
} }
if (LoopVar10 < WNDSIZ) { if (LoopVar10 < WNDSIZ) {
mPosition[LoopVar10] = (NODE) (mPos | PERC_FLAG); mPosition[LoopVar10] = (NODE)(mPos | PERC_FLAG);
} }
} else { } else {
// //
// Locate the target tree // Locate the target tree
// //
LoopVar6 = (NODE) (mText[mPos] + WNDSIZ); LoopVar6 = (NODE)(mText[mPos] + WNDSIZ);
LoopVar5 = mText[mPos + 1]; LoopVar5 = mText[mPos + 1];
LoopVar4 = Child (LoopVar6, LoopVar5); LoopVar4 = Child (LoopVar6, LoopVar5);
if (LoopVar4 == NIL) { if (LoopVar4 == NIL) {
MakeChild (LoopVar6, LoopVar5, mPos); MakeChild (LoopVar6, LoopVar5, mPos);
mMatchLen = 1; mMatchLen = 1;
return ; return;
} }
mMatchLen = 2; mMatchLen = 2;
} }
// //
// Traverse down the tree to find a match. // Traverse down the tree to find a match.
// Update Position value along the route. // Update Position value along the route.
// Node split or creation is involved. // Node split or creation is involved.
// //
for (;;) { for ( ; ;) {
if (LoopVar4 >= WNDSIZ) { if (LoopVar4 >= WNDSIZ) {
LoopVar2 = MAXMATCH; LoopVar2 = MAXMATCH;
mMatchPos = LoopVar4; mMatchPos = LoopVar4;
} else { } else {
LoopVar2 = mLevel[LoopVar4]; LoopVar2 = mLevel[LoopVar4];
mMatchPos = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); mMatchPos = (NODE)(mPosition[LoopVar4] & ~PERC_FLAG);
} }
if (mMatchPos >= mPos) { if (mMatchPos >= mPos) {
@ -424,7 +425,7 @@ InsertNode (
while (mMatchLen < LoopVar2) { while (mMatchLen < LoopVar2) {
if (*TempString3 != *TempString2) { if (*TempString3 != *TempString2) {
Split (LoopVar4); Split (LoopVar4);
return ; return;
} }
mMatchLen++; mMatchLen++;
@ -441,7 +442,7 @@ InsertNode (
LoopVar4 = Child (LoopVar6, *TempString3); LoopVar4 = Child (LoopVar6, *TempString3);
if (LoopVar4 == NIL) { if (LoopVar4 == NIL) {
MakeChild (LoopVar6, *TempString3, mPos); MakeChild (LoopVar6, *TempString3, mPos);
return ; return;
} }
mMatchLen++; mMatchLen++;
@ -460,7 +461,6 @@ InsertNode (
// Special usage of 'next' // Special usage of 'next'
// //
mNext[LoopVar4] = mPos; mNext[LoopVar4] = mPos;
} }
/** /**
@ -484,7 +484,7 @@ DeleteNode (
NODE LoopVar9; NODE LoopVar9;
if (mParent[mPos] == NIL) { if (mParent[mPos] == NIL) {
return ; return;
} }
LoopVar4 = mPrev[mPos]; LoopVar4 = mPrev[mPos];
@ -494,15 +494,15 @@ DeleteNode (
LoopVar4 = mParent[mPos]; LoopVar4 = mParent[mPos];
mParent[mPos] = NIL; mParent[mPos] = NIL;
if (LoopVar4 >= WNDSIZ) { if (LoopVar4 >= WNDSIZ) {
return ; return;
} }
mChildCount[LoopVar4]--; mChildCount[LoopVar4]--;
if (mChildCount[LoopVar4] > 1) { if (mChildCount[LoopVar4] > 1) {
return ; return;
} }
LoopVar10 = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); LoopVar10 = (NODE)(mPosition[LoopVar4] & ~PERC_FLAG);
if (LoopVar10 >= mPos) { if (LoopVar10 >= mPos) {
LoopVar10 -= WNDSIZ; LoopVar10 -= WNDSIZ;
} }
@ -510,7 +510,7 @@ DeleteNode (
LoopVar11 = LoopVar10; LoopVar11 = LoopVar10;
LoopVar6 = mParent[LoopVar4]; LoopVar6 = mParent[LoopVar4];
LoopVar9 = mPosition[LoopVar6]; LoopVar9 = mPosition[LoopVar6];
while ((LoopVar9 & PERC_FLAG) != 0){ while ((LoopVar9 & PERC_FLAG) != 0) {
LoopVar9 &= ~PERC_FLAG; LoopVar9 &= ~PERC_FLAG;
if (LoopVar9 >= mPos) { if (LoopVar9 >= mPos) {
LoopVar9 -= WNDSIZ; LoopVar9 -= WNDSIZ;
@ -520,7 +520,7 @@ DeleteNode (
LoopVar11 = LoopVar9; LoopVar11 = LoopVar9;
} }
mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ); mPosition[LoopVar6] = (NODE)(LoopVar11 | WNDSIZ);
LoopVar6 = mParent[LoopVar6]; LoopVar6 = mParent[LoopVar6];
LoopVar9 = mPosition[LoopVar6]; LoopVar9 = mPosition[LoopVar6];
} }
@ -534,7 +534,7 @@ DeleteNode (
LoopVar11 = LoopVar9; LoopVar11 = LoopVar9;
} }
mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ | PERC_FLAG); mPosition[LoopVar6] = (NODE)(LoopVar11 | WNDSIZ | PERC_FLAG);
} }
LoopVar11 = Child (LoopVar4, mText[LoopVar10 + mLevel[LoopVar4]]); LoopVar11 = Child (LoopVar4, mText[LoopVar10 + mLevel[LoopVar4]]);
@ -609,6 +609,7 @@ GetNextMatch (
if (Temp == NULL) { if (Temp == NULL) {
return (FALSE); return (FALSE);
} }
CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH); CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH);
CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH); CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH);
FreePool (Temp); FreePool (Temp);
@ -643,7 +644,7 @@ DownHeap (
LoopVar2 = mHeap[i]; LoopVar2 = mHeap[i];
LoopVar1 = 2 * i; LoopVar1 = 2 * i;
while (LoopVar1 <= mHeapSize) { while (LoopVar1 <= mHeapSize) {
if (LoopVar1 < mHeapSize && mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]]) { if ((LoopVar1 < mHeapSize) && (mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]])) {
LoopVar1++; LoopVar1++;
} }
@ -656,7 +657,7 @@ DownHeap (
LoopVar1 = 2 * i; LoopVar1 = 2 * i;
} }
mHeap[i] = (INT16) LoopVar2; mHeap[i] = (INT16)LoopVar2;
} }
/** /**
@ -726,7 +727,7 @@ MakeLen (
LoopVar2 = mLenCnt[LoopVar1]; LoopVar2 = mLenCnt[LoopVar1];
LoopVar2--; LoopVar2--;
while (LoopVar2 >= 0) { while (LoopVar2 >= 0) {
mLen[*mSortPtr++] = (UINT8) LoopVar1; mLen[*mSortPtr++] = (UINT8)LoopVar1;
LoopVar2--; LoopVar2--;
} }
} }
@ -742,8 +743,8 @@ MakeLen (
VOID VOID
MakeCode ( MakeCode (
IN INT32 LoopVar8, IN INT32 LoopVar8,
IN UINT8 Len[ ], IN UINT8 Len[],
OUT UINT16 Code[ ] OUT UINT16 Code[]
) )
{ {
INT32 LoopVar1; INT32 LoopVar1;
@ -751,7 +752,7 @@ MakeCode (
Start[1] = 0; Start[1] = 0;
for (LoopVar1 = 1; LoopVar1 <= 16; LoopVar1++) { for (LoopVar1 = 1; LoopVar1 <= 16; LoopVar1++) {
Start[LoopVar1 + 1] = (UINT16) ((Start[LoopVar1] + mLenCnt[LoopVar1]) << 1); Start[LoopVar1 + 1] = (UINT16)((Start[LoopVar1] + mLenCnt[LoopVar1]) << 1);
} }
for (LoopVar1 = 0; LoopVar1 < LoopVar8; LoopVar1++) { for (LoopVar1 = 0; LoopVar1 < LoopVar8; LoopVar1++) {
@ -772,9 +773,9 @@ MakeCode (
INT32 INT32
MakeTree ( MakeTree (
IN INT32 NParm, IN INT32 NParm,
IN UINT16 FreqParm[ ], IN UINT16 FreqParm[],
OUT UINT8 LenParm[ ], OUT UINT8 LenParm[],
OUT UINT16 CodeParm[ ] OUT UINT16 CodeParm[]
) )
{ {
INT32 LoopVar1; INT32 LoopVar1;
@ -798,7 +799,7 @@ MakeTree (
mLen[LoopVar1] = 0; mLen[LoopVar1] = 0;
if ((mFreq[LoopVar1]) != 0) { if ((mFreq[LoopVar1]) != 0) {
mHeapSize++; mHeapSize++;
mHeap[mHeapSize] = (INT16) LoopVar1; mHeap[mHeapSize] = (INT16)LoopVar1;
} }
} }
@ -818,22 +819,22 @@ MakeTree (
do { do {
LoopVar1 = mHeap[1]; LoopVar1 = mHeap[1];
if (LoopVar1 < mTempInt32) { if (LoopVar1 < mTempInt32) {
*mSortPtr++ = (UINT16) LoopVar1; *mSortPtr++ = (UINT16)LoopVar1;
} }
mHeap[1] = mHeap[mHeapSize--]; mHeap[1] = mHeap[mHeapSize--];
DownHeap (1); DownHeap (1);
LoopVar2 = mHeap[1]; LoopVar2 = mHeap[1];
if (LoopVar2 < mTempInt32) { if (LoopVar2 < mTempInt32) {
*mSortPtr++ = (UINT16) LoopVar2; *mSortPtr++ = (UINT16)LoopVar2;
} }
LoopVar3 = Avail++; LoopVar3 = Avail++;
mFreq[LoopVar3] = (UINT16) (mFreq[LoopVar1] + mFreq[LoopVar2]); mFreq[LoopVar3] = (UINT16)(mFreq[LoopVar1] + mFreq[LoopVar2]);
mHeap[1] = (INT16) LoopVar3; mHeap[1] = (INT16)LoopVar3;
DownHeap (1); DownHeap (1);
mLeft[LoopVar3] = (UINT16) LoopVar1; mLeft[LoopVar3] = (UINT16)LoopVar1;
mRight[LoopVar3] = (UINT16) LoopVar2; mRight[LoopVar3] = (UINT16)LoopVar2;
} while (mHeapSize > 1); } while (mHeapSize > 1);
mSortPtr = CodeParm; mSortPtr = CodeParm;
@ -863,21 +864,21 @@ PutBits (
if (LoopVar8 < mBitCount) { if (LoopVar8 < mBitCount) {
mSubBitBuf |= x << (mBitCount -= LoopVar8); mSubBitBuf |= x << (mBitCount -= LoopVar8);
} else { } else {
Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount))); Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount)));
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = Temp; *mDst++ = Temp;
} }
mCompSize++; mCompSize++;
if (LoopVar8 < UINT8_BIT) { if (LoopVar8 < UINT8_BIT) {
mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8); mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8);
} else { } else {
Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT)); Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT));
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = Temp; *mDst++ = Temp;
} }
mCompSize++; mCompSize++;
mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - LoopVar8); mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - LoopVar8);
@ -921,7 +922,7 @@ EncodeP (
PutBits (mPTLen[LoopVar5], mPTCode[LoopVar5]); PutBits (mPTLen[LoopVar5], mPTCode[LoopVar5]);
if (LoopVar5 > 1) { if (LoopVar5 > 1) {
PutBits(LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5))); PutBits (LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5)));
} }
} }
@ -962,7 +963,7 @@ CountTFreq (
} }
if (Count <= 2) { if (Count <= 2) {
mTFreq[0] = (UINT16) (mTFreq[0] + Count); mTFreq[0] = (UINT16)(mTFreq[0] + Count);
} else if (Count <= 18) { } else if (Count <= 18) {
mTFreq[1]++; mTFreq[1]++;
} else if (Count == 19) { } else if (Count == 19) {
@ -972,7 +973,7 @@ CountTFreq (
mTFreq[2]++; mTFreq[2]++;
} }
} else { } else {
ASSERT((LoopVar3+2)<(2 * NT - 1)); ASSERT ((LoopVar3+2) < (2 * NT - 1));
mTFreq[LoopVar3 + 2]++; mTFreq[LoopVar3 + 2]++;
} }
} }
@ -1069,7 +1070,7 @@ WriteCLen (
PutBits (CBIT, Count - 20); PutBits (CBIT, Count - 20);
} }
} else { } else {
ASSERT((LoopVar3+2)<NPT); ASSERT ((LoopVar3+2) < NPT);
PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]); PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
} }
} }
@ -1095,6 +1096,7 @@ SendBlock (
UINT32 Pos; UINT32 Pos;
UINT32 Size; UINT32 Size;
Flags = 0; Flags = 0;
Root = MakeTree (NC, mCFreq, mCLen, mCCode); Root = MakeTree (NC, mCFreq, mCLen, mCCode);
@ -1133,8 +1135,9 @@ SendBlock (
} else { } else {
Flags <<= 1; Flags <<= 1;
} }
if ((Flags & (1U << (UINT8_BIT - 1))) != 0){
EncodeC(mBuf[Pos++] + (1U << UINT8_BIT)); if ((Flags & (1U << (UINT8_BIT - 1))) != 0) {
EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));
LoopVar3 = mBuf[Pos++] << UINT8_BIT; LoopVar3 = mBuf[Pos++] << UINT8_BIT;
LoopVar3 += mBuf[Pos++]; LoopVar3 += mBuf[Pos++];
@ -1191,17 +1194,19 @@ CompressOutput (
CPos = mOutputPos++; CPos = mOutputPos++;
mBuf[CPos] = 0; mBuf[CPos] = 0;
} }
mBuf[mOutputPos++] = (UINT8) LoopVar5;
mBuf[mOutputPos++] = (UINT8)LoopVar5;
mCFreq[LoopVar5]++; mCFreq[LoopVar5]++;
if (LoopVar5 >= (1U << UINT8_BIT)) { if (LoopVar5 >= (1U << UINT8_BIT)) {
mBuf[CPos] = (UINT8)(mBuf[CPos]|mOutputMask); mBuf[CPos] = (UINT8)(mBuf[CPos]|mOutputMask);
mBuf[mOutputPos++] = (UINT8)(LoopVar7 >> UINT8_BIT); mBuf[mOutputPos++] = (UINT8)(LoopVar7 >> UINT8_BIT);
mBuf[mOutputPos++] = (UINT8) LoopVar7; mBuf[mOutputPos++] = (UINT8)LoopVar7;
LoopVar5 = 0; LoopVar5 = 0;
while (LoopVar7!=0) { while (LoopVar7 != 0) {
LoopVar7 >>= 1; LoopVar7 >>= 1;
LoopVar5++; LoopVar5++;
} }
mPFreq[LoopVar5]++; mPFreq[LoopVar5]++;
} }
} }
@ -1263,28 +1268,32 @@ Encode (
if (!GetNextMatch ()) { if (!GetNextMatch ()) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} }
if (mMatchLen > mRemainder) { if (mMatchLen > mRemainder) {
mMatchLen = mRemainder; mMatchLen = mRemainder;
} }
if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { if ((mMatchLen > LastMatchLen) || (LastMatchLen < THRESHOLD)) {
// //
// Not enough benefits are gained by outputting a pointer, // Not enough benefits are gained by outputting a pointer,
// so just output the original character // so just output the original character
// //
CompressOutput(mText[mPos - 1], 0); CompressOutput (mText[mPos - 1], 0);
} else { } else {
// //
// Outputting a pointer is beneficial enough, do it. // Outputting a pointer is beneficial enough, do it.
// //
CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), CompressOutput (
(mPos - LastMatchPos - 2) & (WNDSIZ - 1)); LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
(mPos - LastMatchPos - 2) & (WNDSIZ - 1)
);
LastMatchLen--; LastMatchLen--;
while (LastMatchLen > 0) { while (LastMatchLen > 0) {
if (!GetNextMatch ()) { if (!GetNextMatch ()) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} }
LastMatchLen--; LastMatchLen--;
} }
@ -1354,12 +1363,14 @@ Compress (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Null terminate the compressed data // Null terminate the compressed data
// //
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = 0; *mDst++ = 0;
} }
// //
// Fill in compressed size and original size // Fill in compressed size and original size
// //
@ -1377,6 +1388,4 @@ Compress (
*DstSize = mCompSize + 1 + 8; *DstSize = mCompSize + 1 + 8;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }

View File

@ -30,4 +30,3 @@ Compress (
); );
#endif #endif

View File

@ -20,7 +20,7 @@
@retval SHELL_SUCCESS The display was successful. @retval SHELL_SUCCESS The display was successful.
**/ **/
SHELL_STATUS SHELL_STATUS
DisplayTheBlocks( DisplayTheBlocks (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,
IN CONST UINT64 Lba, IN CONST UINT64 Lba,
IN CONST UINT8 BlockCount IN CONST UINT8 BlockCount
@ -36,33 +36,33 @@ DisplayTheBlocks(
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, (EFI_DEVICE_PATH_PROTOCOL **)&DevPath, &BlockIoHandle); Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, (EFI_DEVICE_PATH_PROTOCOL **)&DevPath, &BlockIoHandle);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return (SHELL_NOT_FOUND); return (SHELL_NOT_FOUND);
} }
Status = gBS->OpenProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); Status = gBS->OpenProtocol (BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return (SHELL_NOT_FOUND); return (SHELL_NOT_FOUND);
} }
BufferSize = BlockIo->Media->BlockSize * BlockCount; BufferSize = BlockIo->Media->BlockSize * BlockCount;
if(BlockIo->Media->IoAlign == 0) { if (BlockIo->Media->IoAlign == 0) {
BlockIo->Media->IoAlign = 1; BlockIo->Media->IoAlign = 1;
} }
if (BufferSize > 0) { if (BufferSize > 0) {
OriginalBuffer = AllocateZeroPool(BufferSize + BlockIo->Media->IoAlign); OriginalBuffer = AllocateZeroPool (BufferSize + BlockIo->Media->IoAlign);
Buffer = ALIGN_POINTER (OriginalBuffer,BlockIo->Media->IoAlign); Buffer = ALIGN_POINTER (OriginalBuffer, BlockIo->Media->IoAlign);
} else { } else {
ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount); ShellPrintEx (-1, -1, L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount);
OriginalBuffer = NULL; OriginalBuffer = NULL;
Buffer = NULL; Buffer = NULL;
} }
Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer); Status = BlockIo->ReadBlocks (BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer);
if (!EFI_ERROR(Status) && Buffer != NULL) { if (!EFI_ERROR (Status) && (Buffer != NULL)) {
ShellPrintHiiEx( ShellPrintHiiEx (
-1, -1,
-1, -1,
NULL, NULL,
@ -73,9 +73,9 @@ DisplayTheBlocks(
BlockIo BlockIo
); );
DumpHex(2,0,BufferSize,Buffer); DumpHex (2, 0, BufferSize, Buffer);
} else { } else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"dblk", L"BlockIo"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"dblk", L"BlockIo");
ShellStatus = SHELL_DEVICE_ERROR; ShellStatus = SHELL_DEVICE_ERROR;
} }
@ -83,7 +83,7 @@ DisplayTheBlocks(
FreePool (OriginalBuffer); FreePool (OriginalBuffer);
} }
gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL); gBS->CloseProtocol (BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL);
return (ShellStatus); return (ShellStatus);
} }
@ -117,61 +117,63 @@ ShellCommandRunDblk (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = CommandInit(); Status = CommandInit ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// parse the command line // parse the command line
// //
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dblk", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 4) { if (ShellCommandLineGetCount (Package) > 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dblk"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dblk");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 2) { } else if (ShellCommandLineGetCount (Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"dblk"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"dblk");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
// //
// Parse the params // Parse the params
// //
BlockName = ShellCommandLineGetRawValue(Package, 1); BlockName = ShellCommandLineGetRawValue (Package, 1);
LbaString = ShellCommandLineGetRawValue(Package, 2); LbaString = ShellCommandLineGetRawValue (Package, 2);
BlockCountString = ShellCommandLineGetRawValue(Package, 3); BlockCountString = ShellCommandLineGetRawValue (Package, 3);
if (LbaString == NULL) { if (LbaString == NULL) {
Lba = 0; Lba = 0;
} else { } else {
if (!ShellIsHexOrDecimalNumber(LbaString, TRUE, FALSE)) { if (!ShellIsHexOrDecimalNumber (LbaString, TRUE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", LbaString); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", LbaString);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
ShellConvertStringToUint64(LbaString, &Lba, TRUE, FALSE);
ShellConvertStringToUint64 (LbaString, &Lba, TRUE, FALSE);
} }
if (BlockCountString == NULL) { if (BlockCountString == NULL) {
BlockCount = 1; BlockCount = 1;
} else { } else {
if (!ShellIsHexOrDecimalNumber(BlockCountString, TRUE, FALSE)) { if (!ShellIsHexOrDecimalNumber (BlockCountString, TRUE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
ShellConvertStringToUint64(BlockCountString, &BlockCount, TRUE, FALSE);
ShellConvertStringToUint64 (BlockCountString, &BlockCount, TRUE, FALSE);
if (BlockCount > 0x10) { if (BlockCount > 0x10) {
BlockCount = 0x10; BlockCount = 0x10;
} else if (BlockCount == 0) { } else if (BlockCount == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
} }
@ -180,16 +182,16 @@ ShellCommandRunDblk (
// //
// do the work if we have a valid block identifier // do the work if we have a valid block identifier
// //
if (gEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) { if (gEfiShellProtocol->GetDevicePathFromMap (BlockName) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockName); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockName);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
DevPath = (EFI_DEVICE_PATH_PROTOCOL*)gEfiShellProtocol->GetDevicePathFromMap(BlockName); DevPath = (EFI_DEVICE_PATH_PROTOCOL *)gEfiShellProtocol->GetDevicePathFromMap (BlockName);
if (gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevPath, NULL) == EFI_NOT_FOUND) { if (gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &DevPath, NULL) == EFI_NOT_FOUND) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MAP_PROTOCOL), gShellDebug1HiiHandle, L"dblk", BlockName, L"BlockIo"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MAP_PROTOCOL), gShellDebug1HiiHandle, L"dblk", BlockName, L"BlockIo");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ShellStatus = DisplayTheBlocks(gEfiShellProtocol->GetDevicePathFromMap(BlockName), Lba, (UINT8)BlockCount); ShellStatus = DisplayTheBlocks (gEfiShellProtocol->GetDevicePathFromMap (BlockName), Lba, (UINT8)BlockCount);
} }
} }
} }
@ -197,5 +199,6 @@ ShellCommandRunDblk (
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
return (ShellStatus); return (ShellStatus);
} }

View File

@ -24,13 +24,14 @@
@return A printable character representing Char. @return A printable character representing Char.
**/ **/
CHAR16 CHAR16
MakePrintable( MakePrintable (
IN CONST CHAR16 Char IN CONST CHAR16 Char
) )
{ {
if ((Char < 0x20 && Char > 0)||(Char > 126)) { if (((Char < 0x20) && (Char > 0)) || (Char > 126)) {
return (L'?'); return (L'?');
} }
return (Char); return (Char);
} }
@ -41,7 +42,7 @@ MakePrintable(
@param[in] Size The length of memory to display. @param[in] Size The length of memory to display.
**/ **/
SHELL_STATUS SHELL_STATUS
DisplayMmioMemory( DisplayMmioMemory (
IN CONST VOID *Address, IN CONST VOID *Address,
IN CONST UINTN Size IN CONST UINTN Size
) )
@ -53,33 +54,34 @@ DisplayMmioMemory(
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
Status = gBS->LocateProtocol(&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRbIo); Status = gBS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID **)&PciRbIo);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"dmem"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"dmem");
return (SHELL_NOT_FOUND); return (SHELL_NOT_FOUND);
} }
Buffer = AllocateZeroPool(Size);
Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) { if (Buffer == NULL) {
return SHELL_OUT_OF_RESOURCES; return SHELL_OUT_OF_RESOURCES;
} }
Status = PciRbIo->Mem.Read(PciRbIo, EfiPciWidthUint8, (UINT64)(UINTN)Address, Size, Buffer); Status = PciRbIo->Mem.Read (PciRbIo, EfiPciWidthUint8, (UINT64)(UINTN)Address, Size, Buffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_ER), gShellDebug1HiiHandle, L"dmem"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_ER), gShellDebug1HiiHandle, L"dmem");
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} else { } else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_MMIO_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_MMIO_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size);
DumpHex(2, (UINTN)Address, Size, Buffer); DumpHex (2, (UINTN)Address, Size, Buffer);
} }
FreePool(Buffer); FreePool (Buffer);
return (ShellStatus); return (ShellStatus);
} }
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-mmio", TypeFlag}, { L"-mmio", TypeFlag },
{NULL, TypeMax} { NULL, TypeMax }
}; };
/** /**
Function for 'dmem' command. Function for 'dmem' command.
@ -116,44 +118,45 @@ ShellCommandRunDmem (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = CommandInit(); Status = CommandInit ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// parse the command line // parse the command line
// //
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmem", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 3) { if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmem"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmem");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
Temp1 = ShellCommandLineGetRawValue(Package, 1); Temp1 = ShellCommandLineGetRawValue (Package, 1);
if (Temp1 == NULL) { if (Temp1 == NULL) {
Address = gST; Address = gST;
Size = sizeof (*gST); Size = sizeof (*gST);
} else { } else {
if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) { if (!ShellIsHexOrDecimalNumber (Temp1, TRUE, FALSE) || EFI_ERROR (ShellConvertStringToUint64 (Temp1, (UINT64 *)&Address, TRUE, FALSE))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
Temp1 = ShellCommandLineGetRawValue(Package, 2);
Temp1 = ShellCommandLineGetRawValue (Package, 2);
if (Temp1 == NULL) { if (Temp1 == NULL) {
Size = 512; Size = 512;
} else { } else {
if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, &Size, TRUE, FALSE))) { if (!ShellIsHexOrDecimalNumber (Temp1, FALSE, FALSE) || EFI_ERROR (ShellConvertStringToUint64 (Temp1, &Size, TRUE, FALSE))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
} }
@ -161,39 +164,48 @@ ShellCommandRunDmem (
} }
if (ShellStatus == SHELL_SUCCESS) { if (ShellStatus == SHELL_SUCCESS) {
if (!ShellCommandLineGetFlag(Package, L"-mmio")) { if (!ShellCommandLineGetFlag (Package, L"-mmio")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size);
DumpHex(2, (UINTN)Address, (UINTN)Size, Address); DumpHex (2, (UINTN)Address, (UINTN)Size, Address);
if (Address == (VOID*)gST) { if (Address == (VOID *)gST) {
Acpi20TableAddress = 0; Acpi20TableAddress = 0;
AcpiTableAddress = 0; AcpiTableAddress = 0;
SalTableAddress = 0; SalTableAddress = 0;
SmbiosTableAddress = 0; SmbiosTableAddress = 0;
MpsTableAddress = 0; MpsTableAddress = 0;
for (TableWalker = 0 ; TableWalker < gST->NumberOfTableEntries ; TableWalker++) { for (TableWalker = 0; TableWalker < gST->NumberOfTableEntries; TableWalker++) {
if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi20TableGuid)) { if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi20TableGuid)) {
Acpi20TableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; Acpi20TableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
continue; continue;
} }
if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi10TableGuid)) {
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi10TableGuid)) {
AcpiTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; AcpiTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
continue; continue;
} }
if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbiosTableGuid)) {
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbiosTableGuid)) {
SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
continue; continue;
} }
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbios3TableGuid)) { if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbios3TableGuid)) {
SmbiosTableAddress = (UINT64) (UINTN) gST->ConfigurationTable[TableWalker].VendorTable; SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
continue; continue;
} }
if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiMpsTableGuid)) {
if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiMpsTableGuid)) {
MpsTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; MpsTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
continue; 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, (UINT64)(UINTN)Address,
gST->Hdr.HeaderSize, gST->Hdr.HeaderSize,
gST->Hdr.Revision, gST->Hdr.Revision,
@ -210,11 +222,10 @@ ShellCommandRunDmem (
); );
} }
} else { } else {
ShellStatus = DisplayMmioMemory(Address, (UINTN)Size); ShellStatus = DisplayMmioMemory (Address, (UINTN)Size);
} }
} }
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }

View File

@ -49,27 +49,31 @@ GetAttrType (
if ((Atts & EFI_VARIABLE_NON_VOLATILE) != 0) { if ((Atts & EFI_VARIABLE_NON_VOLATILE) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+NV", 0); StrnCatGrow (&RetString, &BufLen, L"+NV", 0);
} }
if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) { if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0); StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0);
} else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) { } else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+BS", 0); StrnCatGrow (&RetString, &BufLen, L"+BS", 0);
} }
if ((Atts & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) { if ((Atts & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+HR", 0); StrnCatGrow (&RetString, &BufLen, L"+HR", 0);
} }
if ((Atts & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) { if ((Atts & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+AW", 0); StrnCatGrow (&RetString, &BufLen, L"+AW", 0);
} }
if ((Atts & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) { if ((Atts & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+AT", 0); StrnCatGrow (&RetString, &BufLen, L"+AT", 0);
} }
if (RetString == NULL) { if (RetString == NULL) {
RetString = StrnCatGrow(&RetString, &BufLen, L"Invalid", 0); RetString = StrnCatGrow (&RetString, &BufLen, L"Invalid", 0);
} }
if ((RetString != NULL) && (RetString[0] == L'+')) { if ((RetString != NULL) && (RetString[0] == L'+')) {
CopyMem(RetString, RetString + 1, StrSize(RetString + 1)); CopyMem (RetString, RetString + 1, StrSize (RetString + 1));
} }
return RetString; return RetString;
@ -85,7 +89,7 @@ GetAttrType (
@return The hex format string. @return The hex format string.
**/ **/
CHAR16* CHAR16 *
BinaryToHexString ( BinaryToHexString (
IN VOID *Buffer, IN VOID *Buffer,
IN UINTN BufferSize, IN UINTN BufferSize,
@ -105,9 +109,10 @@ BinaryToHexString (
&HexString[StringIndex], &HexString[StringIndex],
HexStringSize - StringIndex * sizeof (CHAR16), HexStringSize - StringIndex * sizeof (CHAR16),
L"%02x", L"%02x",
((UINT8 *) Buffer)[Index] ((UINT8 *)Buffer)[Index]
); );
} }
return HexString; return HexString;
} }
@ -188,8 +193,9 @@ LoadVariablesFromFile (
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
break; break;
} }
BufferSize = RemainingSize; BufferSize = RemainingSize;
Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *) Buffer + 2); Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *)Buffer + 2);
if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) { if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
ShellStatus = SHELL_VOLUME_CORRUPTED; ShellStatus = SHELL_VOLUME_CORRUPTED;
FreePool (Buffer); FreePool (Buffer);
@ -199,15 +205,15 @@ LoadVariablesFromFile (
// //
// Check Crc32 // Check Crc32
// //
* (UINT32 *) Buffer = NameSize; *(UINT32 *)Buffer = NameSize;
* ((UINT32 *) Buffer + 1) = DataSize; *((UINT32 *)Buffer + 1) = DataSize;
BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32); BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32);
gBS->CalculateCrc32 ( gBS->CalculateCrc32 (
Buffer, Buffer,
BufferSize, BufferSize,
&Crc32 &Crc32
); );
if (Crc32 != * (UINT32 *) (Buffer + BufferSize)) { if (Crc32 != *(UINT32 *)(Buffer + BufferSize)) {
FreePool (Buffer); FreePool (Buffer);
ShellStatus = SHELL_VOLUME_CORRUPTED; ShellStatus = SHELL_VOLUME_CORRUPTED;
break; break;
@ -221,10 +227,11 @@ LoadVariablesFromFile (
ShellStatus = SHELL_OUT_OF_RESOURCES; ShellStatus = SHELL_OUT_OF_RESOURCES;
break; break;
} }
Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE; Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
Variable->Name = (CHAR16 *) (Variable + 1); Variable->Name = (CHAR16 *)(Variable + 1);
Variable->DataSize = DataSize; Variable->DataSize = DataSize;
Variable->Data = (UINT8 *) Variable->Name + NameSize; Variable->Data = (UINT8 *)Variable->Name + NameSize;
CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize); CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize);
CopyMem (&Variable->Guid, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize, sizeof (EFI_GUID)); CopyMem (&Variable->Guid, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize, sizeof (EFI_GUID));
CopyMem (&Variable->Attributes, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID), sizeof (UINT32)); CopyMem (&Variable->Attributes, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID), sizeof (UINT32));
@ -235,7 +242,7 @@ LoadVariablesFromFile (
} }
if ((Position != FileSize) || (ShellStatus != SHELL_SUCCESS)) { if ((Position != FileSize) || (ShellStatus != SHELL_SUCCESS)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle, L"dmpstore"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle, L"dmpstore");
if (Position != FileSize) { if (Position != FileSize) {
ShellStatus = SHELL_VOLUME_CORRUPTED; ShellStatus = SHELL_VOLUME_CORRUPTED;
} }
@ -244,18 +251,27 @@ LoadVariablesFromFile (
for ( Link = GetFirstNode (&List) for ( Link = GetFirstNode (&List)
; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS) ; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
; Link = GetNextNode (&List, Link) ; Link = GetNextNode (&List, Link)
) { )
{
Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE); Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *) Name)) && if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *)Name)) &&
((Guid == NULL) || CompareGuid (&Variable->Guid, Guid)) ((Guid == NULL) || CompareGuid (&Variable->Guid, Guid))
) { )
{
Attributes = GetAttrType (Variable->Attributes); Attributes = GetAttrType (Variable->Attributes);
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle, -1,
Attributes, &Variable->Guid, Variable->Name, Variable->DataSize -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
Attributes,
&Variable->Guid,
Variable->Name,
Variable->DataSize
); );
SHELL_FREE_NON_NULL(Attributes); SHELL_FREE_NON_NULL (Attributes);
*Found = TRUE; *Found = TRUE;
Status = gRT->SetVariable ( Status = gRT->SetVariable (
@ -266,7 +282,7 @@ LoadVariablesFromFile (
Variable->Data Variable->Data
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", Variable->Name, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", Variable->Name, Status);
} }
} }
} }
@ -310,7 +326,7 @@ AppendSingleVariableToFile (
UINTN BufferSize; UINTN BufferSize;
EFI_STATUS Status; EFI_STATUS Status;
NameSize = (UINT32) StrSize (Name); NameSize = (UINT32)StrSize (Name);
BufferSize = sizeof (NameSize) + sizeof (DataSize) BufferSize = sizeof (NameSize) + sizeof (DataSize)
+ sizeof (*Guid) + sizeof (*Guid)
+ sizeof (Attributes) + sizeof (Attributes)
@ -326,9 +342,9 @@ AppendSingleVariableToFile (
// //
// NameSize and DataSize // NameSize and DataSize
// //
* (UINT32 *) Ptr = NameSize; *(UINT32 *)Ptr = NameSize;
Ptr += sizeof (NameSize); Ptr += sizeof (NameSize);
*(UINT32 *) Ptr = DataSize; *(UINT32 *)Ptr = DataSize;
Ptr += sizeof (DataSize); Ptr += sizeof (DataSize);
// //
@ -346,7 +362,7 @@ AppendSingleVariableToFile (
// //
// Attributes // Attributes
// //
* (UINT32 *) Ptr = Attributes; *(UINT32 *)Ptr = Attributes;
Ptr += sizeof (Attributes); Ptr += sizeof (Attributes);
// //
@ -358,14 +374,15 @@ AppendSingleVariableToFile (
// //
// Crc32 // Crc32
// //
gBS->CalculateCrc32 (Buffer, (UINTN) Ptr - (UINTN) Buffer, (UINT32 *) Ptr); gBS->CalculateCrc32 (Buffer, (UINTN)Ptr - (UINTN)Buffer, (UINT32 *)Ptr);
Status = ShellWriteFile (FileHandle, &BufferSize, Buffer); Status = ShellWriteFile (FileHandle, &BufferSize, Buffer);
FreePool (Buffer); FreePool (Buffer);
if (!EFI_ERROR (Status) && if (!EFI_ERROR (Status) &&
(BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32)) (BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32))
) { )
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -402,7 +419,7 @@ CascadeProcessVariables (
IN CONST EFI_GUID *Guid OPTIONAL, IN CONST EFI_GUID *Guid OPTIONAL,
IN DMP_STORE_TYPE Type, IN DMP_STORE_TYPE Type,
IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL, IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL,
IN CONST CHAR16 * CONST PrevName, IN CONST CHAR16 *CONST PrevName,
IN EFI_GUID FoundVarGuid, IN EFI_GUID FoundVarGuid,
IN BOOLEAN *FoundOne, IN BOOLEAN *FoundOne,
IN BOOLEAN StandardFormatOutput IN BOOLEAN StandardFormatOutput
@ -420,27 +437,27 @@ CascadeProcessVariables (
EFI_STATUS SetStatus; EFI_STATUS SetStatus;
CONST CHAR16 *GuidName; CONST CHAR16 *GuidName;
if (ShellGetExecutionBreakFlag()) { if (ShellGetExecutionBreakFlag ()) {
return (SHELL_ABORTED); return (SHELL_ABORTED);
} }
NameSize = 0; NameSize = 0;
FoundVarName = NULL; FoundVarName = NULL;
if (PrevName!=NULL) { if (PrevName != NULL) {
StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0); StrnCatGrow (&FoundVarName, &NameSize, PrevName, 0);
} else { } else {
FoundVarName = AllocateZeroPool(sizeof(CHAR16)); FoundVarName = AllocateZeroPool (sizeof (CHAR16));
NameSize = sizeof(CHAR16); NameSize = sizeof (CHAR16);
} }
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status == EFI_BUFFER_TOO_SMALL) {
SHELL_FREE_NON_NULL(FoundVarName); SHELL_FREE_NON_NULL (FoundVarName);
FoundVarName = AllocateZeroPool (NameSize); FoundVarName = AllocateZeroPool (NameSize);
if (FoundVarName != NULL) { if (FoundVarName != NULL) {
if (PrevName != NULL) { if (PrevName != NULL) {
StrnCpyS(FoundVarName, NameSize/sizeof(CHAR16), PrevName, NameSize/sizeof(CHAR16) - 1); StrnCpyS (FoundVarName, NameSize/sizeof (CHAR16), PrevName, NameSize/sizeof (CHAR16) - 1);
} }
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
@ -453,10 +470,10 @@ CascadeProcessVariables (
// No more is fine. // No more is fine.
// //
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
SHELL_FREE_NON_NULL(FoundVarName); SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_SUCCESS); return (SHELL_SUCCESS);
} else if (EFI_ERROR(Status)) { } else if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL(FoundVarName); SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_DEVICE_ERROR); return (SHELL_DEVICE_ERROR);
} }
@ -465,8 +482,8 @@ CascadeProcessVariables (
// //
ShellStatus = CascadeProcessVariables (Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne, StandardFormatOutput); ShellStatus = CascadeProcessVariables (Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne, StandardFormatOutput);
if (ShellGetExecutionBreakFlag() || (ShellStatus == SHELL_ABORTED)) { if (ShellGetExecutionBreakFlag () || (ShellStatus == SHELL_ABORTED)) {
SHELL_FREE_NON_NULL(FoundVarName); SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_ABORTED); return (SHELL_ABORTED);
} }
@ -474,11 +491,12 @@ CascadeProcessVariables (
// No matter what happened we process our own variable // No matter what happened we process our own variable
// Only continue if Guid and VariableName are each either NULL or a match // 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) ) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, FoundVarName, (CHAR16 *)Name))
&& ( Guid == NULL && ( (Guid == NULL)
|| CompareGuid(&FoundVarGuid, Guid) ) || CompareGuid (&FoundVarGuid, Guid))
) { )
{
DataSize = 0; DataSize = 0;
DataBuffer = NULL; DataBuffer = NULL;
// //
@ -495,20 +513,31 @@ CascadeProcessVariables (
Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer); Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
} }
} }
// //
// Last error check then print this variable out. // Last error check then print this variable out.
// //
if (Type == DmpStoreDisplay) { if (Type == DmpStoreDisplay) {
if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) { if (!EFI_ERROR (Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
AttrString = GetAttrType(Atts); AttrString = GetAttrType (Atts);
if (StandardFormatOutput) { if (StandardFormatOutput) {
HexString = AllocatePool ((DataSize * 2 + 1) * sizeof (CHAR16)); HexString = AllocatePool ((DataSize * 2 + 1) * sizeof (CHAR16));
if (HexString != NULL) { if (HexString != NULL) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_VAR_SFO), gShellDebug1HiiHandle, -1,
FoundVarName, &FoundVarGuid, Atts, DataSize, -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_VAR_SFO),
gShellDebug1HiiHandle,
FoundVarName,
&FoundVarGuid,
Atts,
DataSize,
BinaryToHexString ( BinaryToHexString (
DataBuffer, DataSize, HexString, (DataSize * 2 + 1) * sizeof (CHAR16) DataBuffer,
DataSize,
HexString,
(DataSize * 2 + 1) * sizeof (CHAR16)
) )
); );
FreePool (HexString); FreePool (HexString);
@ -516,35 +545,58 @@ CascadeProcessVariables (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} }
} else { } else {
Status = gEfiShellProtocol->GetGuidName(&FoundVarGuid, &GuidName); Status = gEfiShellProtocol->GetGuidName (&FoundVarGuid, &GuidName);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle, -1,
AttrString, &FoundVarGuid, FoundVarName, DataSize -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
AttrString,
&FoundVarGuid,
FoundVarName,
DataSize
); );
} else { } else {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2), gShellDebug1HiiHandle, -1,
AttrString, GuidName, FoundVarName, DataSize -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2),
gShellDebug1HiiHandle,
AttrString,
GuidName,
FoundVarName,
DataSize
); );
} }
DumpHex (2, 0, DataSize, DataBuffer); DumpHex (2, 0, DataSize, DataBuffer);
} }
SHELL_FREE_NON_NULL (AttrString); SHELL_FREE_NON_NULL (AttrString);
} }
} else if (Type == DmpStoreSave) { } else if (Type == DmpStoreSave) {
if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) { if (!EFI_ERROR (Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
AttrString = GetAttrType (Atts); AttrString = GetAttrType (Atts);
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle, -1,
AttrString, &FoundVarGuid, FoundVarName, DataSize -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
AttrString,
&FoundVarGuid,
FoundVarName,
DataSize
); );
Status = AppendSingleVariableToFile ( Status = AppendSingleVariableToFile (
FileHandle, FileHandle,
FoundVarName, FoundVarName,
&FoundVarGuid, &FoundVarGuid,
Atts, Atts,
(UINT32) DataSize, (UINT32)DataSize,
DataBuffer DataBuffer
); );
SHELL_FREE_NON_NULL (AttrString); SHELL_FREE_NON_NULL (AttrString);
@ -557,27 +609,39 @@ CascadeProcessVariables (
if (StandardFormatOutput) { if (StandardFormatOutput) {
if (SetStatus == EFI_SUCCESS) { if (SetStatus == EFI_SUCCESS) {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO), gShellDebug1HiiHandle, -1,
FoundVarName, &FoundVarGuid -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO),
gShellDebug1HiiHandle,
FoundVarName,
&FoundVarGuid
); );
} }
} else { } else {
ShellPrintHiiEx ( ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_DELETE_LINE), gShellDebug1HiiHandle, -1,
&FoundVarGuid, FoundVarName, SetStatus -1,
NULL,
STRING_TOKEN (STR_DMPSTORE_DELETE_LINE),
gShellDebug1HiiHandle,
&FoundVarGuid,
FoundVarName,
SetStatus
); );
} }
} }
SHELL_FREE_NON_NULL(DataBuffer);
SHELL_FREE_NON_NULL (DataBuffer);
} }
SHELL_FREE_NON_NULL(FoundVarName); SHELL_FREE_NON_NULL (FoundVarName);
if (Status == EFI_DEVICE_ERROR) { if (Status == EFI_DEVICE_ERROR) {
ShellStatus = SHELL_DEVICE_ERROR; ShellStatus = SHELL_DEVICE_ERROR;
} else if (Status == EFI_SECURITY_VIOLATION) { } else if (Status == EFI_SECURITY_VIOLATION) {
ShellStatus = SHELL_SECURITY_VIOLATION; ShellStatus = SHELL_SECURITY_VIOLATION;
} else if (EFI_ERROR(Status)) { } else if (EFI_ERROR (Status)) {
ShellStatus = SHELL_NOT_READY; ShellStatus = SHELL_NOT_READY;
} }
@ -614,10 +678,10 @@ ProcessVariables (
Found = FALSE; Found = FALSE;
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
ZeroMem (&FoundVarGuid, sizeof(EFI_GUID)); ZeroMem (&FoundVarGuid, sizeof (EFI_GUID));
if (StandardFormatOutput) { if (StandardFormatOutput) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"dmpstore"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"dmpstore");
} }
if (Type == DmpStoreLoad) { if (Type == DmpStoreLoad) {
@ -628,43 +692,45 @@ ProcessVariables (
if (!Found) { if (!Found) {
if (ShellStatus == SHELL_OUT_OF_RESOURCES) { if (ShellStatus == SHELL_OUT_OF_RESOURCES) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"dmpstore"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"dmpstore");
return (ShellStatus); return (ShellStatus);
} else if (Name != NULL && Guid == NULL) { } else if ((Name != NULL) && (Guid == NULL)) {
if (StandardFormatOutput) { if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N_SFO), gShellDebug1HiiHandle, Name); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N_SFO), gShellDebug1HiiHandle, Name);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, L"dmpstore", Name); 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); 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) { if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_SFO), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_SFO), gShellDebug1HiiHandle);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle, L"dmpstore"); 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) { if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G_SFO), gShellDebug1HiiHandle, Guid); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G_SFO), gShellDebug1HiiHandle, Guid);
} else { } else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid);
} }
} }
return (SHELL_NOT_FOUND); return (SHELL_NOT_FOUND);
} }
return (ShellStatus); return (ShellStatus);
} }
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-d", TypeFlag}, { L"-d", TypeFlag },
{L"-l", TypeValue}, { L"-l", TypeValue },
{L"-s", TypeValue}, { L"-s", TypeValue },
{L"-all", TypeFlag}, { L"-all", TypeFlag },
{L"-guid", TypeValue}, { L"-guid", TypeValue },
{L"-sfo", TypeFlag}, { L"-sfo", TypeFlag },
{NULL, TypeMax} { NULL, TypeMax }
}; };
/** /**
Function for 'dmpstore' command. Function for 'dmpstore' command.
@ -702,42 +768,43 @@ ShellCommandRunDmpStore (
StandardFormatOutput = FALSE; StandardFormatOutput = FALSE;
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 2) { if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag(Package, L"-all") && ShellCommandLineGetFlag(Package, L"-guid")) { } else if (ShellCommandLineGetFlag (Package, L"-all") && ShellCommandLineGetFlag (Package, L"-guid")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-all", L"-guid"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-all", L"-guid");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-l")) { } else if (ShellCommandLineGetFlag (Package, L"-s") && ShellCommandLineGetFlag (Package, L"-l")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l", L"-s"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l", L"-s");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-d")) { } else if ((ShellCommandLineGetFlag (Package, L"-s") || ShellCommandLineGetFlag (Package, L"-l")) && ShellCommandLineGetFlag (Package, L"-d")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-d"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-d");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-sfo")) { } else if ((ShellCommandLineGetFlag (Package, L"-s") || ShellCommandLineGetFlag (Package, L"-l")) && ShellCommandLineGetFlag (Package, L"-sfo")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-sfo"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-sfo");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
// //
// Determine the GUID to search for based on -all and -guid parameters // Determine the GUID to search for based on -all and -guid parameters
// //
if (!ShellCommandLineGetFlag(Package, L"-all")) { if (!ShellCommandLineGetFlag (Package, L"-all")) {
GuidStr = ShellCommandLineGetValue(Package, L"-guid"); GuidStr = ShellCommandLineGetValue (Package, L"-guid");
if (GuidStr != NULL) { if (GuidStr != NULL) {
RStatus = StrToGuid (GuidStr, &GuidData); RStatus = StrToGuid (GuidStr, &GuidData);
if (RETURN_ERROR (RStatus) || (GuidStr[GUID_STRING_LENGTH] != L'\0')) { if (RETURN_ERROR (RStatus) || (GuidStr[GUID_STRING_LENGTH] != L'\0')) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmpstore", GuidStr); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmpstore", GuidStr);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
Guid = &GuidData; Guid = &GuidData;
} else { } else {
Guid = &gEfiGlobalVariableGuid; Guid = &gEfiGlobalVariableGuid;
@ -749,14 +816,14 @@ ShellCommandRunDmpStore (
// //
// Get the Name of the variable to find // Get the Name of the variable to find
// //
Name = ShellCommandLineGetRawValue(Package, 1); Name = ShellCommandLineGetRawValue (Package, 1);
if (ShellStatus == SHELL_SUCCESS) { if (ShellStatus == SHELL_SUCCESS) {
if (ShellCommandLineGetFlag(Package, L"-s")) { if (ShellCommandLineGetFlag (Package, L"-s")) {
Type = DmpStoreSave; Type = DmpStoreSave;
File = ShellCommandLineGetValue(Package, L"-s"); File = ShellCommandLineGetValue (Package, L"-s");
if (File == NULL) { if (File == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-s"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-s");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
@ -778,6 +845,7 @@ ShellCommandRunDmpStore (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
} }
} }
FreePool (FileInfo); FreePool (FileInfo);
} }
} else if (Status == EFI_NOT_FOUND) { } else if (Status == EFI_NOT_FOUND) {
@ -803,16 +871,16 @@ ShellCommandRunDmpStore (
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
} }
} else if (ShellCommandLineGetFlag(Package, L"-l")) { } else if (ShellCommandLineGetFlag (Package, L"-l")) {
Type = DmpStoreLoad; Type = DmpStoreLoad;
File = ShellCommandLineGetValue(Package, L"-l"); File = ShellCommandLineGetValue (Package, L"-l");
if (File == NULL) { if (File == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-l"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-l");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
FileInfo = ShellGetFileInfo (FileHandle); FileInfo = ShellGetFileInfo (FileHandle);
@ -824,15 +892,16 @@ ShellCommandRunDmpStore (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
FreePool (FileInfo); FreePool (FileInfo);
} }
} }
} }
} else if (ShellCommandLineGetFlag(Package, L"-d")) { } else if (ShellCommandLineGetFlag (Package, L"-d")) {
Type = DmpStoreDelete; Type = DmpStoreDelete;
} }
if (ShellCommandLineGetFlag (Package,L"-sfo")) { if (ShellCommandLineGetFlag (Package, L"-sfo")) {
StandardFormatOutput = TRUE; StandardFormatOutput = TRUE;
} }
} }
@ -843,6 +912,7 @@ ShellCommandRunDmpStore (
} else if (Type == DmpStoreLoad) { } else if (Type == DmpStoreLoad) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File);
} }
ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput); ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput);
if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) { if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
ShellCloseFile (&FileHandle); ShellCloseFile (&FileHandle);
@ -854,6 +924,6 @@ ShellCommandRunDmpStore (
if (Package != NULL) { if (Package != NULL) {
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
return ShellStatus; return ShellStatus;
} }

View File

@ -32,7 +32,8 @@ ShellCommandRunEdit (
CHAR16 *Nfs; CHAR16 *Nfs;
CHAR16 *Spot; CHAR16 *Spot;
CONST CHAR16 *TempParam; CONST CHAR16 *TempParam;
// SHELL_FILE_HANDLE TempHandle;
// SHELL_FILE_HANDLE TempHandle;
Buffer = NULL; Buffer = NULL;
ShellStatus = SHELL_SUCCESS; ShellStatus = SHELL_SUCCESS;
@ -41,45 +42,47 @@ ShellCommandRunEdit (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = CommandInit(); Status = CommandInit ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// parse the command line // parse the command line
// //
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"edit", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 2) { if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"edit"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"edit");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
Cwd = gEfiShellProtocol->GetCurDir(NULL); Cwd = gEfiShellProtocol->GetCurDir (NULL);
if (Cwd == NULL) { if (Cwd == NULL) {
Cwd = ShellGetEnvironmentVariable(L"path"); Cwd = ShellGetEnvironmentVariable (L"path");
if (Cwd != NULL) { if (Cwd != NULL) {
Nfs = StrnCatGrow(&Nfs, NULL, Cwd+3, 0); Nfs = StrnCatGrow (&Nfs, NULL, Cwd+3, 0);
if (Nfs != NULL) { if (Nfs != NULL) {
Spot = StrStr(Nfs, L";"); Spot = StrStr (Nfs, L";");
if (Spot != NULL) { if (Spot != NULL) {
*Spot = CHAR_NULL; *Spot = CHAR_NULL;
} }
Spot = StrStr(Nfs, L"\\");
Spot = StrStr (Nfs, L"\\");
if (Spot != NULL) { if (Spot != NULL) {
Spot[1] = CHAR_NULL; Spot[1] = CHAR_NULL;
} }
gEfiShellProtocol->SetCurDir(NULL, Nfs);
FreePool(Nfs); gEfiShellProtocol->SetCurDir (NULL, Nfs);
FreePool (Nfs);
} }
} }
} }
@ -89,23 +92,23 @@ ShellCommandRunEdit (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gST->ConOut->ClearScreen (gST->ConOut); gST->ConOut->ClearScreen (gST->ConOut);
gST->ConOut->EnableCursor (gST->ConOut, TRUE); gST->ConOut->EnableCursor (gST->ConOut, TRUE);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_INIT_FAILED), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_MAIN_INIT_FAILED), gShellDebug1HiiHandle);
} else { } else {
MainEditorBackup (); MainEditorBackup ();
// //
// if editor launched with file named // if editor launched with file named
// //
if (ShellCommandLineGetCount(Package) == 2) { if (ShellCommandLineGetCount (Package) == 2) {
TempParam = ShellCommandLineGetRawValue(Package, 1); TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT(TempParam != NULL); ASSERT (TempParam != NULL);
FileBufferSetFileName (TempParam); FileBufferSetFileName (TempParam);
// if (EFI_ERROR(ShellFileExists(MainEditor.FileBuffer->FileName))) { // if (EFI_ERROR(ShellFileExists(MainEditor.FileBuffer->FileName))) {
// Status = ShellOpenFileByName(MainEditor.FileBuffer->FileName, &TempHandle, EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0); // Status = ShellOpenFileByName(MainEditor.FileBuffer->FileName, &TempHandle, EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
// if (!EFI_ERROR(Status)) { // if (!EFI_ERROR(Status)) {
// ShellCloseFile(&TempHandle); // ShellCloseFile(&TempHandle);
// } // }
// } // }
} }
Status = FileBufferRead (MainEditor.FileBuffer->FileName, FALSE); Status = FileBufferRead (MainEditor.FileBuffer->FileName, FALSE);
@ -119,7 +122,7 @@ ShellCommandRunEdit (
// //
// back up the status string // back up the status string
// //
Buffer = CatSPrint (NULL, L"%s", StatusBarGetString()); Buffer = CatSPrint (NULL, L"%s", StatusBarGetString ());
} }
MainEditorCleanup (); MainEditorCleanup ();
@ -129,19 +132,19 @@ ShellCommandRunEdit (
// //
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
} else if (Status == EFI_OUT_OF_RESOURCES) { } else if (Status == EFI_OUT_OF_RESOURCES) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"edit"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"edit");
} else { } else {
if (Buffer != NULL) { if (Buffer != NULL) {
if (StrCmp (Buffer, L"") != 0) { if (StrCmp (Buffer, L"") != 0) {
// //
// print out the status string // print out the status string
// //
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_BUFFER), gShellDebug1HiiHandle, Buffer); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_MAIN_BUFFER), gShellDebug1HiiHandle, Buffer);
} else { } else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle);
} }
} else { } else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle);
} }
} }
@ -150,7 +153,9 @@ ShellCommandRunEdit (
} }
} }
} }
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
return ShellStatus; return ShellStatus;
} }

View File

@ -73,7 +73,7 @@ FileBufferInit (
// //
// basically initialize the FileBuffer // basically initialize the FileBuffer
// //
CopyMem (&FileBuffer , &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER)); CopyMem (&FileBuffer, &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER));
CopyMem (&FileBufferBackupVar, &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER)); CopyMem (&FileBufferBackupVar, &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER));
// //
@ -157,7 +157,7 @@ InternalEditorMiscLineAdvance (
UINTN Index; UINTN Index;
CONST EFI_EDITOR_LINE *Line; CONST EFI_EDITOR_LINE *Line;
if (CurrentLine == NULL || LineList == NULL) { if ((CurrentLine == NULL) || (LineList == NULL)) {
return NULL; return NULL;
} }
@ -196,7 +196,7 @@ InternalEditorMiscLineRetreat (
UINTN Index; UINTN Index;
CONST EFI_EDITOR_LINE *Line; CONST EFI_EDITOR_LINE *Line;
if (CurrentLine == NULL || LineList == NULL) { if ((CurrentLine == NULL) || (LineList == NULL)) {
return NULL; return NULL;
} }
@ -237,10 +237,10 @@ MoveLine (
// if > 0, the advance // if > 0, the advance
// //
if (Count <= 0) { if (Count <= 0) {
AbsCount = (UINTN)ABS(Count); AbsCount = (UINTN)ABS (Count);
Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead); Line = InternalEditorMiscLineRetreat (AbsCount, MainEditor.FileBuffer->CurrentLine, MainEditor.FileBuffer->ListHead);
} else { } else {
Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead); Line = InternalEditorMiscLineAdvance ((UINTN)Count, MainEditor.FileBuffer->CurrentLine, MainEditor.FileBuffer->ListHead);
} }
return Line; return Line;
@ -271,20 +271,20 @@ FileBufferRestoreMousePosition (
Line = NULL; Line = NULL;
if (MainEditor.MouseSupported) { if (MainEditor.MouseSupported) {
if (FileBufferMouseNeedRefresh) { if (FileBufferMouseNeedRefresh) {
FileBufferMouseNeedRefresh = FALSE; FileBufferMouseNeedRefresh = FALSE;
// //
// if mouse position not moved and only mouse action // if mouse position not moved and only mouse action
// so do not need to refresh mouse position // so do not need to refresh mouse position
// //
if ((FileBuffer.MousePosition.Row == FileBufferBackupVar.MousePosition.Row && if ( ((FileBuffer.MousePosition.Row == FileBufferBackupVar.MousePosition.Row) &&
FileBuffer.MousePosition.Column == FileBufferBackupVar.MousePosition.Column) (FileBuffer.MousePosition.Column == FileBufferBackupVar.MousePosition.Column))
&& EditorMouseAction) { && EditorMouseAction)
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// backup the old screen attributes // backup the old screen attributes
// //
@ -307,7 +307,7 @@ FileBufferRestoreMousePosition (
CurrentLine = FileBuffer.CurrentLine; CurrentLine = FileBuffer.CurrentLine;
Line = MoveLine (FRow - FileBuffer.FilePosition.Row); Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
if (Line == NULL || FColumn > Line->Size) { if ((Line == NULL) || (FColumn > Line->Size)) {
HasCharacter = FALSE; HasCharacter = FALSE;
} }
@ -329,6 +329,7 @@ FileBufferRestoreMousePosition (
Value Value
); );
} }
// //
// set the new mouse position // set the new mouse position
// //
@ -347,7 +348,7 @@ FileBufferRestoreMousePosition (
CurrentLine = FileBuffer.CurrentLine; CurrentLine = FileBuffer.CurrentLine;
Line = MoveLine (FRow - FileBuffer.FilePosition.Row); Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
if (Line == NULL || FColumn > Line->Size) { if ((Line == NULL) || (FColumn > Line->Size)) {
HasCharacter = FALSE; HasCharacter = FALSE;
} }
@ -369,15 +370,18 @@ FileBufferRestoreMousePosition (
Value Value
); );
} }
// //
// end of HasCharacter // end of HasCharacter
// //
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data); gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
} }
// //
// end of MouseNeedRefresh // end of MouseNeedRefresh
// //
} }
// //
// end of MouseSupported // end of MouseSupported
// //
@ -406,7 +410,6 @@ FileBufferFreeLines (
// free all the lines // free all the lines
// //
if (FileBuffer.Lines != NULL) { if (FileBuffer.Lines != NULL) {
Line = FileBuffer.Lines; Line = FileBuffer.Lines;
Link = &(Line->Link); Link = &(Line->Link);
do { do {
@ -419,6 +422,7 @@ FileBufferFreeLines (
LineFree (Line); LineFree (Line);
} while (Link != FileBuffer.ListHead); } while (Link != FileBuffer.ListHead);
} }
// //
// clean the line list related structure // clean the line list related structure
// //
@ -456,7 +460,6 @@ FileBufferCleanup (
SHELL_FREE_NON_NULL (FileBufferBackupVar.FileName); SHELL_FREE_NON_NULL (FileBufferBackupVar.FileName);
return Status; return Status;
} }
/** /**
@ -473,7 +476,6 @@ FileBufferPrintLine (
IN CONST UINTN Row IN CONST UINTN Row
) )
{ {
CHAR16 *Buffer; CHAR16 *Buffer;
UINTN Limit; UINTN Limit;
CHAR16 *PrintLine; CHAR16 *PrintLine;
@ -493,7 +495,7 @@ FileBufferPrintLine (
BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16); BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16);
PrintLine = AllocatePool (BufLen); PrintLine = AllocatePool (BufLen);
if (PrintLine != NULL) { if (PrintLine != NULL) {
StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column)); StrnCpyS (PrintLine, BufLen/sizeof (CHAR16), Buffer, MIN (Limit, MainEditor.ScreenSize.Column));
for (Limit = StrLen (PrintLine); Limit < MainEditor.ScreenSize.Column; Limit++) { for (Limit = StrLen (PrintLine); Limit < MainEditor.ScreenSize.Column; Limit++) {
PrintLine[Limit] = L' '; PrintLine[Limit] = L' ';
} }
@ -502,7 +504,7 @@ FileBufferPrintLine (
PrintLine2 = AllocatePool (BufLen * 2); PrintLine2 = AllocatePool (BufLen * 2);
if (PrintLine2 != NULL) { if (PrintLine2 != NULL) {
ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE); ShellCopySearchAndReplace (PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
ShellPrintEx ( ShellPrintEx (
0, 0,
@ -512,6 +514,7 @@ FileBufferPrintLine (
); );
FreePool (PrintLine2); FreePool (PrintLine2);
} }
FreePool (PrintLine); FreePool (PrintLine);
} }
@ -563,10 +566,10 @@ FileBufferRefresh (
// //
if (!FileBufferNeedRefresh && if (!FileBufferNeedRefresh &&
!FileBufferOnlyLineNeedRefresh && !FileBufferOnlyLineNeedRefresh &&
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row && (FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row) &&
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column (FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column)
) { )
{
FileBufferRestoreMousePosition (); FileBufferRestoreMousePosition ();
FileBufferRestorePosition (); FileBufferRestorePosition ();
@ -580,10 +583,10 @@ FileBufferRefresh (
// only need to refresh current line // only need to refresh current line
// //
if (FileBufferOnlyLineNeedRefresh && if (FileBufferOnlyLineNeedRefresh &&
FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row && (FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row) &&
FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column (FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column)
) { )
{
EditorClearLine (FileBuffer.DisplayPosition.Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row); EditorClearLine (FileBuffer.DisplayPosition.Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
FileBufferPrintLine ( FileBufferPrintLine (
FileBuffer.CurrentLine, FileBuffer.CurrentLine,
@ -604,6 +607,7 @@ FileBufferRefresh (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// get the first line that will be displayed // get the first line that will be displayed
// //
@ -627,6 +631,7 @@ FileBufferRefresh (
Link = Link->ForwardLink; Link = Link->ForwardLink;
Row++; Row++;
} while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1)); } while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1));
// //
// while not file end and not screen full // while not file end and not screen full
// //
@ -669,6 +674,7 @@ FileBufferCreateLine (
if (Line == NULL) { if (Line == NULL) {
return NULL; return NULL;
} }
// //
// initialize the structure // initialize the structure
// //
@ -680,7 +686,7 @@ FileBufferCreateLine (
// //
// initial buffer of the line is "\0" // initial buffer of the line is "\0"
// //
ASSERT(CHAR_NULL == CHAR_NULL); ASSERT (CHAR_NULL == CHAR_NULL);
Line->Buffer = CatSPrint (NULL, L"\0"); Line->Buffer = CatSPrint (NULL, L"\0");
if (Line->Buffer == NULL) { if (Line->Buffer == NULL) {
return NULL; return NULL;
@ -717,9 +723,10 @@ FileBufferSetFileName (
// //
// Verify the parameters // Verify the parameters
// //
if (!IsValidFileName(Str)) { if (!IsValidFileName (Str)) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
// //
// free the old file name // free the old file name
// //
@ -735,6 +742,7 @@ FileBufferSetFileName (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Free the existing file lines and reset the modified flag. Free the existing file lines and reset the modified flag.
@ -754,7 +762,6 @@ FileBufferFree (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Read a file from disk into the FileBuffer. Read a file from disk into the FileBuffer.
@ -809,14 +816,14 @@ FileBufferRead (
// //
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
CreateFile = FALSE; CreateFile = FALSE;
if (FileHandle == NULL) { if (FileHandle == NULL) {
StatusBarSetStatusString (L"Disk Error"); StatusBarSetStatusString (L"Disk Error");
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
Info = ShellGetFileInfo(FileHandle); Info = ShellGetFileInfo (FileHandle);
if (Info->Attribute & EFI_FILE_DIRECTORY) { if (Info->Attribute & EFI_FILE_DIRECTORY) {
StatusBarSetStatusString (L"Directory Can Not Be Edited"); StatusBarSetStatusString (L"Directory Can Not Be Edited");
@ -829,10 +836,11 @@ FileBufferRead (
} else { } else {
FileBuffer.ReadOnly = FALSE; FileBuffer.ReadOnly = FALSE;
} }
// //
// get file size // get file size
// //
FileSize = (UINTN) Info->FileSize; FileSize = (UINTN)Info->FileSize;
FreePool (Info); FreePool (Info);
} else if (Status == EFI_NOT_FOUND) { } else if (Status == EFI_NOT_FOUND) {
@ -841,13 +849,14 @@ FileBufferRead (
// //
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_WRITE_PROTECTED || if ((Status == EFI_WRITE_PROTECTED) ||
Status == EFI_ACCESS_DENIED || (Status == EFI_ACCESS_DENIED) ||
Status == EFI_NO_MEDIA || (Status == EFI_NO_MEDIA) ||
Status == EFI_MEDIA_CHANGED (Status == EFI_MEDIA_CHANGED)
) { )
{
StatusBarSetStatusString (L"Access Denied"); 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"); StatusBarSetStatusString (L"Disk Error");
} else { } else {
StatusBarSetStatusString (L"Invalid File Name or Current-working-directory"); StatusBarSetStatusString (L"Invalid File Name or Current-working-directory");
@ -862,12 +871,14 @@ FileBufferRead (
if (Status == EFI_WARN_DELETE_FAILURE) { if (Status == EFI_WARN_DELETE_FAILURE) {
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
} }
FileHandle = NULL; FileHandle = NULL;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Access Denied"); StatusBarSetStatusString (L"Access Denied");
return Status; return Status;
} }
} }
// //
// file doesn't exist, so set CreateFile to TRUE // file doesn't exist, so set CreateFile to TRUE
// //
@ -881,12 +892,13 @@ FileBufferRead (
if (StrCmp (FileName, FileBuffer.FileName) != 0) { if (StrCmp (FileName, FileBuffer.FileName) != 0) {
FileBufferSetFileName (FileName); FileBufferSetFileName (FileName);
} }
// //
// free the old lines // free the old lines
// //
FileBufferFree (); FileBufferFree ();
} }
// //
// the file exists // the file exists
// //
@ -898,17 +910,19 @@ FileBufferRead (
if (Buffer == NULL) { if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// read file into Buffer // read file into Buffer
// //
Status = ShellReadFile (FileHandle, &FileSize, Buffer); Status = ShellReadFile (FileHandle, &FileSize, Buffer);
ShellCloseFile(&FileHandle); ShellCloseFile (&FileHandle);
FileHandle = NULL; FileHandle = NULL;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Read File Failed"); StatusBarSetStatusString (L"Read File Failed");
SHELL_FREE_NON_NULL (Buffer); SHELL_FREE_NON_NULL (Buffer);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
// //
// nothing in this file // nothing in this file
// //
@ -933,7 +947,7 @@ FileBufferRead (
// //
// Unicode file // Unicode file
// //
if (*(UINT16 *) Buffer == EFI_UNICODE_BYTE_ORDER_MARK) { if (*(UINT16 *)Buffer == EFI_UNICODE_BYTE_ORDER_MARK) {
// //
// Unicode file's size should be even // Unicode file's size should be even
// //
@ -956,10 +970,12 @@ FileBufferRead (
} else { } else {
FileBuffer.FileType = FileTypeAscii; FileBuffer.FileType = FileTypeAscii;
} }
// //
// end of AsciiBuffer == // end of AsciiBuffer ==
// //
} }
// //
// end of FileSize < 2 // end of FileSize < 2
// all the check ends // all the check ends
@ -1038,10 +1054,12 @@ FileBufferRead (
break; break;
} }
} }
// //
// endif == ASCII // endif == ASCII
// //
} }
// //
// end of for LineSize // end of for LineSize
// //
@ -1064,6 +1082,7 @@ FileBufferRead (
SHELL_FREE_NON_NULL (Buffer); SHELL_FREE_NON_NULL (Buffer);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// calculate file length // calculate file length
// //
@ -1079,18 +1098,20 @@ FileBufferRead (
RemoveEntryList (&Line->Link); RemoveEntryList (&Line->Link);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// copy this line to Line->Buffer // copy this line to Line->Buffer
// //
for (LoopVar2 = 0; LoopVar2 < LineSize; LoopVar2++) { for (LoopVar2 = 0; LoopVar2 < LineSize; LoopVar2++) {
if (FileBuffer.FileType == FileTypeAscii) { if (FileBuffer.FileType == FileTypeAscii) {
Line->Buffer[LoopVar2] = (CHAR16) AsciiBuffer[LoopVar1]; Line->Buffer[LoopVar2] = (CHAR16)AsciiBuffer[LoopVar1];
} else { } else {
Line->Buffer[LoopVar2] = UnicodeBuffer[LoopVar1]; Line->Buffer[LoopVar2] = UnicodeBuffer[LoopVar1];
} }
LoopVar1++; LoopVar1++;
} }
// //
// LoopVar1 now points to where CHAR_CARRIAGE_RETURN or CHAR_LINEFEED; // LoopVar1 now points to where CHAR_CARRIAGE_RETURN or CHAR_LINEFEED;
// //
@ -1100,32 +1121,35 @@ FileBufferRead (
Line->TotalSize = LineSize; Line->TotalSize = LineSize;
Line->Type = Type; Line->Type = Type;
if (Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) { if ((Type == NewLineTypeCarriageReturnLineFeed) || (Type == NewLineTypeLineFeedCarriageReturn)) {
LoopVar1++; LoopVar1++;
} }
// //
// last character is a return, SO create a new line // last character is a return, SO create a new line
// //
if (((Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) && LineSizeBackup == FileSize - 2) || if ((((Type == NewLineTypeCarriageReturnLineFeed) || (Type == NewLineTypeLineFeedCarriageReturn)) && (LineSizeBackup == FileSize - 2)) ||
((Type == NewLineTypeLineFeed || Type == NewLineTypeCarriageReturn) && LineSizeBackup == FileSize - 1) (((Type == NewLineTypeLineFeed) || (Type == NewLineTypeCarriageReturn)) && (LineSizeBackup == FileSize - 1))
) { )
{
Line = FileBufferCreateLine (); Line = FileBufferCreateLine ();
if (Line == NULL) { if (Line == NULL) {
SHELL_FREE_NON_NULL (Buffer); SHELL_FREE_NON_NULL (Buffer);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
} }
// //
// end of if // end of if
// //
} }
// //
// end of LoopVar1 // end of LoopVar1
// //
SHELL_FREE_NON_NULL (Buffer); SHELL_FREE_NON_NULL (Buffer);
} }
// //
// end of if CreateFile // end of if CreateFile
// //
@ -1149,7 +1173,8 @@ Done:
StatusBarSetStatusString (UnicodeBuffer); StatusBarSetStatusString (UnicodeBuffer);
FreePool (UnicodeBuffer); FreePool (UnicodeBuffer);
} }
/*
/*
// //
// check whether we have fs?: in filename // check whether we have fs?: in filename
// //
@ -1224,8 +1249,8 @@ Done:
FreePool (VolumeInfo); FreePool (VolumeInfo);
RootFs->Close (RootFs); RootFs->Close (RootFs);
} }
// //
*/ */
// //
// has line // has line
// //
@ -1248,7 +1273,6 @@ Done:
FileBufferOnlyLineNeedRefresh = FALSE; FileBufferOnlyLineNeedRefresh = FALSE;
FileBufferMouseNeedRefresh = TRUE; FileBufferMouseNeedRefresh = TRUE;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1278,10 +1302,11 @@ GetNewLine (
// //
// not legal new line type // 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; *Size = 0;
return ; return;
} }
// //
// use_cr: give 0x0d // use_cr: give 0x0d
// //
@ -1296,8 +1321,9 @@ GetNewLine (
} }
*Size = NewLineSize; *Size = NewLineSize;
return ; return;
} }
// //
// use_lf: give 0x0a // use_lf: give 0x0a
// //
@ -1312,8 +1338,9 @@ GetNewLine (
} }
*Size = NewLineSize; *Size = NewLineSize;
return ; return;
} }
// //
// use_crlf: give 0x0d 0x0a // use_crlf: give 0x0d 0x0a
// //
@ -1332,8 +1359,9 @@ GetNewLine (
} }
*Size = NewLineSize; *Size = NewLineSize;
return ; return;
} }
// //
// use_lfcr: give 0x0a 0x0d // use_lfcr: give 0x0a 0x0d
// //
@ -1352,9 +1380,8 @@ GetNewLine (
} }
*Size = NewLineSize; *Size = NewLineSize;
return ; return;
} }
} }
/** /**
@ -1379,7 +1406,7 @@ UnicodeToAscii (
// just buffer copy, not character copy // just buffer copy, not character copy
// //
for (Index = 0; Index < Length; Index++) { for (Index = 0; Index < Length; Index++) {
*AStr++ = (CHAR8) *UStr++; *AStr++ = (CHAR8)*UStr++;
} }
return Index; return Index;
@ -1433,12 +1460,10 @@ FileBufferSave (
Attribute = 0; Attribute = 0;
// //
// if is the old file // 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 // file has not been modified
// //
@ -1458,25 +1483,25 @@ FileBufferSave (
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0); Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Info = ShellGetFileInfo(FileHandle); 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"); StatusBarSetStatusString (L"Directory Can Not Be Saved");
ShellCloseFile (&FileHandle); ShellCloseFile (&FileHandle);
FreePool(Info); FreePool (Info);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
if (Info != NULL) { if (Info != NULL) {
Attribute = Info->Attribute & ~EFI_FILE_READ_ONLY; Attribute = Info->Attribute & ~EFI_FILE_READ_ONLY;
FreePool(Info); FreePool (Info);
} }
// //
// if file exits, so delete it // if file exits, so delete it
// //
Status = ShellDeleteFile (&FileHandle); 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"); StatusBarSetStatusString (L"Write File Failed");
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
@ -1494,7 +1519,7 @@ FileBufferSave (
// //
if (FileBuffer.FileType == FileTypeUnicode) { if (FileBuffer.FileType == FileTypeUnicode) {
Length = 2; Length = 2;
Status = ShellWriteFile (FileHandle, &Length, (VOID*)&gUnicodeFileTag); Status = ShellWriteFile (FileHandle, &Length, (VOID *)&gUnicodeFileTag);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellDeleteFile (&FileHandle); ShellDeleteFile (&FileHandle);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
@ -1522,16 +1547,18 @@ FileBufferSave (
if (Line->Type != NewLineTypeDefault) { if (Line->Type != NewLineTypeDefault) {
Type = Line->Type; Type = Line->Type;
} }
// //
// newline character is at most 4 bytes ( two Unicode characters ) // newline character is at most 4 bytes ( two Unicode characters )
// //
Length = 4; Length = 4;
if (Line->Buffer != NULL && Line->Size != 0) { if ((Line->Buffer != NULL) && (Line->Size != 0)) {
if (FileBuffer.FileType == FileTypeAscii) { if (FileBuffer.FileType == FileTypeAscii) {
Length += Line->Size; Length += Line->Size;
} else { } else {
Length += (Line->Size * 2); Length += (Line->Size * 2);
} }
// //
// end if FileTypeAscii // end if FileTypeAscii
// //
@ -1548,25 +1575,27 @@ FileBufferSave (
FreePool (Cache); FreePool (Cache);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
Ptr = Cache; Ptr = Cache;
LeftSize = TotalSize; LeftSize = TotalSize;
} }
if (Line->Buffer != NULL && Line->Size != 0) { if ((Line->Buffer != NULL) && (Line->Size != 0)) {
if (FileBuffer.FileType == FileTypeAscii) { if (FileBuffer.FileType == FileTypeAscii) {
UnicodeToAscii (Line->Buffer, Line->Size, Ptr); UnicodeToAscii (Line->Buffer, Line->Size, Ptr);
Length = Line->Size; Length = Line->Size;
} else { } else {
Length = (Line->Size * 2); Length = (Line->Size * 2);
CopyMem (Ptr, (CHAR8 *) Line->Buffer, Length); CopyMem (Ptr, (CHAR8 *)Line->Buffer, Length);
} }
// //
// end if FileTypeAscii // end if FileTypeAscii
// //
Ptr += Length; Ptr += Length;
LeftSize -= Length; LeftSize -= Length;
} }
// //
// end of if Line -> Buffer != NULL && Line -> Size != 0 // end of if Line -> Buffer != NULL && Line -> Size != 0
// //
@ -1574,7 +1603,7 @@ FileBufferSave (
// //
if (Link->ForwardLink != FileBuffer.ListHead) { if (Link->ForwardLink != FileBuffer.ListHead) {
GetNewLine (Type, NewLineBuffer, &NewLineSize); GetNewLine (Type, NewLineBuffer, &NewLineSize);
CopyMem (Ptr, (CHAR8 *) NewLineBuffer, NewLineSize); CopyMem (Ptr, (CHAR8 *)NewLineBuffer, NewLineSize);
Ptr += NewLineSize; Ptr += NewLineSize;
LeftSize -= NewLineSize; LeftSize -= NewLineSize;
@ -1595,7 +1624,7 @@ FileBufferSave (
FreePool (Cache); FreePool (Cache);
ShellCloseFile(&FileHandle); ShellCloseFile (&FileHandle);
FileBuffer.FileModified = FALSE; FileBuffer.FileModified = FALSE;
@ -1613,7 +1642,7 @@ FileBufferSave (
// //
// now everything is ready , you can set the new file name to filebuffer // 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 // not the same
// //
@ -1722,7 +1751,7 @@ LineCat (
Str = CatSPrint (NULL, L"%s%s", Dest->Buffer, Src->Buffer); Str = CatSPrint (NULL, L"%s%s", Dest->Buffer, Src->Buffer);
if (Str == NULL) { if (Str == NULL) {
Dest->Buffer = NULL; Dest->Buffer = NULL;
return ; return;
} }
Dest->Size = Size + Src->Size; Dest->Size = Size + Src->Size;
@ -1781,6 +1810,7 @@ FileBufferDoBackspace (
if (Line->Buffer == NULL) { if (Line->Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// remove End from line list // remove End from line list
// //
@ -1791,7 +1821,6 @@ FileBufferDoBackspace (
FileBufferNeedRefresh = TRUE; FileBufferNeedRefresh = TRUE;
FileBufferOnlyLineNeedRefresh = FALSE; FileBufferOnlyLineNeedRefresh = FALSE;
} else { } else {
// //
// just delete the previous character // just delete the previous character
@ -1873,6 +1902,7 @@ FileBufferDoReturn (
Line->Buffer[FileColumn - 1] = CHAR_NULL; Line->Buffer[FileColumn - 1] = CHAR_NULL;
Line->Size = FileColumn - 1; Line->Size = FileColumn - 1;
} }
// //
// increase NumLines // increase NumLines
// //
@ -1933,6 +1963,7 @@ FileBufferDoDelete (
if (Line->Link.ForwardLink == FileBuffer.ListHead) { if (Line->Link.ForwardLink == FileBuffer.ListHead) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// since last character, // since last character,
// so will add the next line to this line // so will add the next line to this line
@ -1951,7 +1982,6 @@ FileBufferDoDelete (
FileBufferNeedRefresh = TRUE; FileBufferNeedRefresh = TRUE;
FileBufferOnlyLineNeedRefresh = FALSE; FileBufferOnlyLineNeedRefresh = FALSE;
} else { } else {
// //
// just delete current character // just delete current character
@ -2052,6 +2082,7 @@ LineStrInsert (
Line->TotalSize += 8; Line->TotalSize += 8;
} }
// //
// move the later part of the string one character right // move the later part of the string one character right
// //
@ -2059,6 +2090,7 @@ LineStrInsert (
for (Index = StrSize; Index > Pos; Index--) { for (Index = StrSize; Index > Pos; Index--) {
TempStringPtr[Index] = TempStringPtr[Index - 1]; TempStringPtr[Index] = TempStringPtr[Index - 1];
} }
// //
// insert char into it. // insert char into it.
// //
@ -2098,11 +2130,12 @@ FileBufferAddChar (
// or replace the character. // or replace the character.
// //
FilePos = FileBuffer.FilePosition.Column - 1; 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); LineStrInsert (Line, Char, FilePos, Line->Size + 1);
} else { } else {
Line->Buffer[FilePos] = Char; Line->Buffer[FilePos] = Char;
} }
// //
// move cursor to right // move cursor to right
// //
@ -2156,14 +2189,13 @@ FileBufferDoCharInput (
// //
// DEAL WITH ASCII CHAR, filter out thing like ctrl+f // 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"); Status = StatusBarSetStatusString (L"Unknown Command");
} else { } else {
Status = FileBufferAddChar (Char); Status = FileBufferAddChar (Char);
} }
break; break;
} }
return Status; return Status;
@ -2204,7 +2236,6 @@ FileBufferScrollDown (
if (FCol > Line->Size) { if (FCol > Line->Size) {
FCol = Line->Size + 1; FCol = Line->Size + 1;
} }
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -2246,7 +2277,6 @@ FileBufferScrollUp (
if (FCol > Line->Size) { if (FCol > Line->Size) {
FCol = Line->Size + 1; FCol = Line->Size + 1;
} }
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -2287,6 +2317,7 @@ FileBufferPageDown (
// //
Gap = FileBuffer.NumLines - FRow; Gap = FileBuffer.NumLines - FRow;
} }
// //
// get correct line // get correct line
// //
@ -2295,7 +2326,7 @@ FileBufferPageDown (
// //
// if that line, is not that long, so move to the end of that line // 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; 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 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; FCol = Line->Size + 1;
} }
@ -2498,7 +2529,7 @@ FileBufferHandleInput (
// insert // insert
// //
case SCAN_INSERT: case SCAN_INSERT:
FileBuffer.ModeInsert = (BOOLEAN)!FileBuffer.ModeInsert; FileBuffer.ModeInsert = (BOOLEAN) !FileBuffer.ModeInsert;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
break; break;
@ -2621,10 +2652,10 @@ MoveCurrentLine (
UINTN AbsCount; UINTN AbsCount;
if (Count <= 0) { if (Count <= 0) {
AbsCount = (UINTN)ABS(Count); AbsCount = (UINTN)ABS (Count);
Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead); Line = InternalEditorMiscLineRetreat (AbsCount, MainEditor.FileBuffer->CurrentLine, MainEditor.FileBuffer->ListHead);
} else { } else {
Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead); Line = InternalEditorMiscLineAdvance ((UINTN)Count, MainEditor.FileBuffer->CurrentLine, MainEditor.FileBuffer->ListHead);
} }
if (Line == NULL) { if (Line == NULL) {
@ -2690,7 +2721,7 @@ FileBufferMovePosition (
// //
FileBuffer.FilePosition.Row = NewFilePosRow; FileBuffer.FilePosition.Row = NewFilePosRow;
if (RowGap < 0) { if (RowGap < 0) {
Abs = (UINTN)ABS(RowGap); Abs = (UINTN)ABS (RowGap);
FileBuffer.DisplayPosition.Row -= Abs; FileBuffer.DisplayPosition.Row -= Abs;
} else { } else {
FileBuffer.DisplayPosition.Row += RowGap; FileBuffer.DisplayPosition.Row += RowGap;
@ -2744,7 +2775,6 @@ FileBufferMovePosition (
// let CurrentLine point to correct line; // let CurrentLine point to correct line;
// //
FileBuffer.CurrentLine = MoveCurrentLine (RowGap); FileBuffer.CurrentLine = MoveCurrentLine (RowGap);
} }
/** /**
@ -2779,17 +2809,19 @@ FileBufferCutLine (
// //
// if is the last dummy line, SO CAN not cut // 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
// //
) { )
{
// //
// LAST LINE AND NOTHING ON THIS LINE, SO CUT NOTHING // LAST LINE AND NOTHING ON THIS LINE, SO CUT NOTHING
// //
StatusBarSetStatusString (L"Nothing to Cut"); StatusBarSetStatusString (L"Nothing to Cut");
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// if is the last line, so create a dummy line // if is the last line, so create a dummy line
// //
@ -2855,6 +2887,7 @@ FileBufferPasteLine (
if (MainEditor.CutLine == NULL) { if (MainEditor.CutLine == NULL) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// read only file can not be pasted on // read only file can not be pasted on
// //
@ -2867,6 +2900,7 @@ FileBufferPasteLine (
if (NewLine == NULL) { if (NewLine == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// insert it above current line // insert it above current line
// //
@ -2962,7 +2996,7 @@ FileBufferSearch (
Row = FileBuffer.FilePosition.Row + 1; Row = FileBuffer.FilePosition.Row + 1;
while (Link != FileBuffer.ListHead) { while (Link != FileBuffer.ListHead) {
Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE); Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
// Position = StrStr (Line->Buffer, Str); // Position = StrStr (Line->Buffer, Str);
CharPos = StrStr (Line->Buffer, Str); CharPos = StrStr (Line->Buffer, Str);
if (CharPos != NULL) { if (CharPos != NULL) {
Position = CharPos - Line->Buffer + 1; Position = CharPos - Line->Buffer + 1;
@ -3051,6 +3085,7 @@ FileBufferReplace (
if (FileBuffer.CurrentLine->Buffer == NULL) { if (FileBuffer.CurrentLine->Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// the end CHAR_NULL character; // the end CHAR_NULL character;
// //
@ -3064,6 +3099,7 @@ FileBufferReplace (
*Buffer = *(Buffer - Gap); *Buffer = *(Buffer - Gap);
Buffer--; Buffer--;
} }
// //
// set replace into it // set replace into it
// //
@ -3137,8 +3173,8 @@ FileBufferAdjustMousePosition (
// get absolute value // get absolute value
// //
AbsX = ABS(TextX); AbsX = ABS (TextX);
AbsY = ABS(TextY); AbsY = ABS (TextY);
CoordinateX = FileBuffer.MousePosition.Column; CoordinateX = FileBuffer.MousePosition.Column;
CoordinateY = FileBuffer.MousePosition.Row; CoordinateY = FileBuffer.MousePosition.Row;
@ -3162,29 +3198,30 @@ FileBufferAdjustMousePosition (
CoordinateY = 0; CoordinateY = 0;
} }
} }
// //
// check whether new mouse column position is beyond screen // check whether new mouse column position is beyond screen
// if not, adjust it // if not, adjust it
// //
if (CoordinateX >= 1 && CoordinateX <= MainEditor.ScreenSize.Column) { if ((CoordinateX >= 1) && (CoordinateX <= MainEditor.ScreenSize.Column)) {
FileBuffer.MousePosition.Column = CoordinateX; FileBuffer.MousePosition.Column = CoordinateX;
} else if (CoordinateX < 1) { } else if (CoordinateX < 1) {
FileBuffer.MousePosition.Column = 1; FileBuffer.MousePosition.Column = 1;
} else if (CoordinateX > MainEditor.ScreenSize.Column) { } else if (CoordinateX > MainEditor.ScreenSize.Column) {
FileBuffer.MousePosition.Column = MainEditor.ScreenSize.Column; FileBuffer.MousePosition.Column = MainEditor.ScreenSize.Column;
} }
// //
// check whether new mouse row position is beyond screen // check whether new mouse row position is beyond screen
// if not, adjust it // if not, adjust it
// //
if (CoordinateY >= 2 && CoordinateY <= (MainEditor.ScreenSize.Row - 1)) { if ((CoordinateY >= 2) && (CoordinateY <= (MainEditor.ScreenSize.Row - 1))) {
FileBuffer.MousePosition.Row = CoordinateY; FileBuffer.MousePosition.Row = CoordinateY;
} else if (CoordinateY < 2) { } else if (CoordinateY < 2) {
FileBuffer.MousePosition.Row = 2; FileBuffer.MousePosition.Row = 2;
} else if (CoordinateY > (MainEditor.ScreenSize.Row - 1)) { } else if (CoordinateY > (MainEditor.ScreenSize.Row - 1)) {
FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 1); FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 1);
} }
} }
/** /**
@ -3255,6 +3292,7 @@ FileBufferReplaceAll (
if (Line->Buffer == NULL) { if (Line->Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// the end CHAR_NULL character; // the end CHAR_NULL character;
// //
@ -3268,8 +3306,7 @@ FileBufferReplaceAll (
*Buffer = *(Buffer - Gap); *Buffer = *(Buffer - Gap);
Buffer--; Buffer--;
} }
} else if (ReplaceLen < SearchLen) {
} else if (ReplaceLen < SearchLen){
Buffer = Line->Buffer + Position + ReplaceLen; Buffer = Line->Buffer + Position + ReplaceLen;
Gap = SearchLen - ReplaceLen; Gap = SearchLen - ReplaceLen;
@ -3278,8 +3315,9 @@ FileBufferReplaceAll (
Buffer++; Buffer++;
} }
} else { } else {
ASSERT(ReplaceLen == SearchLen); ASSERT (ReplaceLen == SearchLen);
} }
// //
// set replace into it // set replace into it
// //
@ -3298,6 +3336,7 @@ FileBufferReplaceAll (
Link = Link->ForwardLink; Link = Link->ForwardLink;
} }
} }
// //
// call refresh to fresh edit area // call refresh to fresh edit area
// //
@ -3318,4 +3357,3 @@ FileBufferSetModified (
{ {
FileBuffer.FileModified = TRUE; FileBuffer.FileModified = TRUE;
} }

View File

@ -60,7 +60,7 @@ FileBufferRefresh (
**/ **/
EFI_STATUS EFI_STATUS
FileBufferHandleInput ( FileBufferHandleInput (
IN CONST EFI_INPUT_KEY * Key IN CONST EFI_INPUT_KEY *Key
); );
/** /**

View File

@ -35,7 +35,6 @@ extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
EFI_EDITOR_GLOBAL_EDITOR MainEditor; EFI_EDITOR_GLOBAL_EDITOR MainEditor;
/** /**
Load a file from disk to editor Load a file from disk to editor
@ -155,30 +154,30 @@ MainCommandPasteLine (
Help info that will be displayed. Help info that will be displayed.
**/ **/
EFI_STRING_ID MainMenuHelpInfo[] = { EFI_STRING_ID MainMenuHelpInfo[] = {
STRING_TOKEN(STR_EDIT_HELP_TITLE), STRING_TOKEN (STR_EDIT_HELP_TITLE),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_LIST_TITLE), STRING_TOKEN (STR_EDIT_HELP_LIST_TITLE),
STRING_TOKEN(STR_EDIT_HELP_DIV), STRING_TOKEN (STR_EDIT_HELP_DIV),
STRING_TOKEN(STR_EDIT_HELP_GO_TO_LINE), STRING_TOKEN (STR_EDIT_HELP_GO_TO_LINE),
STRING_TOKEN(STR_EDIT_HELP_SAVE_FILE), STRING_TOKEN (STR_EDIT_HELP_SAVE_FILE),
STRING_TOKEN(STR_EDIT_HELP_EXIT), STRING_TOKEN (STR_EDIT_HELP_EXIT),
STRING_TOKEN(STR_EDIT_HELP_SEARCH), STRING_TOKEN (STR_EDIT_HELP_SEARCH),
STRING_TOKEN(STR_EDIT_HELP_SEARCH_REPLACE), STRING_TOKEN (STR_EDIT_HELP_SEARCH_REPLACE),
STRING_TOKEN(STR_EDIT_HELP_CUT_LINE), STRING_TOKEN (STR_EDIT_HELP_CUT_LINE),
STRING_TOKEN(STR_EDIT_HELP_PASTE_LINE), STRING_TOKEN (STR_EDIT_HELP_PASTE_LINE),
STRING_TOKEN(STR_EDIT_HELP_OPEN_FILE), STRING_TOKEN (STR_EDIT_HELP_OPEN_FILE),
STRING_TOKEN(STR_EDIT_HELP_FILE_TYPE), STRING_TOKEN (STR_EDIT_HELP_FILE_TYPE),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_EXIT_HELP), STRING_TOKEN (STR_EDIT_HELP_EXIT_HELP),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK), STRING_TOKEN (STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_DIV), STRING_TOKEN (STR_EDIT_HELP_DIV),
0 0
}; };
MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = { MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {
@ -213,55 +212,55 @@ MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {
EDITOR_MENU_ITEM MainMenuItems[] = { EDITOR_MENU_ITEM MainMenuItems[] = {
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_GO_TO_LINE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_GO_TO_LINE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F1), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F1),
MainCommandGotoLine MainCommandGotoLine
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_SAVE_FILE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_SAVE_FILE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F2), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F2),
MainCommandSaveFile MainCommandSaveFile
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_EXIT), STRING_TOKEN (STR_EDIT_LIBMENUBAR_EXIT),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F3), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F3),
MainCommandExit MainCommandExit
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_SEARCH), STRING_TOKEN (STR_EDIT_LIBMENUBAR_SEARCH),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F4), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F4),
MainCommandSearch MainCommandSearch
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_SEARCH_REPLACE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_SEARCH_REPLACE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F5), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F5),
MainCommandSearchReplace MainCommandSearchReplace
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_CUT_LINE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_CUT_LINE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F6), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F6),
MainCommandCutLine MainCommandCutLine
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_PASTE_LINE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_PASTE_LINE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F7), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F7),
MainCommandPasteLine MainCommandPasteLine
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_OPEN_FILE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_OPEN_FILE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F8), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F8),
MainCommandOpenFile MainCommandOpenFile
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_FILE_TYPE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F9), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F9),
MainCommandSwitchFileType MainCommandSwitchFileType
}, },
{ {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE), STRING_TOKEN (STR_EDIT_LIBMENUBAR_FILE_TYPE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F11), STRING_TOKEN (STR_EDIT_LIBMENUBAR_F11),
MainCommandSwitchFileType MainCommandSwitchFileType
}, },
@ -272,7 +271,6 @@ EDITOR_MENU_ITEM MainMenuItems[] = {
} }
}; };
/** /**
Load a file from disk to editor Load a file from disk to editor
@ -317,11 +315,11 @@ MainCommandOpenFile (
// whether to save it first. // whether to save it first.
// //
if (MainEditor.FileBuffer->FileModified) { if (MainEditor.FileBuffer->FileModified) {
Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? "); Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// the answer is just one character // the answer is just one character
// //
@ -329,6 +327,7 @@ MainCommandOpenFile (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// loop for user's answer // loop for user's answer
// valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C' // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
@ -336,7 +335,7 @@ MainCommandOpenFile (
Done = FALSE; Done = FALSE;
while (!Done) { while (!Done) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -345,7 +344,7 @@ MainCommandOpenFile (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
// //
@ -375,6 +374,7 @@ MainCommandOpenFile (
} }
} }
} }
// //
// TO get the open file name // TO get the open file name
// //
@ -392,7 +392,7 @@ MainCommandOpenFile (
while (1) { while (1) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -400,14 +400,15 @@ MainCommandOpenFile (
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// The input string length should > 0 // The input string length should > 0
// //
if (StrLen (InputBarGetString()) > 0) { if (StrLen (InputBarGetString ()) > 0) {
// //
// CHECK if filename is valid // CHECK if filename is valid
// //
if (!IsValidFileName (InputBarGetString())) { if (!IsValidFileName (InputBarGetString ())) {
FileBufferRead (MainEditor.FileBuffer->FileName, TRUE); FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
StatusBarSetStatusString (L"Invalid File Name"); StatusBarSetStatusString (L"Invalid File Name");
return EFI_SUCCESS; return EFI_SUCCESS;
@ -416,10 +417,11 @@ MainCommandOpenFile (
break; break;
} }
} }
// //
// read from disk // read from disk
// //
Status = FileBufferRead (InputBarGetString(), FALSE); Status = FileBufferRead (InputBarGetString (), FALSE);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FileBufferRead (MainEditor.FileBuffer->FileName, TRUE); FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
@ -529,7 +531,6 @@ MainCommandPasteLine (
return Status; return Status;
} }
/** /**
search string in file buffer search string in file buffer
@ -576,7 +577,7 @@ MainCommandSearch (
} }
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC // ESC
@ -584,17 +585,19 @@ MainCommandSearch (
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// just enter pressed // just enter pressed
// //
if (StrLen (InputBarGetString()) == 0) { if (StrLen (InputBarGetString ()) == 0) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Buffer = CatSPrint (NULL, L"%s", InputBarGetString()); Buffer = CatSPrint (NULL, L"%s", InputBarGetString ());
if (Buffer == NULL) { if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// the first time , search from current position // the first time , search from current position
// //
@ -611,6 +614,7 @@ MainCommandSearch (
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
break; break;
} }
// //
// Find next // Find next
// //
@ -629,7 +633,7 @@ MainCommandSearch (
Done = FALSE; Done = FALSE;
while (!Done) { while (!Done) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -639,7 +643,7 @@ MainCommandSearch (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
Done = TRUE; Done = TRUE;
@ -649,19 +653,20 @@ MainCommandSearch (
case L'N': case L'N':
FreePool (Buffer); FreePool (Buffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// end of which // end of which
// //
} }
// //
// end of while !Done // end of while !Done
// for search second, third time, search from current position + strlen // for search second, third time, search from current position + strlen
// //
Offset = StrLen (Buffer); Offset = StrLen (Buffer);
} while (1); } while (1);
// //
// end of do // end of do
// //
@ -736,7 +741,7 @@ MainCommandSearchReplace (
} }
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC // ESC
@ -744,14 +749,15 @@ MainCommandSearchReplace (
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// if just pressed enter // if just pressed enter
// //
if (StrLen (InputBarGetString()) == 0) { if (StrLen (InputBarGetString ()) == 0) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Search = CatSPrint (NULL, L"%s", InputBarGetString()); Search = CatSPrint (NULL, L"%s", InputBarGetString ());
if (Search == NULL) { if (Search == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -772,7 +778,7 @@ MainCommandSearchReplace (
} }
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC // ESC
@ -781,7 +787,7 @@ MainCommandSearchReplace (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Replace = CatSPrint (NULL, L"%s", InputBarGetString()); Replace = CatSPrint (NULL, L"%s", InputBarGetString ());
if (Replace == NULL) { if (Replace == NULL) {
FreePool (Search); FreePool (Search);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -815,6 +821,7 @@ MainCommandSearchReplace (
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
break; break;
} }
// //
// replace or not? // replace or not?
// //
@ -836,7 +843,7 @@ MainCommandSearchReplace (
Done = FALSE; Done = FALSE;
while (!Done) { while (!Done) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -847,7 +854,7 @@ MainCommandSearchReplace (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
Done = TRUE; Done = TRUE;
@ -872,12 +879,13 @@ MainCommandSearchReplace (
FreePool (Search); FreePool (Search);
FreePool (Replace); FreePool (Replace);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// end of which // end of which
// //
} }
// //
// end of while !Done // end of while !Done
// Decide to Replace // Decide to Replace
@ -890,6 +898,7 @@ MainCommandSearchReplace (
StatusBarSetStatusString (L"Read Only File Can Not Be Modified"); StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// replace all // replace all
// //
@ -899,6 +908,7 @@ MainCommandSearchReplace (
FreePool (Replace); FreePool (Replace);
return Status; return Status;
} }
// //
// replace // replace
// //
@ -909,6 +919,7 @@ MainCommandSearchReplace (
return Status; return Status;
} }
} }
// //
// Find next // Find next
// //
@ -929,7 +940,7 @@ MainCommandSearchReplace (
Done = FALSE; Done = FALSE;
while (!Done) { while (!Done) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -940,7 +951,7 @@ MainCommandSearchReplace (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
Done = TRUE; Done = TRUE;
@ -951,18 +962,19 @@ MainCommandSearchReplace (
FreePool (Search); FreePool (Search);
FreePool (Replace); FreePool (Replace);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// end of which // end of which
// //
} }
// //
// end of while !Done // end of while !Done
// //
First = FALSE; First = FALSE;
} while (1); } while (1);
// //
// end of do // end of do
// //
@ -1004,7 +1016,6 @@ MainCommandExit (
// if file has been modified, so will prompt user whether to save the changes // if file has been modified, so will prompt user whether to save the changes
// //
if (MainEditor.FileBuffer->FileModified) { if (MainEditor.FileBuffer->FileModified) {
Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? "); Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -1017,7 +1028,7 @@ MainCommandExit (
while (1) { while (1) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -1026,7 +1037,7 @@ MainCommandExit (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
// //
@ -1047,14 +1058,12 @@ MainCommandExit (
case L'c': case L'c':
case L'C': case L'C':
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
} }
EditorExit = TRUE; EditorExit = TRUE;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -1086,6 +1095,7 @@ MainCommandGotoLine (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// line number's digit <= 6 // line number's digit <= 6
// //
@ -1095,7 +1105,7 @@ MainCommandGotoLine (
} }
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// press ESC // press ESC
@ -1103,22 +1113,24 @@ MainCommandGotoLine (
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// if JUST press enter // if JUST press enter
// //
if (StrLen (InputBarGetString()) == 0) { if (StrLen (InputBarGetString ()) == 0) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Row = ShellStrToUintn (InputBarGetString()); Row = ShellStrToUintn (InputBarGetString ());
// //
// invalid line number // invalid line number
// //
if (Row > MainEditor.FileBuffer->NumLines || Row <= 0) { if ((Row > MainEditor.FileBuffer->NumLines) || (Row <= 0)) {
StatusBarSetStatusString (L"No Such Line"); StatusBarSetStatusString (L"No Such Line");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// move cursor to that line's start // move cursor to that line's start
// //
@ -1200,22 +1212,22 @@ MainCommandSaveFile (
} }
Status = InputBarSetPrompt (Str); Status = InputBarSetPrompt (Str);
FreePool(Str); FreePool (Str);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = InputBarSetStringSize (100); Status = InputBarSetStringSize (100);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// get new file name // get new file name
// //
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// if user pressed ESC // if user pressed ESC
@ -1227,10 +1239,10 @@ MainCommandSaveFile (
// //
// if just enter pressed, so think save to current file name // if just enter pressed, so think save to current file name
// //
if (StrLen (InputBarGetString()) == 0) { if (StrLen (InputBarGetString ()) == 0) {
FileName = CatSPrint (NULL, L"%s", MainEditor.FileBuffer->FileName); FileName = CatSPrint (NULL, L"%s", MainEditor.FileBuffer->FileName);
} else { } else {
FileName = CatSPrint (NULL, L"%s", InputBarGetString()); FileName = CatSPrint (NULL, L"%s", InputBarGetString ());
} }
if (FileName == NULL) { if (FileName == NULL) {
@ -1265,18 +1277,18 @@ MainCommandSaveFile (
// //
// if the file exists // if the file exists
// //
if (ShellFileExists(FileName) != EFI_NOT_FOUND) { if (ShellFileExists (FileName) != EFI_NOT_FOUND) {
// //
// check for read only // check for read only
// //
Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Open Failed"); StatusBarSetStatusString (L"Open Failed");
FreePool (FileName); FreePool (FileName);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Info = ShellGetFileInfo(FileHandle); Info = ShellGetFileInfo (FileHandle);
if (Info == NULL) { if (Info == NULL) {
StatusBarSetStatusString (L"Access Denied"); StatusBarSetStatusString (L"Access Denied");
FreePool (FileName); FreePool (FileName);
@ -1289,6 +1301,7 @@ MainCommandSaveFile (
FreePool (FileName); FreePool (FileName);
return (EFI_SUCCESS); return (EFI_SUCCESS);
} }
FreePool (Info); FreePool (Info);
// //
@ -1308,7 +1321,7 @@ MainCommandSaveFile (
while (TRUE) { while (TRUE) {
Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column); Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// ESC pressed // ESC pressed
@ -1318,7 +1331,7 @@ MainCommandSaveFile (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
switch (InputBarGetString()[0]) { switch (InputBarGetString ()[0]) {
case L'y': case L'y':
case L'Y': case L'Y':
break; break;
@ -1337,7 +1350,7 @@ MainCommandSaveFile (
// //
// save file to disk with specified name // save file to disk with specified name
// //
FileBufferSetModified(); FileBufferSetModified ();
Status = FileBufferSave (FileName); Status = FileBufferSave (FileName);
SHELL_FREE_NON_NULL (FileName); SHELL_FREE_NON_NULL (FileName);
@ -1364,7 +1377,7 @@ MainCommandDisplayHelp (
// print helpInfo // print helpInfo
// //
for (CurrentLine = 0; 0 != MainMenuHelpInfo[CurrentLine]; CurrentLine++) { for (CurrentLine = 0; 0 != MainMenuHelpInfo[CurrentLine]; CurrentLine++) {
InfoString = HiiGetString(gShellDebug1HiiHandle, MainMenuHelpInfo[CurrentLine], NULL); InfoString = HiiGetString (gShellDebug1HiiHandle, MainMenuHelpInfo[CurrentLine], NULL);
ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString); ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString);
} }
@ -1376,13 +1389,15 @@ MainCommandDisplayHelp (
if (EFI_ERROR (Status) || (EventIndex != 0)) { if (EFI_ERROR (Status) || (EventIndex != 0)) {
continue; continue;
} }
Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData); Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) || 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, // For consoles that don't support/report shift state,
// CTRL+W is translated to L'W' - L'A' + 1. // 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) && } 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_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, // For consoles that supports/reports shift state,
// make sure that only CONTROL shift key is pressed. // make sure that only CONTROL shift key is pressed.
@ -1402,6 +1418,7 @@ MainCommandDisplayHelp (
} }
} }
} }
// //
// update screen with file buffer's info // update screen with file buffer's info
// //
@ -1416,14 +1433,13 @@ MainCommandDisplayHelp (
EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors; EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
INTN OriginalMode; INTN OriginalMode;
// //
// basic initialization for MainEditor // basic initialization for MainEditor
// //
EFI_EDITOR_GLOBAL_EDITOR MainEditorConst = { EFI_EDITOR_GLOBAL_EDITOR MainEditorConst = {
&FileBuffer, &FileBuffer,
{ {
{0, 0} { 0, 0}
}, },
{ {
0, 0,
@ -1461,7 +1477,7 @@ MainEditorInit (
// //
MainEditor.ColorAttributes.Colors.Foreground = gST->ConOut->Mode->Attribute & 0x000000ff; MainEditor.ColorAttributes.Colors.Foreground = gST->ConOut->Mode->Attribute & 0x000000ff;
MainEditor.ColorAttributes.Colors.Background = (UINT8) (gST->ConOut->Mode->Attribute >> 4); MainEditor.ColorAttributes.Colors.Background = (UINT8)(gST->ConOut->Mode->Attribute >> 4);
OriginalColors = MainEditor.ColorAttributes.Colors; OriginalColors = MainEditor.ColorAttributes.Colors;
OriginalMode = gST->ConOut->Mode->Mode; OriginalMode = gST->ConOut->Mode->Mode;
@ -1483,7 +1499,7 @@ MainEditorInit (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gST->ConsoleInHandle, gST->ConsoleInHandle,
&gEfiSimpleTextInputExProtocolGuid, &gEfiSimpleTextInputExProtocolGuid,
(VOID**)&MainEditor.TextInputEx (VOID **)&MainEditor.TextInputEx
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -1495,7 +1511,7 @@ MainEditorInit (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gST->ConsoleInHandle, gST->ConsoleInHandle,
&gEfiSimplePointerProtocolGuid, &gEfiSimplePointerProtocolGuid,
(VOID**)&MainEditor.MouseInterface (VOID **)&MainEditor.MouseInterface
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -1510,7 +1526,7 @@ MainEditorInit (
&HandleCount, &HandleCount,
&HandleBuffer &HandleBuffer
); );
if (!EFI_ERROR (Status) && HandleCount > 0) { if (!EFI_ERROR (Status) && (HandleCount > 0)) {
// //
// Try to find the first available mouse device // Try to find the first available mouse device
// //
@ -1518,19 +1534,20 @@ MainEditorInit (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiSimplePointerProtocolGuid, &gEfiSimplePointerProtocolGuid,
(VOID**)&MainEditor.MouseInterface (VOID **)&MainEditor.MouseInterface
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
} }
if (!EFI_ERROR (Status) && MainEditor.MouseInterface != NULL) { if (!EFI_ERROR (Status) && (MainEditor.MouseInterface != NULL)) {
MainEditor.MouseAccumulatorX = 0; MainEditor.MouseAccumulatorX = 0;
MainEditor.MouseAccumulatorY = 0; MainEditor.MouseAccumulatorY = 0;
MainEditor.MouseSupported = TRUE; MainEditor.MouseSupported = TRUE;
@ -1541,20 +1558,20 @@ MainEditorInit (
// //
Status = MainTitleBarInit (L"UEFI EDIT"); Status = MainTitleBarInit (L"UEFI EDIT");
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_TITLEBAR), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_TITLEBAR), gShellDebug1HiiHandle);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
Status = ControlHotKeyInit (MainControlBasedMenuFunctions); Status = ControlHotKeyInit (MainControlBasedMenuFunctions);
Status = MenuBarInit (MainMenuItems); Status = MenuBarInit (MainMenuItems);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_MAINMENU), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_MAINMENU), gShellDebug1HiiHandle);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
Status = StatusBarInit (); Status = StatusBarInit ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_STATUSBAR), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR), gShellDebug1HiiHandle);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
@ -1562,9 +1579,10 @@ MainEditorInit (
Status = FileBufferInit (); Status = FileBufferInit ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_FILEBUFFER), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), gShellDebug1HiiHandle);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
// //
// clear whole screen and enable cursor // clear whole screen and enable cursor
// //
@ -1599,21 +1617,23 @@ MainEditorCleanup (
// if error, do not exit // if error, do not exit
// just print some warning // just print some warning
// //
MainTitleBarCleanup(); MainTitleBarCleanup ();
StatusBarCleanup(); StatusBarCleanup ();
InputBarCleanup(); InputBarCleanup ();
MenuBarCleanup (); MenuBarCleanup ();
Status = FileBufferCleanup (); Status = FileBufferCleanup ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gShellDebug1HiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gShellDebug1HiiHandle);
} }
// //
// restore old mode // restore old mode
// //
if (OriginalMode != gST->ConOut->Mode->Mode) { if (OriginalMode != gST->ConOut->Mode->Mode) {
gST->ConOut->SetMode (gST->ConOut, OriginalMode); gST->ConOut->SetMode (gST->ConOut, OriginalMode);
} }
// //
// restore old screen color // restore old screen color
// //
@ -1643,22 +1663,22 @@ MainEditorRefresh (
// //
// call the components refresh function // call the components refresh function
// //
if (EditorFirst if ( EditorFirst
|| StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0 || (StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0)
|| FileBufferBackupVar.FileType != FileBuffer.FileType || (FileBufferBackupVar.FileType != FileBuffer.FileType)
|| FileBufferBackupVar.FileModified != FileBuffer.FileModified || (FileBufferBackupVar.FileModified != FileBuffer.FileModified)
|| FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly) { || (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); MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
FileBufferRestorePosition (); FileBufferRestorePosition ();
} }
if (EditorFirst if ( EditorFirst
|| FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row || (FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row)
|| FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column || (FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column)
|| FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert || (FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert)
|| StatusBarGetRefresh()) { || StatusBarGetRefresh ())
{
StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert); StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert);
FileBufferRestorePosition (); FileBufferRestorePosition ();
} }
@ -1690,9 +1710,9 @@ GetTextX (
INT32 Gap; INT32 Gap;
MainEditor.MouseAccumulatorX += GuidX; MainEditor.MouseAccumulatorX += GuidX;
Gap = (MainEditor.MouseAccumulatorX * (INT32) MainEditor.ScreenSize.Column) / (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionX); Gap = (MainEditor.MouseAccumulatorX * (INT32)MainEditor.ScreenSize.Column) / (INT32)(50 * (INT32)MainEditor.MouseInterface->Mode->ResolutionX);
MainEditor.MouseAccumulatorX = (MainEditor.MouseAccumulatorX * (INT32) MainEditor.ScreenSize.Column) % (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionX); MainEditor.MouseAccumulatorX = (MainEditor.MouseAccumulatorX * (INT32)MainEditor.ScreenSize.Column) % (INT32)(50 * (INT32)MainEditor.MouseInterface->Mode->ResolutionX);
MainEditor.MouseAccumulatorX = MainEditor.MouseAccumulatorX / (INT32) MainEditor.ScreenSize.Column; MainEditor.MouseAccumulatorX = MainEditor.MouseAccumulatorX / (INT32)MainEditor.ScreenSize.Column;
return Gap; return Gap;
} }
@ -1711,9 +1731,9 @@ GetTextY (
INT32 Gap; INT32 Gap;
MainEditor.MouseAccumulatorY += GuidY; MainEditor.MouseAccumulatorY += GuidY;
Gap = (MainEditor.MouseAccumulatorY * (INT32) MainEditor.ScreenSize.Row) / (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionY); Gap = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize.Row) / (INT32)(50 * (INT32)MainEditor.MouseInterface->Mode->ResolutionY);
MainEditor.MouseAccumulatorY = (MainEditor.MouseAccumulatorY * (INT32) MainEditor.ScreenSize.Row) % (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionY); MainEditor.MouseAccumulatorY = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize.Row) % (INT32)(50 * (INT32)MainEditor.MouseInterface->Mode->ResolutionY);
MainEditor.MouseAccumulatorY = MainEditor.MouseAccumulatorY / (INT32) MainEditor.ScreenSize.Row; MainEditor.MouseAccumulatorY = MainEditor.MouseAccumulatorY / (INT32)MainEditor.ScreenSize.Row;
return Gap; return Gap;
} }
@ -1731,7 +1751,6 @@ MainEditorHandleMouseInput (
IN EFI_SIMPLE_POINTER_STATE MouseState IN EFI_SIMPLE_POINTER_STATE MouseState
) )
{ {
INT32 TextX; INT32 TextX;
INT32 TextY; INT32 TextY;
UINTN FRow; UINTN FRow;
@ -1763,14 +1782,12 @@ MainEditorHandleMouseInput (
FileBufferAdjustMousePosition (TextX, TextY); FileBufferAdjustMousePosition (TextX, TextY);
Action = TRUE; Action = TRUE;
} }
// //
// if left button pushed down // if left button pushed down
// //
if (MouseState.LeftButton) { if (MouseState.LeftButton) {
FCol = MainEditor.FileBuffer->MousePosition.Column - 1 + 1; FCol = MainEditor.FileBuffer->MousePosition.Column - 1 + 1;
FRow = MainEditor.FileBuffer->FilePosition.Row + FRow = MainEditor.FileBuffer->FilePosition.Row +
@ -1806,6 +1823,7 @@ MainEditorHandleMouseInput (
Action = TRUE; Action = TRUE;
} }
// //
// mouse has action // mouse has action
// //
@ -1837,7 +1855,6 @@ MainEditorKeyInput (
BOOLEAN NoShiftState; BOOLEAN NoShiftState;
do { do {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
EditorMouseAction = FALSE; EditorMouseAction = FALSE;
@ -1857,7 +1874,6 @@ MainEditorKeyInput (
&MouseState &MouseState
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = MainEditorHandleMouseInput (MouseState); Status = MainEditorHandleMouseInput (MouseState);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -1884,7 +1900,7 @@ MainEditorKeyInput (
// //
// clear previous status string // clear previous status string
// //
StatusBarSetRefresh(); StatusBarSetRefresh ();
// //
// NoShiftState: TRUE when no shift key is pressed. // NoShiftState: TRUE when no shift key is pressed.
// //
@ -1892,7 +1908,7 @@ MainEditorKeyInput (
// //
// dispatch to different components' key handling function // dispatch to different components' key handling function
// //
if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey(&KeyData)) { if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey (&KeyData)) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} else if (NoShiftState && ((KeyData.Key.ScanCode == SCAN_NULL) || ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN)))) { } else if (NoShiftState && ((KeyData.Key.ScanCode == SCAN_NULL) || ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN)))) {
Status = FileBufferHandleInput (&KeyData.Key); Status = FileBufferHandleInput (&KeyData.Key);
@ -1903,22 +1919,21 @@ MainEditorKeyInput (
FileBufferMouseNeedRefresh = FALSE; 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 // 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"); StatusBarSetStatusString (L"Disk Error. Try Again");
} }
} }
}
}
}
}
// //
// after handling, refresh editor // after handling, refresh editor
// //
MainEditorRefresh (); MainEditorRefresh ();
} while (Status != EFI_OUT_OF_RESOURCES && !EditorExit); } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
return Status; return Status;
@ -1947,6 +1962,7 @@ MainEditorSetCutLine (
// //
LineFree (MainEditor.CutLine); LineFree (MainEditor.CutLine);
} }
// //
// duplicate the line to clipboard // duplicate the line to clipboard
// //

View File

@ -31,6 +31,7 @@ LineDup (
if (Dest == NULL) { if (Dest == NULL) {
return NULL; return NULL;
} }
// //
// allocate and set the line buffer // allocate and set the line buffer
// //
@ -63,22 +64,12 @@ LineFree (
) )
{ {
if (Src == NULL) { if (Src == NULL) {
return ; return;
} }
// //
// free the line buffer and then the line structure itself // free the line buffer and then the line structure itself
// //
SHELL_FREE_NON_NULL (Src->Buffer); SHELL_FREE_NON_NULL (Src->Buffer);
SHELL_FREE_NON_NULL (Src); SHELL_FREE_NON_NULL (Src);
} }

View File

@ -11,8 +11,6 @@
#include "TextEditorTypes.h" #include "TextEditorTypes.h"
/** /**
Free a EFI_EDITOR_LINE structure. Free a EFI_EDITOR_LINE structure.
@ -36,9 +34,4 @@ LineDup (
IN EFI_EDITOR_LINE *Src IN EFI_EDITOR_LINE *Src
); );
#endif #endif

View File

@ -91,7 +91,6 @@ typedef struct {
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface; EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
INT32 MouseAccumulatorX; INT32 MouseAccumulatorX;
INT32 MouseAccumulatorY; INT32 MouseAccumulatorY;
} EFI_EDITOR_GLOBAL_EDITOR; } EFI_EDITOR_GLOBAL_EDITOR;
#endif #endif

View File

@ -106,7 +106,6 @@ typedef union {
UINTN Data; UINTN Data;
} INPUT_BAR_COLOR_UNION; } INPUT_BAR_COLOR_UNION;
/** /**
The refresh function for InputBar, it will wait for user input The refresh function for InputBar, it will wait for user input
@ -152,10 +151,10 @@ InputBarRefresh (
// //
// clear input bar // clear input bar
// //
EditorClearLine (LastRow , LastColumn, LastRow); EditorClearLine (LastRow, LastColumn, LastRow);
gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1); gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);
// //
// this is a selection mPrompt, cursor will stay in edit area // this is a selection mPrompt, cursor will stay in edit area
@ -168,25 +167,30 @@ InputBarRefresh (
} else { } else {
NoDisplay = FALSE; NoDisplay = FALSE;
} }
// //
// wait for user input // wait for user input
// //
for (;;) { for ( ; ;) {
Status = gBS->WaitForEvent (1, &mTextInEx->WaitForKeyEx, &EventIndex); Status = gBS->WaitForEvent (1, &mTextInEx->WaitForKeyEx, &EventIndex);
if (EFI_ERROR (Status) || (EventIndex != 0)) { if (EFI_ERROR (Status) || (EventIndex != 0)) {
continue; continue;
} }
Status = mTextInEx->ReadKeyStrokeEx (mTextInEx, &KeyData); Status = mTextInEx->ReadKeyStrokeEx (mTextInEx, &KeyData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) && 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. // Shift key pressed.
// //
continue; continue;
} }
// //
// pressed ESC // pressed ESC
// //
@ -195,10 +199,11 @@ InputBarRefresh (
Status = EFI_NOT_READY; Status = EFI_NOT_READY;
break; break;
} }
// //
// return pressed // 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; break;
} else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) { } else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {
// //
@ -208,12 +213,10 @@ InputBarRefresh (
Size--; Size--;
mReturnString[Size] = CHAR_NULL; mReturnString[Size] = CHAR_NULL;
if (!NoDisplay) { if (!NoDisplay) {
InputBarPrintInput (LastColumn, LastRow); 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 // VALID ASCII char pressed
// //
@ -231,22 +234,18 @@ InputBarRefresh (
mReturnString[Size] = CHAR_NULL; mReturnString[Size] = CHAR_NULL;
if (!NoDisplay) { if (!NoDisplay) {
InputBarPrintInput (LastColumn, LastRow); InputBarPrintInput (LastColumn, LastRow);
} else { } else {
// //
// if just choose yes/no // if just choose yes/no
// //
break; break;
} }
} }
} }
mReturnString[Size] = CHAR_NULL; mReturnString[Size] = CHAR_NULL;
// //
// restore screen attributes // restore screen attributes
// //
@ -301,7 +300,7 @@ InputBarSetStringSize (
SHELL_FREE_NON_NULL (mReturnString); SHELL_FREE_NON_NULL (mReturnString);
StringSize = Size; StringSize = Size;
mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof(mReturnString[0])); mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof (mReturnString[0]));
if (mReturnString == NULL) { if (mReturnString == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -315,7 +314,7 @@ InputBarSetStringSize (
@retval NULL No input has been received. @retval NULL No input has been received.
@return The string that was input. @return The string that was input.
**/ **/
CONST CHAR16* CONST CHAR16 *
InputBarGetString ( InputBarGetString (
VOID VOID
) )

View File

@ -73,7 +73,7 @@ InputBarSetStringSize (
@retval NULL No input has been received. @retval NULL No input has been received.
@return The string that was input. @return The string that was input.
**/ **/
CONST CHAR16* CONST CHAR16 *
InputBarGetString ( InputBarGetString (
VOID VOID
); );

View File

@ -22,7 +22,7 @@ MenuBarCleanup (
VOID VOID
) )
{ {
SHELL_FREE_NON_NULL(MenuItems); SHELL_FREE_NON_NULL (MenuItems);
} }
/** /**
@ -40,13 +40,15 @@ MenuBarInit (
{ {
CONST EDITOR_MENU_ITEM *ItemsWalker; 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)); MenuItems = AllocateZeroPool ((NumItems+1) * sizeof (EDITOR_MENU_ITEM));
if (MenuItems == NULL) { if (MenuItems == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem(MenuItems, Items, (NumItems+1) * sizeof(EDITOR_MENU_ITEM));
CopyMem (MenuItems, Items, (NumItems+1) * sizeof (EDITOR_MENU_ITEM));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -65,6 +67,7 @@ ControlHotKeyInit (
ControlBasedMenuFunctions = Items; ControlBasedMenuFunctions = Items;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Refresh function for the menu bar. Refresh function for the menu bar.
@ -97,17 +100,13 @@ MenuBarRefresh (
// //
EditorClearLine (LastRow - 2, LastCol, LastRow); EditorClearLine (LastRow - 2, LastCol, LastRow);
EditorClearLine (LastRow - 1, LastCol, LastRow); EditorClearLine (LastRow - 1, LastCol, LastRow);
EditorClearLine (LastRow , LastCol, LastRow); EditorClearLine (LastRow, LastCol, LastRow);
// //
// print out the menu items // print out the menu items
// //
for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) { for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) {
NameString = HiiGetString (gShellDebug1HiiHandle, Item->NameToken, NULL);
NameString = HiiGetString(gShellDebug1HiiHandle, Item->NameToken, NULL);
Width = MAX ((StrLen (NameString) + 6), 20); Width = MAX ((StrLen (NameString) + 6), 20);
if (((Col + Width) > LastCol)) { if (((Col + Width) > LastCol)) {
@ -115,7 +114,7 @@ MenuBarRefresh (
Col = 1; Col = 1;
} }
FunctionKeyString = HiiGetString(gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL); FunctionKeyString = HiiGetString (gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);
ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString); ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
@ -178,7 +177,8 @@ MenuBarDispatchControlHotKey (
ControlIndex = MAX_UINT16; ControlIndex = MAX_UINT16;
if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) || 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, // For consoles that don't support/report shift state,
// Ctrl+A is translated to 1 (UnicodeChar). // Ctrl+A is translated to 1 (UnicodeChar).
@ -186,7 +186,8 @@ MenuBarDispatchControlHotKey (
ControlIndex = KeyData->Key.UnicodeChar; ControlIndex = KeyData->Key.UnicodeChar;
} else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) && } 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_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, // For consoles that supports/reports shift state,
// make sure only CONTROL is pressed. // make sure only CONTROL is pressed.
@ -197,8 +198,9 @@ MenuBarDispatchControlHotKey (
ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1; ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;
} }
} }
if ((SCAN_CONTROL_Z < ControlIndex)
||(NULL == ControlBasedMenuFunctions[ControlIndex])) if ( (SCAN_CONTROL_Z < ControlIndex)
|| (NULL == ControlBasedMenuFunctions[ControlIndex]))
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -206,5 +208,3 @@ MenuBarDispatchControlHotKey (
ControlBasedMenuFunctions[ControlIndex](); ControlBasedMenuFunctions[ControlIndex]();
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -22,7 +22,6 @@
#define SCAN_CONTROL_W 23 #define SCAN_CONTROL_W 23
#define SCAN_CONTROL_Z 26 #define SCAN_CONTROL_Z 26
typedef typedef
EFI_STATUS EFI_STATUS
(*MENU_ITEM_FUNCTION) ( (*MENU_ITEM_FUNCTION) (

View File

@ -91,6 +91,7 @@ StatusBarRefresh (
if (!StatusStringChanged && StatusBarNeedRefresh) { if (!StatusStringChanged && StatusBarNeedRefresh) {
StatusBarSetStatusString (L"\0"); StatusBarSetStatusString (L"\0");
} }
// //
// when it's called first time after editor launch, so refresh is mandatory // when it's called first time after editor launch, so refresh is mandatory
// //
@ -117,7 +118,7 @@ StatusBarRefresh (
// //
// print row, column fields // print row, column fields
// //
if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) { if ((FileRow != (UINTN)(-1)) && (FileCol != (UINTN)(-1))) {
ShellPrintEx ( ShellPrintEx (
0, 0,
(INT32)(LastRow) - 1, (INT32)(LastRow) - 1,
@ -143,6 +144,7 @@ StatusBarRefresh (
} else { } else {
ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR"); ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
} }
// //
// restore the old screen attributes // restore the old screen attributes
// //
@ -191,7 +193,7 @@ StatusBarSetStatusString (
@return The string that is used. @return The string that is used.
**/ **/
CONST CHAR16* CONST CHAR16 *
StatusBarGetString ( StatusBarGetString (
VOID VOID
) )
@ -203,7 +205,7 @@ StatusBarGetString (
Function to set the need refresh boolean to TRUE. Function to set the need refresh boolean to TRUE.
**/ **/
VOID VOID
StatusBarSetRefresh( StatusBarSetRefresh (
VOID VOID
) )
{ {
@ -216,7 +218,7 @@ StatusBarSetRefresh(
@retval TRUE The status bar needs to be refreshed. @retval TRUE The status bar needs to be refreshed.
**/ **/
BOOLEAN BOOLEAN
StatusBarGetRefresh( StatusBarGetRefresh (
VOID VOID
) )
{ {

View File

@ -70,7 +70,7 @@ StatusBarSetStatusString (
@return The string that is used. @return The string that is used.
**/ **/
CONST CHAR16* CONST CHAR16 *
StatusBarGetString ( StatusBarGetString (
VOID VOID
); );
@ -79,7 +79,7 @@ StatusBarGetString (
Function to set the need refresh boolean to TRUE. Function to set the need refresh boolean to TRUE.
**/ **/
VOID VOID
StatusBarSetRefresh( StatusBarSetRefresh (
VOID VOID
); );
@ -89,7 +89,7 @@ StatusBarSetRefresh(
@retval TRUE The status bar needs to be refreshed. @retval TRUE The status bar needs to be refreshed.
**/ **/
BOOLEAN BOOLEAN
StatusBarGetRefresh( StatusBarGetRefresh (
VOID VOID
); );

View File

@ -34,6 +34,7 @@ MainTitleBarInit (
// //
Title = CatSPrint (NULL, L"%s", Prompt); Title = CatSPrint (NULL, L"%s", Prompt);
} }
if (Title == NULL) { if (Title == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -94,7 +95,6 @@ MainTitleBarRefresh (
CONST CHAR16 *FileNameTmp; CONST CHAR16 *FileNameTmp;
INTN TempInteger; INTN TempInteger;
// //
// backup the old screen attributes // backup the old screen attributes
// //
@ -121,10 +121,12 @@ MainTitleBarRefresh (
Title Title
); );
} }
if (FileName == NULL) { if (FileName == NULL) {
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data); gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// First Extract the FileName from fullpath // First Extract the FileName from fullpath
// //
@ -141,57 +143,62 @@ MainTitleBarRefresh (
// the space for file name is 20 characters // the space for file name is 20 characters
// //
if (StrLen (FileNameTmp) <= 20) { if (StrLen (FileNameTmp) <= 20) {
ShellPrintEx (-1,-1, L"%s ", FileNameTmp); ShellPrintEx (-1, -1, L"%s ", FileNameTmp);
for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) { for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) {
ShellPrintEx (-1,-1, L" "); ShellPrintEx (-1, -1, L" ");
} }
} else { } else {
for (TempInteger = 0; TempInteger < 17; TempInteger++) { for (TempInteger = 0; TempInteger < 17; TempInteger++) {
ShellPrintEx (-1,-1, L"%c", FileNameTmp[TempInteger]); ShellPrintEx (-1, -1, L"%c", FileNameTmp[TempInteger]);
} }
// //
// print "..." // print "..."
// //
ShellPrintEx (-1,-1, L"... "); ShellPrintEx (-1, -1, L"... ");
} }
// //
// print file type field // print file type field
// //
switch (FileType){ switch (FileType) {
case FileTypeAscii: case FileTypeAscii:
case FileTypeUnicode: case FileTypeUnicode:
if (FileType == FileTypeAscii){ if (FileType == FileTypeAscii) {
ShellPrintEx (-1,-1, L" ASCII "); ShellPrintEx (-1, -1, L" ASCII ");
} else { } else {
ShellPrintEx (-1,-1, L" UNICODE "); ShellPrintEx (-1, -1, L" UNICODE ");
} }
// //
// print read-only field for text files // print read-only field for text files
// //
if (ReadOnly) { if (ReadOnly) {
ShellPrintEx (-1,-1, L"ReadOnly "); ShellPrintEx (-1, -1, L"ReadOnly ");
} else { } else {
ShellPrintEx (-1,-1, L" "); ShellPrintEx (-1, -1, L" ");
} }
break; break;
case FileTypeDiskBuffer: case FileTypeDiskBuffer:
case FileTypeMemBuffer: case FileTypeMemBuffer:
// //
// Print the offset. // Print the offset.
// //
ShellPrintEx (-1,-1, L"Offset %X | Size %X", Offset, Size); ShellPrintEx (-1, -1, L"Offset %X | Size %X", Offset, Size);
case FileTypeFileBuffer: case FileTypeFileBuffer:
break; break;
default: default:
break; break;
} }
// //
// print modified field // print modified field
// //
if (Modified) { if (Modified) {
ShellPrintEx (-1,-1, L"Modified"); ShellPrintEx (-1, -1, L"Modified");
} }
// //
// restore the old attribute // restore the old attribute
// //

View File

@ -52,74 +52,78 @@ ShellCommandRunEfiCompress (
// //
// initialize the shell lib (we must be in non-auto-init...) // initialize the shell lib (we must be in non-auto-init...)
// //
Status = ShellInitialize(); Status = ShellInitialize ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
Status = CommandInit(); Status = CommandInit ();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
// //
// parse the command line // parse the command line
// //
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) { 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); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"eficompress", ProblemParam);
FreePool(ProblemParam); FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
ASSERT(FALSE); ASSERT (FALSE);
} }
} else { } else {
if (ShellCommandLineGetCount(Package) > 3) { if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"eficompress"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) { } else if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress"); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
TempParam = ShellCommandLineGetRawValue(Package, 1); TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT(TempParam != NULL); ASSERT (TempParam != NULL);
InFileName = ShellFindFilePath(TempParam); InFileName = ShellFindFilePath (TempParam);
OutFileName = ShellCommandLineGetRawValue(Package, 2); OutFileName = ShellCommandLineGetRawValue (Package, 2);
if (InFileName == NULL) { if (InFileName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam);
ShellStatus = SHELL_NOT_FOUND; ShellStatus = SHELL_NOT_FOUND;
} else { } else {
if (ShellIsDirectory(InFileName) == EFI_SUCCESS){ if (ShellIsDirectory (InFileName) == EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName); if (ShellIsDirectory (OutFileName) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} }
if (ShellStatus == SHELL_SUCCESS) { if (ShellStatus == SHELL_SUCCESS) {
Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName (InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 1)); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_NOT_FOUND; 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)) { Status = ShellOpenFileByName (OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 2)); 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; ShellStatus = SHELL_NOT_FOUND;
} }
} }
if (ShellStatus == SHELL_SUCCESS) { if (ShellStatus == SHELL_SUCCESS) {
Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize); Status = gEfiShellProtocol->GetFileSize (InShellFileHandle, &InSize);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR (Status);
InBuffer = AllocateZeroPool((UINTN)InSize); InBuffer = AllocateZeroPool ((UINTN)InSize);
if (InBuffer == NULL) { if (InBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} else { } else {
InSize2 = (UINTN) InSize; InSize2 = (UINTN)InSize;
Status = gEfiShellProtocol->ReadFile (InShellFileHandle, &InSize2, InBuffer); Status = gEfiShellProtocol->ReadFile (InShellFileHandle, &InSize2, InBuffer);
InSize = InSize2; InSize = InSize2;
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = Compress (InBuffer, InSize, OutBuffer, &OutSize); Status = Compress (InBuffer, InSize, OutBuffer, &OutSize);
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status == EFI_BUFFER_TOO_SMALL) {
OutBuffer = AllocateZeroPool ((UINTN) OutSize); OutBuffer = AllocateZeroPool ((UINTN)OutSize);
if (OutBuffer == NULL) { if (OutBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} else { } else {
@ -127,14 +131,15 @@ ShellCommandRunEfiCompress (
} }
} }
} }
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status); 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); ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : SHELL_DEVICE_ERROR);
} else { } else {
OutSize2 = (UINTN)OutSize; OutSize2 = (UINTN)OutSize;
Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &OutSize2, OutBuffer); Status = gEfiShellProtocol->WriteFile (OutShellFileHandle, &OutSize2, OutBuffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"eficompress", OutFileName); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"eficompress", OutFileName);
ShellStatus = SHELL_DEVICE_ERROR; ShellStatus = SHELL_DEVICE_ERROR;
} }
} }
@ -144,15 +149,18 @@ ShellCommandRunEfiCompress (
ShellCommandLineFreeVarList (Package); ShellCommandLineFreeVarList (Package);
} }
if (InShellFileHandle != NULL) { if (InShellFileHandle != NULL) {
gEfiShellProtocol->CloseFile(InShellFileHandle); gEfiShellProtocol->CloseFile (InShellFileHandle);
} }
if (OutShellFileHandle != NULL) { if (OutShellFileHandle != NULL) {
gEfiShellProtocol->CloseFile(OutShellFileHandle); gEfiShellProtocol->CloseFile (OutShellFileHandle);
} }
SHELL_FREE_NON_NULL(InFileName);
SHELL_FREE_NON_NULL(InBuffer); SHELL_FREE_NON_NULL (InFileName);
SHELL_FREE_NON_NULL(OutBuffer); SHELL_FREE_NON_NULL (InBuffer);
SHELL_FREE_NON_NULL (OutBuffer);
return (ShellStatus); return (ShellStatus);
} }

Some files were not shown because too many files have changed in this diff Show More