1 /******************************************************************************
3 * Module Name: adwalk - Application-level disassembler parse tree walk routines
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp.
12 * All rights reserved.
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
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
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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
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
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
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
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 *****************************************************************************/
153 #include "accommon.h"
154 #include "acparser.h"
156 #include "acdisasm.h"
157 #include "acdispat.h"
158 #include "acnamesp.h"
162 #define _COMPONENT ACPI_TOOLS
163 ACPI_MODULE_NAME ("adwalk")
166 * aslmap - opcode mappings and reserved method names
169 AslMapNamedOpcodeToDataType (
172 /* Local prototypes */
175 AcpiDmFindOrphanDescending (
176 ACPI_PARSE_OBJECT *Op,
181 AcpiDmDumpDescending (
182 ACPI_PARSE_OBJECT *Op,
187 AcpiDmXrefDescendingOp (
188 ACPI_PARSE_OBJECT *Op,
193 AcpiDmCommonAscendingOp (
194 ACPI_PARSE_OBJECT *Op,
199 AcpiDmLoadDescendingOp (
200 ACPI_PARSE_OBJECT *Op,
205 AcpiDmInspectPossibleArgs (
206 UINT32 CurrentOpArgCount,
208 ACPI_PARSE_OBJECT *Op);
211 AcpiDmCommonDescendingOp (
212 ACPI_PARSE_OBJECT *Op,
217 AcpiDmProcessResourceDescriptors (
218 ACPI_PARSE_OBJECT *Op,
222 /*******************************************************************************
224 * FUNCTION: AcpiDmDumpTree
226 * PARAMETERS: Origin - Starting object
230 * DESCRIPTION: Parse tree walk to format and output the nodes
232 ******************************************************************************/
236 ACPI_PARSE_OBJECT *Origin)
238 ACPI_OP_WALK_INFO Info;
246 AcpiOsPrintf ("/*\nAML Parse Tree\n\n");
250 Info.WalkState = NULL;
252 AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info);
253 AcpiOsPrintf ("*/\n\n");
257 /*******************************************************************************
259 * FUNCTION: AcpiDmFindOrphanMethods
261 * PARAMETERS: Origin - Starting object
265 * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods
266 * that are not resolved in the namespace
268 ******************************************************************************/
271 AcpiDmFindOrphanMethods (
272 ACPI_PARSE_OBJECT *Origin)
274 ACPI_OP_WALK_INFO Info;
284 Info.WalkState = NULL;
286 AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info);
290 /*******************************************************************************
292 * FUNCTION: AcpiDmFinishNamespaceLoad
294 * PARAMETERS: ParseTreeRoot - Root of the parse tree
295 * NamespaceRoot - Root of the internal namespace
296 * OwnerId - OwnerId of the table to be disassembled
300 * DESCRIPTION: Load all namespace items that are created within control
301 * methods. Used before namespace cross reference
303 ******************************************************************************/
306 AcpiDmFinishNamespaceLoad (
307 ACPI_PARSE_OBJECT *ParseTreeRoot,
308 ACPI_NAMESPACE_NODE *NamespaceRoot,
309 ACPI_OWNER_ID OwnerId)
312 ACPI_OP_WALK_INFO Info;
313 ACPI_WALK_STATE *WalkState;
321 /* Create and initialize a new walk state */
323 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
329 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
331 if (ACPI_FAILURE (Status))
338 Info.WalkState = WalkState;
340 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp,
341 AcpiDmCommonAscendingOp, &Info);
342 ACPI_FREE (WalkState);
346 /*******************************************************************************
348 * FUNCTION: AcpiDmCrossReferenceNamespace
350 * PARAMETERS: ParseTreeRoot - Root of the parse tree
351 * NamespaceRoot - Root of the internal namespace
352 * OwnerId - OwnerId of the table to be disassembled
356 * DESCRIPTION: Cross reference the namespace to create externals
358 ******************************************************************************/
361 AcpiDmCrossReferenceNamespace (
362 ACPI_PARSE_OBJECT *ParseTreeRoot,
363 ACPI_NAMESPACE_NODE *NamespaceRoot,
364 ACPI_OWNER_ID OwnerId)
367 ACPI_OP_WALK_INFO Info;
368 ACPI_WALK_STATE *WalkState;
376 /* Create and initialize a new walk state */
378 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
384 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
386 if (ACPI_FAILURE (Status))
393 Info.WalkState = WalkState;
395 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp,
396 AcpiDmCommonAscendingOp, &Info);
397 ACPI_FREE (WalkState);
401 /*******************************************************************************
403 * FUNCTION: AcpiDmConvertParseObjects
405 * PARAMETERS: ParseTreeRoot - Root of the parse tree
406 * NamespaceRoot - Root of the internal namespace
410 * DESCRIPTION: Begin parse tree walk to perform conversions needed for
411 * disassembly. These include resource descriptors and switch/case
414 ******************************************************************************/
417 AcpiDmConvertParseObjects (
418 ACPI_PARSE_OBJECT *ParseTreeRoot,
419 ACPI_NAMESPACE_NODE *NamespaceRoot)
422 ACPI_OP_WALK_INFO Info;
423 ACPI_WALK_STATE *WalkState;
431 /* Create and initialize a new walk state */
433 WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL);
439 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
441 if (ACPI_FAILURE (Status))
443 ACPI_FREE (WalkState);
449 Info.WalkState = WalkState;
451 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmCommonDescendingOp,
452 AcpiDmCommonAscendingOp, &Info);
453 ACPI_FREE (WalkState);
455 if (AcpiGbl_TempListHead) {
456 AcpiDmClearTempList();
463 /*******************************************************************************
465 * FUNCTION: AcpiDmDumpDescending
467 * PARAMETERS: ASL_WALK_CALLBACK
471 * DESCRIPTION: Format and print contents of one parse Op.
473 ******************************************************************************/
476 AcpiDmDumpDescending (
477 ACPI_PARSE_OBJECT *Op,
481 ACPI_OP_WALK_INFO *Info = Context;
491 /* Most of the information (count, level, name) here */
494 AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level);
495 AcpiDmIndent (Level);
496 AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode));
498 /* Extra info is helpful */
500 switch (Op->Common.AmlOpcode)
504 AcpiOsPrintf ("%2.2X", (UINT32) Op->Common.Value.Integer);
509 AcpiOsPrintf ("%4.4X", (UINT32) Op->Common.Value.Integer);
514 AcpiOsPrintf ("%8.8X", (UINT32) Op->Common.Value.Integer);
519 AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
522 case AML_INT_NAMEPATH_OP:
524 if (Op->Common.Value.String)
526 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String,
528 if (ACPI_SUCCESS (Status))
530 AcpiOsPrintf ("%s %p", Path, Op->Common.Node);
535 AcpiOsPrintf ("Could not externalize pathname for node [%4.4s]",
536 Op->Common.Node->Name.Ascii);
541 AcpiOsPrintf ("[NULL]");
549 AcpiOsPrintf ("%4.4s",
550 ACPI_CAST_PTR (char, &Op->Named.Name));
553 case AML_INT_NAMEDFIELD_OP:
555 AcpiOsPrintf ("%4.4s Length: (bits) %8.8X%8.8X (bytes) %8.8X%8.8X",
556 ACPI_CAST_PTR (char, &Op->Named.Name),
557 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
558 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer / 8));
572 /*******************************************************************************
574 * FUNCTION: AcpiDmFindOrphanDescending
576 * PARAMETERS: ASL_WALK_CALLBACK
580 * DESCRIPTION: Check namepath Ops for orphaned method invocations
582 * Note: Parts of this are experimental, under possible further development.
584 ******************************************************************************/
587 AcpiDmFindOrphanDescending (
588 ACPI_PARSE_OBJECT *Op,
592 const ACPI_OPCODE_INFO *OpInfo;
593 ACPI_PARSE_OBJECT *ChildOp;
594 ACPI_PARSE_OBJECT *NextOp;
595 ACPI_PARSE_OBJECT *ParentOp;
604 #ifdef ACPI_UNDER_DEVELOPMENT
605 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
608 switch (Op->Common.AmlOpcode)
610 #ifdef ACPI_UNDER_DEVELOPMENT
613 ChildOp = Op->Common.Value.Arg;
614 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
615 !ChildOp->Common.Node)
617 AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,
619 AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n",
620 Op->Common.AmlOpName, Path);
623 NextOp = Op->Common.Next;
626 /* This NamePath has no args, assume it is an integer */
628 AcpiDmAddOpToExternalList (ChildOp,
629 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
633 ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);
634 AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n",
635 ArgCount, AcpiDmCountChildren (Op));
639 /* One Arg means this is just a Store(Name,Target) */
641 AcpiDmAddOpToExternalList (ChildOp,
642 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
646 AcpiDmAddOpToExternalList (ChildOp,
647 ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
655 ChildOp = Op->Common.Value.Arg;
656 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
657 !ChildOp->Common.Node)
659 NextOp = Op->Common.Next;
662 /* This NamePath has no args, assume it is an integer */
664 AcpiDmAddOpToExternalList (ChildOp,
665 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
669 ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);
672 /* One Arg means this is just a Store(Name,Target) */
674 AcpiDmAddOpToExternalList (ChildOp,
675 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0);
679 AcpiDmAddOpToExternalList (ChildOp,
680 ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
684 case AML_INT_NAMEPATH_OP:
686 /* Must examine parent to see if this namepath is an argument */
688 ParentOp = Op->Common.Parent;
689 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
691 if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
692 (OpInfo->Class != AML_CLASS_CREATE) &&
693 (OpInfo->ObjectType != ACPI_TYPE_LOCAL_ALIAS) &&
694 (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
697 ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op);
700 * Check if namepath is a predicate for if/while or lone parameter to
705 if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
706 (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||
707 (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&
709 /* And namepath is the first argument */
710 (ParentOp->Common.Value.Arg == Op))
712 AcpiDmAddOpToExternalList (Op,
713 Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
719 * This is a standalone namestring (not a parameter to another
720 * operator) - it *must* be a method invocation, nothing else is
721 * grammatically possible.
723 AcpiDmAddOpToExternalList (Op,
724 Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
737 /*******************************************************************************
739 * FUNCTION: AcpiDmLoadDescendingOp
741 * PARAMETERS: ASL_WALK_CALLBACK
745 * DESCRIPTION: Descending handler for namespace control method object load
747 ******************************************************************************/
750 AcpiDmLoadDescendingOp (
751 ACPI_PARSE_OBJECT *Op,
755 ACPI_OP_WALK_INFO *Info = Context;
756 const ACPI_OPCODE_INFO *OpInfo;
757 ACPI_WALK_STATE *WalkState;
758 ACPI_OBJECT_TYPE ObjectType;
761 ACPI_PARSE_OBJECT *NextOp;
762 ACPI_NAMESPACE_NODE *Node;
764 BOOLEAN PreDefined = FALSE;
765 UINT8 PreDefineIndex = 0;
768 WalkState = Info->WalkState;
769 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
770 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
772 /* Only interested in operators that create new names */
774 if (!(OpInfo->Flags & AML_NAMED) &&
775 !(OpInfo->Flags & AML_CREATE))
780 /* Get the NamePath from the appropriate place */
782 if (OpInfo->Flags & AML_NAMED)
784 /* For all named operators, get the new name */
786 Path = Op->Named.Path;
788 if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
790 *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
795 else if (OpInfo->Flags & AML_CREATE)
797 /* New name is the last child */
799 NextOp = Op->Common.Value.Arg;
801 while (NextOp->Common.Next)
803 NextOp = NextOp->Common.Next;
806 Path = NextOp->Common.Value.String;
814 /* Insert the name into the namespace */
816 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
817 ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,
820 Op->Common.Node = Node;
822 if (ACPI_SUCCESS (Status))
824 /* Check if it's a predefined node */
826 while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
828 if (ACPI_COMPARE_NAMESEG (Node->Name.Ascii,
829 AcpiGbl_PreDefinedNames[PreDefineIndex].Name))
839 * Set node owner id if it satisfies all the following conditions:
840 * 1) Not a predefined node, _SB_ etc
841 * 2) Not the root node
842 * 3) Not a node created by Scope
845 (Node != AcpiGbl_RootNode) &&
846 (Op->Common.AmlOpcode != AML_SCOPE_OP))
848 Node->OwnerId = WalkState->OwnerId;
855 if (AcpiNsOpensScope (ObjectType))
859 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
861 if (ACPI_FAILURE (Status))
872 /*******************************************************************************
874 * FUNCTION: AcpiDmXrefDescendingOp
876 * PARAMETERS: ASL_WALK_CALLBACK
880 * DESCRIPTION: Descending handler for namespace cross reference
882 ******************************************************************************/
885 AcpiDmXrefDescendingOp (
886 ACPI_PARSE_OBJECT *Op,
890 ACPI_OP_WALK_INFO *Info = Context;
891 const ACPI_OPCODE_INFO *OpInfo;
892 ACPI_WALK_STATE *WalkState;
893 ACPI_OBJECT_TYPE ObjectType;
894 ACPI_OBJECT_TYPE ObjectType2;
897 ACPI_PARSE_OBJECT *NextOp;
898 ACPI_NAMESPACE_NODE *Node;
899 ACPI_OPERAND_OBJECT *Object;
900 UINT32 ParamCount = 0;
905 WalkState = Info->WalkState;
906 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
907 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
909 if ((!(OpInfo->Flags & AML_NAMED)) &&
910 (!(OpInfo->Flags & AML_CREATE)) &&
911 (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP) &&
912 (Op->Common.AmlOpcode != AML_NOTIFY_OP))
917 /* Get the NamePath from the appropriate place */
919 if (OpInfo->Flags & AML_NAMED)
922 * Only these two operators (Alias, Scope) refer to an existing
923 * name, it is the first argument
925 if (Op->Common.AmlOpcode == AML_ALIAS_OP)
927 ObjectType = ACPI_TYPE_ANY;
929 NextOp = Op->Common.Value.Arg;
930 NextOp = NextOp->Common.Value.Arg;
931 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
933 Path = NextOp->Common.Value.String;
936 else if (Op->Common.AmlOpcode == AML_SCOPE_OP ||
937 Op->Common.AmlOpcode == AML_EXTERNAL_OP)
939 Path = Op->Named.Path;
942 else if (OpInfo->Flags & AML_CREATE)
944 /* Referenced Buffer Name is the first child */
946 ObjectType = ACPI_TYPE_BUFFER; /* Change from TYPE_BUFFER_FIELD */
948 NextOp = Op->Common.Value.Arg;
949 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
951 Path = NextOp->Common.Value.String;
954 else if (Op->Common.AmlOpcode == AML_NOTIFY_OP)
956 Path = Op->Common.Value.Arg->Asl.Value.String;
960 Path = Op->Common.Value.String;
969 * Lookup the name in the namespace. Name must exist at this point, or it
970 * is an invalid reference.
972 * The namespace is also used as a lookup table for references to resource
973 * descriptors and the fields within them.
976 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
977 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
980 if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL))
982 /* Node was created by an External() statement */
984 Status = AE_NOT_FOUND;
987 if (ACPI_FAILURE (Status))
989 if (Status == AE_NOT_FOUND)
992 * Add this symbol as an external declaration, except if the
993 * parent is a CondRefOf operator. For this operator, we do not
994 * need an external, nor do we want one, since this can cause
995 * disassembly problems if the symbol is actually a control
998 if (!(Op->Asl.Parent &&
999 (Op->Asl.Parent->Asl.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)))
1003 AcpiDmAddNodeToExternalList (Node,
1004 (UINT8) ObjectType, 7, Flags);
1008 AcpiDmAddOpToExternalList (Op, Path,
1009 (UINT8) ObjectType, 7, Flags);
1016 * Found the node, but check if it came from an external table.
1017 * Add it to external list. Note: Node->OwnerId == 0 indicates
1018 * one of the built-in ACPI Names (_OS_ etc.) which can safely
1021 else if (Node->OwnerId &&
1022 (WalkState->OwnerId != Node->OwnerId))
1024 ObjectType2 = ObjectType;
1026 Object = AcpiNsGetAttachedObject (Node);
1029 ObjectType2 = Object->Common.Type;
1030 if (ObjectType2 == ACPI_TYPE_METHOD)
1032 ParamCount = Object->Method.ParamCount;
1036 Pathname = AcpiNsGetExternalPathname (Node);
1039 return (AE_NO_MEMORY);
1042 AcpiDmAddNodeToExternalList (Node, (UINT8) ObjectType2,
1043 ParamCount, ACPI_EXT_RESOLVED_REFERENCE);
1045 ACPI_FREE (Pathname);
1046 Op->Common.Node = Node;
1050 Op->Common.Node = Node;
1055 /* Open new scope if necessary */
1057 if (AcpiNsOpensScope (ObjectType))
1059 if (Op->Common.Node)
1061 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
1063 if (ACPI_FAILURE (Status))
1073 /*******************************************************************************
1075 * FUNCTION: AcpiDmCommonDescendingOp
1077 * PARAMETERS: ASL_WALK_CALLBACK
1079 * RETURN: ACPI_STATUS
1081 * DESCRIPTION: Perform parse tree preprocessing before main disassembly walk.
1083 ******************************************************************************/
1086 AcpiDmCommonDescendingOp (
1087 ACPI_PARSE_OBJECT *Op,
1094 /* Resource descriptor conversion */
1096 Status = AcpiDmProcessResourceDescriptors (Op, Level, Context);
1097 if (ACPI_FAILURE (Status))
1102 /* Switch/Case conversion */
1104 Status = AcpiDmProcessSwitch (Op);
1109 /*******************************************************************************
1111 * FUNCTION: AcpiDmProcessResourceDescriptors
1113 * PARAMETERS: ASL_WALK_CALLBACK
1115 * RETURN: ACPI_STATUS
1117 * DESCRIPTION: Convert fixed-offset references to resource descriptors to
1118 * symbolic references. Should only be called after namespace has
1119 * been cross referenced.
1121 ******************************************************************************/
1124 AcpiDmProcessResourceDescriptors (
1125 ACPI_PARSE_OBJECT *Op,
1129 ACPI_OP_WALK_INFO *Info = Context;
1130 const ACPI_OPCODE_INFO *OpInfo;
1131 ACPI_WALK_STATE *WalkState;
1132 ACPI_OBJECT_TYPE ObjectType;
1136 WalkState = Info->WalkState;
1137 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
1139 /* Open new scope if necessary */
1141 ObjectType = OpInfo->ObjectType;
1142 if (AcpiNsOpensScope (ObjectType))
1144 if (Op->Common.Node)
1147 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
1149 if (ACPI_FAILURE (Status))
1157 * Check if this operator contains a reference to a resource descriptor.
1158 * If so, convert the reference into a symbolic reference.
1160 AcpiDmCheckResourceReference (Op, WalkState);
1164 /*******************************************************************************
1166 * FUNCTION: AcpiDmCommonAscendingOp
1168 * PARAMETERS: ASL_WALK_CALLBACK
1172 * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes
1173 * scope if necessary.
1175 ******************************************************************************/
1178 AcpiDmCommonAscendingOp (
1179 ACPI_PARSE_OBJECT *Op,
1183 ACPI_OP_WALK_INFO *Info = Context;
1184 ACPI_OBJECT_TYPE ObjectType;
1187 /* Close scope if necessary */
1189 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
1191 if (AcpiNsOpensScope (ObjectType))
1193 (void) AcpiDsScopeStackPop (Info->WalkState);
1199 /*******************************************************************************
1201 * FUNCTION: AcpiDmInspectPossibleArgs
1203 * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the
1204 * possible method invocation found
1205 * TargetCount - Number of targets (0,1,2) for this op
1210 * DESCRIPTION: Examine following args and next ops for possible arguments
1211 * for an unrecognized method invocation.
1213 ******************************************************************************/
1216 AcpiDmInspectPossibleArgs (
1217 UINT32 CurrentOpArgCount,
1219 ACPI_PARSE_OBJECT *Op)
1221 const ACPI_OPCODE_INFO *OpInfo;
1223 UINT32 ArgumentCount = 0;
1224 ACPI_PARSE_OBJECT *NextOp;
1225 ACPI_PARSE_OBJECT *ExecuteOp;
1233 /* Lookahead for the maximum number of possible arguments */
1235 NextOp = Op->Common.Next;
1237 for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && NextOp; i++)
1239 OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode);
1241 /* Any one of these operators is "very probably" not a method arg */
1243 if ((NextOp->Common.AmlOpcode == AML_STORE_OP) ||
1244 (NextOp->Common.AmlOpcode == AML_NOTIFY_OP) ||
1245 (OpInfo->Class == AML_CLASS_CONTROL) ||
1246 (OpInfo->Class == AML_CLASS_CREATE) ||
1247 (OpInfo->Class == AML_CLASS_NAMED_OBJECT))
1252 if (OpInfo->Class == AML_CLASS_EXECUTE)
1254 /* Probable that this is method arg if there is no target */
1256 ExecuteOp = NextOp->Common.Value.Arg;
1259 if ((ExecuteOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
1260 (ExecuteOp->Common.Value.Arg == NULL))
1262 /* No target, could be a method arg */
1267 if (NextOp->Common.AmlOpcode == AML_REF_OF_OP)
1272 ExecuteOp = ExecuteOp->Common.Next;
1277 /* Has a target, not method arg */
1279 return (ArgumentCount);
1284 NextOp = NextOp->Common.Next;
1287 return (ArgumentCount);