diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exconfig.c')
-rw-r--r-- | sys/contrib/dev/acpica/exconfig.c | 244 |
1 files changed, 75 insertions, 169 deletions
diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index ea10bf5..60d8b36 100644 --- a/sys/contrib/dev/acpica/exconfig.c +++ b/sys/contrib/dev/acpica/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 1.87 $ + * $Revision: 1.103 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -133,7 +133,7 @@ static ACPI_STATUS AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle); @@ -155,16 +155,15 @@ AcpiExAddTable ( static ACPI_STATUS AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE ("ExAddTable"); + ACPI_FUNCTION_TRACE (ExAddTable); /* Create an object to be the table handle */ @@ -182,44 +181,17 @@ AcpiExAddTable ( /* Install the new table into the local data structures */ - ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - - TableInfo.Type = ACPI_TABLE_SSDT; - TableInfo.Pointer = Table; - TableInfo.Length = (ACPI_SIZE) Table->Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - Status = AcpiTbInstallTable (&TableInfo); - ObjDesc->Reference.Object = TableInfo.InstalledDesc; - - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* Table already exists, just return the handle */ - - return_ACPI_STATUS (AE_OK); - } - goto Cleanup; - } + ObjDesc->Reference.Object = ACPI_CAST_PTR (void, TableIndex); /* Add the table to the namespace */ - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, ParentNode); + Status = AcpiNsLoadTable (TableIndex, ParentNode); if (ACPI_FAILURE (Status)) { - /* Uninstall table on error */ - - (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); - goto Cleanup; + AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; } - return_ACPI_STATUS (AE_OK); - - -Cleanup: - AcpiUtRemoveReference (ObjDesc); - *DdbHandle = NULL; return_ACPI_STATUS (Status); } @@ -233,7 +205,7 @@ Cleanup: * * RETURN: Status * - * DESCRIPTION: Load an ACPI table + * DESCRIPTION: Load an ACPI table from the RSDT/XSDT * ******************************************************************************/ @@ -244,35 +216,22 @@ AcpiExLoadTableOp ( { ACPI_STATUS Status; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_TABLE_HEADER *Table; + ACPI_NATIVE_UINT TableIndex; ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *StartNode; ACPI_NAMESPACE_NODE *ParameterNode = NULL; ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; - ACPI_FUNCTION_TRACE ("ExLoadTableOp"); + ACPI_FUNCTION_TRACE (ExLoadTableOp); -#if 0 - /* - * Make sure that the signature does not match one of the tables that - * is already loaded. - */ - Status = AcpiTbMatchSignature (Operand[0]->String.Pointer, NULL); - if (Status == AE_OK) - { - /* Signature matched -- don't allow override */ - - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } -#endif - - /* Find the ACPI table */ + /* Find the ACPI table in the RSDT/XSDT */ Status = AcpiTbFindTable (Operand[0]->String.Pointer, Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &Table); + Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) @@ -307,8 +266,8 @@ AcpiExLoadTableOp ( * Find the node referenced by the RootPathString. This is the * location within the namespace where the table will be loaded. */ - Status = AcpiNsGetNodeByPath (Operand[3]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParentNode); + Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -331,7 +290,7 @@ AcpiExLoadTableOp ( /* Find the node referenced by the ParameterPathString */ - Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, + Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { @@ -341,7 +300,7 @@ AcpiExLoadTableOp ( /* Load the table into the namespace */ - Status = AcpiExAddTable (Table, ParentNode, &DdbHandle); + Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -363,6 +322,14 @@ AcpiExLoadTableOp ( } } + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + ACPI_INFO ((AE_INFO, + "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]", + Table->Signature, Table->OemId, Table->OemTableId)); + } + *ReturnDesc = DdbHandle; return_ACPI_STATUS (Status); } @@ -372,7 +339,7 @@ AcpiExLoadTableOp ( * * FUNCTION: AcpiExLoadOp * - * PARAMETERS: ObjDesc - Region or Field where the table will be + * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be * obtained * Target - Where a handle to the table will be stored * WalkState - Current state @@ -381,6 +348,12 @@ AcpiExLoadTableOp ( * * DESCRIPTION: Load an ACPI table from a field or operation region * + * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer + * objects before this code is reached. + * + * If source is an operation region, it must refer to SystemMemory, as + * per the ACPI specification. + * ******************************************************************************/ ACPI_STATUS @@ -389,23 +362,31 @@ AcpiExLoadOp ( ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; ACPI_OPERAND_OBJECT *DdbHandle; - ACPI_OPERAND_OBJECT *BufferDesc = NULL; - ACPI_TABLE_HEADER *TablePtr = NULL; - ACPI_PHYSICAL_ADDRESS Address; - ACPI_TABLE_HEADER TableHeader; - UINT32 i; + ACPI_TABLE_DESC TableDesc; + ACPI_NATIVE_UINT TableIndex; + ACPI_STATUS Status; + - ACPI_FUNCTION_TRACE ("ExLoadOp"); + ACPI_FUNCTION_TRACE (ExLoadOp); - /* Object can be either an OpRegion or a Field */ + ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + /* Source Object can be either an OpRegion or a Buffer/Field */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_REGION: + /* Region must be SystemMemory (from ACPI spec) */ + + if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); @@ -422,113 +403,40 @@ AcpiExLoadOp ( } } - /* Get the base physical address of the region */ - - Address = ObjDesc->Region.Address; - - /* Get the table length from the table header */ - - TableHeader.Length = 0; - for (i = 0; i < 8; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, - ((UINT8 *) &TableHeader) + i); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Sanity check the table length */ - - if (TableHeader.Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_BAD_HEADER); - } - - /* Allocate a buffer for the entire table */ - - TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); - if (!TablePtr) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Get the entire table from the op region */ - - for (i = 0; i < TableHeader.Length; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, - ((UINT8 *) TablePtr + i)); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } + TableDesc.Address = ObjDesc->Region.Address; + TableDesc.Length = ObjDesc->Region.Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_MAPPED; break; + case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* Simply extract the buffer from the buffer object */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Buffer or Field %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); - /* - * The length of the field must be at least as large as the table. - * Read the entire field and thus the entire table. Buffer is - * allocated during the read. - */ - Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, - BufferDesc->Buffer.Pointer); - - /* All done with the BufferDesc, delete it */ - - BufferDesc->Buffer.Pointer = NULL; - AcpiUtRemoveReference (BufferDesc); - - /* Sanity check the table length */ + TableDesc.Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + ObjDesc->Buffer.Pointer); + TableDesc.Length = TableDesc.Pointer->Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; - if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) - { - Status = AE_BAD_HEADER; - goto Cleanup; - } + ObjDesc->Buffer.Pointer = NULL; break; - default: return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* The table must be either an SSDT or a PSDT */ - - if ((!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_TableData[ACPI_TABLE_PSDT].Signature, - AcpiGbl_TableData[ACPI_TABLE_PSDT].SigLength)) && - (!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_TableData[ACPI_TABLE_SSDT].Signature, - AcpiGbl_TableData[ACPI_TABLE_SSDT].SigLength))) + /* + * Install the new table into the local data structures + */ + Status = AcpiTbAddTable (&TableDesc, &TableIndex); + if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", - TablePtr->Signature)); - Status = AE_BAD_SIGNATURE; goto Cleanup; } - /* Install the new table into the local data structures */ - - Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); + Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); if (ACPI_FAILURE (Status)) { /* On error, TablePtr was deallocated above */ @@ -551,7 +459,7 @@ AcpiExLoadOp ( Cleanup: if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (TablePtr); + AcpiTbDeleteTable (&TableDesc); } return_ACPI_STATUS (Status); } @@ -575,10 +483,10 @@ AcpiExUnloadTable ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; - ACPI_TABLE_DESC *TableInfo; + ACPI_NATIVE_UINT TableIndex; - ACPI_FUNCTION_TRACE ("ExUnloadTable"); + ACPI_FUNCTION_TRACE (ExUnloadTable); /* @@ -594,20 +502,18 @@ AcpiExUnloadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the actual table descriptor from the DdbHandle */ + /* Get the table index from the DdbHandle */ - TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; + TableIndex = (ACPI_NATIVE_UINT) TableDesc->Reference.Object; /* * Delete the entire namespace under this table Node * (Offset contains the TableId) */ - AcpiNsDeleteNamespaceByOwner (TableInfo->OwnerId); - AcpiUtReleaseOwnerId (&TableInfo->OwnerId); - - /* Delete the table itself */ + AcpiTbDeleteNamespaceByOwner (TableIndex); + AcpiTbReleaseOwnerId (TableIndex); - (void) AcpiTbUninstallTable (TableInfo->InstalledDesc); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); /* Delete the table descriptor (DdbHandle) */ |