1 /******************************************************************************
2  *
3  * Name: acdebug.h - ACPI/AML debugger
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2004, R. Byron Moore
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 
48 #define ACPI_DEBUG_BUFFER_SIZE  4196
49 
50 struct command_info
51 {
52 	char                            *name;          /* Command Name */
53 	u8                              min_args;       /* Minimum arguments required */
54 };
55 
56 
57 struct argument_info
58 {
59 	char                            *name;          /* Argument Name */
60 };
61 
62 
63 #define PARAM_LIST(pl)                  pl
64 
65 #define DBTEST_OUTPUT_LEVEL(lvl)        if (acpi_gbl_db_opt_verbose)
66 
67 #define VERBOSE_PRINT(fp)               DBTEST_OUTPUT_LEVEL(lvl) {\
68 			  acpi_os_printf PARAM_LIST(fp);}
69 
70 #define EX_NO_SINGLE_STEP               1
71 #define EX_SINGLE_STEP                  2
72 
73 
74 /* Prototypes */
75 
76 
77 /*
78  * dbxface - external debugger interfaces
79  */
80 
81 acpi_status
82 acpi_db_initialize (
83 	void);
84 
85 void
86 acpi_db_terminate (
87 	void);
88 
89 acpi_status
90 acpi_db_single_step (
91 	struct acpi_walk_state          *walk_state,
92 	union acpi_parse_object         *op,
93 	u32                             op_type);
94 
95 acpi_status
96 acpi_db_start_command (
97 	struct acpi_walk_state          *walk_state,
98 	union acpi_parse_object         *op);
99 
100 void
101 acpi_db_method_end (
102 	struct acpi_walk_state          *walk_state);
103 
104 
105 /*
106  * dbcmds - debug commands and output routines
107  */
108 
109 void
110 acpi_db_display_table_info (
111 	char                            *table_arg);
112 
113 void
114 acpi_db_unload_acpi_table (
115 	char                            *table_arg,
116 	char                            *instance_arg);
117 
118 void
119 acpi_db_set_method_breakpoint (
120 	char                            *location,
121 	struct acpi_walk_state          *walk_state,
122 	union acpi_parse_object         *op);
123 
124 void
125 acpi_db_set_method_call_breakpoint (
126 	union acpi_parse_object         *op);
127 
128 void
129 acpi_db_disassemble_aml (
130 	char                            *statements,
131 	union acpi_parse_object         *op);
132 
133 void
134 acpi_db_dump_namespace (
135 	char                            *start_arg,
136 	char                            *depth_arg);
137 
138 void
139 acpi_db_dump_namespace_by_owner (
140 	char                            *owner_arg,
141 	char                            *depth_arg);
142 
143 void
144 acpi_db_send_notify (
145 	char                            *name,
146 	u32                             value);
147 
148 void
149 acpi_db_set_method_data (
150 	char                            *type_arg,
151 	char                            *index_arg,
152 	char                            *value_arg);
153 
154 acpi_status
155 acpi_db_display_objects (
156 	char                            *obj_type_arg,
157 	char                            *display_count_arg);
158 
159 acpi_status
160 acpi_db_find_name_in_namespace (
161 	char                            *name_arg);
162 
163 void
164 acpi_db_set_scope (
165 	char                            *name);
166 
167 void
168 acpi_db_find_references (
169 	char                            *object_arg);
170 
171 void
172 acpi_db_display_locks (void);
173 
174 
175 void
176 acpi_db_display_resources (
177 	char                            *object_arg);
178 
179 void
180 acpi_db_display_gpes (void);
181 
182 void
183 acpi_db_check_integrity (
184 	void);
185 
186 acpi_status
187 acpi_db_integrity_walk (
188 	acpi_handle                     obj_handle,
189 	u32                             nesting_level,
190 	void                            *context,
191 	void                            **return_value);
192 
193 acpi_status
194 acpi_db_walk_and_match_name (
195 	acpi_handle                     obj_handle,
196 	u32                             nesting_level,
197 	void                            *context,
198 	void                            **return_value);
199 
200 acpi_status
201 acpi_db_walk_for_references (
202 	acpi_handle                     obj_handle,
203 	u32                             nesting_level,
204 	void                            *context,
205 	void                            **return_value);
206 
207 acpi_status
208 acpi_db_walk_for_specific_objects (
209 	acpi_handle                     obj_handle,
210 	u32                             nesting_level,
211 	void                            *context,
212 	void                            **return_value);
213 
214 void
215 acpi_db_generate_gpe (
216 	char                            *gpe_arg,
217 	char                            *block_arg);
218 
219 /*
220  * dbdisply - debug display commands
221  */
222 
223 void
224 acpi_db_display_method_info (
225 	union acpi_parse_object         *op);
226 
227 void
228 acpi_db_decode_and_display_object (
229 	char                            *target,
230 	char                            *output_type);
231 
232 void
233 acpi_db_display_result_object (
234 	union acpi_operand_object       *obj_desc,
235 	struct acpi_walk_state          *walk_state);
236 
237 acpi_status
238 acpi_db_display_all_methods (
239 	char                            *display_count_arg);
240 
241 void
242 acpi_db_display_arguments (
243 	void);
244 
245 void
246 acpi_db_display_locals (
247 	void);
248 
249 void
250 acpi_db_display_results (
251 	void);
252 
253 void
254 acpi_db_display_calling_tree (
255 	void);
256 
257 void
258 acpi_db_display_object_type (
259 	char                            *object_arg);
260 
261 void
262 acpi_db_display_argument_object (
263 	union acpi_operand_object       *obj_desc,
264 	struct acpi_walk_state          *walk_state);
265 
266 void
267 acpi_db_dump_parser_descriptor (
268 	union acpi_parse_object         *op);
269 
270 void *
271 acpi_db_get_pointer (
272 	void                            *target);
273 
274 
275 /*
276  * dbexec - debugger control method execution
277  */
278 
279 void
280 acpi_db_execute (
281 	char                            *name,
282 	char                            **args,
283 	u32                             flags);
284 
285 void
286 acpi_db_create_execution_threads (
287 	char                            *num_threads_arg,
288 	char                            *num_loops_arg,
289 	char                            *method_name_arg);
290 
291 acpi_status
292 acpi_db_execute_method (
293 	struct acpi_db_method_info      *info,
294 	struct acpi_buffer              *return_obj);
295 
296 void
297 acpi_db_execute_setup (
298 	struct acpi_db_method_info      *info);
299 
300 u32
301 acpi_db_get_outstanding_allocations (
302 	void);
303 
304 void ACPI_SYSTEM_XFACE
305 acpi_db_method_thread (
306 	void                            *context);
307 
308 acpi_status
309 acpi_db_execution_walk (
310 	acpi_handle                     obj_handle,
311 	u32                             nesting_level,
312 	void                            *context,
313 	void                            **return_value);
314 
315 
316 /*
317  * dbfileio - Debugger file I/O commands
318  */
319 
320 acpi_object_type
321 acpi_db_match_argument (
322 	char                            *user_argument,
323 	struct argument_info            *arguments);
324 
325 acpi_status
326 ae_local_load_table (
327 	struct acpi_table_header        *table_ptr);
328 
329 void
330 acpi_db_close_debug_file (
331 	void);
332 
333 void
334 acpi_db_open_debug_file (
335 	char                            *name);
336 
337 acpi_status
338 acpi_db_load_acpi_table (
339 	char                            *filename);
340 
341 acpi_status
342 acpi_db_get_table_from_file (
343 	char                            *filename,
344 	struct acpi_table_header        **table);
345 
346 acpi_status
347 acpi_db_read_table_from_file (
348 	char                            *filename,
349 	struct acpi_table_header        **table);
350 
351 /*
352  * dbhistry - debugger HISTORY command
353  */
354 
355 void
356 acpi_db_add_to_history (
357 	char                            *command_line);
358 
359 void
360 acpi_db_display_history (void);
361 
362 char *
363 acpi_db_get_from_history (
364 	char                            *command_num_arg);
365 
366 
367 /*
368  * dbinput - user front-end to the AML debugger
369  */
370 
371 acpi_status
372 acpi_db_command_dispatch (
373 	char                            *input_buffer,
374 	struct acpi_walk_state          *walk_state,
375 	union acpi_parse_object         *op);
376 
377 void ACPI_SYSTEM_XFACE
378 acpi_db_execute_thread (
379 	void                            *context);
380 
381 acpi_status
382 acpi_db_user_commands (
383 	char                            prompt,
384 	union acpi_parse_object         *op);
385 
386 void
387 acpi_db_display_help (
388 	char                            *help_type);
389 
390 char *
391 acpi_db_get_next_token (
392 	char                            *string,
393 	char                            **next);
394 
395 u32
396 acpi_db_get_line (
397 	char                            *input_buffer);
398 
399 u32
400 acpi_db_match_command (
401 	char                            *user_command);
402 
403 void
404 acpi_db_single_thread (
405 	void);
406 
407 
408 /*
409  * dbstats - Generation and display of ACPI table statistics
410  */
411 
412 void
413 acpi_db_generate_statistics (
414 	union acpi_parse_object         *root,
415 	u8                              is_method);
416 
417 
418 acpi_status
419 acpi_db_display_statistics (
420 	char                            *type_arg);
421 
422 acpi_status
423 acpi_db_classify_one_object (
424 	acpi_handle                     obj_handle,
425 	u32                             nesting_level,
426 	void                            *context,
427 	void                            **return_value);
428 
429 void
430 acpi_db_count_namespace_objects (
431 	void);
432 
433 void
434 acpi_db_enumerate_object (
435 	union acpi_operand_object       *obj_desc);
436 
437 
438 /*
439  * dbutils - AML debugger utilities
440  */
441 
442 void
443 acpi_db_set_output_destination (
444 	u32                             where);
445 
446 void
447 acpi_db_dump_buffer (
448 	u32                             address);
449 
450 void
451 acpi_db_dump_object (
452 	union acpi_object               *obj_desc,
453 	u32                             level);
454 
455 void
456 acpi_db_prep_namestring (
457 	char                            *name);
458 
459 
460 acpi_status
461 acpi_db_second_pass_parse (
462 	union acpi_parse_object         *root);
463 
464 struct acpi_namespace_node *
465 acpi_db_local_ns_lookup (
466 	char                            *name);
467 
468 
469 #endif  /* __ACDEBUG_H__ */
470