summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/dispatcher/dsopcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/dispatcher/dsopcode.c')
-rw-r--r--sys/contrib/dev/acpica/dispatcher/dsopcode.c746
1 files changed, 4 insertions, 742 deletions
diff --git a/sys/contrib/dev/acpica/dispatcher/dsopcode.c b/sys/contrib/dev/acpica/dispatcher/dsopcode.c
index b56e5fc..2f8aae2 100644
--- a/sys/contrib/dev/acpica/dispatcher/dsopcode.c
+++ b/sys/contrib/dev/acpica/dispatcher/dsopcode.c
@@ -1,7 +1,6 @@
/******************************************************************************
*
- * Module Name: dsopcode - Dispatcher Op Region support and handling of
- * "control" opcodes
+ * Module Name: dsopcode - Dispatcher suport for regions and fields
*
*****************************************************************************/
@@ -60,13 +59,6 @@
/* Local prototypes */
static ACPI_STATUS
-AcpiDsExecuteArguments (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_NAMESPACE_NODE *ScopeNode,
- UINT32 AmlLength,
- UINT8 *AmlStart);
-
-static ACPI_STATUS
AcpiDsInitBufferField (
UINT16 AmlOpcode,
ACPI_OPERAND_OBJECT *ObjDesc,
@@ -78,369 +70,6 @@ AcpiDsInitBufferField (
/*******************************************************************************
*
- * FUNCTION: AcpiDsExecuteArguments
- *
- * PARAMETERS: Node - Object NS node
- * ScopeNode - Parent NS node
- * AmlLength - Length of executable AML
- * AmlStart - Pointer to the AML
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Late (deferred) execution of region or field arguments
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiDsExecuteArguments (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_NAMESPACE_NODE *ScopeNode,
- UINT32 AmlLength,
- UINT8 *AmlStart)
-{
- ACPI_STATUS Status;
- ACPI_PARSE_OBJECT *Op;
- ACPI_WALK_STATE *WalkState;
-
-
- ACPI_FUNCTION_TRACE (DsExecuteArguments);
-
-
- /*
- * Allocate a new parser op to be the root of the parsed tree
- */
- Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
- if (!Op)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Save the Node for use in AcpiPsParseAml */
-
- Op->Common.Node = ScopeNode;
-
- /* Create and initialize a new parser state */
-
- WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
- if (!WalkState)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
- AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
-
- /* Mark this parse as a deferred opcode */
-
- WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
- WalkState->DeferredNode = Node;
-
- /* Pass1: Parse the entire declaration */
-
- Status = AcpiPsParseAml (WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Get and init the Op created above */
-
- Op->Common.Node = Node;
- AcpiPsDeleteParseTree (Op);
-
- /* Evaluate the deferred arguments */
-
- Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
- if (!Op)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Op->Common.Node = ScopeNode;
-
- /* Create and initialize a new parser state */
-
- WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
- if (!WalkState)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Execute the opcode and arguments */
-
- Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
- AmlLength, NULL, ACPI_IMODE_EXECUTE);
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
-
- /* Mark this execution as a deferred opcode */
-
- WalkState->DeferredNode = Node;
- Status = AcpiPsParseAml (WalkState);
-
-Cleanup:
- AcpiPsDeleteParseTree (Op);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsGetBufferFieldArguments
- *
- * PARAMETERS: ObjDesc - A valid BufferField object
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
- * evaluation of these field attributes.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDsGetBufferFieldArguments (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_OPERAND_OBJECT *ExtraDesc;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc);
-
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Get the AML pointer (method object) and BufferField node */
-
- ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
- Node = ObjDesc->BufferField.Node;
-
- ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
- AcpiUtGetNodeName (Node)));
-
- /* Execute the AML code for the TermArg arguments */
-
- Status = AcpiDsExecuteArguments (Node, Node->Parent,
- ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsGetBankFieldArguments
- *
- * PARAMETERS: ObjDesc - A valid BankField object
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Get BankField BankValue. This implements the late
- * evaluation of these field attributes.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDsGetBankFieldArguments (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_OPERAND_OBJECT *ExtraDesc;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc);
-
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Get the AML pointer (method object) and BankField node */
-
- ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
- Node = ObjDesc->BankField.Node;
-
- ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL));
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
- AcpiUtGetNodeName (Node)));
-
- /* Execute the AML code for the TermArg arguments */
-
- Status = AcpiDsExecuteArguments (Node, Node->Parent,
- ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsGetBufferArguments
- *
- * PARAMETERS: ObjDesc - A valid Buffer object
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Get Buffer length and initializer byte list. This implements
- * the late evaluation of these attributes.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDsGetBufferArguments (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc);
-
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Get the Buffer node */
-
- Node = ObjDesc->Buffer.Node;
- if (!Node)
- {
- ACPI_ERROR ((AE_INFO,
- "No pointer back to namespace node in buffer object %p", ObjDesc));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
-
- /* Execute the AML code for the TermArg arguments */
-
- Status = AcpiDsExecuteArguments (Node, Node,
- ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsGetPackageArguments
- *
- * PARAMETERS: ObjDesc - A valid Package object
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Get Package length and initializer byte list. This implements
- * the late evaluation of these attributes.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDsGetPackageArguments (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc);
-
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Get the Package node */
-
- Node = ObjDesc->Package.Node;
- if (!Node)
- {
- ACPI_ERROR ((AE_INFO,
- "No pointer back to namespace node in package %p", ObjDesc));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n"));
-
- /* Execute the AML code for the TermArg arguments */
-
- Status = AcpiDsExecuteArguments (Node, Node,
- ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
- return_ACPI_STATUS (Status);
-}
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiDsGetRegionArguments
- *
- * PARAMETERS: ObjDesc - A valid region object
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Get region address and length. This implements the late
- * evaluation of these region attributes.
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiDsGetRegionArguments (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ExtraDesc;
-
-
- ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc);
-
-
- if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
- if (!ExtraDesc)
- {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- /* Get the Region node */
-
- Node = ObjDesc->Region.Node;
-
- ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
- AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
-
- /* Execute the argument AML */
-
- Status = AcpiDsExecuteArguments (Node, Node->Parent,
- ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: AcpiDsInitializeRegion
*
* PARAMETERS: ObjHandle - Region namespace node
@@ -870,8 +499,9 @@ AcpiDsEvalRegionOperands (
*
* RETURN: Status
*
- * DESCRIPTION: Get region address and length
- * Called from AcpiDsExecEndOp during DataTableRegion parse tree walk
+ * DESCRIPTION: Get region address and length.
+ * Called from AcpiDsExecEndOp during DataTableRegion parse
+ * tree walk.
*
******************************************************************************/
@@ -1177,371 +807,3 @@ AcpiDsEvalBankFieldOperands (
return_ACPI_STATUS (Status);
}
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsExecBeginControlOp
- *
- * PARAMETERS: WalkList - The list that owns the walk stack
- * Op - The control Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handles all control ops encountered during control method
- * execution.
- *
- ******************************************************************************/
-
-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;
-
-
- /* 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);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDsExecEndControlOp
- *
- * PARAMETERS: WalkList - The list that owns the walk stack
- * Op - The control Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handles all control ops encountered during control method
- * execution.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDsExecEndControlOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_GENERIC_STATE *ControlState;
-
-
- ACPI_FUNCTION_NAME (DsExecEndControlOp);
-
-
- switch (Op->Common.AmlOpcode)
- {
- case AML_IF_OP:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
-
- /*
- * Save the result of the predicate in case there is an
- * ELSE to come
- */
- WalkState->LastPredicate =
- (BOOLEAN) WalkState->ControlState->Common.Value;
-
- /*
- * Pop the control state that was created at the start
- * of the IF and free it
- */
- ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
- AcpiUtDeleteGenericState (ControlState);
- break;
-
-
- case AML_ELSE_OP:
-
- break;
-
-
- case AML_WHILE_OP:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
-
- ControlState = WalkState->ControlState;
- if (ControlState->Common.Value)
- {
- /* Predicate was true, the body of the loop was just executed */
-
- /*
- * This loop counter mechanism allows the interpreter to escape
- * possibly infinite loops. This can occur in poorly written AML
- * when the hardware does not respond within a while loop and the
- * loop does not implement a timeout.
- */
- ControlState->Control.LoopCount++;
- if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS)
- {
- Status = AE_AML_INFINITE_LOOP;
- break;
- }
-
- /*
- * Go back and evaluate the predicate and maybe execute the loop
- * another time
- */
- Status = AE_CTRL_PENDING;
- WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
- break;
- }
-
- /* Predicate was false, terminate this while loop */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "[WHILE_OP] termination! Op=%p\n",Op));
-
- /* Pop this control state and free it */
-
- ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
- AcpiUtDeleteGenericState (ControlState);
- break;
-
-
- case AML_RETURN_OP:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
-
- /*
- * One optional operand -- the return value
- * It can be either an immediate operand or a result that
- * has been bubbled up the tree
- */
- if (Op->Common.Value.Arg)
- {
- /* Since we have a real Return(), delete any implicit return */
-
- AcpiDsClearImplicitReturn (WalkState);
-
- /* Return statement has an immediate operand */
-
- Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * If value being returned is a Reference (such as
- * an arg or local), resolve it now because it may
- * cease to exist at the end of the method.
- */
- Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Get the return value and save as the last result
- * value. This is the only place where WalkState->ReturnDesc
- * is set to anything other than zero!
- */
- WalkState->ReturnDesc = WalkState->Operands[0];
- }
- else if (WalkState->ResultCount)
- {
- /* Since we have a real Return(), delete any implicit return */
-
- AcpiDsClearImplicitReturn (WalkState);
-
- /*
- * The return value has come from a previous calculation.
- *
- * If value being returned is a Reference (such as
- * an arg or local), resolve it now because it may
- * cease to exist at the end of the method.
- *
- * Allow references created by the Index operator to return unchanged.
- */
- if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
- ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
- ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX))
- {
- Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
- }
- else
- {
- /* No return operand */
-
- if (WalkState->NumOperands)
- {
- AcpiUtRemoveReference (WalkState->Operands [0]);
- }
-
- WalkState->Operands [0] = NULL;
- WalkState->NumOperands = 0;
- WalkState->ReturnDesc = NULL;
- }
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "Completed RETURN_OP State=%p, RetVal=%p\n",
- WalkState, WalkState->ReturnDesc));
-
- /* End the control method execution right now */
-
- Status = AE_CTRL_TERMINATE;
- break;
-
-
- case AML_NOOP_OP:
-
- /* Just do nothing! */
- break;
-
-
- case AML_BREAK_POINT_OP:
-
- /*
- * Set the single-step flag. This will cause the debugger (if present)
- * to break to the console within the AML debugger at the start of the
- * next AML instruction.
- */
- ACPI_DEBUGGER_EXEC (
- AcpiGbl_CmSingleStep = TRUE);
- ACPI_DEBUGGER_EXEC (
- AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
-
- /* Call to the OSL in case OS wants a piece of the action */
-
- Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
- "Executed AML Breakpoint opcode");
- break;
-
-
- case AML_BREAK_OP:
- case AML_CONTINUE_OP: /* ACPI 2.0 */
-
-
- /* Pop and delete control states until we find a while */
-
- while (WalkState->ControlState &&
- (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
- {
- ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
- AcpiUtDeleteGenericState (ControlState);
- }
-
- /* No while found? */
-
- if (!WalkState->ControlState)
- {
- return (AE_AML_NO_WHILE);
- }
-
- /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
-
- WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
-
- /* Return status depending on opcode */
-
- if (Op->Common.AmlOpcode == AML_BREAK_OP)
- {
- Status = AE_CTRL_BREAK;
- }
- else
- {
- Status = AE_CTRL_CONTINUE;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
- Op->Common.AmlOpcode, Op));
-
- Status = AE_AML_BAD_OPCODE;
- break;
- }
-
- return (Status);
-}
-
OpenPOWER on IntegriCloud