1/******************************************************************************
2 *
3 * Name: acdebug.h - ACPI/AML debugger
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2015, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions, and the following disclaimer,
16 *    without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 *    substantially similar to the "NO WARRANTY" disclaimer below
19 *    ("Disclaimer") and any redistribution must be conditioned upon
20 *    including a substantially similar Disclaimer requirement for further
21 *    binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 *    of any contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACDEBUG_H__
45#define __ACDEBUG_H__
46
47/* The debugger is used in conjunction with the disassembler most of time */
48
49#ifdef ACPI_DISASSEMBLER
50#include "acdisasm.h"
51#endif
52
53#define ACPI_DEBUG_BUFFER_SIZE  0x4000	/* 16K buffer for return objects */
54
55struct acpi_db_command_info {
56	char *name;		/* Command Name */
57	u8 min_args;		/* Minimum arguments required */
58};
59
60struct acpi_db_command_help {
61	u8 line_count;		/* Number of help lines */
62	char *invocation;	/* Command Invocation */
63	char *description;	/* Command Description */
64};
65
66struct acpi_db_argument_info {
67	char *name;		/* Argument Name */
68};
69
70struct acpi_db_execute_walk {
71	u32 count;
72	u32 max_count;
73};
74
75#define PARAM_LIST(pl)                  pl
76
77#define EX_NO_SINGLE_STEP               1
78#define EX_SINGLE_STEP                  2
79
80/*
81 * dbxface - external debugger interfaces
82 */
83acpi_status
84acpi_db_single_step(struct acpi_walk_state *walk_state,
85		    union acpi_parse_object *op, u32 op_type);
86
87/*
88 * dbcmds - debug commands and output routines
89 */
90struct acpi_namespace_node *acpi_db_convert_to_node(char *in_string);
91
92void acpi_db_display_table_info(char *table_arg);
93
94void acpi_db_display_template(char *buffer_arg);
95
96void acpi_db_unload_acpi_table(char *name);
97
98void acpi_db_send_notify(char *name, u32 value);
99
100void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg);
101
102acpi_status acpi_db_sleep(char *object_arg);
103
104void acpi_db_trace(char *enable_arg, char *method_arg, char *once_arg);
105
106void acpi_db_display_locks(void);
107
108void acpi_db_display_resources(char *object_arg);
109
110ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void))
111
112void acpi_db_display_handlers(void);
113
114ACPI_HW_DEPENDENT_RETURN_VOID(void
115			      acpi_db_generate_gpe(char *gpe_arg,
116						   char *block_arg))
117ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void))
118
119void acpi_db_execute_test(char *type_arg);
120
121/*
122 * dbconvert - miscellaneous conversion routines
123 */
124acpi_status acpi_db_hex_char_to_value(int hex_char, u8 *return_value);
125
126acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object);
127
128acpi_status
129acpi_db_convert_to_object(acpi_object_type type,
130			  char *string, union acpi_object *object);
131
132u8 *acpi_db_encode_pld_buffer(struct acpi_pld_info *pld_info);
133
134void acpi_db_dump_pld_buffer(union acpi_object *obj_desc);
135
136/*
137 * dbmethod - control method commands
138 */
139void
140acpi_db_set_method_breakpoint(char *location,
141			      struct acpi_walk_state *walk_state,
142			      union acpi_parse_object *op);
143
144void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
145
146void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
147
148acpi_status acpi_db_disassemble_method(char *name);
149
150void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
151
152void acpi_db_batch_execute(char *count_arg);
153
154/*
155 * dbnames - namespace commands
156 */
157void acpi_db_set_scope(char *name);
158
159void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
160
161void acpi_db_dump_namespace_paths(void);
162
163void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
164
165acpi_status acpi_db_find_name_in_namespace(char *name_arg);
166
167void acpi_db_check_predefined_names(void);
168
169acpi_status
170acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
171
172void acpi_db_check_integrity(void);
173
174void acpi_db_find_references(char *object_arg);
175
176void acpi_db_get_bus_info(void);
177
178/*
179 * dbdisply - debug display commands
180 */
181void acpi_db_display_method_info(union acpi_parse_object *op);
182
183void acpi_db_decode_and_display_object(char *target, char *output_type);
184
185void
186acpi_db_display_result_object(union acpi_operand_object *obj_desc,
187			      struct acpi_walk_state *walk_state);
188
189acpi_status acpi_db_display_all_methods(char *display_count_arg);
190
191void acpi_db_display_arguments(void);
192
193void acpi_db_display_locals(void);
194
195void acpi_db_display_results(void);
196
197void acpi_db_display_calling_tree(void);
198
199void acpi_db_display_object_type(char *object_arg);
200
201void
202acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
203				struct acpi_walk_state *walk_state);
204
205/*
206 * dbexec - debugger control method execution
207 */
208void
209acpi_db_execute(char *name, char **args, acpi_object_type * types, u32 flags);
210
211void
212acpi_db_create_execution_threads(char *num_threads_arg,
213				 char *num_loops_arg, char *method_name_arg);
214
215void acpi_db_delete_objects(u32 count, union acpi_object *objects);
216
217#ifdef ACPI_DBG_TRACK_ALLOCATIONS
218u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
219#endif
220
221/*
222 * dbfileio - Debugger file I/O commands
223 */
224acpi_object_type
225acpi_db_match_argument(char *user_argument,
226		       struct acpi_db_argument_info *arguments);
227
228void acpi_db_close_debug_file(void);
229
230void acpi_db_open_debug_file(char *name);
231
232acpi_status acpi_db_load_acpi_table(char *filename);
233
234acpi_status
235acpi_db_get_table_from_file(char *filename,
236			    struct acpi_table_header **table,
237			    u8 must_be_aml_table);
238
239/*
240 * dbhistry - debugger HISTORY command
241 */
242void acpi_db_add_to_history(char *command_line);
243
244void acpi_db_display_history(void);
245
246char *acpi_db_get_from_history(char *command_num_arg);
247
248char *acpi_db_get_history_by_index(u32 commandd_num);
249
250/*
251 * dbinput - user front-end to the AML debugger
252 */
253acpi_status
254acpi_db_command_dispatch(char *input_buffer,
255			 struct acpi_walk_state *walk_state,
256			 union acpi_parse_object *op);
257
258void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
259
260acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op);
261
262char *acpi_db_get_next_token(char *string,
263			     char **next, acpi_object_type * return_type);
264
265/*
266 * dbobject
267 */
268void acpi_db_decode_internal_object(union acpi_operand_object *obj_desc);
269
270void
271acpi_db_display_internal_object(union acpi_operand_object *obj_desc,
272				struct acpi_walk_state *walk_state);
273
274void acpi_db_decode_arguments(struct acpi_walk_state *walk_state);
275
276void acpi_db_decode_locals(struct acpi_walk_state *walk_state);
277
278void
279acpi_db_dump_method_info(acpi_status status,
280			 struct acpi_walk_state *walk_state);
281
282/*
283 * dbstats - Generation and display of ACPI table statistics
284 */
285void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method);
286
287acpi_status acpi_db_display_statistics(char *type_arg);
288
289/*
290 * dbutils - AML debugger utilities
291 */
292void acpi_db_set_output_destination(u32 where);
293
294void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level);
295
296void acpi_db_prep_namestring(char *name);
297
298struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name);
299
300void acpi_db_uint32_to_hex_string(u32 value, char *buffer);
301
302#endif				/* __ACDEBUG_H__ */
303