BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / acpi / acpica / components / utilities / utdelete.c
blobea2033b0e11e7aa46f5ae7e373b9fae72777962d
1 /*******************************************************************************
3 * Module Name: utdelete - object deletion and reference count utilities
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
116 #define __UTDELETE_C__
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "acinterp.h"
121 #include "acnamesp.h"
122 #include "acevents.h"
125 #define _COMPONENT ACPI_UTILITIES
126 ACPI_MODULE_NAME ("utdelete")
128 /* Local prototypes */
130 static void
131 AcpiUtDeleteInternalObj (
132 ACPI_OPERAND_OBJECT *Object);
134 static void
135 AcpiUtUpdateRefCount (
136 ACPI_OPERAND_OBJECT *Object,
137 UINT32 Action);
140 /*******************************************************************************
142 * FUNCTION: AcpiUtDeleteInternalObj
144 * PARAMETERS: Object - Object to be deleted
146 * RETURN: None
148 * DESCRIPTION: Low level object deletion, after reference counts have been
149 * updated (All reference counts, including sub-objects!)
151 ******************************************************************************/
153 static void
154 AcpiUtDeleteInternalObj (
155 ACPI_OPERAND_OBJECT *Object)
157 void *ObjPointer = NULL;
158 ACPI_OPERAND_OBJECT *HandlerDesc;
159 ACPI_OPERAND_OBJECT *SecondDesc;
160 ACPI_OPERAND_OBJECT *NextDesc;
161 ACPI_OPERAND_OBJECT *StartDesc;
162 ACPI_OPERAND_OBJECT **LastObjPtr;
165 ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
168 if (!Object)
170 return_VOID;
174 * Must delete or free any pointers within the object that are not
175 * actual ACPI objects (for example, a raw buffer pointer).
177 switch (Object->Common.Type)
179 case ACPI_TYPE_STRING:
181 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
182 Object, Object->String.Pointer));
184 /* Free the actual string buffer */
186 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
188 /* But only if it is NOT a pointer into an ACPI table */
190 ObjPointer = Object->String.Pointer;
192 break;
194 case ACPI_TYPE_BUFFER:
196 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
197 Object, Object->Buffer.Pointer));
199 /* Free the actual buffer */
201 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
203 /* But only if it is NOT a pointer into an ACPI table */
205 ObjPointer = Object->Buffer.Pointer;
207 break;
209 case ACPI_TYPE_PACKAGE:
211 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
212 Object->Package.Count));
215 * Elements of the package are not handled here, they are deleted
216 * separately
219 /* Free the (variable length) element pointer array */
221 ObjPointer = Object->Package.Elements;
222 break;
225 * These objects have a possible list of notify handlers.
226 * Device object also may have a GPE block.
228 case ACPI_TYPE_DEVICE:
230 if (Object->Device.GpeBlock)
232 (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
235 /*lint -fallthrough */
237 case ACPI_TYPE_PROCESSOR:
238 case ACPI_TYPE_THERMAL:
240 /* Walk the address handler list for this object */
242 HandlerDesc = Object->CommonNotify.Handler;
243 while (HandlerDesc)
245 NextDesc = HandlerDesc->AddressSpace.Next;
246 AcpiUtRemoveReference (HandlerDesc);
247 HandlerDesc = NextDesc;
249 break;
251 case ACPI_TYPE_MUTEX:
253 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
254 "***** Mutex %p, OS Mutex %p\n",
255 Object, Object->Mutex.OsMutex));
257 if (Object == AcpiGbl_GlobalLockMutex)
259 /* Global Lock has extra semaphore */
261 (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
262 AcpiGbl_GlobalLockSemaphore = NULL;
264 AcpiOsDeleteMutex (Object->Mutex.OsMutex);
265 AcpiGbl_GlobalLockMutex = NULL;
267 else
269 AcpiExUnlinkMutex (Object);
270 AcpiOsDeleteMutex (Object->Mutex.OsMutex);
272 break;
274 case ACPI_TYPE_EVENT:
276 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
277 "***** Event %p, OS Semaphore %p\n",
278 Object, Object->Event.OsSemaphore));
280 (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
281 Object->Event.OsSemaphore = 0;
282 break;
284 case ACPI_TYPE_METHOD:
286 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
287 "***** Method %p\n", Object));
289 /* Delete the method mutex if it exists */
291 if (Object->Method.Mutex)
293 AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
294 AcpiUtDeleteObjectDesc (Object->Method.Mutex);
295 Object->Method.Mutex = NULL;
297 break;
299 case ACPI_TYPE_REGION:
301 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
302 "***** Region %p\n", Object));
305 * Update AddressRange list. However, only permanent regions
306 * are installed in this list. (Not created within a method)
308 if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
310 AcpiUtRemoveAddressRange (Object->Region.SpaceId,
311 Object->Region.Node);
314 SecondDesc = AcpiNsGetSecondaryObject (Object);
315 if (SecondDesc)
318 * Free the RegionContext if and only if the handler is one of the
319 * default handlers -- and therefore, we created the context object
320 * locally, it was not created by an external caller.
322 HandlerDesc = Object->Region.Handler;
323 if (HandlerDesc)
325 NextDesc = HandlerDesc->AddressSpace.RegionList;
326 StartDesc = NextDesc;
327 LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
329 /* Remove the region object from the handler list */
331 while (NextDesc)
333 if (NextDesc == Object)
335 *LastObjPtr = NextDesc->Region.Next;
336 break;
339 /* Walk the linked list of handlers */
341 LastObjPtr = &NextDesc->Region.Next;
342 NextDesc = NextDesc->Region.Next;
344 /* Prevent infinite loop if list is corrupted */
346 if (NextDesc == StartDesc)
348 ACPI_ERROR ((AE_INFO,
349 "Circular region list in address handler object %p",
350 HandlerDesc));
351 return_VOID;
355 if (HandlerDesc->AddressSpace.HandlerFlags &
356 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
358 /* Deactivate region and free region context */
360 if (HandlerDesc->AddressSpace.Setup)
362 (void) HandlerDesc->AddressSpace.Setup (Object,
363 ACPI_REGION_DEACTIVATE,
364 HandlerDesc->AddressSpace.Context,
365 &SecondDesc->Extra.RegionContext);
369 AcpiUtRemoveReference (HandlerDesc);
372 /* Now we can free the Extra object */
374 AcpiUtDeleteObjectDesc (SecondDesc);
376 break;
378 case ACPI_TYPE_BUFFER_FIELD:
380 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
381 "***** Buffer Field %p\n", Object));
383 SecondDesc = AcpiNsGetSecondaryObject (Object);
384 if (SecondDesc)
386 AcpiUtDeleteObjectDesc (SecondDesc);
388 break;
390 case ACPI_TYPE_LOCAL_BANK_FIELD:
392 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
393 "***** Bank Field %p\n", Object));
395 SecondDesc = AcpiNsGetSecondaryObject (Object);
396 if (SecondDesc)
398 AcpiUtDeleteObjectDesc (SecondDesc);
400 break;
402 default:
404 break;
407 /* Free any allocated memory (pointer within the object) found above */
409 if (ObjPointer)
411 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
412 ObjPointer));
413 ACPI_FREE (ObjPointer);
416 /* Now the object can be safely deleted */
418 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
419 Object, AcpiUtGetObjectTypeName (Object)));
421 AcpiUtDeleteObjectDesc (Object);
422 return_VOID;
426 /*******************************************************************************
428 * FUNCTION: AcpiUtDeleteInternalObjectList
430 * PARAMETERS: ObjList - Pointer to the list to be deleted
432 * RETURN: None
434 * DESCRIPTION: This function deletes an internal object list, including both
435 * simple objects and package objects
437 ******************************************************************************/
439 void
440 AcpiUtDeleteInternalObjectList (
441 ACPI_OPERAND_OBJECT **ObjList)
443 ACPI_OPERAND_OBJECT **InternalObj;
446 ACPI_FUNCTION_ENTRY ();
449 /* Walk the null-terminated internal list */
451 for (InternalObj = ObjList; *InternalObj; InternalObj++)
453 AcpiUtRemoveReference (*InternalObj);
456 /* Free the combined parameter pointer list and object array */
458 ACPI_FREE (ObjList);
459 return;
463 /*******************************************************************************
465 * FUNCTION: AcpiUtUpdateRefCount
467 * PARAMETERS: Object - Object whose ref count is to be updated
468 * Action - What to do (REF_INCREMENT or REF_DECREMENT)
470 * RETURN: None. Sets new reference count within the object
472 * DESCRIPTION: Modify the reference count for an internal acpi object
474 ******************************************************************************/
476 static void
477 AcpiUtUpdateRefCount (
478 ACPI_OPERAND_OBJECT *Object,
479 UINT32 Action)
481 UINT16 OriginalCount;
482 UINT16 NewCount = 0;
483 ACPI_CPU_FLAGS LockFlags;
486 ACPI_FUNCTION_NAME (UtUpdateRefCount);
489 if (!Object)
491 return;
495 * Always get the reference count lock. Note: Interpreter and/or
496 * Namespace is not always locked when this function is called.
498 LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock);
499 OriginalCount = Object->Common.ReferenceCount;
501 /* Perform the reference count action (increment, decrement) */
503 switch (Action)
505 case REF_INCREMENT:
507 NewCount = OriginalCount + 1;
508 Object->Common.ReferenceCount = NewCount;
509 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
511 /* The current reference count should never be zero here */
513 if (!OriginalCount)
515 ACPI_WARNING ((AE_INFO,
516 "Obj %p, Reference Count was zero before increment\n",
517 Object));
520 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
521 "Obj %p Type %.2X Refs %.2X [Incremented]\n",
522 Object, Object->Common.Type, NewCount));
523 break;
525 case REF_DECREMENT:
527 /* The current reference count must be non-zero */
529 if (OriginalCount)
531 NewCount = OriginalCount - 1;
532 Object->Common.ReferenceCount = NewCount;
535 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
537 if (!OriginalCount)
539 ACPI_WARNING ((AE_INFO,
540 "Obj %p, Reference Count is already zero, cannot decrement\n",
541 Object));
544 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
545 "Obj %p Type %.2X Refs %.2X [Decremented]\n",
546 Object, Object->Common.Type, NewCount));
548 /* Actually delete the object on a reference count of zero */
550 if (NewCount == 0)
552 AcpiUtDeleteInternalObj (Object);
554 break;
556 default:
558 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
559 ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)",
560 Action));
561 return;
565 * Sanity check the reference count, for debug purposes only.
566 * (A deleted object will have a huge reference count)
568 if (NewCount > ACPI_MAX_REFERENCE_COUNT)
570 ACPI_WARNING ((AE_INFO,
571 "Large Reference Count (0x%X) in object %p, Type=0x%.2X",
572 NewCount, Object, Object->Common.Type));
577 /*******************************************************************************
579 * FUNCTION: AcpiUtUpdateObjectReference
581 * PARAMETERS: Object - Increment ref count for this object
582 * and all sub-objects
583 * Action - Either REF_INCREMENT or REF_DECREMENT
585 * RETURN: Status
587 * DESCRIPTION: Increment the object reference count
589 * Object references are incremented when:
590 * 1) An object is attached to a Node (namespace object)
591 * 2) An object is copied (all subobjects must be incremented)
593 * Object references are decremented when:
594 * 1) An object is detached from an Node
596 ******************************************************************************/
598 ACPI_STATUS
599 AcpiUtUpdateObjectReference (
600 ACPI_OPERAND_OBJECT *Object,
601 UINT16 Action)
603 ACPI_STATUS Status = AE_OK;
604 ACPI_GENERIC_STATE *StateList = NULL;
605 ACPI_OPERAND_OBJECT *NextObject = NULL;
606 ACPI_OPERAND_OBJECT *PrevObject;
607 ACPI_GENERIC_STATE *State;
608 UINT32 i;
611 ACPI_FUNCTION_NAME (UtUpdateObjectReference);
614 while (Object)
616 /* Make sure that this isn't a namespace handle */
618 if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
620 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
621 "Object %p is NS handle\n", Object));
622 return (AE_OK);
626 * All sub-objects must have their reference count incremented also.
627 * Different object types have different subobjects.
629 switch (Object->Common.Type)
631 case ACPI_TYPE_DEVICE:
632 case ACPI_TYPE_PROCESSOR:
633 case ACPI_TYPE_POWER:
634 case ACPI_TYPE_THERMAL:
636 * Update the notify objects for these types (if present)
637 * Two lists, system and device notify handlers.
639 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
641 PrevObject = Object->CommonNotify.NotifyList[i];
642 while (PrevObject)
644 NextObject = PrevObject->Notify.Next[i];
645 AcpiUtUpdateRefCount (PrevObject, Action);
646 PrevObject = NextObject;
649 break;
651 case ACPI_TYPE_PACKAGE:
653 * We must update all the sub-objects of the package,
654 * each of whom may have their own sub-objects.
656 for (i = 0; i < Object->Package.Count; i++)
659 * Null package elements are legal and can be simply
660 * ignored.
662 NextObject = Object->Package.Elements[i];
663 if (!NextObject)
665 continue;
668 switch (NextObject->Common.Type)
670 case ACPI_TYPE_INTEGER:
671 case ACPI_TYPE_STRING:
672 case ACPI_TYPE_BUFFER:
674 * For these very simple sub-objects, we can just
675 * update the reference count here and continue.
676 * Greatly increases performance of this operation.
678 AcpiUtUpdateRefCount (NextObject, Action);
679 break;
681 default:
683 * For complex sub-objects, push them onto the stack
684 * for later processing (this eliminates recursion.)
686 Status = AcpiUtCreateUpdateStateAndPush (
687 NextObject, Action, &StateList);
688 if (ACPI_FAILURE (Status))
690 goto ErrorExit;
692 break;
695 NextObject = NULL;
696 break;
698 case ACPI_TYPE_BUFFER_FIELD:
700 NextObject = Object->BufferField.BufferObj;
701 break;
703 case ACPI_TYPE_LOCAL_REGION_FIELD:
705 NextObject = Object->Field.RegionObj;
706 break;
708 case ACPI_TYPE_LOCAL_BANK_FIELD:
710 NextObject = Object->BankField.BankObj;
711 Status = AcpiUtCreateUpdateStateAndPush (
712 Object->BankField.RegionObj, Action, &StateList);
713 if (ACPI_FAILURE (Status))
715 goto ErrorExit;
717 break;
719 case ACPI_TYPE_LOCAL_INDEX_FIELD:
721 NextObject = Object->IndexField.IndexObj;
722 Status = AcpiUtCreateUpdateStateAndPush (
723 Object->IndexField.DataObj, Action, &StateList);
724 if (ACPI_FAILURE (Status))
726 goto ErrorExit;
728 break;
730 case ACPI_TYPE_LOCAL_REFERENCE:
732 * The target of an Index (a package, string, or buffer) or a named
733 * reference must track changes to the ref count of the index or
734 * target object.
736 if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
737 (Object->Reference.Class== ACPI_REFCLASS_NAME))
739 NextObject = Object->Reference.Object;
741 break;
743 case ACPI_TYPE_REGION:
744 default:
746 break; /* No subobjects for all other types */
750 * Now we can update the count in the main object. This can only
751 * happen after we update the sub-objects in case this causes the
752 * main object to be deleted.
754 AcpiUtUpdateRefCount (Object, Action);
755 Object = NULL;
757 /* Move on to the next object to be updated */
759 if (NextObject)
761 Object = NextObject;
762 NextObject = NULL;
764 else if (StateList)
766 State = AcpiUtPopGenericState (&StateList);
767 Object = State->Update.Object;
768 AcpiUtDeleteGenericState (State);
772 return (AE_OK);
775 ErrorExit:
777 ACPI_EXCEPTION ((AE_INFO, Status,
778 "Could not update object reference count"));
780 /* Free any stacked Update State objects */
782 while (StateList)
784 State = AcpiUtPopGenericState (&StateList);
785 AcpiUtDeleteGenericState (State);
788 return (Status);
792 /*******************************************************************************
794 * FUNCTION: AcpiUtAddReference
796 * PARAMETERS: Object - Object whose reference count is to be
797 * incremented
799 * RETURN: None
801 * DESCRIPTION: Add one reference to an ACPI object
803 ******************************************************************************/
805 void
806 AcpiUtAddReference (
807 ACPI_OPERAND_OBJECT *Object)
810 ACPI_FUNCTION_NAME (UtAddReference);
813 /* Ensure that we have a valid object */
815 if (!AcpiUtValidInternalObject (Object))
817 return;
820 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
821 "Obj %p Current Refs=%X [To Be Incremented]\n",
822 Object, Object->Common.ReferenceCount));
824 /* Increment the reference count */
826 (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
827 return;
831 /*******************************************************************************
833 * FUNCTION: AcpiUtRemoveReference
835 * PARAMETERS: Object - Object whose ref count will be decremented
837 * RETURN: None
839 * DESCRIPTION: Decrement the reference count of an ACPI internal object
841 ******************************************************************************/
843 void
844 AcpiUtRemoveReference (
845 ACPI_OPERAND_OBJECT *Object)
848 ACPI_FUNCTION_NAME (UtRemoveReference);
852 * Allow a NULL pointer to be passed in, just ignore it. This saves
853 * each caller from having to check. Also, ignore NS nodes.
855 if (!Object ||
856 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
859 return;
862 /* Ensure that we have a valid object */
864 if (!AcpiUtValidInternalObject (Object))
866 return;
869 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
870 "Obj %p Current Refs=%X [To Be Decremented]\n",
871 Object, Object->Common.ReferenceCount));
874 * Decrement the reference count, and only actually delete the object
875 * if the reference count becomes 0. (Must also decrement the ref count
876 * of all subobjects!)
878 (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
879 return;