dbobject.c revision 1.1 1 1.1 christos /*******************************************************************************
2 1.1 christos *
3 1.1 christos * Module Name: dbobject - ACPI object decode and display
4 1.1 christos *
5 1.1 christos ******************************************************************************/
6 1.1 christos
7 1.1 christos /*
8 1.1 christos * Copyright (C) 2000 - 2015, Intel Corp.
9 1.1 christos * All rights reserved.
10 1.1 christos *
11 1.1 christos * Redistribution and use in source and binary forms, with or without
12 1.1 christos * modification, are permitted provided that the following conditions
13 1.1 christos * are met:
14 1.1 christos * 1. Redistributions of source code must retain the above copyright
15 1.1 christos * notice, this list of conditions, and the following disclaimer,
16 1.1 christos * without modification.
17 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1 christos * including a substantially similar Disclaimer requirement for further
21 1.1 christos * binary redistribution.
22 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1 christos * of any contributors may be used to endorse or promote products derived
24 1.1 christos * from this software without specific prior written permission.
25 1.1 christos *
26 1.1 christos * Alternatively, this software may be distributed under the terms of the
27 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1 christos * Software Foundation.
29 1.1 christos *
30 1.1 christos * NO WARRANTY
31 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.1 christos */
43 1.1 christos
44 1.1 christos #include "acpi.h"
45 1.1 christos #include "accommon.h"
46 1.1 christos #include "acnamesp.h"
47 1.1 christos #include "acdebug.h"
48 1.1 christos #ifdef ACPI_DISASSEMBLER
49 1.1 christos #include "acdisasm.h"
50 1.1 christos #endif
51 1.1 christos
52 1.1 christos
53 1.1 christos #ifdef ACPI_DEBUGGER
54 1.1 christos
55 1.1 christos #define _COMPONENT ACPI_CA_DEBUGGER
56 1.1 christos ACPI_MODULE_NAME ("dbobject")
57 1.1 christos
58 1.1 christos /* Local prototypes */
59 1.1 christos
60 1.1 christos static void
61 1.1 christos AcpiDbDecodeNode (
62 1.1 christos ACPI_NAMESPACE_NODE *Node);
63 1.1 christos
64 1.1 christos
65 1.1 christos /*******************************************************************************
66 1.1 christos *
67 1.1 christos * FUNCTION: AcpiDbDumpMethodInfo
68 1.1 christos *
69 1.1 christos * PARAMETERS: Status - Method execution status
70 1.1 christos * WalkState - Current state of the parse tree walk
71 1.1 christos *
72 1.1 christos * RETURN: None
73 1.1 christos *
74 1.1 christos * DESCRIPTION: Called when a method has been aborted because of an error.
75 1.1 christos * Dumps the method execution stack, and the method locals/args,
76 1.1 christos * and disassembles the AML opcode that failed.
77 1.1 christos *
78 1.1 christos ******************************************************************************/
79 1.1 christos
80 1.1 christos void
81 1.1 christos AcpiDbDumpMethodInfo (
82 1.1 christos ACPI_STATUS Status,
83 1.1 christos ACPI_WALK_STATE *WalkState)
84 1.1 christos {
85 1.1 christos ACPI_THREAD_STATE *Thread;
86 1.1 christos
87 1.1 christos
88 1.1 christos /* Ignore control codes, they are not errors */
89 1.1 christos
90 1.1 christos if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
91 1.1 christos {
92 1.1 christos return;
93 1.1 christos }
94 1.1 christos
95 1.1 christos /* We may be executing a deferred opcode */
96 1.1 christos
97 1.1 christos if (WalkState->DeferredNode)
98 1.1 christos {
99 1.1 christos AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
100 1.1 christos return;
101 1.1 christos }
102 1.1 christos
103 1.1 christos /*
104 1.1 christos * If there is no Thread, we are not actually executing a method.
105 1.1 christos * This can happen when the iASL compiler calls the interpreter
106 1.1 christos * to perform constant folding.
107 1.1 christos */
108 1.1 christos Thread = WalkState->Thread;
109 1.1 christos if (!Thread)
110 1.1 christos {
111 1.1 christos return;
112 1.1 christos }
113 1.1 christos
114 1.1 christos /* Display the method locals and arguments */
115 1.1 christos
116 1.1 christos AcpiOsPrintf ("\n");
117 1.1 christos AcpiDbDecodeLocals (WalkState);
118 1.1 christos AcpiOsPrintf ("\n");
119 1.1 christos AcpiDbDecodeArguments (WalkState);
120 1.1 christos AcpiOsPrintf ("\n");
121 1.1 christos }
122 1.1 christos
123 1.1 christos
124 1.1 christos /*******************************************************************************
125 1.1 christos *
126 1.1 christos * FUNCTION: AcpiDbDecodeInternalObject
127 1.1 christos *
128 1.1 christos * PARAMETERS: ObjDesc - Object to be displayed
129 1.1 christos *
130 1.1 christos * RETURN: None
131 1.1 christos *
132 1.1 christos * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
133 1.1 christos *
134 1.1 christos ******************************************************************************/
135 1.1 christos
136 1.1 christos void
137 1.1 christos AcpiDbDecodeInternalObject (
138 1.1 christos ACPI_OPERAND_OBJECT *ObjDesc)
139 1.1 christos {
140 1.1 christos UINT32 i;
141 1.1 christos
142 1.1 christos
143 1.1 christos if (!ObjDesc)
144 1.1 christos {
145 1.1 christos AcpiOsPrintf (" Uninitialized");
146 1.1 christos return;
147 1.1 christos }
148 1.1 christos
149 1.1 christos if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
150 1.1 christos {
151 1.1 christos AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
152 1.1 christos return;
153 1.1 christos }
154 1.1 christos
155 1.1 christos AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
156 1.1 christos
157 1.1 christos switch (ObjDesc->Common.Type)
158 1.1 christos {
159 1.1 christos case ACPI_TYPE_INTEGER:
160 1.1 christos
161 1.1 christos AcpiOsPrintf (" %8.8X%8.8X",
162 1.1 christos ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
163 1.1 christos break;
164 1.1 christos
165 1.1 christos case ACPI_TYPE_STRING:
166 1.1 christos
167 1.1 christos AcpiOsPrintf ("(%u) \"%.24s",
168 1.1 christos ObjDesc->String.Length, ObjDesc->String.Pointer);
169 1.1 christos
170 1.1 christos if (ObjDesc->String.Length > 24)
171 1.1 christos {
172 1.1 christos AcpiOsPrintf ("...");
173 1.1 christos }
174 1.1 christos else
175 1.1 christos {
176 1.1 christos AcpiOsPrintf ("\"");
177 1.1 christos }
178 1.1 christos break;
179 1.1 christos
180 1.1 christos case ACPI_TYPE_BUFFER:
181 1.1 christos
182 1.1 christos AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
183 1.1 christos for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
184 1.1 christos {
185 1.1 christos AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
186 1.1 christos }
187 1.1 christos break;
188 1.1 christos
189 1.1 christos default:
190 1.1 christos
191 1.1 christos AcpiOsPrintf (" %p", ObjDesc);
192 1.1 christos break;
193 1.1 christos }
194 1.1 christos }
195 1.1 christos
196 1.1 christos
197 1.1 christos /*******************************************************************************
198 1.1 christos *
199 1.1 christos * FUNCTION: AcpiDbDecodeNode
200 1.1 christos *
201 1.1 christos * PARAMETERS: Node - Object to be displayed
202 1.1 christos *
203 1.1 christos * RETURN: None
204 1.1 christos *
205 1.1 christos * DESCRIPTION: Short display of a namespace node
206 1.1 christos *
207 1.1 christos ******************************************************************************/
208 1.1 christos
209 1.1 christos static void
210 1.1 christos AcpiDbDecodeNode (
211 1.1 christos ACPI_NAMESPACE_NODE *Node)
212 1.1 christos {
213 1.1 christos
214 1.1 christos AcpiOsPrintf ("<Node> Name %4.4s",
215 1.1 christos AcpiUtGetNodeName (Node));
216 1.1 christos
217 1.1 christos if (Node->Flags & ANOBJ_METHOD_ARG)
218 1.1 christos {
219 1.1 christos AcpiOsPrintf (" [Method Arg]");
220 1.1 christos }
221 1.1 christos if (Node->Flags & ANOBJ_METHOD_LOCAL)
222 1.1 christos {
223 1.1 christos AcpiOsPrintf (" [Method Local]");
224 1.1 christos }
225 1.1 christos
226 1.1 christos switch (Node->Type)
227 1.1 christos {
228 1.1 christos /* These types have no attached object */
229 1.1 christos
230 1.1 christos case ACPI_TYPE_DEVICE:
231 1.1 christos
232 1.1 christos AcpiOsPrintf (" Device");
233 1.1 christos break;
234 1.1 christos
235 1.1 christos case ACPI_TYPE_THERMAL:
236 1.1 christos
237 1.1 christos AcpiOsPrintf (" Thermal Zone");
238 1.1 christos break;
239 1.1 christos
240 1.1 christos default:
241 1.1 christos
242 1.1 christos AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node));
243 1.1 christos break;
244 1.1 christos }
245 1.1 christos }
246 1.1 christos
247 1.1 christos
248 1.1 christos /*******************************************************************************
249 1.1 christos *
250 1.1 christos * FUNCTION: AcpiDbDisplayInternalObject
251 1.1 christos *
252 1.1 christos * PARAMETERS: ObjDesc - Object to be displayed
253 1.1 christos * WalkState - Current walk state
254 1.1 christos *
255 1.1 christos * RETURN: None
256 1.1 christos *
257 1.1 christos * DESCRIPTION: Short display of an internal object
258 1.1 christos *
259 1.1 christos ******************************************************************************/
260 1.1 christos
261 1.1 christos void
262 1.1 christos AcpiDbDisplayInternalObject (
263 1.1 christos ACPI_OPERAND_OBJECT *ObjDesc,
264 1.1 christos ACPI_WALK_STATE *WalkState)
265 1.1 christos {
266 1.1 christos UINT8 Type;
267 1.1 christos
268 1.1 christos
269 1.1 christos AcpiOsPrintf ("%p ", ObjDesc);
270 1.1 christos
271 1.1 christos if (!ObjDesc)
272 1.1 christos {
273 1.1 christos AcpiOsPrintf ("<Null Object>\n");
274 1.1 christos return;
275 1.1 christos }
276 1.1 christos
277 1.1 christos /* Decode the object type */
278 1.1 christos
279 1.1 christos switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
280 1.1 christos {
281 1.1 christos case ACPI_DESC_TYPE_PARSER:
282 1.1 christos
283 1.1 christos AcpiOsPrintf ("<Parser> ");
284 1.1 christos break;
285 1.1 christos
286 1.1 christos case ACPI_DESC_TYPE_NAMED:
287 1.1 christos
288 1.1 christos AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
289 1.1 christos break;
290 1.1 christos
291 1.1 christos case ACPI_DESC_TYPE_OPERAND:
292 1.1 christos
293 1.1 christos Type = ObjDesc->Common.Type;
294 1.1 christos if (Type > ACPI_TYPE_LOCAL_MAX)
295 1.1 christos {
296 1.1 christos AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
297 1.1 christos return;
298 1.1 christos }
299 1.1 christos
300 1.1 christos /* Decode the ACPI object type */
301 1.1 christos
302 1.1 christos switch (ObjDesc->Common.Type)
303 1.1 christos {
304 1.1 christos case ACPI_TYPE_LOCAL_REFERENCE:
305 1.1 christos
306 1.1 christos AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
307 1.1 christos
308 1.1 christos /* Decode the refererence */
309 1.1 christos
310 1.1 christos switch (ObjDesc->Reference.Class)
311 1.1 christos {
312 1.1 christos case ACPI_REFCLASS_LOCAL:
313 1.1 christos
314 1.1 christos AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
315 1.1 christos if (WalkState)
316 1.1 christos {
317 1.1 christos ObjDesc = WalkState->LocalVariables
318 1.1 christos [ObjDesc->Reference.Value].Object;
319 1.1 christos AcpiOsPrintf ("%p", ObjDesc);
320 1.1 christos AcpiDbDecodeInternalObject (ObjDesc);
321 1.1 christos }
322 1.1 christos break;
323 1.1 christos
324 1.1 christos case ACPI_REFCLASS_ARG:
325 1.1 christos
326 1.1 christos AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
327 1.1 christos if (WalkState)
328 1.1 christos {
329 1.1 christos ObjDesc = WalkState->Arguments
330 1.1 christos [ObjDesc->Reference.Value].Object;
331 1.1 christos AcpiOsPrintf ("%p", ObjDesc);
332 1.1 christos AcpiDbDecodeInternalObject (ObjDesc);
333 1.1 christos }
334 1.1 christos break;
335 1.1 christos
336 1.1 christos case ACPI_REFCLASS_INDEX:
337 1.1 christos
338 1.1 christos switch (ObjDesc->Reference.TargetType)
339 1.1 christos {
340 1.1 christos case ACPI_TYPE_BUFFER_FIELD:
341 1.1 christos
342 1.1 christos AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
343 1.1 christos AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
344 1.1 christos break;
345 1.1 christos
346 1.1 christos case ACPI_TYPE_PACKAGE:
347 1.1 christos
348 1.1 christos AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
349 1.1 christos if (!ObjDesc->Reference.Where)
350 1.1 christos {
351 1.1 christos AcpiOsPrintf (" Uninitialized WHERE pointer");
352 1.1 christos }
353 1.1 christos else
354 1.1 christos {
355 1.1 christos AcpiDbDecodeInternalObject (
356 1.1 christos *(ObjDesc->Reference.Where));
357 1.1 christos }
358 1.1 christos break;
359 1.1 christos
360 1.1 christos default:
361 1.1 christos
362 1.1 christos AcpiOsPrintf ("Unknown index target type");
363 1.1 christos break;
364 1.1 christos }
365 1.1 christos break;
366 1.1 christos
367 1.1 christos case ACPI_REFCLASS_REFOF:
368 1.1 christos
369 1.1 christos if (!ObjDesc->Reference.Object)
370 1.1 christos {
371 1.1 christos AcpiOsPrintf ("Uninitialized reference subobject pointer");
372 1.1 christos break;
373 1.1 christos }
374 1.1 christos
375 1.1 christos /* Reference can be to a Node or an Operand object */
376 1.1 christos
377 1.1 christos switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
378 1.1 christos {
379 1.1 christos case ACPI_DESC_TYPE_NAMED:
380 1.1 christos AcpiDbDecodeNode (ObjDesc->Reference.Object);
381 1.1 christos break;
382 1.1 christos
383 1.1 christos case ACPI_DESC_TYPE_OPERAND:
384 1.1 christos AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
385 1.1 christos break;
386 1.1 christos
387 1.1 christos default:
388 1.1 christos break;
389 1.1 christos }
390 1.1 christos break;
391 1.1 christos
392 1.1 christos case ACPI_REFCLASS_NAME:
393 1.1 christos
394 1.1 christos AcpiDbDecodeNode (ObjDesc->Reference.Node);
395 1.1 christos break;
396 1.1 christos
397 1.1 christos case ACPI_REFCLASS_DEBUG:
398 1.1 christos case ACPI_REFCLASS_TABLE:
399 1.1 christos
400 1.1 christos AcpiOsPrintf ("\n");
401 1.1 christos break;
402 1.1 christos
403 1.1 christos default: /* Unknown reference class */
404 1.1 christos
405 1.1 christos AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
406 1.1 christos break;
407 1.1 christos }
408 1.1 christos break;
409 1.1 christos
410 1.1 christos default:
411 1.1 christos
412 1.1 christos AcpiOsPrintf ("<Obj> ");
413 1.1 christos AcpiDbDecodeInternalObject (ObjDesc);
414 1.1 christos break;
415 1.1 christos }
416 1.1 christos break;
417 1.1 christos
418 1.1 christos default:
419 1.1 christos
420 1.1 christos AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
421 1.1 christos AcpiUtGetDescriptorName (ObjDesc));
422 1.1 christos break;
423 1.1 christos }
424 1.1 christos
425 1.1 christos AcpiOsPrintf ("\n");
426 1.1 christos }
427 1.1 christos
428 1.1 christos
429 1.1 christos /*******************************************************************************
430 1.1 christos *
431 1.1 christos * FUNCTION: AcpiDbDecodeLocals
432 1.1 christos *
433 1.1 christos * PARAMETERS: WalkState - State for current method
434 1.1 christos *
435 1.1 christos * RETURN: None
436 1.1 christos *
437 1.1 christos * DESCRIPTION: Display all locals for the currently running control method
438 1.1 christos *
439 1.1 christos ******************************************************************************/
440 1.1 christos
441 1.1 christos void
442 1.1 christos AcpiDbDecodeLocals (
443 1.1 christos ACPI_WALK_STATE *WalkState)
444 1.1 christos {
445 1.1 christos UINT32 i;
446 1.1 christos ACPI_OPERAND_OBJECT *ObjDesc;
447 1.1 christos ACPI_NAMESPACE_NODE *Node;
448 1.1 christos
449 1.1 christos
450 1.1 christos ObjDesc = WalkState->MethodDesc;
451 1.1 christos Node = WalkState->MethodNode;
452 1.1 christos if (!Node)
453 1.1 christos {
454 1.1 christos AcpiOsPrintf (
455 1.1 christos "No method node (Executing subtree for buffer or opregion)\n");
456 1.1 christos return;
457 1.1 christos }
458 1.1 christos
459 1.1 christos if (Node->Type != ACPI_TYPE_METHOD)
460 1.1 christos {
461 1.1 christos AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
462 1.1 christos return;
463 1.1 christos }
464 1.1 christos
465 1.1 christos AcpiOsPrintf ("Local Variables for method [%4.4s]:\n",
466 1.1 christos AcpiUtGetNodeName (Node));
467 1.1 christos
468 1.1 christos for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
469 1.1 christos {
470 1.1 christos ObjDesc = WalkState->LocalVariables[i].Object;
471 1.1 christos AcpiOsPrintf (" Local%X: ", i);
472 1.1 christos AcpiDbDisplayInternalObject (ObjDesc, WalkState);
473 1.1 christos }
474 1.1 christos }
475 1.1 christos
476 1.1 christos
477 1.1 christos /*******************************************************************************
478 1.1 christos *
479 1.1 christos * FUNCTION: AcpiDbDecodeArguments
480 1.1 christos *
481 1.1 christos * PARAMETERS: WalkState - State for current method
482 1.1 christos *
483 1.1 christos * RETURN: None
484 1.1 christos *
485 1.1 christos * DESCRIPTION: Display all arguments for the currently running control method
486 1.1 christos *
487 1.1 christos ******************************************************************************/
488 1.1 christos
489 1.1 christos void
490 1.1 christos AcpiDbDecodeArguments (
491 1.1 christos ACPI_WALK_STATE *WalkState)
492 1.1 christos {
493 1.1 christos UINT32 i;
494 1.1 christos ACPI_OPERAND_OBJECT *ObjDesc;
495 1.1 christos ACPI_NAMESPACE_NODE *Node;
496 1.1 christos
497 1.1 christos
498 1.1 christos ObjDesc = WalkState->MethodDesc;
499 1.1 christos Node = WalkState->MethodNode;
500 1.1 christos if (!Node)
501 1.1 christos {
502 1.1 christos AcpiOsPrintf (
503 1.1 christos "No method node (Executing subtree for buffer or opregion)\n");
504 1.1 christos return;
505 1.1 christos }
506 1.1 christos
507 1.1 christos if (Node->Type != ACPI_TYPE_METHOD)
508 1.1 christos {
509 1.1 christos AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
510 1.1 christos return;
511 1.1 christos }
512 1.1 christos
513 1.1 christos AcpiOsPrintf (
514 1.1 christos "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n",
515 1.1 christos AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel);
516 1.1 christos
517 1.1 christos for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
518 1.1 christos {
519 1.1 christos ObjDesc = WalkState->Arguments[i].Object;
520 1.1 christos AcpiOsPrintf (" Arg%u: ", i);
521 1.1 christos AcpiDbDisplayInternalObject (ObjDesc, WalkState);
522 1.1 christos }
523 1.1 christos }
524 1.1 christos
525 1.1 christos #endif
526