📄 utdelete.c
字号:
voidAcpiUtDeleteInternalObjectList ( ACPI_OPERAND_OBJECT **ObjList){ ACPI_OPERAND_OBJECT **InternalObj; ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList); /* Walk the null-terminated internal list */ for (InternalObj = ObjList; *InternalObj; InternalObj++) { AcpiUtRemoveReference (*InternalObj); } /* Free the combined parameter pointer list and object array */ ACPI_FREE (ObjList); return_VOID;}/******************************************************************************* * * FUNCTION: AcpiUtUpdateRefCount * * PARAMETERS: Object - Object whose ref count is to be updated * Action - What to do * * RETURN: New ref count * * DESCRIPTION: Modify the ref count and return it. * ******************************************************************************/static voidAcpiUtUpdateRefCount ( ACPI_OPERAND_OBJECT *Object, UINT32 Action){ UINT16 Count; UINT16 NewCount; ACPI_FUNCTION_NAME (UtUpdateRefCount); if (!Object) { return; } Count = Object->Common.ReferenceCount; NewCount = Count; /* * Perform the reference count action (increment, decrement, force delete) */ switch (Action) { case REF_INCREMENT: NewCount++; Object->Common.ReferenceCount = NewCount; ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n", Object, NewCount)); break; case REF_DECREMENT: if (Count < 1) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n", Object, NewCount)); NewCount = 0; } else { NewCount--; ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } if (ACPI_GET_OBJECT_TYPE (Object) == ACPI_TYPE_METHOD) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } Object->Common.ReferenceCount = NewCount; if (NewCount == 0) { AcpiUtDeleteInternalObj (Object); } break; case REF_FORCE_DELETE: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); NewCount = 0; Object->Common.ReferenceCount = NewCount; AcpiUtDeleteInternalObj (Object); break; default: ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); break; } /* * Sanity check the reference count, for debug purposes only. * (A deleted object will have a huge reference count) */ if (Count > ACPI_MAX_REFERENCE_COUNT) { ACPI_WARNING ((AE_INFO, "Large Reference Count (%X) in object %p", Count, Object)); }}/******************************************************************************* * * FUNCTION: AcpiUtUpdateObjectReference * * PARAMETERS: Object - Increment ref count for this object * and all sub-objects * Action - Either REF_INCREMENT or REF_DECREMENT or * REF_FORCE_DELETE * * RETURN: Status * * DESCRIPTION: Increment the object reference count * * Object references are incremented when: * 1) An object is attached to a Node (namespace object) * 2) An object is copied (all subobjects must be incremented) * * Object references are decremented when: * 1) An object is detached from an Node * ******************************************************************************/ACPI_STATUSAcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT *Object, UINT16 Action){ ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *StateList = NULL; ACPI_OPERAND_OBJECT *NextObject = NULL; ACPI_GENERIC_STATE *State; ACPI_NATIVE_UINT i; ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object); while (Object) { /* Make sure that this isn't a namespace handle */ if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", Object)); return_ACPI_STATUS (AE_OK); } /* * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ switch (ACPI_GET_OBJECT_TYPE (Object)) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: case ACPI_TYPE_THERMAL: /* Update the notify objects for these types (if present) */ AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action); AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action); break; case ACPI_TYPE_PACKAGE: /* * We must update all the sub-objects of the package, * each of whom may have their own sub-objects. */ for (i = 0; i < Object->Package.Count; i++) { /* * Push each element onto the stack for later processing. * Note: There can be null elements within the package, * these are simply ignored */ Status = AcpiUtCreateUpdateStateAndPush ( Object->Package.Elements[i], Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } } break; case ACPI_TYPE_BUFFER_FIELD: NextObject = Object->BufferField.BufferObj; break; case ACPI_TYPE_LOCAL_REGION_FIELD: NextObject = Object->Field.RegionObj; break; case ACPI_TYPE_LOCAL_BANK_FIELD: NextObject = Object->BankField.BankObj; Status = AcpiUtCreateUpdateStateAndPush ( Object->BankField.RegionObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; case ACPI_TYPE_LOCAL_INDEX_FIELD: NextObject = Object->IndexField.IndexObj; Status = AcpiUtCreateUpdateStateAndPush ( Object->IndexField.DataObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; case ACPI_TYPE_LOCAL_REFERENCE: /* * The target of an Index (a package, string, or buffer) or a named * reference must track changes to the ref count of the index or * target object. */ if ((Object->Reference.Opcode == AML_INDEX_OP) || (Object->Reference.Opcode == AML_INT_NAMEPATH_OP)) { NextObject = Object->Reference.Object; } break; case ACPI_TYPE_REGION: default: break; /* No subobjects for all other types */ } /* * Now we can update the count in the main object. This can only * happen after we update the sub-objects in case this causes the * main object to be deleted. */ AcpiUtUpdateRefCount (Object, Action); Object = NULL; /* Move on to the next object to be updated */ if (NextObject) { Object = NextObject; NextObject = NULL; } else if (StateList) { State = AcpiUtPopGenericState (&StateList); Object = State->Update.Object; AcpiUtDeleteGenericState (State); } } return_ACPI_STATUS (AE_OK);ErrorExit: ACPI_EXCEPTION ((AE_INFO, Status, "Could not update object reference count")); return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiUtAddReference * * PARAMETERS: Object - Object whose reference count is to be * incremented * * RETURN: None * * DESCRIPTION: Add one reference to an ACPI object * ******************************************************************************/voidAcpiUtAddReference ( ACPI_OPERAND_OBJECT *Object){ ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object); /* Ensure that we have a valid object */ if (!AcpiUtValidInternalObject (Object)) { return_VOID; } ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Current Refs=%X [To Be Incremented]\n", Object, Object->Common.ReferenceCount)); /* Increment the reference count */ (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); return_VOID;}/******************************************************************************* * * FUNCTION: AcpiUtRemoveReference * * PARAMETERS: Object - Object whose ref count will be decremented * * RETURN: None * * DESCRIPTION: Decrement the reference count of an ACPI internal object * ******************************************************************************/voidAcpiUtRemoveReference ( ACPI_OPERAND_OBJECT *Object){ ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object); /* * Allow a NULL pointer to be passed in, just ignore it. This saves * each caller from having to check. Also, ignore NS nodes. * */ if (!Object || (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) { return_VOID; } /* Ensure that we have a valid object */ if (!AcpiUtValidInternalObject (Object)) { return_VOID; } ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Current Refs=%X [To Be Decremented]\n", Object, Object->Common.ReferenceCount)); /* * Decrement the reference count, and only actually delete the object * if the reference count becomes 0. (Must also decrement the ref count * of all subobjects!) */ (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); return_VOID;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -