1 /******************************************************************************
3 * Module Name: asllookup- Namespace lookup
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #include <contrib/dev/acpica/compiler/aslcompiler.h>
119 #include "aslcompiler.y.h"
121 #include <contrib/dev/acpica/acparser.h>
122 #include <contrib/dev/acpica/amlcode.h>
123 #include <contrib/dev/acpica/acnamesp.h>
124 #include <contrib/dev/acpica/acdispat.h>
127 #define _COMPONENT ACPI_COMPILER
128 ACPI_MODULE_NAME ("asllookup")
130 /* Local prototypes */
133 LsCompareOneNamespaceObject (
134 ACPI_HANDLE ObjHandle,
140 LsDoOneNamespaceObject (
141 ACPI_HANDLE ObjHandle,
152 ACPI_PARSE_OBJECT *Op,
153 UINT32 RegionBitLength,
154 UINT32 FieldBitOffset,
155 UINT32 FieldBitLength,
156 UINT32 AccessBitWidth);
159 LkNamespaceLocateBegin (
160 ACPI_PARSE_OBJECT *Op,
165 LkNamespaceLocateEnd (
166 ACPI_PARSE_OBJECT *Op,
172 ACPI_HANDLE ObjHandle,
178 /*******************************************************************************
180 * FUNCTION: LsDoOneNamespaceObject
182 * PARAMETERS: ACPI_WALK_CALLBACK
186 * DESCRIPTION: Dump a namespace object to the namespace output file.
187 * Called during the walk of the namespace to dump all objects.
189 ******************************************************************************/
192 LsDoOneNamespaceObject (
193 ACPI_HANDLE ObjHandle,
198 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
199 ACPI_OPERAND_OBJECT *ObjDesc;
200 ACPI_PARSE_OBJECT *Op;
203 Gbl_NumNamespaceObjects++;
205 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5d [%d] %*s %4.4s - %s",
206 Gbl_NumNamespaceObjects, Level, (Level * 3), " ",
208 AcpiUtGetTypeName (Node->Type));
211 ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object);
215 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
221 (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND))
225 case ACPI_TYPE_INTEGER:
227 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
228 " [Initial Value 0x%8.8X%8.8X]",
229 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
233 case ACPI_TYPE_STRING:
235 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
236 " [Initial Value \"%s\"]",
237 ObjDesc->String.Pointer);
241 /* Nothing to do for other types */
250 case ACPI_TYPE_INTEGER:
252 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
256 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
257 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
261 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
262 " [Initial Value 0x%8.8X%8.8X]",
263 ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
267 case ACPI_TYPE_STRING:
269 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
273 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
274 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
278 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
279 " [Initial Value \"%s\"]",
280 Op->Asl.Value.String);
284 case ACPI_TYPE_LOCAL_REGION_FIELD:
286 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
287 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
291 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
292 " [Offset 0x%04X Length 0x%04X bits]",
293 Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer);
297 case ACPI_TYPE_BUFFER_FIELD:
299 switch (Op->Asl.ParseOpcode)
301 case PARSEOP_CREATEBYTEFIELD:
302 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BYTE ( 8 bit)]");
305 case PARSEOP_CREATEDWORDFIELD:
306 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [DWORD (32 bit)]");
309 case PARSEOP_CREATEQWORDFIELD:
310 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [QWORD (64 bit)]");
313 case PARSEOP_CREATEWORDFIELD:
314 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [WORD (16 bit)]");
317 case PARSEOP_CREATEBITFIELD:
318 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BIT ( 1 bit)]");
321 case PARSEOP_CREATEFIELD:
322 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Arbitrary Bit Field]");
332 case ACPI_TYPE_PACKAGE:
334 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
338 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
339 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
345 if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
346 (Op->Asl.ParseOpcode == PARSEOP_RAW_DATA))
348 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
349 " [Initial Length 0x%.2X elements]",
350 Op->Asl.Value.Integer);
355 case ACPI_TYPE_BUFFER:
357 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
361 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
362 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
368 if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER))
370 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
371 " [Initial Length 0x%.2X bytes]",
372 Op->Asl.Value.Integer);
377 case ACPI_TYPE_METHOD:
379 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
380 " [Code Length 0x%.4X bytes]",
381 Op->Asl.AmlSubtreeLength);
385 case ACPI_TYPE_LOCAL_RESOURCE:
387 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
388 " [Desc Offset 0x%.4X Bytes]", Node->Value);
392 case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
394 if (Node->Flags & 0x80)
396 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
397 " [Field Offset 0x%.4X Bits 0x%.4X Bytes]",
398 Node->Value, Node->Value / 8);
402 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
403 " [Field Offset 0x%.4X Bytes]", Node->Value);
409 /* Nothing to do for other types */
414 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
420 LsSetupNsList (void * Handle)
423 Gbl_NsOutputFlag = TRUE;
424 Gbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle;
428 /*******************************************************************************
430 * FUNCTION: LsDisplayNamespace
436 * DESCRIPTION: Walk the namespace an display information about each node
437 * in the tree. Information is written to the optional
438 * namespace output file.
440 ******************************************************************************/
449 if (!Gbl_NsOutputFlag)
454 Gbl_NumNamespaceObjects = 0;
458 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n");
459 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n");
461 /* Walk entire namespace from the root */
463 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
464 ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject,
470 /*******************************************************************************
472 * FUNCTION: LsCompareOneNamespaceObject
474 * PARAMETERS: ACPI_WALK_CALLBACK
478 * DESCRIPTION: Compare name of one object.
480 ******************************************************************************/
483 LsCompareOneNamespaceObject (
484 ACPI_HANDLE ObjHandle,
489 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
492 /* Simply check the name */
494 if (*((UINT32 *) (Context)) == Node->Name.Integer)
496 /* Abort walk if we found one instance */
498 return (AE_CTRL_TRUE);
505 /*******************************************************************************
507 * FUNCTION: LkObjectExists
509 * PARAMETERS: Name - 4 char ACPI name
511 * RETURN: TRUE if name exists in namespace
513 * DESCRIPTION: Walk the namespace to find an object
515 ******************************************************************************/
524 /* Walk entire namespace from the supplied root */
526 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
527 ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject,
529 if (Status == AE_CTRL_TRUE)
531 /* At least one instance of the name was found */
540 /*******************************************************************************
542 * FUNCTION: LkGetNameOp
544 * PARAMETERS: Op - Current Op
546 * RETURN: NameOp associated with the input op
548 * DESCRIPTION: Find the name declaration op associated with the operator
550 ******************************************************************************/
554 ACPI_PARSE_OBJECT *Op)
556 const ACPI_OPCODE_INFO *OpInfo;
557 ACPI_PARSE_OBJECT *NameOp = Op;
560 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
563 /* Get the NamePath from the appropriate place */
565 if (OpInfo->Flags & AML_NAMED)
567 /* For nearly all NAMED operators, the name reference is the first child */
569 NameOp = Op->Asl.Child;
570 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
573 * ALIAS is the only oddball opcode, the name declaration
574 * (alias name) is the second operand
576 NameOp = Op->Asl.Child->Asl.Next;
579 else if (OpInfo->Flags & AML_CREATE)
581 /* Name must appear as the last parameter */
583 NameOp = Op->Asl.Child;
584 while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
586 NameOp = NameOp->Asl.Next;
594 /*******************************************************************************
596 * FUNCTION: LkIsObjectUsed
598 * PARAMETERS: ACPI_WALK_CALLBACK
602 * DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
603 * We have to be careful, because some types and names are
604 * typically or always unreferenced, we don't want to issue
605 * excessive warnings.
607 ******************************************************************************/
611 ACPI_HANDLE ObjHandle,
616 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
619 /* Referenced flag is set during the namespace xref */
621 if (Node->Flags & ANOBJ_IS_REFERENCED)
627 * Ignore names that start with an underscore,
628 * these are the reserved ACPI names and are typically not referenced,
629 * they are called by the host OS.
631 if (Node->Name.Ascii[0] == '_')
636 /* There are some types that are typically not referenced, ignore them */
640 case ACPI_TYPE_DEVICE:
641 case ACPI_TYPE_PROCESSOR:
642 case ACPI_TYPE_POWER:
643 case ACPI_TYPE_LOCAL_RESOURCE:
650 /* All others are valid unreferenced namespace objects */
654 AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL);
660 /*******************************************************************************
662 * FUNCTION: LkFindUnreferencedObjects
668 * DESCRIPTION: Namespace walk to find objects that are not referenced in any
669 * way. Must be called after the namespace has been cross
672 ******************************************************************************/
675 LkFindUnreferencedObjects (
679 /* Walk entire namespace from the supplied root */
681 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
682 ACPI_UINT32_MAX, FALSE, LkIsObjectUsed,
687 /*******************************************************************************
689 * FUNCTION: LkCrossReferenceNamespace
695 * DESCRIPTION: Perform a cross reference check of the parse tree against the
696 * namespace. Every named referenced within the parse tree
697 * should be get resolved with a namespace lookup. If not, the
698 * original reference in the ASL code is invalid -- i.e., refers
699 * to a non-existent object.
701 * NOTE: The ASL "External" operator causes the name to be inserted into the
702 * namespace so that references to the external name will be resolved
705 ******************************************************************************/
708 LkCrossReferenceNamespace (
711 ACPI_WALK_STATE *WalkState;
714 DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n");
717 * Create a new walk state for use when looking up names
718 * within the namespace (Passed as context to the callbacks)
720 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
726 /* Walk the entire parse tree */
728 TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin,
729 LkNamespaceLocateEnd, WalkState);
734 /*******************************************************************************
736 * FUNCTION: LkCheckFieldRange
738 * PARAMETERS: RegionBitLength - Length of entire parent region
739 * FieldBitOffset - Start of the field unit (within region)
740 * FieldBitLength - Entire length of field unit
741 * AccessBitWidth - Access width of the field unit
745 * DESCRIPTION: Check one field unit to make sure it fits in the parent
748 * Note: AccessBitWidth must be either 8,16,32, or 64
750 ******************************************************************************/
754 ACPI_PARSE_OBJECT *Op,
755 UINT32 RegionBitLength,
756 UINT32 FieldBitOffset,
757 UINT32 FieldBitLength,
758 UINT32 AccessBitWidth)
760 UINT32 FieldEndBitOffset;
764 * Check each field unit against the region size. The entire
765 * field unit (start offset plus length) must fit within the
768 FieldEndBitOffset = FieldBitOffset + FieldBitLength;
770 if (FieldEndBitOffset > RegionBitLength)
772 /* Field definition itself is beyond the end-of-region */
774 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
779 * Now check that the field plus AccessWidth doesn't go beyond
780 * the end-of-region. Assumes AccessBitWidth is a power of 2
782 FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
784 if (FieldEndBitOffset > RegionBitLength)
786 /* Field definition combined with the access is beyond EOR */
788 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
792 /*******************************************************************************
794 * FUNCTION: LkNamespaceLocateBegin
796 * PARAMETERS: ASL_WALK_CALLBACK
800 * DESCRIPTION: Descending callback used during cross-reference. For named
801 * object references, attempt to locate the name in the
804 * NOTE: ASL references to named fields within resource descriptors are
805 * resolved to integer values here. Therefore, this step is an
806 * important part of the code generation. We don't know that the
807 * name refers to a resource descriptor until now.
809 ******************************************************************************/
812 LkNamespaceLocateBegin (
813 ACPI_PARSE_OBJECT *Op,
817 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
818 ACPI_NAMESPACE_NODE *Node;
820 ACPI_OBJECT_TYPE ObjectType;
823 ACPI_PARSE_OBJECT *NextOp;
824 ACPI_PARSE_OBJECT *OwningOp;
825 ACPI_PARSE_OBJECT *SpaceIdOp;
826 UINT32 MinimumLength;
828 const ACPI_OPCODE_INFO *OpInfo;
832 ACPI_FUNCTION_TRACE_PTR (LkNamespaceLocateBegin, Op);
835 * If this node is the actual declaration of a name
836 * [such as the XXXX name in "Method (XXXX)"],
837 * we are not interested in it here. We only care about names that are
838 * references to other objects within the namespace and the parent objects
839 * of name declarations
841 if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
846 /* We are only interested in opcodes that have an associated name */
848 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
850 if ((!(OpInfo->Flags & AML_NAMED)) &&
851 (!(OpInfo->Flags & AML_CREATE)) &&
852 (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
853 (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
854 (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
860 * We must enable the "search-to-root" for single NameSegs, but
861 * we have to be very careful about opening up scopes
863 Flags = ACPI_NS_SEARCH_PARENT;
864 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
865 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
866 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
869 * These are name references, do not push the scope stack
872 Flags |= ACPI_NS_DONT_OPEN_SCOPE;
875 /* Get the NamePath from the appropriate place */
877 if (OpInfo->Flags & AML_NAMED)
879 /* For nearly all NAMED operators, the name reference is the first child */
881 Path = Op->Asl.Child->Asl.Value.String;
882 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
885 * ALIAS is the only oddball opcode, the name declaration
886 * (alias name) is the second operand
888 Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
891 else if (OpInfo->Flags & AML_CREATE)
893 /* Name must appear as the last parameter */
895 NextOp = Op->Asl.Child;
896 while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
898 NextOp = NextOp->Asl.Next;
900 Path = NextOp->Asl.Value.String;
904 Path = Op->Asl.Value.String;
907 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
908 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
909 "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
912 * Lookup the name in the namespace. Name must exist at this point, or it
913 * is an invalid reference.
915 * The namespace is also used as a lookup table for references to resource
916 * descriptors and the fields within them.
920 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
921 ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
922 if (ACPI_FAILURE (Status))
924 if (Status == AE_NOT_FOUND)
927 * We didn't find the name reference by path -- we can qualify this
928 * a little better before we print an error message
930 if (strlen (Path) == ACPI_NAME_SIZE)
932 /* A simple, one-segment ACPI name */
934 if (LkObjectExists (Path))
937 * There exists such a name, but we couldn't get to it
940 AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op,
941 Op->Asl.ExternalName);
945 /* The name doesn't exist, period */
947 if ((Op->Asl.Parent) &&
948 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
950 /* Ignore not found if parent is CondRefOf */
955 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST,
956 Op, Op->Asl.ExternalName);
961 /* Check for a fully qualified path */
963 if (Path[0] == AML_ROOT_PREFIX)
965 /* Gave full path, the object does not exist */
967 if ((Op->Asl.Parent) &&
968 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
970 /* Ignore not found if parent is CondRefOf */
975 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op,
976 Op->Asl.ExternalName);
981 * We can't tell whether it doesn't exist or just
984 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
985 Op->Asl.ExternalName);
994 /* Check for a reference vs. name declaration */
996 if (!(OpInfo->Flags & AML_NAMED) &&
997 !(OpInfo->Flags & AML_CREATE))
999 /* This node has been referenced, mark it for reference check */
1001 Node->Flags |= ANOBJ_IS_REFERENCED;
1004 /* Attempt to optimize the NamePath */
1006 OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
1009 * 1) Dereference an alias (A name reference that is an alias)
1010 * Aliases are not nested, the alias always points to the final object
1012 if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) &&
1013 (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
1015 /* This node points back to the original PARSEOP_ALIAS */
1019 /* The first child is the alias target op */
1021 NextOp = NextOp->Asl.Child;
1023 /* That in turn points back to original target alias node */
1025 if (NextOp->Asl.Node)
1027 Node = NextOp->Asl.Node;
1030 /* Else - forward reference to alias, will be resolved later */
1033 /* 2) Check for a reference to a resource descriptor */
1035 if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
1036 (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
1039 * This was a reference to a field within a resource descriptor. Extract
1040 * the associated field offset (either a bit or byte offset depending on
1041 * the field type) and change the named reference into an integer for
1042 * AML code generation
1045 if (Node->Flags & ANOBJ_IS_BIT_OFFSET)
1047 Op->Asl.CompileFlags |= NODE_IS_BIT_OFFSET;
1050 /* Perform BitOffset <--> ByteOffset conversion if necessary */
1052 switch (Op->Asl.Parent->Asl.AmlOpcode)
1054 case AML_CREATE_FIELD_OP:
1056 /* We allow a Byte offset to Bit Offset conversion for this op */
1058 if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
1060 /* Simply multiply byte offset times 8 to get bit offset */
1062 Temp = ACPI_MUL_8 (Temp);
1067 case AML_CREATE_BIT_FIELD_OP:
1069 /* This op requires a Bit Offset */
1071 if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
1073 AslError (ASL_ERROR, ASL_MSG_BYTES_TO_BITS, Op, NULL);
1078 case AML_CREATE_BYTE_FIELD_OP:
1079 case AML_CREATE_WORD_FIELD_OP:
1080 case AML_CREATE_DWORD_FIELD_OP:
1081 case AML_CREATE_QWORD_FIELD_OP:
1084 /* These Ops require Byte offsets */
1086 if (Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
1088 AslError (ASL_ERROR, ASL_MSG_BITS_TO_BYTES, Op, NULL);
1094 /* Nothing to do for other opcodes */
1098 /* Now convert this node to an integer whose value is the field offset */
1100 Op->Asl.AmlLength = 0;
1101 Op->Asl.ParseOpcode = PARSEOP_INTEGER;
1102 Op->Asl.Value.Integer = (UINT64) Temp;
1103 Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
1105 OpcGenerateAmlOpcode (Op);
1108 /* 3) Check for a method invocation */
1110 else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
1111 (Node->Type == ACPI_TYPE_METHOD) &&
1113 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
1115 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
1119 * A reference to a method within one of these opcodes is not an
1120 * invocation of the method, it is simply a reference to the method.
1122 if ((Op->Asl.Parent) &&
1123 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
1124 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) ||
1125 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
1130 * There are two types of method invocation:
1131 * 1) Invocation with arguments -- the parser recognizes this
1133 * 2) Invocation with no arguments --the parser cannot determine that
1134 * this is a method invocation, therefore we have to figure it out
1137 if (Node->Type != ACPI_TYPE_METHOD)
1139 sprintf (MsgBuffer, "%s is a %s",
1140 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
1142 AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
1146 /* Save the method node in the caller's op */
1148 Op->Asl.Node = Node;
1149 if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
1155 * This is a method invocation, with or without arguments.
1156 * Count the number of arguments, each appears as a child
1157 * under the parent node
1159 Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
1160 UtSetParseOpName (Op);
1163 NextOp = Op->Asl.Child;
1168 NextOp = NextOp->Asl.Next;
1171 if (Node->Value != ASL_EXTERNAL_METHOD)
1174 * Check the parsed arguments with the number expected by the
1175 * method declaration itself
1177 if (PassedArgs != Node->Value)
1179 sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName,
1182 if (PassedArgs < Node->Value)
1184 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
1188 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
1194 /* 4) Check for an ASL Field definition */
1196 else if ((Op->Asl.Parent) &&
1197 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
1198 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
1201 * Offset checking for fields. If the parent operation region has a
1202 * constant length (known at compile time), we can check fields
1203 * defined in that region against the region length. This will catch
1204 * fields and field units that cannot possibly fit within the region.
1206 * Note: Index fields do not directly reference an operation region,
1207 * thus they are not included in this check.
1209 if (Op == Op->Asl.Parent->Asl.Child)
1212 * This is the first child of the field node, which is
1213 * the name of the region. Get the parse node for the
1214 * region -- which contains the length of the region.
1216 OwningOp = Node->Op;
1217 Op->Asl.Parent->Asl.ExtraValue =
1218 ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
1220 /* Examine the field access width */
1222 switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
1224 case AML_FIELD_ACCESS_ANY:
1225 case AML_FIELD_ACCESS_BYTE:
1226 case AML_FIELD_ACCESS_BUFFER:
1231 case AML_FIELD_ACCESS_WORD:
1235 case AML_FIELD_ACCESS_DWORD:
1239 case AML_FIELD_ACCESS_QWORD:
1245 * Is the region at least as big as the access width?
1246 * Note: DataTableRegions have 0 length
1248 if (((UINT32) OwningOp->Asl.Value.Integer) &&
1249 ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
1251 AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
1255 * Check EC/CMOS/SMBUS fields to make sure that the correct
1256 * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
1258 SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
1259 switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
1264 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
1266 AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
1272 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
1274 AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
1280 /* Nothing to do for other address spaces */
1287 * This is one element of the field list. Check to make sure
1288 * that it does not go beyond the end of the parent operation region.
1290 * In the code below:
1291 * Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
1292 * Op->Asl.ExtraValue - Field start offset (bits)
1293 * Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
1294 * Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
1296 if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
1298 LkCheckFieldRange (Op,
1299 Op->Asl.Parent->Asl.ExtraValue,
1301 (UINT32) Op->Asl.Child->Asl.Value.Integer,
1302 Op->Asl.Child->Asl.ExtraValue);
1307 Op->Asl.Node = Node;
1312 /*******************************************************************************
1314 * FUNCTION: LkNamespaceLocateEnd
1316 * PARAMETERS: ASL_WALK_CALLBACK
1320 * DESCRIPTION: Ascending callback used during cross reference. We only
1321 * need to worry about scope management here.
1323 ******************************************************************************/
1326 LkNamespaceLocateEnd (
1327 ACPI_PARSE_OBJECT *Op,
1331 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
1332 const ACPI_OPCODE_INFO *OpInfo;
1335 ACPI_FUNCTION_TRACE (LkNamespaceLocateEnd);
1338 /* We are only interested in opcodes that have an associated name */
1340 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1341 if (!(OpInfo->Flags & AML_NAMED))
1346 /* Not interested in name references, we did not open a scope for them */
1348 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
1349 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
1350 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
1355 /* Pop the scope stack if necessary */
1357 if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
1360 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1361 "%s: Popping scope for Op %p\n",
1362 AcpiUtGetTypeName (OpInfo->ObjectType), Op));
1364 (void) AcpiDsScopeStackPop (WalkState);