Sync ACPICA with Intel's version 20180508 (from previously 20170831).
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / aslxrefout.c
blob0e548ece23b614e9eda61349a4db0e9d095ebf28
1 /******************************************************************************
3 * Module Name: aslxrefout.c - support for optional cross-reference file
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
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.
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
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;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
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.
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.
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.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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.
80 * 4. Disclaimer and Export Compliance
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.
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.
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
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.
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.
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.
150 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "acnamesp.h"
155 #include "acparser.h"
156 #include "amlcode.h"
158 #define _COMPONENT ACPI_COMPILER
159 ACPI_MODULE_NAME ("aslxrefout")
162 /* Local prototypes */
164 static ACPI_STATUS
165 OtXrefWalkPart2 (
166 ACPI_PARSE_OBJECT *Op,
167 UINT32 Level,
168 void *Context);
170 static ACPI_STATUS
171 OtXrefWalkPart3 (
172 ACPI_PARSE_OBJECT *Op,
173 UINT32 Level,
174 void *Context);
176 static ACPI_STATUS
177 OtXrefAnalysisWalkPart1 (
178 ACPI_PARSE_OBJECT *Op,
179 UINT32 Level,
180 void *Context);
183 static ACPI_STATUS
184 OtXrefAnalysisWalkPart2 (
185 ACPI_PARSE_OBJECT *Op,
186 UINT32 Level,
187 void *Context);
189 static ACPI_STATUS
190 OtXrefAnalysisWalkPart3 (
191 ACPI_PARSE_OBJECT *Op,
192 UINT32 Level,
193 void *Context);
196 /*******************************************************************************
198 * FUNCTION: OtPrintHeaders
200 * PARAMETERS: Message - Main header message
202 * RETURN: None
204 * DESCRIPTION: Emits the main header message along with field descriptions
206 ******************************************************************************/
208 void
209 OtPrintHeaders (
210 char *Message)
212 UINT32 Length;
215 Length = strlen (Message);
217 FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\n%s\n", Message);
218 while (Length)
220 FlPrintFile (ASL_FILE_XREF_OUTPUT, "-");
221 Length--;
224 FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nLineno %-40s Description\n",
225 "Full Pathname");
229 /*******************************************************************************
231 * FUNCTION: OtCreateXrefFile
233 * PARAMETERS: None
235 * RETURN: None
237 * DESCRIPTION Main entry point for parts 2 and 3 of the cross-reference
238 * file.
240 ******************************************************************************/
242 void
243 OtCreateXrefFile (
244 void)
246 ASL_XREF_INFO XrefInfo;
249 /* Build cross-reference output file if requested */
251 if (!Gbl_CrossReferenceOutput)
253 return;
256 memset (&XrefInfo, 0, sizeof (ASL_XREF_INFO));
258 /* Cross-reference output file, part 2 (Method invocations) */
260 OtPrintHeaders ("Part 2: Method Reference Map "
261 "(Invocations of each user-defined control method)");
263 TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
264 OtXrefWalkPart2, NULL, &XrefInfo);
266 /* Cross-reference output file, part 3 (All other object refs) */
268 OtPrintHeaders ("Part 3: Full Object Reference Map "
269 "(Methods that reference each object in namespace");
271 TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
272 OtXrefWalkPart3, NULL, &XrefInfo);
274 /* Cross-reference summary */
276 FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n\nObject Summary\n");
278 FlPrintFile (ASL_FILE_XREF_OUTPUT,
279 "\nTotal methods: %u\n",
280 XrefInfo.TotalPredefinedMethods + XrefInfo.TotalUserMethods);
281 FlPrintFile (ASL_FILE_XREF_OUTPUT,
282 "Total predefined methods: %u\n",
283 XrefInfo.TotalPredefinedMethods);
285 FlPrintFile (ASL_FILE_XREF_OUTPUT,
286 "\nTotal user methods: %u\n",
287 XrefInfo.TotalUserMethods);
288 FlPrintFile (ASL_FILE_XREF_OUTPUT,
289 "Total unreferenced user methods %u\n",
290 XrefInfo.TotalUnreferenceUserMethods);
292 FlPrintFile (ASL_FILE_XREF_OUTPUT,
293 "\nTotal defined objects: %u\n",
294 XrefInfo.TotalObjects);
295 FlPrintFile (ASL_FILE_XREF_OUTPUT,
296 "Total unreferenced objects: %u\n",
297 XrefInfo.TotalUnreferencedObjects);
302 * Part 1 of the cross reference file. This part emits the namespace objects
303 * that are referenced by each control method in the namespace.
305 * Part 2 and 3 are below part 1.
308 /*******************************************************************************
310 * FUNCTION: OtXrefWalkPart1
312 * PARAMETERS: Op - Current parse Op
313 * Level - Current tree nesting level
314 * MethodInfo - Info block for the current method
317 * RETURN: None
319 * DESCRIPTION: Entry point for the creation of the method call reference map.
320 * For each control method in the namespace, all other methods
321 * that invoke the method are listed. Predefined names/methods
322 * that start with an underscore are ignored, because these are
323 * essentially external/public interfaces.
325 * DESCRIPTION: Entry point for the creation of the object reference map.
326 * For each control method in the namespace, all objects that
327 * are referenced by the method are listed.
329 * Called during a normal namespace walk, once per namespace
330 * object. (MtMethodAnalysisWalkBegin)
332 ******************************************************************************/
334 void
335 OtXrefWalkPart1 (
336 ACPI_PARSE_OBJECT *Op,
337 UINT32 Level,
338 ASL_METHOD_INFO *MethodInfo)
340 ACPI_NAMESPACE_NODE *Node;
341 ACPI_PARSE_OBJECT *NextOp;
342 ACPI_PARSE_OBJECT *FieldOp;
343 char *ParentPath;
344 UINT32 Length;
345 ACPI_STATUS Status;
348 switch (Op->Asl.ParseOpcode)
350 case PARSEOP_NAMESEG:
351 case PARSEOP_NAMESTRING:
352 case PARSEOP_METHODCALL:
354 if (!MethodInfo ||
355 (MethodInfo->Op->Asl.Child == Op) ||
356 !Op->Asl.Node)
358 break;
361 MethodInfo->CurrentOp = Op;
362 Node = Op->Asl.Node;
364 /* Find all objects referenced by this method */
366 Status = TrWalkParseTree (MethodInfo->Op, ASL_WALK_VISIT_DOWNWARD,
367 OtXrefAnalysisWalkPart1, NULL, MethodInfo);
369 if (Status == AE_CTRL_TERMINATE)
371 ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
373 FlPrintFile (ASL_FILE_XREF_OUTPUT, " %-40s %s",
374 ParentPath, AcpiUtGetTypeName (Node->Type));
375 ACPI_FREE (ParentPath);
377 switch (Node->Type)
379 /* Handle externals */
381 case ACPI_TYPE_ANY:
382 case ACPI_TYPE_FIELD_UNIT:
384 FlPrintFile (ASL_FILE_XREF_OUTPUT, " <External Object>");
385 break;
387 case ACPI_TYPE_INTEGER:
389 FlPrintFile (ASL_FILE_XREF_OUTPUT, " %8.8X%8.8X",
390 ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
391 break;
393 case ACPI_TYPE_METHOD:
395 FlPrintFile (ASL_FILE_XREF_OUTPUT, " Invocation (%u args)",
396 Node->ArgCount);
397 break;
399 case ACPI_TYPE_BUFFER_FIELD:
401 NextOp = Node->Op; /* Create Buffer Field Op */
402 switch (NextOp->Asl.ParseOpcode)
404 case PARSEOP_CREATEBITFIELD:
405 Length = 1;
406 break;
408 case PARSEOP_CREATEBYTEFIELD:
409 Length = 8;
410 break;
412 case PARSEOP_CREATEWORDFIELD:
413 Length = 16;
414 break;
416 case PARSEOP_CREATEDWORDFIELD:
417 Length = 32;
418 break;
420 case PARSEOP_CREATEQWORDFIELD:
421 Length = 64;
422 break;
424 default:
425 Length = 0;
426 break;
429 NextOp = NextOp->Asl.Child; /* Buffer name */
431 if (!NextOp->Asl.ExternalName)
433 FlPrintFile (ASL_FILE_XREF_OUTPUT, " in Arg/Local");
435 else
437 ParentPath = AcpiNsGetNormalizedPathname (
438 NextOp->Asl.Node, TRUE);
440 FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Buffer %s",
441 Length, ParentPath);
442 ACPI_FREE (ParentPath);
444 break;
446 case ACPI_TYPE_LOCAL_REGION_FIELD:
448 NextOp = Node->Op;
449 FieldOp = NextOp->Asl.Parent;
450 NextOp = FieldOp->Asl.Child;
452 ParentPath = AcpiNsGetNormalizedPathname (
453 NextOp->Asl.Node, TRUE);
455 FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Region %s",
456 (UINT32) Node->Op->Asl.Child->Asl.Value.Integer,
457 ParentPath);
458 ACPI_FREE (ParentPath);
460 if (FieldOp->Asl.ParseOpcode == PARSEOP_FIELD)
462 Node = NextOp->Asl.Node; /* Region node */
463 NextOp = Node->Op; /* PARSEOP_REGION */
464 NextOp = NextOp->Asl.Child; /* Region name */
465 NextOp = NextOp->Asl.Next;
467 /* Get region space/addr/len? */
469 FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%s)",
470 AcpiUtGetRegionName ((UINT8)
471 NextOp->Asl.Value.Integer));
473 break;
475 default:
476 break;
479 FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n");
481 break;
483 case PARSEOP_METHOD:
485 ParentPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE);
487 FlPrintFile (ASL_FILE_XREF_OUTPUT,
488 "\n[%5u] %-40s %s Declaration (%u args)\n",
489 Op->Asl.LogicalLineNumber, ParentPath,
490 AcpiUtGetTypeName (Op->Asl.Node->Type), Op->Asl.Node->ArgCount);
492 ACPI_FREE (ParentPath);
493 break;
495 default:
496 break;
501 /*******************************************************************************
503 * FUNCTION: OtXrefAnalysisWalkPart1
505 * PARAMETERS: ASL_WALK_CALLBACK
507 * RETURN: Status
509 * DESCRIPTION: Secondary walk for cross-reference part 1.
511 ******************************************************************************/
513 static ACPI_STATUS
514 OtXrefAnalysisWalkPart1 (
515 ACPI_PARSE_OBJECT *Op,
516 UINT32 Level,
517 void *Context)
519 ASL_METHOD_INFO *MethodInfo = (ASL_METHOD_INFO *) Context;
520 ACPI_PARSE_OBJECT *Next;
523 /* Only interested in name string Ops -- ignore all others */
525 if ((Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
526 (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
527 (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
529 return (AE_OK);
532 /* No node means a locally declared object -- ignore */
534 if (!Op->Asl.Node)
536 return (AE_OK);
539 /* When we encounter the source Op, we are done */
541 Next = MethodInfo->CurrentOp;
542 if (Next == Op)
544 return (AE_CTRL_TERMINATE);
547 /* If we have a name match, this Op is a duplicate */
549 if ((Next->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
550 (Next->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
551 (Next->Asl.ParseOpcode == PARSEOP_METHODCALL))
553 if (!strcmp (Op->Asl.ExternalName, Next->Asl.ExternalName))
555 return (AE_ALREADY_EXISTS);
559 return (AE_OK);
564 * Part 2 of the cross reference file. This part emits the names of each
565 * non-predefined method in the namespace (user methods), along with the
566 * names of each control method that references that method.
569 /*******************************************************************************
571 * FUNCTION: OtXrefWalkPart2
573 * PARAMETERS: ASL_WALK_CALLBACK
575 * RETURN: Status
577 * DESCRIPTION: For each control method in the namespace, we will re-walk the
578 * namespace to find each and every invocation of that control
579 * method. Brute force, but does not matter, even for large
580 * namespaces. Ignore predefined names (start with underscore).
582 ******************************************************************************/
584 static ACPI_STATUS
585 OtXrefWalkPart2 (
586 ACPI_PARSE_OBJECT *Op,
587 UINT32 Level,
588 void *Context)
590 ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context;
591 ACPI_NAMESPACE_NODE *Node;
592 char *ParentPath;
595 /* Looking for Method Declaration Ops only */
597 if (!Op->Asl.Node ||
598 (Op->Asl.ParseOpcode != PARSEOP_METHOD))
600 return (AE_OK);
603 /* Ignore predefined names */
605 if (Op->Asl.Node->Name.Ascii[0] == '_')
607 XrefInfo->TotalPredefinedMethods++;
608 return (AE_OK);
611 Node = Op->Asl.Node;
612 ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
614 FlPrintFile (ASL_FILE_XREF_OUTPUT,
615 "\n[%5u] %-40s %s Declaration (%u args)\n",
616 Op->Asl.LogicalLineNumber, ParentPath,
617 AcpiUtGetTypeName (Node->Type), Node->ArgCount);
619 XrefInfo->TotalUserMethods++;
620 XrefInfo->ThisMethodInvocations = 0;
621 XrefInfo->MethodOp = Op;
623 (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
624 OtXrefAnalysisWalkPart2, NULL, XrefInfo);
626 if (!XrefInfo->ThisMethodInvocations)
628 FlPrintFile (ASL_FILE_XREF_OUTPUT,
629 " Zero invocations of this method in this module\n");
630 XrefInfo->TotalUnreferenceUserMethods++;
632 else
634 FlPrintFile (ASL_FILE_XREF_OUTPUT,
635 " %u invocations of method %s in this module\n",
636 XrefInfo->ThisMethodInvocations, ParentPath);
639 ACPI_FREE (ParentPath);
640 return (AE_OK);
644 /*******************************************************************************
646 * FUNCTION: OtXrefAnalysisWalkPart2
648 * PARAMETERS: ASL_WALK_CALLBACK
650 * RETURN: Status
652 * DESCRIPTION: For every Op that is a method invocation, emit a reference
653 * line if the Op is invoking the target method.
655 ******************************************************************************/
657 static ACPI_STATUS
658 OtXrefAnalysisWalkPart2 (
659 ACPI_PARSE_OBJECT *Op,
660 UINT32 Level,
661 void *Context)
663 ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context;
664 ACPI_PARSE_OBJECT *CallerOp;
665 char *CallerFullPathname;
668 /* Looking for MethodCall Ops only */
670 if (!Op->Asl.Node ||
671 (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
673 return (AE_OK);
676 /* If not a match to the target method, we are done */
678 if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node)
680 return (AE_CTRL_DEPTH);
683 /* Find parent method to get method caller namepath */
685 CallerOp = Op->Asl.Parent;
686 while (CallerOp &&
687 (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD))
689 CallerOp = CallerOp->Asl.Parent;
692 /* There is no parent method for External() statements */
694 if (!CallerOp)
696 return (AE_OK);
699 CallerFullPathname = AcpiNsGetNormalizedPathname (
700 CallerOp->Asl.Node, TRUE);
702 FlPrintFile (ASL_FILE_XREF_OUTPUT,
703 "[%5u] %-40s Invocation path: %s\n",
704 Op->Asl.LogicalLineNumber, CallerFullPathname,
705 Op->Asl.ExternalName);
707 ACPI_FREE (CallerFullPathname);
708 XrefInfo->ThisMethodInvocations++;
709 return (AE_OK);
714 * Part 3 of the cross reference file. This part emits the names of each
715 * non-predefined method in the namespace (user methods), along with the
716 * names of each control method that references that method.
719 /*******************************************************************************
721 * FUNCTION: OtXrefWalkPart3
723 * PARAMETERS: ASL_WALK_CALLBACK
725 * RETURN: Status
727 * DESCRIPTION: Cross-reference part 3. references to objects other than
728 * control methods.
730 ******************************************************************************/
732 static ACPI_STATUS
733 OtXrefWalkPart3 (
734 ACPI_PARSE_OBJECT *Op,
735 UINT32 Level,
736 void *Context)
738 ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context;
739 ACPI_NAMESPACE_NODE *Node;
740 char *ParentPath;
741 const ACPI_OPCODE_INFO *OpInfo;
744 /* Ignore method declarations */
746 if (!Op->Asl.Node ||
747 (Op->Asl.ParseOpcode == PARSEOP_METHOD))
749 return (AE_OK);
752 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
753 if (!(OpInfo->Class & AML_CLASS_NAMED_OBJECT))
755 return (AE_OK);
758 /* Only care about named object creation opcodes */
760 if ((Op->Asl.ParseOpcode != PARSEOP_NAME) &&
761 (Op->Asl.ParseOpcode != PARSEOP_DEVICE) &&
762 (Op->Asl.ParseOpcode != PARSEOP_MUTEX) &&
763 (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION) &&
764 (Op->Asl.ParseOpcode != PARSEOP_FIELD) &&
765 (Op->Asl.ParseOpcode != PARSEOP_EVENT))
767 return (AE_OK);
770 /* Ignore predefined names */
772 if (Op->Asl.Node->Name.Ascii[0] == '_')
774 return (AE_OK);
777 Node = Op->Asl.Node;
778 ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
780 FlPrintFile (ASL_FILE_XREF_OUTPUT,
781 "\n[%5u] %-40s %s Declaration\n",
782 Op->Asl.LogicalLineNumber, ParentPath,
783 AcpiUtGetTypeName (Node->Type));
784 ACPI_FREE (ParentPath);
786 XrefInfo->MethodOp = Op;
787 XrefInfo->ThisObjectReferences = 0;
788 XrefInfo->TotalObjects = 0;
790 (void) TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
791 OtXrefAnalysisWalkPart3, NULL, XrefInfo);
793 if (!XrefInfo->ThisObjectReferences)
795 FlPrintFile (ASL_FILE_XREF_OUTPUT,
796 " Zero references to this object in this module\n");
797 XrefInfo->TotalUnreferencedObjects++;
799 else
801 FlPrintFile (ASL_FILE_XREF_OUTPUT,
802 " %u references to this object in this module\n",
803 XrefInfo->ThisObjectReferences, ParentPath);
806 return (AE_OK);
810 /*******************************************************************************
812 * FUNCTION: OtXrefAnalysisWalkPart3
814 * PARAMETERS: ASL_WALK_CALLBACK
816 * RETURN: Status
818 * DESCRIPTION: Secondary walk for cross-reference part 3.
820 ******************************************************************************/
822 static ACPI_STATUS
823 OtXrefAnalysisWalkPart3 (
824 ACPI_PARSE_OBJECT *Op,
825 UINT32 Level,
826 void *Context)
828 ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context;
829 char *CallerFullPathname = NULL;
830 ACPI_PARSE_OBJECT *CallerOp;
831 const char *Operator;
834 if (!Op->Asl.Node)
836 return (AE_OK);
839 XrefInfo->TotalObjects++;
841 /* Ignore Op that actually defined the object */
843 if (Op == XrefInfo->MethodOp)
845 return (AE_OK);
848 /* Only interested in Ops that reference the target node */
850 if (Op->Asl.Node != XrefInfo->MethodOp->Asl.Node)
852 return (AE_OK);
855 /* Find parent "open scope" object to get method caller namepath */
857 CallerOp = Op->Asl.Parent;
858 while (CallerOp &&
859 (CallerOp->Asl.ParseOpcode != PARSEOP_NAME) &&
860 (CallerOp->Asl.ParseOpcode != PARSEOP_METHOD) &&
861 (CallerOp->Asl.ParseOpcode != PARSEOP_DEVICE) &&
862 (CallerOp->Asl.ParseOpcode != PARSEOP_POWERRESOURCE) &&
863 (CallerOp->Asl.ParseOpcode != PARSEOP_PROCESSOR) &&
864 (CallerOp->Asl.ParseOpcode != PARSEOP_THERMALZONE))
866 CallerOp = CallerOp->Asl.Parent;
869 if (CallerOp == XrefInfo->CurrentMethodOp)
871 return (AE_OK);
874 /* Null CallerOp means the caller is at the namespace root */
876 if (CallerOp)
878 CallerFullPathname = AcpiNsGetNormalizedPathname (
879 CallerOp->Asl.Node, TRUE);
882 /* There are some special cases for the oddball operators */
884 if (Op->Asl.ParseOpcode == PARSEOP_SCOPE)
886 Operator = "Scope";
888 else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_ALIAS)
890 Operator = "Alias";
892 else if (!CallerOp)
894 Operator = "ModLevel";
896 else
898 Operator = AcpiUtGetTypeName (CallerOp->Asl.Node->Type);
901 FlPrintFile (ASL_FILE_XREF_OUTPUT,
902 "[%5u] %-40s %-8s via path: %s, Operator: %s\n",
903 Op->Asl.LogicalLineNumber,
904 CallerFullPathname ? CallerFullPathname : "<root>",
905 Operator,
906 Op->Asl.ExternalName,
907 Op->Asl.Parent->Asl.ParseOpName);
909 if (!CallerOp)
911 CallerOp = ACPI_TO_POINTER (0xFFFFFFFF);
914 if (CallerFullPathname)
916 ACPI_FREE (CallerFullPathname);
919 XrefInfo->CurrentMethodOp = CallerOp;
920 XrefInfo->ThisObjectReferences++;
921 return (AE_OK);