1 /******************************************************************************
3 * Module Name: aslxref - Namespace cross-reference
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, 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/compiler/aslcompiler.h>
45 #include "aslcompiler.y.h"
46 #include <contrib/dev/acpica/include/acparser.h>
47 #include <contrib/dev/acpica/include/amlcode.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
49 #include <contrib/dev/acpica/include/acdispat.h>
52 #define _COMPONENT ACPI_COMPILER
53 ACPI_MODULE_NAME ("aslxref")
55 /* Local prototypes */
58 XfNamespaceLocateBegin (
59 ACPI_PARSE_OBJECT *Op,
64 XfNamespaceLocateEnd (
65 ACPI_PARSE_OBJECT *Op,
74 XfCompareOneNamespaceObject (
75 ACPI_HANDLE ObjHandle,
82 ACPI_PARSE_OBJECT *Op,
83 UINT32 RegionBitLength,
84 UINT32 FieldBitOffset,
85 UINT32 FieldBitLength,
86 UINT32 AccessBitWidth);
88 #ifdef __UNDER_DEVELOPMENT
89 static ACPI_PARSE_OBJECT *
91 ACPI_PARSE_OBJECT *Op);
94 XfCheckIllegalReference (
95 ACPI_PARSE_OBJECT *Op,
96 ACPI_NAMESPACE_NODE *Node);
100 ACPI_PARSE_OBJECT *MethodOp1,
101 ACPI_PARSE_OBJECT *MethodOp2);
105 /*******************************************************************************
107 * FUNCTION: XfCrossReferenceNamespace
113 * DESCRIPTION: Perform a cross reference check of the parse tree against the
114 * namespace. Every named referenced within the parse tree
115 * should be get resolved with a namespace lookup. If not, the
116 * original reference in the ASL code is invalid -- i.e., refers
117 * to a non-existent object.
119 * NOTE: The ASL "External" operator causes the name to be inserted into the
120 * namespace so that references to the external name will be resolved
123 ******************************************************************************/
126 XfCrossReferenceNamespace (
129 ACPI_WALK_STATE *WalkState;
132 DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n");
135 * Create a new walk state for use when looking up names
136 * within the namespace (Passed as context to the callbacks)
138 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
141 return (AE_NO_MEMORY);
144 /* Walk the entire parse tree */
146 TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin,
147 XfNamespaceLocateEnd, WalkState);
149 ACPI_FREE (WalkState);
154 /*******************************************************************************
156 * FUNCTION: XfObjectExists
158 * PARAMETERS: Name - 4 char ACPI name
160 * RETURN: TRUE if name exists in namespace
162 * DESCRIPTION: Walk the namespace to find an object
164 ******************************************************************************/
173 /* Walk entire namespace from the supplied root */
175 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
176 ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL,
178 if (Status == AE_CTRL_TRUE)
180 /* At least one instance of the name was found */
189 /*******************************************************************************
191 * FUNCTION: XfCompareOneNamespaceObject
193 * PARAMETERS: ACPI_WALK_CALLBACK
197 * DESCRIPTION: Compare name of one object.
199 ******************************************************************************/
202 XfCompareOneNamespaceObject (
203 ACPI_HANDLE ObjHandle,
208 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
211 /* Simply check the name */
213 if (*((UINT32 *) (Context)) == Node->Name.Integer)
215 /* Abort walk if we found one instance */
217 return (AE_CTRL_TRUE);
224 /*******************************************************************************
226 * FUNCTION: XfCheckFieldRange
228 * PARAMETERS: RegionBitLength - Length of entire parent region
229 * FieldBitOffset - Start of the field unit (within region)
230 * FieldBitLength - Entire length of field unit
231 * AccessBitWidth - Access width of the field unit
235 * DESCRIPTION: Check one field unit to make sure it fits in the parent
238 * Note: AccessBitWidth must be either 8,16,32, or 64
240 ******************************************************************************/
244 ACPI_PARSE_OBJECT *Op,
245 UINT32 RegionBitLength,
246 UINT32 FieldBitOffset,
247 UINT32 FieldBitLength,
248 UINT32 AccessBitWidth)
250 UINT32 FieldEndBitOffset;
254 * Check each field unit against the region size. The entire
255 * field unit (start offset plus length) must fit within the
258 FieldEndBitOffset = FieldBitOffset + FieldBitLength;
260 if (FieldEndBitOffset > RegionBitLength)
262 /* Field definition itself is beyond the end-of-region */
264 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
269 * Now check that the field plus AccessWidth doesn't go beyond
270 * the end-of-region. Assumes AccessBitWidth is a power of 2
272 FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
274 if (FieldEndBitOffset > RegionBitLength)
276 /* Field definition combined with the access is beyond EOR */
278 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
283 #ifdef __UNDER_DEVELOPMENT
284 /*******************************************************************************
286 * FUNCTION: XfIsObjectParental
288 * PARAMETERS: ChildOp - Op to be checked
289 * PossibleParentOp - Determine if this op is in the family
291 * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp
293 * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to
294 * detect if a method is declared within another method.
296 ******************************************************************************/
300 ACPI_PARSE_OBJECT *ChildOp,
301 ACPI_PARSE_OBJECT *PossibleParentOp)
303 ACPI_PARSE_OBJECT *ParentOp;
306 /* Search upwards through the tree for possible parent */
311 if (ParentOp == PossibleParentOp)
316 ParentOp = ParentOp->Asl.Parent;
323 /*******************************************************************************
325 * FUNCTION: XfGetParentMethod
327 * PARAMETERS: Op - Op to be checked
329 * RETURN: Op for parent method. NULL if object is not within a method.
331 * DESCRIPTION: Determine if an object is within a control method. Used to
332 * implement special rules for named references from within a
335 * NOTE: It would be better to have the parser set a flag in the Op if possible.
337 ******************************************************************************/
339 static ACPI_PARSE_OBJECT *
341 ACPI_PARSE_OBJECT *Op)
343 ACPI_PARSE_OBJECT *ParentOp;
351 if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
356 /* Walk upwards through the parse tree, up to the root if necessary */
361 if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD)
366 ParentOp = ParentOp->Asl.Parent;
369 /* Object is not within a method */
375 /*******************************************************************************
377 * FUNCTION: XfCheckIllegalReference
379 * PARAMETERS: Op - Op referring to the target
380 * TargetNode - Target of the reference
382 * RETURN: None. Emits error message for an illegal reference
384 * DESCRIPTION: Determine if a named reference is legal. A "named" reference
385 * is something like: Store(ABCD, ...), where ABCD is an AML
386 * Nameseg or Namepath.
388 * NOTE: Caller must ensure that the name Op is in fact a reference, and not
389 * an actual name declaration (creation of a named object).
391 ******************************************************************************/
394 XfCheckIllegalReference (
395 ACPI_PARSE_OBJECT *Op,
396 ACPI_NAMESPACE_NODE *TargetNode)
398 ACPI_PARSE_OBJECT *MethodOp1;
399 ACPI_PARSE_OBJECT *MethodOp2;
400 ACPI_PARSE_OBJECT *TargetOp;
404 * Check for an illegal reference to a named object:
406 * 1) References from one control method to another, non-parent
407 * method are not allowed, they will fail at runtime.
409 * 2) Forward references within a control method are not allowed.
410 * AML interpreters use a one-pass parse of control methods
411 * so these forward references will fail at runtime.
413 TargetOp = TargetNode->Op;
415 MethodOp1 = XfGetParentMethod (Op);
416 MethodOp2 = XfGetParentMethod (TargetOp);
418 /* Are both objects within control method(s)? */
420 if (!MethodOp1 || !MethodOp2)
425 /* Objects not in the same method? */
427 if (MethodOp1 != MethodOp2)
430 * 1) Cross-method named reference
432 * This is OK if and only if the target reference is within in a
433 * method that is a parent of current method
435 if (!XfIsObjectParental (MethodOp1, MethodOp2))
437 AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op,
438 Op->Asl.ExternalName);
443 * 2) Both reference and target are in the same method. Check if this is
444 * an (illegal) forward reference by examining the exact source code
445 * location of each (the referenced object and the object declaration).
446 * This is a bit nasty, yet effective.
448 else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset)
450 AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
451 Op->Asl.ExternalName);
458 /*******************************************************************************
460 * FUNCTION: XfNamespaceLocateBegin
462 * PARAMETERS: ASL_WALK_CALLBACK
466 * DESCRIPTION: Descending callback used during cross-reference. For named
467 * object references, attempt to locate the name in the
470 * NOTE: ASL references to named fields within resource descriptors are
471 * resolved to integer values here. Therefore, this step is an
472 * important part of the code generation. We don't know that the
473 * name refers to a resource descriptor until now.
475 ******************************************************************************/
478 XfNamespaceLocateBegin (
479 ACPI_PARSE_OBJECT *Op,
483 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
484 ACPI_NAMESPACE_NODE *Node;
486 ACPI_OBJECT_TYPE ObjectType;
489 ACPI_PARSE_OBJECT *NextOp;
490 ACPI_PARSE_OBJECT *OwningOp;
491 ACPI_PARSE_OBJECT *SpaceIdOp;
492 UINT32 MinimumLength;
494 UINT32 FieldBitLength;
497 const ACPI_OPCODE_INFO *OpInfo;
501 ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op);
504 * If this node is the actual declaration of a name
505 * [such as the XXXX name in "Method (XXXX)"],
506 * we are not interested in it here. We only care about names that are
507 * references to other objects within the namespace and the parent objects
508 * of name declarations
510 if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
512 return_ACPI_STATUS (AE_OK);
515 /* We are only interested in opcodes that have an associated name */
517 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
519 if ((!(OpInfo->Flags & AML_NAMED)) &&
520 (!(OpInfo->Flags & AML_CREATE)) &&
521 (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
522 (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
523 (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
525 return_ACPI_STATUS (AE_OK);
529 * One special case: CondRefOf operator - we don't care if the name exists
530 * or not at this point, just ignore it, the point of the operator is to
531 * determine if the name exists at runtime.
533 if ((Op->Asl.Parent) &&
534 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
536 return_ACPI_STATUS (AE_OK);
540 * We must enable the "search-to-root" for single NameSegs, but
541 * we have to be very careful about opening up scopes
543 Flags = ACPI_NS_SEARCH_PARENT;
544 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
545 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
546 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
549 * These are name references, do not push the scope stack
552 Flags |= ACPI_NS_DONT_OPEN_SCOPE;
555 /* Get the NamePath from the appropriate place */
557 if (OpInfo->Flags & AML_NAMED)
559 /* For nearly all NAMED operators, the name reference is the first child */
561 Path = Op->Asl.Child->Asl.Value.String;
562 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
565 * ALIAS is the only oddball opcode, the name declaration
566 * (alias name) is the second operand
568 Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
571 else if (OpInfo->Flags & AML_CREATE)
573 /* Name must appear as the last parameter */
575 NextOp = Op->Asl.Child;
576 while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
578 NextOp = NextOp->Asl.Next;
580 Path = NextOp->Asl.Value.String;
584 Path = Op->Asl.Value.String;
587 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
588 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
589 "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
592 * Lookup the name in the namespace. Name must exist at this point, or it
593 * is an invalid reference.
595 * The namespace is also used as a lookup table for references to resource
596 * descriptors and the fields within them.
600 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
601 ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
602 if (ACPI_FAILURE (Status))
604 if (Status == AE_NOT_FOUND)
607 * We didn't find the name reference by path -- we can qualify this
608 * a little better before we print an error message
610 if (strlen (Path) == ACPI_NAME_SIZE)
612 /* A simple, one-segment ACPI name */
614 if (XfObjectExists (Path))
617 * There exists such a name, but we couldn't get to it
620 AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op,
621 Op->Asl.ExternalName);
625 /* The name doesn't exist, period */
627 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST,
628 Op, Op->Asl.ExternalName);
633 /* Check for a fully qualified path */
635 if (Path[0] == AML_ROOT_PREFIX)
637 /* Gave full path, the object does not exist */
639 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op,
640 Op->Asl.ExternalName);
645 * We can't tell whether it doesn't exist or just
648 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
649 Op->Asl.ExternalName);
656 return_ACPI_STATUS (Status);
659 /* Check for a reference vs. name declaration */
661 if (!(OpInfo->Flags & AML_NAMED) &&
662 !(OpInfo->Flags & AML_CREATE))
664 /* This node has been referenced, mark it for reference check */
666 Node->Flags |= ANOBJ_IS_REFERENCED;
668 #ifdef __UNDER_DEVELOPMENT
670 /* Check for an illegal reference */
672 XfCheckIllegalReference (Op, Node);
676 /* Attempt to optimize the NamePath */
678 OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
681 * 1) Dereference an alias (A name reference that is an alias)
682 * Aliases are not nested, the alias always points to the final object
684 if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) &&
685 (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
687 /* This node points back to the original PARSEOP_ALIAS */
691 /* The first child is the alias target op */
693 NextOp = NextOp->Asl.Child;
695 /* That in turn points back to original target alias node */
697 if (NextOp->Asl.Node)
699 Node = NextOp->Asl.Node;
702 /* Else - forward reference to alias, will be resolved later */
705 /* 2) Check for a reference to a resource descriptor */
707 if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
708 (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
711 * This was a reference to a field within a resource descriptor.
712 * Extract the associated field offset (either a bit or byte
713 * offset depending on the field type) and change the named
714 * reference into an integer for AML code generation
716 Offset = Node->Value;
717 TagBitLength = Node->Length;
720 * If a field is being created, generate the length (in bits) of
721 * the field. Note: Opcodes other than CreateXxxField and Index
722 * can come through here. For other opcodes, we just need to
723 * convert the resource tag reference to an integer offset.
725 switch (Op->Asl.Parent->Asl.AmlOpcode)
727 case AML_CREATE_FIELD_OP: /* Variable "Length" field, in bits */
729 * We know the length operand is an integer constant because
730 * we know that it contains a reference to a resource
733 FieldBitLength = (UINT32) Op->Asl.Next->Asl.Value.Integer;
736 case AML_CREATE_BIT_FIELD_OP:
741 case AML_CREATE_BYTE_FIELD_OP:
747 case AML_CREATE_WORD_FIELD_OP:
752 case AML_CREATE_DWORD_FIELD_OP:
757 case AML_CREATE_QWORD_FIELD_OP:
768 /* Check the field length against the length of the resource tag */
772 if (TagBitLength < FieldBitLength)
774 Message = ASL_MSG_TAG_SMALLER;
776 else if (TagBitLength > FieldBitLength)
778 Message = ASL_MSG_TAG_LARGER;
783 sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s",
784 TagBitLength, (TagBitLength > 1) ? "s" : "",
785 FieldBitLength, (FieldBitLength > 1) ? "s" : "");
787 AslError (ASL_WARNING, Message, Op, MsgBuffer);
791 /* Convert the BitOffset to a ByteOffset for certain opcodes */
793 switch (Op->Asl.Parent->Asl.AmlOpcode)
795 case AML_CREATE_BYTE_FIELD_OP:
796 case AML_CREATE_WORD_FIELD_OP:
797 case AML_CREATE_DWORD_FIELD_OP:
798 case AML_CREATE_QWORD_FIELD_OP:
801 Offset = ACPI_DIV_8 (Offset);
809 /* Now convert this node to an integer whose value is the field offset */
811 Op->Asl.AmlLength = 0;
812 Op->Asl.ParseOpcode = PARSEOP_INTEGER;
813 Op->Asl.Value.Integer = (UINT64) Offset;
814 Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
816 OpcGenerateAmlOpcode (Op);
819 /* 3) Check for a method invocation */
821 else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
822 (Node->Type == ACPI_TYPE_METHOD) &&
824 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
826 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
829 * A reference to a method within one of these opcodes is not an
830 * invocation of the method, it is simply a reference to the method.
832 if ((Op->Asl.Parent) &&
833 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
834 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) ||
835 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
836 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)||
837 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
839 return_ACPI_STATUS (AE_OK);
842 * There are two types of method invocation:
843 * 1) Invocation with arguments -- the parser recognizes this
845 * 2) Invocation with no arguments --the parser cannot determine that
846 * this is a method invocation, therefore we have to figure it out
849 if (Node->Type != ACPI_TYPE_METHOD)
851 sprintf (MsgBuffer, "%s is a %s",
852 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
854 AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
855 return_ACPI_STATUS (AE_OK);
858 /* Save the method node in the caller's op */
861 if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
863 return_ACPI_STATUS (AE_OK);
867 * This is a method invocation, with or without arguments.
868 * Count the number of arguments, each appears as a child
869 * under the parent node
871 Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
872 UtSetParseOpName (Op);
875 NextOp = Op->Asl.Child;
880 NextOp = NextOp->Asl.Next;
883 if (Node->Value != ASL_EXTERNAL_METHOD)
886 * Check the parsed arguments with the number expected by the
887 * method declaration itself
889 if (PassedArgs != Node->Value)
891 sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName,
894 if (PassedArgs < Node->Value)
896 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
900 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
906 /* 4) Check for an ASL Field definition */
908 else if ((Op->Asl.Parent) &&
909 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
910 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
913 * Offset checking for fields. If the parent operation region has a
914 * constant length (known at compile time), we can check fields
915 * defined in that region against the region length. This will catch
916 * fields and field units that cannot possibly fit within the region.
918 * Note: Index fields do not directly reference an operation region,
919 * thus they are not included in this check.
921 if (Op == Op->Asl.Parent->Asl.Child)
924 * This is the first child of the field node, which is
925 * the name of the region. Get the parse node for the
926 * region -- which contains the length of the region.
929 Op->Asl.Parent->Asl.ExtraValue =
930 ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
932 /* Examine the field access width */
934 switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
936 case AML_FIELD_ACCESS_ANY:
937 case AML_FIELD_ACCESS_BYTE:
938 case AML_FIELD_ACCESS_BUFFER:
944 case AML_FIELD_ACCESS_WORD:
949 case AML_FIELD_ACCESS_DWORD:
954 case AML_FIELD_ACCESS_QWORD:
961 * Is the region at least as big as the access width?
962 * Note: DataTableRegions have 0 length
964 if (((UINT32) OwningOp->Asl.Value.Integer) &&
965 ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
967 AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
971 * Check EC/CMOS/SMBUS fields to make sure that the correct
972 * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
974 SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
975 switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
977 case ACPI_ADR_SPACE_EC:
978 case ACPI_ADR_SPACE_CMOS:
979 case ACPI_ADR_SPACE_GPIO:
981 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
983 AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
987 case ACPI_ADR_SPACE_SMBUS:
988 case ACPI_ADR_SPACE_IPMI:
989 case ACPI_ADR_SPACE_GSBUS:
991 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
993 AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
999 /* Nothing to do for other address spaces */
1007 * This is one element of the field list. Check to make sure
1008 * that it does not go beyond the end of the parent operation region.
1010 * In the code below:
1011 * Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
1012 * Op->Asl.ExtraValue - Field start offset (bits)
1013 * Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
1014 * Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
1016 if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
1018 XfCheckFieldRange (Op,
1019 Op->Asl.Parent->Asl.ExtraValue,
1021 (UINT32) Op->Asl.Child->Asl.Value.Integer,
1022 Op->Asl.Child->Asl.ExtraValue);
1027 /* 5) Check for a connection object */
1029 else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION)
1031 return_ACPI_STATUS (Status);
1035 Op->Asl.Node = Node;
1036 return_ACPI_STATUS (Status);
1040 /*******************************************************************************
1042 * FUNCTION: XfNamespaceLocateEnd
1044 * PARAMETERS: ASL_WALK_CALLBACK
1048 * DESCRIPTION: Ascending callback used during cross reference. We only
1049 * need to worry about scope management here.
1051 ******************************************************************************/
1054 XfNamespaceLocateEnd (
1055 ACPI_PARSE_OBJECT *Op,
1059 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
1060 const ACPI_OPCODE_INFO *OpInfo;
1063 ACPI_FUNCTION_TRACE (XfNamespaceLocateEnd);
1066 /* We are only interested in opcodes that have an associated name */
1068 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1069 if (!(OpInfo->Flags & AML_NAMED))
1071 return_ACPI_STATUS (AE_OK);
1074 /* Not interested in name references, we did not open a scope for them */
1076 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
1077 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
1078 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
1080 return_ACPI_STATUS (AE_OK);
1083 /* Pop the scope stack if necessary */
1085 if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
1088 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1089 "%s: Popping scope for Op %p\n",
1090 AcpiUtGetTypeName (OpInfo->ObjectType), Op));
1092 (void) AcpiDsScopeStackPop (WalkState);
1095 return_ACPI_STATUS (AE_OK);