1*3446Smrj /******************************************************************************* 2*3446Smrj * 3*3446Smrj * Module Name: nsalloc - Namespace allocation and deletion utilities 4*3446Smrj * $Revision: 1.106 $ 5*3446Smrj * 6*3446Smrj ******************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj 118*3446Smrj #define __NSALLOC_C__ 119*3446Smrj 120*3446Smrj #include "acpi.h" 121*3446Smrj #include "acnamesp.h" 122*3446Smrj 123*3446Smrj 124*3446Smrj #define _COMPONENT ACPI_NAMESPACE 125*3446Smrj ACPI_MODULE_NAME ("nsalloc") 126*3446Smrj 127*3446Smrj 128*3446Smrj /******************************************************************************* 129*3446Smrj * 130*3446Smrj * FUNCTION: AcpiNsCreateNode 131*3446Smrj * 132*3446Smrj * PARAMETERS: Name - Name of the new node (4 char ACPI name) 133*3446Smrj * 134*3446Smrj * RETURN: New namespace node (Null on failure) 135*3446Smrj * 136*3446Smrj * DESCRIPTION: Create a namespace node 137*3446Smrj * 138*3446Smrj ******************************************************************************/ 139*3446Smrj 140*3446Smrj ACPI_NAMESPACE_NODE * 141*3446Smrj AcpiNsCreateNode ( 142*3446Smrj UINT32 Name) 143*3446Smrj { 144*3446Smrj ACPI_NAMESPACE_NODE *Node; 145*3446Smrj 146*3446Smrj 147*3446Smrj ACPI_FUNCTION_TRACE (NsCreateNode); 148*3446Smrj 149*3446Smrj 150*3446Smrj Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); 151*3446Smrj if (!Node) 152*3446Smrj { 153*3446Smrj return_PTR (NULL); 154*3446Smrj } 155*3446Smrj 156*3446Smrj ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); 157*3446Smrj 158*3446Smrj Node->Name.Integer = Name; 159*3446Smrj ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); 160*3446Smrj return_PTR (Node); 161*3446Smrj } 162*3446Smrj 163*3446Smrj 164*3446Smrj /******************************************************************************* 165*3446Smrj * 166*3446Smrj * FUNCTION: AcpiNsDeleteNode 167*3446Smrj * 168*3446Smrj * PARAMETERS: Node - Node to be deleted 169*3446Smrj * 170*3446Smrj * RETURN: None 171*3446Smrj * 172*3446Smrj * DESCRIPTION: Delete a namespace node 173*3446Smrj * 174*3446Smrj ******************************************************************************/ 175*3446Smrj 176*3446Smrj void 177*3446Smrj AcpiNsDeleteNode ( 178*3446Smrj ACPI_NAMESPACE_NODE *Node) 179*3446Smrj { 180*3446Smrj ACPI_NAMESPACE_NODE *ParentNode; 181*3446Smrj ACPI_NAMESPACE_NODE *PrevNode; 182*3446Smrj ACPI_NAMESPACE_NODE *NextNode; 183*3446Smrj 184*3446Smrj 185*3446Smrj ACPI_FUNCTION_TRACE_PTR (NsDeleteNode, Node); 186*3446Smrj 187*3446Smrj 188*3446Smrj ParentNode = AcpiNsGetParentNode (Node); 189*3446Smrj 190*3446Smrj PrevNode = NULL; 191*3446Smrj NextNode = ParentNode->Child; 192*3446Smrj 193*3446Smrj /* Find the node that is the previous peer in the parent's child list */ 194*3446Smrj 195*3446Smrj while (NextNode != Node) 196*3446Smrj { 197*3446Smrj PrevNode = NextNode; 198*3446Smrj NextNode = PrevNode->Peer; 199*3446Smrj } 200*3446Smrj 201*3446Smrj if (PrevNode) 202*3446Smrj { 203*3446Smrj /* Node is not first child, unlink it */ 204*3446Smrj 205*3446Smrj PrevNode->Peer = NextNode->Peer; 206*3446Smrj if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) 207*3446Smrj { 208*3446Smrj PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; 209*3446Smrj } 210*3446Smrj } 211*3446Smrj else 212*3446Smrj { 213*3446Smrj /* Node is first child (has no previous peer) */ 214*3446Smrj 215*3446Smrj if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) 216*3446Smrj { 217*3446Smrj /* No peers at all */ 218*3446Smrj 219*3446Smrj ParentNode->Child = NULL; 220*3446Smrj } 221*3446Smrj else 222*3446Smrj { /* Link peer list to parent */ 223*3446Smrj 224*3446Smrj ParentNode->Child = NextNode->Peer; 225*3446Smrj } 226*3446Smrj } 227*3446Smrj 228*3446Smrj ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); 229*3446Smrj 230*3446Smrj /* 231*3446Smrj * Detach an object if there is one, then delete the node 232*3446Smrj */ 233*3446Smrj AcpiNsDetachObject (Node); 234*3446Smrj (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); 235*3446Smrj return_VOID; 236*3446Smrj } 237*3446Smrj 238*3446Smrj 239*3446Smrj /******************************************************************************* 240*3446Smrj * 241*3446Smrj * FUNCTION: AcpiNsInstallNode 242*3446Smrj * 243*3446Smrj * PARAMETERS: WalkState - Current state of the walk 244*3446Smrj * ParentNode - The parent of the new Node 245*3446Smrj * Node - The new Node to install 246*3446Smrj * Type - ACPI object type of the new Node 247*3446Smrj * 248*3446Smrj * RETURN: None 249*3446Smrj * 250*3446Smrj * DESCRIPTION: Initialize a new namespace node and install it amongst 251*3446Smrj * its peers. 252*3446Smrj * 253*3446Smrj * Note: Current namespace lookup is linear search. This appears 254*3446Smrj * to be sufficient as namespace searches consume only a small 255*3446Smrj * fraction of the execution time of the ACPI subsystem. 256*3446Smrj * 257*3446Smrj ******************************************************************************/ 258*3446Smrj 259*3446Smrj void 260*3446Smrj AcpiNsInstallNode ( 261*3446Smrj ACPI_WALK_STATE *WalkState, 262*3446Smrj ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ 263*3446Smrj ACPI_NAMESPACE_NODE *Node, /* New Child*/ 264*3446Smrj ACPI_OBJECT_TYPE Type) 265*3446Smrj { 266*3446Smrj ACPI_OWNER_ID OwnerId = 0; 267*3446Smrj ACPI_NAMESPACE_NODE *ChildNode; 268*3446Smrj 269*3446Smrj 270*3446Smrj ACPI_FUNCTION_TRACE (NsInstallNode); 271*3446Smrj 272*3446Smrj 273*3446Smrj /* 274*3446Smrj * Get the owner ID from the Walk state 275*3446Smrj * The owner ID is used to track table deletion and 276*3446Smrj * deletion of objects created by methods 277*3446Smrj */ 278*3446Smrj if (WalkState) 279*3446Smrj { 280*3446Smrj OwnerId = WalkState->OwnerId; 281*3446Smrj } 282*3446Smrj 283*3446Smrj /* Link the new entry into the parent and existing children */ 284*3446Smrj 285*3446Smrj ChildNode = ParentNode->Child; 286*3446Smrj if (!ChildNode) 287*3446Smrj { 288*3446Smrj ParentNode->Child = Node; 289*3446Smrj Node->Flags |= ANOBJ_END_OF_PEER_LIST; 290*3446Smrj Node->Peer = ParentNode; 291*3446Smrj } 292*3446Smrj else 293*3446Smrj { 294*3446Smrj while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) 295*3446Smrj { 296*3446Smrj ChildNode = ChildNode->Peer; 297*3446Smrj } 298*3446Smrj 299*3446Smrj ChildNode->Peer = Node; 300*3446Smrj 301*3446Smrj /* Clear end-of-list flag */ 302*3446Smrj 303*3446Smrj ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; 304*3446Smrj Node->Flags |= ANOBJ_END_OF_PEER_LIST; 305*3446Smrj Node->Peer = ParentNode; 306*3446Smrj } 307*3446Smrj 308*3446Smrj /* Init the new entry */ 309*3446Smrj 310*3446Smrj Node->OwnerId = OwnerId; 311*3446Smrj Node->Type = (UINT8) Type; 312*3446Smrj 313*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 314*3446Smrj "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", 315*3446Smrj AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, 316*3446Smrj AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), 317*3446Smrj ParentNode)); 318*3446Smrj 319*3446Smrj return_VOID; 320*3446Smrj } 321*3446Smrj 322*3446Smrj 323*3446Smrj /******************************************************************************* 324*3446Smrj * 325*3446Smrj * FUNCTION: AcpiNsDeleteChildren 326*3446Smrj * 327*3446Smrj * PARAMETERS: ParentNode - Delete this objects children 328*3446Smrj * 329*3446Smrj * RETURN: None. 330*3446Smrj * 331*3446Smrj * DESCRIPTION: Delete all children of the parent object. In other words, 332*3446Smrj * deletes a "scope". 333*3446Smrj * 334*3446Smrj ******************************************************************************/ 335*3446Smrj 336*3446Smrj void 337*3446Smrj AcpiNsDeleteChildren ( 338*3446Smrj ACPI_NAMESPACE_NODE *ParentNode) 339*3446Smrj { 340*3446Smrj ACPI_NAMESPACE_NODE *ChildNode; 341*3446Smrj ACPI_NAMESPACE_NODE *NextNode; 342*3446Smrj UINT8 Flags; 343*3446Smrj 344*3446Smrj 345*3446Smrj ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); 346*3446Smrj 347*3446Smrj 348*3446Smrj if (!ParentNode) 349*3446Smrj { 350*3446Smrj return_VOID; 351*3446Smrj } 352*3446Smrj 353*3446Smrj /* If no children, all done! */ 354*3446Smrj 355*3446Smrj ChildNode = ParentNode->Child; 356*3446Smrj if (!ChildNode) 357*3446Smrj { 358*3446Smrj return_VOID; 359*3446Smrj } 360*3446Smrj 361*3446Smrj /* 362*3446Smrj * Deallocate all children at this level 363*3446Smrj */ 364*3446Smrj do 365*3446Smrj { 366*3446Smrj /* Get the things we need */ 367*3446Smrj 368*3446Smrj NextNode = ChildNode->Peer; 369*3446Smrj Flags = ChildNode->Flags; 370*3446Smrj 371*3446Smrj /* Grandchildren should have all been deleted already */ 372*3446Smrj 373*3446Smrj if (ChildNode->Child) 374*3446Smrj { 375*3446Smrj ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", 376*3446Smrj ParentNode, ChildNode)); 377*3446Smrj } 378*3446Smrj 379*3446Smrj /* Now we can free this child object */ 380*3446Smrj 381*3446Smrj ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); 382*3446Smrj 383*3446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", 384*3446Smrj ChildNode, AcpiGbl_CurrentNodeCount)); 385*3446Smrj 386*3446Smrj /* 387*3446Smrj * Detach an object if there is one, then free the child node 388*3446Smrj */ 389*3446Smrj AcpiNsDetachObject (ChildNode); 390*3446Smrj 391*3446Smrj /* Now we can delete the node */ 392*3446Smrj 393*3446Smrj (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, ChildNode); 394*3446Smrj 395*3446Smrj /* And move on to the next child in the list */ 396*3446Smrj 397*3446Smrj ChildNode = NextNode; 398*3446Smrj 399*3446Smrj } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); 400*3446Smrj 401*3446Smrj 402*3446Smrj /* Clear the parent's child pointer */ 403*3446Smrj 404*3446Smrj ParentNode->Child = NULL; 405*3446Smrj 406*3446Smrj return_VOID; 407*3446Smrj } 408*3446Smrj 409*3446Smrj 410*3446Smrj /******************************************************************************* 411*3446Smrj * 412*3446Smrj * FUNCTION: AcpiNsDeleteNamespaceSubtree 413*3446Smrj * 414*3446Smrj * PARAMETERS: ParentNode - Root of the subtree to be deleted 415*3446Smrj * 416*3446Smrj * RETURN: None. 417*3446Smrj * 418*3446Smrj * DESCRIPTION: Delete a subtree of the namespace. This includes all objects 419*3446Smrj * stored within the subtree. 420*3446Smrj * 421*3446Smrj ******************************************************************************/ 422*3446Smrj 423*3446Smrj void 424*3446Smrj AcpiNsDeleteNamespaceSubtree ( 425*3446Smrj ACPI_NAMESPACE_NODE *ParentNode) 426*3446Smrj { 427*3446Smrj ACPI_NAMESPACE_NODE *ChildNode = NULL; 428*3446Smrj UINT32 Level = 1; 429*3446Smrj 430*3446Smrj 431*3446Smrj ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); 432*3446Smrj 433*3446Smrj 434*3446Smrj if (!ParentNode) 435*3446Smrj { 436*3446Smrj return_VOID; 437*3446Smrj } 438*3446Smrj 439*3446Smrj /* 440*3446Smrj * Traverse the tree of objects until we bubble back up 441*3446Smrj * to where we started. 442*3446Smrj */ 443*3446Smrj while (Level > 0) 444*3446Smrj { 445*3446Smrj /* Get the next node in this scope (NULL if none) */ 446*3446Smrj 447*3446Smrj ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); 448*3446Smrj if (ChildNode) 449*3446Smrj { 450*3446Smrj /* Found a child node - detach any attached object */ 451*3446Smrj 452*3446Smrj AcpiNsDetachObject (ChildNode); 453*3446Smrj 454*3446Smrj /* Check if this node has any children */ 455*3446Smrj 456*3446Smrj if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) 457*3446Smrj { 458*3446Smrj /* 459*3446Smrj * There is at least one child of this node, 460*3446Smrj * visit the node 461*3446Smrj */ 462*3446Smrj Level++; 463*3446Smrj ParentNode = ChildNode; 464*3446Smrj ChildNode = NULL; 465*3446Smrj } 466*3446Smrj } 467*3446Smrj else 468*3446Smrj { 469*3446Smrj /* 470*3446Smrj * No more children of this parent node. 471*3446Smrj * Move up to the grandparent. 472*3446Smrj */ 473*3446Smrj Level--; 474*3446Smrj 475*3446Smrj /* 476*3446Smrj * Now delete all of the children of this parent 477*3446Smrj * all at the same time. 478*3446Smrj */ 479*3446Smrj AcpiNsDeleteChildren (ParentNode); 480*3446Smrj 481*3446Smrj /* New "last child" is this parent node */ 482*3446Smrj 483*3446Smrj ChildNode = ParentNode; 484*3446Smrj 485*3446Smrj /* Move up the tree to the grandparent */ 486*3446Smrj 487*3446Smrj ParentNode = AcpiNsGetParentNode (ParentNode); 488*3446Smrj } 489*3446Smrj } 490*3446Smrj 491*3446Smrj return_VOID; 492*3446Smrj } 493*3446Smrj 494*3446Smrj 495*3446Smrj /******************************************************************************* 496*3446Smrj * 497*3446Smrj * FUNCTION: AcpiNsDeleteNamespaceByOwner 498*3446Smrj * 499*3446Smrj * PARAMETERS: OwnerId - All nodes with this owner will be deleted 500*3446Smrj * 501*3446Smrj * RETURN: Status 502*3446Smrj * 503*3446Smrj * DESCRIPTION: Delete entries within the namespace that are owned by a 504*3446Smrj * specific ID. Used to delete entire ACPI tables. All 505*3446Smrj * reference counts are updated. 506*3446Smrj * 507*3446Smrj * MUTEX: Locks namespace during deletion walk. 508*3446Smrj * 509*3446Smrj ******************************************************************************/ 510*3446Smrj 511*3446Smrj void 512*3446Smrj AcpiNsDeleteNamespaceByOwner ( 513*3446Smrj ACPI_OWNER_ID OwnerId) 514*3446Smrj { 515*3446Smrj ACPI_NAMESPACE_NODE *ChildNode; 516*3446Smrj ACPI_NAMESPACE_NODE *DeletionNode; 517*3446Smrj ACPI_NAMESPACE_NODE *ParentNode; 518*3446Smrj UINT32 Level; 519*3446Smrj ACPI_STATUS Status; 520*3446Smrj 521*3446Smrj 522*3446Smrj ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); 523*3446Smrj 524*3446Smrj 525*3446Smrj if (OwnerId == 0) 526*3446Smrj { 527*3446Smrj return_VOID; 528*3446Smrj } 529*3446Smrj 530*3446Smrj /* Lock namespace for possible update */ 531*3446Smrj 532*3446Smrj Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 533*3446Smrj if (ACPI_FAILURE (Status)) 534*3446Smrj { 535*3446Smrj return_VOID; 536*3446Smrj } 537*3446Smrj 538*3446Smrj DeletionNode = NULL; 539*3446Smrj ParentNode = AcpiGbl_RootNode; 540*3446Smrj ChildNode = NULL; 541*3446Smrj Level = 1; 542*3446Smrj 543*3446Smrj /* 544*3446Smrj * Traverse the tree of nodes until we bubble back up 545*3446Smrj * to where we started. 546*3446Smrj */ 547*3446Smrj while (Level > 0) 548*3446Smrj { 549*3446Smrj /* 550*3446Smrj * Get the next child of this parent node. When ChildNode is NULL, 551*3446Smrj * the first child of the parent is returned 552*3446Smrj */ 553*3446Smrj ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); 554*3446Smrj 555*3446Smrj if (DeletionNode) 556*3446Smrj { 557*3446Smrj AcpiNsDeleteChildren (DeletionNode); 558*3446Smrj AcpiNsDeleteNode (DeletionNode); 559*3446Smrj DeletionNode = NULL; 560*3446Smrj } 561*3446Smrj 562*3446Smrj if (ChildNode) 563*3446Smrj { 564*3446Smrj if (ChildNode->OwnerId == OwnerId) 565*3446Smrj { 566*3446Smrj /* Found a matching child node - detach any attached object */ 567*3446Smrj 568*3446Smrj AcpiNsDetachObject (ChildNode); 569*3446Smrj } 570*3446Smrj 571*3446Smrj /* Check if this node has any children */ 572*3446Smrj 573*3446Smrj if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) 574*3446Smrj { 575*3446Smrj /* 576*3446Smrj * There is at least one child of this node, 577*3446Smrj * visit the node 578*3446Smrj */ 579*3446Smrj Level++; 580*3446Smrj ParentNode = ChildNode; 581*3446Smrj ChildNode = NULL; 582*3446Smrj } 583*3446Smrj else if (ChildNode->OwnerId == OwnerId) 584*3446Smrj { 585*3446Smrj DeletionNode = ChildNode; 586*3446Smrj } 587*3446Smrj } 588*3446Smrj else 589*3446Smrj { 590*3446Smrj /* 591*3446Smrj * No more children of this parent node. 592*3446Smrj * Move up to the grandparent. 593*3446Smrj */ 594*3446Smrj Level--; 595*3446Smrj if (Level != 0) 596*3446Smrj { 597*3446Smrj if (ParentNode->OwnerId == OwnerId) 598*3446Smrj { 599*3446Smrj DeletionNode = ParentNode; 600*3446Smrj } 601*3446Smrj } 602*3446Smrj 603*3446Smrj /* New "last child" is this parent node */ 604*3446Smrj 605*3446Smrj ChildNode = ParentNode; 606*3446Smrj 607*3446Smrj /* Move up the tree to the grandparent */ 608*3446Smrj 609*3446Smrj ParentNode = AcpiNsGetParentNode (ParentNode); 610*3446Smrj } 611*3446Smrj } 612*3446Smrj 613*3446Smrj (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 614*3446Smrj return_VOID; 615*3446Smrj } 616*3446Smrj 617*3446Smrj 618