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

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

View File

@@ -60,7 +60,7 @@ FileBufferRefresh (
**/
EFI_STATUS
FileBufferHandleInput (
IN CONST EFI_INPUT_KEY * Key
IN CONST EFI_INPUT_KEY *Key
);
/**
@@ -99,7 +99,7 @@ FileBufferRestorePosition (
**/
EFI_STATUS
FileBufferSetFileName (
IN CONST CHAR16 *Str
IN CONST CHAR16 *Str
);
/**
@@ -115,8 +115,8 @@ FileBufferSetFileName (
**/
EFI_STATUS
FileBufferRead (
IN CONST CHAR16 *FileName,
IN CONST BOOLEAN Recover
IN CONST CHAR16 *FileName,
IN CONST BOOLEAN Recover
);
/**
@@ -130,7 +130,7 @@ FileBufferRead (
**/
EFI_STATUS
FileBufferSave (
CONST CHAR16 *FileName
CONST CHAR16 *FileName
);
/**
@@ -141,8 +141,8 @@ FileBufferSave (
**/
VOID
FileBufferMovePosition (
IN CONST UINTN NewFilePosRow,
IN CONST UINTN NewFilePosCol
IN CONST UINTN NewFilePosRow,
IN CONST UINTN NewFilePosCol
);
/**
@@ -157,7 +157,7 @@ FileBufferMovePosition (
**/
EFI_STATUS
FileBufferCutLine (
OUT EFI_EDITOR_LINE **CutLine
OUT EFI_EDITOR_LINE **CutLine
);
/**
@@ -183,7 +183,7 @@ FileBufferPasteLine (
EFI_STATUS
FileBufferSearch (
IN CONST CHAR16 *Str,
IN CONST UINTN Offset
IN CONST UINTN Offset
);
/**
@@ -199,8 +199,8 @@ FileBufferSearch (
**/
EFI_STATUS
FileBufferReplace (
IN CONST CHAR16 *Replace,
IN CONST UINTN SearchLen
IN CONST CHAR16 *Replace,
IN CONST UINTN SearchLen
);
/**
@@ -212,9 +212,9 @@ FileBufferReplace (
**/
EFI_STATUS
FileBufferReplaceAll (
IN CHAR16 *SearchStr,
IN CHAR16 *ReplaceStr,
IN UINTN Offset
IN CHAR16 *SearchStr,
IN CHAR16 *ReplaceStr,
IN UINTN Offset
);
/**
@@ -225,8 +225,8 @@ FileBufferReplaceAll (
**/
VOID
FileBufferAdjustMousePosition (
IN CONST INT32 TextX,
IN CONST INT32 TextY
IN CONST INT32 TextX,
IN CONST INT32 TextY
);
/**

View File

@@ -19,10 +19,10 @@
**/
EFI_EDITOR_LINE *
LineDup (
IN EFI_EDITOR_LINE *Src
IN EFI_EDITOR_LINE *Src
)
{
EFI_EDITOR_LINE *Dest;
EFI_EDITOR_LINE *Dest;
//
// allocate for the line structure
@@ -31,6 +31,7 @@ LineDup (
if (Dest == NULL) {
return NULL;
}
//
// allocate and set the line buffer
//
@@ -59,26 +60,16 @@ LineDup (
**/
VOID
LineFree (
IN EFI_EDITOR_LINE *Src
IN EFI_EDITOR_LINE *Src
)
{
if (Src == NULL) {
return ;
return;
}
//
// free the line buffer and then the line structure itself
//
SHELL_FREE_NON_NULL (Src->Buffer);
SHELL_FREE_NON_NULL (Src);
}

View File

@@ -11,8 +11,6 @@
#include "TextEditorTypes.h"
/**
Free a EFI_EDITOR_LINE structure.
@@ -20,7 +18,7 @@
**/
VOID
LineFree (
IN EFI_EDITOR_LINE *Src
IN EFI_EDITOR_LINE *Src
);
/**
@@ -33,12 +31,7 @@ LineFree (
**/
EFI_EDITOR_LINE *
LineDup (
IN EFI_EDITOR_LINE *Src
IN EFI_EDITOR_LINE *Src
);
#endif

View File

@@ -19,8 +19,8 @@
#include "EditMenuBar.h"
#include "Misc.h"
extern EFI_EDITOR_GLOBAL_EDITOR MainEditor;
extern BOOLEAN EditorFirst;
extern BOOLEAN EditorExit;
extern EFI_EDITOR_GLOBAL_EDITOR MainEditor;
extern BOOLEAN EditorFirst;
extern BOOLEAN EditorExit;
#endif // _EFI_EDIT_H_

View File

@@ -13,12 +13,12 @@
#include "EditTitleBar.h"
#include "EditMenuBar.h"
#define MIN_POOL_SIZE 125
#define MAX_STRING_LENGTH 127
#define MIN_POOL_SIZE 125
#define MAX_STRING_LENGTH 127
typedef struct {
UINTN Row;
UINTN Column;
UINTN Row;
UINTN Column;
} EFI_EDITOR_POSITION;
typedef
@@ -38,60 +38,59 @@ typedef enum {
#define LINE_LIST_SIGNATURE SIGNATURE_32 ('e', 'e', 'l', 'l')
typedef struct _EFI_EDITOR_LINE {
UINTN Signature;
CHAR16 *Buffer;
UINTN Size; // unit is Unicode
UINTN TotalSize; // unit is Unicode, exclude CHAR_NULL
EE_NEWLINE_TYPE Type;
LIST_ENTRY Link;
UINTN Signature;
CHAR16 *Buffer;
UINTN Size; // unit is Unicode
UINTN TotalSize; // unit is Unicode, exclude CHAR_NULL
EE_NEWLINE_TYPE Type;
LIST_ENTRY Link;
} EFI_EDITOR_LINE;
typedef struct {
UINT32 Foreground : 4;
UINT32 Background : 4;
UINT32 Foreground : 4;
UINT32 Background : 4;
} EFI_EDITOR_COLOR_ATTRIBUTES;
typedef union {
EFI_EDITOR_COLOR_ATTRIBUTES Colors;
UINTN Data;
EFI_EDITOR_COLOR_ATTRIBUTES Colors;
UINTN Data;
} EFI_EDITOR_COLOR_UNION;
typedef struct {
UINTN Columns;
UINTN Rows;
UINTN Columns;
UINTN Rows;
} EFI_EDITOR_TEXT_MODE;
typedef struct {
CHAR16 *FileName; // file name current edited in editor
EDIT_FILE_TYPE FileType; // Unicode file or ASCII file
LIST_ENTRY *ListHead; // list head of lines
EFI_EDITOR_LINE *Lines; // lines of current file
UINTN NumLines; // total line numbers
EFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
EFI_EDITOR_POSITION FilePosition; // cursor position in file
EFI_EDITOR_POSITION MousePosition; // mouse position in screen
CHAR16 *FileName; // file name current edited in editor
EDIT_FILE_TYPE FileType; // Unicode file or ASCII file
LIST_ENTRY *ListHead; // list head of lines
EFI_EDITOR_LINE *Lines; // lines of current file
UINTN NumLines; // total line numbers
EFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
EFI_EDITOR_POSITION FilePosition; // cursor position in file
EFI_EDITOR_POSITION MousePosition; // mouse position in screen
// file position of first byte displayed on screen
//
EFI_EDITOR_POSITION LowVisibleRange;
EFI_EDITOR_POSITION LowVisibleRange;
BOOLEAN FileModified; // file is modified or not
BOOLEAN ModeInsert; // input mode INS or OVR
BOOLEAN ReadOnly; // file is read-only or not
EFI_EDITOR_LINE *CurrentLine; // current line cursor is at
BOOLEAN FileModified; // file is modified or not
BOOLEAN ModeInsert; // input mode INS or OVR
BOOLEAN ReadOnly; // file is read-only or not
EFI_EDITOR_LINE *CurrentLine; // current line cursor is at
} EFI_EDITOR_FILE_BUFFER;
typedef struct {
EFI_EDITOR_FILE_BUFFER *FileBuffer;
EFI_EDITOR_COLOR_UNION ColorAttributes;
EFI_EDITOR_POSITION ScreenSize; // row number and column number
EFI_EDITOR_LINE *CutLine; // clip board
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
BOOLEAN MouseSupported;
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
INT32 MouseAccumulatorX;
INT32 MouseAccumulatorY;
EFI_EDITOR_FILE_BUFFER *FileBuffer;
EFI_EDITOR_COLOR_UNION ColorAttributes;
EFI_EDITOR_POSITION ScreenSize; // row number and column number
EFI_EDITOR_LINE *CutLine; // clip board
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
BOOLEAN MouseSupported;
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
INT32 MouseAccumulatorX;
INT32 MouseAccumulatorY;
} EFI_EDITOR_GLOBAL_EDITOR;
#endif

View File

@@ -9,10 +9,10 @@
#include "EditInputBar.h"
#include "UefiShellDebug1CommandsLib.h"
CHAR16 *mPrompt; // Input bar mPrompt string.
CHAR16 *mReturnString; // The returned string.
UINTN StringSize; // Size of mReturnString space size.
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *mTextInEx;
CHAR16 *mPrompt; // Input bar mPrompt string.
CHAR16 *mReturnString; // The returned string.
UINTN StringSize; // Size of mReturnString space size.
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *mTextInEx;
/**
Initialize the input bar.
@@ -21,7 +21,7 @@ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *mTextInEx;
**/
VOID
InputBarInit (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
)
{
mPrompt = NULL;
@@ -56,8 +56,8 @@ InputBarCleanup (
**/
VOID
InputBarPrintInput (
IN UINTN LastColumn,
IN UINTN LastRow
IN UINTN LastColumn,
IN UINTN LastRow
)
{
UINTN Limit;
@@ -67,8 +67,8 @@ InputBarPrintInput (
UINTN mPromptLen;
mPromptLen = StrLen (mPrompt);
Limit = LastColumn - mPromptLen - 1;
Size = StrLen (mReturnString);
Limit = LastColumn - mPromptLen - 1;
Size = StrLen (mReturnString);
//
// check whether the mPrompt length and input length will
@@ -97,16 +97,15 @@ InputBarPrintInput (
}
typedef struct {
UINT32 Foreground : 4;
UINT32 Background : 3;
UINT32 Foreground : 4;
UINT32 Background : 3;
} INPUT_BAR_COLOR_ATTRIBUTES;
typedef union {
INPUT_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
INPUT_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
} INPUT_BAR_COLOR_UNION;
/**
The refresh function for InputBar, it will wait for user input
@@ -117,25 +116,25 @@ typedef union {
**/
EFI_STATUS
InputBarRefresh (
UINTN LastRow,
UINTN LastColumn
UINTN LastRow,
UINTN LastColumn
)
{
INPUT_BAR_COLOR_UNION Orig;
INPUT_BAR_COLOR_UNION New;
EFI_KEY_DATA KeyData;
UINTN Size;
EFI_STATUS Status;
BOOLEAN NoDisplay;
UINTN EventIndex;
UINTN CursorRow;
UINTN CursorCol;
INPUT_BAR_COLOR_UNION Orig;
INPUT_BAR_COLOR_UNION New;
EFI_KEY_DATA KeyData;
UINTN Size;
EFI_STATUS Status;
BOOLEAN NoDisplay;
UINTN EventIndex;
UINTN CursorRow;
UINTN CursorCol;
//
// variable initialization
//
Size = 0;
Status = EFI_SUCCESS;
Size = 0;
Status = EFI_SUCCESS;
//
// back up the old screen attributes
@@ -152,10 +151,10 @@ InputBarRefresh (
//
// clear input bar
//
EditorClearLine (LastRow , LastColumn, LastRow);
EditorClearLine (LastRow, LastColumn, LastRow);
gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);
//
// this is a selection mPrompt, cursor will stay in edit area
@@ -168,37 +167,43 @@ InputBarRefresh (
} else {
NoDisplay = FALSE;
}
//
// wait for user input
//
for (;;) {
for ( ; ;) {
Status = gBS->WaitForEvent (1, &mTextInEx->WaitForKeyEx, &EventIndex);
if (EFI_ERROR (Status) || (EventIndex != 0)) {
continue;
}
Status = mTextInEx->ReadKeyStrokeEx (mTextInEx, &KeyData);
if (EFI_ERROR (Status)) {
continue;
}
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
(KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID)) {
(KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID))
{
//
// Shift key pressed.
//
continue;
}
//
// pressed ESC
//
if (KeyData.Key.ScanCode == SCAN_ESC) {
Size = 0;
Status = EFI_NOT_READY;
Size = 0;
Status = EFI_NOT_READY;
break;
}
//
// return pressed
//
if (KeyData.Key.UnicodeChar == CHAR_LINEFEED || KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
if ((KeyData.Key.UnicodeChar == CHAR_LINEFEED) || (KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {
break;
} else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {
//
@@ -208,12 +213,10 @@ InputBarRefresh (
Size--;
mReturnString[Size] = CHAR_NULL;
if (!NoDisplay) {
InputBarPrintInput (LastColumn, LastRow);
}
}
} else if (KeyData.Key.UnicodeChar <= 127 && KeyData.Key.UnicodeChar >= 32) {
} else if ((KeyData.Key.UnicodeChar <= 127) && (KeyData.Key.UnicodeChar >= 32)) {
//
// VALID ASCII char pressed
//
@@ -231,22 +234,18 @@ InputBarRefresh (
mReturnString[Size] = CHAR_NULL;
if (!NoDisplay) {
InputBarPrintInput (LastColumn, LastRow);
} else {
//
// if just choose yes/no
//
break;
}
}
}
mReturnString[Size] = CHAR_NULL;
//
// restore screen attributes
//
@@ -266,7 +265,7 @@ InputBarRefresh (
**/
EFI_STATUS
InputBarSetPrompt (
IN CONST CHAR16 *Str
IN CONST CHAR16 *Str
)
{
//
@@ -292,7 +291,7 @@ InputBarSetPrompt (
**/
EFI_STATUS
InputBarSetStringSize (
UINTN Size
UINTN Size
)
{
//
@@ -300,8 +299,8 @@ InputBarSetStringSize (
//
SHELL_FREE_NON_NULL (mReturnString);
StringSize = Size;
mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof(mReturnString[0]));
StringSize = Size;
mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof (mReturnString[0]));
if (mReturnString == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -315,7 +314,7 @@ InputBarSetStringSize (
@retval NULL No input has been received.
@return The string that was input.
**/
CONST CHAR16*
CONST CHAR16 *
InputBarGetString (
VOID
)

View File

@@ -16,7 +16,7 @@
**/
VOID
InputBarInit (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
);
/**
@@ -37,8 +37,8 @@ InputBarCleanup (
**/
EFI_STATUS
InputBarRefresh (
UINTN LastRow,
UINTN LastColumn
UINTN LastRow,
UINTN LastColumn
);
/**
@@ -51,7 +51,7 @@ InputBarRefresh (
**/
EFI_STATUS
InputBarSetPrompt (
IN CONST CHAR16 *Str
IN CONST CHAR16 *Str
);
/**
@@ -64,7 +64,7 @@ InputBarSetPrompt (
**/
EFI_STATUS
InputBarSetStringSize (
UINTN Size
UINTN Size
);
/**
@@ -73,7 +73,7 @@ InputBarSetStringSize (
@retval NULL No input has been received.
@return The string that was input.
**/
CONST CHAR16*
CONST CHAR16 *
InputBarGetString (
VOID
);

View File

@@ -10,9 +10,9 @@
#include "UefiShellDebug1CommandsLib.h"
#include "EditStatusBar.h"
EDITOR_MENU_ITEM *MenuItems;
MENU_ITEM_FUNCTION *ControlBasedMenuFunctions;
UINTN NumItems;
EDITOR_MENU_ITEM *MenuItems;
MENU_ITEM_FUNCTION *ControlBasedMenuFunctions;
UINTN NumItems;
/**
Cleanup function for a menu bar. frees all allocated memory.
@@ -22,7 +22,7 @@ MenuBarCleanup (
VOID
)
{
SHELL_FREE_NON_NULL(MenuItems);
SHELL_FREE_NON_NULL (MenuItems);
}
/**
@@ -40,13 +40,15 @@ MenuBarInit (
{
CONST EDITOR_MENU_ITEM *ItemsWalker;
for (NumItems = 0, ItemsWalker = Items ; ItemsWalker != NULL && ItemsWalker->Function != NULL ; ItemsWalker++,NumItems++);
for (NumItems = 0, ItemsWalker = Items; ItemsWalker != NULL && ItemsWalker->Function != NULL; ItemsWalker++, NumItems++) {
}
MenuItems = AllocateZeroPool((NumItems+1) * sizeof(EDITOR_MENU_ITEM));
MenuItems = AllocateZeroPool ((NumItems+1) * sizeof (EDITOR_MENU_ITEM));
if (MenuItems == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem(MenuItems, Items, (NumItems+1) * sizeof(EDITOR_MENU_ITEM));
CopyMem (MenuItems, Items, (NumItems+1) * sizeof (EDITOR_MENU_ITEM));
return EFI_SUCCESS;
}
@@ -65,6 +67,7 @@ ControlHotKeyInit (
ControlBasedMenuFunctions = Items;
return EFI_SUCCESS;
}
/**
Refresh function for the menu bar.
@@ -75,16 +78,16 @@ ControlHotKeyInit (
**/
EFI_STATUS
MenuBarRefresh (
IN CONST UINTN LastRow,
IN CONST UINTN LastCol
IN CONST UINTN LastRow,
IN CONST UINTN LastCol
)
{
EDITOR_MENU_ITEM *Item;
UINTN Col;
UINTN Row;
UINTN Width;
CHAR16 *NameString;
CHAR16 *FunctionKeyString;
UINTN Col;
UINTN Row;
UINTN Width;
CHAR16 *NameString;
CHAR16 *FunctionKeyString;
//
// variable initialization
@@ -97,25 +100,21 @@ MenuBarRefresh (
//
EditorClearLine (LastRow - 2, LastCol, LastRow);
EditorClearLine (LastRow - 1, LastCol, LastRow);
EditorClearLine (LastRow , LastCol, LastRow);
EditorClearLine (LastRow, LastCol, LastRow);
//
// print out the menu items
//
for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) {
NameString = HiiGetString (gShellDebug1HiiHandle, Item->NameToken, NULL);
NameString = HiiGetString(gShellDebug1HiiHandle, Item->NameToken, NULL);
Width = MAX ((StrLen (NameString) + 6), 20);
Width = MAX ((StrLen (NameString) + 6), 20);
if (((Col + Width) > LastCol)) {
Row++;
Col = 1;
}
FunctionKeyString = HiiGetString(gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);
FunctionKeyString = HiiGetString (gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);
ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
@@ -138,12 +137,12 @@ MenuBarRefresh (
**/
EFI_STATUS
MenuBarDispatchFunctionKey (
IN CONST EFI_INPUT_KEY *Key
IN CONST EFI_INPUT_KEY *Key
)
{
UINTN Index;
UINTN Index;
Index = Key->ScanCode - SCAN_F1;
Index = Key->ScanCode - SCAN_F1;
//
// check whether in range
@@ -167,10 +166,10 @@ MenuBarDispatchFunctionKey (
**/
EFI_STATUS
MenuBarDispatchControlHotKey (
IN CONST EFI_KEY_DATA *KeyData
IN CONST EFI_KEY_DATA *KeyData
)
{
UINT16 ControlIndex;
UINT16 ControlIndex;
//
// Set to invalid value first.
@@ -178,7 +177,8 @@ MenuBarDispatchControlHotKey (
ControlIndex = MAX_UINT16;
if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
(KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
(KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID))
{
//
// For consoles that don't support/report shift state,
// Ctrl+A is translated to 1 (UnicodeChar).
@@ -186,7 +186,8 @@ MenuBarDispatchControlHotKey (
ControlIndex = KeyData->Key.UnicodeChar;
} else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {
((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0))
{
//
// For consoles that supports/reports shift state,
// make sure only CONTROL is pressed.
@@ -197,14 +198,13 @@ MenuBarDispatchControlHotKey (
ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;
}
}
if ((SCAN_CONTROL_Z < ControlIndex)
||(NULL == ControlBasedMenuFunctions[ControlIndex]))
if ( (SCAN_CONTROL_Z < ControlIndex)
|| (NULL == ControlBasedMenuFunctions[ControlIndex]))
{
return EFI_NOT_FOUND;
return EFI_NOT_FOUND;
}
ControlBasedMenuFunctions[ControlIndex]();
return EFI_SUCCESS;
}

View File

@@ -22,7 +22,6 @@
#define SCAN_CONTROL_W 23
#define SCAN_CONTROL_Z 26
typedef
EFI_STATUS
(*MENU_ITEM_FUNCTION) (
@@ -30,9 +29,9 @@ EFI_STATUS
);
typedef struct _EDITOR_MENU_ITEM {
EFI_STRING_ID NameToken;
CHAR16 FunctionKeyToken;
MENU_ITEM_FUNCTION Function;
EFI_STRING_ID NameToken;
CHAR16 FunctionKeyToken;
MENU_ITEM_FUNCTION Function;
} EDITOR_MENU_ITEM;
/**
@@ -78,8 +77,8 @@ MenuBarCleanup (
**/
EFI_STATUS
MenuBarRefresh (
IN CONST UINTN LastRow,
IN CONST UINTN LastCol
IN CONST UINTN LastRow,
IN CONST UINTN LastCol
);
/**
@@ -93,7 +92,7 @@ MenuBarRefresh (
**/
EFI_STATUS
MenuBarDispatchFunctionKey (
IN CONST EFI_INPUT_KEY *Key
IN CONST EFI_INPUT_KEY *Key
);
/**
@@ -107,7 +106,7 @@ MenuBarDispatchFunctionKey (
**/
EFI_STATUS
MenuBarDispatchControlHotKey (
IN CONST EFI_KEY_DATA *KeyData
IN CONST EFI_KEY_DATA *KeyData
);
#endif

View File

@@ -9,9 +9,9 @@
#include "EditStatusBar.h"
#include "UefiShellDebug1CommandsLib.h"
CHAR16 *StatusString;
BOOLEAN StatusBarNeedRefresh;
BOOLEAN StatusStringChanged;
CHAR16 *StatusString;
BOOLEAN StatusBarNeedRefresh;
BOOLEAN StatusStringChanged;
/**
Initialization function for Status Bar.
@@ -53,13 +53,13 @@ StatusBarCleanup (
}
typedef struct {
UINT32 Foreground : 4;
UINT32 Background : 3;
UINT32 Foreground : 4;
UINT32 Background : 3;
} STATUS_BAR_COLOR_ATTRIBUTES;
typedef union {
STATUS_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
STATUS_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
} STATUS_BAR_COLOR_UNION;
/**
@@ -91,6 +91,7 @@ StatusBarRefresh (
if (!StatusStringChanged && StatusBarNeedRefresh) {
StatusBarSetStatusString (L"\0");
}
//
// when it's called first time after editor launch, so refresh is mandatory
//
@@ -117,7 +118,7 @@ StatusBarRefresh (
//
// print row, column fields
//
if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) {
if ((FileRow != (UINTN)(-1)) && (FileCol != (UINTN)(-1))) {
ShellPrintEx (
0,
(INT32)(LastRow) - 1,
@@ -143,6 +144,7 @@ StatusBarRefresh (
} else {
ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
}
//
// restore the old screen attributes
//
@@ -153,8 +155,8 @@ StatusBarRefresh (
//
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
StatusBarNeedRefresh = FALSE;
StatusStringChanged = FALSE;
StatusBarNeedRefresh = FALSE;
StatusStringChanged = FALSE;
return EFI_SUCCESS;
}
@@ -169,7 +171,7 @@ StatusBarRefresh (
**/
EFI_STATUS
StatusBarSetStatusString (
IN CHAR16 *Str
IN CHAR16 *Str
)
{
StatusStringChanged = TRUE;
@@ -191,7 +193,7 @@ StatusBarSetStatusString (
@return The string that is used.
**/
CONST CHAR16*
CONST CHAR16 *
StatusBarGetString (
VOID
)
@@ -203,7 +205,7 @@ StatusBarGetString (
Function to set the need refresh boolean to TRUE.
**/
VOID
StatusBarSetRefresh(
StatusBarSetRefresh (
VOID
)
{
@@ -216,7 +218,7 @@ StatusBarSetRefresh(
@retval TRUE The status bar needs to be refreshed.
**/
BOOLEAN
StatusBarGetRefresh(
StatusBarGetRefresh (
VOID
)
{

View File

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

View File

@@ -22,7 +22,7 @@ CHAR16 *Title = NULL;
**/
EFI_STATUS
MainTitleBarInit (
CONST CHAR16 *Prompt
CONST CHAR16 *Prompt
)
{
SHELL_FREE_NON_NULL (Title);
@@ -34,6 +34,7 @@ MainTitleBarInit (
//
Title = CatSPrint (NULL, L"%s", Prompt);
}
if (Title == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -54,13 +55,13 @@ MainTitleBarCleanup (
}
typedef struct {
UINT32 Foreground : 4;
UINT32 Background : 4;
UINT32 Foreground : 4;
UINT32 Background : 4;
} TITLE_BAR_COLOR_ATTRIBUTES;
typedef union {
TITLE_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
TITLE_BAR_COLOR_ATTRIBUTES Colors;
UINTN Data;
} TITLE_BAR_COLOR_UNION;
/**
@@ -79,21 +80,20 @@ typedef union {
**/
EFI_STATUS
MainTitleBarRefresh (
IN CONST CHAR16 *FileName OPTIONAL,
IN CONST EDIT_FILE_TYPE FileType,
IN CONST BOOLEAN ReadOnly,
IN CONST BOOLEAN Modified,
IN CONST UINTN LastCol,
IN CONST UINTN LastRow,
IN CONST UINTN Offset,
IN CONST UINTN Size
IN CONST CHAR16 *FileName OPTIONAL,
IN CONST EDIT_FILE_TYPE FileType,
IN CONST BOOLEAN ReadOnly,
IN CONST BOOLEAN Modified,
IN CONST UINTN LastCol,
IN CONST UINTN LastRow,
IN CONST UINTN Offset,
IN CONST UINTN Size
)
{
TITLE_BAR_COLOR_UNION Orig;
TITLE_BAR_COLOR_UNION New;
CONST CHAR16 *FileNameTmp;
INTN TempInteger;
TITLE_BAR_COLOR_UNION Orig;
TITLE_BAR_COLOR_UNION New;
CONST CHAR16 *FileNameTmp;
INTN TempInteger;
//
// backup the old screen attributes
@@ -121,10 +121,12 @@ MainTitleBarRefresh (
Title
);
}
if (FileName == NULL) {
gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
return EFI_SUCCESS;
}
//
// First Extract the FileName from fullpath
//
@@ -141,57 +143,62 @@ MainTitleBarRefresh (
// the space for file name is 20 characters
//
if (StrLen (FileNameTmp) <= 20) {
ShellPrintEx (-1,-1, L"%s ", FileNameTmp);
ShellPrintEx (-1, -1, L"%s ", FileNameTmp);
for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) {
ShellPrintEx (-1,-1, L" ");
ShellPrintEx (-1, -1, L" ");
}
} else {
for (TempInteger = 0; TempInteger < 17; TempInteger++) {
ShellPrintEx (-1,-1, L"%c", FileNameTmp[TempInteger]);
ShellPrintEx (-1, -1, L"%c", FileNameTmp[TempInteger]);
}
//
// print "..."
//
ShellPrintEx (-1,-1, L"... ");
ShellPrintEx (-1, -1, L"... ");
}
//
// print file type field
//
switch (FileType){
switch (FileType) {
case FileTypeAscii:
case FileTypeUnicode:
if (FileType == FileTypeAscii){
ShellPrintEx (-1,-1, L" ASCII ");
if (FileType == FileTypeAscii) {
ShellPrintEx (-1, -1, L" ASCII ");
} else {
ShellPrintEx (-1,-1, L" UNICODE ");
ShellPrintEx (-1, -1, L" UNICODE ");
}
//
// print read-only field for text files
//
if (ReadOnly) {
ShellPrintEx (-1,-1, L"ReadOnly ");
ShellPrintEx (-1, -1, L"ReadOnly ");
} else {
ShellPrintEx (-1,-1, L" ");
ShellPrintEx (-1, -1, L" ");
}
break;
break;
case FileTypeDiskBuffer:
case FileTypeMemBuffer:
//
// Print the offset.
//
ShellPrintEx (-1,-1, L"Offset %X | Size %X", Offset, Size);
ShellPrintEx (-1, -1, L"Offset %X | Size %X", Offset, Size);
case FileTypeFileBuffer:
break;
default:
break;
}
//
// print modified field
//
if (Modified) {
ShellPrintEx (-1,-1, L"Modified");
ShellPrintEx (-1, -1, L"Modified");
}
//
// restore the old attribute
//

View File

@@ -19,7 +19,7 @@
**/
EFI_STATUS
MainTitleBarInit (
CONST CHAR16 *Prompt
CONST CHAR16 *Prompt
);
/**
@@ -55,14 +55,14 @@ typedef enum {
**/
EFI_STATUS
MainTitleBarRefresh (
IN CONST CHAR16 *FileName OPTIONAL,
IN CONST EDIT_FILE_TYPE FileType,
IN CONST BOOLEAN ReadOnly,
IN CONST BOOLEAN Modified,
IN CONST UINTN LastCol,
IN CONST UINTN LastRow,
IN CONST UINTN Offset,
IN CONST UINTN Size
IN CONST CHAR16 *FileName OPTIONAL,
IN CONST EDIT_FILE_TYPE FileType,
IN CONST BOOLEAN ReadOnly,
IN CONST BOOLEAN Modified,
IN CONST UINTN LastCol,
IN CONST UINTN LastRow,
IN CONST UINTN Offset,
IN CONST UINTN Size
);
#endif

View File

@@ -23,103 +23,107 @@ ShellCommandRunEfiCompress (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InShellFileHandle;
SHELL_FILE_HANDLE OutShellFileHandle;
UINT64 OutSize;
UINTN OutSize2;
VOID *OutBuffer;
UINT64 InSize;
UINTN InSize2;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
CONST CHAR16 *TempParam;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InShellFileHandle;
SHELL_FILE_HANDLE OutShellFileHandle;
UINT64 OutSize;
UINTN OutSize2;
VOID *OutBuffer;
UINT64 InSize;
UINTN InSize2;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
CONST CHAR16 *TempParam;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InShellFileHandle = NULL;
OutShellFileHandle = NULL;
InBuffer = NULL;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InShellFileHandle = NULL;
OutShellFileHandle = NULL;
InBuffer = NULL;
//
// 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"eficompress", 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"eficompress", 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"eficompress");
if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress");
} else if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
InFileName = ShellFindFilePath(TempParam);
OutFileName = ShellCommandLineGetRawValue(Package, 2);
TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT (TempParam != NULL);
InFileName = ShellFindFilePath (TempParam);
OutFileName = ShellCommandLineGetRawValue (Package, 2);
if (InFileName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam);
ShellStatus = SHELL_NOT_FOUND;
} else {
if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
if (ShellIsDirectory (InFileName) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
if (ShellIsDirectory (OutFileName) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 1));
Status = ShellOpenFileByName (InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_NOT_FOUND;
}
Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 2));
Status = ShellOpenFileByName (OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue (Package, 2));
ShellStatus = SHELL_NOT_FOUND;
}
}
if (ShellStatus == SHELL_SUCCESS) {
Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize);
ASSERT_EFI_ERROR(Status);
InBuffer = AllocateZeroPool((UINTN)InSize);
Status = gEfiShellProtocol->GetFileSize (InShellFileHandle, &InSize);
ASSERT_EFI_ERROR (Status);
InBuffer = AllocateZeroPool ((UINTN)InSize);
if (InBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
InSize2 = (UINTN) InSize;
Status = gEfiShellProtocol->ReadFile (InShellFileHandle, &InSize2, InBuffer);
InSize = InSize2;
InSize2 = (UINTN)InSize;
Status = gEfiShellProtocol->ReadFile (InShellFileHandle, &InSize2, InBuffer);
InSize = InSize2;
ASSERT_EFI_ERROR (Status);
Status = Compress (InBuffer, InSize, OutBuffer, &OutSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
OutBuffer = AllocateZeroPool ((UINTN) OutSize);
OutBuffer = AllocateZeroPool ((UINTN)OutSize);
if (OutBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
@@ -127,14 +131,15 @@ ShellCommandRunEfiCompress (
}
}
}
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status);
ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : SHELL_DEVICE_ERROR);
} else {
OutSize2 = (UINTN)OutSize;
Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &OutSize2, OutBuffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"eficompress", OutFileName);
Status = gEfiShellProtocol->WriteFile (OutShellFileHandle, &OutSize2, OutBuffer);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"eficompress", OutFileName);
ShellStatus = SHELL_DEVICE_ERROR;
}
}
@@ -144,15 +149,18 @@ ShellCommandRunEfiCompress (
ShellCommandLineFreeVarList (Package);
}
if (InShellFileHandle != NULL) {
gEfiShellProtocol->CloseFile(InShellFileHandle);
gEfiShellProtocol->CloseFile (InShellFileHandle);
}
if (OutShellFileHandle != NULL) {
gEfiShellProtocol->CloseFile(OutShellFileHandle);
gEfiShellProtocol->CloseFile (OutShellFileHandle);
}
SHELL_FREE_NON_NULL(InFileName);
SHELL_FREE_NON_NULL(InBuffer);
SHELL_FREE_NON_NULL(OutBuffer);
SHELL_FREE_NON_NULL (InFileName);
SHELL_FREE_NON_NULL (InBuffer);
SHELL_FREE_NON_NULL (OutBuffer);
return (ShellStatus);
}

View File

@@ -10,7 +10,6 @@
#include "UefiShellDebug1CommandsLib.h"
#include <Protocol/Decompress.h>
/**
Function for 'decompress' command.
@@ -24,124 +23,126 @@ ShellCommandRunEfiDecompress (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InFileHandle;
SHELL_FILE_HANDLE OutFileHandle;
UINT32 OutSize;
UINTN OutSizeTemp;
VOID *OutBuffer;
UINTN InSize;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
UINT64 Temp64Bit;
UINT32 ScratchSize;
VOID *ScratchBuffer;
EFI_DECOMPRESS_PROTOCOL *Decompress;
CONST CHAR16 *TempParam;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InFileHandle;
SHELL_FILE_HANDLE OutFileHandle;
UINT32 OutSize;
UINTN OutSizeTemp;
VOID *OutBuffer;
UINTN InSize;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
UINT64 Temp64Bit;
UINT32 ScratchSize;
VOID *ScratchBuffer;
EFI_DECOMPRESS_PROTOCOL *Decompress;
CONST CHAR16 *TempParam;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ScratchSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InBuffer = NULL;
ScratchBuffer = NULL;
InFileHandle = NULL;
OutFileHandle = NULL;
Decompress = NULL;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ScratchSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InBuffer = NULL;
ScratchBuffer = NULL;
InFileHandle = NULL;
OutFileHandle = NULL;
Decompress = NULL;
//
// 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"efidecompress", 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"efidecompress", 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"efidecompress");
if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"efidecompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"efidecompress");
} else if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"efidecompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
InFileName = ShellFindFilePath(TempParam);
OutFileName = ShellCommandLineGetRawValue(Package, 2);
TempParam = ShellCommandLineGetRawValue (Package, 1);
ASSERT (TempParam != NULL);
InFileName = ShellFindFilePath (TempParam);
OutFileName = ShellCommandLineGetRawValue (Package, 2);
if (InFileName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"efidecompress", TempParam);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"efidecompress", TempParam);
ShellStatus = SHELL_NOT_FOUND;
} else {
if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", InFileName);
if (ShellIsDirectory (InFileName) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", InFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", OutFileName);
if (ShellIsDirectory (OutFileName) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", OutFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"efidecompress", ShellCommandLineGetRawValue(Package, 1));
Status = ShellOpenFileByName (InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"efidecompress", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_NOT_FOUND;
}
}
if (ShellStatus == SHELL_SUCCESS) {
Status = FileHandleGetSize(InFileHandle, &Temp64Bit);
ASSERT(Temp64Bit <= (UINT32)(-1));
Status = FileHandleGetSize (InFileHandle, &Temp64Bit);
ASSERT (Temp64Bit <= (UINT32)(-1));
InSize = (UINTN)Temp64Bit;
ASSERT_EFI_ERROR(Status);
InBuffer = AllocateZeroPool(InSize);
ASSERT_EFI_ERROR (Status);
InBuffer = AllocateZeroPool (InSize);
if (InBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
Status = gEfiShellProtocol->ReadFile (InFileHandle, &InSize, InBuffer);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**) &Decompress);
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **)&Decompress);
ASSERT_EFI_ERROR (Status);
Status = Decompress->GetInfo (Decompress, InBuffer, (UINT32) InSize, &OutSize, &ScratchSize);
Status = Decompress->GetInfo (Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize);
}
if (EFI_ERROR(Status) || OutSize == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
if (EFI_ERROR (Status) || (OutSize == 0)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
ShellStatus = SHELL_NOT_FOUND;
} else {
Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);
Status = ShellOpenFileByName (OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue (Package, 2), Status);
ShellStatus = SHELL_NOT_FOUND;
} else {
OutBuffer = AllocateZeroPool(OutSize);
ScratchBuffer = AllocateZeroPool(ScratchSize);
if (OutBuffer == NULL || ScratchBuffer == NULL) {
OutBuffer = AllocateZeroPool (OutSize);
ScratchBuffer = AllocateZeroPool (ScratchSize);
if ((OutBuffer == NULL) || (ScratchBuffer == NULL)) {
Status = EFI_OUT_OF_RESOURCES;
} else {
Status = Decompress->Decompress (Decompress, InBuffer, (UINT32) InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
Status = Decompress->Decompress (Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
}
}
}
@@ -151,8 +152,8 @@ ShellCommandRunEfiDecompress (
ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : SHELL_DEVICE_ERROR);
} else {
OutSizeTemp = OutSize;
Status = gEfiShellProtocol->WriteFile (OutFileHandle, &OutSizeTemp, OutBuffer);
OutSize = (UINT32) OutSizeTemp;
Status = gEfiShellProtocol->WriteFile (OutFileHandle, &OutSizeTemp, OutBuffer);
OutSize = (UINT32)OutSizeTemp;
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"efidecompress", OutFileName, Status);
ShellStatus = SHELL_DEVICE_ERROR;
@@ -164,17 +165,19 @@ ShellCommandRunEfiDecompress (
ShellCommandLineFreeVarList (Package);
}
if (InFileHandle != NULL) {
gEfiShellProtocol->CloseFile(InFileHandle);
}
if (OutFileHandle != NULL) {
gEfiShellProtocol->CloseFile(OutFileHandle);
gEfiShellProtocol->CloseFile (InFileHandle);
}
SHELL_FREE_NON_NULL(InFileName);
SHELL_FREE_NON_NULL(InBuffer);
SHELL_FREE_NON_NULL(OutBuffer);
SHELL_FREE_NON_NULL(ScratchBuffer);
if (OutFileHandle != NULL) {
gEfiShellProtocol->CloseFile (OutFileHandle);
}
SHELL_FREE_NON_NULL (InFileName);
SHELL_FREE_NON_NULL (InBuffer);
SHELL_FREE_NON_NULL (OutBuffer);
SHELL_FREE_NON_NULL (ScratchBuffer);
return (ShellStatus);
}

View File

@@ -62,7 +62,7 @@ HBufferImageRefresh (
**/
EFI_STATUS
HBufferImageHandleInput (
IN EFI_INPUT_KEY *Key
IN EFI_INPUT_KEY *Key
);
/**
@@ -92,14 +92,14 @@ HBufferImageBackup (
**/
EFI_STATUS
HBufferImageRead (
IN CONST CHAR16 *FileName,
IN CONST CHAR16 *DiskName,
IN UINTN DiskOffset,
IN UINTN DiskSize,
IN UINTN MemOffset,
IN UINTN MemSize,
IN EDIT_FILE_TYPE BufferType,
IN BOOLEAN Recover
IN CONST CHAR16 *FileName,
IN CONST CHAR16 *DiskName,
IN UINTN DiskOffset,
IN UINTN DiskSize,
IN UINTN MemOffset,
IN UINTN MemSize,
IN EDIT_FILE_TYPE BufferType,
IN BOOLEAN Recover
);
/**
@@ -117,13 +117,13 @@ HBufferImageRead (
**/
EFI_STATUS
HBufferImageSave (
IN CHAR16 *FileName,
IN CHAR16 *DiskName,
IN UINTN DiskOffset,
IN UINTN DiskSize,
IN UINTN MemOffset,
IN UINTN MemSize,
IN EDIT_FILE_TYPE BufferType
IN CHAR16 *FileName,
IN CHAR16 *DiskName,
IN UINTN DiskOffset,
IN UINTN DiskSize,
IN UINTN MemOffset,
IN UINTN MemSize,
IN EDIT_FILE_TYPE BufferType
);
/**
@@ -140,7 +140,6 @@ HBufferImageMovePosition (
IN BOOLEAN HighBits
);
/**
Create a new line and append it to the line list.
Fields affected:
@@ -177,9 +176,9 @@ HBufferImageFree (
**/
EFI_STATUS
HBufferImageDeleteCharacterFromBuffer (
IN UINTN Pos,
IN UINTN Count,
OUT UINT8 *DeleteBuffer
IN UINTN Pos,
IN UINTN Count,
OUT UINT8 *DeleteBuffer
);
/**
@@ -193,9 +192,9 @@ HBufferImageDeleteCharacterFromBuffer (
**/
EFI_STATUS
HBufferImageAddCharacterToBuffer (
IN UINTN Pos,
IN UINTN Count,
IN UINT8 *AddBuffer
IN UINTN Pos,
IN UINTN Count,
IN UINT8 *AddBuffer
);
/**
@@ -235,8 +234,8 @@ HBufferImageListToBuffer (
**/
VOID
HBufferImageAdjustMousePosition (
IN INT32 TextX,
IN INT32 TextY
IN INT32 TextX,
IN INT32 TextY
);
/**
@@ -250,8 +249,8 @@ HBufferImageAdjustMousePosition (
**/
BOOLEAN
HBufferImageIsAtHighBits (
IN UINTN Column,
OUT UINTN *FCol
IN UINTN Column,
OUT UINTN *FCol
);
/**

View File

@@ -9,16 +9,16 @@
#include "HexEditor.h"
typedef struct {
UINT8 *Buffer;
UINTN Size;
UINT8 *Buffer;
UINTN Size;
} HEFI_EDITOR_CLIPBOARD;
HEFI_EDITOR_CLIPBOARD HClipBoard;
HEFI_EDITOR_CLIPBOARD HClipBoard;
//
// for basic initialization of HClipBoard
//
HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
NULL,
0
};
@@ -53,7 +53,6 @@ HClipBoardCleanup (
VOID
)
{
SHELL_FREE_NON_NULL (HClipBoard.Buffer);
return EFI_SUCCESS;
@@ -69,8 +68,8 @@ HClipBoardCleanup (
**/
EFI_STATUS
HClipBoardSet (
IN UINT8 *Buffer,
IN UINTN Size
IN UINT8 *Buffer,
IN UINTN Size
)
{
//
@@ -80,7 +79,7 @@ HClipBoardSet (
SHELL_FREE_NON_NULL (HClipBoard.Buffer);
HClipBoard.Buffer = Buffer;
HClipBoard.Size = Size;
HClipBoard.Size = Size;
return EFI_SUCCESS;
}

View File

@@ -44,8 +44,8 @@ HClipBoardCleanup (
**/
EFI_STATUS
HClipBoardSet (
IN UINT8 *Buffer,
IN UINTN Size
IN UINT8 *Buffer,
IN UINTN Size
);
/**

View File

@@ -9,22 +9,22 @@
#include "HexEditor.h"
#include <Protocol/BlockIo.h>
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
HEFI_EDITOR_DISK_IMAGE HDiskImage;
HEFI_EDITOR_DISK_IMAGE HDiskImageBackupVar;
HEFI_EDITOR_DISK_IMAGE HDiskImage;
HEFI_EDITOR_DISK_IMAGE HDiskImageBackupVar;
//
// for basic initialization of HDiskImage
//
HEFI_EDITOR_DISK_IMAGE HDiskImageConst = {
HEFI_EDITOR_DISK_IMAGE HDiskImageConst = {
NULL,
0,
0,
@@ -70,13 +70,13 @@ HDiskImageBackup (
//
SHELL_FREE_NON_NULL (HDiskImageBackupVar.Name);
HDiskImageBackupVar.Name = CatSPrint(NULL, L"%s", HDiskImage.Name);
HDiskImageBackupVar.Name = CatSPrint (NULL, L"%s", HDiskImage.Name);
if (HDiskImageBackupVar.Name == NULL) {
return EFI_OUT_OF_RESOURCES;
}
HDiskImageBackupVar.Offset = HDiskImage.Offset;
HDiskImageBackupVar.Size = HDiskImage.Size;
HDiskImageBackupVar.Offset = HDiskImage.Offset;
HDiskImageBackupVar.Size = HDiskImage.Size;
return EFI_SUCCESS;
}
@@ -109,9 +109,9 @@ HDiskImageCleanup (
**/
EFI_STATUS
HDiskImageSetDiskNameOffsetSize (
IN CONST CHAR16 *Str,
IN UINTN Offset,
IN UINTN Size
IN CONST CHAR16 *Str,
IN UINTN Offset,
IN UINTN Size
)
{
if (Str == HDiskImage.Name) {
@@ -131,8 +131,8 @@ HDiskImageSetDiskNameOffsetSize (
return EFI_OUT_OF_RESOURCES;
}
HDiskImage.Offset = Offset;
HDiskImage.Size = Size;
HDiskImage.Offset = Offset;
HDiskImage.Size = Size;
return EFI_SUCCESS;
}
@@ -152,10 +152,10 @@ HDiskImageSetDiskNameOffsetSize (
**/
EFI_STATUS
HDiskImageRead (
IN CONST CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
IN CONST CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@@ -165,46 +165,49 @@ HDiskImageRead (
EFI_BLOCK_IO_PROTOCOL *BlkIo;
EFI_STATUS Status;
VOID *Buffer;
CHAR16 *Str;
UINTN Bytes;
VOID *Buffer;
CHAR16 *Str;
UINTN Bytes;
HEFI_EDITOR_LINE *Line;
HEFI_EDITOR_LINE *Line;
HBufferImage.BufferType = FileTypeDiskBuffer;
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
DevicePath = gEfiShellProtocol->GetDevicePathFromMap (DeviceName);
if (DevicePath == NULL) {
StatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
DupDevicePath = DuplicateDevicePath(DevicePath);
DupDevicePath = DuplicateDevicePath (DevicePath);
DupDevicePathForFree = DupDevicePath;
//
// get blkio interface
//
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);
FreePool(DupDevicePathForFree);
Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &DupDevicePath, &Handle);
FreePool (DupDevicePathForFree);
if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
Status = gBS->OpenProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
//
// if Offset exceeds LastBlock,
// return error
//
if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) {
if ((Offset > BlkIo->Media->LastBlock) || (Offset + Size > BlkIo->Media->LastBlock)) {
StatusBarSetStatusString (L"Invalid Offset + Size");
return EFI_LOAD_ERROR;
}
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocateZeroPool (Bytes);
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocateZeroPool (Bytes);
if (Buffer == NULL) {
StatusBarSetStatusString (L"Read Disk Failed");
@@ -246,25 +249,26 @@ HDiskImageRead (
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
//
// initialize some variables
//
HDiskImage.BlockSize = BlkIo->Media->BlockSize;
HDiskImage.BlockSize = BlkIo->Media->BlockSize;
HBufferImage.DisplayPosition.Row = 2;
HBufferImage.DisplayPosition.Column = 10;
HBufferImage.MousePosition.Row = 2;
HBufferImage.MousePosition.Column = 10;
HBufferImage.MousePosition.Row = 2;
HBufferImage.MousePosition.Column = 10;
HBufferImage.LowVisibleRow = 1;
HBufferImage.HighBits = TRUE;
HBufferImage.LowVisibleRow = 1;
HBufferImage.HighBits = TRUE;
HBufferImage.BufferPosition.Row = 1;
HBufferImage.BufferPosition.Column = 1;
HBufferImage.BufferPosition.Row = 1;
HBufferImage.BufferPosition.Column = 1;
if (!Recover) {
Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
Str = CatSPrint (NULL, L"%d Lines Read", HBufferImage.NumLines);
if (Str == NULL) {
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
@@ -275,7 +279,6 @@ HDiskImageRead (
HMainEditor.SelectStart = 0;
HMainEditor.SelectEnd = 0;
}
//
@@ -283,11 +286,11 @@ HDiskImageRead (
//
if (HBufferImage.Lines != NULL) {
HBufferImage.CurrentLine = CR (
HBufferImage.ListHead->ForwardLink,
HEFI_EDITOR_LINE,
Link,
EFI_EDITOR_LINE_LIST
);
HBufferImage.ListHead->ForwardLink,
HEFI_EDITOR_LINE,
Link,
EFI_EDITOR_LINE_LIST
);
} else {
//
// create a dummy line
@@ -324,12 +327,11 @@ HDiskImageRead (
**/
EFI_STATUS
HDiskImageSave (
IN CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size
IN CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree;
@@ -348,35 +350,38 @@ HDiskImageSave (
HBufferImage.BufferType = FileTypeDiskBuffer;
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
DevicePath = gEfiShellProtocol->GetDevicePathFromMap (DeviceName);
if (DevicePath == NULL) {
// StatusBarSetStatusString (L"Cannot Find Device");
// StatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
DupDevicePath = DuplicateDevicePath(DevicePath);
DupDevicePath = DuplicateDevicePath (DevicePath);
DupDevicePathForFree = DupDevicePath;
//
// get blkio interface
//
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);
FreePool(DupDevicePathForFree);
Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &DupDevicePath, &Handle);
FreePool (DupDevicePathForFree);
if (EFI_ERROR (Status)) {
// StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR (Status)) {
// StatusBarSetStatusString (L"Read Disk Failed");
// StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocateZeroPool (Bytes);
Status = gBS->OpenProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR (Status)) {
// StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocateZeroPool (Bytes);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// concatenate the line list to a buffer
//
@@ -402,6 +407,7 @@ HDiskImageSave (
if (EFI_ERROR (Status)) {
return EFI_LOAD_ERROR;
}
//
// now not modified
//

View File

@@ -60,10 +60,10 @@ HDiskImageBackup (
**/
EFI_STATUS
HDiskImageRead (
IN CONST CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
IN CONST CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
);
/**
@@ -81,9 +81,9 @@ HDiskImageRead (
**/
EFI_STATUS
HDiskImageSave (
IN CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size
IN CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size
);
#endif

View File

@@ -8,22 +8,22 @@
#include "HexEditor.h"
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
HEFI_EDITOR_FILE_IMAGE HFileImage;
HEFI_EDITOR_FILE_IMAGE HFileImageBackupVar;
HEFI_EDITOR_FILE_IMAGE HFileImage;
HEFI_EDITOR_FILE_IMAGE HFileImageBackupVar;
//
// for basic initialization of HFileImage
//
HEFI_EDITOR_BUFFER_IMAGE HFileImageConst = {
HEFI_EDITOR_BUFFER_IMAGE HFileImageConst = {
NULL,
0,
FALSE
@@ -66,7 +66,7 @@ HFileImageBackup (
)
{
SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
HFileImageBackupVar.FileName = CatSPrint(NULL, L"%s", HFileImage.FileName);
HFileImageBackupVar.FileName = CatSPrint (NULL, L"%s", HFileImage.FileName);
if (HFileImageBackupVar.FileName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -84,7 +84,6 @@ HFileImageCleanup (
VOID
)
{
SHELL_FREE_NON_NULL (HFileImage.FileName);
SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
@@ -101,7 +100,7 @@ HFileImageCleanup (
**/
EFI_STATUS
HFileImageSetFileName (
IN CONST CHAR16 *Str
IN CONST CHAR16 *Str
)
{
if (Str == HFileImage.FileName) {
@@ -111,6 +110,7 @@ HFileImageSetFileName (
//
return EFI_SUCCESS;
}
//
// free the old file name
//
@@ -136,18 +136,18 @@ HFileImageSetFileName (
EFI_STATUS
HFileImageRead (
IN CONST CHAR16 *FileName,
IN BOOLEAN Recover
IN BOOLEAN Recover
)
{
HEFI_EDITOR_LINE *Line;
UINT8 *Buffer;
CHAR16 *UnicodeBuffer;
EFI_STATUS Status;
HEFI_EDITOR_LINE *Line;
UINT8 *Buffer;
CHAR16 *UnicodeBuffer;
EFI_STATUS Status;
//
// variable initialization
//
Line = NULL;
Line = NULL;
//
// in this function, when you return error ( except EFI_OUT_OF_RESOURCES )
@@ -157,14 +157,14 @@ HFileImageRead (
// so if you want to print the error status
// you should set the status string
//
Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);
Status = ReadFileIntoBuffer (FileName, (VOID **)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);
//
// NULL pointer is only also a failure for a non-zero file size.
//
if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) {
UnicodeBuffer = CatSPrint(NULL, L"Read error on file %s: %r", FileName, Status);
if ((EFI_ERROR (Status)) || ((Buffer == NULL) && (HFileImage.Size != 0))) {
UnicodeBuffer = CatSPrint (NULL, L"Read error on file %s: %r", FileName, Status);
if (UnicodeBuffer == NULL) {
SHELL_FREE_NON_NULL(Buffer);
SHELL_FREE_NON_NULL (Buffer);
return EFI_OUT_OF_RESOURCES;
}
@@ -195,12 +195,12 @@ HFileImageRead (
HBufferImage.HighBits = TRUE;
HBufferImage.BufferPosition.Row = 1;
HBufferImage.BufferPosition.Column = 1;
HBufferImage.BufferType = FileTypeFileBuffer;
HBufferImage.BufferType = FileTypeFileBuffer;
if (!Recover) {
UnicodeBuffer = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
UnicodeBuffer = CatSPrint (NULL, L"%d Lines Read", HBufferImage.NumLines);
if (UnicodeBuffer == NULL) {
SHELL_FREE_NON_NULL(Buffer);
SHELL_FREE_NON_NULL (Buffer);
return EFI_OUT_OF_RESOURCES;
}
@@ -222,7 +222,7 @@ HFileImageRead (
//
Line = HBufferImageCreateLine ();
if (Line == NULL) {
SHELL_FREE_NON_NULL(Buffer);
SHELL_FREE_NON_NULL (Buffer);
return EFI_OUT_OF_RESOURCES;
}
@@ -248,20 +248,19 @@ HFileImageRead (
**/
EFI_STATUS
HFileImageSave (
IN CHAR16 *FileName
IN CHAR16 *FileName
)
{
LIST_ENTRY *Link;
HEFI_EDITOR_LINE *Line;
CHAR16 *Str;
EFI_STATUS Status;
UINTN NumLines;
SHELL_FILE_HANDLE FileHandle;
UINTN TotalSize;
UINT8 *Buffer;
UINT8 *Ptr;
EDIT_FILE_TYPE BufferTypeBackup;
LIST_ENTRY *Link;
HEFI_EDITOR_LINE *Line;
CHAR16 *Str;
EFI_STATUS Status;
UINTN NumLines;
SHELL_FILE_HANDLE FileHandle;
UINTN TotalSize;
UINT8 *Buffer;
UINT8 *Ptr;
EDIT_FILE_TYPE BufferTypeBackup;
BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeFileBuffer;
@@ -269,11 +268,11 @@ HFileImageSave (
//
// if is the old file
//
if (HFileImage.FileName != NULL && FileName != NULL && StrCmp (FileName, HFileImage.FileName) == 0) {
if ((HFileImage.FileName != NULL) && (FileName != NULL) && (StrCmp (FileName, HFileImage.FileName) == 0)) {
//
// check whether file exists on disk
//
if (ShellIsFile(FileName) == EFI_SUCCESS) {
if (ShellIsFile (FileName) == EFI_SUCCESS) {
//
// current file exists on disk
// so if not modified, then not save
@@ -281,6 +280,7 @@ HFileImageSave (
if (HBufferImage.Modified == FALSE) {
return EFI_SUCCESS;
}
//
// if file is read-only, set error
//
@@ -291,7 +291,7 @@ HFileImageSave (
}
}
if (ShellIsDirectory(FileName) == EFI_SUCCESS) {
if (ShellIsDirectory (FileName) == EFI_SUCCESS) {
StatusBarSetStatusString (L"Directory Can Not Be Saved");
return EFI_LOAD_ERROR;
}
@@ -303,11 +303,11 @@ HFileImageSave (
// the file exits, delete it
//
Status = ShellDeleteFile (&FileHandle);
if (EFI_ERROR (Status) || Status == EFI_WARN_DELETE_FAILURE) {
if (EFI_ERROR (Status) || (Status == EFI_WARN_DELETE_FAILURE)) {
StatusBarSetStatusString (L"Write File Failed");
return EFI_LOAD_ERROR;
}
}
}
//
// write all the lines back to disk
@@ -320,11 +320,13 @@ HFileImageSave (
if (Line->Size != 0) {
TotalSize += Line->Size;
}
//
// end of if Line -> Size != 0
//
NumLines++;
}
//
// end of for Link
//
@@ -341,12 +343,12 @@ HFileImageSave (
CopyMem (Ptr, Line->Buffer, Line->Size);
Ptr += Line->Size;
}
//
// end of if Line -> Size != 0
//
}
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR (Status)) {
@@ -361,22 +363,23 @@ HFileImageSave (
return EFI_LOAD_ERROR;
}
ShellCloseFile(&FileHandle);
ShellCloseFile (&FileHandle);
HBufferImage.Modified = FALSE;
//
// set status string
//
Str = CatSPrint(NULL, L"%d Lines Written", NumLines);
Str = CatSPrint (NULL, L"%d Lines Written", NumLines);
StatusBarSetStatusString (Str);
FreePool (Str);
//
// now everything is ready , you can set the new file name to filebuffer
//
if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||
(FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){
if (((BufferTypeBackup != FileTypeFileBuffer) && (FileName != NULL)) ||
((FileName != NULL) && (HFileImage.FileName != NULL) && (StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)))
{
//
// not the same
//

View File

@@ -57,7 +57,7 @@ HFileImageBackup (
EFI_STATUS
HFileImageRead (
IN CONST CHAR16 *FileName,
IN BOOLEAN Recover
IN BOOLEAN Recover
);
/**
@@ -71,7 +71,7 @@ HFileImageRead (
**/
EFI_STATUS
HFileImageSave (
IN CHAR16 *FileName
IN CHAR16 *FileName
);
#endif

View File

@@ -13,12 +13,12 @@
//
// Global Variables
//
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-f", TypeFlag},
{L"-d", TypeFlag},
{L"-m", TypeFlag},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-f", TypeFlag },
{ L"-d", TypeFlag },
{ L"-m", TypeFlag },
{ NULL, TypeMax }
};
/**
Function for 'hexedit' command.
@@ -33,20 +33,20 @@ ShellCommandRunHexEdit (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CHAR16 *Buffer;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CHAR16 *NewName;
CONST CHAR16 *Name;
UINTN Offset;
UINTN Size;
EDIT_FILE_TYPE WhatToDo;
EFI_STATUS Status;
CHAR16 *Buffer;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CHAR16 *NewName;
CONST CHAR16 *Name;
UINTN Offset;
UINTN Size;
EDIT_FILE_TYPE WhatToDo;
Buffer = NULL;
ShellStatus = SHELL_SUCCESS;
NewName = NULL;
NewName = NULL;
Buffer = NULL;
Name = NULL;
Offset = 0;
@@ -56,43 +56,44 @@ ShellCommandRunHexEdit (
//
// 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"hexedit", 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"hexedit", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
//
// Check for -d
//
if (ShellCommandLineGetFlag(Package, L"-d")){
if (ShellCommandLineGetCount(Package) < 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
if (ShellCommandLineGetFlag (Package, L"-d")) {
if (ShellCommandLineGetCount (Package) < 4) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
} else if (ShellCommandLineGetCount (Package) > 4) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeDiskBuffer;
Name = ShellCommandLineGetRawValue(Package, 1);
Offset = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 3));
Name = ShellCommandLineGetRawValue (Package, 1);
Offset = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 2));
Size = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 3));
}
if (Offset == (UINTN)-1 || Size == (UINTN)-1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");
if ((Offset == (UINTN)-1) || (Size == (UINTN)-1)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
@@ -100,20 +101,20 @@ ShellCommandRunHexEdit (
//
// check for -f
//
if (ShellCommandLineGetFlag(Package, L"-f") && (WhatToDo == FileTypeNone)){
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
if (ShellCommandLineGetFlag (Package, L"-f") && (WhatToDo == FileTypeNone)) {
if (ShellCommandLineGetCount (Package) < 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
} else if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Name = ShellCommandLineGetRawValue(Package, 1);
if (Name == NULL || !IsValidFileName(Name)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
Name = ShellCommandLineGetRawValue (Package, 1);
if ((Name == NULL) || !IsValidFileName (Name)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeFileBuffer;
WhatToDo = FileTypeFileBuffer;
}
}
}
@@ -121,46 +122,47 @@ ShellCommandRunHexEdit (
//
// check for -m
//
if (ShellCommandLineGetFlag(Package, L"-m") && (WhatToDo == FileTypeNone)){
if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
if (ShellCommandLineGetFlag (Package, L"-m") && (WhatToDo == FileTypeNone)) {
if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
} else if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeMemBuffer;
Offset = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 1));
Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
}
}
Name = ShellCommandLineGetRawValue(Package, 1);
if (WhatToDo == FileTypeNone && Name != NULL) {
if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (!IsValidFileName(Name)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeFileBuffer;
}
} else if (WhatToDo == FileTypeNone) {
if (gEfiShellProtocol->GetCurDir(NULL) == NULL) {
ShellStatus = SHELL_NOT_FOUND;
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
} else {
NewName = EditGetDefaultFileName(L"bin");
Name = NewName;
WhatToDo = FileTypeFileBuffer;
Offset = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 1));
Size = ShellStrToUintn (ShellCommandLineGetRawValue (Package, 2));
}
}
if (ShellStatus == SHELL_SUCCESS && WhatToDo == FileTypeNone) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
Name = ShellCommandLineGetRawValue (Package, 1);
if ((WhatToDo == FileTypeNone) && (Name != NULL)) {
if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (!IsValidFileName (Name)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeFileBuffer;
}
} else if (WhatToDo == FileTypeNone) {
if (gEfiShellProtocol->GetCurDir (NULL) == NULL) {
ShellStatus = SHELL_NOT_FOUND;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
} else {
NewName = EditGetDefaultFileName (L"bin");
Name = NewName;
WhatToDo = FileTypeFileBuffer;
}
}
if ((ShellStatus == SHELL_SUCCESS) && (WhatToDo == FileTypeNone)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (WhatToDo == FileTypeFileBuffer && ShellGetCurrentDir(NULL) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
} else if ((WhatToDo == FileTypeFileBuffer) && (ShellGetCurrentDir (NULL) == NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
}
@@ -172,62 +174,64 @@ ShellCommandRunHexEdit (
if (EFI_ERROR (Status)) {
gST->ConOut->ClearScreen (gST->ConOut);
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_INIT_FAILED), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_INIT_FAILED), gShellDebug1HiiHandle);
} else {
HMainEditorBackup ();
switch (WhatToDo) {
case FileTypeFileBuffer:
Status = HBufferImageRead (
Name==NULL?L"":Name,
NULL,
0,
0,
0,
0,
FileTypeFileBuffer,
FALSE
);
break;
case FileTypeFileBuffer:
Status = HBufferImageRead (
Name == NULL ? L"" : Name,
NULL,
0,
0,
0,
0,
FileTypeFileBuffer,
FALSE
);
break;
case FileTypeDiskBuffer:
Status = HBufferImageRead (
NULL,
Name==NULL?L"":Name,
Offset,
Size,
0,
0,
FileTypeDiskBuffer,
FALSE
);
break;
case FileTypeDiskBuffer:
Status = HBufferImageRead (
NULL,
Name == NULL ? L"" : Name,
Offset,
Size,
0,
0,
FileTypeDiskBuffer,
FALSE
);
break;
case FileTypeMemBuffer:
Status = HBufferImageRead (
NULL,
NULL,
0,
0,
(UINT32) Offset,
Size,
FileTypeMemBuffer,
FALSE
);
break;
case FileTypeMemBuffer:
Status = HBufferImageRead (
NULL,
NULL,
0,
0,
(UINT32)Offset,
Size,
FileTypeMemBuffer,
FALSE
);
break;
default:
Status = EFI_NOT_FOUND;
break;
default:
Status = EFI_NOT_FOUND;
break;
}
if (!EFI_ERROR (Status)) {
HMainEditorRefresh ();
Status = HMainEditorKeyInput ();
}
if (Status != EFI_OUT_OF_RESOURCES) {
//
// back up the status string
//
Buffer = CatSPrint (NULL, L"%s\r\n", StatusBarGetString());
Buffer = CatSPrint (NULL, L"%s\r\n", StatusBarGetString ());
}
}
@@ -246,22 +250,23 @@ ShellCommandRunHexEdit (
// print editor exit code on screen
//
if (Status == EFI_OUT_OF_RESOURCES) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"hexedit");
} else if (EFI_ERROR(Status)){
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"hexedit");
} else if (EFI_ERROR (Status)) {
if (Buffer != NULL) {
if (StrCmp (Buffer, L"") != 0) {
//
// print out the status string
//
ShellPrintEx(-1, -1, L"%s", Buffer);
ShellPrintEx (-1, -1, L"%s", Buffer);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
}
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
}
}
}
ShellCommandLineFreeVarList (Package);
}

View File

@@ -14,12 +14,11 @@
#define EFI_EDITOR_LINE_LIST SIGNATURE_32 ('e', 'e', 'l', 'l')
#define ASCII_POSITION ((0x10 * 3) + 12)
#define ASCII_POSITION ((0x10 * 3) + 12)
typedef struct {
UINTN Row;
UINTN Column;
UINTN Row;
UINTN Column;
} HEFI_EDITOR_POSITION;
typedef
@@ -29,92 +28,90 @@ EFI_STATUS
);
typedef struct {
CHAR16 Name[50];
CHAR16 Key[3];
HEFI_MENU_ITEM_FUNCTION Function;
CHAR16 Name[50];
CHAR16 Key[3];
HEFI_MENU_ITEM_FUNCTION Function;
} HMENU_ITEMS;
typedef struct _HEFI_EDITOR_LINE {
UINTN Signature;
UINT8 Buffer[0x10];
UINTN Size; // unit is Unicode
LIST_ENTRY Link;
UINTN Signature;
UINT8 Buffer[0x10];
UINTN Size; // unit is Unicode
LIST_ENTRY Link;
} HEFI_EDITOR_LINE;
typedef struct _HEFI_EDITOR_MENU_ITEM {
CHAR16 NameToken;
CHAR16 FunctionKeyToken;
HEFI_MENU_ITEM_FUNCTION Function;
CHAR16 NameToken;
CHAR16 FunctionKeyToken;
HEFI_MENU_ITEM_FUNCTION Function;
} HEFI_EDITOR_MENU_ITEM;
typedef struct {
UINT32 Foreground : 4;
UINT32 Background : 4;
UINT32 Foreground : 4;
UINT32 Background : 4;
} HEFI_EDITOR_COLOR_ATTRIBUTES;
typedef union {
HEFI_EDITOR_COLOR_ATTRIBUTES Colors;
UINTN Data;
HEFI_EDITOR_COLOR_ATTRIBUTES Colors;
UINTN Data;
} HEFI_EDITOR_COLOR_UNION;
typedef struct {
UINTN Columns;
UINTN Rows;
UINTN Columns;
UINTN Rows;
} HEFI_EDITOR_TEXT_MODE;
typedef struct {
CHAR16 *Name;
CHAR16 *Name;
UINTN BlockSize;
UINTN Size;
UINTN Offset;
UINTN BlockSize;
UINTN Size;
UINTN Offset;
} HEFI_EDITOR_DISK_IMAGE;
typedef struct {
EFI_CPU_IO2_PROTOCOL *IoFncs;
UINTN Offset;
UINTN Size;
EFI_CPU_IO2_PROTOCOL *IoFncs;
UINTN Offset;
UINTN Size;
} HEFI_EDITOR_MEM_IMAGE;
typedef struct {
CHAR16 *FileName;
UINTN Size; // file size
BOOLEAN ReadOnly; // file is read-only or not
CHAR16 *FileName;
UINTN Size; // file size
BOOLEAN ReadOnly; // file is read-only or not
} HEFI_EDITOR_FILE_IMAGE;
typedef struct {
LIST_ENTRY *ListHead; // list head of lines
HEFI_EDITOR_LINE *Lines; // lines of current file
UINTN NumLines; // number of lines
HEFI_EDITOR_LINE *CurrentLine; // current line cursor is at
HEFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
HEFI_EDITOR_POSITION MousePosition; // mouse position in screen
HEFI_EDITOR_POSITION BufferPosition; // cursor position in buffer
UINTN LowVisibleRow; // the lowest visible row of file position
BOOLEAN HighBits; // cursor is at the high4 bits or low4 bits
BOOLEAN Modified; // BUFFER is modified or not
EDIT_FILE_TYPE BufferType;
HEFI_EDITOR_FILE_IMAGE *FileImage;
HEFI_EDITOR_DISK_IMAGE *DiskImage;
HEFI_EDITOR_MEM_IMAGE *MemImage;
LIST_ENTRY *ListHead; // list head of lines
HEFI_EDITOR_LINE *Lines; // lines of current file
UINTN NumLines; // number of lines
HEFI_EDITOR_LINE *CurrentLine; // current line cursor is at
HEFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
HEFI_EDITOR_POSITION MousePosition; // mouse position in screen
HEFI_EDITOR_POSITION BufferPosition; // cursor position in buffer
UINTN LowVisibleRow; // the lowest visible row of file position
BOOLEAN HighBits; // cursor is at the high4 bits or low4 bits
BOOLEAN Modified; // BUFFER is modified or not
EDIT_FILE_TYPE BufferType;
HEFI_EDITOR_FILE_IMAGE *FileImage;
HEFI_EDITOR_DISK_IMAGE *DiskImage;
HEFI_EDITOR_MEM_IMAGE *MemImage;
} HEFI_EDITOR_BUFFER_IMAGE;
typedef struct {
HEFI_EDITOR_BUFFER_IMAGE *BufferImage;
HEFI_EDITOR_BUFFER_IMAGE *BufferImage;
HEFI_EDITOR_COLOR_UNION ColorAttributes;
HEFI_EDITOR_POSITION ScreenSize; // row number and column number
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
BOOLEAN MouseSupported;
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
INT32 MouseAccumulatorX;
INT32 MouseAccumulatorY;
HEFI_EDITOR_COLOR_UNION ColorAttributes;
HEFI_EDITOR_POSITION ScreenSize; // row number and column number
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
BOOLEAN MouseSupported;
EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
INT32 MouseAccumulatorX;
INT32 MouseAccumulatorY;
UINTN SelectStart; // starting from 1
UINTN SelectEnd; // starting from 1
UINTN SelectStart; // starting from 1
UINTN SelectEnd; // starting from 1
} HEFI_EDITOR_GLOBAL_EDITOR;
#endif

View File

@@ -8,23 +8,23 @@
#include "HexEditor.h"
extern EFI_HANDLE HImageHandleBackup;
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
HEFI_EDITOR_MEM_IMAGE HMemImage;
HEFI_EDITOR_MEM_IMAGE HMemImageBackupVar;
HEFI_EDITOR_MEM_IMAGE HMemImage;
HEFI_EDITOR_MEM_IMAGE HMemImageBackupVar;
//
// for basic initialization of HDiskImage
//
HEFI_EDITOR_MEM_IMAGE HMemImageConst = {
HEFI_EDITOR_MEM_IMAGE HMemImageConst = {
NULL,
0,
0
@@ -49,10 +49,10 @@ HMemImageInit (
CopyMem (&HMemImage, &HMemImageConst, sizeof (HMemImage));
Status = gBS->LocateProtocol (
&gEfiCpuIo2ProtocolGuid,
NULL,
(VOID**)&HMemImage.IoFncs
);
&gEfiCpuIo2ProtocolGuid,
NULL,
(VOID **)&HMemImage.IoFncs
);
if (!EFI_ERROR (Status)) {
return EFI_SUCCESS;
} else {
@@ -88,13 +88,12 @@ HMemImageBackup (
**/
EFI_STATUS
HMemImageSetMemOffsetSize (
IN UINTN Offset,
IN UINTN Size
IN UINTN Offset,
IN UINTN Size
)
{
HMemImage.Offset = Offset;
HMemImage.Size = Size;
HMemImage.Offset = Offset;
HMemImage.Size = Size;
return EFI_SUCCESS;
}
@@ -112,32 +111,31 @@ HMemImageSetMemOffsetSize (
**/
EFI_STATUS
HMemImageRead (
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
)
{
EFI_STATUS Status;
void *Buffer;
CHAR16 *Str;
HEFI_EDITOR_LINE *Line;
EFI_STATUS Status;
void *Buffer;
CHAR16 *Str;
HEFI_EDITOR_LINE *Line;
HBufferImage.BufferType = FileTypeMemBuffer;
Buffer = AllocateZeroPool (Size);
Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) {
StatusBarSetStatusString (L"Read Memory Failed");
return EFI_OUT_OF_RESOURCES;
}
Status = HMemImage.IoFncs->Mem.Read (
HMemImage.IoFncs,
EfiCpuIoWidthUint8,
Offset,
Size,
Buffer
);
HMemImage.IoFncs,
EfiCpuIoWidthUint8,
Offset,
Size,
Buffer
);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
@@ -155,22 +153,22 @@ HMemImageRead (
return Status;
}
Status = HMemImageSetMemOffsetSize (Offset, Size);
Status = HMemImageSetMemOffsetSize (Offset, Size);
HBufferImage.DisplayPosition.Row = 2;
HBufferImage.DisplayPosition.Column = 10;
HBufferImage.MousePosition.Row = 2;
HBufferImage.MousePosition.Column = 10;
HBufferImage.MousePosition.Row = 2;
HBufferImage.MousePosition.Column = 10;
HBufferImage.LowVisibleRow = 1;
HBufferImage.HighBits = TRUE;
HBufferImage.LowVisibleRow = 1;
HBufferImage.HighBits = TRUE;
HBufferImage.BufferPosition.Row = 1;
HBufferImage.BufferPosition.Column = 1;
HBufferImage.BufferPosition.Row = 1;
HBufferImage.BufferPosition.Column = 1;
if (!Recover) {
Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
Str = CatSPrint (NULL, L"%d Lines Read", HBufferImage.NumLines);
if (Str == NULL) {
StatusBarSetStatusString (L"Read Memory Failed");
return EFI_OUT_OF_RESOURCES;
@@ -181,7 +179,6 @@ HMemImageRead (
HMainEditor.SelectStart = 0;
HMainEditor.SelectEnd = 0;
}
//
@@ -208,7 +205,6 @@ HMemImageRead (
HBufferImageMouseNeedRefresh = TRUE;
return EFI_SUCCESS;
}
/**
@@ -223,13 +219,12 @@ HMemImageRead (
**/
EFI_STATUS
HMemImageSave (
IN UINTN Offset,
IN UINTN Size
IN UINTN Offset,
IN UINTN Size
)
{
EFI_STATUS Status;
VOID *Buffer;
EFI_STATUS Status;
VOID *Buffer;
//
// not modified, so directly return
@@ -240,7 +235,7 @@ HMemImageSave (
HBufferImage.BufferType = FileTypeMemBuffer;
Buffer = AllocateZeroPool (Size);
Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -251,22 +246,24 @@ HMemImageSave (
FreePool (Buffer);
return Status;
}
//
// write back to memory
//
Status = HMemImage.IoFncs->Mem.Write (
HMemImage.IoFncs,
EfiCpuIoWidthUint8,
Offset,
Size,
Buffer
);
HMemImage.IoFncs,
EfiCpuIoWidthUint8,
Offset,
Size,
Buffer
);
FreePool (Buffer);
if (EFI_ERROR (Status)) {
return EFI_LOAD_ERROR;
}
//
// now not modified
//
@@ -274,5 +271,3 @@ HMemImageSave (
return EFI_SUCCESS;
}

View File

@@ -45,8 +45,8 @@ HMemImageBackup (
**/
EFI_STATUS
HMemImageSetMemOffsetSize (
IN UINTN Offset,
IN UINTN Size
IN UINTN Offset,
IN UINTN Size
);
/**
@@ -62,9 +62,9 @@ HMemImageSetMemOffsetSize (
**/
EFI_STATUS
HMemImageRead (
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
);
/**
@@ -79,8 +79,8 @@ HMemImageRead (
**/
EFI_STATUS
HMemImageSave (
IN UINTN Offset,
IN UINTN Size
IN UINTN Offset,
IN UINTN Size
);
#endif

View File

@@ -17,15 +17,14 @@ extern BOOLEAN HEditorMouseAction;
**/
VOID
HLineFree (
IN HEFI_EDITOR_LINE *Src
IN HEFI_EDITOR_LINE *Src
)
{
if (Src == NULL) {
return ;
return;
}
SHELL_FREE_NON_NULL (Src);
}
/**
@@ -38,7 +37,7 @@ HLineFree (
**/
HEFI_EDITOR_LINE *
HLineAdvance (
IN UINTN Count
IN UINTN Count
)
{
UINTN Index;
@@ -73,7 +72,7 @@ HLineAdvance (
**/
HEFI_EDITOR_LINE *
HLineRetreat (
IN UINTN Count
IN UINTN Count
)
{
UINTN Index;
@@ -110,7 +109,7 @@ HLineRetreat (
**/
HEFI_EDITOR_LINE *
HMoveLine (
IN INTN Count
IN INTN Count
)
{
HEFI_EDITOR_LINE *Line;
@@ -122,8 +121,8 @@ HMoveLine (
// do not set currentline to Line
//
if (Count <= 0) {
AbsCount = (UINTN)ABS(Count);
Line = HLineRetreat (AbsCount);
AbsCount = (UINTN)ABS (Count);
Line = HLineRetreat (AbsCount);
} else {
Line = HLineAdvance ((UINTN)Count);
}
@@ -143,7 +142,7 @@ HMoveLine (
**/
HEFI_EDITOR_LINE *
HMoveCurrentLine (
IN INTN Count
IN INTN Count
)
{
HEFI_EDITOR_LINE *Line;
@@ -154,8 +153,8 @@ HMoveCurrentLine (
// >0: advance
//
if (Count <= 0) {
AbsCount = (UINTN)ABS(Count);
Line = HLineRetreat (AbsCount);
AbsCount = (UINTN)ABS (Count);
Line = HLineRetreat (AbsCount);
} else {
Line = HLineAdvance ((UINTN)Count);
}
@@ -169,7 +168,6 @@ HMoveCurrentLine (
return Line;
}
/**
Free all the lines in HBufferImage.
Fields affected:
@@ -185,8 +183,8 @@ HMoveCurrentLine (
**/
EFI_STATUS
HFreeLines (
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
)
{
LIST_ENTRY *Link;
@@ -196,18 +194,17 @@ HFreeLines (
// release all the lines
//
if (Lines != NULL) {
Line = Lines;
Link = &(Line->Link);
Line = Lines;
Link = &(Line->Link);
do {
Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
Link = Link->ForwardLink;
Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
Link = Link->ForwardLink;
HLineFree (Line);
} while (Link != ListHead);
}
ListHead->ForwardLink = ListHead;
ListHead->BackLink = ListHead;
ListHead->BackLink = ListHead;
return EFI_SUCCESS;
}
@@ -221,15 +218,15 @@ HFreeLines (
**/
INT32
HGetTextX (
IN INT32 GuidX
IN INT32 GuidX
)
{
INT32 Gap;
INT32 Gap;
HMainEditor.MouseAccumulatorX += GuidX;
Gap = (HMainEditor.MouseAccumulatorX * (INT32) HMainEditor.ScreenSize.Column) / (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionX);
HMainEditor.MouseAccumulatorX = (HMainEditor.MouseAccumulatorX * (INT32) HMainEditor.ScreenSize.Column) % (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionX);
HMainEditor.MouseAccumulatorX = HMainEditor.MouseAccumulatorX / (INT32) HMainEditor.ScreenSize.Column;
Gap = (HMainEditor.MouseAccumulatorX * (INT32)HMainEditor.ScreenSize.Column) / (INT32)(50 * (INT32)HMainEditor.MouseInterface->Mode->ResolutionX);
HMainEditor.MouseAccumulatorX = (HMainEditor.MouseAccumulatorX * (INT32)HMainEditor.ScreenSize.Column) % (INT32)(50 * (INT32)HMainEditor.MouseInterface->Mode->ResolutionX);
HMainEditor.MouseAccumulatorX = HMainEditor.MouseAccumulatorX / (INT32)HMainEditor.ScreenSize.Column;
return Gap;
}
@@ -242,15 +239,15 @@ HGetTextX (
**/
INT32
HGetTextY (
IN INT32 GuidY
IN INT32 GuidY
)
{
INT32 Gap;
INT32 Gap;
HMainEditor.MouseAccumulatorY += GuidY;
Gap = (HMainEditor.MouseAccumulatorY * (INT32) HMainEditor.ScreenSize.Row) / (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionY);
HMainEditor.MouseAccumulatorY = (HMainEditor.MouseAccumulatorY * (INT32) HMainEditor.ScreenSize.Row) % (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionY);
HMainEditor.MouseAccumulatorY = HMainEditor.MouseAccumulatorY / (INT32) HMainEditor.ScreenSize.Row;
Gap = (HMainEditor.MouseAccumulatorY * (INT32)HMainEditor.ScreenSize.Row) / (INT32)(50 * (INT32)HMainEditor.MouseInterface->Mode->ResolutionY);
HMainEditor.MouseAccumulatorY = (HMainEditor.MouseAccumulatorY * (INT32)HMainEditor.ScreenSize.Row) % (INT32)(50 * (INT32)HMainEditor.MouseInterface->Mode->ResolutionY);
HMainEditor.MouseAccumulatorY = HMainEditor.MouseAccumulatorY / (INT32)HMainEditor.ScreenSize.Row;
return Gap;
}

View File

@@ -23,7 +23,7 @@
**/
HEFI_EDITOR_LINE *
HMoveLine (
IN INTN Count
IN INTN Count
);
/**
@@ -38,7 +38,7 @@ HMoveLine (
**/
HEFI_EDITOR_LINE *
HMoveCurrentLine (
IN INTN Count
IN INTN Count
);
/**
@@ -56,8 +56,8 @@ HMoveCurrentLine (
**/
EFI_STATUS
HFreeLines (
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
);
/**
@@ -69,7 +69,7 @@ HFreeLines (
**/
INT32
HGetTextX (
IN INT32 GuidX
IN INT32 GuidX
);
/**
@@ -81,7 +81,7 @@ HGetTextX (
**/
INT32
HGetTextY (
IN INT32 GuidY
IN INT32 GuidY
);
#endif

View File

@@ -39,15 +39,15 @@ LoadPciRomConnectAllDriversToAllControllers (
**/
EFI_STATUS
LoadEfiDriversFromRomImage (
VOID *RomBar,
UINTN RomSize,
CONST CHAR16 *FileName
VOID *RomBar,
UINTN RomSize,
CONST CHAR16 *FileName
);
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-nc", TypeFlag},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-nc", TypeFlag },
{ NULL, TypeMax }
};
/**
Function for 'loadpcirom' command.
@@ -62,17 +62,18 @@ ShellCommandRunLoadPciRom (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_SHELL_FILE_INFO *FileList;
UINTN SourceSize;
UINT8 *File1Buffer;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
BOOLEAN Connect;
CONST CHAR16 *Param;
UINTN ParamCount;
EFI_SHELL_FILE_INFO *Node;
EFI_SHELL_FILE_INFO *FileList;
UINTN SourceSize;
UINT8 *File1Buffer;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
BOOLEAN Connect;
CONST CHAR16 *Param;
UINTN ParamCount;
EFI_SHELL_FILE_INFO *Node;
//
// Local variable initializations
//
@@ -80,25 +81,24 @@ ShellCommandRunLoadPciRom (
ShellStatus = SHELL_SUCCESS;
FileList = NULL;
//
// verify number of arguments
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"loadpcirom", 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"loadpcirom", 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_FEW), gShellDebug1HiiHandle, L"loadpcirom");
if (ShellCommandLineGetCount (Package) < 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"loadpcirom");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetFlag(Package, L"-nc")) {
if (ShellCommandLineGetFlag (Package, L"-nc")) {
Connect = FALSE;
} else {
Connect = TRUE;
@@ -108,64 +108,73 @@ ShellCommandRunLoadPciRom (
// get a list with each file specified by parameters
// if parameter is a directory then add all the files below it to the list
//
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
; Param != NULL
; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
){
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param);
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue (Package, ParamCount)
; Param != NULL
; ParamCount++, Param = ShellCommandLineGetRawValue (Package, ParamCount)
)
{
Status = ShellOpenFileMetaArg ((CHAR16 *)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param);
ShellStatus = SHELL_ACCESS_DENIED;
break;
}
}
if (ShellStatus == SHELL_SUCCESS && FileList != NULL) {
if ((ShellStatus == SHELL_SUCCESS) && (FileList != NULL)) {
//
// loop through the list and make sure we are not aborting...
//
for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
){
if (EFI_ERROR(Node->Status)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
; !IsNull (&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag ()
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
)
{
if (EFI_ERROR (Node->Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
ShellStatus = SHELL_INVALID_PARAMETER;
continue;
}
if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
if (FileHandleIsDirectory (Node->Handle) == EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
ShellStatus = SHELL_INVALID_PARAMETER;
continue;
}
SourceSize = (UINTN) Node->Info->FileSize;
SourceSize = (UINTN)Node->Info->FileSize;
File1Buffer = AllocateZeroPool (SourceSize);
if (File1Buffer == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"loadpcirom");
ShellStatus = SHELL_OUT_OF_RESOURCES;
continue;
}
Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
Status = gEfiShellProtocol->ReadFile (Node->Handle, &SourceSize, File1Buffer);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = LoadEfiDriversFromRomImage (
File1Buffer,
SourceSize,
Node->FullName
);
File1Buffer,
SourceSize,
Node->FullName
);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);
}
FreePool(File1Buffer);
FreePool (File1Buffer);
}
} else if (ShellStatus == SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom");
ShellStatus = SHELL_NOT_FOUND;
}
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
Status = ShellCloseFileMetaArg(&FileList);
if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
Status = ShellCloseFileMetaArg (&FileList);
}
FileList = NULL;
if (Connect) {
@@ -192,9 +201,9 @@ ShellCommandRunLoadPciRom (
**/
EFI_STATUS
LoadEfiDriversFromRomImage (
VOID *RomBar,
UINTN RomSize,
CONST CHAR16 *FileName
VOID *RomBar,
UINTN RomSize,
CONST CHAR16 *FileName
)
{
@@ -219,17 +228,16 @@ LoadEfiDriversFromRomImage (
EFI_DECOMPRESS_PROTOCOL *Decompress;
UINT32 InitializationSize;
ImageIndex = 0;
ReturnStatus = EFI_NOT_FOUND;
RomBarOffset = (UINTN) RomBar;
ImageIndex = 0;
ReturnStatus = EFI_NOT_FOUND;
RomBarOffset = (UINTN)RomBar;
do {
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *)(UINTN)RomBarOffset;
if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex);
return ReturnStatus;
}
@@ -237,19 +245,21 @@ LoadEfiDriversFromRomImage (
// If the pointer to the PCI Data Structure is invalid, no further images can be located.
// The PCI Data Structure must be DWORD aligned.
//
if (EfiRomHeader->PcirOffset == 0 ||
(EfiRomHeader->PcirOffset & 3) != 0 ||
RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
if ((EfiRomHeader->PcirOffset == 0) ||
((EfiRomHeader->PcirOffset & 3) != 0) ||
(RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize))
{
break;
}
Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);
Pcir = (PCI_DATA_STRUCTURE *)(UINTN)(RomBarOffset + EfiRomHeader->PcirOffset);
//
// If a valid signature is not present in the PCI Data Structure, no further images can be located.
//
if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
break;
}
ImageSize = Pcir->ImageLength * 512;
if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {
break;
@@ -258,14 +268,13 @@ LoadEfiDriversFromRomImage (
if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER)))
{
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
InitializationSize = EfiRomHeader->InitializationSize * 512;
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
InitializationSize = EfiRomHeader->InitializationSize * 512;
if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset);
if ((InitializationSize <= ImageSize) && (ImageOffset < InitializationSize)) {
ImageBuffer = (VOID *)(UINTN)(RomBarOffset + ImageOffset);
ImageLength = InitializationSize - ImageOffset;
DecompressedImageBuffer = NULL;
@@ -278,33 +287,33 @@ LoadEfiDriversFromRomImage (
}
if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
ASSERT_EFI_ERROR(Status);
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **)&Decompress);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
SkipImage = TRUE;
} else {
SkipImage = TRUE;
Status = Decompress->GetInfo (
Decompress,
ImageBuffer,
ImageLength,
&DestinationSize,
&ScratchSize
);
Status = Decompress->GetInfo (
Decompress,
ImageBuffer,
ImageLength,
&DestinationSize,
&ScratchSize
);
if (!EFI_ERROR (Status)) {
DecompressedImageBuffer = AllocateZeroPool (DestinationSize);
if (ImageBuffer != NULL) {
Scratch = AllocateZeroPool (ScratchSize);
if (Scratch != NULL) {
Status = Decompress->Decompress (
Decompress,
ImageBuffer,
ImageLength,
DecompressedImageBuffer,
DestinationSize,
Scratch,
ScratchSize
);
Decompress,
ImageBuffer,
ImageLength,
DecompressedImageBuffer,
DestinationSize,
Scratch,
ScratchSize
);
if (!EFI_ERROR (Status)) {
ImageBuffer = DecompressedImageBuffer;
ImageLength = DestinationSize;
@@ -326,13 +335,13 @@ LoadEfiDriversFromRomImage (
FilePath = FileDevicePath (NULL, RomFileName);
Status = gBS->LoadImage (
TRUE,
gImageHandle,
FilePath,
ImageBuffer,
ImageLength,
&ImageHandle
);
TRUE,
gImageHandle,
FilePath,
ImageBuffer,
ImageLength,
&ImageHandle
);
if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
@@ -343,13 +352,14 @@ LoadEfiDriversFromRomImage (
if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (ImageHandle);
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
} else {
Status = gBS->StartImage (ImageHandle, NULL, NULL);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status);
} else {
ReturnStatus = Status;
}
@@ -359,13 +369,12 @@ LoadEfiDriversFromRomImage (
if (DecompressedImageBuffer != NULL) {
FreePool (DecompressedImageBuffer);
}
}
}
RomBarOffset = RomBarOffset + ImageSize;
ImageIndex++;
} while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));
} while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN)RomBar) < RomSize));
return ReturnStatus;
}
@@ -402,11 +411,13 @@ LoadPciRomConnectAllDriversToAllControllers (
Status = EFI_ABORTED;
break;
}
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
}
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
return Status;
}

View File

@@ -11,41 +11,41 @@
//
// Need full names for Standard-Format Output
//
STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
//
// Need short names for some memory types
//
STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
#include "UefiShellDebug1CommandsLib.h"
typedef struct {
UINT32 Type;
UINT64 NumberOfPages;
LIST_ENTRY Link;
UINT32 Type;
UINT64 NumberOfPages;
LIST_ENTRY Link;
} MEMORY_LENGTH_ENTRY;
/**
@@ -57,14 +57,14 @@ typedef struct {
**/
VOID
AddMemoryLength (
LIST_ENTRY *List,
UINT32 Type,
UINT64 NumberOfPages
LIST_ENTRY *List,
UINT32 Type,
UINT64 NumberOfPages
)
{
MEMORY_LENGTH_ENTRY *Entry;
MEMORY_LENGTH_ENTRY *NewEntry;
LIST_ENTRY *Link;
MEMORY_LENGTH_ENTRY *Entry;
MEMORY_LENGTH_ENTRY *NewEntry;
LIST_ENTRY *Link;
Entry = NULL;
for (Link = GetFirstNode (List); !IsNull (List, Link); Link = GetNextNode (List, Link)) {
@@ -89,7 +89,8 @@ AddMemoryLength (
if (NewEntry == NULL) {
return;
}
NewEntry->Type = Type;
NewEntry->Type = Type;
NewEntry->NumberOfPages = 0;
InsertTailList (Link, &NewEntry->Link);
}
@@ -110,52 +111,52 @@ ShellCommandRunMemMap (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN Size;
EFI_MEMORY_DESCRIPTOR *Descriptors;
UINTN MapKey;
UINTN ItemSize;
UINT32 Version;
EFI_MEMORY_DESCRIPTOR *Walker;
UINT64 ReservedPages;
UINT64 LoadCodePages;
UINT64 LoadDataPages;
UINT64 BSCodePages;
UINT64 BSDataPages;
UINT64 RTDataPages;
UINT64 RTCodePages;
UINT64 AvailPages;
UINT64 TotalPages;
UINT64 ReservedPagesSize;
UINT64 LoadCodePagesSize;
UINT64 LoadDataPagesSize;
UINT64 BSCodePagesSize;
UINT64 BSDataPagesSize;
UINT64 RTDataPagesSize;
UINT64 RTCodePagesSize;
UINT64 AvailPagesSize;
UINT64 TotalPagesSize;
UINT64 AcpiReclaimPages;
UINT64 AcpiNvsPages;
UINT64 MmioSpacePages;
UINT64 AcpiReclaimPagesSize;
UINT64 AcpiNvsPagesSize;
UINT64 MmioSpacePagesSize;
UINT64 MmioPortPages;
UINT64 MmioPortPagesSize;
UINT64 UnusableMemoryPages;
UINT64 UnusableMemoryPagesSize;
UINT64 PalCodePages;
UINT64 PalCodePagesSize;
UINT64 PersistentPages;
UINT64 PersistentPagesSize;
BOOLEAN Sfo;
LIST_ENTRY MemoryList;
MEMORY_LENGTH_ENTRY *Entry;
LIST_ENTRY *Link;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN Size;
EFI_MEMORY_DESCRIPTOR *Descriptors;
UINTN MapKey;
UINTN ItemSize;
UINT32 Version;
EFI_MEMORY_DESCRIPTOR *Walker;
UINT64 ReservedPages;
UINT64 LoadCodePages;
UINT64 LoadDataPages;
UINT64 BSCodePages;
UINT64 BSDataPages;
UINT64 RTDataPages;
UINT64 RTCodePages;
UINT64 AvailPages;
UINT64 TotalPages;
UINT64 ReservedPagesSize;
UINT64 LoadCodePagesSize;
UINT64 LoadDataPagesSize;
UINT64 BSCodePagesSize;
UINT64 BSDataPagesSize;
UINT64 RTDataPagesSize;
UINT64 RTCodePagesSize;
UINT64 AvailPagesSize;
UINT64 TotalPagesSize;
UINT64 AcpiReclaimPages;
UINT64 AcpiNvsPages;
UINT64 MmioSpacePages;
UINT64 AcpiReclaimPagesSize;
UINT64 AcpiNvsPagesSize;
UINT64 MmioSpacePagesSize;
UINT64 MmioPortPages;
UINT64 MmioPortPagesSize;
UINT64 UnusableMemoryPages;
UINT64 UnusableMemoryPagesSize;
UINT64 PalCodePages;
UINT64 PalCodePagesSize;
UINT64 PersistentPages;
UINT64 PersistentPagesSize;
BOOLEAN Sfo;
LIST_ENTRY MemoryList;
MEMORY_LENGTH_ENTRY *Entry;
LIST_ENTRY *Link;
AcpiReclaimPages = 0;
AcpiNvsPages = 0;
@@ -182,42 +183,43 @@ ShellCommandRunMemMap (
//
// 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 (SfoParamList, &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"memmap", 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"memmap", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
if (ShellCommandLineGetCount (Package) > 1) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = gBS->GetMemoryMap(&Size, Descriptors, &MapKey, &ItemSize, &Version);
if (Status == EFI_BUFFER_TOO_SMALL){
Size += SIZE_1KB;
Descriptors = AllocateZeroPool(Size);
Status = gBS->GetMemoryMap(&Size, Descriptors, &MapKey, &ItemSize, &Version);
Status = gBS->GetMemoryMap (&Size, Descriptors, &MapKey, &ItemSize, &Version);
if (Status == EFI_BUFFER_TOO_SMALL) {
Size += SIZE_1KB;
Descriptors = AllocateZeroPool (Size);
Status = gBS->GetMemoryMap (&Size, Descriptors, &MapKey, &ItemSize, &Version);
}
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
ShellStatus = SHELL_ACCESS_DENIED;
} else {
ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
ASSERT (Version == EFI_MEMORY_DESCRIPTOR_VERSION);
Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
Sfo = ShellCommandLineGetFlag (Package, L"-sfo");
if (!Sfo) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
} else {
@@ -225,79 +227,80 @@ ShellCommandRunMemMap (
}
for ( Walker = Descriptors
; (Walker < (EFI_MEMORY_DESCRIPTOR *) ((UINT8*)Descriptors + Size)) && (Walker != NULL)
; Walker = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *)Walker + ItemSize)
){
; (Walker < (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Descriptors + Size)) && (Walker != NULL)
; Walker = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Walker + ItemSize)
)
{
switch (Walker->Type) {
case EfiReservedMemoryType:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
case EfiReservedMemoryType:
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ReservedPages += Walker->NumberOfPages;
break;
case EfiLoaderCode:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
LoadCodePages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiLoaderData:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
LoadDataPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiBootServicesCode:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiBootServicesCodeShort:NameEfiBootServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiBootServicesCodeShort : NameEfiBootServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
BSCodePages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiBootServicesData:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiBootServicesDataShort:NameEfiBootServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiBootServicesDataShort : NameEfiBootServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
BSDataPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiRuntimeServicesCode:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiRuntimeServicesCodeShort:NameEfiRuntimeServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiRuntimeServicesCodeShort : NameEfiRuntimeServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
RTCodePages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiRuntimeServicesData:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiRuntimeServicesDataShort:NameEfiRuntimeServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiRuntimeServicesDataShort : NameEfiRuntimeServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
RTDataPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiConventionalMemory:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
AvailPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiPersistentMemory:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPersistentMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPersistentMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
PersistentPages += Walker->NumberOfPages;
TotalPages += Walker->NumberOfPages;
break;
case EfiUnusableMemory:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiUnusableMemoryShort:NameEfiUnusableMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiUnusableMemoryShort : NameEfiUnusableMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
UnusableMemoryPages += Walker->NumberOfPages;
break;
case EfiACPIReclaimMemory:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiACPIReclaimMemoryShort:NameEfiACPIReclaimMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiACPIReclaimMemoryShort : NameEfiACPIReclaimMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
AcpiReclaimPages += Walker->NumberOfPages;
break;
case EfiACPIMemoryNVS:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiACPIMemoryNVSShort:NameEfiACPIMemoryNVS, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
AcpiNvsPages += Walker->NumberOfPages;
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiACPIMemoryNVSShort : NameEfiACPIMemoryNVS, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
AcpiNvsPages += Walker->NumberOfPages;
break;
case EfiMemoryMappedIO:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiMemoryMappedIOShort:NameEfiMemoryMappedIO, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
MmioSpacePages += Walker->NumberOfPages;
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiMemoryMappedIOShort : NameEfiMemoryMappedIO, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
MmioSpacePages += Walker->NumberOfPages;
break;
case EfiMemoryMappedIOPortSpace:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiMemoryMappedIOPortSpaceShort:NameEfiMemoryMappedIOPortSpace, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiMemoryMappedIOPortSpaceShort : NameEfiMemoryMappedIOPortSpace, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
MmioPortPages += Walker->NumberOfPages;
break;
case EfiPalCode:
ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64(SIZE_4KB,Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
TotalPages += Walker->NumberOfPages;
PalCodePages += Walker->NumberOfPages;
break;
default:
@@ -308,46 +311,67 @@ ShellCommandRunMemMap (
if (!Sfo) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_ITEM_OTHER), gShellDebug1HiiHandle, Walker->Type, Walker->PhysicalStart, Walker->PhysicalStart + MultU64x64 (SIZE_4KB, Walker->NumberOfPages) - 1, Walker->NumberOfPages, Walker->Attribute);
}
TotalPages += Walker->NumberOfPages;
AddMemoryLength (&MemoryList, Walker->Type, Walker->NumberOfPages);
break;
}
}
//
// print the summary
//
ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages);
LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages);
LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages);
BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages);
BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages);
RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages);
RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages);
AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages);
TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages);
AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages);
AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages);
MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages);
MmioPortPagesSize = MultU64x64(SIZE_4KB,MmioPortPages);
PalCodePagesSize = MultU64x64(SIZE_4KB,PalCodePages);
PersistentPagesSize = MultU64x64(SIZE_4KB,PersistentPages);
UnusableMemoryPagesSize = MultU64x64(SIZE_4KB,UnusableMemoryPages);
ReservedPagesSize = MultU64x64 (SIZE_4KB, ReservedPages);
LoadCodePagesSize = MultU64x64 (SIZE_4KB, LoadCodePages);
LoadDataPagesSize = MultU64x64 (SIZE_4KB, LoadDataPages);
BSCodePagesSize = MultU64x64 (SIZE_4KB, BSCodePages);
BSDataPagesSize = MultU64x64 (SIZE_4KB, BSDataPages);
RTDataPagesSize = MultU64x64 (SIZE_4KB, RTDataPages);
RTCodePagesSize = MultU64x64 (SIZE_4KB, RTCodePages);
AvailPagesSize = MultU64x64 (SIZE_4KB, AvailPages);
TotalPagesSize = MultU64x64 (SIZE_4KB, TotalPages);
AcpiReclaimPagesSize = MultU64x64 (SIZE_4KB, AcpiReclaimPages);
AcpiNvsPagesSize = MultU64x64 (SIZE_4KB, AcpiNvsPages);
MmioSpacePagesSize = MultU64x64 (SIZE_4KB, MmioSpacePages);
MmioPortPagesSize = MultU64x64 (SIZE_4KB, MmioPortPages);
PalCodePagesSize = MultU64x64 (SIZE_4KB, PalCodePages);
PersistentPagesSize = MultU64x64 (SIZE_4KB, PersistentPages);
UnusableMemoryPagesSize = MultU64x64 (SIZE_4KB, UnusableMemoryPages);
if (!Sfo) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
ReservedPages, ReservedPagesSize,
LoadCodePages, LoadCodePagesSize,
LoadDataPages, LoadDataPagesSize,
BSCodePages, BSCodePagesSize,
BSDataPages, BSDataPagesSize,
RTCodePages, RTCodePagesSize,
RTDataPages, RTDataPagesSize,
AcpiReclaimPages, AcpiReclaimPagesSize,
AcpiNvsPages, AcpiNvsPagesSize,
MmioSpacePages, MmioSpacePagesSize,
MmioPortPages, MmioPortPagesSize,
PalCodePages, PalCodePagesSize,
AvailPages, AvailPagesSize,
PersistentPages, PersistentPagesSize
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_MEMMAP_LIST_SUMM),
gShellDebug1HiiHandle,
ReservedPages,
ReservedPagesSize,
LoadCodePages,
LoadCodePagesSize,
LoadDataPages,
LoadDataPagesSize,
BSCodePages,
BSCodePagesSize,
BSDataPages,
BSDataPagesSize,
RTCodePages,
RTCodePagesSize,
RTDataPages,
RTDataPagesSize,
AcpiReclaimPages,
AcpiReclaimPagesSize,
AcpiNvsPages,
AcpiNvsPagesSize,
MmioSpacePages,
MmioSpacePagesSize,
MmioPortPages,
MmioPortPagesSize,
PalCodePages,
PalCodePagesSize,
AvailPages,
AvailPagesSize,
PersistentPages,
PersistentPagesSize
);
//
@@ -355,16 +379,34 @@ ShellCommandRunMemMap (
//
for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); Link = GetNextNode (&MemoryList, Link)) {
Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER), gShellDebug1HiiHandle,
Entry->Type, Entry->NumberOfPages, MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER),
gShellDebug1HiiHandle,
Entry->Type,
Entry->NumberOfPages,
MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
);
}
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM2), gShellDebug1HiiHandle,
DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
);
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_MEMMAP_LIST_SUMM2),
gShellDebug1HiiHandle,
DivU64x32 (MultU64x64 (SIZE_4KB, TotalPages), SIZE_1MB),
TotalPagesSize
);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO),
gShellDebug1HiiHandle,
TotalPagesSize,
ReservedPagesSize,
BSCodePagesSize,
@@ -381,15 +423,16 @@ ShellCommandRunMemMap (
AcpiNvsPagesSize,
PalCodePagesSize,
PersistentPagesSize
);
);
}
}
}
ShellCommandLineFreeVarList (Package);
}
if (Descriptors != NULL) {
FreePool(Descriptors);
FreePool (Descriptors);
}
//
@@ -401,4 +444,3 @@ ShellCommandRunMemMap (
return (ShellStatus);
}

View File

@@ -21,7 +21,7 @@ typedef enum {
ShellMmPciExpress
} SHELL_MM_ACCESS_TYPE;
CONST UINT16 mShellMmAccessTypeStr[] = {
CONST UINT16 mShellMmAccessTypeStr[] = {
STRING_TOKEN (STR_MM_MEM),
STRING_TOKEN (STR_MM_MMIO),
STRING_TOKEN (STR_MM_IO),
@@ -29,24 +29,24 @@ CONST UINT16 mShellMmAccessTypeStr[] = {
STRING_TOKEN (STR_MM_PCIE)
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-mmio", TypeFlag},
{L"-mem", TypeFlag},
{L"-io", TypeFlag},
{L"-pci", TypeFlag},
{L"-pcie", TypeFlag},
{L"-n", TypeFlag},
{L"-w", TypeValue},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-mmio", TypeFlag },
{ L"-mem", TypeFlag },
{ L"-io", TypeFlag },
{ L"-pci", TypeFlag },
{ L"-pcie", TypeFlag },
{ L"-n", TypeFlag },
{ L"-w", TypeValue },
{ NULL, TypeMax }
};
CONST UINT64 mShellMmMaxNumber[] = {
CONST UINT64 mShellMmMaxNumber[] = {
0, MAX_UINT8, MAX_UINT16, 0, MAX_UINT32, 0, 0, 0, MAX_UINT64
};
CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH mShellMmRootBridgeIoWidth[] = {
CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH mShellMmRootBridgeIoWidth[] = {
0, EfiPciWidthUint8, EfiPciWidthUint16, 0, EfiPciWidthUint32, 0, 0, 0, EfiPciWidthUint64
};
CONST EFI_CPU_IO_PROTOCOL_WIDTH mShellMmCpuIoWidth[] = {
CONST EFI_CPU_IO_PROTOCOL_WIDTH mShellMmCpuIoWidth[] = {
0, EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, 0, EfiCpuIoWidthUint32, 0, 0, 0, EfiCpuIoWidthUint64
};
@@ -64,13 +64,13 @@ CONST EFI_CPU_IO_PROTOCOL_WIDTH mShellMmCpuIoWidth[] = {
**/
VOID
ShellMmDecodePciAddress (
IN BOOLEAN PciFormat,
IN UINT64 Address,
OUT UINT32 *Segment,
OUT UINT8 *Bus,
OUT UINT8 *Device OPTIONAL,
OUT UINT8 *Function OPTIONAL,
OUT UINT32 *Register OPTIONAL
IN BOOLEAN PciFormat,
IN UINT64 Address,
OUT UINT32 *Segment,
OUT UINT8 *Bus,
OUT UINT8 *Device OPTIONAL,
OUT UINT8 *Function OPTIONAL,
OUT UINT32 *Register OPTIONAL
)
{
if (PciFormat) {
@@ -78,33 +78,37 @@ ShellMmDecodePciAddress (
// PCI Configuration Space.The address will have the format ssssbbddffrr,
// where ssss = Segment, bb = Bus, dd = Device, ff = Function and rr = Register.
//
*Segment = (UINT32) (RShiftU64 (Address, 32) & 0xFFFF);
*Bus = (UINT8) (((UINT32) Address) >> 24);
*Segment = (UINT32)(RShiftU64 (Address, 32) & 0xFFFF);
*Bus = (UINT8)(((UINT32)Address) >> 24);
if (Device != NULL) {
*Device = (UINT8) (((UINT32) Address) >> 16);
*Device = (UINT8)(((UINT32)Address) >> 16);
}
if (Function != NULL) {
*Function = (UINT8) (((UINT32) Address) >> 8);
*Function = (UINT8)(((UINT32)Address) >> 8);
}
if (Register != NULL) {
*Register = (UINT8) Address;
*Register = (UINT8)Address;
}
} else {
//
// PCI Express Configuration Space.The address will have the format ssssssbbddffrrr,
// where ssss = Segment, bb = Bus, dd = Device, ff = Function and rrr = Register.
//
*Segment = (UINT32) (RShiftU64 (Address, 36) & 0xFFFF);
*Bus = (UINT8) RShiftU64 (Address, 28);
*Segment = (UINT32)(RShiftU64 (Address, 36) & 0xFFFF);
*Bus = (UINT8)RShiftU64 (Address, 28);
if (Device != NULL) {
*Device = (UINT8) (((UINT32) Address) >> 20);
*Device = (UINT8)(((UINT32)Address) >> 20);
}
if (Function != NULL) {
*Function = (UINT8) (((UINT32) Address) >> 12);
*Function = (UINT8)(((UINT32)Address) >> 12);
}
if (Register != NULL) {
*Register = (UINT32) (Address & 0xFFF);
*Register = (UINT32)(Address & 0xFFF);
}
}
}
@@ -122,80 +126,90 @@ ShellMmDecodePciAddress (
**/
VOID
ShellMmAccess (
IN SHELL_MM_ACCESS_TYPE AccessType,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
IN EFI_CPU_IO2_PROTOCOL *CpuIo,
IN BOOLEAN Read,
IN UINT64 Address,
IN UINTN Size,
IN OUT VOID *Buffer
IN SHELL_MM_ACCESS_TYPE AccessType,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
IN EFI_CPU_IO2_PROTOCOL *CpuIo,
IN BOOLEAN Read,
IN UINT64 Address,
IN UINTN Size,
IN OUT VOID *Buffer
)
{
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM RootBridgeIoMem;
EFI_CPU_IO_PROTOCOL_IO_MEM CpuIoMem;
UINT32 Segment;
UINT8 Bus;
UINT8 Device;
UINT8 Function;
UINT32 Register;
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM RootBridgeIoMem;
EFI_CPU_IO_PROTOCOL_IO_MEM CpuIoMem;
UINT32 Segment;
UINT8 Bus;
UINT8 Device;
UINT8 Function;
UINT32 Register;
if (AccessType == ShellMmMemory) {
if (Read) {
CopyMem (Buffer, (VOID *) (UINTN) Address, Size);
CopyMem (Buffer, (VOID *)(UINTN)Address, Size);
} else {
CopyMem ((VOID *) (UINTN) Address, Buffer, Size);
CopyMem ((VOID *)(UINTN)Address, Buffer, Size);
}
} else {
RootBridgeIoMem = NULL;
CpuIoMem = NULL;
CpuIoMem = NULL;
switch (AccessType) {
case ShellMmPci:
case ShellMmPciExpress:
ASSERT (PciRootBridgeIo != NULL);
ShellMmDecodePciAddress ((BOOLEAN) (AccessType == ShellMmPci), Address, &Segment, &Bus, &Device, &Function, &Register);
if (Read) {
Status = PciRootBridgeIo->Pci.Read (
PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size],
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
1, Buffer
);
} else {
Status = PciRootBridgeIo->Pci.Write (
PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size],
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
1, Buffer
);
}
ASSERT_EFI_ERROR (Status);
return;
case ShellMmPci:
case ShellMmPciExpress:
ASSERT (PciRootBridgeIo != NULL);
ShellMmDecodePciAddress ((BOOLEAN)(AccessType == ShellMmPci), Address, &Segment, &Bus, &Device, &Function, &Register);
if (Read) {
Status = PciRootBridgeIo->Pci.Read (
PciRootBridgeIo,
mShellMmRootBridgeIoWidth[Size],
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
1,
Buffer
);
} else {
Status = PciRootBridgeIo->Pci.Write (
PciRootBridgeIo,
mShellMmRootBridgeIoWidth[Size],
EFI_PCI_ADDRESS (Bus, Device, Function, Register),
1,
Buffer
);
}
case ShellMmMemoryMappedIo:
if (PciRootBridgeIo != NULL) {
RootBridgeIoMem = Read ? PciRootBridgeIo->Mem.Read : PciRootBridgeIo->Mem.Write;
}
if (CpuIo != NULL) {
CpuIoMem = Read ? CpuIo->Mem.Read : CpuIo->Mem.Write;
}
break;
ASSERT_EFI_ERROR (Status);
return;
case ShellMmIo:
if (PciRootBridgeIo != NULL) {
RootBridgeIoMem = Read ? PciRootBridgeIo->Io.Read : PciRootBridgeIo->Io.Write;
}
if (CpuIo != NULL) {
CpuIoMem = Read ? CpuIo->Io.Read : CpuIo->Io.Write;
}
break;
default:
ASSERT (FALSE);
break;
case ShellMmMemoryMappedIo:
if (PciRootBridgeIo != NULL) {
RootBridgeIoMem = Read ? PciRootBridgeIo->Mem.Read : PciRootBridgeIo->Mem.Write;
}
if (CpuIo != NULL) {
CpuIoMem = Read ? CpuIo->Mem.Read : CpuIo->Mem.Write;
}
break;
case ShellMmIo:
if (PciRootBridgeIo != NULL) {
RootBridgeIoMem = Read ? PciRootBridgeIo->Io.Read : PciRootBridgeIo->Io.Write;
}
if (CpuIo != NULL) {
CpuIoMem = Read ? CpuIo->Io.Read : CpuIo->Io.Write;
}
break;
default:
ASSERT (FALSE);
break;
}
Status = EFI_UNSUPPORTED;
if (RootBridgeIoMem != NULL) {
Status = RootBridgeIoMem (PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size], Address, 1, Buffer);
}
if (EFI_ERROR (Status) && (CpuIoMem != NULL)) {
Status = CpuIoMem (CpuIo, mShellMmCpuIoWidth[Size], Address, 1, Buffer);
}
@@ -203,71 +217,79 @@ ShellMmAccess (
if (EFI_ERROR (Status)) {
if (AccessType == ShellMmIo) {
switch (Size) {
case 1:
if (Read) {
*(UINT8 *) Buffer = IoRead8 ((UINTN) Address);
} else {
IoWrite8 ((UINTN) Address, *(UINT8 *) Buffer);
}
break;
case 2:
if (Read) {
*(UINT16 *) Buffer = IoRead16 ((UINTN) Address);
} else {
IoWrite16 ((UINTN) Address, *(UINT16 *) Buffer);
}
break;
case 4:
if (Read) {
*(UINT32 *) Buffer = IoRead32 ((UINTN) Address);
} else {
IoWrite32 ((UINTN) Address, *(UINT32 *) Buffer);
}
break;
case 8:
if (Read) {
*(UINT64 *) Buffer = IoRead64 ((UINTN) Address);
} else {
IoWrite64 ((UINTN) Address, *(UINT64 *) Buffer);
}
break;
default:
ASSERT (FALSE);
break;
case 1:
if (Read) {
*(UINT8 *)Buffer = IoRead8 ((UINTN)Address);
} else {
IoWrite8 ((UINTN)Address, *(UINT8 *)Buffer);
}
break;
case 2:
if (Read) {
*(UINT16 *)Buffer = IoRead16 ((UINTN)Address);
} else {
IoWrite16 ((UINTN)Address, *(UINT16 *)Buffer);
}
break;
case 4:
if (Read) {
*(UINT32 *)Buffer = IoRead32 ((UINTN)Address);
} else {
IoWrite32 ((UINTN)Address, *(UINT32 *)Buffer);
}
break;
case 8:
if (Read) {
*(UINT64 *)Buffer = IoRead64 ((UINTN)Address);
} else {
IoWrite64 ((UINTN)Address, *(UINT64 *)Buffer);
}
break;
default:
ASSERT (FALSE);
break;
}
} else {
switch (Size) {
case 1:
if (Read) {
*(UINT8 *) Buffer = MmioRead8 ((UINTN) Address);
} else {
MmioWrite8 ((UINTN) Address, *(UINT8 *) Buffer);
}
break;
case 2:
if (Read) {
*(UINT16 *) Buffer = MmioRead16 ((UINTN) Address);
} else {
MmioWrite16 ((UINTN) Address, *(UINT16 *) Buffer);
}
break;
case 4:
if (Read) {
*(UINT32 *) Buffer = MmioRead32 ((UINTN) Address);
} else {
MmioWrite32 ((UINTN) Address, *(UINT32 *) Buffer);
}
break;
case 8:
if (Read) {
*(UINT64 *) Buffer = MmioRead64 ((UINTN) Address);
} else {
MmioWrite64 ((UINTN) Address, *(UINT64 *) Buffer);
}
break;
default:
ASSERT (FALSE);
break;
case 1:
if (Read) {
*(UINT8 *)Buffer = MmioRead8 ((UINTN)Address);
} else {
MmioWrite8 ((UINTN)Address, *(UINT8 *)Buffer);
}
break;
case 2:
if (Read) {
*(UINT16 *)Buffer = MmioRead16 ((UINTN)Address);
} else {
MmioWrite16 ((UINTN)Address, *(UINT16 *)Buffer);
}
break;
case 4:
if (Read) {
*(UINT32 *)Buffer = MmioRead32 ((UINTN)Address);
} else {
MmioWrite32 ((UINTN)Address, *(UINT32 *)Buffer);
}
break;
case 8:
if (Read) {
*(UINT64 *)Buffer = MmioRead64 ((UINTN)Address);
} else {
MmioWrite64 ((UINTN)Address, *(UINT64 *)Buffer);
}
break;
default:
ASSERT (FALSE);
break;
}
}
}
@@ -289,35 +311,35 @@ ShellMmAccess (
**/
BOOLEAN
ShellMmLocateIoProtocol (
IN SHELL_MM_ACCESS_TYPE AccessType,
IN UINT64 Address,
OUT EFI_CPU_IO2_PROTOCOL **CpuIo,
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **PciRootBridgeIo
IN SHELL_MM_ACCESS_TYPE AccessType,
IN UINT64 Address,
OUT EFI_CPU_IO2_PROTOCOL **CpuIo,
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **PciRootBridgeIo
)
{
EFI_STATUS Status;
UINTN Index;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Io;
UINT32 Segment;
UINT8 Bus;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
EFI_STATUS Status;
UINTN Index;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Io;
UINT32 Segment;
UINT8 Bus;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
Status = gBS->LocateProtocol (&gEfiCpuIo2ProtocolGuid, NULL, (VOID **) CpuIo);
Status = gBS->LocateProtocol (&gEfiCpuIo2ProtocolGuid, NULL, (VOID **)CpuIo);
if (EFI_ERROR (Status)) {
*CpuIo = NULL;
}
*PciRootBridgeIo = NULL;
HandleBuffer = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiPciRootBridgeIoProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiPciRootBridgeIoProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
if (EFI_ERROR (Status) || (HandleCount == 0) || (HandleBuffer == NULL)) {
return FALSE;
}
@@ -325,7 +347,7 @@ ShellMmLocateIoProtocol (
Segment = 0;
Bus = 0;
if ((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) {
ShellMmDecodePciAddress ((BOOLEAN) (AccessType == ShellMmPci), Address, &Segment, &Bus, NULL, NULL, NULL);
ShellMmDecodePciAddress ((BOOLEAN)(AccessType == ShellMmPci), Address, &Segment, &Bus, NULL, NULL, NULL);
}
//
@@ -335,7 +357,7 @@ ShellMmLocateIoProtocol (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciRootBridgeIoProtocolGuid,
(VOID *) &Io
(VOID *)&Io
);
if (EFI_ERROR (Status)) {
continue;
@@ -343,8 +365,9 @@ ShellMmLocateIoProtocol (
if ((((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) && (Io->SegmentNumber == Segment)) ||
((AccessType == ShellMmIo) || (AccessType == ShellMmMemoryMappedIo))
) {
Status = Io->Configuration (Io, (VOID **) &Descriptors);
)
{
Status = Io->Configuration (Io, (VOID **)&Descriptors);
if (!EFI_ERROR (Status)) {
while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {
//
@@ -353,25 +376,29 @@ ShellMmLocateIoProtocol (
if ((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) &&
((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) &&
((Bus >= Descriptors->AddrRangeMin) && (Bus <= Descriptors->AddrRangeMax))
) {
)
{
*PciRootBridgeIo = Io;
break;
//
// Compare the address range for MMIO/IO access
//
//
// Compare the address range for MMIO/IO access
//
} else if ((((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) && (AccessType == ShellMmIo)) ||
((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && (AccessType == ShellMmMemoryMappedIo))
) && ((Address >= Descriptors->AddrRangeMin) && (Address <= Descriptors->AddrRangeMax))
) {
)
{
*PciRootBridgeIo = Io;
break;
}
Descriptors++;
}
}
}
}
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
@@ -392,37 +419,37 @@ ShellCommandRunMm (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_CPU_IO2_PROTOCOL *CpuIo;
UINT64 Address;
UINT64 Value;
SHELL_MM_ACCESS_TYPE AccessType;
UINT64 Buffer;
UINTN Index;
UINTN Size;
BOOLEAN Complete;
CHAR16 *InputStr;
BOOLEAN Interactive;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp;
BOOLEAN HasPciRootBridgeIo;
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_CPU_IO2_PROTOCOL *CpuIo;
UINT64 Address;
UINT64 Value;
SHELL_MM_ACCESS_TYPE AccessType;
UINT64 Buffer;
UINTN Index;
UINTN Size;
BOOLEAN Complete;
CHAR16 *InputStr;
BOOLEAN Interactive;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp;
BOOLEAN HasPciRootBridgeIo;
Value = 0;
Address = 0;
Value = 0;
Address = 0;
ShellStatus = SHELL_SUCCESS;
InputStr = NULL;
Size = 1;
AccessType = ShellMmMemory;
InputStr = NULL;
Size = 1;
AccessType = ShellMmMemory;
//
// Parse arguments
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR (Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mm", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -439,37 +466,40 @@ ShellCommandRunMm (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else if (ShellCommandLineGetFlag (Package, L"-w") && ShellCommandLineGetValue (Package, L"-w") == NULL) {
} else if (ShellCommandLineGetFlag (Package, L"-w") && (ShellCommandLineGetValue (Package, L"-w") == NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"mm", L"-w");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else {
if (ShellCommandLineGetFlag (Package, L"-mmio")) {
AccessType = ShellMmMemoryMappedIo;
if (ShellCommandLineGetFlag (Package, L"-mem")
|| ShellCommandLineGetFlag (Package, L"-io")
|| ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
) {
if ( ShellCommandLineGetFlag (Package, L"-mem")
|| ShellCommandLineGetFlag (Package, L"-io")
|| ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
)
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
} else if (ShellCommandLineGetFlag (Package, L"-mem")) {
AccessType = ShellMmMemory;
if (ShellCommandLineGetFlag (Package, L"-io")
|| ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
) {
if ( ShellCommandLineGetFlag (Package, L"-io")
|| ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
)
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
} else if (ShellCommandLineGetFlag (Package, L"-io")) {
AccessType = ShellMmIo;
if (ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
) {
if ( ShellCommandLineGetFlag (Package, L"-pci")
|| ShellCommandLineGetFlag (Package, L"-pcie")
)
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
@@ -477,7 +507,8 @@ ShellCommandRunMm (
} else if (ShellCommandLineGetFlag (Package, L"-pci")) {
AccessType = ShellMmPci;
if (ShellCommandLineGetFlag (Package, L"-pcie")
) {
)
{
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
@@ -499,13 +530,14 @@ ShellCommandRunMm (
if (Temp != NULL) {
Size = ShellStrToUintn (Temp);
}
if ((Size != 1) && (Size != 2) && (Size != 4) && (Size != 8)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"mm", Temp, L"-w");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
Temp = ShellCommandLineGetRawValue (Package, 1);
Temp = ShellCommandLineGetRawValue (Package, 1);
Status = ShellConvertStringToUint64 (Temp, &Address, TRUE, FALSE);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mm", Temp);
@@ -529,6 +561,7 @@ ShellCommandRunMm (
ShellStatus = SHELL_NOT_FOUND;
goto Done;
}
if (PciRootBridgeIo == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE_ADDRESS_RANGE), gShellDebug1HiiHandle, L"mm", Address);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -565,11 +598,13 @@ ShellCommandRunMm (
if (!gEfiShellProtocol->BatchIsActive ()) {
ShellPrintHiiEx (-1, -1, NULL, mShellMmAccessTypeStr[AccessType], gShellDebug1HiiHandle);
}
ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, TRUE, Address, Size, &Buffer);
if (!gEfiShellProtocol->BatchIsActive ()) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
}
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_BUF), gShellDebug1HiiHandle, Size * 2, Buffer & mShellMmMaxNumber[Size]);
ShellPrintEx (-1, -1, L"\r\n");
goto Done;
@@ -592,20 +627,23 @@ ShellCommandRunMm (
FreePool (InputStr);
InputStr = NULL;
}
ShellPromptForResponse (ShellPromptResponseTypeFreeform, NULL, (VOID**) &InputStr);
ShellPromptForResponse (ShellPromptResponseTypeFreeform, NULL, (VOID **)&InputStr);
if (InputStr != NULL) {
//
// skip space characters
//
for (Index = 0; InputStr[Index] == ' '; Index++);
for (Index = 0; InputStr[Index] == ' '; Index++) {
}
if (InputStr[Index] != CHAR_NULL) {
if ((InputStr[Index] == '.') || (InputStr[Index] == 'q') || (InputStr[Index] == 'Q')) {
Complete = TRUE;
} else if (!EFI_ERROR (ShellConvertStringToUint64 (InputStr + Index, &Buffer, TRUE, TRUE)) &&
(Buffer <= mShellMmMaxNumber[Size])
) {
)
{
ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, FALSE, Address, Size, &Buffer);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle, L"mm");
@@ -618,14 +656,17 @@ ShellCommandRunMm (
ShellPrintEx (-1, -1, L"\r\n");
} while (!Complete);
}
ASSERT (ShellStatus == SHELL_SUCCESS);
Done:
if (InputStr != NULL) {
FreePool (InputStr);
}
if (Package != NULL) {
ShellCommandLineFreeVarList (Package);
}
return ShellStatus;
}

View File

@@ -22,99 +22,104 @@ ShellCommandRunMode (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN NewCol;
UINTN NewRow;
UINTN Col;
UINTN Row;
CONST CHAR16 *Temp;
BOOLEAN Done;
INT32 LoopVar;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN NewCol;
UINTN NewRow;
UINTN Col;
UINTN Row;
CONST CHAR16 *Temp;
BOOLEAN Done;
INT32 LoopVar;
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"mode", 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"mode", 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"mode");
if (ShellCommandLineGetCount (Package) > 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mode");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mode");
} else if (ShellCommandLineGetCount (Package) == 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mode");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) == 3) {
Temp = ShellCommandLineGetRawValue(Package, 1);
if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
} else if (ShellCommandLineGetCount (Package) == 3) {
Temp = ShellCommandLineGetRawValue (Package, 1);
if (!ShellIsHexOrDecimalNumber (Temp, FALSE, FALSE)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
}
NewCol = ShellStrToUintn(Temp);
Temp = ShellCommandLineGetRawValue(Package, 2);
if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
}
NewRow = ShellStrToUintn(Temp);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
if (EFI_ERROR(Status)) {
NewCol = ShellStrToUintn (Temp);
Temp = ShellCommandLineGetRawValue (Package, 2);
if (!ShellIsHexOrDecimalNumber (Temp, FALSE, FALSE)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
}
NewRow = ShellStrToUintn (Temp);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS; LoopVar++) {
Status = gST->ConOut->QueryMode (gST->ConOut, LoopVar, &Col, &Row);
if (EFI_ERROR (Status)) {
continue;
}
if (Col == NewCol && Row == NewRow) {
Status = gST->ConOut->SetMode(gST->ConOut, LoopVar);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode");
if ((Col == NewCol) && (Row == NewRow)) {
Status = gST->ConOut->SetMode (gST->ConOut, LoopVar);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode");
ShellStatus = SHELL_DEVICE_ERROR;
} else {
// worked fine...
Done = TRUE;
}
break;
}
}
if (!Done) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode");
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else if (ShellCommandLineGetCount(Package) == 1) {
} else if (ShellCommandLineGetCount (Package) == 1) {
//
// print out valid
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS; LoopVar++) {
Status = gST->ConOut->QueryMode (gST->ConOut, LoopVar, &Col, &Row);
if (EFI_ERROR (Status)) {
continue;
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode?L'*':L' ');
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode ? L'*' : L' ');
}
}
ShellCommandLineFreeVarList (Package);
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@ typedef enum {
PciUndefined
} PCI_HEADER_TYPE;
#define INDEX_OF(Field) ((UINT8 *) (Field) - (UINT8 *) mConfigSpace)
#define INDEX_OF(Field) ((UINT8 *) (Field) - (UINT8 *) mConfigSpace)
#define IS_PCIE_ENDPOINT(DevicePortType) \
((DevicePortType) == PCIE_DEVICE_PORT_TYPE_PCIE_ENDPOINT || \
@@ -33,24 +33,24 @@ typedef enum {
// Data region after PCI configuration header(for cardbus bridge)
//
typedef struct {
UINT16 SubVendorId; // Subsystem Vendor ID
UINT16 SubSystemId; // Subsystem ID
UINT32 LegacyBase; // Optional 16-Bit PC Card Legacy
UINT16 SubVendorId; // Subsystem Vendor ID
UINT16 SubSystemId; // Subsystem ID
UINT32 LegacyBase; // Optional 16-Bit PC Card Legacy
// Mode Base Address
//
UINT32 Data[46];
UINT32 Data[46];
} PCI_CARDBUS_DATA;
typedef union {
PCI_DEVICE_HEADER_TYPE_REGION Device;
PCI_BRIDGE_CONTROL_REGISTER Bridge;
PCI_CARDBUS_CONTROL_REGISTER CardBus;
PCI_DEVICE_HEADER_TYPE_REGION Device;
PCI_BRIDGE_CONTROL_REGISTER Bridge;
PCI_CARDBUS_CONTROL_REGISTER CardBus;
} NON_COMMON_UNION;
typedef struct {
PCI_DEVICE_INDEPENDENT_REGION Common;
NON_COMMON_UNION NonCommon;
UINT32 Data[48];
PCI_DEVICE_INDEPENDENT_REGION Common;
NON_COMMON_UNION NonCommon;
UINT32 Data[48];
} PCI_CONFIG_SPACE;
#pragma pack()

View File

@@ -24,8 +24,8 @@
**/
SHELL_STATUS
DisplaySettings (
IN UINTN HandleIdx,
IN BOOLEAN HandleValid
IN UINTN HandleIdx,
IN BOOLEAN HandleValid
)
{
EFI_SERIAL_IO_PROTOCOL *SerialIo;
@@ -37,88 +37,89 @@ DisplaySettings (
CHAR16 Parity;
SHELL_STATUS ShellStatus;
Handles = NULL;
StopBits = NULL;
Handles = NULL;
StopBits = NULL;
ShellStatus = SHELL_SUCCESS;
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
return SHELL_INVALID_PARAMETER;
}
for (Index = 0; Index < NoHandles; Index++) {
if (HandleValid) {
if (ConvertHandleIndexToHandle(HandleIdx) != Handles[Index]) {
if (ConvertHandleIndexToHandle (HandleIdx) != Handles[Index]) {
continue;
}
}
Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
if (!EFI_ERROR (Status)) {
switch (SerialIo->Mode->Parity) {
case DefaultParity:
case DefaultParity:
Parity = 'D';
break;
Parity = 'D';
break;
case NoParity:
case NoParity:
Parity = 'N';
break;
Parity = 'N';
break;
case EvenParity:
case EvenParity:
Parity = 'E';
break;
Parity = 'E';
break;
case OddParity:
case OddParity:
Parity = 'O';
break;
Parity = 'O';
break;
case MarkParity:
case MarkParity:
Parity = 'M';
break;
Parity = 'M';
break;
case SpaceParity:
case SpaceParity:
Parity = 'S';
break;
Parity = 'S';
break;
default:
default:
Parity = 'U';
Parity = 'U';
}
switch (SerialIo->Mode->StopBits) {
case DefaultStopBits:
case DefaultStopBits:
StopBits = L"Default";
break;
StopBits = L"Default";
break;
case OneStopBit:
case OneStopBit:
StopBits = L"1";
break;
StopBits = L"1";
break;
case TwoStopBits:
case TwoStopBits:
StopBits = L"2";
break;
StopBits = L"2";
break;
case OneFiveStopBits:
case OneFiveStopBits:
StopBits = L"1.5";
break;
StopBits = L"1.5";
break;
default:
default:
StopBits = L"Unknown";
StopBits = L"Unknown";
}
ShellPrintHiiEx(
ShellPrintHiiEx (
-1,
-1,
NULL,
@@ -130,9 +131,9 @@ DisplaySettings (
Parity,
SerialIo->Mode->DataBits,
StopBits
);
);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellStatus = SHELL_NOT_FOUND;
break;
}
@@ -143,8 +144,8 @@ DisplaySettings (
}
if (Index == NoHandles) {
if ((NoHandles != 0 && HandleValid) || 0 == NoHandles) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NOT_FOUND), gShellDebug1HiiHandle, L"sermode");
if (((NoHandles != 0) && HandleValid) || (0 == NoHandles)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NOT_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellStatus = SHELL_NOT_FOUND;
}
}
@@ -191,27 +192,27 @@ ShellCommandRunSerMode (
Package = NULL;
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"sermode", 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"sermode", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) < 6 && ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"sermode");
if ((ShellCommandLineGetCount (Package) < 6) && (ShellCommandLineGetCount (Package) > 2)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"sermode");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 6) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"sermode");
} else if (ShellCommandLineGetCount (Package) > 6) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"sermode");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Temp = ShellCommandLineGetRawValue(Package, 1);
Temp = ShellCommandLineGetRawValue (Package, 1);
if (Temp != NULL) {
Status = ShellConvertStringToUint64(Temp, &Intermediate, TRUE, FALSE);
Status = ShellConvertStringToUint64 (Temp, &Intermediate, TRUE, FALSE);
HandleIdx = (UINTN)Intermediate;
Temp = ShellCommandLineGetRawValue(Package, 2);
Temp = ShellCommandLineGetRawValue (Package, 2);
if (Temp == NULL) {
ShellStatus = DisplaySettings (HandleIdx, TRUE);
goto Done;
@@ -220,95 +221,101 @@ ShellCommandRunSerMode (
ShellStatus = DisplaySettings (0, FALSE);
goto Done;
}
Temp = ShellCommandLineGetRawValue(Package, 2);
Temp = ShellCommandLineGetRawValue (Package, 2);
if (Temp != NULL) {
BaudRate = ShellStrToUintn(Temp);
BaudRate = ShellStrToUintn (Temp);
} else {
ASSERT(FALSE);
ASSERT (FALSE);
BaudRate = 0;
}
Temp = ShellCommandLineGetRawValue(Package, 3);
if (Temp == NULL || StrLen(Temp)>1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
Temp = ShellCommandLineGetRawValue (Package, 3);
if ((Temp == NULL) || (StrLen (Temp) > 1)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
switch(Temp[0]){
case 'd':
case 'D':
Parity = DefaultParity;
break;
case 'n':
case 'N':
Parity = NoParity;
break;
case 'e':
case 'E':
Parity = EvenParity;
break;
case 'o':
case 'O':
Parity = OddParity;
break;
case 'm':
case 'M':
Parity = MarkParity;
break;
case 's':
case 'S':
Parity = SpaceParity;
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
switch (Temp[0]) {
case 'd':
case 'D':
Parity = DefaultParity;
break;
case 'n':
case 'N':
Parity = NoParity;
break;
case 'e':
case 'E':
Parity = EvenParity;
break;
case 'o':
case 'O':
Parity = OddParity;
break;
case 'm':
case 'M':
Parity = MarkParity;
break;
case 's':
case 'S':
Parity = SpaceParity;
break;
default:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
}
Temp = ShellCommandLineGetRawValue(Package, 4);
Temp = ShellCommandLineGetRawValue (Package, 4);
if (Temp != NULL) {
DataBits = ShellStrToUintn(Temp);
DataBits = ShellStrToUintn (Temp);
} else {
//
// make sure this is some number not in the list below.
//
DataBits = 0;
}
switch (DataBits) {
case 4:
case 7:
case 8:
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
case 4:
case 7:
case 8:
break;
default:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
Temp = ShellCommandLineGetRawValue(Package, 5);
Value = ShellStrToUintn(Temp);
Temp = ShellCommandLineGetRawValue (Package, 5);
Value = ShellStrToUintn (Temp);
switch (Value) {
case 0:
StopBits = DefaultStopBits;
break;
case 0:
StopBits = DefaultStopBits;
break;
case 1:
StopBits = OneStopBit;
break;
case 1:
StopBits = OneStopBit;
break;
case 2:
StopBits = TwoStopBits;
break;
case 2:
StopBits = TwoStopBits;
break;
case 15:
StopBits = OneFiveStopBits;
break;
case 15:
StopBits = OneFiveStopBits;
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
default:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
@@ -318,39 +325,40 @@ ShellCommandRunSerMode (
continue;
}
Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
if (!EFI_ERROR (Status)) {
Status = SerialIo->SetAttributes (
SerialIo,
(UINT64) BaudRate,
SerialIo->Mode->ReceiveFifoDepth,
SerialIo->Mode->Timeout,
Parity,
(UINT8) DataBits,
StopBits
);
SerialIo,
(UINT64)BaudRate,
SerialIo->Mode->ReceiveFifoDepth,
SerialIo->Mode->Timeout,
Parity,
(UINT8)DataBits,
StopBits
);
if (EFI_ERROR (Status)) {
if (Status == EFI_INVALID_PARAMETER) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_UNSUPPORTED), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_UNSUPPORTED), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex (Handles[Index]));
ShellStatus = SHELL_UNSUPPORTED;
} else if (Status == EFI_DEVICE_ERROR) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_DEV_ERROR), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_DEV_ERROR), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex (Handles[Index]));
ShellStatus = SHELL_ACCESS_DENIED;
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_FAIL), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_FAIL), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex (Handles[Index]));
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_HANDLE), gShellDebug1HiiHandle, ConvertHandleToHandleIndex(Handles[Index]));
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_HANDLE), gShellDebug1HiiHandle, ConvertHandleToHandleIndex (Handles[Index]));
}
break;
}
}
}
}
if (ShellStatus == SHELL_SUCCESS && Index == NoHandles) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_BAD_HANDLE), gShellDebug1HiiHandle, L"sermode", HandleIdx);
if ((ShellStatus == SHELL_SUCCESS) && (Index == NoHandles)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SERMODE_BAD_HANDLE), gShellDebug1HiiHandle, L"sermode", HandleIdx);
ShellStatus = SHELL_INVALID_PARAMETER;
}
@@ -358,8 +366,10 @@ Done:
if (Package != NULL) {
ShellCommandLineFreeVarList (Package);
}
if (Handles != NULL) {
FreePool (Handles);
}
return ShellStatus;
}

View File

@@ -22,78 +22,81 @@ ShellCommandRunSetSize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp1;
UINTN NewSize;
UINTN LoopVar;
SHELL_FILE_HANDLE FileHandle;
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp1;
UINTN NewSize;
UINTN LoopVar;
SHELL_FILE_HANDLE FileHandle;
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"setsize", 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"setsize", 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_FEW), gShellDebug1HiiHandle, L"setsize");
if (ShellCommandLineGetCount (Package) < 3) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
NewSize = 0;
NewSize = 0;
} else {
Temp1 = ShellCommandLineGetRawValue(Package, 1);
if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
Temp1 = ShellCommandLineGetRawValue (Package, 1);
if (!ShellIsHexOrDecimalNumber (Temp1, FALSE, FALSE)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
NewSize = 0;
NewSize = 0;
} else {
NewSize = ShellStrToUintn(Temp1);
NewSize = ShellStrToUintn (Temp1);
}
}
for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
if (EFI_ERROR(Status)) {
Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
for (LoopVar = 2; LoopVar < ShellCommandLineGetCount (Package) && ShellStatus == SHELL_SUCCESS; LoopVar++) {
Status = ShellOpenFileByName (ShellCommandLineGetRawValue (Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
if (EFI_ERROR (Status)) {
Status = ShellOpenFileByName (ShellCommandLineGetRawValue (Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
}
if (EFI_ERROR(Status) && LoopVar == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
if (EFI_ERROR (Status) && (LoopVar == 2)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
} else if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue (Package, LoopVar));
ShellStatus = SHELL_INVALID_PARAMETER;
break;
} else {
Status = FileHandleSetSize(FileHandle, NewSize);
Status = FileHandleSetSize (FileHandle, NewSize);
if (Status == EFI_VOLUME_FULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle, L"setsize");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_VOLUME_FULL;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
} else if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue (Package, LoopVar));
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_DONE), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar));
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_DONE), gShellDebug1HiiHandle, ShellCommandLineGetRawValue (Package, LoopVar));
}
ShellCloseFile(&FileHandle);
ShellCloseFile (&FileHandle);
}
}

View File

@@ -9,21 +9,21 @@
#include "UefiShellDebug1CommandsLib.h"
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-guid", TypeValue},
{L"-bs", TypeFlag},
{L"-rt", TypeFlag},
{L"-nv", TypeFlag},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-guid", TypeValue },
{ L"-bs", TypeFlag },
{ L"-rt", TypeFlag },
{ L"-nv", TypeFlag },
{ NULL, TypeMax }
};
typedef enum {
DataTypeHexNumber = 0,
DataTypeHexArray = 1,
DataTypeAscii = 2,
DataTypeUnicode = 3,
DataTypeDevicePath = 4,
DataTypeUnKnow = 5
DataTypeHexNumber = 0,
DataTypeHexArray = 1,
DataTypeAscii = 2,
DataTypeUnicode = 3,
DataTypeDevicePath = 4,
DataTypeUnKnow = 5
} DATA_TYPE;
typedef union {
@@ -49,13 +49,14 @@ IsStringOfHexNibbles (
IN CONST CHAR16 *String
)
{
CONST CHAR16 *Pos;
CONST CHAR16 *Pos;
for (Pos = String; *Pos != L'\0'; ++Pos) {
if (!ShellIsHexaDecimalDigitCharacter (*Pos)) {
return FALSE;
}
}
return TRUE;
}
@@ -71,14 +72,14 @@ TestDataType (
IN CONST CHAR16 *Data
)
{
if (Data[0] == L'0' && (Data[1] == L'x' || Data[1] == L'X')) {
if (IsStringOfHexNibbles (Data+2) && StrLen (Data + 2) <= 16) {
if ((Data[0] == L'0') && ((Data[1] == L'x') || (Data[1] == L'X'))) {
if (IsStringOfHexNibbles (Data+2) && (StrLen (Data + 2) <= 16)) {
return DataTypeHexNumber;
} else {
return DataTypeUnKnow;
}
} else if (Data[0] == L'H') {
if (IsStringOfHexNibbles (Data + 1) && StrLen (Data + 1) % 2 == 0) {
if (IsStringOfHexNibbles (Data + 1) && (StrLen (Data + 1) % 2 == 0)) {
return DataTypeHexArray;
} else {
return DataTypeUnKnow;
@@ -87,11 +88,11 @@ TestDataType (
return DataTypeAscii;
} else if (Data[0] == L'L') {
return DataTypeUnicode;
} else if (Data[0] == L'P' || StrnCmp (Data, L"--", 2) == 0) {
} else if ((Data[0] == L'P') || (StrnCmp (Data, L"--", 2) == 0)) {
return DataTypeDevicePath;
}
if (IsStringOfHexNibbles (Data) && StrLen (Data) % 2 == 0) {
if (IsStringOfHexNibbles (Data) && (StrLen (Data) % 2 == 0)) {
return DataTypeHexArray;
}
@@ -114,9 +115,9 @@ TestDataType (
**/
EFI_STATUS
ParseParameterData (
IN CONST CHAR16 *Data,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize
IN CONST CHAR16 *Data,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize
)
{
UINT64 HexNumber;
@@ -127,14 +128,14 @@ ParseParameterData (
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_STATUS Status;
HexNumber = 0;
HexNumberLen = 0;
Size = 0;
AsciiBuffer = NULL;
DevPath = NULL;
Status = EFI_SUCCESS;
HexNumber = 0;
HexNumberLen = 0;
Size = 0;
AsciiBuffer = NULL;
DevPath = NULL;
Status = EFI_SUCCESS;
if (Data == NULL || BufferSize == NULL) {
if ((Data == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -145,20 +146,22 @@ ParseParameterData (
//
StrHexToUint64S (Data + 2, NULL, &HexNumber);
HexNumberLen = StrLen (Data + 2);
if (HexNumberLen >= 1 && HexNumberLen <= 2) {
if ((HexNumberLen >= 1) && (HexNumberLen <= 2)) {
Size = 1;
} else if (HexNumberLen >= 3 && HexNumberLen <= 4) {
} else if ((HexNumberLen >= 3) && (HexNumberLen <= 4)) {
Size = 2;
} else if (HexNumberLen >= 5 && HexNumberLen <= 8) {
} else if ((HexNumberLen >= 5) && (HexNumberLen <= 8)) {
Size = 4;
} else if (HexNumberLen >= 9 && HexNumberLen <= 16) {
} else if ((HexNumberLen >= 9) && (HexNumberLen <= 16)) {
Size = 8;
}
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem(Buffer, (VOID *)&HexNumber, Size);
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, (VOID *)&HexNumber, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeHexArray) {
//
@@ -169,11 +172,12 @@ ParseParameterData (
}
Size = StrLen (Data) / 2;
if (Buffer != NULL && *BufferSize >= Size) {
StrHexToBytes(Data, StrLen (Data), (UINT8 *)Buffer, Size);
if ((Buffer != NULL) && (*BufferSize >= Size)) {
StrHexToBytes (Data, StrLen (Data), (UINT8 *)Buffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeAscii) {
//
@@ -182,6 +186,7 @@ ParseParameterData (
if (*Data == L'S') {
Data = Data + 1;
}
AsciiBuffer = AllocateZeroPool (StrSize (Data) / 2);
if (AsciiBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -189,13 +194,15 @@ ParseParameterData (
AsciiSPrint (AsciiBuffer, StrSize (Data) / 2, "%s", (CHAR8 *)Data);
Size = StrSize (Data) / 2 - 1;
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, AsciiBuffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (AsciiBuffer);
} else if (DataType == DataTypeUnicode) {
//
@@ -204,12 +211,14 @@ ParseParameterData (
if (*Data == L'L') {
Data = Data + 1;
}
Size = StrSize (Data) - sizeof (CHAR16);
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, Data, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeDevicePath) {
if (*Data == L'P') {
@@ -217,19 +226,22 @@ ParseParameterData (
} else if (StrnCmp (Data, L"--", 2) == 0) {
Data = Data + 2;
}
DevPath = ConvertTextToDevicePath (Data);
if (DevPath == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
Status = EFI_INVALID_PARAMETER;
} else {
Size = GetDevicePathSize (DevPath);
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, DevPath, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (DevPath);
} else {
Status = EFI_INVALID_PARAMETER;
@@ -251,23 +263,23 @@ ParseParameterData (
**/
EFI_STATUS
GetVariableDataFromParameter (
IN CONST LIST_ENTRY *Package,
OUT UINT8 **Buffer,
OUT UINTN *BufferSize
IN CONST LIST_ENTRY *Package,
OUT UINT8 **Buffer,
OUT UINTN *BufferSize
)
{
CONST CHAR16 *TempData;
UINTN Index;
UINTN TotalSize;
UINTN Size;
UINT8 *BufferWalker;
EFI_STATUS Status;
CONST CHAR16 *TempData;
UINTN Index;
UINTN TotalSize;
UINTN Size;
UINT8 *BufferWalker;
EFI_STATUS Status;
TotalSize = 0;
Size = 0;
Status = EFI_SUCCESS;
TotalSize = 0;
Size = 0;
Status = EFI_SUCCESS;
if (BufferSize == NULL || Buffer == NULL || ShellCommandLineGetCount (Package) < 3) {
if ((BufferSize == NULL) || (Buffer == NULL) || (ShellCommandLineGetCount (Package) < 3)) {
return EFI_INVALID_PARAMETER;
}
@@ -281,8 +293,8 @@ GetVariableDataFromParameter (
}
TempData = TempData + 1;
Size = 0;
Status = ParseParameterData (TempData, NULL, &Size);
Size = 0;
Status = ParseParameterData (TempData, NULL, &Size);
if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL) {
//
@@ -295,13 +307,14 @@ GetVariableDataFromParameter (
} else if (Status == EFI_NOT_FOUND) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
}
return Status;
}
}
}
*BufferSize = TotalSize;
*Buffer = AllocateZeroPool (TotalSize);
*Buffer = AllocateZeroPool (TotalSize);
if (*Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -311,11 +324,11 @@ GetVariableDataFromParameter (
TempData = ShellCommandLineGetRawValue (Package, Index);
TempData = TempData + 1;
Size = TotalSize;
Size = TotalSize;
Status = ParseParameterData (TempData, (VOID *)BufferWalker, &Size);
if (!EFI_ERROR (Status)) {
BufferWalker = BufferWalker + Size;
TotalSize = TotalSize - Size;
TotalSize = TotalSize - Size;
} else {
return Status;
}
@@ -338,131 +351,139 @@ ShellCommandRunSetVar (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *VariableName;
EFI_GUID Guid;
CONST CHAR16 *StringGuid;
UINT32 Attributes;
VOID *Buffer;
UINTN Size;
UINTN LoopVar;
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *VariableName;
EFI_GUID Guid;
CONST CHAR16 *StringGuid;
UINT32 Attributes;
VOID *Buffer;
UINTN Size;
UINTN LoopVar;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Buffer = NULL;
Size = 0;
Attributes = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Buffer = NULL;
Size = 0;
Attributes = 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"setvar", 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"setvar", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else if (ShellCommandLineCheckDuplicate (Package,&ProblemParam) != EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DUPLICATE), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineCheckDuplicate (Package, &ProblemParam) != EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DUPLICATE), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
if (ShellCommandLineGetCount (Package) < 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
VariableName = ShellCommandLineGetRawValue(Package, 1);
if (!ShellCommandLineGetFlag(Package, L"-guid")){
CopyGuid(&Guid, &gEfiGlobalVariableGuid);
VariableName = ShellCommandLineGetRawValue (Package, 1);
if (!ShellCommandLineGetFlag (Package, L"-guid")) {
CopyGuid (&Guid, &gEfiGlobalVariableGuid);
} else {
StringGuid = ShellCommandLineGetValue(Package, L"-guid");
RStatus = StrToGuid (StringGuid, &Guid);
StringGuid = ShellCommandLineGetValue (Package, L"-guid");
RStatus = StrToGuid (StringGuid, &Guid);
if (RETURN_ERROR (RStatus) || (StringGuid[GUID_STRING_LENGTH] != L'\0')) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
if (ShellCommandLineGetCount(Package) == 2) {
if (ShellCommandLineGetCount (Package) == 2) {
//
// Display
//
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Buffer = AllocateZeroPool (Size);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
}
if (!EFI_ERROR(Status) && Buffer != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
if (!EFI_ERROR (Status) && (Buffer != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
for (LoopVar = 0; LoopVar < Size; LoopVar++) {
ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]);
ShellPrintEx (-1, -1, L"%02x ", ((UINT8 *)Buffer)[LoopVar]);
}
ShellPrintEx(-1, -1, L"\r\n");
ShellPrintEx (-1, -1, L"\r\n");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
//
// Create, Delete or Modify.
//
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Buffer = AllocateZeroPool (Size);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
}
if (EFI_ERROR(Status) || Buffer == NULL) {
if (EFI_ERROR (Status) || (Buffer == NULL)) {
//
// Creating a new variable. determine attributes from command line.
//
Attributes = 0;
if (ShellCommandLineGetFlag(Package, L"-bs")) {
if (ShellCommandLineGetFlag (Package, L"-bs")) {
Attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
}
if (ShellCommandLineGetFlag(Package, L"-rt")) {
if (ShellCommandLineGetFlag (Package, L"-rt")) {
Attributes |= EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_BOOTSERVICE_ACCESS;
}
if (ShellCommandLineGetFlag(Package, L"-nv")) {
if (ShellCommandLineGetFlag (Package, L"-nv")) {
Attributes |= EFI_VARIABLE_NON_VOLATILE;
}
}
SHELL_FREE_NON_NULL(Buffer);
Size = 0;
Status = GetVariableDataFromParameter(Package, (UINT8 **)&Buffer, &Size);
if (!EFI_ERROR(Status)) {
Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, Size, Buffer);
SHELL_FREE_NON_NULL (Buffer);
Size = 0;
Status = GetVariableDataFromParameter (Package, (UINT8 **)&Buffer, &Size);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable ((CHAR16 *)VariableName, &Guid, Attributes, Size, Buffer);
}
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellStatus = SHELL_ACCESS_DENIED;
} else {
ASSERT(ShellStatus == SHELL_SUCCESS);
ASSERT (ShellStatus == SHELL_SUCCESS);
}
}
}
ShellCommandLineFreeVarList (Package);
}
if (Buffer != NULL) {
FreePool(Buffer);
FreePool (Buffer);
}
return (ShellStatus);

View File

@@ -19,46 +19,46 @@
**/
VOID
DisplaySELAccessMethod (
IN CONST UINT8 Key,
IN CONST UINT8 Option
IN CONST UINT8 Key,
IN CONST UINT8 Option
)
{
//
// Print prompt
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ACCESS_METHOD), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ACCESS_METHOD), gShellDebug1HiiHandle);
PRINT_INFO_OPTION (Key, Option);
//
// Print value info
//
switch (Key) {
case 0:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_EIGHT_BIT), gShellDebug1HiiHandle);
break;
case 0:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_EIGHT_BIT), gShellDebug1HiiHandle);
break;
case 1:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TWO_EIGHT_BITS), gShellDebug1HiiHandle);
break;
case 1:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TWO_EIGHT_BITS), gShellDebug1HiiHandle);
break;
case 2:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_SIXTEEN_BIT), gShellDebug1HiiHandle);
break;
case 2:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_SIXTEEN_BIT), gShellDebug1HiiHandle);
break;
case 3:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MEM_MAPPED_PHYS), gShellDebug1HiiHandle);
break;
case 3:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MEM_MAPPED_PHYS), gShellDebug1HiiHandle);
break;
case 4:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_VIA_GENERAL), gShellDebug1HiiHandle);
break;
case 4:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_VIA_GENERAL), gShellDebug1HiiHandle);
break;
default:
if (Key <= 0x7f) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR_OEM), gShellDebug1HiiHandle);
}
default:
if (Key <= 0x7f) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR_OEM), gShellDebug1HiiHandle);
}
}
}
@@ -70,33 +70,33 @@ DisplaySELAccessMethod (
**/
VOID
DisplaySELLogStatus (
UINT8 Key,
UINT8 Option
UINT8 Key,
UINT8 Option
)
{
//
// Print prompt
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_STATUS), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_STATUS), gShellDebug1HiiHandle);
PRINT_INFO_OPTION (Key, Option);
//
// Print value info
//
if ((Key & 0x01) != 0) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
}
if ((Key & 0x02) != 0) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_FULL), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_FULL), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_NOT_FULL), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_NOT_FULL), gShellDebug1HiiHandle);
}
if ((Key & 0xFC) != 0) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RES_BITS_NOT_ZERO), gShellDebug1HiiHandle, Key & 0xFC);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RES_BITS_NOT_ZERO), gShellDebug1HiiHandle, Key & 0xFC);
}
}
@@ -108,27 +108,27 @@ DisplaySELLogStatus (
**/
VOID
DisplaySysEventLogHeaderFormat (
UINT8 Key,
UINT8 Option
UINT8 Key,
UINT8 Option
)
{
//
// Print prompt
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_FORMAT), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_FORMAT), gShellDebug1HiiHandle);
PRINT_INFO_OPTION (Key, Option);
//
// Print value info
//
if (Key == 0x00) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
} else if (Key == 0x01) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
} else if (Key <= 0x7f) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
}
}
@@ -140,23 +140,23 @@ DisplaySysEventLogHeaderFormat (
**/
VOID
DisplaySELLogHeaderLen (
UINT8 Key,
UINT8 Option
UINT8 Key,
UINT8 Option
)
{
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_LEN), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_LEN), gShellDebug1HiiHandle);
PRINT_INFO_OPTION (Key, Option);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_VAR_D), gShellDebug1HiiHandle, Key & 0x7F);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_VAR_D), gShellDebug1HiiHandle, Key & 0x7F);
//
// The most-significant bit of the field specifies
// whether (0) or not (1) the record has been read
//
if ((Key & 0x80) != 0) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_READ), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_READ), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_NOT_READ), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_NOT_READ), gShellDebug1HiiHandle);
}
}
@@ -167,19 +167,22 @@ DisplaySELLogHeaderLen (
**/
VOID
DisplaySysEventLogHeaderType1 (
IN UINT8 *LogHeader
IN UINT8 *LogHeader
)
{
LOG_HEADER_TYPE1_FORMAT *Header;
LOG_HEADER_TYPE1_FORMAT *Header;
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG), gShellDebug1HiiHandle);
//
// Print Log Header Type1 Format info
//
Header = (LOG_HEADER_TYPE1_FORMAT *) (LogHeader);
Header = (LOG_HEADER_TYPE1_FORMAT *)(LogHeader);
ShellPrintHiiEx(-1,-1,NULL,
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_OEM_RESERVED),
gShellDebug1HiiHandle,
Header->OEMReserved[0],
@@ -187,21 +190,24 @@ DisplaySysEventLogHeaderType1 (
Header->OEMReserved[2],
Header->OEMReserved[3],
Header->OEMReserved[4]
);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_TIME), gShellDebug1HiiHandle, Header->Metw);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_COUNT), gShellDebug1HiiHandle, Header->Meci);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_ADDRESS), gShellDebug1HiiHandle, Header->CMOSAddress);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_INDEX), gShellDebug1HiiHandle, Header->CMOSBitIndex);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUM_STARTING_OFF), gShellDebug1HiiHandle, Header->StartingOffset);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUN_BYTE_COUNT), gShellDebug1HiiHandle, Header->ChecksumOffset);
ShellPrintHiiEx(-1,-1,NULL,
);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_TIME), gShellDebug1HiiHandle, Header->Metw);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_COUNT), gShellDebug1HiiHandle, Header->Meci);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_ADDRESS), gShellDebug1HiiHandle, Header->CMOSAddress);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_INDEX), gShellDebug1HiiHandle, Header->CMOSBitIndex);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUM_STARTING_OFF), gShellDebug1HiiHandle, Header->StartingOffset);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUN_BYTE_COUNT), gShellDebug1HiiHandle, Header->ChecksumOffset);
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RESERVED),
gShellDebug1HiiHandle,
Header->OEMReserved[0],
Header->OEMReserved[1],
Header->OEMReserved[2]
);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_HEADER_REVISION), gShellDebug1HiiHandle, Header->HeaderRevision);
);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_HEADER_REVISION), gShellDebug1HiiHandle, Header->HeaderRevision);
}
/**
@@ -212,27 +218,27 @@ DisplaySysEventLogHeaderType1 (
**/
VOID
DisplaySysEventLogHeader (
UINT8 LogHeaderFormat,
UINT8 *LogHeader
UINT8 LogHeaderFormat,
UINT8 *LogHeader
)
{
//
// Print prompt
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER), gShellDebug1HiiHandle);
//
// Print value info
//
if (LogHeaderFormat == 0x00) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
} else if (LogHeaderFormat == 0x01) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
DisplaySysEventLogHeaderType1 (LogHeader);
} else if (LogHeaderFormat <= 0x7f) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FUTURE_ASSIGN), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FUTURE_ASSIGN), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
}
}
@@ -244,8 +250,8 @@ DisplaySysEventLogHeader (
**/
VOID
DisplayElVdfInfo (
UINT8 ElVdfType,
UINT8 *VarData
UINT8 ElVdfType,
UINT8 *VarData
)
{
UINT16 *Word;
@@ -260,60 +266,60 @@ DisplayElVdfInfo (
// Display Type description
//
switch (ElVdfType) {
case 0:
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_STD_FORMAT), gShellDebug1HiiHandle);
break;
case 0:
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_STD_FORMAT), gShellDebug1HiiHandle);
break;
case 1:
Word = (UINT16 *) (VarData + 1);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
break;
case 1:
Word = (UINT16 *)(VarData + 1);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
break;
case 2:
Dword = (UINT32 *) (VarData + 1);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
case 2:
Dword = (UINT32 *)(VarData + 1);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
case 3:
Word = (UINT16 *) (VarData + 1);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
//
// Followed by a multiple-event counter
//
Dword = (UINT32 *) (VarData + 1);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
case 3:
Word = (UINT16 *)(VarData + 1);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
//
// Followed by a multiple-event counter
//
Dword = (UINT32 *)(VarData + 1);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
case 4:
Dword = (UINT32 *) (VarData + 1);
DisplayPostResultsBitmapDw1 (*Dword, SHOW_DETAIL);
Dword++;
DisplayPostResultsBitmapDw2 (*Dword, SHOW_DETAIL);
break;
case 4:
Dword = (UINT32 *)(VarData + 1);
DisplayPostResultsBitmapDw1 (*Dword, SHOW_DETAIL);
Dword++;
DisplayPostResultsBitmapDw2 (*Dword, SHOW_DETAIL);
break;
case 5:
Dword = (UINT32 *) (VarData + 1);
DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
break;
case 5:
Dword = (UINT32 *)(VarData + 1);
DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
break;
case 6:
Dword = (UINT32 *) (VarData + 1);
DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
//
// Followed by a multiple-event counter
//
Dword = (UINT32 *) (VarData + 1);
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
case 6:
Dword = (UINT32 *)(VarData + 1);
DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
//
// Followed by a multiple-event counter
//
Dword = (UINT32 *)(VarData + 1);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
break;
default:
if (ElVdfType <= 0x7F) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_UNUSED_AVAIL_FOR_ASSIGN), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_SYSTEM), gShellDebug1HiiHandle);
}
default:
if (ElVdfType <= 0x7F) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_UNUSED_AVAIL_FOR_ASSIGN), gShellDebug1HiiHandle);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_SYSTEM), gShellDebug1HiiHandle);
}
}
}
@@ -329,25 +335,24 @@ DisplaySysEventLogData (
UINT16 LogAreaLength
)
{
LOG_RECORD_FORMAT *Log;
UINT8 ElVdfType;
LOG_RECORD_FORMAT *Log;
UINT8 ElVdfType;
//
// Event Log Variable Data Format Types
//
UINTN Offset;
UINTN Offset;
//
// Print prompt
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG_2), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG_2), gShellDebug1HiiHandle);
//
// Print Log info
//
Offset = 0;
Log = (LOG_RECORD_FORMAT *) LogData;
Offset = 0;
Log = (LOG_RECORD_FORMAT *)LogData;
while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) {
if (Log != NULL) {
//
// Display Event Log Record Information
@@ -362,21 +367,24 @@ DisplaySysEventLogData (
// (as read from CMOS) of the occurrence of the event
// So Print as hex and represent decimal
//
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);
if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);
if ((Log != NULL) && (Log->Year >= 80) && (Log->Year <= 99)) {
Print (L"19");
} else if (Log != NULL && Log->Year <= 79) {
} else if ((Log != NULL) && (Log->Year <= 79)) {
Print (L"20");
} else {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);
//
// Get a Event Log Record
//
Log = (LOG_RECORD_FORMAT *) (LogData + Offset);
Log = (LOG_RECORD_FORMAT *)(LogData + Offset);
continue;
}
ShellPrintHiiEx(-1,-1,NULL,
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),
gShellDebug1HiiHandle,
Log->Year,
@@ -385,7 +393,7 @@ DisplaySysEventLogData (
Log->Hour,
Log->Minute,
Log->Second
);
);
//
// Display Variable Data Format
@@ -394,7 +402,7 @@ DisplaySysEventLogData (
//
// Get a Event Log Record
//
Log = (LOG_RECORD_FORMAT *) (LogData + Offset);
Log = (LOG_RECORD_FORMAT *)(LogData + Offset);
continue;
}
@@ -403,7 +411,7 @@ DisplaySysEventLogData (
//
// Get a Event Log Record
//
Log = (LOG_RECORD_FORMAT *) (LogData + Offset);
Log = (LOG_RECORD_FORMAT *)(LogData + Offset);
}
}
}

View File

@@ -14,28 +14,28 @@
#pragma pack(1)
typedef struct {
UINT8 Type;
UINT8 Length;
UINT8 Year;
UINT8 Month;
UINT8 Day;
UINT8 Hour;
UINT8 Minute;
UINT8 Second;
UINT8 LogVariableData[1];
UINT8 Type;
UINT8 Length;
UINT8 Year;
UINT8 Month;
UINT8 Day;
UINT8 Hour;
UINT8 Minute;
UINT8 Second;
UINT8 LogVariableData[1];
} LOG_RECORD_FORMAT;
typedef struct {
UINT8 OEMReserved[5];
UINT8 Metw; // Multiple Event Time Window
UINT8 Meci; // Multiple Event Count Increment
UINT8 CMOSAddress; // Pre-boot Event Log Reset - CMOS Address
UINT8 CMOSBitIndex; // Pre-boot Event Log Reset - CMOS Bit Index
UINT8 StartingOffset; // CMOS Checksum - Starting Offset
UINT8 ByteCount; // CMOS Checksum - Byte Count
UINT8 ChecksumOffset; // CMOS Checksum - Checksum Offset
UINT8 Reserved[3];
UINT8 HeaderRevision;
UINT8 OEMReserved[5];
UINT8 Metw; // Multiple Event Time Window
UINT8 Meci; // Multiple Event Count Increment
UINT8 CMOSAddress; // Pre-boot Event Log Reset - CMOS Address
UINT8 CMOSBitIndex; // Pre-boot Event Log Reset - CMOS Bit Index
UINT8 StartingOffset; // CMOS Checksum - Starting Offset
UINT8 ByteCount; // CMOS Checksum - Byte Count
UINT8 ChecksumOffset; // CMOS Checksum - Checksum Offset
UINT8 Reserved[3];
UINT8 HeaderRevision;
} LOG_HEADER_TYPE1_FORMAT;
#pragma pack()
@@ -51,8 +51,8 @@ typedef struct {
**/
VOID
DisplaySELAccessMethod (
IN CONST UINT8 Key,
IN CONST UINT8 Option
IN CONST UINT8 Key,
IN CONST UINT8 Option
);
/**
@@ -63,8 +63,8 @@ DisplaySELAccessMethod (
**/
VOID
DisplaySELLogStatus (
UINT8 Key,
UINT8 Option
UINT8 Key,
UINT8 Option
);
/**
@@ -75,8 +75,8 @@ DisplaySELLogStatus (
**/
VOID
DisplaySysEventLogHeaderFormat (
UINT8 Key,
UINT8 Option
UINT8 Key,
UINT8 Option
);
/**
@@ -87,8 +87,8 @@ DisplaySysEventLogHeaderFormat (
**/
VOID
DisplaySysEventLogHeader (
UINT8 LogHeaderFormat,
UINT8 *LogHeader
UINT8 LogHeaderFormat,
UINT8 *LogHeader
);
/**

View File

@@ -6,20 +6,19 @@
**/
#include "UefiShellDebug1CommandsLib.h"
#include <Guid/SmBios.h>
#include "LibSmbiosView.h"
#include "SmbiosView.h"
STATIC UINT8 mInit = 0;
STATIC UINT8 m64Init = 0;
STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
STATIC SMBIOS_TABLE_3_0_ENTRY_POINT *mSmbios64BitTable = NULL;
STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;
STATIC SMBIOS_STRUCTURE_POINTER m_Smbios64BitStruct;
STATIC SMBIOS_STRUCTURE_POINTER *mSmbios64BitStruct = &m_Smbios64BitStruct;
STATIC UINT8 mInit = 0;
STATIC UINT8 m64Init = 0;
STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
STATIC SMBIOS_TABLE_3_0_ENTRY_POINT *mSmbios64BitTable = NULL;
STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;
STATIC SMBIOS_STRUCTURE_POINTER m_Smbios64BitStruct;
STATIC SMBIOS_STRUCTURE_POINTER *mSmbios64BitStruct = &m_Smbios64BitStruct;
/**
Init the SMBIOS VIEW API's environment.
@@ -39,25 +38,27 @@ LibSmbiosInit (
if (mInit == 1) {
return EFI_SUCCESS;
}
//
// Get SMBIOS table from System Configure table
//
Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);
Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **)&mSmbiosTable);
if (mSmbiosTable == NULL) {
return EFI_NOT_FOUND;
}
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
return Status;
}
//
// Init SMBIOS structure table address
//
mSmbiosStruct->Raw = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress);
mSmbiosStruct->Raw = (UINT8 *)(UINTN)(mSmbiosTable->TableAddress);
mInit = 1;
mInit = 1;
return EFI_SUCCESS;
}
@@ -79,25 +80,27 @@ LibSmbios64BitInit (
if (m64Init == 1) {
return EFI_SUCCESS;
}
//
// Get SMBIOS table from System Configure table
//
Status = GetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID**)&mSmbios64BitTable);
Status = GetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **)&mSmbios64BitTable);
if (mSmbios64BitTable == NULL) {
return EFI_NOT_FOUND;
}
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
return Status;
}
//
// Init SMBIOS structure table address
//
mSmbios64BitStruct->Raw = (UINT8 *) (UINTN) (mSmbios64BitTable->TableAddress);
mSmbios64BitStruct->Raw = (UINT8 *)(UINTN)(mSmbios64BitTable->TableAddress);
m64Init = 1;
m64Init = 1;
return EFI_SUCCESS;
}
@@ -144,7 +147,7 @@ LibSmbios64BitCleanup (
**/
VOID
LibSmbiosGetEPS (
OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
)
{
//
@@ -160,7 +163,7 @@ LibSmbiosGetEPS (
**/
VOID
LibSmbios64BitGetEPS (
OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
)
{
//
@@ -178,10 +181,10 @@ LibSmbios64BitGetEPS (
@return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
**/
CHAR8*
CHAR8 *
LibGetSmbiosString (
IN SMBIOS_STRUCTURE_POINTER *Smbios,
IN UINT16 StringNumber
IN SMBIOS_STRUCTURE_POINTER *Smbios,
IN UINT16 StringNumber
)
{
UINT16 Index;
@@ -192,7 +195,7 @@ LibGetSmbiosString (
//
// Skip over formatted section
//
String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length);
String = (CHAR8 *)(Smbios->Raw + Smbios->Hdr->Length);
//
// Look through unformated section
@@ -201,10 +204,13 @@ LibGetSmbiosString (
if (StringNumber == Index) {
return String;
}
//
// Skip string
//
for (; *String != 0; String++);
for ( ; *String != 0; String++) {
}
String++;
if (*String == 0) {
@@ -254,7 +260,7 @@ LibGetSmbiosStructure (
}
if ((Buffer == NULL) || (Length == NULL)) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
return DMI_INVALID_HANDLE;
}
@@ -267,11 +273,11 @@ LibGetSmbiosStructure (
//
// Walk to next structure
//
LibGetSmbiosString (&Smbios, (UINT16) (-1));
LibGetSmbiosString (&Smbios, (UINT16)(-1));
//
// Length = Next structure head - this structure head
//
*Length = (UINT16) (Smbios.Raw - Raw);
*Length = (UINT16)(Smbios.Raw - Raw);
*Buffer = Raw;
//
// update with the next structure handle.
@@ -281,12 +287,14 @@ LibGetSmbiosStructure (
} else {
*Handle = INVALID_HANDLE;
}
return DMI_SUCCESS;
}
//
// Walk to next structure
//
LibGetSmbiosString (&Smbios, (UINT16) (-1));
LibGetSmbiosString (&Smbios, (UINT16)(-1));
}
*Handle = INVALID_HANDLE;
@@ -326,12 +334,12 @@ LibGetSmbios64BitStructure (
}
if ((Buffer == NULL) || (Length == NULL)) {
ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
return DMI_INVALID_HANDLE;
}
*Length = 0;
Smbios.Hdr = mSmbios64BitStruct->Hdr;
*Length = 0;
Smbios.Hdr = mSmbios64BitStruct->Hdr;
SmbiosEnd.Raw = Smbios.Raw + mSmbios64BitTableLength;
while (Smbios.Raw < SmbiosEnd.Raw) {
@@ -340,11 +348,11 @@ LibGetSmbios64BitStructure (
//
// Walk to next structure
//
LibGetSmbiosString (&Smbios, (UINT16) (-1));
LibGetSmbiosString (&Smbios, (UINT16)(-1));
//
// Length = Next structure head - this structure head
//
*Length = (UINT16) (Smbios.Raw - Raw);
*Length = (UINT16)(Smbios.Raw - Raw);
*Buffer = Raw;
//
// update with the next structure handle.
@@ -354,12 +362,14 @@ LibGetSmbios64BitStructure (
} else {
*Handle = INVALID_HANDLE;
}
return DMI_SUCCESS;
}
//
// Walk to next structure
//
LibGetSmbiosString (&Smbios, (UINT16) (-1));
LibGetSmbiosString (&Smbios, (UINT16)(-1));
}
*Handle = INVALID_HANDLE;

View File

@@ -11,22 +11,22 @@
#include <IndustryStandard/SmBios.h>
#define DMI_SUCCESS 0x00
#define DMI_UNKNOWN_FUNCTION 0x81
#define DMI_FUNCTION_NOT_SUPPORTED 0x82
#define DMI_INVALID_HANDLE 0x83
#define DMI_BAD_PARAMETER 0x84
#define DMI_INVALID_SUBFUNCTION 0x85
#define DMI_NO_CHANGE 0x86
#define DMI_ADD_STRUCTURE_FAILED 0x87
#define DMI_READ_ONLY 0x8D
#define DMI_LOCK_NOT_SUPPORTED 0x90
#define DMI_CURRENTLY_LOCKED 0x91
#define DMI_INVALID_LOCK 0x92
#define DMI_SUCCESS 0x00
#define DMI_UNKNOWN_FUNCTION 0x81
#define DMI_FUNCTION_NOT_SUPPORTED 0x82
#define DMI_INVALID_HANDLE 0x83
#define DMI_BAD_PARAMETER 0x84
#define DMI_INVALID_SUBFUNCTION 0x85
#define DMI_NO_CHANGE 0x86
#define DMI_ADD_STRUCTURE_FAILED 0x87
#define DMI_READ_ONLY 0x8D
#define DMI_LOCK_NOT_SUPPORTED 0x90
#define DMI_CURRENTLY_LOCKED 0x91
#define DMI_INVALID_LOCK 0x92
#define INVALID_HANDLE (UINT16) (-1)
#define INVALID_HANDLE (UINT16) (-1)
#define EFI_SMBIOSERR(val) EFIERR (0x30000 | val)
#define EFI_SMBIOSERR(val) EFIERR (0x30000 | val)
#define EFI_SMBIOSERR_FAILURE EFI_SMBIOSERR (1)
#define EFI_SMBIOSERR_STRUCT_NOT_FOUND EFI_SMBIOSERR (2)
@@ -76,7 +76,7 @@ LibSmbios64BitCleanup (
**/
VOID
LibSmbiosGetEPS (
OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
);
/**
@@ -86,7 +86,7 @@ LibSmbiosGetEPS (
**/
VOID
LibSmbios64BitGetEPS (
OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
);
/**
@@ -98,10 +98,10 @@ LibSmbios64BitGetEPS (
@return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
**/
CHAR8*
CHAR8 *
LibGetSmbiosString (
IN SMBIOS_STRUCTURE_POINTER *Smbios,
IN UINT16 StringNumber
IN SMBIOS_STRUCTURE_POINTER *Smbios,
IN UINT16 StringNumber
);
/**

View File

@@ -22,8 +22,8 @@ extern UINT8 SmbiosMinorVersion;
//
// SHOW_ALL: WaitEnter() not wait input.
//
#define SHOW_ALL 0x04
#define SHOW_STATISTICS 0x05
#define SHOW_ALL 0x04
#define SHOW_STATISTICS 0x05
#define AS_UINT16(pData) (*((UINT16 *) pData))
#define AS_UINT32(pData) (*((UINT32 *) pData))
@@ -89,8 +89,8 @@ DisplayBiosCharacteristics (
**/
VOID
DisplayBiosCharacteristicsExt1 (
IN UINT8 Byte1,
IN UINT8 Option
IN UINT8 Byte1,
IN UINT8 Option
);
/**
@@ -101,8 +101,8 @@ DisplayBiosCharacteristicsExt1 (
**/
VOID
DisplayBiosCharacteristicsExt2 (
IN UINT8 Byte2,
IN UINT8 Option
IN UINT8 Byte2,
IN UINT8 Option
);
/**
@@ -113,8 +113,8 @@ DisplayBiosCharacteristicsExt2 (
**/
VOID
DisplayProcessorFamily (
UINT8 Family,
UINT8 Option
UINT8 Family,
UINT8 Option
);
/**
@@ -125,8 +125,8 @@ DisplayProcessorFamily (
**/
VOID
DisplayProcessorFamily2 (
IN UINT16 Family2,
IN UINT8 Option
IN UINT16 Family2,
IN UINT8 Option
);
/**
@@ -153,8 +153,8 @@ DisplayProcessorFamily2 (
**/
VOID
DisplayProcessorVoltage (
IN UINT8 Voltage,
IN UINT8 Option
IN UINT8 Voltage,
IN UINT8 Option
);
/**
@@ -179,8 +179,8 @@ Bits 2:0 CPU Status
**/
VOID
DisplayProcessorStatus (
IN UINT8 Status,
IN UINT8 Option
IN UINT8 Status,
IN UINT8 Option
);
/**
@@ -192,9 +192,9 @@ DisplayProcessorStatus (
**/
VOID
DisplayMaxMemoryModuleSize (
IN UINT8 Size,
IN UINT8 SlotNum,
IN UINT8 Option
IN UINT8 Size,
IN UINT8 SlotNum,
IN UINT8 Option
);
/**
@@ -206,9 +206,9 @@ DisplayMaxMemoryModuleSize (
**/
VOID
DisplayMemoryModuleConfigHandles (
IN UINT16 *Handles,
IN UINT8 SlotNum,
IN UINT8 Option
IN UINT16 *Handles,
IN UINT8 SlotNum,
IN UINT8 Option
);
/**
@@ -219,8 +219,8 @@ DisplayMemoryModuleConfigHandles (
**/
VOID
DisplayMmBankConnections (
IN UINT8 BankConnections,
IN UINT8 Option
IN UINT8 BankConnections,
IN UINT8 Option
);
/**
@@ -239,8 +239,8 @@ DisplayMmBankConnections (
**/
VOID
DisplayMmMemorySize (
IN UINT8 Size,
IN UINT8 Option
IN UINT8 Size,
IN UINT8 Option
);
/**
@@ -273,8 +273,8 @@ Bits 2:0 Cache Level
**/
VOID
DisplayCacheConfiguration (
IN UINT16 CacheConfiguration,
IN UINT8 Option
IN UINT16 CacheConfiguration,
IN UINT8 Option
);
/**
@@ -339,8 +339,8 @@ DisplaySBDSManufactureDate (
**/
VOID
DisplaySystemResetCapabilities (
IN UINT8 Reset,
IN UINT8 Option
IN UINT8 Reset,
IN UINT8 Option
);
/**
@@ -375,8 +375,8 @@ DisplaySystemResetCapabilities (
**/
VOID
DisplayHardwareSecuritySettings (
IN UINT8 Settings,
IN UINT8 Option
IN UINT8 Settings,
IN UINT8 Option
);
/**
@@ -387,8 +387,8 @@ DisplayHardwareSecuritySettings (
**/
VOID
DisplayOBRAConnections (
IN UINT8 Connections,
IN UINT8 Option
IN UINT8 Connections,
IN UINT8 Option
);
/**
@@ -399,8 +399,8 @@ DisplayOBRAConnections (
**/
VOID
DisplaySystemBootStatus (
IN UINT8 Parameter,
IN UINT8 Option
IN UINT8 Parameter,
IN UINT8 Option
);
/**
@@ -435,7 +435,8 @@ DisplayTpmDeviceCharacteristics (
**/
VOID
DisplayProcessorArchitectureType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
#endif

View File

@@ -12,11 +12,11 @@
#include <IndustryStandard/SmBios.h>
#define QUERY_TABLE_UNFOUND 0xFF
#define QUERY_TABLE_UNFOUND 0xFF
typedef struct TABLE_ITEM {
UINT16 Key;
CHAR16 *Info;
UINT16 Key;
CHAR16 *Info;
} TABLE_ITEM;
//
@@ -59,11 +59,11 @@ typedef struct TABLE_ITEM {
**/
UINT8
QueryTable (
IN TABLE_ITEM *Table,
IN UINTN Number,
IN UINT8 Key,
IN OUT CHAR16 *Info,
IN UINTN InfoLen
IN TABLE_ITEM *Table,
IN UINTN Number,
IN UINT8 Key,
IN OUT CHAR16 *Info,
IN UINTN InfoLen
);
/**
@@ -74,8 +74,8 @@ QueryTable (
**/
VOID
DisplayStructureTypeInfo (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -86,8 +86,8 @@ DisplayStructureTypeInfo (
**/
VOID
DisplaySystemWakeupType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -98,8 +98,8 @@ DisplaySystemWakeupType (
**/
VOID
DisplayBaseBoardFeatureFlags (
IN UINT8 FeatureFlags,
IN UINT8 Option
IN UINT8 FeatureFlags,
IN UINT8 Option
);
/**
@@ -109,9 +109,9 @@ DisplayBaseBoardFeatureFlags (
@param[in] Option The optional information.
**/
VOID
DisplayBaseBoardBoardType(
IN UINT8 Type,
IN UINT8 Option
DisplayBaseBoardBoardType (
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -122,8 +122,8 @@ DisplayBaseBoardBoardType(
**/
VOID
DisplaySystemEnclosureType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -134,8 +134,8 @@ DisplaySystemEnclosureType (
**/
VOID
DisplaySystemEnclosureStatus (
IN UINT8 Status,
IN UINT8 Option
IN UINT8 Status,
IN UINT8 Option
);
/**
@@ -146,8 +146,8 @@ DisplaySystemEnclosureStatus (
**/
VOID
DisplaySESecurityStatus (
IN UINT8 Status,
IN UINT8 Option
IN UINT8 Status,
IN UINT8 Option
)
;
@@ -159,8 +159,8 @@ DisplaySESecurityStatus (
**/
VOID
DisplayProcessorType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -171,8 +171,8 @@ DisplayProcessorType (
**/
VOID
DisplayProcessorUpgrade (
IN UINT8 Upgrade,
IN UINT8 Option
IN UINT8 Upgrade,
IN UINT8 Option
);
/**
@@ -183,8 +183,8 @@ DisplayProcessorUpgrade (
**/
VOID
DisplayProcessorCharacteristics (
IN UINT16 Type,
IN UINT8 Option
IN UINT16 Type,
IN UINT8 Option
);
/**
@@ -195,8 +195,8 @@ DisplayProcessorCharacteristics (
**/
VOID
DisplayMcErrorDetectMethod (
IN UINT8 Method,
IN UINT8 Option
IN UINT8 Method,
IN UINT8 Option
);
/**
@@ -207,8 +207,8 @@ DisplayMcErrorDetectMethod (
**/
VOID
DisplayMcErrorCorrectCapability (
IN UINT8 Capability,
IN UINT8 Option
IN UINT8 Capability,
IN UINT8 Option
);
/**
@@ -219,8 +219,8 @@ DisplayMcErrorCorrectCapability (
**/
VOID
DisplayMcInterleaveSupport (
IN UINT8 Support,
IN UINT8 Option
IN UINT8 Support,
IN UINT8 Option
);
/**
@@ -243,8 +243,8 @@ DisplayMcMemorySpeeds (
**/
VOID
DisplayMemoryModuleVoltage (
IN UINT8 Voltage,
IN UINT8 Option
IN UINT8 Voltage,
IN UINT8 Option
);
/**
@@ -267,8 +267,8 @@ DisplayMmMemoryType (
**/
VOID
DisplayMmErrorStatus (
IN UINT8 Status,
IN UINT8 Option
IN UINT8 Status,
IN UINT8 Option
);
/**
@@ -291,8 +291,8 @@ DisplayCacheSRAMType (
**/
VOID
DisplayCacheErrCorrectingType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -303,8 +303,8 @@ DisplayCacheErrCorrectingType (
**/
VOID
DisplayCacheSystemCacheType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -315,8 +315,8 @@ DisplayCacheSystemCacheType (
**/
VOID
DisplayCacheAssociativity (
IN UINT8 Associativity,
IN UINT8 Option
IN UINT8 Associativity,
IN UINT8 Option
);
/**
@@ -327,8 +327,8 @@ DisplayCacheAssociativity (
**/
VOID
DisplayPortConnectorType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -339,8 +339,8 @@ DisplayPortConnectorType (
**/
VOID
DisplayPortType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -351,8 +351,8 @@ DisplayPortType (
**/
VOID
DisplaySystemSlotType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -363,8 +363,8 @@ DisplaySystemSlotType (
**/
VOID
DisplaySystemSlotDataBusWidth (
IN UINT8 Width,
IN UINT8 Option
IN UINT8 Width,
IN UINT8 Option
);
/**
@@ -375,8 +375,8 @@ DisplaySystemSlotDataBusWidth (
**/
VOID
DisplaySystemSlotCurrentUsage (
IN UINT8 Usage,
IN UINT8 Option
IN UINT8 Usage,
IN UINT8 Option
);
/**
@@ -387,8 +387,8 @@ DisplaySystemSlotCurrentUsage (
**/
VOID
DisplaySystemSlotLength (
IN UINT8 Length,
IN UINT8 Option
IN UINT8 Length,
IN UINT8 Option
);
/**
@@ -399,8 +399,8 @@ DisplaySystemSlotLength (
**/
VOID
DisplaySlotCharacteristics1 (
IN UINT8 Chara1,
IN UINT8 Option
IN UINT8 Chara1,
IN UINT8 Option
);
/**
@@ -411,8 +411,8 @@ DisplaySlotCharacteristics1 (
**/
VOID
DisplaySlotCharacteristics2 (
IN UINT8 Chara2,
IN UINT8 Option
IN UINT8 Chara2,
IN UINT8 Option
);
/**
@@ -423,8 +423,8 @@ DisplaySlotCharacteristics2 (
**/
VOID
DisplayOnboardDeviceTypes (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -435,8 +435,8 @@ DisplayOnboardDeviceTypes (
**/
VOID
DisplaySELTypes (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -447,8 +447,8 @@ DisplaySELTypes (
**/
VOID
DisplaySELVarDataFormatType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -495,8 +495,8 @@ DisplaySELSysManagementTypes (
**/
VOID
DisplayPMALocation (
IN UINT8 Location,
IN UINT8 Option
IN UINT8 Location,
IN UINT8 Option
);
/**
@@ -507,8 +507,8 @@ DisplayPMALocation (
**/
VOID
DisplayPMAUse (
IN UINT8 Use,
IN UINT8 Option
IN UINT8 Use,
IN UINT8 Option
);
/**
@@ -519,8 +519,8 @@ DisplayPMAUse (
**/
VOID
DisplayPMAErrorCorrectionTypes (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -531,8 +531,8 @@ DisplayPMAErrorCorrectionTypes (
**/
VOID
DisplayMemoryDeviceFormFactor (
IN UINT8 FormFactor,
IN UINT8 Option
IN UINT8 FormFactor,
IN UINT8 Option
);
/**
@@ -543,8 +543,8 @@ DisplayMemoryDeviceFormFactor (
**/
VOID
DisplayMemoryDeviceType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -591,8 +591,8 @@ DisplayMemoryDeviceMemoryOperatingModeCapability (
**/
VOID
DisplayMemoryErrorType (
IN UINT8 ErrorType,
IN UINT8 Option
IN UINT8 ErrorType,
IN UINT8 Option
);
/**
@@ -603,8 +603,8 @@ DisplayMemoryErrorType (
**/
VOID
DisplayMemoryErrorGranularity (
IN UINT8 Granularity,
IN UINT8 Option
IN UINT8 Granularity,
IN UINT8 Option
);
/**
@@ -615,8 +615,8 @@ DisplayMemoryErrorGranularity (
**/
VOID
DisplayMemoryErrorOperation (
IN UINT8 Operation,
IN UINT8 Option
IN UINT8 Operation,
IN UINT8 Option
);
/**
@@ -627,8 +627,8 @@ DisplayMemoryErrorOperation (
**/
VOID
DisplayPointingDeviceType (
IN UINT8 Type,
IN UINT8 Option
IN UINT8 Type,
IN UINT8 Option
);
/**
@@ -639,8 +639,8 @@ DisplayPointingDeviceType (
**/
VOID
DisplayPointingDeviceInterface (
IN UINT8 Interface,
IN UINT8 Option
IN UINT8 Interface,
IN UINT8 Option
);
/**
@@ -651,8 +651,8 @@ DisplayPointingDeviceInterface (
**/
VOID
DisplayPBDeviceChemistry (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -663,8 +663,8 @@ DisplayPBDeviceChemistry (
**/
VOID
DisplayVPLocation (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -675,8 +675,8 @@ DisplayVPLocation (
**/
VOID
DisplayVPStatus (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -687,8 +687,8 @@ DisplayVPStatus (
**/
VOID
DisplayCoolingDeviceStatus (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -699,8 +699,8 @@ DisplayCoolingDeviceStatus (
**/
VOID
DisplayCoolingDeviceType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -711,8 +711,8 @@ DisplayCoolingDeviceType (
**/
VOID
DisplayTemperatureProbeStatus (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -723,8 +723,8 @@ DisplayTemperatureProbeStatus (
**/
VOID
DisplayTemperatureProbeLoc (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -735,8 +735,8 @@ DisplayTemperatureProbeLoc (
**/
VOID
DisplayECPStatus (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -747,8 +747,8 @@ DisplayECPStatus (
**/
VOID
DisplayECPLoc (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -759,8 +759,8 @@ DisplayECPLoc (
**/
VOID
DisplayMDType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -771,8 +771,8 @@ DisplayMDType (
**/
VOID
DisplayMDAddressType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -783,8 +783,8 @@ DisplayMDAddressType (
**/
VOID
DisplayMemoryChannelType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -795,8 +795,8 @@ DisplayMemoryChannelType (
**/
VOID
DisplayIPMIDIBMCInterfaceType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
/**
@@ -807,8 +807,8 @@ DisplayIPMIDIBMCInterfaceType (
**/
VOID
DisplayMCHostInterfaceType (
IN UINT8 Key,
IN UINT8 Option
IN UINT8 Key,
IN UINT8 Option
);
#endif

View File

@@ -9,15 +9,15 @@
#ifndef _SMBIOS_VIEW_H_
#define _SMBIOS_VIEW_H_
#define STRUCTURE_TYPE_RANDOM (UINT8) 0xFE
#define STRUCTURE_TYPE_INVALID (UINT8) 0xFF
#define STRUCTURE_TYPE_RANDOM (UINT8) 0xFE
#define STRUCTURE_TYPE_INVALID (UINT8) 0xFF
typedef struct {
UINT16 Index;
UINT8 Type;
UINT16 Handle;
UINT16 Addr; // offset from table head
UINT16 Length; // total structure length
UINT16 Index;
UINT8 Type;
UINT16 Handle;
UINT16 Addr; // offset from table head
UINT16 Length; // total structure length
} STRUCTURE_STATISTICS;
/**
@@ -34,10 +34,10 @@ typedef struct {
**/
EFI_STATUS
SMBiosView (
IN UINT8 QueryType,
IN UINT16 QueryHandle,
IN UINT8 Option,
IN BOOLEAN RandomView
IN UINT8 QueryType,
IN UINT16 QueryHandle,
IN UINT8 Option,
IN BOOLEAN RandomView
);
/**
@@ -54,10 +54,10 @@ SMBiosView (
**/
EFI_STATUS
SMBios64View (
IN UINT8 QueryType,
IN UINT16 QueryHandle,
IN UINT8 Option,
IN BOOLEAN RandomView
IN UINT8 QueryType,
IN UINT16 QueryHandle,
IN UINT8 Option,
IN BOOLEAN RandomView
);
/**
@@ -89,7 +89,7 @@ InitSmbios64BitTableStatistics (
**/
EFI_STATUS
DisplayStatisticsTable (
IN UINT8 Option
IN UINT8 Option
);
/**
@@ -101,7 +101,7 @@ DisplayStatisticsTable (
**/
EFI_STATUS
DisplaySmbios64BitStatisticsTable (
IN UINT8 Option
IN UINT8 Option
);
/**
@@ -111,9 +111,9 @@ DisplaySmbios64BitStatisticsTable (
@return A pointer to a string representing the ShowType (or 'undefined type' if not known).
**/
CHAR16*
CHAR16 *
GetShowTypeString (
UINT8 ShowType
UINT8 ShowType
);
extern UINT8 gShowType;

View File

@@ -9,8 +9,8 @@
#include "UefiShellDebug1CommandsLib.h"
#include <Library/BcfgCommandLib.h>
STATIC CONST CHAR16 mFileName[] = L"Debug1Commands";
EFI_HII_HANDLE gShellDebug1HiiHandle = NULL;
STATIC CONST CHAR16 mFileName[] = L"Debug1Commands";
EFI_HII_HANDLE gShellDebug1HiiHandle = NULL;
/**
Gets the debug file name. This will be used if HII is not working.
@@ -18,7 +18,7 @@ EFI_HII_HANDLE gShellDebug1HiiHandle = NULL;
@retval NULL No file is available.
@return The NULL-terminated filename to get help from.
**/
CONST CHAR16*
CONST CHAR16 *
EFIAPI
ShellCommandGetManFileNameDebug1 (
VOID
@@ -46,7 +46,7 @@ UefiShellDebug1CommandsLibConstructor (
//
// check our bit of the profiles mask
//
if ((PcdGet8(PcdShellProfileMask) & BIT1) == 0) {
if ((PcdGet8 (PcdShellProfileMask) & BIT1) == 0) {
return (EFI_SUCCESS);
}
@@ -61,27 +61,27 @@ UefiShellDebug1CommandsLibConstructor (
//
// install our shell command handlers that are always installed
//
ShellCommandRegisterCommandName(L"setsize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) );
ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) );
ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) );
ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) );
ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) );
ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) );
ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) );
ShellCommandRegisterCommandName(L"loadpcirom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) );
ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) );
ShellCommandRegisterCommandName(L"setvar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) );
ShellCommandRegisterCommandName(L"sermode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) );
ShellCommandRegisterCommandName(L"pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) );
ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) );
ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) );
ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) );
ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) );
ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT) );
ShellCommandRegisterCommandName (L"setsize", ShellCommandRunSetSize, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_SETSIZE));
ShellCommandRegisterCommandName (L"comp", ShellCommandRunComp, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_COMP));
ShellCommandRegisterCommandName (L"mode", ShellCommandRunMode, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_MODE));
ShellCommandRegisterCommandName (L"memmap", ShellCommandRunMemMap, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_MEMMAP));
ShellCommandRegisterCommandName (L"eficompress", ShellCommandRunEfiCompress, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_EFICOMPRESS));
ShellCommandRegisterCommandName (L"efidecompress", ShellCommandRunEfiDecompress, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_EFIDCOMPRESS));
ShellCommandRegisterCommandName (L"dmem", ShellCommandRunDmem, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_DMEM));
ShellCommandRegisterCommandName (L"loadpcirom", ShellCommandRunLoadPciRom, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_LOAD_PCI_ROM));
ShellCommandRegisterCommandName (L"mm", ShellCommandRunMm, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_MM));
ShellCommandRegisterCommandName (L"setvar", ShellCommandRunSetVar, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_SETVAR));
ShellCommandRegisterCommandName (L"sermode", ShellCommandRunSerMode, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_SERMODE));
ShellCommandRegisterCommandName (L"pci", ShellCommandRunPci, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_PCI));
ShellCommandRegisterCommandName (L"smbiosview", ShellCommandRunSmbiosView, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_SMBIOSVIEW));
ShellCommandRegisterCommandName (L"dmpstore", ShellCommandRunDmpStore, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_DMPSTORE));
ShellCommandRegisterCommandName (L"dblk", ShellCommandRunDblk, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_DBLK));
ShellCommandRegisterCommandName (L"edit", ShellCommandRunEdit, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_EDIT));
ShellCommandRegisterCommandName (L"hexedit", ShellCommandRunHexEdit, ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN (STR_GET_HELP_HEXEDIT));
ShellCommandRegisterAlias(L"dmem", L"mem");
ShellCommandRegisterAlias (L"dmem", L"mem");
BcfgLibraryRegisterBcfgCommand(ImageHandle, SystemTable, L"Debug1");
BcfgLibraryRegisterBcfgCommand (ImageHandle, SystemTable, L"Debug1");
return (EFI_SUCCESS);
}
@@ -100,14 +100,13 @@ UefiShellDebug1CommandsLibDestructor (
)
{
if (gShellDebug1HiiHandle != NULL) {
HiiRemovePackages(gShellDebug1HiiHandle);
HiiRemovePackages (gShellDebug1HiiHandle);
}
BcfgLibraryUnregisterBcfgCommand(ImageHandle, SystemTable);
BcfgLibraryUnregisterBcfgCommand (ImageHandle, SystemTable);
return (EFI_SUCCESS);
}
/**
Function returns a system configuration table that is stored in the
EFI System Table based on the provided GUID.
@@ -120,11 +119,12 @@ UefiShellDebug1CommandsLibDestructor (
**/
EFI_STATUS
GetSystemConfigurationTable (
IN EFI_GUID *TableGuid,
IN OUT VOID **Table
IN EFI_GUID *TableGuid,
IN OUT VOID **Table
)
{
UINTN Index;
UINTN Index;
ASSERT (Table != NULL);
for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
@@ -146,13 +146,13 @@ GetSystemConfigurationTable (
**/
VOID
EditorClearLine (
IN UINTN Row,
IN UINTN LastCol,
IN UINTN LastRow
IN UINTN Row,
IN UINTN LastCol,
IN UINTN LastRow
)
{
UINTN Col;
CHAR16 Line[200];
UINTN Col;
CHAR16 Line[200];
if (Row == 0) {
Row = 1;
@@ -180,7 +180,7 @@ EditorClearLine (
//
// print out the blank line
//
ShellPrintEx ((INT32) Col - 1, (INT32) Row - 1, Line);
ShellPrintEx ((INT32)Col - 1, (INT32)Row - 1, Line);
}
}
@@ -194,13 +194,13 @@ EditorClearLine (
**/
BOOLEAN
IsValidFileNameChar (
IN CONST CHAR16 Ch
IN CONST CHAR16 Ch
)
{
//
// See if there are any illegal characters within the name
//
if (Ch < 0x20 || Ch == L'\"' || Ch == L'*' || Ch == L'/' || Ch == L'<' || Ch == L'>' || Ch == L'?' || Ch == L'|') {
if ((Ch < 0x20) || (Ch == L'\"') || (Ch == L'*') || (Ch == L'/') || (Ch == L'<') || (Ch == L'>') || (Ch == L'?') || (Ch == L'|')) {
return FALSE;
}
@@ -217,25 +217,25 @@ IsValidFileNameChar (
**/
BOOLEAN
IsValidFileName (
IN CONST CHAR16 *Name
IN CONST CHAR16 *Name
)
{
UINTN Index;
UINTN Len;
UINTN Index;
UINTN Len;
//
// check the length of Name
//
for (Len = 0, Index = StrLen (Name) - 1; Index + 1 != 0; Index--, Len++) {
if (Name[Index] == '\\' || Name[Index] == ':') {
if ((Name[Index] == '\\') || (Name[Index] == ':')) {
break;
}
}
if (Len == 0 || Len > 255) {
if ((Len == 0) || (Len > 255)) {
return FALSE;
}
//
// check whether any char in Name not appears in valid file name char
//
@@ -258,14 +258,14 @@ IsValidFileName (
**/
CHAR16 *
EditGetDefaultFileName (
IN CONST CHAR16 *Extension
IN CONST CHAR16 *Extension
)
{
EFI_STATUS Status;
UINTN Suffix;
CHAR16 *FileNameTmp;
EFI_STATUS Status;
UINTN Suffix;
CHAR16 *FileNameTmp;
Suffix = 0;
Suffix = 0;
do {
FileNameTmp = CatSPrint (NULL, L"NewFile%d.%s", Suffix, Extension);
@@ -311,27 +311,27 @@ EditGetDefaultFileName (
**/
EFI_STATUS
ReadFileIntoBuffer (
IN CONST CHAR16 *FileName,
OUT VOID **Buffer,
OUT UINTN *BufferSize OPTIONAL,
OUT BOOLEAN *ReadOnly
IN CONST CHAR16 *FileName,
OUT VOID **Buffer,
OUT UINTN *BufferSize OPTIONAL,
OUT BOOLEAN *ReadOnly
)
{
VOID *InternalBuffer;
UINTN FileSize;
SHELL_FILE_HANDLE FileHandle;
BOOLEAN CreateFile;
EFI_STATUS Status;
EFI_FILE_INFO *Info;
VOID *InternalBuffer;
UINTN FileSize;
SHELL_FILE_HANDLE FileHandle;
BOOLEAN CreateFile;
EFI_STATUS Status;
EFI_FILE_INFO *Info;
InternalBuffer = NULL;
FileSize = 0;
FileHandle = NULL;
CreateFile = FALSE;
Status = EFI_SUCCESS;
Info = NULL;
InternalBuffer = NULL;
FileSize = 0;
FileHandle = NULL;
CreateFile = FALSE;
Status = EFI_SUCCESS;
Info = NULL;
if (FileName == NULL || Buffer == NULL || ReadOnly == NULL) {
if ((FileName == NULL) || (Buffer == NULL) || (ReadOnly == NULL)) {
return (EFI_INVALID_PARAMETER);
}
@@ -340,13 +340,13 @@ ReadFileIntoBuffer (
//
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
if (!EFI_ERROR(Status)) {
ASSERT(CreateFile == FALSE);
if (!EFI_ERROR (Status)) {
ASSERT (CreateFile == FALSE);
if (FileHandle == NULL) {
return EFI_LOAD_ERROR;
}
Info = ShellGetFileInfo(FileHandle);
Info = ShellGetFileInfo (FileHandle);
if (Info->Attribute & EFI_FILE_DIRECTORY) {
FreePool (Info);
@@ -358,10 +358,11 @@ ReadFileIntoBuffer (
} else {
*ReadOnly = FALSE;
}
//
// get file size
//
FileSize = (UINTN) Info->FileSize;
FileSize = (UINTN)Info->FileSize;
FreePool (Info);
} else if (Status == EFI_NOT_FOUND) {
@@ -379,10 +380,12 @@ ReadFileIntoBuffer (
if (Status == EFI_WARN_DELETE_FAILURE) {
Status = EFI_ACCESS_DENIED;
}
if (EFI_ERROR (Status)) {
return Status;
}
}
//
// file doesn't exist, so set CreateFile to TRUE and can't be read-only
//
@@ -401,21 +404,23 @@ ReadFileIntoBuffer (
if (InternalBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// read file into InternalBuffer
//
Status = ShellReadFile (FileHandle, &FileSize, InternalBuffer);
ShellCloseFile(&FileHandle);
ShellCloseFile (&FileHandle);
FileHandle = NULL;
if (EFI_ERROR (Status)) {
SHELL_FREE_NON_NULL (InternalBuffer);
return EFI_LOAD_ERROR;
}
}
*Buffer = InternalBuffer;
if (BufferSize != NULL) {
*BufferSize = FileSize;
}
return (EFI_SUCCESS);
return (EFI_SUCCESS);
}

View File

@@ -51,8 +51,7 @@
#include <Library/PrintLib.h>
#include <Library/HandleParsingLib.h>
extern EFI_HII_HANDLE gShellDebug1HiiHandle;
extern EFI_HII_HANDLE gShellDebug1HiiHandle;
/**
Function returns a system configuration table that is stored in the
@@ -66,8 +65,8 @@ extern EFI_HII_HANDLE gShellDebug1HiiHandle;
**/
EFI_STATUS
GetSystemConfigurationTable (
IN EFI_GUID *TableGuid,
IN OUT VOID **Table
IN EFI_GUID *TableGuid,
IN OUT VOID **Table
);
/**
@@ -313,9 +312,9 @@ ShellCommandRunHexEdit (
**/
VOID
EditorClearLine (
IN UINTN Row,
IN UINTN LastCol,
IN UINTN LastRow
IN UINTN Row,
IN UINTN LastCol,
IN UINTN LastRow
);
/**
@@ -328,7 +327,7 @@ EditorClearLine (
**/
BOOLEAN
IsValidFileName (
IN CONST CHAR16 *Name
IN CONST CHAR16 *Name
);
/**
@@ -341,7 +340,7 @@ IsValidFileName (
**/
CHAR16 *
EditGetDefaultFileName (
IN CONST CHAR16 *Extension
IN CONST CHAR16 *Extension
);
/**
@@ -368,10 +367,10 @@ EditGetDefaultFileName (
**/
EFI_STATUS
ReadFileIntoBuffer (
IN CONST CHAR16 *FileName,
OUT VOID **Buffer,
OUT UINTN *BufferSize OPTIONAL,
OUT BOOLEAN *ReadOnly
IN CONST CHAR16 *FileName,
OUT VOID **Buffer,
OUT UINTN *BufferSize OPTIONAL,
OUT BOOLEAN *ReadOnly
);
#endif

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