1 /*******************************************************************************
3 * Module Name: dbobject - ACPI object decode and display
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <acpi/acpi.h>
49 #define _COMPONENT ACPI_CA_DEBUGGER
50 ACPI_MODULE_NAME("dbobject")
52 /* Local prototypes */
53 static void acpi_db_decode_node(struct acpi_namespace_node
*node
);
55 /*******************************************************************************
57 * FUNCTION: acpi_db_dump_method_info
59 * PARAMETERS: status - Method execution status
60 * walk_state - Current state of the parse tree walk
64 * DESCRIPTION: Called when a method has been aborted because of an error.
65 * Dumps the method execution stack, and the method locals/args,
66 * and disassembles the AML opcode that failed.
68 ******************************************************************************/
71 acpi_db_dump_method_info(acpi_status status
, struct acpi_walk_state
*walk_state
)
73 struct acpi_thread_state
*thread
;
75 /* Ignore control codes, they are not errors */
77 if ((status
& AE_CODE_MASK
) == AE_CODE_CONTROL
) {
81 /* We may be executing a deferred opcode */
83 if (walk_state
->deferred_node
) {
84 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
89 * If there is no Thread, we are not actually executing a method.
90 * This can happen when the iASL compiler calls the interpreter
91 * to perform constant folding.
93 thread
= walk_state
->thread
;
98 /* Display the method locals and arguments */
100 acpi_os_printf("\n");
101 acpi_db_decode_locals(walk_state
);
102 acpi_os_printf("\n");
103 acpi_db_decode_arguments(walk_state
);
104 acpi_os_printf("\n");
107 /*******************************************************************************
109 * FUNCTION: acpi_db_decode_internal_object
111 * PARAMETERS: obj_desc - Object to be displayed
115 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
117 ******************************************************************************/
119 void acpi_db_decode_internal_object(union acpi_operand_object
*obj_desc
)
124 acpi_os_printf(" Uninitialized");
128 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc
) != ACPI_DESC_TYPE_OPERAND
) {
129 acpi_os_printf(" %p [%s]", obj_desc
,
130 acpi_ut_get_descriptor_name(obj_desc
));
134 acpi_os_printf(" %s", acpi_ut_get_object_type_name(obj_desc
));
136 switch (obj_desc
->common
.type
) {
137 case ACPI_TYPE_INTEGER
:
139 acpi_os_printf(" %8.8X%8.8X",
140 ACPI_FORMAT_UINT64(obj_desc
->integer
.value
));
143 case ACPI_TYPE_STRING
:
145 acpi_os_printf("(%u) \"%.24s",
146 obj_desc
->string
.length
,
147 obj_desc
->string
.pointer
);
149 if (obj_desc
->string
.length
> 24) {
150 acpi_os_printf("...");
152 acpi_os_printf("\"");
156 case ACPI_TYPE_BUFFER
:
158 acpi_os_printf("(%u)", obj_desc
->buffer
.length
);
159 for (i
= 0; (i
< 8) && (i
< obj_desc
->buffer
.length
); i
++) {
160 acpi_os_printf(" %2.2X", obj_desc
->buffer
.pointer
[i
]);
166 acpi_os_printf(" %p", obj_desc
);
171 /*******************************************************************************
173 * FUNCTION: acpi_db_decode_node
175 * PARAMETERS: node - Object to be displayed
179 * DESCRIPTION: Short display of a namespace node
181 ******************************************************************************/
183 static void acpi_db_decode_node(struct acpi_namespace_node
*node
)
186 acpi_os_printf("<Node> Name %4.4s",
187 acpi_ut_get_node_name(node
));
189 if (node
->flags
& ANOBJ_METHOD_ARG
) {
190 acpi_os_printf(" [Method Arg]");
192 if (node
->flags
& ANOBJ_METHOD_LOCAL
) {
193 acpi_os_printf(" [Method Local]");
196 switch (node
->type
) {
198 /* These types have no attached object */
200 case ACPI_TYPE_DEVICE
:
202 acpi_os_printf(" Device");
205 case ACPI_TYPE_THERMAL
:
207 acpi_os_printf(" Thermal Zone");
212 acpi_db_decode_internal_object(acpi_ns_get_attached_object
218 /*******************************************************************************
220 * FUNCTION: acpi_db_display_internal_object
222 * PARAMETERS: obj_desc - Object to be displayed
223 * walk_state - Current walk state
227 * DESCRIPTION: Short display of an internal object
229 ******************************************************************************/
232 acpi_db_display_internal_object(union acpi_operand_object
*obj_desc
,
233 struct acpi_walk_state
*walk_state
)
237 acpi_os_printf("%p ", obj_desc
);
240 acpi_os_printf("<Null Object>\n");
244 /* Decode the object type */
246 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc
)) {
247 case ACPI_DESC_TYPE_PARSER
:
249 acpi_os_printf("<Parser> ");
252 case ACPI_DESC_TYPE_NAMED
:
254 acpi_db_decode_node((struct acpi_namespace_node
*)obj_desc
);
257 case ACPI_DESC_TYPE_OPERAND
:
259 type
= obj_desc
->common
.type
;
260 if (type
> ACPI_TYPE_LOCAL_MAX
) {
261 acpi_os_printf(" Type %X [Invalid Type]", (u32
)type
);
265 /* Decode the ACPI object type */
267 switch (obj_desc
->common
.type
) {
268 case ACPI_TYPE_LOCAL_REFERENCE
:
270 acpi_os_printf("[%s] ",
271 acpi_ut_get_reference_name(obj_desc
));
273 /* Decode the refererence */
275 switch (obj_desc
->reference
.class) {
276 case ACPI_REFCLASS_LOCAL
:
278 acpi_os_printf("%X ",
279 obj_desc
->reference
.value
);
281 obj_desc
= walk_state
->local_variables
282 [obj_desc
->reference
.value
].object
;
283 acpi_os_printf("%p", obj_desc
);
284 acpi_db_decode_internal_object
289 case ACPI_REFCLASS_ARG
:
291 acpi_os_printf("%X ",
292 obj_desc
->reference
.value
);
294 obj_desc
= walk_state
->arguments
295 [obj_desc
->reference
.value
].object
;
296 acpi_os_printf("%p", obj_desc
);
297 acpi_db_decode_internal_object
302 case ACPI_REFCLASS_INDEX
:
304 switch (obj_desc
->reference
.target_type
) {
305 case ACPI_TYPE_BUFFER_FIELD
:
310 acpi_db_decode_internal_object
311 (obj_desc
->reference
.object
);
314 case ACPI_TYPE_PACKAGE
:
319 if (!obj_desc
->reference
.where
) {
321 (" Uninitialized WHERE pointer");
323 acpi_db_decode_internal_object(*
333 ("Unknown index target type");
338 case ACPI_REFCLASS_REFOF
:
340 if (!obj_desc
->reference
.object
) {
342 ("Uninitialized reference subobject pointer");
346 /* Reference can be to a Node or an Operand object */
348 switch (ACPI_GET_DESCRIPTOR_TYPE
349 (obj_desc
->reference
.object
)) {
350 case ACPI_DESC_TYPE_NAMED
:
352 acpi_db_decode_node(obj_desc
->reference
.
356 case ACPI_DESC_TYPE_OPERAND
:
358 acpi_db_decode_internal_object
359 (obj_desc
->reference
.object
);
367 case ACPI_REFCLASS_NAME
:
369 acpi_db_decode_node(obj_desc
->reference
.node
);
372 case ACPI_REFCLASS_DEBUG
:
373 case ACPI_REFCLASS_TABLE
:
375 acpi_os_printf("\n");
378 default: /* Unknown reference class */
380 acpi_os_printf("%2.2X\n",
381 obj_desc
->reference
.class);
388 acpi_os_printf("<Obj> ");
389 acpi_db_decode_internal_object(obj_desc
);
396 acpi_os_printf("<Not a valid ACPI Object Descriptor> [%s]",
397 acpi_ut_get_descriptor_name(obj_desc
));
401 acpi_os_printf("\n");
404 /*******************************************************************************
406 * FUNCTION: acpi_db_decode_locals
408 * PARAMETERS: walk_state - State for current method
412 * DESCRIPTION: Display all locals for the currently running control method
414 ******************************************************************************/
416 void acpi_db_decode_locals(struct acpi_walk_state
*walk_state
)
419 union acpi_operand_object
*obj_desc
;
420 struct acpi_namespace_node
*node
;
421 u8 display_locals
= FALSE
;
423 obj_desc
= walk_state
->method_desc
;
424 node
= walk_state
->method_node
;
428 ("No method node (Executing subtree for buffer or opregion)\n");
432 if (node
->type
!= ACPI_TYPE_METHOD
) {
433 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
437 /* Are any locals actually set? */
439 for (i
= 0; i
< ACPI_METHOD_NUM_LOCALS
; i
++) {
440 obj_desc
= walk_state
->local_variables
[i
].object
;
442 display_locals
= TRUE
;
447 /* If any are set, only display the ones that are set */
449 if (display_locals
) {
451 ("\nInitialized Local Variables for method [%4.4s]:\n",
452 acpi_ut_get_node_name(node
));
454 for (i
= 0; i
< ACPI_METHOD_NUM_LOCALS
; i
++) {
455 obj_desc
= walk_state
->local_variables
[i
].object
;
457 acpi_os_printf(" Local%X: ", i
);
458 acpi_db_display_internal_object(obj_desc
,
464 ("No Local Variables are initialized for method [%4.4s]\n",
465 acpi_ut_get_node_name(node
));
469 /*******************************************************************************
471 * FUNCTION: acpi_db_decode_arguments
473 * PARAMETERS: walk_state - State for current method
477 * DESCRIPTION: Display all arguments for the currently running control method
479 ******************************************************************************/
481 void acpi_db_decode_arguments(struct acpi_walk_state
*walk_state
)
484 union acpi_operand_object
*obj_desc
;
485 struct acpi_namespace_node
*node
;
486 u8 display_args
= FALSE
;
488 node
= walk_state
->method_node
;
489 obj_desc
= walk_state
->method_desc
;
493 ("No method node (Executing subtree for buffer or opregion)\n");
497 if (node
->type
!= ACPI_TYPE_METHOD
) {
498 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
502 /* Are any arguments actually set? */
504 for (i
= 0; i
< ACPI_METHOD_NUM_ARGS
; i
++) {
505 obj_desc
= walk_state
->arguments
[i
].object
;
512 /* If any are set, only display the ones that are set */
515 acpi_os_printf("Initialized Arguments for Method [%4.4s]: "
516 "(%X arguments defined for method invocation)\n",
517 acpi_ut_get_node_name(node
),
518 obj_desc
->method
.param_count
);
520 for (i
= 0; i
< ACPI_METHOD_NUM_ARGS
; i
++) {
521 obj_desc
= walk_state
->arguments
[i
].object
;
523 acpi_os_printf(" Arg%u: ", i
);
524 acpi_db_display_internal_object(obj_desc
,
530 ("No Arguments are initialized for method [%4.4s]\n",
531 acpi_ut_get_node_name(node
));