1 /*******************************************************************************
2 *
3 * Module Name: dbdisply - debug display commands
4 *
5 ******************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "amlcode.h"
155 #include "acdispat.h"
156 #include "acnamesp.h"
157 #include "acparser.h"
158 #include "acinterp.h"
159 #include "acevents.h"
160 #include "acdebug.h"
161
162
163 #define _COMPONENT ACPI_CA_DEBUGGER
164 ACPI_MODULE_NAME ("dbdisply")
165
166 /* Local prototypes */
167
168 static void
169 AcpiDbDumpParserDescriptor (
170 ACPI_PARSE_OBJECT *Op);
171
172 static void *
173 AcpiDbGetPointer (
174 void *Target);
175
176 static ACPI_STATUS
177 AcpiDbDisplayNonRootHandlers (
178 ACPI_HANDLE ObjHandle,
179 UINT32 NestingLevel,
180 void *Context,
181 void **ReturnValue);
182
183 /*
184 * System handler information.
185 * Used for Handlers command, in AcpiDbDisplayHandlers.
186 */
187 #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
188 #define ACPI_HANDLER_NAME_STRING "%30s : "
189 #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
190 #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"
191 #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
192
193 /* All predefined Address Space IDs */
194
195 static ACPI_ADR_SPACE_TYPE AcpiGbl_SpaceIdList[] =
196 {
197 ACPI_ADR_SPACE_SYSTEM_MEMORY,
198 ACPI_ADR_SPACE_SYSTEM_IO,
199 ACPI_ADR_SPACE_PCI_CONFIG,
200 ACPI_ADR_SPACE_EC,
201 ACPI_ADR_SPACE_SMBUS,
202 ACPI_ADR_SPACE_CMOS,
203 ACPI_ADR_SPACE_PCI_BAR_TARGET,
204 ACPI_ADR_SPACE_IPMI,
205 ACPI_ADR_SPACE_GPIO,
206 ACPI_ADR_SPACE_GSBUS,
207 ACPI_ADR_SPACE_PLATFORM_COMM,
208 ACPI_ADR_SPACE_PLATFORM_RT,
209 ACPI_ADR_SPACE_DATA_TABLE,
210 ACPI_ADR_SPACE_FIXED_HARDWARE
211 };
212
213 /* Global handler information */
214
215 typedef struct acpi_handler_info
216 {
217 void *Handler;
218 char *Name;
219
220 } ACPI_HANDLER_INFO;
221
222 static ACPI_HANDLER_INFO AcpiGbl_HandlerList[] =
223 {
224 {&AcpiGbl_GlobalNotify[0].Handler, "System Notifications"},
225 {&AcpiGbl_GlobalNotify[1].Handler, "Device Notifications"},
226 {&AcpiGbl_TableHandler, "ACPI Table Events"},
227 {&AcpiGbl_ExceptionHandler, "Control Method Exceptions"},
228 {&AcpiGbl_InterfaceHandler, "OSI Invocations"}
229 };
230
231
232 /*******************************************************************************
233 *
234 * FUNCTION: AcpiDbGetPointer
235 *
236 * PARAMETERS: Target - Pointer to string to be converted
237 *
238 * RETURN: Converted pointer
239 *
240 * DESCRIPTION: Convert an ascii pointer value to a real value
241 *
242 ******************************************************************************/
243
244 static void *
AcpiDbGetPointer(void * Target)245 AcpiDbGetPointer (
246 void *Target)
247 {
248 void *ObjPtr;
249 ACPI_SIZE Address;
250
251
252 Address = strtoul (Target, NULL, 16);
253 ObjPtr = ACPI_TO_POINTER (Address);
254 return (ObjPtr);
255 }
256
257
258 /*******************************************************************************
259 *
260 * FUNCTION: AcpiDbDumpParserDescriptor
261 *
262 * PARAMETERS: Op - A parser Op descriptor
263 *
264 * RETURN: None
265 *
266 * DESCRIPTION: Display a formatted parser object
267 *
268 ******************************************************************************/
269
270 static void
AcpiDbDumpParserDescriptor(ACPI_PARSE_OBJECT * Op)271 AcpiDbDumpParserDescriptor (
272 ACPI_PARSE_OBJECT *Op)
273 {
274 const ACPI_OPCODE_INFO *Info;
275
276
277 Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
278
279 AcpiOsPrintf ("Parser Op Descriptor:\n");
280 AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
281
282 ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
283 Info->Name));
284
285 AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
286 AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
287 AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
288 }
289
290
291 /*******************************************************************************
292 *
293 * FUNCTION: AcpiDbDecodeAndDisplayObject
294 *
295 * PARAMETERS: Target - String with object to be displayed. Names
296 * and hex pointers are supported.
297 * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q)
298 *
299 * RETURN: None
300 *
301 * DESCRIPTION: Display a formatted ACPI object
302 *
303 ******************************************************************************/
304
305 void
AcpiDbDecodeAndDisplayObject(char * Target,char * OutputType)306 AcpiDbDecodeAndDisplayObject (
307 char *Target,
308 char *OutputType)
309 {
310 void *ObjPtr;
311 ACPI_NAMESPACE_NODE *Node;
312 ACPI_OPERAND_OBJECT *ObjDesc;
313 UINT32 Display = DB_BYTE_DISPLAY;
314 char Buffer[80];
315 ACPI_BUFFER RetBuf;
316 ACPI_STATUS Status;
317 UINT32 Size;
318
319
320 if (!Target)
321 {
322 return;
323 }
324
325 /* Decode the output type */
326
327 if (OutputType)
328 {
329 AcpiUtStrupr (OutputType);
330 if (OutputType[0] == 'W')
331 {
332 Display = DB_WORD_DISPLAY;
333 }
334 else if (OutputType[0] == 'D')
335 {
336 Display = DB_DWORD_DISPLAY;
337 }
338 else if (OutputType[0] == 'Q')
339 {
340 Display = DB_QWORD_DISPLAY;
341 }
342 }
343
344 RetBuf.Length = sizeof (Buffer);
345 RetBuf.Pointer = Buffer;
346
347 /* Differentiate between a number and a name */
348
349 if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
350 {
351 ObjPtr = AcpiDbGetPointer (Target);
352 if (!AcpiOsReadable (ObjPtr, 16))
353 {
354 AcpiOsPrintf (
355 "Address %p is invalid in this address space\n",
356 ObjPtr);
357 return;
358 }
359
360 /* Decode the object type */
361
362 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
363 {
364 case ACPI_DESC_TYPE_NAMED:
365
366 /* This is a namespace Node */
367
368 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
369 {
370 AcpiOsPrintf (
371 "Cannot read entire Named object at address %p\n",
372 ObjPtr);
373 return;
374 }
375
376 Node = ObjPtr;
377 goto DumpNode;
378
379 case ACPI_DESC_TYPE_OPERAND:
380
381 /* This is a ACPI OPERAND OBJECT */
382
383 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
384 {
385 AcpiOsPrintf (
386 "Cannot read entire ACPI object at address %p\n",
387 ObjPtr);
388 return;
389 }
390
391 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT),
392 Display, ACPI_UINT32_MAX);
393 AcpiExDumpObjectDescriptor (ObjPtr, 1);
394 break;
395
396 case ACPI_DESC_TYPE_PARSER:
397
398 /* This is a Parser Op object */
399
400 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
401 {
402 AcpiOsPrintf (
403 "Cannot read entire Parser object at address %p\n",
404 ObjPtr);
405 return;
406 }
407
408 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT),
409 Display, ACPI_UINT32_MAX);
410 AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
411 break;
412
413 default:
414
415 /* Is not a recognizable object */
416
417 AcpiOsPrintf (
418 "Not a known ACPI internal object, descriptor type %2.2X\n",
419 ACPI_GET_DESCRIPTOR_TYPE (ObjPtr));
420
421 Size = 16;
422 if (AcpiOsReadable (ObjPtr, 64))
423 {
424 Size = 64;
425 }
426
427 /* Just dump some memory */
428
429 AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
430 break;
431 }
432
433 return;
434 }
435
436 /* The parameter is a name string that must be resolved to a Named obj */
437
438 Node = AcpiDbLocalNsLookup (Target);
439 if (!Node)
440 {
441 return;
442 }
443
444
445 DumpNode:
446 /* Now dump the NS node */
447
448 Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
449 if (ACPI_FAILURE (Status))
450 {
451 AcpiOsPrintf ("Could not convert name to pathname\n");
452 }
453
454 else
455 {
456 AcpiOsPrintf ("Object %p: Namespace Node - Pathname: %s\n",
457 Node, (char *) RetBuf.Pointer);
458 }
459
460 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
461 {
462 AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
463 return;
464 }
465
466 AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
467 Display, ACPI_UINT32_MAX);
468 AcpiExDumpNamespaceNode (Node, 1);
469
470 ObjDesc = AcpiNsGetAttachedObject (Node);
471 if (ObjDesc)
472 {
473 AcpiOsPrintf ("\nAttached Object %p:", ObjDesc);
474 if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
475 {
476 AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
477 ObjDesc);
478 return;
479 }
480
481 if (ACPI_GET_DESCRIPTOR_TYPE (
482 ((ACPI_NAMESPACE_NODE *) ObjDesc)) == ACPI_DESC_TYPE_NAMED)
483 {
484 AcpiOsPrintf (" Namespace Node - ");
485 Status = AcpiGetName ((ACPI_NAMESPACE_NODE *) ObjDesc,
486 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
487 if (ACPI_FAILURE (Status))
488 {
489 AcpiOsPrintf ("Could not convert name to pathname\n");
490 }
491 else
492 {
493 AcpiOsPrintf ("Pathname: %s",
494 (char *) RetBuf.Pointer);
495 }
496
497 AcpiOsPrintf ("\n");
498 AcpiUtDebugDumpBuffer ((void *) ObjDesc,
499 sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);
500 }
501 else
502 {
503 AcpiOsPrintf ("\n");
504 AcpiUtDebugDumpBuffer ((void *) ObjDesc,
505 sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
506 }
507
508 AcpiExDumpObjectDescriptor (ObjDesc, 1);
509 }
510 }
511
512
513 /*******************************************************************************
514 *
515 * FUNCTION: AcpiDbDisplayMethodInfo
516 *
517 * PARAMETERS: StartOp - Root of the control method parse tree
518 *
519 * RETURN: None
520 *
521 * DESCRIPTION: Display information about the current method
522 *
523 ******************************************************************************/
524
525 void
AcpiDbDisplayMethodInfo(ACPI_PARSE_OBJECT * StartOp)526 AcpiDbDisplayMethodInfo (
527 ACPI_PARSE_OBJECT *StartOp)
528 {
529 ACPI_WALK_STATE *WalkState;
530 ACPI_OPERAND_OBJECT *ObjDesc;
531 ACPI_NAMESPACE_NODE *Node;
532 ACPI_PARSE_OBJECT *RootOp;
533 ACPI_PARSE_OBJECT *Op;
534 const ACPI_OPCODE_INFO *OpInfo;
535 UINT32 NumOps = 0;
536 UINT32 NumOperands = 0;
537 UINT32 NumOperators = 0;
538 UINT32 NumRemainingOps = 0;
539 UINT32 NumRemainingOperands = 0;
540 UINT32 NumRemainingOperators = 0;
541 BOOLEAN CountRemaining = FALSE;
542
543
544 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
545 if (!WalkState)
546 {
547 AcpiOsPrintf ("There is no method currently executing\n");
548 return;
549 }
550
551 ObjDesc = WalkState->MethodDesc;
552 Node = WalkState->MethodNode;
553
554 AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
555 AcpiUtGetNodeName (Node));
556 AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
557 (UINT32) ObjDesc->Method.ParamCount,
558 (UINT32) ObjDesc->Method.SyncLevel);
559
560 RootOp = StartOp;
561 while (RootOp->Common.Parent)
562 {
563 RootOp = RootOp->Common.Parent;
564 }
565
566 Op = RootOp;
567
568 while (Op)
569 {
570 if (Op == StartOp)
571 {
572 CountRemaining = TRUE;
573 }
574
575 NumOps++;
576 if (CountRemaining)
577 {
578 NumRemainingOps++;
579 }
580
581 /* Decode the opcode */
582
583 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
584 switch (OpInfo->Class)
585 {
586 case AML_CLASS_ARGUMENT:
587
588 if (CountRemaining)
589 {
590 NumRemainingOperands++;
591 }
592
593 NumOperands++;
594 break;
595
596 case AML_CLASS_UNKNOWN:
597
598 /* Bad opcode or ASCII character */
599
600 continue;
601
602 default:
603
604 if (CountRemaining)
605 {
606 NumRemainingOperators++;
607 }
608
609 NumOperators++;
610 break;
611 }
612
613 Op = AcpiPsGetDepthNext (StartOp, Op);
614 }
615
616 AcpiOsPrintf (
617 "Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
618 NumOps, NumOperators, NumOperands);
619
620 AcpiOsPrintf (
621 "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
622 NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
623 }
624
625
626 /*******************************************************************************
627 *
628 * FUNCTION: AcpiDbDisplayLocals
629 *
630 * PARAMETERS: None
631 *
632 * RETURN: None
633 *
634 * DESCRIPTION: Display all locals for the currently running control method
635 *
636 ******************************************************************************/
637
638 void
AcpiDbDisplayLocals(void)639 AcpiDbDisplayLocals (
640 void)
641 {
642 ACPI_WALK_STATE *WalkState;
643
644
645 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
646 if (!WalkState)
647 {
648 AcpiOsPrintf ("There is no method currently executing\n");
649 return;
650 }
651
652 AcpiDbDecodeLocals (WalkState);
653 }
654
655
656 /*******************************************************************************
657 *
658 * FUNCTION: AcpiDbDisplayArguments
659 *
660 * PARAMETERS: None
661 *
662 * RETURN: None
663 *
664 * DESCRIPTION: Display all arguments for the currently running control method
665 *
666 ******************************************************************************/
667
668 void
AcpiDbDisplayArguments(void)669 AcpiDbDisplayArguments (
670 void)
671 {
672 ACPI_WALK_STATE *WalkState;
673
674
675 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
676 if (!WalkState)
677 {
678 AcpiOsPrintf ("There is no method currently executing\n");
679 return;
680 }
681
682 AcpiDbDecodeArguments (WalkState);
683 }
684
685
686 /*******************************************************************************
687 *
688 * FUNCTION: AcpiDbDisplayResults
689 *
690 * PARAMETERS: None
691 *
692 * RETURN: None
693 *
694 * DESCRIPTION: Display current contents of a method result stack
695 *
696 ******************************************************************************/
697
698 void
AcpiDbDisplayResults(void)699 AcpiDbDisplayResults (
700 void)
701 {
702 UINT32 i;
703 ACPI_WALK_STATE *WalkState;
704 ACPI_OPERAND_OBJECT *ObjDesc;
705 UINT32 ResultCount = 0;
706 ACPI_NAMESPACE_NODE *Node;
707 ACPI_GENERIC_STATE *Frame;
708 UINT32 Index; /* Index onto current frame */
709
710
711 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
712 if (!WalkState)
713 {
714 AcpiOsPrintf ("There is no method currently executing\n");
715 return;
716 }
717
718 Node = WalkState->MethodNode;
719
720 if (WalkState->Results)
721 {
722 ResultCount = WalkState->ResultCount;
723 }
724
725 AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
726 AcpiUtGetNodeName (Node), ResultCount);
727
728 /* From the top element of result stack */
729
730 Frame = WalkState->Results;
731 Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
732
733 for (i = 0; i < ResultCount; i++)
734 {
735 ObjDesc = Frame->Results.ObjDesc[Index];
736 AcpiOsPrintf ("Result%u: ", i);
737 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
738
739 if (Index == 0)
740 {
741 Frame = Frame->Results.Next;
742 Index = ACPI_RESULTS_FRAME_OBJ_NUM;
743 }
744
745 Index--;
746 }
747 }
748
749
750 /*******************************************************************************
751 *
752 * FUNCTION: AcpiDbDisplayCallingTree
753 *
754 * PARAMETERS: None
755 *
756 * RETURN: None
757 *
758 * DESCRIPTION: Display current calling tree of nested control methods
759 *
760 ******************************************************************************/
761
762 void
AcpiDbDisplayCallingTree(void)763 AcpiDbDisplayCallingTree (
764 void)
765 {
766 ACPI_WALK_STATE *WalkState;
767 ACPI_NAMESPACE_NODE *Node;
768
769
770 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
771 if (!WalkState)
772 {
773 AcpiOsPrintf ("There is no method currently executing\n");
774 return;
775 }
776
777 AcpiOsPrintf ("Current Control Method Call Tree\n");
778
779 while (WalkState)
780 {
781 Node = WalkState->MethodNode;
782 AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node));
783
784 WalkState = WalkState->Next;
785 }
786 }
787
788
789 /*******************************************************************************
790 *
791 * FUNCTION: AcpiDbDisplayObjectType
792 *
793 * PARAMETERS: ObjectArg - User entered NS node handle
794 *
795 * RETURN: None
796 *
797 * DESCRIPTION: Display type of an arbitrary NS node
798 *
799 ******************************************************************************/
800
801 void
AcpiDbDisplayObjectType(char * ObjectArg)802 AcpiDbDisplayObjectType (
803 char *ObjectArg)
804 {
805 ACPI_SIZE Arg;
806 ACPI_HANDLE Handle;
807 ACPI_DEVICE_INFO *Info;
808 ACPI_STATUS Status;
809 UINT32 i;
810
811
812 Arg = strtoul (ObjectArg, NULL, 16);
813 Handle = ACPI_TO_POINTER (Arg);
814
815 Status = AcpiGetObjectInfo (Handle, &Info);
816 if (ACPI_FAILURE (Status))
817 {
818 AcpiOsPrintf ("Could not get object info, %s\n",
819 AcpiFormatException (Status));
820 return;
821 }
822
823 AcpiOsPrintf ("ADR: %8.8X%8.8X, Flags: %X\n",
824 ACPI_FORMAT_UINT64 (Info->Address), Info->Flags);
825
826 AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
827 Info->HighestDstates[0], Info->HighestDstates[1],
828 Info->HighestDstates[2], Info->HighestDstates[3]);
829
830 AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
831 Info->LowestDstates[0], Info->LowestDstates[1],
832 Info->LowestDstates[2], Info->LowestDstates[3],
833 Info->LowestDstates[4]);
834
835 if (Info->Valid & ACPI_VALID_HID)
836 {
837 AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
838 }
839
840 if (Info->Valid & ACPI_VALID_UID)
841 {
842 AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
843 }
844
845 if (Info->Valid & ACPI_VALID_CID)
846 {
847 for (i = 0; i < Info->CompatibleIdList.Count; i++)
848 {
849 AcpiOsPrintf ("CID %u: %s\n", i,
850 Info->CompatibleIdList.Ids[i].String);
851 }
852 }
853
854 ACPI_FREE (Info);
855 }
856
857
858 /*******************************************************************************
859 *
860 * FUNCTION: AcpiDbDisplayResultObject
861 *
862 * PARAMETERS: ObjDesc - Object to be displayed
863 * WalkState - Current walk state
864 *
865 * RETURN: None
866 *
867 * DESCRIPTION: Display the result of an AML opcode
868 *
869 * Note: Currently only displays the result object if we are single stepping.
870 * However, this output may be useful in other contexts and could be enabled
871 * to do so if needed.
872 *
873 ******************************************************************************/
874
875 void
AcpiDbDisplayResultObject(ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)876 AcpiDbDisplayResultObject (
877 ACPI_OPERAND_OBJECT *ObjDesc,
878 ACPI_WALK_STATE *WalkState)
879 {
880
881 #ifndef ACPI_APPLICATION
882 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
883 {
884 return;
885 }
886 #endif
887
888 /* Only display if single stepping */
889
890 if (!AcpiGbl_CmSingleStep)
891 {
892 return;
893 }
894
895 AcpiOsPrintf ("ResultObj: ");
896 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
897 AcpiOsPrintf ("\n");
898 }
899
900
901 /*******************************************************************************
902 *
903 * FUNCTION: AcpiDbDisplayArgumentObject
904 *
905 * PARAMETERS: ObjDesc - Object to be displayed
906 * WalkState - Current walk state
907 *
908 * RETURN: None
909 *
910 * DESCRIPTION: Display the result of an AML opcode
911 *
912 ******************************************************************************/
913
914 void
AcpiDbDisplayArgumentObject(ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)915 AcpiDbDisplayArgumentObject (
916 ACPI_OPERAND_OBJECT *ObjDesc,
917 ACPI_WALK_STATE *WalkState)
918 {
919
920 #ifndef ACPI_APPLICATION
921 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
922 {
923 return;
924 }
925 #endif
926
927 if (!AcpiGbl_CmSingleStep)
928 {
929 return;
930 }
931
932 AcpiOsPrintf ("ArgObj: ");
933 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
934 }
935
936
937 #if (!ACPI_REDUCED_HARDWARE)
938 /*******************************************************************************
939 *
940 * FUNCTION: AcpiDbDisplayGpes
941 *
942 * PARAMETERS: None
943 *
944 * RETURN: None
945 *
946 * DESCRIPTION: Display the current GPE structures
947 *
948 ******************************************************************************/
949
950 void
AcpiDbDisplayGpes(void)951 AcpiDbDisplayGpes (
952 void)
953 {
954 ACPI_GPE_BLOCK_INFO *GpeBlock;
955 ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
956 ACPI_GPE_EVENT_INFO *GpeEventInfo;
957 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
958 char *GpeType;
959 ACPI_GPE_NOTIFY_INFO *Notify;
960 UINT32 GpeIndex;
961 UINT32 Block = 0;
962 UINT32 i;
963 UINT32 j;
964 UINT32 Count;
965 char Buffer[80];
966 ACPI_BUFFER RetBuf;
967 ACPI_STATUS Status;
968
969
970 RetBuf.Length = sizeof (Buffer);
971 RetBuf.Pointer = Buffer;
972
973 Block = 0;
974
975 /* Walk the GPE lists */
976
977 GpeXruptInfo = AcpiGbl_GpeXruptListHead;
978 while (GpeXruptInfo)
979 {
980 GpeBlock = GpeXruptInfo->GpeBlockListHead;
981 while (GpeBlock)
982 {
983 Status = AcpiGetName (GpeBlock->Node,
984 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
985 if (ACPI_FAILURE (Status))
986 {
987 AcpiOsPrintf ("Could not convert name to pathname\n");
988 }
989
990 if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
991 {
992 GpeType = "FADT-defined GPE block";
993 }
994 else
995 {
996 GpeType = "GPE Block Device";
997 }
998
999 AcpiOsPrintf (
1000 "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",
1001 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
1002
1003 AcpiOsPrintf (
1004 " Registers: %u (%u GPEs)\n",
1005 GpeBlock->RegisterCount, GpeBlock->GpeCount);
1006
1007 AcpiOsPrintf (
1008 " GPE range: 0x%X to 0x%X on interrupt %u\n",
1009 GpeBlock->BlockBaseNumber,
1010 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
1011 GpeXruptInfo->InterruptNumber);
1012
1013 AcpiOsPrintf (
1014 " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
1015 GpeBlock->RegisterInfo,
1016 ACPI_FORMAT_UINT64 (
1017 GpeBlock->RegisterInfo->StatusAddress.Address),
1018 ACPI_FORMAT_UINT64 (
1019 GpeBlock->RegisterInfo->EnableAddress.Address));
1020
1021 AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo);
1022
1023 /* Examine each GPE Register within the block */
1024
1025 for (i = 0; i < GpeBlock->RegisterCount; i++)
1026 {
1027 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
1028
1029 AcpiOsPrintf (
1030 " Reg %u: (GPE %.2X-%.2X) "
1031 "RunEnable %2.2X WakeEnable %2.2X"
1032 " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
1033 i, GpeRegisterInfo->BaseGpeNumber,
1034 GpeRegisterInfo->BaseGpeNumber +
1035 (ACPI_GPE_REGISTER_WIDTH - 1),
1036 GpeRegisterInfo->EnableForRun,
1037 GpeRegisterInfo->EnableForWake,
1038 ACPI_FORMAT_UINT64 (
1039 GpeRegisterInfo->StatusAddress.Address),
1040 ACPI_FORMAT_UINT64 (
1041 GpeRegisterInfo->EnableAddress.Address));
1042
1043 /* Now look at the individual GPEs in this byte register */
1044
1045 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
1046 {
1047 GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
1048 GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
1049
1050 if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
1051 ACPI_GPE_DISPATCH_NONE)
1052 {
1053 /* This GPE is not used (no method or handler), ignore it */
1054
1055 continue;
1056 }
1057
1058 AcpiOsPrintf (
1059 " GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",
1060 GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
1061 GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
1062
1063 /* Decode the flags byte */
1064
1065 if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
1066 {
1067 AcpiOsPrintf ("Level, ");
1068 }
1069 else
1070 {
1071 AcpiOsPrintf ("Edge, ");
1072 }
1073
1074 if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
1075 {
1076 AcpiOsPrintf ("CanWake, ");
1077 }
1078 else
1079 {
1080 AcpiOsPrintf ("RunOnly, ");
1081 }
1082
1083 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags))
1084 {
1085 case ACPI_GPE_DISPATCH_NONE:
1086
1087 AcpiOsPrintf ("NotUsed");
1088 break;
1089
1090 case ACPI_GPE_DISPATCH_METHOD:
1091
1092 AcpiOsPrintf ("Method");
1093 break;
1094
1095 case ACPI_GPE_DISPATCH_HANDLER:
1096
1097 AcpiOsPrintf ("Handler");
1098 break;
1099
1100 case ACPI_GPE_DISPATCH_NOTIFY:
1101
1102 Count = 0;
1103 Notify = GpeEventInfo->Dispatch.NotifyList;
1104 while (Notify)
1105 {
1106 Count++;
1107 Notify = Notify->Next;
1108 }
1109
1110 AcpiOsPrintf ("Implicit Notify on %u devices",
1111 Count);
1112 break;
1113
1114 case ACPI_GPE_DISPATCH_RAW_HANDLER:
1115
1116 AcpiOsPrintf ("RawHandler");
1117 break;
1118
1119 default:
1120
1121 AcpiOsPrintf ("UNKNOWN: %X",
1122 ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags));
1123 break;
1124 }
1125
1126 AcpiOsPrintf (")\n");
1127 }
1128 }
1129
1130 Block++;
1131 GpeBlock = GpeBlock->Next;
1132 }
1133
1134 GpeXruptInfo = GpeXruptInfo->Next;
1135 }
1136 }
1137 #endif /* !ACPI_REDUCED_HARDWARE */
1138
1139
1140 /*******************************************************************************
1141 *
1142 * FUNCTION: AcpiDbDisplayHandlers
1143 *
1144 * PARAMETERS: None
1145 *
1146 * RETURN: None
1147 *
1148 * DESCRIPTION: Display the currently installed global handlers
1149 *
1150 ******************************************************************************/
1151
1152 void
AcpiDbDisplayHandlers(void)1153 AcpiDbDisplayHandlers (
1154 void)
1155 {
1156 ACPI_OPERAND_OBJECT *ObjDesc;
1157 ACPI_OPERAND_OBJECT *HandlerObj;
1158 ACPI_ADR_SPACE_TYPE SpaceId;
1159 UINT32 i;
1160
1161
1162 /* Operation region handlers */
1163
1164 AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
1165
1166 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
1167 if (ObjDesc)
1168 {
1169 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
1170 {
1171 SpaceId = AcpiGbl_SpaceIdList[i];
1172
1173 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1174 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
1175
1176 HandlerObj = AcpiEvFindRegionHandler (
1177 SpaceId, ObjDesc->CommonNotify.Handler);
1178 if (HandlerObj)
1179 {
1180 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1181 (HandlerObj->AddressSpace.HandlerFlags &
1182 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
1183 "Default" : "User",
1184 HandlerObj->AddressSpace.Handler);
1185
1186 goto FoundHandler;
1187 }
1188
1189 /* There is no handler for this SpaceId */
1190
1191 AcpiOsPrintf ("None\n");
1192
1193 FoundHandler:;
1194 }
1195
1196 /* Find all handlers for user-defined SpaceIDs */
1197
1198 HandlerObj = ObjDesc->CommonNotify.Handler;
1199 while (HandlerObj)
1200 {
1201 if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
1202 {
1203 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1204 "User-defined ID", HandlerObj->AddressSpace.SpaceId);
1205 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1206 (HandlerObj->AddressSpace.HandlerFlags &
1207 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
1208 "Default" : "User",
1209 HandlerObj->AddressSpace.Handler);
1210 }
1211
1212 HandlerObj = HandlerObj->AddressSpace.Next;
1213 }
1214 }
1215
1216 #if (!ACPI_REDUCED_HARDWARE)
1217
1218 /* Fixed event handlers */
1219
1220 AcpiOsPrintf ("\nFixed Event Handlers:\n");
1221
1222 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
1223 {
1224 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
1225 if (AcpiGbl_FixedEventHandlers[i].Handler)
1226 {
1227 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1228 AcpiGbl_FixedEventHandlers[i].Handler);
1229 }
1230 else
1231 {
1232 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1233 }
1234 }
1235
1236 #endif /* !ACPI_REDUCED_HARDWARE */
1237
1238 /* Miscellaneous global handlers */
1239
1240 AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
1241
1242 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
1243 {
1244 AcpiOsPrintf (ACPI_HANDLER_NAME_STRING,
1245 AcpiGbl_HandlerList[i].Name);
1246
1247 if (AcpiGbl_HandlerList[i].Handler)
1248 {
1249 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1250 AcpiGbl_HandlerList[i].Handler);
1251 }
1252 else
1253 {
1254 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1255 }
1256 }
1257
1258
1259 /* Other handlers that are installed throughout the namespace */
1260
1261 AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
1262
1263 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1264 ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
1265 NULL, NULL, NULL);
1266 }
1267
1268
1269 /*******************************************************************************
1270 *
1271 * FUNCTION: AcpiDbDisplayNonRootHandlers
1272 *
1273 * PARAMETERS: ACPI_WALK_CALLBACK
1274 *
1275 * RETURN: Status
1276 *
1277 * DESCRIPTION: Display information about all handlers installed for a
1278 * device object.
1279 *
1280 ******************************************************************************/
1281
1282 static ACPI_STATUS
AcpiDbDisplayNonRootHandlers(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)1283 AcpiDbDisplayNonRootHandlers (
1284 ACPI_HANDLE ObjHandle,
1285 UINT32 NestingLevel,
1286 void *Context,
1287 void **ReturnValue)
1288 {
1289 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
1290 ACPI_OPERAND_OBJECT *ObjDesc;
1291 ACPI_OPERAND_OBJECT *HandlerObj;
1292 char *Pathname;
1293
1294
1295 ObjDesc = AcpiNsGetAttachedObject (Node);
1296 if (!ObjDesc)
1297 {
1298 return (AE_OK);
1299 }
1300
1301 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1302 if (!Pathname)
1303 {
1304 return (AE_OK);
1305 }
1306
1307 /* Display all handlers associated with this device */
1308
1309 HandlerObj = ObjDesc->CommonNotify.Handler;
1310 while (HandlerObj)
1311 {
1312 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1313 AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
1314 HandlerObj->AddressSpace.SpaceId);
1315
1316 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
1317 (HandlerObj->AddressSpace.HandlerFlags &
1318 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1319 HandlerObj->AddressSpace.Handler);
1320
1321 AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
1322
1323 HandlerObj = HandlerObj->AddressSpace.Next;
1324 }
1325
1326 ACPI_FREE (Pathname);
1327 return (AE_OK);
1328 }
1329