Debian Codegraph @

source/compiler/aslxref.c

raw symbols SCIP
1 /******************************************************************************
2 *
3 * Module Name: aslxref - Namespace cross-reference
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2026, Intel Corp.
9 * All rights reserved.
10 *
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.
25 *
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.
29 *
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 MERCHANTABILITY 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.
42 */
43
44 #include "aslcompiler.h"
45 #include "aslcompiler.y.h"
46 #include "acparser.h"
47 #include "amlcode.h"
48 #include "acnamesp.h"
49 #include "acdispat.h"
50
51
52 #define _COMPONENT ACPI_COMPILER
53 ACPI_MODULE_NAME ("aslxref")
54
55 /* Local prototypes */
56
57 static ACPI_STATUS
58 XfNamespaceLocateBegin (
59 ACPI_PARSE_OBJECT *Op,
60 UINT32 Level,
61 void *Context);
62
63 static ACPI_STATUS
64 XfNamespaceLocateEnd (
65 ACPI_PARSE_OBJECT *Op,
66 UINT32 Level,
67 void *Context);
68
69 static BOOLEAN
70 XfValidateCrossReference (
71 ACPI_PARSE_OBJECT *Op,
72 const ACPI_OPCODE_INFO *OpInfo,
73 ACPI_NAMESPACE_NODE *Node);
74
75 static BOOLEAN
76 XfObjectExists (
77 char *Name);
78
79 static ACPI_STATUS
80 XfCompareOneNamespaceObject (
81 ACPI_HANDLE ObjHandle,
82 UINT32 Level,
83 void *Context,
84 void **ReturnValue);
85
86 static void
87 XfCheckFieldRange (
88 ACPI_PARSE_OBJECT *Op,
89 UINT32 RegionBitLength,
90 UINT32 FieldBitOffset,
91 UINT32 FieldBitLength,
92 UINT32 AccessBitWidth);
93
94 static BOOLEAN
95 XfFindCondRefOfName (
96 ACPI_NAMESPACE_NODE *Node,
97 ACPI_PARSE_OBJECT *Op);
98
99 static BOOLEAN
100 XfRefIsGuardedByIfCondRefOf (
101 ACPI_NAMESPACE_NODE *Node,
102 ACPI_PARSE_OBJECT *Op);
103
104
105 /*******************************************************************************
106 *
107 * FUNCTION: XfCrossReferenceNamespace
108 *
109 * PARAMETERS: None
110 *
111 * RETURN: Status
112 *
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.
118 *
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
121 * correctly here.
122 *
123 ******************************************************************************/
124
125 ACPI_STATUS
126 XfCrossReferenceNamespace (
127 void)
128 {
129 ACPI_WALK_STATE *WalkState;
130
131
132 /*
133 * Create a new walk state for use when looking up names
134 * within the namespace (Passed as context to the callbacks)
135 */
136 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
137 if (!WalkState)
138 {
139 return (AE_NO_MEMORY);
140 }
141
142 /* Walk the entire parse tree */
143
144 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
145 XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState);
146
147 ACPI_FREE (WalkState);
148 return (AE_OK);
149 }
150
151
152 /*******************************************************************************
153 *
154 * FUNCTION: XfObjectExists
155 *
156 * PARAMETERS: Name - 4 char ACPI name
157 *
158 * RETURN: TRUE if name exists in namespace
159 *
160 * DESCRIPTION: Walk the namespace to find an object
161 *
162 ******************************************************************************/
163
164 static BOOLEAN
165 XfObjectExists (
166 char *Name)
167 {
168 ACPI_STATUS Status;
169
170
171 /* Walk entire namespace from the supplied root */
172
173 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
174 ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL,
175 Name, NULL);
176 if (Status == AE_CTRL_TRUE)
177 {
178 /* At least one instance of the name was found */
179
180 return (TRUE);
181 }
182
183 return (FALSE);
184 }
185
186
187 /*******************************************************************************
188 *
189 * FUNCTION: XfCompareOneNamespaceObject
190 *
191 * PARAMETERS: ACPI_WALK_CALLBACK
192 *
193 * RETURN: Status
194 *
195 * DESCRIPTION: Compare name of one object.
196 *
197 ******************************************************************************/
198
199 static ACPI_STATUS
200 XfCompareOneNamespaceObject (
201 ACPI_HANDLE ObjHandle,
202 UINT32 Level,
203 void *Context,
204 void **ReturnValue)
205 {
206 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
207
208
209 /* Simply check the name */
210
211 if (*((UINT32 *) (Context)) == Node->Name.Integer)
212 {
213 /* Abort walk if we found one instance */
214
215 return (AE_CTRL_TRUE);
216 }
217
218 return (AE_OK);
219 }
220
221
222 /*******************************************************************************
223 *
224 * FUNCTION: XfCheckFieldRange
225 *
226 * PARAMETERS: RegionBitLength - Length of entire parent region
227 * FieldBitOffset - Start of the field unit (within region)
228 * FieldBitLength - Entire length of field unit
229 * AccessBitWidth - Access width of the field unit
230 *
231 * RETURN: None
232 *
233 * DESCRIPTION: Check one field unit to make sure it fits in the parent
234 * op region.
235 *
236 * Note: AccessBitWidth must be either 8,16,32, or 64
237 *
238 ******************************************************************************/
239
240 static void
241 XfCheckFieldRange (
242 ACPI_PARSE_OBJECT *Op,
243 UINT32 RegionBitLength,
244 UINT32 FieldBitOffset,
245 UINT32 FieldBitLength,
246 UINT32 AccessBitWidth)
247 {
248 UINT32 FieldEndBitOffset;
249
250
251 /*
252 * Check each field unit against the region size. The entire
253 * field unit (start offset plus length) must fit within the
254 * region.
255 */
256 FieldEndBitOffset = FieldBitOffset + FieldBitLength;
257
258 if (FieldEndBitOffset > RegionBitLength)
259 {
260 /* Field definition itself is beyond the end-of-region */
261
262 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
263 return;
264 }
265
266 /*
267 * Now check that the field plus AccessWidth doesn't go beyond
268 * the end-of-region. Assumes AccessBitWidth is a power of 2
269 */
270 FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
271
272 if (FieldEndBitOffset > RegionBitLength)
273 {
274 /* Field definition combined with the access is beyond EOR */
275
276 AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
277 }
278 }
279
280
281 /*******************************************************************************
282 *
283 * FUNCTION: XfNamespaceLocateBegin
284 *
285 * PARAMETERS: ASL_WALK_CALLBACK
286 *
287 * RETURN: Status
288 *
289 * DESCRIPTION: Descending callback used during cross-reference. For named
290 * object references, attempt to locate the name in the
291 * namespace.
292 *
293 * NOTE: ASL references to named fields within resource descriptors are
294 * resolved to integer values here. Therefore, this step is an
295 * important part of the code generation. We don't know that the
296 * name refers to a resource descriptor until now.
297 *
298 ******************************************************************************/
299
300 static ACPI_STATUS
301 XfNamespaceLocateBegin (
302 ACPI_PARSE_OBJECT *Op,
303 UINT32 Level,
304 void *Context)
305 {
306 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
307 ACPI_NAMESPACE_NODE *Node;
308 ACPI_STATUS Status;
309 ACPI_OBJECT_TYPE ObjectType;
310 char *Path;
311 UINT8 PassedArgs;
312 ACPI_PARSE_OBJECT *NextOp;
313 ACPI_PARSE_OBJECT *OwningOp;
314 ACPI_PARSE_OBJECT *SpaceIdOp;
315 UINT32 MinimumLength;
316 UINT32 Offset;
317 UINT32 FieldBitLength;
318 UINT32 TagBitLength;
319 UINT8 Message = 0;
320 const ACPI_OPCODE_INFO *OpInfo;
321 UINT32 Flags;
322 ASL_METHOD_LOCAL *MethodLocals = NULL;
323 ASL_METHOD_LOCAL *MethodArgs = NULL;
324 int RegisterNumber;
325 UINT32 i;
326 ACPI_NAMESPACE_NODE *DeclarationParentMethod;
327 ACPI_PARSE_OBJECT *ReferenceParentMethod;
328 char *ExternalPath;
329
330
331 ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op);
332
333
334 if ((Op->Asl.AmlOpcode == AML_METHOD_OP) && Op->Asl.Node)
335 {
336 Node = Op->Asl.Node;
337
338 /* Support for method LocalX/ArgX analysis */
339
340 if (!Node->MethodLocals)
341 {
342 /* Create local/arg info blocks */
343
344 MethodLocals = UtLocalCalloc (
345 sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_LOCALS);
346 Node->MethodLocals = MethodLocals;
347
348 MethodArgs = UtLocalCalloc (
349 sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_ARGS);
350 Node->MethodArgs = MethodArgs;
351
352 /*
353 * Get the method argument count
354 * First, get the name node
355 */
356 NextOp = Op->Asl.Child;
357
358 /* Get the NumArguments node */
359
360 NextOp = NextOp->Asl.Next;
361 Node->ArgCount = (UINT8)
362 (((UINT8) NextOp->Asl.Value.Integer) & 0x07);
363
364 /* We will track all possible ArgXs */
365
366 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
367 {
368 if (i < Node->ArgCount)
369 {
370 /* Real Args are always "initialized" */
371
372 MethodArgs[i].Flags = ASL_ARG_INITIALIZED;
373 }
374 else
375 {
376 /* Other ArgXs can be used as locals */
377
378 MethodArgs[i].Flags = ASL_ARG_IS_LOCAL;
379 }
380
381 MethodArgs[i].Op = Op;
382 }
383 }
384 }
385
386 /*
387 * If this node is the actual declaration of a name
388 * [such as the XXXX name in "Method (XXXX)"],
389 * we are not interested in it here. We only care about names that are
390 * references to other objects within the namespace and the parent objects
391 * of name declarations
392 */
393 if (Op->Asl.CompileFlags & OP_IS_NAME_DECLARATION)
394 {
395 return_ACPI_STATUS (AE_OK);
396 }
397
398 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
399
400 /* Check method LocalX variables */
401
402 if (OpInfo->Type == AML_TYPE_LOCAL_VARIABLE)
403 {
404 /* Find parent method Op */
405
406 NextOp = UtGetParentMethodOp (Op);
407 if (!NextOp)
408 {
409 return_ACPI_STATUS (AE_OK);
410 }
411
412 /* Get method node */
413
414 Node = NextOp->Asl.Node;
415
416 RegisterNumber = Op->Asl.AmlOpcode & 0x0007; /* 0x60 through 0x67 */
417 MethodLocals = Node->MethodLocals;
418
419 if (Op->Asl.CompileFlags & OP_IS_TARGET)
420 {
421 /* Local is being initialized */
422
423 MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_INITIALIZED;
424 MethodLocals[RegisterNumber].Op = Op;
425
426 return_ACPI_STATUS (AE_OK);
427 }
428
429 /* Mark this Local as referenced */
430
431 MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_REFERENCED;
432 MethodLocals[RegisterNumber].Op = Op;
433
434 return_ACPI_STATUS (AE_OK);
435 }
436
437 /* Check method ArgX variables */
438
439 if (OpInfo->Type == AML_TYPE_METHOD_ARGUMENT)
440 {
441 /* Find parent method Op */
442
443 NextOp = UtGetParentMethodOp (Op);
444 if (!NextOp)
445 {
446 return_ACPI_STATUS (AE_OK);
447 }
448
449 /* Get method node */
450
451 Node = NextOp->Asl.Node;
452
453 /* Malformed tree: parent method has no namespace node */
454 if (!Node)
455 {
456 return_ACPI_STATUS (AE_OK);
457 }
458
459 /* Get Arg # */
460
461 RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */
462 MethodArgs = Node->MethodArgs;
463
464 /* Gracefully handle malformed trees where method args were not set up */
465 if (!MethodArgs)
466 {
467 return_ACPI_STATUS (AE_OK);
468 }
469
470 /* Mark this Arg as referenced */
471
472 MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED;
473 MethodArgs[RegisterNumber].Op = Op;
474
475 if (Op->Asl.CompileFlags & OP_IS_TARGET)
476 {
477 /* Arg is being initialized */
478
479 MethodArgs[RegisterNumber].Flags |= ASL_ARG_INITIALIZED;
480 }
481
482 return_ACPI_STATUS (AE_OK);
483 }
484
485 /*
486 * After method ArgX and LocalX, we are only interested in opcodes
487 * that have an associated name
488 */
489 if ((!(OpInfo->Flags & AML_NAMED)) &&
490 (!(OpInfo->Flags & AML_CREATE)) &&
491 (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
492 (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
493 (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) &&
494 (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
495 {
496 return_ACPI_STATUS (AE_OK);
497 }
498
499 /*
500 * We must enable the "search-to-root" for single NameSegs, but
501 * we have to be very careful about opening up scopes
502 */
503 Flags = ACPI_NS_SEARCH_PARENT;
504 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
505 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
506 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
507 (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) ||
508 (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF))
509 {
510 /*
511 * These are name references, do not push the scope stack
512 * for them.
513 */
514 Flags |= ACPI_NS_DONT_OPEN_SCOPE;
515 }
516
517 /* Get the NamePath from the appropriate place */
518
519 if (OpInfo->Flags & AML_NAMED)
520 {
521 /* For nearly all NAMED operators, the name reference is the first child */
522
523 Path = Op->Asl.Child->Asl.Value.String;
524 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
525 {
526 /*
527 * ALIAS is the only oddball opcode, the name declaration
528 * (alias name) is the second operand
529 */
530 Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
531 }
532 }
533 else if (OpInfo->Flags & AML_CREATE)
534 {
535 /* Name must appear as the last parameter */
536
537 NextOp = Op->Asl.Child;
538 while (!(NextOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
539 {
540 NextOp = NextOp->Asl.Next;
541 }
542
543 Path = NextOp->Asl.Value.String;
544 }
545 else
546 {
547 Path = Op->Asl.Value.String;
548 }
549
550 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
551 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
552 "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
553
554 /*
555 * Lookup the name in the namespace. Name must exist at this point, or it
556 * is an invalid reference.
557 *
558 * The namespace is also used as a lookup table for references to resource
559 * descriptors and the fields within them.
560 */
561 AslGbl_NsLookupCount++;
562
563 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
564 ACPI_IMODE_EXECUTE, Flags, WalkState, &Node);
565 if (ACPI_FAILURE (Status))
566 {
567 if (Status == AE_NOT_FOUND)
568 {
569 /*
570 * We didn't find the name reference by path -- we can qualify this
571 * a little better before we print an error message
572 */
573
574 if ((Op->Asl.Parent) &&
575 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
576 {
577 /*
578 * One special case: CondRefOf operator - if the name doesn't
579 * exist at this point, it means that there's no actual or
580 * external declaration. If the name is not found, just ignore
581 * it, the point of the operator is to determine if the name
582 * exists at runtime. We wanted to see if this named object
583 * exists to facilitate analysis to allow protected usage of
584 * undeclared externals.
585 */
586 return_ACPI_STATUS (AE_OK);
587 }
588 else if (strlen (Path) == ACPI_NAMESEG_SIZE)
589 {
590 /* A simple, one-segment ACPI name */
591
592 if (XfObjectExists (Path))
593 {
594 /*
595 * There exists such a name, but we couldn't get to it
596 * from this scope
597 */
598 AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op,
599 Op->Asl.ExternalName);
600 }
601 else
602 {
603 /* The name doesn't exist, period */
604
605 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST,
606 Op, Op->Asl.ExternalName);
607 }
608 }
609 else
610 {
611 /* The NamePath contains multiple NameSegs */
612
613 if ((OpInfo->Flags & AML_CREATE) ||
614 (OpInfo->ObjectType == ACPI_TYPE_LOCAL_ALIAS))
615 {
616 /*
617 * The new name is the last parameter. For the
618 * CreateXXXXField and Alias operators
619 */
620 NextOp = Op->Asl.Child;
621 while (!(NextOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
622 {
623 NextOp = NextOp->Asl.Next;
624 }
625
626 AslError (ASL_ERROR, ASL_MSG_PREFIX_NOT_EXIST, NextOp,
627 NextOp->Asl.ExternalName);
628 }
629 else if (OpInfo->Flags & AML_NAMED)
630 {
631 /* The new name is the first parameter */
632
633 AslError (ASL_ERROR, ASL_MSG_PREFIX_NOT_EXIST, Op,
634 Op->Asl.ExternalName);
635 }
636 else if (Path[0] == AML_ROOT_PREFIX)
637 {
638 /* Full namepath from root, the object does not exist */
639
640 AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op,
641 Op->Asl.ExternalName);
642 }
643 else
644 {
645 /*
646 * Generic "not found" error. Cannot determine whether it
647 * doesn't exist or just can't be reached. However, we
648 * can differentiate between a NameSeg vs. NamePath.
649 */
650 if (strlen (Op->Asl.ExternalName) == ACPI_NAMESEG_SIZE)
651 {
652 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
653 Op->Asl.ExternalName);
654 }
655 else
656 {
657 AslError (ASL_ERROR, ASL_MSG_NAMEPATH_NOT_EXIST, Op,
658 Op->Asl.ExternalName);
659 }
660 }
661 }
662
663 Status = AE_OK;
664 }
665
666 return_ACPI_STATUS (Status);
667 }
668
669 /* Check for an attempt to access an object in another method */
670
671 if (!XfValidateCrossReference (Op, OpInfo, Node))
672 {
673 AslError (ASL_ERROR, ASL_MSG_TEMPORARY_OBJECT, Op,
674 Op->Asl.ExternalName);
675 return_ACPI_STATUS (Status);
676 }
677
678 /* Object was found above, check for an illegal forward reference */
679
680 if (Op->Asl.CompileFlags & OP_NOT_FOUND_DURING_LOAD)
681 {
682 /*
683 * During the load phase, this Op was flagged as a possible
684 * illegal forward reference. In other words, Op is a name path or
685 * name segment that refers to a named object declared after the
686 * reference. In this scinario, Node refers to the actual declaration
687 * and Op is a parse node that references the named object.
688 *
689 * Note:
690 *
691 * Object references inside of control methods are allowed to
692 * refer to objects declared outside of control methods.
693 *
694 * If the declaration and reference are both contained inside of the
695 * same method or outside of any method, this is a forward reference
696 * and should be reported as a compiler error.
697 */
698 DeclarationParentMethod = UtGetParentMethodNode (Node);
699 ReferenceParentMethod = UtGetParentMethodOp (Op);
700
701 /* case 1: declaration and reference are both outside of method */
702
703 if (!ReferenceParentMethod && !DeclarationParentMethod)
704 {
705 AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
706 Op->Asl.ExternalName);
707 }
708
709 /* case 2: declaration and reference are both inside of the same method */
710
711 else if (ReferenceParentMethod && DeclarationParentMethod &&
712 ReferenceParentMethod == DeclarationParentMethod->Op)
713 {
714 AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
715 Op->Asl.ExternalName);
716 }
717 }
718
719 /* Check for a reference vs. name declaration */
720
721 if (!(OpInfo->Flags & AML_NAMED) &&
722 !(OpInfo->Flags & AML_CREATE))
723 {
724 /* This node has been referenced, mark it for reference check */
725
726 Node->Flags |= ANOBJ_IS_REFERENCED;
727 }
728
729 /*
730 * Attempt to optimize the NamePath
731 *
732 * One special case: CondRefOf operator - not all AML interpreter
733 * implementations expect optimized namepaths as a parameter to this
734 * operator. They require relative name paths with prefix operators or
735 * namepaths starting with the root scope.
736 *
737 * Other AML interpreter implementations do not perform the namespace
738 * search that starts at the current scope and recursively searching the
739 * parent scope until the root scope. The lack of search is only known to
740 * occur for the namestring parameter for the CondRefOf operator.
741 */
742 if ((Op->Asl.Parent) &&
743 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF))
744 {
745 OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
746 }
747
748 /*
749 * 1) Dereference an alias (A name reference that is an alias)
750 * Aliases are not nested, the alias always points to the final object
751 */
752 if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) &&
753 (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
754 {
755 /* This node points back to the original PARSEOP_ALIAS */
756
757 NextOp = Node->Op;
758
759 /* The first child is the alias target op */
760
761 NextOp = NextOp->Asl.Child;
762
763 /* That in turn points back to original target alias node */
764
765 if (NextOp->Asl.Node)
766 {
767 Node = NextOp->Asl.Node;
768 }
769
770 /* Else - forward reference to alias, will be resolved later */
771 }
772
773 /* 2) Check for a reference to a resource descriptor */
774
775 if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
776 (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
777 {
778 /*
779 * This was a reference to a field within a resource descriptor.
780 * Extract the associated field offset (either a bit or byte
781 * offset depending on the field type) and change the named
782 * reference into an integer for AML code generation
783 */
784 Offset = Node->Value;
785 TagBitLength = Node->Length;
786
787 /*
788 * If a field is being created, generate the length (in bits) of
789 * the field. Note: Opcodes other than CreateXxxField and Index
790 * can come through here. For other opcodes, we just need to
791 * convert the resource tag reference to an integer offset.
792 */
793 switch (Op->Asl.Parent->Asl.AmlOpcode)
794 {
795 case AML_CREATE_FIELD_OP: /* Variable "Length" field, in bits */
796 /*
797 * We know the length operand is an integer constant because
798 * we know that it contains a reference to a resource
799 * descriptor tag.
800 */
801 FieldBitLength = (UINT32) Op->Asl.Next->Asl.Value.Integer;
802 break;
803
804 case AML_CREATE_BIT_FIELD_OP:
805
806 FieldBitLength = 1;
807 break;
808
809 case AML_CREATE_BYTE_FIELD_OP:
810 case AML_INDEX_OP:
811
812 FieldBitLength = 8;
813 break;
814
815 case AML_CREATE_WORD_FIELD_OP:
816
817 FieldBitLength = 16;
818 break;
819
820 case AML_CREATE_DWORD_FIELD_OP:
821
822 FieldBitLength = 32;
823 break;
824
825 case AML_CREATE_QWORD_FIELD_OP:
826
827 FieldBitLength = 64;
828 break;
829
830 default:
831
832 FieldBitLength = 0;
833 break;
834 }
835
836 /* Check the field length against the length of the resource tag */
837
838 if (FieldBitLength)
839 {
840 if (TagBitLength < FieldBitLength)
841 {
842 Message = ASL_MSG_TAG_SMALLER;
843 }
844 else if (TagBitLength > FieldBitLength)
845 {
846 Message = ASL_MSG_TAG_LARGER;
847 }
848
849 if (Message)
850 {
851 sprintf (AslGbl_MsgBuffer,
852 "Size mismatch, Tag: %u bit%s, Field: %u bit%s",
853 TagBitLength, (TagBitLength > 1) ? "s" : "",
854 FieldBitLength, (FieldBitLength > 1) ? "s" : "");
855
856 AslError (ASL_WARNING, Message, Op, AslGbl_MsgBuffer);
857 }
858 }
859
860 /* Convert the BitOffset to a ByteOffset for certain opcodes */
861
862 switch (Op->Asl.Parent->Asl.AmlOpcode)
863 {
864 case AML_CREATE_BYTE_FIELD_OP:
865 case AML_CREATE_WORD_FIELD_OP:
866 case AML_CREATE_DWORD_FIELD_OP:
867 case AML_CREATE_QWORD_FIELD_OP:
868 case AML_INDEX_OP:
869
870 Offset = ACPI_DIV_8 (Offset);
871 break;
872
873 default:
874
875 break;
876 }
877
878 /* Now convert this node to an integer whose value is the field offset */
879
880 Op->Asl.AmlLength = 0;
881 Op->Asl.ParseOpcode = PARSEOP_INTEGER;
882 Op->Asl.Value.Integer = (UINT64) Offset;
883 Op->Asl.CompileFlags |= OP_IS_RESOURCE_FIELD;
884
885 OpcGenerateAmlOpcode (Op);
886 }
887
888 /* 3) Check for a method invocation */
889
890 else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
891 (Node->Type == ACPI_TYPE_METHOD) &&
892 (Op->Asl.Parent) &&
893 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
894
895 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
896 {
897 /*
898 * A reference to a method within one of these opcodes is not an
899 * invocation of the method, it is simply a reference to the method.
900 *
901 * September 2016: Removed DeRefOf from this list
902 * July 2020: Added Alias to this list
903 */
904 if ((Op->Asl.Parent) &&
905 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
906 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
907 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)||
908 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE) ||
909 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_ALIAS)))
910 {
911 return_ACPI_STATUS (AE_OK);
912 }
913
914 /*
915 * There are two types of method invocation:
916 * 1) Invocation with arguments -- the parser recognizes this
917 * as a METHODCALL.
918 * 2) Invocation with no arguments --the parser cannot determine that
919 * this is a method invocation, therefore we have to figure it out
920 * here.
921 */
922 if (Node->Type != ACPI_TYPE_METHOD)
923 {
924 sprintf (AslGbl_MsgBuffer, "%s is a %s",
925 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
926
927 AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, AslGbl_MsgBuffer);
928 return_ACPI_STATUS (AE_OK);
929 }
930
931 /* Save the method node in the caller's op */
932
933 Op->Asl.Node = Node;
934 if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
935 {
936 return_ACPI_STATUS (AE_OK);
937 }
938
939 /*
940 * This is a method invocation, with or without arguments.
941 * Count the number of arguments, each appears as a child
942 * under the parent node
943 */
944 Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
945 UtSetParseOpName (Op);
946
947 PassedArgs = 0;
948 NextOp = Op->Asl.Child;
949
950 while (NextOp)
951 {
952 PassedArgs++;
953 NextOp = NextOp->Asl.Next;
954 }
955
956 if (Node->Value != ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS &&
957 Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL)
958 {
959 /*
960 * Check the parsed arguments with the number expected by the
961 * method declaration itself
962 */
963 if (PassedArgs != Node->Value)
964 {
965 if (Node->Flags & ANOBJ_IS_EXTERNAL)
966 {
967 sprintf (AslGbl_MsgBuffer,
968 "according to previous use, %s requires %u",
969 Op->Asl.ExternalName, Node->Value);
970 }
971 else
972 {
973 sprintf (AslGbl_MsgBuffer, "%s requires %u", Op->Asl.ExternalName,
974 Node->Value);
975 }
976
977 if (PassedArgs < Node->Value)
978 {
979 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, AslGbl_MsgBuffer);
980 }
981 else
982 {
983 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, AslGbl_MsgBuffer);
984 }
985 }
986 }
987
988 /*
989 * At this point, a method call to an external method has been
990 * detected. As of 11/19/2019, iASL does not support parameter counts
991 * for methods declared as external. Therefore, save the parameter
992 * count of the first method call and use this count check other
993 * method calls to ensure that the methods are being called with the
994 * same amount of parameters.
995 */
996 else if (Node->Type == ACPI_TYPE_METHOD &&
997 (Node->Flags & ANOBJ_IS_EXTERNAL) &&
998 Node->Value == ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS &&
999 Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL)
1000 {
1001 Node->Value = PassedArgs;
1002 }
1003 }
1004
1005 /* 4) Check for an ASL Field definition */
1006
1007 else if ((Op->Asl.Parent) &&
1008 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
1009 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
1010 {
1011 /*
1012 * Offset checking for fields. If the parent operation region has a
1013 * constant length (known at compile time), we can check fields
1014 * defined in that region against the region length. This will catch
1015 * fields and field units that cannot possibly fit within the region.
1016 *
1017 * Note: Index fields do not directly reference an operation region,
1018 * thus they are not included in this check.
1019 */
1020 if (Op == Op->Asl.Parent->Asl.Child)
1021 {
1022 /*
1023 * This is the first child of the field node, which is
1024 * the name of the region. Get the parse node for the
1025 * region -- which contains the length of the region.
1026 */
1027 OwningOp = Node->Op;
1028 Op->Asl.Parent->Asl.ExtraValue =
1029 ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
1030
1031 /* Examine the field access width */
1032
1033 switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
1034 {
1035 case AML_FIELD_ACCESS_ANY:
1036 case AML_FIELD_ACCESS_BYTE:
1037 case AML_FIELD_ACCESS_BUFFER:
1038 default:
1039
1040 MinimumLength = 1;
1041 break;
1042
1043 case AML_FIELD_ACCESS_WORD:
1044
1045 MinimumLength = 2;
1046 break;
1047
1048 case AML_FIELD_ACCESS_DWORD:
1049
1050 MinimumLength = 4;
1051 break;
1052
1053 case AML_FIELD_ACCESS_QWORD:
1054
1055 MinimumLength = 8;
1056 break;
1057 }
1058
1059 /*
1060 * Is the region at least as big as the access width?
1061 * Note: DataTableRegions have 0 length
1062 */
1063 if (((UINT32) OwningOp->Asl.Value.Integer) &&
1064 ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
1065 {
1066 AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
1067 }
1068
1069 /*
1070 * Check EC/CMOS/SMBUS fields to make sure that the correct
1071 * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
1072 */
1073 SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
1074 switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
1075 {
1076 case ACPI_ADR_SPACE_EC:
1077 case ACPI_ADR_SPACE_CMOS:
1078 case ACPI_ADR_SPACE_GPIO:
1079
1080 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer !=
1081 AML_FIELD_ACCESS_BYTE)
1082 {
1083 AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
1084 }
1085 break;
1086
1087 case ACPI_ADR_SPACE_SMBUS:
1088 case ACPI_ADR_SPACE_IPMI:
1089 case ACPI_ADR_SPACE_GSBUS:
1090
1091 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer !=
1092 AML_FIELD_ACCESS_BUFFER)
1093 {
1094 AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
1095 }
1096 break;
1097
1098 default:
1099
1100 /* Nothing to do for other address spaces */
1101
1102 break;
1103 }
1104 }
1105 else
1106 {
1107 /*
1108 * This is one element of the field list. Check to make sure
1109 * that it does not go beyond the end of the parent operation region.
1110 *
1111 * In the code below:
1112 * Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
1113 * Op->Asl.ExtraValue - Field start offset (bits)
1114 * Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
1115 * Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
1116 */
1117 if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
1118 {
1119 XfCheckFieldRange (Op,
1120 Op->Asl.Parent->Asl.ExtraValue,
1121 Op->Asl.ExtraValue,
1122 (UINT32) Op->Asl.Child->Asl.Value.Integer,
1123 Op->Asl.Child->Asl.ExtraValue);
1124 }
1125 }
1126 }
1127
1128 /*
1129 * 5) Check for external resolution
1130 *
1131 * By this point, everything should be loaded in the namespace. If a
1132 * namespace lookup results in a namespace node that is an external, it
1133 * means that this named object was not defined in the input ASL. This
1134 * causes issues because there are plenty of incidents where developers
1135 * use the external keyword to suppress compiler errors about undefined
1136 * objects. Note: this only applies when compiling multiple definition
1137 * blocks.
1138 *
1139 * Do not check for external resolution in the following cases:
1140 *
1141 * case 1) External (ABCD)
1142 *
1143 * This declares ABCD as an external so there is no requirement for
1144 * ABCD to be loaded in the namespace when analyzing the actual
1145 * External() statement.
1146 *
1147 * case 2) CondRefOf (ABCD)
1148 *
1149 * This operator will query the ACPI namespace on the existence of
1150 * ABCD. If ABCD does not exist, this operator will return a 0
1151 * without incurring AML runtime errors. Therefore, ABCD is allowed
1152 * to not exist when analyzing the CondRefOf operator.
1153 *
1154 * case 3) External (ABCD)
1155 * if (CondRefOf (ABCD))
1156 * {
1157 * Store (0, ABCD)
1158 * }
1159 *
1160 * In this case, ABCD is accessed only if it exists due to the if
1161 * statement so there is no need to flag the ABCD nested in the
1162 * store operator.
1163 */
1164 if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next &&
1165 (Node->Flags & ANOBJ_IS_EXTERNAL) &&
1166 Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL &&
1167 Op->Asl.ParseOpcode != PARSEOP_EXTERNAL &&
1168 Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF &&
1169 !XfRefIsGuardedByIfCondRefOf (Node, Op))
1170 {
1171 ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE);
1172 sprintf (AslGbl_MsgBuffer, "full path of external object: %s",
1173 ExternalPath);
1174 AslDualParseOpError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL,
1175 ASL_MSG_EXTERNAL_FOUND_HERE, Node->Op, AslGbl_MsgBuffer);
1176 if (ExternalPath)
1177 {
1178 ACPI_FREE (ExternalPath);
1179 }
1180 }
1181
1182 /* 5) Check for a connection object */
1183 #if 0
1184 else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION)
1185 {
1186 return_ACPI_STATUS (Status);
1187 }
1188 #endif
1189
1190 Op->Asl.Node = Node;
1191 return_ACPI_STATUS (Status);
1192 }
1193
1194
1195 /*******************************************************************************
1196 *
1197 * FUNCTION: XfRefIsGuardedByIfCondRefOf
1198 *
1199 * PARAMETERS: Node - Named object reference node
1200 * Op - Named object reference parse node
1201 *
1202 * RETURN: BOOLEAN
1203 *
1204 * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...))
1205 * refers to Node.
1206 *
1207 ******************************************************************************/
1208
1209 static BOOLEAN
1210 XfRefIsGuardedByIfCondRefOf (
1211 ACPI_NAMESPACE_NODE *Node,
1212 ACPI_PARSE_OBJECT *Op)
1213 {
1214 ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent;
1215
1216
1217 while (Parent)
1218 {
1219 if (Parent->Asl.ParseOpcode == PARSEOP_IF &&
1220 XfFindCondRefOfName (Node, Parent->Asl.Child))
1221 {
1222 return (TRUE);
1223 }
1224
1225 Parent = Parent->Asl.Parent;
1226 }
1227
1228 return (FALSE);
1229 }
1230
1231
1232 /*******************************************************************************
1233 *
1234 * FUNCTION: XfRefIsGuardedByIfCondRefOf
1235 *
1236 * PARAMETERS: Node - Named object reference node
1237 * Op - Named object reference parse node
1238 *
1239 * RETURN: BOOLEAN
1240 *
1241 * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...))
1242 * refers to Node.
1243 *
1244 ******************************************************************************/
1245
1246 static BOOLEAN
1247 XfFindCondRefOfName (
1248 ACPI_NAMESPACE_NODE *Node,
1249 ACPI_PARSE_OBJECT *Op)
1250 {
1251 BOOLEAN CondRefOfFound = FALSE;
1252
1253
1254 if (!Op)
1255 {
1256 return (FALSE);
1257 }
1258
1259 switch (Op->Asl.ParseOpcode)
1260 {
1261 case PARSEOP_CONDREFOF:
1262
1263 return (Op->Asl.Child->Common.Node == Node);
1264 break;
1265
1266 case PARSEOP_LAND:
1267
1268 CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child);
1269 if (CondRefOfFound)
1270 {
1271 return (TRUE);
1272 }
1273
1274 return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next));
1275 break;
1276
1277 default:
1278
1279 return (FALSE);
1280 break;
1281 }
1282 }
1283
1284
1285 /*******************************************************************************
1286 *
1287 * FUNCTION: XfNamespaceLocateEnd
1288 *
1289 * PARAMETERS: ASL_WALK_CALLBACK
1290 *
1291 * RETURN: Status
1292 *
1293 * DESCRIPTION: Ascending callback used during cross reference. We only
1294 * need to worry about scope management here.
1295 *
1296 ******************************************************************************/
1297
1298 static ACPI_STATUS
1299 XfNamespaceLocateEnd (
1300 ACPI_PARSE_OBJECT *Op,
1301 UINT32 Level,
1302 void *Context)
1303 {
1304 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
1305 const ACPI_OPCODE_INFO *OpInfo;
1306
1307
1308 ACPI_FUNCTION_TRACE (XfNamespaceLocateEnd);
1309
1310
1311 /* We are only interested in opcodes that have an associated name */
1312
1313 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1314 if (!(OpInfo->Flags & AML_NAMED))
1315 {
1316 return_ACPI_STATUS (AE_OK);
1317 }
1318
1319 /* Not interested in name references, we did not open a scope for them */
1320
1321 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
1322 (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
1323 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
1324 (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
1325 {
1326 return_ACPI_STATUS (AE_OK);
1327 }
1328
1329 /* Pop the scope stack if necessary */
1330
1331 if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
1332 {
1333
1334 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1335 "%s: Popping scope for Op %p\n",
1336 AcpiUtGetTypeName (OpInfo->ObjectType), Op));
1337
1338 (void) AcpiDsScopeStackPop (WalkState);
1339 }
1340
1341 return_ACPI_STATUS (AE_OK);
1342 }
1343
1344
1345 /*******************************************************************************
1346 *
1347 * FUNCTION: XfValidateCrossReference
1348 *
1349 * PARAMETERS: Op - Parse Op that references the object
1350 * OpInfo - Parse Op info struct
1351 * Node - Node for the referenced object
1352 *
1353 * RETURN: TRUE if the reference is legal, FALSE otherwise
1354 *
1355 * DESCRIPTION: Determine if a reference to another object is allowed.
1356 *
1357 * EXAMPLE:
1358 * Method (A) {Name (INT1, 1)} Declaration of object INT1
1359 * Method (B) (Store (2, \A.INT1)} Illegal reference to object INT1
1360 * (INT1 is temporary, valid only during
1361 * execution of A)
1362 *
1363 * NOTES:
1364 * A null pointer returned by either UtGetParentMethodOp or
1365 * UtGetParentMethodNode indicates that the parameter object is not
1366 * within a control method.
1367 *
1368 * Five cases are handled: Case(Op, Node)
1369 * 1) Case(0,0): Op is not within a method, Node is not --> OK
1370 * 2) Case(0,1): Op is not within a method, but Node is --> Illegal
1371 * 3) Case(1,0): Op is within a method, Node is not --> OK
1372 * 4) Case(1,1): Both are within the same method --> OK
1373 * 5) Case(1,1): Both are in methods, but not same method --> Illegal
1374 *
1375 ******************************************************************************/
1376
1377 static BOOLEAN
1378 XfValidateCrossReference (
1379 ACPI_PARSE_OBJECT *Op,
1380 const ACPI_OPCODE_INFO *OpInfo,
1381 ACPI_NAMESPACE_NODE *Node)
1382 {
1383 ACPI_PARSE_OBJECT *ReferencingMethodOp;
1384 ACPI_NAMESPACE_NODE *ReferencedMethodNode;
1385
1386
1387 /* Ignore actual named (and related) object declarations */
1388
1389 if (OpInfo->Flags & (AML_NAMED | AML_CREATE | AML_DEFER | AML_HAS_ARGS))
1390 {
1391 return (TRUE);
1392 }
1393
1394 /*
1395 * 1) Search upwards in parse tree for owner of the referencing object
1396 * 2) Search upwards in namespace to find the owner of the referenced object
1397 */
1398 ReferencingMethodOp = UtGetParentMethodOp (Op);
1399 ReferencedMethodNode = UtGetParentMethodNode (Node);
1400
1401 if (!ReferencingMethodOp && !ReferencedMethodNode)
1402 {
1403 /*
1404 * 1) Case (0,0): Both Op and Node are not within methods
1405 * --> OK
1406 */
1407 return (TRUE);
1408 }
1409
1410 if (!ReferencingMethodOp && ReferencedMethodNode)
1411 {
1412 /*
1413 * 2) Case (0,1): Op is not in a method, but Node is within a
1414 * method --> illegal
1415 */
1416 return (FALSE);
1417 }
1418 else if (ReferencingMethodOp && !ReferencedMethodNode)
1419 {
1420 /*
1421 * 3) Case (1,0): Op is within a method, but Node is not
1422 * --> OK
1423 */
1424 return (TRUE);
1425 }
1426 else if (ReferencingMethodOp->Asl.Node == ReferencedMethodNode)
1427 {
1428 /*
1429 * 4) Case (1,1): Both Op and Node are within the same method
1430 * --> OK
1431 */
1432 return (TRUE);
1433 }
1434 else
1435 {
1436 /*
1437 * 5) Case (1,1), Op and Node are in different methods
1438 * --> Illegal
1439 */
1440 return (FALSE);
1441 }
1442 }