mirror of
https://github.com/acpica/acpica/
synced 2025-01-27 19:55:25 +03:00
Tables: Cleanup table checksum verification code.
This patch reduces code redundancy by moving the FACS/S3PT checksum verification skip logic into AcpiTbVerifyChecksum(). This patch also adds ApIsValidChecksum() to be called by AcpiDump OSL codes to verify the checksum of RSDP and tables. Lv Zheng.
This commit is contained in:
parent
b39ecb7097
commit
5041f3c13d
@ -347,11 +347,9 @@ AcpiDbReadTable (
|
||||
|
||||
fseek (fp, 0, SEEK_SET);
|
||||
|
||||
/* The RSDT, FACS and S3PT tables do not have standard ACPI headers */
|
||||
/* The RSDP table does not have standard ACPI header */
|
||||
|
||||
if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") ||
|
||||
ACPI_COMPARE_NAME (TableHeader.Signature, "FACS") ||
|
||||
ACPI_COMPARE_NAME (TableHeader.Signature, "S3PT"))
|
||||
if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD "))
|
||||
{
|
||||
*TableLength = FileSize;
|
||||
StandardHeader = FALSE;
|
||||
|
@ -165,14 +165,9 @@ AcpiTbVerifyTable (
|
||||
}
|
||||
}
|
||||
|
||||
/* FACS is the odd table, has no standard ACPI header and no checksum */
|
||||
/* Always calculate checksum, ignore bad checksum if requested */
|
||||
|
||||
if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
|
||||
{
|
||||
/* Always calculate checksum, ignore bad checksum if requested */
|
||||
|
||||
Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
|
||||
}
|
||||
Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
@ -283,6 +283,17 @@ AcpiTbVerifyChecksum (
|
||||
UINT8 Checksum;
|
||||
|
||||
|
||||
/*
|
||||
* FACS/S3PT:
|
||||
* They are the odd tables, have no standard ACPI header and no checksum
|
||||
*/
|
||||
|
||||
if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT) ||
|
||||
ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
|
||||
{
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
/* Compute the checksum on the table */
|
||||
|
||||
Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length);
|
||||
|
@ -950,18 +950,9 @@ OslMapTable (
|
||||
return (AE_BAD_ADDRESS);
|
||||
}
|
||||
|
||||
(void) ApIsValidChecksum (MappedTable);
|
||||
|
||||
*Table = MappedTable;
|
||||
|
||||
/*
|
||||
* Checksum for RSDP.
|
||||
* Note: Other checksums are computed during the table dump.
|
||||
*/
|
||||
|
||||
if (AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MappedTable)) ==
|
||||
AE_BAD_CHECKSUM)
|
||||
{
|
||||
fprintf (stderr, "Warning: wrong checksum for RSDP\n");
|
||||
}
|
||||
|
||||
return (AE_OK);
|
||||
}
|
||||
|
@ -999,16 +999,7 @@ OslMapTable (
|
||||
|
||||
*Table = MappedTable;
|
||||
|
||||
/*
|
||||
* Checksum for RSDP.
|
||||
* Note: Other checksums are computed during the table dump.
|
||||
*/
|
||||
|
||||
if (AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MappedTable)) ==
|
||||
AE_BAD_CHECKSUM)
|
||||
{
|
||||
fprintf (stderr, "Warning: wrong checksum for RSDP\n");
|
||||
}
|
||||
(void) ApIsValidChecksum (MappedTable);
|
||||
|
||||
return (AE_OK);
|
||||
}
|
||||
@ -1213,17 +1204,9 @@ OslReadTableFromFile (
|
||||
Total += Count;
|
||||
}
|
||||
|
||||
/* Validate checksum, except for special tables */
|
||||
/* Validate checksum */
|
||||
|
||||
if (!ACPI_COMPARE_NAME (Header.Signature, ACPI_SIG_S3PT) &&
|
||||
!ACPI_COMPARE_NAME (Header.Signature, ACPI_SIG_FACS))
|
||||
{
|
||||
if (AcpiTbChecksum ((UINT8 *) LocalTable, TableLength))
|
||||
{
|
||||
fprintf (stderr, "%4.4s: Warning: wrong checksum\n",
|
||||
Header.Signature);
|
||||
}
|
||||
}
|
||||
(void) ApIsValidChecksum (LocalTable);
|
||||
|
||||
ErrorExit:
|
||||
fclose (TableFile);
|
||||
|
@ -201,6 +201,10 @@ BOOLEAN
|
||||
ApIsValidHeader (
|
||||
ACPI_TABLE_HEADER *Table);
|
||||
|
||||
BOOLEAN
|
||||
ApIsValidChecksum (
|
||||
ACPI_TABLE_HEADER *Table);
|
||||
|
||||
|
||||
/*
|
||||
* apfiles - File I/O utilities
|
||||
|
@ -163,6 +163,50 @@ ApIsValidHeader (
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP))
|
||||
{
|
||||
/*
|
||||
* 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 (ACPI_FAILURE (Status))
|
||||
{
|
||||
fprintf (stderr, "%4.4s: Warning: wrong checksum\n",
|
||||
Table->Signature);
|
||||
}
|
||||
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: ApDumpTableBuffer
|
||||
@ -190,13 +234,6 @@ ApDumpTableBuffer (
|
||||
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);
|
||||
}
|
||||
|
||||
/* Print only the header if requested */
|
||||
|
||||
if (Gbl_SummaryMode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user