1 /******************************************************************************
3 * Module Name: adwalk - Application-level disassembler parse tree walk routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acparser.h>
47 #include <contrib/dev/acpica/include/amlcode.h>
48 #include <contrib/dev/acpica/include/acdisasm.h>
49 #include <contrib/dev/acpica/include/acdispat.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
51 #include <contrib/dev/acpica/include/acapps.h>
54 #define _COMPONENT ACPI_TOOLS
55 ACPI_MODULE_NAME ("adwalk")
58 * aslmap - opcode mappings and reserved method names
61 AslMapNamedOpcodeToDataType (
64 /* Local prototypes */
67 AcpiDmFindOrphanDescending (
68 ACPI_PARSE_OBJECT *Op,
73 AcpiDmDumpDescending (
74 ACPI_PARSE_OBJECT *Op,
79 AcpiDmXrefDescendingOp (
80 ACPI_PARSE_OBJECT *Op,
85 AcpiDmCommonAscendingOp (
86 ACPI_PARSE_OBJECT *Op,
91 AcpiDmLoadDescendingOp (
92 ACPI_PARSE_OBJECT *Op,
97 AcpiDmInspectPossibleArgs (
98 UINT32 CurrentOpArgCount,
100 ACPI_PARSE_OBJECT *Op);
103 AcpiDmResourceDescendingOp (
104 ACPI_PARSE_OBJECT *Op,
109 /*******************************************************************************
111 * FUNCTION: AcpiDmDumpTree
113 * PARAMETERS: Origin - Starting object
117 * DESCRIPTION: Parse tree walk to format and output the nodes
119 ******************************************************************************/
123 ACPI_PARSE_OBJECT *Origin)
125 ACPI_OP_WALK_INFO Info;
133 AcpiOsPrintf ("/*\nAML Parse Tree\n\n");
137 Info.WalkState = NULL;
139 AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info);
140 AcpiOsPrintf ("*/\n\n");
144 /*******************************************************************************
146 * FUNCTION: AcpiDmFindOrphanMethods
148 * PARAMETERS: Origin - Starting object
152 * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods
153 * that are not resolved in the namespace
155 ******************************************************************************/
158 AcpiDmFindOrphanMethods (
159 ACPI_PARSE_OBJECT *Origin)
161 ACPI_OP_WALK_INFO Info;
171 Info.WalkState = NULL;
173 AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info);
177 /*******************************************************************************
179 * FUNCTION: AcpiDmFinishNamespaceLoad
181 * PARAMETERS: ParseTreeRoot - Root of the parse tree
182 * NamespaceRoot - Root of the internal namespace
183 * OwnerId - OwnerId of the table to be disassembled
187 * DESCRIPTION: Load all namespace items that are created within control
188 * methods. Used before namespace cross reference
190 ******************************************************************************/
193 AcpiDmFinishNamespaceLoad (
194 ACPI_PARSE_OBJECT *ParseTreeRoot,
195 ACPI_NAMESPACE_NODE *NamespaceRoot,
196 ACPI_OWNER_ID OwnerId)
199 ACPI_OP_WALK_INFO Info;
200 ACPI_WALK_STATE *WalkState;
208 /* Create and initialize a new walk state */
210 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
216 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
218 if (ACPI_FAILURE (Status))
225 Info.WalkState = WalkState;
227 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp,
228 AcpiDmCommonAscendingOp, &Info);
229 ACPI_FREE (WalkState);
233 /*******************************************************************************
235 * FUNCTION: AcpiDmCrossReferenceNamespace
237 * PARAMETERS: ParseTreeRoot - Root of the parse tree
238 * NamespaceRoot - Root of the internal namespace
239 * OwnerId - OwnerId of the table to be disassembled
243 * DESCRIPTION: Cross reference the namespace to create externals
245 ******************************************************************************/
248 AcpiDmCrossReferenceNamespace (
249 ACPI_PARSE_OBJECT *ParseTreeRoot,
250 ACPI_NAMESPACE_NODE *NamespaceRoot,
251 ACPI_OWNER_ID OwnerId)
254 ACPI_OP_WALK_INFO Info;
255 ACPI_WALK_STATE *WalkState;
263 /* Create and initialize a new walk state */
265 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
271 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
273 if (ACPI_FAILURE (Status))
280 Info.WalkState = WalkState;
282 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp,
283 AcpiDmCommonAscendingOp, &Info);
284 ACPI_FREE (WalkState);
288 /*******************************************************************************
290 * FUNCTION: AcpiDmConvertResourceIndexes
292 * PARAMETERS: ParseTreeRoot - Root of the parse tree
293 * NamespaceRoot - Root of the internal namespace
297 * DESCRIPTION: Convert fixed-offset references to resource descriptors to
298 * symbolic references. Should only be called after namespace has
299 * been cross referenced.
301 ******************************************************************************/
304 AcpiDmConvertResourceIndexes (
305 ACPI_PARSE_OBJECT *ParseTreeRoot,
306 ACPI_NAMESPACE_NODE *NamespaceRoot)
309 ACPI_OP_WALK_INFO Info;
310 ACPI_WALK_STATE *WalkState;
318 /* Create and initialize a new walk state */
320 WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL);
326 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type,
328 if (ACPI_FAILURE (Status))
330 ACPI_FREE (WalkState);
336 Info.WalkState = WalkState;
338 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp,
339 AcpiDmCommonAscendingOp, &Info);
340 ACPI_FREE (WalkState);
345 /*******************************************************************************
347 * FUNCTION: AcpiDmDumpDescending
349 * PARAMETERS: ASL_WALK_CALLBACK
353 * DESCRIPTION: Format and print contents of one parse Op.
355 ******************************************************************************/
358 AcpiDmDumpDescending (
359 ACPI_PARSE_OBJECT *Op,
363 ACPI_OP_WALK_INFO *Info = Context;
372 /* Most of the information (count, level, name) here */
375 AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level);
376 AcpiDmIndent (Level);
377 AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode));
379 /* Extra info is helpful */
381 switch (Op->Common.AmlOpcode)
385 AcpiOsPrintf ("%2.2X", (UINT32) Op->Common.Value.Integer);
390 AcpiOsPrintf ("%4.4X", (UINT32) Op->Common.Value.Integer);
395 AcpiOsPrintf ("%8.8X", (UINT32) Op->Common.Value.Integer);
400 AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
403 case AML_INT_NAMEPATH_OP:
405 if (Op->Common.Value.String)
407 AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String,
409 AcpiOsPrintf ("%s %p", Path, Op->Common.Node);
414 AcpiOsPrintf ("[NULL]");
421 case AML_INT_NAMEDFIELD_OP:
423 AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name));
436 /*******************************************************************************
438 * FUNCTION: AcpiDmFindOrphanDescending
440 * PARAMETERS: ASL_WALK_CALLBACK
444 * DESCRIPTION: Check namepath Ops for orphaned method invocations
446 * Note: Parts of this are experimental, under possible further development.
448 ******************************************************************************/
451 AcpiDmFindOrphanDescending (
452 ACPI_PARSE_OBJECT *Op,
456 const ACPI_OPCODE_INFO *OpInfo;
457 ACPI_PARSE_OBJECT *ChildOp;
458 ACPI_PARSE_OBJECT *NextOp;
459 ACPI_PARSE_OBJECT *ParentOp;
468 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
470 switch (Op->Common.AmlOpcode)
472 #ifdef ACPI_UNDER_DEVELOPMENT
475 ChildOp = Op->Common.Value.Arg;
476 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
477 !ChildOp->Common.Node)
479 AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,
481 AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n",
482 Op->Common.AmlOpName, Path);
485 NextOp = Op->Common.Next;
488 /* This NamePath has no args, assume it is an integer */
490 AcpiDmAddOpToExternalList (ChildOp,
491 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
495 ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);
496 AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n",
497 ArgCount, AcpiDmCountChildren (Op));
501 /* One Arg means this is just a Store(Name,Target) */
503 AcpiDmAddOpToExternalList (ChildOp,
504 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
508 AcpiDmAddOpToExternalList (ChildOp,
509 ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
517 ChildOp = Op->Common.Value.Arg;
518 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
519 !ChildOp->Common.Node)
521 NextOp = Op->Common.Next;
524 /* This NamePath has no args, assume it is an integer */
526 AcpiDmAddOpToExternalList (ChildOp,
527 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
531 ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);
534 /* One Arg means this is just a Store(Name,Target) */
536 AcpiDmAddOpToExternalList (ChildOp,
537 ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0);
541 AcpiDmAddOpToExternalList (ChildOp,
542 ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
546 case AML_INT_NAMEPATH_OP:
548 /* Must examine parent to see if this namepath is an argument */
550 ParentOp = Op->Common.Parent;
551 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
553 if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
554 (OpInfo->Class != AML_CLASS_CREATE) &&
555 (OpInfo->ObjectType != ACPI_TYPE_LOCAL_ALIAS) &&
556 (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
559 ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op);
562 * Check if namepath is a predicate for if/while or lone parameter to
567 if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
568 (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||
569 (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&
571 /* And namepath is the first argument */
572 (ParentOp->Common.Value.Arg == Op))
574 AcpiDmAddOpToExternalList (Op,
575 Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
581 * This is a standalone namestring (not a parameter to another
582 * operator) - it *must* be a method invocation, nothing else is
583 * grammatically possible.
585 AcpiDmAddOpToExternalList (Op,
586 Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
599 /*******************************************************************************
601 * FUNCTION: AcpiDmLoadDescendingOp
603 * PARAMETERS: ASL_WALK_CALLBACK
607 * DESCRIPTION: Descending handler for namespace control method object load
609 ******************************************************************************/
612 AcpiDmLoadDescendingOp (
613 ACPI_PARSE_OBJECT *Op,
617 ACPI_OP_WALK_INFO *Info = Context;
618 const ACPI_OPCODE_INFO *OpInfo;
619 ACPI_WALK_STATE *WalkState;
620 ACPI_OBJECT_TYPE ObjectType;
623 ACPI_PARSE_OBJECT *NextOp;
624 ACPI_NAMESPACE_NODE *Node;
626 BOOLEAN PreDefined = FALSE;
627 UINT8 PreDefineIndex = 0;
630 WalkState = Info->WalkState;
631 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
632 ObjectType = OpInfo->ObjectType;
633 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
635 /* Only interested in operators that create new names */
637 if (!(OpInfo->Flags & AML_NAMED) &&
638 !(OpInfo->Flags & AML_CREATE))
643 /* Get the NamePath from the appropriate place */
645 if (OpInfo->Flags & AML_NAMED)
647 /* For all named operators, get the new name */
649 Path = (char *) Op->Named.Path;
651 if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
653 *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
658 else if (OpInfo->Flags & AML_CREATE)
660 /* New name is the last child */
662 NextOp = Op->Common.Value.Arg;
664 while (NextOp->Common.Next)
666 NextOp = NextOp->Common.Next;
669 Path = NextOp->Common.Value.String;
677 /* Insert the name into the namespace */
679 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
680 ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,
683 Op->Common.Node = Node;
685 if (ACPI_SUCCESS (Status))
687 /* Check if it's a predefined node */
689 while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
691 if (ACPI_COMPARE_NAME (Node->Name.Ascii,
692 AcpiGbl_PreDefinedNames[PreDefineIndex].Name))
702 * Set node owner id if it satisfies all the following conditions:
703 * 1) Not a predefined node, _SB_ etc
704 * 2) Not the root node
705 * 3) Not a node created by Scope
708 if (!PreDefined && Node != AcpiGbl_RootNode &&
709 Op->Common.AmlOpcode != AML_SCOPE_OP)
711 Node->OwnerId = WalkState->OwnerId;
718 if (AcpiNsOpensScope (ObjectType))
722 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
724 if (ACPI_FAILURE (Status))
735 /*******************************************************************************
737 * FUNCTION: AcpiDmXrefDescendingOp
739 * PARAMETERS: ASL_WALK_CALLBACK
743 * DESCRIPTION: Descending handler for namespace cross reference
745 ******************************************************************************/
748 AcpiDmXrefDescendingOp (
749 ACPI_PARSE_OBJECT *Op,
753 ACPI_OP_WALK_INFO *Info = Context;
754 const ACPI_OPCODE_INFO *OpInfo;
755 ACPI_WALK_STATE *WalkState;
756 ACPI_OBJECT_TYPE ObjectType;
757 ACPI_OBJECT_TYPE ObjectType2;
760 ACPI_PARSE_OBJECT *NextOp;
761 ACPI_NAMESPACE_NODE *Node;
762 ACPI_OPERAND_OBJECT *Object;
763 UINT32 ParamCount = 0;
768 WalkState = Info->WalkState;
769 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
770 ObjectType = OpInfo->ObjectType;
771 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
773 if ((!(OpInfo->Flags & AML_NAMED)) &&
774 (!(OpInfo->Flags & AML_CREATE)) &&
775 (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP) &&
776 (Op->Common.AmlOpcode != AML_NOTIFY_OP))
780 else if (Op->Common.Parent &&
781 Op->Common.Parent->Common.AmlOpcode == AML_EXTERNAL_OP)
783 /* External() NamePath */
785 Path = Op->Common.Value.String;
786 ObjectType = (ACPI_OBJECT_TYPE) Op->Common.Next->Common.Value.Integer;
787 if (ObjectType == ACPI_TYPE_METHOD)
789 ParamCount = (UINT32)
790 Op->Common.Next->Common.Next->Common.Value.Integer;
793 Flags |= ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_OPCODE;
794 AcpiDmAddOpToExternalList (Op, Path,
795 (UINT8) ObjectType, ParamCount, Flags);
800 /* Get the NamePath from the appropriate place */
802 if (OpInfo->Flags & AML_NAMED)
805 * Only these two operators (Alias, Scope) refer to an existing
806 * name, it is the first argument
808 if (Op->Common.AmlOpcode == AML_ALIAS_OP)
810 ObjectType = ACPI_TYPE_ANY;
812 NextOp = Op->Common.Value.Arg;
813 NextOp = NextOp->Common.Value.Arg;
814 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
816 Path = NextOp->Common.Value.String;
819 else if (Op->Common.AmlOpcode == AML_SCOPE_OP)
821 Path = (char *) Op->Named.Path;
824 else if (OpInfo->Flags & AML_CREATE)
826 /* Referenced Buffer Name is the first child */
828 ObjectType = ACPI_TYPE_BUFFER; /* Change from TYPE_BUFFER_FIELD */
830 NextOp = Op->Common.Value.Arg;
831 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
833 Path = NextOp->Common.Value.String;
836 else if (Op->Common.AmlOpcode == AML_NOTIFY_OP)
838 Path = Op->Common.Value.Arg->Asl.Value.String;
842 Path = Op->Common.Value.String;
851 * Lookup the name in the namespace. Name must exist at this point, or it
852 * is an invalid reference.
854 * The namespace is also used as a lookup table for references to resource
855 * descriptors and the fields within them.
858 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
859 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
862 if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL))
864 /* Node was created by an External() statement */
866 Status = AE_NOT_FOUND;
869 if (ACPI_FAILURE (Status))
871 if (Status == AE_NOT_FOUND)
874 * Add this symbol as an external declaration, except if the
875 * parent is a CondRefOf operator. For this operator, we do not
876 * need an external, nor do we want one, since this can cause
877 * disassembly problems if the symbol is actually a control
880 if (!(Op->Asl.Parent &&
881 (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP)))
885 AcpiDmAddNodeToExternalList (Node,
886 (UINT8) ObjectType, 7, Flags);
890 AcpiDmAddOpToExternalList (Op, Path,
891 (UINT8) ObjectType, 7, Flags);
898 * Found the node, but check if it came from an external table.
899 * Add it to external list. Note: Node->OwnerId == 0 indicates
900 * one of the built-in ACPI Names (_OS_ etc.) which can safely
903 else if (Node->OwnerId &&
904 (WalkState->OwnerId != Node->OwnerId))
906 ObjectType2 = ObjectType;
908 Object = AcpiNsGetAttachedObject (Node);
911 ObjectType2 = Object->Common.Type;
912 if (ObjectType2 == ACPI_TYPE_METHOD)
914 ParamCount = Object->Method.ParamCount;
918 Pathname = AcpiNsGetExternalPathname (Node);
921 return (AE_NO_MEMORY);
924 AcpiDmAddNodeToExternalList (Node, (UINT8) ObjectType2,
925 ParamCount, ACPI_EXT_RESOLVED_REFERENCE);
927 ACPI_FREE (Pathname);
928 Op->Common.Node = Node;
932 Op->Common.Node = Node;
937 /* Open new scope if necessary */
939 if (AcpiNsOpensScope (ObjectType))
943 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
945 if (ACPI_FAILURE (Status))
956 /*******************************************************************************
958 * FUNCTION: AcpiDmResourceDescendingOp
960 * PARAMETERS: ASL_WALK_CALLBACK
964 * DESCRIPTION: Process one parse op during symbolic resource index conversion.
966 ******************************************************************************/
969 AcpiDmResourceDescendingOp (
970 ACPI_PARSE_OBJECT *Op,
974 ACPI_OP_WALK_INFO *Info = Context;
975 const ACPI_OPCODE_INFO *OpInfo;
976 ACPI_WALK_STATE *WalkState;
977 ACPI_OBJECT_TYPE ObjectType;
981 WalkState = Info->WalkState;
982 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
984 /* Open new scope if necessary */
986 ObjectType = OpInfo->ObjectType;
987 if (AcpiNsOpensScope (ObjectType))
992 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
994 if (ACPI_FAILURE (Status))
1002 * Check if this operator contains a reference to a resource descriptor.
1003 * If so, convert the reference into a symbolic reference.
1005 AcpiDmCheckResourceReference (Op, WalkState);
1010 /*******************************************************************************
1012 * FUNCTION: AcpiDmCommonAscendingOp
1014 * PARAMETERS: ASL_WALK_CALLBACK
1018 * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes
1019 * scope if necessary.
1021 ******************************************************************************/
1024 AcpiDmCommonAscendingOp (
1025 ACPI_PARSE_OBJECT *Op,
1029 ACPI_OP_WALK_INFO *Info = Context;
1030 const ACPI_OPCODE_INFO *OpInfo;
1031 ACPI_OBJECT_TYPE ObjectType;
1034 /* Close scope if necessary */
1036 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
1037 ObjectType = OpInfo->ObjectType;
1038 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
1040 if (AcpiNsOpensScope (ObjectType))
1042 (void) AcpiDsScopeStackPop (Info->WalkState);
1049 /*******************************************************************************
1051 * FUNCTION: AcpiDmInspectPossibleArgs
1053 * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the
1054 * possible method invocation found
1055 * TargetCount - Number of targets (0,1,2) for this op
1060 * DESCRIPTION: Examine following args and next ops for possible arguments
1061 * for an unrecognized method invocation.
1063 ******************************************************************************/
1066 AcpiDmInspectPossibleArgs (
1067 UINT32 CurrentOpArgCount,
1069 ACPI_PARSE_OBJECT *Op)
1071 const ACPI_OPCODE_INFO *OpInfo;
1073 UINT32 ArgumentCount = 0;
1074 ACPI_PARSE_OBJECT *NextOp;
1075 ACPI_PARSE_OBJECT *ExecuteOp;
1083 /* Lookahead for the maximum number of possible arguments */
1085 NextOp = Op->Common.Next;
1087 for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && NextOp; i++)
1089 OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode);
1091 /* Any one of these operators is "very probably" not a method arg */
1093 if ((NextOp->Common.AmlOpcode == AML_STORE_OP) ||
1094 (NextOp->Common.AmlOpcode == AML_NOTIFY_OP) ||
1095 (OpInfo->Class == AML_CLASS_CONTROL) ||
1096 (OpInfo->Class == AML_CLASS_CREATE) ||
1097 (OpInfo->Class == AML_CLASS_NAMED_OBJECT))
1102 if (OpInfo->Class == AML_CLASS_EXECUTE)
1104 /* Probable that this is method arg if there is no target */
1106 ExecuteOp = NextOp->Common.Value.Arg;
1109 if ((ExecuteOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
1110 (ExecuteOp->Common.Value.Arg == NULL))
1112 /* No target, could be a method arg */
1117 if (NextOp->Common.AmlOpcode == AML_REF_OF_OP)
1122 ExecuteOp = ExecuteOp->Common.Next;
1127 /* Has a target, not method arg */
1129 return (ArgumentCount);
1134 NextOp = NextOp->Common.Next;
1137 return (ArgumentCount);