ACPI_STATUS AcpiPsPushScope ( ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Op, UINT32 RemainingArgs, UINT32 ArgCount) { ACPI_GENERIC_STATE *Scope; ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); Scope = AcpiUtCreateGenericState (); if (!Scope) { return_ACPI_STATUS (AE_NO_MEMORY); } Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; Scope->ParseScope.Op = Op; Scope->ParseScope.ArgList = RemainingArgs; Scope->ParseScope.ArgCount = ArgCount; Scope->ParseScope.PkgEnd = ParserState->PkgEnd; /* Push onto scope stack */ AcpiUtPushGenericState (&ParserState->Scope, Scope); if (ArgCount == ACPI_VAR_ARGS) { /* Multiple arguments */ Scope->ParseScope.ArgEnd = ParserState->PkgEnd; } else { /* Single argument */ Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); } return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiUtCreatePkgStateAndPush ( void *InternalObject, void *ExternalObject, UINT16 Index, ACPI_GENERIC_STATE **StateList) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_ENTRY (); State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); if (!State) { return (AE_NO_MEMORY); } AcpiUtPushGenericState (StateList, State); return (AE_OK); }
static ACPI_STATUS AcpiDsResultStackPush ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME (DsResultStackPush); /* Check for stack overflow */ if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > ACPI_RESULTS_OBJ_NUM_MAX) { ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%u", WalkState, WalkState->ResultSize)); return (AE_STACK_OVERFLOW); } State = AcpiUtCreateGenericState (); if (!State) { return (AE_NO_MEMORY); } State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; AcpiUtPushGenericState (&WalkState->Results, State); /* Increase the length of the result stack by the length of frame */ WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", State, WalkState)); return (AE_OK); }
ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; ACPI_GENERIC_STATE *OldScopeInfo; ACPI_FUNCTION_TRACE (DsScopeStackPush); if (!Node) { /* Invalid scope */ ACPI_ERROR ((AE_INFO, "Null scope parameter")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!AcpiUtValidObjectType (Type)) { ACPI_WARNING ((AE_INFO, "Invalid object type: 0x%X", Type)); } /* Allocate a new scope object */ ScopeInfo = AcpiUtCreateGenericState (); if (!ScopeInfo) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new scope object */ ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE; ScopeInfo->Scope.Node = Node; ScopeInfo->Common.Value = (UINT16) Type; WalkState->ScopeDepth++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); OldScopeInfo = WalkState->ScopeInfo; if (OldScopeInfo) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "[%4.4s] (%s)", AcpiUtGetNodeName (OldScopeInfo->Scope.Node), AcpiUtGetTypeName (OldScopeInfo->Common.Value))); } else { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, ACPI_NAMESPACE_ROOT)); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, ", New scope -> [%4.4s] (%s)\n", AcpiUtGetNodeName (ScopeInfo->Scope.Node), AcpiUtGetTypeName (ScopeInfo->Common.Value))); /* Push new scope object onto stack */ AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *ControlState; ACPI_FUNCTION_NAME (DsExecBeginControlOp); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, Op->Common.AmlOpcode, WalkState)); switch (Op->Common.AmlOpcode) { case AML_WHILE_OP: /* * If this is an additional iteration of a while loop, continue. * There is no need to allocate a new control state. */ if (WalkState->ControlState) { if (WalkState->ControlState->Control.AmlPredicateStart == (WalkState->ParserState.Aml - 1)) { /* Reset the state to start-of-loop */ WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; break; } } /*lint -fallthrough */ case AML_IF_OP: /* * IF/WHILE: Create a new control state to manage these * constructs. We need to manage these as a stack, in order * to handle nesting. */ ControlState = AcpiUtCreateControlState (); if (!ControlState) { Status = AE_NO_MEMORY; break; } /* * Save a pointer to the predicate for multiple executions * of a loop */ ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; ControlState->Control.Opcode = Op->Common.AmlOpcode; ControlState->Control.LoopTimeout = AcpiOsGetTimer () + (UINT64) (AcpiGbl_MaxLoopIterations * ACPI_100NSEC_PER_SEC); /* Push the control state on this walk's control stack */ AcpiUtPushGenericState (&WalkState->ControlState, ControlState); break; case AML_ELSE_OP: /* Predicate is in the state object */ /* If predicate is true, the IF was executed, ignore ELSE part */ if (WalkState->LastPredicate) { Status = AE_CTRL_TRUE; } break; case AML_RETURN_OP: break; default: break; } return (Status); }
ACPI_STATUS AcpiUtWalkPackageTree ( ACPI_OPERAND_OBJECT *SourceObject, void *TargetObject, ACPI_PKG_CALLBACK WalkCallback, void *Context) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *StateList = NULL; ACPI_GENERIC_STATE *State; UINT32 ThisIndex; ACPI_OPERAND_OBJECT *ThisSourceObj; ACPI_FUNCTION_TRACE (UtWalkPackageTree); State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); if (!State) { return_ACPI_STATUS (AE_NO_MEMORY); } while (State) { /* Get one element of the package */ ThisIndex = State->Pkg.Index; ThisSourceObj = (ACPI_OPERAND_OBJECT *) State->Pkg.SourceObject->Package.Elements[ThisIndex]; /* * Check for: * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * case below. */ if ((!ThisSourceObj) || (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) { Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } State->Pkg.Index++; while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ AcpiUtDeleteGenericState (State); State = AcpiUtPopGenericState (&StateList); /* Finished when there are no more states */ if (!State) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS (AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ State->Pkg.Index++; } } else { /* This is a subobject of type package */ Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ AcpiUtPushGenericState (&StateList, State); State = AcpiUtCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0); if (!State) { /* Free any stacked Update State objects */ while (StateList) { State = AcpiUtPopGenericState (&StateList); AcpiUtDeleteGenericState (State); } return_ACPI_STATUS (AE_NO_MEMORY); } } } /* We should never get here */ return_ACPI_STATUS (AE_AML_INTERNAL); }
ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *ControlState; ACPI_FUNCTION_NAME (DsExecBeginControlOp); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, Op->Common.AmlOpcode, WalkState)); switch (Op->Common.AmlOpcode) { case AML_IF_OP: case AML_WHILE_OP: /* * IF/WHILE: Create a new control state to manage these * constructs. We need to manage these as a stack, in order * to handle nesting. */ ControlState = AcpiUtCreateControlState (); if (!ControlState) { Status = AE_NO_MEMORY; break; } /* * Save a pointer to the predicate for multiple executions * of a loop */ ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; ControlState->Control.Opcode = Op->Common.AmlOpcode; /* Push the control state on this walk's control stack */ AcpiUtPushGenericState (&WalkState->ControlState, ControlState); break; case AML_ELSE_OP: /* Predicate is in the state object */ /* If predicate is true, the IF was executed, ignore ELSE part */ if (WalkState->LastPredicate) { Status = AE_CTRL_TRUE; } break; case AML_RETURN_OP: break; default: break; } return (Status); }
ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; ACPI_GENERIC_STATE *OldScopeInfo; ACPI_FUNCTION_TRACE ("DsScopeStackPush"); if (!Node) { /* Invalid scope */ ACPI_REPORT_ERROR (("DsScopeStackPush: null scope passed\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!AcpiUtValidObjectType (Type)) { ACPI_REPORT_WARNING (("DsScopeStackPush: type code out of range\n")); } /* Allocate a new scope object */ ScopeInfo = AcpiUtCreateGenericState (); if (!ScopeInfo) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new scope object */ ScopeInfo->Common.DataType = ACPI_DESC_TYPE_STATE_WSCOPE; ScopeInfo->Scope.Node = Node; ScopeInfo->Common.Value = (UINT16) Type; WalkState->ScopeDepth++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); OldScopeInfo = WalkState->ScopeInfo; if (OldScopeInfo) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "[%4.4s] (%10s)", OldScopeInfo->Scope.Node->Name.Ascii, AcpiUtGetTypeName (OldScopeInfo->Common.Value))); } else { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "[\\___] (%10s)", "ROOT")); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, ", New scope -> [%4.4s] (%s)\n", ScopeInfo->Scope.Node->Name.Ascii, AcpiUtGetTypeName (ScopeInfo->Common.Value))); /* Push new scope object onto stack */ AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); return_ACPI_STATUS (AE_OK); }