diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exconfig.c')
-rw-r--r-- | sys/contrib/dev/acpica/exconfig.c | 87 |
1 files changed, 55 insertions, 32 deletions
diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index 793131d..ea10bf5 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: 79 $ + * $Revision: 1.87 $ * *****************************************************************************/ @@ -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 @@ -129,6 +129,14 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconfig") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + ACPI_TABLE_HEADER *Table, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + /******************************************************************************* * @@ -145,7 +153,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExAddTable ( ACPI_TABLE_HEADER *Table, ACPI_NAMESPACE_NODE *ParentNode, @@ -167,18 +175,31 @@ AcpiExAddTable ( return_ACPI_STATUS (AE_NO_MEMORY); } + /* Init the table handle */ + + ObjDesc->Reference.Opcode = AML_LOAD_OP; + *DdbHandle = ObjDesc; + /* 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; + 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; } @@ -193,16 +214,12 @@ AcpiExAddTable ( goto Cleanup; } - /* Init the table handle */ - - ObjDesc->Reference.Opcode = AML_LOAD_OP; - ObjDesc->Reference.Object = TableInfo.InstalledDesc; - *DdbHandle = ObjDesc; return_ACPI_STATUS (AE_OK); Cleanup: AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; return_ACPI_STATUS (Status); } @@ -312,11 +329,10 @@ AcpiExLoadTableOp ( StartNode = ParentNode; } - /* - * Find the node referenced by the ParameterPathString - */ + /* Find the node referenced by the ParameterPathString */ + Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -337,8 +353,9 @@ AcpiExLoadTableOp ( { /* Store the parameter data into the optional parameter object */ - Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); @@ -468,16 +485,23 @@ AcpiExLoadOp ( Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); if (ACPI_FAILURE (Status)) { - goto Cleanup; + return_ACPI_STATUS (Status); } - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); + TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + BufferDesc->Buffer.Pointer); + + /* All done with the BufferDesc, delete it */ - /* Sanity check the table length */ + BufferDesc->Buffer.Pointer = NULL; + AcpiUtRemoveReference (BufferDesc); + + /* Sanity check the table length */ if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) { - return_ACPI_STATUS (AE_BAD_HEADER); + Status = AE_BAD_HEADER; + goto Cleanup; } break; @@ -507,7 +531,9 @@ AcpiExLoadOp ( Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); if (ACPI_FAILURE (Status)) { - goto Cleanup; + /* On error, TablePtr was deallocated above */ + + return_ACPI_STATUS (Status); } /* Store the DdbHandle into the Target operand */ @@ -516,18 +542,14 @@ AcpiExLoadOp ( if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); - } - return_ACPI_STATUS (Status); + /* TablePtr was deallocated above */ + return_ACPI_STATUS (Status); + } Cleanup: - - if (BufferDesc) - { - AcpiUtRemoveReference (BufferDesc); - } - else + if (ACPI_FAILURE (Status)) { ACPI_MEM_FREE (TablePtr); } @@ -580,7 +602,8 @@ AcpiExUnloadTable ( * Delete the entire namespace under this table Node * (Offset contains the TableId) */ - AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + AcpiNsDeleteNamespaceByOwner (TableInfo->OwnerId); + AcpiUtReleaseOwnerId (&TableInfo->OwnerId); /* Delete the table itself */ |