ACPI_STATUS AcpiDsEvalTableRegionOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT **Operand; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; ACPI_TABLE_HEADER *Table; UINT32 TableIndex; ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); /* * This is where we evaluate the Signature string, OemId string, * and OemTableId string of the Data Table Region declaration */ Node = Op->Common.Node; /* NextOp points to Signature string op */ NextOp = Op->Common.Value.Arg; /* * Evaluate/create the Signature string, OemId string, * and OemTableId string operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Operand = &WalkState->Operands[0]; /* * Resolve the Signature string, OemId string, * and OemTableId string operands */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Find the ACPI table */ Status = AcpiTbFindTable ( Operand[0]->String.Pointer, Operand[1]->String.Pointer, Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { ACPI_ERROR ((AE_INFO, "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT", Operand[0]->String.Pointer, Operand[1]->String.Pointer, Operand[2]->String.Pointer)); } goto Cleanup; } Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) { goto Cleanup; } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { Status = AE_NOT_EXIST; goto Cleanup; } ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table); ObjDesc->Region.Length = Table->Length; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; Cleanup: AcpiUtRemoveReference (Operand[0]); AcpiUtRemoveReference (Operand[1]); AcpiUtRemoveReference (Operand[2]); return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); /* * This is where we evaluate the address and length fields of the * CreateXxxField declaration */ Node = Op->Common.Node; /* NextOp points to the op that holds the Buffer */ NextOp = Op->Common.Value.Arg; /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* Resolve the operands */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X", AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); return_ACPI_STATUS (Status); } /* Initialize the Buffer Field */ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) { /* NOTE: Slightly different operands for this opcode */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, WalkState->Operands[0], WalkState->Operands[1], WalkState->Operands[2], WalkState->Operands[3]); } else { /* All other, CreateXxxField opcodes */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, WalkState->Operands[0], WalkState->Operands[1], NULL, WalkState->Operands[2]); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDsEvalRegionOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *OperandDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); /* * This is where we evaluate the address and length fields of the * OpRegion declaration */ Node = Op->Common.Node; /* NextOp points to the op that holds the SpaceID */ NextOp = Op->Common.Value.Arg; /* NextOp points to address op */ NextOp = NextOp->Common.Next; /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Resolve the length and address operands to numbers */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* * Get the length operand and save it * (at Top of stack) */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); /* * Get the address and save it * (at top of stack - 1) */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDsLoad1EndOp ( ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Op; ACPI_OBJECT_TYPE ObjectType; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (DsLoad1EndOp); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) { return_ACPI_STATUS (AE_OK); } /* Get the object type to determine if we should pop the scope */ ObjectType = WalkState->OpInfo->ObjectType; #ifndef ACPI_NO_METHOD_EXECUTION if (WalkState->OpInfo->Flags & AML_FIELD) { /* * If we are executing a method, do not create any namespace objects * during the load phase, only during execution. */ if (!WalkState->MethodNode) { if (WalkState->Opcode == AML_FIELD_OP || WalkState->Opcode == AML_BANK_FIELD_OP || WalkState->Opcode == AML_INDEX_FIELD_OP) { Status = AcpiDsInitFieldObjects (Op, WalkState); } } return_ACPI_STATUS (Status); } /* * If we are executing a method, do not create any namespace objects * during the load phase, only during execution. */ if (!WalkState->MethodNode) { if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, ACPI_ADR_SPACE_DATA_TABLE, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } #endif if (Op->Common.AmlOpcode == AML_NAME_OP) { /* For Name opcode, get the object type from the argument */ if (Op->Common.Value.Arg) { ObjectType = (AcpiPsGetOpcodeInfo ( (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; /* Set node type if we have a namespace node */ if (Op->Common.Node) { Op->Common.Node->Type = (UINT8) ObjectType; } } } /* * If we are executing a method, do not create any namespace objects * during the load phase, only during execution. */ if (!WalkState->MethodNode) { if (Op->Common.AmlOpcode == AML_METHOD_OP) { /* * MethodOp PkgLength NameString MethodFlags TermList * * Note: We must create the method node/object pair as soon as we * see the method declaration. This allows later pass1 parsing * of invocations of the method (need to know the number of * arguments.) */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "LOADING-Method: State=%p Op=%p NamedObj=%p\n", WalkState, Op, Op->Named.Node)); if (!AcpiNsGetAttachedObject (Op->Named.Node)) { WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); WalkState->NumOperands = 1; Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); if (ACPI_SUCCESS (Status)) { Status = AcpiExCreateMethod (Op->Named.Data, Op->Named.Length, WalkState); } WalkState->Operands[0] = NULL; WalkState->NumOperands = 0; if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } }
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 infinite loop detection 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. */ if (ACPI_TIME_AFTER (AcpiOsGetTimer (), ControlState->Control.LoopTimeout)) { Status = AE_AML_LOOP_TIMEOUT; 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_BREAKPOINT_OP: AcpiDbSignalBreakPoint (WalkState); /* 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); }
ACPI_STATUS AcpiDsExecEndOp ( ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Op; ACPI_STATUS Status = AE_OK; UINT32 OpType; UINT32 OpClass; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *FirstArg; ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); Op = WalkState->Op; OpType = WalkState->OpInfo->Type; OpClass = WalkState->OpInfo->Class; if (OpClass == AML_CLASS_UNKNOWN) { ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } FirstArg = Op->Common.Value.Arg; /* Init the walk state */ WalkState->NumOperands = 0; WalkState->OperandIndex = 0; WalkState->ReturnDesc = NULL; WalkState->ResultObj = NULL; /* Call debugger for single step support (DEBUG build only) */ Status = AcpiDbSingleStep (WalkState, Op, OpClass); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Decode the Opcode Class */ switch (OpClass) { case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */ if (WalkState->Opcode == AML_INT_NAMEPATH_OP) { Status = AcpiDsEvaluateNamePath (WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } } break; case AML_CLASS_EXECUTE: /* Most operators with arguments */ /* Build resolved operand stack */ Status = AcpiDsCreateOperands (WalkState, FirstArg); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* * All opcodes require operand resolution, with the only exceptions * being the ObjectType and SizeOf operators. */ if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) { /* Resolve all operands */ Status = AcpiExResolveOperands (WalkState->Opcode, &(WalkState->Operands [WalkState->NumOperands -1]), WalkState); } if (ACPI_SUCCESS (Status)) { /* * Dispatch the request to the appropriate interpreter handler * routine. There is one routine per opcode "type" based upon the * number of opcode arguments and return type. */ Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); } else { /* * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the * Local is uninitialized. */ if ((Status == AE_AML_UNINITIALIZED_LOCAL) && (WalkState->Opcode == AML_STORE_OP) && (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[0]->Reference.Class == WalkState->Operands[1]->Reference.Class) && (WalkState->Operands[0]->Reference.Value == WalkState->Operands[1]->Reference.Value)) { Status = AE_OK; } else { ACPI_EXCEPTION ((AE_INFO, Status, "While resolving operands for [%s]", AcpiPsGetOpcodeName (WalkState->Opcode))); } } /* Always delete the argument objects and clear the operand stack */ AcpiDsClearOperands (WalkState); /* * If a result object was returned from above, push it on the * current result stack */ if (ACPI_SUCCESS (Status) && WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } break; default: switch (OpType) { case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ /* 1 Operand, 0 ExternalResult, 0 InternalResult */ Status = AcpiDsExecEndControlOp (WalkState, Op); break; case AML_TYPE_METHOD_CALL: /* * If the method is referenced from within a package * declaration, it is not a invocation of the method, just * a reference to it. */ if ((Op->Asl.Parent) && ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", Op)); Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node; AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); return_ACPI_STATUS (AE_OK); } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); /* * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains * the method Node pointer */ /* NextOp points to the op that holds the method name */ NextOp = FirstArg; /* NextOp points to first argument op */ NextOp = NextOp->Common.Next; /* * Get the method's arguments and put them on the operand stack */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { break; } /* * Since the operands will be passed to another control method, * we must resolve all local references here (Local variables, * arguments to *this* method, etc.) */ Status = AcpiDsResolveOperands (WalkState); if (ACPI_FAILURE (Status)) { /* On error, clear all resolved operands */ AcpiDsClearOperands (WalkState); break; } /* * Tell the walk loop to preempt this running method and * execute the new method */ Status = AE_CTRL_TRANSFER; /* * Return now; we don't want to disturb anything, * especially the operand count! */ return_ACPI_STATUS (Status); case AML_TYPE_CREATE_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing CreateField Buffer/Index Op=%p\n", Op)); Status = AcpiDsLoad2EndOp (WalkState); if (ACPI_FAILURE (Status)) { break; } Status = AcpiDsEvalBufferFieldOperands (WalkState, Op); break; case AML_TYPE_CREATE_OBJECT: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); switch (Op->Common.Parent->Common.AmlOpcode) { case AML_NAME_OP: /* * Put the Node on the object stack (Contains the ACPI Name * of this object) */ WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; WalkState->NumOperands = 1; Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent); if (ACPI_FAILURE (Status)) { break; } /* Fall through */ /*lint -fallthrough */ case AML_INT_EVAL_SUBTREE_OP: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL); break; } /* * If a result object was returned from above, push it on the * current result stack */ if (WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } break; case AML_TYPE_NAMED_FIELD: case AML_TYPE_NAMED_COMPLEX: case AML_TYPE_NAMED_SIMPLE: case AML_TYPE_NAMED_NO_OBJ: Status = AcpiDsLoad2EndOp (WalkState); if (ACPI_FAILURE (Status)) { break; } if (Op->Common.AmlOpcode == AML_REGION_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing OpRegion Address/Length Op=%p\n", Op)); Status = AcpiDsEvalRegionOperands (WalkState, Op); if (ACPI_FAILURE (Status)) { break; } } else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing DataTableRegion Strings Op=%p\n", Op)); Status = AcpiDsEvalTableRegionOperands (WalkState, Op); if (ACPI_FAILURE (Status)) { break; } } else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing BankField Op=%p\n", Op)); Status = AcpiDsEvalBankFieldOperands (WalkState, Op); if (ACPI_FAILURE (Status)) { break; } } break; case AML_TYPE_UNDEFINED: ACPI_ERROR ((AE_INFO, "Undefined opcode type Op=%p", Op)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); case AML_TYPE_BOGUS: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Internal opcode=%X type Op=%p\n", WalkState->Opcode, Op)); break; default: ACPI_ERROR ((AE_INFO, "Unimplemented opcode, class=0x%X " "type=0x%X Opcode=0x%X Op=%p", OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; break; } } /* * ACPI 2.0 support for 64-bit integers: Truncate numeric * result value if we are executing from a 32-bit ACPI table */ (void) AcpiExTruncateFor32bitTable (WalkState->ResultObj); /* * Check if we just completed the evaluation of a * conditional predicate */ if ((ACPI_SUCCESS (Status)) && (WalkState->ControlState) && (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) { Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj); WalkState->ResultObj = NULL; } Cleanup: if (WalkState->ResultObj) { /* Break to debugger to display result */ AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState); /* * Delete the result op if and only if: * Parent will not use the result -- such as any * non-nested type2 op in a method (parent will be method) */ AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState); } #ifdef _UNDER_DEVELOPMENT if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd) { AcpiDbMethodEnd (WalkState); } #endif /* Invoke exception handler on error */ if (ACPI_FAILURE (Status)) { Status = AcpiDsMethodError (Status, WalkState); } /* Always clear the object stack */ WalkState->NumOperands = 0; return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiDsEvalTableRegionOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT **Operand; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; UINT32 TableIndex; ACPI_TABLE_HEADER *Table; ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); /* * This is where we evaluate the SignatureString and OemIDString * and OemTableIDString of the DataTableRegion declaration */ Node = Op->Common.Node; /* NextOp points to SignatureString op */ NextOp = Op->Common.Value.Arg; /* * Evaluate/create the SignatureString and OemIDString * and OemTableIDString operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Resolve the SignatureString and OemIDString * and OemTableIDString operands */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Operand = &WalkState->Operands[0]; /* Find the ACPI table */ Status = AcpiTbFindTable (Operand[0]->String.Pointer, Operand[1]->String.Pointer, Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiUtRemoveReference (Operand[0]); AcpiUtRemoveReference (Operand[1]); AcpiUtRemoveReference (Operand[2]); Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); ObjDesc->Region.Length = Table->Length; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", ObjDesc, ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; return_ACPI_STATUS (Status); }
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)); if (WalkState->ControlState->Common.Value) { /* Predicate was true, go back and evaluate it again! */ Status = AE_CTRL_PENDING; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); /* Pop this control state and free it */ ControlState = AcpiUtPopGenericState (&WalkState->ControlState); WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; 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) { /* 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->Results) && (WalkState->Results->Results.NumResults > 0)) { /* * 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) && (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) { 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: /* Call up to the OS service layer to handle this */ Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ 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_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", Op->Common.AmlOpcode, Op)); Status = AE_AML_BAD_OPCODE; break; } return (Status); }