mirror of
https://github.com/acpica/acpica/
synced 2025-01-16 14:29:18 +03:00
Namespace load utilities
date 2000.04.19.22.09.00; author rmoore1; state Exp;
This commit is contained in:
parent
05490f286c
commit
bdb6116a2c
@ -1,7 +1,7 @@
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: nsload - namespace loading/expanding/contracting procedures
|
||||
* $Revision: 1.61 $
|
||||
*
|
||||
* Module Name: nsload - namespace loading procedures
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
|
||||
* All rights reserved.
|
||||
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
|
||||
* reserved.
|
||||
*
|
||||
* 2. License
|
||||
*
|
||||
@ -38,9 +38,9 @@
|
||||
* The above copyright and patent license is granted only if the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 3. Conditions
|
||||
* 3. Conditions
|
||||
*
|
||||
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
||||
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
||||
* Redistribution of source code of any substantial portion of the Covered
|
||||
* Code or modification with rights to further distribute source must include
|
||||
* the above Copyright Notice, the above License, this list of Conditions,
|
||||
@ -48,11 +48,11 @@
|
||||
* Licensee must cause all Covered Code to which Licensee contributes to
|
||||
* contain a file documenting the changes Licensee made to create that Covered
|
||||
* Code and the date of any change. Licensee must include in that file the
|
||||
* documentation of any changes made by any predecessor Licensee. Licensee
|
||||
* documentation of any changes made by any predecessor Licensee. Licensee
|
||||
* must include a prominent statement that the modification is derived,
|
||||
* directly or indirectly, from Original Intel Code.
|
||||
*
|
||||
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
||||
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
||||
* Redistribution of source code of any substantial portion of the Covered
|
||||
* Code or modification without rights to further distribute source must
|
||||
* include the following Disclaimer and Export Compliance provision in the
|
||||
@ -86,7 +86,7 @@
|
||||
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
||||
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE.
|
||||
* PARTICULAR PURPOSE.
|
||||
*
|
||||
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
||||
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
||||
@ -116,113 +116,183 @@
|
||||
|
||||
#define __NSLOAD_C__
|
||||
|
||||
#include "acpi.h"
|
||||
#include "acnamesp.h"
|
||||
#include "acparser.h"
|
||||
#include "acdispat.h"
|
||||
#include <acpi.h>
|
||||
#include <acobject.h>
|
||||
#include <interp.h>
|
||||
#include <namesp.h>
|
||||
#include <methods.h>
|
||||
#include <amlcode.h>
|
||||
#include <pnp.h>
|
||||
#include <parser.h>
|
||||
#include <dispatch.h>
|
||||
|
||||
|
||||
#define _COMPONENT ACPI_NAMESPACE
|
||||
ACPI_MODULE_NAME ("nsload")
|
||||
#define _COMPONENT NAMESPACE
|
||||
MODULE_NAME ("nsload");
|
||||
|
||||
|
||||
#ifndef ACPI_NO_METHOD_EXECUTION
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiNsLoadTable
|
||||
* FUNCTION: NsParseTable
|
||||
*
|
||||
* PARAMETERS: TableDesc - Descriptor for table to be loaded
|
||||
* Node - Owning NS node
|
||||
* PARAMETERS: Aml - Pointer to the raw AML code to parse
|
||||
* AmlSize - Length of the AML to parse
|
||||
* DescendingCallback - Called as each opcode is encountered during
|
||||
* descent of the parse tree
|
||||
* AscendingCallback - Called as each opcode is completed, during
|
||||
* ascent of the parse tree
|
||||
* RootObject - TBD: REMOVE??
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Load one ACPI table into the namespace
|
||||
* DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiNsLoadTable (
|
||||
NsParseTable (
|
||||
ACPI_TABLE_DESC *TableDesc,
|
||||
ACPI_NAMESPACE_NODE *Node)
|
||||
NAME_TABLE_ENTRY *Scope)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("NsLoadTable");
|
||||
FUNCTION_TRACE ("NsParseTable");
|
||||
|
||||
|
||||
/* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
|
||||
/* Create the root object */
|
||||
|
||||
if (!(AcpiGbl_AcpiTableData[TableDesc->Type].Flags & ACPI_TABLE_EXECUTABLE))
|
||||
Gbl_ParsedNamespaceRoot = PsAllocOp (AML_ScopeOp);
|
||||
if (!Gbl_ParsedNamespaceRoot)
|
||||
{
|
||||
/* Just ignore this table */
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
/* Check validity of the AML start and length */
|
||||
/* Initialize the root object */
|
||||
|
||||
if (!TableDesc->AmlStart)
|
||||
((ACPI_NAMED_OP *) Gbl_ParsedNamespaceRoot)->Name = * (UINT32 *) NS_ROOT;
|
||||
|
||||
/* Pass 1: Parse everything except control method bodies */
|
||||
|
||||
Status = PsParseAml (Gbl_ParsedNamespaceRoot, TableDesc->AmlPointer, TableDesc->AmlLength);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n"));
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
#ifndef PARSER_ONLY
|
||||
|
||||
DEBUG_PRINT (TRACE_PARSE, ("NsParseTable: Building Internal Namespace\n"));
|
||||
BREAKPOINT3;
|
||||
|
||||
/* TBD: Temp only */
|
||||
|
||||
PsWalkParsedAml (PsGetChild (Gbl_ParsedNamespaceRoot), Gbl_ParsedNamespaceRoot, NULL, Scope, NULL, NULL,
|
||||
TableDesc, DsLoad1BeginOp, DsLoad1EndOp);
|
||||
|
||||
|
||||
PsWalkParsedAml (PsGetChild (Gbl_ParsedNamespaceRoot), Gbl_ParsedNamespaceRoot, NULL, Scope, NULL, NULL,
|
||||
TableDesc, DsLoad2BeginOp, DsLoad2EndOp);
|
||||
|
||||
|
||||
/*
|
||||
* Now that the internal namespace has been constructed, we can delete the
|
||||
* parsed namespace, since it is no longer needed
|
||||
*/
|
||||
|
||||
DEBUG_PRINT (TRACE_PARSE, ("NsParseTable: Deleting Parsed Namespace\n"));
|
||||
BREAKPOINT3;
|
||||
|
||||
|
||||
PsDeleteParseTree (Gbl_ParsedNamespaceRoot);
|
||||
Gbl_ParsedNamespaceRoot = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* FUNCTION: NsLoadTable
|
||||
*
|
||||
* PARAMETERS: *PcodeAddr - Address of pcode block
|
||||
* PcodeLength - Length of pcode block
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Mainline of the AML load/dump subsystem. Sets up the
|
||||
* input engine, calls handler for outermost object type.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
NsLoadTable (
|
||||
ACPI_TABLE_DESC *TableDesc,
|
||||
NAME_TABLE_ENTRY *Entry)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
FUNCTION_TRACE ("NsLoadTable");
|
||||
|
||||
|
||||
if (!TableDesc->AmlPointer)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_ERROR, ("NsLoadTable: Null AML pointer\n"));
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", TableDesc->AmlStart));
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTable: AML block at %p\n", TableDesc->AmlPointer));
|
||||
|
||||
|
||||
if (!TableDesc->AmlLength)
|
||||
{
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Zero-length AML block\n"));
|
||||
DEBUG_PRINT (ACPI_ERROR, ("NsLoadTable: Zero-length AML block\n"));
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse the table and load the namespace with all named
|
||||
* objects found within. Control methods are NOT parsed
|
||||
* at this time. In fact, the control methods cannot be
|
||||
* parsed until the entire namespace is loaded, because
|
||||
* if a control method makes a forward reference (call)
|
||||
* to another control method, we can't continue parsing
|
||||
* because we don't know how many arguments to parse next!
|
||||
* Parse the table and load the namespace with all named objects found within.
|
||||
* Control methods are NOT parsed at this time. In fact, the control methods
|
||||
* cannot be parsed until the entire namespace is loaded, because if a control
|
||||
* method makes a forward reference (call) to another control method, we can't
|
||||
* continue parsing because we don't know how many arguments to parse next!
|
||||
*/
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n"));
|
||||
|
||||
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTable: **** Loading table into namespace ****\n"));
|
||||
|
||||
Status = AcpiNsParseTable (TableDesc, Node->Child);
|
||||
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
|
||||
CmAcquireMutex (MTX_NAMESPACE);
|
||||
Status = NsParseTable (TableDesc, Entry->Scope);
|
||||
CmReleaseMutex (MTX_NAMESPACE);
|
||||
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now we can parse the control methods. We always parse
|
||||
* them here for a sanity check, and if configured for
|
||||
* just-in-time parsing, we delete the control method
|
||||
* Now we can parse the control methods. We always parse them here for a sanity
|
||||
* check, and if configured for just-in-time parsing, we delete the control method
|
||||
* parse trees.
|
||||
*/
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
||||
"**** Begin Table Method Parsing and Object Initialization ****\n"));
|
||||
|
||||
Status = AcpiDsInitializeObjects (TableDesc, Node);
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTable: **** Begin Table Method Parsing and Object Initialization ****\n"));
|
||||
BREAKPOINT3;
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
||||
"**** Completed Table Method Parsing and Object Initialization ****\n"));
|
||||
Status = DsInitializeObjects (TableDesc, Entry);
|
||||
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTable: **** Completed Table Method Parsing and Object Initialization ****\n"));
|
||||
BREAKPOINT3;
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiNsLoadTableByType
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: NsLoadTableByType
|
||||
*
|
||||
* PARAMETERS: TableType - Id of the table type to load
|
||||
*
|
||||
@ -232,37 +302,37 @@ AcpiNsLoadTable (
|
||||
* of the given type are loaded. The mechanism allows this
|
||||
* routine to be called repeatedly.
|
||||
*
|
||||
******************************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiNsLoadTableByType (
|
||||
NsLoadTableByType (
|
||||
ACPI_TABLE_TYPE TableType)
|
||||
{
|
||||
UINT32 i;
|
||||
ACPI_STATUS Status;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
ACPI_TABLE_HEADER *TablePtr;
|
||||
ACPI_TABLE_DESC *TableDesc;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("NsLoadTableByType");
|
||||
|
||||
FUNCTION_TRACE ("NsLoadTableByType");
|
||||
|
||||
|
||||
Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
CmAcquireMutex (MTX_TABLES);
|
||||
|
||||
|
||||
/*
|
||||
* Table types supported are:
|
||||
* DSDT (one), SSDT/PSDT (multiple)
|
||||
*/
|
||||
|
||||
switch (TableType)
|
||||
{
|
||||
case ACPI_TABLE_DSDT:
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n"));
|
||||
case TABLE_DSDT:
|
||||
|
||||
TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_DSDT];
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading DSDT\n"));
|
||||
|
||||
TableDesc = &Gbl_AcpiTables[TABLE_DSDT];
|
||||
|
||||
/* If table already loaded into namespace, just return */
|
||||
|
||||
@ -273,71 +343,86 @@ AcpiNsLoadTableByType (
|
||||
|
||||
TableDesc->TableId = TABLE_ID_DSDT;
|
||||
|
||||
/* Initialize the root of the namespace tree */
|
||||
|
||||
Status = NsRootInitialize ();
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
goto UnlockAndExit;
|
||||
}
|
||||
|
||||
/* Now load the single DSDT */
|
||||
|
||||
Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
|
||||
Status = NsLoadTable (TableDesc, Gbl_RootObject);
|
||||
if (ACPI_SUCCESS (Status))
|
||||
{
|
||||
TableDesc->LoadedIntoNamespace = TRUE;
|
||||
TableDesc->RootEntry = Gbl_RootObject;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case ACPI_TABLE_SSDT:
|
||||
case TABLE_SSDT:
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n",
|
||||
AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count));
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading %d SSDTs\n",
|
||||
Gbl_AcpiTables[TABLE_SSDT].Count));
|
||||
|
||||
/*
|
||||
* Traverse list of SSDT tables
|
||||
*/
|
||||
TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT];
|
||||
for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++)
|
||||
|
||||
TableDesc = &Gbl_AcpiTables[TABLE_SSDT];
|
||||
for (i = 0; i < Gbl_AcpiTables[TABLE_SSDT].Count; i++)
|
||||
{
|
||||
/*
|
||||
* Only attempt to load table if it is not
|
||||
* already loaded!
|
||||
*/
|
||||
if (!TableDesc->LoadedIntoNamespace)
|
||||
{
|
||||
Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
break;
|
||||
}
|
||||
TablePtr = TableDesc->Pointer;
|
||||
|
||||
TableDesc->LoadedIntoNamespace = TRUE;
|
||||
}
|
||||
|
||||
TableDesc = TableDesc->Next;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ACPI_TABLE_PSDT:
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
|
||||
AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count));
|
||||
|
||||
/*
|
||||
* Traverse list of PSDT tables
|
||||
*/
|
||||
TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT];
|
||||
|
||||
for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++)
|
||||
{
|
||||
/* Only attempt to load table if it is not already loaded! */
|
||||
|
||||
if (!TableDesc->LoadedIntoNamespace)
|
||||
{
|
||||
Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
|
||||
Status = NsLoadTable (TableDesc, Gbl_RootObject);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TableDesc->LoadedIntoNamespace = TRUE;
|
||||
TableDesc->RootEntry = Gbl_RootObject;
|
||||
}
|
||||
|
||||
TableDesc = TableDesc->Next;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case TABLE_PSDT:
|
||||
|
||||
DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading %d PSDTs\n",
|
||||
Gbl_AcpiTables[TABLE_PSDT].Count));
|
||||
|
||||
/*
|
||||
* Traverse list of PSDT tables
|
||||
*/
|
||||
|
||||
TableDesc = &Gbl_AcpiTables[TABLE_PSDT];
|
||||
for (i = 0; i < Gbl_AcpiTables[TABLE_PSDT].Count ; i++)
|
||||
{
|
||||
TablePtr = TableDesc->Pointer;
|
||||
|
||||
/* Only attempt to load table if it is not already loaded! */
|
||||
|
||||
if (!TableDesc->LoadedIntoNamespace)
|
||||
{
|
||||
Status = NsLoadTable (TableDesc, Gbl_RootObject);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TableDesc->LoadedIntoNamespace = TRUE;
|
||||
TableDesc->RootEntry = Gbl_RootObject;
|
||||
}
|
||||
|
||||
TableDesc = TableDesc->Next;
|
||||
@ -348,207 +433,18 @@ AcpiNsLoadTableByType (
|
||||
|
||||
default:
|
||||
Status = AE_SUPPORT;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
UnlockAndExit:
|
||||
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiLoadNamespace
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
|
||||
* (DSDT points to either the BIOS or a buffer.)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiNsLoadNamespace (
|
||||
void)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("AcpiLoadNameSpace");
|
||||
|
||||
|
||||
/* There must be at least a DSDT installed */
|
||||
|
||||
if (AcpiGbl_DSDT == NULL)
|
||||
{
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n"));
|
||||
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the namespace. The DSDT is required,
|
||||
* but the SSDT and PSDT tables are optional.
|
||||
*/
|
||||
Status = AcpiNsLoadTableByType (ACPI_TABLE_DSDT);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/* Ignore exceptions from these */
|
||||
|
||||
(void) AcpiNsLoadTableByType (ACPI_TABLE_SSDT);
|
||||
(void) AcpiNsLoadTableByType (ACPI_TABLE_PSDT);
|
||||
|
||||
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
|
||||
"ACPI Namespace successfully loaded at root %p\n",
|
||||
AcpiGbl_RootNode));
|
||||
CmReleaseMutex (MTX_TABLES);
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiNsDeleteSubtree
|
||||
*
|
||||
* PARAMETERS: StartHandle - Handle in namespace where search begins
|
||||
*
|
||||
* RETURNS Status
|
||||
*
|
||||
* DESCRIPTION: Walks the namespace starting at the given handle and deletes
|
||||
* all objects, entries, and scopes in the entire subtree.
|
||||
*
|
||||
* Namespace/Interpreter should be locked or the subsystem should
|
||||
* be in shutdown before this routine is called.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiNsDeleteSubtree (
|
||||
ACPI_HANDLE StartHandle)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_HANDLE ChildHandle;
|
||||
ACPI_HANDLE ParentHandle;
|
||||
ACPI_HANDLE NextChildHandle;
|
||||
ACPI_HANDLE Dummy;
|
||||
UINT32 Level;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("NsDeleteSubtree");
|
||||
|
||||
|
||||
ParentHandle = StartHandle;
|
||||
ChildHandle = 0;
|
||||
Level = 1;
|
||||
|
||||
/*
|
||||
* Traverse the tree of objects until we bubble back up
|
||||
* to where we started.
|
||||
*/
|
||||
while (Level > 0)
|
||||
{
|
||||
/* Attempt to get the next object in this scope */
|
||||
|
||||
Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle,
|
||||
ChildHandle, &NextChildHandle);
|
||||
|
||||
ChildHandle = NextChildHandle;
|
||||
|
||||
/* Did we get a new object? */
|
||||
|
||||
if (ACPI_SUCCESS (Status))
|
||||
{
|
||||
/* Check if this object has any children */
|
||||
|
||||
if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle,
|
||||
0, &Dummy)))
|
||||
{
|
||||
/*
|
||||
* There is at least one child of this object,
|
||||
* visit the object
|
||||
*/
|
||||
Level++;
|
||||
ParentHandle = ChildHandle;
|
||||
ChildHandle = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* No more children in this object, go back up to
|
||||
* the object's parent
|
||||
*/
|
||||
Level--;
|
||||
|
||||
/* Delete all children now */
|
||||
|
||||
AcpiNsDeleteChildren (ChildHandle);
|
||||
|
||||
ChildHandle = ParentHandle;
|
||||
Status = AcpiGetParent (ParentHandle, &ParentHandle);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now delete the starting object, and we are done */
|
||||
|
||||
AcpiNsDeleteNode (ChildHandle);
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiNsUnloadNameSpace
|
||||
*
|
||||
* PARAMETERS: Handle - Root of namespace subtree to be deleted
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Shrinks the namespace, typically in response to an undocking
|
||||
* event. Deletes an entire subtree starting from (and
|
||||
* including) the given handle.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiNsUnloadNamespace (
|
||||
ACPI_HANDLE Handle)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("NsUnloadNameSpace");
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if (!AcpiGbl_RootNode)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_NAMESPACE);
|
||||
}
|
||||
|
||||
if (!Handle)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/* This function does the real work */
|
||||
|
||||
Status = AcpiNsDeleteSubtree (Handle);
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user