Commit | Line | Data |
---|---|---|
99575102 LZ |
1 | /******************************************************************************* |
2 | * | |
3 | * Module Name: dbdisply - debug display commands | |
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 | #include <acpi/acpi.h> | |
45 | #include "accommon.h" | |
46 | #include "amlcode.h" | |
47 | #include "acdispat.h" | |
48 | #include "acnamesp.h" | |
49 | #include "acparser.h" | |
50 | #include "acinterp.h" | |
51 | #include "acdebug.h" | |
52 | ||
53 | #define _COMPONENT ACPI_CA_DEBUGGER | |
54 | ACPI_MODULE_NAME("dbdisply") | |
55 | ||
56 | /* Local prototypes */ | |
57 | static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op); | |
58 | ||
59 | static void *acpi_db_get_pointer(void *target); | |
60 | ||
61 | static acpi_status | |
62 | acpi_db_display_non_root_handlers(acpi_handle obj_handle, | |
63 | u32 nesting_level, | |
64 | void *context, void **return_value); | |
65 | ||
66 | /* | |
67 | * System handler information. | |
68 | * Used for Handlers command, in acpi_db_display_handlers. | |
69 | */ | |
70 | #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : " | |
71 | #define ACPI_HANDLER_NAME_STRING "%30s : " | |
72 | #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n" | |
73 | #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)" | |
74 | #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n" | |
75 | ||
76 | /* All predefined Address Space IDs */ | |
77 | ||
78 | static acpi_adr_space_type acpi_gbl_space_id_list[] = { | |
79 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | |
80 | ACPI_ADR_SPACE_SYSTEM_IO, | |
81 | ACPI_ADR_SPACE_PCI_CONFIG, | |
82 | ACPI_ADR_SPACE_EC, | |
83 | ACPI_ADR_SPACE_SMBUS, | |
84 | ACPI_ADR_SPACE_CMOS, | |
85 | ACPI_ADR_SPACE_PCI_BAR_TARGET, | |
86 | ACPI_ADR_SPACE_IPMI, | |
87 | ACPI_ADR_SPACE_GPIO, | |
88 | ACPI_ADR_SPACE_GSBUS, | |
89 | ACPI_ADR_SPACE_DATA_TABLE, | |
90 | ACPI_ADR_SPACE_FIXED_HARDWARE | |
91 | }; | |
92 | ||
93 | /* Global handler information */ | |
94 | ||
95 | typedef struct acpi_handler_info { | |
96 | void *handler; | |
97 | char *name; | |
98 | ||
99 | } acpi_handler_info; | |
100 | ||
101 | static struct acpi_handler_info acpi_gbl_handler_list[] = { | |
102 | {&acpi_gbl_global_notify[0].handler, "System Notifications"}, | |
103 | {&acpi_gbl_global_notify[1].handler, "Device Notifications"}, | |
104 | {&acpi_gbl_table_handler, "ACPI Table Events"}, | |
105 | {&acpi_gbl_exception_handler, "Control Method Exceptions"}, | |
106 | {&acpi_gbl_interface_handler, "OSI Invocations"} | |
107 | }; | |
108 | ||
109 | /******************************************************************************* | |
110 | * | |
111 | * FUNCTION: acpi_db_get_pointer | |
112 | * | |
113 | * PARAMETERS: target - Pointer to string to be converted | |
114 | * | |
115 | * RETURN: Converted pointer | |
116 | * | |
117 | * DESCRIPTION: Convert an ascii pointer value to a real value | |
118 | * | |
119 | ******************************************************************************/ | |
120 | ||
121 | static void *acpi_db_get_pointer(void *target) | |
122 | { | |
123 | void *obj_ptr; | |
124 | acpi_size address; | |
125 | ||
126 | address = strtoul(target, NULL, 16); | |
127 | obj_ptr = ACPI_TO_POINTER(address); | |
128 | return (obj_ptr); | |
129 | } | |
130 | ||
131 | /******************************************************************************* | |
132 | * | |
133 | * FUNCTION: acpi_db_dump_parser_descriptor | |
134 | * | |
135 | * PARAMETERS: op - A parser Op descriptor | |
136 | * | |
137 | * RETURN: None | |
138 | * | |
139 | * DESCRIPTION: Display a formatted parser object | |
140 | * | |
141 | ******************************************************************************/ | |
142 | ||
143 | static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op) | |
144 | { | |
145 | const struct acpi_opcode_info *info; | |
146 | ||
147 | info = acpi_ps_get_opcode_info(op->common.aml_opcode); | |
148 | ||
149 | acpi_os_printf("Parser Op Descriptor:\n"); | |
150 | acpi_os_printf("%20.20s : %4.4X\n", "Opcode", op->common.aml_opcode); | |
151 | ||
152 | ACPI_DEBUG_ONLY_MEMBERS(acpi_os_printf("%20.20s : %s\n", "Opcode Name", | |
153 | info->name)); | |
154 | ||
155 | acpi_os_printf("%20.20s : %p\n", "Value/ArgList", op->common.value.arg); | |
156 | acpi_os_printf("%20.20s : %p\n", "Parent", op->common.parent); | |
157 | acpi_os_printf("%20.20s : %p\n", "NextOp", op->common.next); | |
158 | } | |
159 | ||
160 | /******************************************************************************* | |
161 | * | |
162 | * FUNCTION: acpi_db_decode_and_display_object | |
163 | * | |
164 | * PARAMETERS: target - String with object to be displayed. Names | |
165 | * and hex pointers are supported. | |
166 | * output_type - Byte, Word, Dword, or Qword (B|W|D|Q) | |
167 | * | |
168 | * RETURN: None | |
169 | * | |
170 | * DESCRIPTION: Display a formatted ACPI object | |
171 | * | |
172 | ******************************************************************************/ | |
173 | ||
174 | void acpi_db_decode_and_display_object(char *target, char *output_type) | |
175 | { | |
176 | void *obj_ptr; | |
177 | struct acpi_namespace_node *node; | |
178 | union acpi_operand_object *obj_desc; | |
179 | u32 display = DB_BYTE_DISPLAY; | |
180 | char buffer[80]; | |
181 | struct acpi_buffer ret_buf; | |
182 | acpi_status status; | |
183 | u32 size; | |
184 | ||
185 | if (!target) { | |
186 | return; | |
187 | } | |
188 | ||
189 | /* Decode the output type */ | |
190 | ||
191 | if (output_type) { | |
192 | acpi_ut_strupr(output_type); | |
193 | if (output_type[0] == 'W') { | |
194 | display = DB_WORD_DISPLAY; | |
195 | } else if (output_type[0] == 'D') { | |
196 | display = DB_DWORD_DISPLAY; | |
197 | } else if (output_type[0] == 'Q') { | |
198 | display = DB_QWORD_DISPLAY; | |
199 | } | |
200 | } | |
201 | ||
202 | ret_buf.length = sizeof(buffer); | |
203 | ret_buf.pointer = buffer; | |
204 | ||
205 | /* Differentiate between a number and a name */ | |
206 | ||
207 | if ((target[0] >= 0x30) && (target[0] <= 0x39)) { | |
208 | obj_ptr = acpi_db_get_pointer(target); | |
209 | if (!acpi_os_readable(obj_ptr, 16)) { | |
210 | acpi_os_printf | |
211 | ("Address %p is invalid in this address space\n", | |
212 | obj_ptr); | |
213 | return; | |
214 | } | |
215 | ||
216 | /* Decode the object type */ | |
217 | ||
218 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)) { | |
219 | case ACPI_DESC_TYPE_NAMED: | |
220 | ||
221 | /* This is a namespace Node */ | |
222 | ||
223 | if (!acpi_os_readable | |
224 | (obj_ptr, sizeof(struct acpi_namespace_node))) { | |
225 | acpi_os_printf | |
226 | ("Cannot read entire Named object at address %p\n", | |
227 | obj_ptr); | |
228 | return; | |
229 | } | |
230 | ||
231 | node = obj_ptr; | |
232 | goto dump_node; | |
233 | ||
234 | case ACPI_DESC_TYPE_OPERAND: | |
235 | ||
236 | /* This is a ACPI OPERAND OBJECT */ | |
237 | ||
238 | if (!acpi_os_readable | |
239 | (obj_ptr, sizeof(union acpi_operand_object))) { | |
240 | acpi_os_printf | |
241 | ("Cannot read entire ACPI object at address %p\n", | |
242 | obj_ptr); | |
243 | return; | |
244 | } | |
245 | ||
246 | acpi_ut_debug_dump_buffer(obj_ptr, | |
247 | sizeof(union | |
248 | acpi_operand_object), | |
249 | display, ACPI_UINT32_MAX); | |
250 | acpi_ex_dump_object_descriptor(obj_ptr, 1); | |
251 | break; | |
252 | ||
253 | case ACPI_DESC_TYPE_PARSER: | |
254 | ||
255 | /* This is a Parser Op object */ | |
256 | ||
257 | if (!acpi_os_readable | |
258 | (obj_ptr, sizeof(union acpi_parse_object))) { | |
259 | acpi_os_printf | |
260 | ("Cannot read entire Parser object at address %p\n", | |
261 | obj_ptr); | |
262 | return; | |
263 | } | |
264 | ||
265 | acpi_ut_debug_dump_buffer(obj_ptr, | |
266 | sizeof(union | |
267 | acpi_parse_object), | |
268 | display, ACPI_UINT32_MAX); | |
269 | acpi_db_dump_parser_descriptor((union acpi_parse_object | |
270 | *)obj_ptr); | |
271 | break; | |
272 | ||
273 | default: | |
274 | ||
275 | /* Is not a recognizeable object */ | |
276 | ||
277 | acpi_os_printf | |
278 | ("Not a known ACPI internal object, descriptor type %2.2X\n", | |
279 | ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)); | |
280 | ||
281 | size = 16; | |
282 | if (acpi_os_readable(obj_ptr, 64)) { | |
283 | size = 64; | |
284 | } | |
285 | ||
286 | /* Just dump some memory */ | |
287 | ||
288 | acpi_ut_debug_dump_buffer(obj_ptr, size, display, | |
289 | ACPI_UINT32_MAX); | |
290 | break; | |
291 | } | |
292 | ||
293 | return; | |
294 | } | |
295 | ||
296 | /* The parameter is a name string that must be resolved to a Named obj */ | |
297 | ||
298 | node = acpi_db_local_ns_lookup(target); | |
299 | if (!node) { | |
300 | return; | |
301 | } | |
302 | ||
303 | dump_node: | |
304 | /* Now dump the NS node */ | |
305 | ||
306 | status = acpi_get_name(node, ACPI_FULL_PATHNAME_NO_TRAILING, &ret_buf); | |
307 | if (ACPI_FAILURE(status)) { | |
308 | acpi_os_printf("Could not convert name to pathname\n"); | |
309 | } | |
310 | ||
311 | else { | |
312 | acpi_os_printf("Object (%p) Pathname: %s\n", | |
313 | node, (char *)ret_buf.pointer); | |
314 | } | |
315 | ||
316 | if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) { | |
317 | acpi_os_printf("Invalid Named object at address %p\n", node); | |
318 | return; | |
319 | } | |
320 | ||
321 | acpi_ut_debug_dump_buffer((void *)node, | |
322 | sizeof(struct acpi_namespace_node), display, | |
323 | ACPI_UINT32_MAX); | |
324 | acpi_ex_dump_namespace_node(node, 1); | |
325 | ||
326 | obj_desc = acpi_ns_get_attached_object(node); | |
327 | if (obj_desc) { | |
328 | acpi_os_printf("\nAttached Object (%p):\n", obj_desc); | |
329 | if (!acpi_os_readable | |
330 | (obj_desc, sizeof(union acpi_operand_object))) { | |
331 | acpi_os_printf | |
332 | ("Invalid internal ACPI Object at address %p\n", | |
333 | obj_desc); | |
334 | return; | |
335 | } | |
336 | ||
337 | acpi_ut_debug_dump_buffer((void *)obj_desc, | |
338 | sizeof(union acpi_operand_object), | |
339 | display, ACPI_UINT32_MAX); | |
340 | acpi_ex_dump_object_descriptor(obj_desc, 1); | |
341 | } | |
342 | } | |
343 | ||
344 | /******************************************************************************* | |
345 | * | |
346 | * FUNCTION: acpi_db_display_method_info | |
347 | * | |
348 | * PARAMETERS: start_op - Root of the control method parse tree | |
349 | * | |
350 | * RETURN: None | |
351 | * | |
352 | * DESCRIPTION: Display information about the current method | |
353 | * | |
354 | ******************************************************************************/ | |
355 | ||
356 | void acpi_db_display_method_info(union acpi_parse_object *start_op) | |
357 | { | |
358 | struct acpi_walk_state *walk_state; | |
359 | union acpi_operand_object *obj_desc; | |
360 | struct acpi_namespace_node *node; | |
361 | union acpi_parse_object *root_op; | |
362 | union acpi_parse_object *op; | |
363 | const struct acpi_opcode_info *op_info; | |
364 | u32 num_ops = 0; | |
365 | u32 num_operands = 0; | |
366 | u32 num_operators = 0; | |
367 | u32 num_remaining_ops = 0; | |
368 | u32 num_remaining_operands = 0; | |
369 | u32 num_remaining_operators = 0; | |
370 | u8 count_remaining = FALSE; | |
371 | ||
372 | walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list); | |
373 | if (!walk_state) { | |
374 | acpi_os_printf("There is no method currently executing\n"); | |
375 | return; | |
376 | } | |
377 | ||
378 | obj_desc = walk_state->method_desc; | |
379 | node = walk_state->method_node; | |
380 | ||
381 | acpi_os_printf("Currently executing control method is [%4.4s]\n", | |
382 | acpi_ut_get_node_name(node)); | |
383 | acpi_os_printf("%X Arguments, SyncLevel = %X\n", | |
384 | (u32)obj_desc->method.param_count, | |
385 | (u32)obj_desc->method.sync_level); | |
386 | ||
387 | root_op = start_op; | |
388 | while (root_op->common.parent) { | |
389 | root_op = root_op->common.parent; | |
390 | } | |
391 | ||
392 | op = root_op; | |
393 | ||
394 | while (op) { | |
395 | if (op == start_op) { | |
396 | count_remaining = TRUE; | |
397 | } | |
398 | ||
399 | num_ops++; | |
400 | if (count_remaining) { | |
401 | num_remaining_ops++; | |
402 | } | |
403 | ||
404 | /* Decode the opcode */ | |
405 | ||
406 | op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); | |
407 | switch (op_info->class) { | |
408 | case AML_CLASS_ARGUMENT: | |
409 | ||
410 | if (count_remaining) { | |
411 | num_remaining_operands++; | |
412 | } | |
413 | ||
414 | num_operands++; | |
415 | break; | |
416 | ||
417 | case AML_CLASS_UNKNOWN: | |
418 | ||
419 | /* Bad opcode or ASCII character */ | |
420 | ||
421 | continue; | |
422 | ||
423 | default: | |
424 | ||
425 | if (count_remaining) { | |
426 | num_remaining_operators++; | |
427 | } | |
428 | ||
429 | num_operators++; | |
430 | break; | |
431 | } | |
432 | ||
433 | op = acpi_ps_get_depth_next(start_op, op); | |
434 | } | |
435 | ||
436 | acpi_os_printf | |
437 | ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n", | |
438 | num_ops, num_operators, num_operands); | |
439 | ||
440 | acpi_os_printf | |
441 | ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", | |
442 | num_remaining_ops, num_remaining_operators, | |
443 | num_remaining_operands); | |
444 | } | |
445 | ||
446 | /******************************************************************************* | |
447 | * | |
448 | * FUNCTION: acpi_db_display_locals | |
449 | * | |
450 | * PARAMETERS: None | |
451 | * | |
452 | * RETURN: None | |
453 | * | |
454 | * DESCRIPTION: Display all locals for the currently running control method | |
455 | * | |
456 | ******************************************************************************/ | |
457 | ||
458 | void acpi_db_display_locals(void) | |
459 | { | |
460 | struct acpi_walk_state *walk_state; | |
461 | ||
462 | walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list); | |
463 | if (!walk_state) { | |
464 | acpi_os_printf("There is no method currently executing\n"); | |
465 | return; | |
466 | } | |
467 | ||
468 | acpi_db_decode_locals(walk_state); | |
469 | } | |
470 | ||
471 | /******************************************************************************* | |
472 | * | |
473 | * FUNCTION: acpi_db_display_arguments | |
474 | * | |
475 | * PARAMETERS: None | |
476 | * | |
477 | * RETURN: None | |
478 | * | |
479 | * DESCRIPTION: Display all arguments for the currently running control method | |
480 | * | |
481 | ******************************************************************************/ | |
482 | ||
483 | void acpi_db_display_arguments(void) | |
484 | { | |
485 | struct acpi_walk_state *walk_state; | |
486 | ||
487 | walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list); | |
488 | if (!walk_state) { | |
489 | acpi_os_printf("There is no method currently executing\n"); | |
490 | return; | |
491 | } | |
492 | ||
493 | acpi_db_decode_arguments(walk_state); | |
494 | } | |
495 | ||
496 | /******************************************************************************* | |
497 | * | |
498 | * FUNCTION: acpi_db_display_results | |
499 | * | |
500 | * PARAMETERS: None | |
501 | * | |
502 | * RETURN: None | |
503 | * | |
504 | * DESCRIPTION: Display current contents of a method result stack | |
505 | * | |
506 | ******************************************************************************/ | |
507 | ||
508 | void acpi_db_display_results(void) | |
509 | { | |
510 | u32 i; | |
511 | struct acpi_walk_state *walk_state; | |
512 | union acpi_operand_object *obj_desc; | |
513 | u32 result_count = 0; | |
514 | struct acpi_namespace_node *node; | |
515 | union acpi_generic_state *frame; | |
516 | u32 index; /* Index onto current frame */ | |
517 | ||
518 | walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list); | |
519 | if (!walk_state) { | |
520 | acpi_os_printf("There is no method currently executing\n"); | |
521 | return; | |
522 | } | |
523 | ||
524 | obj_desc = walk_state->method_desc; | |
525 | node = walk_state->method_node; | |
526 | ||
527 | if (walk_state->results) { | |
528 | result_count = walk_state->result_count; | |
529 | } | |
530 | ||
531 | acpi_os_printf("Method [%4.4s] has %X stacked result objects\n", | |
532 | acpi_ut_get_node_name(node), result_count); | |
533 | ||
534 | /* From the top element of result stack */ | |
535 | ||
536 | frame = walk_state->results; | |
537 | index = (result_count - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; | |
538 | ||
539 | for (i = 0; i < result_count; i++) { | |
540 | obj_desc = frame->results.obj_desc[index]; | |
541 | acpi_os_printf("Result%u: ", i); | |
542 | acpi_db_display_internal_object(obj_desc, walk_state); | |
543 | ||
544 | if (index == 0) { | |
545 | frame = frame->results.next; | |
546 | index = ACPI_RESULTS_FRAME_OBJ_NUM; | |
547 | } | |
548 | ||
549 | index--; | |
550 | } | |
551 | } | |
552 | ||
553 | /******************************************************************************* | |
554 | * | |
555 | * FUNCTION: acpi_db_display_calling_tree | |
556 | * | |
557 | * PARAMETERS: None | |
558 | * | |
559 | * RETURN: None | |
560 | * | |
561 | * DESCRIPTION: Display current calling tree of nested control methods | |
562 | * | |
563 | ******************************************************************************/ | |
564 | ||
565 | void acpi_db_display_calling_tree(void) | |
566 | { | |
567 | struct acpi_walk_state *walk_state; | |
568 | struct acpi_namespace_node *node; | |
569 | ||
570 | walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list); | |
571 | if (!walk_state) { | |
572 | acpi_os_printf("There is no method currently executing\n"); | |
573 | return; | |
574 | } | |
575 | ||
576 | node = walk_state->method_node; | |
577 | acpi_os_printf("Current Control Method Call Tree\n"); | |
578 | ||
579 | while (walk_state) { | |
580 | node = walk_state->method_node; | |
581 | acpi_os_printf(" [%4.4s]\n", acpi_ut_get_node_name(node)); | |
582 | ||
583 | walk_state = walk_state->next; | |
584 | } | |
585 | } | |
586 | ||
587 | /******************************************************************************* | |
588 | * | |
589 | * FUNCTION: acpi_db_display_object_type | |
590 | * | |
07cb390f | 591 | * PARAMETERS: object_arg - User entered NS node handle |
99575102 LZ |
592 | * |
593 | * RETURN: None | |
594 | * | |
595 | * DESCRIPTION: Display type of an arbitrary NS node | |
596 | * | |
597 | ******************************************************************************/ | |
598 | ||
07cb390f | 599 | void acpi_db_display_object_type(char *object_arg) |
99575102 | 600 | { |
07cb390f | 601 | acpi_handle handle; |
99575102 LZ |
602 | struct acpi_device_info *info; |
603 | acpi_status status; | |
604 | u32 i; | |
605 | ||
07cb390f | 606 | handle = ACPI_TO_POINTER(strtoul(object_arg, NULL, 16)); |
99575102 | 607 | |
07cb390f | 608 | status = acpi_get_object_info(handle, &info); |
99575102 LZ |
609 | if (ACPI_FAILURE(status)) { |
610 | acpi_os_printf("Could not get object info, %s\n", | |
611 | acpi_format_exception(status)); | |
612 | return; | |
613 | } | |
614 | ||
07cb390f BM |
615 | acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", |
616 | ACPI_FORMAT_UINT64(info->address), | |
617 | info->current_status, info->flags); | |
618 | ||
619 | acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", | |
620 | info->highest_dstates[0], info->highest_dstates[1], | |
621 | info->highest_dstates[2], info->highest_dstates[3]); | |
622 | ||
623 | acpi_os_printf("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", | |
624 | info->lowest_dstates[0], info->lowest_dstates[1], | |
625 | info->lowest_dstates[2], info->lowest_dstates[3], | |
626 | info->lowest_dstates[4]); | |
99575102 LZ |
627 | |
628 | if (info->valid & ACPI_VALID_HID) { | |
629 | acpi_os_printf("HID: %s\n", info->hardware_id.string); | |
630 | } | |
631 | ||
632 | if (info->valid & ACPI_VALID_UID) { | |
633 | acpi_os_printf("UID: %s\n", info->unique_id.string); | |
634 | } | |
635 | ||
99575102 LZ |
636 | if (info->valid & ACPI_VALID_CID) { |
637 | for (i = 0; i < info->compatible_id_list.count; i++) { | |
638 | acpi_os_printf("CID %u: %s\n", i, | |
639 | info->compatible_id_list.ids[i].string); | |
640 | } | |
641 | } | |
642 | ||
643 | ACPI_FREE(info); | |
644 | } | |
645 | ||
646 | /******************************************************************************* | |
647 | * | |
648 | * FUNCTION: acpi_db_display_result_object | |
649 | * | |
650 | * PARAMETERS: obj_desc - Object to be displayed | |
651 | * walk_state - Current walk state | |
652 | * | |
653 | * RETURN: None | |
654 | * | |
655 | * DESCRIPTION: Display the result of an AML opcode | |
656 | * | |
657 | * Note: Curently only displays the result object if we are single stepping. | |
658 | * However, this output may be useful in other contexts and could be enabled | |
659 | * to do so if needed. | |
660 | * | |
661 | ******************************************************************************/ | |
662 | ||
663 | void | |
664 | acpi_db_display_result_object(union acpi_operand_object *obj_desc, | |
665 | struct acpi_walk_state *walk_state) | |
666 | { | |
667 | ||
8a2a2501 LZ |
668 | #ifndef ACPI_APPLICATION |
669 | if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) { | |
670 | return; | |
671 | } | |
672 | #endif | |
673 | ||
99575102 LZ |
674 | /* Only display if single stepping */ |
675 | ||
676 | if (!acpi_gbl_cm_single_step) { | |
677 | return; | |
678 | } | |
679 | ||
680 | acpi_os_printf("ResultObj: "); | |
681 | acpi_db_display_internal_object(obj_desc, walk_state); | |
682 | acpi_os_printf("\n"); | |
683 | } | |
684 | ||
685 | /******************************************************************************* | |
686 | * | |
687 | * FUNCTION: acpi_db_display_argument_object | |
688 | * | |
689 | * PARAMETERS: obj_desc - Object to be displayed | |
690 | * walk_state - Current walk state | |
691 | * | |
692 | * RETURN: None | |
693 | * | |
694 | * DESCRIPTION: Display the result of an AML opcode | |
695 | * | |
696 | ******************************************************************************/ | |
697 | ||
698 | void | |
699 | acpi_db_display_argument_object(union acpi_operand_object *obj_desc, | |
700 | struct acpi_walk_state *walk_state) | |
701 | { | |
702 | ||
8a2a2501 LZ |
703 | #ifndef ACPI_APPLICATION |
704 | if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) { | |
705 | return; | |
706 | } | |
707 | #endif | |
708 | ||
99575102 LZ |
709 | if (!acpi_gbl_cm_single_step) { |
710 | return; | |
711 | } | |
712 | ||
713 | acpi_os_printf("ArgObj: "); | |
714 | acpi_db_display_internal_object(obj_desc, walk_state); | |
715 | } | |
716 | ||
717 | #if (!ACPI_REDUCED_HARDWARE) | |
718 | /******************************************************************************* | |
719 | * | |
720 | * FUNCTION: acpi_db_display_gpes | |
721 | * | |
722 | * PARAMETERS: None | |
723 | * | |
724 | * RETURN: None | |
725 | * | |
726 | * DESCRIPTION: Display the current GPE structures | |
727 | * | |
728 | ******************************************************************************/ | |
729 | ||
730 | void acpi_db_display_gpes(void) | |
731 | { | |
732 | struct acpi_gpe_block_info *gpe_block; | |
733 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | |
734 | struct acpi_gpe_event_info *gpe_event_info; | |
735 | struct acpi_gpe_register_info *gpe_register_info; | |
736 | char *gpe_type; | |
737 | struct acpi_gpe_notify_info *notify; | |
738 | u32 gpe_index; | |
739 | u32 block = 0; | |
740 | u32 i; | |
741 | u32 j; | |
742 | u32 count; | |
743 | char buffer[80]; | |
744 | struct acpi_buffer ret_buf; | |
745 | acpi_status status; | |
746 | ||
747 | ret_buf.length = sizeof(buffer); | |
748 | ret_buf.pointer = buffer; | |
749 | ||
750 | block = 0; | |
751 | ||
752 | /* Walk the GPE lists */ | |
753 | ||
754 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | |
755 | while (gpe_xrupt_info) { | |
756 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | |
757 | while (gpe_block) { | |
758 | status = acpi_get_name(gpe_block->node, | |
759 | ACPI_FULL_PATHNAME_NO_TRAILING, | |
760 | &ret_buf); | |
761 | if (ACPI_FAILURE(status)) { | |
762 | acpi_os_printf | |
763 | ("Could not convert name to pathname\n"); | |
764 | } | |
765 | ||
766 | if (gpe_block->node == acpi_gbl_fadt_gpe_device) { | |
767 | gpe_type = "FADT-defined GPE block"; | |
768 | } else { | |
769 | gpe_type = "GPE Block Device"; | |
770 | } | |
771 | ||
772 | acpi_os_printf | |
773 | ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", | |
774 | block, gpe_block, gpe_block->node, buffer, | |
775 | gpe_type); | |
776 | ||
777 | acpi_os_printf(" Registers: %u (%u GPEs)\n", | |
778 | gpe_block->register_count, | |
779 | gpe_block->gpe_count); | |
780 | ||
781 | acpi_os_printf | |
782 | (" GPE range: 0x%X to 0x%X on interrupt %u\n", | |
783 | gpe_block->block_base_number, | |
784 | gpe_block->block_base_number + | |
785 | (gpe_block->gpe_count - 1), | |
786 | gpe_xrupt_info->interrupt_number); | |
787 | ||
788 | acpi_os_printf | |
789 | (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", | |
790 | gpe_block->register_info, | |
791 | ACPI_FORMAT_UINT64(gpe_block->register_info-> | |
792 | status_address.address), | |
793 | ACPI_FORMAT_UINT64(gpe_block->register_info-> | |
794 | enable_address.address)); | |
795 | ||
796 | acpi_os_printf(" EventInfo: %p\n", | |
797 | gpe_block->event_info); | |
798 | ||
799 | /* Examine each GPE Register within the block */ | |
800 | ||
801 | for (i = 0; i < gpe_block->register_count; i++) { | |
802 | gpe_register_info = | |
803 | &gpe_block->register_info[i]; | |
804 | ||
805 | acpi_os_printf(" Reg %u: (GPE %.2X-%.2X) " | |
806 | "RunEnable %2.2X WakeEnable %2.2X" | |
807 | " Status %8.8X%8.8X Enable %8.8X%8.8X\n", | |
808 | i, | |
809 | gpe_register_info-> | |
810 | base_gpe_number, | |
811 | gpe_register_info-> | |
812 | base_gpe_number + | |
813 | (ACPI_GPE_REGISTER_WIDTH - 1), | |
814 | gpe_register_info-> | |
815 | enable_for_run, | |
816 | gpe_register_info-> | |
817 | enable_for_wake, | |
818 | ACPI_FORMAT_UINT64 | |
819 | (gpe_register_info-> | |
820 | status_address.address), | |
821 | ACPI_FORMAT_UINT64 | |
822 | (gpe_register_info-> | |
823 | enable_address.address)); | |
824 | ||
825 | /* Now look at the individual GPEs in this byte register */ | |
826 | ||
827 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | |
828 | gpe_index = | |
829 | (i * ACPI_GPE_REGISTER_WIDTH) + j; | |
830 | gpe_event_info = | |
831 | &gpe_block->event_info[gpe_index]; | |
832 | ||
833 | if (ACPI_GPE_DISPATCH_TYPE | |
834 | (gpe_event_info->flags) == | |
835 | ACPI_GPE_DISPATCH_NONE) { | |
836 | ||
837 | /* This GPE is not used (no method or handler), ignore it */ | |
838 | ||
839 | continue; | |
840 | } | |
841 | ||
842 | acpi_os_printf | |
843 | (" GPE %.2X: %p RunRefs %2.2X Flags %2.2X (", | |
844 | gpe_block->block_base_number + | |
845 | gpe_index, gpe_event_info, | |
846 | gpe_event_info->runtime_count, | |
847 | gpe_event_info->flags); | |
848 | ||
849 | /* Decode the flags byte */ | |
850 | ||
851 | if (gpe_event_info-> | |
852 | flags & ACPI_GPE_LEVEL_TRIGGERED) { | |
853 | acpi_os_printf("Level, "); | |
854 | } else { | |
855 | acpi_os_printf("Edge, "); | |
856 | } | |
857 | ||
858 | if (gpe_event_info-> | |
859 | flags & ACPI_GPE_CAN_WAKE) { | |
860 | acpi_os_printf("CanWake, "); | |
861 | } else { | |
862 | acpi_os_printf("RunOnly, "); | |
863 | } | |
864 | ||
865 | switch (ACPI_GPE_DISPATCH_TYPE | |
866 | (gpe_event_info->flags)) { | |
867 | case ACPI_GPE_DISPATCH_NONE: | |
868 | ||
869 | acpi_os_printf("NotUsed"); | |
870 | break; | |
871 | ||
872 | case ACPI_GPE_DISPATCH_METHOD: | |
873 | ||
874 | acpi_os_printf("Method"); | |
875 | break; | |
876 | ||
877 | case ACPI_GPE_DISPATCH_HANDLER: | |
878 | ||
879 | acpi_os_printf("Handler"); | |
880 | break; | |
881 | ||
882 | case ACPI_GPE_DISPATCH_NOTIFY: | |
883 | ||
884 | count = 0; | |
885 | notify = | |
886 | gpe_event_info->dispatch. | |
887 | notify_list; | |
888 | while (notify) { | |
889 | count++; | |
890 | notify = notify->next; | |
891 | } | |
892 | ||
893 | acpi_os_printf | |
894 | ("Implicit Notify on %u devices", | |
895 | count); | |
896 | break; | |
897 | ||
898 | case ACPI_GPE_DISPATCH_RAW_HANDLER: | |
899 | ||
900 | acpi_os_printf("RawHandler"); | |
901 | break; | |
902 | ||
903 | default: | |
904 | ||
905 | acpi_os_printf("UNKNOWN: %X", | |
906 | ACPI_GPE_DISPATCH_TYPE | |
907 | (gpe_event_info-> | |
908 | flags)); | |
909 | break; | |
910 | } | |
911 | ||
912 | acpi_os_printf(")\n"); | |
913 | } | |
914 | } | |
915 | ||
916 | block++; | |
917 | gpe_block = gpe_block->next; | |
918 | } | |
919 | ||
920 | gpe_xrupt_info = gpe_xrupt_info->next; | |
921 | } | |
922 | } | |
923 | #endif /* !ACPI_REDUCED_HARDWARE */ | |
924 | ||
925 | /******************************************************************************* | |
926 | * | |
927 | * FUNCTION: acpi_db_display_handlers | |
928 | * | |
929 | * PARAMETERS: None | |
930 | * | |
931 | * RETURN: None | |
932 | * | |
933 | * DESCRIPTION: Display the currently installed global handlers | |
934 | * | |
935 | ******************************************************************************/ | |
936 | ||
937 | void acpi_db_display_handlers(void) | |
938 | { | |
939 | union acpi_operand_object *obj_desc; | |
940 | union acpi_operand_object *handler_obj; | |
941 | acpi_adr_space_type space_id; | |
942 | u32 i; | |
943 | ||
944 | /* Operation region handlers */ | |
945 | ||
946 | acpi_os_printf("\nOperation Region Handlers at the namespace root:\n"); | |
947 | ||
948 | obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node); | |
949 | if (obj_desc) { | |
950 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) { | |
951 | space_id = acpi_gbl_space_id_list[i]; | |
952 | handler_obj = obj_desc->device.handler; | |
953 | ||
954 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, | |
955 | acpi_ut_get_region_name((u8)space_id), | |
956 | space_id); | |
957 | ||
958 | while (handler_obj) { | |
959 | if (acpi_gbl_space_id_list[i] == | |
960 | handler_obj->address_space.space_id) { | |
961 | acpi_os_printf | |
962 | (ACPI_HANDLER_PRESENT_STRING, | |
963 | (handler_obj->address_space. | |
964 | handler_flags & | |
965 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) | |
966 | ? "Default" : "User", | |
967 | handler_obj->address_space. | |
968 | handler); | |
969 | ||
970 | goto found_handler; | |
971 | } | |
972 | ||
973 | handler_obj = handler_obj->address_space.next; | |
974 | } | |
975 | ||
976 | /* There is no handler for this space_id */ | |
977 | ||
978 | acpi_os_printf("None\n"); | |
979 | ||
980 | found_handler: ; | |
981 | } | |
982 | ||
983 | /* Find all handlers for user-defined space_IDs */ | |
984 | ||
985 | handler_obj = obj_desc->device.handler; | |
986 | while (handler_obj) { | |
987 | if (handler_obj->address_space.space_id >= | |
988 | ACPI_USER_REGION_BEGIN) { | |
989 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, | |
990 | "User-defined ID", | |
991 | handler_obj->address_space. | |
992 | space_id); | |
993 | acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, | |
994 | (handler_obj->address_space. | |
995 | handler_flags & | |
996 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) | |
997 | ? "Default" : "User", | |
998 | handler_obj->address_space. | |
999 | handler); | |
1000 | } | |
1001 | ||
1002 | handler_obj = handler_obj->address_space.next; | |
1003 | } | |
1004 | } | |
1005 | #if (!ACPI_REDUCED_HARDWARE) | |
1006 | ||
1007 | /* Fixed event handlers */ | |
1008 | ||
1009 | acpi_os_printf("\nFixed Event Handlers:\n"); | |
1010 | ||
1011 | for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { | |
1012 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, | |
1013 | acpi_ut_get_event_name(i), i); | |
1014 | if (acpi_gbl_fixed_event_handlers[i].handler) { | |
1015 | acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User", | |
1016 | acpi_gbl_fixed_event_handlers[i]. | |
1017 | handler); | |
1018 | } else { | |
1019 | acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None"); | |
1020 | } | |
1021 | } | |
1022 | ||
1023 | #endif /* !ACPI_REDUCED_HARDWARE */ | |
1024 | ||
1025 | /* Miscellaneous global handlers */ | |
1026 | ||
1027 | acpi_os_printf("\nMiscellaneous Global Handlers:\n"); | |
1028 | ||
1029 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) { | |
1030 | acpi_os_printf(ACPI_HANDLER_NAME_STRING, | |
1031 | acpi_gbl_handler_list[i].name); | |
1032 | ||
1033 | if (acpi_gbl_handler_list[i].handler) { | |
1034 | acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User", | |
1035 | acpi_gbl_handler_list[i].handler); | |
1036 | } else { | |
1037 | acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None"); | |
1038 | } | |
1039 | } | |
1040 | ||
1041 | /* Other handlers that are installed throughout the namespace */ | |
1042 | ||
1043 | acpi_os_printf("\nOperation Region Handlers for specific devices:\n"); | |
1044 | ||
1045 | (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | |
1046 | ACPI_UINT32_MAX, | |
1047 | acpi_db_display_non_root_handlers, NULL, NULL, | |
1048 | NULL); | |
1049 | } | |
1050 | ||
1051 | /******************************************************************************* | |
1052 | * | |
1053 | * FUNCTION: acpi_db_display_non_root_handlers | |
1054 | * | |
1055 | * PARAMETERS: acpi_walk_callback | |
1056 | * | |
1057 | * RETURN: Status | |
1058 | * | |
1059 | * DESCRIPTION: Display information about all handlers installed for a | |
1060 | * device object. | |
1061 | * | |
1062 | ******************************************************************************/ | |
1063 | ||
1064 | static acpi_status | |
1065 | acpi_db_display_non_root_handlers(acpi_handle obj_handle, | |
1066 | u32 nesting_level, | |
1067 | void *context, void **return_value) | |
1068 | { | |
1069 | struct acpi_namespace_node *node = | |
1070 | ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle); | |
1071 | union acpi_operand_object *obj_desc; | |
1072 | union acpi_operand_object *handler_obj; | |
1073 | char *pathname; | |
1074 | ||
1075 | obj_desc = acpi_ns_get_attached_object(node); | |
1076 | if (!obj_desc) { | |
1077 | return (AE_OK); | |
1078 | } | |
1079 | ||
0e166e4f | 1080 | pathname = acpi_ns_get_normalized_pathname(node, TRUE); |
99575102 LZ |
1081 | if (!pathname) { |
1082 | return (AE_OK); | |
1083 | } | |
1084 | ||
1085 | /* Display all handlers associated with this device */ | |
1086 | ||
1087 | handler_obj = obj_desc->device.handler; | |
1088 | while (handler_obj) { | |
1089 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, | |
1090 | acpi_ut_get_region_name((u8)handler_obj-> | |
1091 | address_space.space_id), | |
1092 | handler_obj->address_space.space_id); | |
1093 | ||
1094 | acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2, | |
1095 | (handler_obj->address_space.handler_flags & | |
1096 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" | |
1097 | : "User", handler_obj->address_space.handler); | |
1098 | ||
1099 | acpi_os_printf(" Device Name: %s (%p)\n", pathname, node); | |
1100 | ||
1101 | handler_obj = handler_obj->address_space.next; | |
1102 | } | |
1103 | ||
1104 | ACPI_FREE(pathname); | |
1105 | return (AE_OK); | |
1106 | } |