1 /******************************************************************************* 2 * 3 * Module Name: utdelete - object deletion and reference count utilities 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 #define __UTDELETE_C__ 117 118 #include "acpi.h" 119 #include "accommon.h" 120 #include "acinterp.h" 121 #include "acnamesp.h" 122 #include "acevents.h" 123 124 125 #define _COMPONENT ACPI_UTILITIES 126 ACPI_MODULE_NAME ("utdelete") 127 128 /* Local prototypes */ 129 130 static void 131 AcpiUtDeleteInternalObj ( 132 ACPI_OPERAND_OBJECT *Object); 133 134 static void 135 AcpiUtUpdateRefCount ( 136 ACPI_OPERAND_OBJECT *Object, 137 UINT32 Action); 138 139 140 /******************************************************************************* 141 * 142 * FUNCTION: AcpiUtDeleteInternalObj 143 * 144 * PARAMETERS: Object - Object to be deleted 145 * 146 * RETURN: None 147 * 148 * DESCRIPTION: Low level object deletion, after reference counts have been 149 * updated (All reference counts, including sub-objects!) 150 * 151 ******************************************************************************/ 152 153 static void 154 AcpiUtDeleteInternalObj ( 155 ACPI_OPERAND_OBJECT *Object) 156 { 157 void *ObjPointer = NULL; 158 ACPI_OPERAND_OBJECT *HandlerDesc; 159 ACPI_OPERAND_OBJECT *SecondDesc; 160 ACPI_OPERAND_OBJECT *NextDesc; 161 ACPI_OPERAND_OBJECT *StartDesc; 162 ACPI_OPERAND_OBJECT **LastObjPtr; 163 164 165 ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); 166 167 168 if (!Object) 169 { 170 return_VOID; 171 } 172 173 /* 174 * Must delete or free any pointers within the object that are not 175 * actual ACPI objects (for example, a raw buffer pointer). 176 */ 177 switch (Object->Common.Type) 178 { 179 case ACPI_TYPE_STRING: 180 181 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", 182 Object, Object->String.Pointer)); 183 184 /* Free the actual string buffer */ 185 186 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) 187 { 188 /* But only if it is NOT a pointer into an ACPI table */ 189 190 ObjPointer = Object->String.Pointer; 191 } 192 break; 193 194 case ACPI_TYPE_BUFFER: 195 196 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", 197 Object, Object->Buffer.Pointer)); 198 199 /* Free the actual buffer */ 200 201 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) 202 { 203 /* But only if it is NOT a pointer into an ACPI table */ 204 205 ObjPointer = Object->Buffer.Pointer; 206 } 207 break; 208 209 case ACPI_TYPE_PACKAGE: 210 211 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", 212 Object->Package.Count)); 213 214 /* 215 * Elements of the package are not handled here, they are deleted 216 * separately 217 */ 218 219 /* Free the (variable length) element pointer array */ 220 221 ObjPointer = Object->Package.Elements; 222 break; 223 224 /* 225 * These objects have a possible list of notify handlers. 226 * Device object also may have a GPE block. 227 */ 228 case ACPI_TYPE_DEVICE: 229 230 if (Object->Device.GpeBlock) 231 { 232 (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock); 233 } 234 235 /*lint -fallthrough */ 236 237 case ACPI_TYPE_PROCESSOR: 238 case ACPI_TYPE_THERMAL: 239 240 /* Walk the address handler list for this object */ 241 242 HandlerDesc = Object->CommonNotify.Handler; 243 while (HandlerDesc) 244 { 245 NextDesc = HandlerDesc->AddressSpace.Next; 246 AcpiUtRemoveReference (HandlerDesc); 247 HandlerDesc = NextDesc; 248 } 249 break; 250 251 case ACPI_TYPE_MUTEX: 252 253 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 254 "***** Mutex %p, OS Mutex %p\n", 255 Object, Object->Mutex.OsMutex)); 256 257 if (Object == AcpiGbl_GlobalLockMutex) 258 { 259 /* Global Lock has extra semaphore */ 260 261 (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); 262 AcpiGbl_GlobalLockSemaphore = NULL; 263 264 AcpiOsDeleteMutex (Object->Mutex.OsMutex); 265 AcpiGbl_GlobalLockMutex = NULL; 266 } 267 else 268 { 269 AcpiExUnlinkMutex (Object); 270 AcpiOsDeleteMutex (Object->Mutex.OsMutex); 271 } 272 break; 273 274 case ACPI_TYPE_EVENT: 275 276 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 277 "***** Event %p, OS Semaphore %p\n", 278 Object, Object->Event.OsSemaphore)); 279 280 (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); 281 Object->Event.OsSemaphore = 0; 282 break; 283 284 case ACPI_TYPE_METHOD: 285 286 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 287 "***** Method %p\n", Object)); 288 289 /* Delete the method mutex if it exists */ 290 291 if (Object->Method.Mutex) 292 { 293 AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); 294 AcpiUtDeleteObjectDesc (Object->Method.Mutex); 295 Object->Method.Mutex = NULL; 296 } 297 break; 298 299 case ACPI_TYPE_REGION: 300 301 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 302 "***** Region %p\n", Object)); 303 304 /* 305 * Update AddressRange list. However, only permanent regions 306 * are installed in this list. (Not created within a method) 307 */ 308 if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY)) 309 { 310 AcpiUtRemoveAddressRange (Object->Region.SpaceId, 311 Object->Region.Node); 312 } 313 314 SecondDesc = AcpiNsGetSecondaryObject (Object); 315 if (SecondDesc) 316 { 317 /* 318 * Free the RegionContext if and only if the handler is one of the 319 * default handlers -- and therefore, we created the context object 320 * locally, it was not created by an external caller. 321 */ 322 HandlerDesc = Object->Region.Handler; 323 if (HandlerDesc) 324 { 325 NextDesc = HandlerDesc->AddressSpace.RegionList; 326 StartDesc = NextDesc; 327 LastObjPtr = &HandlerDesc->AddressSpace.RegionList; 328 329 /* Remove the region object from the handler list */ 330 331 while (NextDesc) 332 { 333 if (NextDesc == Object) 334 { 335 *LastObjPtr = NextDesc->Region.Next; 336 break; 337 } 338 339 /* Walk the linked list of handlers */ 340 341 LastObjPtr = &NextDesc->Region.Next; 342 NextDesc = NextDesc->Region.Next; 343 344 /* Prevent infinite loop if list is corrupted */ 345 346 if (NextDesc == StartDesc) 347 { 348 ACPI_ERROR ((AE_INFO, 349 "Circular region list in address handler object %p", 350 HandlerDesc)); 351 return_VOID; 352 } 353 } 354 355 if (HandlerDesc->AddressSpace.HandlerFlags & 356 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) 357 { 358 /* Deactivate region and free region context */ 359 360 if (HandlerDesc->AddressSpace.Setup) 361 { 362 (void) HandlerDesc->AddressSpace.Setup (Object, 363 ACPI_REGION_DEACTIVATE, 364 HandlerDesc->AddressSpace.Context, 365 &SecondDesc->Extra.RegionContext); 366 } 367 } 368 369 AcpiUtRemoveReference (HandlerDesc); 370 } 371 372 /* Now we can free the Extra object */ 373 374 AcpiUtDeleteObjectDesc (SecondDesc); 375 } 376 break; 377 378 case ACPI_TYPE_BUFFER_FIELD: 379 380 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 381 "***** Buffer Field %p\n", Object)); 382 383 SecondDesc = AcpiNsGetSecondaryObject (Object); 384 if (SecondDesc) 385 { 386 AcpiUtDeleteObjectDesc (SecondDesc); 387 } 388 break; 389 390 case ACPI_TYPE_LOCAL_BANK_FIELD: 391 392 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 393 "***** Bank Field %p\n", Object)); 394 395 SecondDesc = AcpiNsGetSecondaryObject (Object); 396 if (SecondDesc) 397 { 398 AcpiUtDeleteObjectDesc (SecondDesc); 399 } 400 break; 401 402 default: 403 404 break; 405 } 406 407 /* Free any allocated memory (pointer within the object) found above */ 408 409 if (ObjPointer) 410 { 411 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", 412 ObjPointer)); 413 ACPI_FREE (ObjPointer); 414 } 415 416 /* Now the object can be safely deleted */ 417 418 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", 419 Object, AcpiUtGetObjectTypeName (Object))); 420 421 AcpiUtDeleteObjectDesc (Object); 422 return_VOID; 423 } 424 425 426 /******************************************************************************* 427 * 428 * FUNCTION: AcpiUtDeleteInternalObjectList 429 * 430 * PARAMETERS: ObjList - Pointer to the list to be deleted 431 * 432 * RETURN: None 433 * 434 * DESCRIPTION: This function deletes an internal object list, including both 435 * simple objects and package objects 436 * 437 ******************************************************************************/ 438 439 void 440 AcpiUtDeleteInternalObjectList ( 441 ACPI_OPERAND_OBJECT **ObjList) 442 { 443 ACPI_OPERAND_OBJECT **InternalObj; 444 445 446 ACPI_FUNCTION_ENTRY (); 447 448 449 /* Walk the null-terminated internal list */ 450 451 for (InternalObj = ObjList; *InternalObj; InternalObj++) 452 { 453 AcpiUtRemoveReference (*InternalObj); 454 } 455 456 /* Free the combined parameter pointer list and object array */ 457 458 ACPI_FREE (ObjList); 459 return; 460 } 461 462 463 /******************************************************************************* 464 * 465 * FUNCTION: AcpiUtUpdateRefCount 466 * 467 * PARAMETERS: Object - Object whose ref count is to be updated 468 * Action - What to do (REF_INCREMENT or REF_DECREMENT) 469 * 470 * RETURN: None. Sets new reference count within the object 471 * 472 * DESCRIPTION: Modify the reference count for an internal acpi object 473 * 474 ******************************************************************************/ 475 476 static void 477 AcpiUtUpdateRefCount ( 478 ACPI_OPERAND_OBJECT *Object, 479 UINT32 Action) 480 { 481 UINT16 OriginalCount; 482 UINT16 NewCount = 0; 483 ACPI_CPU_FLAGS LockFlags; 484 485 486 ACPI_FUNCTION_NAME (UtUpdateRefCount); 487 488 489 if (!Object) 490 { 491 return; 492 } 493 494 /* 495 * Always get the reference count lock. Note: Interpreter and/or 496 * Namespace is not always locked when this function is called. 497 */ 498 LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock); 499 OriginalCount = Object->Common.ReferenceCount; 500 501 /* Perform the reference count action (increment, decrement) */ 502 503 switch (Action) 504 { 505 case REF_INCREMENT: 506 507 NewCount = OriginalCount + 1; 508 Object->Common.ReferenceCount = NewCount; 509 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 510 511 /* The current reference count should never be zero here */ 512 513 if (!OriginalCount) 514 { 515 ACPI_WARNING ((AE_INFO, 516 "Obj %p, Reference Count was zero before increment\n", 517 Object)); 518 } 519 520 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 521 "Obj %p Type %.2X Refs %.2X [Incremented]\n", 522 Object, Object->Common.Type, NewCount)); 523 break; 524 525 case REF_DECREMENT: 526 527 /* The current reference count must be non-zero */ 528 529 if (OriginalCount) 530 { 531 NewCount = OriginalCount - 1; 532 Object->Common.ReferenceCount = NewCount; 533 } 534 535 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 536 537 if (!OriginalCount) 538 { 539 ACPI_WARNING ((AE_INFO, 540 "Obj %p, Reference Count is already zero, cannot decrement\n", 541 Object)); 542 } 543 544 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 545 "Obj %p Type %.2X Refs %.2X [Decremented]\n", 546 Object, Object->Common.Type, NewCount)); 547 548 /* Actually delete the object on a reference count of zero */ 549 550 if (NewCount == 0) 551 { 552 AcpiUtDeleteInternalObj (Object); 553 } 554 break; 555 556 default: 557 558 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 559 ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)", 560 Action)); 561 return; 562 } 563 564 /* 565 * Sanity check the reference count, for debug purposes only. 566 * (A deleted object will have a huge reference count) 567 */ 568 if (NewCount > ACPI_MAX_REFERENCE_COUNT) 569 { 570 ACPI_WARNING ((AE_INFO, 571 "Large Reference Count (0x%X) in object %p, Type=0x%.2X", 572 NewCount, Object, Object->Common.Type)); 573 } 574 } 575 576 577 /******************************************************************************* 578 * 579 * FUNCTION: AcpiUtUpdateObjectReference 580 * 581 * PARAMETERS: Object - Increment ref count for this object 582 * and all sub-objects 583 * Action - Either REF_INCREMENT or REF_DECREMENT 584 * 585 * RETURN: Status 586 * 587 * DESCRIPTION: Increment the object reference count 588 * 589 * Object references are incremented when: 590 * 1) An object is attached to a Node (namespace object) 591 * 2) An object is copied (all subobjects must be incremented) 592 * 593 * Object references are decremented when: 594 * 1) An object is detached from an Node 595 * 596 ******************************************************************************/ 597 598 ACPI_STATUS 599 AcpiUtUpdateObjectReference ( 600 ACPI_OPERAND_OBJECT *Object, 601 UINT16 Action) 602 { 603 ACPI_STATUS Status = AE_OK; 604 ACPI_GENERIC_STATE *StateList = NULL; 605 ACPI_OPERAND_OBJECT *NextObject = NULL; 606 ACPI_OPERAND_OBJECT *PrevObject; 607 ACPI_GENERIC_STATE *State; 608 UINT32 i; 609 610 611 ACPI_FUNCTION_NAME (UtUpdateObjectReference); 612 613 614 while (Object) 615 { 616 /* Make sure that this isn't a namespace handle */ 617 618 if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) 619 { 620 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 621 "Object %p is NS handle\n", Object)); 622 return (AE_OK); 623 } 624 625 /* 626 * All sub-objects must have their reference count incremented also. 627 * Different object types have different subobjects. 628 */ 629 switch (Object->Common.Type) 630 { 631 case ACPI_TYPE_DEVICE: 632 case ACPI_TYPE_PROCESSOR: 633 case ACPI_TYPE_POWER: 634 case ACPI_TYPE_THERMAL: 635 /* 636 * Update the notify objects for these types (if present) 637 * Two lists, system and device notify handlers. 638 */ 639 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) 640 { 641 PrevObject = Object->CommonNotify.NotifyList[i]; 642 while (PrevObject) 643 { 644 NextObject = PrevObject->Notify.Next[i]; 645 AcpiUtUpdateRefCount (PrevObject, Action); 646 PrevObject = NextObject; 647 } 648 } 649 break; 650 651 case ACPI_TYPE_PACKAGE: 652 /* 653 * We must update all the sub-objects of the package, 654 * each of whom may have their own sub-objects. 655 */ 656 for (i = 0; i < Object->Package.Count; i++) 657 { 658 /* 659 * Null package elements are legal and can be simply 660 * ignored. 661 */ 662 NextObject = Object->Package.Elements[i]; 663 if (!NextObject) 664 { 665 continue; 666 } 667 668 switch (NextObject->Common.Type) 669 { 670 case ACPI_TYPE_INTEGER: 671 case ACPI_TYPE_STRING: 672 case ACPI_TYPE_BUFFER: 673 /* 674 * For these very simple sub-objects, we can just 675 * update the reference count here and continue. 676 * Greatly increases performance of this operation. 677 */ 678 AcpiUtUpdateRefCount (NextObject, Action); 679 break; 680 681 default: 682 /* 683 * For complex sub-objects, push them onto the stack 684 * for later processing (this eliminates recursion.) 685 */ 686 Status = AcpiUtCreateUpdateStateAndPush ( 687 NextObject, Action, &StateList); 688 if (ACPI_FAILURE (Status)) 689 { 690 goto ErrorExit; 691 } 692 break; 693 } 694 } 695 NextObject = NULL; 696 break; 697 698 case ACPI_TYPE_BUFFER_FIELD: 699 700 NextObject = Object->BufferField.BufferObj; 701 break; 702 703 case ACPI_TYPE_LOCAL_REGION_FIELD: 704 705 NextObject = Object->Field.RegionObj; 706 break; 707 708 case ACPI_TYPE_LOCAL_BANK_FIELD: 709 710 NextObject = Object->BankField.BankObj; 711 Status = AcpiUtCreateUpdateStateAndPush ( 712 Object->BankField.RegionObj, Action, &StateList); 713 if (ACPI_FAILURE (Status)) 714 { 715 goto ErrorExit; 716 } 717 break; 718 719 case ACPI_TYPE_LOCAL_INDEX_FIELD: 720 721 NextObject = Object->IndexField.IndexObj; 722 Status = AcpiUtCreateUpdateStateAndPush ( 723 Object->IndexField.DataObj, Action, &StateList); 724 if (ACPI_FAILURE (Status)) 725 { 726 goto ErrorExit; 727 } 728 break; 729 730 case ACPI_TYPE_LOCAL_REFERENCE: 731 /* 732 * The target of an Index (a package, string, or buffer) or a named 733 * reference must track changes to the ref count of the index or 734 * target object. 735 */ 736 if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || 737 (Object->Reference.Class== ACPI_REFCLASS_NAME)) 738 { 739 NextObject = Object->Reference.Object; 740 } 741 break; 742 743 case ACPI_TYPE_REGION: 744 default: 745 746 break; /* No subobjects for all other types */ 747 } 748 749 /* 750 * Now we can update the count in the main object. This can only 751 * happen after we update the sub-objects in case this causes the 752 * main object to be deleted. 753 */ 754 AcpiUtUpdateRefCount (Object, Action); 755 Object = NULL; 756 757 /* Move on to the next object to be updated */ 758 759 if (NextObject) 760 { 761 Object = NextObject; 762 NextObject = NULL; 763 } 764 else if (StateList) 765 { 766 State = AcpiUtPopGenericState (&StateList); 767 Object = State->Update.Object; 768 AcpiUtDeleteGenericState (State); 769 } 770 } 771 772 return (AE_OK); 773 774 775 ErrorExit: 776 777 ACPI_EXCEPTION ((AE_INFO, Status, 778 "Could not update object reference count")); 779 780 /* Free any stacked Update State objects */ 781 782 while (StateList) 783 { 784 State = AcpiUtPopGenericState (&StateList); 785 AcpiUtDeleteGenericState (State); 786 } 787 788 return (Status); 789 } 790 791 792 /******************************************************************************* 793 * 794 * FUNCTION: AcpiUtAddReference 795 * 796 * PARAMETERS: Object - Object whose reference count is to be 797 * incremented 798 * 799 * RETURN: None 800 * 801 * DESCRIPTION: Add one reference to an ACPI object 802 * 803 ******************************************************************************/ 804 805 void 806 AcpiUtAddReference ( 807 ACPI_OPERAND_OBJECT *Object) 808 { 809 810 ACPI_FUNCTION_NAME (UtAddReference); 811 812 813 /* Ensure that we have a valid object */ 814 815 if (!AcpiUtValidInternalObject (Object)) 816 { 817 return; 818 } 819 820 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 821 "Obj %p Current Refs=%X [To Be Incremented]\n", 822 Object, Object->Common.ReferenceCount)); 823 824 /* Increment the reference count */ 825 826 (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); 827 return; 828 } 829 830 831 /******************************************************************************* 832 * 833 * FUNCTION: AcpiUtRemoveReference 834 * 835 * PARAMETERS: Object - Object whose ref count will be decremented 836 * 837 * RETURN: None 838 * 839 * DESCRIPTION: Decrement the reference count of an ACPI internal object 840 * 841 ******************************************************************************/ 842 843 void 844 AcpiUtRemoveReference ( 845 ACPI_OPERAND_OBJECT *Object) 846 { 847 848 ACPI_FUNCTION_NAME (UtRemoveReference); 849 850 851 /* 852 * Allow a NULL pointer to be passed in, just ignore it. This saves 853 * each caller from having to check. Also, ignore NS nodes. 854 */ 855 if (!Object || 856 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) 857 858 { 859 return; 860 } 861 862 /* Ensure that we have a valid object */ 863 864 if (!AcpiUtValidInternalObject (Object)) 865 { 866 return; 867 } 868 869 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 870 "Obj %p Current Refs=%X [To Be Decremented]\n", 871 Object, Object->Common.ReferenceCount)); 872 873 /* 874 * Decrement the reference count, and only actually delete the object 875 * if the reference count becomes 0. (Must also decrement the ref count 876 * of all subobjects!) 877 */ 878 (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); 879 return; 880 } 881