1 /******************************************************************************
3 * Module Name: adwalk - Application-level disassembler parse tree walk routines
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2014, 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 *****************************************************************************/
118 #include "accommon.h"
119 #include "acparser.h"
121 #include "acdisasm.h"
122 #include "acdispat.h"
123 #include "acnamesp.h"
127 #define _COMPONENT ACPI_TOOLS
128 ACPI_MODULE_NAME ("adwalk")
131 * aslmap - opcode mappings and reserved method names
134 AslMapNamedOpcodeToDataType (
137 /* Local prototypes */
140 AcpiDmFindOrphanDescending (
141 ACPI_PARSE_OBJECT
*Op
,
146 AcpiDmDumpDescending (
147 ACPI_PARSE_OBJECT
*Op
,
152 AcpiDmXrefDescendingOp (
153 ACPI_PARSE_OBJECT
*Op
,
158 AcpiDmCommonAscendingOp (
159 ACPI_PARSE_OBJECT
*Op
,
164 AcpiDmLoadDescendingOp (
165 ACPI_PARSE_OBJECT
*Op
,
170 AcpiDmInspectPossibleArgs (
171 UINT32 CurrentOpArgCount
,
173 ACPI_PARSE_OBJECT
*Op
);
176 AcpiDmResourceDescendingOp (
177 ACPI_PARSE_OBJECT
*Op
,
182 /*******************************************************************************
184 * FUNCTION: AcpiDmDumpTree
186 * PARAMETERS: Origin - Starting object
190 * DESCRIPTION: Parse tree walk to format and output the nodes
192 ******************************************************************************/
196 ACPI_PARSE_OBJECT
*Origin
)
198 ACPI_OP_WALK_INFO Info
;
206 AcpiOsPrintf ("/*\nAML Parse Tree\n\n");
210 Info
.WalkState
= NULL
;
211 AcpiDmWalkParseTree (Origin
, AcpiDmDumpDescending
, NULL
, &Info
);
212 AcpiOsPrintf ("*/\n\n");
216 /*******************************************************************************
218 * FUNCTION: AcpiDmFindOrphanMethods
220 * PARAMETERS: Origin - Starting object
224 * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods
225 * that are not resolved in the namespace
227 ******************************************************************************/
230 AcpiDmFindOrphanMethods (
231 ACPI_PARSE_OBJECT
*Origin
)
233 ACPI_OP_WALK_INFO Info
;
243 Info
.WalkState
= NULL
;
244 AcpiDmWalkParseTree (Origin
, AcpiDmFindOrphanDescending
, NULL
, &Info
);
248 /*******************************************************************************
250 * FUNCTION: AcpiDmFinishNamespaceLoad
252 * PARAMETERS: ParseTreeRoot - Root of the parse tree
253 * NamespaceRoot - Root of the internal namespace
254 * OwnerId - OwnerId of the table to be disassembled
258 * DESCRIPTION: Load all namespace items that are created within control
259 * methods. Used before namespace cross reference
261 ******************************************************************************/
264 AcpiDmFinishNamespaceLoad (
265 ACPI_PARSE_OBJECT
*ParseTreeRoot
,
266 ACPI_NAMESPACE_NODE
*NamespaceRoot
,
267 ACPI_OWNER_ID OwnerId
)
270 ACPI_OP_WALK_INFO Info
;
271 ACPI_WALK_STATE
*WalkState
;
279 /* Create and initialize a new walk state */
281 WalkState
= AcpiDsCreateWalkState (OwnerId
, ParseTreeRoot
, NULL
, NULL
);
287 Status
= AcpiDsScopeStackPush (NamespaceRoot
, NamespaceRoot
->Type
, WalkState
);
288 if (ACPI_FAILURE (Status
))
295 Info
.WalkState
= WalkState
;
296 AcpiDmWalkParseTree (ParseTreeRoot
, AcpiDmLoadDescendingOp
,
297 AcpiDmCommonAscendingOp
, &Info
);
298 ACPI_FREE (WalkState
);
302 /*******************************************************************************
304 * FUNCTION: AcpiDmCrossReferenceNamespace
306 * PARAMETERS: ParseTreeRoot - Root of the parse tree
307 * NamespaceRoot - Root of the internal namespace
308 * OwnerId - OwnerId of the table to be disassembled
312 * DESCRIPTION: Cross reference the namespace to create externals
314 ******************************************************************************/
317 AcpiDmCrossReferenceNamespace (
318 ACPI_PARSE_OBJECT
*ParseTreeRoot
,
319 ACPI_NAMESPACE_NODE
*NamespaceRoot
,
320 ACPI_OWNER_ID OwnerId
)
323 ACPI_OP_WALK_INFO Info
;
324 ACPI_WALK_STATE
*WalkState
;
332 /* Create and initialize a new walk state */
334 WalkState
= AcpiDsCreateWalkState (OwnerId
, ParseTreeRoot
, NULL
, NULL
);
340 Status
= AcpiDsScopeStackPush (NamespaceRoot
, NamespaceRoot
->Type
, WalkState
);
341 if (ACPI_FAILURE (Status
))
348 Info
.WalkState
= WalkState
;
349 AcpiDmWalkParseTree (ParseTreeRoot
, AcpiDmXrefDescendingOp
,
350 AcpiDmCommonAscendingOp
, &Info
);
351 ACPI_FREE (WalkState
);
355 /*******************************************************************************
357 * FUNCTION: AcpiDmConvertResourceIndexes
359 * PARAMETERS: ParseTreeRoot - Root of the parse tree
360 * NamespaceRoot - Root of the internal namespace
364 * DESCRIPTION: Convert fixed-offset references to resource descriptors to
365 * symbolic references. Should only be called after namespace has
366 * been cross referenced.
368 ******************************************************************************/
371 AcpiDmConvertResourceIndexes (
372 ACPI_PARSE_OBJECT
*ParseTreeRoot
,
373 ACPI_NAMESPACE_NODE
*NamespaceRoot
)
376 ACPI_OP_WALK_INFO Info
;
377 ACPI_WALK_STATE
*WalkState
;
385 /* Create and initialize a new walk state */
387 WalkState
= AcpiDsCreateWalkState (0, ParseTreeRoot
, NULL
, NULL
);
393 Status
= AcpiDsScopeStackPush (NamespaceRoot
, NamespaceRoot
->Type
, WalkState
);
394 if (ACPI_FAILURE (Status
))
401 Info
.WalkState
= WalkState
;
402 AcpiDmWalkParseTree (ParseTreeRoot
, AcpiDmResourceDescendingOp
,
403 AcpiDmCommonAscendingOp
, &Info
);
404 ACPI_FREE (WalkState
);
409 /*******************************************************************************
411 * FUNCTION: AcpiDmDumpDescending
413 * PARAMETERS: ASL_WALK_CALLBACK
417 * DESCRIPTION: Format and print contents of one parse Op.
419 ******************************************************************************/
422 AcpiDmDumpDescending (
423 ACPI_PARSE_OBJECT
*Op
,
427 ACPI_OP_WALK_INFO
*Info
= Context
;
436 /* Most of the information (count, level, name) here */
439 AcpiOsPrintf ("% 5d [%2.2d] ", Info
->Count
, Level
);
440 AcpiDmIndent (Level
);
441 AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op
->Common
.AmlOpcode
));
443 /* Extra info is helpful */
445 switch (Op
->Common
.AmlOpcode
)
449 AcpiOsPrintf ("%2.2X", (UINT32
) Op
->Common
.Value
.Integer
);
454 AcpiOsPrintf ("%4.4X", (UINT32
) Op
->Common
.Value
.Integer
);
459 AcpiOsPrintf ("%8.8X", (UINT32
) Op
->Common
.Value
.Integer
);
464 AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op
->Common
.Value
.Integer
));
467 case AML_INT_NAMEPATH_OP
:
469 if (Op
->Common
.Value
.String
)
471 AcpiNsExternalizeName (ACPI_UINT32_MAX
, Op
->Common
.Value
.String
,
473 AcpiOsPrintf ("%s %p", Path
, Op
->Common
.Node
);
478 AcpiOsPrintf ("[NULL]");
485 case AML_INT_NAMEDFIELD_OP
:
487 AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op
->Named
.Name
));
500 /*******************************************************************************
502 * FUNCTION: AcpiDmFindOrphanDescending
504 * PARAMETERS: ASL_WALK_CALLBACK
508 * DESCRIPTION: Check namepath Ops for orphaned method invocations
510 * Note: Experimental.
512 ******************************************************************************/
515 AcpiDmFindOrphanDescending (
516 ACPI_PARSE_OBJECT
*Op
,
520 const ACPI_OPCODE_INFO
*OpInfo
;
521 ACPI_PARSE_OBJECT
*ChildOp
;
522 ACPI_PARSE_OBJECT
*NextOp
;
523 ACPI_PARSE_OBJECT
*ParentOp
;
532 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
534 switch (Op
->Common
.AmlOpcode
)
536 #ifdef ACPI_UNDER_DEVELOPMENT
539 ChildOp
= Op
->Common
.Value
.Arg
;
540 if ((ChildOp
->Common
.AmlOpcode
== AML_INT_NAMEPATH_OP
) &&
541 !ChildOp
->Common
.Node
)
543 AcpiNsExternalizeName (ACPI_UINT32_MAX
, ChildOp
->Common
.Value
.String
,
545 AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n",
546 Op
->Common
.AmlOpName
, Path
);
549 NextOp
= Op
->Common
.Next
;
552 /* This NamePath has no args, assume it is an integer */
554 AcpiDmAddOpToExternalList (ChildOp
,
555 ChildOp
->Common
.Value
.String
, ACPI_TYPE_INTEGER
, 0, 0);
559 ArgCount
= AcpiDmInspectPossibleArgs (3, 1, NextOp
);
560 AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n",
561 ArgCount
, AcpiDmCountChildren (Op
));
565 /* One Arg means this is just a Store(Name,Target) */
567 AcpiDmAddOpToExternalList (ChildOp
,
568 ChildOp
->Common
.Value
.String
, ACPI_TYPE_INTEGER
, 0, 0);
572 AcpiDmAddOpToExternalList (ChildOp
,
573 ChildOp
->Common
.Value
.String
, ACPI_TYPE_METHOD
, ArgCount
, 0);
580 ChildOp
= Op
->Common
.Value
.Arg
;
581 if ((ChildOp
->Common
.AmlOpcode
== AML_INT_NAMEPATH_OP
) &&
582 !ChildOp
->Common
.Node
)
584 NextOp
= Op
->Common
.Next
;
587 /* This NamePath has no args, assume it is an integer */
589 AcpiDmAddOpToExternalList (ChildOp
,
590 ChildOp
->Common
.Value
.String
, ACPI_TYPE_INTEGER
, 0, 0);
594 ArgCount
= AcpiDmInspectPossibleArgs (2, 1, NextOp
);
597 /* One Arg means this is just a Store(Name,Target) */
599 AcpiDmAddOpToExternalList (ChildOp
,
600 ChildOp
->Common
.Value
.String
, ACPI_TYPE_INTEGER
, 0, 0);
604 AcpiDmAddOpToExternalList (ChildOp
,
605 ChildOp
->Common
.Value
.String
, ACPI_TYPE_METHOD
, ArgCount
, 0);
609 case AML_INT_NAMEPATH_OP
:
611 /* Must examine parent to see if this namepath is an argument */
613 ParentOp
= Op
->Common
.Parent
;
614 OpInfo
= AcpiPsGetOpcodeInfo (ParentOp
->Common
.AmlOpcode
);
616 if ((OpInfo
->Class
!= AML_CLASS_EXECUTE
) &&
617 (OpInfo
->Class
!= AML_CLASS_CREATE
) &&
618 (OpInfo
->ObjectType
!= ACPI_TYPE_LOCAL_ALIAS
) &&
619 (ParentOp
->Common
.AmlOpcode
!= AML_INT_METHODCALL_OP
) &&
622 ArgCount
= AcpiDmInspectPossibleArgs (0, 0, Op
->Common
.Next
);
625 * Check if namepath is a predicate for if/while or lone parameter to
630 if (((ParentOp
->Common
.AmlOpcode
== AML_IF_OP
) ||
631 (ParentOp
->Common
.AmlOpcode
== AML_WHILE_OP
) ||
632 (ParentOp
->Common
.AmlOpcode
== AML_RETURN_OP
)) &&
634 /* And namepath is the first argument */
635 (ParentOp
->Common
.Value
.Arg
== Op
))
637 AcpiDmAddOpToExternalList (Op
,
638 Op
->Common
.Value
.String
, ACPI_TYPE_INTEGER
, 0, 0);
644 * This is a standalone namestring (not a parameter to another
645 * operator) - it *must* be a method invocation, nothing else is
646 * grammatically possible.
648 AcpiDmAddOpToExternalList (Op
,
649 Op
->Common
.Value
.String
, ACPI_TYPE_METHOD
, ArgCount
, 0);
662 /*******************************************************************************
664 * FUNCTION: AcpiDmLoadDescendingOp
666 * PARAMETERS: ASL_WALK_CALLBACK
670 * DESCRIPTION: Descending handler for namespace control method object load
672 ******************************************************************************/
675 AcpiDmLoadDescendingOp (
676 ACPI_PARSE_OBJECT
*Op
,
680 ACPI_OP_WALK_INFO
*Info
= Context
;
681 const ACPI_OPCODE_INFO
*OpInfo
;
682 ACPI_WALK_STATE
*WalkState
;
683 ACPI_OBJECT_TYPE ObjectType
;
686 ACPI_PARSE_OBJECT
*NextOp
;
687 ACPI_NAMESPACE_NODE
*Node
;
689 BOOLEAN PreDefined
= FALSE
;
690 UINT8 PreDefineIndex
= 0;
693 WalkState
= Info
->WalkState
;
694 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
695 ObjectType
= OpInfo
->ObjectType
;
696 ObjectType
= AslMapNamedOpcodeToDataType (Op
->Asl
.AmlOpcode
);
698 /* Only interested in operators that create new names */
700 if (!(OpInfo
->Flags
& AML_NAMED
) &&
701 !(OpInfo
->Flags
& AML_CREATE
))
706 /* Get the NamePath from the appropriate place */
708 if (OpInfo
->Flags
& AML_NAMED
)
710 /* For all named operators, get the new name */
712 Path
= (char *) Op
->Named
.Path
;
714 if (!Path
&& Op
->Common
.AmlOpcode
== AML_INT_NAMEDFIELD_OP
)
716 *ACPI_CAST_PTR (UINT32
, &FieldPath
[0]) = Op
->Named
.Name
;
721 else if (OpInfo
->Flags
& AML_CREATE
)
723 /* New name is the last child */
725 NextOp
= Op
->Common
.Value
.Arg
;
727 while (NextOp
->Common
.Next
)
729 NextOp
= NextOp
->Common
.Next
;
731 Path
= NextOp
->Common
.Value
.String
;
739 /* Insert the name into the namespace */
741 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Path
, ObjectType
,
742 ACPI_IMODE_LOAD_PASS2
, ACPI_NS_DONT_OPEN_SCOPE
,
745 Op
->Common
.Node
= Node
;
747 if (ACPI_SUCCESS (Status
))
749 /* Check if it's a predefined node */
751 while (AcpiGbl_PreDefinedNames
[PreDefineIndex
].Name
)
753 if (ACPI_COMPARE_NAME (Node
->Name
.Ascii
,
754 AcpiGbl_PreDefinedNames
[PreDefineIndex
].Name
))
764 * Set node owner id if it satisfies all the following conditions:
765 * 1) Not a predefined node, _SB_ etc
766 * 2) Not the root node
767 * 3) Not a node created by Scope
770 if (!PreDefined
&& Node
!= AcpiGbl_RootNode
&&
771 Op
->Common
.AmlOpcode
!= AML_SCOPE_OP
)
773 Node
->OwnerId
= WalkState
->OwnerId
;
780 if (AcpiNsOpensScope (ObjectType
))
784 Status
= AcpiDsScopeStackPush (Op
->Common
.Node
, ObjectType
, WalkState
);
785 if (ACPI_FAILURE (Status
))
796 /*******************************************************************************
798 * FUNCTION: AcpiDmXrefDescendingOp
800 * PARAMETERS: ASL_WALK_CALLBACK
804 * DESCRIPTION: Descending handler for namespace cross reference
806 ******************************************************************************/
809 AcpiDmXrefDescendingOp (
810 ACPI_PARSE_OBJECT
*Op
,
814 ACPI_OP_WALK_INFO
*Info
= Context
;
815 const ACPI_OPCODE_INFO
*OpInfo
;
816 ACPI_WALK_STATE
*WalkState
;
817 ACPI_OBJECT_TYPE ObjectType
;
818 ACPI_OBJECT_TYPE ObjectType2
;
821 ACPI_PARSE_OBJECT
*NextOp
;
822 ACPI_NAMESPACE_NODE
*Node
;
823 ACPI_OPERAND_OBJECT
*Object
;
824 UINT32 ParamCount
= 0;
828 WalkState
= Info
->WalkState
;
829 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
830 ObjectType
= OpInfo
->ObjectType
;
831 ObjectType
= AslMapNamedOpcodeToDataType (Op
->Asl
.AmlOpcode
);
833 if ((!(OpInfo
->Flags
& AML_NAMED
)) &&
834 (!(OpInfo
->Flags
& AML_CREATE
)) &&
835 (Op
->Common
.AmlOpcode
!= AML_INT_NAMEPATH_OP
) &&
836 (Op
->Common
.AmlOpcode
!= AML_NOTIFY_OP
))
842 /* Get the NamePath from the appropriate place */
844 if (OpInfo
->Flags
& AML_NAMED
)
847 * Only these two operators (Alias, Scope) refer to an existing
848 * name, it is the first argument
850 if (Op
->Common
.AmlOpcode
== AML_ALIAS_OP
)
852 ObjectType
= ACPI_TYPE_ANY
;
854 NextOp
= Op
->Common
.Value
.Arg
;
855 NextOp
= NextOp
->Common
.Value
.Arg
;
856 if (NextOp
->Common
.AmlOpcode
== AML_INT_NAMEPATH_OP
)
858 Path
= NextOp
->Common
.Value
.String
;
861 else if (Op
->Common
.AmlOpcode
== AML_SCOPE_OP
)
863 Path
= (char *) Op
->Named
.Path
;
866 else if (OpInfo
->Flags
& AML_CREATE
)
868 /* Referenced Buffer Name is the first child */
870 ObjectType
= ACPI_TYPE_BUFFER
; /* Change from TYPE_BUFFER_FIELD */
872 NextOp
= Op
->Common
.Value
.Arg
;
873 if (NextOp
->Common
.AmlOpcode
== AML_INT_NAMEPATH_OP
)
875 Path
= NextOp
->Common
.Value
.String
;
878 else if (Op
->Common
.AmlOpcode
== AML_NOTIFY_OP
)
880 Path
= Op
->Common
.Value
.Arg
->Asl
.Value
.String
;
884 Path
= Op
->Common
.Value
.String
;
893 * Lookup the name in the namespace. Name must exist at this point, or it
894 * is an invalid reference.
896 * The namespace is also used as a lookup table for references to resource
897 * descriptors and the fields within them.
900 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Path
, ACPI_TYPE_ANY
,
901 ACPI_IMODE_EXECUTE
, ACPI_NS_SEARCH_PARENT
| ACPI_NS_DONT_OPEN_SCOPE
,
903 if (ACPI_SUCCESS (Status
) && (Node
->Flags
& ANOBJ_IS_EXTERNAL
))
905 /* Node was created by an External() statement */
907 Status
= AE_NOT_FOUND
;
910 if (ACPI_FAILURE (Status
))
912 if (Status
== AE_NOT_FOUND
)
915 * Add this symbol as an external declaration, except if the
916 * parent is a CondRefOf operator. For this operator, we do not
917 * need an external, nor do we want one, since this can cause
918 * disassembly problems if the symbol is actually a control
921 if (!(Op
->Asl
.Parent
&&
922 (Op
->Asl
.Parent
->Asl
.AmlOpcode
== AML_COND_REF_OF_OP
)))
926 AcpiDmAddNodeToExternalList (Node
,
927 (UINT8
) ObjectType
, 0, 0);
931 AcpiDmAddOpToExternalList (Op
, Path
,
932 (UINT8
) ObjectType
, 0, 0);
939 * Found the node, but check if it came from an external table.
940 * Add it to external list. Note: Node->OwnerId == 0 indicates
941 * one of the built-in ACPI Names (_OS_ etc.) which can safely
944 else if (Node
->OwnerId
&&
945 (WalkState
->OwnerId
!= Node
->OwnerId
))
947 ObjectType2
= ObjectType
;
949 Object
= AcpiNsGetAttachedObject (Node
);
952 ObjectType2
= Object
->Common
.Type
;
953 if (ObjectType2
== ACPI_TYPE_METHOD
)
955 ParamCount
= Object
->Method
.ParamCount
;
959 Pathname
= AcpiNsGetExternalPathname (Node
);
962 return (AE_NO_MEMORY
);
965 AcpiDmAddNodeToExternalList (Node
, (UINT8
) ObjectType2
,
966 ParamCount
, ACPI_EXT_RESOLVED_REFERENCE
);
968 ACPI_FREE (Pathname
);
969 Op
->Common
.Node
= Node
;
973 Op
->Common
.Node
= Node
;
978 /* Open new scope if necessary */
980 if (AcpiNsOpensScope (ObjectType
))
984 Status
= AcpiDsScopeStackPush (Op
->Common
.Node
, ObjectType
, WalkState
);
985 if (ACPI_FAILURE (Status
))
996 /*******************************************************************************
998 * FUNCTION: AcpiDmResourceDescendingOp
1000 * PARAMETERS: ASL_WALK_CALLBACK
1004 * DESCRIPTION: Process one parse op during symbolic resource index conversion.
1006 ******************************************************************************/
1009 AcpiDmResourceDescendingOp (
1010 ACPI_PARSE_OBJECT
*Op
,
1014 ACPI_OP_WALK_INFO
*Info
= Context
;
1015 const ACPI_OPCODE_INFO
*OpInfo
;
1016 ACPI_WALK_STATE
*WalkState
;
1017 ACPI_OBJECT_TYPE ObjectType
;
1021 WalkState
= Info
->WalkState
;
1022 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
1024 /* Open new scope if necessary */
1026 ObjectType
= OpInfo
->ObjectType
;
1027 if (AcpiNsOpensScope (ObjectType
))
1029 if (Op
->Common
.Node
)
1032 Status
= AcpiDsScopeStackPush (Op
->Common
.Node
, ObjectType
, WalkState
);
1033 if (ACPI_FAILURE (Status
))
1041 * Check if this operator contains a reference to a resource descriptor.
1042 * If so, convert the reference into a symbolic reference.
1044 AcpiDmCheckResourceReference (Op
, WalkState
);
1049 /*******************************************************************************
1051 * FUNCTION: AcpiDmCommonAscendingOp
1053 * PARAMETERS: ASL_WALK_CALLBACK
1057 * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes
1058 * scope if necessary.
1060 ******************************************************************************/
1063 AcpiDmCommonAscendingOp (
1064 ACPI_PARSE_OBJECT
*Op
,
1068 ACPI_OP_WALK_INFO
*Info
= Context
;
1069 const ACPI_OPCODE_INFO
*OpInfo
;
1070 ACPI_OBJECT_TYPE ObjectType
;
1073 /* Close scope if necessary */
1075 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
1076 ObjectType
= OpInfo
->ObjectType
;
1077 ObjectType
= AslMapNamedOpcodeToDataType (Op
->Asl
.AmlOpcode
);
1079 if (AcpiNsOpensScope (ObjectType
))
1081 (void) AcpiDsScopeStackPop (Info
->WalkState
);
1088 /*******************************************************************************
1090 * FUNCTION: AcpiDmInspectPossibleArgs
1092 * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the
1093 * possible method invocation found
1094 * TargetCount - Number of targets (0,1,2) for this op
1099 * DESCRIPTION: Examine following args and next ops for possible arguments
1100 * for an unrecognized method invocation.
1102 ******************************************************************************/
1105 AcpiDmInspectPossibleArgs (
1106 UINT32 CurrentOpArgCount
,
1108 ACPI_PARSE_OBJECT
*Op
)
1110 const ACPI_OPCODE_INFO
*OpInfo
;
1116 Lookahead
= (ACPI_METHOD_NUM_ARGS
+ TargetCount
) - CurrentOpArgCount
;
1118 /* Lookahead for the maximum number of possible arguments */
1120 for (i
= 0; i
< Lookahead
; i
++)
1127 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Common
.AmlOpcode
);
1130 * Any one of these operators is "very probably" not a method arg
1132 if ((Op
->Common
.AmlOpcode
== AML_STORE_OP
) ||
1133 (Op
->Common
.AmlOpcode
== AML_NOTIFY_OP
))
1138 if ((OpInfo
->Class
!= AML_CLASS_EXECUTE
) &&
1139 (OpInfo
->Class
!= AML_CLASS_CONTROL
))
1144 Op
= Op
->Common
.Next
;