diff options
author | Robert Moore <Robert.Moore@intel.com> | 2022-10-19 13:23:10 -0700 |
---|---|---|
committer | Robert Moore <Robert.Moore@intel.com> | 2022-10-19 13:23:10 -0700 |
commit | 8ac4e5116f59d6f9ba2fbeb9ce22ab58237a278f (patch) | |
tree | 9df29448e6705a5f924da6d0914a907d8d3831f2 | |
parent | 7021087eedb0d7156286e9e4f255e93c07816921 (diff) | |
download | acpica-8ac4e5116f59d6f9ba2fbeb9ce22ab58237a278f.tar.gz |
Finish support for the CDAT table, in both the data table
compiler and the disassembler.
35 files changed, 1339 insertions, 202 deletions
diff --git a/source/common/acfileio.c b/source/common/acfileio.c index 7c624f5d3..77f7337a3 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -387,16 +387,36 @@ AcGetOneTableFromFile ( ACPI_TABLE_HEADER TableHeader; ACPI_TABLE_HEADER *Table; INT32 Count; - long TableOffset; - + UINT32 TableLength; + UINT32 HeaderLength; + long TableOffset = 0; *ReturnTable = NULL; /* Get the table header to examine signature and length */ + /* + * Special handling for the CDAT table (both the Length field + * and the Checksum field are not in the standard positions). + * (The table header is non-standard). + */ + if (AcpiGbl_CDAT) + { + HeaderLength = sizeof (ACPI_TABLE_CDAT); + } + else + { + HeaderLength = sizeof (ACPI_TABLE_HEADER); + } + + Status = AcValidateTableHeader (File, TableOffset); + if (ACPI_FAILURE (Status)) + { + return (Status); + } TableOffset = ftell (File); - Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File); - if (Count != sizeof (ACPI_TABLE_HEADER)) + Count = fread (&TableHeader, 1, HeaderLength, File); + if (Count != (INT32) HeaderLength) { return (AE_CTRL_TERMINATE); } @@ -405,12 +425,6 @@ AcGetOneTableFromFile ( { /* Validate the table signature/header (limited ASCII chars) */ - Status = AcValidateTableHeader (File, TableOffset); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - /* * Table must be an AML table (DSDT/SSDT). * Used for iASL -e option only. @@ -425,9 +439,22 @@ AcGetOneTableFromFile ( } } + /* + * Special handling for the CDAT table (both the Length field + * and the Checksum field are not in the standard positions). + */ + if (AcpiGbl_CDAT) + { + TableLength = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader)->Length; + } + else + { + TableLength = TableHeader.Length; + } + /* Allocate a buffer for the entire table */ - Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length); + Table = AcpiOsAllocate ((ACPI_SIZE) TableLength); if (!Table) { return (AE_NO_MEMORY); @@ -436,22 +463,31 @@ AcGetOneTableFromFile ( /* Read the entire ACPI table, including header */ fseek (File, TableOffset, SEEK_SET); - - Count = fread (Table, 1, TableHeader.Length, File); + Count = fread (Table, 1, TableLength, File); /* * Checks for data table headers happen later in the execution. Only verify * for Aml tables at this point in the code. */ - if (GetOnlyAmlTables && Count != (INT32) TableHeader.Length) + if (GetOnlyAmlTables && Count != (INT32) TableLength) { Status = AE_ERROR; goto ErrorExit; } - /* Validate the checksum (just issue a warning) */ + /* + * Validate the checksum (just issue a warning if incorrect). + * Note: CDAT is special cased here because the table does + * not have the checksum field in the standard position. + */ + if (AcpiGbl_CDAT) + { + Status = AcpiUtVerifyCdatChecksum ((ACPI_TABLE_CDAT *) Table, TableLength); + } else + { + Status = AcpiUtVerifyChecksum (Table, TableLength); + } - Status = AcpiTbVerifyChecksum (Table, TableHeader.Length); if (ACPI_FAILURE (Status)) { Status = AcCheckTextModeCorruption (Table); @@ -540,6 +576,8 @@ AcValidateTableHeader ( long TableOffset) { ACPI_TABLE_HEADER TableHeader; + ACPI_TABLE_CDAT *CdatTableHeader = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader); + UINT32 HeaderLength; ACPI_SIZE Actual; long OriginalOffset; UINT32 FileSize; @@ -548,6 +586,16 @@ AcValidateTableHeader ( ACPI_FUNCTION_TRACE (AcValidateTableHeader); + /* Determine the type of table header */ + + if (AcpiGbl_CDAT) + { + HeaderLength = sizeof (ACPI_TABLE_CDAT); + } + else + { + HeaderLength = sizeof (ACPI_TABLE_HEADER); + } /* Read a potential table header */ @@ -556,41 +604,76 @@ AcValidateTableHeader ( { fprintf (stderr, "SEEK error\n"); } - Actual = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File); + Actual = fread (&TableHeader, 1, HeaderLength, File); if (fseek (File, OriginalOffset, SEEK_SET)) { fprintf (stderr, "SEEK error\n"); } - if (Actual < sizeof (ACPI_TABLE_HEADER)) + if (Actual < HeaderLength) { fprintf (stderr, "Could not read entire table header: Actual %u, Requested %u\n", - (UINT32) Actual, (UINT32) sizeof (ACPI_TABLE_HEADER)); + (UINT32) Actual, HeaderLength); return (AE_ERROR); } /* Validate the signature (limited ASCII chars) */ - if (!AcpiUtValidNameseg (TableHeader.Signature)) + if (!AcpiGbl_CDAT && !AcpiUtValidNameseg (TableHeader.Signature)) { + /* + * The "-ds cdat" option was not used, and the signature is not valid. + * + * For CDAT we are assuming that there should be at least one non-ASCII + * byte in the (normally) 4-character Signature field (at least the + * high-order byte should be zero). Otherwise, this is OK. + */ + fprintf (stderr, + "\nTable appears to be a CDAT table, which has no signature.\n" + "If this is in fact a CDAT table, use the -ds option on the\n" + "command line to specify the table type (signature):\n" + "\"iasl -d -ds CDAT <file>\" or \"iasl -ds CDAT -T CDAT\"\n\n"); + return (AE_BAD_SIGNATURE); } /* Validate table length against bytes remaining in the file */ FileSize = CmGetFileSize (File); - if (TableHeader.Length > (UINT32) (FileSize - TableOffset)) + if (!AcpiGbl_CDAT) + { + /* Standard ACPI table header */ + + if (TableHeader.Length > (UINT32) (FileSize - TableOffset)) + { + fprintf (stderr, "Table [%4.4s] is too long for file - " + "needs: 0x%.2X, remaining in file: 0x%.2X\n", + TableHeader.Signature, TableHeader.Length, + (UINT32) (FileSize - TableOffset)); + return (AE_BAD_HEADER); + } + } + else if (CdatTableHeader->Length > (UINT32) (FileSize - TableOffset)) { - fprintf (stderr, "Table [%4.4s] is too long for file - " + /* Special header for CDAT table */ + + fprintf (stderr, "Table [CDAT] is too long for file - " "needs: 0x%.2X, remaining in file: 0x%.2X\n", - TableHeader.Signature, TableHeader.Length, + CdatTableHeader->Length, (UINT32) (FileSize - TableOffset)); return (AE_BAD_HEADER); } + /* For CDAT table, there are no ASCII fields in the header, we are done */ + + if (AcpiGbl_CDAT) + { + return (AE_OK); + } + /* - * These fields must be ASCII: OemId, OemTableId, AslCompilerId. + * These standard fields must be ASCII: OemId, OemTableId, AslCompilerId. * We allow a NULL terminator in OemId and OemTableId. */ for (i = 0; i < ACPI_NAMESEG_SIZE; i++) diff --git a/source/common/adisasm.c b/source/common/adisasm.c index ecb984858..49338e741 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -476,13 +476,13 @@ AdDisassembleOneTable ( /* This is a "Data Table" (non-AML table) */ AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n", - Table->Signature); + AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature); AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] " "FieldName : FieldValue (in hex)\n */\n\n"); AcpiDmDumpDataTable (Table); fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", - Table->Signature); + AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature); if (File) { diff --git a/source/common/ahtable.c b/source/common/ahtable.c index 4eb6febb9..418621b66 100644 --- a/source/common/ahtable.c +++ b/source/common/ahtable.c @@ -207,6 +207,7 @@ const AH_TABLE AcpiGbl_SupportedTables[] = {ACPI_SIG_BGRT, "Boot Graphics Resource Table"}, {ACPI_SIG_BOOT, "Simple Boot Flag Table"}, {ACPI_SIG_CCEL, "CC-Event Log Table"}, + {ACPI_SIG_CDAT, "Coherent Device Attribute Table"}, {ACPI_SIG_CEDT, "CXL Early Discovery Table"}, {ACPI_SIG_CPEP, "Corrected Platform Error Polling Table"}, {ACPI_SIG_CSRT, "Core System Resource Table"}, diff --git a/source/common/dmtable.c b/source/common/dmtable.c index c7d9c056c..9b95ecc74 100644 --- a/source/common/dmtable.c +++ b/source/common/dmtable.c @@ -234,6 +234,17 @@ static const char *AcpiDmAsfSubnames[] = "Unknown Subtable Type" /* Reserved */ }; +static const char *AcpiDmCdatSubnames[] = +{ + "Device Scoped Memory Affinity Structure (DSMAS)", + "Device scoped Latency and Bandwidth Information Structure (DSLBIS)", + "Device Scoped Memory Side Cache Information Structure (DSMSCIS)", + "Device Scoped Initiator Structure (DSIS)", + "Device Scoped EFI Memory Type Structure (DSEMTS)", + "Switch Scoped Latency and Bandwidth Information Structure (SSLBIS)", + "Unknown Subtable Type" /* Reserved */ +}; + static const char *AcpiDmCedtSubnames[] = { "CXL Host Bridge Structure", @@ -666,6 +677,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt, NULL, NULL, TemplateBgrt}, {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot}, {ACPI_SIG_CCEL, AcpiDmTableInfoCcel, NULL, NULL, TemplateCcel}, + {ACPI_SIG_CDAT, NULL, AcpiDmDumpCdat, NULL, TemplateCdat}, {ACPI_SIG_CEDT, NULL, AcpiDmDumpCedt, DtCompileCedt, TemplateCedt}, {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep}, {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt}, @@ -732,44 +744,6 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = /******************************************************************************* * - * FUNCTION: AcpiDmGenerateChecksum - * - * PARAMETERS: Table - Pointer to table to be checksummed - * Length - Length of the table - * OriginalChecksum - Value of the checksum field - * - * RETURN: 8 bit checksum of buffer - * - * DESCRIPTION: Computes an 8 bit checksum of the table. - * - ******************************************************************************/ - -UINT8 -AcpiDmGenerateChecksum ( - void *Table, - UINT32 Length, - UINT8 OriginalChecksum) -{ - UINT8 Checksum; - - - /* Sum the entire table as-is */ - - Checksum = AcpiTbChecksum ((UINT8 *) Table, Length); - - /* Subtract off the existing checksum value in the table */ - - Checksum = (UINT8) (Checksum - OriginalChecksum); - - /* Compute the final checksum */ - - Checksum = (UINT8) (0 - Checksum); - return (Checksum); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDmGetTableData * * PARAMETERS: Signature - ACPI signature (4 chars) to match @@ -842,7 +816,7 @@ AcpiDmDumpDataTable ( /* * Handle tables that don't use the common ACPI table header structure. - * Currently, these are the FACS, RSDP, and S3PT. + * Currently, these are the FACS, RSDP, S3PT and CDAT. */ if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS)) { @@ -862,6 +836,28 @@ AcpiDmDumpDataTable ( { Length = AcpiDmDumpS3pt (Table); } + else if (!AcpiUtValidNameseg (Table->Signature)) + { + /* + * For CDAT we are assuming that there should be at least one non-ASCII + * byte in the (normally) 4-character Signature field (at least the + * high-order byte should be zero). + */ + if (AcpiGbl_CDAT) + { + /* + * Invalid signature and <-ds CDAT> was specified on the command line. + * Therefore, we have a CDAT table. + */ + AcpiDmDumpCdat (Table); + } + else + { + fprintf (stderr, "Table has an invalid signature\n"); + } + + return; + } else { /* @@ -1114,7 +1110,8 @@ AcpiDmDumpTable ( { AcpiOsPrintf ( "/**** ACPI table terminates " - "in the middle of a data structure! (dump table) */\n"); + "in the middle of a data structure! (dump table) \n" + "CurrentOffset: %X, TableLength: %X ***/", CurrentOffset, TableLength); return (AE_BAD_DATA); } @@ -1148,6 +1145,7 @@ AcpiDmDumpTable ( case ACPI_DMT_AEST_XFACE: case ACPI_DMT_AEST_XRUPT: case ACPI_DMT_ASF: + case ACPI_DMT_CDAT: case ACPI_DMT_HESTNTYP: case ACPI_DMT_FADTPM: case ACPI_DMT_EINJACT: @@ -1530,7 +1528,7 @@ AcpiDmDumpTable ( /* Checksum, display and validate */ AcpiOsPrintf ("%2.2X", *Target); - Temp8 = AcpiDmGenerateChecksum (Table, + Temp8 = AcpiUtGenerateChecksum (Table, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum); @@ -1676,6 +1674,20 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]); break; + case ACPI_DMT_CDAT: + + /* CDAT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_CDAT_TYPE_RESERVED) + { + Temp8 = ACPI_CDAT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, + AcpiDmCdatSubnames[Temp8]); + break; + case ACPI_DMT_CEDT: /* CEDT subtable types */ diff --git a/source/common/dmtables.c b/source/common/dmtables.c index 6f42bcb3b..7ade78685 100644 --- a/source/common/dmtables.c +++ b/source/common/dmtables.c @@ -296,7 +296,7 @@ AdCreateTableHeader ( AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum); - Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); + Checksum = AcpiUtChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); if (Checksum) { AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X", diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index b4faf6831..dc1745d5d 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -384,7 +384,7 @@ AcpiDmDumpRsdp ( /* Validate the first checksum */ - Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON), + Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON), Rsdp->Checksum); if (Checksum != Rsdp->Checksum) { @@ -405,7 +405,7 @@ AcpiDmDumpRsdp ( /* Validate the extended checksum over entire RSDP */ - Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP), + Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP), Rsdp->ExtendedChecksum); if (Checksum != Rsdp->ExtendedChecksum) { diff --git a/source/common/dmtbdump1.c b/source/common/dmtbdump1.c index 13662611e..ae5f0f862 100644 --- a/source/common/dmtbdump1.c +++ b/source/common/dmtbdump1.c @@ -153,6 +153,7 @@ #include "accommon.h" #include "acdisasm.h" #include "actables.h" +#include "aslcompiler.h" /* This module used for application-level code only */ @@ -608,6 +609,192 @@ AcpiDmDumpAsf ( } } + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpCdat + * + * PARAMETERS: InTable - A CDAT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a CDAT. This table type consists + * of an open-ended number of subtables. + * + ******************************************************************************/ + +void +AcpiDmDumpCdat ( + ACPI_TABLE_HEADER *InTable) +{ + ACPI_TABLE_CDAT *Table = ACPI_CAST_PTR (ACPI_TABLE_CDAT, InTable); + ACPI_STATUS Status; + ACPI_CDAT_HEADER *Subtable; + ACPI_TABLE_CDAT *CdatTable = ACPI_CAST_PTR (ACPI_TABLE_CDAT, Table); + ACPI_DMTABLE_INFO *InfoTable; + UINT32 Length = CdatTable->Length; + UINT32 Offset = sizeof (ACPI_TABLE_CDAT); + UINT32 SubtableLength; + UINT32 SubtableType; + INT32 EntriesLength; + + + /* Main table */ + + Status = AcpiDmDumpTable (Offset, 0, CdatTable, 0, + AcpiDmTableInfoCdatTableHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, sizeof (ACPI_TABLE_CDAT)); + while (Offset < Table->Length) + { + /* Dump the common subtable header */ + + DbgPrint (ASL_DEBUG_OUTPUT, "0) HeaderOffset: %X\n", Offset); + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + sizeof (ACPI_CDAT_HEADER), AcpiDmTableInfoCdatHeader); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point past the common subtable header, decode the subtable type */ + + Offset += sizeof (ACPI_CDAT_HEADER); + SubtableType = Subtable->Type; + + switch (Subtable->Type) + { + case ACPI_CDAT_TYPE_DSMAS: + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + SubtableLength = sizeof (ACPI_CDAT_DSMAS); + + InfoTable = AcpiDmTableInfoCdat0; + break; + + case ACPI_CDAT_TYPE_DSLBIS: + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + SubtableLength = sizeof (ACPI_CDAT_DSLBIS); + DbgPrint (ASL_DEBUG_OUTPUT, "1) Offset: %X\n", Offset); + + InfoTable = AcpiDmTableInfoCdat1; + break; + + case ACPI_CDAT_TYPE_DSMSCIS: + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + SubtableLength = sizeof (ACPI_CDAT_DSMSCIS); + + InfoTable = AcpiDmTableInfoCdat2; + break; + + case ACPI_CDAT_TYPE_DSIS: + DbgPrint (ASL_DEBUG_OUTPUT, "2) Offset: %X ", Offset); + SubtableLength = sizeof (ACPI_CDAT_DSIS); + DbgPrint (ASL_DEBUG_OUTPUT, "1) input pointer: %p\n", Table); + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + DbgPrint (ASL_DEBUG_OUTPUT, "1) output pointers: %p, %p, Offset: %X\n", + Table, Subtable, Offset); + DbgPrint (ASL_DEBUG_OUTPUT, "3) Offset: %X\n", Offset); + + InfoTable = AcpiDmTableInfoCdat3; + break; + + case ACPI_CDAT_TYPE_DSEMTS: + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + SubtableLength = sizeof (ACPI_CDAT_DSEMTS); + + InfoTable = AcpiDmTableInfoCdat4; + break; + + case ACPI_CDAT_TYPE_SSLBIS: + SubtableLength = Subtable->Length; + + InfoTable = AcpiDmTableInfoCdat5; + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + break; + + default: + fprintf (stderr, "ERROR: Unknown SubtableType: %X\n", Subtable->Type); + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, "SubtableType: %X, Length: %X Actual " + "Length: %X Offset: %X tableptr: %p\n", SubtableType, + Subtable->Length, SubtableLength, Offset, Table); + + /* + * Do the subtable-specific fields + */ + Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, "Subtable Type: %X, Offset: %X, SubtableLength: %X\n", + SubtableType, Offset, SubtableLength); + + /* Additional sub-subtables, dependent on the main subtable type */ + + switch (SubtableType) + { + case ACPI_CDAT_TYPE_SSLBIS: + Offset += sizeof (ACPI_CDAT_SSLBIS); + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, + Offset); + + DbgPrint (ASL_DEBUG_OUTPUT, "Case SSLBIS, Offset: %X, SubtableLength: %X " + "Subtable->Length %X\n", Offset, SubtableLength, Subtable->Length); + + /* Generate the total length of all the SSLBE entries */ + + EntriesLength = SubtableLength - sizeof (ACPI_CDAT_HEADER) - + sizeof (ACPI_CDAT_SSLBIS); + DbgPrint (ASL_DEBUG_OUTPUT, "EntriesLength: %X, Offset: %X, Table->Length: %X\n", + EntriesLength, Offset, Table->Length); + + /* Do each of the SSLBE Entries */ + + while ((EntriesLength > 0) && (Offset < Table->Length)) + { + AcpiOsPrintf ("\n"); + + Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset, + AcpiDmTableInfoCdatEntries); + if (ACPI_FAILURE (Status)) + { + return; + } + + EntriesLength -= sizeof (ACPI_CDAT_SSLBE); + Offset += sizeof (ACPI_CDAT_SSLBE); + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + } + + SubtableLength = 0; + break; + + default: + break; + } + + DbgPrint (ASL_DEBUG_OUTPUT, "Offset: %X, Subtable Length: %X\n", + Offset, SubtableLength); + + /* Point to next subtable */ + + Offset += SubtableLength; + Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset); + } + + return; +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpCedt @@ -651,12 +838,14 @@ AcpiDmDumpCedt ( case ACPI_CEDT_TYPE_CHBS: Status = AcpiDmDumpTable (Length, Offset, Subtable, Subtable->Length, AcpiDmTableInfoCedt0); - if (ACPI_FAILURE (Status)) { + if (ACPI_FAILURE (Status)) + { return; } break; - case ACPI_CEDT_TYPE_CFMWS: { + case ACPI_CEDT_TYPE_CFMWS: + { ACPI_CEDT_CFMWS *ptr = (ACPI_CEDT_CFMWS *) Subtable; unsigned int i, max = 0x01 << (ptr->InterleaveWays); @@ -664,18 +853,22 @@ AcpiDmDumpCedt ( Status = AcpiDmDumpTable (Length, Offset, Subtable, Subtable->Length, AcpiDmTableInfoCedt1); - if (ACPI_FAILURE (Status)) { + if (ACPI_FAILURE (Status)) + { return; } /* Now, print out any interleave targets beyond the first. */ - for (i = 1; i < max; i++) { - unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET(ACPI_CEDT_CFMWS, InterleaveTargets); + for (i = 1; i < max; i++) + { + unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveTargets); unsigned int *trg = &(ptr->InterleaveTargets[i]); + Status = AcpiDmDumpTable (Length, loc_offset, trg, Subtable->Length, AcpiDmTableInfoCedt1_te); - if (ACPI_FAILURE (Status)) { + if (ACPI_FAILURE (Status)) + { return; } } diff --git a/source/common/dmtbdump2.c b/source/common/dmtbdump2.c index 2f99911d2..3fb4d531e 100644 --- a/source/common/dmtbdump2.c +++ b/source/common/dmtbdump2.c @@ -2135,13 +2135,13 @@ AcpiDmDumpPhat ( case ACPI_PHAT_TYPE_FW_VERSION_DATA: InfoTable = AcpiDmTableInfoPhat0; - SubtableLength = sizeof (ACPI_PHAT_VERSION_DATA); + SubtableLength = Offset += sizeof (ACPI_PHAT_VERSION_DATA); break; case ACPI_PHAT_TYPE_FW_HEALTH_DATA: InfoTable = AcpiDmTableInfoPhat1; - SubtableLength = sizeof (ACPI_PHAT_HEALTH_DATA); + SubtableLength = Offset += sizeof (ACPI_PHAT_TYPE_FW_HEALTH_DATA); break; default: @@ -2152,14 +2152,13 @@ AcpiDmDumpPhat ( return; } - Status = AcpiDmDumpTable (Length, Offset, Subtable, + Status = AcpiDmDumpTable (Length, SubtableLength, Subtable, SubtableLength, InfoTable); if (ACPI_FAILURE (Status)) { return; } - Offset += SubtableLength; OriginalOffset = Offset; switch (Subtable->Type) { diff --git a/source/common/dmtbinfo1.c b/source/common/dmtbinfo1.c index d6a94bfc1..9afed4d6a 100644 --- a/source/common/dmtbinfo1.c +++ b/source/common/dmtbinfo1.c @@ -494,6 +494,116 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[] = ACPI_DMT_TERMINATOR }; +/******************************************************************************* + * + * CDAT - Coherent Device Attribute Table + * + ******************************************************************************/ + + /* Table header (not ACPI-compliant) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdatTableHdr[] = +{ + {ACPI_DMT_UINT32, ACPI_CDAT_OFFSET (Length), "CDAT Table Length", DT_LENGTH}, + {ACPI_DMT_UINT8, ACPI_CDAT_OFFSET (Revision), "Revision", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT_OFFSET (Checksum), "Checksum", 0}, + {ACPI_DMT_UINT48, ACPI_CDAT_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_CDAT_OFFSET (Sequence), "Sequence", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Common subtable header */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdatHeader[] = +{ + {ACPI_DMT_CDAT, ACPI_CDATH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_CDATH_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_CDATH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 0: Device Scoped Memory Affinity Structure (DSMAS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat0[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT0_OFFSET (DsmadHandle), "DSMAD Handle", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT0_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT0_OFFSET (DpaBaseAddress), "DPA Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT0_OFFSET (DpaLength), "DPA Length", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 1: Device scoped Latency and Bandwidth Information Structure (DSLBIS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat1[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT1_OFFSET (Handle), "Handle", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT1_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT1_OFFSET (DataType), "Data Type", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT1_OFFSET (EntryBaseUnit), "Entry Base Unit", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT1_OFFSET (Entry[0]), "Entry0", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT1_OFFSET (Entry[1]), "Entry1", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT1_OFFSET (Entry[2]), "Entry2", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT1_OFFSET (Reserved2), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 2: Device Scoped Memory Side Cache Information Structure (DSMSCIS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat2[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT2_OFFSET (DsmasHandle), "DSMAS Handle", 0}, + {ACPI_DMT_UINT24, ACPI_CDAT2_OFFSET (Reserved[3]), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT2_OFFSET (SideCacheSize), "Side Cache Size", 0}, + {ACPI_DMT_UINT32, ACPI_CDAT2_OFFSET (CacheAttributes), "Cache Attributes", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 3: Device Scoped Initiator Structure (DSIS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat3[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT3_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT3_OFFSET (Handle), "Handle", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT3_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 4: Device Scoped EFI Memory Type Structure (DSEMTS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat4[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT4_OFFSET (DsmasHandle), "DSMAS Handle", 0}, + {ACPI_DMT_UINT8, ACPI_CDAT4_OFFSET (MemoryType), "Memory Type", 0}, + {ACPI_DMT_UINT16, ACPI_CDAT4_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT4_OFFSET (DpaOffset), "DPA Offset", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT4_OFFSET (RangeLength), "DPA Range Length", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable 5: Switch Scoped Latency and Bandwidth Information Structure (SSLBIS) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdat5[] = +{ + {ACPI_DMT_UINT8, ACPI_CDAT5_OFFSET (DataType), "Data Type", 0}, + {ACPI_DMT_UINT24, ACPI_CDAT5_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_CDAT5_OFFSET (EntryBaseUnit), "Entry Base Unit", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Switch Scoped Latency and Bandwidth Entry (SSLBE) (For subtable 5 above) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoCdatEntries[] = +{ + {ACPI_DMT_UINT16, ACPI_CDATE_OFFSET (PortxId), "Port X Id", 0}, + {ACPI_DMT_UINT16, ACPI_CDATE_OFFSET (PortyId), "Port Y Id", 0}, + {ACPI_DMT_UINT16, ACPI_CDATE_OFFSET (LatencyOrBandwidth), "Latency or Bandwidth", 0}, + {ACPI_DMT_UINT16, ACPI_CDATE_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 6ae3a0aa2..a0c67424d 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -153,6 +153,7 @@ #include "aslcompiler.y.h" #include "amlcode.h" #include "acconvert.h" +#include "actbinfo.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslcodegen") @@ -181,6 +182,10 @@ static void CgUpdateHeader ( ACPI_PARSE_OBJECT *Op); +static void +CgUpdateCdatHeader ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -207,7 +212,14 @@ CgGenerateAmlOutput ( CgAmlWriteWalk, NULL, NULL); DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); - CgUpdateHeader (AslGbl_CurrentDB); + if (AcpiGbl_CDAT) + { + CgUpdateCdatHeader (AslGbl_CurrentDB); + } + else + { + CgUpdateHeader (AslGbl_CurrentDB); + } } @@ -658,6 +670,67 @@ CgWriteTableHeader ( /******************************************************************************* * + * FUNCTION: CgUpdateCdatHeader + * + * PARAMETERS: Op - Op for the Definition Block + * + * RETURN: None. + * + * DESCRIPTION: Complete the ACPI table by calculating the checksum and + * re-writing the header for the input definition block + * + ******************************************************************************/ + +static void +CgUpdateCdatHeader ( + ACPI_PARSE_OBJECT *Op) +{ + signed char Sum; + UINT32 i; + UINT32 Length; + UINT8 FileByte; + UINT8 Checksum; + + + /* Calculate the checksum over the entire definition block */ + + Sum = 0; + Length = sizeof (ACPI_TABLE_CDAT) + Op->Asl.AmlSubtreeLength; + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset); + + for (i = 0; i < Length; i++) + { + if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, + "Table length is greater than size of the input file"); + return; + } + + Sum = (signed char) (Sum + FileByte); + } + + Checksum = (UINT8) (0 - Sum); + + DbgPrint (ASL_DEBUG_OUTPUT, "Computed checksum = %X\n", Checksum); + + /* Re-write the checksum byte */ + + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + + ACPI_CDAT_OFFSET (Checksum)); + + FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1); + + /* + * Seek to the end of the file. This is done to support multiple file + * compilation. Doing this simplifies other parts of the codebase because + * it eliminates the need to seek for a different starting place. + */ + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + Length); +} + +/******************************************************************************* + * * FUNCTION: CgUpdateHeader * * PARAMETERS: Op - Op for the Definition Block diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 62d0f76da..f97cd9d82 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -291,7 +291,6 @@ CmDoCompile ( AslGbl_SyntaxError = FALSE; UtEndEvent (Event); UtEndEvent (FullCompile); - return (AE_OK); AslGbl_ParserErrorDetected = FALSE; AslGbl_SyntaxError = FALSE; diff --git a/source/compiler/aslhelp.c b/source/compiler/aslhelp.c index d83d41e3d..1cdbf8a76 100644 --- a/source/compiler/aslhelp.c +++ b/source/compiler/aslhelp.c @@ -262,6 +262,7 @@ Usage ( ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)"); ACPI_OPTION ("-df", "Force disassembler to assume table contains valid AML"); ACPI_OPTION ("-dl", "Emit legacy ASL code only (no C-style operators)"); + ACPI_OPTION ("-ds <signature(4)>", "Specify a table signature(4) (CDAT table only)"); ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file"); ACPI_OPTION ("-in", "Ignore NoOp opcodes"); diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 3c0678ce7..37484f79b 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -152,6 +152,7 @@ #include "aslcompiler.h" #include "acapps.h" #include "acdisasm.h" +#include "acglobal.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asloption") @@ -176,7 +177,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|t|T+G^v^w|x:z" +#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|:t|T+G^v^w|x:z" /******************************************************************************* @@ -366,7 +367,6 @@ AslDoOptions ( { return (-1); } - AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); break; @@ -445,6 +445,28 @@ AslDoOptions ( AcpiGbl_CstyleDisassembly = FALSE; break; + case 's': /* Specify table signature (Only supported for CDAT table) */ + + /* Get the required argument */ + + if (AcpiGetoptArgument (argc, argv)) + { + return (-1); + } + + /* Check for exact string "CDAT" (upper or lower case) */ + + AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg); + if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT)) + { + printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg); + return (-1); + } + + AcpiGbl_CDAT = malloc (5); + AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5); + break; + default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); @@ -837,7 +859,7 @@ AslDoOptions ( AslGbl_HexOutputFlag = HEX_OUTPUT_C; break; - case 'p': /* data table flex/bison prototype */ + case 'p': /* data table flex/bison prototype */ AslGbl_DtLexBisonPrototype = TRUE; break; diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index 45462adf9..9542a79d3 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -317,7 +317,7 @@ AslDetectSourceFileType ( else { fprintf (stderr, - "Binary file does not contain a valid ACPI table\n"); + "Binary file does not contain a valid standard ACPI table\n"); } Type = ASL_INPUT_TYPE_BINARY; diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 89eb937d5..11fcb8b9a 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -452,6 +452,48 @@ DtCompileDataTable ( } /* + * If the first field is named "CDAT Table Length" (not "Signature"), + * assume that we have a CDAT table (whose table header does not have + * a signature). Instead, the TableLength field is where the + * signature would (normally) be. + */ + else if (!strcmp ((*FieldList)->Name, "CDAT Table Length")) + { + /* No longer true: (However, use this technique in the disassembler) + * We are assuming that there + * should be at least one non-ASCII byte in the 4-character + * Signature field, (At least the high-order byte should be zero). + */ + Status = DtCompileTable (FieldList, AcpiDmTableInfoCdatTableHdr, + &AslGbl_RootTable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Compile the CDAT */ + + DtPushSubtable (AslGbl_RootTable); + Status = DtCompileCdat ((void **) FieldList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Set the overall table length and the table checksum. + * The entire compiled table (including the CDAT table header with + * the table length and checksum) is in AslGbl_RootTable->Buffer. + */ + DtSetTableLength (); + DtSetTableChecksum (&ACPI_CAST_PTR (ACPI_TABLE_CDAT, AslGbl_RootTable->Buffer)->Checksum); + + DtDumpFieldList (RootField); + DtDumpSubtableList (); + return (AE_OK); + } + + /* * All other tables must use the common ACPI table header. Insert the * current iASL IDs (name, version), and compile the header now. */ diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index d3afaed5d..e85ca5397 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -578,7 +578,7 @@ DtCompileAsf ( void **PFieldList); ACPI_STATUS -DtCompileCpep ( +DtCompileCdat ( void **PFieldList); ACPI_STATUS @@ -586,6 +586,10 @@ DtCompileCedt ( void **PFieldList); ACPI_STATUS +DtCompileCpep ( + void **PFieldList); + +ACPI_STATUS DtCompileCsrt ( void **PFieldList); @@ -774,6 +778,7 @@ extern const unsigned char TemplateBdat[]; extern const unsigned char TemplateBert[]; extern const unsigned char TemplateBgrt[]; extern const unsigned char TemplateCcel[]; +extern const unsigned char TemplateCdat[]; extern const unsigned char TemplateCedt[]; extern const unsigned char TemplateCpep[]; extern const unsigned char TemplateCsrt[]; diff --git a/source/compiler/dttable1.c b/source/compiler/dttable1.c index 9ac043506..592ae0921 100644 --- a/source/compiler/dttable1.c +++ b/source/compiler/dttable1.c @@ -657,6 +657,133 @@ DtCompileAsf ( /****************************************************************************** * + * FUNCTION: DtCompileCdat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CDAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCdat ( + void **List) +{ + ACPI_STATUS Status = AE_OK; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_CDAT_HEADER *CdatHeader; + ACPI_DMTABLE_INFO *InfoTable = NULL; + DT_FIELD *SubtableStart; + + + /* Walk the parse tree. + * + * Note: Main table consists of only the CDAT table header + * (This is not the standard ACPI table header, however)-- + * Followed by some number of subtables. + */ + while (*PFieldList) + { + SubtableStart = *PFieldList; + + /* Compile the expected CDAT Subtable header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCdatHeader, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + CdatHeader = ACPI_CAST_PTR (ACPI_CDAT_HEADER, Subtable->Buffer); + + /* Decode the subtable by type */ + + switch (CdatHeader->Type) + { + case ACPI_CDAT_TYPE_DSMAS: + InfoTable = AcpiDmTableInfoCdat0; + break; + + case ACPI_CDAT_TYPE_DSLBIS: + InfoTable = AcpiDmTableInfoCdat1; + break; + + case ACPI_CDAT_TYPE_DSMSCIS: + InfoTable = AcpiDmTableInfoCdat2; + break; + + case ACPI_CDAT_TYPE_DSIS: + InfoTable = AcpiDmTableInfoCdat3; + break; + + case ACPI_CDAT_TYPE_DSEMTS: + InfoTable = AcpiDmTableInfoCdat4; + break; + + case ACPI_CDAT_TYPE_SSLBIS: + InfoTable = AcpiDmTableInfoCdat5; + break; + + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "CDAT"); + } + + /* Compile the CDAT subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + switch (CdatHeader->Type) + { + /* Multiple entries supported for this type */ + + case ACPI_CDAT_TYPE_SSLBIS: + + /* + * Check for multiple SSLBEs + */ + while (*PFieldList && !AcpiUtStricmp ((*PFieldList)->Name, "Port X ID")) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoCdatEntries, &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + } + break; + + default: + break; + } + + /* Pop off the CDAT Subtable header subtree */ + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompileCedt * * PARAMETERS: List - Current field list pointer diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 9a4b2d910..3ab99978a 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -408,6 +408,39 @@ const unsigned char TemplateCedt[] = 0x03,0x5e,0xba,0x00 /* 00000198 ".^.." */ }; +const unsigned char TemplateCdat[] = +{ + 0xE4,0x00,0x00,0x00,0x01,0x0C,0x00,0x00, /* 00000000 "........" */ + 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, /* 00000008 "........" */ + 0x03,0x00,0x08,0x00,0x04,0x56,0x00,0x00, /* 00000010 ".....V.." */ + 0x00,0x00,0x18,0x00,0xEF,0x01,0x00,0x00, /* 00000018 "........" */ + 0x89,0x67,0x45,0x23,0x01,0x00,0x00,0x00, /* 00000020 ".gE#...." */ + 0xAB,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x03,0x00,0x08,0x00,0x04,0x56,0x00,0x00, /* 00000030 ".....V.." */ + 0x01,0x00,0x18,0x00,0x44,0x04,0x64,0x00, /* 00000038 "....D.d." */ + 0xCD,0xAB,0x89,0x67,0x45,0x23,0x01,0x00, /* 00000040 "...gE#.." */ + 0x33,0x22,0x44,0x33,0x55,0x44,0x00,0x00, /* 00000048 "3"D3UD.." */ + 0x02,0x00,0x14,0x00,0x99,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x78,0x56,0x34,0x12, /* 00000058 "....xV4." */ + 0x55,0x55,0x44,0x44,0x04,0x00,0x18,0x00, /* 00000060 "UUDD...." */ + 0x88,0x32,0x00,0x00,0x77,0x77,0x77,0x77, /* 00000068 ".2..wwww" */ + 0x11,0x11,0x11,0x11,0x88,0x88,0x88,0x88, /* 00000070 "........" */ + 0x22,0x22,0x22,0x22,0x05,0x00,0x20,0x00, /* 00000078 """"".. ." */ + 0x04,0x00,0x00,0x00,0x44,0x44,0x44,0x44, /* 00000080 "....DDDD" */ + 0x33,0x33,0x33,0x33,0x44,0x44,0x55,0x55, /* 00000088 "3333DDUU" */ + 0x66,0x66,0x00,0x00,0x77,0x77,0x88,0x88, /* 00000090 "ff..ww.." */ + 0x99,0x99,0x00,0x00,0x05,0x00,0x18,0x00, /* 00000098 "........" */ + 0x04,0x00,0x00,0x00,0x22,0x22,0x22,0x22, /* 000000A0 "....""""" */ + 0x11,0x11,0x11,0x11,0x34,0x12,0x56,0x78, /* 000000A8 "....4.Vx" */ + 0x11,0x11,0x00,0x00,0x05,0x00,0x30,0x00, /* 000000B0 "......0." */ + 0x08,0x00,0x00,0x00,0x66,0x66,0x66,0x66, /* 000000B8 "....ffff" */ + 0x55,0x55,0x55,0x55,0x44,0x44,0x55,0x55, /* 000000C0 "UUUUDDUU" */ + 0x66,0x66,0x00,0x00,0x77,0x77,0x88,0x88, /* 000000C8 "ff..ww.." */ + 0x99,0x99,0x00,0x00,0xAA,0xAA,0xBB,0xBB, /* 000000D0 "........" */ + 0xCC,0xCC,0x00,0x00,0x55,0x55,0x44,0x44, /* 000000D8 "....UUDD" */ + 0x33,0x33,0x00,0x00 /* 000000E0 "33.." */ +}; + const unsigned char TemplateCpep[] = { 0x43,0x50,0x45,0x50,0x34,0x00,0x00,0x00, /* 00000000 "CPEP4..." */ diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index e950763e7..45bff3df5 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -601,6 +601,7 @@ DtGetFieldLength ( case ACPI_DMT_AEST_XFACE: case ACPI_DMT_AEST_XRUPT: case ACPI_DMT_ASF: + case ACPI_DMT_CDAT: case ACPI_DMT_HESTNTYP: case ACPI_DMT_FADTPM: case ACPI_DMT_EINJACT: @@ -800,7 +801,7 @@ DtSum ( UINT8 *Sum = ReturnValue; - Checksum = AcpiTbChecksum (Subtable->Buffer, Subtable->Length); + Checksum = AcpiUtChecksum (Subtable->Buffer, Subtable->Length); *Sum = (UINT8) (*Sum + Checksum); } diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c index 5e4f7ca74..d974d951b 100644 --- a/source/components/tables/tbdata.c +++ b/source/components/tables/tbdata.c @@ -724,7 +724,7 @@ AcpiTbVerifyTempTable ( { /* Verify the checksum */ - Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + Status = AcpiUtVerifyChecksum (TableDesc->Pointer, TableDesc->Length); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 7ae35f190..97876614b 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -472,7 +472,7 @@ AcpiTbParseFadt ( * Validate the FADT checksum before we copy the table. Ignore * checksum error as we want to try to get the DSDT and FACS. */ - (void) AcpiTbVerifyChecksum (Table, Length); + (void) AcpiUtVerifyChecksum (Table, Length); /* Create a local copy of the FADT in common ACPI 2.0+ format */ diff --git a/source/components/tables/tbprint.c b/source/components/tables/tbprint.c index 0b53e7373..cdad69af4 100644 --- a/source/components/tables/tbprint.c +++ b/source/components/tables/tbprint.c @@ -152,6 +152,8 @@ #include "acpi.h" #include "accommon.h" #include "actables.h" +#include "acdisasm.h" +#include "acutils.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbprint") @@ -192,7 +194,7 @@ AcpiTbFixString ( while (Length && *String) { - if (!isprint ((int) *String)) + if (!isprint ((int) (UINT8) *String)) { *String = '?'; } @@ -293,89 +295,3 @@ AcpiTbPrintTableHeader ( } } - -/******************************************************************************* - * - * FUNCTION: AcpiTbValidateChecksum - * - * PARAMETERS: Table - ACPI table to verify - * Length - Length of entire table - * - * RETURN: Status - * - * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns - * exception on bad checksum. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbVerifyChecksum ( - ACPI_TABLE_HEADER *Table, - UINT32 Length) -{ - UINT8 Checksum; - - - /* - * FACS/S3PT: - * They are the odd tables, have no standard ACPI header and no checksum - */ - - if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_S3PT) || - ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS)) - { - return (AE_OK); - } - - /* Compute the checksum on the table */ - - Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length); - - /* Checksum ok? (should be zero) */ - - if (Checksum) - { - ACPI_BIOS_WARNING ((AE_INFO, - "Incorrect checksum in table [%4.4s] - 0x%2.2X, " - "should be 0x%2.2X", - Table->Signature, Table->Checksum, - (UINT8) (Table->Checksum - Checksum))); - -#if (ACPI_CHECKSUM_ABORT) - return (AE_BAD_CHECKSUM); -#endif - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbChecksum - * - * PARAMETERS: Buffer - Pointer to memory region to be checked - * Length - Length of this memory region - * - * RETURN: Checksum (UINT8) - * - * DESCRIPTION: Calculates circular checksum of memory region. - * - ******************************************************************************/ - -UINT8 -AcpiTbChecksum ( - UINT8 *Buffer, - UINT32 Length) -{ - UINT8 Sum = 0; - UINT8 *End = Buffer + Length; - - - while (Buffer < End) - { - Sum = (UINT8) (Sum + *(Buffer++)); - } - - return (Sum); -} diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c index d2a30dc38..5188d26da 100644 --- a/source/components/tables/tbutils.c +++ b/source/components/tables/tbutils.c @@ -471,7 +471,7 @@ AcpiTbParseRootTable ( /* Validate the root table checksum */ - Status = AcpiTbVerifyChecksum (Table, Length); + Status = AcpiUtVerifyChecksum (Table, Length); if (ACPI_FAILURE (Status)) { AcpiOsUnmapMemory (Table, Length); diff --git a/source/components/tables/tbxfroot.c b/source/components/tables/tbxfroot.c index aebadac5b..97cb65c79 100644 --- a/source/components/tables/tbxfroot.c +++ b/source/components/tables/tbxfroot.c @@ -227,7 +227,7 @@ AcpiTbValidateRsdp ( /* Check the standard checksum */ - if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + if (AcpiUtChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { return (AE_BAD_CHECKSUM); } @@ -235,7 +235,7 @@ AcpiTbValidateRsdp ( /* Check extended checksum if table version >= 2 */ if ((Rsdp->Revision >= 2) && - (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + (AcpiUtChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { return (AE_BAD_CHECKSUM); } diff --git a/source/components/utilities/utcksum.c b/source/components/utilities/utcksum.c new file mode 100755 index 000000000..b8ea869ba --- /dev/null +++ b/source/components/utilities/utcksum.c @@ -0,0 +1,335 @@ +/****************************************************************************** + * + * Module Name: utcksum - Support generating table checksums + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + ***************************************************************************** + * + * Alternatively, you may choose to be licensed under the terms of the + * following license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, you may choose to be licensed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acdisasm.h" +#include "acutils.h" + + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_CA_DISASSEMBLER + ACPI_MODULE_NAME ("utcksum") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtVerifyChecksum + * + * PARAMETERS: Table - ACPI table to verify + * Length - Length of entire table + * + * RETURN: Status + * + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns + * exception on bad checksum. + * Note: We don't have to check for a CDAT here, since CDAT is + * not in the RSDT/XSDT, and the CDAT table is never installed + * via ACPICA. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + UINT8 Checksum; + + + /* + * FACS/S3PT: + * They are the odd tables, have no standard ACPI header and no checksum + */ + if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_S3PT) || + ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS)) + { + return (AE_OK); + } + + /* Compute the checksum on the table */ + + Length = Table->Length; + Checksum = AcpiUtGenerateChecksum (ACPI_CAST_PTR (UINT8, Table), Length, Table->Checksum); + + /* Computed checksum matches table? */ + + if (Checksum != Table->Checksum) + { + ACPI_BIOS_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - 0x%2.2X, " + "should be 0x%2.2X", + Table->Signature, Table->Checksum, + Table->Checksum - Checksum)); + +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtVerifyCdatChecksum + * + * PARAMETERS: Table - CDAT ACPI table to verify + * Length - Length of entire table + * + * RETURN: Status + * + * DESCRIPTION: Verifies that the CDAT table checksums to zero. Optionally + * returns an exception on bad checksum. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtVerifyCdatChecksum ( + ACPI_TABLE_CDAT *CdatTable, + UINT32 Length) +{ + UINT8 Checksum; + + + /* Compute the checksum on the table */ + + Checksum = AcpiUtGenerateChecksum (ACPI_CAST_PTR (UINT8, CdatTable), + CdatTable->Length, CdatTable->Checksum); + + /* Computed checksum matches table? */ + + if (Checksum != CdatTable->Checksum) + { + ACPI_BIOS_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - 0x%2.2X, " + "should be 0x%2.2X", + AcpiGbl_CDAT, CdatTable->Checksum, Checksum)); + +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif + } + + CdatTable->Checksum = Checksum; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGenerateChecksum + * + * PARAMETERS: Table - Pointer to table to be checksummed + * Length - Length of the table + * OriginalChecksum - Value of the checksum field + * + * RETURN: 8 bit checksum of buffer + * + * DESCRIPTION: Computes an 8 bit checksum of the table. + * + ******************************************************************************/ + +UINT8 +AcpiUtGenerateChecksum ( + void *Table, + UINT32 Length, + UINT8 OriginalChecksum) +{ + UINT8 Checksum; + + + /* Sum the entire table as-is */ + + Checksum = AcpiUtChecksum ((UINT8 *) Table, Length); + + /* Subtract off the existing checksum value in the table */ + + Checksum = (UINT8) (Checksum - OriginalChecksum); + + /* Compute and return the final checksum */ + + Checksum = (UINT8) (0 - Checksum); + return (Checksum); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtChecksum + * + * PARAMETERS: Buffer - Pointer to memory region to be checked + * Length - Length of this memory region + * + * RETURN: Checksum (UINT8) + * + * DESCRIPTION: Calculates circular checksum of memory region. + * + ******************************************************************************/ + +UINT8 +AcpiUtChecksum ( + UINT8 *Buffer, + UINT32 Length) +{ + UINT8 Sum = 0; + UINT8 *End = Buffer + Length; + + + while (Buffer < End) + { + Sum = (UINT8) (Sum + *(Buffer++)); + } + + return (Sum); +} diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index e9e15c69a..47ce0b15b 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -260,6 +260,7 @@ typedef enum ACPI_DMT_AEST_XRUPT, ACPI_DMT_AGDI, ACPI_DMT_ASF, + ACPI_DMT_CDAT, ACPI_DMT_CEDT, ACPI_DMT_DMAR, ACPI_DMT_DMAR_SCOPE, @@ -403,6 +404,15 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoBert[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoBgrt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoCcel[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdatTableHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdatHeader[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdat5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCdatEntries[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoCedtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoCedt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoCedt1[]; @@ -753,6 +763,10 @@ AcpiDmDumpCcel ( ACPI_TABLE_HEADER *Table); void +AcpiDmDumpCdat ( + ACPI_TABLE_HEADER *Table); + +void AcpiDmDumpCedt ( ACPI_TABLE_HEADER *Table); diff --git a/source/include/acglobal.h b/source/include/acglobal.h index b8831b467..1850d94be 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -167,6 +167,7 @@ ACPI_GLOBAL (ACPI_TABLE_LIST, AcpiGbl_RootTableList); ACPI_GLOBAL (ACPI_TABLE_HEADER *, AcpiGbl_DSDT); ACPI_GLOBAL (ACPI_TABLE_HEADER, AcpiGbl_OriginalDsdtHeader); +ACPI_INIT_GLOBAL (char *, AcpiGbl_CDAT, NULL); ACPI_INIT_GLOBAL (UINT32, AcpiGbl_DsdtIndex, ACPI_INVALID_TABLE_INDEX); ACPI_INIT_GLOBAL (UINT32, AcpiGbl_FacsIndex, ACPI_INVALID_TABLE_INDEX); ACPI_INIT_GLOBAL (UINT32, AcpiGbl_XFacsIndex, ACPI_INVALID_TABLE_INDEX); diff --git a/source/include/actables.h b/source/include/actables.h index 40b79a47c..e9b070f91 100644 --- a/source/include/actables.h +++ b/source/include/actables.h @@ -345,16 +345,6 @@ AcpiTbPrintTableHeader( ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER *Header); -UINT8 -AcpiTbChecksum ( - UINT8 *Buffer, - UINT32 Length); - -ACPI_STATUS -AcpiTbVerifyChecksum ( - ACPI_TABLE_HEADER *Table, - UINT32 Length); - void AcpiTbCheckDsdtHeader ( void); diff --git a/source/include/actbinfo.h b/source/include/actbinfo.h index 9f0d5867f..53a73cb20 100644 --- a/source/include/actbinfo.h +++ b/source/include/actbinfo.h @@ -153,6 +153,7 @@ * Macros used to generate offsets to specific table fields */ #define ACPI_AGDI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_AGDI,f) +//define ACPI_CDAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_CDAT,f) #define ACPI_FACS_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_FACS,f) #define ACPI_GAS_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GENERIC_ADDRESS,f) #define ACPI_HDR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_HEADER,f) @@ -234,6 +235,15 @@ #define ACPI_ASF2a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_ASF_CONTROL_DATA,f) #define ACPI_ASF3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_ASF_RMCP,f) #define ACPI_ASF4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_ASF_ADDRESS,f) +#define ACPI_CDAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_CDAT,f) +#define ACPI_CDATH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_HEADER,f) +#define ACPI_CDAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_DSMAS,f) +#define ACPI_CDAT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_DSLBIS,f) +#define ACPI_CDAT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_DSMSCIS,f) +#define ACPI_CDAT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_DSIS,f) +#define ACPI_CDAT4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_DSEMTS,f) +#define ACPI_CDAT5_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_SSLBIS,f) +#define ACPI_CDATE_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CDAT_SSLBE,f) #define ACPI_CEDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CEDT_HEADER, f) #define ACPI_CEDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CEDT_CHBS, f) #define ACPI_CEDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_CEDT_CFMWS, f) diff --git a/source/include/actbl1.h b/source/include/actbl1.h index 3de78b0d8..1040226a8 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -189,6 +189,7 @@ #define ACPI_SIG_HMAT "HMAT" /* Heterogeneous Memory Attributes Table */ #define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ #define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table*/ #define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ #define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ @@ -494,12 +495,154 @@ typedef struct acpi_table_boot } ACPI_TABLE_BOOT; + +/******************************************************************************* + * + * CDAT - Coherent Device Attribute Table + * Version 1 + * + * Conforms to the "Coherent Device Attribute Table (CDAT) Specification + " (Revision 1.01, October 2020.) + * + ******************************************************************************/ + +typedef struct acpi_table_cdat +{ + UINT32 Length; /* Length of table in bytes, including this header */ + UINT8 Revision; /* ACPI Specification minor version number */ + UINT8 Checksum; /* To make sum of entire table == 0 */ + UINT8 Reserved[6]; + UINT32 Sequence; /* Used to detect runtime CDAT table changes */ + +} ACPI_TABLE_CDAT; + + +/* CDAT common subtable header */ + +typedef struct acpi_cdat_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_CDAT_HEADER; + +/* Values for Type field above */ + +enum AcpiCdatType +{ + ACPI_CDAT_TYPE_DSMAS = 0, + ACPI_CDAT_TYPE_DSLBIS = 1, + ACPI_CDAT_TYPE_DSMSCIS = 2, + ACPI_CDAT_TYPE_DSIS = 3, + ACPI_CDAT_TYPE_DSEMTS = 4, + ACPI_CDAT_TYPE_SSLBIS = 5, + ACPI_CDAT_TYPE_RESERVED = 6 /* 6 through 0xFF are reserved */ +}; + + +/* Subtable 0: Device Scoped Memory Affinity Structure (DSMAS) */ + +typedef struct acpi_cadt_dsmas +{ + UINT8 DsmadHandle; + UINT8 Flags; + UINT16 Reserved; + UINT64 DpaBaseAddress; + UINT64 DpaLength; + +} ACPI_CDAT_DSMAS; + +/* Flags for subtable above */ + +#define ACPI_CEDT_DSMAS_NON_VOLATILE (1 << 2) + + +/* Subtable 1: Device scoped Latency and Bandwidth Information Structure (DSLBIS) */ + +typedef struct acpi_cdat_dslbis +{ + UINT8 Handle; + UINT8 Flags; /* If Handle matches a DSMAS handle, the definition of this field matches + * Flags field in HMAT System Locality Latency */ + UINT8 DataType; + UINT8 Reserved; + UINT64 EntryBaseUnit; + UINT16 Entry[3]; + UINT16 Reserved2; + +} ACPI_CDAT_DSLBIS; + + +/* Subtable 2: Device Scoped Memory Side Cache Information Structure (DSMSCIS) */ + +typedef struct acpi_cdat_dsmscis +{ + UINT8 DsmasHandle; + UINT8 Reserved[3]; + UINT64 SideCacheSize; + UINT32 CacheAttributes; + +} ACPI_CDAT_DSMSCIS; + + +/* Subtable 3: Device Scoped Initiator Structure (DSIS) */ + +typedef struct acpi_cdat_dsis +{ + UINT8 Flags; + UINT8 Handle; + UINT16 Reserved; + +} ACPI_CDAT_DSIS; + +/* Flags for above subtable */ + +#define ACPI_CDAT_DSIS_MEM_ATTACHED (1 << 0) + + +/* Subtable 4: Device Scoped EFI Memory Type Structure (DSEMTS) */ + +typedef struct acpi_cdat_dsemts +{ + UINT8 DsmasHandle; + UINT8 MemoryType; + UINT16 Reserved; + UINT64 DpaOffset; + UINT64 RangeLength; + +} ACPI_CDAT_DSEMTS; + + +/* Subtable 5: Switch Scoped Latency and Bandwidth Information Structure (SSLBIS) */ + +typedef struct acpi_cdat_sslbis +{ + UINT8 DataType; + UINT8 Reserved[3]; + UINT64 EntryBaseUnit; + +} ACPI_CDAT_SSLBIS; + + +/* Sub-subtable for above, SslbeEntries field */ + +typedef struct acpi_cdat_sslbe +{ + UINT16 PortxId; + UINT16 PortyId; + UINT16 LatencyOrBandwidth; + UINT16 Reserved; + +} ACPI_CDAT_SSLBE; + + /******************************************************************************* * * CEDT - CXL Early Discovery Table * Version 1 * - * Conforms to the "CXL Early Discovery Table" (CXL 2.0) + * Conforms to the "CXL Early Discovery Table" (CXL 2.0, October 2020) * ******************************************************************************/ diff --git a/source/include/actbl2.h b/source/include/actbl2.h index 67de89db8..74d292581 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -172,6 +172,7 @@ #define ACPI_SIG_APMT "APMT" /* Arm Performance Monitoring Unit table */ #define ACPI_SIG_BDAT "BDAT" /* BIOS Data ACPI Table */ #define ACPI_SIG_CCEL "CCEL" /* CC Event Log Table */ +#define ACPI_SIG_CDAT "CDAT" /* Coherent Device Attribute Table */ #define ACPI_SIG_IORT "IORT" /* IO Remapping Table */ #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ #define ACPI_SIG_LPIT "LPIT" /* Low Power Idle Table */ @@ -179,7 +180,6 @@ #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ #define ACPI_SIG_MPST "MPST" /* Memory Power State Table */ -#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ #define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ #define ACPI_SIG_NFIT "NFIT" /* NVDIMM Firmware Interface Table */ #define ACPI_SIG_NHLT "NHLT" /* Non HD Audio Link Table */ diff --git a/source/include/acutils.h b/source/include/acutils.h index f23ee559b..a0e7953b1 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -318,6 +318,31 @@ AcpiUtCheckAndRepairAscii ( /* + * utcksum - Checksum utilities + */ +UINT8 +AcpiUtGenerateChecksum ( + void *Table, + UINT32 Length, + UINT8 OriginalChecksum); + +UINT8 +AcpiUtChecksum ( + UINT8 *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiUtVerifyCdatChecksum ( + ACPI_TABLE_CDAT *CdatTable, + UINT32 Length); + +ACPI_STATUS +AcpiUtVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + + +/* * utnonansi - Non-ANSI C library functions */ void diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index d66832d1a..0cf8d00ab 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -234,7 +234,9 @@ ApIsValidChecksum ( } else { - Status = AcpiTbVerifyChecksum (Table, Table->Length); + /* We don't have to check for a CDAT here, since CDAT is not in the RSDT/XSDT */ + + Status = AcpiUtVerifyChecksum (Table, Table->Length); } if (ACPI_FAILURE (Status)) diff --git a/source/tools/acpiexec/aetables.c b/source/tools/acpiexec/aetables.c index 97f4fb73a..c758084ce 100644 --- a/source/tools/acpiexec/aetables.c +++ b/source/tools/acpiexec/aetables.c @@ -267,7 +267,7 @@ AeInitializeTableHeader ( /* Set the checksum, must set to zero first */ Header->Checksum = 0; - Header->Checksum = (UINT8) -AcpiTbChecksum ( + Header->Checksum = (UINT8) -AcpiUtChecksum ( (void *) Header, Header->Length); } @@ -420,7 +420,7 @@ AeBuildLocalTables ( AeInitializeTableHeader ((void *) LocalXSDT, ACPI_SIG_XSDT, XsdtSize); LocalRSDP.Checksum = 0; - LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ( + LocalRSDP.Checksum = (UINT8) -AcpiUtChecksum ( (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH); if (!DsdtAddress) @@ -471,7 +471,7 @@ AeBuildLocalTables ( /* Complete the external FADT with the checksum */ ExternalFadt->Header.Checksum = 0; - ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + ExternalFadt->Header.Checksum = (UINT8) -AcpiUtChecksum ( (void *) ExternalFadt, ExternalFadt->Header.Length); } else if (AcpiGbl_UseHwReducedFadt) @@ -551,7 +551,7 @@ AeBuildLocalTables ( LocalTEST.Length = sizeof (ACPI_TABLE_HEADER); LocalTEST.Checksum = 0; - LocalTEST.Checksum = (UINT8) -AcpiTbChecksum ( + LocalTEST.Checksum = (UINT8) -AcpiUtChecksum ( (void *) &LocalTEST, LocalTEST.Length); /* @@ -565,7 +565,7 @@ AeBuildLocalTables ( LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER); LocalBADTABLE.Checksum = 0; - LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum ( + LocalBADTABLE.Checksum = (UINT8) -AcpiUtChecksum ( (void *) &LocalBADTABLE, LocalBADTABLE.Length); } diff --git a/source/tools/examples/extables.c b/source/tools/examples/extables.c index 9f2bcc108..8633788ea 100644 --- a/source/tools/examples/extables.c +++ b/source/tools/examples/extables.c @@ -315,19 +315,19 @@ ExInitializeAcpiTables ( /* Set new checksums for the modified tables */ Rsdp->Checksum = 0; - Rsdp->Checksum = (UINT8) -AcpiTbChecksum ( + Rsdp->Checksum = (UINT8) -AcpiUtChecksum ( (void *) RsdpCode, ACPI_RSDP_CHECKSUM_LENGTH); Rsdt->Header.Checksum = 0; - Rsdt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + Rsdt->Header.Checksum = (UINT8) -AcpiUtChecksum ( (void *) Rsdt, Rsdt->Header.Length); Xsdt->Header.Checksum = 0; - Xsdt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + Xsdt->Header.Checksum = (UINT8) -AcpiUtChecksum ( (void *) Xsdt, Xsdt->Header.Length); Fadt->Header.Checksum = 0; - Fadt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + Fadt->Header.Checksum = (UINT8) -AcpiUtChecksum ( (void *) Fadt, Fadt->Header.Length); } |