diff options
Diffstat (limited to 'sys/contrib/dev/acpica/tbinstal.c')
-rw-r--r-- | sys/contrib/dev/acpica/tbinstal.c | 184 |
1 files changed, 101 insertions, 83 deletions
diff --git a/sys/contrib/dev/acpica/tbinstal.c b/sys/contrib/dev/acpica/tbinstal.c index a7c889c..7198a0c 100644 --- a/sys/contrib/dev/acpica/tbinstal.c +++ b/sys/contrib/dev/acpica/tbinstal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * $Revision: 47 $ + * $Revision: 55 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -118,12 +118,62 @@ #define __TBINSTAL_C__ #include "acpi.h" -#include "achware.h" #include "actables.h" #define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbinstal") + ACPI_MODULE_NAME ("tbinstal") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbMatchSignature + * + * PARAMETERS: Signature - Table signature to match + * TableInfo - Return data + * + * RETURN: Status + * + * DESCRIPTION: Compare signature against the list of "ACPI-subsystem-owned" + * tables (DSDT/FADT/SSDT, etc.) Returns the TableTypeID on match. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbMatchSignature ( + NATIVE_CHAR *Signature, + ACPI_TABLE_DESC *TableInfo) +{ + NATIVE_UINT i; + + + ACPI_FUNCTION_TRACE ("TbMatchSignature"); + + + /* + * Search for a signature match among the known table types + */ + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (!ACPI_STRNCMP (Signature, AcpiGbl_AcpiTableData[i].Signature, + AcpiGbl_AcpiTableData[i].SigLength)) + { + /* Found a signature match, return index if requested */ + + if (TableInfo) + { + TableInfo->Type = (UINT8) i; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Signature match %4.4s\n", + (char *) AcpiGbl_AcpiTableData[i].Signature)); + + return_ACPI_STATUS (AE_OK); + } + } + + return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); +} /******************************************************************************* @@ -148,7 +198,7 @@ AcpiTbInstallTable ( { ACPI_STATUS Status; - FUNCTION_TRACE ("TbInstallTable"); + ACPI_FUNCTION_TRACE ("TbInstallTable"); /* @@ -163,7 +213,11 @@ AcpiTbInstallTable ( /* Lock tables while installing */ - AcpiUtAcquireMutex (ACPI_MTX_TABLES); + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Install the table into the global data structure */ @@ -172,7 +226,7 @@ AcpiTbInstallTable ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", AcpiGbl_AcpiTableData[TableInfo->Type].Name, TableInfo->Pointer)); - AcpiUtReleaseMutex (ACPI_MTX_TABLES); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } @@ -205,11 +259,9 @@ AcpiTbRecognizeTable ( { ACPI_TABLE_HEADER *TableHeader; ACPI_STATUS Status; - ACPI_TABLE_TYPE TableType = 0; - UINT32 i; - FUNCTION_TRACE ("TbRecognizeTable"); + ACPI_FUNCTION_TRACE ("TbRecognizeTable"); /* Ensure that we have a valid table pointer */ @@ -221,56 +273,35 @@ AcpiTbRecognizeTable ( } /* - * Search for a signature match among the known table types - * Start at index one -> Skip the RSDP + * We only "recognize" a limited number of ACPI tables -- namely, the + * ones that are used by the subsystem (DSDT, FADT, etc.) + * + * An AE_NOT_FOUND means that the table was not recognized. + * This can be any one of many valid ACPI tables, it just isn't one of + * the tables that is consumed by the core subsystem */ - Status = AE_SUPPORT; - for (i = 1; i < NUM_ACPI_TABLES; i++) + Status = AcpiTbMatchSignature (TableHeader->Signature, TableInfo); + if (ACPI_SUCCESS (Status)) { - if (!STRNCMP (TableHeader->Signature, - AcpiGbl_AcpiTableData[i].Signature, - AcpiGbl_AcpiTableData[i].SigLength)) - { - /* - * Found a signature match, get the pertinent info from the - * TableData structure - */ - TableType = i; - Status = AcpiGbl_AcpiTableData[i].Status; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found %4.4s\n", - (char*)AcpiGbl_AcpiTableData[i].Signature)); - break; - } - } - - /* Return the table type and length via the info struct */ - - TableInfo->Type = (UINT8) TableType; - TableInfo->Length = TableHeader->Length; + /* Return the table type and length via the info struct */ + TableInfo->Length = TableHeader->Length; - /* - * Validate checksum for _most_ tables, - * even the ones whose signature we don't recognize - */ - if (TableType != ACPI_TABLE_FACS) - { - /* But don't abort if the checksum is wrong */ - /* TBD: [Future] make this a configuration option? */ - - AcpiTbVerifyTableChecksum (TableHeader); - } + /* + * Validate checksum for _most_ tables, + * even the ones whose signature we don't recognize + */ + if (TableInfo->Type != ACPI_TABLE_FACS) + { + Status = AcpiTbVerifyTableChecksum (TableHeader); + if (ACPI_FAILURE (Status) && + (!ACPI_CHECKSUM_ABORT)) + { + /* Ignore the error if configuration says so */ - /* - * An AE_SUPPORT means that the table was not recognized. - * We basically ignore this; just print a debug message - */ - if (Status == AE_SUPPORT) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Unsupported table %s (Type %X) was found and discarded\n", - AcpiGbl_AcpiTableData[TableType].Name, TableType)); + Status = AE_OK; + } + } } return_ACPI_STATUS (Status); @@ -299,7 +330,7 @@ AcpiTbInitTableDescriptor ( ACPI_TABLE_DESC *TableDesc; - FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); + ACPI_FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); /* * Install the table into the global data structure @@ -307,13 +338,12 @@ AcpiTbInitTableDescriptor ( ListHead = &AcpiGbl_AcpiTables[TableType]; TableDesc = ListHead; - /* * Two major types of tables: 1) Only one instance is allowed. This * includes most ACPI tables such as the DSDT. 2) Multiple instances of * the table are allowed. This includes SSDT and PSDTs. */ - if (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags)) + if (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags)) { /* * Only one table allowed, and a table has alread been installed @@ -325,9 +355,9 @@ AcpiTbInitTableDescriptor ( } TableDesc->Count = 1; + TableDesc->Prev = NULL; + TableDesc->Next = NULL; } - - else { /* @@ -357,16 +387,15 @@ AcpiTbInitTableDescriptor ( ListHead->Prev = TableDesc; } - else { TableDesc->Count = 1; } } - /* Common initialization of the table descriptor */ + TableDesc->Type = TableInfo->Type; TableDesc->Pointer = TableInfo->Pointer; TableDesc->BasePointer = TableInfo->BasePointer; TableDesc->Length = TableInfo->Length; @@ -374,7 +403,7 @@ AcpiTbInitTableDescriptor ( TableDesc->AmlStart = (UINT8 *) (TableDesc->Pointer + 1), TableDesc->AmlLength = (UINT32) (TableDesc->Length - (UINT32) sizeof (ACPI_TABLE_HEADER)); - TableDesc->TableId = AcpiUtAllocateOwnerId (OWNER_TYPE_TABLE); + TableDesc->TableId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_TABLE); TableDesc->LoadedIntoNamespace = FALSE; /* @@ -386,7 +415,6 @@ AcpiTbInitTableDescriptor ( *(AcpiGbl_AcpiTableData[TableType].GlobalPtr) = TableInfo->Pointer; } - /* Return Data */ TableInfo->TableId = TableDesc->TableId; @@ -422,7 +450,6 @@ AcpiTbDeleteAcpiTables (void) { AcpiTbDeleteAcpiTable (Type); } - } @@ -443,7 +470,8 @@ void AcpiTbDeleteAcpiTable ( ACPI_TABLE_TYPE Type) { - FUNCTION_TRACE_U32 ("TbDeleteAcpiTable", Type); + + ACPI_FUNCTION_TRACE_U32 ("TbDeleteAcpiTable", Type); if (Type > ACPI_TABLE_MAX) @@ -451,14 +479,15 @@ AcpiTbDeleteAcpiTable ( return_VOID; } - - AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_TABLES))) + { + return; + } /* Free the table */ AcpiTbFreeAcpiTablesOfType (&AcpiGbl_AcpiTables[Type]); - /* Clear the appropriate "typed" global table pointer */ switch (Type) @@ -489,8 +518,7 @@ AcpiTbDeleteAcpiTable ( break; } - AcpiUtReleaseMutex (ACPI_MTX_TABLES); - + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_VOID; } @@ -517,7 +545,7 @@ AcpiTbFreeAcpiTablesOfType ( UINT32 i; - FUNCTION_TRACE_PTR ("TbFreeAcpiTablesOfType", ListHead); + ACPI_FUNCTION_TRACE_PTR ("TbFreeAcpiTablesOfType", ListHead); /* Get the head of the list */ @@ -567,17 +595,14 @@ AcpiTbDeleteSingleTable ( switch (TableDesc->Allocation) { - case ACPI_MEM_NOT_ALLOCATED: break; - case ACPI_MEM_ALLOCATED: ACPI_MEM_FREE (TableDesc->BasePointer); break; - case ACPI_MEM_MAPPED: AcpiOsUnmapMemory (TableDesc->BasePointer, TableDesc->Length); @@ -608,7 +633,7 @@ AcpiTbUninstallTable ( ACPI_TABLE_DESC *NextDesc; - FUNCTION_TRACE_PTR ("TbDeleteSingleTable", TableDesc); + ACPI_FUNCTION_TRACE_PTR ("TbDeleteSingleTable", TableDesc); if (!TableDesc) @@ -616,7 +641,6 @@ AcpiTbUninstallTable ( return_PTR (NULL); } - /* Unlink the descriptor */ if (TableDesc->Prev) @@ -629,17 +653,14 @@ AcpiTbUninstallTable ( TableDesc->Next->Prev = TableDesc->Prev; } - /* Free the memory allocated for the table itself */ AcpiTbDeleteSingleTable (TableDesc); - /* Free the table descriptor (Don't delete the list head, tho) */ if ((TableDesc->Prev) == (TableDesc->Next)) { - NextDesc = NULL; /* Clear the list head */ @@ -647,9 +668,7 @@ AcpiTbUninstallTable ( TableDesc->Pointer = NULL; TableDesc->Length = 0; TableDesc->Count = 0; - } - else { /* Free the table descriptor */ @@ -658,7 +677,6 @@ AcpiTbUninstallTable ( ACPI_MEM_FREE (TableDesc); } - return_PTR (NextDesc); } |