dmwalk.c revision 7b1019a6d29ccb7999dc76cba3dde1c627e8e609
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/*******************************************************************************
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Module Name: dmwalk - AML disassembly tree walk
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis ******************************************************************************/
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (C) 2000 - 2016, Intel Corp.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Redistribution and use in source and binary forms, with or without
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * modification, are permitted provided that the following conditions
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * 1. Redistributions of source code must retain the above copyright
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * notice, this list of conditions, and the following disclaimer,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * without modification.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * 2. Redistributions in binary form must reproduce at minimum a disclaimer
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * substantially similar to the "NO WARRANTY" disclaimer below
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * ("Disclaimer") and any redistribution must be conditioned upon
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * including a substantially similar Disclaimer requirement for further
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * binary redistribution.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * 3. Neither the names of the above-listed copyright holders nor the names
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * of any contributors may be used to endorse or promote products derived
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * from this software without specific prior written permission.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Alternatively, this software may be distributed under the terms of the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * GNU General Public License ("GPL") version 2 as published by the Free
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Software Foundation.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * POSSIBILITY OF SUCH DAMAGES.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define DB_FULL_OP_INFO "[%4.4s] @%5.5X #%4.4X: "
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* Stub for non-compiler code */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* Local prototypes */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/*******************************************************************************
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * FUNCTION: AcpiDmDisassemble
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * PARAMETERS: WalkState - Current state
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Origin - Starting object
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * NumOpcodes - Max number of opcodes to be displayed
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * RETURN: None
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * DESCRIPTION: Disassemble parser object and its children. This is the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * main entry point of the disassembler.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis ******************************************************************************/
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis memset (&Info, 0, sizeof (ACPI_OP_WALK_INFO));
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis Info.StartAml = Op->Common.Aml - sizeof (ACPI_TABLE_HEADER);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis Info.AmlOffset = Op->Common.Aml - Info.StartAml;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/*******************************************************************************
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * FUNCTION: AcpiDmWalkParseTree
void *Context)
while (Op)
if (AscendingCallback)
if (Next)
if (!NodePreviouslyVisited)
static UINT32
if (!Op)
return (BLOCK_NONE);
case AML_ELSE_OP:
return (BLOCK_BRACE);
case AML_METHOD_OP:
case AML_DEVICE_OP:
case AML_SCOPE_OP:
case AML_PROCESSOR_OP:
case AML_POWER_RES_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
case AML_WHILE_OP:
case AML_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_BANK_FIELD_OP:
case AML_BUFFER_OP:
return (BLOCK_NONE);
case AML_PACKAGE_OP:
case AML_VAR_PACKAGE_OP:
case AML_EVENT_OP:
return (BLOCK_PAREN);
case AML_INT_METHODCALL_OP:
return (BLOCK_NONE);
return (BLOCK_PAREN);
return (BLOCK_NONE);
if (!Op)
return (BLOCK_NONE);
case AML_ELSE_OP:
case AML_METHOD_OP:
case AML_DEVICE_OP:
case AML_SCOPE_OP:
case AML_POWER_RES_OP:
case AML_PROCESSOR_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
case AML_WHILE_OP:
case AML_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_BANK_FIELD_OP:
return (BLOCK_NONE);
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
case AML_VAR_PACKAGE_OP:
return (BLOCK_COMMA_LIST);
return (BLOCK_COMMA_LIST);
return (BLOCK_NONE);
static ACPI_STATUS
void *Context)
return (AE_CTRL_DEPTH);
if (NextOp)
if (NextOp2 &&
return (AE_CTRL_DEPTH);
if (Level == 0)
return (AE_OK);
case AML_NOOP_OP:
return (AE_OK);
return (AE_OK);
return (AE_OK);
case AML_ALIAS_OP:
case AML_METHOD_OP:
case AML_NAME_OP:
case AML_REGION_OP:
case AML_POWER_RES_OP:
return (AE_OK);
case AML_PROCESSOR_OP:
return (AE_OK);
case AML_MUTEX_OP:
case AML_DATA_REGION_OP:
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:
case AML_FIELD_OP:
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_BUFFER_OP:
if (!NextOp)
return (AE_OK);
return (AE_OK);
return (AE_OK);
case AML_IF_OP:
case AML_VAR_PACKAGE_OP:
case AML_WHILE_OP:
if (NextOp)
return (AE_OK);
case AML_PACKAGE_OP:
if (NextOp)
return (AE_OK);
case AML_MATCH_OP:
return (AE_OK);
static ACPI_STATUS
void *Context)
return (AE_OK);
return (AE_OK);
case BLOCK_PAREN:
case BLOCK_BRACE:
case BLOCK_NONE:
case AML_PACKAGE_OP:
case AML_VAR_PACKAGE_OP:
return (AE_OK);
if (ParentOp &&
return (AE_OK);