Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/utdelete.c need to be fixed.

0001 /*******************************************************************************
0002  *
0003  * Module Name: utdelete - object deletion and reference count utilities
0004  *
0005  ******************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights.  You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code.  No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision.  In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change.  Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee.  Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution.  In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government.  In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************/
0115 
0116 #define __UTDELETE_C__
0117 
0118 #include "acpi.h"
0119 #include "accommon.h"
0120 #include "acinterp.h"
0121 #include "acnamesp.h"
0122 #include "acevents.h"
0123 
0124 
0125 #define _COMPONENT          ACPI_UTILITIES
0126         ACPI_MODULE_NAME    ("utdelete")
0127 
0128 /* Local prototypes */
0129 
0130 static void
0131 AcpiUtDeleteInternalObj (
0132     ACPI_OPERAND_OBJECT     *Object);
0133 
0134 static void
0135 AcpiUtUpdateRefCount (
0136     ACPI_OPERAND_OBJECT     *Object,
0137     UINT32                  Action);
0138 
0139 
0140 /*******************************************************************************
0141  *
0142  * FUNCTION:    AcpiUtDeleteInternalObj
0143  *
0144  * PARAMETERS:  Object         - Object to be deleted
0145  *
0146  * RETURN:      None
0147  *
0148  * DESCRIPTION: Low level object deletion, after reference counts have been
0149  *              updated (All reference counts, including sub-objects!)
0150  *
0151  ******************************************************************************/
0152 
0153 static void
0154 AcpiUtDeleteInternalObj (
0155     ACPI_OPERAND_OBJECT     *Object)
0156 {
0157     void                    *ObjPointer = NULL;
0158     ACPI_OPERAND_OBJECT     *HandlerDesc;
0159     ACPI_OPERAND_OBJECT     *SecondDesc;
0160     ACPI_OPERAND_OBJECT     *NextDesc;
0161     ACPI_OPERAND_OBJECT     **LastObjPtr;
0162 
0163 
0164     ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
0165 
0166 
0167     if (!Object)
0168     {
0169         return_VOID;
0170     }
0171 
0172     /*
0173      * Must delete or free any pointers within the object that are not
0174      * actual ACPI objects (for example, a raw buffer pointer).
0175      */
0176     switch (Object->Common.Type)
0177     {
0178     case ACPI_TYPE_STRING:
0179 
0180         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
0181             Object, Object->String.Pointer));
0182 
0183         /* Free the actual string buffer */
0184 
0185         if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
0186         {
0187             /* But only if it is NOT a pointer into an ACPI table */
0188 
0189             ObjPointer = Object->String.Pointer;
0190         }
0191         break;
0192 
0193 
0194     case ACPI_TYPE_BUFFER:
0195 
0196         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
0197             Object, Object->Buffer.Pointer));
0198 
0199         /* Free the actual buffer */
0200 
0201         if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
0202         {
0203             /* But only if it is NOT a pointer into an ACPI table */
0204 
0205             ObjPointer = Object->Buffer.Pointer;
0206         }
0207         break;
0208 
0209 
0210     case ACPI_TYPE_PACKAGE:
0211 
0212         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
0213             Object->Package.Count));
0214 
0215         /*
0216          * Elements of the package are not handled here, they are deleted
0217          * separately
0218          */
0219 
0220         /* Free the (variable length) element pointer array */
0221 
0222         ObjPointer = Object->Package.Elements;
0223         break;
0224 
0225 
0226     /*
0227      * These objects have a possible list of notify handlers.
0228      * Device object also may have a GPE block.
0229      */
0230     case ACPI_TYPE_DEVICE:
0231 
0232         if (Object->Device.GpeBlock)
0233         {
0234             (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
0235         }
0236 
0237         /*lint -fallthrough */
0238 
0239     case ACPI_TYPE_PROCESSOR:
0240     case ACPI_TYPE_THERMAL:
0241 
0242         /* Walk the notify handler list for this object */
0243 
0244         HandlerDesc = Object->CommonNotify.Handler;
0245         while (HandlerDesc)
0246         {
0247             NextDesc = HandlerDesc->AddressSpace.Next;
0248             AcpiUtRemoveReference (HandlerDesc);
0249             HandlerDesc = NextDesc;
0250         }
0251         break;
0252 
0253 
0254     case ACPI_TYPE_MUTEX:
0255 
0256         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0257             "***** Mutex %p, OS Mutex %p\n",
0258             Object, Object->Mutex.OsMutex));
0259 
0260         if (Object == AcpiGbl_GlobalLockMutex)
0261         {
0262             /* Global Lock has extra semaphore */
0263 
0264             (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
0265             AcpiGbl_GlobalLockSemaphore = NULL;
0266 
0267             AcpiOsDeleteMutex (Object->Mutex.OsMutex);
0268             AcpiGbl_GlobalLockMutex = NULL;
0269         }
0270         else
0271         {
0272             AcpiExUnlinkMutex (Object);
0273             AcpiOsDeleteMutex (Object->Mutex.OsMutex);
0274         }
0275         break;
0276 
0277 
0278     case ACPI_TYPE_EVENT:
0279 
0280         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0281             "***** Event %p, OS Semaphore %p\n",
0282             Object, Object->Event.OsSemaphore));
0283 
0284         (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
0285         Object->Event.OsSemaphore = NULL;
0286         break;
0287 
0288 
0289     case ACPI_TYPE_METHOD:
0290 
0291         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0292             "***** Method %p\n", Object));
0293 
0294         /* Delete the method mutex if it exists */
0295 
0296         if (Object->Method.Mutex)
0297         {
0298             AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
0299             AcpiUtDeleteObjectDesc (Object->Method.Mutex);
0300             Object->Method.Mutex = NULL;
0301         }
0302         break;
0303 
0304 
0305     case ACPI_TYPE_REGION:
0306 
0307         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0308             "***** Region %p\n", Object));
0309 
0310         SecondDesc = AcpiNsGetSecondaryObject (Object);
0311         if (SecondDesc)
0312         {
0313             /*
0314              * Free the RegionContext if and only if the handler is one of the
0315              * default handlers -- and therefore, we created the context object
0316              * locally, it was not created by an external caller.
0317              */
0318             HandlerDesc = Object->Region.Handler;
0319             if (HandlerDesc)
0320             {
0321                 NextDesc = HandlerDesc->AddressSpace.RegionList;
0322                 LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
0323 
0324                 /* Remove the region object from the handler's list */
0325 
0326                 while (NextDesc)
0327                 {
0328                     if (NextDesc == Object)
0329                     {
0330                         *LastObjPtr = NextDesc->Region.Next;
0331                         break;
0332                     }
0333 
0334                     /* Walk the linked list of handler */
0335 
0336                     LastObjPtr = &NextDesc->Region.Next;
0337                     NextDesc = NextDesc->Region.Next;
0338                 }
0339 
0340                 if (HandlerDesc->AddressSpace.HandlerFlags &
0341                     ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
0342                 {
0343                     /* Deactivate region and free region context */
0344 
0345                     if (HandlerDesc->AddressSpace.Setup)
0346                     {
0347                         (void) HandlerDesc->AddressSpace.Setup (Object,
0348                             ACPI_REGION_DEACTIVATE,
0349                             HandlerDesc->AddressSpace.Context,
0350                             &SecondDesc->Extra.RegionContext);
0351                     }
0352                 }
0353 
0354                 AcpiUtRemoveReference (HandlerDesc);
0355             }
0356 
0357             /* Now we can free the Extra object */
0358 
0359             AcpiUtDeleteObjectDesc (SecondDesc);
0360         }
0361         break;
0362 
0363 
0364     case ACPI_TYPE_BUFFER_FIELD:
0365 
0366         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0367             "***** Buffer Field %p\n", Object));
0368 
0369         SecondDesc = AcpiNsGetSecondaryObject (Object);
0370         if (SecondDesc)
0371         {
0372             AcpiUtDeleteObjectDesc (SecondDesc);
0373         }
0374         break;
0375 
0376 
0377     case ACPI_TYPE_LOCAL_BANK_FIELD:
0378 
0379         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0380             "***** Bank Field %p\n", Object));
0381 
0382         SecondDesc = AcpiNsGetSecondaryObject (Object);
0383         if (SecondDesc)
0384         {
0385             AcpiUtDeleteObjectDesc (SecondDesc);
0386         }
0387         break;
0388 
0389 
0390     default:
0391         break;
0392     }
0393 
0394     /* Free any allocated memory (pointer within the object) found above */
0395 
0396     if (ObjPointer)
0397     {
0398         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
0399             ObjPointer));
0400         ACPI_FREE (ObjPointer);
0401     }
0402 
0403     /* Now the object can be safely deleted */
0404 
0405     ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
0406         Object, AcpiUtGetObjectTypeName (Object)));
0407 
0408     AcpiUtDeleteObjectDesc (Object);
0409     return_VOID;
0410 }
0411 
0412 
0413 /*******************************************************************************
0414  *
0415  * FUNCTION:    AcpiUtDeleteInternalObjectList
0416  *
0417  * PARAMETERS:  ObjList         - Pointer to the list to be deleted
0418  *
0419  * RETURN:      None
0420  *
0421  * DESCRIPTION: This function deletes an internal object list, including both
0422  *              simple objects and package objects
0423  *
0424  ******************************************************************************/
0425 
0426 void
0427 AcpiUtDeleteInternalObjectList (
0428     ACPI_OPERAND_OBJECT     **ObjList)
0429 {
0430     ACPI_OPERAND_OBJECT     **InternalObj;
0431 
0432 
0433     ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList);
0434 
0435 
0436     /* Walk the null-terminated internal list */
0437 
0438     for (InternalObj = ObjList; *InternalObj; InternalObj++)
0439     {
0440         AcpiUtRemoveReference (*InternalObj);
0441     }
0442 
0443     /* Free the combined parameter pointer list and object array */
0444 
0445     ACPI_FREE (ObjList);
0446     return_VOID;
0447 }
0448 
0449 
0450 /*******************************************************************************
0451  *
0452  * FUNCTION:    AcpiUtUpdateRefCount
0453  *
0454  * PARAMETERS:  Object          - Object whose ref count is to be updated
0455  *              Action          - What to do
0456  *
0457  * RETURN:      New ref count
0458  *
0459  * DESCRIPTION: Modify the ref count and return it.
0460  *
0461  ******************************************************************************/
0462 
0463 static void
0464 AcpiUtUpdateRefCount (
0465     ACPI_OPERAND_OBJECT     *Object,
0466     UINT32                  Action)
0467 {
0468     UINT16                  Count;
0469     UINT16                  NewCount;
0470 
0471 
0472     ACPI_FUNCTION_NAME (UtUpdateRefCount);
0473 
0474 
0475     if (!Object)
0476     {
0477         return;
0478     }
0479 
0480     Count = Object->Common.ReferenceCount;
0481     NewCount = Count;
0482 
0483     /*
0484      * Perform the reference count action (increment, decrement, force delete)
0485      */
0486     switch (Action)
0487     {
0488     case REF_INCREMENT:
0489 
0490         NewCount++;
0491         Object->Common.ReferenceCount = NewCount;
0492 
0493         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0494             "Obj %p Refs=%X, [Incremented]\n",
0495             Object, NewCount));
0496         break;
0497 
0498     case REF_DECREMENT:
0499 
0500         if (Count < 1)
0501         {
0502             ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0503                 "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
0504                 Object, NewCount));
0505 
0506             NewCount = 0;
0507         }
0508         else
0509         {
0510             NewCount--;
0511 
0512             ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0513                 "Obj %p Refs=%X, [Decremented]\n",
0514                 Object, NewCount));
0515         }
0516 
0517         if (Object->Common.Type == ACPI_TYPE_METHOD)
0518         {
0519             ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0520                 "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount));
0521         }
0522 
0523         Object->Common.ReferenceCount = NewCount;
0524         if (NewCount == 0)
0525         {
0526             AcpiUtDeleteInternalObj (Object);
0527         }
0528         break;
0529 
0530     case REF_FORCE_DELETE:
0531 
0532         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0533             "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count));
0534 
0535         NewCount = 0;
0536         Object->Common.ReferenceCount = NewCount;
0537         AcpiUtDeleteInternalObj (Object);
0538         break;
0539 
0540     default:
0541 
0542         ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action));
0543         break;
0544     }
0545 
0546     /*
0547      * Sanity check the reference count, for debug purposes only.
0548      * (A deleted object will have a huge reference count)
0549      */
0550     if (Count > ACPI_MAX_REFERENCE_COUNT)
0551     {
0552         ACPI_WARNING ((AE_INFO,
0553             "Large Reference Count (%X) in object %p", Count, Object));
0554     }
0555 }
0556 
0557 
0558 /*******************************************************************************
0559  *
0560  * FUNCTION:    AcpiUtUpdateObjectReference
0561  *
0562  * PARAMETERS:  Object              - Increment ref count for this object
0563  *                                    and all sub-objects
0564  *              Action              - Either REF_INCREMENT or REF_DECREMENT or
0565  *                                    REF_FORCE_DELETE
0566  *
0567  * RETURN:      Status
0568  *
0569  * DESCRIPTION: Increment the object reference count
0570  *
0571  * Object references are incremented when:
0572  * 1) An object is attached to a Node (namespace object)
0573  * 2) An object is copied (all subobjects must be incremented)
0574  *
0575  * Object references are decremented when:
0576  * 1) An object is detached from an Node
0577  *
0578  ******************************************************************************/
0579 
0580 ACPI_STATUS
0581 AcpiUtUpdateObjectReference (
0582     ACPI_OPERAND_OBJECT     *Object,
0583     UINT16                  Action)
0584 {
0585     ACPI_STATUS             Status = AE_OK;
0586     ACPI_GENERIC_STATE      *StateList = NULL;
0587     ACPI_OPERAND_OBJECT     *NextObject = NULL;
0588     ACPI_GENERIC_STATE      *State;
0589     UINT32                  i;
0590 
0591 
0592     ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object);
0593 
0594 
0595     while (Object)
0596     {
0597         /* Make sure that this isn't a namespace handle */
0598 
0599         if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
0600         {
0601             ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0602                 "Object %p is NS handle\n", Object));
0603             return_ACPI_STATUS (AE_OK);
0604         }
0605 
0606         /*
0607          * All sub-objects must have their reference count incremented also.
0608          * Different object types have different subobjects.
0609          */
0610         switch (Object->Common.Type)
0611         {
0612         case ACPI_TYPE_DEVICE:
0613         case ACPI_TYPE_PROCESSOR:
0614         case ACPI_TYPE_POWER:
0615         case ACPI_TYPE_THERMAL:
0616 
0617             /* Update the notify objects for these types (if present) */
0618 
0619             AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action);
0620             AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action);
0621             break;
0622 
0623         case ACPI_TYPE_PACKAGE:
0624             /*
0625              * We must update all the sub-objects of the package,
0626              * each of whom may have their own sub-objects.
0627              */
0628             for (i = 0; i < Object->Package.Count; i++)
0629             {
0630                 /*
0631                  * Push each element onto the stack for later processing.
0632                  * Note: There can be null elements within the package,
0633                  * these are simply ignored
0634                  */
0635                 Status = AcpiUtCreateUpdateStateAndPush (
0636                             Object->Package.Elements[i], Action, &StateList);
0637                 if (ACPI_FAILURE (Status))
0638                 {
0639                     goto ErrorExit;
0640                 }
0641             }
0642             break;
0643 
0644         case ACPI_TYPE_BUFFER_FIELD:
0645 
0646             NextObject = Object->BufferField.BufferObj;
0647             break;
0648 
0649         case ACPI_TYPE_LOCAL_REGION_FIELD:
0650 
0651             NextObject = Object->Field.RegionObj;
0652             break;
0653 
0654         case ACPI_TYPE_LOCAL_BANK_FIELD:
0655 
0656             NextObject = Object->BankField.BankObj;
0657             Status = AcpiUtCreateUpdateStateAndPush (
0658                         Object->BankField.RegionObj, Action, &StateList);
0659             if (ACPI_FAILURE (Status))
0660             {
0661                 goto ErrorExit;
0662             }
0663             break;
0664 
0665         case ACPI_TYPE_LOCAL_INDEX_FIELD:
0666 
0667             NextObject = Object->IndexField.IndexObj;
0668             Status = AcpiUtCreateUpdateStateAndPush (
0669                         Object->IndexField.DataObj, Action, &StateList);
0670             if (ACPI_FAILURE (Status))
0671             {
0672                 goto ErrorExit;
0673             }
0674             break;
0675 
0676         case ACPI_TYPE_LOCAL_REFERENCE:
0677             /*
0678              * The target of an Index (a package, string, or buffer) or a named
0679              * reference must track changes to the ref count of the index or
0680              * target object.
0681              */
0682             if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
0683                 (Object->Reference.Class== ACPI_REFCLASS_NAME))
0684             {
0685                 NextObject = Object->Reference.Object;
0686             }
0687             break;
0688 
0689         case ACPI_TYPE_REGION:
0690         default:
0691             break; /* No subobjects for all other types */
0692         }
0693 
0694         /*
0695          * Now we can update the count in the main object. This can only
0696          * happen after we update the sub-objects in case this causes the
0697          * main object to be deleted.
0698          */
0699         AcpiUtUpdateRefCount (Object, Action);
0700         Object = NULL;
0701 
0702         /* Move on to the next object to be updated */
0703 
0704         if (NextObject)
0705         {
0706             Object = NextObject;
0707             NextObject = NULL;
0708         }
0709         else if (StateList)
0710         {
0711             State = AcpiUtPopGenericState (&StateList);
0712             Object = State->Update.Object;
0713             AcpiUtDeleteGenericState (State);
0714         }
0715     }
0716 
0717     return_ACPI_STATUS (AE_OK);
0718 
0719 
0720 ErrorExit:
0721 
0722     ACPI_EXCEPTION ((AE_INFO, Status,
0723         "Could not update object reference count"));
0724 
0725     /* Free any stacked Update State objects */
0726 
0727     while (StateList)
0728     {
0729         State = AcpiUtPopGenericState (&StateList);
0730         AcpiUtDeleteGenericState (State);
0731     }
0732 
0733     return_ACPI_STATUS (Status);
0734 }
0735 
0736 
0737 /*******************************************************************************
0738  *
0739  * FUNCTION:    AcpiUtAddReference
0740  *
0741  * PARAMETERS:  Object          - Object whose reference count is to be
0742  *                                incremented
0743  *
0744  * RETURN:      None
0745  *
0746  * DESCRIPTION: Add one reference to an ACPI object
0747  *
0748  ******************************************************************************/
0749 
0750 void
0751 AcpiUtAddReference (
0752     ACPI_OPERAND_OBJECT     *Object)
0753 {
0754 
0755     ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object);
0756 
0757 
0758     /* Ensure that we have a valid object */
0759 
0760     if (!AcpiUtValidInternalObject (Object))
0761     {
0762         return_VOID;
0763     }
0764 
0765     ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0766         "Obj %p Current Refs=%X [To Be Incremented]\n",
0767         Object, Object->Common.ReferenceCount));
0768 
0769     /* Increment the reference count */
0770 
0771     (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
0772     return_VOID;
0773 }
0774 
0775 
0776 /*******************************************************************************
0777  *
0778  * FUNCTION:    AcpiUtRemoveReference
0779  *
0780  * PARAMETERS:  Object         - Object whose ref count will be decremented
0781  *
0782  * RETURN:      None
0783  *
0784  * DESCRIPTION: Decrement the reference count of an ACPI internal object
0785  *
0786  ******************************************************************************/
0787 
0788 void
0789 AcpiUtRemoveReference (
0790     ACPI_OPERAND_OBJECT     *Object)
0791 {
0792 
0793     ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object);
0794 
0795 
0796     /*
0797      * Allow a NULL pointer to be passed in, just ignore it. This saves
0798      * each caller from having to check. Also, ignore NS nodes.
0799      *
0800      */
0801     if (!Object ||
0802         (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
0803 
0804     {
0805         return_VOID;
0806     }
0807 
0808     /* Ensure that we have a valid object */
0809 
0810     if (!AcpiUtValidInternalObject (Object))
0811     {
0812         return_VOID;
0813     }
0814 
0815     ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
0816         "Obj %p Current Refs=%X [To Be Decremented]\n",
0817         Object, Object->Common.ReferenceCount));
0818 
0819     /*
0820      * Decrement the reference count, and only actually delete the object
0821      * if the reference count becomes 0. (Must also decrement the ref count
0822      * of all subobjects!)
0823      */
0824     (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
0825     return_VOID;
0826 }
0827 
0828