ReactOS  0.4.14-dev-342-gdc047f9
utdelete.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acevents.h"
Include dependency graph for utdelete.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_UTILITIES
 

Functions

static void AcpiUtDeleteInternalObj (ACPI_OPERAND_OBJECT *Object)
 
static void AcpiUtUpdateRefCount (ACPI_OPERAND_OBJECT *Object, UINT32 Action)
 
void AcpiUtDeleteInternalObjectList (ACPI_OPERAND_OBJECT **ObjList)
 
ACPI_STATUS AcpiUtUpdateObjectReference (ACPI_OPERAND_OBJECT *Object, UINT16 Action)
 
void AcpiUtAddReference (ACPI_OPERAND_OBJECT *Object)
 
void AcpiUtRemoveReference (ACPI_OPERAND_OBJECT *Object)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_UTILITIES

Definition at line 51 of file utdelete.c.

Function Documentation

◆ AcpiUtAddReference()

void AcpiUtAddReference ( ACPI_OPERAND_OBJECT Object)

Definition at line 746 of file utdelete.c.

748 {
749 
750  ACPI_FUNCTION_NAME (UtAddReference);
751 
752 
753  /* Ensure that we have a valid object */
754 
756  {
757  return;
758  }
759 
761  "Obj %p Current Refs=%X [To Be Incremented]\n",
762  Object, Object->Common.ReferenceCount));
763 
764  /* Increment the reference count */
765 
767  return;
768 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_STATUS AcpiUtUpdateObjectReference(ACPI_OPERAND_OBJECT *Object, UINT16 Action)
Definition: utdelete.c:539
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
static IUnknown Object
Definition: main.c:512
BOOLEAN AcpiUtValidInternalObject(void *Object)
Definition: utobject.c:376
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175
#define REF_INCREMENT
Definition: acutils.h:180

Referenced by AcpiDsBuildInternalPackageObj(), AcpiDsDoImplicitReturn(), AcpiDsExecEndOp(), AcpiDsMethodDataGetValue(), AcpiDsMethodDataSetValue(), AcpiEvAttachRegion(), AcpiExOpcode_1A_0T_1R(), AcpiExOpcode_1A_1T_1R(), AcpiExOpcode_2A_1T_1R(), AcpiExPrepFieldValue(), AcpiExResolveNodeToValue(), AcpiExResolveObjectToValue(), AcpiExStoreObjectToIndex(), AcpiInstallNotifyHandler(), AcpiNsAttachObject(), AcpiNsConvertToReference(), AcpiNsResolveReferences(), and AcpiUtCopySimpleObject().

◆ AcpiUtDeleteInternalObj()

static void AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT Object)
static

Definition at line 80 of file utdelete.c.

82 {
83  void *ObjPointer = NULL;
84  ACPI_OPERAND_OBJECT *HandlerDesc;
85  ACPI_OPERAND_OBJECT *SecondDesc;
86  ACPI_OPERAND_OBJECT *NextDesc;
87  ACPI_OPERAND_OBJECT *StartDesc;
88  ACPI_OPERAND_OBJECT **LastObjPtr;
89 
90 
91  ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
92 
93 
94  if (!Object)
95  {
97  }
98 
99  /*
100  * Must delete or free any pointers within the object that are not
101  * actual ACPI objects (for example, a raw buffer pointer).
102  */
103  switch (Object->Common.Type)
104  {
105  case ACPI_TYPE_STRING:
106 
107  ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
108  Object, Object->String.Pointer));
109 
110  /* Free the actual string buffer */
111 
112  if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
113  {
114  /* But only if it is NOT a pointer into an ACPI table */
115 
116  ObjPointer = Object->String.Pointer;
117  }
118  break;
119 
120  case ACPI_TYPE_BUFFER:
121 
122  ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
123  Object, Object->Buffer.Pointer));
124 
125  /* Free the actual buffer */
126 
127  if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
128  {
129  /* But only if it is NOT a pointer into an ACPI table */
130 
131  ObjPointer = Object->Buffer.Pointer;
132  }
133  break;
134 
135  case ACPI_TYPE_PACKAGE:
136 
137  ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
138  Object->Package.Count));
139 
140  /*
141  * Elements of the package are not handled here, they are deleted
142  * separately
143  */
144 
145  /* Free the (variable length) element pointer array */
146 
147  ObjPointer = Object->Package.Elements;
148  break;
149 
150  /*
151  * These objects have a possible list of notify handlers.
152  * Device object also may have a GPE block.
153  */
154  case ACPI_TYPE_DEVICE:
155 
156  if (Object->Device.GpeBlock)
157  {
158  (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
159  }
160 
161  /*lint -fallthrough */
162 
163  case ACPI_TYPE_PROCESSOR:
164  case ACPI_TYPE_THERMAL:
165 
166  /* Walk the address handler list for this object */
167 
168  HandlerDesc = Object->CommonNotify.Handler;
169  while (HandlerDesc)
170  {
171  NextDesc = HandlerDesc->AddressSpace.Next;
172  AcpiUtRemoveReference (HandlerDesc);
173  HandlerDesc = NextDesc;
174  }
175  break;
176 
177  case ACPI_TYPE_MUTEX:
178 
180  "***** Mutex %p, OS Mutex %p\n",
181  Object, Object->Mutex.OsMutex));
182 
183  if (Object == AcpiGbl_GlobalLockMutex)
184  {
185  /* Global Lock has extra semaphore */
186 
187  (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
188  AcpiGbl_GlobalLockSemaphore = NULL;
189 
190  AcpiOsDeleteMutex (Object->Mutex.OsMutex);
191  AcpiGbl_GlobalLockMutex = NULL;
192  }
193  else
194  {
196  AcpiOsDeleteMutex (Object->Mutex.OsMutex);
197  }
198  break;
199 
200  case ACPI_TYPE_EVENT:
201 
203  "***** Event %p, OS Semaphore %p\n",
204  Object, Object->Event.OsSemaphore));
205 
206  (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
207  Object->Event.OsSemaphore = NULL;
208  break;
209 
210  case ACPI_TYPE_METHOD:
211 
213  "***** Method %p\n", Object));
214 
215  /* Delete the method mutex if it exists */
216 
217  if (Object->Method.Mutex)
218  {
219  AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
220  AcpiUtDeleteObjectDesc (Object->Method.Mutex);
221  Object->Method.Mutex = NULL;
222  }
223 
224  if (Object->Method.Node)
225  {
226  Object->Method.Node = NULL;
227  }
228  break;
229 
230  case ACPI_TYPE_REGION:
231 
233  "***** Region %p\n", Object));
234 
235  /*
236  * Update AddressRange list. However, only permanent regions
237  * are installed in this list. (Not created within a method)
238  */
239  if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
240  {
241  AcpiUtRemoveAddressRange (Object->Region.SpaceId,
242  Object->Region.Node);
243  }
244 
245  SecondDesc = AcpiNsGetSecondaryObject (Object);
246  if (SecondDesc)
247  {
248  /*
249  * Free the RegionContext if and only if the handler is one of the
250  * default handlers -- and therefore, we created the context object
251  * locally, it was not created by an external caller.
252  */
253  HandlerDesc = Object->Region.Handler;
254  if (HandlerDesc)
255  {
256  NextDesc = HandlerDesc->AddressSpace.RegionList;
257  StartDesc = NextDesc;
258  LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
259 
260  /* Remove the region object from the handler list */
261 
262  while (NextDesc)
263  {
264  if (NextDesc == Object)
265  {
266  *LastObjPtr = NextDesc->Region.Next;
267  break;
268  }
269 
270  /* Walk the linked list of handlers */
271 
272  LastObjPtr = &NextDesc->Region.Next;
273  NextDesc = NextDesc->Region.Next;
274 
275  /* Prevent infinite loop if list is corrupted */
276 
277  if (NextDesc == StartDesc)
278  {
280  "Circular region list in address handler object %p",
281  HandlerDesc));
282  return_VOID;
283  }
284  }
285 
286  if (HandlerDesc->AddressSpace.HandlerFlags &
288  {
289  /* Deactivate region and free region context */
290 
291  if (HandlerDesc->AddressSpace.Setup)
292  {
293  (void) HandlerDesc->AddressSpace.Setup (Object,
295  HandlerDesc->AddressSpace.Context,
296  &SecondDesc->Extra.RegionContext);
297  }
298  }
299 
300  AcpiUtRemoveReference (HandlerDesc);
301  }
302 
303  /* Now we can free the Extra object */
304 
305  AcpiUtDeleteObjectDesc (SecondDesc);
306  }
307  if (Object->Field.InternalPccBuffer)
308  {
309  ACPI_FREE(Object->Field.InternalPccBuffer);
310  }
311 
312  break;
313 
315 
317  "***** Buffer Field %p\n", Object));
318 
319  SecondDesc = AcpiNsGetSecondaryObject (Object);
320  if (SecondDesc)
321  {
322  AcpiUtDeleteObjectDesc (SecondDesc);
323  }
324  break;
325 
327 
329  "***** Bank Field %p\n", Object));
330 
331  SecondDesc = AcpiNsGetSecondaryObject (Object);
332  if (SecondDesc)
333  {
334  AcpiUtDeleteObjectDesc (SecondDesc);
335  }
336  break;
337 
338  default:
339 
340  break;
341  }
342 
343  /* Free any allocated memory (pointer within the object) found above */
344 
345  if (ObjPointer)
346  {
347  ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
348  ObjPointer));
349  ACPI_FREE (ObjPointer);
350  }
351 
352  /* Now the object can be safely deleted */
353 
354  ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ALLOCATIONS, "%s: Deleting Object %p [%s]\n",
356 
358  return_VOID;
359 }
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_TYPE_EVENT
Definition: actypes.h:685
union acpi_operand_object * Next
Definition: acobject.h:205
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ACPI_TYPE_THERMAL
Definition: actypes.h:691
#define ACPI_TYPE_BUFFER
Definition: actypes.h:681
void AcpiUtDeleteObjectDesc(ACPI_OPERAND_OBJECT *Object)
Definition: utobject.c:473
ACPI_ADR_SPACE_SETUP Setup
Definition: acobject.h:415
#define ACPI_REGION_DEACTIVATE
Definition: actypes.h:1221
union acpi_operand_object * RegionList
Definition: acobject.h:416
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:682
#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
Definition: acobject.h:423
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:538
void AcpiExUnlinkMutex(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exmutex.c:73
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
union acpi_operand_object * Next
Definition: acobject.h:417
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define ACPI_TYPE_METHOD
Definition: actypes.h:686
ACPI_STATUS AcpiEvDeleteGpeBlock(ACPI_GPE_BLOCK_INFO *GpeBlock)
Definition: evgpeblk.c:148
ACPI_STATUS AcpiOsDeleteSemaphore(ACPI_SEMAPHORE Handle)
Definition: osl.c:378
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
static IUnknown Object
Definition: main.c:512
#define return_VOID
Definition: acoutput.h:495
ACPI_OBJECT_ADDR_HANDLER AddressSpace
Definition: acobject.h:536
#define ACPI_TYPE_DEVICE
Definition: actypes.h:684
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:690
#define ACPI_GET_FUNCTION_NAME
Definition: acgcc.h:67
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:692
#define ACPI_TYPE_MUTEX
Definition: actypes.h:687
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_TYPE_REGION
Definition: actypes.h:688
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:708
void * RegionContext
Definition: acobject.h:480
#define ACPI_TYPE_STRING
Definition: actypes.h:680
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175
void AcpiOsDeleteMutex(ACPI_MUTEX Handle)
Definition: osl.c:293
void AcpiUtRemoveAddressRange(ACPI_ADR_SPACE_TYPE SpaceId, ACPI_NAMESPACE_NODE *RegionNode)
Definition: utaddress.c:139
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:263
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346
#define ANOBJ_TEMPORARY
Definition: aclocal.h:216

Referenced by AcpiUtUpdateRefCount().

◆ AcpiUtDeleteInternalObjectList()

void AcpiUtDeleteInternalObjectList ( ACPI_OPERAND_OBJECT **  ObjList)

Definition at line 376 of file utdelete.c.

378 {
379  ACPI_OPERAND_OBJECT **InternalObj;
380 
381 
383 
384 
385  /* Walk the null-terminated internal list */
386 
387  for (InternalObj = ObjList; *InternalObj; InternalObj++)
388  {
389  AcpiUtRemoveReference (*InternalObj);
390  }
391 
392  /* Free the combined parameter pointer list and object array */
393 
394  ACPI_FREE (ObjList);
395  return;
396 }
#define ACPI_FREE(a)
Definition: actypes.h:386
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484

Referenced by AcpiEvaluateObject().

◆ AcpiUtRemoveReference()

void AcpiUtRemoveReference ( ACPI_OPERAND_OBJECT Object)

Definition at line 784 of file utdelete.c.

786 {
787 
788  ACPI_FUNCTION_NAME (UtRemoveReference);
789 
790 
791  /*
792  * Allow a NULL pointer to be passed in, just ignore it. This saves
793  * each caller from having to check. Also, ignore NS nodes.
794  */
795  if (!Object ||
797 
798  {
799  return;
800  }
801 
802  /* Ensure that we have a valid object */
803 
805  {
806  return;
807  }
808 
810  "%s: Obj %p Current Refs=%X [To Be Decremented]\n",
811  ACPI_GET_FUNCTION_NAME, Object, Object->Common.ReferenceCount));
812 
813  /*
814  * Decrement the reference count, and only actually delete the object
815  * if the reference count becomes 0. (Must also decrement the ref count
816  * of all subobjects!)
817  */
819  return;
820 }
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_STATUS AcpiUtUpdateObjectReference(ACPI_OPERAND_OBJECT *Object, UINT16 Action)
Definition: utdelete.c:539
static IUnknown Object
Definition: main.c:512
#define ACPI_GET_FUNCTION_NAME
Definition: acgcc.h:67
BOOLEAN AcpiUtValidInternalObject(void *Object)
Definition: utobject.c:376
#define REF_DECREMENT
Definition: acutils.h:181
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:574
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiDsBuildInternalBufferObj(), AcpiDsBuildInternalObject(), AcpiDsBuildInternalPackageObj(), AcpiDsCallControlMethod(), AcpiDsClearImplicitReturn(), AcpiDsClearOperands(), AcpiDsCreateBufferField(), AcpiDsCreateNode(), AcpiDsDeleteResultIfNotUsed(), AcpiDsEvalBankFieldOperands(), AcpiDsEvalDataObjectOperands(), AcpiDsEvalRegionOperands(), AcpiDsEvalTableRegionOperands(), AcpiDsEvaluateNamePath(), AcpiDsExecEndControlOp(), AcpiDsGetFieldNames(), AcpiDsGetPredicateValue(), AcpiDsInitBufferField(), AcpiDsLoad2EndOp(), AcpiDsMethodDataDeleteValue(), AcpiDsObjStackPopAndDelete(), AcpiDsResolvePackageElement(), AcpiDsRestartControlMethod(), AcpiDsStoreObjectToLocal(), AcpiEvaluateObject(), AcpiEvDetachRegion(), AcpiEvExecuteRegMethod(), AcpiEvInstallSpaceHandler(), AcpiExCreateEvent(), AcpiExCreateMethod(), AcpiExCreateMutex(), AcpiExCreatePowerResource(), AcpiExCreateProcessor(), AcpiExCreateRegion(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExLoadOp(), AcpiExLoadTableOp(), AcpiExOpcode_0A_0T_1R(), AcpiExOpcode_1A_0T_1R(), AcpiExOpcode_1A_1T_1R(), AcpiExOpcode_2A_0T_1R(), AcpiExOpcode_2A_1T_1R(), AcpiExOpcode_2A_2T_1R(), AcpiExOpcode_3A_1T_1R(), AcpiExOpcode_6A_0T_1R(), AcpiExPrepFieldValue(), AcpiExReadDataFromField(), AcpiExResolveMultiple(), AcpiExResolveObjectToValue(), AcpiExResolveOperands(), AcpiExStoreDirectToNode(), AcpiExStoreObjectToIndex(), AcpiExStoreObjectToObject(), AcpiGetSleepTypeData(), AcpiInstallGpeBlock(), AcpiInstallMethod(), AcpiInstallNotifyHandler(), AcpiNsDeleteNode(), AcpiNsDetachData(), AcpiNsDetachObject(), AcpiNsEvaluate(), AcpiNsExecuteTable(), AcpiNsRemoveElement(), AcpiNsRepair_FDE(), AcpiNsRepair_HID(), AcpiNsResolveReferences(), AcpiNsRootInitialize(), AcpiNsSearchAndEnter(), AcpiNsSimpleRepair(), AcpiPsParseAml(), AcpiRemoveAddressSpaceHandler(), AcpiRemoveNotifyHandler(), AcpiRsGetAeiMethodData(), AcpiRsGetCrsMethodData(), AcpiRsGetMethodData(), AcpiRsGetPrsMethodData(), AcpiRsGetPrtMethodData(), AcpiRsSetSrsMethodData(), AcpiUtCopyEpackageToIpackage(), AcpiUtCopyEsimpleToIsimple(), AcpiUtCopyIelementToIelement(), AcpiUtCopyIobjectToIobject(), AcpiUtCopyIpackageToIpackage(), AcpiUtCreateBufferObject(), AcpiUtCreateStringObject(), AcpiUtDeleteInternalObj(), AcpiUtDeleteInternalObjectList(), AcpiUtEvaluateNumericObject(), AcpiUtEvaluateObject(), AcpiUtExecute_CID(), AcpiUtExecute_CLS(), AcpiUtExecute_HID(), AcpiUtExecute_STA(), AcpiUtExecute_UID(), AcpiUtExecutePowerMethods(), and AcpiUtOsiImplementation().

◆ AcpiUtUpdateObjectReference()

ACPI_STATUS AcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT Object,
UINT16  Action 
)

Definition at line 539 of file utdelete.c.

542 {
544  ACPI_GENERIC_STATE *StateList = NULL;
545  ACPI_OPERAND_OBJECT *NextObject = NULL;
546  ACPI_OPERAND_OBJECT *PrevObject;
548  UINT32 i;
549 
550 
551  ACPI_FUNCTION_NAME (UtUpdateObjectReference);
552 
553 
554  while (Object)
555  {
556  /* Make sure that this isn't a namespace handle */
557 
559  {
561  "Object %p is NS handle\n", Object));
562  return (AE_OK);
563  }
564 
565  /*
566  * All sub-objects must have their reference count incremented
567  * also. Different object types have different subobjects.
568  */
569  switch (Object->Common.Type)
570  {
571  case ACPI_TYPE_DEVICE:
572  case ACPI_TYPE_PROCESSOR:
573  case ACPI_TYPE_POWER:
574  case ACPI_TYPE_THERMAL:
575  /*
576  * Update the notify objects for these types (if present)
577  * Two lists, system and device notify handlers.
578  */
579  for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
580  {
581  PrevObject = Object->CommonNotify.NotifyList[i];
582  while (PrevObject)
583  {
584  NextObject = PrevObject->Notify.Next[i];
585  AcpiUtUpdateRefCount (PrevObject, Action);
586  PrevObject = NextObject;
587  }
588  }
589  break;
590 
591  case ACPI_TYPE_PACKAGE:
592  /*
593  * We must update all the sub-objects of the package,
594  * each of whom may have their own sub-objects.
595  */
596  for (i = 0; i < Object->Package.Count; i++)
597  {
598  /*
599  * Null package elements are legal and can be simply
600  * ignored.
601  */
602  NextObject = Object->Package.Elements[i];
603  if (!NextObject)
604  {
605  continue;
606  }
607 
608  switch (NextObject->Common.Type)
609  {
610  case ACPI_TYPE_INTEGER:
611  case ACPI_TYPE_STRING:
612  case ACPI_TYPE_BUFFER:
613  /*
614  * For these very simple sub-objects, we can just
615  * update the reference count here and continue.
616  * Greatly increases performance of this operation.
617  */
618  AcpiUtUpdateRefCount (NextObject, Action);
619  break;
620 
621  default:
622  /*
623  * For complex sub-objects, push them onto the stack
624  * for later processing (this eliminates recursion.)
625  */
627  NextObject, Action, &StateList);
628  if (ACPI_FAILURE (Status))
629  {
630  goto ErrorExit;
631  }
632  break;
633  }
634  }
635  NextObject = NULL;
636  break;
637 
639 
640  NextObject = Object->BufferField.BufferObj;
641  break;
642 
644 
645  NextObject = Object->Field.RegionObj;
646  break;
647 
649 
650  NextObject = Object->BankField.BankObj;
652  Object->BankField.RegionObj, Action, &StateList);
653  if (ACPI_FAILURE (Status))
654  {
655  goto ErrorExit;
656  }
657  break;
658 
660 
661  NextObject = Object->IndexField.IndexObj;
663  Object->IndexField.DataObj, Action, &StateList);
664  if (ACPI_FAILURE (Status))
665  {
666  goto ErrorExit;
667  }
668  break;
669 
671  /*
672  * The target of an Index (a package, string, or buffer) or a named
673  * reference must track changes to the ref count of the index or
674  * target object.
675  */
676  if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
677  (Object->Reference.Class== ACPI_REFCLASS_NAME))
678  {
679  NextObject = Object->Reference.Object;
680  }
681  break;
682 
683  case ACPI_TYPE_REGION:
684  default:
685 
686  break; /* No subobjects for all other types */
687  }
688 
689  /*
690  * Now we can update the count in the main object. This can only
691  * happen after we update the sub-objects in case this causes the
692  * main object to be deleted.
693  */
695  Object = NULL;
696 
697  /* Move on to the next object to be updated */
698 
699  if (NextObject)
700  {
701  Object = NextObject;
702  NextObject = NULL;
703  }
704  else if (StateList)
705  {
706  State = AcpiUtPopGenericState (&StateList);
707  Object = State->Update.Object;
709  }
710  }
711 
712  return (AE_OK);
713 
714 
715 ErrorExit:
716 
718  "Could not update object reference count"));
719 
720  /* Free any stacked Update State objects */
721 
722  while (StateList)
723  {
724  State = AcpiUtPopGenericState (&StateList);
726  }
727 
728  return (Status);
729 }
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
static void AcpiUtUpdateRefCount(ACPI_OPERAND_OBJECT *Object, UINT32 Action)
Definition: utdelete.c:413
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
#define ACPI_TYPE_THERMAL
Definition: actypes.h:691
#define ACPI_TYPE_BUFFER
Definition: actypes.h:681
#define ACPI_TYPE_INTEGER
Definition: actypes.h:679
#define ACPI_TYPE_POWER
Definition: actypes.h:689
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:710
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_LOCAL_INDEX_FIELD
Definition: actypes.h:709
union acpi_operand_object * Next[2]
Definition: acobject.h:402
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:682
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
ACPI_STATUS AcpiUtCreateUpdateStateAndPush(ACPI_OPERAND_OBJECT *Object, UINT16 Action, ACPI_GENERIC_STATE **StateList)
Definition: utmisc.c:219
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_OBJECT_NOTIFY_HANDLER Notify
Definition: acobject.h:535
static IUnknown Object
Definition: main.c:512
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:707
#define ACPI_TYPE_DEVICE
Definition: actypes.h:684
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:690
Status
Definition: gdiplustypes.h:24
enum State_ State
Definition: pofuncs.h:54
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:692
ACPI_OBJECT_COMMON Common
Definition: acobject.h:516
#define ACPI_TYPE_REGION
Definition: actypes.h:688
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:708
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_TYPE_STRING
Definition: actypes.h:680
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:574
#define AE_OK
Definition: acexcep.h:97
#define ACPI_NUM_NOTIFY_TYPES
Definition: actypes.h:838
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiPsUpdateParameterList(), AcpiUtAddReference(), and AcpiUtRemoveReference().

◆ AcpiUtUpdateRefCount()

static void AcpiUtUpdateRefCount ( ACPI_OPERAND_OBJECT Object,
UINT32  Action 
)
static

Definition at line 413 of file utdelete.c.

416 {
417  UINT16 OriginalCount;
418  UINT16 NewCount = 0;
419  ACPI_CPU_FLAGS LockFlags;
420  char *Message;
421 
422 
423  ACPI_FUNCTION_NAME (UtUpdateRefCount);
424 
425 
426  if (!Object)
427  {
428  return;
429  }
430 
431  /*
432  * Always get the reference count lock. Note: Interpreter and/or
433  * Namespace is not always locked when this function is called.
434  */
435  LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock);
436  OriginalCount = Object->Common.ReferenceCount;
437 
438  /* Perform the reference count action (increment, decrement) */
439 
440  switch (Action)
441  {
442  case REF_INCREMENT:
443 
444  NewCount = OriginalCount + 1;
445  Object->Common.ReferenceCount = NewCount;
446  AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
447 
448  /* The current reference count should never be zero here */
449 
450  if (!OriginalCount)
451  {
453  "Obj %p, Reference Count was zero before increment\n",
454  Object));
455  }
456 
458  "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n",
459  Object, Object->Common.Type,
460  AcpiUtGetObjectTypeName (Object), NewCount));
461  Message = "Incremement";
462  break;
463 
464  case REF_DECREMENT:
465 
466  /* The current reference count must be non-zero */
467 
468  if (OriginalCount)
469  {
470  NewCount = OriginalCount - 1;
471  Object->Common.ReferenceCount = NewCount;
472  }
473 
474  AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
475 
476  if (!OriginalCount)
477  {
479  "Obj %p, Reference Count is already zero, cannot decrement\n",
480  Object));
481  }
482 
484  "%s: Obj %p Type %.2X Refs %.2X [Decremented]\n",
485  ACPI_GET_FUNCTION_NAME, Object, Object->Common.Type, NewCount));
486 
487  /* Actually delete the object on a reference count of zero */
488 
489  if (NewCount == 0)
490  {
492  }
493  Message = "Decrement";
494  break;
495 
496  default:
497 
498  AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
499  ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)",
500  Action));
501  return;
502  }
503 
504  /*
505  * Sanity check the reference count, for debug purposes only.
506  * (A deleted object will have a huge reference count)
507  */
508  if (NewCount > ACPI_MAX_REFERENCE_COUNT)
509  {
511  "Large Reference Count (0x%X) in object %p, Type=0x%.2X Operation=%s",
512  NewCount, Object, Object->Common.Type, Message));
513  }
514 }
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_MAX_REFERENCE_COUNT
Definition: acconfig.h:128
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
Definition: osl.c:498
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_CPU_FLAGS
Definition: actypes.h:252
#define AE_INFO
Definition: acoutput.h:230
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
static IUnknown Object
Definition: main.c:512
CHAR Message[80]
Definition: alive.c:5
#define ACPI_GET_FUNCTION_NAME
Definition: acgcc.h:67
unsigned short UINT16
static void AcpiUtDeleteInternalObj(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:80
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define REF_DECREMENT
Definition: acutils.h:181
void AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
Definition: osl.c:516
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:263
#define REF_INCREMENT
Definition: acutils.h:180

Referenced by AcpiUtUpdateObjectReference().