dbdisply.c revision 1.14 1 /*******************************************************************************
2 *
3 * Module Name: dbdisply - debug display commands
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2018, 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.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 "acevents.h"
52 #include "acdebug.h"
53
54
55 #define _COMPONENT ACPI_CA_DEBUGGER
56 ACPI_MODULE_NAME ("dbdisply")
57
58 /* Local prototypes */
59
60 static void
61 AcpiDbDumpParserDescriptor (
62 ACPI_PARSE_OBJECT *Op);
63
64 static void *
65 AcpiDbGetPointer (
66 void *Target);
67
68 static ACPI_STATUS
69 AcpiDbDisplayNonRootHandlers (
70 ACPI_HANDLE ObjHandle,
71 UINT32 NestingLevel,
72 void *Context,
73 void **ReturnValue);
74
75 /*
76 * System handler information.
77 * Used for Handlers command, in AcpiDbDisplayHandlers.
78 */
79 #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
80 #define ACPI_HANDLER_NAME_STRING "%30s : "
81 #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
82 #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"
83 #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
84
85 /* All predefined Address Space IDs */
86
87 static ACPI_ADR_SPACE_TYPE AcpiGbl_SpaceIdList[] =
88 {
89 ACPI_ADR_SPACE_SYSTEM_MEMORY,
90 ACPI_ADR_SPACE_SYSTEM_IO,
91 ACPI_ADR_SPACE_PCI_CONFIG,
92 ACPI_ADR_SPACE_EC,
93 ACPI_ADR_SPACE_SMBUS,
94 ACPI_ADR_SPACE_CMOS,
95 ACPI_ADR_SPACE_PCI_BAR_TARGET,
96 ACPI_ADR_SPACE_IPMI,
97 ACPI_ADR_SPACE_GPIO,
98 ACPI_ADR_SPACE_GSBUS,
99 ACPI_ADR_SPACE_DATA_TABLE,
100 ACPI_ADR_SPACE_FIXED_HARDWARE
101 };
102
103 /* Global handler information */
104
105 typedef struct acpi_handler_info
106 {
107 void *Handler;
108 char *Name;
109
110 } ACPI_HANDLER_INFO;
111
112 static ACPI_HANDLER_INFO AcpiGbl_HandlerList[] =
113 {
114 {&AcpiGbl_GlobalNotify[0].Handler, __UNCONST("System Notifications")},
115 {&AcpiGbl_GlobalNotify[1].Handler, __UNCONST("Device Notifications")},
116 {&AcpiGbl_TableHandler, __UNCONST("ACPI Table Events")},
117 {&AcpiGbl_ExceptionHandler, __UNCONST("Control Method Exceptions")},
118 {&AcpiGbl_InterfaceHandler, __UNCONST("OSI Invocations")}
119 };
120
121
122 /*******************************************************************************
123 *
124 * FUNCTION: AcpiDbGetPointer
125 *
126 * PARAMETERS: Target - Pointer to string to be converted
127 *
128 * RETURN: Converted pointer
129 *
130 * DESCRIPTION: Convert an ascii pointer value to a real value
131 *
132 ******************************************************************************/
133
134 static void *
135 AcpiDbGetPointer (
136 void *Target)
137 {
138 void *ObjPtr;
139 ACPI_SIZE Address;
140
141
142 Address = strtoul (Target, NULL, 16);
143 ObjPtr = ACPI_TO_POINTER (Address);
144 return (ObjPtr);
145 }
146
147
148 /*******************************************************************************
149 *
150 * FUNCTION: AcpiDbDumpParserDescriptor
151 *
152 * PARAMETERS: Op - A parser Op descriptor
153 *
154 * RETURN: None
155 *
156 * DESCRIPTION: Display a formatted parser object
157 *
158 ******************************************************************************/
159
160 static void
161 AcpiDbDumpParserDescriptor (
162 ACPI_PARSE_OBJECT *Op)
163 {
164 const ACPI_OPCODE_INFO *Info;
165
166
167 Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
168
169 AcpiOsPrintf ("Parser Op Descriptor:\n");
170 AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
171
172 ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
173 Info->Name));
174
175 AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
176 AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
177 AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
178 }
179
180
181 /*******************************************************************************
182 *
183 * FUNCTION: AcpiDbDecodeAndDisplayObject
184 *
185 * PARAMETERS: Target - String with object to be displayed. Names
186 * and hex pointers are supported.
187 * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q)
188 *
189 * RETURN: None
190 *
191 * DESCRIPTION: Display a formatted ACPI object
192 *
193 ******************************************************************************/
194
195 void
196 AcpiDbDecodeAndDisplayObject (
197 char *Target,
198 char *OutputType)
199 {
200 void *ObjPtr;
201 ACPI_NAMESPACE_NODE *Node;
202 ACPI_OPERAND_OBJECT *ObjDesc;
203 UINT32 Display = DB_BYTE_DISPLAY;
204 char Buffer[80];
205 ACPI_BUFFER RetBuf;
206 ACPI_STATUS Status;
207 UINT32 Size;
208
209
210 if (!Target)
211 {
212 return;
213 }
214
215 /* Decode the output type */
216
217 if (OutputType)
218 {
219 AcpiUtStrupr (OutputType);
220 if (OutputType[0] == 'W')
221 {
222 Display = DB_WORD_DISPLAY;
223 }
224 else if (OutputType[0] == 'D')
225 {
226 Display = DB_DWORD_DISPLAY;
227 }
228 else if (OutputType[0] == 'Q')
229 {
230 Display = DB_QWORD_DISPLAY;
231 }
232 }
233
234 RetBuf.Length = sizeof (Buffer);
235 RetBuf.Pointer = Buffer;
236
237 /* Differentiate between a number and a name */
238
239 if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
240 {
241 ObjPtr = AcpiDbGetPointer (Target);
242 if (!AcpiOsReadable (ObjPtr, 16))
243 {
244 AcpiOsPrintf (
245 "Address %p is invalid in this address space\n",
246 ObjPtr);
247 return;
248 }
249
250 /* Decode the object type */
251
252 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
253 {
254 case ACPI_DESC_TYPE_NAMED:
255
256 /* This is a namespace Node */
257
258 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
259 {
260 AcpiOsPrintf (
261 "Cannot read entire Named object at address %p\n",
262 ObjPtr);
263 return;
264 }
265
266 Node = ObjPtr;
267 goto DumpNode;
268
269 case ACPI_DESC_TYPE_OPERAND:
270
271 /* This is a ACPI OPERAND OBJECT */
272
273 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
274 {
275 AcpiOsPrintf (
276 "Cannot read entire ACPI object at address %p\n",
277 ObjPtr);
278 return;
279 }
280
281 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT),
282 Display, ACPI_UINT32_MAX);
283 AcpiExDumpObjectDescriptor (ObjPtr, 1);
284 break;
285
286 case ACPI_DESC_TYPE_PARSER:
287
288 /* This is a Parser Op object */
289
290 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
291 {
292 AcpiOsPrintf (
293 "Cannot read entire Parser object at address %p\n",
294 ObjPtr);
295 return;
296 }
297
298 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT),
299 Display, ACPI_UINT32_MAX);
300 AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
301 break;
302
303 default:
304
305 /* Is not a recognizeable object */
306
307 AcpiOsPrintf (
308 "Not a known ACPI internal object, descriptor type %2.2X\n",
309 ACPI_GET_DESCRIPTOR_TYPE (ObjPtr));
310
311 Size = 16;
312 if (AcpiOsReadable (ObjPtr, 64))
313 {
314 Size = 64;
315 }
316
317 /* Just dump some memory */
318
319 AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
320 break;
321 }
322
323 return;
324 }
325
326 /* The parameter is a name string that must be resolved to a Named obj */
327
328 Node = AcpiDbLocalNsLookup (Target);
329 if (!Node)
330 {
331 return;
332 }
333
334
335 DumpNode:
336 /* Now dump the NS node */
337
338 Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
339 if (ACPI_FAILURE (Status))
340 {
341 AcpiOsPrintf ("Could not convert name to pathname\n");
342 }
343
344 else
345 {
346 AcpiOsPrintf ("Object %p: Namespace Node - Pathname: %s\n",
347 Node, (char *) RetBuf.Pointer);
348 }
349
350 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
351 {
352 AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
353 return;
354 }
355
356 AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
357 Display, ACPI_UINT32_MAX);
358 AcpiExDumpNamespaceNode (Node, 1);
359
360 ObjDesc = AcpiNsGetAttachedObject (Node);
361 if (ObjDesc)
362 {
363 AcpiOsPrintf ("\nAttached Object %p:", ObjDesc);
364 if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
365 {
366 AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
367 ObjDesc);
368 return;
369 }
370
371 if (ACPI_GET_DESCRIPTOR_TYPE (
372 ((ACPI_NAMESPACE_NODE *) ObjDesc)) == ACPI_DESC_TYPE_NAMED)
373 {
374 AcpiOsPrintf (" Namespace Node - ");
375 Status = AcpiGetName ((ACPI_NAMESPACE_NODE *) ObjDesc,
376 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
377 if (ACPI_FAILURE (Status))
378 {
379 AcpiOsPrintf ("Could not convert name to pathname\n");
380 }
381 else
382 {
383 AcpiOsPrintf ("Pathname: %s",
384 (char *) RetBuf.Pointer);
385 }
386
387 AcpiOsPrintf ("\n");
388 AcpiUtDebugDumpBuffer ((void *) ObjDesc,
389 sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);
390 }
391 else
392 {
393 AcpiOsPrintf ("\n");
394 AcpiUtDebugDumpBuffer ((void *) ObjDesc,
395 sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
396 }
397
398 AcpiExDumpObjectDescriptor (ObjDesc, 1);
399 }
400 }
401
402
403 /*******************************************************************************
404 *
405 * FUNCTION: AcpiDbDisplayMethodInfo
406 *
407 * PARAMETERS: StartOp - Root of the control method parse tree
408 *
409 * RETURN: None
410 *
411 * DESCRIPTION: Display information about the current method
412 *
413 ******************************************************************************/
414
415 void
416 AcpiDbDisplayMethodInfo (
417 ACPI_PARSE_OBJECT *StartOp)
418 {
419 ACPI_WALK_STATE *WalkState;
420 ACPI_OPERAND_OBJECT *ObjDesc;
421 ACPI_NAMESPACE_NODE *Node;
422 ACPI_PARSE_OBJECT *RootOp;
423 ACPI_PARSE_OBJECT *Op;
424 const ACPI_OPCODE_INFO *OpInfo;
425 UINT32 NumOps = 0;
426 UINT32 NumOperands = 0;
427 UINT32 NumOperators = 0;
428 UINT32 NumRemainingOps = 0;
429 UINT32 NumRemainingOperands = 0;
430 UINT32 NumRemainingOperators = 0;
431 BOOLEAN CountRemaining = FALSE;
432
433
434 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
435 if (!WalkState)
436 {
437 AcpiOsPrintf ("There is no method currently executing\n");
438 return;
439 }
440
441 ObjDesc = WalkState->MethodDesc;
442 Node = WalkState->MethodNode;
443
444 AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
445 AcpiUtGetNodeName (Node));
446 AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
447 (UINT32) ObjDesc->Method.ParamCount,
448 (UINT32) ObjDesc->Method.SyncLevel);
449
450 RootOp = StartOp;
451 while (RootOp->Common.Parent)
452 {
453 RootOp = RootOp->Common.Parent;
454 }
455
456 Op = RootOp;
457
458 while (Op)
459 {
460 if (Op == StartOp)
461 {
462 CountRemaining = TRUE;
463 }
464
465 NumOps++;
466 if (CountRemaining)
467 {
468 NumRemainingOps++;
469 }
470
471 /* Decode the opcode */
472
473 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
474 switch (OpInfo->Class)
475 {
476 case AML_CLASS_ARGUMENT:
477
478 if (CountRemaining)
479 {
480 NumRemainingOperands++;
481 }
482
483 NumOperands++;
484 break;
485
486 case AML_CLASS_UNKNOWN:
487
488 /* Bad opcode or ASCII character */
489
490 continue;
491
492 default:
493
494 if (CountRemaining)
495 {
496 NumRemainingOperators++;
497 }
498
499 NumOperators++;
500 break;
501 }
502
503 Op = AcpiPsGetDepthNext (StartOp, Op);
504 }
505
506 AcpiOsPrintf (
507 "Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
508 NumOps, NumOperators, NumOperands);
509
510 AcpiOsPrintf (
511 "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
512 NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
513 }
514
515
516 /*******************************************************************************
517 *
518 * FUNCTION: AcpiDbDisplayLocals
519 *
520 * PARAMETERS: None
521 *
522 * RETURN: None
523 *
524 * DESCRIPTION: Display all locals for the currently running control method
525 *
526 ******************************************************************************/
527
528 void
529 AcpiDbDisplayLocals (
530 void)
531 {
532 ACPI_WALK_STATE *WalkState;
533
534
535 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
536 if (!WalkState)
537 {
538 AcpiOsPrintf ("There is no method currently executing\n");
539 return;
540 }
541
542 AcpiDbDecodeLocals (WalkState);
543 }
544
545
546 /*******************************************************************************
547 *
548 * FUNCTION: AcpiDbDisplayArguments
549 *
550 * PARAMETERS: None
551 *
552 * RETURN: None
553 *
554 * DESCRIPTION: Display all arguments for the currently running control method
555 *
556 ******************************************************************************/
557
558 void
559 AcpiDbDisplayArguments (
560 void)
561 {
562 ACPI_WALK_STATE *WalkState;
563
564
565 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
566 if (!WalkState)
567 {
568 AcpiOsPrintf ("There is no method currently executing\n");
569 return;
570 }
571
572 AcpiDbDecodeArguments (WalkState);
573 }
574
575
576 /*******************************************************************************
577 *
578 * FUNCTION: AcpiDbDisplayResults
579 *
580 * PARAMETERS: None
581 *
582 * RETURN: None
583 *
584 * DESCRIPTION: Display current contents of a method result stack
585 *
586 ******************************************************************************/
587
588 void
589 AcpiDbDisplayResults (
590 void)
591 {
592 UINT32 i;
593 ACPI_WALK_STATE *WalkState;
594 ACPI_OPERAND_OBJECT *ObjDesc;
595 UINT32 ResultCount = 0;
596 ACPI_NAMESPACE_NODE *Node;
597 ACPI_GENERIC_STATE *Frame;
598 UINT32 Index; /* Index onto current frame */
599
600
601 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
602 if (!WalkState)
603 {
604 AcpiOsPrintf ("There is no method currently executing\n");
605 return;
606 }
607
608 ObjDesc = WalkState->MethodDesc;
609 Node = WalkState->MethodNode;
610
611 if (WalkState->Results)
612 {
613 ResultCount = WalkState->ResultCount;
614 }
615
616 AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
617 AcpiUtGetNodeName (Node), ResultCount);
618
619 /* From the top element of result stack */
620
621 Frame = WalkState->Results;
622 Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
623
624 for (i = 0; i < ResultCount; i++)
625 {
626 ObjDesc = Frame->Results.ObjDesc[Index];
627 AcpiOsPrintf ("Result%u: ", i);
628 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
629
630 if (Index == 0)
631 {
632 Frame = Frame->Results.Next;
633 Index = ACPI_RESULTS_FRAME_OBJ_NUM;
634 }
635
636 Index--;
637 }
638 }
639
640
641 /*******************************************************************************
642 *
643 * FUNCTION: AcpiDbDisplayCallingTree
644 *
645 * PARAMETERS: None
646 *
647 * RETURN: None
648 *
649 * DESCRIPTION: Display current calling tree of nested control methods
650 *
651 ******************************************************************************/
652
653 void
654 AcpiDbDisplayCallingTree (
655 void)
656 {
657 ACPI_WALK_STATE *WalkState;
658 ACPI_NAMESPACE_NODE *Node;
659
660
661 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
662 if (!WalkState)
663 {
664 AcpiOsPrintf ("There is no method currently executing\n");
665 return;
666 }
667
668 Node = WalkState->MethodNode;
669 AcpiOsPrintf ("Current Control Method Call Tree\n");
670
671 while (WalkState)
672 {
673 Node = WalkState->MethodNode;
674 AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node));
675
676 WalkState = WalkState->Next;
677 }
678 }
679
680
681 /*******************************************************************************
682 *
683 * FUNCTION: AcpiDbDisplayObjectType
684 *
685 * PARAMETERS: ObjectArg - User entered NS node handle
686 *
687 * RETURN: None
688 *
689 * DESCRIPTION: Display type of an arbitrary NS node
690 *
691 ******************************************************************************/
692
693 void
694 AcpiDbDisplayObjectType (
695 char *ObjectArg)
696 {
697 ACPI_SIZE Arg;
698 ACPI_HANDLE Handle;
699 ACPI_DEVICE_INFO *Info;
700 ACPI_STATUS Status;
701 UINT32 i;
702
703
704 Arg = strtoul (ObjectArg, NULL, 16);
705 Handle = ACPI_TO_POINTER (Arg);
706
707 Status = AcpiGetObjectInfo (Handle, &Info);
708 if (ACPI_FAILURE (Status))
709 {
710 AcpiOsPrintf ("Could not get object info, %s\n",
711 AcpiFormatException (Status));
712 return;
713 }
714
715 AcpiOsPrintf ("ADR: %8.8X%8.8X, Flags: %X\n",
716 ACPI_FORMAT_UINT64 (Info->Address), Info->Flags);
717
718 AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
719 Info->HighestDstates[0], Info->HighestDstates[1],
720 Info->HighestDstates[2], Info->HighestDstates[3]);
721
722 AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
723 Info->LowestDstates[0], Info->LowestDstates[1],
724 Info->LowestDstates[2], Info->LowestDstates[3],
725 Info->LowestDstates[4]);
726
727 if (Info->Valid & ACPI_VALID_HID)
728 {
729 AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
730 }
731
732 if (Info->Valid & ACPI_VALID_UID)
733 {
734 AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
735 }
736
737 if (Info->Valid & ACPI_VALID_CID)
738 {
739 for (i = 0; i < Info->CompatibleIdList.Count; i++)
740 {
741 AcpiOsPrintf ("CID %u: %s\n", i,
742 Info->CompatibleIdList.Ids[i].String);
743 }
744 }
745
746 ACPI_FREE (Info);
747 }
748
749
750 /*******************************************************************************
751 *
752 * FUNCTION: AcpiDbDisplayResultObject
753 *
754 * PARAMETERS: ObjDesc - Object to be displayed
755 * WalkState - Current walk state
756 *
757 * RETURN: None
758 *
759 * DESCRIPTION: Display the result of an AML opcode
760 *
761 * Note: Curently only displays the result object if we are single stepping.
762 * However, this output may be useful in other contexts and could be enabled
763 * to do so if needed.
764 *
765 ******************************************************************************/
766
767 void
768 AcpiDbDisplayResultObject (
769 ACPI_OPERAND_OBJECT *ObjDesc,
770 ACPI_WALK_STATE *WalkState)
771 {
772
773 #ifndef ACPI_APPLICATION
774 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
775 {
776 return;
777 }
778 #endif
779
780 /* Only display if single stepping */
781
782 if (!AcpiGbl_CmSingleStep)
783 {
784 return;
785 }
786
787 AcpiOsPrintf ("ResultObj: ");
788 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
789 AcpiOsPrintf ("\n");
790 }
791
792
793 /*******************************************************************************
794 *
795 * FUNCTION: AcpiDbDisplayArgumentObject
796 *
797 * PARAMETERS: ObjDesc - Object to be displayed
798 * WalkState - Current walk state
799 *
800 * RETURN: None
801 *
802 * DESCRIPTION: Display the result of an AML opcode
803 *
804 ******************************************************************************/
805
806 void
807 AcpiDbDisplayArgumentObject (
808 ACPI_OPERAND_OBJECT *ObjDesc,
809 ACPI_WALK_STATE *WalkState)
810 {
811
812 #ifndef ACPI_APPLICATION
813 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
814 {
815 return;
816 }
817 #endif
818
819 if (!AcpiGbl_CmSingleStep)
820 {
821 return;
822 }
823
824 AcpiOsPrintf ("ArgObj: ");
825 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
826 }
827
828
829 #if (!ACPI_REDUCED_HARDWARE)
830 /*******************************************************************************
831 *
832 * FUNCTION: AcpiDbDisplayGpes
833 *
834 * PARAMETERS: None
835 *
836 * RETURN: None
837 *
838 * DESCRIPTION: Display the current GPE structures
839 *
840 ******************************************************************************/
841
842 void
843 AcpiDbDisplayGpes (
844 void)
845 {
846 ACPI_GPE_BLOCK_INFO *GpeBlock;
847 ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
848 ACPI_GPE_EVENT_INFO *GpeEventInfo;
849 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
850 const char *GpeType;
851 ACPI_GPE_NOTIFY_INFO *Notify;
852 UINT32 GpeIndex;
853 UINT32 Block = 0;
854 UINT32 i;
855 UINT32 j;
856 UINT32 Count;
857 char Buffer[80];
858 ACPI_BUFFER RetBuf;
859 ACPI_STATUS Status;
860
861
862 RetBuf.Length = sizeof (Buffer);
863 RetBuf.Pointer = Buffer;
864
865 Block = 0;
866
867 /* Walk the GPE lists */
868
869 GpeXruptInfo = AcpiGbl_GpeXruptListHead;
870 while (GpeXruptInfo)
871 {
872 GpeBlock = GpeXruptInfo->GpeBlockListHead;
873 while (GpeBlock)
874 {
875 Status = AcpiGetName (GpeBlock->Node,
876 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
877 if (ACPI_FAILURE (Status))
878 {
879 AcpiOsPrintf ("Could not convert name to pathname\n");
880 }
881
882 if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
883 {
884 GpeType = "FADT-defined GPE block";
885 }
886 else
887 {
888 GpeType = "GPE Block Device";
889 }
890
891 AcpiOsPrintf (
892 "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",
893 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
894
895 AcpiOsPrintf (
896 " Registers: %u (%u GPEs)\n",
897 GpeBlock->RegisterCount, GpeBlock->GpeCount);
898
899 AcpiOsPrintf (
900 " GPE range: 0x%X to 0x%X on interrupt %u\n",
901 GpeBlock->BlockBaseNumber,
902 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
903 GpeXruptInfo->InterruptNumber);
904
905 AcpiOsPrintf (
906 " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
907 GpeBlock->RegisterInfo,
908 ACPI_FORMAT_UINT64 (
909 GpeBlock->RegisterInfo->StatusAddress.Address),
910 ACPI_FORMAT_UINT64 (
911 GpeBlock->RegisterInfo->EnableAddress.Address));
912
913 AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo);
914
915 /* Examine each GPE Register within the block */
916
917 for (i = 0; i < GpeBlock->RegisterCount; i++)
918 {
919 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
920
921 AcpiOsPrintf (
922 " Reg %u: (GPE %.2X-%.2X) "
923 "RunEnable %2.2X WakeEnable %2.2X"
924 " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
925 i, GpeRegisterInfo->BaseGpeNumber,
926 GpeRegisterInfo->BaseGpeNumber +
927 (ACPI_GPE_REGISTER_WIDTH - 1),
928 GpeRegisterInfo->EnableForRun,
929 GpeRegisterInfo->EnableForWake,
930 ACPI_FORMAT_UINT64 (
931 GpeRegisterInfo->StatusAddress.Address),
932 ACPI_FORMAT_UINT64 (
933 GpeRegisterInfo->EnableAddress.Address));
934
935 /* Now look at the individual GPEs in this byte register */
936
937 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
938 {
939 GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
940 GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
941
942 if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
943 ACPI_GPE_DISPATCH_NONE)
944 {
945 /* This GPE is not used (no method or handler), ignore it */
946
947 continue;
948 }
949
950 AcpiOsPrintf (
951 " GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",
952 GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
953 GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
954
955 /* Decode the flags byte */
956
957 if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
958 {
959 AcpiOsPrintf ("Level, ");
960 }
961 else
962 {
963 AcpiOsPrintf ("Edge, ");
964 }
965
966 if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
967 {
968 AcpiOsPrintf ("CanWake, ");
969 }
970 else
971 {
972 AcpiOsPrintf ("RunOnly, ");
973 }
974
975 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags))
976 {
977 case ACPI_GPE_DISPATCH_NONE:
978
979 AcpiOsPrintf ("NotUsed");
980 break;
981
982 case ACPI_GPE_DISPATCH_METHOD:
983
984 AcpiOsPrintf ("Method");
985 break;
986
987 case ACPI_GPE_DISPATCH_HANDLER:
988
989 AcpiOsPrintf ("Handler");
990 break;
991
992 case ACPI_GPE_DISPATCH_NOTIFY:
993
994 Count = 0;
995 Notify = GpeEventInfo->Dispatch.NotifyList;
996 while (Notify)
997 {
998 Count++;
999 Notify = Notify->Next;
1000 }
1001
1002 AcpiOsPrintf ("Implicit Notify on %u devices",
1003 Count);
1004 break;
1005
1006 case ACPI_GPE_DISPATCH_RAW_HANDLER:
1007
1008 AcpiOsPrintf ("RawHandler");
1009 break;
1010
1011 default:
1012
1013 AcpiOsPrintf ("UNKNOWN: %X",
1014 ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags));
1015 break;
1016 }
1017
1018 AcpiOsPrintf (")\n");
1019 }
1020 }
1021
1022 Block++;
1023 GpeBlock = GpeBlock->Next;
1024 }
1025
1026 GpeXruptInfo = GpeXruptInfo->Next;
1027 }
1028 }
1029 #endif /* !ACPI_REDUCED_HARDWARE */
1030
1031
1032 /*******************************************************************************
1033 *
1034 * FUNCTION: AcpiDbDisplayHandlers
1035 *
1036 * PARAMETERS: None
1037 *
1038 * RETURN: None
1039 *
1040 * DESCRIPTION: Display the currently installed global handlers
1041 *
1042 ******************************************************************************/
1043
1044 void
1045 AcpiDbDisplayHandlers (
1046 void)
1047 {
1048 ACPI_OPERAND_OBJECT *ObjDesc;
1049 ACPI_OPERAND_OBJECT *HandlerObj;
1050 ACPI_ADR_SPACE_TYPE SpaceId;
1051 UINT32 i;
1052
1053
1054 /* Operation region handlers */
1055
1056 AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
1057
1058 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
1059 if (ObjDesc)
1060 {
1061 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
1062 {
1063 SpaceId = AcpiGbl_SpaceIdList[i];
1064
1065 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1066 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
1067
1068 HandlerObj = AcpiEvFindRegionHandler (
1069 SpaceId, ObjDesc->CommonNotify.Handler);
1070 if (HandlerObj)
1071 {
1072 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1073 (HandlerObj->AddressSpace.HandlerFlags &
1074 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
1075 "Default" : "User",
1076 HandlerObj->AddressSpace.Handler);
1077
1078 goto FoundHandler;
1079 }
1080
1081 /* There is no handler for this SpaceId */
1082
1083 AcpiOsPrintf ("None\n");
1084
1085 FoundHandler:;
1086 }
1087
1088 /* Find all handlers for user-defined SpaceIDs */
1089
1090 HandlerObj = ObjDesc->CommonNotify.Handler;
1091 while (HandlerObj)
1092 {
1093 if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
1094 {
1095 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1096 "User-defined ID", HandlerObj->AddressSpace.SpaceId);
1097 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1098 (HandlerObj->AddressSpace.HandlerFlags &
1099 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
1100 "Default" : "User",
1101 HandlerObj->AddressSpace.Handler);
1102 }
1103
1104 HandlerObj = HandlerObj->AddressSpace.Next;
1105 }
1106 }
1107
1108 #if (!ACPI_REDUCED_HARDWARE)
1109
1110 /* Fixed event handlers */
1111
1112 AcpiOsPrintf ("\nFixed Event Handlers:\n");
1113
1114 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
1115 {
1116 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
1117 if (AcpiGbl_FixedEventHandlers[i].Handler)
1118 {
1119 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1120 AcpiGbl_FixedEventHandlers[i].Handler);
1121 }
1122 else
1123 {
1124 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1125 }
1126 }
1127
1128 #endif /* !ACPI_REDUCED_HARDWARE */
1129
1130 /* Miscellaneous global handlers */
1131
1132 AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
1133
1134 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
1135 {
1136 AcpiOsPrintf (ACPI_HANDLER_NAME_STRING,
1137 AcpiGbl_HandlerList[i].Name);
1138
1139 if (AcpiGbl_HandlerList[i].Handler)
1140 {
1141 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1142 AcpiGbl_HandlerList[i].Handler);
1143 }
1144 else
1145 {
1146 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1147 }
1148 }
1149
1150
1151 /* Other handlers that are installed throughout the namespace */
1152
1153 AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
1154
1155 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1156 ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
1157 NULL, NULL, NULL);
1158 }
1159
1160
1161 /*******************************************************************************
1162 *
1163 * FUNCTION: AcpiDbDisplayNonRootHandlers
1164 *
1165 * PARAMETERS: ACPI_WALK_CALLBACK
1166 *
1167 * RETURN: Status
1168 *
1169 * DESCRIPTION: Display information about all handlers installed for a
1170 * device object.
1171 *
1172 ******************************************************************************/
1173
1174 static ACPI_STATUS
1175 AcpiDbDisplayNonRootHandlers (
1176 ACPI_HANDLE ObjHandle,
1177 UINT32 NestingLevel,
1178 void *Context,
1179 void **ReturnValue)
1180 {
1181 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
1182 ACPI_OPERAND_OBJECT *ObjDesc;
1183 ACPI_OPERAND_OBJECT *HandlerObj;
1184 char *Pathname;
1185
1186
1187 ObjDesc = AcpiNsGetAttachedObject (Node);
1188 if (!ObjDesc)
1189 {
1190 return (AE_OK);
1191 }
1192
1193 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1194 if (!Pathname)
1195 {
1196 return (AE_OK);
1197 }
1198
1199 /* Display all handlers associated with this device */
1200
1201 HandlerObj = ObjDesc->CommonNotify.Handler;
1202 while (HandlerObj)
1203 {
1204 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1205 AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
1206 HandlerObj->AddressSpace.SpaceId);
1207
1208 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
1209 (HandlerObj->AddressSpace.HandlerFlags &
1210 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1211 HandlerObj->AddressSpace.Handler);
1212
1213 AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
1214
1215 HandlerObj = HandlerObj->AddressSpace.Next;
1216 }
1217
1218 ACPI_FREE (Pathname);
1219 return (AE_OK);
1220 }
1221