diff options
Diffstat (limited to 'source/tools/acpidump/apdump.c')
-rw-r--r-- | source/tools/acpidump/apdump.c | 145 |
1 files changed, 114 insertions, 31 deletions
diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index 5000e4d..6317b25 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -49,6 +49,7 @@ static int ApDumpTableBuffer ( ACPI_TABLE_HEADER *Table, + UINT32 Instance, ACPI_PHYSICAL_ADDRESS Address); @@ -68,26 +69,111 @@ BOOLEAN ApIsValidHeader ( ACPI_TABLE_HEADER *Table) { + if (!ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + /* Make sure signature is all ASCII and a valid ACPI name */ + + if (!AcpiUtValidAcpiName (Table->Signature)) + { + fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", + *(UINT32 *) Table->Signature); + return (FALSE); + } + + /* Check for minimum table length */ + + if (Table->Length <= sizeof (ACPI_TABLE_HEADER)) + { + fprintf (stderr, "Table length (0x%8.8X) is invalid\n", + Table->Length); + return (FALSE); + } + } - /* Make sure signature is all ASCII and a valid ACPI name */ + return (TRUE); +} + + +/****************************************************************************** + * + * FUNCTION: ApIsValidChecksum + * + * PARAMETERS: Table - Pointer to table to be validated + * + * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI table checksum + * + ******************************************************************************/ + +BOOLEAN +ApIsValidChecksum ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_TABLE_RSDP *Rsdp; + + + if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + /* + * Checksum for RSDP. + * Note: Other checksums are computed during the table dump. + */ + + Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); + Status = AcpiTbValidateRsdp (Rsdp); + } + else + { + Status = AcpiTbVerifyChecksum (Table, Table->Length); + } - if (!AcpiUtValidAcpiName (Table->Signature)) + if (ACPI_FAILURE (Status)) { - fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", - *(UINT32 *) Table->Signature); - return (FALSE); + fprintf (stderr, "%4.4s: Warning: wrong checksum\n", + Table->Signature); } - /* Check for minimum table length */ + return (AE_OK); +} + - if (Table->Length <= sizeof (ACPI_TABLE_HEADER)) +/****************************************************************************** + * + * FUNCTION: ApGetTableLength + * + * PARAMETERS: Table - Pointer to the table + * + * RETURN: Table length + * + * DESCRIPTION: Obtain table length according to table signature + * + ******************************************************************************/ + +UINT32 +ApGetTableLength ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_TABLE_RSDP *Rsdp; + + + /* Check if table is valid */ + + if (!ApIsValidHeader (Table)) { - fprintf (stderr, "Table length (0x%8.8X) is invalid\n", - Table->Length); - return (FALSE); + return (0); } - return (TRUE); + if (ACPI_VALIDATE_RSDP_SIG (Table->Signature)) + { + Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); + return (Rsdp->Length); + } + else + { + return (Table->Length); + } } @@ -96,6 +182,7 @@ ApIsValidHeader ( * FUNCTION: ApDumpTableBuffer * * PARAMETERS: Table - ACPI table to be dumped + * Instance - ACPI table instance no. to be dumped * Address - Physical address of the table * * RETURN: None @@ -108,22 +195,13 @@ ApIsValidHeader ( static int ApDumpTableBuffer ( ACPI_TABLE_HEADER *Table, + UINT32 Instance, ACPI_PHYSICAL_ADDRESS Address) { + UINT32 TableLength; - /* Check if the table header appears to be valid */ - - if (!ApIsValidHeader (Table)) - { - return (-1); - } - - /* Validate the table checksum (except FACS - has no checksum) */ - if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) - { - (void) AcpiTbVerifyChecksum (Table, Table->Length); - } + TableLength = ApGetTableLength (Table); /* Print only the header if requested */ @@ -137,7 +215,7 @@ ApDumpTableBuffer ( if (Gbl_BinaryMode) { - return (ApWriteToBinaryFile (Table)); + return (ApWriteToBinaryFile (Table, Instance)); } /* @@ -148,7 +226,7 @@ ApDumpTableBuffer ( printf ("%4.4s @ 0x%8.8X%8.8X\n", Table->Signature, ACPI_FORMAT_UINT64 (Address)); - AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), Table->Length, + AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table), TableLength, DB_BYTE_DISPLAY, 0); printf ("\n"); return (0); @@ -173,6 +251,7 @@ ApDumpAllTables ( void) { ACPI_TABLE_HEADER *Table; + UINT32 Instance = 0; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; UINT32 i; @@ -182,7 +261,7 @@ ApDumpAllTables ( for (i = 0; i < AP_MAX_ACPI_FILES; i++) { - Status = AcpiOsGetTableByIndex (i, &Table, &Address); + Status = AcpiOsGetTableByIndex (i, &Table, &Instance, &Address); if (ACPI_FAILURE (Status)) { /* AE_LIMIT means that no more tables are available */ @@ -205,7 +284,7 @@ ApDumpAllTables ( } } - if (ApDumpTableBuffer (Table, Address)) + if (ApDumpTableBuffer (Table, Instance, Address)) { return (-1); } @@ -261,7 +340,7 @@ ApDumpTableByAddress ( return (-1); } - TableStatus = ApDumpTableBuffer (Table, Address); + TableStatus = ApDumpTableBuffer (Table, 0, Address); free (Table); return (TableStatus); } @@ -306,7 +385,11 @@ ApDumpTableByName ( /* To be friendly, handle tables whose signatures do not match the name */ - if (ACPI_COMPARE_NAME (LocalSignature, "FADT")) + if (ACPI_COMPARE_NAME (LocalSignature, AP_DUMP_SIG_RSDP)) + { + strcpy (LocalSignature, AP_DUMP_SIG_RSDP); + } + else if (ACPI_COMPARE_NAME (LocalSignature, "FADT")) { strcpy (LocalSignature, ACPI_SIG_FADT); } @@ -336,7 +419,7 @@ ApDumpTableByName ( return (-1); } - if (ApDumpTableBuffer (Table, Address)) + if (ApDumpTableBuffer (Table, Instance, Address)) { return (-1); } @@ -395,7 +478,7 @@ ApDumpTableFromFile ( Pathname, Table->Signature, FileSize, FileSize); } - TableStatus = ApDumpTableBuffer (Table, 0); + TableStatus = ApDumpTableBuffer (Table, 0, 0); free (Table); return (TableStatus); } |