1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: dbobject - ACPI object decode and display
6 ******************************************************************************/
13 #define _COMPONENT ACPI_CA_DEBUGGER
14 ACPI_MODULE_NAME("dbobject")
16 /* Local prototypes */
17 static void acpi_db_decode_node(struct acpi_namespace_node
*node
);
19 /*******************************************************************************
21 * FUNCTION: acpi_db_dump_method_info
23 * PARAMETERS: status - Method execution status
24 * walk_state - Current state of the parse tree walk
28 * DESCRIPTION: Called when a method has been aborted because of an error.
29 * Dumps the method execution stack, and the method locals/args,
30 * and disassembles the AML opcode that failed.
32 ******************************************************************************/
35 acpi_db_dump_method_info(acpi_status status
, struct acpi_walk_state
*walk_state
)
37 struct acpi_thread_state
*thread
;
39 /* Ignore control codes, they are not errors */
41 if ((status
& AE_CODE_MASK
) == AE_CODE_CONTROL
) {
45 /* We may be executing a deferred opcode */
47 if (walk_state
->deferred_node
) {
48 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
53 * If there is no Thread, we are not actually executing a method.
54 * This can happen when the iASL compiler calls the interpreter
55 * to perform constant folding.
57 thread
= walk_state
->thread
;
62 /* Display the method locals and arguments */
65 acpi_db_decode_locals(walk_state
);
67 acpi_db_decode_arguments(walk_state
);
71 /*******************************************************************************
73 * FUNCTION: acpi_db_decode_internal_object
75 * PARAMETERS: obj_desc - Object to be displayed
79 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
81 ******************************************************************************/
83 void acpi_db_decode_internal_object(union acpi_operand_object
*obj_desc
)
88 acpi_os_printf(" Uninitialized");
92 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc
) != ACPI_DESC_TYPE_OPERAND
) {
93 acpi_os_printf(" %p [%s]", obj_desc
,
94 acpi_ut_get_descriptor_name(obj_desc
));
98 acpi_os_printf(" %s", acpi_ut_get_object_type_name(obj_desc
));
100 switch (obj_desc
->common
.type
) {
101 case ACPI_TYPE_INTEGER
:
103 acpi_os_printf(" %8.8X%8.8X",
104 ACPI_FORMAT_UINT64(obj_desc
->integer
.value
));
107 case ACPI_TYPE_STRING
:
109 acpi_os_printf("(%u) \"%.60s",
110 obj_desc
->string
.length
,
111 obj_desc
->string
.pointer
);
113 if (obj_desc
->string
.length
> 60) {
114 acpi_os_printf("...");
116 acpi_os_printf("\"");
120 case ACPI_TYPE_BUFFER
:
122 acpi_os_printf("(%u)", obj_desc
->buffer
.length
);
123 for (i
= 0; (i
< 8) && (i
< obj_desc
->buffer
.length
); i
++) {
124 acpi_os_printf(" %2.2X", obj_desc
->buffer
.pointer
[i
]);
130 acpi_os_printf(" %p", obj_desc
);
135 /*******************************************************************************
137 * FUNCTION: acpi_db_decode_node
139 * PARAMETERS: node - Object to be displayed
143 * DESCRIPTION: Short display of a namespace node
145 ******************************************************************************/
147 static void acpi_db_decode_node(struct acpi_namespace_node
*node
)
150 acpi_os_printf("<Node> Name %4.4s",
151 acpi_ut_get_node_name(node
));
153 if (node
->flags
& ANOBJ_METHOD_ARG
) {
154 acpi_os_printf(" [Method Arg]");
156 if (node
->flags
& ANOBJ_METHOD_LOCAL
) {
157 acpi_os_printf(" [Method Local]");
160 switch (node
->type
) {
162 /* These types have no attached object */
164 case ACPI_TYPE_DEVICE
:
166 acpi_os_printf(" Device");
169 case ACPI_TYPE_THERMAL
:
171 acpi_os_printf(" Thermal Zone");
176 acpi_db_decode_internal_object(acpi_ns_get_attached_object
182 /*******************************************************************************
184 * FUNCTION: acpi_db_display_internal_object
186 * PARAMETERS: obj_desc - Object to be displayed
187 * walk_state - Current walk state
191 * DESCRIPTION: Short display of an internal object
193 ******************************************************************************/
196 acpi_db_display_internal_object(union acpi_operand_object
*obj_desc
,
197 struct acpi_walk_state
*walk_state
)
201 acpi_os_printf("%p ", obj_desc
);
204 acpi_os_printf("<Null Object>\n");
208 /* Decode the object type */
210 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc
)) {
211 case ACPI_DESC_TYPE_PARSER
:
213 acpi_os_printf("<Parser> ");
216 case ACPI_DESC_TYPE_NAMED
:
218 acpi_db_decode_node((struct acpi_namespace_node
*)obj_desc
);
221 case ACPI_DESC_TYPE_OPERAND
:
223 type
= obj_desc
->common
.type
;
224 if (type
> ACPI_TYPE_LOCAL_MAX
) {
225 acpi_os_printf(" Type %X [Invalid Type]", (u32
)type
);
229 /* Decode the ACPI object type */
231 switch (obj_desc
->common
.type
) {
232 case ACPI_TYPE_LOCAL_REFERENCE
:
234 acpi_os_printf("[%s] ",
235 acpi_ut_get_reference_name(obj_desc
));
237 /* Decode the refererence */
239 switch (obj_desc
->reference
.class) {
240 case ACPI_REFCLASS_LOCAL
:
242 acpi_os_printf("%X ",
243 obj_desc
->reference
.value
);
245 obj_desc
= walk_state
->local_variables
246 [obj_desc
->reference
.value
].object
;
247 acpi_os_printf("%p", obj_desc
);
248 acpi_db_decode_internal_object
253 case ACPI_REFCLASS_ARG
:
255 acpi_os_printf("%X ",
256 obj_desc
->reference
.value
);
258 obj_desc
= walk_state
->arguments
259 [obj_desc
->reference
.value
].object
;
260 acpi_os_printf("%p", obj_desc
);
261 acpi_db_decode_internal_object
266 case ACPI_REFCLASS_INDEX
:
268 switch (obj_desc
->reference
.target_type
) {
269 case ACPI_TYPE_BUFFER_FIELD
:
274 acpi_db_decode_internal_object
275 (obj_desc
->reference
.object
);
278 case ACPI_TYPE_PACKAGE
:
283 if (!obj_desc
->reference
.where
) {
285 (" Uninitialized WHERE pointer");
287 acpi_db_decode_internal_object(*
297 ("Unknown index target type");
302 case ACPI_REFCLASS_REFOF
:
304 if (!obj_desc
->reference
.object
) {
306 ("Uninitialized reference subobject pointer");
310 /* Reference can be to a Node or an Operand object */
312 switch (ACPI_GET_DESCRIPTOR_TYPE
313 (obj_desc
->reference
.object
)) {
314 case ACPI_DESC_TYPE_NAMED
:
316 acpi_db_decode_node(obj_desc
->reference
.
320 case ACPI_DESC_TYPE_OPERAND
:
322 acpi_db_decode_internal_object
323 (obj_desc
->reference
.object
);
331 case ACPI_REFCLASS_NAME
:
333 acpi_db_decode_node(obj_desc
->reference
.node
);
336 case ACPI_REFCLASS_DEBUG
:
337 case ACPI_REFCLASS_TABLE
:
339 acpi_os_printf("\n");
342 default: /* Unknown reference class */
344 acpi_os_printf("%2.2X\n",
345 obj_desc
->reference
.class);
352 acpi_os_printf("<Obj> ");
353 acpi_db_decode_internal_object(obj_desc
);
360 acpi_os_printf("<Not a valid ACPI Object Descriptor> [%s]",
361 acpi_ut_get_descriptor_name(obj_desc
));
365 acpi_os_printf("\n");
368 /*******************************************************************************
370 * FUNCTION: acpi_db_decode_locals
372 * PARAMETERS: walk_state - State for current method
376 * DESCRIPTION: Display all locals for the currently running control method
378 ******************************************************************************/
380 void acpi_db_decode_locals(struct acpi_walk_state
*walk_state
)
383 union acpi_operand_object
*obj_desc
;
384 struct acpi_namespace_node
*node
;
385 u8 display_locals
= FALSE
;
387 obj_desc
= walk_state
->method_desc
;
388 node
= walk_state
->method_node
;
392 ("No method node (Executing subtree for buffer or opregion)\n");
396 if (node
->type
!= ACPI_TYPE_METHOD
) {
397 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
401 /* Are any locals actually set? */
403 for (i
= 0; i
< ACPI_METHOD_NUM_LOCALS
; i
++) {
404 obj_desc
= walk_state
->local_variables
[i
].object
;
406 display_locals
= TRUE
;
411 /* If any are set, only display the ones that are set */
413 if (display_locals
) {
415 ("\nInitialized Local Variables for Method [%4.4s]:\n",
416 acpi_ut_get_node_name(node
));
418 for (i
= 0; i
< ACPI_METHOD_NUM_LOCALS
; i
++) {
419 obj_desc
= walk_state
->local_variables
[i
].object
;
421 acpi_os_printf(" Local%X: ", i
);
422 acpi_db_display_internal_object(obj_desc
,
428 ("No Local Variables are initialized for Method [%4.4s]\n",
429 acpi_ut_get_node_name(node
));
433 /*******************************************************************************
435 * FUNCTION: acpi_db_decode_arguments
437 * PARAMETERS: walk_state - State for current method
441 * DESCRIPTION: Display all arguments for the currently running control method
443 ******************************************************************************/
445 void acpi_db_decode_arguments(struct acpi_walk_state
*walk_state
)
448 union acpi_operand_object
*obj_desc
;
449 struct acpi_namespace_node
*node
;
450 u8 display_args
= FALSE
;
452 node
= walk_state
->method_node
;
453 obj_desc
= walk_state
->method_desc
;
457 ("No method node (Executing subtree for buffer or opregion)\n");
461 if (node
->type
!= ACPI_TYPE_METHOD
) {
462 acpi_os_printf("Executing subtree for Buffer/Package/Region\n");
466 /* Are any arguments actually set? */
468 for (i
= 0; i
< ACPI_METHOD_NUM_ARGS
; i
++) {
469 obj_desc
= walk_state
->arguments
[i
].object
;
476 /* If any are set, only display the ones that are set */
479 acpi_os_printf("Initialized Arguments for Method [%4.4s]: "
480 "(%X arguments defined for method invocation)\n",
481 acpi_ut_get_node_name(node
),
482 node
->object
->method
.param_count
);
484 for (i
= 0; i
< ACPI_METHOD_NUM_ARGS
; i
++) {
485 obj_desc
= walk_state
->arguments
[i
].object
;
487 acpi_os_printf(" Arg%u: ", i
);
488 acpi_db_display_internal_object(obj_desc
,
494 ("No Arguments are initialized for method [%4.4s]\n",
495 acpi_ut_get_node_name(node
));