Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream/cm object parser #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,39 @@
STATIC
VOID
EFIAPI
PrintOemId (
PrintString (
CONST CHAR8 *Format,
UINT8 *Ptr
);

STATIC
VOID
EFIAPI
PrintString (
PrintStringPtr (
CONST CHAR8 *Format,
UINT8 *Ptr
);

STATIC
VOID
EFIAPI
PrintChar4 (
CONST CHAR8 *Format,
UINT8 *Ptr
);

STATIC
VOID
EFIAPI
PrintChar6 (
CONST CHAR8 *Format,
UINT8 *Ptr
);

STATIC
VOID
EFIAPI
PrintChar8 (
CONST CHAR8 *Format,
UINT8 *Ptr
);
Expand Down Expand Up @@ -190,16 +214,16 @@ STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[] = {
/** A parser for EArmObjNamedComponent.
*/
STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] = {
{ "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "IdMappingCount", 4, "0x%x", NULL },
{ "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "Flags", 4, "0x%x", NULL },
{ "CacheCoherent", 4, "0x%x", NULL },
{ "AllocationHints", 1, "0x%x", NULL },
{ "MemoryAccessFlags", 1, "0x%x", NULL },
{ "AddressSizeLimit", 1, "0x%x", NULL },
{ "ObjectName", sizeof (CHAR8 *), NULL, PrintString },
{ "Identifier", 4, "0x%x", NULL },
{ "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "IdMappingCount", 4, "0x%x", NULL },
{ "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
{ "Flags", 4, "0x%x", NULL },
{ "CacheCoherent", 4, "0x%x", NULL },
{ "AllocationHints", 1, "0x%x", NULL },
{ "MemoryAccessFlags", 1, "0x%x", NULL },
{ "AddressSizeLimit", 1, "0x%x", NULL },
{ "ObjectName", sizeof (CHAR8 *), NULL, PrintStringPtr },
{ "Identifier", 4, "0x%x", NULL },
};

/** A parser for EArmObjRootComplex.
Expand Down Expand Up @@ -740,19 +764,19 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectParser[] = {
*/
STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] = {
{ "Revision", 4, "0x%x", NULL },
{ "OemId[6]", 6, "%C%C%C%C%C%C", PrintOemId }
{ "OemId[6]", 6, "%c%c%c%c%c%c", PrintChar6 }
};

/** A parser for EStdObjAcpiTableList.
*/
STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] = {
{ "AcpiTableSignature", 4, "0x%x", NULL },
{ "AcpiTableRevision", 1, "%d", NULL },
{ "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL },
{ "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", NULL },
{ "OemTableId", 8, "0x%LLX", NULL },
{ "OemRevision", 4, "0x%x", NULL },
{ "MinorRevision", 1, "0x%x", NULL },
{ "AcpiTableSignature", 4, "%c%c%c%c", PrintChar4 },
{ "AcpiTableRevision", 1, "%d", NULL },
{ "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL },
{ "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", NULL },
{ "OemTableId", 8, "%c%c%c%c%c%c%c%c", PrintChar8 },
{ "OemRevision", 4, "0x%x", NULL },
{ "MinorRevision", 1, "0x%x", NULL },
};

/** A parser for EStdObjSmbiosTableList.
Expand All @@ -771,24 +795,102 @@ STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectParser[] = {
ARRAY_SIZE (StdObjAcpiTableInfoParser) },
{ "EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser,
ARRAY_SIZE (StdObjSmbiosTableInfoParser) },
{ "EStdObjMax", NULL, 0}
};

/** Print OEM Id.
/** Print string data.

The string must be NULL terminated.

@param [in] Format Format to print the Ptr.
@param [in] Ptr Pointer to the string.
**/
STATIC
VOID
EFIAPI
PrintString (
IN CONST CHAR8 *Format,
IN UINT8 *Ptr
)
{
if (Ptr == NULL) {
ASSERT (0);
return;
}

DEBUG ((DEBUG_ERROR, "%a", Ptr));
}

/** Print string from pointer.

The string must be NULL terminated.

@param [in] Format Format to print the string.
@param [in] Ptr Pointer to the string pointer.
**/
STATIC
VOID
EFIAPI
PrintStringPtr (
IN CONST CHAR8 *Format,
IN UINT8 *Ptr
)
{
UINT8 *String;

if (Ptr == NULL) {
ASSERT (0);
return;
}

String = *(UINT8 **)Ptr;

if (String == NULL) {
String = (UINT8 *)"(NULLPTR)";
}

PrintString (Format, String);
}

/** Print 4 characters.

@param [in] Format Format to print the Ptr.
@param [in] Ptr Pointer to the characters.
**/
STATIC
VOID
EFIAPI
PrintChar4 (
IN CONST CHAR8 *Format,
IN UINT8 *Ptr
)
{
DEBUG ((
DEBUG_ERROR,
(Format != NULL) ? Format : "%c%c%c%c",
Ptr[0],
Ptr[1],
Ptr[2],
Ptr[3]
));
}

/** Print 6 characters.

@param [in] Format Format to print the Ptr.
@param [in] Ptr Pointer to the OEM Id.
@param [in] Ptr Pointer to the characters.
**/
STATIC
VOID
EFIAPI
PrintOemId (
PrintChar6 (
IN CONST CHAR8 *Format,
IN UINT8 *Ptr
)
{
DEBUG ((
DEBUG_INFO,
(Format != NULL) ? Format : "%C%C%C%C%C%C",
DEBUG_ERROR,
(Format != NULL) ? Format : "%c%c%c%c%c%c",
Ptr[0],
Ptr[1],
Ptr[2],
Expand All @@ -798,22 +900,31 @@ PrintOemId (
));
}

/** Print string.

The string must be NULL terminated.
/** Print 8 characters.

@param [in] Format Format to print the Ptr.
@param [in] Ptr Pointer to the string.
@param [in] Ptr Pointer to the characters.
**/
STATIC
VOID
EFIAPI
PrintString (
CONST CHAR8 *Format,
UINT8 *Ptr
PrintChar8 (
IN CONST CHAR8 *Format,
IN UINT8 *Ptr
)
{
DEBUG ((DEBUG_ERROR, "%a", Ptr));
DEBUG ((
DEBUG_ERROR,
(Format != NULL) ? Format : "%c%c%c%c%c%c%c%c",
Ptr[0],
Ptr[1],
Ptr[2],
Ptr[3],
Ptr[4],
Ptr[5],
Ptr[6],
Ptr[7]
));
}

/** Print fields of the objects.
Expand Down Expand Up @@ -956,6 +1067,12 @@ ParseCmObjDesc (
return;
}

if (ObjId >= ARRAY_SIZE (StdNamespaceObjectParser)) {
DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the StdNamespaceObjectParser array\n", ObjId));
ASSERT (0);
return;
}

ParserArray = &StdNamespaceObjectParser[ObjId];
break;
case EObjNameSpaceArm:
Expand All @@ -964,10 +1081,17 @@ ParseCmObjDesc (
return;
}

if (ObjId >= ARRAY_SIZE (ArmNamespaceObjectParser)) {
DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the ArmNamespaceObjectParser array\n", ObjId));
ASSERT (0);
return;
}

ParserArray = &ArmNamespaceObjectParser[ObjId];
break;
default:
// Not supported
DEBUG ((DEBUG_ERROR, "NameSpaceId 0x%x, ObjId 0x%x is not supported by the parser\n", NameSpaceId, ObjId));
ASSERT (0);
return;
} // switch
Expand All @@ -985,21 +1109,26 @@ ParseCmObjDesc (
ObjIndex + 1,
ObjectCount
));
PrintCmObjDesc (
(VOID *)((UINTN)CmObjDesc->Data + Offset),
ParserArray->Parser,
ParserArray->ItemCount,
&RemainingSize,
1
);
if ((RemainingSize > CmObjDesc->Size) ||
(RemainingSize < 0))
{
ASSERT (0);
return;
}
if (ParserArray->Parser == NULL) {
DEBUG ((DEBUG_ERROR, "Parser not implemented\n"));
RemainingSize = 0;
} else {
PrintCmObjDesc (
(VOID *)((UINTN)CmObjDesc->Data + Offset),
ParserArray->Parser,
ParserArray->ItemCount,
&RemainingSize,
1
);
if ((RemainingSize > CmObjDesc->Size) ||
(RemainingSize < 0))
{
ASSERT (0);
return;
}

Offset = CmObjDesc->Size - RemainingSize;
Offset = CmObjDesc->Size - RemainingSize;
}
} // for

ASSERT (RemainingSize == 0);
Expand Down