diff options
Diffstat (limited to 'sys/contrib/dev/acpica/tbutils.c')
-rw-r--r-- | sys/contrib/dev/acpica/tbutils.c | 145 |
1 files changed, 115 insertions, 30 deletions
diff --git a/sys/contrib/dev/acpica/tbutils.c b/sys/contrib/dev/acpica/tbutils.c index b91d578c4299..3429ebf3d061 100644 --- a/sys/contrib/dev/acpica/tbutils.c +++ b/sys/contrib/dev/acpica/tbutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbutils - Table manipulation utilities - * $Revision: 61 $ + * $Revision: 1.71 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,49 +123,82 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbutils") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc); +#endif + /******************************************************************************* * - * FUNCTION: AcpiTbHandleToObject + * FUNCTION: AcpiTbIsTableInstalled * - * PARAMETERS: TableId - Id for which the function is searching - * TableDesc - Pointer to return the matching table - * descriptor. + * PARAMETERS: NewTableDesc - Descriptor for new table being installed * - * RETURN: Search the tables to find one with a matching TableId and - * return a pointer to that table descriptor. + * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed + * + * DESCRIPTION: Determine if an ACPI table is already installed + * + * MUTEX: Table data structures should be locked * ******************************************************************************/ ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **ReturnTableDesc) +AcpiTbIsTableInstalled ( + ACPI_TABLE_DESC *NewTableDesc) { - UINT32 i; ACPI_TABLE_DESC *TableDesc; - ACPI_FUNCTION_NAME ("TbHandleToObject"); + ACPI_FUNCTION_TRACE ("TbIsTableInstalled"); - for (i = 0; i < ACPI_TABLE_MAX; i++) + /* Get the list descriptor and first table descriptor */ + + TableDesc = AcpiGbl_TableLists[NewTableDesc->Type].Next; + + /* Examine all installed tables of this type */ + + while (TableDesc) { - TableDesc = AcpiGbl_TableLists[i].Next; - while (TableDesc) + /* + * If the table lengths match, perform a full bytewise compare. This + * means that we will allow tables with duplicate OemTableId(s), as + * long as the tables are different in some way. + * + * Checking if the table has been loaded into the namespace means that + * we don't check for duplicate tables during the initial installation + * of tables within the RSDT/XSDT. + */ + if ((TableDesc->LoadedIntoNamespace) && + (TableDesc->Pointer->Length == NewTableDesc->Pointer->Length) && + (!ACPI_MEMCMP (TableDesc->Pointer, NewTableDesc->Pointer, + NewTableDesc->Pointer->Length))) { - if (TableDesc->TableId == TableId) - { - *ReturnTableDesc = TableDesc; - return (AE_OK); - } + /* Match: this table is already installed */ - TableDesc = TableDesc->Next; + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Table [%4.4s] already installed: Rev %X OemTableId [%8.8s]\n", + NewTableDesc->Pointer->Signature, + NewTableDesc->Pointer->Revision, + NewTableDesc->Pointer->OemTableId)); + + NewTableDesc->OwnerId = TableDesc->OwnerId; + NewTableDesc->InstalledDesc = TableDesc; + + return_ACPI_STATUS (AE_ALREADY_EXISTS); } + + /* Get next table on the list */ + + TableDesc = TableDesc->Next; } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); - return (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_OK); } @@ -205,6 +238,7 @@ AcpiTbValidateTableHeader ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot read table header at %p\n", TableHeader)); + return (AE_BAD_ADDRESS); } @@ -219,6 +253,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", (char *) &Signature)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_SIGNATURE); } @@ -233,6 +268,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", (UINT32) TableHeader->Length)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_HEADER); } @@ -267,14 +303,16 @@ AcpiTbVerifyTableChecksum ( /* Compute the checksum on the table */ - Checksum = AcpiTbChecksum (TableHeader, TableHeader->Length); + Checksum = AcpiTbGenerateChecksum (TableHeader, TableHeader->Length); /* Return the appropriate exception */ if (Checksum) { - ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", - TableHeader->Signature, (UINT32) TableHeader->Checksum, (UINT32) Checksum)); + ACPI_REPORT_WARNING (( + "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", + TableHeader->Signature, (UINT32) TableHeader->Checksum, + (UINT32) Checksum)); Status = AE_BAD_CHECKSUM; } @@ -284,19 +322,19 @@ AcpiTbVerifyTableChecksum ( /******************************************************************************* * - * FUNCTION: AcpiTbChecksum + * FUNCTION: AcpiTbGenerateChecksum * * PARAMETERS: Buffer - Buffer to checksum * Length - Size of the buffer * - * RETURNS 8 bit checksum of buffer + * RETURN: 8 bit checksum of buffer * * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. * ******************************************************************************/ UINT8 -AcpiTbChecksum ( +AcpiTbGenerateChecksum ( void *Buffer, UINT32 Length) { @@ -320,3 +358,50 @@ AcpiTbChecksum ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiTbHandleToObject + * + * PARAMETERS: TableId - Id for which the function is searching + * TableDesc - Pointer to return the matching table + * descriptor. + * + * RETURN: Search the tables to find one with a matching TableId and + * return a pointer to that table descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **ReturnTableDesc) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + + + ACPI_FUNCTION_NAME ("TbHandleToObject"); + + + for (i = 0; i < ACPI_TABLE_MAX; i++) + { + TableDesc = AcpiGbl_TableLists[i].Next; + while (TableDesc) + { + if (TableDesc->TableId == TableId) + { + *ReturnTableDesc = TableDesc; + return (AE_OK); + } + + TableDesc = TableDesc->Next; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); + return (AE_BAD_PARAMETER); +} +#endif + + |