1433d6423SLionel Sambuc /*******************************************************************************
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * Module Name: utdelete - object deletion and reference count utilities
4433d6423SLionel Sambuc *
5433d6423SLionel Sambuc ******************************************************************************/
6433d6423SLionel Sambuc
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc * All rights reserved.
10433d6423SLionel Sambuc *
11*29492bb7SDavid van Moolenbroek * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek * are met:
14*29492bb7SDavid van Moolenbroek * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek * notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek * without modification.
17*29492bb7SDavid van Moolenbroek * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek * substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek * ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek * including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek * binary redistribution.
22*29492bb7SDavid van Moolenbroek * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek * of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek * from this software without specific prior written permission.
25433d6423SLionel Sambuc *
26*29492bb7SDavid van Moolenbroek * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek * Software Foundation.
29433d6423SLionel Sambuc *
30*29492bb7SDavid van Moolenbroek * NO WARRANTY
31*29492bb7SDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek */
43433d6423SLionel Sambuc
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acinterp.h"
47433d6423SLionel Sambuc #include "acnamesp.h"
48433d6423SLionel Sambuc #include "acevents.h"
49433d6423SLionel Sambuc
50433d6423SLionel Sambuc
51433d6423SLionel Sambuc #define _COMPONENT ACPI_UTILITIES
52433d6423SLionel Sambuc ACPI_MODULE_NAME ("utdelete")
53433d6423SLionel Sambuc
54433d6423SLionel Sambuc /* Local prototypes */
55433d6423SLionel Sambuc
56433d6423SLionel Sambuc static void
57433d6423SLionel Sambuc AcpiUtDeleteInternalObj (
58433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object);
59433d6423SLionel Sambuc
60433d6423SLionel Sambuc static void
61433d6423SLionel Sambuc AcpiUtUpdateRefCount (
62433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object,
63433d6423SLionel Sambuc UINT32 Action);
64433d6423SLionel Sambuc
65433d6423SLionel Sambuc
66433d6423SLionel Sambuc /*******************************************************************************
67433d6423SLionel Sambuc *
68433d6423SLionel Sambuc * FUNCTION: AcpiUtDeleteInternalObj
69433d6423SLionel Sambuc *
70433d6423SLionel Sambuc * PARAMETERS: Object - Object to be deleted
71433d6423SLionel Sambuc *
72433d6423SLionel Sambuc * RETURN: None
73433d6423SLionel Sambuc *
74433d6423SLionel Sambuc * DESCRIPTION: Low level object deletion, after reference counts have been
75433d6423SLionel Sambuc * updated (All reference counts, including sub-objects!)
76433d6423SLionel Sambuc *
77433d6423SLionel Sambuc ******************************************************************************/
78433d6423SLionel Sambuc
79433d6423SLionel Sambuc static void
AcpiUtDeleteInternalObj(ACPI_OPERAND_OBJECT * Object)80433d6423SLionel Sambuc AcpiUtDeleteInternalObj (
81433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object)
82433d6423SLionel Sambuc {
83433d6423SLionel Sambuc void *ObjPointer = NULL;
84433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *HandlerDesc;
85433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *SecondDesc;
86433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *NextDesc;
87*29492bb7SDavid van Moolenbroek ACPI_OPERAND_OBJECT *StartDesc;
88433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **LastObjPtr;
89433d6423SLionel Sambuc
90433d6423SLionel Sambuc
91433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
92433d6423SLionel Sambuc
93433d6423SLionel Sambuc
94433d6423SLionel Sambuc if (!Object)
95433d6423SLionel Sambuc {
96433d6423SLionel Sambuc return_VOID;
97433d6423SLionel Sambuc }
98433d6423SLionel Sambuc
99433d6423SLionel Sambuc /*
100433d6423SLionel Sambuc * Must delete or free any pointers within the object that are not
101433d6423SLionel Sambuc * actual ACPI objects (for example, a raw buffer pointer).
102433d6423SLionel Sambuc */
103433d6423SLionel Sambuc switch (Object->Common.Type)
104433d6423SLionel Sambuc {
105433d6423SLionel Sambuc case ACPI_TYPE_STRING:
106433d6423SLionel Sambuc
107433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
108433d6423SLionel Sambuc Object, Object->String.Pointer));
109433d6423SLionel Sambuc
110433d6423SLionel Sambuc /* Free the actual string buffer */
111433d6423SLionel Sambuc
112433d6423SLionel Sambuc if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
113433d6423SLionel Sambuc {
114433d6423SLionel Sambuc /* But only if it is NOT a pointer into an ACPI table */
115433d6423SLionel Sambuc
116433d6423SLionel Sambuc ObjPointer = Object->String.Pointer;
117433d6423SLionel Sambuc }
118433d6423SLionel Sambuc break;
119433d6423SLionel Sambuc
120433d6423SLionel Sambuc case ACPI_TYPE_BUFFER:
121433d6423SLionel Sambuc
122433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
123433d6423SLionel Sambuc Object, Object->Buffer.Pointer));
124433d6423SLionel Sambuc
125433d6423SLionel Sambuc /* Free the actual buffer */
126433d6423SLionel Sambuc
127433d6423SLionel Sambuc if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
128433d6423SLionel Sambuc {
129433d6423SLionel Sambuc /* But only if it is NOT a pointer into an ACPI table */
130433d6423SLionel Sambuc
131433d6423SLionel Sambuc ObjPointer = Object->Buffer.Pointer;
132433d6423SLionel Sambuc }
133433d6423SLionel Sambuc break;
134433d6423SLionel Sambuc
135433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE:
136433d6423SLionel Sambuc
137433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
138433d6423SLionel Sambuc Object->Package.Count));
139433d6423SLionel Sambuc
140433d6423SLionel Sambuc /*
141433d6423SLionel Sambuc * Elements of the package are not handled here, they are deleted
142433d6423SLionel Sambuc * separately
143433d6423SLionel Sambuc */
144433d6423SLionel Sambuc
145433d6423SLionel Sambuc /* Free the (variable length) element pointer array */
146433d6423SLionel Sambuc
147433d6423SLionel Sambuc ObjPointer = Object->Package.Elements;
148433d6423SLionel Sambuc break;
149433d6423SLionel Sambuc
150433d6423SLionel Sambuc /*
151433d6423SLionel Sambuc * These objects have a possible list of notify handlers.
152433d6423SLionel Sambuc * Device object also may have a GPE block.
153433d6423SLionel Sambuc */
154433d6423SLionel Sambuc case ACPI_TYPE_DEVICE:
155433d6423SLionel Sambuc
156433d6423SLionel Sambuc if (Object->Device.GpeBlock)
157433d6423SLionel Sambuc {
158433d6423SLionel Sambuc (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
159433d6423SLionel Sambuc }
160433d6423SLionel Sambuc
161433d6423SLionel Sambuc /*lint -fallthrough */
162433d6423SLionel Sambuc
163433d6423SLionel Sambuc case ACPI_TYPE_PROCESSOR:
164433d6423SLionel Sambuc case ACPI_TYPE_THERMAL:
165433d6423SLionel Sambuc
166*29492bb7SDavid van Moolenbroek /* Walk the address handler list for this object */
167433d6423SLionel Sambuc
168433d6423SLionel Sambuc HandlerDesc = Object->CommonNotify.Handler;
169433d6423SLionel Sambuc while (HandlerDesc)
170433d6423SLionel Sambuc {
171433d6423SLionel Sambuc NextDesc = HandlerDesc->AddressSpace.Next;
172433d6423SLionel Sambuc AcpiUtRemoveReference (HandlerDesc);
173433d6423SLionel Sambuc HandlerDesc = NextDesc;
174433d6423SLionel Sambuc }
175433d6423SLionel Sambuc break;
176433d6423SLionel Sambuc
177433d6423SLionel Sambuc case ACPI_TYPE_MUTEX:
178433d6423SLionel Sambuc
179433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
180433d6423SLionel Sambuc "***** Mutex %p, OS Mutex %p\n",
181433d6423SLionel Sambuc Object, Object->Mutex.OsMutex));
182433d6423SLionel Sambuc
183433d6423SLionel Sambuc if (Object == AcpiGbl_GlobalLockMutex)
184433d6423SLionel Sambuc {
185433d6423SLionel Sambuc /* Global Lock has extra semaphore */
186433d6423SLionel Sambuc
187433d6423SLionel Sambuc (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
188433d6423SLionel Sambuc AcpiGbl_GlobalLockSemaphore = NULL;
189433d6423SLionel Sambuc
190433d6423SLionel Sambuc AcpiOsDeleteMutex (Object->Mutex.OsMutex);
191433d6423SLionel Sambuc AcpiGbl_GlobalLockMutex = NULL;
192433d6423SLionel Sambuc }
193433d6423SLionel Sambuc else
194433d6423SLionel Sambuc {
195433d6423SLionel Sambuc AcpiExUnlinkMutex (Object);
196433d6423SLionel Sambuc AcpiOsDeleteMutex (Object->Mutex.OsMutex);
197433d6423SLionel Sambuc }
198433d6423SLionel Sambuc break;
199433d6423SLionel Sambuc
200433d6423SLionel Sambuc case ACPI_TYPE_EVENT:
201433d6423SLionel Sambuc
202433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
203433d6423SLionel Sambuc "***** Event %p, OS Semaphore %p\n",
204433d6423SLionel Sambuc Object, Object->Event.OsSemaphore));
205433d6423SLionel Sambuc
206433d6423SLionel Sambuc (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
207433d6423SLionel Sambuc Object->Event.OsSemaphore = NULL;
208433d6423SLionel Sambuc break;
209433d6423SLionel Sambuc
210433d6423SLionel Sambuc case ACPI_TYPE_METHOD:
211433d6423SLionel Sambuc
212433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
213433d6423SLionel Sambuc "***** Method %p\n", Object));
214433d6423SLionel Sambuc
215433d6423SLionel Sambuc /* Delete the method mutex if it exists */
216433d6423SLionel Sambuc
217433d6423SLionel Sambuc if (Object->Method.Mutex)
218433d6423SLionel Sambuc {
219433d6423SLionel Sambuc AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
220433d6423SLionel Sambuc AcpiUtDeleteObjectDesc (Object->Method.Mutex);
221433d6423SLionel Sambuc Object->Method.Mutex = NULL;
222433d6423SLionel Sambuc }
223433d6423SLionel Sambuc break;
224433d6423SLionel Sambuc
225433d6423SLionel Sambuc case ACPI_TYPE_REGION:
226433d6423SLionel Sambuc
227433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
228433d6423SLionel Sambuc "***** Region %p\n", Object));
229433d6423SLionel Sambuc
230*29492bb7SDavid van Moolenbroek /*
231*29492bb7SDavid van Moolenbroek * Update AddressRange list. However, only permanent regions
232*29492bb7SDavid van Moolenbroek * are installed in this list. (Not created within a method)
233*29492bb7SDavid van Moolenbroek */
234*29492bb7SDavid van Moolenbroek if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
235*29492bb7SDavid van Moolenbroek {
236*29492bb7SDavid van Moolenbroek AcpiUtRemoveAddressRange (Object->Region.SpaceId,
237*29492bb7SDavid van Moolenbroek Object->Region.Node);
238*29492bb7SDavid van Moolenbroek }
239*29492bb7SDavid van Moolenbroek
240433d6423SLionel Sambuc SecondDesc = AcpiNsGetSecondaryObject (Object);
241433d6423SLionel Sambuc if (SecondDesc)
242433d6423SLionel Sambuc {
243433d6423SLionel Sambuc /*
244433d6423SLionel Sambuc * Free the RegionContext if and only if the handler is one of the
245433d6423SLionel Sambuc * default handlers -- and therefore, we created the context object
246433d6423SLionel Sambuc * locally, it was not created by an external caller.
247433d6423SLionel Sambuc */
248433d6423SLionel Sambuc HandlerDesc = Object->Region.Handler;
249433d6423SLionel Sambuc if (HandlerDesc)
250433d6423SLionel Sambuc {
251433d6423SLionel Sambuc NextDesc = HandlerDesc->AddressSpace.RegionList;
252*29492bb7SDavid van Moolenbroek StartDesc = NextDesc;
253433d6423SLionel Sambuc LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
254433d6423SLionel Sambuc
255*29492bb7SDavid van Moolenbroek /* Remove the region object from the handler list */
256433d6423SLionel Sambuc
257433d6423SLionel Sambuc while (NextDesc)
258433d6423SLionel Sambuc {
259433d6423SLionel Sambuc if (NextDesc == Object)
260433d6423SLionel Sambuc {
261433d6423SLionel Sambuc *LastObjPtr = NextDesc->Region.Next;
262433d6423SLionel Sambuc break;
263433d6423SLionel Sambuc }
264433d6423SLionel Sambuc
265*29492bb7SDavid van Moolenbroek /* Walk the linked list of handlers */
266433d6423SLionel Sambuc
267433d6423SLionel Sambuc LastObjPtr = &NextDesc->Region.Next;
268433d6423SLionel Sambuc NextDesc = NextDesc->Region.Next;
269*29492bb7SDavid van Moolenbroek
270*29492bb7SDavid van Moolenbroek /* Prevent infinite loop if list is corrupted */
271*29492bb7SDavid van Moolenbroek
272*29492bb7SDavid van Moolenbroek if (NextDesc == StartDesc)
273*29492bb7SDavid van Moolenbroek {
274*29492bb7SDavid van Moolenbroek ACPI_ERROR ((AE_INFO,
275*29492bb7SDavid van Moolenbroek "Circular region list in address handler object %p",
276*29492bb7SDavid van Moolenbroek HandlerDesc));
277*29492bb7SDavid van Moolenbroek return_VOID;
278*29492bb7SDavid van Moolenbroek }
279433d6423SLionel Sambuc }
280433d6423SLionel Sambuc
281433d6423SLionel Sambuc if (HandlerDesc->AddressSpace.HandlerFlags &
282433d6423SLionel Sambuc ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
283433d6423SLionel Sambuc {
284433d6423SLionel Sambuc /* Deactivate region and free region context */
285433d6423SLionel Sambuc
286433d6423SLionel Sambuc if (HandlerDesc->AddressSpace.Setup)
287433d6423SLionel Sambuc {
288433d6423SLionel Sambuc (void) HandlerDesc->AddressSpace.Setup (Object,
289433d6423SLionel Sambuc ACPI_REGION_DEACTIVATE,
290433d6423SLionel Sambuc HandlerDesc->AddressSpace.Context,
291433d6423SLionel Sambuc &SecondDesc->Extra.RegionContext);
292433d6423SLionel Sambuc }
293433d6423SLionel Sambuc }
294433d6423SLionel Sambuc
295433d6423SLionel Sambuc AcpiUtRemoveReference (HandlerDesc);
296433d6423SLionel Sambuc }
297433d6423SLionel Sambuc
298433d6423SLionel Sambuc /* Now we can free the Extra object */
299433d6423SLionel Sambuc
300433d6423SLionel Sambuc AcpiUtDeleteObjectDesc (SecondDesc);
301433d6423SLionel Sambuc }
302433d6423SLionel Sambuc break;
303433d6423SLionel Sambuc
304433d6423SLionel Sambuc case ACPI_TYPE_BUFFER_FIELD:
305433d6423SLionel Sambuc
306433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
307433d6423SLionel Sambuc "***** Buffer Field %p\n", Object));
308433d6423SLionel Sambuc
309433d6423SLionel Sambuc SecondDesc = AcpiNsGetSecondaryObject (Object);
310433d6423SLionel Sambuc if (SecondDesc)
311433d6423SLionel Sambuc {
312433d6423SLionel Sambuc AcpiUtDeleteObjectDesc (SecondDesc);
313433d6423SLionel Sambuc }
314433d6423SLionel Sambuc break;
315433d6423SLionel Sambuc
316433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_BANK_FIELD:
317433d6423SLionel Sambuc
318433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
319433d6423SLionel Sambuc "***** Bank Field %p\n", Object));
320433d6423SLionel Sambuc
321433d6423SLionel Sambuc SecondDesc = AcpiNsGetSecondaryObject (Object);
322433d6423SLionel Sambuc if (SecondDesc)
323433d6423SLionel Sambuc {
324433d6423SLionel Sambuc AcpiUtDeleteObjectDesc (SecondDesc);
325433d6423SLionel Sambuc }
326433d6423SLionel Sambuc break;
327433d6423SLionel Sambuc
328433d6423SLionel Sambuc default:
329*29492bb7SDavid van Moolenbroek
330433d6423SLionel Sambuc break;
331433d6423SLionel Sambuc }
332433d6423SLionel Sambuc
333433d6423SLionel Sambuc /* Free any allocated memory (pointer within the object) found above */
334433d6423SLionel Sambuc
335433d6423SLionel Sambuc if (ObjPointer)
336433d6423SLionel Sambuc {
337433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
338433d6423SLionel Sambuc ObjPointer));
339433d6423SLionel Sambuc ACPI_FREE (ObjPointer);
340433d6423SLionel Sambuc }
341433d6423SLionel Sambuc
342433d6423SLionel Sambuc /* Now the object can be safely deleted */
343433d6423SLionel Sambuc
344433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
345433d6423SLionel Sambuc Object, AcpiUtGetObjectTypeName (Object)));
346433d6423SLionel Sambuc
347433d6423SLionel Sambuc AcpiUtDeleteObjectDesc (Object);
348433d6423SLionel Sambuc return_VOID;
349433d6423SLionel Sambuc }
350433d6423SLionel Sambuc
351433d6423SLionel Sambuc
352433d6423SLionel Sambuc /*******************************************************************************
353433d6423SLionel Sambuc *
354433d6423SLionel Sambuc * FUNCTION: AcpiUtDeleteInternalObjectList
355433d6423SLionel Sambuc *
356433d6423SLionel Sambuc * PARAMETERS: ObjList - Pointer to the list to be deleted
357433d6423SLionel Sambuc *
358433d6423SLionel Sambuc * RETURN: None
359433d6423SLionel Sambuc *
360433d6423SLionel Sambuc * DESCRIPTION: This function deletes an internal object list, including both
361433d6423SLionel Sambuc * simple objects and package objects
362433d6423SLionel Sambuc *
363433d6423SLionel Sambuc ******************************************************************************/
364433d6423SLionel Sambuc
365433d6423SLionel Sambuc void
AcpiUtDeleteInternalObjectList(ACPI_OPERAND_OBJECT ** ObjList)366433d6423SLionel Sambuc AcpiUtDeleteInternalObjectList (
367433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **ObjList)
368433d6423SLionel Sambuc {
369433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **InternalObj;
370433d6423SLionel Sambuc
371433d6423SLionel Sambuc
372*29492bb7SDavid van Moolenbroek ACPI_FUNCTION_ENTRY ();
373433d6423SLionel Sambuc
374433d6423SLionel Sambuc
375433d6423SLionel Sambuc /* Walk the null-terminated internal list */
376433d6423SLionel Sambuc
377433d6423SLionel Sambuc for (InternalObj = ObjList; *InternalObj; InternalObj++)
378433d6423SLionel Sambuc {
379433d6423SLionel Sambuc AcpiUtRemoveReference (*InternalObj);
380433d6423SLionel Sambuc }
381433d6423SLionel Sambuc
382433d6423SLionel Sambuc /* Free the combined parameter pointer list and object array */
383433d6423SLionel Sambuc
384433d6423SLionel Sambuc ACPI_FREE (ObjList);
385*29492bb7SDavid van Moolenbroek return;
386433d6423SLionel Sambuc }
387433d6423SLionel Sambuc
388433d6423SLionel Sambuc
389433d6423SLionel Sambuc /*******************************************************************************
390433d6423SLionel Sambuc *
391433d6423SLionel Sambuc * FUNCTION: AcpiUtUpdateRefCount
392433d6423SLionel Sambuc *
393433d6423SLionel Sambuc * PARAMETERS: Object - Object whose ref count is to be updated
394*29492bb7SDavid van Moolenbroek * Action - What to do (REF_INCREMENT or REF_DECREMENT)
395433d6423SLionel Sambuc *
396*29492bb7SDavid van Moolenbroek * RETURN: None. Sets new reference count within the object
397433d6423SLionel Sambuc *
398*29492bb7SDavid van Moolenbroek * DESCRIPTION: Modify the reference count for an internal acpi object
399433d6423SLionel Sambuc *
400433d6423SLionel Sambuc ******************************************************************************/
401433d6423SLionel Sambuc
402433d6423SLionel Sambuc static void
AcpiUtUpdateRefCount(ACPI_OPERAND_OBJECT * Object,UINT32 Action)403433d6423SLionel Sambuc AcpiUtUpdateRefCount (
404433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object,
405433d6423SLionel Sambuc UINT32 Action)
406433d6423SLionel Sambuc {
407*29492bb7SDavid van Moolenbroek UINT16 OriginalCount;
408*29492bb7SDavid van Moolenbroek UINT16 NewCount = 0;
409*29492bb7SDavid van Moolenbroek ACPI_CPU_FLAGS LockFlags;
410433d6423SLionel Sambuc
411433d6423SLionel Sambuc
412433d6423SLionel Sambuc ACPI_FUNCTION_NAME (UtUpdateRefCount);
413433d6423SLionel Sambuc
414433d6423SLionel Sambuc
415433d6423SLionel Sambuc if (!Object)
416433d6423SLionel Sambuc {
417433d6423SLionel Sambuc return;
418433d6423SLionel Sambuc }
419433d6423SLionel Sambuc
420433d6423SLionel Sambuc /*
421*29492bb7SDavid van Moolenbroek * Always get the reference count lock. Note: Interpreter and/or
422*29492bb7SDavid van Moolenbroek * Namespace is not always locked when this function is called.
423433d6423SLionel Sambuc */
424*29492bb7SDavid van Moolenbroek LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock);
425*29492bb7SDavid van Moolenbroek OriginalCount = Object->Common.ReferenceCount;
426*29492bb7SDavid van Moolenbroek
427*29492bb7SDavid van Moolenbroek /* Perform the reference count action (increment, decrement) */
428*29492bb7SDavid van Moolenbroek
429433d6423SLionel Sambuc switch (Action)
430433d6423SLionel Sambuc {
431433d6423SLionel Sambuc case REF_INCREMENT:
432433d6423SLionel Sambuc
433*29492bb7SDavid van Moolenbroek NewCount = OriginalCount + 1;
434433d6423SLionel Sambuc Object->Common.ReferenceCount = NewCount;
435*29492bb7SDavid van Moolenbroek AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
436*29492bb7SDavid van Moolenbroek
437*29492bb7SDavid van Moolenbroek /* The current reference count should never be zero here */
438*29492bb7SDavid van Moolenbroek
439*29492bb7SDavid van Moolenbroek if (!OriginalCount)
440*29492bb7SDavid van Moolenbroek {
441*29492bb7SDavid van Moolenbroek ACPI_WARNING ((AE_INFO,
442*29492bb7SDavid van Moolenbroek "Obj %p, Reference Count was zero before increment\n",
443*29492bb7SDavid van Moolenbroek Object));
444*29492bb7SDavid van Moolenbroek }
445433d6423SLionel Sambuc
446433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
447*29492bb7SDavid van Moolenbroek "Obj %p Type %.2X Refs %.2X [Incremented]\n",
448*29492bb7SDavid van Moolenbroek Object, Object->Common.Type, NewCount));
449433d6423SLionel Sambuc break;
450433d6423SLionel Sambuc
451433d6423SLionel Sambuc case REF_DECREMENT:
452433d6423SLionel Sambuc
453*29492bb7SDavid van Moolenbroek /* The current reference count must be non-zero */
454*29492bb7SDavid van Moolenbroek
455*29492bb7SDavid van Moolenbroek if (OriginalCount)
456433d6423SLionel Sambuc {
457*29492bb7SDavid van Moolenbroek NewCount = OriginalCount - 1;
458433d6423SLionel Sambuc Object->Common.ReferenceCount = NewCount;
459*29492bb7SDavid van Moolenbroek }
460*29492bb7SDavid van Moolenbroek
461*29492bb7SDavid van Moolenbroek AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
462*29492bb7SDavid van Moolenbroek
463*29492bb7SDavid van Moolenbroek if (!OriginalCount)
464*29492bb7SDavid van Moolenbroek {
465*29492bb7SDavid van Moolenbroek ACPI_WARNING ((AE_INFO,
466*29492bb7SDavid van Moolenbroek "Obj %p, Reference Count is already zero, cannot decrement\n",
467*29492bb7SDavid van Moolenbroek Object));
468*29492bb7SDavid van Moolenbroek }
469*29492bb7SDavid van Moolenbroek
470*29492bb7SDavid van Moolenbroek ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
471*29492bb7SDavid van Moolenbroek "Obj %p Type %.2X Refs %.2X [Decremented]\n",
472*29492bb7SDavid van Moolenbroek Object, Object->Common.Type, NewCount));
473*29492bb7SDavid van Moolenbroek
474*29492bb7SDavid van Moolenbroek /* Actually delete the object on a reference count of zero */
475*29492bb7SDavid van Moolenbroek
476433d6423SLionel Sambuc if (NewCount == 0)
477433d6423SLionel Sambuc {
478433d6423SLionel Sambuc AcpiUtDeleteInternalObj (Object);
479433d6423SLionel Sambuc }
480433d6423SLionel Sambuc break;
481433d6423SLionel Sambuc
482433d6423SLionel Sambuc default:
483433d6423SLionel Sambuc
484*29492bb7SDavid van Moolenbroek AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
485*29492bb7SDavid van Moolenbroek ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)",
486*29492bb7SDavid van Moolenbroek Action));
487*29492bb7SDavid van Moolenbroek return;
488433d6423SLionel Sambuc }
489433d6423SLionel Sambuc
490433d6423SLionel Sambuc /*
491433d6423SLionel Sambuc * Sanity check the reference count, for debug purposes only.
492433d6423SLionel Sambuc * (A deleted object will have a huge reference count)
493433d6423SLionel Sambuc */
494*29492bb7SDavid van Moolenbroek if (NewCount > ACPI_MAX_REFERENCE_COUNT)
495433d6423SLionel Sambuc {
496433d6423SLionel Sambuc ACPI_WARNING ((AE_INFO,
497*29492bb7SDavid van Moolenbroek "Large Reference Count (0x%X) in object %p, Type=0x%.2X",
498*29492bb7SDavid van Moolenbroek NewCount, Object, Object->Common.Type));
499433d6423SLionel Sambuc }
500433d6423SLionel Sambuc }
501433d6423SLionel Sambuc
502433d6423SLionel Sambuc
503433d6423SLionel Sambuc /*******************************************************************************
504433d6423SLionel Sambuc *
505433d6423SLionel Sambuc * FUNCTION: AcpiUtUpdateObjectReference
506433d6423SLionel Sambuc *
507433d6423SLionel Sambuc * PARAMETERS: Object - Increment ref count for this object
508433d6423SLionel Sambuc * and all sub-objects
509*29492bb7SDavid van Moolenbroek * Action - Either REF_INCREMENT or REF_DECREMENT
510433d6423SLionel Sambuc *
511433d6423SLionel Sambuc * RETURN: Status
512433d6423SLionel Sambuc *
513433d6423SLionel Sambuc * DESCRIPTION: Increment the object reference count
514433d6423SLionel Sambuc *
515433d6423SLionel Sambuc * Object references are incremented when:
516433d6423SLionel Sambuc * 1) An object is attached to a Node (namespace object)
517433d6423SLionel Sambuc * 2) An object is copied (all subobjects must be incremented)
518433d6423SLionel Sambuc *
519433d6423SLionel Sambuc * Object references are decremented when:
520433d6423SLionel Sambuc * 1) An object is detached from an Node
521433d6423SLionel Sambuc *
522433d6423SLionel Sambuc ******************************************************************************/
523433d6423SLionel Sambuc
524433d6423SLionel Sambuc ACPI_STATUS
AcpiUtUpdateObjectReference(ACPI_OPERAND_OBJECT * Object,UINT16 Action)525433d6423SLionel Sambuc AcpiUtUpdateObjectReference (
526433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object,
527433d6423SLionel Sambuc UINT16 Action)
528433d6423SLionel Sambuc {
529433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK;
530433d6423SLionel Sambuc ACPI_GENERIC_STATE *StateList = NULL;
531433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *NextObject = NULL;
532*29492bb7SDavid van Moolenbroek ACPI_OPERAND_OBJECT *PrevObject;
533433d6423SLionel Sambuc ACPI_GENERIC_STATE *State;
534433d6423SLionel Sambuc UINT32 i;
535433d6423SLionel Sambuc
536433d6423SLionel Sambuc
537*29492bb7SDavid van Moolenbroek ACPI_FUNCTION_NAME (UtUpdateObjectReference);
538433d6423SLionel Sambuc
539433d6423SLionel Sambuc
540433d6423SLionel Sambuc while (Object)
541433d6423SLionel Sambuc {
542433d6423SLionel Sambuc /* Make sure that this isn't a namespace handle */
543433d6423SLionel Sambuc
544433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
545433d6423SLionel Sambuc {
546433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
547433d6423SLionel Sambuc "Object %p is NS handle\n", Object));
548*29492bb7SDavid van Moolenbroek return (AE_OK);
549433d6423SLionel Sambuc }
550433d6423SLionel Sambuc
551433d6423SLionel Sambuc /*
552433d6423SLionel Sambuc * All sub-objects must have their reference count incremented also.
553433d6423SLionel Sambuc * Different object types have different subobjects.
554433d6423SLionel Sambuc */
555433d6423SLionel Sambuc switch (Object->Common.Type)
556433d6423SLionel Sambuc {
557433d6423SLionel Sambuc case ACPI_TYPE_DEVICE:
558433d6423SLionel Sambuc case ACPI_TYPE_PROCESSOR:
559433d6423SLionel Sambuc case ACPI_TYPE_POWER:
560433d6423SLionel Sambuc case ACPI_TYPE_THERMAL:
561*29492bb7SDavid van Moolenbroek /*
562*29492bb7SDavid van Moolenbroek * Update the notify objects for these types (if present)
563*29492bb7SDavid van Moolenbroek * Two lists, system and device notify handlers.
564*29492bb7SDavid van Moolenbroek */
565*29492bb7SDavid van Moolenbroek for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
566*29492bb7SDavid van Moolenbroek {
567*29492bb7SDavid van Moolenbroek PrevObject = Object->CommonNotify.NotifyList[i];
568*29492bb7SDavid van Moolenbroek while (PrevObject)
569*29492bb7SDavid van Moolenbroek {
570*29492bb7SDavid van Moolenbroek NextObject = PrevObject->Notify.Next[i];
571*29492bb7SDavid van Moolenbroek AcpiUtUpdateRefCount (PrevObject, Action);
572*29492bb7SDavid van Moolenbroek PrevObject = NextObject;
573*29492bb7SDavid van Moolenbroek }
574*29492bb7SDavid van Moolenbroek }
575433d6423SLionel Sambuc break;
576433d6423SLionel Sambuc
577433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE:
578433d6423SLionel Sambuc /*
579433d6423SLionel Sambuc * We must update all the sub-objects of the package,
580433d6423SLionel Sambuc * each of whom may have their own sub-objects.
581433d6423SLionel Sambuc */
582433d6423SLionel Sambuc for (i = 0; i < Object->Package.Count; i++)
583433d6423SLionel Sambuc {
584433d6423SLionel Sambuc /*
585*29492bb7SDavid van Moolenbroek * Null package elements are legal and can be simply
586*29492bb7SDavid van Moolenbroek * ignored.
587*29492bb7SDavid van Moolenbroek */
588*29492bb7SDavid van Moolenbroek NextObject = Object->Package.Elements[i];
589*29492bb7SDavid van Moolenbroek if (!NextObject)
590*29492bb7SDavid van Moolenbroek {
591*29492bb7SDavid van Moolenbroek continue;
592*29492bb7SDavid van Moolenbroek }
593*29492bb7SDavid van Moolenbroek
594*29492bb7SDavid van Moolenbroek switch (NextObject->Common.Type)
595*29492bb7SDavid van Moolenbroek {
596*29492bb7SDavid van Moolenbroek case ACPI_TYPE_INTEGER:
597*29492bb7SDavid van Moolenbroek case ACPI_TYPE_STRING:
598*29492bb7SDavid van Moolenbroek case ACPI_TYPE_BUFFER:
599*29492bb7SDavid van Moolenbroek /*
600*29492bb7SDavid van Moolenbroek * For these very simple sub-objects, we can just
601*29492bb7SDavid van Moolenbroek * update the reference count here and continue.
602*29492bb7SDavid van Moolenbroek * Greatly increases performance of this operation.
603*29492bb7SDavid van Moolenbroek */
604*29492bb7SDavid van Moolenbroek AcpiUtUpdateRefCount (NextObject, Action);
605*29492bb7SDavid van Moolenbroek break;
606*29492bb7SDavid van Moolenbroek
607*29492bb7SDavid van Moolenbroek default:
608*29492bb7SDavid van Moolenbroek /*
609*29492bb7SDavid van Moolenbroek * For complex sub-objects, push them onto the stack
610*29492bb7SDavid van Moolenbroek * for later processing (this eliminates recursion.)
611433d6423SLionel Sambuc */
612433d6423SLionel Sambuc Status = AcpiUtCreateUpdateStateAndPush (
613*29492bb7SDavid van Moolenbroek NextObject, Action, &StateList);
614433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
615433d6423SLionel Sambuc {
616433d6423SLionel Sambuc goto ErrorExit;
617433d6423SLionel Sambuc }
618*29492bb7SDavid van Moolenbroek break;
619433d6423SLionel Sambuc }
620*29492bb7SDavid van Moolenbroek }
621*29492bb7SDavid van Moolenbroek NextObject = NULL;
622433d6423SLionel Sambuc break;
623433d6423SLionel Sambuc
624433d6423SLionel Sambuc case ACPI_TYPE_BUFFER_FIELD:
625433d6423SLionel Sambuc
626433d6423SLionel Sambuc NextObject = Object->BufferField.BufferObj;
627433d6423SLionel Sambuc break;
628433d6423SLionel Sambuc
629433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REGION_FIELD:
630433d6423SLionel Sambuc
631433d6423SLionel Sambuc NextObject = Object->Field.RegionObj;
632433d6423SLionel Sambuc break;
633433d6423SLionel Sambuc
634433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_BANK_FIELD:
635433d6423SLionel Sambuc
636433d6423SLionel Sambuc NextObject = Object->BankField.BankObj;
637433d6423SLionel Sambuc Status = AcpiUtCreateUpdateStateAndPush (
638433d6423SLionel Sambuc Object->BankField.RegionObj, Action, &StateList);
639433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
640433d6423SLionel Sambuc {
641433d6423SLionel Sambuc goto ErrorExit;
642433d6423SLionel Sambuc }
643433d6423SLionel Sambuc break;
644433d6423SLionel Sambuc
645433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_INDEX_FIELD:
646433d6423SLionel Sambuc
647433d6423SLionel Sambuc NextObject = Object->IndexField.IndexObj;
648433d6423SLionel Sambuc Status = AcpiUtCreateUpdateStateAndPush (
649433d6423SLionel Sambuc Object->IndexField.DataObj, Action, &StateList);
650433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
651433d6423SLionel Sambuc {
652433d6423SLionel Sambuc goto ErrorExit;
653433d6423SLionel Sambuc }
654433d6423SLionel Sambuc break;
655433d6423SLionel Sambuc
656433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REFERENCE:
657433d6423SLionel Sambuc /*
658433d6423SLionel Sambuc * The target of an Index (a package, string, or buffer) or a named
659433d6423SLionel Sambuc * reference must track changes to the ref count of the index or
660433d6423SLionel Sambuc * target object.
661433d6423SLionel Sambuc */
662433d6423SLionel Sambuc if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
663433d6423SLionel Sambuc (Object->Reference.Class== ACPI_REFCLASS_NAME))
664433d6423SLionel Sambuc {
665433d6423SLionel Sambuc NextObject = Object->Reference.Object;
666433d6423SLionel Sambuc }
667433d6423SLionel Sambuc break;
668433d6423SLionel Sambuc
669433d6423SLionel Sambuc case ACPI_TYPE_REGION:
670433d6423SLionel Sambuc default:
671*29492bb7SDavid van Moolenbroek
672433d6423SLionel Sambuc break; /* No subobjects for all other types */
673433d6423SLionel Sambuc }
674433d6423SLionel Sambuc
675433d6423SLionel Sambuc /*
676433d6423SLionel Sambuc * Now we can update the count in the main object. This can only
677433d6423SLionel Sambuc * happen after we update the sub-objects in case this causes the
678433d6423SLionel Sambuc * main object to be deleted.
679433d6423SLionel Sambuc */
680433d6423SLionel Sambuc AcpiUtUpdateRefCount (Object, Action);
681433d6423SLionel Sambuc Object = NULL;
682433d6423SLionel Sambuc
683433d6423SLionel Sambuc /* Move on to the next object to be updated */
684433d6423SLionel Sambuc
685433d6423SLionel Sambuc if (NextObject)
686433d6423SLionel Sambuc {
687433d6423SLionel Sambuc Object = NextObject;
688433d6423SLionel Sambuc NextObject = NULL;
689433d6423SLionel Sambuc }
690433d6423SLionel Sambuc else if (StateList)
691433d6423SLionel Sambuc {
692433d6423SLionel Sambuc State = AcpiUtPopGenericState (&StateList);
693433d6423SLionel Sambuc Object = State->Update.Object;
694433d6423SLionel Sambuc AcpiUtDeleteGenericState (State);
695433d6423SLionel Sambuc }
696433d6423SLionel Sambuc }
697433d6423SLionel Sambuc
698*29492bb7SDavid van Moolenbroek return (AE_OK);
699433d6423SLionel Sambuc
700433d6423SLionel Sambuc
701433d6423SLionel Sambuc ErrorExit:
702433d6423SLionel Sambuc
703433d6423SLionel Sambuc ACPI_EXCEPTION ((AE_INFO, Status,
704433d6423SLionel Sambuc "Could not update object reference count"));
705433d6423SLionel Sambuc
706433d6423SLionel Sambuc /* Free any stacked Update State objects */
707433d6423SLionel Sambuc
708433d6423SLionel Sambuc while (StateList)
709433d6423SLionel Sambuc {
710433d6423SLionel Sambuc State = AcpiUtPopGenericState (&StateList);
711433d6423SLionel Sambuc AcpiUtDeleteGenericState (State);
712433d6423SLionel Sambuc }
713433d6423SLionel Sambuc
714*29492bb7SDavid van Moolenbroek return (Status);
715433d6423SLionel Sambuc }
716433d6423SLionel Sambuc
717433d6423SLionel Sambuc
718433d6423SLionel Sambuc /*******************************************************************************
719433d6423SLionel Sambuc *
720433d6423SLionel Sambuc * FUNCTION: AcpiUtAddReference
721433d6423SLionel Sambuc *
722433d6423SLionel Sambuc * PARAMETERS: Object - Object whose reference count is to be
723433d6423SLionel Sambuc * incremented
724433d6423SLionel Sambuc *
725433d6423SLionel Sambuc * RETURN: None
726433d6423SLionel Sambuc *
727433d6423SLionel Sambuc * DESCRIPTION: Add one reference to an ACPI object
728433d6423SLionel Sambuc *
729433d6423SLionel Sambuc ******************************************************************************/
730433d6423SLionel Sambuc
731433d6423SLionel Sambuc void
AcpiUtAddReference(ACPI_OPERAND_OBJECT * Object)732433d6423SLionel Sambuc AcpiUtAddReference (
733433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object)
734433d6423SLionel Sambuc {
735433d6423SLionel Sambuc
736*29492bb7SDavid van Moolenbroek ACPI_FUNCTION_NAME (UtAddReference);
737433d6423SLionel Sambuc
738433d6423SLionel Sambuc
739433d6423SLionel Sambuc /* Ensure that we have a valid object */
740433d6423SLionel Sambuc
741433d6423SLionel Sambuc if (!AcpiUtValidInternalObject (Object))
742433d6423SLionel Sambuc {
743*29492bb7SDavid van Moolenbroek return;
744433d6423SLionel Sambuc }
745433d6423SLionel Sambuc
746433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
747433d6423SLionel Sambuc "Obj %p Current Refs=%X [To Be Incremented]\n",
748433d6423SLionel Sambuc Object, Object->Common.ReferenceCount));
749433d6423SLionel Sambuc
750433d6423SLionel Sambuc /* Increment the reference count */
751433d6423SLionel Sambuc
752433d6423SLionel Sambuc (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
753*29492bb7SDavid van Moolenbroek return;
754433d6423SLionel Sambuc }
755433d6423SLionel Sambuc
756433d6423SLionel Sambuc
757433d6423SLionel Sambuc /*******************************************************************************
758433d6423SLionel Sambuc *
759433d6423SLionel Sambuc * FUNCTION: AcpiUtRemoveReference
760433d6423SLionel Sambuc *
761433d6423SLionel Sambuc * PARAMETERS: Object - Object whose ref count will be decremented
762433d6423SLionel Sambuc *
763433d6423SLionel Sambuc * RETURN: None
764433d6423SLionel Sambuc *
765433d6423SLionel Sambuc * DESCRIPTION: Decrement the reference count of an ACPI internal object
766433d6423SLionel Sambuc *
767433d6423SLionel Sambuc ******************************************************************************/
768433d6423SLionel Sambuc
769433d6423SLionel Sambuc void
AcpiUtRemoveReference(ACPI_OPERAND_OBJECT * Object)770433d6423SLionel Sambuc AcpiUtRemoveReference (
771433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Object)
772433d6423SLionel Sambuc {
773433d6423SLionel Sambuc
774*29492bb7SDavid van Moolenbroek ACPI_FUNCTION_NAME (UtRemoveReference);
775433d6423SLionel Sambuc
776433d6423SLionel Sambuc
777433d6423SLionel Sambuc /*
778433d6423SLionel Sambuc * Allow a NULL pointer to be passed in, just ignore it. This saves
779433d6423SLionel Sambuc * each caller from having to check. Also, ignore NS nodes.
780433d6423SLionel Sambuc */
781433d6423SLionel Sambuc if (!Object ||
782433d6423SLionel Sambuc (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
783433d6423SLionel Sambuc
784433d6423SLionel Sambuc {
785*29492bb7SDavid van Moolenbroek return;
786433d6423SLionel Sambuc }
787433d6423SLionel Sambuc
788433d6423SLionel Sambuc /* Ensure that we have a valid object */
789433d6423SLionel Sambuc
790433d6423SLionel Sambuc if (!AcpiUtValidInternalObject (Object))
791433d6423SLionel Sambuc {
792*29492bb7SDavid van Moolenbroek return;
793433d6423SLionel Sambuc }
794433d6423SLionel Sambuc
795433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
796433d6423SLionel Sambuc "Obj %p Current Refs=%X [To Be Decremented]\n",
797433d6423SLionel Sambuc Object, Object->Common.ReferenceCount));
798433d6423SLionel Sambuc
799433d6423SLionel Sambuc /*
800433d6423SLionel Sambuc * Decrement the reference count, and only actually delete the object
801433d6423SLionel Sambuc * if the reference count becomes 0. (Must also decrement the ref count
802433d6423SLionel Sambuc * of all subobjects!)
803433d6423SLionel Sambuc */
804433d6423SLionel Sambuc (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
805*29492bb7SDavid van Moolenbroek return;
806433d6423SLionel Sambuc }
807