ACPI_STATUS AcpiExOpcode_0A_0T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ switch (WalkState->Opcode) { case AML_TIMER_OP: /* Timer () */ /* Create a return object of type Integer */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } #if ACPI_MACHINE_WIDTH != 16 ReturnDesc->Integer.Value = AcpiOsGetTimer (); #endif break; default: /* Unknown opcode */ ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; } Cleanup: /* Delete return object on error */ if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); } else { /* Save the return value */ WalkState->ResultObj = ReturnDesc; } return_ACPI_STATUS (Status); }
void UtEndEvent ( UINT8 Event) { if (Event >= ASL_NUM_EVENTS) { return; } /* Insert end time for event */ AslGbl_Events[Event].EndTime = AcpiOsGetTimer (); }
UINT8 UtBeginEvent ( char *Name) { if (AslGbl_NextEvent >= ASL_NUM_EVENTS) { AcpiOsPrintf ("Ran out of compiler event structs!\n"); return (AslGbl_NextEvent); } /* Init event with current (start) time */ AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer (); AslGbl_Events[AslGbl_NextEvent].EventName = Name; AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; return (AslGbl_NextEvent++); }
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 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); }
void AcpiExDoDebugObject ( ACPI_OPERAND_OBJECT *SourceDesc, UINT32 Level, UINT32 Index) { UINT32 i; UINT32 Timer; ACPI_OPERAND_OBJECT *ObjectDesc; UINT32 Value; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); /* Output must be enabled via the DebugObject global or the DbgLevel */ if (!AcpiGbl_EnableAmlDebugObject && !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT)) { return_VOID; } /* * We will emit the current timer value (in microseconds) with each * debug output. Only need the lower 26 bits. This allows for 67 * million microseconds or 67 seconds before rollover. */ Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ Timer &= 0x03FFFFFF; /* * Print line header as long as we are not in the middle of an * object display */ if (!((Level > 0) && Index == 0)) { AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); } /* Display the index for package output only */ if (Index > 0) { AcpiOsPrintf ("(%.2u) ", Index-1); } if (!SourceDesc) { AcpiOsPrintf ("[Null Object]\n"); return_VOID; } if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) { AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); if (!AcpiUtValidInternalObject (SourceDesc)) { AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc); return_VOID; } } else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf ("%s: %p\n", AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), SourceDesc); return_VOID; } else { return_VOID; } /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ switch (SourceDesc->Common.Type) { case ACPI_TYPE_INTEGER: /* Output correct integer width */ if (AcpiGbl_IntegerByteWidth == 4) { AcpiOsPrintf ("0x%8.8X\n", (UINT32) SourceDesc->Integer.Value); } else { AcpiOsPrintf ("0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value)); } break; case ACPI_TYPE_BUFFER: AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length); AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer, (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0); break; case ACPI_TYPE_STRING: AcpiOsPrintf ("[0x%.2X] \"%s\"\n", SourceDesc->String.Length, SourceDesc->String.Pointer); break; case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("[Contains 0x%.2X Elements]\n", SourceDesc->Package.Count); /* Output the entire contents of the package */ for (i = 0; i < SourceDesc->Package.Count; i++) { AcpiExDoDebugObject (SourceDesc->Package.Elements[i], Level+4, i+1); } break; case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc)); /* Decode the reference */ switch (SourceDesc->Reference.Class) { case ACPI_REFCLASS_INDEX: AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value); break; case ACPI_REFCLASS_TABLE: /* Case for DdbHandle */ AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value); return_VOID; default: break; } AcpiOsPrintf (" "); /* Check for valid node first, then valid object */ if (SourceDesc->Reference.Node) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != ACPI_DESC_TYPE_NAMED) { AcpiOsPrintf (" %p - Not a valid namespace node\n", SourceDesc->Reference.Node); } else { AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii); switch ((SourceDesc->Reference.Node)->Type) { /* These types have no attached object */ case ACPI_TYPE_DEVICE: AcpiOsPrintf ("Device\n"); break; case ACPI_TYPE_THERMAL: AcpiOsPrintf ("Thermal Zone\n"); break; default: AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, Level+4, 0); break; } } } else if (SourceDesc->Reference.Object) { if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == ACPI_DESC_TYPE_NAMED) { AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) SourceDesc->Reference.Object)->Object, Level+4, 0); } else { ObjectDesc = SourceDesc->Reference.Object; Value = SourceDesc->Reference.Value; switch (ObjectDesc->Common.Type) { case ACPI_TYPE_BUFFER: AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n", Value, *SourceDesc->Reference.IndexPointer); break; case ACPI_TYPE_STRING: AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n", Value, *SourceDesc->Reference.IndexPointer, *SourceDesc->Reference.IndexPointer); break; case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("Package[%u] = ", Value); AcpiExDoDebugObject (*SourceDesc->Reference.Where, Level+4, 0); break; default: AcpiOsPrintf ("Unknown Reference object type %X\n", ObjectDesc->Common.Type); break; } } } break; default: AcpiOsPrintf ("%p\n", SourceDesc); break; } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); return_VOID; }