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  *
11722b1667SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2023, 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
MtMethodAnalysisWalkBegin(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)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;
20897c0b5abSJung-uk Kim     BOOLEAN                 PrsExists;
20997c0b5abSJung-uk Kim     BOOLEAN                 CrsExists;
21097c0b5abSJung-uk Kim     BOOLEAN                 SrsExists;
21197c0b5abSJung-uk Kim     BOOLEAN                 DisExists;
212efcc2a30SJung-uk Kim 
213efcc2a30SJung-uk Kim 
214f8146b88SJung-uk Kim     /* Build cross-reference output file if requested */
215f8146b88SJung-uk Kim 
2166f1f1a63SJung-uk Kim     if (AslGbl_CrossReferenceOutput)
217f8146b88SJung-uk Kim     {
218f8146b88SJung-uk Kim         OtXrefWalkPart1 (Op, Level, MethodInfo);
219f8146b88SJung-uk Kim     }
220f8146b88SJung-uk Kim 
221efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
222efcc2a30SJung-uk Kim     {
223efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
224efcc2a30SJung-uk Kim 
2256f1f1a63SJung-uk Kim         AslGbl_TotalMethods++;
226efcc2a30SJung-uk Kim 
227efcc2a30SJung-uk Kim         /* Create and init method info */
228efcc2a30SJung-uk Kim 
229efcc2a30SJung-uk Kim         MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
230efcc2a30SJung-uk Kim         MethodInfo->Next = WalkInfo->MethodStack;
231efcc2a30SJung-uk Kim         MethodInfo->Op = Op;
232efcc2a30SJung-uk Kim 
233efcc2a30SJung-uk Kim         WalkInfo->MethodStack = MethodInfo;
234efcc2a30SJung-uk Kim 
235313a0c13SJung-uk Kim         /*
236313a0c13SJung-uk Kim          * Special handling for _PSx methods. Dependency rules (same scope):
237313a0c13SJung-uk Kim          *
238313a0c13SJung-uk Kim          * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3
239313a0c13SJung-uk Kim          * 2) _PS1/_PS2/_PS3: A _PS0 must exist
240313a0c13SJung-uk Kim          */
241278f0de6SJung-uk Kim         if (ACPI_COMPARE_NAMESEG (METHOD_NAME__PS0, Op->Asl.NameSeg))
242313a0c13SJung-uk Kim         {
243313a0c13SJung-uk Kim             /* For _PS0, one of _PS1/_PS2/_PS3 must exist */
244313a0c13SJung-uk Kim 
245313a0c13SJung-uk Kim             if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) &&
246313a0c13SJung-uk Kim                 (!ApFindNameInScope (METHOD_NAME__PS2, Op)) &&
247313a0c13SJung-uk Kim                 (!ApFindNameInScope (METHOD_NAME__PS3, Op)))
248313a0c13SJung-uk Kim             {
249313a0c13SJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
250313a0c13SJung-uk Kim                     "_PS0 requires one of _PS1/_PS2/_PS3 in same scope");
251313a0c13SJung-uk Kim             }
252313a0c13SJung-uk Kim         }
253313a0c13SJung-uk Kim         else if (
254278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS1, Op->Asl.NameSeg) ||
255278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS2, Op->Asl.NameSeg) ||
256278f0de6SJung-uk Kim             ACPI_COMPARE_NAMESEG (METHOD_NAME__PS3, Op->Asl.NameSeg))
257313a0c13SJung-uk Kim         {
258313a0c13SJung-uk Kim             /* For _PS1/_PS2/_PS3, a _PS0 must exist */
259313a0c13SJung-uk Kim 
260313a0c13SJung-uk Kim             if (!ApFindNameInScope (METHOD_NAME__PS0, Op))
261313a0c13SJung-uk Kim             {
2626f1f1a63SJung-uk Kim                 sprintf (AslGbl_MsgBuffer,
263313a0c13SJung-uk Kim                     "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg);
264313a0c13SJung-uk Kim 
265313a0c13SJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
2666f1f1a63SJung-uk Kim                     AslGbl_MsgBuffer);
267313a0c13SJung-uk Kim             }
268313a0c13SJung-uk Kim         }
269313a0c13SJung-uk Kim 
270313a0c13SJung-uk Kim         /* Get the name node */
271efcc2a30SJung-uk Kim 
272efcc2a30SJung-uk Kim         Next = Op->Asl.Child;
273efcc2a30SJung-uk Kim 
274efcc2a30SJung-uk Kim         /* Get the NumArguments node */
275efcc2a30SJung-uk Kim 
276efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
277efcc2a30SJung-uk Kim         MethodInfo->NumArguments = (UINT8)
278efcc2a30SJung-uk Kim             (((UINT8) Next->Asl.Value.Integer) & 0x07);
279efcc2a30SJung-uk Kim 
280efcc2a30SJung-uk Kim         /* Get the SerializeRule and SyncLevel nodes, ignored here */
281efcc2a30SJung-uk Kim 
282efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
283a9d8d09cSJung-uk Kim         MethodInfo->ShouldBeSerialized = (UINT8) Next->Asl.Value.Integer;
284a9d8d09cSJung-uk Kim 
285efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
286efcc2a30SJung-uk Kim         ArgNode = Next;
287efcc2a30SJung-uk Kim 
288efcc2a30SJung-uk Kim         /* Get the ReturnType node */
289efcc2a30SJung-uk Kim 
290efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
291efcc2a30SJung-uk Kim 
292efcc2a30SJung-uk Kim         NextType = Next->Asl.Child;
293efcc2a30SJung-uk Kim 
294ec0234b4SJung-uk Kim         MethodInfo->ValidReturnTypes = MtProcessTypeOp (NextType);
295385fb5d9SJung-uk Kim         Op->Asl.AcpiBtype |= MethodInfo->ValidReturnTypes;
296efcc2a30SJung-uk Kim 
297efcc2a30SJung-uk Kim         /* Get the ParameterType node */
298efcc2a30SJung-uk Kim 
299efcc2a30SJung-uk Kim         Next = Next->Asl.Next;
300efcc2a30SJung-uk Kim 
301efcc2a30SJung-uk Kim         NextType = Next->Asl.Child;
302ec0234b4SJung-uk Kim         if (!NextType)
303efcc2a30SJung-uk Kim         {
304ec0234b4SJung-uk Kim             /*
305ec0234b4SJung-uk Kim              * The optional parameter types list was omitted  at the source
306ec0234b4SJung-uk Kim              * level. Use the Argument count parameter instead.
307ec0234b4SJung-uk Kim              */
308ec0234b4SJung-uk Kim             ActualArgs = MethodInfo->NumArguments;
309efcc2a30SJung-uk Kim         }
310efcc2a30SJung-uk Kim         else
311efcc2a30SJung-uk Kim         {
312ec0234b4SJung-uk Kim             ActualArgs = MtProcessParameterTypeList (NextType,
313ec0234b4SJung-uk Kim                 MethodInfo->ValidArgTypes);
31461b18036SJung-uk Kim             MethodInfo->NumArguments = ActualArgs;
31561b18036SJung-uk Kim             ArgNode->Asl.Value.Integer |= ActualArgs;
316efcc2a30SJung-uk Kim         }
317efcc2a30SJung-uk Kim 
318efcc2a30SJung-uk Kim         if ((MethodInfo->NumArguments) &&
319efcc2a30SJung-uk Kim             (MethodInfo->NumArguments != ActualArgs))
320efcc2a30SJung-uk Kim         {
321ec0234b4SJung-uk Kim             sprintf (AslGbl_MsgBuffer,
322ec0234b4SJung-uk Kim                 "Length = %u", ActualArgs);
323ec0234b4SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_MISMATCH,
324ec0234b4SJung-uk Kim                 Op->Asl.Child->Asl.Next, AslGbl_MsgBuffer);
325efcc2a30SJung-uk Kim         }
326efcc2a30SJung-uk Kim 
327efcc2a30SJung-uk Kim         /* Allow numarguments == 0 for Function() */
328efcc2a30SJung-uk Kim 
329efcc2a30SJung-uk Kim         if ((!MethodInfo->NumArguments) && (ActualArgs))
330efcc2a30SJung-uk Kim         {
331efcc2a30SJung-uk Kim             MethodInfo->NumArguments = ActualArgs;
332efcc2a30SJung-uk Kim             ArgNode->Asl.Value.Integer |= ActualArgs;
333efcc2a30SJung-uk Kim         }
334efcc2a30SJung-uk Kim 
335efcc2a30SJung-uk Kim         /*
336efcc2a30SJung-uk Kim          * Actual arguments are initialized at method entry.
337efcc2a30SJung-uk Kim          * All other ArgX "registers" can be used as locals, so we
338efcc2a30SJung-uk Kim          * track their initialization.
339efcc2a30SJung-uk Kim          */
340efcc2a30SJung-uk Kim         for (i = 0; i < MethodInfo->NumArguments; i++)
341efcc2a30SJung-uk Kim         {
342efcc2a30SJung-uk Kim             MethodInfo->ArgInitialized[i] = TRUE;
343efcc2a30SJung-uk Kim         }
344efcc2a30SJung-uk Kim         break;
345efcc2a30SJung-uk Kim 
346efcc2a30SJung-uk Kim     case PARSEOP_METHODCALL:
347efcc2a30SJung-uk Kim 
34867d9aa44SJung-uk Kim         /* Check for a recursive method call */
34967d9aa44SJung-uk Kim 
350efcc2a30SJung-uk Kim         if (MethodInfo &&
351efcc2a30SJung-uk Kim            (Op->Asl.Node == MethodInfo->Op->Asl.Node))
352efcc2a30SJung-uk Kim         {
35367d9aa44SJung-uk Kim             if (MethodInfo->CreatesNamedObjects)
35467d9aa44SJung-uk Kim             {
35567d9aa44SJung-uk Kim                 /*
35667d9aa44SJung-uk Kim                  * This is an error, as it will fail at runtime on all ACPI
35767d9aa44SJung-uk Kim                  * implementations. Any named object declarations will be
35867d9aa44SJung-uk Kim                  * executed twice, causing failure the second time. Note,
35967d9aa44SJung-uk Kim                  * this is independent of whether the method is declared
36067d9aa44SJung-uk Kim                  * Serialized, because the same thread is attempting to
36167d9aa44SJung-uk Kim                  * reenter the method, and this will always succeed.
36267d9aa44SJung-uk Kim                  */
36367d9aa44SJung-uk Kim                 AslDualParseOpError (ASL_ERROR, ASL_MSG_ILLEGAL_RECURSION, Op,
36467d9aa44SJung-uk Kim                     Op->Asl.Value.String, ASL_MSG_FOUND_HERE, MethodInfo->Op,
36567d9aa44SJung-uk Kim                     MethodInfo->Op->Asl.ExternalName);
36667d9aa44SJung-uk Kim             }
36767d9aa44SJung-uk Kim             else
36867d9aa44SJung-uk Kim             {
36967d9aa44SJung-uk Kim                 /* Method does not create objects, issue a remark */
37067d9aa44SJung-uk Kim 
371efcc2a30SJung-uk Kim                 AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
372efcc2a30SJung-uk Kim             }
37367d9aa44SJung-uk Kim         }
374efcc2a30SJung-uk Kim         break;
375efcc2a30SJung-uk Kim 
376efcc2a30SJung-uk Kim     case PARSEOP_LOCAL0:
377efcc2a30SJung-uk Kim     case PARSEOP_LOCAL1:
378efcc2a30SJung-uk Kim     case PARSEOP_LOCAL2:
379efcc2a30SJung-uk Kim     case PARSEOP_LOCAL3:
380efcc2a30SJung-uk Kim     case PARSEOP_LOCAL4:
381efcc2a30SJung-uk Kim     case PARSEOP_LOCAL5:
382efcc2a30SJung-uk Kim     case PARSEOP_LOCAL6:
383efcc2a30SJung-uk Kim     case PARSEOP_LOCAL7:
384efcc2a30SJung-uk Kim 
385efcc2a30SJung-uk Kim         if (!MethodInfo)
386efcc2a30SJung-uk Kim         {
387efcc2a30SJung-uk Kim             /*
388efcc2a30SJung-uk Kim              * Local was used outside a control method, or there was an error
389efcc2a30SJung-uk Kim              * in the method declaration.
390efcc2a30SJung-uk Kim              */
391f8146b88SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
392f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
393efcc2a30SJung-uk Kim             return (AE_ERROR);
394efcc2a30SJung-uk Kim         }
395efcc2a30SJung-uk Kim 
396fe0f0bbbSJung-uk Kim         RegisterNumber = (Op->Asl.AmlOpcode & 0x0007);
397efcc2a30SJung-uk Kim 
398efcc2a30SJung-uk Kim         /*
399efcc2a30SJung-uk Kim          * If the local is being used as a target, mark the local
400efcc2a30SJung-uk Kim          * initialized
401efcc2a30SJung-uk Kim          */
4025f9b24faSJung-uk Kim         if (Op->Asl.CompileFlags & OP_IS_TARGET)
403efcc2a30SJung-uk Kim         {
404efcc2a30SJung-uk Kim             MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
405efcc2a30SJung-uk Kim         }
406efcc2a30SJung-uk Kim 
407efcc2a30SJung-uk Kim         /*
408efcc2a30SJung-uk Kim          * Otherwise, this is a reference, check if the local
409efcc2a30SJung-uk Kim          * has been previously initialized.
410efcc2a30SJung-uk Kim          *
411efcc2a30SJung-uk Kim          * The only operator that accepts an uninitialized value is ObjectType()
412efcc2a30SJung-uk Kim          */
413efcc2a30SJung-uk Kim         else if ((!MethodInfo->LocalInitialized[RegisterNumber]) &&
414efcc2a30SJung-uk Kim                  (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
415efcc2a30SJung-uk Kim         {
416efcc2a30SJung-uk Kim             LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
417efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
418efcc2a30SJung-uk Kim         }
419efcc2a30SJung-uk Kim         break;
420efcc2a30SJung-uk Kim 
421efcc2a30SJung-uk Kim     case PARSEOP_ARG0:
422efcc2a30SJung-uk Kim     case PARSEOP_ARG1:
423efcc2a30SJung-uk Kim     case PARSEOP_ARG2:
424efcc2a30SJung-uk Kim     case PARSEOP_ARG3:
425efcc2a30SJung-uk Kim     case PARSEOP_ARG4:
426efcc2a30SJung-uk Kim     case PARSEOP_ARG5:
427efcc2a30SJung-uk Kim     case PARSEOP_ARG6:
428efcc2a30SJung-uk Kim 
429efcc2a30SJung-uk Kim         if (!MethodInfo)
430efcc2a30SJung-uk Kim         {
431efcc2a30SJung-uk Kim             /*
432efcc2a30SJung-uk Kim              * Arg was used outside a control method, or there was an error
433efcc2a30SJung-uk Kim              * in the method declaration.
434efcc2a30SJung-uk Kim              */
435f8146b88SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD,
436f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
437efcc2a30SJung-uk Kim             return (AE_ERROR);
438efcc2a30SJung-uk Kim         }
439efcc2a30SJung-uk Kim 
440efcc2a30SJung-uk Kim         RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
441efcc2a30SJung-uk Kim         ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
442efcc2a30SJung-uk Kim 
443efcc2a30SJung-uk Kim         /*
444efcc2a30SJung-uk Kim          * If the Arg is being used as a target, mark the local
445efcc2a30SJung-uk Kim          * initialized
446efcc2a30SJung-uk Kim          */
4475f9b24faSJung-uk Kim         if (Op->Asl.CompileFlags & OP_IS_TARGET)
448efcc2a30SJung-uk Kim         {
449efcc2a30SJung-uk Kim             MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
450efcc2a30SJung-uk Kim         }
451efcc2a30SJung-uk Kim 
452efcc2a30SJung-uk Kim         /*
453efcc2a30SJung-uk Kim          * Otherwise, this is a reference, check if the Arg
454efcc2a30SJung-uk Kim          * has been previously initialized.
455efcc2a30SJung-uk Kim          *
456efcc2a30SJung-uk Kim          * The only operator that accepts an uninitialized value is ObjectType()
457efcc2a30SJung-uk Kim          */
458efcc2a30SJung-uk Kim         else if ((!MethodInfo->ArgInitialized[RegisterNumber]) &&
459efcc2a30SJung-uk Kim             (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
460efcc2a30SJung-uk Kim         {
461efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
462efcc2a30SJung-uk Kim         }
463efcc2a30SJung-uk Kim 
464efcc2a30SJung-uk Kim         /* Flag this arg if it is not a "real" argument to the method */
465efcc2a30SJung-uk Kim 
466efcc2a30SJung-uk Kim         if (RegisterNumber >= MethodInfo->NumArguments)
467efcc2a30SJung-uk Kim         {
468efcc2a30SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
469efcc2a30SJung-uk Kim         }
470efcc2a30SJung-uk Kim         break;
471efcc2a30SJung-uk Kim 
472efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
473efcc2a30SJung-uk Kim 
474efcc2a30SJung-uk Kim         if (!MethodInfo)
475efcc2a30SJung-uk Kim         {
476efcc2a30SJung-uk Kim             /*
477efcc2a30SJung-uk Kim              * Probably was an error in the method declaration,
478efcc2a30SJung-uk Kim              * no additional error here
479efcc2a30SJung-uk Kim              */
480efcc2a30SJung-uk Kim             ACPI_WARNING ((AE_INFO, "%p, No parent method", Op));
481efcc2a30SJung-uk Kim             return (AE_ERROR);
482efcc2a30SJung-uk Kim         }
483efcc2a30SJung-uk Kim 
484efcc2a30SJung-uk Kim         /*
485efcc2a30SJung-uk Kim          * A child indicates a possible return value. A simple Return or
4865f9b24faSJung-uk Kim          * Return() is marked with OP_IS_NULL_RETURN by the parser so
487efcc2a30SJung-uk Kim          * that it is not counted as a "real" return-with-value, although
488efcc2a30SJung-uk Kim          * the AML code that is actually emitted is Return(0). The AML
489efcc2a30SJung-uk Kim          * definition of Return has a required parameter, so we are
490efcc2a30SJung-uk Kim          * forced to convert a null return to Return(0).
491efcc2a30SJung-uk Kim          */
492efcc2a30SJung-uk Kim         if ((Op->Asl.Child) &&
493efcc2a30SJung-uk Kim             (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
4945f9b24faSJung-uk Kim             (!(Op->Asl.Child->Asl.CompileFlags & OP_IS_NULL_RETURN)))
495efcc2a30SJung-uk Kim         {
496efcc2a30SJung-uk Kim             MethodInfo->NumReturnWithValue++;
497efcc2a30SJung-uk Kim         }
498efcc2a30SJung-uk Kim         else
499efcc2a30SJung-uk Kim         {
500efcc2a30SJung-uk Kim             MethodInfo->NumReturnNoValue++;
501efcc2a30SJung-uk Kim         }
502efcc2a30SJung-uk Kim         break;
503efcc2a30SJung-uk Kim 
504efcc2a30SJung-uk Kim     case PARSEOP_BREAK:
505efcc2a30SJung-uk Kim     case PARSEOP_CONTINUE:
506efcc2a30SJung-uk Kim 
507efcc2a30SJung-uk Kim         Next = Op->Asl.Parent;
508efcc2a30SJung-uk Kim         while (Next)
509efcc2a30SJung-uk Kim         {
510efcc2a30SJung-uk Kim             if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
511efcc2a30SJung-uk Kim             {
512efcc2a30SJung-uk Kim                 break;
513efcc2a30SJung-uk Kim             }
514efcc2a30SJung-uk Kim             Next = Next->Asl.Parent;
515efcc2a30SJung-uk Kim         }
516efcc2a30SJung-uk Kim 
517efcc2a30SJung-uk Kim         if (!Next)
518efcc2a30SJung-uk Kim         {
519efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
520efcc2a30SJung-uk Kim         }
521efcc2a30SJung-uk Kim         break;
522efcc2a30SJung-uk Kim 
523efcc2a30SJung-uk Kim     case PARSEOP_STALL:
524efcc2a30SJung-uk Kim 
525efcc2a30SJung-uk Kim         /* We can range check if the argument is an integer */
526efcc2a30SJung-uk Kim 
527efcc2a30SJung-uk Kim         if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
528efcc2a30SJung-uk Kim             (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
529efcc2a30SJung-uk Kim         {
530efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
531efcc2a30SJung-uk Kim         }
532efcc2a30SJung-uk Kim         break;
533efcc2a30SJung-uk Kim 
534efcc2a30SJung-uk Kim     case PARSEOP_DEVICE:
535313a0c13SJung-uk Kim 
536a009b7dcSJung-uk Kim         /* Check usage of _HID and _ADR objects */
537a009b7dcSJung-uk Kim 
538a009b7dcSJung-uk Kim         HidExists = ApFindNameInDeviceTree (METHOD_NAME__HID, Op);
539a009b7dcSJung-uk Kim         AdrExists = ApFindNameInDeviceTree (METHOD_NAME__ADR, Op);
540a009b7dcSJung-uk Kim 
541a009b7dcSJung-uk Kim         if (!HidExists && !AdrExists)
542313a0c13SJung-uk Kim         {
54397c0b5abSJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_MISSING_DEPENDENCY, Op,
54497c0b5abSJung-uk Kim                 "Device object requires a _HID or _ADR");
545313a0c13SJung-uk Kim         }
546a009b7dcSJung-uk Kim         else if (HidExists && AdrExists)
547a009b7dcSJung-uk Kim         {
548a009b7dcSJung-uk Kim             /*
549a009b7dcSJung-uk Kim              * According to the ACPI spec, "A device object must contain
550a009b7dcSJung-uk Kim              * either an _HID object or an _ADR object, but should not contain
551a009b7dcSJung-uk Kim              * both".
552a009b7dcSJung-uk Kim              */
553a009b7dcSJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_MULTIPLE_TYPES, Op,
554a009b7dcSJung-uk Kim                 "Device object requires either a _HID or _ADR, but not both");
555a009b7dcSJung-uk Kim         }
55697c0b5abSJung-uk Kim 
55797c0b5abSJung-uk Kim         /*
55897c0b5abSJung-uk Kim          * Check usage of _CRS, _DIS, _PRS, and _SRS objects (July 2021).
55997c0b5abSJung-uk Kim          *
56097c0b5abSJung-uk Kim          * Under the Device Object:
56197c0b5abSJung-uk Kim          *
5621b7a2680SJung-uk Kim          * 1) If _PRS present, must have _CRS and _SRS
5631b7a2680SJung-uk Kim          * 2) If _SRS present, must have _PRS (_PRS requires _CRS and _SRS)
5641b7a2680SJung-uk Kim          * 3) If _DIS present, must have _SRS (_SRS requires _PRS, _PRS requires _CRS and _SRS)
5651b7a2680SJung-uk Kim          * 4) If _SRS present, probably should have a _DIS (Remark only)
56697c0b5abSJung-uk Kim          */
56797c0b5abSJung-uk Kim         CrsExists = ApFindNameInDeviceTree (METHOD_NAME__CRS, Op);
56897c0b5abSJung-uk Kim         DisExists = ApFindNameInDeviceTree (METHOD_NAME__DIS, Op);
56997c0b5abSJung-uk Kim         PrsExists = ApFindNameInDeviceTree (METHOD_NAME__PRS, Op);
57097c0b5abSJung-uk Kim         SrsExists = ApFindNameInDeviceTree (METHOD_NAME__SRS, Op);
57197c0b5abSJung-uk Kim 
5721b7a2680SJung-uk Kim         /* 1) If _PRS is present, must have a _CRS and _SRS */
57397c0b5abSJung-uk Kim 
57497c0b5abSJung-uk Kim         if (PrsExists)
57597c0b5abSJung-uk Kim         {
57697c0b5abSJung-uk Kim             if (!CrsExists)
57797c0b5abSJung-uk Kim             {
57897c0b5abSJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
5791b7a2680SJung-uk Kim                     "Device has a _PRS, missing a _CRS, required");
58097c0b5abSJung-uk Kim             }
58197c0b5abSJung-uk Kim             if (!SrsExists)
58297c0b5abSJung-uk Kim             {
58397c0b5abSJung-uk Kim                 AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
5841b7a2680SJung-uk Kim                     "Device has a _PRS, missing a _SRS, required");
58597c0b5abSJung-uk Kim             }
58697c0b5abSJung-uk Kim         }
58797c0b5abSJung-uk Kim 
5881b7a2680SJung-uk Kim         /* 2) If _SRS is present, must have _PRS (_PRS requires _CRS and _SRS) */
58997c0b5abSJung-uk Kim 
5901b7a2680SJung-uk Kim         if ((SrsExists) && (!PrsExists))
59197c0b5abSJung-uk Kim         {
59297c0b5abSJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
5931b7a2680SJung-uk Kim                 "Device has a _SRS, missing a _PRS, required");
59497c0b5abSJung-uk Kim         }
5951b7a2680SJung-uk Kim 
5961b7a2680SJung-uk Kim         /* 3) If _DIS is present, must have a _SRS */
5971b7a2680SJung-uk Kim 
5981b7a2680SJung-uk Kim         if ((DisExists) && (!SrsExists))
59997c0b5abSJung-uk Kim         {
60097c0b5abSJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op,
6011b7a2680SJung-uk Kim                 "Device has a _DIS, missing a _SRS, required");
60297c0b5abSJung-uk Kim         }
6031b7a2680SJung-uk Kim 
6041b7a2680SJung-uk Kim         /*
6051b7a2680SJung-uk Kim          * 4) If _SRS is present, should have a _DIS (_PRS requires _CRS
6061b7a2680SJung-uk Kim          * and _SRS)  Remark only.
6071b7a2680SJung-uk Kim          */
6081b7a2680SJung-uk Kim         if ((SrsExists) && (!DisExists))
60997c0b5abSJung-uk Kim         {
61097c0b5abSJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_MISSING_DEPENDENCY, Op,
6111b7a2680SJung-uk Kim                 "Device has a _SRS, no corresponding _DIS");
61297c0b5abSJung-uk Kim         }
613313a0c13SJung-uk Kim         break;
614313a0c13SJung-uk Kim 
615efcc2a30SJung-uk Kim     case PARSEOP_EVENT:
616efcc2a30SJung-uk Kim     case PARSEOP_MUTEX:
617efcc2a30SJung-uk Kim     case PARSEOP_OPERATIONREGION:
618efcc2a30SJung-uk Kim     case PARSEOP_POWERRESOURCE:
619efcc2a30SJung-uk Kim     case PARSEOP_PROCESSOR:
620efcc2a30SJung-uk Kim     case PARSEOP_THERMALZONE:
621efcc2a30SJung-uk Kim 
622efcc2a30SJung-uk Kim         /*
623efcc2a30SJung-uk Kim          * The first operand is a name to be created in the namespace.
624efcc2a30SJung-uk Kim          * Check against the reserved list.
625efcc2a30SJung-uk Kim          */
626efcc2a30SJung-uk Kim         i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
627efcc2a30SJung-uk Kim         if (i < ACPI_VALID_RESERVED_NAME_MAX)
628efcc2a30SJung-uk Kim         {
629f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_RESERVED_USE,
630f8146b88SJung-uk Kim                 Op, Op->Asl.ExternalName);
631efcc2a30SJung-uk Kim         }
632ec0234b4SJung-uk Kim 
633ec0234b4SJung-uk Kim         MtCheckStaticOperationRegionInMethod (Op);
634efcc2a30SJung-uk Kim         break;
635efcc2a30SJung-uk Kim 
636efcc2a30SJung-uk Kim     case PARSEOP_NAME:
637efcc2a30SJung-uk Kim 
638efcc2a30SJung-uk Kim         /* Typecheck any predefined names statically defined with Name() */
639efcc2a30SJung-uk Kim 
640efcc2a30SJung-uk Kim         ApCheckForPredefinedObject (Op, Op->Asl.NameSeg);
641efcc2a30SJung-uk Kim 
642efcc2a30SJung-uk Kim         /* Special typechecking for _HID */
643efcc2a30SJung-uk Kim 
644f9a6772eSJung-uk Kim         if (ACPI_COMPARE_NAMESEG (METHOD_NAME__HID, Op->Asl.NameSeg))
645efcc2a30SJung-uk Kim         {
646efcc2a30SJung-uk Kim             Next = Op->Asl.Child->Asl.Next;
647efcc2a30SJung-uk Kim             AnCheckId (Next, ASL_TYPE_HID);
648efcc2a30SJung-uk Kim         }
649efcc2a30SJung-uk Kim 
650efcc2a30SJung-uk Kim         /* Special typechecking for _CID */
651efcc2a30SJung-uk Kim 
652f9a6772eSJung-uk Kim         else if (ACPI_COMPARE_NAMESEG (METHOD_NAME__CID, Op->Asl.NameSeg))
653efcc2a30SJung-uk Kim         {
654efcc2a30SJung-uk Kim             Next = Op->Asl.Child->Asl.Next;
655efcc2a30SJung-uk Kim 
656efcc2a30SJung-uk Kim             if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
657efcc2a30SJung-uk Kim                 (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
658efcc2a30SJung-uk Kim             {
659efcc2a30SJung-uk Kim                 Next = Next->Asl.Child;
660efcc2a30SJung-uk Kim                 while (Next)
661efcc2a30SJung-uk Kim                 {
662efcc2a30SJung-uk Kim                     AnCheckId (Next, ASL_TYPE_CID);
663efcc2a30SJung-uk Kim                     Next = Next->Asl.Next;
664efcc2a30SJung-uk Kim                 }
665efcc2a30SJung-uk Kim             }
666efcc2a30SJung-uk Kim             else
667efcc2a30SJung-uk Kim             {
668efcc2a30SJung-uk Kim                 AnCheckId (Next, ASL_TYPE_CID);
669efcc2a30SJung-uk Kim             }
670efcc2a30SJung-uk Kim         }
671313a0c13SJung-uk Kim 
672efcc2a30SJung-uk Kim         break;
673efcc2a30SJung-uk Kim 
674efcc2a30SJung-uk Kim     default:
675a9d8d09cSJung-uk Kim 
676efcc2a30SJung-uk Kim         break;
677efcc2a30SJung-uk Kim     }
678efcc2a30SJung-uk Kim 
679a9d8d09cSJung-uk Kim     /* Check for named object creation within a non-serialized method */
680a9d8d09cSJung-uk Kim 
681a9d8d09cSJung-uk Kim     MtCheckNamedObjectInMethod (Op, MethodInfo);
682efcc2a30SJung-uk Kim     return (AE_OK);
683efcc2a30SJung-uk Kim }
684efcc2a30SJung-uk Kim 
685efcc2a30SJung-uk Kim 
686efcc2a30SJung-uk Kim /*******************************************************************************
687efcc2a30SJung-uk Kim  *
688ec0234b4SJung-uk Kim  * FUNCTION:    MtProcessTypeOp
689ec0234b4SJung-uk Kim  *
690ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Op representing a btype
691ec0234b4SJung-uk Kim  *
692ec0234b4SJung-uk Kim  * RETURN:      Btype represented by Op
693ec0234b4SJung-uk Kim  *
694ec0234b4SJung-uk Kim  * DESCRIPTION: Process a parse object that represents single parameter type or
695ec0234b4SJung-uk Kim  *              a return type in method, function, and external declarations.
696ec0234b4SJung-uk Kim  *
697ec0234b4SJung-uk Kim  ******************************************************************************/
698ec0234b4SJung-uk Kim 
699ec0234b4SJung-uk Kim UINT32
MtProcessTypeOp(ACPI_PARSE_OBJECT * TypeOp)700ec0234b4SJung-uk Kim MtProcessTypeOp (
701ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT       *TypeOp)
702ec0234b4SJung-uk Kim {
703ec0234b4SJung-uk Kim     UINT32                  Btype = ACPI_BTYPE_ANY;
704ec0234b4SJung-uk Kim 
705ec0234b4SJung-uk Kim 
706ec0234b4SJung-uk Kim     while (TypeOp)
707ec0234b4SJung-uk Kim     {
708ec0234b4SJung-uk Kim         Btype |= AnMapObjTypeToBtype (TypeOp);
709ec0234b4SJung-uk Kim         TypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
710ec0234b4SJung-uk Kim         TypeOp = TypeOp->Asl.Next;
711ec0234b4SJung-uk Kim     }
712ec0234b4SJung-uk Kim 
713ec0234b4SJung-uk Kim     return (Btype);
714ec0234b4SJung-uk Kim }
715ec0234b4SJung-uk Kim 
716ec0234b4SJung-uk Kim 
717ec0234b4SJung-uk Kim /*******************************************************************************
718ec0234b4SJung-uk Kim  *
719ec0234b4SJung-uk Kim  * FUNCTION:    MtProcessParameterTypeList
720ec0234b4SJung-uk Kim  *
721ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Op representing a btype
722ec0234b4SJung-uk Kim  *
723ec0234b4SJung-uk Kim  * RETURN:      Btype represented by Op
724ec0234b4SJung-uk Kim  *
725ec0234b4SJung-uk Kim  * DESCRIPTION: Process a parse object that represents a parameter type list in
726ec0234b4SJung-uk Kim  *              method, function, and external declarations.
727ec0234b4SJung-uk Kim  *
728ec0234b4SJung-uk Kim  ******************************************************************************/
729ec0234b4SJung-uk Kim 
730ec0234b4SJung-uk Kim UINT8
MtProcessParameterTypeList(ACPI_PARSE_OBJECT * ParamTypeOp,UINT32 * TypeList)731ec0234b4SJung-uk Kim MtProcessParameterTypeList (
732ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT       *ParamTypeOp,
733ec0234b4SJung-uk Kim     UINT32                  *TypeList)
734ec0234b4SJung-uk Kim {
735ec0234b4SJung-uk Kim     UINT8                   ParameterCount = 0;
736ec0234b4SJung-uk Kim 
737ec0234b4SJung-uk Kim 
73861b18036SJung-uk Kim     if (ParamTypeOp && ParamTypeOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
73961b18036SJung-uk Kim     {
74061b18036SJung-uk Kim         /* Special case for a single parameter without braces */
74161b18036SJung-uk Kim 
74261b18036SJung-uk Kim         TypeList[ParameterCount] =
74361b18036SJung-uk Kim             MtProcessTypeOp (ParamTypeOp);
74461b18036SJung-uk Kim 
74561b18036SJung-uk Kim         return (1);
74661b18036SJung-uk Kim     }
74761b18036SJung-uk Kim 
748ec0234b4SJung-uk Kim     while (ParamTypeOp)
749ec0234b4SJung-uk Kim     {
750ec0234b4SJung-uk Kim         TypeList[ParameterCount] =
751ec0234b4SJung-uk Kim             MtProcessTypeOp (ParamTypeOp->Asl.Child);
752ec0234b4SJung-uk Kim 
753ec0234b4SJung-uk Kim         ParameterCount++;
754ec0234b4SJung-uk Kim         ParamTypeOp = ParamTypeOp->Asl.Next;
755ec0234b4SJung-uk Kim     }
756ec0234b4SJung-uk Kim 
757ec0234b4SJung-uk Kim     return (ParameterCount);
758ec0234b4SJung-uk Kim }
759ec0234b4SJung-uk Kim 
760ec0234b4SJung-uk Kim 
761ec0234b4SJung-uk Kim /*******************************************************************************
762ec0234b4SJung-uk Kim  *
763a9d8d09cSJung-uk Kim  * FUNCTION:    MtCheckNamedObjectInMethod
764a9d8d09cSJung-uk Kim  *
765a9d8d09cSJung-uk Kim  * PARAMETERS:  Op                  - Current parser op
766a9d8d09cSJung-uk Kim  *              MethodInfo          - Info for method being parsed
767a9d8d09cSJung-uk Kim  *
768a9d8d09cSJung-uk Kim  * RETURN:      None
769a9d8d09cSJung-uk Kim  *
770a9d8d09cSJung-uk Kim  * DESCRIPTION: Detect if a non-serialized method is creating a named object,
771a9d8d09cSJung-uk Kim  *              which could possibly cause problems if two threads execute
772a9d8d09cSJung-uk Kim  *              the method concurrently. Emit a remark in this case.
773a9d8d09cSJung-uk Kim  *
774a9d8d09cSJung-uk Kim  ******************************************************************************/
775a9d8d09cSJung-uk Kim 
776f8146b88SJung-uk Kim static void
MtCheckNamedObjectInMethod(ACPI_PARSE_OBJECT * Op,ASL_METHOD_INFO * MethodInfo)777a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod (
778a9d8d09cSJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
779a9d8d09cSJung-uk Kim     ASL_METHOD_INFO         *MethodInfo)
780a9d8d09cSJung-uk Kim {
781a9d8d09cSJung-uk Kim     const ACPI_OPCODE_INFO  *OpInfo;
782ec0234b4SJung-uk Kim     char                    *ExternalPath;
783a9d8d09cSJung-uk Kim 
784a9d8d09cSJung-uk Kim 
785f8146b88SJung-uk Kim     /* We don't care about actual method declarations or scopes */
786a9d8d09cSJung-uk Kim 
787f8146b88SJung-uk Kim     if ((Op->Asl.AmlOpcode == AML_METHOD_OP) ||
788f8146b88SJung-uk Kim         (Op->Asl.AmlOpcode == AML_SCOPE_OP))
789a9d8d09cSJung-uk Kim     {
790a9d8d09cSJung-uk Kim         return;
791a9d8d09cSJung-uk Kim     }
792a9d8d09cSJung-uk Kim 
79367d9aa44SJung-uk Kim     /* Determine if we are creating a named object within a method */
79467d9aa44SJung-uk Kim 
79567d9aa44SJung-uk Kim     if (!MethodInfo)
79667d9aa44SJung-uk Kim     {
79767d9aa44SJung-uk Kim         return;
79867d9aa44SJung-uk Kim     }
799a9d8d09cSJung-uk Kim 
800a9d8d09cSJung-uk Kim     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
8010b229c80SJung-uk Kim     if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_FIELD_OP))
802a9d8d09cSJung-uk Kim     {
803a9d8d09cSJung-uk Kim         /*
80467d9aa44SJung-uk Kim          * 1) Mark the method as a method that creates named objects.
80567d9aa44SJung-uk Kim          *
806ec0234b4SJung-uk Kim          * 2) Issue a remark indicating the inefficiency of creating named
807ec0234b4SJung-uk Kim          * objects within a method (Except for compiler-emitted temporary
808ec0234b4SJung-uk Kim          * variables).
809ec0234b4SJung-uk Kim          *
810ec0234b4SJung-uk Kim          * 3) If the method is non-serialized, emit a remark that the method
81167d9aa44SJung-uk Kim          * should be serialized.
812a9d8d09cSJung-uk Kim          *
813a9d8d09cSJung-uk Kim          * Reason: If a thread blocks within the method for any reason, and
81467d9aa44SJung-uk Kim          * another thread enters the method, the method will fail because
81567d9aa44SJung-uk Kim          * an attempt will be made to create the same object twice.
8160b229c80SJung-uk Kim          *
8170b229c80SJung-uk Kim          * Note: The Field opcode is disallowed here because Field() does not
8180b229c80SJung-uk Kim          * create a new named object.
819a9d8d09cSJung-uk Kim          */
820ec0234b4SJung-uk Kim         ExternalPath = AcpiNsGetNormalizedPathname (MethodInfo->Op->Asl.Node, TRUE);
821ec0234b4SJung-uk Kim 
822ec0234b4SJung-uk Kim         /* No error for compiler temp variables (name starts with "_T_") */
823ec0234b4SJung-uk Kim 
824ec0234b4SJung-uk Kim         if ((Op->Asl.NameSeg[0] != '_') &&
825ec0234b4SJung-uk Kim             (Op->Asl.NameSeg[1] != 'T') &&
826ec0234b4SJung-uk Kim             (Op->Asl.NameSeg[2] != '_'))
827ec0234b4SJung-uk Kim         {
828ec0234b4SJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_NAMED_OBJECT_CREATION, Op,
829ec0234b4SJung-uk Kim                 ExternalPath);
830ec0234b4SJung-uk Kim         }
831ec0234b4SJung-uk Kim 
83267d9aa44SJung-uk Kim         MethodInfo->CreatesNamedObjects = TRUE;
83367d9aa44SJung-uk Kim         if (!MethodInfo->ShouldBeSerialized)
834a9d8d09cSJung-uk Kim         {
835a9d8d09cSJung-uk Kim             AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op,
836ec0234b4SJung-uk Kim                 ExternalPath);
837a9d8d09cSJung-uk Kim 
838a9d8d09cSJung-uk Kim             /* Emit message only ONCE per method */
839a9d8d09cSJung-uk Kim 
840a9d8d09cSJung-uk Kim             MethodInfo->ShouldBeSerialized = TRUE;
841a9d8d09cSJung-uk Kim         }
842ec0234b4SJung-uk Kim 
843ec0234b4SJung-uk Kim         if (ExternalPath)
844ec0234b4SJung-uk Kim         {
845ec0234b4SJung-uk Kim             ACPI_FREE (ExternalPath);
846a9d8d09cSJung-uk Kim         }
847a9d8d09cSJung-uk Kim     }
848ec0234b4SJung-uk Kim }
849ec0234b4SJung-uk Kim 
850ec0234b4SJung-uk Kim 
851ec0234b4SJung-uk Kim /*******************************************************************************
852ec0234b4SJung-uk Kim  *
853ec0234b4SJung-uk Kim  * FUNCTION:    MtCheckStaticOperationRegionInMethod
854ec0234b4SJung-uk Kim  *
855ec0234b4SJung-uk Kim  * PARAMETERS:  Op                  - Current parser op
856ec0234b4SJung-uk Kim  *
857ec0234b4SJung-uk Kim  * RETURN:      None
858ec0234b4SJung-uk Kim  *
859ec0234b4SJung-uk Kim  * DESCRIPTION: Warns if an Operation Region with static address or length
860ec0234b4SJung-uk Kim  *              is declared inside a control method
861ec0234b4SJung-uk Kim  *
862ec0234b4SJung-uk Kim  ******************************************************************************/
863ec0234b4SJung-uk Kim 
864ec0234b4SJung-uk Kim static void
MtCheckStaticOperationRegionInMethod(ACPI_PARSE_OBJECT * Op)865ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod(
866ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       Op)
867ec0234b4SJung-uk Kim {
868ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       AddressOp;
869ec0234b4SJung-uk Kim     ACPI_PARSE_OBJECT*       LengthOp;
870ec0234b4SJung-uk Kim 
871ec0234b4SJung-uk Kim 
872ec0234b4SJung-uk Kim     if (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION)
873ec0234b4SJung-uk Kim     {
874ec0234b4SJung-uk Kim         return;
875ec0234b4SJung-uk Kim     }
876ec0234b4SJung-uk Kim 
877ec0234b4SJung-uk Kim     /*
878ec0234b4SJung-uk Kim      * OperationRegion should have 4 arguments defined. At this point, we
879ec0234b4SJung-uk Kim      * assume that the parse tree is well-formed.
880ec0234b4SJung-uk Kim      */
881ec0234b4SJung-uk Kim     AddressOp = Op->Asl.Child->Asl.Next->Asl.Next;
882ec0234b4SJung-uk Kim     LengthOp = Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next;
883ec0234b4SJung-uk Kim 
884ec0234b4SJung-uk Kim     if (UtGetParentMethodOp (Op) &&
885ec0234b4SJung-uk Kim         AddressOp->Asl.ParseOpcode == PARSEOP_INTEGER &&
886ec0234b4SJung-uk Kim         LengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)
887ec0234b4SJung-uk Kim     {
888ec0234b4SJung-uk Kim         /*
889ec0234b4SJung-uk Kim          * At this point, a static operation region declared inside of a
890ec0234b4SJung-uk Kim          * control method has been found. Throw a warning because this is
891ec0234b4SJung-uk Kim          * highly inefficient.
892ec0234b4SJung-uk Kim          */
893ec0234b4SJung-uk Kim         AslError(ASL_WARNING, ASL_MSG_STATIC_OPREGION_IN_METHOD, Op, NULL);
894ec0234b4SJung-uk Kim     }
895ec0234b4SJung-uk Kim 
896ec0234b4SJung-uk Kim     return;
897ec0234b4SJung-uk Kim }
898a9d8d09cSJung-uk Kim 
899a9d8d09cSJung-uk Kim 
900a9d8d09cSJung-uk Kim /*******************************************************************************
901a9d8d09cSJung-uk Kim  *
902efcc2a30SJung-uk Kim  * FUNCTION:    MtMethodAnalysisWalkEnd
903efcc2a30SJung-uk Kim  *
904efcc2a30SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
905efcc2a30SJung-uk Kim  *
906efcc2a30SJung-uk Kim  * RETURN:      Status
907efcc2a30SJung-uk Kim  *
908efcc2a30SJung-uk Kim  * DESCRIPTION: Ascending callback for analysis walk. Complete method
909efcc2a30SJung-uk Kim  *              return analysis.
910efcc2a30SJung-uk Kim  *
911efcc2a30SJung-uk Kim  ******************************************************************************/
912efcc2a30SJung-uk Kim 
913efcc2a30SJung-uk Kim ACPI_STATUS
MtMethodAnalysisWalkEnd(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)914efcc2a30SJung-uk Kim MtMethodAnalysisWalkEnd (
915efcc2a30SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
916efcc2a30SJung-uk Kim     UINT32                  Level,
917efcc2a30SJung-uk Kim     void                    *Context)
918efcc2a30SJung-uk Kim {
919efcc2a30SJung-uk Kim     ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
920efcc2a30SJung-uk Kim     ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;
921ec0234b4SJung-uk Kim     char                    *ExternalPath;
922efcc2a30SJung-uk Kim 
923efcc2a30SJung-uk Kim 
924efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
925efcc2a30SJung-uk Kim     {
926efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
927efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
928a9d8d09cSJung-uk Kim 
929efcc2a30SJung-uk Kim         if (!MethodInfo)
930efcc2a30SJung-uk Kim         {
931efcc2a30SJung-uk Kim             printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
932efcc2a30SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
933efcc2a30SJung-uk Kim                 "No method info for this method");
934efcc2a30SJung-uk Kim 
935efcc2a30SJung-uk Kim             CmCleanupAndExit ();
936efcc2a30SJung-uk Kim             return (AE_AML_INTERNAL);
937efcc2a30SJung-uk Kim         }
938efcc2a30SJung-uk Kim         break;
939efcc2a30SJung-uk Kim 
940efcc2a30SJung-uk Kim     default:
941a9d8d09cSJung-uk Kim 
942efcc2a30SJung-uk Kim         break;
943efcc2a30SJung-uk Kim     }
944efcc2a30SJung-uk Kim 
945efcc2a30SJung-uk Kim     switch (Op->Asl.ParseOpcode)
946efcc2a30SJung-uk Kim     {
947efcc2a30SJung-uk Kim     case PARSEOP_METHOD:
948efcc2a30SJung-uk Kim 
949efcc2a30SJung-uk Kim         WalkInfo->MethodStack = MethodInfo->Next;
950efcc2a30SJung-uk Kim 
951efcc2a30SJung-uk Kim         /*
952efcc2a30SJung-uk Kim          * Check if there is no return statement at the end of the
953efcc2a30SJung-uk Kim          * method AND we can actually get there -- i.e., the execution
954efcc2a30SJung-uk Kim          * of the method can possibly terminate without a return statement.
955efcc2a30SJung-uk Kim          */
956efcc2a30SJung-uk Kim         if ((!AnLastStatementIsReturn (Op)) &&
9575f9b24faSJung-uk Kim             (!(Op->Asl.CompileFlags & OP_HAS_NO_EXIT)))
958efcc2a30SJung-uk Kim         {
959efcc2a30SJung-uk Kim             /*
960efcc2a30SJung-uk Kim              * No return statement, and execution can possibly exit
961efcc2a30SJung-uk Kim              * via this path. This is equivalent to Return ()
962efcc2a30SJung-uk Kim              */
963efcc2a30SJung-uk Kim             MethodInfo->NumReturnNoValue++;
964efcc2a30SJung-uk Kim         }
965efcc2a30SJung-uk Kim 
966efcc2a30SJung-uk Kim         /*
967efcc2a30SJung-uk Kim          * Check for case where some return statements have a return value
968efcc2a30SJung-uk Kim          * and some do not. Exit without a return statement is a return with
969efcc2a30SJung-uk Kim          * no value
970efcc2a30SJung-uk Kim          */
971efcc2a30SJung-uk Kim         if (MethodInfo->NumReturnNoValue &&
972efcc2a30SJung-uk Kim             MethodInfo->NumReturnWithValue)
973efcc2a30SJung-uk Kim         {
974ec0234b4SJung-uk Kim             ExternalPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE);
975ec0234b4SJung-uk Kim 
976efcc2a30SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
977ec0234b4SJung-uk Kim                 ExternalPath);
978ec0234b4SJung-uk Kim 
979ec0234b4SJung-uk Kim             if (ExternalPath)
980ec0234b4SJung-uk Kim             {
981ec0234b4SJung-uk Kim                 ACPI_FREE (ExternalPath);
982ec0234b4SJung-uk Kim             }
983efcc2a30SJung-uk Kim         }
984efcc2a30SJung-uk Kim 
985efcc2a30SJung-uk Kim         /*
986efcc2a30SJung-uk Kim          * If there are any RETURN() statements with no value, or there is a
987efcc2a30SJung-uk Kim          * control path that allows the method to exit without a return value,
988efcc2a30SJung-uk Kim          * we mark the method as a method that does not return a value. This
989efcc2a30SJung-uk Kim          * knowledge can be used to check method invocations that expect a
990efcc2a30SJung-uk Kim          * returned value.
991efcc2a30SJung-uk Kim          */
992efcc2a30SJung-uk Kim         if (MethodInfo->NumReturnNoValue)
993efcc2a30SJung-uk Kim         {
994efcc2a30SJung-uk Kim             if (MethodInfo->NumReturnWithValue)
995efcc2a30SJung-uk Kim             {
9965f9b24faSJung-uk Kim                 Op->Asl.CompileFlags |= OP_METHOD_SOME_NO_RETVAL;
997efcc2a30SJung-uk Kim             }
998efcc2a30SJung-uk Kim             else
999efcc2a30SJung-uk Kim             {
10005f9b24faSJung-uk Kim                 Op->Asl.CompileFlags |= OP_METHOD_NO_RETVAL;
1001efcc2a30SJung-uk Kim             }
1002efcc2a30SJung-uk Kim         }
1003efcc2a30SJung-uk Kim 
1004efcc2a30SJung-uk Kim         /*
1005efcc2a30SJung-uk Kim          * Check predefined method names for correct return behavior
1006efcc2a30SJung-uk Kim          * and correct number of arguments. Also, some special checks
1007efcc2a30SJung-uk Kim          * For GPE and _REG methods.
1008efcc2a30SJung-uk Kim          */
1009efcc2a30SJung-uk Kim         if (ApCheckForPredefinedMethod (Op, MethodInfo))
1010efcc2a30SJung-uk Kim         {
1011efcc2a30SJung-uk Kim             /* Special check for two names like _L01 and _E01 in same scope */
1012efcc2a30SJung-uk Kim 
1013efcc2a30SJung-uk Kim             ApCheckForGpeNameConflict (Op);
1014efcc2a30SJung-uk Kim 
1015efcc2a30SJung-uk Kim             /*
1016efcc2a30SJung-uk Kim              * Special check for _REG: Must have an operation region definition
1017efcc2a30SJung-uk Kim              * within the same scope!
1018efcc2a30SJung-uk Kim              */
1019efcc2a30SJung-uk Kim             ApCheckRegMethod (Op);
1020efcc2a30SJung-uk Kim         }
1021efcc2a30SJung-uk Kim 
1022efcc2a30SJung-uk Kim         ACPI_FREE (MethodInfo);
1023efcc2a30SJung-uk Kim         break;
1024efcc2a30SJung-uk Kim 
1025efcc2a30SJung-uk Kim     case PARSEOP_NAME:
1026efcc2a30SJung-uk Kim 
1027efcc2a30SJung-uk Kim          /* Special check for two names like _L01 and _E01 in same scope */
1028efcc2a30SJung-uk Kim 
1029efcc2a30SJung-uk Kim         ApCheckForGpeNameConflict (Op);
1030efcc2a30SJung-uk Kim         break;
1031efcc2a30SJung-uk Kim 
1032efcc2a30SJung-uk Kim     case PARSEOP_RETURN:
1033efcc2a30SJung-uk Kim 
1034efcc2a30SJung-uk Kim         /*
1035efcc2a30SJung-uk Kim          * If the parent is a predefined method name, attempt to typecheck
1036efcc2a30SJung-uk Kim          * the return value. Only static types can be validated.
1037efcc2a30SJung-uk Kim          */
1038efcc2a30SJung-uk Kim         ApCheckPredefinedReturnValue (Op, MethodInfo);
1039efcc2a30SJung-uk Kim 
1040efcc2a30SJung-uk Kim         /*
1041efcc2a30SJung-uk Kim          * The parent block does not "exit" and continue execution -- the
1042efcc2a30SJung-uk Kim          * method is terminated here with the Return() statement.
1043efcc2a30SJung-uk Kim          */
10445f9b24faSJung-uk Kim         Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
1045efcc2a30SJung-uk Kim 
1046efcc2a30SJung-uk Kim         /* Used in the "typing" pass later */
1047efcc2a30SJung-uk Kim 
1048efcc2a30SJung-uk Kim         Op->Asl.ParentMethod = MethodInfo->Op;
1049efcc2a30SJung-uk Kim 
1050efcc2a30SJung-uk Kim         /*
1051efcc2a30SJung-uk Kim          * If there is a peer node after the return statement, then this
1052efcc2a30SJung-uk Kim          * node is unreachable code -- i.e., it won't be executed because of
1053efcc2a30SJung-uk Kim          * the preceding Return() statement.
1054efcc2a30SJung-uk Kim          */
1055efcc2a30SJung-uk Kim         if (Op->Asl.Next)
1056efcc2a30SJung-uk Kim         {
1057f8146b88SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE,
1058f8146b88SJung-uk Kim                 Op->Asl.Next, NULL);
1059efcc2a30SJung-uk Kim         }
1060efcc2a30SJung-uk Kim         break;
1061efcc2a30SJung-uk Kim 
1062efcc2a30SJung-uk Kim     case PARSEOP_IF:
1063efcc2a30SJung-uk Kim 
10645f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
1065efcc2a30SJung-uk Kim             (Op->Asl.Next) &&
1066efcc2a30SJung-uk Kim             (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
1067efcc2a30SJung-uk Kim         {
1068efcc2a30SJung-uk Kim             /*
1069efcc2a30SJung-uk Kim              * This IF has a corresponding ELSE. The IF block has no exit,
1070efcc2a30SJung-uk Kim              * (it contains an unconditional Return)
1071efcc2a30SJung-uk Kim              * mark the ELSE block to remember this fact.
1072efcc2a30SJung-uk Kim              */
10735f9b24faSJung-uk Kim             Op->Asl.Next->Asl.CompileFlags |= OP_IF_HAS_NO_EXIT;
1074efcc2a30SJung-uk Kim         }
1075efcc2a30SJung-uk Kim         break;
1076efcc2a30SJung-uk Kim 
1077efcc2a30SJung-uk Kim     case PARSEOP_ELSE:
1078efcc2a30SJung-uk Kim 
10795f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
10805f9b24faSJung-uk Kim             (Op->Asl.CompileFlags & OP_IF_HAS_NO_EXIT))
1081efcc2a30SJung-uk Kim         {
1082efcc2a30SJung-uk Kim             /*
1083efcc2a30SJung-uk Kim              * This ELSE block has no exit and the corresponding IF block
1084efcc2a30SJung-uk Kim              * has no exit either. Therefore, the parent node has no exit.
1085efcc2a30SJung-uk Kim              */
10865f9b24faSJung-uk Kim             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
1087efcc2a30SJung-uk Kim         }
1088efcc2a30SJung-uk Kim         break;
1089efcc2a30SJung-uk Kim 
1090efcc2a30SJung-uk Kim 
1091efcc2a30SJung-uk Kim     default:
1092efcc2a30SJung-uk Kim 
10935f9b24faSJung-uk Kim         if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) &&
1094efcc2a30SJung-uk Kim             (Op->Asl.Parent))
1095efcc2a30SJung-uk Kim         {
1096efcc2a30SJung-uk Kim             /* If this node has no exit, then the parent has no exit either */
1097efcc2a30SJung-uk Kim 
10985f9b24faSJung-uk Kim             Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT;
1099efcc2a30SJung-uk Kim         }
1100efcc2a30SJung-uk Kim         break;
1101efcc2a30SJung-uk Kim     }
1102efcc2a30SJung-uk Kim 
1103efcc2a30SJung-uk Kim     return (AE_OK);
1104efcc2a30SJung-uk Kim }
1105