Fixed compatibility of output.
[AROS.git] / arch / all-pc / acpica / source / common / adwalk.c
blob5b048599ec7b50f4dd7afd930e6d0119cebf42ca
1 /******************************************************************************
3 * Module Name: adwalk - Application-level disassembler parse tree walk routines
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
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.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include "acpi.h"
46 #include "accommon.h"
47 #include "acparser.h"
48 #include "amlcode.h"
49 #include "acdisasm.h"
50 #include "acdispat.h"
51 #include "acnamesp.h"
52 #include "acapps.h"
55 #define _COMPONENT ACPI_TOOLS
56 ACPI_MODULE_NAME ("adwalk")
59 * aslmap - opcode mappings and reserved method names
61 ACPI_OBJECT_TYPE
62 AslMapNamedOpcodeToDataType (
63 UINT16 Opcode);
65 /* Local prototypes */
67 static ACPI_STATUS
68 AcpiDmFindOrphanDescending (
69 ACPI_PARSE_OBJECT *Op,
70 UINT32 Level,
71 void *Context);
73 static ACPI_STATUS
74 AcpiDmDumpDescending (
75 ACPI_PARSE_OBJECT *Op,
76 UINT32 Level,
77 void *Context);
79 static ACPI_STATUS
80 AcpiDmXrefDescendingOp (
81 ACPI_PARSE_OBJECT *Op,
82 UINT32 Level,
83 void *Context);
85 static ACPI_STATUS
86 AcpiDmCommonAscendingOp (
87 ACPI_PARSE_OBJECT *Op,
88 UINT32 Level,
89 void *Context);
91 static ACPI_STATUS
92 AcpiDmLoadDescendingOp (
93 ACPI_PARSE_OBJECT *Op,
94 UINT32 Level,
95 void *Context);
97 static UINT32
98 AcpiDmInspectPossibleArgs (
99 UINT32 CurrentOpArgCount,
100 UINT32 TargetCount,
101 ACPI_PARSE_OBJECT *Op);
103 static ACPI_STATUS
104 AcpiDmResourceDescendingOp (
105 ACPI_PARSE_OBJECT *Op,
106 UINT32 Level,
107 void *Context);
110 /*******************************************************************************
112 * FUNCTION: AcpiDmDumpTree
114 * PARAMETERS: Origin - Starting object
116 * RETURN: None
118 * DESCRIPTION: Parse tree walk to format and output the nodes
120 ******************************************************************************/
122 void
123 AcpiDmDumpTree (
124 ACPI_PARSE_OBJECT *Origin)
126 ACPI_OP_WALK_INFO Info;
129 if (!Origin)
131 return;
134 AcpiOsPrintf ("/*\nAML Parse Tree\n\n");
135 Info.Flags = 0;
136 Info.Count = 0;
137 Info.Level = 0;
138 Info.WalkState = NULL;
139 AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info);
140 AcpiOsPrintf ("*/\n\n");
144 /*******************************************************************************
146 * FUNCTION: AcpiDmFindOrphanMethods
148 * PARAMETERS: Origin - Starting object
150 * RETURN: None
152 * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods
153 * that are not resolved in the namespace
155 ******************************************************************************/
157 void
158 AcpiDmFindOrphanMethods (
159 ACPI_PARSE_OBJECT *Origin)
161 ACPI_OP_WALK_INFO Info;
164 if (!Origin)
166 return;
169 Info.Flags = 0;
170 Info.Level = 0;
171 Info.WalkState = NULL;
172 AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info);
176 /*******************************************************************************
178 * FUNCTION: AcpiDmFinishNamespaceLoad
180 * PARAMETERS: ParseTreeRoot - Root of the parse tree
181 * NamespaceRoot - Root of the internal namespace
182 * OwnerId - OwnerId of the table to be disassembled
184 * RETURN: None
186 * DESCRIPTION: Load all namespace items that are created within control
187 * methods. Used before namespace cross reference
189 ******************************************************************************/
191 void
192 AcpiDmFinishNamespaceLoad (
193 ACPI_PARSE_OBJECT *ParseTreeRoot,
194 ACPI_NAMESPACE_NODE *NamespaceRoot,
195 ACPI_OWNER_ID OwnerId)
197 ACPI_STATUS Status;
198 ACPI_OP_WALK_INFO Info;
199 ACPI_WALK_STATE *WalkState;
202 if (!ParseTreeRoot)
204 return;
207 /* Create and initialize a new walk state */
209 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
210 if (!WalkState)
212 return;
215 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
216 if (ACPI_FAILURE (Status))
218 return;
221 Info.Flags = 0;
222 Info.Level = 0;
223 Info.WalkState = WalkState;
224 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp,
225 AcpiDmCommonAscendingOp, &Info);
226 ACPI_FREE (WalkState);
230 /*******************************************************************************
232 * FUNCTION: AcpiDmCrossReferenceNamespace
234 * PARAMETERS: ParseTreeRoot - Root of the parse tree
235 * NamespaceRoot - Root of the internal namespace
236 * OwnerId - OwnerId of the table to be disassembled
238 * RETURN: None
240 * DESCRIPTION: Cross reference the namespace to create externals
242 ******************************************************************************/
244 void
245 AcpiDmCrossReferenceNamespace (
246 ACPI_PARSE_OBJECT *ParseTreeRoot,
247 ACPI_NAMESPACE_NODE *NamespaceRoot,
248 ACPI_OWNER_ID OwnerId)
250 ACPI_STATUS Status;
251 ACPI_OP_WALK_INFO Info;
252 ACPI_WALK_STATE *WalkState;
255 if (!ParseTreeRoot)
257 return;
260 /* Create and initialize a new walk state */
262 WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL);
263 if (!WalkState)
265 return;
268 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
269 if (ACPI_FAILURE (Status))
271 return;
274 Info.Flags = 0;
275 Info.Level = 0;
276 Info.WalkState = WalkState;
277 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp,
278 AcpiDmCommonAscendingOp, &Info);
279 ACPI_FREE (WalkState);
283 /*******************************************************************************
285 * FUNCTION: AcpiDmConvertResourceIndexes
287 * PARAMETERS: ParseTreeRoot - Root of the parse tree
288 * NamespaceRoot - Root of the internal namespace
290 * RETURN: None
292 * DESCRIPTION: Convert fixed-offset references to resource descriptors to
293 * symbolic references. Should only be called after namespace has
294 * been cross referenced.
296 ******************************************************************************/
298 void
299 AcpiDmConvertResourceIndexes (
300 ACPI_PARSE_OBJECT *ParseTreeRoot,
301 ACPI_NAMESPACE_NODE *NamespaceRoot)
303 ACPI_STATUS Status;
304 ACPI_OP_WALK_INFO Info;
305 ACPI_WALK_STATE *WalkState;
308 if (!ParseTreeRoot)
310 return;
313 /* Create and initialize a new walk state */
315 WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL);
316 if (!WalkState)
318 return;
321 Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, WalkState);
322 if (ACPI_FAILURE (Status))
324 return;
327 Info.Flags = 0;
328 Info.Level = 0;
329 Info.WalkState = WalkState;
330 AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp,
331 AcpiDmCommonAscendingOp, &Info);
332 ACPI_FREE (WalkState);
333 return;
337 /*******************************************************************************
339 * FUNCTION: AcpiDmDumpDescending
341 * PARAMETERS: ASL_WALK_CALLBACK
343 * RETURN: Status
345 * DESCRIPTION: Format and print contents of one parse Op.
347 ******************************************************************************/
349 static ACPI_STATUS
350 AcpiDmDumpDescending (
351 ACPI_PARSE_OBJECT *Op,
352 UINT32 Level,
353 void *Context)
355 ACPI_OP_WALK_INFO *Info = Context;
356 char *Path;
359 if (!Op)
361 return (AE_OK);
364 /* Most of the information (count, level, name) here */
366 Info->Count++;
367 AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level);
368 AcpiDmIndent (Level);
369 AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode));
371 /* Extra info is helpful */
373 switch (Op->Common.AmlOpcode)
375 case AML_BYTE_OP:
377 AcpiOsPrintf ("%2.2X", (UINT32) Op->Common.Value.Integer);
378 break;
380 case AML_WORD_OP:
382 AcpiOsPrintf ("%4.4X", (UINT32) Op->Common.Value.Integer);
383 break;
385 case AML_DWORD_OP:
387 AcpiOsPrintf ("%8.8X", (UINT32) Op->Common.Value.Integer);
388 break;
390 case AML_QWORD_OP:
392 AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
393 break;
395 case AML_INT_NAMEPATH_OP:
397 if (Op->Common.Value.String)
399 AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String,
400 NULL, &Path);
401 AcpiOsPrintf ("%s %p", Path, Op->Common.Node);
402 ACPI_FREE (Path);
404 else
406 AcpiOsPrintf ("[NULL]");
408 break;
410 case AML_NAME_OP:
411 case AML_METHOD_OP:
412 case AML_DEVICE_OP:
413 case AML_INT_NAMEDFIELD_OP:
415 AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name));
416 break;
418 default:
420 break;
423 AcpiOsPrintf ("\n");
424 return (AE_OK);
428 /*******************************************************************************
430 * FUNCTION: AcpiDmFindOrphanDescending
432 * PARAMETERS: ASL_WALK_CALLBACK
434 * RETURN: Status
436 * DESCRIPTION: Check namepath Ops for orphaned method invocations
438 * Note: Experimental.
440 ******************************************************************************/
442 static ACPI_STATUS
443 AcpiDmFindOrphanDescending (
444 ACPI_PARSE_OBJECT *Op,
445 UINT32 Level,
446 void *Context)
448 const ACPI_OPCODE_INFO *OpInfo;
449 ACPI_PARSE_OBJECT *ChildOp;
450 ACPI_PARSE_OBJECT *NextOp;
451 ACPI_PARSE_OBJECT *ParentOp;
452 UINT32 ArgCount;
455 if (!Op)
457 return (AE_OK);
460 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
462 switch (Op->Common.AmlOpcode)
464 #ifdef ACPI_UNDER_DEVELOPMENT
465 case AML_ADD_OP:
467 ChildOp = Op->Common.Value.Arg;
468 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
469 !ChildOp->Common.Node)
471 AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,
472 NULL, &Path);
473 AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", Op->Common.AmlOpName, Path);
474 ACPI_FREE (Path);
476 NextOp = Op->Common.Next;
477 if (!NextOp)
479 /* This NamePath has no args, assume it is an integer */
481 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
482 return (AE_OK);
485 ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);
486 AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", ArgCount, AcpiDmCountChildren (Op));
488 if (ArgCount < 1)
490 /* One Arg means this is just a Store(Name,Target) */
492 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
493 return (AE_OK);
496 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
498 break;
499 #endif
501 case AML_STORE_OP:
503 ChildOp = Op->Common.Value.Arg;
504 if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
505 !ChildOp->Common.Node)
507 NextOp = Op->Common.Next;
508 if (!NextOp)
510 /* This NamePath has no args, assume it is an integer */
512 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
513 return (AE_OK);
516 ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);
517 if (ArgCount <= 1)
519 /* One Arg means this is just a Store(Name,Target) */
521 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);
522 return (AE_OK);
525 AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
527 break;
529 case AML_INT_NAMEPATH_OP:
531 /* Must examine parent to see if this namepath is an argument */
533 ParentOp = Op->Common.Parent;
534 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
536 if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
537 (OpInfo->Class != AML_CLASS_CREATE) &&
538 (OpInfo->ObjectType != ACPI_TYPE_LOCAL_ALIAS) &&
539 (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
540 !Op->Common.Node)
542 ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next);
545 * Check if namepath is a predicate for if/while or lone parameter to
546 * a return.
548 if (ArgCount == 0)
550 if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
551 (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||
552 (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&
554 /* And namepath is the first argument */
555 (ParentOp->Common.Value.Arg == Op))
557 AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_INTEGER, 0);
558 break;
563 * This is a standalone namestring (not a parameter to another
564 * operator) - it *must* be a method invocation, nothing else is
565 * grammatically possible.
567 AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);
570 break;
572 default:
574 break;
577 return (AE_OK);
581 /*******************************************************************************
583 * FUNCTION: AcpiDmLoadDescendingOp
585 * PARAMETERS: ASL_WALK_CALLBACK
587 * RETURN: Status
589 * DESCRIPTION: Descending handler for namespace control method object load
591 ******************************************************************************/
593 static ACPI_STATUS
594 AcpiDmLoadDescendingOp (
595 ACPI_PARSE_OBJECT *Op,
596 UINT32 Level,
597 void *Context)
599 ACPI_OP_WALK_INFO *Info = Context;
600 const ACPI_OPCODE_INFO *OpInfo;
601 ACPI_WALK_STATE *WalkState;
602 ACPI_OBJECT_TYPE ObjectType;
603 ACPI_STATUS Status;
604 char *Path = NULL;
605 ACPI_PARSE_OBJECT *NextOp;
606 ACPI_NAMESPACE_NODE *Node;
607 char FieldPath[5];
608 BOOLEAN PreDefined = FALSE;
609 UINT8 PreDefineIndex = 0;
612 WalkState = Info->WalkState;
613 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
614 ObjectType = OpInfo->ObjectType;
615 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
617 /* Only interested in operators that create new names */
619 if (!(OpInfo->Flags & AML_NAMED) &&
620 !(OpInfo->Flags & AML_CREATE))
622 goto Exit;
625 /* Get the NamePath from the appropriate place */
627 if (OpInfo->Flags & AML_NAMED)
629 /* For all named operators, get the new name */
631 Path = (char *) Op->Named.Path;
633 if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
635 *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
636 FieldPath[4] = 0;
637 Path = FieldPath;
640 else if (OpInfo->Flags & AML_CREATE)
642 /* New name is the last child */
644 NextOp = Op->Common.Value.Arg;
646 while (NextOp->Common.Next)
648 NextOp = NextOp->Common.Next;
650 Path = NextOp->Common.Value.String;
653 if (!Path)
655 goto Exit;
658 /* Insert the name into the namespace */
660 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
661 ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,
662 WalkState, &Node);
664 Op->Common.Node = Node;
666 if (ACPI_SUCCESS (Status))
668 /* Check if it's a predefined node */
670 while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
672 if (ACPI_COMPARE_NAME (Node->Name.Ascii,
673 AcpiGbl_PreDefinedNames[PreDefineIndex].Name))
675 PreDefined = TRUE;
676 break;
679 PreDefineIndex++;
683 * Set node owner id if it satisfies all the following conditions:
684 * 1) Not a predefined node, _SB_ etc
685 * 2) Not the root node
686 * 3) Not a node created by Scope
689 if (!PreDefined && Node != AcpiGbl_RootNode &&
690 Op->Common.AmlOpcode != AML_SCOPE_OP)
692 Node->OwnerId = WalkState->OwnerId;
697 Exit:
699 if (AcpiNsOpensScope (ObjectType))
701 if (Op->Common.Node)
703 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
704 if (ACPI_FAILURE (Status))
706 return (Status);
711 return (AE_OK);
715 /*******************************************************************************
717 * FUNCTION: AcpiDmXrefDescendingOp
719 * PARAMETERS: ASL_WALK_CALLBACK
721 * RETURN: Status
723 * DESCRIPTION: Descending handler for namespace cross reference
725 ******************************************************************************/
727 static ACPI_STATUS
728 AcpiDmXrefDescendingOp (
729 ACPI_PARSE_OBJECT *Op,
730 UINT32 Level,
731 void *Context)
733 ACPI_OP_WALK_INFO *Info = Context;
734 const ACPI_OPCODE_INFO *OpInfo;
735 ACPI_WALK_STATE *WalkState;
736 ACPI_OBJECT_TYPE ObjectType;
737 ACPI_OBJECT_TYPE ObjectType2;
738 ACPI_STATUS Status;
739 char *Path = NULL;
740 ACPI_PARSE_OBJECT *NextOp;
741 ACPI_NAMESPACE_NODE *Node;
742 ACPI_OPERAND_OBJECT *Object;
743 UINT32 ParamCount = 0;
746 WalkState = Info->WalkState;
747 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
748 ObjectType = OpInfo->ObjectType;
749 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
751 if ((!(OpInfo->Flags & AML_NAMED)) &&
752 (!(OpInfo->Flags & AML_CREATE)) &&
753 (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
755 goto Exit;
758 /* Get the NamePath from the appropriate place */
760 if (OpInfo->Flags & AML_NAMED)
763 * Only these two operators (Alias, Scope) refer to an existing
764 * name, it is the first argument
766 if (Op->Common.AmlOpcode == AML_ALIAS_OP)
768 ObjectType = ACPI_TYPE_ANY;
770 NextOp = Op->Common.Value.Arg;
771 NextOp = NextOp->Common.Value.Arg;
772 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
774 Path = NextOp->Common.Value.String;
777 else if (Op->Common.AmlOpcode == AML_SCOPE_OP)
779 Path = (char *) Op->Named.Path;
782 else if (OpInfo->Flags & AML_CREATE)
784 /* Referenced Buffer Name is the first child */
786 ObjectType = ACPI_TYPE_BUFFER; /* Change from TYPE_BUFFER_FIELD */
788 NextOp = Op->Common.Value.Arg;
789 if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
791 Path = NextOp->Common.Value.String;
794 else
796 Path = Op->Common.Value.String;
799 if (!Path)
801 goto Exit;
805 * Lookup the name in the namespace. Name must exist at this point, or it
806 * is an invalid reference.
808 * The namespace is also used as a lookup table for references to resource
809 * descriptors and the fields within them.
811 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
812 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
813 WalkState, &Node);
814 if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL))
816 Status = AE_NOT_FOUND;
819 if (ACPI_FAILURE (Status))
821 if (Status == AE_NOT_FOUND)
824 * Add this symbol as an external declaration, except if the
825 * parent is a CondRefOf operator. For this operator, we do not
826 * need an external, nor do we want one, since this can cause
827 * disassembly problems if the symbol is actually a control
828 * method.
830 if (!(Op->Asl.Parent &&
831 (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP)))
833 AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType, 0);
839 * Found the node in external table, add it to external list
840 * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc
842 else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId)
844 ObjectType2 = ObjectType;
846 Object = AcpiNsGetAttachedObject (Node);
847 if (Object)
849 ObjectType2 = Object->Common.Type;
850 if (ObjectType2 == ACPI_TYPE_METHOD)
852 ParamCount = Object->Method.ParamCount;
856 AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType2, ParamCount | 0x80);
857 Op->Common.Node = Node;
859 else
861 Op->Common.Node = Node;
865 Exit:
866 /* Open new scope if necessary */
868 if (AcpiNsOpensScope (ObjectType))
870 if (Op->Common.Node)
872 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
873 if (ACPI_FAILURE (Status))
875 return (Status);
880 return (AE_OK);
884 /*******************************************************************************
886 * FUNCTION: AcpiDmResourceDescendingOp
888 * PARAMETERS: ASL_WALK_CALLBACK
890 * RETURN: None
892 * DESCRIPTION: Process one parse op during symbolic resource index conversion.
894 ******************************************************************************/
896 static ACPI_STATUS
897 AcpiDmResourceDescendingOp (
898 ACPI_PARSE_OBJECT *Op,
899 UINT32 Level,
900 void *Context)
902 ACPI_OP_WALK_INFO *Info = Context;
903 const ACPI_OPCODE_INFO *OpInfo;
904 ACPI_WALK_STATE *WalkState;
905 ACPI_OBJECT_TYPE ObjectType;
906 ACPI_STATUS Status;
909 WalkState = Info->WalkState;
910 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
912 /* Open new scope if necessary */
914 ObjectType = OpInfo->ObjectType;
915 if (AcpiNsOpensScope (ObjectType))
917 if (Op->Common.Node)
920 Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);
921 if (ACPI_FAILURE (Status))
923 return (Status);
929 * Check if this operator contains a reference to a resource descriptor.
930 * If so, convert the reference into a symbolic reference.
932 AcpiDmCheckResourceReference (Op, WalkState);
933 return (AE_OK);
937 /*******************************************************************************
939 * FUNCTION: AcpiDmCommonAscendingOp
941 * PARAMETERS: ASL_WALK_CALLBACK
943 * RETURN: None
945 * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes
946 * scope if necessary.
948 ******************************************************************************/
950 static ACPI_STATUS
951 AcpiDmCommonAscendingOp (
952 ACPI_PARSE_OBJECT *Op,
953 UINT32 Level,
954 void *Context)
956 ACPI_OP_WALK_INFO *Info = Context;
957 const ACPI_OPCODE_INFO *OpInfo;
958 ACPI_OBJECT_TYPE ObjectType;
961 /* Close scope if necessary */
963 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
964 ObjectType = OpInfo->ObjectType;
965 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
967 if (AcpiNsOpensScope (ObjectType))
969 (void) AcpiDsScopeStackPop (Info->WalkState);
972 return (AE_OK);
976 /*******************************************************************************
978 * FUNCTION: AcpiDmInspectPossibleArgs
980 * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the
981 * possible method invocation found
982 * TargetCount - Number of targets (0,1,2) for this op
983 * Op - Parse op
985 * RETURN: Status
987 * DESCRIPTION: Examine following args and next ops for possible arguments
988 * for an unrecognized method invocation.
990 ******************************************************************************/
992 static UINT32
993 AcpiDmInspectPossibleArgs (
994 UINT32 CurrentOpArgCount,
995 UINT32 TargetCount,
996 ACPI_PARSE_OBJECT *Op)
998 const ACPI_OPCODE_INFO *OpInfo;
999 UINT32 i;
1000 UINT32 Last = 0;
1001 UINT32 Lookahead;
1004 Lookahead = (ACPI_METHOD_NUM_ARGS + TargetCount) - CurrentOpArgCount;
1006 /* Lookahead for the maximum number of possible arguments */
1008 for (i = 0; i < Lookahead; i++)
1010 if (!Op)
1012 break;
1015 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
1018 * Any one of these operators is "very probably" not a method arg
1020 if ((Op->Common.AmlOpcode == AML_STORE_OP) ||
1021 (Op->Common.AmlOpcode == AML_NOTIFY_OP))
1023 break;
1026 if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
1027 (OpInfo->Class != AML_CLASS_CONTROL))
1029 Last = i+1;
1032 Op = Op->Common.Next;
1035 return (Last);