1efcc2a30SJung-uk Kim /******************************************************************************
2efcc2a30SJung-uk Kim  *
3efcc2a30SJung-uk Kim  * Module Name: aslmethod.c - Control method analysis walk
4efcc2a30SJung-uk Kim  *
5efcc2a30SJung-uk Kim  *****************************************************************************/
6efcc2a30SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11f425b8beSJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12efcc2a30SJung-uk Kim  * All rights reserved.
13efcc2a30SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119efcc2a30SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120efcc2a30SJung-uk Kim  * modification, are permitted provided that the following conditions
121efcc2a30SJung-uk Kim  * are met:
122efcc2a30SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123efcc2a30SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124efcc2a30SJung-uk Kim  *    without modification.
125efcc2a30SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126efcc2a30SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127efcc2a30SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128efcc2a30SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129efcc2a30SJung-uk Kim  *    binary redistribution.
130efcc2a30SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131efcc2a30SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132efcc2a30SJung-uk Kim  *    from this software without specific prior written permission.
133efcc2a30SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147efcc2a30SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148efcc2a30SJung-uk Kim  * Software Foundation.
149efcc2a30SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151efcc2a30SJung-uk Kim 
152efcc2a30SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
153efcc2a30SJung-uk Kim #include "aslcompiler.y.h"
154ec0234b4SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
155a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
156a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h>
157efcc2a30SJung-uk Kim 
158efcc2a30SJung-uk Kim 
159efcc2a30SJung-uk Kim #define _COMPONENT          ACPI_COMPILER
160efcc2a30SJung-uk Kim         ACPI_MODULE_NAME    ("aslmethod")
161efcc2a30SJung-uk Kim 
162efcc2a30SJung-uk Kim 
163a9d8d09cSJung-uk Kim /* Local prototypes */
164a9d8d09cSJung-uk Kim 
165f8146b88SJung-uk Kim static void
166a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod (
167a9d8d09cSJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
168a9d8d09cSJung-uk Kim     ASL_METHOD_INFO         *MethodInfo);
169a9d8d09cSJung-uk Kim 
170ec0234b4SJung-uk Kim static void
171ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod (
172ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
173ec0234b4SJung-uk Kim 
174a9d8d09cSJung-uk Kim 
175efcc2a30SJung-uk Kim /*******************************************************************************
176efcc2a30SJung-uk Kim  *
177efcc2a30SJung-uk Kim  * FUNCTION:    MtMethodAnalysisWalkBegin
178efcc2a30SJung-uk Kim  *
179efcc2a30SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
180efcc2a30SJung-uk Kim  *
181efcc2a30SJung-uk Kim  * RETURN:      Status
182efcc2a30SJung-uk Kim  *
183efcc2a30SJung-uk Kim  * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
184efcc2a30SJung-uk Kim  *              1) Initialized local variables
185efcc2a30SJung-uk Kim  *              2) Valid arguments
186efcc2a30SJung-uk Kim  *              3) Return types
187efcc2a30SJung-uk Kim  *
188efcc2a30SJung-uk Kim  ******************************************************************************/
189efcc2a30SJung-uk Kim 
190efcc2a30SJung-uk Kim ACPI_STATUS
191efcc2a30SJung-uk Kim MtMethodAnalysisWalkBegin (
192efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
193efcc2a30SJung-uk Kim     UINT32                  Level,
194efcc2a30SJung-uk Kim     void                    *Context)
195efcc2a30SJung-uk Kim {
196efcc2a30SJung-uk Kim     ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
197efcc2a30SJung-uk Kim     ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;
198efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *Next;
199efcc2a30SJung-uk Kim     UINT32                  RegisterNumber;
200efcc2a30SJung-uk Kim     UINT32                  i;
201efcc2a30SJung-uk Kim     char                    LocalName[] = "Local0";
202efcc2a30SJung-uk Kim     char                    ArgName[] = "Arg0";
203efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *ArgNode;
204efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *NextType;
205efcc2a30SJung-uk Kim     UINT8                   ActualArgs = 0;
206a009b7dcSJung-uk Kim     BOOLEAN                 HidExists;
207a009b7dcSJung-uk Kim     BOOLEAN                 AdrExists;
208efcc2a30SJung-uk Kim 
209efcc2a30SJung-uk Kim 
210f8146b88SJung-uk Kim     /* Build cross-reference output file if requested */
211f8146b88SJung-uk Kim 
2126f1f1a63SJung-uk Kim     if (AslGbl_CrossReferenceOutput)
213f8146b88SJung-uk Kim     {
214f8146b88SJung-uk Kim         OtXrefWalkPart1 (Op, Level, MethodInfo);
215f8146b88SJung-uk Kim     }
216f8146b88SJung-uk Kim 
217efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
218efcc2a30SJung-uk Kim     {
219efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
220efcc2a30SJung-uk Kim 
2216f1f1a63SJung-uk Kim         AslGbl_TotalMethods++;
222efcc2a30SJung-uk Kim 
223efcc2a30SJung-uk Kim         /* Create and init method info */
224efcc2a30SJung-uk Kim 
225efcc2a30SJung-uk Kim         MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
226efcc2a30SJung-uk Kim         MethodInfo->Next = WalkInfo->MethodStack;
227efcc2a30SJung-uk Kim         MethodInfo->Op = Op;
228efcc2a30SJung-uk Kim 
229efcc2a30SJung-uk Kim         WalkInfo->MethodStack = MethodInfo;
230efcc2a30SJung-uk Kim 
231313a0c13SJung-uk Kim         /*
232313a0c13SJung-uk Kim          * Special handling for _PSx methods. Dependency rules (same scope):
233313a0c13SJung-uk Kim          *
234313a0c13SJung-uk Kim          * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3
235313a0c13SJung-uk Kim          * 2) _PS1/_PS2/_PS3: A _PS0 must exist
236313a0c13SJung-uk Kim          */
237278f0de6SJung-uk Kim         if (ACPI_COMPARE_NAMESEG (METHOD_NAME__PS0, Op->Asl.NameSeg))
238313a0c13SJung-uk Kim         {
239313a0c13SJung-uk Kim             /* For _PS0, one of _PS1/_PS2/_PS3 must exist */
240313a0c13SJung-uk Kim 
241313a0c13SJung-uk Kim             if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) &&
242313a0c13SJung-uk Kim                 (!ApFindNameInScope (METHOD_NAME__PS2, Op)) &&
243313a0c13SJung-uk Kim                 (!ApFindNameInScope (METHOD_NAME__PS3, Op)))
244313a0c13SJung-uk Kim             {
245313a0c13SJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
246313a0c13SJung-uk Kim                     "_PS0 requires one of _PS1/_PS2/_PS3 in same scope");
247313a0c13SJung-uk Kim             }
248313a0c13SJung-uk Kim         }
249313a0c13SJung-uk Kim         else if (
250278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS1, Op->Asl.NameSeg) ||
251278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS2, Op->Asl.NameSeg) ||
252278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS3, Op->Asl.NameSeg))
253313a0c13SJung-uk Kim         {
254313a0c13SJung-uk Kim             /* For _PS1/_PS2/_PS3, a _PS0 must exist */
255313a0c13SJung-uk Kim 
256313a0c13SJung-uk Kim             if (!ApFindNameInScope (METHOD_NAME__PS0, Op))
257313a0c13SJung-uk Kim             {
2586f1f1a63SJung-uk Kim                 sprintf (AslGbl_MsgBuffer,
259313a0c13SJung-uk Kim                     "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg);
260313a0c13SJung-uk Kim 
261313a0c13SJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
2626f1f1a63SJung-uk Kim                     AslGbl_MsgBuffer);
263313a0c13SJung-uk Kim             }
264313a0c13SJung-uk Kim         }
265313a0c13SJung-uk Kim 
266313a0c13SJung-uk Kim         /* Get the name node */
267efcc2a30SJung-uk Kim 
268efcc2a30SJung-uk Kim         Next = Op->Asl.Child;
269efcc2a30SJung-uk Kim 
270efcc2a30SJung-uk Kim         /* Get the NumArguments node */
271efcc2a30SJung-uk Kim 
272efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
273efcc2a30SJung-uk Kim         MethodInfo->NumArguments = (UINT8)
274efcc2a30SJung-uk Kim             (((UINT8) Next->Asl.Value.Integer) & 0x07);
275efcc2a30SJung-uk Kim 
276efcc2a30SJung-uk Kim         /* Get the SerializeRule and SyncLevel nodes, ignored here */
277efcc2a30SJung-uk Kim 
278efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
279a9d8d09cSJung-uk Kim         MethodInfo->ShouldBeSerialized = (UINT8) Next->Asl.Value.Integer;
280a9d8d09cSJung-uk Kim 
281efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
282efcc2a30SJung-uk Kim         ArgNode = Next;
283efcc2a30SJung-uk Kim 
284efcc2a30SJung-uk Kim         /* Get the ReturnType node */
285efcc2a30SJung-uk Kim 
286efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
287efcc2a30SJung-uk Kim 
288efcc2a30SJung-uk Kim         NextType = Next->Asl.Child;
289efcc2a30SJung-uk Kim 
290ec0234b4SJung-uk Kim         MethodInfo->ValidReturnTypes = MtProcessTypeOp (NextType);
291385fb5d9SJung-uk Kim         Op->Asl.AcpiBtype |= MethodInfo->ValidReturnTypes;
292efcc2a30SJung-uk Kim 
293efcc2a30SJung-uk Kim         /* Get the ParameterType node */
294efcc2a30SJung-uk Kim 
295efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
296efcc2a30SJung-uk Kim 
297efcc2a30SJung-uk Kim         NextType = Next->Asl.Child;
298ec0234b4SJung-uk Kim         if (!NextType)
299efcc2a30SJung-uk Kim         {
300ec0234b4SJung-uk Kim             /*
301ec0234b4SJung-uk Kim              * The optional parameter types list was omitted  at the source
302ec0234b4SJung-uk Kim              * level. Use the Argument count parameter instead.
303ec0234b4SJung-uk Kim              */
304ec0234b4SJung-uk Kim             ActualArgs = MethodInfo->NumArguments;
305efcc2a30SJung-uk Kim         }
306efcc2a30SJung-uk Kim         else
307efcc2a30SJung-uk Kim         {
308ec0234b4SJung-uk Kim             ActualArgs = MtProcessParameterTypeList (NextType,
309ec0234b4SJung-uk Kim                 MethodInfo->ValidArgTypes);
31061b18036SJung-uk Kim             MethodInfo->NumArguments = ActualArgs;
31161b18036SJung-uk Kim             ArgNode->Asl.Value.Integer |= ActualArgs;
312efcc2a30SJung-uk Kim         }
313efcc2a30SJung-uk Kim 
314efcc2a30SJung-uk Kim         if ((MethodInfo->NumArguments) &&
315efcc2a30SJung-uk Kim             (MethodInfo->NumArguments != ActualArgs))
316efcc2a30SJung-uk Kim         {
317ec0234b4SJung-uk Kim             sprintf (AslGbl_MsgBuffer,
318ec0234b4SJung-uk Kim                 "Length = %u", ActualArgs);
319ec0234b4SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_MISMATCH,
320ec0234b4SJung-uk Kim                 Op->Asl.Child->Asl.Next, AslGbl_MsgBuffer);
321efcc2a30SJung-uk Kim         }
322efcc2a30SJung-uk Kim 
323efcc2a30SJung-uk Kim         /* Allow numarguments == 0 for Function() */
324efcc2a30SJung-uk Kim 
325efcc2a30SJung-uk Kim         if ((!MethodInfo->NumArguments) && (ActualArgs))
326efcc2a30SJung-uk Kim         {
327efcc2a30SJung-uk Kim             MethodInfo->NumArguments = ActualArgs;
328efcc2a30SJung-uk Kim             ArgNode->Asl.Value.Integer |= ActualArgs;
329efcc2a30SJung-uk Kim         }
330efcc2a30SJung-uk Kim 
331efcc2a30SJung-uk Kim         /*
332efcc2a30SJung-uk Kim          * Actual arguments are initialized at method entry.
333efcc2a30SJung-uk Kim          * All other ArgX "registers" can be used as locals, so we
334efcc2a30SJung-uk Kim          * track their initialization.
335efcc2a30SJung-uk Kim          */
336efcc2a30SJung-uk Kim         for (i = 0; i < MethodInfo->NumArguments; i++)
337efcc2a30SJung-uk Kim         {
338efcc2a30SJung-uk Kim             MethodInfo->ArgInitialized[i] = TRUE;
339efcc2a30SJung-uk Kim         }
340efcc2a30SJung-uk Kim         break;
341efcc2a30SJung-uk Kim 
342efcc2a30SJung-uk Kim     case PARSEOP_METHODCALL:
343efcc2a30SJung-uk Kim 
34467d9aa44SJung-uk Kim         /* Check for a recursive method call */
34567d9aa44SJung-uk Kim 
346efcc2a30SJung-uk Kim         if (MethodInfo &&
347efcc2a30SJung-uk Kim            (Op->Asl.Node == MethodInfo->Op->Asl.Node))
348efcc2a30SJung-uk Kim         {
34967d9aa44SJung-uk Kim             if (MethodInfo->CreatesNamedObjects)
35067d9aa44SJung-uk Kim             {
35167d9aa44SJung-uk Kim                 /*
35267d9aa44SJung-uk Kim                  * This is an error, as it will fail at runtime on all ACPI
35367d9aa44SJung-uk Kim                  * implementations. Any named object declarations will be
35467d9aa44SJung-uk Kim                  * executed twice, causing failure the second time. Note,
35567d9aa44SJung-uk Kim                  * this is independent of whether the method is declared
35667d9aa44SJung-uk Kim                  * Serialized, because the same thread is attempting to
35767d9aa44SJung-uk Kim                  * reenter the method, and this will always succeed.
35867d9aa44SJung-uk Kim                  */
35967d9aa44SJung-uk Kim                 AslDualParseOpError (ASL_ERROR, ASL_MSG_ILLEGAL_RECURSION, Op,
36067d9aa44SJung-uk Kim                     Op->Asl.Value.String, ASL_MSG_FOUND_HERE, MethodInfo->Op,
36167d9aa44SJung-uk Kim                     MethodInfo->Op->Asl.ExternalName);
36267d9aa44SJung-uk Kim             }
36367d9aa44SJung-uk Kim             else
36467d9aa44SJung-uk Kim             {
36567d9aa44SJung-uk Kim                 /* Method does not create objects, issue a remark */
36667d9aa44SJung-uk Kim 
367efcc2a30SJung-uk Kim                 AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
368efcc2a30SJung-uk Kim             }
36967d9aa44SJung-uk Kim         }
370efcc2a30SJung-uk Kim         break;
371efcc2a30SJung-uk Kim 
372efcc2a30SJung-uk Kim     case PARSEOP_LOCAL0:
373efcc2a30SJung-uk Kim     case PARSEOP_LOCAL1:
374efcc2a30SJung-uk Kim     case PARSEOP_LOCAL2:
375efcc2a30SJung-uk Kim     case PARSEOP_LOCAL3:
376efcc2a30SJung-uk Kim     case PARSEOP_LOCAL4:
377efcc2a30SJung-uk Kim     case PARSEOP_LOCAL5:
378efcc2a30SJung-uk Kim     case PARSEOP_LOCAL6:
379efcc2a30SJung-uk Kim     case PARSEOP_LOCAL7:
380efcc2a30SJung-uk Kim 
381efcc2a30SJung-uk Kim         if (!MethodInfo)
382efcc2a30SJung-uk Kim         {
383efcc2a30SJung-uk Kim             /*
384efcc2a30SJung-uk Kim              * Local was used outside a control method, or there was an error
385efcc2a30SJung-uk Kim              * in the method declaration.
386efcc2a30SJung-uk Kim              */
387f8146b88SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
388f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
389efcc2a30SJung-uk Kim             return (AE_ERROR);
390efcc2a30SJung-uk Kim         }
391efcc2a30SJung-uk Kim 
392fe0f0bbbSJung-uk Kim         RegisterNumber = (Op->Asl.AmlOpcode & 0x0007);
393efcc2a30SJung-uk Kim 
394efcc2a30SJung-uk Kim         /*
395efcc2a30SJung-uk Kim          * If the local is being used as a target, mark the local
396efcc2a30SJung-uk Kim          * initialized
397efcc2a30SJung-uk Kim          */
3985f9b24faSJung-uk Kim         if (Op->Asl.CompileFlags & OP_IS_TARGET)
399efcc2a30SJung-uk Kim         {
400efcc2a30SJung-uk Kim             MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
401efcc2a30SJung-uk Kim         }
402efcc2a30SJung-uk Kim 
403efcc2a30SJung-uk Kim         /*
404efcc2a30SJung-uk Kim          * Otherwise, this is a reference, check if the local
405efcc2a30SJung-uk Kim          * has been previously initialized.
406efcc2a30SJung-uk Kim          *
407efcc2a30SJung-uk Kim          * The only operator that accepts an uninitialized value is ObjectType()
408efcc2a30SJung-uk Kim          */
409efcc2a30SJung-uk Kim         else if ((!MethodInfo->LocalInitialized[RegisterNumber]) &&
410efcc2a30SJung-uk Kim                  (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
411efcc2a30SJung-uk Kim         {
412efcc2a30SJung-uk Kim             LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
413efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
414efcc2a30SJung-uk Kim         }
415efcc2a30SJung-uk Kim         break;
416efcc2a30SJung-uk Kim 
417efcc2a30SJung-uk Kim     case PARSEOP_ARG0:
418efcc2a30SJung-uk Kim     case PARSEOP_ARG1:
419efcc2a30SJung-uk Kim     case PARSEOP_ARG2:
420efcc2a30SJung-uk Kim     case PARSEOP_ARG3:
421efcc2a30SJung-uk Kim     case PARSEOP_ARG4:
422efcc2a30SJung-uk Kim     case PARSEOP_ARG5:
423efcc2a30SJung-uk Kim     case PARSEOP_ARG6:
424efcc2a30SJung-uk Kim 
425efcc2a30SJung-uk Kim         if (!MethodInfo)
426efcc2a30SJung-uk Kim         {
427efcc2a30SJung-uk Kim             /*
428efcc2a30SJung-uk Kim              * Arg was used outside a control method, or there was an error
429efcc2a30SJung-uk Kim              * in the method declaration.
430efcc2a30SJung-uk Kim              */
431f8146b88SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
432f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
433efcc2a30SJung-uk Kim             return (AE_ERROR);
434efcc2a30SJung-uk Kim         }
435efcc2a30SJung-uk Kim 
436efcc2a30SJung-uk Kim         RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
437efcc2a30SJung-uk Kim         ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
438efcc2a30SJung-uk Kim 
439efcc2a30SJung-uk Kim         /*
440efcc2a30SJung-uk Kim          * If the Arg is being used as a target, mark the local
441efcc2a30SJung-uk Kim          * initialized
442efcc2a30SJung-uk Kim          */
4435f9b24faSJung-uk Kim         if (Op->Asl.CompileFlags & OP_IS_TARGET)
444efcc2a30SJung-uk Kim         {
445efcc2a30SJung-uk Kim             MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
446efcc2a30SJung-uk Kim         }
447efcc2a30SJung-uk Kim 
448efcc2a30SJung-uk Kim         /*
449efcc2a30SJung-uk Kim          * Otherwise, this is a reference, check if the Arg
450efcc2a30SJung-uk Kim          * has been previously initialized.
451efcc2a30SJung-uk Kim          *
452efcc2a30SJung-uk Kim          * The only operator that accepts an uninitialized value is ObjectType()
453efcc2a30SJung-uk Kim          */
454efcc2a30SJung-uk Kim         else if ((!MethodInfo->ArgInitialized[RegisterNumber]) &&
455efcc2a30SJung-uk Kim             (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
456efcc2a30SJung-uk Kim         {
457efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
458efcc2a30SJung-uk Kim         }
459efcc2a30SJung-uk Kim 
460efcc2a30SJung-uk Kim         /* Flag this arg if it is not a "real" argument to the method */
461efcc2a30SJung-uk Kim 
462efcc2a30SJung-uk Kim         if (RegisterNumber >= MethodInfo->NumArguments)
463efcc2a30SJung-uk Kim         {
464efcc2a30SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
465efcc2a30SJung-uk Kim         }
466efcc2a30SJung-uk Kim         break;
467efcc2a30SJung-uk Kim 
468efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
469efcc2a30SJung-uk Kim 
470efcc2a30SJung-uk Kim         if (!MethodInfo)
471efcc2a30SJung-uk Kim         {
472efcc2a30SJung-uk Kim             /*
473efcc2a30SJung-uk Kim              * Probably was an error in the method declaration,
474efcc2a30SJung-uk Kim              * no additional error here
475efcc2a30SJung-uk Kim              */
476efcc2a30SJung-uk Kim             ACPI_WARNING ((AE_INFO, "%p, No parent method", Op));
477efcc2a30SJung-uk Kim             return (AE_ERROR);
478efcc2a30SJung-uk Kim         }
479efcc2a30SJung-uk Kim 
480efcc2a30SJung-uk Kim         /*
481efcc2a30SJung-uk Kim          * A child indicates a possible return value. A simple Return or
4825f9b24faSJung-uk Kim          * Return() is marked with OP_IS_NULL_RETURN by the parser so
483efcc2a30SJung-uk Kim          * that it is not counted as a "real" return-with-value, although
484efcc2a30SJung-uk Kim          * the AML code that is actually emitted is Return(0). The AML
485efcc2a30SJung-uk Kim          * definition of Return has a required parameter, so we are
486efcc2a30SJung-uk Kim          * forced to convert a null return to Return(0).
487efcc2a30SJung-uk Kim          */
488efcc2a30SJung-uk Kim         if ((Op->Asl.Child) &&
489efcc2a30SJung-uk Kim             (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
4905f9b24faSJung-uk Kim             (!(Op->Asl.Child->Asl.CompileFlags & OP_IS_NULL_RETURN)))
491efcc2a30SJung-uk Kim         {
492efcc2a30SJung-uk Kim             MethodInfo->NumReturnWithValue++;
493efcc2a30SJung-uk Kim         }
494efcc2a30SJung-uk Kim         else
495efcc2a30SJung-uk Kim         {
496efcc2a30SJung-uk Kim             MethodInfo->NumReturnNoValue++;
497efcc2a30SJung-uk Kim         }
498efcc2a30SJung-uk Kim         break;
499efcc2a30SJung-uk Kim 
500efcc2a30SJung-uk Kim     case PARSEOP_BREAK:
501efcc2a30SJung-uk Kim     case PARSEOP_CONTINUE:
502efcc2a30SJung-uk Kim 
503efcc2a30SJung-uk Kim         Next = Op->Asl.Parent;
504efcc2a30SJung-uk Kim         while (Next)
505efcc2a30SJung-uk Kim         {
506efcc2a30SJung-uk Kim             if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
507efcc2a30SJung-uk Kim             {
508efcc2a30SJung-uk Kim                 break;
509efcc2a30SJung-uk Kim             }
510efcc2a30SJung-uk Kim             Next = Next->Asl.Parent;
511efcc2a30SJung-uk Kim         }
512efcc2a30SJung-uk Kim 
513efcc2a30SJung-uk Kim         if (!Next)
514efcc2a30SJung-uk Kim         {
515efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
516efcc2a30SJung-uk Kim         }
517efcc2a30SJung-uk Kim         break;
518efcc2a30SJung-uk Kim 
519efcc2a30SJung-uk Kim     case PARSEOP_STALL:
520efcc2a30SJung-uk Kim 
521efcc2a30SJung-uk Kim         /* We can range check if the argument is an integer */
522efcc2a30SJung-uk Kim 
523efcc2a30SJung-uk Kim         if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
524efcc2a30SJung-uk Kim             (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
525efcc2a30SJung-uk Kim         {
526efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
527efcc2a30SJung-uk Kim         }
528efcc2a30SJung-uk Kim         break;
529efcc2a30SJung-uk Kim 
530efcc2a30SJung-uk Kim     case PARSEOP_DEVICE:
531313a0c13SJung-uk Kim 
532a009b7dcSJung-uk Kim         /* Check usage of _HID and _ADR objects */
533a009b7dcSJung-uk Kim 
534a009b7dcSJung-uk Kim         HidExists = ApFindNameInDeviceTree (METHOD_NAME__HID, Op);
535a009b7dcSJung-uk Kim         AdrExists = ApFindNameInDeviceTree (METHOD_NAME__ADR, Op);
536a009b7dcSJung-uk Kim 
537a009b7dcSJung-uk Kim         if (!HidExists && !AdrExists)
538313a0c13SJung-uk Kim         {
539313a0c13SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
540313a0c13SJung-uk Kim                 "Device object requires a _HID or _ADR in same scope");
541313a0c13SJung-uk Kim         }
542a009b7dcSJung-uk Kim         else if (HidExists && AdrExists)
543a009b7dcSJung-uk Kim         {
544a009b7dcSJung-uk Kim             /*
545a009b7dcSJung-uk Kim              * According to the ACPI spec, "A device object must contain
546a009b7dcSJung-uk Kim              * either an _HID object or an _ADR object, but should not contain
547a009b7dcSJung-uk Kim              * both".
548a009b7dcSJung-uk Kim              */
549a009b7dcSJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_MULTIPLE_TYPES, Op,
550a009b7dcSJung-uk Kim                 "Device object requires either a _HID or _ADR, but not both");
551a009b7dcSJung-uk Kim         }
552313a0c13SJung-uk Kim         break;
553313a0c13SJung-uk Kim 
554efcc2a30SJung-uk Kim     case PARSEOP_EVENT:
555efcc2a30SJung-uk Kim     case PARSEOP_MUTEX:
556efcc2a30SJung-uk Kim     case PARSEOP_OPERATIONREGION:
557efcc2a30SJung-uk Kim     case PARSEOP_POWERRESOURCE:
558efcc2a30SJung-uk Kim     case PARSEOP_PROCESSOR:
559efcc2a30SJung-uk Kim     case PARSEOP_THERMALZONE:
560efcc2a30SJung-uk Kim 
561efcc2a30SJung-uk Kim         /*
562efcc2a30SJung-uk Kim          * The first operand is a name to be created in the namespace.
563efcc2a30SJung-uk Kim          * Check against the reserved list.
564efcc2a30SJung-uk Kim          */
565efcc2a30SJung-uk Kim         i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
566efcc2a30SJung-uk Kim         if (i < ACPI_VALID_RESERVED_NAME_MAX)
567efcc2a30SJung-uk Kim         {
568f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_RESERVED_USE,
569f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
570efcc2a30SJung-uk Kim         }
571ec0234b4SJung-uk Kim 
572ec0234b4SJung-uk Kim         MtCheckStaticOperationRegionInMethod (Op);
573efcc2a30SJung-uk Kim         break;
574efcc2a30SJung-uk Kim 
575efcc2a30SJung-uk Kim     case PARSEOP_NAME:
576efcc2a30SJung-uk Kim 
577efcc2a30SJung-uk Kim         /* Typecheck any predefined names statically defined with Name() */
578efcc2a30SJung-uk Kim 
579efcc2a30SJung-uk Kim         ApCheckForPredefinedObject (Op, Op->Asl.NameSeg);
580efcc2a30SJung-uk Kim 
581efcc2a30SJung-uk Kim         /* Special typechecking for _HID */
582efcc2a30SJung-uk Kim 
583f9a6772eSJung-uk Kim         if (ACPI_COMPARE_NAMESEG (METHOD_NAME__HID, Op->Asl.NameSeg))
584efcc2a30SJung-uk Kim         {
585efcc2a30SJung-uk Kim             Next = Op->Asl.Child->Asl.Next;
586efcc2a30SJung-uk Kim             AnCheckId (Next, ASL_TYPE_HID);
587efcc2a30SJung-uk Kim         }
588efcc2a30SJung-uk Kim 
589efcc2a30SJung-uk Kim         /* Special typechecking for _CID */
590efcc2a30SJung-uk Kim 
591f9a6772eSJung-uk Kim         else if (ACPI_COMPARE_NAMESEG (METHOD_NAME__CID, Op->Asl.NameSeg))
592efcc2a30SJung-uk Kim         {
593efcc2a30SJung-uk Kim             Next = Op->Asl.Child->Asl.Next;
594efcc2a30SJung-uk Kim 
595efcc2a30SJung-uk Kim             if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
596efcc2a30SJung-uk Kim                 (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
597efcc2a30SJung-uk Kim             {
598efcc2a30SJung-uk Kim                 Next = Next->Asl.Child;
599efcc2a30SJung-uk Kim                 while (Next)
600efcc2a30SJung-uk Kim                 {
601efcc2a30SJung-uk Kim                     AnCheckId (Next, ASL_TYPE_CID);
602efcc2a30SJung-uk Kim                     Next = Next->Asl.Next;
603efcc2a30SJung-uk Kim                 }
604efcc2a30SJung-uk Kim             }
605efcc2a30SJung-uk Kim             else
606efcc2a30SJung-uk Kim             {
607efcc2a30SJung-uk Kim                 AnCheckId (Next, ASL_TYPE_CID);
608efcc2a30SJung-uk Kim             }
609efcc2a30SJung-uk Kim         }
610313a0c13SJung-uk Kim 
611efcc2a30SJung-uk Kim         break;
612efcc2a30SJung-uk Kim 
613efcc2a30SJung-uk Kim     default:
614a9d8d09cSJung-uk Kim 
615efcc2a30SJung-uk Kim         break;
616efcc2a30SJung-uk Kim     }
617efcc2a30SJung-uk Kim 
618a9d8d09cSJung-uk Kim     /* Check for named object creation within a non-serialized method */
619a9d8d09cSJung-uk Kim 
620a9d8d09cSJung-uk Kim     MtCheckNamedObjectInMethod (Op, MethodInfo);
621efcc2a30SJung-uk Kim     return (AE_OK);
622efcc2a30SJung-uk Kim }
623efcc2a30SJung-uk Kim 
624efcc2a30SJung-uk Kim 
625efcc2a30SJung-uk Kim /*******************************************************************************
626efcc2a30SJung-uk Kim  *
627ec0234b4SJung-uk Kim  * FUNCTION:    MtProcessTypeOp
628ec0234b4SJung-uk Kim  *
629ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Op representing a btype
630ec0234b4SJung-uk Kim  *
631ec0234b4SJung-uk Kim  * RETURN:      Btype represented by Op
632ec0234b4SJung-uk Kim  *
633ec0234b4SJung-uk Kim  * DESCRIPTION: Process a parse object that represents single parameter type or
634ec0234b4SJung-uk Kim  *              a return type in method, function, and external declarations.
635ec0234b4SJung-uk Kim  *
636ec0234b4SJung-uk Kim  ******************************************************************************/
637ec0234b4SJung-uk Kim 
638ec0234b4SJung-uk Kim UINT32
639ec0234b4SJung-uk Kim MtProcessTypeOp (
640ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT       *TypeOp)
641ec0234b4SJung-uk Kim {
642ec0234b4SJung-uk Kim     UINT32                  Btype = ACPI_BTYPE_ANY;
643ec0234b4SJung-uk Kim 
644ec0234b4SJung-uk Kim 
645ec0234b4SJung-uk Kim     while (TypeOp)
646ec0234b4SJung-uk Kim     {
647ec0234b4SJung-uk Kim         Btype |= AnMapObjTypeToBtype (TypeOp);
648ec0234b4SJung-uk Kim         TypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
649ec0234b4SJung-uk Kim         TypeOp = TypeOp->Asl.Next;
650ec0234b4SJung-uk Kim     }
651ec0234b4SJung-uk Kim 
652ec0234b4SJung-uk Kim     return (Btype);
653ec0234b4SJung-uk Kim }
654ec0234b4SJung-uk Kim 
655ec0234b4SJung-uk Kim 
656ec0234b4SJung-uk Kim /*******************************************************************************
657ec0234b4SJung-uk Kim  *
658ec0234b4SJung-uk Kim  * FUNCTION:    MtProcessParameterTypeList
659ec0234b4SJung-uk Kim  *
660ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Op representing a btype
661ec0234b4SJung-uk Kim  *
662ec0234b4SJung-uk Kim  * RETURN:      Btype represented by Op
663ec0234b4SJung-uk Kim  *
664ec0234b4SJung-uk Kim  * DESCRIPTION: Process a parse object that represents a parameter type list in
665ec0234b4SJung-uk Kim  *              method, function, and external declarations.
666ec0234b4SJung-uk Kim  *
667ec0234b4SJung-uk Kim  ******************************************************************************/
668ec0234b4SJung-uk Kim 
669ec0234b4SJung-uk Kim UINT8
670ec0234b4SJung-uk Kim MtProcessParameterTypeList (
671ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT       *ParamTypeOp,
672ec0234b4SJung-uk Kim     UINT32                  *TypeList)
673ec0234b4SJung-uk Kim {
674ec0234b4SJung-uk Kim     UINT8                   ParameterCount = 0;
675ec0234b4SJung-uk Kim 
676ec0234b4SJung-uk Kim 
67761b18036SJung-uk Kim     if (ParamTypeOp && ParamTypeOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
67861b18036SJung-uk Kim     {
67961b18036SJung-uk Kim         /* Special case for a single parameter without braces */
68061b18036SJung-uk Kim 
68161b18036SJung-uk Kim         TypeList[ParameterCount] =
68261b18036SJung-uk Kim             MtProcessTypeOp (ParamTypeOp);
68361b18036SJung-uk Kim 
68461b18036SJung-uk Kim         return (1);
68561b18036SJung-uk Kim     }
68661b18036SJung-uk Kim 
687ec0234b4SJung-uk Kim     while (ParamTypeOp)
688ec0234b4SJung-uk Kim     {
689ec0234b4SJung-uk Kim         TypeList[ParameterCount] =
690ec0234b4SJung-uk Kim             MtProcessTypeOp (ParamTypeOp->Asl.Child);
691ec0234b4SJung-uk Kim 
692ec0234b4SJung-uk Kim         ParameterCount++;
693ec0234b4SJung-uk Kim         ParamTypeOp = ParamTypeOp->Asl.Next;
694ec0234b4SJung-uk Kim     }
695ec0234b4SJung-uk Kim 
696ec0234b4SJung-uk Kim     return (ParameterCount);
697ec0234b4SJung-uk Kim }
698ec0234b4SJung-uk Kim 
699ec0234b4SJung-uk Kim 
700ec0234b4SJung-uk Kim /*******************************************************************************
701ec0234b4SJung-uk Kim  *
702a9d8d09cSJung-uk Kim  * FUNCTION:    MtCheckNamedObjectInMethod
703a9d8d09cSJung-uk Kim  *
704a9d8d09cSJung-uk Kim  * PARAMETERS:  Op                  - Current parser op
705a9d8d09cSJung-uk Kim  *              MethodInfo          - Info for method being parsed
706a9d8d09cSJung-uk Kim  *
707a9d8d09cSJung-uk Kim  * RETURN:      None
708a9d8d09cSJung-uk Kim  *
709a9d8d09cSJung-uk Kim  * DESCRIPTION: Detect if a non-serialized method is creating a named object,
710a9d8d09cSJung-uk Kim  *              which could possibly cause problems if two threads execute
711a9d8d09cSJung-uk Kim  *              the method concurrently. Emit a remark in this case.
712a9d8d09cSJung-uk Kim  *
713a9d8d09cSJung-uk Kim  ******************************************************************************/
714a9d8d09cSJung-uk Kim 
715f8146b88SJung-uk Kim static void
716a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod (
717a9d8d09cSJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
718a9d8d09cSJung-uk Kim     ASL_METHOD_INFO         *MethodInfo)
719a9d8d09cSJung-uk Kim {
720a9d8d09cSJung-uk Kim     const ACPI_OPCODE_INFO  *OpInfo;
721ec0234b4SJung-uk Kim     char                    *ExternalPath;
722a9d8d09cSJung-uk Kim 
723a9d8d09cSJung-uk Kim 
724f8146b88SJung-uk Kim     /* We don't care about actual method declarations or scopes */
725a9d8d09cSJung-uk Kim 
726f8146b88SJung-uk Kim     if ((Op->Asl.AmlOpcode == AML_METHOD_OP) ||
727f8146b88SJung-uk Kim         (Op->Asl.AmlOpcode == AML_SCOPE_OP))
728a9d8d09cSJung-uk Kim     {
729a9d8d09cSJung-uk Kim         return;
730a9d8d09cSJung-uk Kim     }
731a9d8d09cSJung-uk Kim 
73267d9aa44SJung-uk Kim     /* Determine if we are creating a named object within a method */
73367d9aa44SJung-uk Kim 
73467d9aa44SJung-uk Kim     if (!MethodInfo)
73567d9aa44SJung-uk Kim     {
73667d9aa44SJung-uk Kim         return;
73767d9aa44SJung-uk Kim     }
738a9d8d09cSJung-uk Kim 
739a9d8d09cSJung-uk Kim     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
7400b229c80SJung-uk Kim     if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_FIELD_OP))
741a9d8d09cSJung-uk Kim     {
742a9d8d09cSJung-uk Kim         /*
74367d9aa44SJung-uk Kim          * 1) Mark the method as a method that creates named objects.
74467d9aa44SJung-uk Kim          *
745ec0234b4SJung-uk Kim          * 2) Issue a remark indicating the inefficiency of creating named
746ec0234b4SJung-uk Kim          * objects within a method (Except for compiler-emitted temporary
747ec0234b4SJung-uk Kim          * variables).
748ec0234b4SJung-uk Kim          *
749ec0234b4SJung-uk Kim          * 3) If the method is non-serialized, emit a remark that the method
75067d9aa44SJung-uk Kim          * should be serialized.
751a9d8d09cSJung-uk Kim          *
752a9d8d09cSJung-uk Kim          * Reason: If a thread blocks within the method for any reason, and
75367d9aa44SJung-uk Kim          * another thread enters the method, the method will fail because
75467d9aa44SJung-uk Kim          * an attempt will be made to create the same object twice.
7550b229c80SJung-uk Kim          *
7560b229c80SJung-uk Kim          * Note: The Field opcode is disallowed here because Field() does not
7570b229c80SJung-uk Kim          * create a new named object.
758a9d8d09cSJung-uk Kim          */
759ec0234b4SJung-uk Kim         ExternalPath = AcpiNsGetNormalizedPathname (MethodInfo->Op->Asl.Node, TRUE);
760ec0234b4SJung-uk Kim 
761ec0234b4SJung-uk Kim         /* No error for compiler temp variables (name starts with "_T_") */
762ec0234b4SJung-uk Kim 
763ec0234b4SJung-uk Kim         if ((Op->Asl.NameSeg[0] != '_') &&
764ec0234b4SJung-uk Kim             (Op->Asl.NameSeg[1] != 'T') &&
765ec0234b4SJung-uk Kim             (Op->Asl.NameSeg[2] != '_'))
766ec0234b4SJung-uk Kim         {
767ec0234b4SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_NAMED_OBJECT_CREATION, Op,
768ec0234b4SJung-uk Kim                 ExternalPath);
769ec0234b4SJung-uk Kim         }
770ec0234b4SJung-uk Kim 
77167d9aa44SJung-uk Kim         MethodInfo->CreatesNamedObjects = TRUE;
77267d9aa44SJung-uk Kim         if (!MethodInfo->ShouldBeSerialized)
773a9d8d09cSJung-uk Kim         {
774a9d8d09cSJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op,
775ec0234b4SJung-uk Kim                 ExternalPath);
776a9d8d09cSJung-uk Kim 
777a9d8d09cSJung-uk Kim             /* Emit message only ONCE per method */
778a9d8d09cSJung-uk Kim 
779a9d8d09cSJung-uk Kim             MethodInfo->ShouldBeSerialized = TRUE;
780a9d8d09cSJung-uk Kim         }
781ec0234b4SJung-uk Kim 
782ec0234b4SJung-uk Kim         if (ExternalPath)
783ec0234b4SJung-uk Kim         {
784ec0234b4SJung-uk Kim             ACPI_FREE (ExternalPath);
785a9d8d09cSJung-uk Kim         }
786a9d8d09cSJung-uk Kim     }
787ec0234b4SJung-uk Kim }
788ec0234b4SJung-uk Kim 
789ec0234b4SJung-uk Kim 
790ec0234b4SJung-uk Kim /*******************************************************************************
791ec0234b4SJung-uk Kim  *
792ec0234b4SJung-uk Kim  * FUNCTION:    MtCheckStaticOperationRegionInMethod
793ec0234b4SJung-uk Kim  *
794ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Current parser op
795ec0234b4SJung-uk Kim  *
796ec0234b4SJung-uk Kim  * RETURN:      None
797ec0234b4SJung-uk Kim  *
798ec0234b4SJung-uk Kim  * DESCRIPTION: Warns if an Operation Region with static address or length
799ec0234b4SJung-uk Kim  *              is declared inside a control method
800ec0234b4SJung-uk Kim  *
801ec0234b4SJung-uk Kim  ******************************************************************************/
802ec0234b4SJung-uk Kim 
803ec0234b4SJung-uk Kim static void
804ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod(
805ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       Op)
806ec0234b4SJung-uk Kim {
807ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       AddressOp;
808ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       LengthOp;
809ec0234b4SJung-uk Kim 
810ec0234b4SJung-uk Kim 
811ec0234b4SJung-uk Kim     if (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION)
812ec0234b4SJung-uk Kim     {
813ec0234b4SJung-uk Kim         return;
814ec0234b4SJung-uk Kim     }
815ec0234b4SJung-uk Kim 
816ec0234b4SJung-uk Kim     /*
817ec0234b4SJung-uk Kim      * OperationRegion should have 4 arguments defined. At this point, we
818ec0234b4SJung-uk Kim      * assume that the parse tree is well-formed.
819ec0234b4SJung-uk Kim      */
820ec0234b4SJung-uk Kim     AddressOp = Op->Asl.Child->Asl.Next->Asl.Next;
821ec0234b4SJung-uk Kim     LengthOp = Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next;
822ec0234b4SJung-uk Kim 
823ec0234b4SJung-uk Kim     if (UtGetParentMethodOp (Op) &&
824ec0234b4SJung-uk Kim         AddressOp->Asl.ParseOpcode == PARSEOP_INTEGER &&
825ec0234b4SJung-uk Kim         LengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)
826ec0234b4SJung-uk Kim     {
827ec0234b4SJung-uk Kim         /*
828ec0234b4SJung-uk Kim          * At this point, a static operation region declared inside of a
829ec0234b4SJung-uk Kim          * control method has been found. Throw a warning because this is
830ec0234b4SJung-uk Kim          * highly inefficient.
831ec0234b4SJung-uk Kim          */
832ec0234b4SJung-uk Kim         AslError(ASL_WARNING, ASL_MSG_STATIC_OPREGION_IN_METHOD, Op, NULL);
833ec0234b4SJung-uk Kim     }
834ec0234b4SJung-uk Kim 
835ec0234b4SJung-uk Kim     return;
836ec0234b4SJung-uk Kim }
837a9d8d09cSJung-uk Kim 
838a9d8d09cSJung-uk Kim 
839a9d8d09cSJung-uk Kim /*******************************************************************************
840a9d8d09cSJung-uk Kim  *
841efcc2a30SJung-uk Kim  * FUNCTION:    MtMethodAnalysisWalkEnd
842efcc2a30SJung-uk Kim  *
843efcc2a30SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
844efcc2a30SJung-uk Kim  *
845efcc2a30SJung-uk Kim  * RETURN:      Status
846efcc2a30SJung-uk Kim  *
847efcc2a30SJung-uk Kim  * DESCRIPTION: Ascending callback for analysis walk. Complete method
848efcc2a30SJung-uk Kim  *              return analysis.
849efcc2a30SJung-uk Kim  *
850efcc2a30SJung-uk Kim  ******************************************************************************/
851efcc2a30SJung-uk Kim 
852efcc2a30SJung-uk Kim ACPI_STATUS
853efcc2a30SJung-uk Kim MtMethodAnalysisWalkEnd (
854efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
855efcc2a30SJung-uk Kim     UINT32                  Level,
856efcc2a30SJung-uk Kim     void                    *Context)
857efcc2a30SJung-uk Kim {
858efcc2a30SJung-uk Kim     ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
859efcc2a30SJung-uk Kim     ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;
860ec0234b4SJung-uk Kim     char                    *ExternalPath;
861efcc2a30SJung-uk Kim 
862efcc2a30SJung-uk Kim 
863efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
864efcc2a30SJung-uk Kim     {
865efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
866efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
867a9d8d09cSJung-uk Kim 
868efcc2a30SJung-uk Kim         if (!MethodInfo)
869efcc2a30SJung-uk Kim         {
870efcc2a30SJung-uk Kim             printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
871efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
872efcc2a30SJung-uk Kim                 "No method info for this method");
873efcc2a30SJung-uk Kim 
874efcc2a30SJung-uk Kim             CmCleanupAndExit ();
875efcc2a30SJung-uk Kim             return (AE_AML_INTERNAL);
876efcc2a30SJung-uk Kim         }
877efcc2a30SJung-uk Kim         break;
878efcc2a30SJung-uk Kim 
879efcc2a30SJung-uk Kim     default:
880a9d8d09cSJung-uk Kim 
881efcc2a30SJung-uk Kim         break;
882efcc2a30SJung-uk Kim     }
883efcc2a30SJung-uk Kim 
884efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
885efcc2a30SJung-uk Kim     {
886efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
887efcc2a30SJung-uk Kim 
888efcc2a30SJung-uk Kim         WalkInfo->MethodStack = MethodInfo->Next;
889efcc2a30SJung-uk Kim 
890efcc2a30SJung-uk Kim         /*
891efcc2a30SJung-uk Kim          * Check if there is no return statement at the end of the
892efcc2a30SJung-uk Kim          * method AND we can actually get there -- i.e., the execution
893efcc2a30SJung-uk Kim          * of the method can possibly terminate without a return statement.
894efcc2a30SJung-uk Kim          */
895efcc2a30SJung-uk Kim         if ((!AnLastStatementIsReturn (Op)) &&
8965f9b24faSJung-uk Kim             (!(Op->Asl.CompileFlags & OP_HAS_NO_EXIT)))
897efcc2a30SJung-uk Kim         {
898efcc2a30SJung-uk Kim             /*
899efcc2a30SJung-uk Kim              * No return statement, and execution can possibly exit
900efcc2a30SJung-uk Kim              * via this path. This is equivalent to Return ()
901efcc2a30SJung-uk Kim              */
902efcc2a30SJung-uk Kim             MethodInfo->NumReturnNoValue++;
903efcc2a30SJung-uk Kim         }
904efcc2a30SJung-uk Kim 
905efcc2a30SJung-uk Kim         /*
906efcc2a30SJung-uk Kim          * Check for case where some return statements have a return value
907efcc2a30SJung-uk Kim          * and some do not. Exit without a return statement is a return with
908efcc2a30SJung-uk Kim          * no value
909efcc2a30SJung-uk Kim          */
910efcc2a30SJung-uk Kim         if (MethodInfo->NumReturnNoValue &&
911efcc2a30SJung-uk Kim             MethodInfo->NumReturnWithValue)
912efcc2a30SJung-uk Kim         {
913ec0234b4SJung-uk Kim             ExternalPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE);
914ec0234b4SJung-uk Kim 
915efcc2a30SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
916ec0234b4SJung-uk Kim                 ExternalPath);
917ec0234b4SJung-uk Kim 
918ec0234b4SJung-uk Kim             if (ExternalPath)
919ec0234b4SJung-uk Kim             {
920ec0234b4SJung-uk Kim                 ACPI_FREE (ExternalPath);
921ec0234b4SJung-uk Kim             }
922efcc2a30SJung-uk Kim         }
923efcc2a30SJung-uk Kim 
924efcc2a30SJung-uk Kim         /*
925efcc2a30SJung-uk Kim          * If there are any RETURN() statements with no value, or there is a
926efcc2a30SJung-uk Kim          * control path that allows the method to exit without a return value,
927efcc2a30SJung-uk Kim          * we mark the method as a method that does not return a value. This
928efcc2a30SJung-uk Kim          * knowledge can be used to check method invocations that expect a
929efcc2a30SJung-uk Kim          * returned value.
930efcc2a30SJung-uk Kim          */
931efcc2a30SJung-uk Kim         if (MethodInfo->NumReturnNoValue)
932efcc2a30SJung-uk Kim         {
933efcc2a30SJung-uk Kim             if (MethodInfo->NumReturnWithValue)
934efcc2a30SJung-uk Kim             {
9355f9b24faSJung-uk Kim                 Op->Asl.CompileFlags |= OP_METHOD_SOME_NO_RETVAL;
936efcc2a30SJung-uk Kim             }
937efcc2a30SJung-uk Kim             else
938efcc2a30SJung-uk Kim             {
9395f9b24faSJung-uk Kim                 Op->Asl.CompileFlags |= OP_METHOD_NO_RETVAL;
940efcc2a30SJung-uk Kim             }
941efcc2a30SJung-uk Kim         }
942efcc2a30SJung-uk Kim 
943efcc2a30SJung-uk Kim         /*
944efcc2a30SJung-uk Kim          * Check predefined method names for correct return behavior
945efcc2a30SJung-uk Kim          * and correct number of arguments. Also, some special checks
946efcc2a30SJung-uk Kim          * For GPE and _REG methods.
947efcc2a30SJung-uk Kim          */
948efcc2a30SJung-uk Kim         if (ApCheckForPredefinedMethod (Op, MethodInfo))
949efcc2a30SJung-uk Kim         {
950efcc2a30SJung-uk Kim             /* Special check for two names like _L01 and _E01 in same scope */
951efcc2a30SJung-uk Kim 
952efcc2a30SJung-uk Kim             ApCheckForGpeNameConflict (Op);
953efcc2a30SJung-uk Kim 
954efcc2a30SJung-uk Kim             /*
955efcc2a30SJung-uk Kim              * Special check for _REG: Must have an operation region definition
956efcc2a30SJung-uk Kim              * within the same scope!
957efcc2a30SJung-uk Kim              */
958efcc2a30SJung-uk Kim             ApCheckRegMethod (Op);
959efcc2a30SJung-uk Kim         }
960efcc2a30SJung-uk Kim 
961efcc2a30SJung-uk Kim         ACPI_FREE (MethodInfo);
962efcc2a30SJung-uk Kim         break;
963efcc2a30SJung-uk Kim 
964efcc2a30SJung-uk Kim     case PARSEOP_NAME:
965efcc2a30SJung-uk Kim 
966efcc2a30SJung-uk Kim          /* Special check for two names like _L01 and _E01 in same scope */
967efcc2a30SJung-uk Kim 
968efcc2a30SJung-uk Kim         ApCheckForGpeNameConflict (Op);
969efcc2a30SJung-uk Kim         break;
970efcc2a30SJung-uk Kim 
971efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
972efcc2a30SJung-uk Kim 
973efcc2a30SJung-uk Kim         /*
974efcc2a30SJung-uk Kim          * If the parent is a predefined method name, attempt to typecheck
975efcc2a30SJung-uk Kim          * the return value. Only static types can be validated.
976efcc2a30SJung-uk Kim          */
977efcc2a30SJung-uk Kim         ApCheckPredefinedReturnValue (Op, MethodInfo);
978efcc2a30SJung-uk Kim 
979efcc2a30SJung-uk Kim         /*
980efcc2a30SJung-uk Kim          * The parent block does not "exit" and continue execution -- the
981efcc2a30SJung-uk Kim          * method is terminated here with the Return() statement.
982efcc2a30SJung-uk Kim          */
9835f9b24faSJung-uk Kim         Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
984efcc2a30SJung-uk Kim 
985efcc2a30SJung-uk Kim         /* Used in the "typing" pass later */
986efcc2a30SJung-uk Kim 
987efcc2a30SJung-uk Kim         Op->Asl.ParentMethod = MethodInfo->Op;
988efcc2a30SJung-uk Kim 
989efcc2a30SJung-uk Kim         /*
990efcc2a30SJung-uk Kim          * If there is a peer node after the return statement, then this
991efcc2a30SJung-uk Kim          * node is unreachable code -- i.e., it won't be executed because of
992efcc2a30SJung-uk Kim          * the preceding Return() statement.
993efcc2a30SJung-uk Kim          */
994efcc2a30SJung-uk Kim         if (Op->Asl.Next)
995efcc2a30SJung-uk Kim         {
996f8146b88SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE,
997f8146b88SJung-uk Kim                 Op->Asl.Next, NULL);
998efcc2a30SJung-uk Kim         }
999efcc2a30SJung-uk Kim         break;
1000efcc2a30SJung-uk Kim 
1001efcc2a30SJung-uk Kim     case PARSEOP_IF:
1002efcc2a30SJung-uk Kim 
10035f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
1004efcc2a30SJung-uk Kim             (Op->Asl.Next) &&
1005efcc2a30SJung-uk Kim             (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
1006efcc2a30SJung-uk Kim         {
1007efcc2a30SJung-uk Kim             /*
1008efcc2a30SJung-uk Kim              * This IF has a corresponding ELSE. The IF block has no exit,
1009efcc2a30SJung-uk Kim              * (it contains an unconditional Return)
1010efcc2a30SJung-uk Kim              * mark the ELSE block to remember this fact.
1011efcc2a30SJung-uk Kim              */
10125f9b24faSJung-uk Kim             Op->Asl.Next->Asl.CompileFlags |= OP_IF_HAS_NO_EXIT;
1013efcc2a30SJung-uk Kim         }
1014efcc2a30SJung-uk Kim         break;
1015efcc2a30SJung-uk Kim 
1016efcc2a30SJung-uk Kim     case PARSEOP_ELSE:
1017efcc2a30SJung-uk Kim 
10185f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
10195f9b24faSJung-uk Kim             (Op->Asl.CompileFlags & OP_IF_HAS_NO_EXIT))
1020efcc2a30SJung-uk Kim         {
1021efcc2a30SJung-uk Kim             /*
1022efcc2a30SJung-uk Kim              * This ELSE block has no exit and the corresponding IF block
1023efcc2a30SJung-uk Kim              * has no exit either. Therefore, the parent node has no exit.
1024efcc2a30SJung-uk Kim              */
10255f9b24faSJung-uk Kim             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
1026efcc2a30SJung-uk Kim         }
1027efcc2a30SJung-uk Kim         break;
1028efcc2a30SJung-uk Kim 
1029efcc2a30SJung-uk Kim 
1030efcc2a30SJung-uk Kim     default:
1031efcc2a30SJung-uk Kim 
10325f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
1033efcc2a30SJung-uk Kim             (Op->Asl.Parent))
1034efcc2a30SJung-uk Kim         {
1035efcc2a30SJung-uk Kim             /* If this node has no exit, then the parent has no exit either */
1036efcc2a30SJung-uk Kim 
10375f9b24faSJung-uk Kim             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
1038efcc2a30SJung-uk Kim         }
1039efcc2a30SJung-uk Kim         break;
1040efcc2a30SJung-uk Kim     }
1041efcc2a30SJung-uk Kim 
1042efcc2a30SJung-uk Kim     return (AE_OK);
1043efcc2a30SJung-uk Kim }
1044