⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbinput.c

📁 上传linux-jx2410的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger *              $Revision: 1.1.1.1 $ * ******************************************************************************//* *  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 "actables.h"#include "acnamesp.h"#include "acinterp.h"#include "acdebug.h"#ifdef ENABLE_DEBUGGER#define _COMPONENT          ACPI_DEBUGGER	 MODULE_NAME         ("dbinput")/* * Globals that are specific to the debugger */NATIVE_CHAR                 acpi_gbl_db_line_buf[80];NATIVE_CHAR                 acpi_gbl_db_parsed_buf[80];NATIVE_CHAR                 acpi_gbl_db_scope_buf[40];NATIVE_CHAR                 acpi_gbl_db_debug_filename[40];NATIVE_CHAR                 *acpi_gbl_db_args[DB_MAX_ARGS];NATIVE_CHAR                 *acpi_gbl_db_buffer = NULL;NATIVE_CHAR                 *acpi_gbl_db_filename = NULL;u8                          acpi_gbl_db_output_to_file = FALSE;u32                         acpi_gbl_db_debug_level = ACPI_LV_VERBOSITY2;u32                         acpi_gbl_db_console_debug_level = NORMAL_DEFAULT | ACPI_LV_TABLES;u8                          acpi_gbl_db_output_flags = DB_CONSOLE_OUTPUT;u8                          acpi_gbl_db_opt_tables    = FALSE;u8                          acpi_gbl_db_opt_disasm    = FALSE;u8                          acpi_gbl_db_opt_stats     = FALSE;u8                          acpi_gbl_db_opt_parse_jit = FALSE;u8                          acpi_gbl_db_opt_verbose   = TRUE;u8                          acpi_gbl_db_opt_ini_methods = TRUE;/* * Statistic globals */u16                         acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];u16                         acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];u16                         acpi_gbl_obj_type_count_misc;u16                         acpi_gbl_node_type_count_misc;u32                         acpi_gbl_num_nodes;u32                         acpi_gbl_num_objects;u32                         acpi_gbl_size_of_parse_tree;u32                         acpi_gbl_size_of_method_trees;u32                         acpi_gbl_size_of_node_entries;u32                         acpi_gbl_size_of_acpi_objects;/* * Top-level debugger commands. * * This list of commands must match the string table below it */enum acpi_ex_debugger_commands{	CMD_NOT_FOUND = 0,	CMD_NULL,	CMD_ALLOCATIONS,	CMD_ARGS,	CMD_ARGUMENTS,	CMD_BREAKPOINT,	CMD_CALL,	CMD_CLOSE,	CMD_DEBUG,	CMD_DUMP,	CMD_ENABLEACPI,	CMD_EVENT,	CMD_EXECUTE,	CMD_EXIT,	CMD_FIND,	CMD_GO,	CMD_HELP,	CMD_HELP2,	CMD_HISTORY,	CMD_HISTORY_EXE,	CMD_HISTORY_LAST,	CMD_INFORMATION,	CMD_INTO,	CMD_LEVEL,	CMD_LIST,	CMD_LOAD,	CMD_LOCALS,	CMD_LOCKS,	CMD_METHODS,	CMD_NAMESPACE,	CMD_NOTIFY,	CMD_OBJECT,	CMD_OPEN,	CMD_OWNER,	CMD_PREFIX,	CMD_QUIT,	CMD_REFERENCES,	CMD_RESOURCES,	CMD_RESULTS,	CMD_SET,	CMD_STATS,	CMD_STOP,	CMD_TABLES,	CMD_TERMINATE,	CMD_THREADS,	CMD_TREE,	CMD_UNLOAD};#define CMD_FIRST_VALID     2const COMMAND_INFO          acpi_gbl_db_commands[] ={ {"<NOT FOUND>",  0},	{"<NULL>",       0},	{"ALLOCATIONS",  0},	{"ARGS",         0},	{"ARGUMENTS",    0},	{"BREAKPOINT",   1},	{"CALL",         0},	{"CLOSE",        0},	{"DEBUG",        1},	{"DUMP",         1},	{"ENABLEACPI",   0},	{"EVENT",        1},	{"EXECUTE",      1},	{"EXIT",         0},	{"FIND",         1},	{"GO",           0},	{"HELP",         0},	{"?",            0},	{"HISTORY",      0},	{"!",            1},	{"!!",           0},	{"INFORMATION",  0},	{"INTO",         0},	{"LEVEL",        0},	{"LIST",         0},	{"LOAD",         1},	{"LOCALS",       0},	{"LOCKS",        0},	{"METHODS",      0},	{"NAMESPACE",    0},	{"NOTIFY",       2},	{"OBJECT",       1},	{"OPEN",         1},	{"OWNER",        1},	{"PREFIX",       0},	{"QUIT",         0},	{"REFERENCES",   1},	{"RESOURCES",    1},	{"RESULTS",      0},	{"SET",          3},	{"STATS",        0},	{"STOP",         0},	{"TABLES",       0},	{"TERMINATE",    0},	{"THREADS",      3},	{"TREE",         0},	{"UNLOAD",       1},	{NULL,           0}};/******************************************************************************* * * FUNCTION:    Acpi_db_display_help * * PARAMETERS:  Help_type       - Subcommand (optional) * * RETURN:      None * * DESCRIPTION: Print a usage message. * ******************************************************************************/voidacpi_db_display_help (	NATIVE_CHAR             *help_type){	/* No parameter, just give the overview */	if (!help_type)	{		acpi_os_printf ("ACPI CA Debugger Commands\n\n");		acpi_os_printf ("The following classes of commands are available. Help is available for\n");		acpi_os_printf ("each class by entering \"Help <Class_name>\"\n\n");		acpi_os_printf ("  [GENERAL]       General-Purpose Commands\n");		acpi_os_printf ("  [NAMESPACE]     Namespace Access Commands\n");		acpi_os_printf ("  [METHOD]        Control Method Execution Commands\n");		acpi_os_printf ("  [FILE]          File I/O Commands\n");		return;	}	/*	 * Parameter is the command class	 *	 * The idea here is to keep each class of commands smaller than a screenful	 */	switch (help_type[0])	{	case 'G':		acpi_os_printf ("\n_general-Purpose Commands\n\n");		acpi_os_printf ("Allocations                       Display list of current memory allocations\n");		acpi_os_printf ("Dump <Address>|<Namepath>\n");		acpi_os_printf ("   [Byte|Word|Dword|Qword]        Display ACPI objects or memory\n");		acpi_os_printf ("Enable_acpi                       Enable ACPI (hardware) mode\n");		acpi_os_printf ("Help                              This help screen\n");		acpi_os_printf ("History                           Display command history buffer\n");		acpi_os_printf ("Level [<Debug_level>] [console]   Get/Set debug level for file or console\n");		acpi_os_printf ("Locks                             Current status of internal mutexes\n");		acpi_os_printf ("Quit or Exit                      Exit this command\n");		acpi_os_printf ("Stats [Allocations|Memory|Misc\n");		acpi_os_printf ("     |Objects|Tables]             Display namespace and memory statistics\n");		acpi_os_printf ("Tables                            Display info about loaded ACPI tables\n");		acpi_os_printf ("Unload <Table_sig> [Instance]     Unload an ACPI table\n");		acpi_os_printf ("! <Command_number>                Execute command from history buffer\n");		acpi_os_printf ("!!                                Execute last command again\n");		return;	case 'N':		acpi_os_printf ("\n_namespace Access Commands\n\n");		acpi_os_printf ("Debug <Namepath> [Arguments]      Single Step a control method\n");		acpi_os_printf ("Event <F|G> <Value>               Generate Acpi_event (Fixed/GPE)\n");		acpi_os_printf ("Execute <Namepath> [Arguments]    Execute control method\n");		acpi_os_printf ("Find <Name> (? is wildcard)       Find ACPI name(s) with wildcards\n");		acpi_os_printf ("Method                            Display list of loaded control methods\n");		acpi_os_printf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n");		acpi_os_printf ("Notify <Name_path> <Value>        Send a notification\n");		acpi_os_printf ("Objects <Object_type>             Display all objects of the given type\n");		acpi_os_printf ("Owner <Owner_id> [Depth]          Display loaded namespace by object owner\n");		acpi_os_printf ("Prefix [<Name_path>]              Set or Get current execution prefix\n");		acpi_os_printf ("References <Addr>                 Find all references to object at addr\n");		acpi_os_printf ("Resources xxx                     Get and display resources\n");		acpi_os_printf ("Terminate                         Delete namespace and all internal objects\n");		acpi_os_printf ("Thread <Threads><Loops><Name_path> Spawn threads to execute method(s)\n");		return;	case 'M':		acpi_os_printf ("\n_control Method Execution Commands\n\n");		acpi_os_printf ("Arguments (or Args)               Display method arguments\n");		acpi_os_printf ("Breakpoint <Aml_offset>           Set an AML execution breakpoint\n");		acpi_os_printf ("Call                              Run to next control method invocation\n");		acpi_os_printf ("Go                                Allow method to run to completion\n");		acpi_os_printf ("Information                       Display info about the current method\n");		acpi_os_printf ("Into                              Step into (not over) a method call\n");		acpi_os_printf ("List [# of Aml Opcodes]           Display method ASL statements\n");		acpi_os_printf ("Locals                            Display method local variables\n");		acpi_os_printf ("Results                           Display method result stack\n");		acpi_os_printf ("Set <A|L> <#> <Value>             Set method data (Arguments/Locals)\n");		acpi_os_printf ("Stop                              Terminate control method\n");		acpi_os_printf ("Tree                              Display control method calling tree\n");		acpi_os_printf ("<Enter>                           Single step next AML opcode (over calls)\n");		return;	case 'F':		acpi_os_printf ("\n_file I/O Commands\n\n");		acpi_os_printf ("Close                             Close debug output file\n");		acpi_os_printf ("Open <Output Filename>            Open a file for debug output\n");		acpi_os_printf ("Load <Input Filename>             Load ACPI table from a file\n");		return;	default:		acpi_os_printf ("Unrecognized Command Class: %x\n", help_type);		return;	}}/******************************************************************************* * * FUNCTION:    Acpi_db_get_next_token * * PARAMETERS:  String          - Command buffer *              Next            - Return value, end of next token * * RETURN:      Pointer to the start of the next token. * * DESCRIPTION: Command line parsing.  Get the next token on the command line * ******************************************************************************/NATIVE_CHAR *acpi_db_get_next_token (	NATIVE_CHAR             *string,	NATIVE_CHAR             **next){	NATIVE_CHAR             *start;	/* At end of buffer? */	if (!string || !(*string))	{		return (NULL);	}	/* Get rid of any spaces at the beginning */	if (*string == ' ')	{		while (*string && (*string == ' '))		{			string++;		}		if (!(*string))		{			return (NULL);		}	}	start = string;	/* Find end of token */	while (*string && (*string != ' '))	{		string++;	}	if (!(*string))	{		*next = NULL;	}	else	{		*string = 0;		*next = string + 1;	}	return (start);}/******************************************************************************* * * FUNCTION:    Acpi_db_get_line * * PARAMETERS:  Input_buffer        - Command line buffer * * RETURN:      None * * DESCRIPTION: Get the next command line from the user.  Gets entire line *              up to the next newline * ******************************************************************************/u32acpi_db_get_line (	NATIVE_CHAR             *input_buffer){	u32                     i;	u32                     count;	NATIVE_CHAR             *next;	NATIVE_CHAR             *this;	STRCPY (acpi_gbl_db_parsed_buf, input_buffer);	STRUPR (acpi_gbl_db_parsed_buf);	this = acpi_gbl_db_parsed_buf;	for (i = 0; i < DB_MAX_ARGS; i++)	{		acpi_gbl_db_args[i] = acpi_db_get_next_token (this, &next);		if (!acpi_gbl_db_args[i])		{			break;		}		this = next;	}	/* Uppercase the actual command */	if (acpi_gbl_db_args[0])	{		STRUPR (acpi_gbl_db_args[0]);	}	count = i;	if (count)	{		count--;  /* Number of args only */	}	return (count);}/******************************************************************************* * * FUNCTION:    Acpi_db_match_command * * PARAMETERS:  User_command            - User command line * * RETURN:      Index into command array, -1 if not found * * DESCRIPTION: Search command array for a command match * ******************************************************************************/u32acpi_db_match_command (	NATIVE_CHAR             *user_command){	u32                     i;	if (!user_command || user_command[0] == 0)	{		return (CMD_NULL);	}	for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++)	{		if (STRSTR (acpi_gbl_db_commands[i].name, user_command) == acpi_gbl_db_commands[i].name)		{			return (i);		}	}	/* Command not recognized */	return (CMD_NOT_FOUND);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -