1 /******************************************************************************
3 * Module Name: aslwalks.c - Miscellaneous analytical parse tree walks
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "acparser.h"
158 #define _COMPONENT ACPI_COMPILER
159 ACPI_MODULE_NAME ("aslwalks")
162 /* Local prototypes */
165 AnAnalyzeStoreOperator (
166 ACPI_PARSE_OBJECT
*Op
);
169 /*******************************************************************************
171 * FUNCTION: AnMethodTypingWalkEnd
173 * PARAMETERS: ASL_WALK_CALLBACK
177 * DESCRIPTION: Ascending callback for typing walk. Complete the method
178 * return analysis. Check methods for:
179 * 1) Initialized local variables
183 ******************************************************************************/
186 AnMethodTypingWalkEnd (
187 ACPI_PARSE_OBJECT
*Op
,
194 switch (Op
->Asl
.ParseOpcode
)
198 Op
->Asl
.CompileFlags
|= OP_METHOD_TYPED
;
203 if ((Op
->Asl
.Child
) &&
204 (Op
->Asl
.Child
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
))
206 ThisOpBtype
= AnGetBtype (Op
->Asl
.Child
);
208 if ((Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_METHODCALL
) &&
209 (ThisOpBtype
== (ACPI_UINT32_MAX
-1)))
212 * The called method is untyped at this time (typically a
213 * forward reference).
215 * Check for a recursive method call first. Note: the
216 * Child->Node will be null if the method has not been
219 if (Op
->Asl
.Child
->Asl
.Node
&&
220 (Op
->Asl
.ParentMethod
!= Op
->Asl
.Child
->Asl
.Node
->Op
))
222 /* We must type the method here */
224 TrWalkParseTree (Op
->Asl
.Child
->Asl
.Node
->Op
,
225 ASL_WALK_VISIT_UPWARD
, NULL
,
226 AnMethodTypingWalkEnd
, NULL
);
228 ThisOpBtype
= AnGetBtype (Op
->Asl
.Child
);
232 /* Returns a value, save the value type */
234 if (Op
->Asl
.ParentMethod
)
236 Op
->Asl
.ParentMethod
->Asl
.AcpiBtype
|= ThisOpBtype
;
250 /*******************************************************************************
252 * FUNCTION: AnOperandTypecheckWalkEnd
254 * PARAMETERS: ASL_WALK_CALLBACK
258 * DESCRIPTION: Ascending callback for analysis walk. Complete method
261 ******************************************************************************/
264 AnOperandTypecheckWalkEnd (
265 ACPI_PARSE_OBJECT
*Op
,
269 const ACPI_OPCODE_INFO
*OpInfo
;
270 UINT32 RuntimeArgTypes
;
271 UINT32 RuntimeArgTypes2
;
272 UINT32 RequiredBtypes
;
273 UINT32 ThisNodeBtype
;
276 ACPI_PARSE_OBJECT
*ArgOp
;
280 switch (Op
->Asl
.AmlOpcode
)
282 case AML_RAW_DATA_BYTE
:
283 case AML_RAW_DATA_WORD
:
284 case AML_RAW_DATA_DWORD
:
285 case AML_RAW_DATA_QWORD
:
286 case AML_RAW_DATA_BUFFER
:
287 case AML_RAW_DATA_CHAIN
:
288 case AML_PACKAGE_LENGTH
:
289 case AML_UNASSIGNED_OPCODE
:
290 case AML_DEFAULT_ARG_OP
:
292 /* Ignore the internal (compiler-only) AML opcodes */
301 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Asl
.AmlOpcode
);
307 ArgOp
= Op
->Asl
.Child
;
308 OpcodeClass
= OpInfo
->Class
;
309 RuntimeArgTypes
= OpInfo
->RuntimeArgs
;
311 #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
313 * Update 11/2008: In practice, we can't perform this check. A simple
314 * analysis is not sufficient. Also, it can cause errors when compiling
315 * disassembled code because of the way Switch operators are implemented
316 * (a While(One) loop with a named temp variable created within.)
320 * If we are creating a named object, check if we are within a while loop
321 * by checking if the parent is a WHILE op. This is a simple analysis, but
322 * probably sufficient for many cases.
324 * Allow Scope(), Buffer(), and Package().
326 if (((OpcodeClass
== AML_CLASS_NAMED_OBJECT
) && (Op
->Asl
.AmlOpcode
!= AML_SCOPE_OP
)) ||
327 ((OpcodeClass
== AML_CLASS_CREATE
) && (OpInfo
->Flags
& AML_NSNODE
)))
329 if (Op
->Asl
.Parent
->Asl
.AmlOpcode
== AML_WHILE_OP
)
331 AslError (ASL_ERROR
, ASL_MSG_NAMED_OBJECT_IN_WHILE
, Op
, NULL
);
337 * Special case for control opcodes IF/RETURN/WHILE since they
338 * have no runtime arg list (at this time)
340 switch (Op
->Asl
.AmlOpcode
)
346 if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_METHODCALL
)
348 /* Check for an internal method */
350 if (AnIsInternalMethod (ArgOp
))
355 /* The lone arg is a method call, check it */
357 RequiredBtypes
= AnMapArgTypeToBtype (ARGI_INTEGER
);
358 if (Op
->Asl
.AmlOpcode
== AML_RETURN_OP
)
360 RequiredBtypes
= 0xFFFFFFFF;
363 ThisNodeBtype
= AnGetBtype (ArgOp
);
364 if (ThisNodeBtype
== ACPI_UINT32_MAX
)
369 AnCheckMethodReturnValue (Op
, OpInfo
, ArgOp
,
370 RequiredBtypes
, ThisNodeBtype
);
374 case AML_EXTERNAL_OP
:
376 * Not really a "runtime" opcode since it used by disassembler only.
377 * The parser will find any issues with the operands.
386 /* Ignore the non-executable opcodes */
388 if (RuntimeArgTypes
== ARGI_INVALID_OPCODE
)
394 * Special handling for certain opcodes.
396 switch (Op
->Asl
.AmlOpcode
)
398 /* BankField has one TermArg */
400 case AML_BANK_FIELD_OP
:
402 OpcodeClass
= AML_CLASS_EXECUTE
;
403 ArgOp
= ArgOp
->Asl
.Next
;
404 ArgOp
= ArgOp
->Asl
.Next
;
407 /* Operation Region has 2 TermArgs */
411 OpcodeClass
= AML_CLASS_EXECUTE
;
412 ArgOp
= ArgOp
->Asl
.Next
;
413 ArgOp
= ArgOp
->Asl
.Next
;
416 /* DataTableRegion has 3 TermArgs */
418 case AML_DATA_REGION_OP
:
420 OpcodeClass
= AML_CLASS_EXECUTE
;
421 ArgOp
= ArgOp
->Asl
.Next
;
424 /* Buffers/Packages have a length that is a TermArg */
428 case AML_VARIABLE_PACKAGE_OP
:
430 /* If length is a constant, we are done */
432 if ((ArgOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) ||
433 (ArgOp
->Asl
.ParseOpcode
== PARSEOP_RAW_DATA
))
439 /* Store can write any object to the Debug object */
443 * If this is a Store() to the Debug object, we don't need
444 * to perform any further validation -- because a Store of
445 * any object to Debug is permitted and supported.
447 if (ArgOp
->Asl
.Next
->Asl
.AmlOpcode
== AML_DEBUG_OP
)
459 case AML_CLASS_EXECUTE
:
460 case AML_CLASS_CREATE
:
461 case AML_CLASS_CONTROL
:
462 case AML_CLASS_RETURN_VALUE
:
464 /* Reverse the runtime argument list */
466 RuntimeArgTypes2
= 0;
467 while ((ArgType
= GET_CURRENT_ARG_TYPE (RuntimeArgTypes
)))
469 RuntimeArgTypes2
<<= ARG_TYPE_WIDTH
;
470 RuntimeArgTypes2
|= ArgType
;
471 INCREMENT_ARG_LIST (RuntimeArgTypes
);
474 /* Typecheck each argument */
476 while ((ArgType
= GET_CURRENT_ARG_TYPE (RuntimeArgTypes2
)))
478 /* Get the required type(s) for the argument */
480 RequiredBtypes
= AnMapArgTypeToBtype (ArgType
);
484 AslError (ASL_ERROR
, ASL_MSG_COMPILER_INTERNAL
, Op
,
485 "Null ArgOp in argument loop");
489 /* Get the actual type of the argument */
491 ThisNodeBtype
= AnGetBtype (ArgOp
);
492 if (ThisNodeBtype
== ACPI_UINT32_MAX
)
497 /* Examine the arg based on the required type of the arg */
503 if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
)
505 /* ZERO is the placeholder for "don't store result" */
507 ThisNodeBtype
= RequiredBtypes
;
513 case ARGI_STORE_TARGET
:
515 if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
)
518 * This is the case where an original reference to a resource
519 * descriptor field has been replaced by an (Integer) offset.
520 * These named fields are supported at compile-time only;
521 * the names are not passed to the interpreter (via the AML).
523 if ((ArgOp
->Asl
.Node
->Type
== ACPI_TYPE_LOCAL_RESOURCE_FIELD
) ||
524 (ArgOp
->Asl
.Node
->Type
== ACPI_TYPE_LOCAL_RESOURCE
))
526 AslError (ASL_ERROR
, ASL_MSG_RESOURCE_FIELD
,
531 AslError (ASL_ERROR
, ASL_MSG_INVALID_TYPE
,
538 #ifdef __FUTURE_IMPLEMENTATION
540 * Possible future typechecking support
542 case ARGI_REFERENCE
: /* References */
543 case ARGI_INTEGER_REF
:
544 case ARGI_OBJECT_REF
:
545 case ARGI_DEVICE_REF
:
547 switch (ArgOp
->Asl
.ParseOpcode
)
558 /* TBD: implement analysis of current value (type) of the local */
559 /* For now, just treat any local as a typematch */
561 /*ThisNodeBtype = RequiredBtypes;*/
572 /* Hard to analyze argument types, so we won't */
573 /* for now. Just treat any arg as a typematch */
575 /* ThisNodeBtype = RequiredBtypes; */
594 /* Check for a type mismatch (required versus actual) */
596 CommonBtypes
= ThisNodeBtype
& RequiredBtypes
;
598 if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_METHODCALL
)
600 if (AnIsInternalMethod (ArgOp
))
605 /* Check a method call for a valid return value */
607 AnCheckMethodReturnValue (Op
, OpInfo
, ArgOp
,
608 RequiredBtypes
, ThisNodeBtype
);
612 * Now check if the actual type(s) match at least one
613 * bit to the required type
615 else if (!CommonBtypes
)
617 /* No match -- this is a type mismatch error */
619 AnFormatBtype (AslGbl_StringBuffer
, ThisNodeBtype
);
620 AnFormatBtype (AslGbl_StringBuffer2
, RequiredBtypes
);
622 sprintf (AslGbl_MsgBuffer
, "[%s] found, %s operator requires [%s]",
623 AslGbl_StringBuffer
, OpInfo
->Name
, AslGbl_StringBuffer2
);
625 AslError (ASL_ERROR
, ASL_MSG_INVALID_TYPE
,
626 ArgOp
, AslGbl_MsgBuffer
);
630 ArgOp
= ArgOp
->Asl
.Next
;
631 INCREMENT_ARG_LIST (RuntimeArgTypes2
);
644 /*******************************************************************************
646 * FUNCTION: AnOtherSemanticAnalysisWalkBegin
648 * PARAMETERS: ASL_WALK_CALLBACK
652 * DESCRIPTION: Descending callback for the analysis walk. Checks for
653 * miscellaneous issues in the code.
655 ******************************************************************************/
658 AnOtherSemanticAnalysisWalkBegin (
659 ACPI_PARSE_OBJECT
*Op
,
663 ACPI_PARSE_OBJECT
*ArgOp
;
664 ACPI_PARSE_OBJECT
*PrevArgOp
= NULL
;
665 const ACPI_OPCODE_INFO
*OpInfo
;
666 ACPI_NAMESPACE_NODE
*Node
;
669 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Asl
.AmlOpcode
);
673 * Determine if an execution class operator actually does something by
674 * checking if it has a target and/or the function return value is used.
675 * (Target is optional, so a standalone statement can actually do nothing.)
677 if ((OpInfo
->Class
== AML_CLASS_EXECUTE
) &&
678 (OpInfo
->Flags
& AML_HAS_RETVAL
) &&
679 (!AnIsResultUsed (Op
)))
681 if (OpInfo
->Flags
& AML_HAS_TARGET
)
684 * Find the target node, it is always the last child. If the target
685 * is not specified in the ASL, a default node of type Zero was
686 * created by the parser.
688 ArgOp
= Op
->Asl
.Child
;
689 while (ArgOp
->Asl
.Next
)
692 ArgOp
= ArgOp
->Asl
.Next
;
695 /* Divide() is the only weird case, it has two targets */
697 if (Op
->Asl
.AmlOpcode
== AML_DIVIDE_OP
)
699 if ((ArgOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
) &&
701 (PrevArgOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
))
703 AslError (ASL_ERROR
, ASL_MSG_RESULT_NOT_USED
,
704 Op
, Op
->Asl
.ExternalName
);
708 else if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
)
710 AslError (ASL_ERROR
, ASL_MSG_RESULT_NOT_USED
,
711 Op
, Op
->Asl
.ExternalName
);
717 * Has no target and the result is not used. Only a couple opcodes
718 * can have this combination.
720 switch (Op
->Asl
.ParseOpcode
)
722 case PARSEOP_ACQUIRE
:
724 case PARSEOP_LOADTABLE
:
730 AslError (ASL_ERROR
, ASL_MSG_RESULT_NOT_USED
,
731 Op
, Op
->Asl
.ExternalName
);
739 * Semantic checks for individual ASL operators
741 switch (Op
->Asl
.ParseOpcode
)
745 if (AslGbl_DoTypechecking
)
747 AnAnalyzeStoreOperator (Op
);
752 case PARSEOP_ACQUIRE
:
755 * Emit a warning if the timeout parameter for these operators is not
756 * ACPI_WAIT_FOREVER, and the result value from the operator is not
757 * checked, meaning that a timeout could happen, but the code
758 * would not know about it.
761 /* First child is the namepath, 2nd child is timeout */
763 ArgOp
= Op
->Asl
.Child
;
764 ArgOp
= ArgOp
->Asl
.Next
;
767 * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
770 if (((ArgOp
->Asl
.ParseOpcode
== PARSEOP_WORDCONST
) ||
771 (ArgOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
)) &&
772 (ArgOp
->Asl
.Value
.Integer
>= (UINT64
) ACPI_WAIT_FOREVER
))
778 * The operation could timeout. If the return value is not used
779 * (indicates timeout occurred), issue a warning
781 if (!AnIsResultUsed (Op
))
783 AslError (ASL_WARNING
, ASL_MSG_TIMEOUT
, ArgOp
,
784 Op
->Asl
.ExternalName
);
788 case PARSEOP_CREATEFIELD
:
790 * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
792 ArgOp
= Op
->Asl
.Child
;
793 ArgOp
= ArgOp
->Asl
.Next
;
794 ArgOp
= ArgOp
->Asl
.Next
;
796 if ((ArgOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
) ||
797 ((ArgOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) &&
798 (ArgOp
->Asl
.Value
.Integer
== 0)))
800 AslError (ASL_ERROR
, ASL_MSG_NON_ZERO
, ArgOp
, NULL
);
804 case PARSEOP_CONNECTION
:
806 * Ensure that the referenced operation region has the correct SPACE_ID.
807 * From the grammar/parser, we know the parent is a FIELD definition.
809 ArgOp
= Op
->Asl
.Parent
; /* Field definition */
810 ArgOp
= ArgOp
->Asl
.Child
; /* First child is the OpRegion Name */
811 Node
= ArgOp
->Asl
.Node
; /* OpRegion namespace node */
817 ArgOp
= Node
->Op
; /* OpRegion definition */
818 ArgOp
= ArgOp
->Asl
.Child
; /* First child is the OpRegion Name */
819 ArgOp
= ArgOp
->Asl
.Next
; /* Next peer is the SPACE_ID (what we want) */
822 * The Connection() operator is only valid for the following operation
823 * region SpaceIds: GeneralPurposeIo and GenericSerialBus.
825 if ((ArgOp
->Asl
.Value
.Integer
!= ACPI_ADR_SPACE_GPIO
) &&
826 (ArgOp
->Asl
.Value
.Integer
!= ACPI_ADR_SPACE_GSBUS
))
828 AslError (ASL_ERROR
, ASL_MSG_CONNECTION_INVALID
, Op
, NULL
);
834 * Ensure that fields for GeneralPurposeIo and GenericSerialBus
835 * contain at least one Connection() operator
837 ArgOp
= Op
->Asl
.Child
; /* 1st child is the OpRegion Name */
838 Node
= ArgOp
->Asl
.Node
; /* OpRegion namespace node */
844 ArgOp
= Node
->Op
; /* OpRegion definition */
845 ArgOp
= ArgOp
->Asl
.Child
; /* First child is the OpRegion Name */
846 ArgOp
= ArgOp
->Asl
.Next
; /* Next peer is the SPACE_ID (what we want) */
848 /* We are only interested in GeneralPurposeIo and GenericSerialBus */
850 if ((ArgOp
->Asl
.Value
.Integer
!= ACPI_ADR_SPACE_GPIO
) &&
851 (ArgOp
->Asl
.Value
.Integer
!= ACPI_ADR_SPACE_GSBUS
))
856 ArgOp
= Op
->Asl
.Child
; /* 1st child is the OpRegion Name */
857 ArgOp
= ArgOp
->Asl
.Next
; /* AccessType */
858 ArgOp
= ArgOp
->Asl
.Next
; /* LockRule */
859 ArgOp
= ArgOp
->Asl
.Next
; /* UpdateRule */
860 ArgOp
= ArgOp
->Asl
.Next
; /* Start of FieldUnitList */
862 /* Walk the FieldUnitList */
866 if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_CONNECTION
)
870 else if (ArgOp
->Asl
.ParseOpcode
== PARSEOP_NAMESEG
)
872 AslError (ASL_ERROR
, ASL_MSG_CONNECTION_MISSING
, ArgOp
, NULL
);
876 ArgOp
= ArgOp
->Asl
.Next
;
889 /*******************************************************************************
891 * FUNCTION: AnAnalyzeStoreOperator
893 * PARAMETERS: Op - Store() operator
897 * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package
898 * objects where there are more restrictions than other data
901 ******************************************************************************/
904 AnAnalyzeStoreOperator (
905 ACPI_PARSE_OBJECT
*Op
)
907 ACPI_NAMESPACE_NODE
*SourceNode
;
908 ACPI_NAMESPACE_NODE
*TargetNode
;
909 ACPI_PARSE_OBJECT
*SourceOperandOp
;
910 ACPI_PARSE_OBJECT
*TargetOperandOp
;
911 UINT32 SourceOperandBtype
;
912 UINT32 TargetOperandBtype
;
915 /* Extract the two operands for STORE */
917 SourceOperandOp
= Op
->Asl
.Child
;
918 TargetOperandOp
= SourceOperandOp
->Asl
.Next
;
921 * Ignore these Source operand opcodes, they cannot be typechecked,
922 * the actual result is unknown here.
924 switch (SourceOperandOp
->Asl
.ParseOpcode
)
926 /* For these, type of the returned value is unknown at compile time */
928 case PARSEOP_DEREFOF
:
929 case PARSEOP_METHODCALL
:
931 case PARSEOP_COPYOBJECT
:
938 if (!AslGbl_EnableReferenceTypechecking
)
944 * These opcodes always return an object reference, and thus
945 * the result can only be stored to a Local, Arg, or Debug.
947 if (TargetOperandOp
->Asl
.AmlOpcode
== AML_DEBUG_OP
)
952 if ((TargetOperandOp
->Asl
.AmlOpcode
< AML_LOCAL0
) ||
953 (TargetOperandOp
->Asl
.AmlOpcode
> AML_ARG6
))
955 AslError (ASL_ERROR
, ASL_MSG_INVALID_TYPE
, TargetOperandOp
,
956 "Source [Reference], Target must be [Local/Arg/Debug]");
965 * Ignore these Target operand opcodes, they cannot be typechecked
967 switch (TargetOperandOp
->Asl
.ParseOpcode
)
970 case PARSEOP_DEREFOF
:
982 * Ignore typecheck for External() operands of type "UnknownObj",
983 * we don't know the actual type (source or target).
985 SourceNode
= SourceOperandOp
->Asl
.Node
;
987 (SourceNode
->Flags
& ANOBJ_IS_EXTERNAL
) &&
988 (SourceNode
->Type
== ACPI_TYPE_ANY
))
993 TargetNode
= TargetOperandOp
->Asl
.Node
;
995 (TargetNode
->Flags
& ANOBJ_IS_EXTERNAL
) &&
996 (TargetNode
->Type
== ACPI_TYPE_ANY
))
1002 * A NULL node with a namepath AML opcode indicates non-existent
1003 * name. Just return, the error message is generated elsewhere.
1005 if ((!SourceNode
&& (SourceOperandOp
->Asl
.AmlOpcode
== AML_INT_NAMEPATH_OP
)) ||
1006 (!TargetNode
&& (TargetOperandOp
->Asl
.AmlOpcode
== AML_INT_NAMEPATH_OP
)))
1012 * Simple check for source same as target via NS node.
1013 * -- Could be expanded to locals and args.
1015 if (SourceNode
&& TargetNode
)
1017 if (SourceNode
== TargetNode
)
1019 AslError (ASL_WARNING
, ASL_MSG_DUPLICATE_ITEM
,
1020 TargetOperandOp
, "Source is the same as Target");
1025 /* Ignore typecheck if either source or target is a local or arg */
1027 if ((SourceOperandOp
->Asl
.AmlOpcode
>= AML_LOCAL0
) &&
1028 (SourceOperandOp
->Asl
.AmlOpcode
<= AML_ARG6
))
1030 return; /* Cannot type a local/arg at compile time */
1033 if ((TargetOperandOp
->Asl
.AmlOpcode
>= AML_LOCAL0
) &&
1034 (TargetOperandOp
->Asl
.AmlOpcode
<= AML_ARG6
))
1036 return; /* Cannot type a local/arg at compile time */
1040 * Package objects are a special case because they cannot by implicitly
1041 * converted to/from anything. Check for these two illegal cases:
1043 * Store (non-package, package)
1044 * Store (package, non-package)
1046 SourceOperandBtype
= AnGetBtype (SourceOperandOp
);
1047 TargetOperandBtype
= AnGetBtype (TargetOperandOp
);
1049 /* Check source first for (package, non-package) case */
1051 if (SourceOperandBtype
& ACPI_BTYPE_PACKAGE
)
1053 /* If Source is PACKAGE-->Target must be PACKAGE */
1055 if (!(TargetOperandBtype
& ACPI_BTYPE_PACKAGE
))
1057 AslError (ASL_ERROR
, ASL_MSG_INVALID_TYPE
, TargetOperandOp
,
1058 "Source is [Package], Target must be a package also");
1062 /* Else check target for (non-package, package) case */
1064 else if (TargetOperandBtype
& ACPI_BTYPE_PACKAGE
)
1066 /* If Target is PACKAGE, Source must be PACKAGE */
1068 if (!(SourceOperandBtype
& ACPI_BTYPE_PACKAGE
))
1070 AslError (ASL_ERROR
, ASL_MSG_INVALID_TYPE
, SourceOperandOp
,
1071 "Target is [Package], Source must be a package also");