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

@ -21,7 +21,7 @@
// the resource section. Thus the application can use '-?' option to show help message in
// Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_ACPIVIEW);
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_ACPIVIEW);
/**
Application Entry Point wrapper around the shell command

File diff suppressed because it is too large Load Diff

View File

@ -12,31 +12,31 @@
#define CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('c', 'o', 'P', 'D')
typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{
UINTN Signature;
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_HANDLE OldConHandle; ///< old protocol handle
UINTN ScreenCount; ///< How many screens worth of data to save
CHAR16 *Buffer; ///< Buffer to save data
UINTN BufferSize; ///< size of buffer in bytes
typedef struct _CONSOLE_LOGGER_PRIVATE_DATA {
UINTN Signature;
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_HANDLE OldConHandle; ///< old protocol handle
UINTN ScreenCount; ///< How many screens worth of data to save
CHAR16 *Buffer; ///< Buffer to save data
UINTN BufferSize; ///< size of buffer in bytes
// start row is the top of the screen
UINTN OriginalStartRow; ///< What the originally visible start row was
UINTN CurrentStartRow; ///< what the currently visible start row is
// start row is the top of the screen
UINTN OriginalStartRow; ///< What the originally visible start row was
UINTN CurrentStartRow; ///< what the currently visible start row is
UINTN RowsPerScreen; ///< how many rows the screen can display
UINTN ColsPerScreen; ///< how many columns the screen can display
UINTN RowsPerScreen; ///< how many rows the screen can display
UINTN ColsPerScreen; ///< how many columns the screen can display
INT32 *Attributes; ///< Buffer for Attribute to be saved for each character
UINTN AttribSize; ///< Size of Attributes in bytes
INT32 *Attributes; ///< Buffer for Attribute to be saved for each character
UINTN AttribSize; ///< Size of Attributes in bytes
EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode; ///< mode of the history log
BOOLEAN Enabled; ///< Set to FALSE when a break is requested.
UINTN RowCounter; ///< Initial row of each print job.
EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode; ///< mode of the history log
BOOLEAN Enabled; ///< Set to FALSE when a break is requested.
UINTN RowCounter; ///< Initial row of each print job.
} CONSOLE_LOGGER_PRIVATE_DATA;
#define CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(a) CR (a, CONSOLE_LOGGER_PRIVATE_DATA, OurConOut, CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE)
#define CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(a) CR (a, CONSOLE_LOGGER_PRIVATE_DATA, OurConOut, CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE)
/**
Install our intermediate ConOut into the system table to
@ -52,9 +52,9 @@ typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{
@sa InstallProtocolInterface
**/
EFI_STATUS
ConsoleLoggerInstall(
IN CONST UINTN ScreensToSave,
OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
ConsoleLoggerInstall (
IN CONST UINTN ScreensToSave,
OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
);
/**
@ -67,8 +67,8 @@ ConsoleLoggerInstall(
@return other The operation failed. This was from UninstallProtocolInterface.
**/
EFI_STATUS
ConsoleLoggerUninstall(
IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
ConsoleLoggerUninstall (
IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@ -84,10 +84,10 @@ ConsoleLoggerUninstall(
@param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/
EFI_STATUS
ConsoleLoggerDisplayHistory(
IN CONST BOOLEAN Forward,
IN CONST UINTN Rows,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
ConsoleLoggerDisplayHistory (
IN CONST BOOLEAN Forward,
IN CONST UINTN Rows,
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@ -100,8 +100,8 @@ ConsoleLoggerDisplayHistory(
@sa UpdateDisplayFromHistory
**/
EFI_STATUS
ConsoleLoggerStopHistory(
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
ConsoleLoggerStopHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@ -112,8 +112,8 @@ ConsoleLoggerStopHistory(
@return other The operation failed.
**/
EFI_STATUS
UpdateDisplayFromHistory(
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
UpdateDisplayFromHistory (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@ -129,8 +129,8 @@ UpdateDisplayFromHistory(
EFI_STATUS
EFIAPI
ConsoleLoggerReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
/**
@ -151,9 +151,9 @@ ConsoleLoggerReset (
**/
EFI_STATUS
EFIAPI
ConsoleLoggerOutputString(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
ConsoleLoggerOutputString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
);
/**
@ -173,8 +173,8 @@ ConsoleLoggerOutputString(
EFI_STATUS
EFIAPI
ConsoleLoggerTestString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
);
/**
@ -237,8 +237,8 @@ ConsoleLoggerSetMode (
EFI_STATUS
EFIAPI
ConsoleLoggerSetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
);
/**
@ -275,8 +275,8 @@ EFI_STATUS
EFIAPI
ConsoleLoggerSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Column,
IN UINTN Row
IN UINTN Column,
IN UINTN Row
);
/**
@ -309,9 +309,8 @@ ConsoleLoggerEnableCursor (
history buffers.
**/
EFI_STATUS
ConsoleLoggerResetBuffers(
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
ConsoleLoggerResetBuffers (
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
#endif //_CONSOLE_LOGGER_HEADER_

View File

@ -9,20 +9,20 @@
#include "Shell.h"
extern BOOLEAN AsciiRedirection;
extern BOOLEAN AsciiRedirection;
typedef struct {
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE TheHandle;
UINT64 RemainingBytesOfInputFile;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE TheHandle;
UINT64 RemainingBytesOfInputFile;
} SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
typedef struct {
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE TheHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE TheHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
} SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
/**
@ -36,8 +36,8 @@ typedef struct {
VOID
EFIAPI
ConInWaitForKey (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
gBS->SignalEvent (Event);
@ -53,9 +53,9 @@ ConInWaitForKey (
**/
EFI_STATUS
EFIAPI
FileBasedSimpleTextInReset(
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
FileBasedSimpleTextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
return (EFI_SUCCESS);
@ -71,18 +71,18 @@ FileBasedSimpleTextInReset(
**/
EFI_STATUS
EFIAPI
FileBasedSimpleTextInReadKeyStroke(
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN OUT EFI_INPUT_KEY *Key
FileBasedSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN OUT EFI_INPUT_KEY *Key
)
{
UINTN Size;
UINTN CharSize;
UINTN Size;
UINTN CharSize;
//
// Verify the parameters
//
if (Key == NULL || This == NULL) {
if ((Key == NULL) || (This == NULL)) {
return (EFI_INVALID_PARAMETER);
}
@ -93,13 +93,14 @@ FileBasedSimpleTextInReadKeyStroke(
return (EFI_NOT_READY);
}
Size = sizeof(CHAR16);
Size = sizeof (CHAR16);
if(!AsciiRedirection) {
CharSize = sizeof(CHAR16);
if (!AsciiRedirection) {
CharSize = sizeof (CHAR16);
} else {
CharSize = sizeof(CHAR8);
CharSize = sizeof (CHAR8);
}
//
// Decrement the amount of free space by Size or set to zero (for odd length files)
//
@ -110,10 +111,11 @@ FileBasedSimpleTextInReadKeyStroke(
}
Key->ScanCode = 0;
return (ShellInfoObject.NewEfiShellProtocol->ReadFile(
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
&Size,
&Key->UnicodeChar));
return (ShellInfoObject.NewEfiShellProtocol->ReadFile (
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
&Size,
&Key->UnicodeChar
));
}
/**
@ -126,8 +128,8 @@ FileBasedSimpleTextInReadKeyStroke(
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
EFI_SIMPLE_TEXT_INPUT_PROTOCOL*
CreateSimpleTextInOnFile(
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *
CreateSimpleTextInOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation
)
@ -137,17 +139,17 @@ CreateSimpleTextInOnFile(
UINT64 CurrentPosition;
UINT64 FileSize;
if (HandleLocation == NULL || FileHandleToUse == NULL) {
if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL);
}
ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
if (ProtocolToReturn == NULL) {
return (NULL);
}
ShellGetFileSize (FileHandleToUse, &FileSize);
ShellGetFilePosition(FileHandleToUse, &CurrentPosition);
ShellGetFileSize (FileHandleToUse, &FileSize);
ShellGetFilePosition (FileHandleToUse, &CurrentPosition);
//
// Initialize the protocol members
@ -165,21 +167,23 @@ CreateSimpleTextInOnFile(
&ProtocolToReturn->SimpleTextIn.WaitForKey
);
if (EFI_ERROR(Status)) {
FreePool(ProtocolToReturn);
if (EFI_ERROR (Status)) {
FreePool (ProtocolToReturn);
return (NULL);
}
///@todo possibly also install SimpleTextInputEx on the handle at this point.
Status = gBS->InstallProtocolInterface(
&(ProtocolToReturn->TheHandle),
&gEfiSimpleTextInProtocolGuid,
EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextIn));
if (!EFI_ERROR(Status)) {
/// @todo possibly also install SimpleTextInputEx on the handle at this point.
Status = gBS->InstallProtocolInterface (
&(ProtocolToReturn->TheHandle),
&gEfiSimpleTextInProtocolGuid,
EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextIn)
);
if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle;
return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)ProtocolToReturn);
return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)ProtocolToReturn);
} else {
FreePool(ProtocolToReturn);
FreePool (ProtocolToReturn);
return (NULL);
}
}
@ -193,26 +197,27 @@ CreateSimpleTextInOnFile(
@retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
CloseSimpleTextInOnFile(
CloseSimpleTextInOnFile (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
)
{
EFI_STATUS Status;
EFI_STATUS Status1;
EFI_STATUS Status;
EFI_STATUS Status1;
if (SimpleTextIn == NULL) {
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(
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle,
&gEfiSimpleTextInProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn));
Status1 = gBS->UninstallProtocolInterface (
((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->TheHandle,
&gEfiSimpleTextInProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn)
);
FreePool(SimpleTextIn);
if (!EFI_ERROR(Status)) {
FreePool (SimpleTextIn);
if (!EFI_ERROR (Status)) {
return (Status1);
} else {
return (Status);
@ -230,8 +235,8 @@ CloseSimpleTextInOnFile(
EFI_STATUS
EFIAPI
FileBasedSimpleTextOutReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
return (EFI_SUCCESS);
@ -249,8 +254,8 @@ FileBasedSimpleTextOutReset (
EFI_STATUS
EFIAPI
FileBasedSimpleTextOutTestString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
)
{
return (EFI_SUCCESS);
@ -270,22 +275,23 @@ FileBasedSimpleTextOutTestString (
EFI_STATUS
EFIAPI
FileBasedSimpleTextOutQueryMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
OUT UINTN *Columns,
OUT UINTN *Rows
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
OUT UINTN *Columns,
OUT UINTN *Rows
)
{
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;
PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
// Pass the QueryMode call thru to the original SimpleTextOutProtocol
return (PassThruProtocol->QueryMode(
PassThruProtocol,
ModeNumber,
Columns,
Rows));
return (PassThruProtocol->QueryMode (
PassThruProtocol,
ModeNumber,
Columns,
Rows
));
}
/**
@ -300,7 +306,7 @@ EFI_STATUS
EFIAPI
FileBasedSimpleTextOutSetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber
IN UINTN ModeNumber
)
{
return (EFI_UNSUPPORTED);
@ -320,8 +326,8 @@ FileBasedSimpleTextOutSetMode (
EFI_STATUS
EFIAPI
FileBasedSimpleTextOutSetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
)
{
return (EFI_SUCCESS);
@ -357,8 +363,8 @@ EFI_STATUS
EFIAPI
FileBasedSimpleTextOutSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Column,
IN UINTN Row
IN UINTN Column,
IN UINTN Row
)
{
return (EFI_SUCCESS);
@ -377,7 +383,7 @@ EFI_STATUS
EFIAPI
FileBasedSimpleTextOutEnableCursor (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN Visible
IN BOOLEAN Visible
)
{
return (EFI_SUCCESS);
@ -402,16 +408,18 @@ FileBasedSimpleTextOutEnableCursor (
EFI_STATUS
EFIAPI
FileBasedSimpleTextOutOutputString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *WString
)
{
UINTN Size;
Size = StrLen(WString) * sizeof(CHAR16);
return (ShellInfoObject.NewEfiShellProtocol->WriteFile(
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
&Size,
WString));
UINTN Size;
Size = StrLen (WString) * sizeof (CHAR16);
return (ShellInfoObject.NewEfiShellProtocol->WriteFile (
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
&Size,
WString
));
}
/**
@ -425,24 +433,25 @@ FileBasedSimpleTextOutOutputString (
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
CreateSimpleTextOutOnFile(
IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *
CreateSimpleTextOutOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
)
{
SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
EFI_STATUS Status;
SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
EFI_STATUS Status;
if (HandleLocation == NULL || FileHandleToUse == NULL) {
if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL);
}
ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
if (ProtocolToReturn == NULL) {
return (NULL);
}
ProtocolToReturn->FileHandle = FileHandleToUse;
ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
@ -454,11 +463,12 @@ CreateSimpleTextOutOnFile(
ProtocolToReturn->SimpleTextOut.SetCursorPosition = FileBasedSimpleTextOutSetCursorPosition;
ProtocolToReturn->SimpleTextOut.EnableCursor = FileBasedSimpleTextOutEnableCursor;
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) {
FreePool(ProtocolToReturn);
FreePool (ProtocolToReturn);
return (NULL);
}
ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
@ -466,17 +476,18 @@ CreateSimpleTextOutOnFile(
ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow;
ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;
Status = gBS->InstallProtocolInterface(
&(ProtocolToReturn->TheHandle),
&gEfiSimpleTextOutProtocolGuid,
EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextOut));
if (!EFI_ERROR(Status)) {
Status = gBS->InstallProtocolInterface (
&(ProtocolToReturn->TheHandle),
&gEfiSimpleTextOutProtocolGuid,
EFI_NATIVE_INTERFACE,
&(ProtocolToReturn->SimpleTextOut)
);
if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle;
return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);
return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)ProtocolToReturn);
} else {
SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode);
SHELL_FREE_NON_NULL(ProtocolToReturn);
SHELL_FREE_NON_NULL (ProtocolToReturn->SimpleTextOut.Mode);
SHELL_FREE_NON_NULL (ProtocolToReturn);
return (NULL);
}
}
@ -490,19 +501,22 @@ CreateSimpleTextOutOnFile(
@retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
CloseSimpleTextOutOnFile(
CloseSimpleTextOutOnFile (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
)
{
EFI_STATUS Status;
if (SimpleTextOut == NULL) {
return (EFI_INVALID_PARAMETER);
}
Status = gBS->UninstallProtocolInterface(
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle,
&gEfiSimpleTextOutProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));
FreePool(SimpleTextOut->Mode);
FreePool(SimpleTextOut);
Status = gBS->UninstallProtocolInterface (
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->TheHandle,
&gEfiSimpleTextOutProtocolGuid,
&(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->SimpleTextOut)
);
FreePool (SimpleTextOut->Mode);
FreePool (SimpleTextOut);
return (Status);
}

View File

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

View File

@ -18,9 +18,9 @@
**/
VOID
MoveCursorBackward (
IN UINTN LineLength,
IN OUT UINTN *Column,
IN OUT UINTN *Row
IN UINTN LineLength,
IN OUT UINTN *Column,
IN OUT UINTN *Row
);
/**
@ -33,10 +33,10 @@ MoveCursorBackward (
**/
VOID
MoveCursorForward (
IN UINTN LineLength,
IN UINTN TotalRow,
IN OUT UINTN *Column,
IN OUT UINTN *Row
IN UINTN LineLength,
IN UINTN TotalRow,
IN OUT UINTN *Column,
IN OUT UINTN *Row
);
/**
@ -50,10 +50,9 @@ MoveCursorForward (
**/
VOID
PrintCommandHistory (
IN CONST UINTN TotalCols,
IN CONST UINTN TotalRows,
IN CONST UINTN StartColumn
IN CONST UINTN TotalCols,
IN CONST UINTN TotalRows,
IN CONST UINTN StartColumn
);
#endif //_FILE_HANDLE_INTERNAL_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -10,34 +10,34 @@
#define _SHELL_FILE_HANDLE_WRAPPERS_HEADER_
typedef struct {
LIST_ENTRY Link;
CHAR16* Buffer;
LIST_ENTRY Link;
CHAR16 *Buffer;
} SHELL_LINE_LIST;
typedef struct {
UINTN LogCount;
SHELL_LINE_LIST *Log;
UINTN LogCount;
SHELL_LINE_LIST *Log;
} SHELL_LINE_LOG;
///
/// FILE styte interfaces for StdIn.
///
extern EFI_FILE_PROTOCOL FileInterfaceStdIn;
extern EFI_FILE_PROTOCOL FileInterfaceStdIn;
///
/// FILE styte interfaces for StdOut.
///
extern EFI_FILE_PROTOCOL FileInterfaceStdOut;
extern EFI_FILE_PROTOCOL FileInterfaceStdOut;
///
/// FILE styte interfaces for StdErr.
///
extern EFI_FILE_PROTOCOL FileInterfaceStdErr;
extern EFI_FILE_PROTOCOL FileInterfaceStdErr;
///
/// FILE style interface for NUL file.
///
extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
/**
Creates a EFI_FILE_PROTOCOL (almost) object for using to access
@ -48,9 +48,9 @@ extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
@retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
EFI_FILE_PROTOCOL*
CreateFileInterfaceEnv(
CONST CHAR16 *EnvName
EFI_FILE_PROTOCOL *
CreateFileInterfaceEnv (
CONST CHAR16 *EnvName
);
/**
@ -62,9 +62,9 @@ CreateFileInterfaceEnv(
@retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
EFI_FILE_PROTOCOL*
CreateFileInterfaceMem(
IN CONST BOOLEAN Unicode
EFI_FILE_PROTOCOL *
CreateFileInterfaceMem (
IN CONST BOOLEAN Unicode
);
/**
@ -77,11 +77,10 @@ CreateFileInterfaceMem(
@retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
EFI_FILE_PROTOCOL*
CreateFileInterfaceFile(
EFI_FILE_PROTOCOL *
CreateFileInterfaceFile (
IN CONST EFI_FILE_PROTOCOL *Template,
IN CONST BOOLEAN Unicode
);
#endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_

File diff suppressed because it is too large Load Diff

View File

@ -51,75 +51,75 @@
#include "ConsoleWrappers.h"
#include "FileHandleWrappers.h"
extern CONST CHAR16 mNoNestingEnvVarName[];
extern CONST CHAR16 mNoNestingTrue[];
extern CONST CHAR16 mNoNestingFalse[];
extern CONST CHAR16 mNoNestingEnvVarName[];
extern CONST CHAR16 mNoNestingTrue[];
extern CONST CHAR16 mNoNestingFalse[];
typedef struct {
LIST_ENTRY Link; ///< Standard linked list handler.
SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split.
SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split.
LIST_ENTRY Link; ///< Standard linked list handler.
SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split.
SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split.
} SPLIT_LIST;
typedef struct {
UINT32 Startup:1; ///< Was "-startup" found on command line.
UINT32 NoStartup:1; ///< Was "-nostartup" found on command line.
UINT32 NoConsoleOut:1; ///< Was "-noconsoleout" found on command line.
UINT32 NoConsoleIn:1; ///< Was "-noconsolein" found on command line.
UINT32 NoInterrupt:1; ///< Was "-nointerrupt" found on command line.
UINT32 NoMap:1; ///< Was "-nomap" found on command line.
UINT32 NoVersion:1; ///< Was "-noversion" found on command line.
UINT32 Delay:1; ///< Was "-delay[:n] found on command line
UINT32 Exit:1; ///< Was "-_exit" found on command line
UINT32 NoNest:1; ///< Was "-nonest" found on command line
UINT32 Reserved:7; ///< Extra bits
UINT32 Startup : 1; ///< Was "-startup" found on command line.
UINT32 NoStartup : 1; ///< Was "-nostartup" found on command line.
UINT32 NoConsoleOut : 1; ///< Was "-noconsoleout" found on command line.
UINT32 NoConsoleIn : 1; ///< Was "-noconsolein" found on command line.
UINT32 NoInterrupt : 1; ///< Was "-nointerrupt" found on command line.
UINT32 NoMap : 1; ///< Was "-nomap" found on command line.
UINT32 NoVersion : 1; ///< Was "-noversion" found on command line.
UINT32 Delay : 1; ///< Was "-delay[:n] found on command line
UINT32 Exit : 1; ///< Was "-_exit" found on command line
UINT32 NoNest : 1; ///< Was "-nonest" found on command line
UINT32 Reserved : 7; ///< Extra bits
} SHELL_BITS;
typedef union {
SHELL_BITS Bits;
UINT16 AllBits;
SHELL_BITS Bits;
UINT16 AllBits;
} SHELL_BIT_UNION;
typedef struct {
SHELL_BIT_UNION BitUnion;
UINTN Delay; ///< Seconds of delay default:5.
CHAR16 *FileName; ///< Filename to run upon successful initialization.
CHAR16 *FileOptions; ///< Options to pass to FileName.
SHELL_BIT_UNION BitUnion;
UINTN Delay; ///< Seconds of delay default:5.
CHAR16 *FileName; ///< Filename to run upon successful initialization.
CHAR16 *FileOptions; ///< Options to pass to FileName.
} SHELL_INIT_SETTINGS;
typedef struct {
BUFFER_LIST CommandHistory;
UINTN VisibleRowNumber;
UINTN OriginalVisibleRowNumber;
BOOLEAN InsertMode; ///< Is the current typing mode insert (FALSE = overwrite).
BUFFER_LIST CommandHistory;
UINTN VisibleRowNumber;
UINTN OriginalVisibleRowNumber;
BOOLEAN InsertMode; ///< Is the current typing mode insert (FALSE = overwrite).
} SHELL_VIEWING_SETTINGS;
typedef struct {
EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;
EFI_SHELL_PROTOCOL *NewEfiShellProtocol;
BOOLEAN PageBreakEnabled;
BOOLEAN RootShellInstance;
SHELL_INIT_SETTINGS ShellInitSettings;
BUFFER_LIST BufferToFreeList; ///< List of buffers that were returned to the user to free.
SHELL_VIEWING_SETTINGS ViewingSettings;
EFI_HII_HANDLE HiiHandle; ///< Handle from HiiLib.
UINTN LogScreenCount; ///< How many screens of log information to save.
EFI_EVENT UserBreakTimer; ///< Timer event for polling for CTRL-C.
EFI_DEVICE_PATH_PROTOCOL *ImageDevPath; ///< DevicePath for ourselves.
EFI_DEVICE_PATH_PROTOCOL *FileDevPath; ///< DevicePath for ourselves.
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; ///< Pointer for ConsoleInformation.
EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.
SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.
SPLIT_LIST SplitList; ///< List of Splits in FILO stack.
VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.
EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;
EFI_SHELL_PROTOCOL *NewEfiShellProtocol;
BOOLEAN PageBreakEnabled;
BOOLEAN RootShellInstance;
SHELL_INIT_SETTINGS ShellInitSettings;
BUFFER_LIST BufferToFreeList; ///< List of buffers that were returned to the user to free.
SHELL_VIEWING_SETTINGS ViewingSettings;
EFI_HII_HANDLE HiiHandle; ///< Handle from HiiLib.
UINTN LogScreenCount; ///< How many screens of log information to save.
EFI_EVENT UserBreakTimer; ///< Timer event for polling for CTRL-C.
EFI_DEVICE_PATH_PROTOCOL *ImageDevPath; ///< DevicePath for ourselves.
EFI_DEVICE_PATH_PROTOCOL *FileDevPath; ///< DevicePath for ourselves.
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; ///< Pointer for ConsoleInformation.
EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.
SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.
SPLIT_LIST SplitList; ///< List of Splits in FILO stack.
VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.
} SHELL_INFO;
#pragma pack(1)
@ -127,12 +127,12 @@ typedef struct {
/// HII specific Vendor Device Path definition.
///
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
} SHELL_MAN_HII_VENDOR_DEVICE_PATH;
#pragma pack()
extern SHELL_INFO ShellInfoObject;
extern SHELL_INFO ShellInfoObject;
/**
Converts the command line to its post-processed form. this replaces variables and alias' per UEFI Shell spec.
@ -144,8 +144,8 @@ extern SHELL_INFO ShellInfoObject;
@return some other error occurred
**/
EFI_STATUS
ProcessCommandLineToFinal(
IN OUT CHAR16 **CmdLine
ProcessCommandLineToFinal (
IN OUT CHAR16 **CmdLine
);
/**
@ -154,8 +154,8 @@ ProcessCommandLineToFinal(
@param[in] ErrorCode the error code to put into lasterror
**/
EFI_STATUS
SetLastError(
IN CONST SHELL_STATUS ErrorCode
SetLastError (
IN CONST SHELL_STATUS ErrorCode
);
/**
@ -164,7 +164,7 @@ SetLastError(
@retval EFI_SUCCESS all init commands were run successfully.
**/
EFI_STATUS
SetBuiltInAlias(
SetBuiltInAlias (
VOID
);
@ -184,8 +184,8 @@ SetBuiltInAlias(
**/
EFI_STATUS
GetDevicePathsForImageAndFile (
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
);
/**
@ -216,7 +216,7 @@ GetDevicePathsForImageAndFile (
@retval EFI_SUCCESS the variable is initialized.
**/
EFI_STATUS
ProcessCommandLine(
ProcessCommandLine (
VOID
);
@ -231,9 +231,9 @@ ProcessCommandLine(
@retval EFI_SUCCESS The variable is initialized.
**/
EFI_STATUS
DoStartupScript(
IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
DoStartupScript (
IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@ -255,9 +255,9 @@ DoShellPrompt (
@param Buffer Something to pass to FreePool when the shell is exiting.
**/
VOID*
AddBufferToFreeList(
VOID *Buffer
VOID *
AddBufferToFreeList (
VOID *Buffer
);
/**
@ -266,8 +266,8 @@ AddBufferToFreeList(
@param Buffer[in] The line buffer to add.
**/
VOID
AddLineToCommandHistory(
IN CONST CHAR16 *Buffer
AddLineToCommandHistory (
IN CONST CHAR16 *Buffer
);
/**
@ -281,8 +281,8 @@ AddLineToCommandHistory(
@retval EFI_ABORTED the command's operation was aborted
**/
EFI_STATUS
RunCommand(
IN CONST CHAR16 *CmdLine
RunCommand (
IN CONST CHAR16 *CmdLine
);
/**
@ -298,12 +298,11 @@ RunCommand(
@retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
RunShellCommand(
IN CONST CHAR16 *CmdLine,
OUT EFI_STATUS *CommandStatus
RunShellCommand (
IN CONST CHAR16 *CmdLine,
OUT EFI_STATUS *CommandStatus
);
/**
Function to process a NSH script file via SHELL_FILE_HANDLE.
@ -346,11 +345,11 @@ RunScriptFile (
@return the location of the first character in the string
@retval CHAR_NULL no instance of any character in CharacterList was found in String
**/
CONST CHAR16*
FindFirstCharacter(
IN CONST CHAR16 *String,
IN CONST CHAR16 *CharacterList,
IN CONST CHAR16 EscapeCharacter
CONST CHAR16 *
FindFirstCharacter (
IN CONST CHAR16 *String,
IN CONST CHAR16 *CharacterList,
IN CONST CHAR16 EscapeCharacter
);
/**
@ -359,8 +358,8 @@ FindFirstCharacter(
@param[in] String pointer to the string to trim them off.
**/
EFI_STATUS
TrimSpaces(
IN CHAR16 **String
TrimSpaces (
IN CHAR16 **String
);
/**
@ -371,7 +370,7 @@ TrimSpaces(
**/
VOID
SaveBufferList (
OUT LIST_ENTRY *OldBufferList
OUT LIST_ENTRY *OldBufferList
);
/**
@ -381,10 +380,7 @@ SaveBufferList (
**/
VOID
RestoreBufferList (
IN OUT LIST_ENTRY *OldBufferList
IN OUT LIST_ENTRY *OldBufferList
);
#endif //_SHELL_INTERNAL_HEADER_

View File

@ -14,7 +14,7 @@
//
// The list is used to cache the environment variables.
//
ENV_VAR_LIST gShellEnvVarList;
ENV_VAR_LIST gShellEnvVarList;
/**
Reports whether an environment variable is Volatile or Non-Volatile.
@ -27,8 +27,8 @@ ENV_VAR_LIST gShellEnvVarList;
**/
EFI_STATUS
IsVolatileEnv (
IN CONST CHAR16 *EnvVarName,
OUT BOOLEAN *Volatile
IN CONST CHAR16 *EnvVarName,
OUT BOOLEAN *Volatile
)
{
EFI_STATUS Status;
@ -38,29 +38,35 @@ IsVolatileEnv (
ASSERT (Volatile != NULL);
Size = 0;
Size = 0;
Buffer = NULL;
//
// get the variable
//
Status = gRT->GetVariable((CHAR16*)EnvVarName,
&gShellVariableGuid,
&Attribs,
&Size,
Buffer);
Status = gRT->GetVariable (
(CHAR16 *)EnvVarName,
&gShellVariableGuid,
&Attribs,
&Size,
Buffer
);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = gRT->GetVariable((CHAR16*)EnvVarName,
&gShellVariableGuid,
&Attribs,
&Size,
Buffer);
FreePool(Buffer);
Status = gRT->GetVariable (
(CHAR16 *)EnvVarName,
&gShellVariableGuid,
&Attribs,
&Size,
Buffer
);
FreePool (Buffer);
}
//
// not found means volatile
//
@ -68,6 +74,7 @@ IsVolatileEnv (
*Volatile = TRUE;
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
@ -75,7 +82,7 @@ IsVolatileEnv (
//
// 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;
}
@ -85,30 +92,33 @@ IsVolatileEnv (
@param[in] List The pointer to pointer to list.
**/
VOID
FreeEnvironmentVariableList(
IN LIST_ENTRY *List
FreeEnvironmentVariableList (
IN LIST_ENTRY *List
)
{
ENV_VAR_LIST *Node;
ENV_VAR_LIST *Node;
ASSERT (List != NULL);
if (List == NULL) {
return;
}
for ( Node = (ENV_VAR_LIST*)GetFirstNode(List)
; !IsListEmpty(List)
; Node = (ENV_VAR_LIST*)GetFirstNode(List)
){
ASSERT(Node != NULL);
RemoveEntryList(&Node->Link);
for ( Node = (ENV_VAR_LIST *)GetFirstNode (List)
; !IsListEmpty (List)
; Node = (ENV_VAR_LIST *)GetFirstNode (List)
)
{
ASSERT (Node != NULL);
RemoveEntryList (&Node->Link);
if (Node->Key != NULL) {
FreePool(Node->Key);
FreePool (Node->Key);
}
if (Node->Val != NULL) {
FreePool(Node->Val);
FreePool (Node->Val);
}
FreePool(Node);
FreePool (Node);
}
}
@ -121,18 +131,18 @@ FreeEnvironmentVariableList(
@retval EFI_SUCCESS the list was created successfully.
**/
EFI_STATUS
GetEnvironmentVariableList(
IN OUT LIST_ENTRY *ListHead
GetEnvironmentVariableList (
IN OUT LIST_ENTRY *ListHead
)
{
CHAR16 *VariableName;
UINTN NameSize;
UINTN NameBufferSize;
EFI_STATUS Status;
EFI_GUID Guid;
UINTN ValSize;
UINTN ValBufferSize;
ENV_VAR_LIST *VarList;
CHAR16 *VariableName;
UINTN NameSize;
UINTN NameBufferSize;
EFI_STATUS Status;
EFI_GUID Guid;
UINTN ValSize;
UINTN ValBufferSize;
ENV_VAR_LIST *VarList;
if (ListHead == NULL) {
return (EFI_INVALID_PARAMETER);
@ -140,34 +150,36 @@ GetEnvironmentVariableList(
Status = EFI_SUCCESS;
ValBufferSize = INIT_DATA_BUFFER_SIZE;
ValBufferSize = INIT_DATA_BUFFER_SIZE;
NameBufferSize = INIT_NAME_BUFFER_SIZE;
VariableName = AllocateZeroPool(NameBufferSize);
VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
*VariableName = CHAR_NULL;
while (!EFI_ERROR(Status)) {
while (!EFI_ERROR (Status)) {
NameSize = NameBufferSize;
Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
if (Status == EFI_NOT_FOUND){
Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
break;
} else if (Status == EFI_BUFFER_TOO_SMALL) {
NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
SHELL_FREE_NON_NULL(VariableName);
VariableName = AllocateZeroPool(NameBufferSize);
SHELL_FREE_NON_NULL (VariableName);
VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
break;
}
NameSize = NameBufferSize;
Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
}
if (!EFI_ERROR(Status) && CompareGuid(&Guid, &gShellVariableGuid)){
VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
if (!EFI_ERROR (Status) && CompareGuid (&Guid, &gShellVariableGuid)) {
VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
@ -177,12 +189,13 @@ GetEnvironmentVariableList(
//
VarList->Val = AllocateZeroPool (ValSize + sizeof (CHAR16));
if (VarList->Val == NULL) {
SHELL_FREE_NON_NULL(VarList);
Status = EFI_OUT_OF_RESOURCES;
break;
SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES;
break;
}
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
if (Status == EFI_BUFFER_TOO_SMALL){
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;
SHELL_FREE_NON_NULL (VarList->Val);
//
@ -190,34 +203,36 @@ GetEnvironmentVariableList(
//
VarList->Val = AllocateZeroPool (ValBufferSize + sizeof (CHAR16));
if (VarList->Val == NULL) {
SHELL_FREE_NON_NULL(VarList);
SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES;
break;
}
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) {
SHELL_FREE_NON_NULL(VarList->Val);
SHELL_FREE_NON_NULL(VarList);
SHELL_FREE_NON_NULL (VarList->Val);
SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES;
} else {
InsertTailList(ListHead, &VarList->Link);
InsertTailList (ListHead, &VarList->Link);
}
} else {
SHELL_FREE_NON_NULL(VarList->Val);
SHELL_FREE_NON_NULL(VarList);
SHELL_FREE_NON_NULL (VarList->Val);
SHELL_FREE_NON_NULL (VarList);
}
} // if (VarList == NULL) ... else ...
} // compare guid
} // while
SHELL_FREE_NON_NULL (VariableName);
if (EFI_ERROR(Status)) {
FreeEnvironmentVariableList(ListHead);
if (EFI_ERROR (Status)) {
FreeEnvironmentVariableList (ListHead);
}
return (Status);
@ -236,51 +251,56 @@ GetEnvironmentVariableList(
@retval EFI_SUCCESS the list was Set successfully.
**/
EFI_STATUS
SetEnvironmentVariableList(
IN LIST_ENTRY *ListHead
SetEnvironmentVariableList (
IN LIST_ENTRY *ListHead
)
{
ENV_VAR_LIST VarList;
ENV_VAR_LIST *Node;
EFI_STATUS Status;
UINTN Size;
ENV_VAR_LIST VarList;
ENV_VAR_LIST *Node;
EFI_STATUS Status;
UINTN Size;
InitializeListHead(&VarList.Link);
InitializeListHead (&VarList.Link);
//
// Delete all the current environment variables
//
Status = GetEnvironmentVariableList(&VarList.Link);
ASSERT_EFI_ERROR(Status);
Status = GetEnvironmentVariableList (&VarList.Link);
ASSERT_EFI_ERROR (Status);
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&VarList.Link)
; !IsNull(&VarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&VarList.Link, &Node->Link)
){
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&VarList.Link)
; !IsNull (&VarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST *)GetNextNode (&VarList.Link, &Node->Link)
)
{
if (Node->Key != NULL) {
Status = SHELL_DELETE_ENVIRONMENT_VARIABLE(Node->Key);
Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Node->Key);
}
ASSERT_EFI_ERROR(Status);
ASSERT_EFI_ERROR (Status);
}
FreeEnvironmentVariableList(&VarList.Link);
FreeEnvironmentVariableList (&VarList.Link);
//
// set all the variables from the list
//
for ( Node = (ENV_VAR_LIST*)GetFirstNode(ListHead)
; !IsNull(ListHead, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(ListHead, &Node->Link)
){
for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
; !IsNull (ListHead, &Node->Link)
; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
)
{
Size = StrSize (Node->Val) - sizeof (CHAR16);
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(Node->Key, Size, Node->Val);
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
} else {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
}
ASSERT_EFI_ERROR(Status);
ASSERT_EFI_ERROR (Status);
}
FreeEnvironmentVariableList(ListHead);
FreeEnvironmentVariableList (ListHead);
return (Status);
}
@ -299,8 +319,8 @@ SetEnvironmentVariableList(
@sa SetEnvironmentVariableList
**/
EFI_STATUS
SetEnvironmentVariables(
IN CONST CHAR16 **Environment
SetEnvironmentVariables (
IN CONST CHAR16 **Environment
)
{
CONST CHAR16 *CurrentString;
@ -318,61 +338,65 @@ SetEnvironmentVariables(
// Build a list identical to the ones used for get/set list functions above
//
for ( CurrentCount = 0
;
; CurrentCount++
){
;
; CurrentCount++
)
{
CurrentString = Environment[CurrentCount];
if (CurrentString == NULL) {
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) {
SetEnvironmentVariableList(&VarList->Link);
SetEnvironmentVariableList (&VarList->Link);
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) {
SHELL_FREE_NON_NULL(Node);
SetEnvironmentVariableList(&VarList->Link);
SHELL_FREE_NON_NULL (Node);
SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES);
}
//
// Copy the string into the Key, leaving the last character allocated as NULL to terminate
//
StrnCpyS( Node->Key,
StrStr(CurrentString, L"=") - CurrentString + 1,
CurrentString,
StrStr(CurrentString, L"=") - CurrentString
);
StrnCpyS (
Node->Key,
StrStr (CurrentString, L"=") - CurrentString + 1,
CurrentString,
StrStr (CurrentString, L"=") - CurrentString
);
//
// 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) {
SHELL_FREE_NON_NULL(Node->Key);
SHELL_FREE_NON_NULL(Node);
SetEnvironmentVariableList(&VarList->Link);
SHELL_FREE_NON_NULL (Node->Key);
SHELL_FREE_NON_NULL (Node);
SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES);
}
Node->Atts = EFI_VARIABLE_BOOTSERVICE_ACCESS;
if (VarList == NULL) {
VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) {
SHELL_FREE_NON_NULL(Node->Key);
SHELL_FREE_NON_NULL(Node->Val);
SHELL_FREE_NON_NULL(Node);
SHELL_FREE_NON_NULL (Node->Key);
SHELL_FREE_NON_NULL (Node->Val);
SHELL_FREE_NON_NULL (Node);
return (EFI_OUT_OF_RESOURCES);
}
InitializeListHead(&VarList->Link);
}
InsertTailList(&VarList->Link, &Node->Link);
InitializeListHead (&VarList->Link);
}
InsertTailList (&VarList->Link, &Node->Link);
} // for loop
//
@ -380,7 +404,7 @@ SetEnvironmentVariables(
// this function also frees the memory and deletes all pre-existing
// shell-guid based environment variables.
//
return (SetEnvironmentVariableList(&VarList->Link));
return (SetEnvironmentVariableList (&VarList->Link));
}
/**
@ -400,28 +424,30 @@ SetEnvironmentVariables(
**/
EFI_STATUS
ShellFindEnvVarInList (
IN CONST CHAR16 *Key,
OUT CHAR16 **Value,
OUT UINTN *ValueSize,
OUT UINT32 *Atts OPTIONAL
IN CONST CHAR16 *Key,
OUT CHAR16 **Value,
OUT UINTN *ValueSize,
OUT UINT32 *Atts OPTIONAL
)
{
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;
}
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
){
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
*Value = AllocateCopyPool(StrSize(Node->Val), Node->Val);
*ValueSize = StrSize(Node->Val);
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
)
{
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
*Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
*ValueSize = StrSize (Node->Val);
if (Atts != NULL) {
*Atts = Node->Atts;
}
return EFI_SUCCESS;
}
}
@ -444,17 +470,17 @@ ShellFindEnvVarInList (
**/
EFI_STATUS
ShellAddEnvVarToList (
IN CONST CHAR16 *Key,
IN CONST CHAR16 *Value,
IN UINTN ValueSize,
IN UINT32 Atts
IN CONST CHAR16 *Key,
IN CONST CHAR16 *Value,
IN UINTN ValueSize,
IN UINT32 Atts
)
{
ENV_VAR_LIST *Node;
CHAR16 *LocalKey;
CHAR16 *LocalValue;
ENV_VAR_LIST *Node;
CHAR16 *LocalKey;
CHAR16 *LocalValue;
if (Key == NULL || Value == NULL || ValueSize == 0) {
if ((Key == NULL) || (Value == NULL) || (ValueSize == 0)) {
return EFI_INVALID_PARAMETER;
}
@ -466,14 +492,15 @@ ShellAddEnvVarToList (
//
// Update the variable value if it exists in gShellEnvVarList.
//
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
){
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
)
{
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
Node->Atts = Atts;
SHELL_FREE_NON_NULL(Node->Val);
Node->Val = LocalValue;
SHELL_FREE_NON_NULL (Node->Val);
Node->Val = LocalValue;
return EFI_SUCCESS;
}
}
@ -482,21 +509,23 @@ ShellAddEnvVarToList (
// If the environment variable key doesn't exist in list just insert
// a new node.
//
LocalKey = AllocateCopyPool (StrSize(Key), Key);
LocalKey = AllocateCopyPool (StrSize (Key), Key);
if (LocalKey == NULL) {
FreePool (LocalValue);
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) {
FreePool (LocalKey);
FreePool (LocalValue);
return EFI_OUT_OF_RESOURCES;
}
Node->Key = LocalKey;
Node->Val = LocalValue;
Node->Key = LocalKey;
Node->Val = LocalValue;
Node->Atts = Atts;
InsertTailList(&gShellEnvVarList.Link, &Node->Link);
InsertTailList (&gShellEnvVarList.Link, &Node->Link);
return EFI_SUCCESS;
}
@ -512,24 +541,25 @@ ShellAddEnvVarToList (
**/
EFI_STATUS
ShellRemvoeEnvVarFromList (
IN CONST CHAR16 *Key
IN CONST CHAR16 *Key
)
{
ENV_VAR_LIST *Node;
ENV_VAR_LIST *Node;
if (Key == NULL) {
return EFI_INVALID_PARAMETER;
}
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
; !IsNull(&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
){
if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
SHELL_FREE_NON_NULL(Node->Key);
SHELL_FREE_NON_NULL(Node->Val);
RemoveEntryList(&Node->Link);
SHELL_FREE_NON_NULL(Node);
for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
; !IsNull (&gShellEnvVarList.Link, &Node->Link)
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
)
{
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
SHELL_FREE_NON_NULL (Node->Key);
SHELL_FREE_NON_NULL (Node->Val);
RemoveEntryList (&Node->Link);
SHELL_FREE_NON_NULL (Node);
return EFI_SUCCESS;
}
}
@ -547,9 +577,9 @@ ShellInitEnvVarList (
VOID
)
{
EFI_STATUS Status;
EFI_STATUS Status;
InitializeListHead(&gShellEnvVarList.Link);
InitializeListHead (&gShellEnvVarList.Link);
Status = GetEnvironmentVariableList (&gShellEnvVarList.Link);
return Status;
@ -565,8 +595,7 @@ ShellFreeEnvVarList (
)
{
FreeEnvironmentVariableList (&gShellEnvVarList.Link);
InitializeListHead(&gShellEnvVarList.Link);
InitializeListHead (&gShellEnvVarList.Link);
return;
}

View File

@ -15,17 +15,16 @@
#define _SHELL_ENVIRONMENT_VARIABLE_HEADER_
typedef struct {
LIST_ENTRY Link;
CHAR16 *Key;
CHAR16 *Val;
UINT32 Atts;
LIST_ENTRY Link;
CHAR16 *Key;
CHAR16 *Val;
UINT32 Atts;
} ENV_VAR_LIST;
//
// The list is used to cache the environment variables.
//
extern ENV_VAR_LIST gShellEnvVarList;
extern ENV_VAR_LIST gShellEnvVarList;
/**
Reports whether an environment variable is Volatile or Non-Volatile.
@ -38,8 +37,8 @@ extern ENV_VAR_LIST gShellEnvVarList;
**/
EFI_STATUS
IsVolatileEnv (
IN CONST CHAR16 *EnvVarName,
OUT BOOLEAN *Volatile
IN CONST CHAR16 *EnvVarName,
OUT BOOLEAN *Volatile
);
/**
@ -73,7 +72,7 @@ IsVolatileEnv (
@retval other An error occurred
@sa SetVariable
**/
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@ -93,7 +92,7 @@ IsVolatileEnv (
@retval other An error occurred
@sa SetVariable
**/
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer) \
(gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
0, \
@ -114,7 +113,7 @@ IsVolatileEnv (
@retval other An error occurred
@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, \
&gShellVariableGuid, \
Atts, \
@ -134,7 +133,7 @@ IsVolatileEnv (
@retval other An error occurred
@sa SetVariable
**/
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@ -150,8 +149,8 @@ IsVolatileEnv (
@retval EFI_SUCCESS the list was created successfully.
**/
EFI_STATUS
GetEnvironmentVariableList(
IN OUT LIST_ENTRY *List
GetEnvironmentVariableList (
IN OUT LIST_ENTRY *List
);
/**
@ -167,8 +166,8 @@ GetEnvironmentVariableList(
@retval EFI_SUCCESS The list was Set successfully.
**/
EFI_STATUS
SetEnvironmentVariableList(
IN LIST_ENTRY *List
SetEnvironmentVariableList (
IN LIST_ENTRY *List
);
/**
@ -187,8 +186,8 @@ SetEnvironmentVariableList(
@sa SetEnvironmentVariableList
**/
EFI_STATUS
SetEnvironmentVariables(
IN CONST CHAR16 **Environment
SetEnvironmentVariables (
IN CONST CHAR16 **Environment
);
/**
@ -197,8 +196,8 @@ SetEnvironmentVariables(
@param[in] List The pointer to pointer to list.
**/
VOID
FreeEnvironmentVariableList(
IN LIST_ENTRY *List
FreeEnvironmentVariableList (
IN LIST_ENTRY *List
);
/**
@ -218,10 +217,10 @@ FreeEnvironmentVariableList(
**/
EFI_STATUS
ShellFindEnvVarInList (
IN CONST CHAR16 *Key,
OUT CHAR16 **Value,
OUT UINTN *ValueSize,
OUT UINT32 *Atts OPTIONAL
IN CONST CHAR16 *Key,
OUT CHAR16 **Value,
OUT UINTN *ValueSize,
OUT UINT32 *Atts OPTIONAL
);
/**
@ -239,10 +238,10 @@ ShellFindEnvVarInList (
**/
EFI_STATUS
ShellAddEnvVarToList (
IN CONST CHAR16 *Key,
IN CONST CHAR16 *Value,
IN UINTN ValueSize,
IN UINT32 Atts
IN CONST CHAR16 *Key,
IN CONST CHAR16 *Value,
IN UINTN ValueSize,
IN UINT32 Atts
);
/**
@ -256,7 +255,7 @@ ShellAddEnvVarToList (
**/
EFI_STATUS
ShellRemvoeEnvVarFromList (
IN CONST CHAR16 *Key
IN CONST CHAR16 *Key
);
/**
@ -279,4 +278,3 @@ ShellFreeEnvVarList (
);
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_

View File

@ -17,15 +17,14 @@
EFI_HII_HANDLE mShellManHiiHandle = NULL;
EFI_HANDLE mShellManDriverHandle = NULL;
SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
SHELL_MAN_HII_GUID
@ -34,8 +33,8 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8) (END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@ -52,11 +51,12 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
**/
CHAR16 *
GetExecuatableFileName (
IN CONST CHAR16 *NameString
IN CONST CHAR16 *NameString
)
{
CHAR16 *Buffer;
CHAR16 *SuffixStr;
if (NameString == NULL) {
return (NULL);
}
@ -64,31 +64,33 @@ GetExecuatableFileName (
//
// Fix the file name
//
if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".efi"), L".efi", StrLen(L".efi"))==0) {
Buffer = AllocateCopyPool(StrSize(NameString), NameString);
} else if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".man"), L".man", StrLen(L".man"))==0) {
Buffer = AllocateCopyPool(StrSize(NameString), NameString);
if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".efi"), L".efi", StrLen (L".efi")) == 0) {
Buffer = AllocateCopyPool (StrSize (NameString), NameString);
} else if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".man"), L".man", StrLen (L".man")) == 0) {
Buffer = AllocateCopyPool (StrSize (NameString), NameString);
if (Buffer != NULL) {
SuffixStr = Buffer+StrLen(Buffer)-StrLen(L".man");
StrnCpyS (SuffixStr, StrSize(L".man")/sizeof(CHAR16), L".efi", StrLen(L".efi"));
SuffixStr = Buffer+StrLen (Buffer)-StrLen (L".man");
StrnCpyS (SuffixStr, StrSize (L".man")/sizeof (CHAR16), L".efi", StrLen (L".efi"));
}
} else {
Buffer = AllocateZeroPool(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16));
Buffer = AllocateZeroPool (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16));
if (Buffer != NULL) {
StrnCpyS( Buffer,
(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16),
NameString,
StrLen(NameString)
);
StrnCatS( Buffer,
(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16),
L".efi",
StrLen(L".efi")
);
StrnCpyS (
Buffer,
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
NameString,
StrLen (NameString)
);
StrnCatS (
Buffer,
(StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
L".efi",
StrLen (L".efi")
);
}
}
return (Buffer);
return (Buffer);
}
/**
@ -103,34 +105,39 @@ GetExecuatableFileName (
@return the new filename with .man as the extension.
**/
CHAR16 *
GetManFileName(
IN CONST CHAR16 *ManFileName
GetManFileName (
IN CONST CHAR16 *ManFileName
)
{
CHAR16 *Buffer;
CHAR16 *Buffer;
if (ManFileName == NULL) {
return (NULL);
}
//
// Fix the file name
//
if (StrnCmp(ManFileName+StrLen(ManFileName)-4, L".man", 4)==0) {
Buffer = AllocateCopyPool(StrSize(ManFileName), ManFileName);
if (StrnCmp (ManFileName+StrLen (ManFileName)-4, L".man", 4) == 0) {
Buffer = AllocateCopyPool (StrSize (ManFileName), ManFileName);
} else {
Buffer = AllocateZeroPool(StrSize(ManFileName) + 4*sizeof(CHAR16));
Buffer = AllocateZeroPool (StrSize (ManFileName) + 4*sizeof (CHAR16));
if (Buffer != NULL) {
StrnCpyS( Buffer,
(StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
ManFileName,
StrLen(ManFileName)
);
StrnCatS( Buffer,
(StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
L".man",
4
);
StrnCpyS (
Buffer,
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
ManFileName,
StrLen (ManFileName)
);
StrnCatS (
Buffer,
(StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
L".man",
4
);
}
}
return (Buffer);
}
@ -149,22 +156,23 @@ GetManFileName(
@retval EFI_NOT_FOUND The file was not found.
**/
EFI_STATUS
SearchPathForFile(
IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *Handle
SearchPathForFile (
IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *Handle
)
{
CHAR16 *FullFileName;
EFI_STATUS Status;
CHAR16 *FullFileName;
EFI_STATUS Status;
if ( FileName == NULL
|| Handle == NULL
|| StrLen(FileName) == 0
){
if ( (FileName == NULL)
|| (Handle == NULL)
|| (StrLen (FileName) == 0)
)
{
return (EFI_INVALID_PARAMETER);
}
FullFileName = ShellFindFilePath(FileName);
FullFileName = ShellFindFilePath (FileName);
if (FullFileName == NULL) {
return (EFI_NOT_FOUND);
}
@ -172,8 +180,8 @@ SearchPathForFile(
//
// now open that file
//
Status = EfiShellOpenFileByName(FullFileName, Handle, EFI_FILE_MODE_READ);
FreePool(FullFileName);
Status = EfiShellOpenFileByName (FullFileName, Handle, EFI_FILE_MODE_READ);
FreePool (FullFileName);
return (Status);
}
@ -197,7 +205,7 @@ SearchPathForFile(
an allocated buffer.
**/
EFI_STATUS
ManFileFindSections(
ManFileFindSections (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText,
@ -205,75 +213,84 @@ ManFileFindSections(
IN BOOLEAN Ascii
)
{
EFI_STATUS Status;
CHAR16 *ReadLine;
UINTN Size;
BOOLEAN CurrentlyReading;
CHAR16 *SectionName;
UINTN SectionLen;
BOOLEAN Found;
EFI_STATUS Status;
CHAR16 *ReadLine;
UINTN Size;
BOOLEAN CurrentlyReading;
CHAR16 *SectionName;
UINTN SectionLen;
BOOLEAN Found;
if ( Handle == NULL
|| HelpText == NULL
|| HelpSize == NULL
){
if ( (Handle == NULL)
|| (HelpText == NULL)
|| (HelpSize == NULL)
)
{
return (EFI_INVALID_PARAMETER);
}
Status = EFI_SUCCESS;
CurrentlyReading = FALSE;
Size = 1024;
Found = FALSE;
Status = EFI_SUCCESS;
CurrentlyReading = FALSE;
Size = 1024;
Found = FALSE;
ReadLine = AllocateZeroPool(Size);
ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
for (;!ShellFileHandleEof(Handle);Size = 1024) {
Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, &Ascii);
for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, &Ascii);
if (ReadLine[0] == L'#') {
//
// Skip comment lines
//
continue;
}
//
// ignore too small of buffer...
//
if (Status == EFI_BUFFER_TOO_SMALL) {
Status = EFI_SUCCESS;
}
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
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.
//
break;
} else if (StrnCmp(ReadLine, L".SH", 3) == 0) {
} else if (StrnCmp (ReadLine, L".SH", 3) == 0) {
if (Sections == NULL) {
CurrentlyReading = TRUE;
continue;
}
//
// we found a section
//
if (CurrentlyReading) {
CurrentlyReading = FALSE;
}
//
// is this a section we want to read in?
//
for ( SectionName = ReadLine + 3
; *SectionName == L' '
; SectionName++);
SectionLen = StrLen(SectionName);
SectionName = StrStr(Sections, SectionName);
; *SectionName == L' '
; SectionName++)
{
}
SectionLen = StrLen (SectionName);
SectionName = StrStr (Sections, SectionName);
if (SectionName == NULL) {
continue;
}
if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {
if ((*(SectionName + SectionLen) == CHAR_NULL) || (*(SectionName + SectionLen) == L',')) {
CurrentlyReading = TRUE;
}
} else if (CurrentlyReading) {
@ -281,15 +298,17 @@ ManFileFindSections(
//
// 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, L"\r\n", 0);
}
}
FreePool(ReadLine);
if (!Found && !EFI_ERROR(Status)) {
FreePool (ReadLine);
if (!Found && !EFI_ERROR (Status)) {
return (EFI_NOT_FOUND);
}
return (Status);
}
@ -315,12 +334,12 @@ ManFileFindSections(
@retval FALSE Line did not contain the Title Header
**/
BOOLEAN
IsTitleHeader(
IN CONST CHAR16 *Command,
IN CHAR16 *Line,
OUT CHAR16 **BriefDesc OPTIONAL,
OUT UINTN *BriefSize OPTIONAL,
OUT BOOLEAN *Found
IsTitleHeader (
IN CONST CHAR16 *Command,
IN CHAR16 *Line,
OUT CHAR16 **BriefDesc OPTIONAL,
OUT UINTN *BriefSize OPTIONAL,
OUT BOOLEAN *Found
)
{
// The states of a simple state machine used to recognize a title header line
@ -334,86 +353,84 @@ IsTitleHeader(
BOOLEAN ReturnValue; // TRUE if this the Title Header line of *some* MAN file.
BOOLEAN ReturnFound; // TRUE if this the Title Header line of *the desired* MAN file.
ReturnValue = FALSE;
ReturnFound = FALSE;
ReturnValue = FALSE;
ReturnFound = FALSE;
CommandIndex = 0;
State = LookForThMacro;
State = LookForThMacro;
do {
if (*Line == L'\0') {
break;
}
switch (State) {
// Handle "^\s*.TH\s"
// Go to state LookForCommandName if the title header macro is present; otherwise,
// eat white space. If we see something other than white space, this is not a
// title header line.
case LookForThMacro:
if (StrnCmp (L".TH ", Line, 4) == 0 || StrnCmp (L".TH\t", Line, 4) == 0) {
if ((StrnCmp (L".TH ", Line, 4) == 0) || (StrnCmp (L".TH\t", Line, 4) == 0)) {
Line += 4;
State = LookForCommandName;
}
else if (*Line == L' ' || *Line == L'\t') {
} else if ((*Line == L' ') || (*Line == L'\t')) {
Line++;
}
else {
} else {
State = Final;
}
break;
break;
// Handle "\s*"
// Eat any "extra" whitespace after the title header macro (we have already seen
// at least one white space character). Go to state CompareCommands when a
// non-white space is seen.
case LookForCommandName:
if (*Line == L' ' || *Line == L'\t') {
if ((*Line == L' ') || (*Line == L'\t')) {
Line++;
}
else {
} else {
ReturnValue = TRUE; // This is *some* command's title header line.
State = CompareCommands;
State = CompareCommands;
// Do not increment Line; it points to the first character of the command
// name on the title header line.
}
break;
break;
// Handle "(\S)\s"
// Compare Command to the title header command name, ignoring case. When we
// reach the end of the command (i.e. we see white space), the next state
// depends on whether the caller wants a copy of the Brief Description.
case CompareCommands:
if (*Line == L' ' || *Line == L'\t') {
if ((*Line == L' ') || (*Line == L'\t')) {
ReturnFound = TRUE; // This is the desired command's title header line.
State = (BriefDesc == NULL) ? Final : GetBriefDescription;
}
else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
State = (BriefDesc == NULL) ? Final : GetBriefDescription;
} else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
State = Final;
}
Line++;
break;
break;
// Handle "[\s01]*(.*)$"
// Skip whitespace, '0', and '1' characters, if any, prior to the brief description.
// Return the description to the caller.
case GetBriefDescription:
if (*Line != L' ' && *Line != L'\t' && *Line != L'0' && *Line != L'1') {
*BriefSize = StrSize(Line);
*BriefDesc = AllocateZeroPool(*BriefSize);
if ((*Line != L' ') && (*Line != L'\t') && (*Line != L'0') && (*Line != L'1')) {
*BriefSize = StrSize (Line);
*BriefDesc = AllocateZeroPool (*BriefSize);
if (*BriefDesc != NULL) {
StrCpyS(*BriefDesc, (*BriefSize)/sizeof(CHAR16), Line);
StrCpyS (*BriefDesc, (*BriefSize)/sizeof (CHAR16), Line);
}
State = Final;
}
Line++;
break;
break;
default:
break;
break;
}
} while (State < Final);
*Found = ReturnFound;
@ -441,7 +458,7 @@ IsTitleHeader(
an allocated buffer if requested.
**/
EFI_STATUS
ManFileFindTitleSection(
ManFileFindTitleSection (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Command,
OUT CHAR16 **BriefDesc OPTIONAL,
@ -455,18 +472,19 @@ ManFileFindTitleSection(
BOOLEAN Found;
UINTN Start;
if ( Handle == NULL
|| Command == NULL
|| (BriefDesc != NULL && BriefSize == NULL)
){
if ( (Handle == NULL)
|| (Command == NULL)
|| ((BriefDesc != NULL) && (BriefSize == NULL))
)
{
return (EFI_INVALID_PARAMETER);
}
Status = EFI_SUCCESS;
Size = 1024;
Found = FALSE;
Status = EFI_SUCCESS;
Size = 1024;
Found = FALSE;
ReadLine = AllocateZeroPool(Size);
ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@ -474,20 +492,21 @@ ManFileFindTitleSection(
//
// Do not pass any leading path information that may be present to IsTitleHeader().
//
Start = StrLen(Command);
while ((Start != 0)
&& (*(Command + Start - 1) != L'\\')
&& (*(Command + Start - 1) != L'/')
&& (*(Command + Start - 1) != L':')) {
Start = StrLen (Command);
while ( (Start != 0)
&& (*(Command + Start - 1) != L'\\')
&& (*(Command + Start - 1) != L'/')
&& (*(Command + Start - 1) != L':'))
{
--Start;
}
for (;!ShellFileHandleEof(Handle);Size = 1024) {
Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii);
for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, Ascii);
//
// ignore too small of buffer...
//
if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
break;
}
@ -498,7 +517,7 @@ ManFileFindTitleSection(
}
}
FreePool(ReadLine);
FreePool (ReadLine);
return (Status);
}
@ -533,32 +552,33 @@ ManFileFindTitleSection(
@retval EFI_NOT_FOUND There is no help text available for Command.
**/
EFI_STATUS
ProcessManFile(
IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL,
OUT CHAR16 **BriefDesc OPTIONAL,
OUT CHAR16 **HelpText
ProcessManFile (
IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL,
OUT CHAR16 **BriefDesc OPTIONAL,
OUT CHAR16 **HelpText
)
{
CHAR16 *TempString;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE CmdFileImgHandle;
EFI_STATUS Status;
UINTN HelpSize;
UINTN BriefSize;
UINTN StringIdWalker;
BOOLEAN Ascii;
CHAR16 *CmdFileName;
CHAR16 *CmdFilePathName;
EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
CHAR16 *TempString;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE CmdFileImgHandle;
EFI_STATUS Status;
UINTN HelpSize;
UINTN BriefSize;
UINTN StringIdWalker;
BOOLEAN Ascii;
CHAR16 *CmdFileName;
CHAR16 *CmdFilePathName;
EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
if ( ManFileName == NULL
|| Command == NULL
|| HelpText == NULL
){
if ( (ManFileName == NULL)
|| (Command == NULL)
|| (HelpText == NULL)
)
{
return (EFI_INVALID_PARAMETER);
}
@ -577,47 +597,49 @@ ProcessManFile(
//
// See if it's in HII first
//
TempString = ShellCommandGetCommandHelp(Command);
TempString = ShellCommandGetCommandHelp (Command);
if (TempString != NULL) {
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16);
HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0);
HelpSize = 0;
BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR(Status) && HelpText != NULL){
Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
ShellCloseFile (&FileHandle);
} else {
//
// If the image is a external app, check .MAN file first.
//
FileHandle = NULL;
TempString = GetManFileName(ManFileName);
FileHandle = NULL;
TempString = GetManFileName (ManFileName);
if (TempString == NULL) {
return (EFI_INVALID_PARAMETER);
}
Status = SearchPathForFile(TempString, &FileHandle);
if (EFI_ERROR(Status)) {
FileDevPath = FileDevicePath(NULL, TempString);
DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);
Status = InternalOpenFileDevicePath(DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);
SHELL_FREE_NON_NULL(FileDevPath);
SHELL_FREE_NON_NULL(DevPath);
Status = SearchPathForFile (TempString, &FileHandle);
if (EFI_ERROR (Status)) {
FileDevPath = FileDevicePath (NULL, TempString);
DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);
Status = InternalOpenFileDevicePath (DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);
SHELL_FREE_NON_NULL (FileDevPath);
SHELL_FREE_NON_NULL (DevPath);
}
if (!EFI_ERROR(Status)) {
if (!EFI_ERROR (Status)) {
HelpSize = 0;
BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR(Status) && HelpText != NULL){
Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
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.
//
@ -628,23 +650,25 @@ ProcessManFile(
//
// Load the app image to check EFI_HII_PACKAGE_LIST_PROTOCOL.
//
CmdFileName = GetExecuatableFileName(TempString);
CmdFileName = GetExecuatableFileName (TempString);
if (CmdFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
//
// If the file in CWD then use the file name, else use the full
// path name.
//
CmdFilePathName = ShellFindFilePath(CmdFileName);
CmdFilePathName = ShellFindFilePath (CmdFileName);
if (CmdFilePathName == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CmdFilePathName);
Status = gBS->LoadImage(FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
if(EFI_ERROR(Status)) {
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
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 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) {
gBS->UnloadImage (CmdFileImgHandle);
}
*HelpText = NULL;
goto Done;
}
Status = gBS->OpenProtocol(
Status = gBS->OpenProtocol (
CmdFileImgHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID**)&PackageListHeader,
(VOID **)&PackageListHeader,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if(EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
*HelpText = NULL;
goto Done;
}
@ -679,60 +705,62 @@ ProcessManFile(
EFI_NATIVE_INTERFACE,
&mShellManHiiDevicePath
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
goto Done;
}
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageListHeader,
mShellManDriverHandle,
&mShellManHiiHandle
);
gHiiDatabase,
PackageListHeader,
mShellManDriverHandle,
&mShellManHiiHandle
);
if (EFI_ERROR (Status)) {
goto Done;
}
StringIdWalker = 1;
do {
SHELL_FREE_NON_NULL(TempString);
if (BriefDesc != NULL) {
SHELL_FREE_NON_NULL(*BriefDesc);
}
TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
if (TempString == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0);
HelpSize = 0;
BriefSize = 0;
Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR(Status) && HelpText != NULL){
Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
ShellCloseFile (&FileHandle);
if (!EFI_ERROR(Status)){
//
// Found what we need and return
//
goto Done;
}
SHELL_FREE_NON_NULL (TempString);
if (BriefDesc != NULL) {
SHELL_FREE_NON_NULL (*BriefDesc);
}
StringIdWalker += 1;
TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
if (TempString == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0);
HelpSize = 0;
BriefSize = 0;
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
ShellCloseFile (&FileHandle);
if (!EFI_ERROR (Status)) {
//
// Found what we need and return
//
goto Done;
}
StringIdWalker += 1;
} while (StringIdWalker < 0xFFFF && TempString != NULL);
}
Done:
if (mShellManDriverHandle != NULL) {
gBS->UninstallProtocolInterface (
mShellManDriverHandle,
&gEfiDevicePathProtocolGuid,
&mShellManHiiDevicePath
mShellManDriverHandle,
&gEfiDevicePathProtocolGuid,
&mShellManHiiDevicePath
);
mShellManDriverHandle = NULL;
}
@ -746,12 +774,11 @@ Done:
Status = gBS->UnloadImage (CmdFileImgHandle);
}
SHELL_FREE_NON_NULL(TempString);
SHELL_FREE_NON_NULL(CmdFileName);
SHELL_FREE_NON_NULL(CmdFilePathName);
SHELL_FREE_NON_NULL(FileDevPath);
SHELL_FREE_NON_NULL(DevPath);
SHELL_FREE_NON_NULL (TempString);
SHELL_FREE_NON_NULL (CmdFileName);
SHELL_FREE_NON_NULL (CmdFilePathName);
SHELL_FREE_NON_NULL (FileDevPath);
SHELL_FREE_NON_NULL (DevPath);
return (Status);
}

View File

@ -39,12 +39,12 @@
@retval EFI_NOT_FOUND There is no help text available for Command.
**/
EFI_STATUS
ProcessManFile(
IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL,
OUT CHAR16 **BriefDesc,
OUT CHAR16 **HelpText
ProcessManFile (
IN CONST CHAR16 *ManFileName,
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Sections OPTIONAL,
OUT CHAR16 **BriefDesc,
OUT CHAR16 **HelpText
);
/**
@ -66,7 +66,7 @@ ProcessManFile(
an allocated buffer.
**/
EFI_STATUS
ManFileFindSections(
ManFileFindSections (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText,
@ -75,4 +75,3 @@ ManFileFindSections(
);
#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.
**/
EFI_STATUS
UpdateArgcArgv(
UpdateArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CONST CHAR16 *NewCommandLine,
IN SHELL_OPERATION_TYPES Type,
@ -93,19 +93,19 @@ UpdateArgcArgv(
@param[in] OldArgc pointer to old number of items in Argv list
**/
VOID
RestoreArgcArgv(
RestoreArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 ***OldArgv,
IN UINTN *OldArgc
);
typedef struct {
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
EFI_HANDLE ConInHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_HANDLE ConOutHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
EFI_HANDLE ErrOutHandle;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
EFI_HANDLE ConInHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_HANDLE ConOutHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
EFI_HANDLE ErrOutHandle;
} SYSTEM_TABLE_INFO;
/**
@ -126,7 +126,7 @@ typedef struct {
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
UpdateStdInStdOutStdErr(
UpdateStdInStdOutStdErr (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 *NewCommandLine,
OUT SHELL_FILE_HANDLE *OldStdIn,
@ -172,11 +172,11 @@ RestoreStdInStdOutStdErr (
@return EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
ParseCommandLineToArgs(
IN CONST CHAR16 *CommandLine,
IN BOOLEAN StripQuotation,
IN OUT CHAR16 ***Argv,
IN OUT UINTN *Argc
ParseCommandLineToArgs (
IN CONST CHAR16 *CommandLine,
IN BOOLEAN StripQuotation,
IN OUT CHAR16 ***Argv,
IN OUT UINTN *Argc
);
/**
@ -200,7 +200,7 @@ ParseCommandLineToArgs(
@return EFI_NOT_FOUND A closing " could not be found on the specified string
**/
EFI_STATUS
GetNextParameter(
GetNextParameter (
IN OUT CHAR16 **Walker,
IN OUT CHAR16 **TempParameter,
IN CONST UINTN Length,
@ -208,4 +208,3 @@ GetNextParameter(
);
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -29,16 +29,18 @@
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
IN UINTN Argc,
IN CHAR16 **Argv
)
{
UINTN Index;
if (Argc == 1) {
Print (L"Argv[1] = NULL\n");
}
for (Index = 1; Index < Argc; Index++) {
Print(L"Argv[%d]: \"%s\"\n", Index, Argv[Index]);
Print (L"Argv[%d]: \"%s\"\n", Index, Argv[Index]);
}
return 0;

View File

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

View File

@ -24,14 +24,19 @@
**/
INTN
EFIAPI
Test(CONST VOID *b1, CONST VOID *b2)
Test (
CONST VOID *b1,
CONST VOID *b2
)
{
if (*(INTN*)b1 == *(INTN*)b2) {
if (*(INTN *)b1 == *(INTN *)b2) {
return (0);
}
if (*(INTN*)b1 < *(INTN*)b2) {
return(-1);
if (*(INTN *)b1 < *(INTN *)b2) {
return (-1);
}
return (1);
}
@ -52,11 +57,11 @@ Test(CONST VOID *b1, CONST VOID *b2)
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
IN UINTN Argc,
IN CHAR16 **Argv
)
{
INTN Array[10];
INTN Array[10];
Array[0] = 2;
Array[1] = 3;
@ -69,9 +74,9 @@ ShellAppMain (
Array[8] = 1;
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]);
PerformQuickSort(Array, 10, sizeof(INTN), Test);
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]);
PerformQuickSort (Array, 10, sizeof (INTN), Test);
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]);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@
#ifndef _DP_H_
#define _DP_H_
#include <Uefi.h>
#include <Guid/Performance.h>
@ -36,32 +35,32 @@
#include <Library/UefiHiiServicesLib.h>
#include <Library/PerformanceLib.h>
extern EFI_HII_HANDLE mDpHiiHandle;
extern EFI_HII_HANDLE mDpHiiHandle;
#define DP_MAJOR_VERSION 2
#define DP_MINOR_VERSION 5
#define DP_MAJOR_VERSION 2
#define DP_MINOR_VERSION 5
/**
* The value assigned to DP_DEBUG controls which debug output
* is generated. Set it to ZERO to disable.
**/
#define DP_DEBUG 0
#define DP_DEBUG 0
#define DEFAULT_THRESHOLD 1000 ///< One millisecond.
#define DEFAULT_DISPLAYCOUNT 50
#define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
#define DEFAULT_THRESHOLD 1000 ///< One millisecond.
#define DEFAULT_DISPLAYCOUNT 50
#define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
/// 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.
typedef struct {
UINT64 StartCount; ///< Value timer is initialized with.
UINT64 EndCount; ///< Value timer has just before it wraps.
UINT32 Frequency; ///< Timer count frequency in KHz.
BOOLEAN CountUp; ///< TRUE if the counter counts up.
UINT64 StartCount; ///< Value timer is initialized with.
UINT64 EndCount; ///< Value timer has just before it wraps.
UINT32 Frequency; ///< Timer count frequency in KHz.
BOOLEAN CountUp; ///< TRUE if the counter counts up.
} TIMER_INFO;
/** Initialize one PERF_CUM_DATA structure instance for token t.
@ -73,40 +72,40 @@ typedef struct {
* - PERF_INIT_CUM_DATA(pointer) A pointer -- CHAR8 *pointer;
* - PERF_INIT_CUM_DATA(array) Address of an array -- CHAR8 array[N];
**/
#define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
#define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
typedef struct {
UINT64 Duration; ///< Cumulative duration for this item.
UINT64 MinDur; ///< Smallest duration encountered.
UINT64 MaxDur; ///< Largest duration encountered.
CHAR8 *Name; ///< ASCII name of this item.
UINT32 Count; ///< Total number of measurements accumulated.
UINT64 Duration; ///< Cumulative duration for this item.
UINT64 MinDur; ///< Smallest duration encountered.
UINT64 MaxDur; ///< Largest duration encountered.
CHAR8 *Name; ///< ASCII name of this item.
UINT32 Count; ///< Total number of measurements accumulated.
} PERF_CUM_DATA;
typedef struct {
UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
UINT32 NumIncomplete; ///< Number of measurements with no END value.
UINT32 NumSummary; ///< Number of summary section measurements.
UINT32 NumHandles; ///< Number of measurements with handles.
UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
UINT32 NumIncomplete; ///< Number of measurements with no END value.
UINT32 NumSummary; ///< Number of summary section measurements.
UINT32 NumHandles; ///< Number of measurements with handles.
UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
} PERF_SUMMARY_DATA;
typedef struct {
CONST VOID *Handle;
CONST CHAR8 *Token; ///< Measured token string name.
CONST CHAR8 *Module; ///< Module string name.
UINT64 StartTimeStamp; ///< Start time point.
UINT64 EndTimeStamp; ///< End time point.
UINT32 Identifier; ///< Identifier.
CONST VOID *Handle;
CONST CHAR8 *Token; ///< Measured token string name.
CONST CHAR8 *Module; ///< Module string name.
UINT64 StartTimeStamp; ///< Start time point.
UINT64 EndTimeStamp; ///< End time point.
UINT32 Identifier; ///< Identifier.
} MEASUREMENT_RECORD;
typedef struct {
CHAR8 *Name; ///< Measured token string name.
UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
UINT64 MinTime; ///< Minimum Elapsed Time.
UINT64 MaxTime; ///< Maximum Elapsed Time.
UINT32 Count; ///< Number of measurements accumulated.
CHAR8 *Name; ///< Measured token string name.
UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
UINT64 MinTime; ///< Minimum Elapsed Time.
UINT64 MaxTime; ///< Maximum Elapsed Time.
UINT32 Count; ///< Number of measurements accumulated.
} PROFILE_RECORD;
/**
@ -122,8 +121,8 @@ typedef struct {
**/
SHELL_STATUS
RunDp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@ -135,6 +134,7 @@ RunDp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
EFI_HANDLE ImageHandle
);
#endif // _DP_H_
#endif // _DP_H_

View File

@ -16,7 +16,7 @@
// the resource section. Thus the application can use '-?' option to show help message in
// Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);
/**
Entry point of Tftp standalone application.
@ -31,11 +31,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (S
EFI_STATUS
EFIAPI
DpAppInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;

View File

@ -25,10 +25,10 @@
SHELL_STATUS
EFIAPI
DpCommandHandler (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
)
{
gEfiShellParametersProtocol = ShellParameters;
@ -49,14 +49,14 @@ DpCommandHandler (
CHAR16 *
EFIAPI
DpCommandGetHelp (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
)
{
return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);
}
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
L"dp",
DpCommandHandler,
DpCommandGetHelp
@ -77,11 +77,12 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
EFI_STATUS
EFIAPI
DpCommandInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
mDpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mDpHiiHandle == NULL) {
return EFI_ABORTED;
@ -108,10 +109,11 @@ DpCommandInitialize (
EFI_STATUS
EFIAPI
DpUnload (
IN EFI_HANDLE ImageHandle
)
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
@ -120,6 +122,7 @@ DpUnload (
if (EFI_ERROR (Status)) {
return Status;
}
HiiRemovePackages (mDpHiiHandle);
return EFI_SUCCESS;
}

View File

@ -10,31 +10,32 @@
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _DP_INTELNAL_H_
#define _DP_INTELNAL_H_
#define DP_GAUGE_STRING_LENGTH 36
#define DP_GAUGE_STRING_LENGTH 36
//
/// Module-Global Variables
///@{
extern EFI_HII_HANDLE mDpHiiHandle;
extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
extern UINT64 mInterestThreshold;
extern BOOLEAN mShowId;
extern UINT8 *mBootPerformanceTable;
extern UINTN mBootPerformanceTableLength;
extern MEASUREMENT_RECORD *mMeasurementList;
extern UINTN mMeasurementNum;
extern EFI_HII_HANDLE mDpHiiHandle;
extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
extern UINT64 mInterestThreshold;
extern BOOLEAN mShowId;
extern UINT8 *mBootPerformanceTable;
extern UINTN mBootPerformanceTableLength;
extern MEASUREMENT_RECORD *mMeasurementList;
extern UINTN mMeasurementNum;
extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.
/// Items for which to gather cumulative statistics.
extern PERF_CUM_DATA CumData[];
extern PERF_CUM_DATA CumData[];
/// Number of items for which we are gathering cumulative statistics.
extern UINT32 const NumCum;
extern UINT32 const NumCum;
///@}
@ -60,7 +61,7 @@ extern UINT32 const NumCum;
**/
UINT64
GetDuration (
IN OUT MEASUREMENT_RECORD *Measurement
IN OUT MEASUREMENT_RECORD *Measurement
);
/**
@ -75,8 +76,8 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase.
**/
BOOLEAN
IsPhase(
IN MEASUREMENT_RECORD *Measurement
IsPhase (
IN MEASUREMENT_RECORD *Measurement
);
/**
@ -89,8 +90,8 @@ IsPhase(
**/
BOOLEAN
IsCorePerf(
IN MEASUREMENT_RECORD *Measurement
IsCorePerf (
IN MEASUREMENT_RECORD *Measurement
);
/**
@ -107,8 +108,8 @@ IsCorePerf(
**/
VOID
DpGetShortPdbFileName (
IN CHAR8 *PdbFileName,
OUT CHAR16 *UnicodeBuffer
IN CHAR8 *PdbFileName,
OUT CHAR16 *UnicodeBuffer
);
/**
@ -129,7 +130,7 @@ DpGetShortPdbFileName (
**/
VOID
DpGetNameFromHandle (
IN EFI_HANDLE Handle
IN EFI_HANDLE Handle
);
/**
@ -147,7 +148,7 @@ DpGetNameFromHandle (
**/
UINT64
DurationInMicroSeconds (
IN UINT64 Duration
IN UINT64 Duration
);
/**
@ -164,8 +165,8 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found.
**/
INTN
GetCumulativeItem(
IN MEASUREMENT_RECORD *Measurement
GetCumulativeItem (
IN MEASUREMENT_RECORD *Measurement
);
/**
@ -186,8 +187,8 @@ GetCumulativeItem(
**/
VOID
GatherStatistics(
IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
GatherStatistics (
IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
);
/**
@ -212,9 +213,9 @@ GatherStatistics(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
DumpAllTrace(
IN UINTN Limit,
IN BOOLEAN ExcludeFlag
DumpAllTrace (
IN UINTN Limit,
IN BOOLEAN ExcludeFlag
);
/**
@ -237,9 +238,9 @@ DumpAllTrace(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
DumpRawTrace(
IN UINTN Limit,
IN BOOLEAN ExcludeFlag
DumpRawTrace (
IN UINTN Limit,
IN BOOLEAN ExcludeFlag
);
/**
@ -247,11 +248,10 @@ DumpRawTrace(
**/
VOID
ProcessPhases(
ProcessPhases (
VOID
);
/**
Gather and print Handle data.
@ -262,11 +262,10 @@ ProcessPhases(
@return Others from a call to gBS->LocateHandleBuffer().
**/
EFI_STATUS
ProcessHandles(
IN BOOLEAN ExcludeFlag
ProcessHandles (
IN BOOLEAN ExcludeFlag
);
/**
Gather and print PEIM data.
@ -276,7 +275,7 @@ ProcessHandles(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
ProcessPeims(
ProcessPeims (
VOID
);
@ -292,7 +291,7 @@ ProcessPeims(
@retval EFI_ABORTED The user aborts the operation.
**/
EFI_STATUS
ProcessGlobal(
ProcessGlobal (
VOID
);
@ -308,8 +307,8 @@ ProcessGlobal(
**/
VOID
ProcessCumulative(
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
ProcessCumulative (
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -55,23 +55,24 @@
**/
UINT64
GetDuration (
IN OUT MEASUREMENT_RECORD *Measurement
IN OUT MEASUREMENT_RECORD *Measurement
)
{
UINT64 Duration;
BOOLEAN Error;
UINT64 Duration;
BOOLEAN Error;
if (Measurement->EndTimeStamp == 0) {
return 0;
}
Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;
Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
if (Error) {
DEBUG ((DEBUG_ERROR, ALit_TimerLibError));
Duration = 0;
}
return Duration;
}
@ -87,18 +88,18 @@ GetDuration (
@retval FALSE The measurement record is NOT for an EFI Phase.
**/
BOOLEAN
IsPhase(
IN MEASUREMENT_RECORD *Measurement
IsPhase (
IN MEASUREMENT_RECORD *Measurement
)
{
BOOLEAN RetVal;
BOOLEAN RetVal;
RetVal = (BOOLEAN)(
((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_PEI) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_DXE) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))
);
((AsciiStrCmp (Measurement->Token, ALit_SEC) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_PEI) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_DXE) == 0) ||
(AsciiStrCmp (Measurement->Token, ALit_BDS) == 0))
);
return RetVal;
}
@ -112,24 +113,24 @@ IsPhase(
**/
BOOLEAN
IsCorePerf(
IN MEASUREMENT_RECORD *Measurement
IsCorePerf (
IN MEASUREMENT_RECORD *Measurement
)
{
BOOLEAN RetVal;
BOOLEAN RetVal;
RetVal = (BOOLEAN)(
((Measurement->Identifier == MODULE_START_ID) ||
(Measurement->Identifier == MODULE_END_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_START_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_END_ID) ||
(Measurement->Identifier == MODULE_DB_START_ID) ||
(Measurement->Identifier == MODULE_DB_END_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_START_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_END_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID))
);
((Measurement->Identifier == MODULE_START_ID) ||
(Measurement->Identifier == MODULE_END_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_START_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_END_ID) ||
(Measurement->Identifier == MODULE_DB_START_ID) ||
(Measurement->Identifier == MODULE_DB_END_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_START_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_END_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID))
);
return RetVal;
}
@ -147,14 +148,14 @@ IsCorePerf(
**/
VOID
DpGetShortPdbFileName (
IN CHAR8 *PdbFileName,
OUT CHAR16 *UnicodeBuffer
IN CHAR8 *PdbFileName,
OUT CHAR16 *UnicodeBuffer
)
{
UINTN IndexA; // Current work location within an ASCII string.
UINTN IndexU; // Current work location within a Unicode string.
UINTN StartIndex;
UINTN EndIndex;
UINTN IndexA; // Current work location within an ASCII string.
UINTN IndexU; // Current work location within a Unicode string.
UINTN StartIndex;
UINTN EndIndex;
ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));
@ -162,8 +163,9 @@ DpGetShortPdbFileName (
StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);
} else {
StartIndex = 0;
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
;
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
}
for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {
StartIndex = IndexA + 1;
@ -176,7 +178,7 @@ DpGetShortPdbFileName (
IndexU = 0;
for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {
UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];
UnicodeBuffer[IndexU] = (CHAR16)PdbFileName[IndexA];
IndexU++;
if (IndexU >= DP_GAUGE_STRING_LENGTH) {
UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;
@ -204,26 +206,26 @@ DpGetShortPdbFileName (
**/
VOID
DpGetNameFromHandle (
IN EFI_HANDLE Handle
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *Image;
CHAR8 *PdbFileName;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_STRING StringPtr;
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_GUID *NameGuid;
CHAR16 *NameString;
UINTN StringSize;
CHAR8 *PlatformLanguage;
CHAR8 *BestLanguage;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *Image;
CHAR8 *PdbFileName;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_STRING StringPtr;
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_GUID *NameGuid;
CHAR16 *NameString;
UINTN StringSize;
CHAR8 *PlatformLanguage;
CHAR8 *BestLanguage;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
Image = NULL;
Image = NULL;
LoadedImageDevicePath = NULL;
DevicePath = NULL;
DevicePath = NULL;
//
// Method 1: Get the name string from image PDB
@ -231,14 +233,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &Image
(VOID **)&Image
);
if (EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
Handle,
&gEfiDriverBindingProtocolGuid,
(VOID **) &DriverBinding,
(VOID **)&DriverBinding,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -247,7 +249,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
DriverBinding->ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &Image
(VOID **)&Image
);
}
}
@ -267,14 +269,14 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiComponentName2ProtocolGuid,
(VOID **) &ComponentName2
(VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
//
// Firstly use platform language setting, secondly use driver's first supported language.
//
GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL);
BestLanguage = GetBestLanguage(
GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID **)&PlatformLanguage, NULL);
BestLanguage = GetBestLanguage (
ComponentName2->SupportedLanguages,
FALSE,
(PlatformLanguage != NULL) ? PlatformLanguage : "",
@ -299,7 +301,7 @@ DpGetNameFromHandle (
Status = gBS->HandleProtocol (
Handle,
&gEfiLoadedImageDevicePathProtocolGuid,
(VOID **) &LoadedImageDevicePath
(VOID **)&LoadedImageDevicePath
);
if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {
DevicePath = LoadedImageDevicePath;
@ -313,10 +315,11 @@ DpGetNameFromHandle (
//
NameGuid = NULL;
while (!IsDevicePathEndType (DevicePath)) {
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
if (NameGuid != NULL) {
break;
}
DevicePath = NextDevicePathNode (DevicePath);
}
@ -326,13 +329,13 @@ DpGetNameFromHandle (
//
NameString = NULL;
StringSize = 0;
Status = GetSectionFromAnyFv (
NameGuid,
EFI_SECTION_USER_INTERFACE,
0,
(VOID **) &NameString,
&StringSize
);
Status = GetSectionFromAnyFv (
NameGuid,
EFI_SECTION_USER_INTERFACE,
0,
(VOID **)&NameString,
&StringSize
);
if (!EFI_ERROR (Status)) {
//
@ -347,6 +350,7 @@ DpGetNameFromHandle (
//
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);
}
return;
} else {
//
@ -386,7 +390,7 @@ DpGetNameFromHandle (
**/
UINT64
DurationInMicroSeconds (
IN UINT64 Duration
IN UINT64 Duration
)
{
return DivU64x32 (Duration, 1000);
@ -406,17 +410,18 @@ DurationInMicroSeconds (
@retval >=0 Return value is the index into CumData where Token is found.
**/
INTN
GetCumulativeItem(
IN MEASUREMENT_RECORD *Measurement
GetCumulativeItem (
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) {
return Index; // Exit, we found a match
}
}
// If the for loop exits, Token was not found.
return -1; // Indicate failure
}

View File

@ -7,16 +7,16 @@
#include <Guid/ExtendedFirmwarePerformance.h>
// ASCII String literals which probably don't need translation
CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
CHAR8 const ALit_SEC[] = SEC_TOK;
CHAR8 const ALit_DXE[] = DXE_TOK;
CHAR8 const ALit_PEI[] = PEI_TOK;
CHAR8 const ALit_BDS[] = BDS_TOK;
CHAR8 const ALit_START_IMAGE[] = START_IMAGE_TOK;
CHAR8 const ALit_LOAD_IMAGE[] = LOAD_IMAGE_TOK;
CHAR8 const ALit_DB_START[] = DRIVERBINDING_START_TOK;
CHAR8 const ALit_DB_SUPPORT[] = DRIVERBINDING_SUPPORT_TOK;
CHAR8 const ALit_DB_STOP[] = DRIVERBINDING_STOP_TOK;
CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
CHAR8 const ALit_SEC[] = SEC_TOK;
CHAR8 const ALit_DXE[] = DXE_TOK;
CHAR8 const ALit_PEI[] = PEI_TOK;
CHAR8 const ALit_BDS[] = BDS_TOK;
CHAR8 const ALit_START_IMAGE[] = START_IMAGE_TOK;
CHAR8 const ALit_LOAD_IMAGE[] = LOAD_IMAGE_TOK;
CHAR8 const ALit_DB_START[] = DRIVERBINDING_START_TOK;
CHAR8 const ALit_DB_SUPPORT[] = DRIVERBINDING_SUPPORT_TOK;
CHAR8 const ALit_DB_STOP[] = DRIVERBINDING_STOP_TOK;
CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
CHAR8 const ALit_PEIM[] = "PEIM";
CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
CHAR8 const ALit_PEIM[] = "PEIM";

View File

@ -4,23 +4,24 @@
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _LITERALS_H_
#define _LITERALS_H_
// ASCII String literals which probably don't need translation
extern CHAR8 const ALit_TimerLibError[];
extern CHAR8 const ALit_SEC[];
extern CHAR8 const ALit_DXE[];
extern CHAR8 const ALit_SHELL[];
extern CHAR8 const ALit_PEI[];
extern CHAR8 const ALit_BDS[];
extern CHAR8 const ALit_PEIM[];
extern CHAR8 const ALit_START_IMAGE[];
extern CHAR8 const ALit_LOAD_IMAGE[];
extern CHAR8 const ALit_DB_START[];
extern CHAR8 const ALit_DB_SUPPORT[];
extern CHAR8 const ALit_DB_STOP[];
extern CHAR8 const ALit_BdsTO[];
extern CHAR8 const ALit_PEIM[];
extern CHAR8 const ALit_TimerLibError[];
extern CHAR8 const ALit_SEC[];
extern CHAR8 const ALit_DXE[];
extern CHAR8 const ALit_SHELL[];
extern CHAR8 const ALit_PEI[];
extern CHAR8 const ALit_BDS[];
extern CHAR8 const ALit_PEIM[];
extern CHAR8 const ALit_START_IMAGE[];
extern CHAR8 const ALit_LOAD_IMAGE[];
extern CHAR8 const ALit_DB_START[];
extern CHAR8 const ALit_DB_SUPPORT[];
extern CHAR8 const ALit_DB_STOP[];
extern CHAR8 const ALit_BdsTO[];
extern CHAR8 const ALit_PEIM[];
#endif // _LITERALS_H_
#endif // _LITERALS_H_

View File

@ -11,7 +11,7 @@
#include "Http.h"
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
//
// Constant strings and definitions related to the message
@ -37,17 +37,17 @@
//
// Buffer size. Note that larger buffer does not mean better speed.
//
#define DEFAULT_BUF_SIZE SIZE_32KB
#define MAX_BUF_SIZE SIZE_4MB
#define DEFAULT_BUF_SIZE SIZE_32KB
#define MAX_BUF_SIZE SIZE_4MB
#define MIN_PARAM_COUNT 2
#define MAX_PARAM_COUNT 4
#define MIN_PARAM_COUNT 2
#define MAX_PARAM_COUNT 4
#define NEED_REDIRECTION(Code) \
(((Code >= HTTP_STATUS_300_MULTIPLE_CHOICES) \
&& (Code <= HTTP_STATUS_307_TEMPORARY_REDIRECT)) \
|| (Code == HTTP_STATUS_308_PERMANENT_REDIRECT))
#define CLOSE_HTTP_HANDLE(ControllerHandle,HttpChildHandle) \
#define CLOSE_HTTP_HANDLE(ControllerHandle, HttpChildHandle) \
do { \
if (HttpChildHandle) { \
CloseProtocolAndDestroyServiceChild ( \
@ -69,13 +69,13 @@ typedef enum {
#define USER_AGENT_HDR "Mozilla/5.0 (EDK2; Linux) Gecko/20100101 Firefox/79.0"
#define TIMER_MAX_TIMEOUT_S 10
#define TIMER_MAX_TIMEOUT_S 10
//
// File name to use when Uri ends with "/".
//
#define DEFAULT_HTML_FILE L"index.html"
#define DEFAULT_HTTP_PROTO L"http"
#define DEFAULT_HTML_FILE L"index.html"
#define DEFAULT_HTTP_PROTO L"http"
//
// String to delete the HTTP progress message to be able to update it :
@ -85,20 +85,20 @@ typedef enum {
L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
#define HTTP_KB L"\b\b\b\b\b\b\b\b\b\b"
#define HTTP_KB L"\b\b\b\b\b\b\b\b\b\b"
//
// Frame for the progression slider.
//
#define HTTP_PROGR_FRAME L"[ ]"
#define HTTP_PROGR_FRAME L"[ ]"
//
// Improve readability by using these macros.
//
#define PRINT_HII(token,...) \
#define PRINT_HII(token, ...) \
ShellPrintHiiEx (\
-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)
//
@ -109,19 +109,19 @@ typedef enum {
//
// Define EPOCH (1970-JANUARY-01) in the Julian Date representation.
//
#define EPOCH_JULIAN_DATE 2440588
#define EPOCH_JULIAN_DATE 2440588
//
// Seconds per unit.
//
#define SEC_PER_MIN ((UINTN) 60)
#define SEC_PER_HOUR ((UINTN) 3600)
#define SEC_PER_DAY ((UINTN) 86400)
#define SEC_PER_MIN ((UINTN) 60)
#define SEC_PER_HOUR ((UINTN) 3600)
#define SEC_PER_DAY ((UINTN) 86400)
//
// String descriptions for server errors.
//
STATIC CONST CHAR16 *ErrStatusDesc[] =
STATIC CONST CHAR16 *ErrStatusDesc[] =
{
L"400 Bad Request",
L"401 Unauthorized",
@ -149,32 +149,32 @@ STATIC CONST CHAR16 *ErrStatusDesc[] =
L"505 HTTP version not supported"
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-i", TypeValue},
{L"-k", TypeFlag},
{L"-l", TypeValue},
{L"-m", TypeFlag},
{L"-s", TypeValue},
{L"-t", TypeValue},
{NULL , TypeMax}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-i", TypeValue },
{ L"-k", TypeFlag },
{ L"-l", TypeValue },
{ L"-m", TypeFlag },
{ L"-s", TypeValue },
{ L"-t", TypeValue },
{ NULL, TypeMax }
};
//
// Local File Handle.
//
STATIC SHELL_FILE_HANDLE mFileHandle = NULL;
STATIC SHELL_FILE_HANDLE mFileHandle = NULL;
//
// Path of the local file, Unicode encoded.
//
STATIC CONST CHAR16 *mLocalFilePath;
STATIC CONST CHAR16 *mLocalFilePath;
STATIC BOOLEAN gRequestCallbackComplete = FALSE;
STATIC BOOLEAN gResponseCallbackComplete = FALSE;
STATIC BOOLEAN gRequestCallbackComplete = FALSE;
STATIC BOOLEAN gResponseCallbackComplete = FALSE;
STATIC BOOLEAN gHttpError;
STATIC BOOLEAN gHttpError;
EFI_HII_HANDLE mHttpHiiHandle;
EFI_HII_HANDLE mHttpHiiHandle;
//
// Functions declarations.
@ -286,9 +286,9 @@ CloseProtocolAndDestroyServiceChild (
STATIC
EFI_STATUS
DownloadFile (
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN EFI_HANDLE ControllerHandle,
IN CHAR16 *NicName
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN EFI_HANDLE ControllerHandle,
IN CHAR16 *NicName
);
/**
@ -302,11 +302,11 @@ DownloadFile (
STATIC
EFI_STATUS
TrimSpaces (
IN CHAR16 *String
IN CHAR16 *String
)
{
CHAR16 *Str;
UINTN Len;
CHAR16 *Str;
UINTN Len;
ASSERT (String != NULL);
@ -328,7 +328,7 @@ TrimSpaces (
//
do {
Len = StrLen (Str);
if (!Len || (Str[Len - 1] != L' ' && Str[Len - 1] != '\t')) {
if (!Len || ((Str[Len - 1] != L' ') && (Str[Len - 1] != '\t'))) {
break;
}
@ -355,8 +355,8 @@ STATIC
VOID
EFIAPI
RequestCallback (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
gRequestCallbackComplete = TRUE;
@ -371,8 +371,8 @@ STATIC
VOID
EFIAPI
ResponseCallback (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
gResponseCallbackComplete = TRUE;
@ -396,19 +396,19 @@ EfiGetEpochDays (
IN EFI_TIME *Time
)
{
UINTN a;
UINTN y;
UINTN m;
UINTN a;
UINTN y;
UINTN m;
//
// Absolute Julian Date representation of the supplied Time.
//
UINTN JulianDate;
UINTN JulianDate;
//
// Number of days elapsed since EPOCH_JULIAN_DAY.
//
UINTN EpochDays;
UINTN EpochDays;
a = (14 - Time->Month) / 12 ;
a = (14 - Time->Month) / 12;
y = Time->Year + 4800 - a;
m = Time->Month + (12 * a) - 3;
@ -437,8 +437,8 @@ EfiTimeToEpoch (
//
// Number of days elapsed since EPOCH_JULIAN_DAY.
//
UINTN EpochDays;
UINTN EpochSeconds;
UINTN EpochDays;
UINTN EpochSeconds;
EpochDays = EfiGetEpochDays (Time);
@ -471,32 +471,32 @@ RunHttp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *CheckPackage;
UINTN ParamCount;
UINTN HandleCount;
UINTN NicNumber;
UINTN InitialSize;
UINTN ParamOffset;
UINTN StartSize;
CHAR16 *ProblemParam;
CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];
CHAR16 *Walker1;
CHAR16 *VStr;
CONST CHAR16 *UserNicName;
CONST CHAR16 *ValueStr;
CONST CHAR16 *RemoteFilePath;
CONST CHAR16 *Walker;
EFI_HTTPv4_ACCESS_POINT IPv4Node;
EFI_HANDLE *Handles;
EFI_HANDLE ControllerHandle;
HTTP_DOWNLOAD_CONTEXT Context;
BOOLEAN NicFound;
EFI_STATUS Status;
LIST_ENTRY *CheckPackage;
UINTN ParamCount;
UINTN HandleCount;
UINTN NicNumber;
UINTN InitialSize;
UINTN ParamOffset;
UINTN StartSize;
CHAR16 *ProblemParam;
CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];
CHAR16 *Walker1;
CHAR16 *VStr;
CONST CHAR16 *UserNicName;
CONST CHAR16 *ValueStr;
CONST CHAR16 *RemoteFilePath;
CONST CHAR16 *Walker;
EFI_HTTPv4_ACCESS_POINT IPv4Node;
EFI_HANDLE *Handles;
EFI_HANDLE ControllerHandle;
HTTP_DOWNLOAD_CONTEXT Context;
BOOLEAN NicFound;
ProblemParam = NULL;
RemoteFilePath = NULL;
NicFound = FALSE;
Handles = NULL;
ProblemParam = NULL;
RemoteFilePath = NULL;
NicFound = FALSE;
Handles = NULL;
//
// Initialize the Shell library (we must be in non-auto-init...).
@ -522,8 +522,8 @@ RunHttp (
TRUE
);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED)
&& (ProblemParam != NULL))
if ( (Status == EFI_VOLUME_CORRUPTED)
&& (ProblemParam != NULL))
{
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PROBLEM), ProblemParam);
SHELL_FREE_NON_NULL (ProblemParam);
@ -554,7 +554,7 @@ RunHttp (
ZeroMem (&IPv4Node, sizeof (IPv4Node));
IPv4Node.UseDefaultAddress = TRUE;
Context.HttpConfigData.HttpVersion = HttpVersion11;
Context.HttpConfigData.HttpVersion = HttpVersion11;
Context.HttpConfigData.AccessPoint.IPv4Node = &IPv4Node;
//
@ -592,7 +592,7 @@ RunHttp (
}
if (*Walker1 == L'/') {
ParamOffset = 1;
ParamOffset = 1;
RemoteFilePath = Walker1;
}
@ -629,7 +629,8 @@ RunHttp (
Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') ||
(*Walker == L'/' ) ) {
(*Walker == L'/'))
{
break;
}
}
@ -659,12 +660,12 @@ RunHttp (
UserNicName = ShellCommandLineGetValue (CheckPackage, L"-i");
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-l");
if ((ValueStr != NULL)
&& (!StringToUint16 (
ValueStr,
&Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort
)
))
if ( (ValueStr != NULL)
&& (!StringToUint16 (
ValueStr,
&Context.HttpConfigData.AccessPoint.IPv4Node->LocalPort
)
))
{
goto Error;
}
@ -674,7 +675,7 @@ RunHttp (
ValueStr = ShellCommandLineGetValue (CheckPackage, L"-s");
if (ValueStr != NULL) {
Context.BufferSize = ShellStrToUintn (ValueStr);
if (!Context.BufferSize || Context.BufferSize > MAX_BUF_SIZE) {
if (!Context.BufferSize || (Context.BufferSize > MAX_BUF_SIZE)) {
PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV), ValueStr);
goto Error;
}
@ -756,10 +757,10 @@ RunHttp (
}
if (gHttpError) {
//
// This is not related to connection, so no need to repeat with
// another interface.
//
//
// This is not related to connection, so no need to repeat with
// another interface.
//
break;
}
}
@ -841,7 +842,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid,
&MnpHandle,
(VOID**)&Mnp
(VOID **)&Mnp
);
if (EFI_ERROR (Status)) {
goto Error;
@ -907,12 +908,12 @@ CreateServiceChildAndOpenProtocol (
EFI_STATUS Status;
*ChildHandle = NULL;
Status = NetLibCreateServiceChild (
ControllerHandle,
gImageHandle,
ServiceBindingProtocolGuid,
ChildHandle
);
Status = NetLibCreateServiceChild (
ControllerHandle,
gImageHandle,
ServiceBindingProtocolGuid,
ChildHandle
);
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
*ChildHandle,
@ -990,8 +991,8 @@ WaitForCompletion (
IN OUT BOOLEAN *CallBackComplete
)
{
EFI_STATUS Status;
EFI_EVENT WaitEvt;
EFI_STATUS Status;
EFI_EVENT WaitEvt;
Status = EFI_SUCCESS;
@ -1005,25 +1006,25 @@ WaitForCompletion (
NULL,
&WaitEvt
);
ASSERT_EFI_ERROR (Status);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
Status = gBS->SetTimer (
WaitEvt,
TimerRelative,
EFI_TIMER_PERIOD_SECONDS (TIMER_MAX_TIMEOUT_S)
);
if (!EFI_ERROR (Status)) {
Status = gBS->SetTimer (
WaitEvt,
TimerRelative,
EFI_TIMER_PERIOD_SECONDS (TIMER_MAX_TIMEOUT_S)
);
ASSERT_EFI_ERROR (Status);
}
ASSERT_EFI_ERROR (Status);
}
while (! *CallBackComplete
&& (!EFI_ERROR (Status))
&& EFI_ERROR (gBS->CheckEvent (WaitEvt)))
while ( !*CallBackComplete
&& (!EFI_ERROR (Status))
&& EFI_ERROR (gBS->CheckEvent (WaitEvt)))
{
Status = Context->Http->Poll (Context->Http);
if (!Context->ContentDownloaded
&& CallBackComplete == &gResponseCallbackComplete)
if ( !Context->ContentDownloaded
&& (CallBackComplete == &gResponseCallbackComplete))
{
//
// An HTTP server may just send a response redirection header.
@ -1032,12 +1033,12 @@ WaitForCompletion (
// Note that at this point Response may not has been populated,
// so it needs to be checked first.
//
if (Context->ResponseToken.Message
&& Context->ResponseToken.Message->Data.Response
&& (NEED_REDIRECTION (
Context->ResponseToken.Message->Data.Response->StatusCode
)
))
if ( Context->ResponseToken.Message
&& Context->ResponseToken.Message->Data.Response
&& (NEED_REDIRECTION (
Context->ResponseToken.Message->Data.Response->StatusCode
)
))
{
break;
}
@ -1079,20 +1080,20 @@ SendRequest (
IN CHAR16 *DownloadUrl
)
{
EFI_HTTP_REQUEST_DATA RequestData;
EFI_HTTP_HEADER RequestHeader[HdrMax];
EFI_HTTP_MESSAGE RequestMessage;
EFI_STATUS Status;
CHAR16 *Host;
UINTN StringSize;
EFI_HTTP_REQUEST_DATA RequestData;
EFI_HTTP_HEADER RequestHeader[HdrMax];
EFI_HTTP_MESSAGE RequestMessage;
EFI_STATUS Status;
CHAR16 *Host;
UINTN StringSize;
ZeroMem (&RequestData, sizeof (RequestData));
ZeroMem (&RequestHeader, sizeof (RequestHeader));
ZeroMem (&RequestMessage, sizeof (RequestMessage));
ZeroMem (&Context->RequestToken, sizeof (Context->RequestToken));
RequestHeader[HdrHost].FieldName = "Host";
RequestHeader[HdrConn].FieldName = "Connection";
RequestHeader[HdrHost].FieldName = "Host";
RequestHeader[HdrConn].FieldName = "Connection";
RequestHeader[HdrAgent].FieldName = "User-Agent";
Host = (CHAR16 *)Context->ServerAddrAndProto;
@ -1113,7 +1114,7 @@ SendRequest (
//
Host++;
StringSize = StrLen (Host) + 1;
StringSize = StrLen (Host) + 1;
RequestHeader[HdrHost].FieldValue = AllocatePool (StringSize);
if (!RequestHeader[HdrHost].FieldValue) {
return EFI_OUT_OF_RESOURCES;
@ -1125,17 +1126,17 @@ SendRequest (
StringSize
);
RequestHeader[HdrConn].FieldValue = "close";
RequestHeader[HdrConn].FieldValue = "close";
RequestHeader[HdrAgent].FieldValue = USER_AGENT_HDR;
RequestMessage.HeaderCount = HdrMax;
RequestMessage.HeaderCount = HdrMax;
RequestData.Method = HttpMethodGet;
RequestData.Url = DownloadUrl;
RequestData.Url = DownloadUrl;
RequestMessage.Data.Request = &RequestData;
RequestMessage.Headers = RequestHeader;
RequestMessage.BodyLength = 0;
RequestMessage.Body = NULL;
RequestMessage.Headers = RequestHeader;
RequestMessage.BodyLength = 0;
RequestMessage.Body = NULL;
Context->RequestToken.Event = NULL;
//
@ -1150,10 +1151,10 @@ SendRequest (
);
ASSERT_EFI_ERROR (Status);
Context->RequestToken.Status = EFI_SUCCESS;
Context->RequestToken.Status = EFI_SUCCESS;
Context->RequestToken.Message = &RequestMessage;
gRequestCallbackComplete = FALSE;
Status = Context->Http->Request (Context->Http, &Context->RequestToken);
gRequestCallbackComplete = FALSE;
Status = Context->Http->Request (Context->Http, &Context->RequestToken);
if (EFI_ERROR (Status)) {
goto Error;
}
@ -1193,15 +1194,15 @@ SavePortion (
IN CHAR8 *Buffer
)
{
CHAR16 Progress[HTTP_PROGRESS_MESSAGE_SIZE];
UINTN NbOfKb;
UINTN Index;
UINTN LastStep;
UINTN Step;
EFI_STATUS Status;
CHAR16 Progress[HTTP_PROGRESS_MESSAGE_SIZE];
UINTN NbOfKb;
UINTN Index;
UINTN LastStep;
UINTN Step;
EFI_STATUS Status;
LastStep = 0;
Step = 0;
Step = 0;
ShellSetFilePosition (mFileHandle, Context->LastReportedNbOfBytes);
Status = ShellWriteFile (mFileHandle, &DownloadLen, Buffer);
@ -1219,14 +1220,14 @@ SavePortion (
}
Context->ContentDownloaded += DownloadLen;
NbOfKb = Context->ContentDownloaded >> 10;
NbOfKb = Context->ContentDownloaded >> 10;
Progress[0] = L'\0';
if (Context->ContentLength) {
LastStep = (Context->LastReportedNbOfBytes * HTTP_PROGRESS_SLIDER_STEPS) /
Context->ContentLength;
Step = (Context->ContentDownloaded * HTTP_PROGRESS_SLIDER_STEPS) /
Context->ContentLength;
LastStep = (Context->LastReportedNbOfBytes * HTTP_PROGRESS_SLIDER_STEPS) /
Context->ContentLength;
Step = (Context->ContentDownloaded * HTTP_PROGRESS_SLIDER_STEPS) /
Context->ContentLength;
}
Context->LastReportedNbOfBytes = Context->ContentDownloaded;
@ -1265,7 +1266,6 @@ SavePortion (
NbOfKb
);
ShellPrintEx (-1, -1, L"%s", Progress);
return EFI_SUCCESS;
@ -1286,29 +1286,29 @@ SavePortion (
STATIC
EFI_STATUS
SetHostURI (
IN CHAR8 *Location,
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN CHAR16 *DownloadUrl
IN CHAR8 *Location,
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN CHAR16 *DownloadUrl
)
{
EFI_STATUS Status;
UINTN StringSize;
UINTN FirstStep;
UINTN Idx;
UINTN Step;
CHAR8 *Walker;
CHAR16 *Temp;
CHAR8 *Tmp;
CHAR16 *Url;
BOOLEAN IsAbEmptyUrl;
EFI_STATUS Status;
UINTN StringSize;
UINTN FirstStep;
UINTN Idx;
UINTN Step;
CHAR8 *Walker;
CHAR16 *Temp;
CHAR8 *Tmp;
CHAR16 *Url;
BOOLEAN IsAbEmptyUrl;
Tmp = NULL;
Url = NULL;
Tmp = NULL;
Url = NULL;
IsAbEmptyUrl = FALSE;
FirstStep = 0;
FirstStep = 0;
StringSize = (AsciiStrSize (Location) * sizeof (CHAR16));
Url = AllocateZeroPool (StringSize);
Url = AllocateZeroPool (StringSize);
if (!Url) {
return EFI_OUT_OF_RESOURCES;
}
@ -1320,7 +1320,7 @@ SetHostURI (
);
if (EFI_ERROR (Status)) {
goto Error;
goto Error;
}
//
@ -1347,11 +1347,11 @@ SetHostURI (
}
if (AsciiStrStr (Location, "://") || IsAbEmptyUrl) {
Idx = 0;
Idx = 0;
Walker = Location;
for (Step = FirstStep; Step < 2; Step++) {
for (; *Walker != '/' && *Walker != '\0'; Walker++) {
for ( ; *Walker != '/' && *Walker != '\0'; Walker++) {
Idx++;
}
@ -1359,7 +1359,7 @@ SetHostURI (
//
// Skip "//"
//
Idx += 2;
Idx += 2;
Walker += 2;
}
}
@ -1375,7 +1375,7 @@ SetHostURI (
//
// Location now points to Uri
//
Location += Idx;
Location += Idx;
StringSize = (Idx + 1) * sizeof (CHAR16);
SHELL_FREE_NON_NULL (Context->ServerAddrAndProto);
@ -1421,7 +1421,7 @@ SetHostURI (
SHELL_FREE_NON_NULL (Context->Uri);
StringSize = AsciiStrSize (Location) * sizeof (CHAR16);
StringSize = AsciiStrSize (Location) * sizeof (CHAR16);
Context->Uri = AllocateZeroPool (StringSize);
if (!Context->Uri) {
Status = EFI_OUT_OF_RESOURCES;
@ -1460,15 +1460,15 @@ STATIC
EFI_STATUS
EFIAPI
ParseMsg (
IN HTTP_BODY_PARSE_EVENT EventType,
IN CHAR8 *Data,
IN UINTN Length,
IN VOID *Context
IN HTTP_BODY_PARSE_EVENT EventType,
IN CHAR8 *Data,
IN UINTN Length,
IN VOID *Context
)
{
if ((Data == NULL)
|| (EventType == BodyParseEventOnComplete)
|| (Context == NULL))
if ( (Data == NULL)
|| (EventType == BodyParseEventOnComplete)
|| (Context == NULL))
{
return EFI_SUCCESS;
}
@ -1476,7 +1476,6 @@ ParseMsg (
return SavePortion (Context, Length, Data);
}
/**
Get HTTP server response and collect the whole body as a file.
Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR).
@ -1498,38 +1497,38 @@ ParseMsg (
STATIC
EFI_STATUS
GetResponse (
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN CHAR16 *DownloadUrl
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN CHAR16 *DownloadUrl
)
{
EFI_HTTP_RESPONSE_DATA ResponseData;
EFI_HTTP_MESSAGE ResponseMessage;
EFI_HTTP_HEADER *Header;
EFI_STATUS Status;
VOID *MsgParser;
EFI_TIME StartTime;
EFI_TIME EndTime;
CONST CHAR16 *Desc;
UINTN ElapsedSeconds;
BOOLEAN IsTrunked;
BOOLEAN CanMeasureTime;
EFI_HTTP_RESPONSE_DATA ResponseData;
EFI_HTTP_MESSAGE ResponseMessage;
EFI_HTTP_HEADER *Header;
EFI_STATUS Status;
VOID *MsgParser;
EFI_TIME StartTime;
EFI_TIME EndTime;
CONST CHAR16 *Desc;
UINTN ElapsedSeconds;
BOOLEAN IsTrunked;
BOOLEAN CanMeasureTime;
ZeroMem (&ResponseData, sizeof (ResponseData));
ZeroMem (&ResponseMessage, sizeof (ResponseMessage));
ZeroMem (&Context->ResponseToken, sizeof (Context->ResponseToken));
IsTrunked = FALSE;
ResponseMessage.Body = Context->Buffer;
Context->ResponseToken.Status = EFI_SUCCESS;
ResponseMessage.Body = Context->Buffer;
Context->ResponseToken.Status = EFI_SUCCESS;
Context->ResponseToken.Message = &ResponseMessage;
Context->ContentLength = 0;
Context->Status = REQ_OK;
Status = EFI_SUCCESS;
MsgParser = NULL;
ResponseData.StatusCode = HTTP_STATUS_UNSUPPORTED_STATUS;
ResponseMessage.Data.Response = &ResponseData;
Context->ResponseToken.Event = NULL;
CanMeasureTime = FALSE;
Context->ContentLength = 0;
Context->Status = REQ_OK;
Status = EFI_SUCCESS;
MsgParser = NULL;
ResponseData.StatusCode = HTTP_STATUS_UNSUPPORTED_STATUS;
ResponseMessage.Data.Response = &ResponseData;
Context->ResponseToken.Event = NULL;
CanMeasureTime = FALSE;
if (Context->Flags & DL_FLAG_TIME) {
ZeroMem (&StartTime, sizeof (StartTime));
CanMeasureTime = !EFI_ERROR (gRT->GetTime (&StartTime, NULL));
@ -1538,8 +1537,8 @@ GetResponse (
do {
SHELL_FREE_NON_NULL (ResponseMessage.Headers);
ResponseMessage.HeaderCount = 0;
gResponseCallbackComplete = FALSE;
ResponseMessage.BodyLength = Context->BufferSize;
gResponseCallbackComplete = FALSE;
ResponseMessage.BodyLength = Context->BufferSize;
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
@ -1642,8 +1641,8 @@ GetResponse (
HttpGetEntityLength (MsgParser, &Context->ContentLength);
if (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST
&& (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
if ( (ResponseData.StatusCode >= HTTP_STATUS_400_BAD_REQUEST)
&& (ResponseData.StatusCode != HTTP_STATUS_308_PERMANENT_REDIRECT))
{
//
// Server reported an error via Response code.
@ -1665,7 +1664,7 @@ GetResponse (
// This gives an RFC HTTP error.
//
Context->Status = ShellStrToUintn (Desc);
Status = ENCODE_ERROR (Context->Status);
Status = ENCODE_ERROR (Context->Status);
}
}
}
@ -1680,13 +1679,13 @@ GetResponse (
ResponseMessage.Body
);
}
} while (!HttpIsMessageComplete (MsgParser)
&& !EFI_ERROR (Status)
&& ResponseMessage.BodyLength);
} while ( !HttpIsMessageComplete (MsgParser)
&& !EFI_ERROR (Status)
&& ResponseMessage.BodyLength);
if (Context->Status != REQ_NEED_REPEAT
&& Status == EFI_SUCCESS
&& CanMeasureTime)
if ( (Context->Status != REQ_NEED_REPEAT)
&& (Status == EFI_SUCCESS)
&& CanMeasureTime)
{
if (!EFI_ERROR (gRT->GetTime (&EndTime, NULL))) {
ElapsedSeconds = EfiTimeToEpoch (&EndTime) - EfiTimeToEpoch (&StartTime);
@ -1726,22 +1725,22 @@ GetResponse (
STATIC
EFI_STATUS
DownloadFile (
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN EFI_HANDLE ControllerHandle,
IN CHAR16 *NicName
IN HTTP_DOWNLOAD_CONTEXT *Context,
IN EFI_HANDLE ControllerHandle,
IN CHAR16 *NicName
)
{
EFI_STATUS Status;
CHAR16 *DownloadUrl;
UINTN UrlSize;
EFI_HANDLE HttpChildHandle;
EFI_STATUS Status;
CHAR16 *DownloadUrl;
UINTN UrlSize;
EFI_HANDLE HttpChildHandle;
ASSERT (Context);
if (Context == NULL) {
return EFI_INVALID_PARAMETER;
}
DownloadUrl = NULL;
DownloadUrl = NULL;
HttpChildHandle = NULL;
Context->Buffer = AllocatePool (Context->BufferSize);
@ -1780,7 +1779,7 @@ DownloadFile (
&gEfiHttpServiceBindingProtocolGuid,
&gEfiHttpProtocolGuid,
&HttpChildHandle,
(VOID**)&Context->Http
(VOID **)&Context->Http
);
if (EFI_ERROR (Status)) {
@ -1794,7 +1793,7 @@ DownloadFile (
goto ON_EXIT;
}
UrlSize = 0;
UrlSize = 0;
DownloadUrl = StrnCatGrow (
&DownloadUrl,
&UrlSize,
@ -1814,7 +1813,8 @@ DownloadFile (
&DownloadUrl,
&UrlSize,
Context->Uri,
StrLen (Context->Uri));
StrLen (Context->Uri)
);
PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl);
@ -1828,7 +1828,6 @@ DownloadFile (
if (Status) {
goto ON_EXIT;
}
} while (Context->Status == REQ_NEED_REPEAT);
if (Context->Status) {
@ -1864,12 +1863,12 @@ ON_EXIT:
**/
EFI_HII_HANDLE
InitializeHiiPackage (
IN EFI_HANDLE ImageHandle
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle.
@ -1891,11 +1890,11 @@ InitializeHiiPackage (
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
NULL,
&HiiHandle
);
gHiiDatabase,
PackageList,
NULL,
&HiiHandle
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;

View File

@ -32,7 +32,7 @@
#include <Protocol/HttpUtilities.h>
#include <Protocol/ServiceBinding.h>
#define HTTP_APP_NAME L"http"
#define HTTP_APP_NAME L"http"
#define REQ_OK 0
#define REQ_NEED_REPEAT 1
@ -40,25 +40,25 @@
//
// Download Flags.
//
#define DL_FLAG_TIME BIT0 // Show elapsed time.
#define DL_FLAG_KEEP_BAD BIT1 // Keep files even if download failed.
#define DL_FLAG_TIME BIT0 // Show elapsed time.
#define DL_FLAG_KEEP_BAD BIT1 // Keep files even if download failed.
extern EFI_HII_HANDLE mHttpHiiHandle;
extern EFI_HII_HANDLE mHttpHiiHandle;
typedef struct {
UINTN ContentDownloaded;
UINTN ContentLength;
UINTN LastReportedNbOfBytes;
UINTN BufferSize;
UINTN Status;
UINTN Flags;
UINT8 *Buffer;
CHAR16 *ServerAddrAndProto;
CHAR16 *Uri;
EFI_HTTP_TOKEN ResponseToken;
EFI_HTTP_TOKEN RequestToken;
EFI_HTTP_PROTOCOL *Http;
EFI_HTTP_CONFIG_DATA HttpConfigData;
UINTN ContentDownloaded;
UINTN ContentLength;
UINTN LastReportedNbOfBytes;
UINTN BufferSize;
UINTN Status;
UINTN Flags;
UINT8 *Buffer;
CHAR16 *ServerAddrAndProto;
CHAR16 *Uri;
EFI_HTTP_TOKEN ResponseToken;
EFI_HTTP_TOKEN RequestToken;
EFI_HTTP_PROTOCOL *Http;
EFI_HTTP_CONFIG_DATA HttpConfigData;
} HTTP_DOWNLOAD_CONTEXT;
/**
@ -87,6 +87,7 @@ RunHttp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
IN EFI_HANDLE ImageHandle
IN EFI_HANDLE ImageHandle
);
#endif // _HTTP_H_

View File

@ -20,7 +20,7 @@
* Thus the application can use '-?' option to show help message in Shell.
*/
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
/**
Entry point of Http standalone application.
@ -35,12 +35,12 @@ EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
EFI_STATUS
EFIAPI
HttpAppInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mHttpHiiHandle == NULL) {

View File

@ -28,10 +28,10 @@
SHELL_STATUS
EFIAPI
HttpCommandHandler (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
)
{
gEfiShellParametersProtocol = ShellParameters;
@ -53,8 +53,8 @@ HttpCommandHandler (
CHAR16 *
EFIAPI
HttpCommandGetHelp (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
)
{
return HiiGetString (
@ -64,7 +64,7 @@ HttpCommandGetHelp (
);
}
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
HTTP_APP_NAME,
HttpCommandHandler,
HttpCommandGetHelp
@ -85,11 +85,11 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
EFI_STATUS
EFIAPI
HttpCommandInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mHttpHiiHandle == NULL) {
@ -117,10 +117,10 @@ HttpCommandInitialize (
EFI_STATUS
EFIAPI
HttpUnload (
IN EFI_HANDLE ImageHandle
)
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface (
ImageHandle,

View File

@ -10,8 +10,8 @@
#include "Tftp.h"
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
EFI_HII_HANDLE mTftpHiiHandle;
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
EFI_HII_HANDLE mTftpHiiHandle;
/*
Constant strings and definitions related to the message indicating the amount of
@ -19,7 +19,7 @@ EFI_HII_HANDLE mTftpHiiHandle;
*/
// Frame for the progression slider
STATIC CONST CHAR16 mTftpProgressFrame[] = L"[ ]";
STATIC CONST CHAR16 mTftpProgressFrame[] = L"[ ]";
// Number of steps in the progression slider
#define TFTP_PROGRESS_SLIDER_STEPS ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) - 3)
@ -33,13 +33,13 @@ STATIC CONST CHAR16 mTftpProgressFrame[] = L"[
// String to delete the TFTP progress message to be able to update it :
// (TFTP_PROGRESS_MESSAGE_SIZE-1) '\b'
STATIC CONST CHAR16 mTftpProgressDelete[] = L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
STATIC CONST CHAR16 mTftpProgressDelete[] = L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
// Local File Handle
SHELL_FILE_HANDLE mFileHandle;
SHELL_FILE_HANDLE mFileHandle;
// Path of the local file, Unicode encoded
CONST CHAR16 *mLocalFilePath;
CONST CHAR16 *mLocalFilePath;
/**
Check and convert the UINT16 option values of the 'tftp' command
@ -206,49 +206,57 @@ CheckPacket (
IN EFI_MTFTP4_PACKET *Packet
);
EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
TRUE, // Use default setting
{ { 0, 0, 0, 0 } }, // StationIp - Not relevant as UseDefaultSetting=TRUE
{ { 0, 0, 0, 0 } }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
{
{ 0, 0, 0, 0 }
}, // StationIp - Not relevant as UseDefaultSetting=TRUE
{
{ 0, 0, 0, 0 }
}, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
0, // LocalPort - Automatically assigned port number.
{ { 0, 0, 0, 0 } }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
{ { 0, 0, 0, 0 } }, // ServerIp - Not known yet
{
{ 0, 0, 0, 0 }
}, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
{
{ 0, 0, 0, 0 }
}, // ServerIp - Not known yet
69, // InitialServerPort - Standard TFTP server port
6, // TryCount - The number of times to transmit request packets and wait for a response.
4 // TimeoutValue - Retransmission timeout in seconds.
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-i", TypeValue},
{L"-l", TypeValue},
{L"-r", TypeValue},
{L"-c", TypeValue},
{L"-t", TypeValue},
{L"-s", TypeValue},
{L"-w", TypeValue},
{NULL , TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-i", TypeValue },
{ L"-l", TypeValue },
{ L"-r", TypeValue },
{ L"-c", TypeValue },
{ L"-t", TypeValue },
{ L"-s", TypeValue },
{ L"-w", TypeValue },
{ NULL, TypeMax }
};
///
/// The default block size (512) of tftp is defined in the RFC1350.
///
#define MTFTP_DEFAULT_BLKSIZE 512
#define MTFTP_DEFAULT_BLKSIZE 512
///
/// The valid range of block size option is defined in the RFC2348.
///
#define MTFTP_MIN_BLKSIZE 8
#define MTFTP_MAX_BLKSIZE 65464
#define MTFTP_MIN_BLKSIZE 8
#define MTFTP_MAX_BLKSIZE 65464
///
/// The default windowsize (1) of tftp.
///
#define MTFTP_DEFAULT_WINDOWSIZE 1
#define MTFTP_DEFAULT_WINDOWSIZE 1
///
/// The valid range of window size option.
/// Note that: RFC 7440 does not mention max window size value, but for the
/// stability reason, the value is limited to 64.
///
#define MTFTP_MIN_WINDOWSIZE 1
#define MTFTP_MAX_WINDOWSIZE 64
#define MTFTP_MIN_WINDOWSIZE 1
#define MTFTP_MAX_WINDOWSIZE 64
/**
Function for 'tftp' command.
@ -319,15 +327,22 @@ RunTftp (
Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) &&
(ProblemParam != NULL) ) {
(ProblemParam != NULL))
{
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), mTftpHiiHandle,
L"tftp", ProblemParam
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PROBLEM),
mTftpHiiHandle,
L"tftp",
ProblemParam
);
FreePool (ProblemParam);
} else {
ASSERT (FALSE);
}
goto Error;
}
@ -337,15 +352,24 @@ RunTftp (
ParamCount = ShellCommandLineGetCount (CheckPackage);
if (ParamCount > 4) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
mTftpHiiHandle, L"tftp"
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_TOO_MANY),
mTftpHiiHandle,
L"tftp"
);
goto Error;
}
if (ParamCount < 3) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
mTftpHiiHandle, L"tftp"
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_TOO_FEW),
mTftpHiiHandle,
L"tftp"
);
goto Error;
}
@ -356,23 +380,29 @@ RunTftp (
// Check the host IPv4 address
//
ValueStr = ShellCommandLineGetRawValue (CheckPackage, 1);
Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle, L"tftp", ValueStr
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
);
goto Error;
}
RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);
ASSERT(RemoteFilePath != NULL);
FilePathSize = StrLen (RemoteFilePath) + 1;
ASSERT (RemoteFilePath != NULL);
FilePathSize = StrLen (RemoteFilePath) + 1;
AsciiRemoteFilePath = AllocatePool (FilePathSize);
if (AsciiRemoteFilePath == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Error;
}
UnicodeStrToAsciiStrS (RemoteFilePath, AsciiRemoteFilePath, FilePathSize);
if (ParamCount == 4) {
@ -381,10 +411,12 @@ RunTftp (
Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') ||
(*Walker == L'/' ) ) {
(*Walker == L'/'))
{
break;
}
}
mLocalFilePath = Walker + 1;
}
@ -423,11 +455,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) {
goto Error;
}
if (Mtftp4ConfigData.TimeoutValue == 0) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle, L"tftp", ValueStr
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
);
goto Error;
}
}
@ -437,11 +475,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &BlockSize)) {
goto Error;
}
if (BlockSize < MTFTP_MIN_BLKSIZE || BlockSize > MTFTP_MAX_BLKSIZE) {
if ((BlockSize < MTFTP_MIN_BLKSIZE) || (BlockSize > MTFTP_MAX_BLKSIZE)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle, L"tftp", ValueStr
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
);
goto Error;
}
}
@ -451,11 +495,17 @@ RunTftp (
if (!StringToUint16 (ValueStr, &WindowSize)) {
goto Error;
}
if (WindowSize < MTFTP_MIN_WINDOWSIZE || WindowSize > MTFTP_MAX_WINDOWSIZE) {
if ((WindowSize < MTFTP_MIN_WINDOWSIZE) || (WindowSize > MTFTP_MAX_WINDOWSIZE)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle, L"tftp", ValueStr
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
);
goto Error;
}
}
@ -464,32 +514,41 @@ RunTftp (
// Locate all MTFTP4 Service Binding protocols
//
ShellStatus = SHELL_NOT_FOUND;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiManagedNetworkServiceBindingProtocolGuid,
NULL,
&HandleCount,
&Handles
);
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiManagedNetworkServiceBindingProtocolGuid,
NULL,
&HandleCount,
&Handles
);
if (EFI_ERROR (Status) || (HandleCount == 0)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
mTftpHiiHandle
);
);
goto Error;
}
for (NicNumber = 0;
(NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS);
NicNumber++) {
NicNumber++)
{
ControllerHandle = Handles[NicNumber];
Status = GetNicName (ControllerHandle, NicNumber, NicName);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
mTftpHiiHandle, NicNumber, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
mTftpHiiHandle,
NicNumber,
Status
);
continue;
}
@ -497,6 +556,7 @@ RunTftp (
if (StrCmp (NicName, UserNicName) != 0) {
continue;
}
NicFound = TRUE;
}
@ -505,46 +565,68 @@ RunTftp (
&gEfiMtftp4ServiceBindingProtocolGuid,
&gEfiMtftp4ProtocolGuid,
&Mtftp4ChildHandle,
(VOID**)&Mtftp4
(VOID **)&Mtftp4
);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
mTftpHiiHandle, NicName, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
mTftpHiiHandle,
NicName,
Status
);
continue;
}
Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
mTftpHiiHandle, NicName, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
mTftpHiiHandle,
NicName,
Status
);
goto NextHandle;
}
Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
mTftpHiiHandle, RemoteFilePath, NicName, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
mTftpHiiHandle,
RemoteFilePath,
NicName,
Status
);
goto NextHandle;
}
Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, WindowSize);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
mTftpHiiHandle, RemoteFilePath, NicName, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
mTftpHiiHandle,
RemoteFilePath,
NicName,
Status
);
goto NextHandle;
}
ShellStatus = SHELL_SUCCESS;
NextHandle:
NextHandle:
CloseProtocolAndDestroyServiceChild (
ControllerHandle,
@ -556,22 +638,27 @@ RunTftp (
if ((UserNicName != NULL) && (!NicFound)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
mTftpHiiHandle, UserNicName
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
mTftpHiiHandle,
UserNicName
);
}
Error:
Error:
ShellCommandLineFreeVarList (CheckPackage);
if (AsciiRemoteFilePath != NULL) {
FreePool (AsciiRemoteFilePath);
}
if (Handles != NULL) {
FreePool (Handles);
}
if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR(Status))) {
if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR (Status))) {
ShellStatus = Status & ~MAX_BIT;
}
@ -599,9 +686,14 @@ StringToUint16 (
Val = ShellStrToUintn (ValueStr);
if (Val > MAX_UINT16) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle, L"tftp", ValueStr
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_PARAM_INV),
mTftpHiiHandle,
L"tftp",
ValueStr
);
return FALSE;
}
@ -645,7 +737,7 @@ GetNicName (
&gEfiManagedNetworkServiceBindingProtocolGuid,
&gEfiManagedNetworkProtocolGuid,
&MnpHandle,
(VOID**)&Mnp
(VOID **)&Mnp
);
if (EFI_ERROR (Status)) {
goto Error;
@ -661,7 +753,7 @@ GetNicName (
IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,
SnpMode.IfType == NET_IFTYPE_ETHERNET ?
L"eth%d" :
L"unk%d" ,
L"unk%d",
NicNumber
);
@ -713,12 +805,12 @@ CreateServiceChildAndOpenProtocol (
EFI_STATUS Status;
*ChildHandle = NULL;
Status = NetLibCreateServiceChild (
ControllerHandle,
gImageHandle,
ServiceBindingProtocolGuid,
ChildHandle
);
Status = NetLibCreateServiceChild (
ControllerHandle,
gImageHandle,
ServiceBindingProtocolGuid,
ChildHandle
);
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
*ChildHandle,
@ -810,21 +902,21 @@ GetFileSize (
UINT32 OptCnt;
UINT8 OptBuf[128];
ReqOpt[0].OptionStr = (UINT8*)"tsize";
OptBuf[0] = '0';
OptBuf[1] = 0;
ReqOpt[0].ValueStr = OptBuf;
ReqOpt[0].OptionStr = (UINT8 *)"tsize";
OptBuf[0] = '0';
OptBuf[1] = 0;
ReqOpt[0].ValueStr = OptBuf;
Status = Mtftp4->GetInfo (
Mtftp4,
NULL,
(UINT8*)FilePath,
NULL,
1,
ReqOpt,
&PktLen,
&Packet
);
Mtftp4,
NULL,
(UINT8 *)FilePath,
NULL,
1,
ReqOpt,
&PktLen,
&Packet
);
if (EFI_ERROR (Status)) {
goto Error;
@ -834,7 +926,7 @@ GetFileSize (
Mtftp4,
PktLen,
Packet,
(UINT32 *) &OptCnt,
(UINT32 *)&OptCnt,
&TableOfOptions
);
if (EFI_ERROR (Status)) {
@ -847,16 +939,18 @@ GetFileSize (
*FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr);
break;
}
OptCnt--;
Option++;
}
FreePool (TableOfOptions);
if (OptCnt == 0) {
Status = EFI_UNSUPPORTED;
}
Error :
Error:
return Status;
}
@ -889,11 +983,11 @@ DownloadFile (
IN UINT16 WindowSize
)
{
EFI_STATUS Status;
DOWNLOAD_CONTEXT *TftpContext;
EFI_MTFTP4_TOKEN Mtftp4Token;
UINT8 BlksizeBuf[10];
UINT8 WindowsizeBuf[10];
EFI_STATUS Status;
DOWNLOAD_CONTEXT *TftpContext;
EFI_MTFTP4_TOKEN Mtftp4Token;
UINT8 BlksizeBuf[10];
UINT8 WindowsizeBuf[10];
ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));
@ -902,13 +996,14 @@ DownloadFile (
Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
TftpContext->FileSize = FileSize;
TftpContext->FileSize = FileSize;
TftpContext->DownloadedNbOfBytes = 0;
TftpContext->LastReportedNbOfBytes = 0;
Mtftp4Token.Filename = (UINT8*)AsciiFilePath;
Mtftp4Token.Filename = (UINT8 *)AsciiFilePath;
Mtftp4Token.CheckPacket = CheckPacket;
Mtftp4Token.Context = (VOID*)TftpContext;
Mtftp4Token.Context = (VOID *)TftpContext;
Mtftp4Token.OptionCount = 0;
Mtftp4Token.OptionList = AllocatePool (sizeof (EFI_MTFTP4_OPTION) * 2);
if (Mtftp4Token.OptionList == NULL) {
@ -917,22 +1012,26 @@ DownloadFile (
}
if (BlockSize != MTFTP_DEFAULT_BLKSIZE) {
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "blksize";
AsciiSPrint ((CHAR8 *) BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf;
Mtftp4Token.OptionCount ++;
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"blksize";
AsciiSPrint ((CHAR8 *)BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = BlksizeBuf;
Mtftp4Token.OptionCount++;
}
if (WindowSize != MTFTP_DEFAULT_WINDOWSIZE) {
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *) "windowsize";
AsciiSPrint ((CHAR8 *) WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf;
Mtftp4Token.OptionCount ++;
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr = (UINT8 *)"windowsize";
AsciiSPrint ((CHAR8 *)WindowsizeBuf, sizeof (WindowsizeBuf), "%d", WindowSize);
Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr = WindowsizeBuf;
Mtftp4Token.OptionCount++;
}
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
mTftpHiiHandle, FilePath
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_DOWNLOADING),
mTftpHiiHandle,
FilePath
);
//
@ -943,24 +1042,32 @@ DownloadFile (
}
Status = ShellOpenFileByName (
mLocalFilePath,
&mFileHandle,
EFI_FILE_MODE_CREATE |
EFI_FILE_MODE_WRITE |
EFI_FILE_MODE_READ,
0
);
mLocalFilePath,
&mFileHandle,
EFI_FILE_MODE_CREATE |
EFI_FILE_MODE_WRITE |
EFI_FILE_MODE_READ,
0
);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
mTftpHiiHandle, L"tftp", mLocalFilePath
);
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
mTftpHiiHandle,
L"tftp",
mLocalFilePath
);
goto Error;
}
Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle
);
@ -969,7 +1076,7 @@ DownloadFile (
//
ShellCloseFile (&mFileHandle);
Error :
Error:
if (TftpContext != NULL) {
FreePool (TftpContext);
}
@ -1016,7 +1123,7 @@ CheckPacket (
return EFI_SUCCESS;
}
Context = (DOWNLOAD_CONTEXT*)Token->Context;
Context = (DOWNLOAD_CONTEXT *)Token->Context;
//
// The data in the packet are prepended with two UINT16 :
@ -1025,19 +1132,28 @@ CheckPacket (
//
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);
if (EFI_ERROR (Status)) {
if (Context->DownloadedNbOfBytes > 0) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_CRLF),
mTftpHiiHandle
);
);
}
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE),
mTftpHiiHandle, mLocalFilePath, Status
);
-1,
-1,
NULL,
STRING_TOKEN (STR_TFTP_ERR_WRITE),
mTftpHiiHandle,
mLocalFilePath,
Status
);
return Status;
}
@ -1046,11 +1162,11 @@ CheckPacket (
}
Context->DownloadedNbOfBytes += DownloadLen;
NbOfKb = Context->DownloadedNbOfBytes / 1024;
NbOfKb = Context->DownloadedNbOfBytes / 1024;
Progress[0] = L'\0';
LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
if (Step <= LastStep) {
return EFI_SUCCESS;
@ -1059,12 +1175,14 @@ CheckPacket (
ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);
Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
for (Index = 1; Index < Step; Index++) {
Progress[Index] = L'=';
}
Progress[Step] = L'>';
UnicodeSPrint (
@ -1089,12 +1207,12 @@ CheckPacket (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
@ -1125,5 +1243,6 @@ InitializeHiiPackage (
if (EFI_ERROR (Status)) {
return NULL;
}
return HiiHandle;
}

View File

@ -30,12 +30,12 @@
#include <Library/PrintLib.h>
#include <Library/UefiHiiServicesLib.h>
extern EFI_HII_HANDLE mTftpHiiHandle;
extern EFI_HII_HANDLE mTftpHiiHandle;
typedef struct {
UINTN FileSize;
UINTN DownloadedNbOfBytes;
UINTN LastReportedNbOfBytes;
UINTN FileSize;
UINTN DownloadedNbOfBytes;
UINTN LastReportedNbOfBytes;
} DOWNLOAD_CONTEXT;
/**
@ -64,6 +64,7 @@ RunTftp (
**/
EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
EFI_HANDLE ImageHandle
);
#endif // _TFTP_H_

View File

@ -17,7 +17,7 @@
// the resource section. Thus the application can use '-?' option to show help message in
// Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);
/**
Entry point of Tftp standalone application.
@ -32,11 +32,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (S
EFI_STATUS
EFIAPI
TftpAppInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) {
return EFI_ABORTED;

View File

@ -26,10 +26,10 @@
SHELL_STATUS
EFIAPI
TftpCommandHandler (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN EFI_SYSTEM_TABLE *SystemTable,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN EFI_SHELL_PROTOCOL *Shell
)
{
gEfiShellParametersProtocol = ShellParameters;
@ -50,14 +50,14 @@ TftpCommandHandler (
CHAR16 *
EFIAPI
TftpCommandGetHelp (
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
IN CONST CHAR8 *Language
)
{
return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);
}
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
L"tftp",
TftpCommandHandler,
TftpCommandGetHelp
@ -78,11 +78,12 @@ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
EFI_STATUS
EFIAPI
TftpCommandInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
if (mTftpHiiHandle == NULL) {
return EFI_ABORTED;
@ -109,10 +110,11 @@ TftpCommandInitialize (
EFI_STATUS
EFIAPI
TftpUnload (
IN EFI_HANDLE ImageHandle
)
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = gBS->UninstallProtocolInterface (
ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
@ -121,6 +123,7 @@ TftpUnload (
if (EFI_ERROR (Status)) {
return Status;
}
HiiRemovePackages (mTftpHiiHandle);
return EFI_SUCCESS;
}

View File

@ -14,6 +14,6 @@
0x0053d9d6, 0x2659, 0x4599, { 0xa2, 0x6b, 0xef, 0x45, 0x36, 0xe6, 0x31, 0xa9 } \
}
extern EFI_GUID gShellAliasGuid;
extern EFI_GUID gShellAliasGuid;
#endif

View File

@ -14,6 +14,6 @@
0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \
}
extern EFI_GUID gEfiShellEnvironment2ExtGuid;
extern EFI_GUID gEfiShellEnvironment2ExtGuid;
#endif

View File

@ -69,17 +69,17 @@
0x5f5f605d, 0x1583, 0x4a2d, {0xa6, 0xb2, 0xeb, 0x12, 0xda, 0xb4, 0xa2, 0xb6 } \
}
extern EFI_GUID gHandleParsingHiiGuid;
extern EFI_GUID gShellDebug1HiiGuid;
extern EFI_GUID gShellDriver1HiiGuid;
extern EFI_GUID gShellInstall1HiiGuid;
extern EFI_GUID gShellLevel1HiiGuid;
extern EFI_GUID gShellLevel2HiiGuid;
extern EFI_GUID gShellLevel3HiiGuid;
extern EFI_GUID gShellNetwork1HiiGuid;
extern EFI_GUID gShellNetwork2HiiGuid;
extern EFI_GUID gShellTftpHiiGuid;
extern EFI_GUID gShellHttpHiiGuid;
extern EFI_GUID gShellBcfgHiiGuid;
extern EFI_GUID gHandleParsingHiiGuid;
extern EFI_GUID gShellDebug1HiiGuid;
extern EFI_GUID gShellDriver1HiiGuid;
extern EFI_GUID gShellInstall1HiiGuid;
extern EFI_GUID gShellLevel1HiiGuid;
extern EFI_GUID gShellLevel2HiiGuid;
extern EFI_GUID gShellLevel3HiiGuid;
extern EFI_GUID gShellNetwork1HiiGuid;
extern EFI_GUID gShellNetwork2HiiGuid;
extern EFI_GUID gShellTftpHiiGuid;
extern EFI_GUID gShellHttpHiiGuid;
extern EFI_GUID gShellBcfgHiiGuid;
#endif

View File

@ -14,6 +14,6 @@
0x51271e13, 0x7de3, 0x43af, { 0x8b, 0xc2, 0x71, 0xad, 0x3b, 0x82, 0x43, 0x25 } \
}
extern EFI_GUID gShellMapGuid;
extern EFI_GUID gShellMapGuid;
#endif

View File

@ -14,6 +14,6 @@
0x171e9188, 0x31d3, 0x40f5, { 0xb1, 0xc, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd } \
}
extern EFI_GUID gEfiShellPkgTokenSpaceGuid;
extern EFI_GUID gEfiShellPkgTokenSpaceGuid;
#endif

View File

@ -14,6 +14,6 @@
0x158def5a, 0xf656, 0x419c, { 0xb0, 0x27, 0x7a, 0x31, 0x92, 0xc0, 0x79, 0xd2 } \
}
extern EFI_GUID gShellVariableGuid;
extern EFI_GUID gShellVariableGuid;
#endif

View File

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

View File

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

View File

@ -26,10 +26,10 @@
**/
EFI_STATUS
EFIAPI
AddNewGuidNameMapping(
IN CONST EFI_GUID *Guid,
IN CONST CHAR16 *TheName,
IN CONST CHAR8 *Lang OPTIONAL
AddNewGuidNameMapping (
IN CONST EFI_GUID *Guid,
IN CONST CHAR16 *TheName,
IN CONST CHAR8 *Lang OPTIONAL
);
/**
@ -43,11 +43,11 @@ AddNewGuidNameMapping(
@return The pointer to a string of the name. The caller
is responsible to free this memory.
**/
CHAR16*
CHAR16 *
EFIAPI
GetStringNameFromGuid(
IN CONST EFI_GUID *Guid,
IN CONST CHAR8 *Lang OPTIONAL
GetStringNameFromGuid (
IN CONST EFI_GUID *Guid,
IN CONST CHAR8 *Lang OPTIONAL
);
/**
@ -63,10 +63,10 @@ GetStringNameFromGuid(
**/
EFI_STATUS
EFIAPI
GetGuidFromStringName(
IN CONST CHAR16 *Name,
IN CONST CHAR8 *Lang OPTIONAL,
OUT EFI_GUID **Guid
GetGuidFromStringName (
IN CONST CHAR16 *Name,
IN CONST CHAR8 *Lang OPTIONAL,
OUT EFI_GUID **Guid
);
/**
@ -85,12 +85,12 @@ GetGuidFromStringName(
@return The pointer to string.
@retval NULL An error was encountered.
**/
CHAR16*
CHAR16 *
EFIAPI
GetProtocolInformationDump(
IN CONST EFI_HANDLE TheHandle,
IN CONST EFI_GUID *Guid,
IN CONST BOOLEAN Verbose
GetProtocolInformationDump (
IN CONST EFI_HANDLE TheHandle,
IN CONST EFI_GUID *Guid,
IN CONST BOOLEAN Verbose
);
/**
@ -105,11 +105,11 @@ GetProtocolInformationDump(
@retval NULL The name could not be found.
@return A pointer to the string name. Do not de-allocate the memory.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
GetStringNameFromHandle(
IN CONST EFI_HANDLE TheHandle,
IN CONST CHAR8 *Language
GetStringNameFromHandle (
IN CONST EFI_HANDLE TheHandle,
IN CONST CHAR8 *Language
);
/**
@ -133,19 +133,19 @@ GetBestLanguageForDriver (
IN BOOLEAN Iso639Language
);
#define HR_UNKNOWN 0
#define HR_IMAGE_HANDLE BIT1
#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding
#define HR_DEVICE_DRIVER BIT3 // device driver (hybrid?)
#define HR_BUS_DRIVER BIT4 // a bus driver (hybrid?)
#define HR_DRIVER_CONFIGURATION_HANDLE BIT5
#define HR_DRIVER_DIAGNOSTICS_HANDLE BIT6
#define HR_COMPONENT_NAME_HANDLE BIT7
#define HR_DEVICE_HANDLE BIT8
#define HR_PARENT_HANDLE BIT9
#define HR_CONTROLLER_HANDLE BIT10
#define HR_CHILD_HANDLE BIT11
#define HR_VALID_MASK (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7|BIT8|BIT9|BIT10|BIT11)
#define HR_UNKNOWN 0
#define HR_IMAGE_HANDLE BIT1
#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding
#define HR_DEVICE_DRIVER BIT3 // device driver (hybrid?)
#define HR_BUS_DRIVER BIT4 // a bus driver (hybrid?)
#define HR_DRIVER_CONFIGURATION_HANDLE BIT5
#define HR_DRIVER_DIAGNOSTICS_HANDLE BIT6
#define HR_COMPONENT_NAME_HANDLE BIT7
#define HR_DEVICE_HANDLE BIT8
#define HR_PARENT_HANDLE BIT9
#define HR_CONTROLLER_HANDLE BIT10
#define HR_CHILD_HANDLE BIT11
#define HR_VALID_MASK (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7|BIT8|BIT9|BIT10|BIT11)
/**
Gets all the related EFI_HANDLEs based on the mask supplied.
@ -177,11 +177,11 @@ GetBestLanguageForDriver (
EFI_STATUS
EFIAPI
ParseHandleDatabaseByRelationship (
IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
IN CONST UINTN Mask,
IN UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
IN CONST UINTN Mask,
IN UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
);
/**
@ -213,11 +213,11 @@ ParseHandleDatabaseByRelationship (
EFI_STATUS
EFIAPI
ParseHandleDatabaseByRelationshipWithType (
IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
IN UINTN *HandleCount,
OUT EFI_HANDLE **HandleBuffer,
OUT UINTN **HandleType
IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
IN UINTN *HandleCount,
OUT EFI_HANDLE **HandleBuffer,
OUT UINTN **HandleType
);
/**
@ -290,10 +290,10 @@ ParseHandleDatabaseByRelationshipWithType (
**/
EFI_STATUS
EFIAPI
ParseHandleDatabaseForChildDevices(
IN CONST EFI_HANDLE DriverHandle,
IN UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
ParseHandleDatabaseForChildDevices (
IN CONST EFI_HANDLE DriverHandle,
IN UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
);
/**
@ -309,13 +309,12 @@ ParseHandleDatabaseForChildDevices(
**/
EFI_STATUS
EFIAPI
ParseHandleDatabaseForChildControllers(
IN CONST EFI_HANDLE ControllerHandle,
OUT UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
ParseHandleDatabaseForChildControllers (
IN CONST EFI_HANDLE ControllerHandle,
OUT UINTN *MatchingHandleCount,
OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
);
/**
Function to retrieve the human-friendly index of a given handle. If the handle
does not have a index one will be automatically assigned. The index value is valid
@ -329,8 +328,8 @@ ParseHandleDatabaseForChildControllers(
**/
UINTN
EFIAPI
ConvertHandleToHandleIndex(
IN CONST EFI_HANDLE TheHandle
ConvertHandleToHandleIndex (
IN CONST EFI_HANDLE TheHandle
);
/**
@ -344,8 +343,8 @@ ConvertHandleToHandleIndex(
**/
EFI_HANDLE
EFIAPI
ConvertHandleIndexToHandle(
IN CONST UINTN TheIndex
ConvertHandleIndexToHandle (
IN CONST UINTN TheIndex
);
/**
@ -359,10 +358,10 @@ ConvertHandleIndexToHandle(
@retval NULL A memory allocation failed.
@return A NULL terminated list of handles.
**/
EFI_HANDLE*
EFI_HANDLE *
EFIAPI
GetHandleListByProtocol (
IN CONST EFI_GUID *ProtocolGuid OPTIONAL
IN CONST EFI_GUID *ProtocolGuid OPTIONAL
);
/**
@ -376,13 +375,12 @@ GetHandleListByProtocol (
@retval NULL ProtocolGuids was NULL.
@return A NULL terminated list of EFI_HANDLEs.
**/
EFI_HANDLE*
EFI_HANDLE *
EFIAPI
GetHandleListByProtocolList (
IN CONST EFI_GUID **ProtocolGuids
IN CONST EFI_GUID **ProtocolGuids
);
/**
Return all supported GUIDs.
@ -397,8 +395,8 @@ GetHandleListByProtocolList (
EFI_STATUS
EFIAPI
GetAllMappingGuids (
OUT EFI_GUID *Guids,
IN OUT UINTN *Count
OUT EFI_GUID *Guids,
IN OUT UINTN *Count
);
#endif // __HANDLE_PARSING_LIB__

View File

@ -26,9 +26,8 @@
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
IN UINTN Argc,
IN CHAR16 **Argv
);
#endif

View File

@ -26,23 +26,23 @@
//
// The extern global protocol poionters.
//
extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;
extern CONST CHAR16* SupportLevel[];
extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;
extern CONST CHAR16 *SupportLevel[];
//
// The map list objects.
//
typedef struct {
LIST_ENTRY Link;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
CHAR16 *MapName;
CHAR16 *CurrentDirectoryPath;
UINT64 Flags;
LIST_ENTRY Link;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
CHAR16 *MapName;
CHAR16 *CurrentDirectoryPath;
UINT64 Flags;
} SHELL_MAP_LIST;
/// List of Mappings - DeviceName and Drive Letter(ism).
extern SHELL_MAP_LIST gShellMapList;
extern SHELL_MAP_LIST gShellMapList;
/// Pointer to node of current directory in the mMapList.
extern SHELL_MAP_LIST *gShellCurMapping;
extern SHELL_MAP_LIST *gShellCurMapping;
/**
Returns the help MAN fileName for a given shell command.
@ -130,14 +130,14 @@ SHELL_STATUS
RETURN_STATUS
EFIAPI
ShellCommandRegisterCommandName (
IN CONST CHAR16 *CommandString,
IN SHELL_RUN_COMMAND CommandHandler,
IN SHELL_GET_MAN_FILENAME GetManFileName,
IN UINT32 ShellMinSupportLevel,
IN CONST CHAR16 *ProfileName,
IN CONST BOOLEAN CanAffectLE,
IN CONST EFI_HII_HANDLE HiiHandle,
IN CONST EFI_STRING_ID ManFormatHelp
IN CONST CHAR16 *CommandString,
IN SHELL_RUN_COMMAND CommandHandler,
IN SHELL_GET_MAN_FILENAME GetManFileName,
IN UINT32 ShellMinSupportLevel,
IN CONST CHAR16 *ProfileName,
IN CONST BOOLEAN CanAffectLE,
IN CONST EFI_HII_HANDLE HiiHandle,
IN CONST EFI_STRING_ID ManFormatHelp
);
/**
@ -167,9 +167,9 @@ ShellCommandRegisterCommandName (
RETURN_STATUS
EFIAPI
ShellCommandRunCommandHandler (
IN CONST CHAR16 *CommandString,
IN OUT SHELL_STATUS *RetVal,
IN OUT BOOLEAN *CanAffectLE OPTIONAL
IN CONST CHAR16 *CommandString,
IN OUT SHELL_STATUS *RetVal,
IN OUT BOOLEAN *CanAffectLE OPTIONAL
);
/**
@ -185,16 +185,15 @@ ShellCommandRunCommandHandler (
@retval other The name of the MAN file.
@sa SHELL_GET_MAN_FILENAME
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellCommandGetManFileNameHandler (
IN CONST CHAR16 *CommandString
IN CONST CHAR16 *CommandString
);
typedef struct {
LIST_ENTRY Link;
CHAR16 *CommandString;
LIST_ENTRY Link;
CHAR16 *CommandString;
} COMMAND_LIST;
/**
@ -206,16 +205,16 @@ typedef struct {
@return A linked list of all available shell commands.
**/
CONST COMMAND_LIST*
CONST COMMAND_LIST *
EFIAPI
ShellCommandGetCommandList (
IN CONST BOOLEAN Sort
IN CONST BOOLEAN Sort
);
typedef struct {
LIST_ENTRY Link;
CHAR16 *CommandString;
CHAR16 *Alias;
LIST_ENTRY Link;
CHAR16 *CommandString;
CHAR16 *Alias;
} ALIAS_LIST;
/**
@ -234,8 +233,8 @@ typedef struct {
RETURN_STATUS
EFIAPI
ShellCommandRegisterAlias (
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Alias
IN CONST CHAR16 *Command,
IN CONST CHAR16 *Alias
);
/**
@ -245,7 +244,7 @@ ShellCommandRegisterAlias (
@return A linked list of all requested shell aliases.
**/
CONST ALIAS_LIST*
CONST ALIAS_LIST *
EFIAPI
ShellCommandGetInitAliasList (
VOID
@ -262,7 +261,7 @@ ShellCommandGetInitAliasList (
BOOLEAN
EFIAPI
ShellCommandIsOnAliasList (
IN CONST CHAR16 *Alias
IN CONST CHAR16 *Alias
);
/**
@ -276,7 +275,7 @@ ShellCommandIsOnAliasList (
BOOLEAN
EFIAPI
ShellCommandIsCommandOnList (
IN CONST CHAR16 *CommandString
IN CONST CHAR16 *CommandString
);
/**
@ -287,10 +286,10 @@ ShellCommandIsCommandOnList (
@retval NULL No help text was found.
@return The string of the help text. The caller required to free.
**/
CHAR16*
CHAR16 *
EFIAPI
ShellCommandGetCommandHelp (
IN CONST CHAR16 *CommandString
IN CONST CHAR16 *CommandString
);
/**
@ -324,11 +323,9 @@ ShellCommandGetEchoState (
VOID
EFIAPI
ShellCommandSetEchoState (
IN BOOLEAN State
IN BOOLEAN State
);
/**
Indicate that the current shell or script should exit.
@ -338,8 +335,8 @@ ShellCommandSetEchoState (
VOID
EFIAPI
ShellCommandRegisterExit (
IN BOOLEAN ScriptOnly,
IN CONST UINT64 ErrorCode
IN BOOLEAN ScriptOnly,
IN CONST UINT64 ErrorCode
);
/**
@ -380,20 +377,20 @@ ShellCommandGetScriptExit (
);
typedef struct {
LIST_ENTRY Link; ///< List enumerator items.
UINTN Line; ///< What line of the script file this was on.
CHAR16 *Cl; ///< The original command line.
VOID *Data; ///< The data structure format dependant upon Command. (not always used)
BOOLEAN Reset; ///< Reset the command (it must be treated like a initial run (but it may have data already))
LIST_ENTRY Link; ///< List enumerator items.
UINTN Line; ///< What line of the script file this was on.
CHAR16 *Cl; ///< The original command line.
VOID *Data; ///< The data structure format dependant upon Command. (not always used)
BOOLEAN Reset; ///< Reset the command (it must be treated like a initial run (but it may have data already))
} SCRIPT_COMMAND_LIST;
typedef struct {
CHAR16 *ScriptName; ///< The filename of this script.
CHAR16 **Argv; ///< The parmameters to the script file.
UINTN Argc; ///< The count of parameters.
LIST_ENTRY CommandList; ///< The script converted to a list of commands (SCRIPT_COMMAND_LIST objects).
SCRIPT_COMMAND_LIST *CurrentCommand; ///< The command currently being operated. If !=NULL must be a member of CommandList.
LIST_ENTRY SubstList; ///< A list of current script loop alias' (ALIAS_LIST objects) (Used for the for %-based replacement).
CHAR16 *ScriptName; ///< The filename of this script.
CHAR16 **Argv; ///< The parmameters to the script file.
UINTN Argc; ///< The count of parameters.
LIST_ENTRY CommandList; ///< The script converted to a list of commands (SCRIPT_COMMAND_LIST objects).
SCRIPT_COMMAND_LIST *CurrentCommand; ///< The command currently being operated. If !=NULL must be a member of CommandList.
LIST_ENTRY SubstList; ///< A list of current script loop alias' (ALIAS_LIST objects) (Used for the for %-based replacement).
} SCRIPT_FILE;
/**
@ -402,7 +399,7 @@ typedef struct {
@retval NULL A script file is not currently running.
@return A pointer to the current script file object.
**/
SCRIPT_FILE*
SCRIPT_FILE *
EFIAPI
ShellCommandGetCurrentScriptFile (
VOID
@ -419,10 +416,10 @@ ShellCommandGetCurrentScriptFile (
@return A pointer to the current running script file after this
change. It is NULL if removing the final script.
**/
SCRIPT_FILE*
SCRIPT_FILE *
EFIAPI
ShellCommandSetNewScript (
IN SCRIPT_FILE *Script OPTIONAL
IN SCRIPT_FILE *Script OPTIONAL
);
/**
@ -433,7 +430,7 @@ ShellCommandSetNewScript (
VOID
EFIAPI
DeleteScriptFileStruct (
IN SCRIPT_FILE *Script
IN SCRIPT_FILE *Script
);
/**
@ -466,10 +463,10 @@ typedef enum {
@retval NULL a memory allocation failed.
@return a new map name string
**/
CHAR16*
CHAR16 *
EFIAPI
ShellCommandCreateNewMappingName(
IN CONST SHELL_MAPPING_TYPE Type
ShellCommandCreateNewMappingName (
IN CONST SHELL_MAPPING_TYPE Type
);
/**
@ -482,7 +479,7 @@ ShellCommandCreateNewMappingName(
EFI_STATUS
EFIAPI
ShellCommandConsistMappingInitialize (
EFI_DEVICE_PATH_PROTOCOL ***Table
EFI_DEVICE_PATH_PROTOCOL ***Table
);
/**
@ -497,7 +494,7 @@ ShellCommandConsistMappingInitialize (
EFI_STATUS
EFIAPI
ShellCommandConsistMappingUnInitialize (
EFI_DEVICE_PATH_PROTOCOL **Table
EFI_DEVICE_PATH_PROTOCOL **Table
);
/**
@ -513,11 +510,11 @@ ShellCommandConsistMappingUnInitialize (
@retval NULL A consistent mapped name could not be created.
@return A pointer to a string allocated from pool with the device name.
**/
CHAR16*
CHAR16 *
EFIAPI
ShellCommandConsistMappingGenMappingName (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN EFI_DEVICE_PATH_PROTOCOL **Table
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN EFI_DEVICE_PATH_PROTOCOL **Table
);
/**
@ -528,10 +525,10 @@ ShellCommandConsistMappingGenMappingName (
@return the node on the list.
**/
SHELL_MAP_LIST*
SHELL_MAP_LIST *
EFIAPI
ShellCommandFindMapItem (
IN CONST CHAR16 *MapKey
IN CONST CHAR16 *MapKey
);
/**
@ -553,11 +550,11 @@ ShellCommandFindMapItem (
**/
EFI_STATUS
EFIAPI
ShellCommandAddMapItemAndUpdatePath(
IN CONST CHAR16 *Name,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST UINT64 Flags,
IN CONST BOOLEAN Path
ShellCommandAddMapItemAndUpdatePath (
IN CONST CHAR16 *Name,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST UINT64 Flags,
IN CONST BOOLEAN Path
);
/**
@ -574,7 +571,7 @@ ShellCommandAddMapItemAndUpdatePath(
**/
EFI_STATUS
EFIAPI
ShellCommandCreateInitialMappingsAndPaths(
ShellCommandCreateInitialMappingsAndPaths (
VOID
);
@ -596,10 +593,10 @@ ShellCommandUpdateMapping (
@return a EFI_FILE_PROTOCOL* representing the same file.
**/
EFI_FILE_PROTOCOL*
EFI_FILE_PROTOCOL *
EFIAPI
ConvertShellHandleToEfiFileProtocol(
IN CONST SHELL_FILE_HANDLE Handle
ConvertShellHandleToEfiFileProtocol (
IN CONST SHELL_FILE_HANDLE Handle
);
/**
@ -612,8 +609,8 @@ ConvertShellHandleToEfiFileProtocol(
**/
BOOLEAN
EFIAPI
ShellFileHandleRemove(
IN CONST SHELL_FILE_HANDLE Handle
ShellFileHandleRemove (
IN CONST SHELL_FILE_HANDLE Handle
);
/**
@ -626,9 +623,9 @@ ShellFileHandleRemove(
**/
SHELL_FILE_HANDLE
EFIAPI
ConvertEfiFileProtocolToShellHandle(
IN CONST EFI_FILE_PROTOCOL *Handle,
IN CONST CHAR16 *Path
ConvertEfiFileProtocolToShellHandle (
IN CONST EFI_FILE_PROTOCOL *Handle,
IN CONST CHAR16 *Path
);
/**
@ -638,13 +635,12 @@ ConvertEfiFileProtocolToShellHandle(
@return A pointer to the path for the file.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellFileHandleGetPath(
IN CONST SHELL_FILE_HANDLE Handle
ShellFileHandleGetPath (
IN CONST SHELL_FILE_HANDLE Handle
);
/**
Function to determine if a SHELL_FILE_HANDLE is at the end of the file.
@ -659,8 +655,8 @@ ShellFileHandleGetPath(
**/
BOOLEAN
EFIAPI
ShellFileHandleEof(
IN SHELL_FILE_HANDLE Handle
ShellFileHandleEof (
IN SHELL_FILE_HANDLE Handle
);
typedef struct {
@ -676,7 +672,7 @@ typedef struct {
VOID
EFIAPI
FreeBufferList (
IN BUFFER_LIST *List
IN BUFFER_LIST *List
);
/**
@ -690,10 +686,10 @@ FreeBufferList (
VOID
EFIAPI
DumpHex (
IN UINTN Indent,
IN UINTN Offset,
IN UINTN DataSize,
IN VOID *UserData
IN UINTN Indent,
IN UINTN Offset,
IN UINTN DataSize,
IN VOID *UserData
);
/**
@ -705,7 +701,7 @@ DumpHex (
@param[in] DataSize The size in bytes of UserData.
@param[in] UserData The data to print out.
**/
CHAR16*
CHAR16 *
EFIAPI
CatSDumpHex (
IN CHAR16 *Buffer,
@ -791,8 +787,9 @@ typedef enum {
EFI_STATUS
EFIAPI
ShellSortFileList (
IN OUT EFI_SHELL_FILE_INFO **FileList,
OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL,
IN SHELL_SORT_FILE_LIST Order
IN OUT EFI_SHELL_FILE_INFO **FileList,
OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL,
IN SHELL_SORT_FILE_LIST Order
);
#endif //_SHELL_COMMAND_LIB_

View File

@ -27,8 +27,8 @@
} \
} while(FALSE)
extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;
extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;
extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
/**
Return a clean, fully-qualified version of an input path. If the return value
@ -58,10 +58,10 @@ extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
Path. The caller must free this memory when it is no
longer needed.
**/
CHAR16*
CHAR16 *
EFIAPI
FullyQualifyPath(
IN CONST CHAR16 *Path
FullyQualifyPath (
IN CONST CHAR16 *Path
);
/**
@ -78,10 +78,10 @@ FullyQualifyPath(
@return The information about the file.
**/
EFI_FILE_INFO*
EFI_FILE_INFO *
EFIAPI
ShellGetFileInfo (
IN SHELL_FILE_HANDLE FileHandle
IN SHELL_FILE_HANDLE FileHandle
);
/**
@ -106,8 +106,8 @@ ShellGetFileInfo (
EFI_STATUS
EFIAPI
ShellSetFileInfo (
IN SHELL_FILE_HANDLE FileHandle,
IN EFI_FILE_INFO *FileInfo
IN SHELL_FILE_HANDLE FileHandle,
IN EFI_FILE_INFO *FileInfo
);
/**
@ -141,11 +141,11 @@ ShellSetFileInfo (
**/
EFI_STATUS
EFIAPI
ShellOpenFileByDevicePath(
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode,
IN UINT64 Attributes
ShellOpenFileByDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode,
IN UINT64 Attributes
);
/**
@ -179,11 +179,11 @@ ShellOpenFileByDevicePath(
**/
EFI_STATUS
EFIAPI
ShellOpenFileByName(
IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode,
IN UINT64 Attributes
ShellOpenFileByName (
IN CONST CHAR16 *FileName,
OUT SHELL_FILE_HANDLE *FileHandle,
IN UINT64 OpenMode,
IN UINT64 Attributes
);
/**
@ -215,9 +215,9 @@ ShellOpenFileByName(
**/
EFI_STATUS
EFIAPI
ShellCreateDirectory(
IN CONST CHAR16 *DirectoryName,
OUT SHELL_FILE_HANDLE *FileHandle
ShellCreateDirectory (
IN CONST CHAR16 *DirectoryName,
OUT SHELL_FILE_HANDLE *FileHandle
);
/**
@ -251,10 +251,10 @@ ShellCreateDirectory(
**/
EFI_STATUS
EFIAPI
ShellReadFile(
IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
ShellReadFile (
IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
);
/**
@ -285,10 +285,10 @@ ShellReadFile(
**/
EFI_STATUS
EFIAPI
ShellWriteFile(
IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *BufferSize,
IN VOID *Buffer
ShellWriteFile (
IN SHELL_FILE_HANDLE FileHandle,
IN OUT UINTN *BufferSize,
IN VOID *Buffer
);
/**
@ -306,7 +306,7 @@ ShellWriteFile(
EFI_STATUS
EFIAPI
ShellCloseFile (
IN SHELL_FILE_HANDLE *FileHandle
IN SHELL_FILE_HANDLE *FileHandle
);
/**
@ -326,7 +326,7 @@ ShellCloseFile (
EFI_STATUS
EFIAPI
ShellDeleteFile (
IN SHELL_FILE_HANDLE *FileHandle
IN SHELL_FILE_HANDLE *FileHandle
);
/**
@ -374,8 +374,8 @@ ShellSetFilePosition (
EFI_STATUS
EFIAPI
ShellGetFilePosition (
IN SHELL_FILE_HANDLE FileHandle,
OUT UINT64 *Position
IN SHELL_FILE_HANDLE FileHandle,
OUT UINT64 *Position
);
/**
@ -395,7 +395,7 @@ ShellGetFilePosition (
EFI_STATUS
EFIAPI
ShellFlushFile (
IN SHELL_FILE_HANDLE FileHandle
IN SHELL_FILE_HANDLE FileHandle
);
/** Retrieve first entry from a directory.
@ -425,8 +425,8 @@ ShellFlushFile (
EFI_STATUS
EFIAPI
ShellFindFirstFile (
IN SHELL_FILE_HANDLE DirHandle,
OUT EFI_FILE_INFO **Buffer
IN SHELL_FILE_HANDLE DirHandle,
OUT EFI_FILE_INFO **Buffer
);
/** Retrieve next entries from a directory.
@ -451,10 +451,10 @@ ShellFindFirstFile (
**/
EFI_STATUS
EFIAPI
ShellFindNextFile(
IN SHELL_FILE_HANDLE DirHandle,
IN OUT EFI_FILE_INFO *Buffer,
IN OUT BOOLEAN *NoFile
ShellFindNextFile (
IN SHELL_FILE_HANDLE DirHandle,
IN OUT EFI_FILE_INFO *Buffer,
IN OUT BOOLEAN *NoFile
);
/**
@ -472,8 +472,8 @@ ShellFindNextFile(
EFI_STATUS
EFIAPI
ShellGetFileSize (
IN SHELL_FILE_HANDLE FileHandle,
OUT UINT64 *Size
IN SHELL_FILE_HANDLE FileHandle,
OUT UINT64 *Size
);
/**
@ -486,7 +486,7 @@ ShellGetFileSize (
**/
BOOLEAN
EFIAPI
ShellGetExecutionBreakFlag(
ShellGetExecutionBreakFlag (
VOID
);
@ -501,10 +501,10 @@ ShellGetExecutionBreakFlag(
@retval NULL The named environment variable does not exist.
@return != NULL The pointer to the value of the environment variable.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellGetEnvironmentVariable (
IN CONST CHAR16 *EnvKey
IN CONST CHAR16 *EnvKey
);
/**
@ -530,9 +530,9 @@ ShellGetEnvironmentVariable (
EFI_STATUS
EFIAPI
ShellSetEnvironmentVariable (
IN CONST CHAR16 *EnvKey,
IN CONST CHAR16 *EnvVal,
IN BOOLEAN Volatile
IN CONST CHAR16 *EnvKey,
IN CONST CHAR16 *EnvVal,
IN BOOLEAN Volatile
);
/**
@ -568,11 +568,11 @@ ShellSetEnvironmentVariable (
EFI_STATUS
EFIAPI
ShellExecute (
IN EFI_HANDLE *ParentHandle,
IN CHAR16 *CommandLine,
IN BOOLEAN Output,
IN CHAR16 **EnvironmentVariables,
OUT EFI_STATUS *Status
IN EFI_HANDLE *ParentHandle,
IN CHAR16 *CommandLine,
IN BOOLEAN Output,
IN CHAR16 **EnvironmentVariables,
OUT EFI_STATUS *Status
);
/**
@ -589,10 +589,10 @@ ShellExecute (
@retval NULL The directory does not exist.
@retval != NULL The directory.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellGetCurrentDir (
IN CHAR16 * CONST DeviceName OPTIONAL
IN CHAR16 *CONST DeviceName OPTIONAL
);
/**
@ -606,7 +606,7 @@ ShellGetCurrentDir (
VOID
EFIAPI
ShellSetPageBreakMode (
IN BOOLEAN CurrentState
IN BOOLEAN CurrentState
);
/**
@ -635,9 +635,9 @@ ShellSetPageBreakMode (
EFI_STATUS
EFIAPI
ShellOpenFileMetaArg (
IN CHAR16 *Arg,
IN UINT64 OpenMode,
IN OUT EFI_SHELL_FILE_INFO **ListHead
IN CHAR16 *Arg,
IN UINT64 OpenMode,
IN OUT EFI_SHELL_FILE_INFO **ListHead
);
/**
@ -651,7 +651,7 @@ ShellOpenFileMetaArg (
EFI_STATUS
EFIAPI
ShellCloseFileMetaArg (
IN OUT EFI_SHELL_FILE_INFO **ListHead
IN OUT EFI_SHELL_FILE_INFO **ListHead
);
/**
@ -669,7 +669,7 @@ ShellCloseFileMetaArg (
CHAR16 *
EFIAPI
ShellFindFilePath (
IN CONST CHAR16 *FileName
IN CONST CHAR16 *FileName
);
/**
@ -691,12 +691,12 @@ ShellFindFilePath (
CHAR16 *
EFIAPI
ShellFindFilePathEx (
IN CONST CHAR16 *FileName,
IN CONST CHAR16 *FileExtension
IN CONST CHAR16 *FileName,
IN CONST CHAR16 *FileExtension
);
typedef enum {
TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").
TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").
TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").
TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").
TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).
@ -707,16 +707,15 @@ typedef enum {
} SHELL_PARAM_TYPE;
typedef struct {
CHAR16 *Name;
SHELL_PARAM_TYPE Type;
CHAR16 *Name;
SHELL_PARAM_TYPE Type;
} SHELL_PARAM_ITEM;
/// Helper structure for no parameters (besides -? and -b)
extern SHELL_PARAM_ITEM EmptyParamList[];
extern SHELL_PARAM_ITEM EmptyParamList[];
/// Helper structure for -sfo only (besides -? and -b)
extern SHELL_PARAM_ITEM SfoParamList[];
extern SHELL_PARAM_ITEM SfoParamList[];
/**
Checks the command line arguments passed against the list of valid ones.
@ -745,15 +744,15 @@ extern SHELL_PARAM_ITEM SfoParamList[];
EFI_STATUS
EFIAPI
ShellCommandLineParseEx (
IN CONST SHELL_PARAM_ITEM *CheckList,
OUT LIST_ENTRY **CheckPackage,
OUT CHAR16 **ProblemParam OPTIONAL,
IN BOOLEAN AutoPageBreak,
IN BOOLEAN AlwaysAllowNumbers
IN CONST SHELL_PARAM_ITEM *CheckList,
OUT LIST_ENTRY **CheckPackage,
OUT CHAR16 **ProblemParam OPTIONAL,
IN BOOLEAN AutoPageBreak,
IN BOOLEAN AlwaysAllowNumbers
);
/// 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.
@ -768,7 +767,7 @@ ShellCommandLineParseEx (
VOID
EFIAPI
ShellCommandLineFreeVarList (
IN LIST_ENTRY *CheckPackage
IN LIST_ENTRY *CheckPackage
);
/**
@ -788,8 +787,8 @@ ShellCommandLineFreeVarList (
BOOLEAN
EFIAPI
ShellCommandLineGetFlag (
IN CONST LIST_ENTRY * CONST CheckPackage,
IN CONST CHAR16 * CONST KeyString
IN CONST LIST_ENTRY *CONST CheckPackage,
IN CONST CHAR16 *CONST KeyString
);
/**
@ -805,11 +804,11 @@ ShellCommandLineGetFlag (
@retval NULL The flag is not on the command line.
@retval !=NULL The pointer to unicode string of the value.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellCommandLineGetValue (
IN CONST LIST_ENTRY *CheckPackage,
IN CHAR16 *KeyString
IN CONST LIST_ENTRY *CheckPackage,
IN CHAR16 *KeyString
);
/**
@ -825,11 +824,11 @@ ShellCommandLineGetValue (
@retval NULL The flag is not on the command line.
@retval !=NULL The pointer to unicode string of the value.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellCommandLineGetRawValue (
IN CONST LIST_ENTRY * CONST CheckPackage,
IN UINTN Position
IN CONST LIST_ENTRY *CONST CheckPackage,
IN UINTN Position
);
/**
@ -844,8 +843,8 @@ ShellCommandLineGetRawValue (
**/
UINTN
EFIAPI
ShellCommandLineGetCount(
IN CONST LIST_ENTRY *CheckPackage
ShellCommandLineGetCount (
IN CONST LIST_ENTRY *CheckPackage
);
/**
@ -865,8 +864,8 @@ ShellCommandLineGetCount(
EFI_STATUS
EFIAPI
ShellCommandLineCheckDuplicate (
IN CONST LIST_ENTRY *CheckPackage,
OUT CHAR16 **Param
IN CONST LIST_ENTRY *CheckPackage,
OUT CHAR16 **Param
);
/**
@ -919,10 +918,10 @@ ShellInitialize (
**/
EFI_STATUS
EFIAPI
ShellPrintEx(
IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL,
IN CONST CHAR16 *Format,
ShellPrintEx (
IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL,
IN CONST CHAR16 *Format,
...
);
@ -960,12 +959,12 @@ ShellPrintEx(
**/
EFI_STATUS
EFIAPI
ShellPrintHiiEx(
IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL,
IN CONST CHAR8 *Language OPTIONAL,
IN CONST EFI_STRING_ID HiiFormatStringId,
IN CONST EFI_HII_HANDLE HiiFormatHandle,
ShellPrintHiiEx (
IN INT32 Col OPTIONAL,
IN INT32 Row OPTIONAL,
IN CONST CHAR8 *Language OPTIONAL,
IN CONST EFI_STRING_ID HiiFormatStringId,
IN CONST EFI_HII_HANDLE HiiFormatHandle,
...
);
@ -982,8 +981,8 @@ ShellPrintHiiEx(
**/
EFI_STATUS
EFIAPI
ShellIsDirectory(
IN CONST CHAR16 *DirName
ShellIsDirectory (
IN CONST CHAR16 *DirName
);
/**
@ -1001,8 +1000,8 @@ ShellIsDirectory(
**/
EFI_STATUS
EFIAPI
ShellIsFile(
IN CONST CHAR16 *Name
ShellIsFile (
IN CONST CHAR16 *Name
);
/**
@ -1020,8 +1019,8 @@ ShellIsFile(
**/
EFI_STATUS
EFIAPI
ShellIsFileInPath(
IN CONST CHAR16 *Name
ShellIsFileInPath (
IN CONST CHAR16 *Name
);
/**
@ -1038,8 +1037,8 @@ ShellIsFileInPath(
**/
UINTN
EFIAPI
ShellStrToUintn(
IN CONST CHAR16 *String
ShellStrToUintn (
IN CONST CHAR16 *String
);
/**
@ -1055,8 +1054,8 @@ ShellStrToUintn(
**/
UINTN
EFIAPI
ShellHexStrToUintn(
IN CONST CHAR16 *String
ShellHexStrToUintn (
IN CONST CHAR16 *String
);
/**
@ -1091,13 +1090,13 @@ ShellHexStrToUintn(
@return The Destination after appending the Source.
**/
CHAR16*
CHAR16 *
EFIAPI
StrnCatGrow (
IN OUT CHAR16 **Destination,
IN OUT UINTN *CurrentSize,
IN CONST CHAR16 *Source,
IN UINTN Count
IN OUT CHAR16 **Destination,
IN OUT UINTN *CurrentSize,
IN CONST CHAR16 *Source,
IN UINTN Count
);
/**
@ -1129,14 +1128,14 @@ StrnCatGrow (
**/
EFI_STATUS
EFIAPI
ShellCopySearchAndReplace(
IN CHAR16 CONST *SourceString,
IN OUT CHAR16 *NewString,
IN UINTN NewSize,
IN CONST CHAR16 *FindTarget,
IN CONST CHAR16 *ReplaceWith,
IN CONST BOOLEAN SkipPreCarrot,
IN CONST BOOLEAN ParameterReplacing
ShellCopySearchAndReplace (
IN CHAR16 CONST *SourceString,
IN OUT CHAR16 *NewString,
IN UINTN NewSize,
IN CONST CHAR16 *FindTarget,
IN CONST CHAR16 *ReplaceWith,
IN CONST BOOLEAN SkipPreCarrot,
IN CONST BOOLEAN ParameterReplacing
);
/**
@ -1156,7 +1155,7 @@ ShellCopySearchAndReplace(
BOOLEAN
EFIAPI
ShellIsHexaDecimalDigitCharacter (
IN CHAR16 Char
IN CHAR16 Char
);
/**
@ -1176,7 +1175,7 @@ ShellIsHexaDecimalDigitCharacter (
BOOLEAN
EFIAPI
ShellIsDecimalDigitCharacter (
IN CHAR16 Char
IN CHAR16 Char
);
///
@ -1233,9 +1232,9 @@ typedef enum {
EFI_STATUS
EFIAPI
ShellPromptForResponse (
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CHAR16 *Prompt OPTIONAL,
IN OUT VOID **Response OPTIONAL
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CHAR16 *Prompt OPTIONAL,
IN OUT VOID **Response OPTIONAL
);
/**
@ -1258,10 +1257,10 @@ ShellPromptForResponse (
EFI_STATUS
EFIAPI
ShellPromptForResponseHii (
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CONST EFI_STRING_ID HiiFormatStringId,
IN CONST EFI_HII_HANDLE HiiFormatHandle,
IN OUT VOID **Response
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CONST EFI_STRING_ID HiiFormatStringId,
IN CONST EFI_HII_HANDLE HiiFormatHandle,
IN OUT VOID **Response
);
/**
@ -1301,9 +1300,9 @@ ShellIsHexOrDecimalNumber (
**/
EFI_STATUS
EFIAPI
ShellConvertStringToUint64(
ShellConvertStringToUint64 (
IN CONST CHAR16 *String,
OUT UINT64 *Value,
OUT UINT64 *Value,
IN CONST BOOLEAN ForceHex,
IN CONST BOOLEAN StopAtSpace
);
@ -1319,8 +1318,8 @@ ShellConvertStringToUint64(
**/
EFI_STATUS
EFIAPI
ShellFileExists(
IN CONST CHAR16 *Name
ShellFileExists (
IN CONST CHAR16 *Name
);
/**
@ -1338,11 +1337,11 @@ ShellFileExists(
@sa ShellFileHandleReadLine
**/
CHAR16*
CHAR16 *
EFIAPI
ShellFileHandleReturnLine(
IN SHELL_FILE_HANDLE Handle,
IN OUT BOOLEAN *Ascii
ShellFileHandleReturnLine (
IN SHELL_FILE_HANDLE Handle,
IN OUT BOOLEAN *Ascii
);
/**
@ -1373,12 +1372,12 @@ ShellFileHandleReturnLine(
**/
EFI_STATUS
EFIAPI
ShellFileHandleReadLine(
IN SHELL_FILE_HANDLE Handle,
IN OUT CHAR16 *Buffer,
IN OUT UINTN *Size,
IN BOOLEAN Truncate,
IN OUT BOOLEAN *Ascii
ShellFileHandleReadLine (
IN SHELL_FILE_HANDLE Handle,
IN OUT CHAR16 *Buffer,
IN OUT UINTN *Size,
IN BOOLEAN Truncate,
IN OUT BOOLEAN *Ascii
);
/**
@ -1406,8 +1405,8 @@ ShellFileHandleReadLine(
**/
EFI_STATUS
EFIAPI
ShellDeleteFileByName(
IN CONST CHAR16 *FileName
ShellDeleteFileByName (
IN CONST CHAR16 *FileName
);
/**
@ -1424,9 +1423,9 @@ ShellDeleteFileByName(
EFI_STATUS
EFIAPI
ShellPrintHelp (
IN CONST CHAR16 *CommandToGetHelpOn,
IN CONST CHAR16 *SectionToGetHelpOn,
IN BOOLEAN PrintCommandText
IN CONST CHAR16 *CommandToGetHelpOn,
IN CONST CHAR16 *SectionToGetHelpOn,
IN BOOLEAN PrintCommandText
);
#endif // __SHELL_LIB__

View File

@ -6,12 +6,11 @@
**/
#ifndef _SHELL_ENVIRONMENT_2_PROTOCOL_H_
#define _SHELL_ENVIRONMENT_2_PROTOCOL_H_
#define DEFAULT_INIT_ROW 1
#define DEFAULT_AUTO_LF FALSE
#define DEFAULT_INIT_ROW 1
#define DEFAULT_AUTO_LF FALSE
/**
This function is a prototype for a function that dumps information on a protocol
@ -24,7 +23,7 @@
**/
typedef
VOID
(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO) (
(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO)(
IN EFI_HANDLE Handle,
IN VOID *Interface
);
@ -45,7 +44,7 @@ VOID
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_INTERNAL_COMMAND) (
(EFIAPI *SHELLENV_INTERNAL_COMMAND)(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
@ -62,7 +61,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SHELLCMD_GET_LINE_HELP) (
(EFIAPI *SHELLCMD_GET_LINE_HELP)(
IN OUT CHAR16 **Str
);
@ -70,20 +69,20 @@ EFI_STATUS
Structure returned from functions that open multiple files.
**/
typedef struct {
UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE.
LIST_ENTRY Link; ///< Linked list helper.
EFI_STATUS Status; ///< File's status.
UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE.
LIST_ENTRY Link; ///< Linked list helper.
EFI_STATUS Status; ///< File's status.
EFI_FILE_HANDLE Parent; ///< What is the Parent file of this file.
UINT64 OpenMode; ///< How was the file opened.
CHAR16 *ParentName; ///< String representation of parent.
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent.
EFI_FILE_HANDLE Parent; ///< What is the Parent file of this file.
UINT64 OpenMode; ///< How was the file opened.
CHAR16 *ParentName; ///< String representation of parent.
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent.
CHAR16 *FullName; ///< Path and file name for this file.
CHAR16 *FileName; ///< File name for this file.
CHAR16 *FullName; ///< Path and file name for this file.
CHAR16 *FileName; ///< File name for this file.
EFI_FILE_HANDLE Handle; ///< Handle to this file.
EFI_FILE_INFO *Info; ///< Pointer to file info for this file.
EFI_FILE_HANDLE Handle; ///< Handle to this file.
EFI_FILE_INFO *Info; ///< Pointer to file info for this file.
} SHELL_FILE_ARG;
/// Signature for SHELL_FILE_ARG.
@ -105,8 +104,8 @@ GUID for the shell environment2 extension (main GUID above).
0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \
}
#define EFI_SHELL_MAJOR_VER 0x00000001 ///< Major version of the EFI_SHELL_ENVIRONMENT2.
#define EFI_SHELL_MINOR_VER 0x00000000 ///< Minor version of the EFI_SHELL_ENVIRONMENT2.
#define EFI_SHELL_MAJOR_VER 0x00000001 ///< Major version of the EFI_SHELL_ENVIRONMENT2.
#define EFI_SHELL_MINOR_VER 0x00000000 ///< Minor version of the EFI_SHELL_ENVIRONMENT2.
/**
Execute a command line.
@ -129,7 +128,7 @@ GUID for the shell environment2 extension (main GUID above).
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_EXECUTE) (
(EFIAPI *SHELLENV_EXECUTE)(
IN EFI_HANDLE *ParentImageHandle,
IN CHAR16 *CommandLine,
IN BOOLEAN DebugOutput
@ -147,7 +146,7 @@ EFI_STATUS
**/
typedef
CHAR16 *
(EFIAPI *SHELLENV_GET_ENV) (
(EFIAPI *SHELLENV_GET_ENV)(
IN CHAR16 *Name
);
@ -163,7 +162,7 @@ CHAR16 *
**/
typedef
CHAR16 *
(EFIAPI *SHELLENV_GET_MAP) (
(EFIAPI *SHELLENV_GET_MAP)(
IN CHAR16 *Name
);
@ -184,7 +183,7 @@ CHAR16 *
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_ADD_CMD) (
(EFIAPI *SHELLENV_ADD_CMD)(
IN SHELLENV_INTERNAL_COMMAND Handler,
IN CHAR16 *Cmd,
IN SHELLCMD_GET_LINE_HELP GetLineHelp
@ -206,7 +205,7 @@ EFI_STATUS
**/
typedef
VOID
(EFIAPI *SHELLENV_ADD_PROT) (
(EFIAPI *SHELLENV_ADD_PROT)(
IN EFI_GUID *Protocol,
IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken 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.
**/
typedef
CHAR16*
(EFIAPI *SHELLENV_GET_PROT) (
CHAR16 *
(EFIAPI *SHELLENV_GET_PROT)(
IN EFI_GUID *Protocol,
IN BOOLEAN GenId
);
@ -249,8 +248,8 @@ CHAR16*
**/
typedef
CHAR16*
(EFIAPI *SHELLENV_CUR_DIR) (
CHAR16 *
(EFIAPI *SHELLENV_CUR_DIR)(
IN CHAR16 *DeviceName OPTIONAL
);
@ -275,7 +274,7 @@ CHAR16*
@sa SHELLENV_FREE_FILE_LIST
**/typedef
EFI_STATUS
(EFIAPI *SHELLENV_FILE_META_ARG) (
(EFIAPI *SHELLENV_FILE_META_ARG)(
IN CHAR16 *Arg,
IN OUT LIST_ENTRY *ListHead
);
@ -289,7 +288,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_FREE_FILE_LIST) (
(EFIAPI *SHELLENV_FREE_FILE_LIST)(
IN OUT LIST_ENTRY *ListHead
);
@ -308,8 +307,8 @@ EFI_STATUS
**/
typedef
EFI_SHELL_INTERFACE*
(EFIAPI *SHELLENV_NEW_SHELL) (
EFI_SHELL_INTERFACE *
(EFIAPI *SHELLENV_NEW_SHELL)(
IN EFI_HANDLE ImageHandle
);
@ -325,7 +324,7 @@ EFI_SHELL_INTERFACE*
**/
typedef
BOOLEAN
(EFIAPI *SHELLENV_BATCH_IS_ACTIVE) (
(EFIAPI *SHELLENV_BATCH_IS_ACTIVE)(
VOID
);
@ -335,7 +334,7 @@ BOOLEAN
**/
typedef
VOID
(EFIAPI *SHELLENV_FREE_RESOURCES) (
(EFIAPI *SHELLENV_FREE_RESOURCES)(
VOID
);
@ -352,7 +351,7 @@ VOID
**/
typedef
VOID
(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK) (
(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK)(
IN INT32 StartRow,
IN BOOLEAN AutoWrap
);
@ -365,7 +364,7 @@ VOID
**/
typedef
VOID
(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK) (
(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK)(
VOID
);
@ -377,7 +376,7 @@ VOID
**/
typedef
BOOLEAN
(EFIAPI *SHELLENV_GET_PAGE_BREAK) (
(EFIAPI *SHELLENV_GET_PAGE_BREAK)(
VOID
);
@ -393,7 +392,7 @@ BOOLEAN
**/
typedef
VOID
(EFIAPI *SHELLENV_SET_KEY_FILTER) (
(EFIAPI *SHELLENV_SET_KEY_FILTER)(
IN UINT32 KeyFilter
);
@ -409,7 +408,7 @@ VOID
**/
typedef
UINT32
(EFIAPI *SHELLENV_GET_KEY_FILTER) (
(EFIAPI *SHELLENV_GET_KEY_FILTER)(
VOID
);
@ -425,7 +424,7 @@ UINT32
**/
typedef
BOOLEAN
(EFIAPI *SHELLENV_GET_EXECUTION_BREAK) (
(EFIAPI *SHELLENV_GET_EXECUTION_BREAK)(
VOID
);
@ -435,7 +434,7 @@ BOOLEAN
**/
typedef
VOID
(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) (
(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL)(
VOID
);
@ -444,7 +443,7 @@ VOID
**/
typedef
VOID
(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) (
(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL)(
VOID
);
@ -457,7 +456,7 @@ VOID
**/
typedef
BOOLEAN
(EFIAPI *SHELLENV_IS_ROOT_SHELL) (
(EFIAPI *SHELLENV_IS_ROOT_SHELL)(
VOID
);
@ -476,7 +475,7 @@ BOOLEAN
**/
typedef
VOID
(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY) (
(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY)(
IN EFI_HANDLE ConInHandle,
IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn,
IN EFI_HANDLE ConOutHandle,
@ -486,6 +485,7 @@ VOID
//
// declarations of handle enumerator
//
/**
For ease of use the shell maps handle #'s to short numbers.
This is only done on request for various internal commands and the references
@ -493,7 +493,7 @@ VOID
**/
typedef
VOID
(EFIAPI *INIT_HANDLE_ENUMERATOR) (
(EFIAPI *INIT_HANDLE_ENUMERATOR)(
VOID
);
@ -514,7 +514,7 @@ VOID
**/
typedef
EFI_STATUS
(EFIAPI *NEXT_HANDLE) (
(EFIAPI *NEXT_HANDLE)(
IN OUT EFI_HANDLE **Handle
);
@ -534,7 +534,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SKIP_HANDLE) (
(EFIAPI *SKIP_HANDLE)(
IN UINTN SkipNum
);
@ -552,7 +552,7 @@ EFI_STATUS
**/
typedef
UINTN
(EFIAPI *RESET_HANDLE_ENUMERATOR) (
(EFIAPI *RESET_HANDLE_ENUMERATOR)(
IN UINTN EnumIndex
);
@ -567,7 +567,7 @@ UINTN
**/
typedef
VOID
(EFIAPI *CLOSE_HANDLE_ENUMERATOR) (
(EFIAPI *CLOSE_HANDLE_ENUMERATOR)(
VOID
);
@ -582,7 +582,7 @@ VOID
**/
typedef
UINTN
(EFIAPI *GET_NUM) (
(EFIAPI *GET_NUM)(
VOID
);
@ -590,43 +590,43 @@ UINTN
Handle Enumerator structure.
**/
typedef struct {
INIT_HANDLE_ENUMERATOR Init; ///< The pointer to INIT_HANDLE_ENUMERATOR function.
NEXT_HANDLE Next; ///< The pointer to NEXT_HANDLE function.
SKIP_HANDLE Skip; ///< The pointer to SKIP_HANDLE function.
RESET_HANDLE_ENUMERATOR Reset; ///< The pointer to RESET_HANDLE_ENUMERATOR function.
CLOSE_HANDLE_ENUMERATOR Close; ///< The pointer to CLOSE_HANDLE_ENUMERATOR function.
GET_NUM GetNum; ///< The pointer to GET_NUM function.
INIT_HANDLE_ENUMERATOR Init; ///< The pointer to INIT_HANDLE_ENUMERATOR function.
NEXT_HANDLE Next; ///< The pointer to NEXT_HANDLE function.
SKIP_HANDLE Skip; ///< The pointer to SKIP_HANDLE function.
RESET_HANDLE_ENUMERATOR Reset; ///< The pointer to RESET_HANDLE_ENUMERATOR function.
CLOSE_HANDLE_ENUMERATOR Close; ///< The pointer to CLOSE_HANDLE_ENUMERATOR function.
GET_NUM GetNum; ///< The pointer to GET_NUM function.
} HANDLE_ENUMERATOR;
/**
Signature for the PROTOCOL_INFO structure.
**/
#define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')
#define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')
/**
PROTOCOL_INFO structure for protocol enumerator functions.
**/
typedef struct {
UINTN Signature; ///< PROTOCOL_INFO_SIGNATURE.
LIST_ENTRY Link; ///< Standard linked list helper member.
UINTN Signature; ///< PROTOCOL_INFO_SIGNATURE.
LIST_ENTRY Link; ///< Standard linked list helper member.
//
// The parsing info for the protocol.
//
EFI_GUID ProtocolId; ///< The GUID for the protocol.
CHAR16 *IdString; ///< The name of the protocol.
SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< The pointer to DumpToken function for the protocol.
SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< The pointer to DumpInfo function for the protocol.
EFI_GUID ProtocolId; ///< The GUID for the protocol.
CHAR16 *IdString; ///< The name of the protocol.
SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< The pointer to DumpToken function for the protocol.
SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< The pointer to DumpInfo function for the protocol.
//
// Patabase info on which handles are supporting this protocol.
//
UINTN NoHandles; ///< The number of handles producing this protocol.
EFI_HANDLE *Handles; ///< The array of handles.
UINTN NoHandles; ///< The number of handles producing this protocol.
EFI_HANDLE *Handles; ///< The array of handles.
} PROTOCOL_INFO;
//
// Declarations of protocol info enumerator.
//
/**
This is an internal shell function to initialize the protocol enumerator.
@ -636,7 +636,7 @@ typedef struct {
**/
typedef
VOID
(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR) (
(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR)(
VOID
);
@ -657,7 +657,7 @@ VOID
**/
typedef
EFI_STATUS
(EFIAPI *NEXT_PROTOCOL_INFO) (
(EFIAPI *NEXT_PROTOCOL_INFO)(
IN OUT PROTOCOL_INFO **ProtocolInfo
);
@ -673,7 +673,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SKIP_PROTOCOL_INFO) (
(EFIAPI *SKIP_PROTOCOL_INFO)(
IN UINTN SkipNum
);
@ -688,11 +688,10 @@ EFI_STATUS
**/
typedef
VOID
(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR) (
(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR)(
VOID
);
/**
This function is an internal shell function for enumeration of protocols.
@ -704,7 +703,7 @@ VOID
**/
typedef
VOID
(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR) (
(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR)(
VOID
);
@ -712,11 +711,11 @@ VOID
Protocol enumerator structure of function pointers.
**/
typedef struct {
INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< The pointer to INIT_PROTOCOL_INFO_ENUMERATOR function.
NEXT_PROTOCOL_INFO Next; ///< The pointer to NEXT_PROTOCOL_INFO function.
SKIP_PROTOCOL_INFO Skip; ///< The pointer to SKIP_PROTOCOL_INFO function.
RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< The pointer to RESET_PROTOCOL_INFO_ENUMERATOR function.
CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< The pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function.
INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< The pointer to INIT_PROTOCOL_INFO_ENUMERATOR function.
NEXT_PROTOCOL_INFO Next; ///< The pointer to NEXT_PROTOCOL_INFO function.
SKIP_PROTOCOL_INFO Skip; ///< The pointer to SKIP_PROTOCOL_INFO function.
RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< The pointer to RESET_PROTOCOL_INFO_ENUMERATOR function.
CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< The pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function.
} PROTOCOL_INFO_ENUMERATOR;
/**
@ -752,7 +751,7 @@ typedef struct {
**/
typedef
EFI_STATUS
(EFIAPI *GET_DEVICE_NAME) (
(EFIAPI *GET_DEVICE_NAME)(
IN EFI_HANDLE DeviceHandle,
IN BOOLEAN UseComponentName,
IN BOOLEAN UseDevicePath,
@ -764,8 +763,8 @@ EFI_STATUS
IN UINTN Indent
);
#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< The string for lowest version this shell supports.
#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< The string for highest version this shell supports.
#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< The string for lowest version this shell supports.
#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< The string for highest version this shell supports.
/**
This function gets the shell mode as stored in the shell environment
@ -778,7 +777,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *GET_SHELL_MODE) (
(EFIAPI *GET_SHELL_MODE)(
OUT CHAR16 **Mode
);
@ -798,8 +797,8 @@ EFI_STATUS
@retval NULL The operation could not be completed.
**/
typedef
EFI_DEVICE_PATH_PROTOCOL*
(EFIAPI *SHELLENV_NAME_TO_PATH) (
EFI_DEVICE_PATH_PROTOCOL *
(EFIAPI *SHELLENV_NAME_TO_PATH)(
IN CHAR16 *Path
);
@ -827,8 +826,8 @@ EFI_DEVICE_PATH_PROTOCOL*
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_GET_FS_NAME) (
IN EFI_DEVICE_PATH_PROTOCOL * DevPath,
(EFIAPI *SHELLENV_GET_FS_NAME)(
IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
IN BOOLEAN ConsistMapping,
OUT CHAR16 **Name
);
@ -855,7 +854,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (
(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD)(
IN CHAR16 *Arg,
IN OUT LIST_ENTRY *ListHead
);
@ -877,8 +876,8 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_DEL_DUP_FILE) (
IN LIST_ENTRY * ListHead
(EFIAPI *SHELLENV_DEL_DUP_FILE)(
IN LIST_ENTRY *ListHead
);
/**
@ -905,65 +904,65 @@ EFI_STATUS
**/
typedef
EFI_STATUS
(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) (
(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH)(
IN CHAR16 *Name,
OUT EFI_DEVICE_PATH_PROTOCOL **DevPath
);
/// EFI_SHELL_ENVIRONMENT2 protocol structure.
typedef struct {
SHELLENV_EXECUTE Execute;
SHELLENV_GET_ENV GetEnv;
SHELLENV_GET_MAP GetMap;
SHELLENV_ADD_CMD AddCmd;
SHELLENV_ADD_PROT AddProt;
SHELLENV_GET_PROT GetProt;
SHELLENV_CUR_DIR CurDir;
SHELLENV_FILE_META_ARG FileMetaArg;
SHELLENV_FREE_FILE_LIST FreeFileList;
SHELLENV_EXECUTE Execute;
SHELLENV_GET_ENV GetEnv;
SHELLENV_GET_MAP GetMap;
SHELLENV_ADD_CMD AddCmd;
SHELLENV_ADD_PROT AddProt;
SHELLENV_GET_PROT GetProt;
SHELLENV_CUR_DIR CurDir;
SHELLENV_FILE_META_ARG FileMetaArg;
SHELLENV_FREE_FILE_LIST FreeFileList;
//
// The following services are only used by the shell itself.
//
SHELLENV_NEW_SHELL NewShell;
SHELLENV_BATCH_IS_ACTIVE BatchIsActive;
SHELLENV_NEW_SHELL NewShell;
SHELLENV_BATCH_IS_ACTIVE BatchIsActive;
SHELLENV_FREE_RESOURCES FreeResources;
SHELLENV_FREE_RESOURCES FreeResources;
//
// GUID to differentiate ShellEnvironment2 from ShellEnvironment.
//
EFI_GUID SESGuid;
EFI_GUID SESGuid;
//
// Major Version grows if shell environment interface has been changes.
//
UINT32 MajorVersion;
UINT32 MinorVersion;
SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;
SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;
SHELLENV_GET_PAGE_BREAK GetPageBreak;
UINT32 MajorVersion;
UINT32 MinorVersion;
SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;
SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;
SHELLENV_GET_PAGE_BREAK GetPageBreak;
SHELLENV_SET_KEY_FILTER SetKeyFilter;
SHELLENV_GET_KEY_FILTER GetKeyFilter;
SHELLENV_SET_KEY_FILTER SetKeyFilter;
SHELLENV_GET_KEY_FILTER GetKeyFilter;
SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;
SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;
SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;
SHELLENV_IS_ROOT_SHELL IsRootShell;
SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;
SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;
SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;
SHELLENV_IS_ROOT_SHELL IsRootShell;
SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;
HANDLE_ENUMERATOR HandleEnumerator;
PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;
GET_DEVICE_NAME GetDeviceName;
GET_SHELL_MODE GetShellMode;
SHELLENV_NAME_TO_PATH NameToPath;
SHELLENV_GET_FS_NAME GetFsName;
SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;
SHELLENV_DEL_DUP_FILE DelDupFileArg;
SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;
SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;
HANDLE_ENUMERATOR HandleEnumerator;
PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;
GET_DEVICE_NAME GetDeviceName;
GET_SHELL_MODE GetShellMode;
SHELLENV_NAME_TO_PATH NameToPath;
SHELLENV_GET_FS_NAME GetFsName;
SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;
SHELLENV_DEL_DUP_FILE DelDupFileArg;
SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;
} EFI_SHELL_ENVIRONMENT2;
extern EFI_GUID gEfiShellEnvironment2Guid;
extern EFI_GUID gEfiShellEnvironment2ExtGuid;
extern EFI_GUID gEfiShellEnvironment2Guid;
extern EFI_GUID gEfiShellEnvironment2ExtGuid;
#endif // _SHELL_ENVIRONMENT_2_PROTOCOL_H_

View File

@ -40,7 +40,7 @@ typedef enum {
/// Attributes for an argument.
///
typedef struct _EFI_SHELL_ARG_INFO {
UINT32 Attributes;
UINT32 Attributes;
} EFI_SHELL_ARG_INFO;
///
@ -50,39 +50,39 @@ typedef struct {
///
/// Handle back to original image handle & image information.
///
EFI_HANDLE ImageHandle;
EFI_LOADED_IMAGE_PROTOCOL *Info;
EFI_HANDLE ImageHandle;
EFI_LOADED_IMAGE_PROTOCOL *Info;
///
/// Parsed arg list converted more C-like format.
///
CHAR16 **Argv;
UINTN Argc;
CHAR16 **Argv;
UINTN Argc;
///
/// Storage for file redirection args after parsing.
///
CHAR16 **RedirArgv;
UINTN RedirArgc;
CHAR16 **RedirArgv;
UINTN RedirArgc;
///
/// A file style handle for console io.
///
EFI_FILE_PROTOCOL *StdIn;
EFI_FILE_PROTOCOL *StdOut;
EFI_FILE_PROTOCOL *StdErr;
EFI_FILE_PROTOCOL *StdIn;
EFI_FILE_PROTOCOL *StdOut;
EFI_FILE_PROTOCOL *StdErr;
///
/// List of attributes for each argument.
///
EFI_SHELL_ARG_INFO *ArgInfo;
EFI_SHELL_ARG_INFO *ArgInfo;
///
/// Whether we are echoing.
///
BOOLEAN EchoOn;
BOOLEAN EchoOn;
} EFI_SHELL_INTERFACE;
extern EFI_GUID gEfiShellInterfaceGuid;
extern EFI_GUID gEfiShellInterfaceGuid;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -99,8 +99,8 @@
#include <Protocol/DriverConfiguration.h>
#include <Protocol/DriverConfiguration2.h>
#include <Protocol/DevicePathUtilities.h>
//#include <Protocol/FirmwareVolume.h>
//#include <Protocol/FirmwareVolume2.h>
// #include <Protocol/FirmwareVolume.h>
// #include <Protocol/FirmwareVolume2.h>
#include <Protocol/DriverFamilyOverride.h>
#include <Protocol/Pcd.h>
#include <Protocol/TcgService.h>
@ -150,8 +150,8 @@
#include <Library/ShellCommandLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1 1
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2 2
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1 1
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2 2
///
/// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec < 2.4a
@ -161,32 +161,32 @@ typedef struct {
/// A unique number identifying the firmware image within the device. The number is
/// between 1 and DescriptorCount.
///
UINT8 ImageIndex;
UINT8 ImageIndex;
///
/// A unique number identifying the firmware image type.
///
EFI_GUID ImageTypeId;
EFI_GUID ImageTypeId;
///
/// A unique number identifying the firmware image.
///
UINT64 ImageId;
UINT64 ImageId;
///
/// A pointer to a null-terminated string representing the firmware image name.
///
CHAR16 *ImageIdName;
CHAR16 *ImageIdName;
///
/// Identifies the version of the device firmware. The format is vendor specific and new
/// version must have a greater value than an old version.
///
UINT32 Version;
UINT32 Version;
///
/// A pointer to a null-terminated string representing the firmware image version name.
///
CHAR16 *VersionName;
CHAR16 *VersionName;
///
/// Size of the image in bytes. If size=0, then only ImageIndex and ImageTypeId are valid.
///
UINTN Size;
UINTN Size;
///
/// Image attributes that are supported by this device. See 'Image Attribute Definitions'
/// for possible returned values of this parameter. A value of 1 indicates the attribute is
@ -194,20 +194,19 @@ typedef struct {
/// value of 0 indicates the attribute is not supported and the current setting value in
/// AttributesSetting is meaningless.
///
UINT64 AttributesSupported;
UINT64 AttributesSupported;
///
/// Image attributes. See 'Image Attribute Definitions' for possible returned values of
/// this parameter.
///
UINT64 AttributesSetting;
UINT64 AttributesSetting;
///
/// Image compatibilities. See 'Image Compatibility Definitions' for possible returned
/// values of this parameter.
///
UINT64 Compatibilities;
UINT64 Compatibilities;
} EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1;
///
/// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec > 2.4a and < 2.5
///
@ -216,32 +215,32 @@ typedef struct {
/// A unique number identifying the firmware image within the device. The number is
/// between 1 and DescriptorCount.
///
UINT8 ImageIndex;
UINT8 ImageIndex;
///
/// A unique number identifying the firmware image type.
///
EFI_GUID ImageTypeId;
EFI_GUID ImageTypeId;
///
/// A unique number identifying the firmware image.
///
UINT64 ImageId;
UINT64 ImageId;
///
/// A pointer to a null-terminated string representing the firmware image name.
///
CHAR16 *ImageIdName;
CHAR16 *ImageIdName;
///
/// Identifies the version of the device firmware. The format is vendor specific and new
/// version must have a greater value than an old version.
///
UINT32 Version;
UINT32 Version;
///
/// A pointer to a null-terminated string representing the firmware image version name.
///
CHAR16 *VersionName;
CHAR16 *VersionName;
///
/// Size of the image in bytes. If size=0, then only ImageIndex and ImageTypeId are valid.
///
UINTN Size;
UINTN Size;
///
/// Image attributes that are supported by this device. See 'Image Attribute Definitions'
/// for possible returned values of this parameter. A value of 1 indicates the attribute is
@ -249,32 +248,32 @@ typedef struct {
/// value of 0 indicates the attribute is not supported and the current setting value in
/// AttributesSetting is meaningless.
///
UINT64 AttributesSupported;
UINT64 AttributesSupported;
///
/// Image attributes. See 'Image Attribute Definitions' for possible returned values of
/// this parameter.
///
UINT64 AttributesSetting;
UINT64 AttributesSetting;
///
/// Image compatibilities. See 'Image Compatibility Definitions' for possible returned
/// values of this parameter.
///
UINT64 Compatibilities;
UINT64 Compatibilities;
///
/// Describes the lowest ImageDescriptor version that the device will accept. Only
/// present in version 2 or higher.
UINT32 LowestSupportedImageVersion;
UINT32 LowestSupportedImageVersion;
} EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2;
typedef struct {
LIST_ENTRY Link;
EFI_HANDLE TheHandle;
UINTN TheIndex;
}HANDLE_LIST;
LIST_ENTRY Link;
EFI_HANDLE TheHandle;
UINTN TheIndex;
} HANDLE_LIST;
typedef struct {
HANDLE_LIST List;
UINTN NextIndex;
HANDLE_LIST List;
UINTN NextIndex;
} HANDLE_INDEX_LIST;
typedef
@ -284,11 +283,10 @@ CHAR16 *
IN CONST BOOLEAN Verbose
);
typedef struct _GUID_INFO_BLOCK{
EFI_STRING_ID StringId;
EFI_GUID *GuidId;
DUMP_PROTOCOL_INFO DumpInfo;
typedef struct _GUID_INFO_BLOCK {
EFI_STRING_ID StringId;
EFI_GUID *GuidId;
DUMP_PROTOCOL_INFO DumpInfo;
} GUID_INFO_BLOCK;
#endif

View File

@ -12,16 +12,16 @@
#include "AcpiView.h"
#include "AcpiViewConfig.h"
STATIC UINT32 gIndent;
STATIC UINT32 mTableErrorCount;
STATIC UINT32 mTableWarningCount;
STATIC UINT32 gIndent;
STATIC UINT32 mTableErrorCount;
STATIC UINT32 mTableWarningCount;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
An ACPI_PARSER array describing the ACPI header.
**/
STATIC CONST ACPI_PARSER AcpiHeaderParser[] = {
STATIC CONST ACPI_PARSER AcpiHeaderParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
@ -113,21 +113,21 @@ IncrementWarningCount (
BOOLEAN
EFIAPI
VerifyChecksum (
IN BOOLEAN Log,
IN UINT8* Ptr,
IN UINT32 Length
IN BOOLEAN Log,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINTN ByteCount;
UINT8 Checksum;
UINTN OriginalAttribute;
UINTN ByteCount;
UINT8 Checksum;
UINTN OriginalAttribute;
//
// set local variables to suppress incorrect compiler/analyzer warnings
//
OriginalAttribute = 0;
ByteCount = 0;
Checksum = 0;
ByteCount = 0;
Checksum = 0;
while (ByteCount < Length) {
Checksum += *(Ptr++);
@ -140,22 +140,29 @@ VerifyChecksum (
if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute (
gST->ConOut,
EFI_TEXT_ATTR (EFI_GREEN,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
EFI_TEXT_ATTR (
EFI_GREEN,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
);
}
Print (L"Table Checksum : OK\n\n");
} else {
IncrementErrorCount ();
if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute (
gST->ConOut,
EFI_TEXT_ATTR (EFI_RED,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
EFI_TEXT_ATTR (
EFI_RED,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
);
}
Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum);
}
if (GetColourHighlighting ()) {
gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
}
@ -173,16 +180,16 @@ VerifyChecksum (
VOID
EFIAPI
DumpRaw (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINTN ByteCount;
UINTN PartLineChars;
UINTN AsciiBufferIndex;
CHAR8 AsciiBuffer[17];
UINTN ByteCount;
UINTN PartLineChars;
UINTN AsciiBufferIndex;
CHAR8 AsciiBuffer[17];
ByteCount = 0;
ByteCount = 0;
AsciiBufferIndex = 0;
Print (L"Address : 0x%p\n", Ptr);
@ -216,6 +223,7 @@ DumpRaw (
if ((Length & 0x0F) <= 8) {
PartLineChars += 2;
}
while (PartLineChars > 0) {
Print (L" ");
PartLineChars--;
@ -236,8 +244,8 @@ DumpRaw (
VOID
EFIAPI
DumpUint8 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
Print (Format, *Ptr);
@ -252,11 +260,11 @@ DumpUint8 (
VOID
EFIAPI
DumpUint16 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
Print (Format, *(UINT16*)Ptr);
Print (Format, *(UINT16 *)Ptr);
}
/**
@ -268,11 +276,11 @@ DumpUint16 (
VOID
EFIAPI
DumpUint32 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
Print (Format, *(UINT32*)Ptr);
Print (Format, *(UINT32 *)Ptr);
}
/**
@ -284,19 +292,19 @@ DumpUint32 (
VOID
EFIAPI
DumpUint64 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
// Some fields are not aligned and this causes alignment faults
// on ARM platforms if the compiler generates LDRD instructions.
// 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 |= (UINT64)*(UINT32*)Ptr;
Val = LShiftU64 (Val, 32);
Val |= (UINT64)*(UINT32 *)Ptr;
Print (Format, Val);
}
@ -313,8 +321,8 @@ DumpUint64 (
VOID
EFIAPI
Dump3Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -337,8 +345,8 @@ Dump3Chars (
VOID
EFIAPI
Dump4Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -362,8 +370,8 @@ Dump4Chars (
VOID
EFIAPI
Dump6Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -389,8 +397,8 @@ Dump6Chars (
VOID
EFIAPI
Dump8Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -418,8 +426,8 @@ Dump8Chars (
VOID
EFIAPI
Dump12Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -454,9 +462,9 @@ Dump12Chars (
VOID
EFIAPI
PrintFieldName (
IN UINT32 Indent,
IN CONST CHAR16* FieldName
)
IN UINT32 Indent,
IN CONST CHAR16 *FieldName
)
{
Print (
L"%*a%-*s : ",
@ -498,38 +506,41 @@ EFIAPI
ParseAcpi (
IN BOOLEAN Trace,
IN UINT32 Indent,
IN CONST CHAR8* AsciiName OPTIONAL,
IN UINT8* Ptr,
IN CONST CHAR8 *AsciiName OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length,
IN CONST ACPI_PARSER* Parser,
IN CONST ACPI_PARSER *Parser,
IN UINT32 ParserItems
)
)
{
UINT32 Index;
UINT32 Offset;
BOOLEAN HighLight;
UINTN OriginalAttribute;
UINT32 Index;
UINT32 Offset;
BOOLEAN HighLight;
UINTN OriginalAttribute;
//
// set local variables to suppress incorrect compiler/analyzer warnings
//
OriginalAttribute = 0;
Offset = 0;
Offset = 0;
// Increment the Indent
gIndent += Indent;
if (Trace && (AsciiName != NULL)){
if (Trace && (AsciiName != NULL)) {
HighLight = GetColourHighlighting ();
if (HighLight) {
OriginalAttribute = gST->ConOut->Mode->Attribute;
gST->ConOut->SetAttribute (
gST->ConOut,
EFI_TEXT_ATTR(EFI_YELLOW,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))
EFI_TEXT_ATTR (
EFI_YELLOW,
((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
)
);
}
Print (
L"%*a%-*a :\n",
gIndent,
@ -544,7 +555,6 @@ ParseAcpi (
for (Index = 0; Index < ParserItems; Index++) {
if ((Offset + Parser[Index].Length) > Length) {
// For fields outside the buffer length provided, reset any pointers
// which were supposed to be updated by this function call
if (Parser[Index].ItemPtr != NULL) {
@ -556,11 +566,12 @@ ParseAcpi (
}
if (GetConsistencyChecking () &&
(Offset != Parser[Index].Offset)) {
(Offset != Parser[Index].Offset))
{
IncrementErrorCount ();
Print (
L"\nERROR: %a: Offset Mismatch for %s\n"
L"CurrentOffset = %d FieldOffset = %d\n",
L"CurrentOffset = %d FieldOffset = %d\n",
AsciiName,
Parser[Index].NameStr,
Offset,
@ -597,20 +608,23 @@ ParseAcpi (
);
} // switch
}
// Validating only makes sense if we are tracing
// the parsed table entries, to report by table name.
if (GetConsistencyChecking () &&
(Parser[Index].FieldValidator != NULL)) {
(Parser[Index].FieldValidator != NULL))
{
Parser[Index].FieldValidator (Ptr, Parser[Index].Context);
}
Print (L"\n");
} // if (Trace)
if (Parser[Index].ItemPtr != NULL) {
*Parser[Index].ItemPtr = (VOID*)Ptr;
*Parser[Index].ItemPtr = (VOID *)Ptr;
}
Ptr += Parser[Index].Length;
Ptr += Parser[Index].Length;
Offset += Parser[Index].Length;
} // for
@ -624,12 +638,12 @@ ParseAcpi (
The GasParser array is used by the ParseAcpi function to parse and/or trace
the GAS structure.
**/
STATIC CONST ACPI_PARSER GasParser[] = {
{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 Offset", 1, 2, 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}
STATIC CONST ACPI_PARSER GasParser[] = {
{ 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 Offset", 1, 2, 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 }
};
/**
@ -644,9 +658,9 @@ STATIC CONST ACPI_PARSER GasParser[] = {
UINT32
EFIAPI
DumpGasStruct (
IN UINT8* Ptr,
IN UINT32 Indent,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Indent,
IN UINT32 Length
)
{
Print (L"\n");
@ -669,8 +683,8 @@ DumpGasStruct (
VOID
EFIAPI
DumpGas (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE));
@ -686,7 +700,7 @@ DumpGas (
UINT32
EFIAPI
DumpAcpiHeader (
IN UINT8* Ptr
IN UINT8 *Ptr
)
{
return ParseAcpi (
@ -715,13 +729,13 @@ DumpAcpiHeader (
UINT32
EFIAPI
ParseAcpiHeader (
IN UINT8* Ptr,
OUT CONST UINT32** Signature,
OUT CONST UINT32** Length,
OUT CONST UINT8** Revision
IN UINT8 *Ptr,
OUT CONST UINT32 **Signature,
OUT CONST UINT32 **Length,
OUT CONST UINT8 **Revision
)
{
UINT32 BytesParsed;
UINT32 BytesParsed;
BytesParsed = ParseAcpi (
FALSE,
@ -733,8 +747,8 @@ ParseAcpiHeader (
);
*Signature = AcpiHdrInfo.Signature;
*Length = AcpiHdrInfo.Length;
*Revision = AcpiHdrInfo.Revision;
*Length = AcpiHdrInfo.Length;
*Revision = AcpiHdrInfo.Revision;
return BytesParsed;
}

View File

@ -50,9 +50,9 @@ IncrementWarningCount (
BOOLEAN
EFIAPI
VerifyChecksum (
IN BOOLEAN Log,
IN UINT8* Ptr,
IN UINT32 Length
IN BOOLEAN Log,
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -64,8 +64,8 @@ VerifyChecksum (
VOID
EFIAPI
DumpRaw (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -77,8 +77,8 @@ DumpRaw (
VOID
EFIAPI
DumpUint8 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
);
/**
@ -90,8 +90,8 @@ DumpUint8 (
VOID
EFIAPI
DumpUint16 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
);
/**
@ -103,8 +103,8 @@ DumpUint16 (
VOID
EFIAPI
DumpUint32 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
);
/**
@ -116,8 +116,8 @@ DumpUint32 (
VOID
EFIAPI
DumpUint64 (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
);
/**
@ -132,8 +132,8 @@ DumpUint64 (
VOID
EFIAPI
Dump3Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -148,8 +148,8 @@ Dump3Chars (
VOID
EFIAPI
Dump4Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -164,8 +164,8 @@ Dump4Chars (
VOID
EFIAPI
Dump6Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -180,8 +180,8 @@ Dump6Chars (
VOID
EFIAPI
Dump8Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -196,8 +196,8 @@ Dump8Chars (
VOID
EFIAPI
Dump12Chars (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -215,8 +215,8 @@ Dump12Chars (
VOID
EFIAPI
PrintFieldName (
IN UINT32 Indent,
IN CONST CHAR16* FieldName
IN UINT32 Indent,
IN CONST CHAR16 *FieldName
);
/**
@ -226,7 +226,7 @@ PrintFieldName (
the 'Format' member of ACPI_PARSER.
@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.
@ -236,7 +236,7 @@ typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16* Format, UINT8* Ptr);
the 'Context' member of the ACPI_PARSER.
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
@ -258,48 +258,47 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8* Ptr, VOID* Context);
representing the field data.
**/
typedef struct AcpiParser {
/// String describing the ACPI table field
/// (Field column from ACPI table spec)
CONST CHAR16* NameStr;
CONST CHAR16 *NameStr;
/// The length of the field.
/// (Byte Length column from ACPI table spec)
UINT32 Length;
UINT32 Length;
/// The offset of the field from the start of the table.
/// (Byte Offset column from ACPI table spec)
UINT32 Offset;
UINT32 Offset;
/// Optional Print() style format string for tracing the data. If not
/// used this must be set to NULL.
CONST CHAR16* Format;
CONST CHAR16 *Format;
/// Optional pointer to a print formatter function which
/// is typically used to trace complex field information.
/// If not used this must be set to NULL.
/// The Format string is passed to the PrintFormatter function
/// but may be ignored by the implementation code.
FNPTR_PRINT_FORMATTER PrintFormatter;
FNPTR_PRINT_FORMATTER PrintFormatter;
/// Optional pointer which may be set to request the parser to update
/// 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.
/// If unused this must be set to NULL.
VOID** ItemPtr;
VOID **ItemPtr;
/// Optional pointer to a field validator function.
/// The function should directly report any appropriate error or warning
/// and invoke the appropriate counter update function.
/// If not used this parameter must be set to NULL.
FNPTR_FIELD_VALIDATOR FieldValidator;
FNPTR_FIELD_VALIDATOR FieldValidator;
/// Optional pointer to context specific information,
/// which the Field Validator function can use to determine
/// additional information about the ACPI table and make
/// decisions about the field being validated.
/// e.g. this could be a pointer to the ACPI table header
VOID* Context;
VOID *Context;
} ACPI_PARSER;
/**
@ -308,23 +307,23 @@ typedef struct AcpiParser {
**/
typedef struct AcpiDescriptionHeaderInfo {
/// ACPI table signature
UINT32* Signature;
UINT32 *Signature;
/// Length of the ACPI table
UINT32* Length;
UINT32 *Length;
/// Revision
UINT8* Revision;
UINT8 *Revision;
/// Checksum
UINT8* Checksum;
UINT8 *Checksum;
/// OEM Id - length is 6 bytes
UINT8* OemId;
UINT8 *OemId;
/// OEM table Id
UINT64* OemTableId;
UINT64 *OemTableId;
/// OEM revision Id
UINT32* OemRevision;
UINT32 *OemRevision;
/// Creator Id
UINT32* CreatorId;
UINT32 *CreatorId;
/// Creator revision
UINT32* CreatorRevision;
UINT32 *CreatorRevision;
} ACPI_DESCRIPTION_HEADER_INFO;
/**
@ -358,10 +357,10 @@ EFIAPI
ParseAcpi (
IN BOOLEAN Trace,
IN UINT32 Indent,
IN CONST CHAR8* AsciiName OPTIONAL,
IN UINT8* Ptr,
IN CONST CHAR8 *AsciiName OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length,
IN CONST ACPI_PARSER* Parser,
IN CONST ACPI_PARSER *Parser,
IN UINT32 ParserItems
);
@ -371,7 +370,7 @@ ParseAcpi (
@param [in] Parser The name of the ACPI_PARSER array describing the
ACPI table fields.
**/
#define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
#define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
/**
This is a helper macro for describing the ACPI header fields.
@ -410,9 +409,9 @@ ParseAcpi (
UINT32
EFIAPI
DumpGasStruct (
IN UINT8* Ptr,
IN UINT32 Indent,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Indent,
IN UINT32 Length
);
/**
@ -424,8 +423,8 @@ DumpGasStruct (
VOID
EFIAPI
DumpGas (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
);
/**
@ -438,7 +437,7 @@ DumpGas (
UINT32
EFIAPI
DumpAcpiHeader (
IN UINT8* Ptr
IN UINT8 *Ptr
);
/**
@ -457,10 +456,10 @@ DumpAcpiHeader (
UINT32
EFIAPI
ParseAcpiHeader (
IN UINT8* Ptr,
OUT CONST UINT32** Signature,
OUT CONST UINT32** Length,
OUT CONST UINT8** Revision
IN UINT8 *Ptr,
OUT CONST UINT32 **Signature,
OUT CONST UINT32 **Length,
OUT CONST UINT8 **Revision
);
/**
@ -478,10 +477,10 @@ ParseAcpiHeader (
VOID
EFIAPI
ParseAcpiAest (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -499,10 +498,10 @@ ParseAcpiAest (
VOID
EFIAPI
ParseAcpiBgrt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -520,10 +519,10 @@ ParseAcpiBgrt (
VOID
EFIAPI
ParseAcpiDbg2 (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -541,10 +540,10 @@ ParseAcpiDbg2 (
VOID
EFIAPI
ParseAcpiDsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -562,10 +561,10 @@ ParseAcpiDsdt (
VOID
EFIAPI
ParseAcpiFacs (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -583,10 +582,10 @@ ParseAcpiFacs (
VOID
EFIAPI
ParseAcpiFadt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -608,10 +607,10 @@ ParseAcpiFadt (
VOID
EFIAPI
ParseAcpiGtdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -634,10 +633,10 @@ ParseAcpiGtdt (
VOID
EFIAPI
ParseAcpiHmat (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -663,10 +662,10 @@ ParseAcpiHmat (
VOID
EFIAPI
ParseAcpiIort (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -692,10 +691,10 @@ ParseAcpiIort (
VOID
EFIAPI
ParseAcpiMadt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -713,10 +712,10 @@ ParseAcpiMadt (
VOID
EFIAPI
ParseAcpiMcfg (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -735,10 +734,10 @@ ParseAcpiMcfg (
VOID
EFIAPI
ParseAcpiPcct (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -756,10 +755,10 @@ ParseAcpiPcct (
VOID
EFIAPI
ParseAcpiPptt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -779,10 +778,10 @@ ParseAcpiPptt (
VOID
EFIAPI
ParseAcpiRsdp (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -803,10 +802,10 @@ ParseAcpiRsdp (
VOID
EFIAPI
ParseAcpiSlit (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -824,10 +823,10 @@ ParseAcpiSlit (
VOID
EFIAPI
ParseAcpiSpcr (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -851,10 +850,10 @@ ParseAcpiSpcr (
VOID
EFIAPI
ParseAcpiSrat (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -872,10 +871,10 @@ ParseAcpiSrat (
VOID
EFIAPI
ParseAcpiSsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
/**
@ -892,10 +891,10 @@ ParseAcpiSsdt (
VOID
EFIAPI
ParseAcpiXsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
#endif // ACPIPARSER_H_

View File

@ -19,14 +19,14 @@
#include "AcpiView.h"
#include "AcpiViewConfig.h"
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
#include "Arm/SbbrValidator.h"
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
#include "Arm/SbbrValidator.h"
#endif
/**
A list of registered ACPI table parsers.
**/
STATIC ACPI_TABLE_PARSER mTableParserList[MAX_ACPI_TABLE_PARSERS];
STATIC ACPI_TABLE_PARSER mTableParserList[MAX_ACPI_TABLE_PARSERS];
/**
Register the ACPI table Parser
@ -46,11 +46,11 @@ STATIC ACPI_TABLE_PARSER mTableParserList[MAX_ACPI_TABLE_PARSERS];
EFI_STATUS
EFIAPI
RegisterParser (
IN UINT32 Signature,
IN PARSE_ACPI_TABLE_PROC ParserProc
IN UINT32 Signature,
IN PARSE_ACPI_TABLE_PROC ParserProc
)
{
UINT32 Index;
UINT32 Index;
if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
return EFI_INVALID_PARAMETER;
@ -70,12 +70,12 @@ RegisterParser (
// Find the first free slot and register the parser
for (Index = 0;
Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
Index++)
Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
Index++)
{
if (mTableParserList[Index].Signature == ACPI_PARSER_SIGNATURE_NULL) {
mTableParserList[Index].Signature = Signature;
mTableParserList[Index].Parser = ParserProc;
mTableParserList[Index].Parser = ParserProc;
return EFI_SUCCESS;
}
}
@ -98,10 +98,10 @@ RegisterParser (
EFI_STATUS
EFIAPI
DeregisterParser (
IN UINT32 Signature
IN UINT32 Signature
)
{
UINT32 Index;
UINT32 Index;
if (Signature == ACPI_PARSER_SIGNATURE_NULL) {
return EFI_INVALID_PARAMETER;
@ -113,7 +113,7 @@ DeregisterParser (
{
if (Signature == mTableParserList[Index].Signature) {
mTableParserList[Index].Signature = ACPI_PARSER_SIGNATURE_NULL;
mTableParserList[Index].Parser = NULL;
mTableParserList[Index].Parser = NULL;
return EFI_SUCCESS;
}
}
@ -138,11 +138,11 @@ DeregisterParser (
EFI_STATUS
EFIAPI
GetParser (
IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC * ParserProc
IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC *ParserProc
)
{
UINT32 Index;
UINT32 Index;
if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
return EFI_INVALID_PARAMETER;
@ -179,16 +179,16 @@ GetParser (
VOID
EFIAPI
ProcessAcpiTable (
IN UINT8* Ptr
IN UINT8 *Ptr
)
{
EFI_STATUS Status;
BOOLEAN Trace;
CONST UINT32* AcpiTableSignature;
CONST UINT32* AcpiTableLength;
CONST UINT8* AcpiTableRevision;
CONST UINT8* SignaturePtr;
PARSE_ACPI_TABLE_PROC ParserProc;
EFI_STATUS Status;
BOOLEAN Trace;
CONST UINT32 *AcpiTableSignature;
CONST UINT32 *AcpiTableLength;
CONST UINT8 *AcpiTableRevision;
CONST UINT8 *SignaturePtr;
PARSE_ACPI_TABLE_PROC ParserProc;
ParseAcpiHeader (
Ptr,
@ -209,7 +209,7 @@ ProcessAcpiTable (
// 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.
if (*AcpiTableLength < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
SignaturePtr = (CONST UINT8*)AcpiTableSignature;
SignaturePtr = (CONST UINT8 *)AcpiTableSignature;
IncrementErrorCount ();
Print (
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 ()) {
ArmSbbrIncrementTableCount (*AcpiTableSignature);
}
#endif
#endif
Status = GetParser (*AcpiTableSignature, &ParserProc);
if (EFI_ERROR (Status)) {
@ -239,6 +240,7 @@ ProcessAcpiTable (
if (Trace) {
DumpAcpiHeader (Ptr);
}
return;
}

View File

@ -11,11 +11,11 @@
/**
The maximum number of ACPI table parsers.
*/
#define MAX_ACPI_TABLE_PARSERS 32
#define MAX_ACPI_TABLE_PARSERS 32
/** An invalid/NULL signature value.
*/
#define ACPI_PARSER_SIGNATURE_NULL 0
#define ACPI_PARSER_SIGNATURE_NULL 0
/**
A function that parses the ACPI table.
@ -27,9 +27,9 @@
**/
typedef
VOID
(EFIAPI * PARSE_ACPI_TABLE_PROC) (
(EFIAPI *PARSE_ACPI_TABLE_PROC)(
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);
@ -39,10 +39,10 @@ VOID
**/
typedef struct AcpiTableParser {
/// ACPI table signature
UINT32 Signature;
UINT32 Signature;
/// The ACPI table parser function.
PARSE_ACPI_TABLE_PROC Parser;
PARSE_ACPI_TABLE_PROC Parser;
} ACPI_TABLE_PARSER;
/**
@ -63,8 +63,8 @@ typedef struct AcpiTableParser {
EFI_STATUS
EFIAPI
RegisterParser (
IN UINT32 Signature,
IN PARSE_ACPI_TABLE_PROC ParserProc
IN UINT32 Signature,
IN PARSE_ACPI_TABLE_PROC ParserProc
);
/**
@ -81,7 +81,7 @@ RegisterParser (
EFI_STATUS
EFIAPI
DeregisterParser (
IN UINT32 Signature
IN UINT32 Signature
);
/**
@ -101,7 +101,7 @@ DeregisterParser (
VOID
EFIAPI
ProcessAcpiTable (
IN UINT8* Ptr
IN UINT8 *Ptr
);
/**
@ -120,8 +120,8 @@ ProcessAcpiTable (
EFI_STATUS
EFIAPI
GetParser (
IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC * ParserProc
IN UINT32 Signature,
OUT PARSE_ACPI_TABLE_PROC *ParserProc
);
#endif // ACPITABLEPARSER_H_

View File

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

View File

@ -11,17 +11,17 @@
/**
A macro to define the max file name length
**/
#define MAX_FILE_NAME_LEN 128
#define MAX_FILE_NAME_LEN 128
/**
Offset to the RSDP revision from the start of the RSDP
**/
#define RSDP_REVISION_OFFSET 15
#define RSDP_REVISION_OFFSET 15
/**
Offset to the RSDP length from the start of the RSDP
**/
#define RSDP_LENGTH_OFFSET 20
#define RSDP_LENGTH_OFFSET 20
/**
This function resets the ACPI table error counter to Zero.
@ -71,7 +71,7 @@ GetWarningCount (
BOOLEAN
ProcessTableReportOptions (
IN CONST UINT32 Signature,
IN CONST UINT8* TablePtr,
IN CONST UINT8 *TablePtr,
IN CONST UINT32 Length
);
@ -88,7 +88,7 @@ ProcessTableReportOptions (
EFI_STATUS
EFIAPI
AcpiView (
IN EFI_SYSTEM_TABLE* SystemTable
IN EFI_SYSTEM_TABLE *SystemTable
);
#endif // ACPIVIEW_H_

View File

@ -11,14 +11,14 @@
#include "AcpiViewConfig.h"
// Report variables
STATIC BOOLEAN mConsistencyCheck;
STATIC BOOLEAN mColourHighlighting;
STATIC EREPORT_OPTION mReportType;
STATIC BOOLEAN mMandatoryTableValidate;
STATIC UINTN mMandatoryTableSpec;
STATIC BOOLEAN mConsistencyCheck;
STATIC BOOLEAN mColourHighlighting;
STATIC EREPORT_OPTION mReportType;
STATIC BOOLEAN mMandatoryTableValidate;
STATIC UINTN mMandatoryTableSpec;
// User selection of which ACPI table should be checked
SELECTED_ACPI_TABLE mSelectedAcpiTable;
SELECTED_ACPI_TABLE mSelectedAcpiTable;
/**
Reset the AcpiView user configuration to defaults
@ -29,13 +29,13 @@ AcpiConfigSetDefaults (
VOID
)
{
mReportType = ReportAll;
mSelectedAcpiTable.Type = 0;
mSelectedAcpiTable.Name = NULL;
mReportType = ReportAll;
mSelectedAcpiTable.Type = 0;
mSelectedAcpiTable.Name = NULL;
mSelectedAcpiTable.Found = FALSE;
mConsistencyCheck = TRUE;
mMandatoryTableValidate = FALSE;
mMandatoryTableSpec = 0;
mConsistencyCheck = TRUE;
mMandatoryTableValidate = FALSE;
mMandatoryTableSpec = 0;
}
/**
@ -49,25 +49,27 @@ AcpiConfigSetDefaults (
STATIC
UINT32
ConvertStrToAcpiSignature (
IN CONST CHAR16 *Str
IN CONST CHAR16 *Str
)
{
UINT8 Index;
CHAR8 Ptr[4];
UINT8 Index;
CHAR8 Ptr[4];
ZeroMem (Ptr, sizeof (Ptr));
Index = 0;
// Convert to Upper case and convert to ASCII
while ((Index < 4) && (Str[Index] != 0)) {
if (Str[Index] >= L'a' && Str[Index] <= L'z') {
if ((Str[Index] >= L'a') && (Str[Index] <= L'z')) {
Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
} else {
Ptr[Index] = (CHAR8)Str[Index];
}
Index++;
}
return *(UINT32 *) Ptr;
return *(UINT32 *)Ptr;
}
/**
@ -80,7 +82,7 @@ ConvertStrToAcpiSignature (
VOID
EFIAPI
SelectAcpiTable (
IN CONST CHAR16 *TableName
IN CONST CHAR16 *TableName
)
{
ASSERT (TableName != NULL);
@ -97,7 +99,7 @@ SelectAcpiTable (
VOID
EFIAPI
GetSelectedAcpiTable (
OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
)
{
*SelectedAcpiTable = &mSelectedAcpiTable;
@ -125,7 +127,7 @@ GetColourHighlighting (
VOID
EFIAPI
SetColourHighlighting (
BOOLEAN Highlight
BOOLEAN Highlight
)
{
mColourHighlighting = Highlight;
@ -153,7 +155,7 @@ GetConsistencyChecking (
VOID
EFIAPI
SetConsistencyChecking (
BOOLEAN ConsistencyChecking
BOOLEAN ConsistencyChecking
)
{
mConsistencyCheck = ConsistencyChecking;
@ -181,7 +183,7 @@ GetReportOption (
VOID
EFIAPI
SetReportOption (
EREPORT_OPTION ReportType
EREPORT_OPTION ReportType
)
{
mReportType = ReportType;
@ -209,7 +211,7 @@ GetMandatoryTableValidate (
VOID
EFIAPI
SetMandatoryTableValidate (
BOOLEAN Validate
BOOLEAN Validate
)
{
mMandatoryTableValidate = Validate;
@ -239,7 +241,7 @@ GetMandatoryTableSpec (
VOID
EFIAPI
SetMandatoryTableSpec (
UINTN Spec
UINTN Spec
)
{
mMandatoryTableSpec = Spec;

View File

@ -27,7 +27,7 @@ GetColourHighlighting (
VOID
EFIAPI
SetColourHighlighting (
BOOLEAN Highlight
BOOLEAN Highlight
);
/**
@ -49,7 +49,7 @@ GetConsistencyChecking (
VOID
EFIAPI
SetConsistencyChecking (
BOOLEAN ConsistencyChecking
BOOLEAN ConsistencyChecking
);
/**
@ -71,7 +71,7 @@ GetMandatoryTableValidate (
VOID
EFIAPI
SetMandatoryTableValidate (
BOOLEAN Validate
BOOLEAN Validate
);
/**
@ -95,7 +95,7 @@ GetMandatoryTableSpec (
VOID
EFIAPI
SetMandatoryTableSpec (
UINTN Spec
UINTN Spec
);
/**
@ -128,7 +128,7 @@ GetReportOption (
VOID
EFIAPI
SetReportOption (
EREPORT_OPTION ReportType
EREPORT_OPTION ReportType
);
/**
@ -136,9 +136,9 @@ SetReportOption (
ACPI table is to be examined by the AcpiView code.
**/
typedef struct {
UINT32 Type; ///< 32bit signature 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.
UINT32 Type; ///< 32bit signature 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.
} SELECTED_ACPI_TABLE;
/**
@ -149,7 +149,7 @@ typedef struct {
VOID
EFIAPI
GetSelectedAcpiTable (
OUT SELECTED_ACPI_TABLE** SelectedAcpiTable
OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
);
/**
@ -162,7 +162,7 @@ GetSelectedAcpiTable (
VOID
EFIAPI
SelectAcpiTable (
CONST CHAR16* TableName
CONST CHAR16 *TableName
);
/**

View File

@ -23,7 +23,7 @@
/**
SBBR specification version strings
**/
STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] = {
STATIC CONST CHAR8 *ArmSbbrVersions[ArmSbbrVersionMax] = {
"1.0", // ArmSbbrVersion_1_0
"1.1", // ArmSbbrVersion_1_1
"1.2" // ArmSbbrVersion_1_2
@ -32,7 +32,7 @@ STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] = {
/**
SBBR 1.0 mandatory ACPI tables
**/
STATIC CONST UINT32 ArmSbbr10Mandatory[] = {
STATIC CONST UINT32 ArmSbbr10Mandatory[] = {
EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
@ -45,7 +45,7 @@ STATIC CONST UINT32 ArmSbbr10Mandatory[] = {
/**
SBBR 1.1 mandatory ACPI tables
**/
STATIC CONST UINT32 ArmSbbr11Mandatory[] = {
STATIC CONST UINT32 ArmSbbr11Mandatory[] = {
EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
@ -59,7 +59,7 @@ STATIC CONST UINT32 ArmSbbr11Mandatory[] = {
/**
SBBR 1.2 mandatory ACPI tables
**/
STATIC CONST UINT32 ArmSbbr12Mandatory[] = {
STATIC CONST UINT32 ArmSbbr12Mandatory[] = {
EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
@ -74,7 +74,7 @@ STATIC CONST UINT32 ArmSbbr12Mandatory[] = {
/**
Mandatory ACPI tables for every SBBR specification version.
**/
STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = {
STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = {
{ ArmSbbr10Mandatory, ARRAY_SIZE (ArmSbbr10Mandatory) }, // SBBR v1.0
{ ArmSbbr11Mandatory, ARRAY_SIZE (ArmSbbr11Mandatory) }, // SBBR v1.1
{ ArmSbbr12Mandatory, ARRAY_SIZE (ArmSbbr12Mandatory) } // SBBR v1.2
@ -84,16 +84,16 @@ STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = {
Data structure to track instance counts for all ACPI tables which are
defined as 'mandatory' in any SBBR version.
**/
STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = {
{EFI_ACPI_6_3_EXTENDED_SYSTEM_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_MULTIPLE_APIC_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_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_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0}
STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = {
{ EFI_ACPI_6_3_EXTENDED_SYSTEM_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_MULTIPLE_APIC_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_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_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0 }
};
/**
@ -105,7 +105,7 @@ ArmSbbrResetTableCounts (
VOID
)
{
UINT32 Table;
UINT32 Table;
for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) {
ArmSbbrTableCounts[Table].Count = 0;
@ -124,10 +124,10 @@ ArmSbbrResetTableCounts (
BOOLEAN
EFIAPI
ArmSbbrIncrementTableCount (
UINT32 Signature
UINT32 Signature
)
{
UINT32 Table;
UINT32 Table;
for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) {
if (Signature == ArmSbbrTableCounts[Table].Signature) {
@ -154,14 +154,14 @@ ArmSbbrIncrementTableCount (
EFI_STATUS
EFIAPI
ArmSbbrReqsValidate (
ARM_SBBR_VERSION Version
ARM_SBBR_VERSION Version
)
{
UINT32 Table;
UINT32 Index;
UINT32 MandatoryTable;
CONST UINT8* SignaturePtr;
BOOLEAN IsArmSbbrViolated;
UINT32 Table;
UINT32 Index;
UINT32 MandatoryTable;
CONST UINT8 *SignaturePtr;
BOOLEAN IsArmSbbrViolated;
if (Version >= ArmSbbrVersionMax) {
return EFI_INVALID_PARAMETER;
@ -172,12 +172,13 @@ ArmSbbrReqsValidate (
// Go through the list of mandatory tables for the input SBBR version
for (Table = 0; Table < ArmSbbrReqs[Version].TableCount; 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
Index = 0;
while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) &&
(ArmSbbrTableCounts[Index].Signature != MandatoryTable)) {
(ArmSbbrTableCounts[Index].Signature != MandatoryTable))
{
Index++;
}
@ -185,7 +186,7 @@ ArmSbbrReqsValidate (
IncrementErrorCount ();
Print (
L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table's instance count not " \
L"found\n",
L"found\n",
ArmSbbrVersions[Version],
SignaturePtr[0],
SignaturePtr[1],

View File

@ -24,26 +24,26 @@
Arm SBBR specification versions.
**/
typedef enum {
ArmSbbrVersion_1_0 = 0,
ArmSbbrVersion_1_1 = 1,
ArmSbbrVersion_1_2 = 2,
ArmSbbrVersionMax = 3
ArmSbbrVersion_1_0 = 0,
ArmSbbrVersion_1_1 = 1,
ArmSbbrVersion_1_2 = 2,
ArmSbbrVersionMax = 3
} ARM_SBBR_VERSION;
/**
The ACPI table instance counter.
**/
typedef struct AcpiTableCounter {
CONST UINT32 Signature; /// ACPI table signature
UINT32 Count; /// Instance count
CONST UINT32 Signature; /// ACPI table signature
UINT32 Count; /// Instance count
} ACPI_TABLE_COUNTER;
/**
ACPI table SBBR requirements.
**/
typedef struct AcpiSbbrReq {
CONST UINT32* Tables; /// List of required tables
CONST UINT32 TableCount; /// Number of elements in Tables
CONST UINT32 *Tables; /// List of required tables
CONST UINT32 TableCount; /// Number of elements in Tables
} ACPI_SBBR_REQ;
/**
@ -67,7 +67,7 @@ ArmSbbrResetTableCounts (
BOOLEAN
EFIAPI
ArmSbbrIncrementTableCount (
UINT32 Signature
UINT32 Signature
);
/**
@ -85,7 +85,7 @@ ArmSbbrIncrementTableCount (
EFI_STATUS
EFIAPI
ArmSbbrReqsValidate (
ARM_SBBR_VERSION Version
ARM_SBBR_VERSION Version
);
#endif // SBBR_VALIDATOR_H_

View File

@ -18,16 +18,16 @@
#include "AcpiViewConfig.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC UINT8* AestNodeType;
STATIC UINT16* AestNodeLength;
STATIC UINT32* NodeDataOffset;
STATIC UINT32* NodeInterfaceOffset;
STATIC UINT32* NodeInterruptArrayOffset;
STATIC UINT32* NodeInterruptCount;
STATIC UINT32* ProcessorId;
STATIC UINT8* ProcessorFlags;
STATIC UINT8* ProcessorResourceType;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC UINT8 *AestNodeType;
STATIC UINT16 *AestNodeLength;
STATIC UINT32 *NodeDataOffset;
STATIC UINT32 *NodeInterfaceOffset;
STATIC UINT32 *NodeInterruptArrayOffset;
STATIC UINT32 *NodeInterruptCount;
STATIC UINT32 *ProcessorId;
STATIC UINT8 *ProcessorFlags;
STATIC UINT8 *ProcessorResourceType;
/**
Validate Processor Flags.
@ -40,16 +40,18 @@ STATIC
VOID
EFIAPI
ValidateProcessorFlags (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// If the global or shared node flag is set then the ACPI Processor ID
// field must be set to 0 and ignored.
if (((*Ptr & 0x3) != 0) && (*ProcessorId != 0)) {
IncrementErrorCount ();
Print (L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
L" or shared nodes.");
Print (
L"\nERROR: 'ACPI Processor ID' field must be set to 0 for global"
L" or shared nodes."
);
}
}
@ -64,13 +66,13 @@ STATIC
VOID
EFIAPI
ValidateGicInterfaceType (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT32 GicInterfaceType;
UINT32 GicInterfaceType;
GicInterfaceType = *(UINT32*)Ptr;
GicInterfaceType = *(UINT32 *)Ptr;
if (GicInterfaceType > 3) {
IncrementErrorCount ();
Print (L"\nError: Invalid GIC Interface type %d", GicInterfaceType);
@ -88,8 +90,8 @@ STATIC
VOID
EFIAPI
ValidateInterfaceType (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*Ptr > 1) {
@ -109,8 +111,8 @@ STATIC
VOID
EFIAPI
ValidateInterruptType (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*Ptr > 1) {
@ -130,8 +132,8 @@ STATIC
VOID
EFIAPI
ValidateInterruptFlags (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if ((*Ptr & 0xfe) != 0) {
@ -149,8 +151,8 @@ ValidateInterruptFlags (
VOID
EFIAPI
DumpVendorSpecificData (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
Print (
@ -183,27 +185,27 @@ DumpVendorSpecificData (
/**
An ACPI_PARSER array describing the ACPI AEST Table.
**/
STATIC CONST ACPI_PARSER AestParser[] = {
STATIC CONST ACPI_PARSER AestParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
/**
An ACPI_PARSER array describing the AEST Node Header.
**/
STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
{L"Type", 1, 0, L"%d", NULL, (VOID**)&AestNodeType, 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"Node Data Offset", 4, 4, L"%d", NULL, (VOID**)&NodeDataOffset, NULL, NULL},
{L"Node Interface Offset", 4, 8, L"%d", NULL,
(VOID**)&NodeInterfaceOffset, NULL, NULL},
{L"Node Interrupt Array Offset", 4, 12, L"%d", NULL,
(VOID**)&NodeInterruptArrayOffset, NULL, NULL},
{L"Node Interrupt Count", 4, 16, L"%d", NULL,
(VOID**)&NodeInterruptCount, 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"Error Injection Countdown Rate", 8, 36, L"%ld", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
{ L"Type", 1, 0, L"%d", NULL, (VOID **)&AestNodeType, 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"Node Data Offset", 4, 4, L"%d", NULL, (VOID **)&NodeDataOffset, NULL, NULL },
{ L"Node Interface Offset", 4, 8, L"%d", NULL,
(VOID **)&NodeInterfaceOffset, NULL, NULL },
{ L"Node Interrupt Array Offset", 4, 12, L"%d", NULL,
(VOID **)&NodeInterruptArrayOffset, NULL, NULL },
{ L"Node Interrupt Count", 4, 16, L"%d", NULL,
(VOID **)&NodeInterruptCount, 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"Error Injection Countdown Rate", 8, 36, L"%ld", NULL, NULL, NULL, NULL }
// Node specific data...
// Node interface...
// Node interrupt array...
@ -212,100 +214,100 @@ STATIC CONST ACPI_PARSER AestNodeHeaderParser[] = {
/**
An ACPI_PARSER array describing the Processor error node specific data.
**/
STATIC CONST ACPI_PARSER AestProcessorStructure[] = {
{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,
NULL},
{L"Reserved", 1, 5, L"0x%x", NULL, NULL, NULL, NULL},
{L"Flags", 1, 6, L"0x%x", NULL, (VOID**)&ProcessorFlags,
ValidateProcessorFlags, NULL},
{L"Revision", 1, 7, L"%d", NULL, NULL, NULL, NULL},
{L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL, NULL,
NULL},
STATIC CONST ACPI_PARSER AestProcessorStructure[] = {
{ 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,
NULL },
{ L"Reserved", 1, 5, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 1, 6, L"0x%x", NULL, (VOID **)&ProcessorFlags,
ValidateProcessorFlags, NULL },
{ L"Revision", 1, 7, L"%d", NULL, NULL, NULL, NULL },
{ L"Processor Affinity Level Indicator", 8, 8, L"0x%lx", NULL, NULL, NULL,
NULL },
// Resource specific data...
};
/**
An ACPI_PARSER array describing the processor cache resource substructure.
**/
STATIC CONST ACPI_PARSER AestProcessorCacheResourceSubstructure[] = {
{L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestProcessorCacheResourceSubstructure[] = {
{ L"Cache reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the processor TLB resource substructure.
**/
STATIC CONST ACPI_PARSER AestProcessorTlbResourceSubstructure[] = {
{L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestProcessorTlbResourceSubstructure[] = {
{ L"TLB reference ID", 4, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 4, 4, L"%d", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the processor generic resource substructure.
**/
STATIC CONST ACPI_PARSER AestProcessorGenericResourceSubstructure[] = {
{L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestProcessorGenericResourceSubstructure[] = {
{ L"Vendor-defined data", 4, 0, L"%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the memory controller structure.
**/
STATIC CONST ACPI_PARSER AestMemoryControllerStructure[] = {
{L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestMemoryControllerStructure[] = {
{ L"Proximity Domain", 4, 0, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the SMMU structure.
**/
STATIC CONST ACPI_PARSER AestSmmuStructure[] = {
{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}
STATIC CONST ACPI_PARSER AestSmmuStructure[] = {
{ 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 }
};
/**
An ACPI_PARSER array describing the vendor-defined structure.
**/
STATIC CONST ACPI_PARSER AestVendorDefinedStructure[] = {
{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"Vendor-specific data", 16, 8, NULL, DumpVendorSpecificData, NULL, NULL}
STATIC CONST ACPI_PARSER AestVendorDefinedStructure[] = {
{ 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"Vendor-specific data", 16, 8, NULL, DumpVendorSpecificData, NULL, NULL }
};
/**
An ACPI_PARSER array describing the GIC structure.
**/
STATIC CONST ACPI_PARSER AestGicStructure[] = {
{L"GIC Interface Type", 4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType,
NULL},
{L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestGicStructure[] = {
{ L"GIC Interface Type", 4, 0, L"0x%x", NULL, NULL, ValidateGicInterfaceType,
NULL },
{ L"GIC Interface reference ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
};
/**
An ACPI_PARSER array describing the node interface.
**/
STATIC CONST ACPI_PARSER AestNodeInterface[] = {
{L"Interface Type", 1, 0, L"%d", NULL, NULL, ValidateInterfaceType, 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"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"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 Support", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Addressing mode", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER AestNodeInterface[] = {
{ L"Interface Type", 1, 0, L"%d", NULL, NULL, ValidateInterfaceType, 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"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"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 Support", 8, 32, 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.
**/
STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
{L"Interrupt Type", 1, 0, L"%d", NULL, NULL, ValidateInterruptType, 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 GSIV", 4, 4, 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}
STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
{ L"Interrupt Type", 1, 0, L"%d", NULL, NULL, ValidateInterruptType, 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 GSIV", 4, 4, 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 }
};
/**
@ -318,11 +320,11 @@ STATIC CONST ACPI_PARSER AestNodeInterrupt[] = {
STATIC
VOID
DumpProcessorNode (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT32 Offset;
UINT32 Offset;
Offset = ParseAcpi (
TRUE,
@ -337,7 +339,8 @@ DumpProcessorNode (
// successfully read.
if ((ProcessorId == NULL) ||
(ProcessorResourceType == NULL) ||
(ProcessorFlags == NULL)) {
(ProcessorFlags == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient Processor Error Node length. Length = %d.\n",
@ -393,8 +396,8 @@ DumpProcessorNode (
STATIC
VOID
DumpMemoryControllerNode (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -416,8 +419,8 @@ DumpMemoryControllerNode (
STATIC
VOID
DumpSmmuNode (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -439,8 +442,8 @@ DumpSmmuNode (
STATIC
VOID
DumpVendorDefinedNode (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -462,8 +465,8 @@ DumpVendorDefinedNode (
STATIC
VOID
DumpGicNode (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -485,8 +488,8 @@ DumpGicNode (
STATIC
VOID
DumpNodeInterface (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -509,19 +512,19 @@ DumpNodeInterface (
STATIC
VOID
DumpNodeInterrupts (
IN UINT8* Ptr,
IN UINT32 Length,
IN UINT32 InterruptCount
IN UINT8 *Ptr,
IN UINT32 Length,
IN UINT32 InterruptCount
)
{
UINT32 Offset;
UINT32 Index;
CHAR8 Buffer[64];
UINT32 Offset;
UINT32 Index;
CHAR8 Buffer[64];
if (Length < (InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT))) {
IncrementErrorCount ();
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",
Length,
(InterruptCount * sizeof (EFI_ACPI_AEST_INTERRUPT_STRUCT)),
@ -547,7 +550,7 @@ DumpNodeInterrupts (
Length - Offset,
PARSER_PARAMS (AestNodeInterrupt)
);
} //for
} // for
}
/**
@ -564,7 +567,7 @@ DumpNodeInterrupts (
STATIC
VOID
DumpAestNodeStructure (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT32 Length,
IN UINT8 NodeType,
IN UINT32 DataOffset,
@ -573,9 +576,9 @@ DumpAestNodeStructure (
IN UINT32 InterruptCount
)
{
UINT32 Offset;
UINT32 RemainingLength;
UINT8* NodeDataPtr;
UINT32 Offset;
UINT32 RemainingLength;
UINT8 *NodeDataPtr;
Offset = ParseAcpi (
TRUE,
@ -589,7 +592,7 @@ DumpAestNodeStructure (
if ((Offset > DataOffset) || (DataOffset > Length)) {
IncrementErrorCount ();
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",
DataOffset,
Offset,
@ -600,7 +603,7 @@ DumpAestNodeStructure (
if ((Offset > InterfaceOffset) || (InterfaceOffset > Length)) {
IncrementErrorCount ();
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",
InterfaceOffset,
Offset,
@ -611,7 +614,7 @@ DumpAestNodeStructure (
if ((Offset > InterruptArrayOffset) || (InterruptArrayOffset > Length)) {
IncrementErrorCount ();
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",
InterruptArrayOffset,
Offset,
@ -620,7 +623,7 @@ DumpAestNodeStructure (
}
// Parse Node Data Field.
NodeDataPtr = Ptr + DataOffset;
NodeDataPtr = Ptr + DataOffset;
RemainingLength = Length - DataOffset;
switch (NodeType) {
case EFI_ACPI_AEST_NODE_TYPE_PROCESSOR:
@ -675,14 +678,14 @@ DumpAestNodeStructure (
VOID
EFIAPI
ParseAcpiAest (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* NodePtr;
UINT8 *NodePtr;
if (!Trace) {
return;
@ -716,10 +719,11 @@ ParseAcpiAest (
(NodeDataOffset == NULL) ||
(NodeInterfaceOffset == NULL) ||
(NodeInterruptArrayOffset == NULL) ||
(NodeInterruptCount == NULL)) {
(NodeInterruptCount == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient length left for Node Structure.\n"\
L"ERROR: Insufficient length left for Node Structure.\n" \
L" Length left = %d.\n",
AcpiTableLength - Offset
);
@ -728,11 +732,12 @@ ParseAcpiAest (
// Validate AEST Node length
if ((*AestNodeLength == 0) ||
((Offset + (*AestNodeLength)) > AcpiTableLength)) {
((Offset + (*AestNodeLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid AEST Node length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*AestNodeLength,
Offset,
AcpiTableLength

View File

@ -14,19 +14,19 @@
#include "AcpiTableParser.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
An ACPI_PARSER array describing the ACPI BDRT Table.
**/
STATIC CONST ACPI_PARSER BgrtParser[] = {
STATIC CONST ACPI_PARSER BgrtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Version", 2, 36, 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 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 Y", 4, 52, L"%d", 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"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 Offset X", 4, 48, L"%d", NULL, NULL, NULL, NULL },
{ L"Image Offset Y", 4, 52, L"%d", NULL, NULL, NULL, NULL }
};
/**
@ -44,10 +44,10 @@ STATIC CONST ACPI_PARSER BgrtParser[] = {
VOID
EFIAPI
ParseAcpiBgrt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {

View File

@ -14,17 +14,17 @@
#include "AcpiTableParser.h"
// Local variables pointing to the table fields
STATIC CONST UINT32* OffsetDbgDeviceInfo;
STATIC CONST UINT32* NumberDbgDeviceInfo;
STATIC CONST UINT16* DbgDevInfoLen;
STATIC CONST UINT8* GasCount;
STATIC CONST UINT16* NameSpaceStringLength;
STATIC CONST UINT16* NameSpaceStringOffset;
STATIC CONST UINT16* OEMDataLength;
STATIC CONST UINT16* OEMDataOffset;
STATIC CONST UINT16* BaseAddrRegOffset;
STATIC CONST UINT16* AddrSizeOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT32 *OffsetDbgDeviceInfo;
STATIC CONST UINT32 *NumberDbgDeviceInfo;
STATIC CONST UINT16 *DbgDevInfoLen;
STATIC CONST UINT8 *GasCount;
STATIC CONST UINT16 *NameSpaceStringLength;
STATIC CONST UINT16 *NameSpaceStringOffset;
STATIC CONST UINT16 *OEMDataLength;
STATIC CONST UINT16 *OEMDataOffset;
STATIC CONST UINT16 *BaseAddrRegOffset;
STATIC CONST UINT16 *AddrSizeOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the NameSpace string length.
@ -37,64 +37,64 @@ STATIC
VOID
EFIAPI
ValidateNameSpaceStrLen (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT16 NameSpaceStrLen;
UINT16 NameSpaceStrLen;
NameSpaceStrLen = *(UINT16*)Ptr;
NameSpaceStrLen = *(UINT16 *)Ptr;
if (NameSpaceStrLen < 2) {
IncrementErrorCount ();
Print (
L"\nERROR: NamespaceString Length = %d. If no Namespace device exists, " \
L"NamespaceString[] must contain a period '.'",
L"NamespaceString[] must contain a period '.'",
NameSpaceStrLen
);
}
}
/// An ACPI_PARSER array describing the ACPI DBG2 table.
STATIC CONST ACPI_PARSER Dbg2Parser[] = {
STATIC CONST ACPI_PARSER Dbg2Parser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"OffsetDbgDeviceInfo", 4, 36, L"0x%x", NULL,
(VOID**)&OffsetDbgDeviceInfo, NULL, NULL},
{L"NumberDbgDeviceInfo", 4, 40, L"%d", NULL,
(VOID**)&NumberDbgDeviceInfo, NULL, NULL}
{ L"OffsetDbgDeviceInfo", 4, 36, L"0x%x", NULL,
(VOID **)&OffsetDbgDeviceInfo, NULL, NULL },
{ L"NumberDbgDeviceInfo", 4, 40, L"%d", NULL,
(VOID **)&NumberDbgDeviceInfo, NULL, NULL }
};
/// An ACPI_PARSER array describing the debug device information structure
/// header.
STATIC CONST ACPI_PARSER DbgDevInfoHeaderParser[] = {
{L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 2, 1, L"%d", NULL, (VOID**)&DbgDevInfoLen, NULL, NULL}
STATIC CONST ACPI_PARSER DbgDevInfoHeaderParser[] = {
{ L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 2, 1, L"%d", NULL, (VOID **)&DbgDevInfoLen, NULL, NULL }
};
/// An ACPI_PARSER array describing the debug device information.
STATIC CONST ACPI_PARSER DbgDevInfoParser[] = {
{L"Revision", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER DbgDevInfoParser[] = {
{ L"Revision", 1, 0, L"0x%x", 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,
(VOID**)&GasCount, NULL, NULL},
{L"NameSpace String Length", 2, 4, L"%d", NULL,
(VOID**)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL},
{L"NameSpace String Offset", 2, 6, L"0x%x", NULL,
(VOID**)&NameSpaceStringOffset, NULL, NULL},
{L"OEM Data Length", 2, 8, L"%d", NULL, (VOID**)&OEMDataLength,
NULL, NULL},
{L"OEM Data Offset", 2, 10, L"0x%x", NULL, (VOID**)&OEMDataOffset,
NULL, NULL},
{ L"Generic Address Registers Count", 1, 3, L"0x%x", NULL,
(VOID **)&GasCount, NULL, NULL },
{ L"NameSpace String Length", 2, 4, L"%d", NULL,
(VOID **)&NameSpaceStringLength, ValidateNameSpaceStrLen, NULL },
{ L"NameSpace String Offset", 2, 6, L"0x%x", NULL,
(VOID **)&NameSpaceStringOffset, NULL, NULL },
{ L"OEM Data Length", 2, 8, L"%d", NULL, (VOID **)&OEMDataLength,
NULL, NULL },
{ L"OEM Data Offset", 2, 10, L"0x%x", NULL, (VOID **)&OEMDataOffset,
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"Reserved", 2, 16, L"%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"Reserved", 2, 16, L"%x", NULL, NULL, NULL, NULL },
{L"Base Address Register Offset", 2, 18, L"0x%x", NULL,
(VOID**)&BaseAddrRegOffset, NULL, NULL},
{L"Address Size Offset", 2, 20, L"0x%x", NULL,
(VOID**)&AddrSizeOffset, NULL, NULL}
{ L"Base Address Register Offset", 2, 18, L"0x%x", NULL,
(VOID **)&BaseAddrRegOffset, NULL, NULL },
{ L"Address Size Offset", 2, 20, L"0x%x", NULL,
(VOID **)&AddrSizeOffset, NULL, NULL }
};
/**
@ -107,8 +107,8 @@ STATIC
VOID
EFIAPI
DumpDbgDeviceInfo (
IN UINT8* Ptr,
IN UINT16 Length
IN UINT8 *Ptr,
IN UINT16 Length
)
{
UINT16 Index;
@ -131,21 +131,23 @@ DumpDbgDeviceInfo (
(OEMDataLength == NULL) ||
(OEMDataOffset == NULL) ||
(BaseAddrRegOffset == NULL) ||
(AddrSizeOffset == NULL)) {
(AddrSizeOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient Debug Device Information Structure length. " \
L"Length = %d.\n",
L"Length = %d.\n",
Length
);
return;
}
// GAS
Index = 0;
Index = 0;
Offset = *BaseAddrRegOffset;
while ((Index++ < *GasCount) &&
(Offset < Length)) {
(Offset < Length))
{
PrintFieldName (4, L"BaseAddressRegister");
Offset += (UINT16)DumpGasStruct (
Ptr + Offset,
@ -160,7 +162,7 @@ DumpDbgDeviceInfo (
IncrementErrorCount ();
Print (
L"ERROR: Invalid GAS count. GasCount = %d. RemainingBufferLength = %d. " \
L"Parsing of the Debug Device Information structure aborted.\n",
L"Parsing of the Debug Device Information structure aborted.\n",
*GasCount,
Length - *AddrSizeOffset
);
@ -168,39 +170,45 @@ DumpDbgDeviceInfo (
}
// Address Size
Index = 0;
Index = 0;
Offset = *AddrSizeOffset;
while ((Index++ < *GasCount) &&
(Offset < Length)) {
(Offset < Length))
{
PrintFieldName (4, L"Address Size");
Print (L"0x%x\n", *((UINT32*)(Ptr + Offset)));
Print (L"0x%x\n", *((UINT32 *)(Ptr + Offset)));
Offset += sizeof (UINT32);
}
// NameSpace String
Index = 0;
Index = 0;
Offset = *NameSpaceStringOffset;
PrintFieldName (4, L"NameSpace String");
while ((Index++ < *NameSpaceStringLength) &&
(Offset < Length)) {
(Offset < Length))
{
Print (L"%c", *(Ptr + Offset));
Offset++;
}
Print (L"\n");
// OEM Data
if (*OEMDataOffset != 0) {
Index = 0;
Index = 0;
Offset = *OEMDataOffset;
PrintFieldName (4, L"OEM Data");
while ((Index++ < *OEMDataLength) &&
(Offset < Length)) {
(Offset < Length))
{
Print (L"%x ", *(Ptr + Offset));
if ((Index & 7) == 0) {
Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L"");
}
Offset++;
}
Print (L"\n");
}
}
@ -220,14 +228,14 @@ DumpDbgDeviceInfo (
VOID
EFIAPI
ParseAcpiDbg2 (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT32 Index;
UINT32 Offset;
UINT32 Index;
if (!Trace) {
return;
@ -245,7 +253,8 @@ ParseAcpiDbg2 (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((OffsetDbgDeviceInfo == NULL) ||
(NumberDbgDeviceInfo == NULL)) {
(NumberDbgDeviceInfo == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d\n",
@ -255,10 +264,9 @@ ParseAcpiDbg2 (
}
Offset = *OffsetDbgDeviceInfo;
Index = 0;
Index = 0;
while (Index++ < *NumberDbgDeviceInfo) {
// Parse the Debug Device Information Structure header to obtain Length
ParseAcpi (
FALSE,
@ -275,8 +283,8 @@ ParseAcpiDbg2 (
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"Debug Device Information structure's 'Length' field. " \
L"RemainingTableBufferLength = %d.\n",
L"Debug Device Information structure's 'Length' field. " \
L"RemainingTableBufferLength = %d.\n",
AcpiTableLength - Offset
);
return;
@ -284,11 +292,12 @@ ParseAcpiDbg2 (
// Validate Debug Device Information Structure length
if ((*DbgDevInfoLen == 0) ||
((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) {
((Offset + (*DbgDevInfoLen)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Debug Device Information Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*DbgDevInfoLen,
Offset,
AcpiTableLength

View File

@ -28,10 +28,10 @@
VOID
EFIAPI
ParseAcpiDsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {

View File

@ -16,23 +16,23 @@
/**
An ACPI_PARSER array describing the ACPI FACS Table.
**/
STATIC CONST ACPI_PARSER FacsParser[] = {
{L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, 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"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"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"Version", 1, 32, L"%d", NULL, 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"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL},
{L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL},
{L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL}
STATIC CONST ACPI_PARSER FacsParser[] = {
{ L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, 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"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"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"Version", 1, 32, L"%d", NULL, 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"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL },
{ L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL },
{ L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL,
NULL }
};
/**
@ -50,10 +50,10 @@ STATIC CONST ACPI_PARSER FacsParser[] = {
VOID
EFIAPI
ParseAcpiFacs (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {

View File

@ -15,33 +15,33 @@
#include "AcpiView.h"
// Local variables
STATIC CONST UINT32* DsdtAddress;
STATIC CONST UINT64* X_DsdtAddress;
STATIC CONST UINT32* Flags;
STATIC CONST UINT32* FirmwareCtrl;
STATIC CONST UINT64* X_FirmwareCtrl;
STATIC CONST UINT8* FadtMinorRevision;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT32 *DsdtAddress;
STATIC CONST UINT64 *X_DsdtAddress;
STATIC CONST UINT32 *Flags;
STATIC CONST UINT32 *FirmwareCtrl;
STATIC CONST UINT64 *X_FirmwareCtrl;
STATIC CONST UINT8 *FadtMinorRevision;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
A macro defining the Hardware reduced ACPI flag
**/
#define HW_REDUCED_ACPI BIT20
#define HW_REDUCED_ACPI BIT20
/**
Offset to the FACS signature from the start of the FACS.
**/
#define FACS_SIGNATURE_OFFSET 0
#define FACS_SIGNATURE_OFFSET 0
/**
Offset to the FACS revision from the start of the FACS.
**/
#define FACS_VERSION_OFFSET 32
#define FACS_VERSION_OFFSET 32
/**
Offset to the FACS length from the start of the FACS.
**/
#define FACS_LENGTH_OFFSET 4
#define FACS_LENGTH_OFFSET 4
/**
Get the ACPI XSDT header info.
@ -63,18 +63,19 @@ STATIC
VOID
EFIAPI
ValidateFirmwareCtrl (
IN UINT8* Ptr,
IN VOID* Context
)
IN UINT8 *Ptr,
IN VOID *Context
)
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT32*)Ptr != 0) {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount ();
Print (
L"\nERROR: Firmware Control must be zero for ARM platforms."
);
);
}
#endif
#endif
}
/**
@ -88,18 +89,19 @@ STATIC
VOID
EFIAPI
ValidateXFirmwareCtrl (
IN UINT8* Ptr,
IN VOID* Context
)
IN UINT8 *Ptr,
IN VOID *Context
)
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT64*)Ptr != 0) {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (*(UINT64 *)Ptr != 0) {
IncrementErrorCount ();
Print (
L"\nERROR: X Firmware Control must be zero for ARM platforms."
);
);
}
#endif
#endif
}
/**
@ -113,83 +115,84 @@ STATIC
VOID
EFIAPI
ValidateFlags (
IN UINT8* Ptr,
IN VOID* Context
)
IN UINT8 *Ptr,
IN VOID *Context
)
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) == 0) {
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (((*(UINT32 *)Ptr) & HW_REDUCED_ACPI) == 0) {
IncrementErrorCount ();
Print (
L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms."
);
);
}
#endif
#endif
}
/**
An ACPI_PARSER array describing the ACPI FADT Table.
**/
STATIC CONST ACPI_PARSER FadtParser[] = {
STATIC CONST ACPI_PARSER FadtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID**)&FirmwareCtrl,
ValidateFirmwareCtrl, NULL},
{L"DSDT", 4, 40, L"0x%x", NULL, (VOID**)&DsdtAddress, 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"SCI_INT", 2, 46, 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_DISABLE", 1, 53, 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"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"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"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"GPE0_BLK", 4, 80, 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_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"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"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"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_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_STRIDE", 2, 102, 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"DAY_ALRM", 1, 106, 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"IAPC_BOOT_ARCH", 2, 109, 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"RESET_REG", 12, 116, NULL, DumpGas, 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"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID**)&FadtMinorRevision,
NULL, NULL},
{L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID**)&X_FirmwareCtrl,
ValidateXFirmwareCtrl, 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_PM1b_EVT_BLK", 12, 160, 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_PM2_CNT_BLK", 12, 196, 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_GPE1_BLK", 12, 232, 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"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL}
{ L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID **)&FirmwareCtrl,
ValidateFirmwareCtrl, NULL },
{ L"DSDT", 4, 40, L"0x%x", NULL, (VOID **)&DsdtAddress, 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"SCI_INT", 2, 46, 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_DISABLE", 1, 53, 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"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"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"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"GPE0_BLK", 4, 80, 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_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"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"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"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_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_STRIDE", 2, 102, 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"DAY_ALRM", 1, 106, 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"IAPC_BOOT_ARCH", 2, 109, 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"RESET_REG", 12, 116, NULL, DumpGas, 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"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID **)&FadtMinorRevision,
NULL, NULL },
{ L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID **)&X_FirmwareCtrl,
ValidateXFirmwareCtrl, 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_PM1b_EVT_BLK", 12, 160, 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_PM2_CNT_BLK", 12, 196, 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_GPE1_BLK", 12, 232, 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"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL }
};
/**
@ -206,19 +209,19 @@ STATIC CONST ACPI_PARSER FadtParser[] = {
VOID
EFIAPI
ParseAcpiFadt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
EFI_STATUS Status;
UINT8* DsdtPtr;
UINT8* FirmwareCtrlPtr;
UINT32 FacsSignature;
UINT32 FacsLength;
UINT8 FacsRevision;
PARSE_ACPI_TABLE_PROC FacsParserProc;
EFI_STATUS Status;
UINT8 *DsdtPtr;
UINT8 *FirmwareCtrlPtr;
UINT32 FacsSignature;
UINT32 FacsLength;
UINT8 FacsRevision;
PARSE_ACPI_TABLE_PROC FacsParserProc;
ParseAcpi (
Trace,
@ -233,7 +236,7 @@ ParseAcpiFadt (
if (FadtMinorRevision != NULL) {
Print (L"\nSummary:\n");
PrintFieldName (2, L"FADT Version");
Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision);
Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision);
}
if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId) {
@ -245,9 +248,9 @@ ParseAcpiFadt (
// If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore
// FIRMWARE_CTRL, else use FIRMWARE_CTRL.
if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) {
FirmwareCtrlPtr = (UINT8*)(UINTN)(*X_FirmwareCtrl);
FirmwareCtrlPtr = (UINT8 *)(UINTN)(*X_FirmwareCtrl);
} else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) {
FirmwareCtrlPtr = (UINT8*)(UINTN)(*FirmwareCtrl);
FirmwareCtrlPtr = (UINT8 *)(UINTN)(*FirmwareCtrl);
} else {
FirmwareCtrlPtr = NULL;
// if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and
@ -255,10 +258,13 @@ ParseAcpiFadt (
// present.
if ((Trace) &&
(Flags != NULL) &&
((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI)) {
((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI))
{
IncrementErrorCount ();
Print (L"ERROR: No FACS table found, "
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n");
Print (
L"ERROR: No FACS table found, "
L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"
);
}
}
@ -266,13 +272,13 @@ ParseAcpiFadt (
// The FACS table does not have a standard ACPI table header. Therefore,
// the signature, length and version needs to be initially parsed.
// 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.
FacsLength = *(UINT32*)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
FacsLength = *(UINT32 *)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
// The FACS version is 1 byte starting at offset 32.
FacsRevision = *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
FacsRevision = *(UINT8 *)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
Trace = ProcessTableReportOptions (
FacsSignature,
@ -298,12 +304,12 @@ ParseAcpiFadt (
// If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
DsdtPtr = (UINT8 *)(UINTN)(*X_DsdtAddress);
} else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
DsdtPtr = (UINT8 *)(UINTN)(*DsdtAddress);
} else {
// 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) {
// The DSDT Table is mandatory for ARM systems
// as the CPU information MUST be presented in
@ -311,7 +317,8 @@ ParseAcpiFadt (
IncrementErrorCount ();
Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
}
#endif
#endif
return;
}

View File

@ -15,16 +15,16 @@
#include "AcpiViewConfig.h"
// "The number of GT Block Timers must be less than or equal to 8"
#define GT_BLOCK_TIMER_COUNT_MAX 8
#define GT_BLOCK_TIMER_COUNT_MAX 8
// Local variables
STATIC CONST UINT32* GtdtPlatformTimerCount;
STATIC CONST UINT32* GtdtPlatformTimerOffset;
STATIC CONST UINT8* PlatformTimerType;
STATIC CONST UINT16* PlatformTimerLength;
STATIC CONST UINT32* GtBlockTimerCount;
STATIC CONST UINT32* GtBlockTimerOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT32 *GtdtPlatformTimerCount;
STATIC CONST UINT32 *GtdtPlatformTimerOffset;
STATIC CONST UINT8 *PlatformTimerType;
STATIC CONST UINT16 *PlatformTimerLength;
STATIC CONST UINT32 *GtBlockTimerCount;
STATIC CONST UINT32 *GtBlockTimerOffset;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the GT Block timer count.
@ -37,13 +37,13 @@ STATIC
VOID
EFIAPI
ValidateGtBlockTimerCount (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT32 BlockTimerCount;
UINT32 BlockTimerCount;
BlockTimerCount = *(UINT32*)Ptr;
BlockTimerCount = *(UINT32 *)Ptr;
if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) {
IncrementErrorCount ();
@ -66,13 +66,13 @@ STATIC
VOID
EFIAPI
ValidateGtFrameNumber (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT8 FrameNumber;
UINT8 FrameNumber;
FrameNumber = *(UINT8*)Ptr;
FrameNumber = *(UINT8 *)Ptr;
if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) {
IncrementErrorCount ();
@ -87,82 +87,82 @@ ValidateGtFrameNumber (
/**
An ACPI_PARSER array describing the ACPI GTDT Table.
**/
STATIC CONST ACPI_PARSER GtdtParser[] = {
STATIC CONST ACPI_PARSER GtdtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"CntControlBase Physical Address", 8, 36, L"0x%lx", 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 FLAGS", 4, 52, L"0x%x", NULL, NULL, NULL, NULL},
{ L"CntControlBase Physical Address",8, 36, L"0x%lx", 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 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 FLAGS", 4, 60, 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"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 GSIV", 4, 64, 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 FLAGS", 4, 76, 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"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Platform Timer Count", 4, 88, L"%d", NULL,
(VOID**)&GtdtPlatformTimerCount, NULL, NULL},
{L"Platform Timer Offset", 4, 92, L"0x%x", NULL,
(VOID**)&GtdtPlatformTimerOffset, 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"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL,NULL, NULL },
{ L"Platform Timer Count", 4, 88, L"%d", NULL,
(VOID **)&GtdtPlatformTimerCount, NULL, NULL },
{ L"Platform Timer Offset", 4, 92, L"0x%x", NULL,
(VOID **)&GtdtPlatformTimerOffset,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 }
};
/**
An ACPI_PARSER array describing the Platform timer header.
**/
STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&PlatformTimerType, NULL, NULL},
{L"Length", 2, 1, NULL, NULL, (VOID**)&PlatformTimerLength, NULL, NULL},
{L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[] = {
{ L"Type", 1, 0, NULL, NULL, (VOID **)&PlatformTimerType, NULL, NULL },
{ L"Length", 2, 1, NULL, NULL, (VOID **)&PlatformTimerLength, NULL, NULL },
{ L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Platform GT Block.
**/
STATIC CONST ACPI_PARSER GtBlockParser[] = {
{L"Type", 1, 0, 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"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Timer Count", 4, 12, L"%d", NULL, (VOID**)&GtBlockTimerCount,
ValidateGtBlockTimerCount, NULL},
{L"Timer Offset", 4, 16, L"%d", NULL, (VOID**)&GtBlockTimerOffset, NULL,
NULL}
STATIC CONST ACPI_PARSER GtBlockParser[] = {
{ L"Type", 1, 0, 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"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Timer Count", 4, 12, L"%d", NULL, (VOID **)&GtBlockTimerCount,
ValidateGtBlockTimerCount, NULL },
{ L"Timer Offset", 4, 16, L"%d", NULL, (VOID **)&GtBlockTimerOffset, NULL,
NULL }
};
/**
An ACPI_PARSER array describing the GT Block timer.
**/
STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {
{L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, 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 (CntEL0BaseX)", 8, 12, L"0x%lx", 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"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"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER GtBlockTimerParser[] = {
{ L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, 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 (CntEL0BaseX)", 8, 12, L"0x%lx", 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"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"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Platform Watchdog.
**/
STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = {
{L"Type", 1, 0, 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"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"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}
STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = {
{ L"Type", 1, 0, 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"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"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 }
};
/**
@ -174,12 +174,12 @@ STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[] = {
STATIC
VOID
DumpGTBlock (
IN UINT8* Ptr,
IN UINT16 Length
IN UINT8 *Ptr,
IN UINT16 Length
)
{
UINT32 Index;
UINT32 Offset;
UINT32 Index;
UINT32 Offset;
ParseAcpi (
TRUE,
@ -193,7 +193,8 @@ DumpGTBlock (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((GtBlockTimerCount == NULL) ||
(GtBlockTimerOffset == NULL)) {
(GtBlockTimerOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient GT Block Structure length. Length = %d.\n",
@ -203,12 +204,13 @@ DumpGTBlock (
}
Offset = *GtBlockTimerOffset;
Index = 0;
Index = 0;
// Parse the specified number of GT Block Timer Structures or the GT Block
// Structure buffer length. Whichever is minimum.
while ((Index++ < *GtBlockTimerCount) &&
(Offset < Length)) {
(Offset < Length))
{
Offset += ParseAcpi (
TRUE,
2,
@ -229,8 +231,8 @@ DumpGTBlock (
STATIC
VOID
DumpWatchdogTimer (
IN UINT8* Ptr,
IN UINT16 Length
IN UINT8 *Ptr,
IN UINT16 Length
)
{
ParseAcpi (
@ -262,15 +264,15 @@ DumpWatchdogTimer (
VOID
EFIAPI
ParseAcpiGtdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Index;
UINT32 Offset;
UINT8* TimerPtr;
UINT32 Index;
UINT32 Offset;
UINT8 *TimerPtr;
if (!Trace) {
return;
@ -288,7 +290,8 @@ ParseAcpiGtdt (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((GtdtPlatformTimerCount == NULL) ||
(GtdtPlatformTimerOffset == NULL)) {
(GtdtPlatformTimerOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
@ -298,13 +301,14 @@ ParseAcpiGtdt (
}
TimerPtr = Ptr + *GtdtPlatformTimerOffset;
Offset = *GtdtPlatformTimerOffset;
Index = 0;
Offset = *GtdtPlatformTimerOffset;
Index = 0;
// Parse the specified number of Platform Timer Structures or the GTDT
// buffer length. Whichever is minimum.
while ((Index++ < *GtdtPlatformTimerCount) &&
(Offset < AcpiTableLength)) {
(Offset < AcpiTableLength))
{
// Parse the Platform Timer Header to obtain Length and Type
ParseAcpi (
FALSE,
@ -318,11 +322,12 @@ ParseAcpiGtdt (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((PlatformTimerType == NULL) ||
(PlatformTimerLength == NULL)) {
(PlatformTimerLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"Platform Timer Structure header. Length = %d.\n",
L"Platform Timer Structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -330,11 +335,12 @@ ParseAcpiGtdt (
// Validate Platform Timer Structure length
if ((*PlatformTimerLength == 0) ||
((Offset + (*PlatformTimerLength)) > AcpiTableLength)) {
((Offset + (*PlatformTimerLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Platform Timer Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*PlatformTimerLength,
Offset,
AcpiTableLength
@ -359,6 +365,6 @@ ParseAcpiGtdt (
} // switch
TimerPtr += *PlatformTimerLength;
Offset += *PlatformTimerLength;
Offset += *PlatformTimerLength;
} // while
}

View File

@ -21,27 +21,27 @@
#include "AcpiView.h"
// Maximum Memory Domain matrix print size.
#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10
#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10
// Local variables
STATIC CONST UINT16* HmatStructureType;
STATIC CONST UINT32* HmatStructureLength;
STATIC CONST UINT16 *HmatStructureType;
STATIC CONST UINT32 *HmatStructureLength;
STATIC CONST UINT32* NumberInitiatorProximityDomain;
STATIC CONST UINT32* NumberTargetProximityDomain;
STATIC CONST UINT32 *NumberInitiatorProximityDomain;
STATIC CONST UINT32 *NumberTargetProximityDomain;
STATIC CONST
EFI_ACPI_6_4_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS*
SllbiFlags;
EFI_ACPI_6_4_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLAGS *
SllbiFlags;
STATIC CONST UINT8* SllbiDataType;
STATIC CONST UINT16* NumberSMBIOSHandles;
STATIC CONST UINT8 *SllbiDataType;
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
**/
STATIC CONST CHAR16* SllbiNames[] = {
STATIC CONST CHAR16 *SllbiNames[] = {
L"Access %sLatency%s",
L"Read %sLatency%s",
L"Write %sLatency%s",
@ -61,15 +61,15 @@ STATIC
VOID
EFIAPI
ValidateCacheAttributes (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*
Attributes;
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_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) {
IncrementErrorCount ();
@ -78,6 +78,7 @@ ValidateCacheAttributes (
Attributes->TotalCacheLevels
);
}
if (Attributes->CacheLevel > 0x3) {
IncrementErrorCount ();
Print (
@ -85,6 +86,7 @@ ValidateCacheAttributes (
Attributes->CacheLevel
);
}
if (Attributes->CacheAssociativity > 0x2) {
IncrementErrorCount ();
Print (
@ -92,6 +94,7 @@ ValidateCacheAttributes (
Attributes->CacheAssociativity
);
}
if (Attributes->WritePolicy > 0x2) {
IncrementErrorCount ();
Print (
@ -111,15 +114,15 @@ STATIC
VOID
EFIAPI
DumpCacheAttributes (
IN CONST CHAR16* Format OPTIONAL,
IN UINT8* Ptr
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
)
{
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*
Attributes;
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_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");
PrintFieldName (4, L"Total Cache Levels");
@ -137,55 +140,55 @@ DumpCacheAttributes (
/**
An ACPI_PARSER array describing the ACPI HMAT Table.
*/
STATIC CONST ACPI_PARSER HmatParser[] = {
STATIC CONST ACPI_PARSER HmatParser[] = {
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.
*/
STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = {
{L"Type", 2, 0, NULL, NULL, (VOID**)&HmatStructureType, NULL, NULL},
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL},
{L"Length", 4, 4, NULL, NULL, (VOID**)&HmatStructureLength, NULL, NULL}
STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] = {
{ L"Type", 2, 0, NULL, NULL, (VOID **)&HmatStructureType, NULL, NULL },
{ L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL },
{ L"Length", 4, 4, NULL, NULL, (VOID **)&HmatStructureLength, NULL, NULL }
};
/**
An ACPI PARSER array describing the Memory Proximity Domain Attributes
Structure - Type 0.
*/
STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = {
{L"Type", 2, 0, 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"Flags", 2, 8, 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 memory", 4, 16, 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, 32, L"0x%lx", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] = {
{ L"Type", 2, 0, 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"Flags", 2, 8, 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 memory", 4, 16, 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, 32, L"0x%lx", NULL, NULL, NULL, NULL }
};
/**
An ACPI PARSER array describing the System Locality Latency and Bandwidth
Information Structure - Type 1.
*/
STATIC CONST ACPI_PARSER SllbiParser[] = {
{L"Type", 2, 0, 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"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"Min Transfer Size", 1, 10, L"%d", 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,
(VOID**)&NumberInitiatorProximityDomain, NULL, NULL},
{L"Target Proximity Dom Count", 4, 16, L"%d", NULL,
(VOID**)&NumberTargetProximityDomain, 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}
STATIC CONST ACPI_PARSER SllbiParser[] = {
{ L"Type", 2, 0, 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"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"Min Transfer Size", 1, 10, L"%d", 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,
(VOID **)&NumberInitiatorProximityDomain, NULL, NULL },
{ L"Target Proximity Dom Count", 4, 16, L"%d", NULL,
(VOID **)&NumberTargetProximityDomain, 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 }
// initiator Proximity Domain list ...
// target Proximity Domain list ...
// Latency/Bandwidth matrix ...
@ -195,18 +198,18 @@ STATIC CONST ACPI_PARSER SllbiParser[] = {
An ACPI PARSER array describing the Memory Side Cache Information
Structure - Type 2.
*/
STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
{L"Type", 2, 0, 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"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"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL,
ValidateCacheAttributes, NULL},
{L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL},
{L"SMBIOS Handle Count", 2, 30, L"%d", NULL,
(VOID**)&NumberSMBIOSHandles, NULL, NULL}
STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
{ L"Type", 2, 0, 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"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"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL,
ValidateCacheAttributes, NULL },
{ L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL },
{ L"SMBIOS Handle Count", 2, 30, L"%d", NULL,
(VOID **)&NumberSMBIOSHandles, NULL, NULL }
// SMBIOS handles List ...
};
@ -222,8 +225,8 @@ STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] = {
STATIC
VOID
DumpMpda (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
ParseAcpi (
@ -248,13 +251,13 @@ DumpMpda (
STATIC
VOID
DumpSllbi (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
CONST UINT32* InitiatorProximityDomainList;
CONST UINT32* TargetProximityDomainList;
CONST UINT16* LatencyBandwidthMatrix;
CONST UINT32 *InitiatorProximityDomainList;
CONST UINT32 *TargetProximityDomainList;
CONST UINT16 *LatencyBandwidthMatrix;
UINT32 Offset;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
CHAR16 SecondBuffer[OUTPUT_FIELD_COLUMN_WIDTH];
@ -278,11 +281,12 @@ DumpSllbi (
if ((SllbiFlags == NULL) ||
(SllbiDataType == NULL) ||
(NumberInitiatorProximityDomain == NULL) ||
(NumberTargetProximityDomain == NULL)) {
(NumberTargetProximityDomain == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"SLLBI structure header. Length = %d.\n",
L"SLLBI structure header. Length = %d.\n",
Length
);
return;
@ -306,10 +310,10 @@ DumpSllbi (
return;
}
InitiatorProximityDomainList = (UINT32*) (Ptr + Offset);
TargetProximityDomainList = InitiatorProximityDomainList +
*NumberInitiatorProximityDomain;
LatencyBandwidthMatrix = (UINT16*) (TargetProximityDomainList +
InitiatorProximityDomainList = (UINT32 *)(Ptr + Offset);
TargetProximityDomainList = InitiatorProximityDomainList +
*NumberInitiatorProximityDomain;
LatencyBandwidthMatrix = (UINT16 *)(TargetProximityDomainList +
*NumberTargetProximityDomain);
// 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);
return;
}
StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]);
// Adjust base name depending on Memory Hierarchy in this Structure
@ -381,7 +386,6 @@ DumpSllbi (
SllbiFlags->MemoryHierarchy
);
return;
} // switch
if (*NumberTargetProximityDomain <= MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX) {
@ -400,34 +404,41 @@ DumpSllbi (
for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) {
IndexTarget++)
{
Print (L" %2d", IndexTarget);
}
Print (L"\n ---+");
for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) {
IndexTarget++)
{
Print (L"------");
}
Print (L"\n");
TargetStartOffset = 0;
for (IndexInitiator = 0;
IndexInitiator < *NumberInitiatorProximityDomain;
IndexInitiator++) {
IndexInitiator++)
{
Print (L" %2d |", IndexInitiator);
for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) {
IndexTarget++)
{
Print (
L" %5d",
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
);
} // for Target
Print (L"\n");
TargetStartOffset += (*NumberTargetProximityDomain);
} // for Initiator
Print (L"\n");
} else {
// Display the latency/bandwidth matrix as a list
@ -441,10 +452,12 @@ DumpSllbi (
TargetStartOffset = 0;
for (IndexInitiator = 0;
IndexInitiator < *NumberInitiatorProximityDomain;
IndexInitiator++) {
IndexInitiator++)
{
for (IndexTarget = 0;
IndexTarget < *NumberTargetProximityDomain;
IndexTarget++) {
IndexTarget++)
{
UnicodeSPrint (
SecondBuffer,
sizeof (SecondBuffer),
@ -459,6 +472,7 @@ DumpSllbi (
LatencyBandwidthMatrix[TargetStartOffset + IndexTarget]
);
} // for Target
TargetStartOffset += (*NumberTargetProximityDomain);
} // for Initiator
}
@ -474,11 +488,11 @@ DumpSllbi (
STATIC
VOID
DumpMsci (
IN UINT8* Ptr,
IN UINT32 Length
IN UINT8 *Ptr,
IN UINT32 Length
)
{
CONST UINT16* SMBIOSHandlesList;
CONST UINT16 *SMBIOSHandlesList;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
UINT32 Offset;
UINT16 Index;
@ -498,7 +512,7 @@ DumpMsci (
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"MSCI structure header. Length = %d.\n",
L"MSCI structure header. Length = %d.\n",
Length
);
return;
@ -515,7 +529,7 @@ DumpMsci (
return;
}
SMBIOSHandlesList = (UINT16*) (Ptr + Offset);
SMBIOSHandlesList = (UINT16 *)(Ptr + Offset);
for (Index = 0; Index < *NumberSMBIOSHandles; Index++) {
UnicodeSPrint (
@ -553,14 +567,14 @@ DumpMsci (
VOID
EFIAPI
ParseAcpiHmat (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* HmatStructurePtr;
UINT32 Offset;
UINT8 *HmatStructurePtr;
if (!Trace) {
return;
@ -591,11 +605,12 @@ ParseAcpiHmat (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((HmatStructureType == NULL) ||
(HmatStructureLength == NULL)) {
(HmatStructureLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"HMAT structure header. Length = %d.\n",
L"HMAT structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -603,11 +618,12 @@ ParseAcpiHmat (
// Validate HMAT Structure length.
if ((*HmatStructureLength == 0) ||
((Offset + (*HmatStructureLength)) > AcpiTableLength)) {
((Offset + (*HmatStructureLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid HMAT Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*HmatStructureLength,
Offset,
AcpiTableLength
@ -629,7 +645,7 @@ ParseAcpiHmat (
);
break;
case EFI_ACPI_6_4_HMAT_TYPE_MEMORY_SIDE_CACHE_INFO:
DumpMsci (
DumpMsci (
HmatStructurePtr,
*HmatStructureLength
);
@ -638,7 +654,7 @@ ParseAcpiHmat (
IncrementErrorCount ();
Print (
L"ERROR: Unknown HMAT structure:"
L" Type = %d, Length = %d\n",
L" Type = %d, Length = %d\n",
*HmatStructureType,
*HmatStructureLength
);
@ -646,6 +662,6 @@ ParseAcpiHmat (
} // switch
HmatStructurePtr += *HmatStructureLength;
Offset += *HmatStructureLength;
Offset += *HmatStructureLength;
} // while
}

View File

@ -16,22 +16,22 @@
#include "AcpiViewConfig.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT32* IortNodeCount;
STATIC CONST UINT32* IortNodeOffset;
STATIC CONST UINT32 *IortNodeCount;
STATIC CONST UINT32 *IortNodeOffset;
STATIC CONST UINT8* IortNodeType;
STATIC CONST UINT16* IortNodeLength;
STATIC CONST UINT32* IortIdMappingCount;
STATIC CONST UINT32* IortIdMappingOffset;
STATIC CONST UINT8 *IortNodeType;
STATIC CONST UINT16 *IortNodeLength;
STATIC CONST UINT32 *IortIdMappingCount;
STATIC CONST UINT32 *IortIdMappingOffset;
STATIC CONST UINT32* InterruptContextCount;
STATIC CONST UINT32* InterruptContextOffset;
STATIC CONST UINT32* PmuInterruptCount;
STATIC CONST UINT32* PmuInterruptOffset;
STATIC CONST UINT32 *InterruptContextCount;
STATIC CONST UINT32 *InterruptContextOffset;
STATIC CONST UINT32 *PmuInterruptCount;
STATIC CONST UINT32 *PmuInterruptOffset;
STATIC CONST UINT32* ItsCount;
STATIC CONST UINT32 *ItsCount;
/**
This function validates the ID Mapping array count for the ITS node.
@ -44,11 +44,11 @@ STATIC
VOID
EFIAPI
ValidateItsIdMappingCount (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr != 0) {
if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping count must be zero.");
}
@ -66,11 +66,11 @@ STATIC
VOID
EFIAPI
ValidatePmcgIdMappingCount (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr > 1) {
if (*(UINT32 *)Ptr > 1) {
IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");
}
@ -87,11 +87,11 @@ STATIC
VOID
EFIAPI
ValidateItsIdArrayReference (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr != 0) {
if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount ();
Print (L"\nERROR: IORT ID Mapping offset must be zero.");
}
@ -119,135 +119,135 @@ ValidateItsIdArrayReference (
/**
An ACPI_PARSER array describing the ACPI IORT Table
**/
STATIC CONST ACPI_PARSER IortParser[] = {
STATIC CONST ACPI_PARSER IortParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Number of IORT Nodes", 4, 36, L"%d", NULL,
(VOID**)&IortNodeCount, NULL, NULL},
{L"Offset to Array of IORT Nodes", 4, 40, L"0x%x", NULL,
(VOID**)&IortNodeOffset, NULL, NULL},
{L"Reserved", 4, 44, L"0x%x", NULL, NULL, NULL, NULL}
{ L"Number of IORT Nodes", 4, 36, L"%d", NULL,
(VOID **)&IortNodeCount, NULL, NULL },
{ L"Offset to Array of IORT Nodes",4, 40, L"0x%x", NULL,
(VOID **)&IortNodeOffset, NULL, NULL },
{ L"Reserved", 4, 44, L"0x%x", NULL,NULL,NULL, NULL }
};
/**
An ACPI_PARSER array describing the IORT node header structure.
**/
STATIC CONST ACPI_PARSER IortNodeHeaderParser[] = {
STATIC CONST ACPI_PARSER IortNodeHeaderParser[] = {
PARSE_IORT_NODE_HEADER (NULL, NULL)
};
/**
An ACPI_PARSER array describing the IORT SMMUv1/2 node.
**/
STATIC CONST ACPI_PARSER IortNodeSmmuV1V2Parser[] = {
PARSE_IORT_NODE_HEADER (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"Model", 4, 32, L"%d", 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,
NULL},
{L"Number of context interrupts", 4, 44, L"%d", NULL,
(VOID**)&InterruptContextCount, NULL, NULL},
{L"Reference to Context Interrupt Array", 4, 48, L"0x%x", NULL,
(VOID**)&InterruptContextOffset, NULL, NULL},
{L"Number of PMU Interrupts", 4, 52, L"%d", NULL,
(VOID**)&PmuInterruptCount, NULL, NULL},
{L"Reference to PMU Interrupt Array", 4, 56, L"0x%x", NULL,
(VOID**)&PmuInterruptOffset, NULL, NULL},
STATIC CONST ACPI_PARSER IortNodeSmmuV1V2Parser[] = {
PARSE_IORT_NODE_HEADER (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"Model", 4, 32, L"%d", 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,
NULL },
{ L"Number of context interrupts", 4, 44, L"%d", NULL,
(VOID **)&InterruptContextCount, NULL, NULL },
{ L"Reference to Context Interrupt Array",4, 48, L"0x%x", NULL,
(VOID **)&InterruptContextOffset, NULL, NULL },
{ L"Number of PMU Interrupts", 4, 52, L"%d", NULL,
(VOID **)&PmuInterruptCount, NULL, NULL },
{ L"Reference to PMU Interrupt Array",4, 56, L"0x%x", NULL,
(VOID **)&PmuInterruptOffset, NULL, NULL },
// Interrupt Array
{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_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_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_NSgCfgIrpt", 4, 68, 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.
**/
STATIC CONST ACPI_PARSER InterruptArrayParser[] = {
{L"Interrupt GSIV", 4, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER InterruptArrayParser[] = {
{ L"Interrupt GSIV", 4, 0, 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.
**/
STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = {
{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"Output base", 4, 8, 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}
STATIC CONST ACPI_PARSER IortNodeIdMappingParser[] = {
{ 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"Output base", 4, 8, 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 }
};
/**
An ACPI_PARSER array describing the IORT SMMUv3 node.
**/
STATIC CONST ACPI_PARSER IortNodeSmmuV3Parser[] = {
STATIC CONST ACPI_PARSER IortNodeSmmuV3Parser[] = {
PARSE_IORT_NODE_HEADER (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"Reserved", 4, 28, L"0x%x", 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"Event", 4, 44, 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"Sync", 4, 56, 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"Base Address", 8, 16, L"0x%lx", 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"VATOS Address", 8, 32, L"0x%lx", 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"PRI", 4, 48, 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"Proximity domain", 4, 60, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Device ID mapping index", 4, 64, L"%d", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IORT ITS node.
**/
STATIC CONST ACPI_PARSER IortNodeItsParser[] = {
STATIC CONST ACPI_PARSER IortNodeItsParser[] = {
PARSE_IORT_NODE_HEADER (
ValidateItsIdMappingCount,
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 }
};
/**
An ACPI_PARSER array describing the ITS ID.
**/
STATIC CONST ACPI_PARSER ItsIdParser[] = {
STATIC CONST ACPI_PARSER ItsIdParser[] = {
{ L"GIC ITS Identifier", 4, 0, L"%d", NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IORT Names Component node.
**/
STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = {
STATIC CONST ACPI_PARSER IortNodeNamedComponentParser[] = {
PARSE_IORT_NODE_HEADER (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"Device memory address size limit", 1, 28, 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"Device memory address size limit",1, 28, L"%d", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IORT Root Complex node.
**/
STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
PARSE_IORT_NODE_HEADER (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"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"Reserved", 3, 33, L"%x %x %x", Dump3Chars, 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"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"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IORT PMCG node.
**/
STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, 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"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 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"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 }
};
/**
@ -260,20 +260,21 @@ STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
STATIC
VOID
DumpIortNodeIdMappings (
IN UINT8* Ptr,
IN UINT32 Length,
IN UINT32 MappingCount
IN UINT8 *Ptr,
IN UINT32 Length,
IN UINT32 MappingCount
)
{
UINT32 Index;
UINT32 Offset;
CHAR8 Buffer[40]; // Used for AsciiName param of ParseAcpi
UINT32 Index;
UINT32 Offset;
CHAR8 Buffer[40]; // Used for AsciiName param of ParseAcpi
Index = 0;
Index = 0;
Offset = 0;
while ((Index < MappingCount) &&
(Offset < Length)) {
(Offset < Length))
{
AsciiSPrint (
Buffer,
sizeof (Buffer),
@ -304,15 +305,15 @@ DumpIortNodeIdMappings (
STATIC
VOID
DumpIortNodeSmmuV1V2 (
IN UINT8* Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
IN UINT8 *Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
{
UINT32 Index;
UINT32 Offset;
CHAR8 Buffer[50]; // Used for AsciiName param of ParseAcpi
UINT32 Index;
UINT32 Offset;
CHAR8 Buffer[50]; // Used for AsciiName param of ParseAcpi
ParseAcpi (
TRUE,
@ -328,7 +329,8 @@ DumpIortNodeSmmuV1V2 (
if ((InterruptContextCount == NULL) ||
(InterruptContextOffset == NULL) ||
(PmuInterruptCount == NULL) ||
(PmuInterruptOffset == NULL)) {
(PmuInterruptOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient SMMUv1/2 node length. Length = %d\n",
@ -338,10 +340,11 @@ DumpIortNodeSmmuV1V2 (
}
Offset = *InterruptContextOffset;
Index = 0;
Index = 0;
while ((Index < *InterruptContextCount) &&
(Offset < Length)) {
(Offset < Length))
{
AsciiSPrint (
Buffer,
sizeof (Buffer),
@ -360,10 +363,11 @@ DumpIortNodeSmmuV1V2 (
}
Offset = *PmuInterruptOffset;
Index = 0;
Index = 0;
while ((Index < *PmuInterruptCount) &&
(Offset < Length)) {
(Offset < Length))
{
AsciiSPrint (
Buffer,
sizeof (Buffer),
@ -400,10 +404,10 @@ DumpIortNodeSmmuV1V2 (
STATIC
VOID
DumpIortNodeSmmuV3 (
IN UINT8* Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
IN UINT8 *Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
{
ParseAcpi (
@ -431,22 +435,22 @@ DumpIortNodeSmmuV3 (
STATIC
VOID
DumpIortNodeIts (
IN UINT8* Ptr,
IN UINT16 Length
IN UINT8 *Ptr,
IN UINT16 Length
)
{
UINT32 Offset;
UINT32 Index;
CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi
UINT32 Offset;
UINT32 Index;
CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi
Offset = ParseAcpi (
TRUE,
2,
"ITS Node",
Ptr,
Length,
PARSER_PARAMS (IortNodeItsParser)
);
TRUE,
2,
"ITS Node",
Ptr,
Length,
PARSER_PARAMS (IortNodeItsParser)
);
// Check if the values used to control the parsing logic have been
// successfully read.
@ -462,7 +466,8 @@ DumpIortNodeIts (
Index = 0;
while ((Index < *ItsCount) &&
(Offset < Length)) {
(Offset < Length))
{
AsciiSPrint (
Buffer,
sizeof (Buffer),
@ -481,7 +486,6 @@ DumpIortNodeIts (
}
// Note: ITS does not have the ID Mappings Array
}
/**
@ -496,13 +500,13 @@ DumpIortNodeIts (
STATIC
VOID
DumpIortNodeNamedComponent (
IN UINT8* Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
IN UINT8 *Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
{
UINT32 Offset;
UINT32 Offset;
Offset = ParseAcpi (
TRUE,
@ -517,10 +521,12 @@ DumpIortNodeNamedComponent (
PrintFieldName (2, L"Device Object Name");
while ((*(Ptr + Offset) != 0) &&
(Offset < Length)) {
(Offset < Length))
{
Print (L"%c", *(Ptr + Offset));
Offset++;
}
Print (L"\n");
DumpIortNodeIdMappings (
@ -542,10 +548,10 @@ DumpIortNodeNamedComponent (
STATIC
VOID
DumpIortNodeRootComplex (
IN UINT8* Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
IN UINT8 *Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
{
ParseAcpi (
@ -576,11 +582,11 @@ DumpIortNodeRootComplex (
STATIC
VOID
DumpIortNodePmcg (
IN UINT8* Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
IN UINT8 *Ptr,
IN UINT16 Length,
IN UINT32 MappingCount,
IN UINT32 MappingOffset
)
{
ParseAcpi (
TRUE,
@ -620,15 +626,15 @@ DumpIortNodePmcg (
VOID
EFIAPI
ParseAcpiIort (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT32 Index;
UINT8* NodePtr;
UINT32 Offset;
UINT32 Index;
UINT8 *NodePtr;
if (!Trace) {
return;
@ -646,7 +652,8 @@ ParseAcpiIort (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((IortNodeCount == NULL) ||
(IortNodeOffset == NULL)) {
(IortNodeOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
@ -655,14 +662,15 @@ ParseAcpiIort (
return;
}
Offset = *IortNodeOffset;
Offset = *IortNodeOffset;
NodePtr = Ptr + Offset;
Index = 0;
Index = 0;
// Parse the specified number of IORT nodes or the IORT table buffer length.
// Whichever is minimum.
while ((Index++ < *IortNodeCount) &&
(Offset < AcpiTableLength)) {
(Offset < AcpiTableLength))
{
// Parse the IORT Node Header
ParseAcpi (
FALSE,
@ -678,11 +686,12 @@ ParseAcpiIort (
if ((IortNodeType == NULL) ||
(IortNodeLength == NULL) ||
(IortIdMappingCount == NULL) ||
(IortIdMappingOffset == NULL)) {
(IortIdMappingOffset == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"IORT node header. Length = %d.\n",
L"IORT node header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -690,11 +699,12 @@ ParseAcpiIort (
// Validate IORT Node length
if ((*IortNodeLength == 0) ||
((Offset + (*IortNodeLength)) > AcpiTableLength)) {
((Offset + (*IortNodeLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid IORT Node length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*IortNodeLength,
Offset,
AcpiTableLength
@ -750,7 +760,7 @@ ParseAcpiIort (
*IortNodeLength,
*IortIdMappingCount,
*IortIdMappingOffset
);
);
break;
default:
@ -759,6 +769,6 @@ ParseAcpiIort (
} // switch
NodePtr += (*IortNodeLength);
Offset += (*IortNodeLength);
Offset += (*IortNodeLength);
} // while
}

View File

@ -19,9 +19,9 @@
#include "MadtParser.h"
// Local Variables
STATIC CONST UINT8* MadtInterruptControllerType;
STATIC CONST UINT8* MadtInterruptControllerLength;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT8 *MadtInterruptControllerType;
STATIC CONST UINT8 *MadtInterruptControllerLength;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the System Vector Base in the GICD.
@ -34,15 +34,15 @@ STATIC
VOID
EFIAPI
ValidateGICDSystemVectorBase (
IN UINT8* Ptr,
IN VOID* Context
)
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr != 0) {
if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount ();
Print (
L"\nERROR: System Vector Base must be zero."
);
);
}
}
@ -57,13 +57,13 @@ STATIC
VOID
EFIAPI
ValidateSpeOverflowInterrupt (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT16 SpeOverflowInterrupt;
UINT16 SpeOverflowInterrupt;
SpeOverflowInterrupt = *(UINT16*)Ptr;
SpeOverflowInterrupt = *(UINT16 *)Ptr;
// SPE not supported by this processor
if (SpeOverflowInterrupt == 0) {
@ -73,183 +73,183 @@ ValidateSpeOverflowInterrupt (
if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) ||
((SpeOverflowInterrupt > ARM_PPI_ID_MAX) &&
(SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) {
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX))
{
IncrementErrorCount ();
Print (
L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
SpeOverflowInterrupt,
ARM_PPI_ID_MIN,
ARM_PPI_ID_MAX,
ARM_PPI_ID_EXTENDED_MIN,
ARM_PPI_ID_EXTENDED_MAX
);
);
} else if (SpeOverflowInterrupt != ARM_PPI_ID_PMBIRQ) {
IncrementWarningCount();
IncrementWarningCount ();
Print (
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.",
SpeOverflowInterrupt,
ARM_PPI_ID_PMBIRQ
);
);
}
}
/**
An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicCParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER GicCParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Flags", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
{L"Parking Protocol Version", 4, 16, 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"Flags", 4, 12, 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"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"GICV", 8, 40, 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"GICR Base Address", 8, 60, 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,
NULL},
{L"Reserved", 1, 77, L"0x%x", NULL, NULL, NULL, NULL},
{L"SPE overflow Interrupt", 2, 78, L"0x%x", NULL, NULL,
ValidateSpeOverflowInterrupt, 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"Physical Base Address", 8, 32, 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"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"MPIDR", 8, 68, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Processor Power Efficiency Class", 1, 76, 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,
ValidateSpeOverflowInterrupt, NULL }
};
/**
An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicDParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER GicDParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"System Vector Base", 4, 16, L"0x%x", NULL, NULL,
ValidateGICDSystemVectorBase, 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"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"System Vector Base", 4, 16, L"0x%x", NULL, NULL,
ValidateGICDSystemVectorBase, NULL },
{ L"GIC Version", 1, 20, L"%d", NULL, 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.
**/
STATIC CONST ACPI_PARSER GicMSIFrameParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER GicMSIFrameParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Flags", 4, 16, 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"Flags", 4, 16, L"0x%x", 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 Count", 2, 20, L"%d", 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.
**/
STATIC CONST ACPI_PARSER GicRParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER GicRParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL,
NULL},
{L"Discovery Range Length", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
{ L"Discovery Range Base Address", 8, 4, L"0x%lx", 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.
**/
STATIC CONST ACPI_PARSER GicITSParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER GicITSParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Reserved", 4, 16, 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"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IO APIC Structure.
**/
STATIC CONST ACPI_PARSER IoApic[] = {
{L"Type", 1, 0, L"0x%x", 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"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"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER IoApic[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Interrupt Source Override Structure.
**/
STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
{L"Type", 1, 0, L"0x%x", 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"Source", 1, 3, 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}
STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
{ L"Type", 1, 0, L"0x%x", 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"Source", 1, 3, 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 }
};
/**
An ACPI_PARSER array describing the Processor Local x2APIC Structure.
**/
STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = {
{ L"Type", 1, 0, L"0x%x", 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"X2APIC ID", 4, 4, 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"X2APIC ID", 4, 4, 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 }
};
/**
An ACPI_PARSER array describing the Local x2APIC NMI Structure.
**/
STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, 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"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the ACPI MADT Table.
**/
STATIC CONST ACPI_PARSER MadtParser[] = {
STATIC CONST ACPI_PARSER MadtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Local Interrupt Controller Address", 4, 36, L"0x%x", NULL, NULL, NULL,
NULL},
{L"Flags", 4, 40, L"0x%x", NULL, NULL, NULL, NULL}
{ L"Local Interrupt Controller Address",4, 36, 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.
**/
STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
{NULL, 1, 0, NULL, NULL, (VOID**)&MadtInterruptControllerType, NULL, NULL},
{L"Length", 1, 1, NULL, NULL, (VOID**)&MadtInterruptControllerLength, NULL,
NULL},
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
{ NULL, 1, 0, NULL, NULL, (VOID **)&MadtInterruptControllerType, NULL, NULL },
{ L"Length", 1, 1, NULL, NULL, (VOID **)&MadtInterruptControllerLength, NULL,
NULL },
{ L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL }
};
/**
@ -275,15 +275,15 @@ STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
VOID
EFIAPI
ParseAcpiMadt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* InterruptContollerPtr;
UINT32 GICDCount;
UINT32 Offset;
UINT8 *InterruptContollerPtr;
UINT32 GICDCount;
GICDCount = 0;
@ -315,11 +315,12 @@ ParseAcpiMadt (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((MadtInterruptControllerType == NULL) ||
(MadtInterruptControllerLength == NULL)) {
(MadtInterruptControllerLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"Interrupt Controller Structure header. Length = %d.\n",
L"Interrupt Controller Structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -327,11 +328,12 @@ ParseAcpiMadt (
// Validate Interrupt Controller Structure length
if ((*MadtInterruptControllerLength == 0) ||
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) {
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Interrupt Controller Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*MadtInterruptControllerLength,
Offset,
AcpiTableLength
@ -340,7 +342,8 @@ ParseAcpiMadt (
}
switch (*MadtInterruptControllerType) {
case EFI_ACPI_6_3_GIC: {
case EFI_ACPI_6_3_GIC:
{
ParseAcpi (
TRUE,
2,
@ -352,15 +355,17 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_GICD: {
case EFI_ACPI_6_3_GICD:
{
if (++GICDCount > 1) {
IncrementErrorCount ();
Print (
L"ERROR: Only one GICD must be present,"
L" GICDCount = %d\n",
L" GICDCount = %d\n",
GICDCount
);
}
ParseAcpi (
TRUE,
2,
@ -372,7 +377,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_GIC_MSI_FRAME: {
case EFI_ACPI_6_3_GIC_MSI_FRAME:
{
ParseAcpi (
TRUE,
2,
@ -384,7 +390,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_GICR: {
case EFI_ACPI_6_3_GICR:
{
ParseAcpi (
TRUE,
2,
@ -396,7 +403,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_GIC_ITS: {
case EFI_ACPI_6_3_GIC_ITS:
{
ParseAcpi (
TRUE,
2,
@ -408,7 +416,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_IO_APIC: {
case EFI_ACPI_6_3_IO_APIC:
{
ParseAcpi (
TRUE,
2,
@ -420,7 +429,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE: {
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE:
{
ParseAcpi (
TRUE,
2,
@ -432,7 +442,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC: {
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC:
{
ParseAcpi (
TRUE,
2,
@ -444,7 +455,8 @@ ParseAcpiMadt (
break;
}
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI: {
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI:
{
ParseAcpi (
TRUE,
2,
@ -456,11 +468,12 @@ ParseAcpiMadt (
break;
}
default: {
default:
{
IncrementErrorCount ();
Print (
L"ERROR: Unknown Interrupt Controller Structure,"
L" Type = %d, Length = %d\n",
L" Type = %d, Length = %d\n",
*MadtInterruptControllerType,
*MadtInterruptControllerLength
);
@ -468,6 +481,6 @@ ParseAcpiMadt (
} // switch
InterruptContollerPtr += *MadtInterruptControllerLength;
Offset += *MadtInterruptControllerLength;
Offset += *MadtInterruptControllerLength;
} // while
}

View File

@ -16,25 +16,25 @@
///
/// Level 3 base server system Private Peripheral Inerrupt (PPI) ID assignments
///
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTP 30
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTPS 29
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHV 28
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTV 27
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHP 26
#define ARM_PPI_ID_GIC_MAINTENANCE_INTERRUPT 25
#define ARM_PPI_ID_CTIIRQ 24
#define ARM_PPI_ID_PERFORMANCE_MONITORS_INTERRUPT 23
#define ARM_PPI_ID_COMMIRQ 22
#define ARM_PPI_ID_PMBIRQ 21
#define ARM_PPI_ID_CNTHPS 20
#define ARM_PPI_ID_CNTHVS 19
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTP 30
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTPS 29
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHV 28
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTV 27
#define ARM_PPI_ID_OVERFLOW_INTERRUPT_FROM_CNTHP 26
#define ARM_PPI_ID_GIC_MAINTENANCE_INTERRUPT 25
#define ARM_PPI_ID_CTIIRQ 24
#define ARM_PPI_ID_PERFORMANCE_MONITORS_INTERRUPT 23
#define ARM_PPI_ID_COMMIRQ 22
#define ARM_PPI_ID_PMBIRQ 21
#define ARM_PPI_ID_CNTHPS 20
#define ARM_PPI_ID_CNTHVS 19
///
/// PPI ID allowed ranges
///
#define ARM_PPI_ID_MAX 31
#define ARM_PPI_ID_MIN 16
#define ARM_PPI_ID_EXTENDED_MAX 1119
#define ARM_PPI_ID_EXTENDED_MIN 1056
#define ARM_PPI_ID_MAX 31
#define ARM_PPI_ID_MIN 16
#define ARM_PPI_ID_EXTENDED_MAX 1119
#define ARM_PPI_ID_EXTENDED_MIN 1056
#endif // MADT_PARSER_H_

View File

@ -14,25 +14,25 @@
#include "AcpiTableParser.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
An ACPI_PARSER array describing the ACPI MCFG Table.
**/
STATIC CONST ACPI_PARSER McfgParser[] = {
STATIC CONST ACPI_PARSER McfgParser[] = {
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.
**/
STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
{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"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"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
{ 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"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"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
@ -50,15 +50,15 @@ STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
VOID
EFIAPI
ParseAcpiMcfg (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT32 PciCfgOffset;
UINT8* PciCfgSpacePtr;
UINT32 Offset;
UINT32 PciCfgOffset;
UINT8 *PciCfgSpacePtr;
if (!Trace) {
return;
@ -85,6 +85,6 @@ ParseAcpiMcfg (
PARSER_PARAMS (PciCfgSpaceBaseAddrParser)
);
PciCfgSpacePtr += PciCfgOffset;
Offset += PciCfgOffset;
Offset += PciCfgOffset;
}
}

View File

@ -17,12 +17,12 @@
#include "PcctParser.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC UINT32* PccGlobalFlags;
STATIC UINT8* PccSubspaceLength;
STATIC UINT8* PccSubspaceType;
STATIC UINT8* ExtendedPccSubspaceInterruptFlags;
STATIC UINT32 *PccGlobalFlags;
STATIC UINT8 *PccSubspaceLength;
STATIC UINT8 *PccSubspaceType;
STATIC UINT8 *ExtendedPccSubspaceInterruptFlags;
/**
This function validates the length coded on 4 bytes of a shared memory range
@ -35,16 +35,16 @@ STATIC
VOID
EFIAPI
ValidateRangeLength4 (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
if (*(UINT32 *)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
IncrementErrorCount ();
Print (
L"\nError: Shared memory range length is too short.\n"
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
);
}
@ -61,16 +61,16 @@ STATIC
VOID
EFIAPI
ValidateRangeLength8 (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT64*)Ptr <= MIN_MEMORY_RANGE_LENGTH) {
if (*(UINT64 *)Ptr <= MIN_MEMORY_RANGE_LENGTH) {
IncrementErrorCount ();
Print (
L"\nError: Shared memory range length is too short.\n"
L"Length is %u when it should be greater than %u",
*(UINT64*)Ptr,
*(UINT64 *)Ptr,
MIN_MEMORY_RANGE_LENGTH
);
}
@ -87,14 +87,14 @@ STATIC
VOID
EFIAPI
ValidatePccMemoryIoGas (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
switch (*(UINT8*)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
switch (*(UINT8 *)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
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:
return;
default:
@ -114,14 +114,14 @@ STATIC
VOID
EFIAPI
ValidatePccGas (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
switch (*(UINT8*)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
switch (*(UINT8 *)Ptr) {
#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64))
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_SYSTEM_MEMORY:
return;
@ -142,8 +142,8 @@ STATIC
VOID
EFIAPI
ValidatePccDoorbellGas (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// For slave subspaces this field is optional, if not present the field
@ -152,7 +152,8 @@ ValidatePccDoorbellGas (
if (IsZeroBuffer (
Ptr,
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) {
))
{
return;
}
}
@ -172,8 +173,8 @@ STATIC
VOID
EFIAPI
ValidatePccIntAckGas (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// If the subspace does not support interrupts or the interrupt is
@ -183,12 +184,14 @@ ValidatePccIntAckGas (
if (((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) ||
((*ExtendedPccSubspaceInterruptFlags &
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE)) {
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE) ==
EFI_ACPI_6_4_PCCT_SUBSPACE_PLATFORM_INTERRUPT_FLAGS_MODE))
{
if (IsZeroBuffer (
Ptr,
sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE)
)) {
))
{
return;
}
}
@ -207,8 +210,8 @@ STATIC
VOID
EFIAPI
ValidatePccErrStatusGas (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// This field is ignored by the OSPM on slave channels.
@ -230,19 +233,20 @@ STATIC
VOID
EFIAPI
ValidatePlatInterrupt (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// If a slave subspace is present in the PCCT, then the global Platform
// Interrupt flag must be set to 1.
if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) &&
((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) !=
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT)) {
EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT))
{
IncrementErrorCount ();
Print (
L"\nError: Global Platform interrupt flag must be set to 1" \
L" if a PCC type 4 structure is present in PCCT."
L" if a PCC type 4 structure is present in PCCT."
);
}
}
@ -250,17 +254,17 @@ ValidatePlatInterrupt (
/**
An ACPI_PARSER array describing the ACPI PCCT Table.
*/
STATIC CONST ACPI_PARSER PcctParser[] = {
STATIC CONST ACPI_PARSER PcctParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Flags", 4, 36, NULL, NULL, (VOID**)&PccGlobalFlags, NULL, NULL},
{L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL}
{ L"Flags", 4, 36, NULL, NULL, (VOID **)&PccGlobalFlags, NULL, NULL },
{ L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the platform communications channel subspace
structure header.
*/
STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = {
STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = {
PCC_SUBSPACE_HEADER ()
// ... Type Specific Fields ...
};
@ -268,126 +272,126 @@ STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = {
/**
An ACPI_PARSER array describing the Generic Communications Subspace - Type 0
*/
STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = {
PCC_SUBSPACE_HEADER (),
{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"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL},
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccMemoryIoGas,
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"Nominal Latency", 4, 52, 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"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"Memory Range Length",8, 16, L"0x%lx", NULL, NULL, ValidateRangeLength8,
NULL },
{ L"Doorbell Register",12, 24, NULL, DumpGas, NULL, ValidatePccMemoryIoGas,
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"Nominal Latency", 4, 52, 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 }
};
/**
An ACPI_PARSER array describing the HW-Reduced Communications Subspace
- Type 1
*/
STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = {
STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = {
PCC_SUBSPACE_HEADER (),
{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"Reserved", 1, 7, L"0x%x", 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,
NULL},
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL,
ValidatePccGas, 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"Nominal Latency", 4, 52, 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"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"Reserved", 1, 7, L"0x%x", 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,
NULL },
{ L"Doorbell Register",12, 24, NULL, DumpGas, NULL,
ValidatePccGas, 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"Nominal Latency", 4, 52, 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 }
};
/**
An ACPI_PARSER array describing the HW-Reduced Communications Subspace
- Type 2
*/
STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = {
STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = {
PCC_SUBSPACE_HEADER (),
{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"Reserved", 1, 7, L"0x%x", 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,
NULL},
{L"Doorbell Register", 12, 24, NULL, DumpGas, NULL,
ValidatePccGas, 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"Nominal Latency", 4, 52, 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"Platform Interrupt Ack Register", 12, 62, NULL, DumpGas, NULL,
ValidatePccGas, 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,
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"Reserved", 1, 7, L"0x%x", 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,
NULL },
{ L"Doorbell Register",12, 24, NULL, DumpGas, NULL,
ValidatePccGas, 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"Nominal Latency", 4, 52, 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"Platform Interrupt Ack Register",12, 62, NULL, DumpGas, NULL,
ValidatePccGas, 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,
NULL, NULL },
};
/**
An ACPI_PARSER array describing the Extended PCC Subspaces - Type 3/4
*/
STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] = {
PCC_SUBSPACE_HEADER (),
{L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL,
ValidatePlatInterrupt, NULL},
{L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL,
(VOID**)&ExtendedPccSubspaceInterruptFlags, 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"Memory Range Length", 4, 16, L"0x%x", NULL, NULL, ValidateRangeLength4,
NULL},
{L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccDoorbellGas, 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"Nominal Latency", 4, 48, 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"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL,
ValidatePccIntAckGas, 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"Reserved", 8, 88, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL,
ValidatePccGas, 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,
ValidatePccGas, 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"Error Status Register", 12, 144, NULL, DumpGas, NULL,
ValidatePccErrStatusGas, NULL},
{L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL, NULL, NULL},
{ L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL,
ValidatePlatInterrupt, NULL },
{ L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL,
(VOID **)&ExtendedPccSubspaceInterruptFlags,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"Memory Range Length", 4, 16, L"0x%x", NULL, NULL,ValidateRangeLength4,
NULL },
{ L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccDoorbellGas, 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"Nominal Latency", 4, 48, 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"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL,
ValidatePccIntAckGas, 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"Reserved", 8, 88, L"0x%lx", NULL, NULL,NULL, NULL },
{ L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL,
ValidatePccGas, 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,
ValidatePccGas, 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"Error Status Register", 12, 144, NULL, DumpGas, NULL,
ValidatePccErrStatusGas, NULL },
{ L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL,NULL, NULL },
};
/**
An ACPI_PARSER array describing the HW Registers based Communications
Subspace Structure - Type 5
*/
STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
PCC_SUBSPACE_HEADER (),
{L"Version", 2, 2, L"0x%x", 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"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, 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"Command Complete Check Register", 12, 48, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, NULL},
{L"Command Complete Check Mask", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL},
{L"Error Status Register", 12, 68, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas, 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"Minimum Request Turnaround Time", 4, 92, 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"Shared Memory Range Length",8, 12, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Doorbell Register", 12, 20, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas,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"Command Complete Check Register",12, 48, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas,NULL },
{ L"Command Complete Check Mask",8, 60, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Error Status Register",12, 68, NULL, DumpGas, NULL,
ValidatePccMemoryIoGas,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"Minimum Request Turnaround Time",4, 92, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
@ -399,7 +403,7 @@ STATIC CONST ACPI_PARSER PccSubspaceType5Parser[] = {
STATIC
VOID
DumpPccSubspaceType0 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -422,7 +426,7 @@ DumpPccSubspaceType0 (
STATIC
VOID
DumpPccSubspaceType1 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -445,7 +449,7 @@ DumpPccSubspaceType1 (
STATIC
VOID
DumpPccSubspaceType2 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -468,7 +472,7 @@ DumpPccSubspaceType2 (
STATIC
VOID
DumpPccSubspaceType3 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -491,7 +495,7 @@ DumpPccSubspaceType3 (
STATIC
VOID
DumpPccSubspaceType4 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -514,7 +518,7 @@ DumpPccSubspaceType4 (
STATIC
VOID
DumpPccSubspaceType5 (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -544,15 +548,15 @@ DumpPccSubspaceType5 (
VOID
EFIAPI
ParseAcpiPcct (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* PccSubspacePtr;
UINTN SubspaceCount;
UINT32 Offset;
UINT8 *PccSubspacePtr;
UINTN SubspaceCount;
if (!Trace) {
return;
@ -584,11 +588,12 @@ ParseAcpiPcct (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((PccSubspaceType == NULL) ||
(PccSubspaceLength == NULL)) {
(PccSubspaceLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"structure header. Length = %u.\n",
L"structure header. Length = %u.\n",
AcpiTableLength - Offset
);
return;
@ -596,11 +601,12 @@ ParseAcpiPcct (
// Validate Structure length
if ((*PccSubspaceLength == 0) ||
((Offset + (*PccSubspaceLength)) > AcpiTableLength)) {
((Offset + (*PccSubspaceLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Structure length. " \
L"Length = %u. Offset = %u. AcpiTableLength = %u.\n",
L"Length = %u. Offset = %u. AcpiTableLength = %u.\n",
*PccSubspaceLength,
Offset,
AcpiTableLength
@ -649,14 +655,14 @@ ParseAcpiPcct (
IncrementErrorCount ();
Print (
L"ERROR: Unknown PCC subspace structure:"
L" Type = %u, Length = %u\n",
L" Type = %u, Length = %u\n",
PccSubspaceType,
*PccSubspaceLength
);
}
PccSubspacePtr += *PccSubspaceLength;
Offset += *PccSubspaceLength;
Offset += *PccSubspaceLength;
SubspaceCount++;
} // while

View File

@ -11,17 +11,17 @@
/**
Minimum value for the 'length' field in subspaces of types 0, 1 and 2.
*/
#define MIN_MEMORY_RANGE_LENGTH 8
#define MIN_MEMORY_RANGE_LENGTH 8
/**
Minimum value for the 'length' field in subspaces of types 3 and 4.
*/
#define MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN 16
#define MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN 16
/**
Maximum number of PCC subspaces.
*/
#define MAX_PCC_SUBSPACES 256
#define MAX_PCC_SUBSPACES 256
/**
Parser for the header of any type of PCC subspace.

View File

@ -17,10 +17,10 @@
#include "PpttParser.h"
// Local variables
STATIC CONST UINT8* ProcessorTopologyStructureType;
STATIC CONST UINT8* ProcessorTopologyStructureLength;
STATIC CONST UINT32* NumberOfPrivateResources;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT8 *ProcessorTopologyStructureType;
STATIC CONST UINT8 *ProcessorTopologyStructureLength;
STATIC CONST UINT32 *NumberOfPrivateResources;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the Cache Type Structure (Type 1) 'Number of sets'
@ -34,12 +34,13 @@ STATIC
VOID
EFIAPI
ValidateCacheNumberOfSets (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT32 NumberOfSets;
NumberOfSets = *(UINT32*)Ptr;
UINT32 NumberOfSets;
NumberOfSets = *(UINT32 *)Ptr;
if (NumberOfSets == 0) {
IncrementErrorCount ();
@ -47,12 +48,12 @@ ValidateCacheNumberOfSets (
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) {
IncrementErrorCount ();
Print (
L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache number of "
L"sets must be less than or equal to %d",
L"sets must be less than or equal to %d",
PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX
);
return;
@ -62,14 +63,14 @@ ValidateCacheNumberOfSets (
IncrementWarningCount ();
Print (
L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of sets "
L"must be less than or equal to %d. Ignore this message if "
L"ARMv8.3-CCIDX is implemented",
L"must be less than or equal to %d. Ignore this message if "
L"ARMv8.3-CCIDX is implemented",
PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX
);
return;
}
#endif
#endif
}
/**
@ -84,12 +85,13 @@ STATIC
VOID
EFIAPI
ValidateCacheAssociativity (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT8 Associativity;
Associativity = *(UINT8*)Ptr;
UINT8 Associativity;
Associativity = *(UINT8 *)Ptr;
if (Associativity == 0) {
IncrementErrorCount ();
@ -109,25 +111,26 @@ STATIC
VOID
EFIAPI
ValidateCacheLineSize (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
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)
// Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register
// LineSize, bits [2:0]
// (Log2(Number of bytes in cache line)) - 4.
UINT16 LineSize;
LineSize = *(UINT16*)Ptr;
UINT16 LineSize;
LineSize = *(UINT16 *)Ptr;
if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) ||
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) {
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX))
{
IncrementErrorCount ();
Print (
L"\nERROR: The cache line size must be between %d and %d bytes"
L" on ARM Platforms.",
L" on ARM Platforms.",
PPTT_ARM_CACHE_LINE_SIZE_MIN,
PPTT_ARM_CACHE_LINE_SIZE_MAX
);
@ -138,7 +141,8 @@ ValidateCacheLineSize (
IncrementErrorCount ();
Print (L"\nERROR: The cache line size is not a power of 2.");
}
#endif
#endif
}
/**
@ -152,15 +156,16 @@ STATIC
VOID
EFIAPI
ValidateCacheAttributes (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
// Reference: Advanced Configuration and Power Interface (ACPI) Specification
// Version 6.2 Errata A, September 2017
// Table 5-153: Cache Type Structure
UINT8 Attributes;
Attributes = *(UINT8*)Ptr;
UINT8 Attributes;
Attributes = *(UINT8 *)Ptr;
if ((Attributes & 0xE0) != 0) {
IncrementErrorCount ();
@ -175,67 +180,67 @@ ValidateCacheAttributes (
/**
An ACPI_PARSER array describing the ACPI PPTT Table.
**/
STATIC CONST ACPI_PARSER PpttParser[] = {
STATIC CONST ACPI_PARSER PpttParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
/**
An ACPI_PARSER array describing the processor topology structure header.
**/
STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&ProcessorTopologyStructureType,
NULL, NULL},
{L"Length", 1, 1, NULL, NULL, (VOID**)&ProcessorTopologyStructureLength,
NULL, NULL},
{L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser[] = {
{ L"Type", 1, 0, NULL, NULL, (VOID **)&ProcessorTopologyStructureType,
NULL, NULL },
{ L"Length", 1, 1, NULL, NULL, (VOID **)&ProcessorTopologyStructureLength,
NULL, NULL },
{ L"Reserved", 2, 2, NULL, NULL, NULL, NULL,NULL }
};
/**
An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
**/
STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"Flags", 4, 4, 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"Number of private resources", 4, 16, L"%d", NULL,
(VOID**)&NumberOfPrivateResources, 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"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Number of private resources", 4, 16, L"%d", NULL,
(VOID **)&NumberOfPrivateResources, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Cache Type Structure - Type 1.
**/
STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"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"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
{L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL},
{L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL},
{L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
{L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, 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"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL },
{ L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL },
{ L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL },
{ L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL }
};
/**
An ACPI_PARSER array describing the ID Type Structure - Type 2.
**/
STATIC CONST ACPI_PARSER IdStructureParser[] = {
{L"Type", 1, 0, L"0x%x", 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},
STATIC CONST ACPI_PARSER IdStructureParser[] = {
{ L"Type", 1, 0, L"0x%x", 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"VENDOR_ID", 4, 4, NULL, Dump4Chars, 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"MAJOR_REV", 2, 24, 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"VENDOR_ID", 4, 4, NULL, Dump4Chars, 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"MAJOR_REV", 2, 24, 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 },
};
/**
@ -248,13 +253,13 @@ STATIC CONST ACPI_PARSER IdStructureParser[] = {
STATIC
VOID
DumpProcessorHierarchyNodeStructure (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
UINT32 Offset;
UINT32 Index;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
UINT32 Offset;
UINT32 Index;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
Offset = ParseAcpi (
TRUE,
@ -281,8 +286,8 @@ DumpProcessorHierarchyNodeStructure (
IncrementErrorCount ();
Print (
L"ERROR: Invalid Number of Private Resources. " \
L"PrivateResourceCount = %d. RemainingBufferLength = %d. " \
L"Parsing of this structure aborted.\n",
L"PrivateResourceCount = %d. RemainingBufferLength = %d. " \
L"Parsing of this structure aborted.\n",
*NumberOfPrivateResources,
Length - Offset
);
@ -304,7 +309,7 @@ DumpProcessorHierarchyNodeStructure (
PrintFieldName (4, Buffer);
Print (
L"0x%x\n",
*((UINT32*)(Ptr + Offset))
*((UINT32 *)(Ptr + Offset))
);
Offset += sizeof (UINT32);
@ -321,7 +326,7 @@ DumpProcessorHierarchyNodeStructure (
STATIC
VOID
DumpCacheTypeStructure (
IN UINT8* Ptr,
IN UINT8 *Ptr,
IN UINT8 Length
)
{
@ -344,8 +349,8 @@ DumpCacheTypeStructure (
STATIC
VOID
DumpIDStructure (
IN UINT8* Ptr,
IN UINT8 Length
IN UINT8 *Ptr,
IN UINT8 Length
)
{
ParseAcpi (
@ -378,14 +383,14 @@ DumpIDStructure (
VOID
EFIAPI
ParseAcpiPptt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* ProcessorTopologyStructurePtr;
UINT32 Offset;
UINT8 *ProcessorTopologyStructurePtr;
if (!Trace) {
return;
@ -416,11 +421,12 @@ ParseAcpiPptt (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((ProcessorTopologyStructureType == NULL) ||
(ProcessorTopologyStructureLength == NULL)) {
(ProcessorTopologyStructureLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"processor topology structure header. Length = %d.\n",
L"processor topology structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -428,11 +434,12 @@ ParseAcpiPptt (
// Validate Processor Topology Structure length
if ((*ProcessorTopologyStructureLength == 0) ||
((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)) {
((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Processor Topology Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*ProcessorTopologyStructureLength,
Offset,
AcpiTableLength
@ -466,13 +473,13 @@ ParseAcpiPptt (
IncrementErrorCount ();
Print (
L"ERROR: Unknown processor topology structure:"
L" Type = %d, Length = %d\n",
L" Type = %d, Length = %d\n",
*ProcessorTopologyStructureType,
*ProcessorTopologyStructureLength
);
}
ProcessorTopologyStructurePtr += *ProcessorTopologyStructureLength;
Offset += *ProcessorTopologyStructureLength;
Offset += *ProcessorTopologyStructureLength;
} // while
}

View File

@ -16,22 +16,22 @@
/// Cache parameters allowed by the architecture with
/// ARMv8.3-CCIDX (Cache extended number of sets)
/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0001
#define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX (1 << 24)
#define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX (1 << 21)
#define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX (1 << 24)
#define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX (1 << 21)
/// Cache parameters allowed by the architecture without
/// ARMv8.3-CCIDX (Cache extended number of sets)
/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0000
#define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX (1 << 15)
#define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX (1 << 10)
#define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX (1 << 15)
#define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX (1 << 10)
/// Common cache parameters
/// Derived from CCSIDR_EL1
/// The LineSize is represented by bits 2:0
/// (Log2(Number of bytes in cache line)) - 4 is used to represent
/// the LineSize bits.
#define PPTT_ARM_CACHE_LINE_SIZE_MAX (1 << 11)
#define PPTT_ARM_CACHE_LINE_SIZE_MIN (1 << 4)
#define PPTT_ARM_CACHE_LINE_SIZE_MAX (1 << 11)
#define PPTT_ARM_CACHE_LINE_SIZE_MIN (1 << 4)
#endif // if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)

View File

@ -13,7 +13,7 @@
#include "AcpiTableParser.h"
// Local Variables
STATIC CONST UINT64* XsdtAddress;
STATIC CONST UINT64 *XsdtAddress;
/**
This function validates the RSDT Address.
@ -26,19 +26,19 @@ STATIC
VOID
EFIAPI
ValidateRsdtAddress (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
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
// Section: 4.2.1.1 RSDP
// Root System Description Pointer (RSDP), ACPI ? 5.2.5.
// - Within the RSDP, the RsdtAddress field must be null (zero) and the
// XsdtAddresss MUST be a valid, non-null, 64-bit value.
UINT32 RsdtAddr;
UINT32 RsdtAddr;
RsdtAddr = *(UINT32*)Ptr;
RsdtAddr = *(UINT32 *)Ptr;
if (RsdtAddr != 0) {
IncrementErrorCount ();
@ -47,7 +47,8 @@ ValidateRsdtAddress (
RsdtAddr
);
}
#endif
#endif
}
/**
@ -61,19 +62,19 @@ STATIC
VOID
EFIAPI
ValidateXsdtAddress (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
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
// Section: 4.2.1.1 RSDP
// Root System Description Pointer (RSDP), ACPI ? 5.2.5.
// - Within the RSDP, the RsdtAddress field must be null (zero) and the
// XsdtAddresss MUST be a valid, non-null, 64-bit value.
UINT64 XsdtAddr;
UINT64 XsdtAddr;
XsdtAddr = *(UINT64*)Ptr;
XsdtAddr = *(UINT64 *)Ptr;
if (XsdtAddr == 0) {
IncrementErrorCount ();
@ -82,23 +83,24 @@ ValidateXsdtAddress (
XsdtAddr
);
}
#endif
#endif
}
/**
An array describing the ACPI RSDP Table.
**/
STATIC CONST ACPI_PARSER RsdpParser[] = {
{L"Signature", 8, 0, NULL, Dump8Chars, 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"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL},
{L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL},
{L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL},
{L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID**)&XsdtAddress,
ValidateXsdtAddress, 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}
STATIC CONST ACPI_PARSER RsdpParser[] = {
{ L"Signature", 8, 0, NULL, Dump8Chars, 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"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL },
{ L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL },
{ L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL },
{ L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID **)&XsdtAddress,
ValidateXsdtAddress, 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 }
};
/**
@ -118,10 +120,10 @@ STATIC CONST ACPI_PARSER RsdpParser[] = {
VOID
EFIAPI
ParseAcpiRsdp (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (Trace) {
@ -144,7 +146,7 @@ ParseAcpiRsdp (
IncrementErrorCount ();
Print (
L"ERROR: Insufficient table length. AcpiTableLength = %d." \
L"RSDP parsing aborted.\n",
L"RSDP parsing aborted.\n",
AcpiTableLength
);
return;
@ -160,5 +162,5 @@ ParseAcpiRsdp (
return;
}
ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress));
ProcessAcpiTable ((UINT8 *)(UINTN)(*XsdtAddress));
}

View File

@ -15,22 +15,22 @@
#include "AcpiTableParser.h"
// Local Variables
STATIC CONST UINT64* SlitSystemLocalityCount;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT64 *SlitSystemLocalityCount;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
An ACPI_PARSER array describing the ACPI SLIT table.
**/
STATIC CONST ACPI_PARSER SlitParser[] = {
STATIC CONST ACPI_PARSER SlitParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Number of System Localities", 8, 36, L"0x%lx", NULL,
(VOID**)&SlitSystemLocalityCount, NULL, NULL}
{ L"Number of System Localities", 8, 36, L"0x%lx", NULL,
(VOID **)&SlitSystemLocalityCount,NULL, NULL }
};
/**
Macro to get the value of a System Locality
**/
#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)
#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)
/**
This function parses the ACPI SLIT table.
@ -50,18 +50,18 @@ STATIC CONST ACPI_PARSER SlitParser[] = {
VOID
EFIAPI
ParseAcpiSlit (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT32 Count;
UINT32 Index;
UINT32 LocalityCount;
UINT8* LocalityPtr;
CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi
UINT32 Offset;
UINT32 Count;
UINT32 Index;
UINT32 LocalityCount;
UINT8 *LocalityPtr;
CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi
if (!Trace) {
return;
@ -103,8 +103,8 @@ ParseAcpiSlit (
IncrementErrorCount ();
Print (
L"ERROR: The Number of System Localities provided can't be represented " \
L"in the SLIT table. SlitSystemLocalityCount = %ld. " \
L"MaxLocalityCountAllowed = %d.\n",
L"in the SLIT table. SlitSystemLocalityCount = %ld. " \
L"MaxLocalityCountAllowed = %d.\n",
*SlitSystemLocalityCount,
MAX_UINT16
);
@ -118,7 +118,7 @@ ParseAcpiSlit (
IncrementErrorCount ();
Print (
L"ERROR: Invalid Number of System Localities. " \
L"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",
L"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",
*SlitSystemLocalityCount,
AcpiTableLength
);
@ -144,12 +144,14 @@ ParseAcpiSlit (
for (Index = 0; Index < LocalityCount; Index++) {
Print (L" (%3d) ", Index);
}
Print (L"\n");
for (Count = 0; Count< LocalityCount; Count++) {
for (Count = 0; Count < LocalityCount; Count++) {
Print (L" (%3d) ", Count);
for (Index = 0; Index < LocalityCount; Index++) {
Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index));
}
Print (L"\n");
}
}
@ -158,23 +160,25 @@ ParseAcpiSlit (
for (Count = 0; Count < LocalityCount; Count++) {
for (Index = 0; Index < LocalityCount; Index++) {
// 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 ();
Print (
L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
L" Normalized Value is not 10\n",
L" Normalized Value is not 10\n",
Count,
Index,
SLIT_ELEMENT (LocalityPtr, Count, Index)
);
}
// Element[i][j] must be equal to Element[j][i]
if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
SLIT_ELEMENT (LocalityPtr, Index, Count)) {
SLIT_ELEMENT (LocalityPtr, Index, Count))
{
IncrementErrorCount ();
Print (
L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
L"Element[0x%lx][0x%lx] (%3d) do not match.\n",
L"Element[0x%lx][0x%lx] (%3d) do not match.\n",
Count,
Index,
SLIT_ELEMENT (LocalityPtr, Count, Index),

View File

@ -16,7 +16,7 @@
#include "AcpiTableParser.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the Interrupt Type.
@ -29,24 +29,26 @@ STATIC
VOID
EFIAPI
ValidateInterruptType (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 InterruptType;
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 InterruptType;
InterruptType = *Ptr;
if (InterruptType !=
EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC)
{
IncrementErrorCount ();
Print (
L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
InterruptType
);
}
#endif
#endif
}
/**
@ -60,12 +62,12 @@ STATIC
VOID
EFIAPI
ValidateIrq (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 Irq;
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
UINT8 Irq;
Irq = *Ptr;
@ -76,35 +78,36 @@ ValidateIrq (
Irq
);
}
#endif
#endif
}
/**
An ACPI_PARSER array describing the ACPI SPCR Table.
**/
STATIC CONST ACPI_PARSER SpcrParser[] = {
STATIC CONST ACPI_PARSER SpcrParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Interface Type", 1, 36, L"%d", NULL, 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"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, 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"Baud Rate", 1, 58, 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"Flow Control", 1, 61, L"0x%x", 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"Interface Type", 1, 36, L"%d", NULL, 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"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, 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"Baud Rate", 1, 58, 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"Flow Control", 1, 61, L"0x%x", 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"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 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 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 Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL},
{L"Reserved", 4, 76, L"%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 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 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 Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL }
};
/**
@ -122,10 +125,10 @@ STATIC CONST ACPI_PARSER SpcrParser[] = {
VOID
EFIAPI
ParseAcpiSpcr (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {

View File

@ -16,10 +16,10 @@
#include "AcpiViewConfig.h"
// Local Variables
STATIC CONST UINT8* SratRAType;
STATIC CONST UINT8* SratRALength;
STATIC CONST UINT8* SratDeviceHandleType;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC CONST UINT8 *SratRAType;
STATIC CONST UINT8 *SratRALength;
STATIC CONST UINT8 *SratDeviceHandleType;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the Reserved field in the SRAT table header.
@ -32,11 +32,11 @@ STATIC
VOID
EFIAPI
ValidateSratReserved (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*(UINT32*)Ptr != 1) {
if (*(UINT32 *)Ptr != 1) {
IncrementErrorCount ();
Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n");
}
@ -54,11 +54,11 @@ STATIC
VOID
EFIAPI
ValidateSratDeviceHandleType (
IN UINT8* Ptr,
IN VOID* Context
IN UINT8 *Ptr,
IN VOID *Context
)
{
UINT8 DeviceHandleType;
UINT8 DeviceHandleType;
DeviceHandleType = *Ptr;
@ -82,11 +82,11 @@ STATIC
VOID
EFIAPI
DumpSratPciBdfNumber (
IN CONST CHAR16* Format,
IN UINT8* Ptr
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
Print (L"\n");
@ -143,20 +143,20 @@ DumpSratPciBdfNumber (
/**
An ACPI_PARSER array describing the Device Handle - ACPI
**/
STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = {
{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"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}
STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = {
{ 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"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Device Handle - PCI
**/
STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = {
{L"PCI Segment", 2, 0, L"0x%x", NULL, 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,
NULL, NULL, NULL}
STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = {
{ L"PCI Segment", 2, 0, L"0x%x", NULL, 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,
NULL, NULL, NULL }
};
/**
@ -170,9 +170,9 @@ STATIC
VOID
EFIAPI
DumpSratDeviceHandle (
IN CONST CHAR16* Format,
IN UINT8* Ptr
)
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
if (SratDeviceHandleType == NULL) {
IncrementErrorCount ();
@ -213,11 +213,11 @@ STATIC
VOID
EFIAPI
DumpSratApicProximity (
IN CONST CHAR16* Format,
IN UINT8* Ptr
)
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
)
{
UINT32 ProximityDomain;
UINT32 ProximityDomain;
ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16);
@ -227,108 +227,108 @@ DumpSratApicProximity (
/**
An ACPI_PARSER array describing the SRAT Table.
**/
STATIC CONST ACPI_PARSER SratParser[] = {
STATIC CONST ACPI_PARSER SratParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{L"Reserved", 4, 36, L"0x%x", NULL, NULL, ValidateSratReserved, NULL},
{L"Reserved", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}
{ L"Reserved", 4, 36, L"0x%x", NULL, NULL, ValidateSratReserved, NULL },
{ L"Reserved", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Resource Allocation structure header.
**/
STATIC CONST ACPI_PARSER SratResourceAllocationParser[] = {
{L"Type", 1, 0, NULL, NULL, (VOID**)&SratRAType, NULL, NULL},
{L"Length", 1, 1, NULL, NULL, (VOID**)&SratRALength, NULL, NULL}
STATIC CONST ACPI_PARSER SratResourceAllocationParser[] = {
{ L"Type", 1, 0, NULL, NULL, (VOID **)&SratRAType, NULL, NULL },
{ L"Length", 1, 1, NULL, NULL, (VOID **)&SratRALength, NULL, NULL }
};
/**
An ACPI_PARSER array describing the GICC Affinity structure.
**/
STATIC CONST ACPI_PARSER SratGicCAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratGicCAffinityParser[] = {
{ L"Type", 1, 0, 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"ACPI Processor UID", 4, 6, 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"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"Flags", 4, 10, 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.
**/
STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = {
{ L"Type", 1, 0, 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"Reserved", 2, 6, L"0x%x", NULL, NULL, NULL, NULL},
{L"ITS Id", 4, 8, 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"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the Generic Initiator Affinity Structure
**/
STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = {
{ L"Type", 1, 0, 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"Device Handle Type", 1, 3, L"%d", NULL, (VOID**)&SratDeviceHandleType,
ValidateSratDeviceHandleType, 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"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
{L"Reserved", 4, 28, 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,
ValidateSratDeviceHandleType, 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"Flags", 4, 24, 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.
**/
STATIC CONST ACPI_PARSER SratMemAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratMemAffinityParser[] = {
{ L"Type", 1, 0, 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"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 High", 4, 12, 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"Reserved", 4, 24, 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"Proximity Domain", 4, 2, 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 High", 4, 12, 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"Reserved", 4, 24, 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 }
};
/**
An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
**/
STATIC CONST ACPI_PARSER SratApciSapicAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratApciSapicAffinityParser[] = {
{ L"Type", 1, 0, 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"APIC ID", 1, 3, 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"Proximity Domain [31:8]", 3, 9, L"0x%x", DumpSratApicProximity,
NULL, NULL, NULL},
{L"Clock Domain", 4, 12, 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"Flags", 4, 4, 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,
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.
**/
STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
{L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
{L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
{ L"Type", 1, 0, 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"Proximity Domain", 4, 4, 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"Clock Domain", 4, 16, L"0x%x", NULL, NULL, NULL, NULL},
{L"Reserved", 4, 20, 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"X2APIC ID", 4, 8, 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"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
@ -352,28 +352,28 @@ STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
VOID
EFIAPI
ParseAcpiSrat (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8* ResourcePtr;
UINT32 GicCAffinityIndex;
UINT32 GicITSAffinityIndex;
UINT32 GenericInitiatorAffinityIndex;
UINT32 MemoryAffinityIndex;
UINT32 ApicSapicAffinityIndex;
UINT32 X2ApicAffinityIndex;
CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi
UINT32 Offset;
UINT8 *ResourcePtr;
UINT32 GicCAffinityIndex;
UINT32 GicITSAffinityIndex;
UINT32 GenericInitiatorAffinityIndex;
UINT32 MemoryAffinityIndex;
UINT32 ApicSapicAffinityIndex;
UINT32 X2ApicAffinityIndex;
CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi
GicCAffinityIndex = 0;
GicITSAffinityIndex = 0;
GicCAffinityIndex = 0;
GicITSAffinityIndex = 0;
GenericInitiatorAffinityIndex = 0;
MemoryAffinityIndex = 0;
ApicSapicAffinityIndex = 0;
X2ApicAffinityIndex = 0;
MemoryAffinityIndex = 0;
ApicSapicAffinityIndex = 0;
X2ApicAffinityIndex = 0;
if (!Trace) {
return;
@ -403,11 +403,12 @@ ParseAcpiSrat (
// Check if the values used to control the parsing logic have been
// successfully read.
if ((SratRAType == NULL) ||
(SratRALength == NULL)) {
(SratRALength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"Static Resource Allocation structure header. Length = %d.\n",
L"Static Resource Allocation structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
@ -415,11 +416,12 @@ ParseAcpiSrat (
// Validate Static Resource Allocation Structure length
if ((*SratRALength == 0) ||
((Offset + (*SratRALength)) > AcpiTableLength)) {
((Offset + (*SratRALength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Static Resource Allocation Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*SratRALength,
Offset,
AcpiTableLength
@ -451,7 +453,7 @@ ParseAcpiSrat (
sizeof (Buffer),
"GIC ITS Affinity Structure [%d]",
GicITSAffinityIndex++
);
);
ParseAcpi (
TRUE,
2,
@ -468,7 +470,7 @@ ParseAcpiSrat (
sizeof (Buffer),
"Generic Initiator Affinity Structure [%d]",
GenericInitiatorAffinityIndex++
);
);
ParseAcpi (
TRUE,
2,
@ -476,7 +478,7 @@ ParseAcpiSrat (
ResourcePtr,
*SratRALength,
PARSER_PARAMS (SratGenericInitiatorAffinityParser)
);
);
break;
case EFI_ACPI_6_3_MEMORY_AFFINITY:
@ -537,6 +539,6 @@ ParseAcpiSrat (
}
ResourcePtr += (*SratRALength);
Offset += (*SratRALength);
Offset += (*SratRALength);
}
}

View File

@ -28,10 +28,10 @@
VOID
EFIAPI
ParseAcpiSsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {

View File

@ -15,11 +15,11 @@
#include "AcpiTableParser.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/** An ACPI_PARSER array describing the ACPI XSDT table.
*/
STATIC CONST ACPI_PARSER XsdtParser[] = {
STATIC CONST ACPI_PARSER XsdtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
@ -30,7 +30,7 @@ CONST ACPI_DESCRIPTION_HEADER_INFO *
EFIAPI
GetAcpiXsdtHeaderInfo (
VOID
)
)
{
return &AcpiHdrInfo;
}
@ -48,17 +48,17 @@ GetAcpiXsdtHeaderInfo (
VOID
EFIAPI
ParseAcpiXsdt (
IN BOOLEAN Trace,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT32 TableOffset;
UINT64* TablePointer;
UINTN EntryIndex;
CHAR16 Buffer[32];
UINT32 Offset;
UINT32 TableOffset;
UINT64 *TablePointer;
UINTN EntryIndex;
CHAR16 Buffer[32];
Offset = ParseAcpi (
Trace,
@ -72,24 +72,24 @@ ParseAcpiXsdt (
TableOffset = Offset;
if (Trace) {
EntryIndex = 0;
TablePointer = (UINT64*)(Ptr + TableOffset);
EntryIndex = 0;
TablePointer = (UINT64 *)(Ptr + TableOffset);
while (Offset < AcpiTableLength) {
CONST UINT32* Signature;
CONST UINT32* Length;
CONST UINT8* Revision;
CONST UINT32 *Signature;
CONST UINT32 *Length;
CONST UINT8 *Revision;
if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
UINT8* SignaturePtr;
if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
UINT8 *SignaturePtr;
ParseAcpiHeader (
(UINT8*)(UINTN)(*TablePointer),
(UINT8 *)(UINTN)(*TablePointer),
&Signature,
&Length,
&Revision
);
SignaturePtr = (UINT8*)Signature;
SignaturePtr = (UINT8 *)Signature;
UnicodeSPrint (
Buffer,
@ -114,7 +114,7 @@ ParseAcpiXsdt (
Print (L"0x%lx\n", *TablePointer);
// Validate the table pointers are not NULL
if ((UINT64*)(UINTN)(*TablePointer) == NULL) {
if ((UINT64 *)(UINTN)(*TablePointer) == NULL) {
IncrementErrorCount ();
Print (
L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n",
@ -122,18 +122,20 @@ ParseAcpiXsdt (
*TablePointer
);
}
Offset += sizeof (UINT64);
TablePointer++;
} // while
}
// Process the tables
Offset = TableOffset;
TablePointer = (UINT64*)(Ptr + TableOffset);
Offset = TableOffset;
TablePointer = (UINT64 *)(Ptr + TableOffset);
while (Offset < AcpiTableLength) {
if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer));
if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {
ProcessAcpiTable ((UINT8 *)(UINTN)(*TablePointer));
}
Offset += sizeof (UINT64);
TablePointer++;
} // while

View File

@ -25,20 +25,20 @@
#include "AcpiView.h"
#include "AcpiViewConfig.h"
CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";
EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
/**
An array of acpiview command line parameters.
**/
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-q", TypeFlag},
{L"-d", TypeFlag},
{L"-h", TypeFlag},
{L"-l", TypeFlag},
{L"-s", TypeValue},
{L"-r", TypeValue},
{NULL, TypeMax}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-q", TypeFlag },
{ L"-d", TypeFlag },
{ L"-h", TypeFlag },
{ L"-l", TypeFlag },
{ L"-s", TypeValue },
{ L"-r", TypeValue },
{ NULL, TypeMax }
};
/**
@ -46,30 +46,30 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
*/
STATIC
CONST
ACPI_TABLE_PARSER ParserList[] = {
{EFI_ACPI_6_3_ARM_ERROR_SOURCE_TABLE_SIGNATURE, ParseAcpiAest},
{EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, ParseAcpiBgrt},
{EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2},
{EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
ParseAcpiDsdt},
{EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs},
{EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt},
{EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt},
{EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiHmat},
{EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort},
{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,
ParseAcpiMcfg},
{EFI_ACPI_6_4_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE,
ParseAcpiPcct},
{EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
ParseAcpiPptt},
{RSDP_TABLE_INFO, ParseAcpiRsdp},
{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_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat},
{EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt},
{EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiXsdt}
ACPI_TABLE_PARSER ParserList[] = {
{ EFI_ACPI_6_3_ARM_ERROR_SOURCE_TABLE_SIGNATURE, ParseAcpiAest },
{ EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, ParseAcpiBgrt },
{ EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2 },
{ EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
ParseAcpiDsdt },
{ EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs },
{ EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt },
{ EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt },
{ EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiHmat },
{ EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort },
{ 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,
ParseAcpiMcfg },
{ EFI_ACPI_6_4_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE,
ParseAcpiPcct },
{ EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
ParseAcpiPptt },
{ RSDP_TABLE_INFO, ParseAcpiRsdp },
{ 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_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat },
{ EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt },
{ EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiXsdt }
};
/**
@ -86,11 +86,11 @@ EFI_STATUS
RegisterAllParsers (
)
{
EFI_STATUS Status;
UINTN Count;
EFI_STATUS Status;
UINTN Count;
Status = EFI_SUCCESS;
Count = sizeof (ParserList) / sizeof (ParserList[0]);
Count = sizeof (ParserList) / sizeof (ParserList[0]);
while (Count-- != 0) {
Status = RegisterParser (
@ -101,6 +101,7 @@ RegisterAllParsers (
return Status;
}
}
return Status;
}
@ -116,14 +117,14 @@ RegisterAllParsers (
UINTN
EFIAPI
ShellDumpBufferToFile (
IN CONST CHAR16* FileNameBuffer,
IN CONST VOID* Buffer,
IN CONST CHAR16 *FileNameBuffer,
IN CONST VOID *Buffer,
IN CONST UINTN BufferSize
)
{
EFI_STATUS Status;
SHELL_FILE_HANDLE DumpFileHandle;
UINTN TransferBytes;
EFI_STATUS Status;
SHELL_FILE_HANDLE DumpFileHandle;
UINTN TransferBytes;
Status = ShellOpenFileByName (
FileNameBuffer,
@ -145,11 +146,11 @@ ShellDumpBufferToFile (
}
TransferBytes = BufferSize;
Status = ShellWriteFile (
DumpFileHandle,
&TransferBytes,
(VOID *) Buffer
);
Status = ShellWriteFile (
DumpFileHandle,
&TransferBytes,
(VOID *)Buffer
);
if (EFI_ERROR (Status)) {
Print (L"ERROR: Failed to write binary file.\n");
@ -167,7 +168,7 @@ ShellDumpBufferToFile (
@return The string pointer to the file name.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellCommandGetManFileNameAcpiView (
VOID
@ -190,27 +191,27 @@ SHELL_STATUS
EFIAPI
ShellCommandRunAcpiView (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE* SystemTable
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
LIST_ENTRY* Package;
CHAR16* ProblemParam;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_FILE_HANDLE TmpDumpFileHandle;
CONST CHAR16* MandatoryTableSpecStr;
CONST CHAR16* SelectedTableName;
CONST CHAR16 *MandatoryTableSpecStr;
CONST CHAR16 *SelectedTableName;
// Set configuration defaults
AcpiConfigSetDefaults ();
ShellStatus = SHELL_SUCCESS;
Package = NULL;
ShellStatus = SHELL_SUCCESS;
Package = NULL;
TmpDumpFileHandle = NULL;
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (
-1,
-1,
@ -224,6 +225,7 @@ ShellCommandRunAcpiView (
} else {
Print (L"acpiview: Error processing input parameter(s)\n");
}
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetCount (Package) > 1) {
@ -246,7 +248,8 @@ ShellCommandRunAcpiView (
L"acpiview"
);
} else if (ShellCommandLineGetFlag (Package, L"-s") &&
ShellCommandLineGetValue (Package, L"-s") == NULL) {
(ShellCommandLineGetValue (Package, L"-s") == NULL))
{
ShellPrintHiiEx (
-1,
-1,
@ -258,7 +261,8 @@ ShellCommandRunAcpiView (
);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag (Package, L"-r") &&
ShellCommandLineGetValue (Package, L"-r") == NULL) {
(ShellCommandLineGetValue (Package, L"-r") == NULL))
{
ShellPrintHiiEx (
-1,
-1,
@ -270,7 +274,8 @@ ShellCommandRunAcpiView (
);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if ((ShellCommandLineGetFlag (Package, L"-s") &&
ShellCommandLineGetFlag (Package, L"-l"))) {
ShellCommandLineGetFlag (Package, L"-l")))
{
ShellPrintHiiEx (
-1,
-1,
@ -281,18 +286,19 @@ ShellCommandRunAcpiView (
);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetFlag (Package, L"-d") &&
!ShellCommandLineGetFlag (Package, L"-s")) {
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_MISSING_OPTION),
gShellAcpiViewHiiHandle,
L"acpiview",
L"-s",
L"-d"
);
ShellStatus = SHELL_INVALID_PARAMETER;
!ShellCommandLineGetFlag (Package, L"-s"))
{
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_GEN_MISSING_OPTION),
gShellAcpiViewHiiHandle,
L"acpiview",
L"-s",
L"-d"
);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
// Turn on colour highlighting if requested
SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
@ -316,9 +322,9 @@ ShellCommandRunAcpiView (
SelectAcpiTable (SelectedTableName);
SetReportOption (ReportSelected);
if (ShellCommandLineGetFlag (Package, L"-d")) {
if (ShellCommandLineGetFlag (Package, L"-d")) {
// Create a temporary file to check if the media is writable.
CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
SetReportOption (ReportDumpBinFile);
UnicodeSPrint (
@ -337,7 +343,7 @@ ShellCommandRunAcpiView (
);
if (EFI_ERROR (Status)) {
ShellStatus = SHELL_INVALID_PARAMETER;
ShellStatus = SHELL_INVALID_PARAMETER;
TmpDumpFileHandle = NULL;
ShellPrintHiiEx (
-1,
@ -349,6 +355,7 @@ ShellCommandRunAcpiView (
);
goto Done;
}
// Delete Temporary file.
ShellDeleteFile (&TmpDumpFileHandle);
} // -d
@ -367,6 +374,7 @@ Done:
if (Package != NULL) {
ShellCommandLineFreeVarList (Package);
}
return ShellStatus;
}
@ -389,7 +397,8 @@ UefiShellAcpiViewCommandLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
gShellAcpiViewHiiHandle = NULL;
// Check Shell Profile Debug1 bit of the profiles mask
@ -412,6 +421,7 @@ UefiShellAcpiViewCommandLibConstructor (
if (gShellAcpiViewHiiHandle == NULL) {
return EFI_DEVICE_ERROR;
}
// Install our Shell command handler
ShellCommandRegisterCommandName (
L"acpiview",
@ -443,5 +453,6 @@ UefiShellAcpiViewCommandLibDestructor (
if (gShellAcpiViewHiiHandle != NULL) {
HiiRemovePackages (gShellAcpiViewHiiHandle);
}
return EFI_SUCCESS;
}

View File

@ -43,51 +43,54 @@ ShellCEntryLib (
)
{
INTN ReturnFromMain;
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
EFI_SHELL_INTERFACE *EfiShellInterface;
EFI_STATUS Status;
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
EFI_SHELL_INTERFACE *EfiShellInterface;
EFI_STATUS Status;
ReturnFromMain = -1;
ReturnFromMain = -1;
EfiShellParametersProtocol = NULL;
EfiShellInterface = NULL;
EfiShellInterface = NULL;
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
&gEfiShellParametersProtocolGuid,
(VOID **)&EfiShellParametersProtocol,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR(Status)) {
Status = SystemTable->BootServices->OpenProtocol (
ImageHandle,
&gEfiShellParametersProtocolGuid,
(VOID **)&EfiShellParametersProtocol,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// use shell 2.0 interface
//
ReturnFromMain = ShellAppMain (
EfiShellParametersProtocol->Argc,
EfiShellParametersProtocol->Argv
);
);
} else {
//
// try to get shell 1.0 interface instead.
//
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
&gEfiShellInterfaceGuid,
(VOID **)&EfiShellInterface,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR(Status)) {
Status = SystemTable->BootServices->OpenProtocol (
ImageHandle,
&gEfiShellInterfaceGuid,
(VOID **)&EfiShellInterface,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// use shell 1.0 interface
//
ReturnFromMain = ShellAppMain (
EfiShellInterface->Argc,
EfiShellInterface->Argv
);
);
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
}
return ReturnFromMain;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -41,24 +41,24 @@
#include <Library/UefiLib.h>
#include <Library/OrderedCollectionLib.h>
typedef struct{
LIST_ENTRY Link;
CHAR16 *CommandString;
SHELL_GET_MAN_FILENAME GetManFileName;
SHELL_RUN_COMMAND CommandHandler;
BOOLEAN LastError;
EFI_HII_HANDLE HiiHandle;
EFI_STRING_ID ManFormatHelp;
typedef struct {
LIST_ENTRY Link;
CHAR16 *CommandString;
SHELL_GET_MAN_FILENAME GetManFileName;
SHELL_RUN_COMMAND CommandHandler;
BOOLEAN LastError;
EFI_HII_HANDLE HiiHandle;
EFI_STRING_ID ManFormatHelp;
} SHELL_COMMAND_INTERNAL_LIST_ENTRY;
typedef struct {
LIST_ENTRY Link;
SCRIPT_FILE *Data;
LIST_ENTRY Link;
SCRIPT_FILE *Data;
} SCRIPT_FILE_LIST;
typedef struct {
EFI_FILE_PROTOCOL *FileHandle;
CHAR16 *Path;
EFI_FILE_PROTOCOL *FileHandle;
CHAR16 *Path;
} SHELL_COMMAND_FILE_HANDLE;
//
@ -72,13 +72,12 @@ typedef struct {
// instead, it *aliases* the FileName or FullName field of the
// EFI_SHELL_FILE_INFO object that was first encountered with this name.
//
CONST CHAR16 *Alias;
CONST CHAR16 *Alias;
//
// A list of EFI_SHELL_FILE_INFO objects whose FileName or FullName fields
// compare equal to Alias, according to gUnicodeCollation->StriColl().
//
LIST_ENTRY SameNameList;
LIST_ENTRY SameNameList;
} SHELL_SORT_UNIQUE_NAME;
#endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_

View File

@ -9,11 +9,11 @@
#include "UefiShellDebug1CommandsLib.h"
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-n", TypeValue},
{L"-s", TypeValue},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-n", TypeValue },
{ L"-s", TypeValue },
{ NULL, TypeMax }
};
typedef enum {
OutOfDiffPoint,
@ -25,10 +25,10 @@ typedef enum {
// Buffer type, for reading both file operands in chunks.
//
typedef struct {
UINT8 *Data; // dynamically allocated buffer
UINTN Allocated; // the allocated size of Data
UINTN Next; // next position in Data to fetch a byte at
UINTN Left; // number of bytes left in Data for fetching at Next
UINT8 *Data; // dynamically allocated buffer
UINTN Allocated; // the allocated size of Data
UINTN Next; // next position in Data to fetch a byte at
UINTN Left; // number of bytes left in Data for fetching at Next
} FILE_BUFFER;
/**
@ -43,7 +43,7 @@ typedef struct {
**/
VOID
PrintDifferentPoint(
PrintDifferentPoint (
CONST CHAR16 *FileName,
CHAR16 *FileTag,
UINT8 *Buffer,
@ -52,7 +52,7 @@ PrintDifferentPoint(
UINT64 DifferentBytes
)
{
UINTN Index;
UINTN Index;
ShellPrintEx (-1, -1, L"%s: %s\r\n %08x:", FileTag, FileName, Address);
@ -73,7 +73,7 @@ PrintDifferentPoint(
// Print data in char-format.
//
for (Index = 0; Index < BufferSize; Index++) {
if (Buffer[Index] >= 0x20 && Buffer[Index] <= 0x7E) {
if ((Buffer[Index] >= 0x20) && (Buffer[Index] <= 0x7E)) {
ShellPrintEx (-1, -1, L"%c", Buffer[Index]);
} else {
//
@ -97,7 +97,7 @@ PrintDifferentPoint(
STATIC
VOID
FileBufferInit (
OUT FILE_BUFFER *FileBuffer
OUT FILE_BUFFER *FileBuffer
)
{
FileBuffer->Allocated = PcdGet32 (PcdShellFileOperationSize);
@ -116,7 +116,7 @@ FileBufferInit (
STATIC
VOID
FileBufferUninit (
IN OUT FILE_BUFFER *FileBuffer
IN OUT FILE_BUFFER *FileBuffer
)
{
SHELL_FREE_NON_NULL (FileBuffer->Data);
@ -154,26 +154,31 @@ FileBufferUninit (
STATIC
EFI_STATUS
FileBufferReadByte (
IN SHELL_FILE_HANDLE FileHandle,
IN OUT FILE_BUFFER *FileBuffer,
OUT UINTN *BytesRead,
OUT UINT8 *Byte
IN SHELL_FILE_HANDLE FileHandle,
IN OUT FILE_BUFFER *FileBuffer,
OUT UINTN *BytesRead,
OUT UINT8 *Byte
)
{
UINTN ReadSize;
EFI_STATUS Status;
UINTN ReadSize;
EFI_STATUS Status;
if (FileBuffer->Left == 0) {
ReadSize = FileBuffer->Allocated;
Status = gEfiShellProtocol->ReadFile (FileHandle, &ReadSize,
FileBuffer->Data);
Status = gEfiShellProtocol->ReadFile (
FileHandle,
&ReadSize,
FileBuffer->Data
);
if (EFI_ERROR (Status)) {
return Status;
}
if (ReadSize == 0) {
*BytesRead = 0;
return EFI_SUCCESS;
}
FileBuffer->Next = 0;
FileBuffer->Left = ReadSize;
}
@ -199,112 +204,114 @@ ShellCommandRunComp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CHAR16 *FileName1;
CHAR16 *FileName2;
CONST CHAR16 *TempParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE FileHandle1;
SHELL_FILE_HANDLE FileHandle2;
UINT64 Size1;
UINT64 Size2;
UINT64 DifferentBytes;
UINT64 DifferentCount;
UINT8 DiffPointNumber;
UINT8 OneByteFromFile1;
UINT8 OneByteFromFile2;
UINT8 *DataFromFile1;
UINT8 *DataFromFile2;
FILE_BUFFER FileBuffer1;
FILE_BUFFER FileBuffer2;
UINTN InsertPosition1;
UINTN InsertPosition2;
UINTN DataSizeFromFile1;
UINTN DataSizeFromFile2;
UINTN TempAddress;
UINTN Index;
UINTN DiffPointAddress;
READ_STATUS ReadStatus;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CHAR16 *FileName1;
CHAR16 *FileName2;
CONST CHAR16 *TempParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE FileHandle1;
SHELL_FILE_HANDLE FileHandle2;
UINT64 Size1;
UINT64 Size2;
UINT64 DifferentBytes;
UINT64 DifferentCount;
UINT8 DiffPointNumber;
UINT8 OneByteFromFile1;
UINT8 OneByteFromFile2;
UINT8 *DataFromFile1;
UINT8 *DataFromFile2;
FILE_BUFFER FileBuffer1;
FILE_BUFFER FileBuffer2;
UINTN InsertPosition1;
UINTN InsertPosition2;
UINTN DataSizeFromFile1;
UINTN DataSizeFromFile2;
UINTN TempAddress;
UINTN Index;
UINTN DiffPointAddress;
READ_STATUS ReadStatus;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
FileName1 = NULL;
FileName2 = NULL;
FileHandle1 = NULL;
FileHandle2 = NULL;
DataFromFile1 = NULL;
DataFromFile2 = NULL;
ReadStatus = OutOfDiffPoint;
DifferentCount = 10;
DifferentBytes = 4;
DiffPointNumber = 0;
InsertPosition1 = 0;
InsertPosition2 = 0;
TempAddress = 0;
DiffPointAddress = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
FileName1 = NULL;
FileName2 = NULL;
FileHandle1 = NULL;
FileHandle2 = NULL;
DataFromFile1 = NULL;
DataFromFile2 = NULL;
ReadStatus = OutOfDiffPoint;
DifferentCount = 10;
DifferentBytes = 4;
DiffPointNumber = 0;
InsertPosition1 = 0;
InsertPosition2 = 0;
TempAddress = 0;
DiffPointAddress = 0;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = ShellInitialize ();
ASSERT_EFI_ERROR (Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
Status = CommandInit ();
ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"comp", ProblemParam);
FreePool(ProblemParam);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"comp", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"comp");
if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"comp");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"comp");
} else if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"comp");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
FileName1 = ShellFindFilePath(TempParam);
TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT (TempParam != NULL);
FileName1 = ShellFindFilePath (TempParam);
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;
} else {
Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
Status = ShellOpenFileByName (FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND;
}
}
TempParam = ShellCommandLineGetRawValue(Package, 2);
ASSERT(TempParam != NULL);
FileName2 = ShellFindFilePath(TempParam);
TempParam = ShellCommandLineGetRawValue (Package, 2);
ASSERT (TempParam != NULL);
FileName2 = ShellFindFilePath (TempParam);
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;
} else {
Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
Status = ShellOpenFileByName (FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
ShellStatus = SHELL_NOT_FOUND;
}
}
if (ShellStatus == SHELL_SUCCESS) {
Status = gEfiShellProtocol->GetFileSize(FileHandle1, &Size1);
ASSERT_EFI_ERROR(Status);
Status = gEfiShellProtocol->GetFileSize(FileHandle2, &Size2);
ASSERT_EFI_ERROR(Status);
Status = gEfiShellProtocol->GetFileSize (FileHandle1, &Size1);
ASSERT_EFI_ERROR (Status);
Status = gEfiShellProtocol->GetFileSize (FileHandle2, &Size2);
ASSERT_EFI_ERROR (Status);
if (ShellCommandLineGetFlag (Package, L"-n")) {
TempParam = ShellCommandLineGetValue (Package, L"-n");
@ -316,7 +323,7 @@ ShellCommandRunComp (
DifferentCount = MAX_UINTN;
} else {
Status = ShellConvertStringToUint64 (TempParam, &DifferentCount, FALSE, TRUE);
if (EFI_ERROR(Status) || DifferentCount == 0) {
if (EFI_ERROR (Status) || (DifferentCount == 0)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
}
@ -331,7 +338,7 @@ ShellCommandRunComp (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = ShellConvertStringToUint64 (TempParam, &DifferentBytes, FALSE, TRUE);
if (EFI_ERROR(Status) || DifferentBytes == 0) {
if (EFI_ERROR (Status) || (DifferentBytes == 0)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-s");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
@ -348,8 +355,9 @@ ShellCommandRunComp (
DataFromFile2 = AllocateZeroPool ((UINTN)DifferentBytes);
FileBufferInit (&FileBuffer1);
FileBufferInit (&FileBuffer2);
if (DataFromFile1 == NULL || DataFromFile2 == NULL ||
FileBuffer1.Data == NULL || FileBuffer2.Data == NULL) {
if ((DataFromFile1 == NULL) || (DataFromFile2 == NULL) ||
(FileBuffer1.Data == NULL) || (FileBuffer2.Data == NULL))
{
ShellStatus = SHELL_OUT_OF_RESOURCES;
SHELL_FREE_NON_NULL (DataFromFile1);
SHELL_FREE_NON_NULL (DataFromFile2);
@ -362,13 +370,21 @@ ShellCommandRunComp (
while (DiffPointNumber < DifferentCount) {
DataSizeFromFile1 = 1;
DataSizeFromFile2 = 1;
OneByteFromFile1 = 0;
OneByteFromFile2 = 0;
Status = FileBufferReadByte (FileHandle1, &FileBuffer1,
&DataSizeFromFile1, &OneByteFromFile1);
OneByteFromFile1 = 0;
OneByteFromFile2 = 0;
Status = FileBufferReadByte (
FileHandle1,
&FileBuffer1,
&DataSizeFromFile1,
&OneByteFromFile1
);
ASSERT_EFI_ERROR (Status);
Status = FileBufferReadByte (FileHandle2, &FileBuffer2,
&DataSizeFromFile2, &OneByteFromFile2);
Status = FileBufferReadByte (
FileHandle2,
&FileBuffer2,
&DataSizeFromFile2,
&OneByteFromFile2
);
ASSERT_EFI_ERROR (Status);
TempAddress++;
@ -378,19 +394,21 @@ ShellCommandRunComp (
// 2.If no more char in File1 or File2, The ReadStatus is InPrevDiffPoint forever.
// So the previous different point is the last one, then break the while block.
//
if ( (DataSizeFromFile1 == 0 && InsertPosition1 == 0 && DataSizeFromFile2 == 0 && InsertPosition2 == 0) ||
(ReadStatus == InPrevDiffPoint && (DataSizeFromFile1 == 0 || DataSizeFromFile2 == 0))
) {
if (((DataSizeFromFile1 == 0) && (InsertPosition1 == 0) && (DataSizeFromFile2 == 0) && (InsertPosition2 == 0)) ||
((ReadStatus == InPrevDiffPoint) && ((DataSizeFromFile1 == 0) || (DataSizeFromFile2 == 0)))
)
{
break;
}
if (ReadStatus == OutOfDiffPoint) {
if (OneByteFromFile1 != OneByteFromFile2) {
ReadStatus = InDiffPoint;
ReadStatus = InDiffPoint;
DiffPointAddress = TempAddress;
if (DataSizeFromFile1 == 1) {
DataFromFile1[InsertPosition1++] = OneByteFromFile1;
}
if (DataSizeFromFile2 == 1) {
DataFromFile2[InsertPosition2++] = OneByteFromFile2;
}
@ -399,6 +417,7 @@ ShellCommandRunComp (
if (DataSizeFromFile1 == 1) {
DataFromFile1[InsertPosition1++] = OneByteFromFile1;
}
if (DataSizeFromFile2 == 1) {
DataFromFile2[InsertPosition2++] = OneByteFromFile2;
}
@ -411,11 +430,11 @@ ShellCommandRunComp (
//
// ReadStatus should be always equal InDiffPoint.
//
if ( InsertPosition1 == DifferentBytes ||
InsertPosition2 == DifferentBytes ||
(DataSizeFromFile1 == 0 && DataSizeFromFile2 == 0)
) {
if ((InsertPosition1 == DifferentBytes) ||
(InsertPosition2 == DifferentBytes) ||
((DataSizeFromFile1 == 0) && (DataSizeFromFile2 == 0))
)
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber);
PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);
PrintDifferentPoint (FileName2, L"File2", DataFromFile2, InsertPosition2, DiffPointAddress, DifferentBytes);
@ -423,7 +442,7 @@ ShellCommandRunComp (
//
// One of two buffuers is empty, it means this is the last different point.
//
if (InsertPosition1 == 0 || InsertPosition2 == 0) {
if ((InsertPosition1 == 0) || (InsertPosition2 == 0)) {
break;
}
@ -438,9 +457,9 @@ ShellCommandRunComp (
//
// 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]) {
ReadStatus = InDiffPoint;
ReadStatus = InDiffPoint;
DiffPointAddress += Index;
break;
}
@ -469,24 +488,26 @@ ShellCommandRunComp (
FileBufferUninit (&FileBuffer2);
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 {
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);
}
SHELL_FREE_NON_NULL(FileName1);
SHELL_FREE_NON_NULL(FileName2);
SHELL_FREE_NON_NULL (FileName1);
SHELL_FREE_NON_NULL (FileName2);
if (FileHandle1 != NULL) {
gEfiShellProtocol->CloseFile(FileHandle1);
gEfiShellProtocol->CloseFile (FileHandle1);
}
if (FileHandle2 != NULL) {
gEfiShellProtocol->CloseFile(FileHandle2);
gEfiShellProtocol->CloseFile (FileHandle2);
}
return (ShellStatus);

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -17,13 +17,13 @@ typedef enum {
} DMP_STORE_TYPE;
typedef struct {
UINT32 Signature;
CHAR16 *Name;
EFI_GUID Guid;
UINT32 Attributes;
UINT32 DataSize;
UINT8 *Data;
LIST_ENTRY Link;
UINT32 Signature;
CHAR16 *Name;
EFI_GUID Guid;
UINT32 Attributes;
UINT32 DataSize;
UINT8 *Data;
LIST_ENTRY Link;
} DMP_STORE_VARIABLE;
#define DMP_STORE_VARIABLE_SIGNATURE SIGNATURE_32 ('_', 'd', 's', 's')
@ -37,39 +37,43 @@ typedef struct {
**/
CHAR16 *
GetAttrType (
IN CONST UINT32 Atts
IN CONST UINT32 Atts
)
{
UINTN BufLen;
CHAR16 *RetString;
UINTN BufLen;
CHAR16 *RetString;
BufLen = 0;
RetString = NULL;
BufLen = 0;
RetString = NULL;
if ((Atts & EFI_VARIABLE_NON_VOLATILE) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+NV", 0);
}
if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0);
} else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+BS", 0);
}
if ((Atts & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+HR", 0);
}
if ((Atts & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+AW", 0);
}
if ((Atts & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
StrnCatGrow (&RetString, &BufLen, L"+AT", 0);
}
if (RetString == NULL) {
RetString = StrnCatGrow(&RetString, &BufLen, L"Invalid", 0);
RetString = StrnCatGrow (&RetString, &BufLen, L"Invalid", 0);
}
if ((RetString != NULL) && (RetString[0] == L'+')) {
CopyMem(RetString, RetString + 1, StrSize(RetString + 1));
CopyMem (RetString, RetString + 1, StrSize (RetString + 1));
}
return RetString;
@ -85,7 +89,7 @@ GetAttrType (
@return The hex format string.
**/
CHAR16*
CHAR16 *
BinaryToHexString (
IN VOID *Buffer,
IN UINTN BufferSize,
@ -93,8 +97,8 @@ BinaryToHexString (
IN UINTN HexStringSize
)
{
UINTN Index;
UINTN StringIndex;
UINTN Index;
UINTN StringIndex;
ASSERT (Buffer != NULL);
ASSERT ((BufferSize * 2 + 1) * sizeof (CHAR16) <= HexStringSize);
@ -105,9 +109,10 @@ BinaryToHexString (
&HexString[StringIndex],
HexStringSize - StringIndex * sizeof (CHAR16),
L"%02x",
((UINT8 *) Buffer)[Index]
((UINT8 *)Buffer)[Index]
);
}
return HexString;
}
@ -126,26 +131,26 @@ BinaryToHexString (
**/
SHELL_STATUS
LoadVariablesFromFile (
IN SHELL_FILE_HANDLE FileHandle,
IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid,
OUT BOOLEAN *Found
IN SHELL_FILE_HANDLE FileHandle,
IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid,
OUT BOOLEAN *Found
)
{
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
UINT32 NameSize;
UINT32 DataSize;
UINTN BufferSize;
UINTN RemainingSize;
UINT64 Position;
UINT64 FileSize;
LIST_ENTRY List;
DMP_STORE_VARIABLE *Variable;
LIST_ENTRY *Link;
CHAR16 *Attributes;
UINT8 *Buffer;
UINT32 Crc32;
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
UINT32 NameSize;
UINT32 DataSize;
UINTN BufferSize;
UINTN RemainingSize;
UINT64 Position;
UINT64 FileSize;
LIST_ENTRY List;
DMP_STORE_VARIABLE *Variable;
LIST_ENTRY *Link;
CHAR16 *Attributes;
UINT8 *Buffer;
UINT32 Crc32;
Status = ShellGetFileSize (FileHandle, &FileSize);
if (EFI_ERROR (Status)) {
@ -162,7 +167,7 @@ LoadVariablesFromFile (
// NameSize
//
BufferSize = sizeof (NameSize);
Status = ShellReadFile (FileHandle, &BufferSize, &NameSize);
Status = ShellReadFile (FileHandle, &BufferSize, &NameSize);
if (EFI_ERROR (Status) || (BufferSize != sizeof (NameSize))) {
ShellStatus = SHELL_VOLUME_CORRUPTED;
break;
@ -172,7 +177,7 @@ LoadVariablesFromFile (
// DataSize
//
BufferSize = sizeof (DataSize);
Status = ShellReadFile (FileHandle, &BufferSize, &DataSize);
Status = ShellReadFile (FileHandle, &BufferSize, &DataSize);
if (EFI_ERROR (Status) || (BufferSize != sizeof (DataSize))) {
ShellStatus = SHELL_VOLUME_CORRUPTED;
break;
@ -188,8 +193,9 @@ LoadVariablesFromFile (
ShellStatus = SHELL_OUT_OF_RESOURCES;
break;
}
BufferSize = RemainingSize;
Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *) Buffer + 2);
BufferSize = RemainingSize;
Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *)Buffer + 2);
if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
ShellStatus = SHELL_VOLUME_CORRUPTED;
FreePool (Buffer);
@ -199,15 +205,15 @@ LoadVariablesFromFile (
//
// Check Crc32
//
* (UINT32 *) Buffer = NameSize;
* ((UINT32 *) Buffer + 1) = DataSize;
BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32);
*(UINT32 *)Buffer = NameSize;
*((UINT32 *)Buffer + 1) = DataSize;
BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32);
gBS->CalculateCrc32 (
Buffer,
BufferSize,
&Crc32
);
if (Crc32 != * (UINT32 *) (Buffer + BufferSize)) {
if (Crc32 != *(UINT32 *)(Buffer + BufferSize)) {
FreePool (Buffer);
ShellStatus = SHELL_VOLUME_CORRUPTED;
break;
@ -221,41 +227,51 @@ LoadVariablesFromFile (
ShellStatus = SHELL_OUT_OF_RESOURCES;
break;
}
Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
Variable->Name = (CHAR16 *) (Variable + 1);
Variable->Name = (CHAR16 *)(Variable + 1);
Variable->DataSize = DataSize;
Variable->Data = (UINT8 *) Variable->Name + NameSize;
CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize);
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->Data, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID) + sizeof (UINT32), DataSize);
Variable->Data = (UINT8 *)Variable->Name + NameSize;
CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize);
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->Data, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID) + sizeof (UINT32), DataSize);
InsertTailList (&List, &Variable->Link);
FreePool (Buffer);
}
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) {
ShellStatus = SHELL_VOLUME_CORRUPTED;
}
}
for ( Link = GetFirstNode (&List)
; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
; Link = GetNextNode (&List, Link)
) {
; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
; Link = GetNextNode (&List, Link)
)
{
Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *) Name)) &&
if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *)Name)) &&
((Guid == NULL) || CompareGuid (&Variable->Guid, Guid))
) {
)
{
Attributes = GetAttrType (Variable->Attributes);
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
Attributes, &Variable->Guid, Variable->Name, Variable->DataSize
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
Attributes,
&Variable->Guid,
Variable->Name,
Variable->DataSize
);
SHELL_FREE_NON_NULL(Attributes);
SHELL_FREE_NON_NULL (Attributes);
*Found = TRUE;
Status = gRT->SetVariable (
@ -266,14 +282,14 @@ LoadVariablesFromFile (
Variable->Data
);
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);
}
}
}
for (Link = GetFirstNode (&List); !IsNull (&List, Link); ) {
Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
Link = RemoveEntryList (&Variable->Link);
Link = RemoveEntryList (&Variable->Link);
FreePool (Variable);
}
@ -296,26 +312,26 @@ LoadVariablesFromFile (
**/
EFI_STATUS
AppendSingleVariableToFile (
IN SHELL_FILE_HANDLE FileHandle,
IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid,
IN UINT32 Attributes,
IN UINT32 DataSize,
IN CONST UINT8 *Data
IN SHELL_FILE_HANDLE FileHandle,
IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid,
IN UINT32 Attributes,
IN UINT32 DataSize,
IN CONST UINT8 *Data
)
{
UINT32 NameSize;
UINT8 *Buffer;
UINT8 *Ptr;
UINTN BufferSize;
EFI_STATUS Status;
UINT32 NameSize;
UINT8 *Buffer;
UINT8 *Ptr;
UINTN BufferSize;
EFI_STATUS Status;
NameSize = (UINT32) StrSize (Name);
NameSize = (UINT32)StrSize (Name);
BufferSize = sizeof (NameSize) + sizeof (DataSize)
+ sizeof (*Guid)
+ sizeof (Attributes)
+ NameSize + DataSize
+ sizeof (UINT32);
+ sizeof (*Guid)
+ sizeof (Attributes)
+ NameSize + DataSize
+ sizeof (UINT32);
Buffer = AllocatePool (BufferSize);
if (Buffer == NULL) {
@ -326,10 +342,10 @@ AppendSingleVariableToFile (
//
// NameSize and DataSize
//
* (UINT32 *) Ptr = NameSize;
Ptr += sizeof (NameSize);
*(UINT32 *) Ptr = DataSize;
Ptr += sizeof (DataSize);
*(UINT32 *)Ptr = NameSize;
Ptr += sizeof (NameSize);
*(UINT32 *)Ptr = DataSize;
Ptr += sizeof (DataSize);
//
// Name
@ -346,8 +362,8 @@ AppendSingleVariableToFile (
//
// Attributes
//
* (UINT32 *) Ptr = Attributes;
Ptr += sizeof (Attributes);
*(UINT32 *)Ptr = Attributes;
Ptr += sizeof (Attributes);
//
// Data
@ -358,14 +374,15 @@ AppendSingleVariableToFile (
//
// Crc32
//
gBS->CalculateCrc32 (Buffer, (UINTN) Ptr - (UINTN) Buffer, (UINT32 *) Ptr);
gBS->CalculateCrc32 (Buffer, (UINTN)Ptr - (UINTN)Buffer, (UINT32 *)Ptr);
Status = ShellWriteFile (FileHandle, &BufferSize, Buffer);
FreePool (Buffer);
if (!EFI_ERROR (Status) &&
(BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32))
) {
)
{
Status = EFI_DEVICE_ERROR;
}
@ -398,49 +415,49 @@ AppendSingleVariableToFile (
**/
SHELL_STATUS
CascadeProcessVariables (
IN CONST CHAR16 *Name OPTIONAL,
IN CONST EFI_GUID *Guid OPTIONAL,
IN DMP_STORE_TYPE Type,
IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL,
IN CONST CHAR16 * CONST PrevName,
IN EFI_GUID FoundVarGuid,
IN BOOLEAN *FoundOne,
IN BOOLEAN StandardFormatOutput
IN CONST CHAR16 *Name OPTIONAL,
IN CONST EFI_GUID *Guid OPTIONAL,
IN DMP_STORE_TYPE Type,
IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL,
IN CONST CHAR16 *CONST PrevName,
IN EFI_GUID FoundVarGuid,
IN BOOLEAN *FoundOne,
IN BOOLEAN StandardFormatOutput
)
{
EFI_STATUS Status;
CHAR16 *FoundVarName;
UINT8 *DataBuffer;
UINTN DataSize;
UINT32 Atts;
SHELL_STATUS ShellStatus;
UINTN NameSize;
CHAR16 *AttrString;
CHAR16 *HexString;
EFI_STATUS SetStatus;
CONST CHAR16 *GuidName;
EFI_STATUS Status;
CHAR16 *FoundVarName;
UINT8 *DataBuffer;
UINTN DataSize;
UINT32 Atts;
SHELL_STATUS ShellStatus;
UINTN NameSize;
CHAR16 *AttrString;
CHAR16 *HexString;
EFI_STATUS SetStatus;
CONST CHAR16 *GuidName;
if (ShellGetExecutionBreakFlag()) {
if (ShellGetExecutionBreakFlag ()) {
return (SHELL_ABORTED);
}
NameSize = 0;
FoundVarName = NULL;
NameSize = 0;
FoundVarName = NULL;
if (PrevName!=NULL) {
StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0);
if (PrevName != NULL) {
StrnCatGrow (&FoundVarName, &NameSize, PrevName, 0);
} else {
FoundVarName = AllocateZeroPool(sizeof(CHAR16));
NameSize = sizeof(CHAR16);
FoundVarName = AllocateZeroPool (sizeof (CHAR16));
NameSize = sizeof (CHAR16);
}
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
if (Status == EFI_BUFFER_TOO_SMALL) {
SHELL_FREE_NON_NULL(FoundVarName);
SHELL_FREE_NON_NULL (FoundVarName);
FoundVarName = AllocateZeroPool (NameSize);
if (FoundVarName != 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);
@ -453,10 +470,10 @@ CascadeProcessVariables (
// No more is fine.
//
if (Status == EFI_NOT_FOUND) {
SHELL_FREE_NON_NULL(FoundVarName);
SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_SUCCESS);
} else if (EFI_ERROR(Status)) {
SHELL_FREE_NON_NULL(FoundVarName);
} else if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_DEVICE_ERROR);
}
@ -465,8 +482,8 @@ CascadeProcessVariables (
//
ShellStatus = CascadeProcessVariables (Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne, StandardFormatOutput);
if (ShellGetExecutionBreakFlag() || (ShellStatus == SHELL_ABORTED)) {
SHELL_FREE_NON_NULL(FoundVarName);
if (ShellGetExecutionBreakFlag () || (ShellStatus == SHELL_ABORTED)) {
SHELL_FREE_NON_NULL (FoundVarName);
return (SHELL_ABORTED);
}
@ -474,18 +491,19 @@ CascadeProcessVariables (
// No matter what happened we process our own variable
// Only continue if Guid and VariableName are each either NULL or a match
//
if ( ( Name == NULL
|| gUnicodeCollation->MetaiMatch(gUnicodeCollation, FoundVarName, (CHAR16*) Name) )
&& ( Guid == NULL
|| CompareGuid(&FoundVarGuid, Guid) )
) {
DataSize = 0;
DataBuffer = NULL;
if ( ( (Name == NULL)
|| gUnicodeCollation->MetaiMatch (gUnicodeCollation, FoundVarName, (CHAR16 *)Name))
&& ( (Guid == NULL)
|| CompareGuid (&FoundVarGuid, Guid))
)
{
DataSize = 0;
DataBuffer = NULL;
//
// do the print or delete
//
*FoundOne = TRUE;
Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
SHELL_FREE_NON_NULL (DataBuffer);
DataBuffer = AllocatePool (DataSize);
@ -495,20 +513,31 @@ CascadeProcessVariables (
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 (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
AttrString = GetAttrType(Atts);
if (!EFI_ERROR (Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
AttrString = GetAttrType (Atts);
if (StandardFormatOutput) {
HexString = AllocatePool ((DataSize * 2 + 1) * sizeof (CHAR16));
if (HexString != NULL) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_VAR_SFO), gShellDebug1HiiHandle,
FoundVarName, &FoundVarGuid, Atts, DataSize,
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_VAR_SFO),
gShellDebug1HiiHandle,
FoundVarName,
&FoundVarGuid,
Atts,
DataSize,
BinaryToHexString (
DataBuffer, DataSize, HexString, (DataSize * 2 + 1) * sizeof (CHAR16)
DataBuffer,
DataSize,
HexString,
(DataSize * 2 + 1) * sizeof (CHAR16)
)
);
FreePool (HexString);
@ -516,35 +545,58 @@ CascadeProcessVariables (
Status = EFI_OUT_OF_RESOURCES;
}
} else {
Status = gEfiShellProtocol->GetGuidName(&FoundVarGuid, &GuidName);
Status = gEfiShellProtocol->GetGuidName (&FoundVarGuid, &GuidName);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
AttrString, &FoundVarGuid, FoundVarName, DataSize
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
AttrString,
&FoundVarGuid,
FoundVarName,
DataSize
);
} else {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2), gShellDebug1HiiHandle,
AttrString, GuidName, FoundVarName, DataSize
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE2),
gShellDebug1HiiHandle,
AttrString,
GuidName,
FoundVarName,
DataSize
);
}
DumpHex (2, 0, DataSize, DataBuffer);
}
SHELL_FREE_NON_NULL (AttrString);
}
} else if (Type == DmpStoreSave) {
if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
if (!EFI_ERROR (Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
AttrString = GetAttrType (Atts);
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
AttrString, &FoundVarGuid, FoundVarName, DataSize
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_HEADER_LINE),
gShellDebug1HiiHandle,
AttrString,
&FoundVarGuid,
FoundVarName,
DataSize
);
Status = AppendSingleVariableToFile (
FileHandle,
FoundVarName,
&FoundVarGuid,
Atts,
(UINT32) DataSize,
(UINT32)DataSize,
DataBuffer
);
SHELL_FREE_NON_NULL (AttrString);
@ -557,27 +609,39 @@ CascadeProcessVariables (
if (StandardFormatOutput) {
if (SetStatus == EFI_SUCCESS) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO), gShellDebug1HiiHandle,
FoundVarName, &FoundVarGuid
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO),
gShellDebug1HiiHandle,
FoundVarName,
&FoundVarGuid
);
}
} else {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_DELETE_LINE), gShellDebug1HiiHandle,
&FoundVarGuid, FoundVarName, SetStatus
-1,
-1,
NULL,
STRING_TOKEN (STR_DMPSTORE_DELETE_LINE),
gShellDebug1HiiHandle,
&FoundVarGuid,
FoundVarName,
SetStatus
);
}
}
SHELL_FREE_NON_NULL(DataBuffer);
SHELL_FREE_NON_NULL (DataBuffer);
}
SHELL_FREE_NON_NULL(FoundVarName);
SHELL_FREE_NON_NULL (FoundVarName);
if (Status == EFI_DEVICE_ERROR) {
ShellStatus = SHELL_DEVICE_ERROR;
} else if (Status == EFI_SECURITY_VIOLATION) {
ShellStatus = SHELL_SECURITY_VIOLATION;
} else if (EFI_ERROR(Status)) {
} else if (EFI_ERROR (Status)) {
ShellStatus = SHELL_NOT_READY;
}
@ -601,23 +665,23 @@ CascadeProcessVariables (
**/
SHELL_STATUS
ProcessVariables (
IN CONST CHAR16 *Name OPTIONAL,
IN CONST EFI_GUID *Guid OPTIONAL,
IN DMP_STORE_TYPE Type,
IN SHELL_FILE_HANDLE FileHandle OPTIONAL,
IN BOOLEAN StandardFormatOutput
IN CONST CHAR16 *Name OPTIONAL,
IN CONST EFI_GUID *Guid OPTIONAL,
IN DMP_STORE_TYPE Type,
IN SHELL_FILE_HANDLE FileHandle OPTIONAL,
IN BOOLEAN StandardFormatOutput
)
{
SHELL_STATUS ShellStatus;
BOOLEAN Found;
EFI_GUID FoundVarGuid;
SHELL_STATUS ShellStatus;
BOOLEAN Found;
EFI_GUID FoundVarGuid;
Found = FALSE;
ShellStatus = SHELL_SUCCESS;
ZeroMem (&FoundVarGuid, sizeof(EFI_GUID));
Found = FALSE;
ShellStatus = SHELL_SUCCESS;
ZeroMem (&FoundVarGuid, sizeof (EFI_GUID));
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) {
@ -628,43 +692,45 @@ ProcessVariables (
if (!Found) {
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);
} else if (Name != NULL && Guid == NULL) {
} else if ((Name != NULL) && (Guid == NULL)) {
if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N_SFO), gShellDebug1HiiHandle, Name);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, L"dmpstore", Name);
}
} else if (Name != NULL && Guid != NULL) {
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)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, L"dmpstore", Guid, Name);
} else if ((Name == NULL) && (Guid == NULL)) {
if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_SFO), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle, L"dmpstore");
}
} else if (Name == NULL && Guid != NULL) {
} else if ((Name == NULL) && (Guid != NULL)) {
if (StandardFormatOutput) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G_SFO), gShellDebug1HiiHandle, Guid);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid);
}
}
return (SHELL_NOT_FOUND);
}
return (ShellStatus);
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-d", TypeFlag},
{L"-l", TypeValue},
{L"-s", TypeValue},
{L"-all", TypeFlag},
{L"-guid", TypeValue},
{L"-sfo", TypeFlag},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-d", TypeFlag },
{ L"-l", TypeValue },
{ L"-s", TypeValue },
{ L"-all", TypeFlag },
{ L"-guid", TypeValue },
{ L"-sfo", TypeFlag },
{ NULL, TypeMax }
};
/**
Function for 'dmpstore' command.
@ -679,20 +745,20 @@ ShellCommandRunDmpStore (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *GuidStr;
CONST CHAR16 *File;
EFI_GUID *Guid;
EFI_GUID GuidData;
CONST CHAR16 *Name;
DMP_STORE_TYPE Type;
SHELL_FILE_HANDLE FileHandle;
EFI_FILE_INFO *FileInfo;
BOOLEAN StandardFormatOutput;
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *GuidStr;
CONST CHAR16 *File;
EFI_GUID *Guid;
EFI_GUID GuidData;
CONST CHAR16 *Name;
DMP_STORE_TYPE Type;
SHELL_FILE_HANDLE FileHandle;
EFI_FILE_INFO *FileInfo;
BOOLEAN StandardFormatOutput;
ShellStatus = SHELL_SUCCESS;
Package = NULL;
@ -702,61 +768,62 @@ ShellCommandRunDmpStore (
StandardFormatOutput = FALSE;
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam);
FreePool(ProblemParam);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore");
if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore");
ShellStatus = SHELL_INVALID_PARAMETER;
} 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");
} 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");
ShellStatus = SHELL_INVALID_PARAMETER;
} 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");
} 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");
ShellStatus = SHELL_INVALID_PARAMETER;
} 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");
} 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");
ShellStatus = SHELL_INVALID_PARAMETER;
} 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");
} 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");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Determine the GUID to search for based on -all and -guid parameters
//
if (!ShellCommandLineGetFlag(Package, L"-all")) {
GuidStr = ShellCommandLineGetValue(Package, L"-guid");
if (!ShellCommandLineGetFlag (Package, L"-all")) {
GuidStr = ShellCommandLineGetValue (Package, L"-guid");
if (GuidStr != NULL) {
RStatus = StrToGuid (GuidStr, &GuidData);
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;
}
Guid = &GuidData;
} else {
} else {
Guid = &gEfiGlobalVariableGuid;
}
} else {
Guid = NULL;
Guid = NULL;
}
//
// Get the Name of the variable to find
//
Name = ShellCommandLineGetRawValue(Package, 1);
Name = ShellCommandLineGetRawValue (Package, 1);
if (ShellStatus == SHELL_SUCCESS) {
if (ShellCommandLineGetFlag(Package, L"-s")) {
if (ShellCommandLineGetFlag (Package, L"-s")) {
Type = DmpStoreSave;
File = ShellCommandLineGetValue(Package, L"-s");
File = ShellCommandLineGetValue (Package, L"-s");
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;
} else {
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);
}
}
FreePool (FileInfo);
}
} else if (Status == EFI_NOT_FOUND) {
@ -803,16 +871,16 @@ ShellCommandRunDmpStore (
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
} else if (ShellCommandLineGetFlag(Package, L"-l")) {
} else if (ShellCommandLineGetFlag (Package, L"-l")) {
Type = DmpStoreLoad;
File = ShellCommandLineGetValue(Package, L"-l");
File = ShellCommandLineGetValue (Package, L"-l");
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;
} else {
Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_READ, 0);
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;
} else {
FileInfo = ShellGetFileInfo (FileHandle);
@ -824,15 +892,16 @@ ShellCommandRunDmpStore (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File);
ShellStatus = SHELL_INVALID_PARAMETER;
}
FreePool (FileInfo);
}
}
}
} else if (ShellCommandLineGetFlag(Package, L"-d")) {
} else if (ShellCommandLineGetFlag (Package, L"-d")) {
Type = DmpStoreDelete;
}
if (ShellCommandLineGetFlag (Package,L"-sfo")) {
if (ShellCommandLineGetFlag (Package, L"-sfo")) {
StandardFormatOutput = TRUE;
}
}
@ -843,6 +912,7 @@ ShellCommandRunDmpStore (
} else if (Type == DmpStoreLoad) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File);
}
ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput);
if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
ShellCloseFile (&FileHandle);
@ -854,6 +924,6 @@ ShellCommandRunDmpStore (
if (Package != NULL) {
ShellCommandLineFreeVarList (Package);
}
return ShellStatus;
}

View File

@ -23,16 +23,17 @@ ShellCommandRunEdit (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CHAR16 *Buffer;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CONST CHAR16 *Cwd;
CHAR16 *Nfs;
CHAR16 *Spot;
CONST CHAR16 *TempParam;
// SHELL_FILE_HANDLE TempHandle;
EFI_STATUS Status;
CHAR16 *Buffer;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CONST CHAR16 *Cwd;
CHAR16 *Nfs;
CHAR16 *Spot;
CONST CHAR16 *TempParam;
// SHELL_FILE_HANDLE TempHandle;
Buffer = NULL;
ShellStatus = SHELL_SUCCESS;
@ -41,45 +42,47 @@ ShellCommandRunEdit (
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = ShellInitialize ();
ASSERT_EFI_ERROR (Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
Status = CommandInit ();
ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"edit", ProblemParam);
FreePool(ProblemParam);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"edit", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"edit");
if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"edit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Cwd = gEfiShellProtocol->GetCurDir(NULL);
Cwd = gEfiShellProtocol->GetCurDir (NULL);
if (Cwd == NULL) {
Cwd = ShellGetEnvironmentVariable(L"path");
Cwd = ShellGetEnvironmentVariable (L"path");
if (Cwd != NULL) {
Nfs = StrnCatGrow(&Nfs, NULL, Cwd+3, 0);
Nfs = StrnCatGrow (&Nfs, NULL, Cwd+3, 0);
if (Nfs != NULL) {
Spot = StrStr(Nfs, L";");
Spot = StrStr (Nfs, L";");
if (Spot != NULL) {
*Spot = CHAR_NULL;
}
Spot = StrStr(Nfs, L"\\");
Spot = StrStr (Nfs, L"\\");
if (Spot != 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)) {
gST->ConOut->ClearScreen (gST->ConOut);
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 {
MainEditorBackup ();
//
// if editor launched with file named
//
if (ShellCommandLineGetCount(Package) == 2) {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
if (ShellCommandLineGetCount (Package) == 2) {
TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT (TempParam != NULL);
FileBufferSetFileName (TempParam);
// 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);
// if (!EFI_ERROR(Status)) {
// ShellCloseFile(&TempHandle);
// }
// }
// 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);
// if (!EFI_ERROR(Status)) {
// ShellCloseFile(&TempHandle);
// }
// }
}
Status = FileBufferRead (MainEditor.FileBuffer->FileName, FALSE);
@ -119,7 +122,7 @@ ShellCommandRunEdit (
//
// back up the status string
//
Buffer = CatSPrint (NULL, L"%s", StatusBarGetString());
Buffer = CatSPrint (NULL, L"%s", StatusBarGetString ());
}
MainEditorCleanup ();
@ -129,19 +132,19 @@ ShellCommandRunEdit (
//
if (Status == EFI_SUCCESS) {
} 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 {
if (Buffer != NULL) {
if (StrCmp (Buffer, L"") != 0) {
//
// 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 {
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 {
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);
}
return ShellStatus;
}

File diff suppressed because it is too large Load Diff

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