📄 dbdisasm.c
字号:
/******************************************************************************* * * Module Name: dbdisasm - parser op tree display routines * $Revision: 50 $ * ******************************************************************************//* * Copyright (C) 2000, 2001 R. Byron Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "acpi.h"#include "acparser.h"#include "amlcode.h"#include "acnamesp.h"#include "acdebug.h"#ifdef ENABLE_DEBUGGER#define _COMPONENT ACPI_DEBUGGER MODULE_NAME ("dbdisasm")#define MAX_SHOW_ENTRY 128#define BLOCK_PAREN 1#define BLOCK_BRACE 2#define DB_NO_OP_INFO " [%2.2d] "#define DB_FULL_OP_INFO "%5.5X #%4.4X [%2.2d] "NATIVE_CHAR *acpi_gbl_db_disasm_indent = "....";/******************************************************************************* * * FUNCTION: Acpi_db_block_type * * PARAMETERS: Op - Object to be examined * * RETURN: Status * * DESCRIPTION: Type of block for this op (parens or braces) * ******************************************************************************/u32acpi_db_block_type ( acpi_parse_object *op){ switch (op->opcode) { case AML_METHOD_OP: return (BLOCK_BRACE); break; default: break; } return (BLOCK_PAREN);}/******************************************************************************* * * FUNCTION: Acpi_ps_display_object_pathname * * PARAMETERS: Op - Object whose pathname is to be obtained * * RETURN: Status * * DESCRIPTION: Diplay the pathname associated with a named object. Two * versions. One searches the parse tree (for parser-only * applications suchas Acpi_dump), and the other searches the * ACPI namespace (the parse tree is probably deleted) * ******************************************************************************/#ifdef PARSER_ONLYacpi_statusacpi_ps_display_object_pathname ( acpi_walk_state *walk_state, acpi_parse_object *op){ acpi_parse_object *target_op; /* Search parent tree up to the root if necessary */ target_op = acpi_ps_find (op, op->value.name, 0, 0); if (!target_op) { /* * Didn't find the name in the parse tree. This may be * a problem, or it may simply be one of the predefined names * (such as _OS_). Rather than worry about looking up all * the predefined names, just display the name as given */ acpi_os_printf (" **** Path not found in parse tree"); } else { /* The target was found, print the name and complete path */ acpi_os_printf (" (Path "); acpi_db_display_path (target_op); acpi_os_printf (")"); } return (AE_OK);}#elseacpi_statusacpi_ps_display_object_pathname ( acpi_walk_state *walk_state, acpi_parse_object *op){ acpi_status status; acpi_namespace_node *node; NATIVE_CHAR buffer[MAX_SHOW_ENTRY]; u32 buffer_size = MAX_SHOW_ENTRY; u32 debug_level; /* Save current debug level so we don't get extraneous debug output */ debug_level = acpi_dbg_level; acpi_dbg_level = 0; /* Just get the Node out of the Op object */ node = op->node; if (!node) { /* Node not defined in this scope, look it up */ status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node)); if (ACPI_FAILURE (status)) { /* * We can't get the pathname since the object * is not in the namespace. This can happen during single * stepping where a dynamic named object is *about* to be created. */ acpi_os_printf (" [Path not found]"); goto exit; } /* Save it for next time. */ op->node = node; } /* Convert Named_desc/handle to a full pathname */ status = acpi_ns_handle_to_pathname (node, &buffer_size, buffer); if (ACPI_FAILURE (status)) { acpi_os_printf ("****Could not get pathname****)"); goto exit; } acpi_os_printf (" (Path %s)", buffer);exit: /* Restore the debug level */ acpi_dbg_level = debug_level; return (status);}#endif/******************************************************************************* * * FUNCTION: Acpi_db_display_op * * PARAMETERS: Origin - Starting object * Num_opcodes - Max number of opcodes to be displayed * * RETURN: None * * DESCRIPTION: Display parser object and its children * ******************************************************************************/voidacpi_db_display_op ( acpi_walk_state *walk_state, acpi_parse_object *origin, u32 num_opcodes){ acpi_parse_object *op = origin; acpi_parse_object *arg; acpi_parse_object *depth; u32 depth_count = 0; u32 last_depth = 0; u32 i; u32 j; if (op) { while (op) { /* indentation */ depth_count = 0; if (!acpi_gbl_db_opt_verbose) { depth_count++; } /* Determine the nesting depth of this argument */ for (depth = op->parent; depth; depth = depth->parent) { arg = acpi_ps_get_arg (depth, 0); while (arg && arg != origin) { arg = arg->next; } if (arg) { break; } depth_count++; } /* Open a new block if we are nested further than last time */ if (depth_count > last_depth) { VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth)); for (i = 0; i < last_depth; i++) { acpi_os_printf ("%s", acpi_gbl_db_disasm_indent); } if (acpi_db_block_type (op) == BLOCK_PAREN) { acpi_os_printf ("(\n"); } else { acpi_os_printf ("{\n"); } } /* Close a block if we are nested less than last time */ else if (depth_count < last_depth) { for (j = 0; j < (last_depth - depth_count); j++) { VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - j)); for (i = 0; i < (last_depth - j - 1); i++) { acpi_os_printf ("%s", acpi_gbl_db_disasm_indent); } if (acpi_db_block_type (op) == BLOCK_PAREN) { acpi_os_printf (")\n"); } else { acpi_os_printf ("}\n"); } } } /* In verbose mode, print the AML offset, opcode and depth count */ VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) op->aml_offset, op->opcode, depth_count)); /* Indent the output according to the depth count */ for (i = 0; i < depth_count; i++) { acpi_os_printf ("%s", acpi_gbl_db_disasm_indent); } /* Now print the opcode */ acpi_db_display_opcode (walk_state, op); /* Resolve a name reference */ if ((op->opcode == AML_INT_NAMEPATH_OP && op->value.name) && (op->parent) && (acpi_gbl_db_opt_verbose)) { acpi_ps_display_object_pathname (walk_state, op); } acpi_os_printf ("\n"); /* Get the next node in the tree */ op = acpi_ps_get_depth_next (origin, op); last_depth = depth_count; num_opcodes--; if (!num_opcodes) { op = NULL; } } /* Close the last block(s) */ depth_count = last_depth -1; for (i = 0; i < last_depth; i++) { VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - i)); for (j = 0; j < depth_count; j++) { acpi_os_printf ("%s", acpi_gbl_db_disasm_indent); } acpi_os_printf ("}\n"); depth_count--; } } else { acpi_db_display_opcode (walk_state, op); }}/******************************************************************************* * * FUNCTION: Acpi_db_display_namestring * * PARAMETERS: Name - ACPI Name string to store * * RETURN: None * * DESCRIPTION: Display namestring. Handles prefix characters * ******************************************************************************/voidacpi_db_display_namestring ( NATIVE_CHAR *name){ u32 seg_count; u8 do_dot = FALSE; if (!name) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -