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