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