Skip to content

Commit

Permalink
iASL Table Compiler: Add full support for RGRT ACPI table
Browse files Browse the repository at this point in the history
Includes compiler, disassembler, and template generator.
  • Loading branch information
acpibob committed May 14, 2021
1 parent aafcdad commit 6949e1d
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/common/ahtable.c
Expand Up @@ -237,6 +237,7 @@ const AH_TABLE AcpiGbl_SupportedTables[] =
{ACPI_SIG_PMTT, "Platform Memory Topology Table"},
{ACPI_SIG_PPTT, "Processor Properties Topology Table"},
{ACPI_SIG_RASF, "RAS Features Table"},
{ACPI_SIG_RGRT, "Regulatory Graphics Resource Table"},
{ACPI_RSDP_NAME,"Root System Description Pointer"},
{ACPI_SIG_RSDT, "Root System Description Table"},
{ACPI_SIG_S3PT, "S3 Performance Table"},
Expand Down
22 changes: 22 additions & 0 deletions source/common/dmtable.c
Expand Up @@ -401,6 +401,12 @@ static const char *AcpiDmPpttSubnames[] =
"Unknown Subtable Type" /* Reserved */
};

static const char *AcpiDmRgrtSubnames[] =
{
"Unknown/Reserved Image Type", /* ACPI_RGRT_TYPE_RESERVED0 */
"Type PNG" /* ACPI_RGRT_IMAGE_TYPE_PNG */
};

static const char *AcpiDmSdevSubnames[] =
{
"Namespace Device", /* ACPI_SDEV_TYPE_NAMESPACE_DEVICE */
Expand Down Expand Up @@ -561,6 +567,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] =
{ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt},
{ACPI_SIG_PPTT, NULL, AcpiDmDumpPptt, DtCompilePptt, TemplatePptt},
{ACPI_SIG_RASF, AcpiDmTableInfoRasf, NULL, NULL, TemplateRasf},
{ACPI_SIG_RGRT, NULL, AcpiDmDumpRgrt, DtCompileRgrt, TemplateRgrt},
{ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt},
{ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt},
{ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst},
Expand Down Expand Up @@ -992,6 +999,7 @@ AcpiDmDumpTable (
case ACPI_DMT_PCCT:
case ACPI_DMT_PMTT:
case ACPI_DMT_PPTT:
case ACPI_DMT_RGRT:
case ACPI_DMT_SDEV:
case ACPI_DMT_SRAT:
case ACPI_DMT_ASF:
Expand Down Expand Up @@ -1715,6 +1723,20 @@ AcpiDmDumpTable (
AcpiDmDumpBuffer (Target, 0, ByteLength, 0, NULL);
break;

case ACPI_DMT_RGRT:

/* RGRT subtable types */

Temp8 = *Target;
if (Temp8 >= ACPI_RGRT_TYPE_RESERVED)
{
Temp8 = ACPI_RGRT_TYPE_RESERVED0;
}

AcpiOsPrintf (UINT8_FORMAT, *Target,
AcpiDmRgrtSubnames[Temp8]);
break;

case ACPI_DMT_SDEV:

/* SDEV subtable types */
Expand Down
40 changes: 40 additions & 0 deletions source/common/dmtbdump2.c
Expand Up @@ -2003,6 +2003,46 @@ AcpiDmDumpPptt (
}


/*******************************************************************************
*
* FUNCTION: AcpiDmDumpRgrt
*
* PARAMETERS: Table - A RGRT table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a RGRT
*
******************************************************************************/

void
AcpiDmDumpRgrt (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
ACPI_TABLE_RGRT *Subtable = ACPI_CAST_PTR (ACPI_TABLE_RGRT, Table);
UINT32 Offset = sizeof (ACPI_TABLE_RGRT);


/* Main table */

Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoRgrt);
if (ACPI_FAILURE (Status))
{
return;
}

/* Dump the binary image as a subtable */

Status = AcpiDmDumpTable (Table->Length, Offset, &Subtable->Image,
Table->Length - Offset, AcpiDmTableInfoRgrt0);
if (ACPI_FAILURE (Status))
{
return;
}
}


/*******************************************************************************
*
* FUNCTION: AcpiDmDumpS3pt
Expand Down
25 changes: 25 additions & 0 deletions source/common/dmtbinfo2.c
Expand Up @@ -1607,6 +1607,31 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoRasf[] =
};


/*******************************************************************************
*
* RGRT - Regulatory Graphics Resource Table
*
******************************************************************************/

ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt[] =
{
{ACPI_DMT_UINT16, ACPI_RGRT_OFFSET (Version), "Version", 0},
{ACPI_DMT_RGRT, ACPI_RGRT_OFFSET (ImageType), "Image Type", 0},
{ACPI_DMT_UINT8, ACPI_RGRT_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};

/*
* We treat the binary image field as its own subtable (to make
* ACPI_DMT_RAW_BUFFER work properly).
*/
ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt0[] =
{
{ACPI_DMT_RAW_BUFFER, 0, "Image", 0},
ACPI_DMT_TERMINATOR
};


/*******************************************************************************
*
* S3PT - S3 Performance Table
Expand Down
5 changes: 5 additions & 0 deletions source/compiler/dtcompiler.h
Expand Up @@ -673,6 +673,10 @@ ACPI_STATUS
DtCompilePptt (
void **PFieldList);

ACPI_STATUS
DtCompileRgrt (
void **PFieldList);

ACPI_STATUS
DtCompileRsdt (
void **PFieldList);
Expand Down Expand Up @@ -781,6 +785,7 @@ extern const unsigned char TemplatePhat[];
extern const unsigned char TemplatePmtt[];
extern const unsigned char TemplatePptt[];
extern const unsigned char TemplateRasf[];
extern const unsigned char TemplateRgrt[];
extern const unsigned char TemplateRsdt[];
extern const unsigned char TemplateS3pt[];
extern const unsigned char TemplateSbst[];
Expand Down
48 changes: 48 additions & 0 deletions source/compiler/dttable2.c
Expand Up @@ -1335,6 +1335,54 @@ DtCompilePptt (
}


/******************************************************************************
*
* FUNCTION: DtCompileRgrt
*
* PARAMETERS: List - Current field list pointer
*
* RETURN: Status
*
* DESCRIPTION: Compile RGRT.
*
*****************************************************************************/

ACPI_STATUS
DtCompileRgrt (
void **List)
{
ACPI_STATUS Status;
DT_SUBTABLE *Subtable;
DT_SUBTABLE *ParentTable;
DT_FIELD **PFieldList = (DT_FIELD **) List;


/* Compile the main table */

Status = DtCompileTable (PFieldList, AcpiDmTableInfoRgrt,
&Subtable);
if (ACPI_FAILURE (Status))
{
return (Status);
}

ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);

/* Compile the "Subtable" -- actually just the binary (PNG) image */

Status = DtCompileTable (PFieldList, AcpiDmTableInfoRgrt0,
&Subtable);
if (ACPI_FAILURE (Status))
{
return (Status);
}

DtInsertSubtable (ParentTable, Subtable);
return (AE_OK);
}


/******************************************************************************
*
* FUNCTION: DtCompileRsdt
Expand Down
14 changes: 14 additions & 0 deletions source/compiler/dttemplate.h
Expand Up @@ -1257,6 +1257,20 @@ const unsigned char TemplateRasf[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000028 "........" */
};

const unsigned char TemplateRgrt[] =
{
0x52,0x47,0x52,0x54,0x50,0x00,0x00,0x00, /* 00000000 "RGRTP..." */
0x01,0x33,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".3INTEL " */
0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
0x31,0x03,0x21,0x20,0x01,0x00,0x01,0x00, /* 00000020 "1.! ...." */
0xAA,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* 00000028 "........" */
0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* 00000030 "........" */
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* 00000038 "........" */
0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, /* 00000040 "........" */
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27 /* 00000048 " !"#$%&'" */
};

const unsigned char TemplateRsdp[] =
{
0x52,0x53,0x44,0x20,0x50,0x54,0x52,0x20, /* 00000000 "RSD PTR " */
Expand Down
1 change: 1 addition & 0 deletions source/compiler/dtutils.c
Expand Up @@ -583,6 +583,7 @@ DtGetFieldLength (
case ACPI_DMT_PCCT:
case ACPI_DMT_PMTT:
case ACPI_DMT_PPTT:
case ACPI_DMT_RGRT:
case ACPI_DMT_SDEV:
case ACPI_DMT_SRAT:
case ACPI_DMT_ASF:
Expand Down
7 changes: 7 additions & 0 deletions source/include/acdisasm.h
Expand Up @@ -276,6 +276,7 @@ typedef enum
ACPI_DMT_PMTT,
ACPI_DMT_PMTT_VENDOR,
ACPI_DMT_PPTT,
ACPI_DMT_RGRT,
ACPI_DMT_SDEI,
ACPI_DMT_SDEV,
ACPI_DMT_SLIC,
Expand Down Expand Up @@ -553,6 +554,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPptt1a[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPptt2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPpttHdr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRasf[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[];
Expand Down Expand Up @@ -782,6 +785,10 @@ void
AcpiDmDumpPptt (
ACPI_TABLE_HEADER *Table);

void
AcpiDmDumpRgrt (
ACPI_TABLE_HEADER *Table);

UINT32
AcpiDmDumpRsdp (
ACPI_TABLE_HEADER *Table);
Expand Down
1 change: 1 addition & 0 deletions source/include/actbinfo.h
Expand Up @@ -183,6 +183,7 @@
#define ACPI_PDTT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PDTT,f)
#define ACPI_PMTT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PMTT,f)
#define ACPI_RASF_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_RASF,f)
#define ACPI_RGRT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_RGRT,f)
#define ACPI_S3PT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_S3PT,f)
#define ACPI_SBST_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SBST,f)
#define ACPI_SDEI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SDEI,f)
Expand Down
31 changes: 31 additions & 0 deletions source/include/actbl2.h
Expand Up @@ -184,6 +184,7 @@
#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
#define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Table */
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
#define ACPI_SIG_RGRT "RGRT" /* Regulatory Graphics Resource Table */
#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */
#define ACPI_SIG_SDEI "SDEI" /* Software Delegated Exception Interface Table */
#define ACPI_SIG_SDEV "SDEV" /* Secure Devices table */
Expand Down Expand Up @@ -2231,6 +2232,36 @@ enum AcpiRasfStatus
#define ACPI_RASF_STATUS (0x1F<<3)


/*******************************************************************************
*
* RGRT - Regulatory Graphics Resource Table
* Version 1
*
* Conforms to "ACPI RGRT" available at:
* https://microsoft.github.io/mu/dyn/mu_plus/MsCorePkg/AcpiRGRT/feature_acpi_rgrt/
*
******************************************************************************/

typedef struct acpi_table_rgrt
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
UINT16 Version;
UINT8 ImageType;
UINT8 Reserved;
UINT8 Image[0];

} ACPI_TABLE_RGRT;

/* ImageType values */

enum AcpiRgrtImageType
{
ACPI_RGRT_TYPE_RESERVED0 = 0,
ACPI_RGRT_IMAGE_TYPE_PNG = 1,
ACPI_RGRT_TYPE_RESERVED = 2 /* 2 and greater are reserved */
};


/*******************************************************************************
*
* SBST - Smart Battery Specification Table
Expand Down
1 change: 1 addition & 0 deletions source/tools/acpisrc/astable.c
Expand Up @@ -676,6 +676,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_TABLE_PHAT", SRC_TYPE_STRUCT},
{"ACPI_TABLE_PMTT", SRC_TYPE_STRUCT},
{"ACPI_TABLE_PPTT", SRC_TYPE_STRUCT},
{"ACPI_TABLE_RGRT", SRC_TYPE_STRUCT},
{"ACPI_TABLE_RSDP", SRC_TYPE_STRUCT},
{"ACPI_TABLE_RSDT", SRC_TYPE_STRUCT},
{"ACPI_TABLE_MCHI", SRC_TYPE_STRUCT},
Expand Down

0 comments on commit 6949e1d

Please sign in to comment.