static ACPI_STATUS AcpiDmDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_OP_WALK_INFO *Info = Context; const ACPI_OPCODE_INFO *OpInfo; UINT32 Name; ACPI_PARSE_OBJECT *NextOp; if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) { /* Ignore this op -- it was handled elsewhere */ return (AE_CTRL_DEPTH); } /* Level 0 is at the Definition Block level */ if (Level == 0) { /* In verbose mode, print the AML offset, opcode and depth count */ if (Info->WalkState) { VERBOSE_PRINT ((DB_FULL_OP_INFO, (Info->WalkState->MethodNode ? Info->WalkState->MethodNode->Name.Ascii : " "), Op->Common.AmlOffset, (UINT32) Op->Common.AmlOpcode)); } if (Op->Common.AmlOpcode == AML_SCOPE_OP) { /* This is the beginning of the Definition Block */ AcpiOsPrintf ("{\n"); /* Emit all External() declarations here */ AcpiDmEmitExternals (); return (AE_OK); } } else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { /* * This is a first-level element of a term list, * indent a new line */ switch (Op->Common.AmlOpcode) { case AML_NOOP_OP: /* * Optionally just ignore this opcode. Some tables use * NoOp opcodes for "padding" out packages that the BIOS * changes dynamically. This can leave hundreds or * thousands of NoOp opcodes that if disassembled, * cannot be compiled because they are syntactically * incorrect. */ if (AcpiGbl_IgnoreNoopOperator) { Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; return (AE_OK); } /* Fallthrough */ default: AcpiDmIndent (Level); break; } Info->LastLevel = Level; Info->Count = 0; } /* * This is an inexpensive mechanism to try and keep lines from getting * too long. When the limit is hit, start a new line at the previous * indent plus one. A better but more expensive mechanism would be to * keep track of the current column. */ Info->Count++; if (Info->Count /* +Info->LastLevel */ > 12) { Info->Count = 0; AcpiOsPrintf ("\n"); AcpiDmIndent (Info->LastLevel + 1); } /* If ASL+ is enabled, check for a C-style operator */ if (AcpiDmCheckForSymbolicOpcode (Op, Info)) { return (AE_OK); } /* Print the opcode name */ AcpiDmDisassembleOneOp (NULL, Info, Op); if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) || (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)) { return (AE_OK); } if ((Op->Common.AmlOpcode == AML_NAME_OP) || (Op->Common.AmlOpcode == AML_RETURN_OP)) { Info->Level--; } /* Start the opcode argument list if necessary */ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); if ((OpInfo->Flags & AML_HAS_ARGS) || (Op->Common.AmlOpcode == AML_EVENT_OP)) { /* This opcode has an argument list */ if (AcpiDmBlockType (Op) & BLOCK_PAREN) { AcpiOsPrintf (" ("); } /* If this is a named opcode, print the associated name value */ if (OpInfo->Flags & AML_NAMED) { switch (Op->Common.AmlOpcode) { case AML_ALIAS_OP: NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); /*lint -fallthrough */ default: Name = AcpiPsGetName (Op); if (Op->Named.Path) { AcpiDmNamestring ((char *) Op->Named.Path); } else { AcpiDmDumpName (Name); } if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) { if (AcpiGbl_DbOpt_Verbose) { (void) AcpiPsDisplayObjectPathname (NULL, Op); } } break; } switch (Op->Common.AmlOpcode) { case AML_METHOD_OP: AcpiDmMethodFlags (Op); AcpiOsPrintf (")"); /* Emit description comment for Method() with a predefined ACPI name */ AcpiDmPredefinedDescription (Op); break; case AML_NAME_OP: /* Check for _HID and related EISAID() */ AcpiDmCheckForHardwareId (Op); AcpiOsPrintf (", "); break; case AML_REGION_OP: AcpiDmRegionFlags (Op); break; case AML_POWER_RES_OP: /* Mark the next two Ops as part of the parameter list */ AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; return (AE_OK); case AML_PROCESSOR_OP: /* Mark the next three Ops as part of the parameter list */ AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; return (AE_OK); case AML_MUTEX_OP: case AML_DATA_REGION_OP: AcpiOsPrintf (", "); return (AE_OK); case AML_EVENT_OP: case AML_ALIAS_OP: return (AE_OK); case AML_SCOPE_OP: case AML_DEVICE_OP: case AML_THERMAL_ZONE_OP: AcpiOsPrintf (")"); break; default: AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode); break; } } else switch (Op->Common.AmlOpcode) { case AML_FIELD_OP: case AML_BANK_FIELD_OP: case AML_INDEX_FIELD_OP: Info->BitOffset = 0; /* Name of the parent OperationRegion */ NextOp = AcpiPsGetDepthNext (NULL, Op); AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; switch (Op->Common.AmlOpcode) { case AML_BANK_FIELD_OP: /* Namestring - Bank Name */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); AcpiDmNamestring (NextOp->Common.Value.Name); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf (", "); /* * Bank Value. This is a TermArg in the middle of the parameter * list, must handle it here. * * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST * eliminates newline in the output. */ NextOp = NextOp->Common.Next; Info->Flags = ACPI_PARSEOP_PARAMLIST; AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info); Info->Flags = 0; Info->Level = Level; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf (", "); break; case AML_INDEX_FIELD_OP: /* Namestring - Data Name */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; break; default: break; } AcpiDmFieldFlags (NextOp); break; case AML_BUFFER_OP: /* The next op is the size parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (!NextOp) { /* Single-step support */ return (AE_OK); } if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE) { /* * We have a resource list. Don't need to output * the buffer size Op. Open up a new block */ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; NextOp = NextOp->Common.Next; AcpiOsPrintf (")"); /* Emit description comment for Name() with a predefined ACPI name */ AcpiDmPredefinedDescription (Op->Asl.Parent); AcpiOsPrintf ("\n"); AcpiDmIndent (Info->Level); AcpiOsPrintf ("{\n"); return (AE_OK); } /* Normal Buffer, mark size as in the parameter list */ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; return (AE_OK); case AML_VAR_PACKAGE_OP: case AML_IF_OP: case AML_WHILE_OP: /* The next op is the size or predicate parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; } return (AE_OK); case AML_PACKAGE_OP: /* The next op is the size parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; } return (AE_OK); case AML_MATCH_OP: AcpiDmMatchOp (Op); break; default: break; } if (AcpiDmBlockType (Op) & BLOCK_BRACE) { AcpiOsPrintf ("\n"); AcpiDmIndent (Level); AcpiOsPrintf ("{\n"); } } return (AE_OK); }
static ACPI_STATUS AcpiDmDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { ACPI_OP_WALK_INFO *Info = Context; const ACPI_OPCODE_INFO *OpInfo; UINT32 Name; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *NextOp2; UINT32 AmlOffset; /* Determine which file this parse node is contained in. */ if (AcpiGbl_CaptureComments) { ASL_CV_LABEL_FILENODE (Op); if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op)) { ASL_CV_SWITCH_FILES (Level, Op); } /* If this parse node has regular comments, print them here. */ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level); } OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); /* Listing support to dump the AML code after the ASL statement */ if (AcpiGbl_DmOpt_Listing) { /* We only care about these classes of objects */ if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) || (OpInfo->Class == AML_CLASS_CONTROL) || (OpInfo->Class == AML_CLASS_CREATE) || ((OpInfo->Class == AML_CLASS_EXECUTE) && (!Op->Common.Next))) { if (AcpiGbl_DmOpt_Listing && Info->PreviousAml) { /* Dump the AML byte code for the previous Op */ if (Op->Common.Aml > Info->PreviousAml) { AcpiOsPrintf ("\n"); AcpiUtDumpBuffer ( (Info->StartAml + Info->AmlOffset), (Op->Common.Aml - Info->PreviousAml), DB_BYTE_DISPLAY, Info->AmlOffset); AcpiOsPrintf ("\n"); } Info->AmlOffset = (Op->Common.Aml - Info->StartAml); } Info->PreviousAml = Op->Common.Aml; } } if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) { /* Ignore this op -- it was handled elsewhere */ return (AE_CTRL_DEPTH); } if (Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE) { /* Ignore this op, but not it's children */ return (AE_OK); } if (Op->Common.AmlOpcode == AML_IF_OP) { NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; /* Don't emit the actual embedded externals unless asked */ if (!AcpiGbl_DmEmitExternalOpcodes) { /* * A Zero predicate indicates the possibility of one or more * External() opcodes within the If() block. */ if (NextOp->Common.AmlOpcode == AML_ZERO_OP) { NextOp2 = NextOp->Common.Next; if (NextOp2 && (NextOp2->Common.AmlOpcode == AML_EXTERNAL_OP)) { /* Ignore the If 0 block and all children */ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; return (AE_CTRL_DEPTH); } } } } } /* Level 0 is at the Definition Block level */ if (Level == 0) { /* In verbose mode, print the AML offset, opcode and depth count */ if (Info->WalkState) { AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, Info->WalkState->ParserState.AmlStart); if (AcpiGbl_DmOpt_Verbose) { if (AcpiGbl_CmSingleStep) { AcpiOsPrintf ("%5.5X/%4.4X: ", AmlOffset, (UINT32) Op->Common.AmlOpcode); } else { AcpiOsPrintf ("AML Offset %5.5X, Opcode %4.4X: ", AmlOffset, (UINT32) Op->Common.AmlOpcode); } } } if (Op->Common.AmlOpcode == AML_SCOPE_OP) { /* This is the beginning of the Definition Block */ AcpiOsPrintf ("{\n"); /* Emit all External() declarations here */ if (!AcpiGbl_DmEmitExternalOpcodes) { AcpiDmEmitExternals (); } return (AE_OK); } } else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) && (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { /* * This is a first-level element of a term list, * indent a new line */ switch (Op->Common.AmlOpcode) { case AML_NOOP_OP: /* * Optionally just ignore this opcode. Some tables use * NoOp opcodes for "padding" out packages that the BIOS * changes dynamically. This can leave hundreds or * thousands of NoOp opcodes that if disassembled, * cannot be compiled because they are syntactically * incorrect. */ if (AcpiGbl_IgnoreNoopOperator) { Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; return (AE_OK); } /* Fallthrough */ default: AcpiDmIndent (Level); break; } Info->LastLevel = Level; Info->Count = 0; } /* * This is an inexpensive mechanism to try and keep lines from getting * too long. When the limit is hit, start a new line at the previous * indent plus one. A better but more expensive mechanism would be to * keep track of the current column. */ Info->Count++; if (Info->Count /* +Info->LastLevel */ > 12) { Info->Count = 0; AcpiOsPrintf ("\n"); AcpiDmIndent (Info->LastLevel + 1); } /* If ASL+ is enabled, check for a C-style operator */ if (AcpiDmCheckForSymbolicOpcode (Op, Info)) { return (AE_OK); } /* Print the opcode name */ AcpiDmDisassembleOneOp (NULL, Info, Op); if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) || (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)) { return (AE_OK); } if ((Op->Common.AmlOpcode == AML_NAME_OP) || (Op->Common.AmlOpcode == AML_RETURN_OP)) { Info->Level--; } if (Op->Common.AmlOpcode == AML_EXTERNAL_OP) { Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; return (AE_CTRL_DEPTH); } /* Start the opcode argument list if necessary */ if ((OpInfo->Flags & AML_HAS_ARGS) || (Op->Common.AmlOpcode == AML_EVENT_OP)) { /* This opcode has an argument list */ if (AcpiDmBlockType (Op) & BLOCK_PAREN) { AcpiOsPrintf (" ("); if (!(AcpiDmBlockType (Op) & BLOCK_BRACE)) { ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0); } } /* If this is a named opcode, print the associated name value */ if (OpInfo->Flags & AML_NAMED) { switch (Op->Common.AmlOpcode) { case AML_ALIAS_OP: NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); /*lint -fallthrough */ default: Name = AcpiPsGetName (Op); if (Op->Named.Path) { AcpiDmNamestring (Op->Named.Path); } else { AcpiDmDumpName (Name); } if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) { if (AcpiGbl_DmOpt_Verbose) { (void) AcpiPsDisplayObjectPathname (NULL, Op); } } break; } switch (Op->Common.AmlOpcode) { case AML_METHOD_OP: AcpiDmMethodFlags (Op); ASL_CV_CLOSE_PAREN (Op, Level); /* Emit description comment for Method() with a predefined ACPI name */ AcpiDmPredefinedDescription (Op); break; case AML_NAME_OP: /* Check for _HID and related EISAID() */ AcpiDmCheckForHardwareId (Op); AcpiOsPrintf (", "); ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0); break; case AML_REGION_OP: AcpiDmRegionFlags (Op); break; case AML_POWER_RESOURCE_OP: /* Mark the next two Ops as part of the parameter list */ AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); case AML_PROCESSOR_OP: /* Mark the next three Ops as part of the parameter list */ AcpiOsPrintf (", "); NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; NextOp = NextOp->Common.Next; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); case AML_MUTEX_OP: case AML_DATA_REGION_OP: AcpiOsPrintf (", "); return (AE_OK); case AML_EVENT_OP: case AML_ALIAS_OP: return (AE_OK); case AML_SCOPE_OP: case AML_DEVICE_OP: case AML_THERMAL_ZONE_OP: ASL_CV_CLOSE_PAREN (Op, Level); break; default: AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode); break; } } else switch (Op->Common.AmlOpcode) { case AML_FIELD_OP: case AML_BANK_FIELD_OP: case AML_INDEX_FIELD_OP: Info->BitOffset = 0; /* Name of the parent OperationRegion */ NextOp = AcpiPsGetDepthNext (NULL, Op); AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; switch (Op->Common.AmlOpcode) { case AML_BANK_FIELD_OP: /* Namestring - Bank Name */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); AcpiDmNamestring (NextOp->Common.Value.Name); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf (", "); /* * Bank Value. This is a TermArg in the middle of the parameter * list, must handle it here. * * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMETER_LIST * eliminates newline in the output. */ NextOp = NextOp->Common.Next; Info->Flags = ACPI_PARSEOP_PARAMETER_LIST; AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info); Info->Flags = 0; Info->Level = Level; NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf (", "); break; case AML_INDEX_FIELD_OP: /* Namestring - Data Name */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); AcpiDmNamestring (NextOp->Common.Value.Name); AcpiOsPrintf (", "); NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; break; default: break; } AcpiDmFieldFlags (NextOp); break; case AML_BUFFER_OP: /* The next op is the size parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (!NextOp) { /* Single-step support */ return (AE_OK); } if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE) { /* * We have a resource list. Don't need to output * the buffer size Op. Open up a new block */ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; NextOp = NextOp->Common.Next; ASL_CV_CLOSE_PAREN (Op, Level); /* Emit description comment for Name() with a predefined ACPI name */ AcpiDmPredefinedDescription (Op->Asl.Parent); AcpiOsPrintf ("\n"); AcpiDmIndent (Info->Level); AcpiOsPrintf ("{\n"); return (AE_OK); } /* Normal Buffer, mark size as in the parameter list */ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; return (AE_OK); case AML_IF_OP: case AML_VARIABLE_PACKAGE_OP: case AML_WHILE_OP: /* The next op is the size or predicate parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; } return (AE_OK); case AML_PACKAGE_OP: /* The next op is the size parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) { NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST; } return (AE_OK); case AML_MATCH_OP: AcpiDmMatchOp (Op); break; default: break; } if (AcpiDmBlockType (Op) & BLOCK_BRACE) { AcpiOsPrintf ("\n"); AcpiDmIndent (Level); AcpiOsPrintf ("{\n"); } } return (AE_OK); }