aslwalks.c revision 1.1.1.1.2.2 1 1.1.1.1.2.2 bouyer /******************************************************************************
2 1.1.1.1.2.2 bouyer *
3 1.1.1.1.2.2 bouyer * Module Name: aslwalks.c - major analytical parse tree walks
4 1.1.1.1.2.2 bouyer *
5 1.1.1.1.2.2 bouyer *****************************************************************************/
6 1.1.1.1.2.2 bouyer
7 1.1.1.1.2.2 bouyer /*
8 1.1.1.1.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.1.2.2 bouyer * All rights reserved.
10 1.1.1.1.2.2 bouyer *
11 1.1.1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.1.2.2 bouyer * are met:
14 1.1.1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.2.2 bouyer * without modification.
17 1.1.1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.2.2 bouyer * binary redistribution.
22 1.1.1.1.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.1.2.2 bouyer *
26 1.1.1.1.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.2.2 bouyer * Software Foundation.
29 1.1.1.1.2.2 bouyer *
30 1.1.1.1.2.2 bouyer * NO WARRANTY
31 1.1.1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.2.2 bouyer */
43 1.1.1.1.2.2 bouyer
44 1.1.1.1.2.2 bouyer
45 1.1.1.1.2.2 bouyer #include "aslcompiler.h"
46 1.1.1.1.2.2 bouyer #include "aslcompiler.y.h"
47 1.1.1.1.2.2 bouyer #include "acparser.h"
48 1.1.1.1.2.2 bouyer #include "amlcode.h"
49 1.1.1.1.2.2 bouyer
50 1.1.1.1.2.2 bouyer
51 1.1.1.1.2.2 bouyer #define _COMPONENT ACPI_COMPILER
52 1.1.1.1.2.2 bouyer ACPI_MODULE_NAME ("aslwalks")
53 1.1.1.1.2.2 bouyer
54 1.1.1.1.2.2 bouyer
55 1.1.1.1.2.2 bouyer /*******************************************************************************
56 1.1.1.1.2.2 bouyer *
57 1.1.1.1.2.2 bouyer * FUNCTION: AnMethodAnalysisWalkBegin
58 1.1.1.1.2.2 bouyer *
59 1.1.1.1.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
60 1.1.1.1.2.2 bouyer *
61 1.1.1.1.2.2 bouyer * RETURN: Status
62 1.1.1.1.2.2 bouyer *
63 1.1.1.1.2.2 bouyer * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
64 1.1.1.1.2.2 bouyer * 1) Initialized local variables
65 1.1.1.1.2.2 bouyer * 2) Valid arguments
66 1.1.1.1.2.2 bouyer * 3) Return types
67 1.1.1.1.2.2 bouyer *
68 1.1.1.1.2.2 bouyer ******************************************************************************/
69 1.1.1.1.2.2 bouyer
70 1.1.1.1.2.2 bouyer ACPI_STATUS
71 1.1.1.1.2.2 bouyer AnMethodAnalysisWalkBegin (
72 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op,
73 1.1.1.1.2.2 bouyer UINT32 Level,
74 1.1.1.1.2.2 bouyer void *Context)
75 1.1.1.1.2.2 bouyer {
76 1.1.1.1.2.2 bouyer ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
77 1.1.1.1.2.2 bouyer ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
78 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Next;
79 1.1.1.1.2.2 bouyer UINT32 RegisterNumber;
80 1.1.1.1.2.2 bouyer UINT32 i;
81 1.1.1.1.2.2 bouyer char LocalName[] = "Local0";
82 1.1.1.1.2.2 bouyer char ArgName[] = "Arg0";
83 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *ArgNode;
84 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *NextType;
85 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *NextParamType;
86 1.1.1.1.2.2 bouyer UINT8 ActualArgs = 0;
87 1.1.1.1.2.2 bouyer
88 1.1.1.1.2.2 bouyer
89 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
90 1.1.1.1.2.2 bouyer {
91 1.1.1.1.2.2 bouyer case PARSEOP_METHOD:
92 1.1.1.1.2.2 bouyer
93 1.1.1.1.2.2 bouyer TotalMethods++;
94 1.1.1.1.2.2 bouyer
95 1.1.1.1.2.2 bouyer /* Create and init method info */
96 1.1.1.1.2.2 bouyer
97 1.1.1.1.2.2 bouyer MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
98 1.1.1.1.2.2 bouyer MethodInfo->Next = WalkInfo->MethodStack;
99 1.1.1.1.2.2 bouyer MethodInfo->Op = Op;
100 1.1.1.1.2.2 bouyer
101 1.1.1.1.2.2 bouyer WalkInfo->MethodStack = MethodInfo;
102 1.1.1.1.2.2 bouyer
103 1.1.1.1.2.2 bouyer /* Get the name node, ignored here */
104 1.1.1.1.2.2 bouyer
105 1.1.1.1.2.2 bouyer Next = Op->Asl.Child;
106 1.1.1.1.2.2 bouyer
107 1.1.1.1.2.2 bouyer /* Get the NumArguments node */
108 1.1.1.1.2.2 bouyer
109 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
110 1.1.1.1.2.2 bouyer MethodInfo->NumArguments = (UINT8)
111 1.1.1.1.2.2 bouyer (((UINT8) Next->Asl.Value.Integer) & 0x07);
112 1.1.1.1.2.2 bouyer
113 1.1.1.1.2.2 bouyer /* Get the SerializeRule and SyncLevel nodes, ignored here */
114 1.1.1.1.2.2 bouyer
115 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
116 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
117 1.1.1.1.2.2 bouyer ArgNode = Next;
118 1.1.1.1.2.2 bouyer
119 1.1.1.1.2.2 bouyer /* Get the ReturnType node */
120 1.1.1.1.2.2 bouyer
121 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
122 1.1.1.1.2.2 bouyer
123 1.1.1.1.2.2 bouyer NextType = Next->Asl.Child;
124 1.1.1.1.2.2 bouyer while (NextType)
125 1.1.1.1.2.2 bouyer {
126 1.1.1.1.2.2 bouyer /* Get and map each of the ReturnTypes */
127 1.1.1.1.2.2 bouyer
128 1.1.1.1.2.2 bouyer MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType);
129 1.1.1.1.2.2 bouyer NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
130 1.1.1.1.2.2 bouyer NextType = NextType->Asl.Next;
131 1.1.1.1.2.2 bouyer }
132 1.1.1.1.2.2 bouyer
133 1.1.1.1.2.2 bouyer /* Get the ParameterType node */
134 1.1.1.1.2.2 bouyer
135 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
136 1.1.1.1.2.2 bouyer
137 1.1.1.1.2.2 bouyer NextType = Next->Asl.Child;
138 1.1.1.1.2.2 bouyer while (NextType)
139 1.1.1.1.2.2 bouyer {
140 1.1.1.1.2.2 bouyer if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
141 1.1.1.1.2.2 bouyer {
142 1.1.1.1.2.2 bouyer NextParamType = NextType->Asl.Child;
143 1.1.1.1.2.2 bouyer while (NextParamType)
144 1.1.1.1.2.2 bouyer {
145 1.1.1.1.2.2 bouyer MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType);
146 1.1.1.1.2.2 bouyer NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
147 1.1.1.1.2.2 bouyer NextParamType = NextParamType->Asl.Next;
148 1.1.1.1.2.2 bouyer }
149 1.1.1.1.2.2 bouyer }
150 1.1.1.1.2.2 bouyer else
151 1.1.1.1.2.2 bouyer {
152 1.1.1.1.2.2 bouyer MethodInfo->ValidArgTypes[ActualArgs] =
153 1.1.1.1.2.2 bouyer AnMapObjTypeToBtype (NextType);
154 1.1.1.1.2.2 bouyer NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
155 1.1.1.1.2.2 bouyer ActualArgs++;
156 1.1.1.1.2.2 bouyer }
157 1.1.1.1.2.2 bouyer
158 1.1.1.1.2.2 bouyer NextType = NextType->Asl.Next;
159 1.1.1.1.2.2 bouyer }
160 1.1.1.1.2.2 bouyer
161 1.1.1.1.2.2 bouyer if ((MethodInfo->NumArguments) &&
162 1.1.1.1.2.2 bouyer (MethodInfo->NumArguments != ActualArgs))
163 1.1.1.1.2.2 bouyer {
164 1.1.1.1.2.2 bouyer /* error: Param list did not match number of args */
165 1.1.1.1.2.2 bouyer }
166 1.1.1.1.2.2 bouyer
167 1.1.1.1.2.2 bouyer /* Allow numarguments == 0 for Function() */
168 1.1.1.1.2.2 bouyer
169 1.1.1.1.2.2 bouyer if ((!MethodInfo->NumArguments) && (ActualArgs))
170 1.1.1.1.2.2 bouyer {
171 1.1.1.1.2.2 bouyer MethodInfo->NumArguments = ActualArgs;
172 1.1.1.1.2.2 bouyer ArgNode->Asl.Value.Integer |= ActualArgs;
173 1.1.1.1.2.2 bouyer }
174 1.1.1.1.2.2 bouyer
175 1.1.1.1.2.2 bouyer /*
176 1.1.1.1.2.2 bouyer * Actual arguments are initialized at method entry.
177 1.1.1.1.2.2 bouyer * All other ArgX "registers" can be used as locals, so we
178 1.1.1.1.2.2 bouyer * track their initialization.
179 1.1.1.1.2.2 bouyer */
180 1.1.1.1.2.2 bouyer for (i = 0; i < MethodInfo->NumArguments; i++)
181 1.1.1.1.2.2 bouyer {
182 1.1.1.1.2.2 bouyer MethodInfo->ArgInitialized[i] = TRUE;
183 1.1.1.1.2.2 bouyer }
184 1.1.1.1.2.2 bouyer break;
185 1.1.1.1.2.2 bouyer
186 1.1.1.1.2.2 bouyer
187 1.1.1.1.2.2 bouyer case PARSEOP_METHODCALL:
188 1.1.1.1.2.2 bouyer
189 1.1.1.1.2.2 bouyer if (MethodInfo &&
190 1.1.1.1.2.2 bouyer (Op->Asl.Node == MethodInfo->Op->Asl.Node))
191 1.1.1.1.2.2 bouyer {
192 1.1.1.1.2.2 bouyer AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName);
193 1.1.1.1.2.2 bouyer }
194 1.1.1.1.2.2 bouyer break;
195 1.1.1.1.2.2 bouyer
196 1.1.1.1.2.2 bouyer
197 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL0:
198 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL1:
199 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL2:
200 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL3:
201 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL4:
202 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL5:
203 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL6:
204 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL7:
205 1.1.1.1.2.2 bouyer
206 1.1.1.1.2.2 bouyer if (!MethodInfo)
207 1.1.1.1.2.2 bouyer {
208 1.1.1.1.2.2 bouyer /*
209 1.1.1.1.2.2 bouyer * Local was used outside a control method, or there was an error
210 1.1.1.1.2.2 bouyer * in the method declaration.
211 1.1.1.1.2.2 bouyer */
212 1.1.1.1.2.2 bouyer AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName);
213 1.1.1.1.2.2 bouyer return (AE_ERROR);
214 1.1.1.1.2.2 bouyer }
215 1.1.1.1.2.2 bouyer
216 1.1.1.1.2.2 bouyer RegisterNumber = (Op->Asl.AmlOpcode & 0x000F);
217 1.1.1.1.2.2 bouyer
218 1.1.1.1.2.2 bouyer /*
219 1.1.1.1.2.2 bouyer * If the local is being used as a target, mark the local
220 1.1.1.1.2.2 bouyer * initialized
221 1.1.1.1.2.2 bouyer */
222 1.1.1.1.2.2 bouyer if (Op->Asl.CompileFlags & NODE_IS_TARGET)
223 1.1.1.1.2.2 bouyer {
224 1.1.1.1.2.2 bouyer MethodInfo->LocalInitialized[RegisterNumber] = TRUE;
225 1.1.1.1.2.2 bouyer }
226 1.1.1.1.2.2 bouyer
227 1.1.1.1.2.2 bouyer /*
228 1.1.1.1.2.2 bouyer * Otherwise, this is a reference, check if the local
229 1.1.1.1.2.2 bouyer * has been previously initialized.
230 1.1.1.1.2.2 bouyer *
231 1.1.1.1.2.2 bouyer * The only operator that accepts an uninitialized value is ObjectType()
232 1.1.1.1.2.2 bouyer */
233 1.1.1.1.2.2 bouyer else if ((!MethodInfo->LocalInitialized[RegisterNumber]) &&
234 1.1.1.1.2.2 bouyer (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
235 1.1.1.1.2.2 bouyer {
236 1.1.1.1.2.2 bouyer LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30);
237 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName);
238 1.1.1.1.2.2 bouyer }
239 1.1.1.1.2.2 bouyer break;
240 1.1.1.1.2.2 bouyer
241 1.1.1.1.2.2 bouyer
242 1.1.1.1.2.2 bouyer case PARSEOP_ARG0:
243 1.1.1.1.2.2 bouyer case PARSEOP_ARG1:
244 1.1.1.1.2.2 bouyer case PARSEOP_ARG2:
245 1.1.1.1.2.2 bouyer case PARSEOP_ARG3:
246 1.1.1.1.2.2 bouyer case PARSEOP_ARG4:
247 1.1.1.1.2.2 bouyer case PARSEOP_ARG5:
248 1.1.1.1.2.2 bouyer case PARSEOP_ARG6:
249 1.1.1.1.2.2 bouyer
250 1.1.1.1.2.2 bouyer if (!MethodInfo)
251 1.1.1.1.2.2 bouyer {
252 1.1.1.1.2.2 bouyer /*
253 1.1.1.1.2.2 bouyer * Arg was used outside a control method, or there was an error
254 1.1.1.1.2.2 bouyer * in the method declaration.
255 1.1.1.1.2.2 bouyer */
256 1.1.1.1.2.2 bouyer AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName);
257 1.1.1.1.2.2 bouyer return (AE_ERROR);
258 1.1.1.1.2.2 bouyer }
259 1.1.1.1.2.2 bouyer
260 1.1.1.1.2.2 bouyer RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8;
261 1.1.1.1.2.2 bouyer ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30);
262 1.1.1.1.2.2 bouyer
263 1.1.1.1.2.2 bouyer /*
264 1.1.1.1.2.2 bouyer * If the Arg is being used as a target, mark the local
265 1.1.1.1.2.2 bouyer * initialized
266 1.1.1.1.2.2 bouyer */
267 1.1.1.1.2.2 bouyer if (Op->Asl.CompileFlags & NODE_IS_TARGET)
268 1.1.1.1.2.2 bouyer {
269 1.1.1.1.2.2 bouyer MethodInfo->ArgInitialized[RegisterNumber] = TRUE;
270 1.1.1.1.2.2 bouyer }
271 1.1.1.1.2.2 bouyer
272 1.1.1.1.2.2 bouyer /*
273 1.1.1.1.2.2 bouyer * Otherwise, this is a reference, check if the Arg
274 1.1.1.1.2.2 bouyer * has been previously initialized.
275 1.1.1.1.2.2 bouyer *
276 1.1.1.1.2.2 bouyer * The only operator that accepts an uninitialized value is ObjectType()
277 1.1.1.1.2.2 bouyer */
278 1.1.1.1.2.2 bouyer else if ((!MethodInfo->ArgInitialized[RegisterNumber]) &&
279 1.1.1.1.2.2 bouyer (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE))
280 1.1.1.1.2.2 bouyer {
281 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName);
282 1.1.1.1.2.2 bouyer }
283 1.1.1.1.2.2 bouyer
284 1.1.1.1.2.2 bouyer /* Flag this arg if it is not a "real" argument to the method */
285 1.1.1.1.2.2 bouyer
286 1.1.1.1.2.2 bouyer if (RegisterNumber >= MethodInfo->NumArguments)
287 1.1.1.1.2.2 bouyer {
288 1.1.1.1.2.2 bouyer AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName);
289 1.1.1.1.2.2 bouyer }
290 1.1.1.1.2.2 bouyer break;
291 1.1.1.1.2.2 bouyer
292 1.1.1.1.2.2 bouyer
293 1.1.1.1.2.2 bouyer case PARSEOP_RETURN:
294 1.1.1.1.2.2 bouyer
295 1.1.1.1.2.2 bouyer if (!MethodInfo)
296 1.1.1.1.2.2 bouyer {
297 1.1.1.1.2.2 bouyer /*
298 1.1.1.1.2.2 bouyer * Probably was an error in the method declaration,
299 1.1.1.1.2.2 bouyer * no additional error here
300 1.1.1.1.2.2 bouyer */
301 1.1.1.1.2.2 bouyer ACPI_WARNING ((AE_INFO, "%p, No parent method", Op));
302 1.1.1.1.2.2 bouyer return (AE_ERROR);
303 1.1.1.1.2.2 bouyer }
304 1.1.1.1.2.2 bouyer
305 1.1.1.1.2.2 bouyer /* Child indicates a return value */
306 1.1.1.1.2.2 bouyer
307 1.1.1.1.2.2 bouyer if ((Op->Asl.Child) &&
308 1.1.1.1.2.2 bouyer (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
309 1.1.1.1.2.2 bouyer {
310 1.1.1.1.2.2 bouyer MethodInfo->NumReturnWithValue++;
311 1.1.1.1.2.2 bouyer }
312 1.1.1.1.2.2 bouyer else
313 1.1.1.1.2.2 bouyer {
314 1.1.1.1.2.2 bouyer MethodInfo->NumReturnNoValue++;
315 1.1.1.1.2.2 bouyer }
316 1.1.1.1.2.2 bouyer break;
317 1.1.1.1.2.2 bouyer
318 1.1.1.1.2.2 bouyer
319 1.1.1.1.2.2 bouyer case PARSEOP_BREAK:
320 1.1.1.1.2.2 bouyer case PARSEOP_CONTINUE:
321 1.1.1.1.2.2 bouyer
322 1.1.1.1.2.2 bouyer Next = Op->Asl.Parent;
323 1.1.1.1.2.2 bouyer while (Next)
324 1.1.1.1.2.2 bouyer {
325 1.1.1.1.2.2 bouyer if (Next->Asl.ParseOpcode == PARSEOP_WHILE)
326 1.1.1.1.2.2 bouyer {
327 1.1.1.1.2.2 bouyer break;
328 1.1.1.1.2.2 bouyer }
329 1.1.1.1.2.2 bouyer Next = Next->Asl.Parent;
330 1.1.1.1.2.2 bouyer }
331 1.1.1.1.2.2 bouyer
332 1.1.1.1.2.2 bouyer if (!Next)
333 1.1.1.1.2.2 bouyer {
334 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL);
335 1.1.1.1.2.2 bouyer }
336 1.1.1.1.2.2 bouyer break;
337 1.1.1.1.2.2 bouyer
338 1.1.1.1.2.2 bouyer
339 1.1.1.1.2.2 bouyer case PARSEOP_STALL:
340 1.1.1.1.2.2 bouyer
341 1.1.1.1.2.2 bouyer /* We can range check if the argument is an integer */
342 1.1.1.1.2.2 bouyer
343 1.1.1.1.2.2 bouyer if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
344 1.1.1.1.2.2 bouyer (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
345 1.1.1.1.2.2 bouyer {
346 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
347 1.1.1.1.2.2 bouyer }
348 1.1.1.1.2.2 bouyer break;
349 1.1.1.1.2.2 bouyer
350 1.1.1.1.2.2 bouyer
351 1.1.1.1.2.2 bouyer case PARSEOP_DEVICE:
352 1.1.1.1.2.2 bouyer case PARSEOP_EVENT:
353 1.1.1.1.2.2 bouyer case PARSEOP_MUTEX:
354 1.1.1.1.2.2 bouyer case PARSEOP_OPERATIONREGION:
355 1.1.1.1.2.2 bouyer case PARSEOP_POWERRESOURCE:
356 1.1.1.1.2.2 bouyer case PARSEOP_PROCESSOR:
357 1.1.1.1.2.2 bouyer case PARSEOP_THERMALZONE:
358 1.1.1.1.2.2 bouyer
359 1.1.1.1.2.2 bouyer /*
360 1.1.1.1.2.2 bouyer * The first operand is a name to be created in the namespace.
361 1.1.1.1.2.2 bouyer * Check against the reserved list.
362 1.1.1.1.2.2 bouyer */
363 1.1.1.1.2.2 bouyer i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
364 1.1.1.1.2.2 bouyer if (i < ACPI_VALID_RESERVED_NAME_MAX)
365 1.1.1.1.2.2 bouyer {
366 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName);
367 1.1.1.1.2.2 bouyer }
368 1.1.1.1.2.2 bouyer break;
369 1.1.1.1.2.2 bouyer
370 1.1.1.1.2.2 bouyer
371 1.1.1.1.2.2 bouyer case PARSEOP_NAME:
372 1.1.1.1.2.2 bouyer
373 1.1.1.1.2.2 bouyer /* Typecheck any predefined names statically defined with Name() */
374 1.1.1.1.2.2 bouyer
375 1.1.1.1.2.2 bouyer ApCheckForPredefinedObject (Op, Op->Asl.NameSeg);
376 1.1.1.1.2.2 bouyer
377 1.1.1.1.2.2 bouyer /* Special typechecking for _HID */
378 1.1.1.1.2.2 bouyer
379 1.1.1.1.2.2 bouyer if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg))
380 1.1.1.1.2.2 bouyer {
381 1.1.1.1.2.2 bouyer Next = Op->Asl.Child->Asl.Next;
382 1.1.1.1.2.2 bouyer AnCheckId (Next, ASL_TYPE_HID);
383 1.1.1.1.2.2 bouyer }
384 1.1.1.1.2.2 bouyer
385 1.1.1.1.2.2 bouyer /* Special typechecking for _CID */
386 1.1.1.1.2.2 bouyer
387 1.1.1.1.2.2 bouyer else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg))
388 1.1.1.1.2.2 bouyer {
389 1.1.1.1.2.2 bouyer Next = Op->Asl.Child->Asl.Next;
390 1.1.1.1.2.2 bouyer
391 1.1.1.1.2.2 bouyer if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
392 1.1.1.1.2.2 bouyer (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
393 1.1.1.1.2.2 bouyer {
394 1.1.1.1.2.2 bouyer Next = Next->Asl.Child;
395 1.1.1.1.2.2 bouyer while (Next)
396 1.1.1.1.2.2 bouyer {
397 1.1.1.1.2.2 bouyer AnCheckId (Next, ASL_TYPE_CID);
398 1.1.1.1.2.2 bouyer Next = Next->Asl.Next;
399 1.1.1.1.2.2 bouyer }
400 1.1.1.1.2.2 bouyer }
401 1.1.1.1.2.2 bouyer else
402 1.1.1.1.2.2 bouyer {
403 1.1.1.1.2.2 bouyer AnCheckId (Next, ASL_TYPE_CID);
404 1.1.1.1.2.2 bouyer }
405 1.1.1.1.2.2 bouyer }
406 1.1.1.1.2.2 bouyer break;
407 1.1.1.1.2.2 bouyer
408 1.1.1.1.2.2 bouyer
409 1.1.1.1.2.2 bouyer default:
410 1.1.1.1.2.2 bouyer break;
411 1.1.1.1.2.2 bouyer }
412 1.1.1.1.2.2 bouyer
413 1.1.1.1.2.2 bouyer return (AE_OK);
414 1.1.1.1.2.2 bouyer }
415 1.1.1.1.2.2 bouyer
416 1.1.1.1.2.2 bouyer
417 1.1.1.1.2.2 bouyer /*******************************************************************************
418 1.1.1.1.2.2 bouyer *
419 1.1.1.1.2.2 bouyer * FUNCTION: AnMethodAnalysisWalkEnd
420 1.1.1.1.2.2 bouyer *
421 1.1.1.1.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
422 1.1.1.1.2.2 bouyer *
423 1.1.1.1.2.2 bouyer * RETURN: Status
424 1.1.1.1.2.2 bouyer *
425 1.1.1.1.2.2 bouyer * DESCRIPTION: Ascending callback for analysis walk. Complete method
426 1.1.1.1.2.2 bouyer * return analysis.
427 1.1.1.1.2.2 bouyer *
428 1.1.1.1.2.2 bouyer ******************************************************************************/
429 1.1.1.1.2.2 bouyer
430 1.1.1.1.2.2 bouyer ACPI_STATUS
431 1.1.1.1.2.2 bouyer AnMethodAnalysisWalkEnd (
432 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op,
433 1.1.1.1.2.2 bouyer UINT32 Level,
434 1.1.1.1.2.2 bouyer void *Context)
435 1.1.1.1.2.2 bouyer {
436 1.1.1.1.2.2 bouyer ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
437 1.1.1.1.2.2 bouyer ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
438 1.1.1.1.2.2 bouyer
439 1.1.1.1.2.2 bouyer
440 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
441 1.1.1.1.2.2 bouyer {
442 1.1.1.1.2.2 bouyer case PARSEOP_METHOD:
443 1.1.1.1.2.2 bouyer case PARSEOP_RETURN:
444 1.1.1.1.2.2 bouyer if (!MethodInfo)
445 1.1.1.1.2.2 bouyer {
446 1.1.1.1.2.2 bouyer printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
447 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
448 1.1.1.1.2.2 bouyer "No method info for this method");
449 1.1.1.1.2.2 bouyer
450 1.1.1.1.2.2 bouyer CmCleanupAndExit ();
451 1.1.1.1.2.2 bouyer return (AE_AML_INTERNAL);
452 1.1.1.1.2.2 bouyer }
453 1.1.1.1.2.2 bouyer break;
454 1.1.1.1.2.2 bouyer
455 1.1.1.1.2.2 bouyer default:
456 1.1.1.1.2.2 bouyer break;
457 1.1.1.1.2.2 bouyer }
458 1.1.1.1.2.2 bouyer
459 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
460 1.1.1.1.2.2 bouyer {
461 1.1.1.1.2.2 bouyer case PARSEOP_METHOD:
462 1.1.1.1.2.2 bouyer
463 1.1.1.1.2.2 bouyer WalkInfo->MethodStack = MethodInfo->Next;
464 1.1.1.1.2.2 bouyer
465 1.1.1.1.2.2 bouyer /*
466 1.1.1.1.2.2 bouyer * Check if there is no return statement at the end of the
467 1.1.1.1.2.2 bouyer * method AND we can actually get there -- i.e., the execution
468 1.1.1.1.2.2 bouyer * of the method can possibly terminate without a return statement.
469 1.1.1.1.2.2 bouyer */
470 1.1.1.1.2.2 bouyer if ((!AnLastStatementIsReturn (Op)) &&
471 1.1.1.1.2.2 bouyer (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT)))
472 1.1.1.1.2.2 bouyer {
473 1.1.1.1.2.2 bouyer /*
474 1.1.1.1.2.2 bouyer * No return statement, and execution can possibly exit
475 1.1.1.1.2.2 bouyer * via this path. This is equivalent to Return ()
476 1.1.1.1.2.2 bouyer */
477 1.1.1.1.2.2 bouyer MethodInfo->NumReturnNoValue++;
478 1.1.1.1.2.2 bouyer }
479 1.1.1.1.2.2 bouyer
480 1.1.1.1.2.2 bouyer /*
481 1.1.1.1.2.2 bouyer * Check for case where some return statements have a return value
482 1.1.1.1.2.2 bouyer * and some do not. Exit without a return statement is a return with
483 1.1.1.1.2.2 bouyer * no value
484 1.1.1.1.2.2 bouyer */
485 1.1.1.1.2.2 bouyer if (MethodInfo->NumReturnNoValue &&
486 1.1.1.1.2.2 bouyer MethodInfo->NumReturnWithValue)
487 1.1.1.1.2.2 bouyer {
488 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
489 1.1.1.1.2.2 bouyer Op->Asl.ExternalName);
490 1.1.1.1.2.2 bouyer }
491 1.1.1.1.2.2 bouyer
492 1.1.1.1.2.2 bouyer /*
493 1.1.1.1.2.2 bouyer * If there are any RETURN() statements with no value, or there is a
494 1.1.1.1.2.2 bouyer * control path that allows the method to exit without a return value,
495 1.1.1.1.2.2 bouyer * we mark the method as a method that does not return a value. This
496 1.1.1.1.2.2 bouyer * knowledge can be used to check method invocations that expect a
497 1.1.1.1.2.2 bouyer * returned value.
498 1.1.1.1.2.2 bouyer */
499 1.1.1.1.2.2 bouyer if (MethodInfo->NumReturnNoValue)
500 1.1.1.1.2.2 bouyer {
501 1.1.1.1.2.2 bouyer if (MethodInfo->NumReturnWithValue)
502 1.1.1.1.2.2 bouyer {
503 1.1.1.1.2.2 bouyer Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL;
504 1.1.1.1.2.2 bouyer }
505 1.1.1.1.2.2 bouyer else
506 1.1.1.1.2.2 bouyer {
507 1.1.1.1.2.2 bouyer Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL;
508 1.1.1.1.2.2 bouyer }
509 1.1.1.1.2.2 bouyer }
510 1.1.1.1.2.2 bouyer
511 1.1.1.1.2.2 bouyer /*
512 1.1.1.1.2.2 bouyer * Check predefined method names for correct return behavior
513 1.1.1.1.2.2 bouyer * and correct number of arguments
514 1.1.1.1.2.2 bouyer */
515 1.1.1.1.2.2 bouyer ApCheckForPredefinedMethod (Op, MethodInfo);
516 1.1.1.1.2.2 bouyer
517 1.1.1.1.2.2 bouyer /* Special check for two names like _L01 and _E01 in same scope */
518 1.1.1.1.2.2 bouyer
519 1.1.1.1.2.2 bouyer ApCheckForGpeNameConflict (Op);
520 1.1.1.1.2.2 bouyer ACPI_FREE (MethodInfo);
521 1.1.1.1.2.2 bouyer break;
522 1.1.1.1.2.2 bouyer
523 1.1.1.1.2.2 bouyer
524 1.1.1.1.2.2 bouyer case PARSEOP_NAME:
525 1.1.1.1.2.2 bouyer
526 1.1.1.1.2.2 bouyer /* Special check for two names like _L01 and _E01 in same scope */
527 1.1.1.1.2.2 bouyer
528 1.1.1.1.2.2 bouyer ApCheckForGpeNameConflict (Op);
529 1.1.1.1.2.2 bouyer break;
530 1.1.1.1.2.2 bouyer
531 1.1.1.1.2.2 bouyer
532 1.1.1.1.2.2 bouyer case PARSEOP_RETURN:
533 1.1.1.1.2.2 bouyer
534 1.1.1.1.2.2 bouyer /*
535 1.1.1.1.2.2 bouyer * If the parent is a predefined method name, attempt to typecheck
536 1.1.1.1.2.2 bouyer * the return value. Only static types can be validated.
537 1.1.1.1.2.2 bouyer */
538 1.1.1.1.2.2 bouyer ApCheckPredefinedReturnValue (Op, MethodInfo);
539 1.1.1.1.2.2 bouyer
540 1.1.1.1.2.2 bouyer /*
541 1.1.1.1.2.2 bouyer * The parent block does not "exit" and continue execution -- the
542 1.1.1.1.2.2 bouyer * method is terminated here with the Return() statement.
543 1.1.1.1.2.2 bouyer */
544 1.1.1.1.2.2 bouyer Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
545 1.1.1.1.2.2 bouyer
546 1.1.1.1.2.2 bouyer /* Used in the "typing" pass later */
547 1.1.1.1.2.2 bouyer
548 1.1.1.1.2.2 bouyer Op->Asl.ParentMethod = MethodInfo->Op;
549 1.1.1.1.2.2 bouyer
550 1.1.1.1.2.2 bouyer /*
551 1.1.1.1.2.2 bouyer * If there is a peer node after the return statement, then this
552 1.1.1.1.2.2 bouyer * node is unreachable code -- i.e., it won't be executed because of
553 1.1.1.1.2.2 bouyer * the preceeding Return() statement.
554 1.1.1.1.2.2 bouyer */
555 1.1.1.1.2.2 bouyer if (Op->Asl.Next)
556 1.1.1.1.2.2 bouyer {
557 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL);
558 1.1.1.1.2.2 bouyer }
559 1.1.1.1.2.2 bouyer break;
560 1.1.1.1.2.2 bouyer
561 1.1.1.1.2.2 bouyer
562 1.1.1.1.2.2 bouyer case PARSEOP_IF:
563 1.1.1.1.2.2 bouyer
564 1.1.1.1.2.2 bouyer if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
565 1.1.1.1.2.2 bouyer (Op->Asl.Next) &&
566 1.1.1.1.2.2 bouyer (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE))
567 1.1.1.1.2.2 bouyer {
568 1.1.1.1.2.2 bouyer /*
569 1.1.1.1.2.2 bouyer * This IF has a corresponding ELSE. The IF block has no exit,
570 1.1.1.1.2.2 bouyer * (it contains an unconditional Return)
571 1.1.1.1.2.2 bouyer * mark the ELSE block to remember this fact.
572 1.1.1.1.2.2 bouyer */
573 1.1.1.1.2.2 bouyer Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT;
574 1.1.1.1.2.2 bouyer }
575 1.1.1.1.2.2 bouyer break;
576 1.1.1.1.2.2 bouyer
577 1.1.1.1.2.2 bouyer
578 1.1.1.1.2.2 bouyer case PARSEOP_ELSE:
579 1.1.1.1.2.2 bouyer
580 1.1.1.1.2.2 bouyer if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
581 1.1.1.1.2.2 bouyer (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT))
582 1.1.1.1.2.2 bouyer {
583 1.1.1.1.2.2 bouyer /*
584 1.1.1.1.2.2 bouyer * This ELSE block has no exit and the corresponding IF block
585 1.1.1.1.2.2 bouyer * has no exit either. Therefore, the parent node has no exit.
586 1.1.1.1.2.2 bouyer */
587 1.1.1.1.2.2 bouyer Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
588 1.1.1.1.2.2 bouyer }
589 1.1.1.1.2.2 bouyer break;
590 1.1.1.1.2.2 bouyer
591 1.1.1.1.2.2 bouyer
592 1.1.1.1.2.2 bouyer default:
593 1.1.1.1.2.2 bouyer
594 1.1.1.1.2.2 bouyer if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) &&
595 1.1.1.1.2.2 bouyer (Op->Asl.Parent))
596 1.1.1.1.2.2 bouyer {
597 1.1.1.1.2.2 bouyer /* If this node has no exit, then the parent has no exit either */
598 1.1.1.1.2.2 bouyer
599 1.1.1.1.2.2 bouyer Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
600 1.1.1.1.2.2 bouyer }
601 1.1.1.1.2.2 bouyer break;
602 1.1.1.1.2.2 bouyer }
603 1.1.1.1.2.2 bouyer
604 1.1.1.1.2.2 bouyer return (AE_OK);
605 1.1.1.1.2.2 bouyer }
606 1.1.1.1.2.2 bouyer
607 1.1.1.1.2.2 bouyer
608 1.1.1.1.2.2 bouyer /*******************************************************************************
609 1.1.1.1.2.2 bouyer *
610 1.1.1.1.2.2 bouyer * FUNCTION: AnMethodTypingWalkEnd
611 1.1.1.1.2.2 bouyer *
612 1.1.1.1.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
613 1.1.1.1.2.2 bouyer *
614 1.1.1.1.2.2 bouyer * RETURN: Status
615 1.1.1.1.2.2 bouyer *
616 1.1.1.1.2.2 bouyer * DESCRIPTION: Ascending callback for typing walk. Complete the method
617 1.1.1.1.2.2 bouyer * return analysis. Check methods for:
618 1.1.1.1.2.2 bouyer * 1) Initialized local variables
619 1.1.1.1.2.2 bouyer * 2) Valid arguments
620 1.1.1.1.2.2 bouyer * 3) Return types
621 1.1.1.1.2.2 bouyer *
622 1.1.1.1.2.2 bouyer ******************************************************************************/
623 1.1.1.1.2.2 bouyer
624 1.1.1.1.2.2 bouyer ACPI_STATUS
625 1.1.1.1.2.2 bouyer AnMethodTypingWalkEnd (
626 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op,
627 1.1.1.1.2.2 bouyer UINT32 Level,
628 1.1.1.1.2.2 bouyer void *Context)
629 1.1.1.1.2.2 bouyer {
630 1.1.1.1.2.2 bouyer UINT32 ThisNodeBtype;
631 1.1.1.1.2.2 bouyer
632 1.1.1.1.2.2 bouyer
633 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
634 1.1.1.1.2.2 bouyer {
635 1.1.1.1.2.2 bouyer case PARSEOP_METHOD:
636 1.1.1.1.2.2 bouyer
637 1.1.1.1.2.2 bouyer Op->Asl.CompileFlags |= NODE_METHOD_TYPED;
638 1.1.1.1.2.2 bouyer break;
639 1.1.1.1.2.2 bouyer
640 1.1.1.1.2.2 bouyer case PARSEOP_RETURN:
641 1.1.1.1.2.2 bouyer
642 1.1.1.1.2.2 bouyer if ((Op->Asl.Child) &&
643 1.1.1.1.2.2 bouyer (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
644 1.1.1.1.2.2 bouyer {
645 1.1.1.1.2.2 bouyer ThisNodeBtype = AnGetBtype (Op->Asl.Child);
646 1.1.1.1.2.2 bouyer
647 1.1.1.1.2.2 bouyer if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
648 1.1.1.1.2.2 bouyer (ThisNodeBtype == (ACPI_UINT32_MAX -1)))
649 1.1.1.1.2.2 bouyer {
650 1.1.1.1.2.2 bouyer /*
651 1.1.1.1.2.2 bouyer * The called method is untyped at this time (typically a
652 1.1.1.1.2.2 bouyer * forward reference).
653 1.1.1.1.2.2 bouyer *
654 1.1.1.1.2.2 bouyer * Check for a recursive method call first.
655 1.1.1.1.2.2 bouyer */
656 1.1.1.1.2.2 bouyer if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)
657 1.1.1.1.2.2 bouyer {
658 1.1.1.1.2.2 bouyer /* We must type the method here */
659 1.1.1.1.2.2 bouyer
660 1.1.1.1.2.2 bouyer TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
661 1.1.1.1.2.2 bouyer ASL_WALK_VISIT_UPWARD, NULL,
662 1.1.1.1.2.2 bouyer AnMethodTypingWalkEnd, NULL);
663 1.1.1.1.2.2 bouyer
664 1.1.1.1.2.2 bouyer ThisNodeBtype = AnGetBtype (Op->Asl.Child);
665 1.1.1.1.2.2 bouyer }
666 1.1.1.1.2.2 bouyer }
667 1.1.1.1.2.2 bouyer
668 1.1.1.1.2.2 bouyer /* Returns a value, save the value type */
669 1.1.1.1.2.2 bouyer
670 1.1.1.1.2.2 bouyer if (Op->Asl.ParentMethod)
671 1.1.1.1.2.2 bouyer {
672 1.1.1.1.2.2 bouyer Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype;
673 1.1.1.1.2.2 bouyer }
674 1.1.1.1.2.2 bouyer }
675 1.1.1.1.2.2 bouyer break;
676 1.1.1.1.2.2 bouyer
677 1.1.1.1.2.2 bouyer default:
678 1.1.1.1.2.2 bouyer break;
679 1.1.1.1.2.2 bouyer }
680 1.1.1.1.2.2 bouyer
681 1.1.1.1.2.2 bouyer return (AE_OK);
682 1.1.1.1.2.2 bouyer }
683 1.1.1.1.2.2 bouyer
684 1.1.1.1.2.2 bouyer
685 1.1.1.1.2.2 bouyer /*******************************************************************************
686 1.1.1.1.2.2 bouyer *
687 1.1.1.1.2.2 bouyer * FUNCTION: AnOperandTypecheckWalkEnd
688 1.1.1.1.2.2 bouyer *
689 1.1.1.1.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
690 1.1.1.1.2.2 bouyer *
691 1.1.1.1.2.2 bouyer * RETURN: Status
692 1.1.1.1.2.2 bouyer *
693 1.1.1.1.2.2 bouyer * DESCRIPTION: Ascending callback for analysis walk. Complete method
694 1.1.1.1.2.2 bouyer * return analysis.
695 1.1.1.1.2.2 bouyer *
696 1.1.1.1.2.2 bouyer ******************************************************************************/
697 1.1.1.1.2.2 bouyer
698 1.1.1.1.2.2 bouyer ACPI_STATUS
699 1.1.1.1.2.2 bouyer AnOperandTypecheckWalkEnd (
700 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op,
701 1.1.1.1.2.2 bouyer UINT32 Level,
702 1.1.1.1.2.2 bouyer void *Context)
703 1.1.1.1.2.2 bouyer {
704 1.1.1.1.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
705 1.1.1.1.2.2 bouyer UINT32 RuntimeArgTypes;
706 1.1.1.1.2.2 bouyer UINT32 RuntimeArgTypes2;
707 1.1.1.1.2.2 bouyer UINT32 RequiredBtypes;
708 1.1.1.1.2.2 bouyer UINT32 ThisNodeBtype;
709 1.1.1.1.2.2 bouyer UINT32 CommonBtypes;
710 1.1.1.1.2.2 bouyer UINT32 OpcodeClass;
711 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *ArgOp;
712 1.1.1.1.2.2 bouyer UINT32 ArgType;
713 1.1.1.1.2.2 bouyer
714 1.1.1.1.2.2 bouyer
715 1.1.1.1.2.2 bouyer switch (Op->Asl.AmlOpcode)
716 1.1.1.1.2.2 bouyer {
717 1.1.1.1.2.2 bouyer case AML_RAW_DATA_BYTE:
718 1.1.1.1.2.2 bouyer case AML_RAW_DATA_WORD:
719 1.1.1.1.2.2 bouyer case AML_RAW_DATA_DWORD:
720 1.1.1.1.2.2 bouyer case AML_RAW_DATA_QWORD:
721 1.1.1.1.2.2 bouyer case AML_RAW_DATA_BUFFER:
722 1.1.1.1.2.2 bouyer case AML_RAW_DATA_CHAIN:
723 1.1.1.1.2.2 bouyer case AML_PACKAGE_LENGTH:
724 1.1.1.1.2.2 bouyer case AML_UNASSIGNED_OPCODE:
725 1.1.1.1.2.2 bouyer case AML_DEFAULT_ARG_OP:
726 1.1.1.1.2.2 bouyer
727 1.1.1.1.2.2 bouyer /* Ignore the internal (compiler-only) AML opcodes */
728 1.1.1.1.2.2 bouyer
729 1.1.1.1.2.2 bouyer return (AE_OK);
730 1.1.1.1.2.2 bouyer
731 1.1.1.1.2.2 bouyer default:
732 1.1.1.1.2.2 bouyer break;
733 1.1.1.1.2.2 bouyer }
734 1.1.1.1.2.2 bouyer
735 1.1.1.1.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
736 1.1.1.1.2.2 bouyer if (!OpInfo)
737 1.1.1.1.2.2 bouyer {
738 1.1.1.1.2.2 bouyer return (AE_OK);
739 1.1.1.1.2.2 bouyer }
740 1.1.1.1.2.2 bouyer
741 1.1.1.1.2.2 bouyer ArgOp = Op->Asl.Child;
742 1.1.1.1.2.2 bouyer RuntimeArgTypes = OpInfo->RuntimeArgs;
743 1.1.1.1.2.2 bouyer OpcodeClass = OpInfo->Class;
744 1.1.1.1.2.2 bouyer
745 1.1.1.1.2.2 bouyer #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
746 1.1.1.1.2.2 bouyer /*
747 1.1.1.1.2.2 bouyer * Update 11/2008: In practice, we can't perform this check. A simple
748 1.1.1.1.2.2 bouyer * analysis is not sufficient. Also, it can cause errors when compiling
749 1.1.1.1.2.2 bouyer * disassembled code because of the way Switch operators are implemented
750 1.1.1.1.2.2 bouyer * (a While(One) loop with a named temp variable created within.)
751 1.1.1.1.2.2 bouyer */
752 1.1.1.1.2.2 bouyer
753 1.1.1.1.2.2 bouyer /*
754 1.1.1.1.2.2 bouyer * If we are creating a named object, check if we are within a while loop
755 1.1.1.1.2.2 bouyer * by checking if the parent is a WHILE op. This is a simple analysis, but
756 1.1.1.1.2.2 bouyer * probably sufficient for many cases.
757 1.1.1.1.2.2 bouyer *
758 1.1.1.1.2.2 bouyer * Allow Scope(), Buffer(), and Package().
759 1.1.1.1.2.2 bouyer */
760 1.1.1.1.2.2 bouyer if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) ||
761 1.1.1.1.2.2 bouyer ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE)))
762 1.1.1.1.2.2 bouyer {
763 1.1.1.1.2.2 bouyer if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP)
764 1.1.1.1.2.2 bouyer {
765 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL);
766 1.1.1.1.2.2 bouyer }
767 1.1.1.1.2.2 bouyer }
768 1.1.1.1.2.2 bouyer #endif
769 1.1.1.1.2.2 bouyer
770 1.1.1.1.2.2 bouyer /*
771 1.1.1.1.2.2 bouyer * Special case for control opcodes IF/RETURN/WHILE since they
772 1.1.1.1.2.2 bouyer * have no runtime arg list (at this time)
773 1.1.1.1.2.2 bouyer */
774 1.1.1.1.2.2 bouyer switch (Op->Asl.AmlOpcode)
775 1.1.1.1.2.2 bouyer {
776 1.1.1.1.2.2 bouyer case AML_IF_OP:
777 1.1.1.1.2.2 bouyer case AML_WHILE_OP:
778 1.1.1.1.2.2 bouyer case AML_RETURN_OP:
779 1.1.1.1.2.2 bouyer
780 1.1.1.1.2.2 bouyer if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
781 1.1.1.1.2.2 bouyer {
782 1.1.1.1.2.2 bouyer /* Check for an internal method */
783 1.1.1.1.2.2 bouyer
784 1.1.1.1.2.2 bouyer if (AnIsInternalMethod (ArgOp))
785 1.1.1.1.2.2 bouyer {
786 1.1.1.1.2.2 bouyer return (AE_OK);
787 1.1.1.1.2.2 bouyer }
788 1.1.1.1.2.2 bouyer
789 1.1.1.1.2.2 bouyer /* The lone arg is a method call, check it */
790 1.1.1.1.2.2 bouyer
791 1.1.1.1.2.2 bouyer RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
792 1.1.1.1.2.2 bouyer if (Op->Asl.AmlOpcode == AML_RETURN_OP)
793 1.1.1.1.2.2 bouyer {
794 1.1.1.1.2.2 bouyer RequiredBtypes = 0xFFFFFFFF;
795 1.1.1.1.2.2 bouyer }
796 1.1.1.1.2.2 bouyer
797 1.1.1.1.2.2 bouyer ThisNodeBtype = AnGetBtype (ArgOp);
798 1.1.1.1.2.2 bouyer if (ThisNodeBtype == ACPI_UINT32_MAX)
799 1.1.1.1.2.2 bouyer {
800 1.1.1.1.2.2 bouyer return (AE_OK);
801 1.1.1.1.2.2 bouyer }
802 1.1.1.1.2.2 bouyer AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
803 1.1.1.1.2.2 bouyer RequiredBtypes, ThisNodeBtype);
804 1.1.1.1.2.2 bouyer }
805 1.1.1.1.2.2 bouyer return (AE_OK);
806 1.1.1.1.2.2 bouyer
807 1.1.1.1.2.2 bouyer default:
808 1.1.1.1.2.2 bouyer break;
809 1.1.1.1.2.2 bouyer }
810 1.1.1.1.2.2 bouyer
811 1.1.1.1.2.2 bouyer /* Ignore the non-executable opcodes */
812 1.1.1.1.2.2 bouyer
813 1.1.1.1.2.2 bouyer if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
814 1.1.1.1.2.2 bouyer {
815 1.1.1.1.2.2 bouyer return (AE_OK);
816 1.1.1.1.2.2 bouyer }
817 1.1.1.1.2.2 bouyer
818 1.1.1.1.2.2 bouyer switch (OpcodeClass)
819 1.1.1.1.2.2 bouyer {
820 1.1.1.1.2.2 bouyer case AML_CLASS_EXECUTE:
821 1.1.1.1.2.2 bouyer case AML_CLASS_CREATE:
822 1.1.1.1.2.2 bouyer case AML_CLASS_CONTROL:
823 1.1.1.1.2.2 bouyer case AML_CLASS_RETURN_VALUE:
824 1.1.1.1.2.2 bouyer
825 1.1.1.1.2.2 bouyer /* TBD: Change class or fix typechecking for these */
826 1.1.1.1.2.2 bouyer
827 1.1.1.1.2.2 bouyer if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) ||
828 1.1.1.1.2.2 bouyer (Op->Asl.AmlOpcode == AML_PACKAGE_OP) ||
829 1.1.1.1.2.2 bouyer (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))
830 1.1.1.1.2.2 bouyer {
831 1.1.1.1.2.2 bouyer break;
832 1.1.1.1.2.2 bouyer }
833 1.1.1.1.2.2 bouyer
834 1.1.1.1.2.2 bouyer /* Reverse the runtime argument list */
835 1.1.1.1.2.2 bouyer
836 1.1.1.1.2.2 bouyer RuntimeArgTypes2 = 0;
837 1.1.1.1.2.2 bouyer while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
838 1.1.1.1.2.2 bouyer {
839 1.1.1.1.2.2 bouyer RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
840 1.1.1.1.2.2 bouyer RuntimeArgTypes2 |= ArgType;
841 1.1.1.1.2.2 bouyer INCREMENT_ARG_LIST (RuntimeArgTypes);
842 1.1.1.1.2.2 bouyer }
843 1.1.1.1.2.2 bouyer
844 1.1.1.1.2.2 bouyer while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
845 1.1.1.1.2.2 bouyer {
846 1.1.1.1.2.2 bouyer RequiredBtypes = AnMapArgTypeToBtype (ArgType);
847 1.1.1.1.2.2 bouyer
848 1.1.1.1.2.2 bouyer ThisNodeBtype = AnGetBtype (ArgOp);
849 1.1.1.1.2.2 bouyer if (ThisNodeBtype == ACPI_UINT32_MAX)
850 1.1.1.1.2.2 bouyer {
851 1.1.1.1.2.2 bouyer goto NextArgument;
852 1.1.1.1.2.2 bouyer }
853 1.1.1.1.2.2 bouyer
854 1.1.1.1.2.2 bouyer /* Examine the arg based on the required type of the arg */
855 1.1.1.1.2.2 bouyer
856 1.1.1.1.2.2 bouyer switch (ArgType)
857 1.1.1.1.2.2 bouyer {
858 1.1.1.1.2.2 bouyer case ARGI_TARGETREF:
859 1.1.1.1.2.2 bouyer
860 1.1.1.1.2.2 bouyer if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
861 1.1.1.1.2.2 bouyer {
862 1.1.1.1.2.2 bouyer /* ZERO is the placeholder for "don't store result" */
863 1.1.1.1.2.2 bouyer
864 1.1.1.1.2.2 bouyer ThisNodeBtype = RequiredBtypes;
865 1.1.1.1.2.2 bouyer break;
866 1.1.1.1.2.2 bouyer }
867 1.1.1.1.2.2 bouyer
868 1.1.1.1.2.2 bouyer if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
869 1.1.1.1.2.2 bouyer {
870 1.1.1.1.2.2 bouyer /*
871 1.1.1.1.2.2 bouyer * This is the case where an original reference to a resource
872 1.1.1.1.2.2 bouyer * descriptor field has been replaced by an (Integer) offset.
873 1.1.1.1.2.2 bouyer * These named fields are supported at compile-time only;
874 1.1.1.1.2.2 bouyer * the names are not passed to the interpreter (via the AML).
875 1.1.1.1.2.2 bouyer */
876 1.1.1.1.2.2 bouyer if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
877 1.1.1.1.2.2 bouyer (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
878 1.1.1.1.2.2 bouyer {
879 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL);
880 1.1.1.1.2.2 bouyer }
881 1.1.1.1.2.2 bouyer else
882 1.1.1.1.2.2 bouyer {
883 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL);
884 1.1.1.1.2.2 bouyer }
885 1.1.1.1.2.2 bouyer break;
886 1.1.1.1.2.2 bouyer }
887 1.1.1.1.2.2 bouyer
888 1.1.1.1.2.2 bouyer if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
889 1.1.1.1.2.2 bouyer (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF))
890 1.1.1.1.2.2 bouyer {
891 1.1.1.1.2.2 bouyer break;
892 1.1.1.1.2.2 bouyer }
893 1.1.1.1.2.2 bouyer
894 1.1.1.1.2.2 bouyer ThisNodeBtype = RequiredBtypes;
895 1.1.1.1.2.2 bouyer break;
896 1.1.1.1.2.2 bouyer
897 1.1.1.1.2.2 bouyer
898 1.1.1.1.2.2 bouyer case ARGI_REFERENCE: /* References */
899 1.1.1.1.2.2 bouyer case ARGI_INTEGER_REF:
900 1.1.1.1.2.2 bouyer case ARGI_OBJECT_REF:
901 1.1.1.1.2.2 bouyer case ARGI_DEVICE_REF:
902 1.1.1.1.2.2 bouyer
903 1.1.1.1.2.2 bouyer switch (ArgOp->Asl.ParseOpcode)
904 1.1.1.1.2.2 bouyer {
905 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL0:
906 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL1:
907 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL2:
908 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL3:
909 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL4:
910 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL5:
911 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL6:
912 1.1.1.1.2.2 bouyer case PARSEOP_LOCAL7:
913 1.1.1.1.2.2 bouyer
914 1.1.1.1.2.2 bouyer /* TBD: implement analysis of current value (type) of the local */
915 1.1.1.1.2.2 bouyer /* For now, just treat any local as a typematch */
916 1.1.1.1.2.2 bouyer
917 1.1.1.1.2.2 bouyer /*ThisNodeBtype = RequiredBtypes;*/
918 1.1.1.1.2.2 bouyer break;
919 1.1.1.1.2.2 bouyer
920 1.1.1.1.2.2 bouyer case PARSEOP_ARG0:
921 1.1.1.1.2.2 bouyer case PARSEOP_ARG1:
922 1.1.1.1.2.2 bouyer case PARSEOP_ARG2:
923 1.1.1.1.2.2 bouyer case PARSEOP_ARG3:
924 1.1.1.1.2.2 bouyer case PARSEOP_ARG4:
925 1.1.1.1.2.2 bouyer case PARSEOP_ARG5:
926 1.1.1.1.2.2 bouyer case PARSEOP_ARG6:
927 1.1.1.1.2.2 bouyer
928 1.1.1.1.2.2 bouyer /* Hard to analyze argument types, sow we won't */
929 1.1.1.1.2.2 bouyer /* For now, just treat any arg as a typematch */
930 1.1.1.1.2.2 bouyer
931 1.1.1.1.2.2 bouyer /* ThisNodeBtype = RequiredBtypes; */
932 1.1.1.1.2.2 bouyer break;
933 1.1.1.1.2.2 bouyer
934 1.1.1.1.2.2 bouyer case PARSEOP_DEBUG:
935 1.1.1.1.2.2 bouyer break;
936 1.1.1.1.2.2 bouyer
937 1.1.1.1.2.2 bouyer case PARSEOP_REFOF:
938 1.1.1.1.2.2 bouyer case PARSEOP_INDEX:
939 1.1.1.1.2.2 bouyer default:
940 1.1.1.1.2.2 bouyer break;
941 1.1.1.1.2.2 bouyer
942 1.1.1.1.2.2 bouyer }
943 1.1.1.1.2.2 bouyer break;
944 1.1.1.1.2.2 bouyer
945 1.1.1.1.2.2 bouyer case ARGI_INTEGER:
946 1.1.1.1.2.2 bouyer default:
947 1.1.1.1.2.2 bouyer break;
948 1.1.1.1.2.2 bouyer }
949 1.1.1.1.2.2 bouyer
950 1.1.1.1.2.2 bouyer
951 1.1.1.1.2.2 bouyer CommonBtypes = ThisNodeBtype & RequiredBtypes;
952 1.1.1.1.2.2 bouyer
953 1.1.1.1.2.2 bouyer if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
954 1.1.1.1.2.2 bouyer {
955 1.1.1.1.2.2 bouyer if (AnIsInternalMethod (ArgOp))
956 1.1.1.1.2.2 bouyer {
957 1.1.1.1.2.2 bouyer return (AE_OK);
958 1.1.1.1.2.2 bouyer }
959 1.1.1.1.2.2 bouyer
960 1.1.1.1.2.2 bouyer /* Check a method call for a valid return value */
961 1.1.1.1.2.2 bouyer
962 1.1.1.1.2.2 bouyer AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
963 1.1.1.1.2.2 bouyer RequiredBtypes, ThisNodeBtype);
964 1.1.1.1.2.2 bouyer }
965 1.1.1.1.2.2 bouyer
966 1.1.1.1.2.2 bouyer /*
967 1.1.1.1.2.2 bouyer * Now check if the actual type(s) match at least one
968 1.1.1.1.2.2 bouyer * bit to the required type
969 1.1.1.1.2.2 bouyer */
970 1.1.1.1.2.2 bouyer else if (!CommonBtypes)
971 1.1.1.1.2.2 bouyer {
972 1.1.1.1.2.2 bouyer /* No match -- this is a type mismatch error */
973 1.1.1.1.2.2 bouyer
974 1.1.1.1.2.2 bouyer AnFormatBtype (StringBuffer, ThisNodeBtype);
975 1.1.1.1.2.2 bouyer AnFormatBtype (StringBuffer2, RequiredBtypes);
976 1.1.1.1.2.2 bouyer
977 1.1.1.1.2.2 bouyer sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]",
978 1.1.1.1.2.2 bouyer StringBuffer, OpInfo->Name, StringBuffer2);
979 1.1.1.1.2.2 bouyer
980 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
981 1.1.1.1.2.2 bouyer }
982 1.1.1.1.2.2 bouyer
983 1.1.1.1.2.2 bouyer NextArgument:
984 1.1.1.1.2.2 bouyer ArgOp = ArgOp->Asl.Next;
985 1.1.1.1.2.2 bouyer INCREMENT_ARG_LIST (RuntimeArgTypes2);
986 1.1.1.1.2.2 bouyer }
987 1.1.1.1.2.2 bouyer break;
988 1.1.1.1.2.2 bouyer
989 1.1.1.1.2.2 bouyer default:
990 1.1.1.1.2.2 bouyer break;
991 1.1.1.1.2.2 bouyer }
992 1.1.1.1.2.2 bouyer
993 1.1.1.1.2.2 bouyer return (AE_OK);
994 1.1.1.1.2.2 bouyer }
995 1.1.1.1.2.2 bouyer
996 1.1.1.1.2.2 bouyer
997 1.1.1.1.2.2 bouyer /*******************************************************************************
998 1.1.1.1.2.2 bouyer *
999 1.1.1.1.2.2 bouyer * FUNCTION: AnOtherSemanticAnalysisWalkBegin
1000 1.1.1.1.2.2 bouyer *
1001 1.1.1.1.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
1002 1.1.1.1.2.2 bouyer *
1003 1.1.1.1.2.2 bouyer * RETURN: Status
1004 1.1.1.1.2.2 bouyer *
1005 1.1.1.1.2.2 bouyer * DESCRIPTION: Descending callback for the analysis walk. Checks for
1006 1.1.1.1.2.2 bouyer * miscellaneous issues in the code.
1007 1.1.1.1.2.2 bouyer *
1008 1.1.1.1.2.2 bouyer ******************************************************************************/
1009 1.1.1.1.2.2 bouyer
1010 1.1.1.1.2.2 bouyer ACPI_STATUS
1011 1.1.1.1.2.2 bouyer AnOtherSemanticAnalysisWalkBegin (
1012 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op,
1013 1.1.1.1.2.2 bouyer UINT32 Level,
1014 1.1.1.1.2.2 bouyer void *Context)
1015 1.1.1.1.2.2 bouyer {
1016 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *ArgNode;
1017 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *PrevArgNode = NULL;
1018 1.1.1.1.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
1019 1.1.1.1.2.2 bouyer
1020 1.1.1.1.2.2 bouyer
1021 1.1.1.1.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1022 1.1.1.1.2.2 bouyer
1023 1.1.1.1.2.2 bouyer /*
1024 1.1.1.1.2.2 bouyer * Determine if an execution class operator actually does something by
1025 1.1.1.1.2.2 bouyer * checking if it has a target and/or the function return value is used.
1026 1.1.1.1.2.2 bouyer * (Target is optional, so a standalone statement can actually do nothing.)
1027 1.1.1.1.2.2 bouyer */
1028 1.1.1.1.2.2 bouyer if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
1029 1.1.1.1.2.2 bouyer (OpInfo->Flags & AML_HAS_RETVAL) &&
1030 1.1.1.1.2.2 bouyer (!AnIsResultUsed (Op)))
1031 1.1.1.1.2.2 bouyer {
1032 1.1.1.1.2.2 bouyer if (OpInfo->Flags & AML_HAS_TARGET)
1033 1.1.1.1.2.2 bouyer {
1034 1.1.1.1.2.2 bouyer /*
1035 1.1.1.1.2.2 bouyer * Find the target node, it is always the last child. If the traget
1036 1.1.1.1.2.2 bouyer * is not specified in the ASL, a default node of type Zero was
1037 1.1.1.1.2.2 bouyer * created by the parser.
1038 1.1.1.1.2.2 bouyer */
1039 1.1.1.1.2.2 bouyer ArgNode = Op->Asl.Child;
1040 1.1.1.1.2.2 bouyer while (ArgNode->Asl.Next)
1041 1.1.1.1.2.2 bouyer {
1042 1.1.1.1.2.2 bouyer PrevArgNode = ArgNode;
1043 1.1.1.1.2.2 bouyer ArgNode = ArgNode->Asl.Next;
1044 1.1.1.1.2.2 bouyer }
1045 1.1.1.1.2.2 bouyer
1046 1.1.1.1.2.2 bouyer /* Divide() is the only weird case, it has two targets */
1047 1.1.1.1.2.2 bouyer
1048 1.1.1.1.2.2 bouyer if (Op->Asl.AmlOpcode == AML_DIVIDE_OP)
1049 1.1.1.1.2.2 bouyer {
1050 1.1.1.1.2.2 bouyer if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) &&
1051 1.1.1.1.2.2 bouyer (PrevArgNode) &&
1052 1.1.1.1.2.2 bouyer (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO))
1053 1.1.1.1.2.2 bouyer {
1054 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED,
1055 1.1.1.1.2.2 bouyer Op, Op->Asl.ExternalName);
1056 1.1.1.1.2.2 bouyer }
1057 1.1.1.1.2.2 bouyer }
1058 1.1.1.1.2.2 bouyer else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO)
1059 1.1.1.1.2.2 bouyer {
1060 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED,
1061 1.1.1.1.2.2 bouyer Op, Op->Asl.ExternalName);
1062 1.1.1.1.2.2 bouyer }
1063 1.1.1.1.2.2 bouyer }
1064 1.1.1.1.2.2 bouyer else
1065 1.1.1.1.2.2 bouyer {
1066 1.1.1.1.2.2 bouyer /*
1067 1.1.1.1.2.2 bouyer * Has no target and the result is not used. Only a couple opcodes
1068 1.1.1.1.2.2 bouyer * can have this combination.
1069 1.1.1.1.2.2 bouyer */
1070 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
1071 1.1.1.1.2.2 bouyer {
1072 1.1.1.1.2.2 bouyer case PARSEOP_ACQUIRE:
1073 1.1.1.1.2.2 bouyer case PARSEOP_WAIT:
1074 1.1.1.1.2.2 bouyer case PARSEOP_LOADTABLE:
1075 1.1.1.1.2.2 bouyer break;
1076 1.1.1.1.2.2 bouyer
1077 1.1.1.1.2.2 bouyer default:
1078 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED,
1079 1.1.1.1.2.2 bouyer Op, Op->Asl.ExternalName);
1080 1.1.1.1.2.2 bouyer break;
1081 1.1.1.1.2.2 bouyer }
1082 1.1.1.1.2.2 bouyer }
1083 1.1.1.1.2.2 bouyer }
1084 1.1.1.1.2.2 bouyer
1085 1.1.1.1.2.2 bouyer
1086 1.1.1.1.2.2 bouyer /*
1087 1.1.1.1.2.2 bouyer * Semantic checks for individual ASL operators
1088 1.1.1.1.2.2 bouyer */
1089 1.1.1.1.2.2 bouyer switch (Op->Asl.ParseOpcode)
1090 1.1.1.1.2.2 bouyer {
1091 1.1.1.1.2.2 bouyer case PARSEOP_ACQUIRE:
1092 1.1.1.1.2.2 bouyer case PARSEOP_WAIT:
1093 1.1.1.1.2.2 bouyer /*
1094 1.1.1.1.2.2 bouyer * Emit a warning if the timeout parameter for these operators is not
1095 1.1.1.1.2.2 bouyer * ACPI_WAIT_FOREVER, and the result value from the operator is not
1096 1.1.1.1.2.2 bouyer * checked, meaning that a timeout could happen, but the code
1097 1.1.1.1.2.2 bouyer * would not know about it.
1098 1.1.1.1.2.2 bouyer */
1099 1.1.1.1.2.2 bouyer
1100 1.1.1.1.2.2 bouyer /* First child is the namepath, 2nd child is timeout */
1101 1.1.1.1.2.2 bouyer
1102 1.1.1.1.2.2 bouyer ArgNode = Op->Asl.Child;
1103 1.1.1.1.2.2 bouyer ArgNode = ArgNode->Asl.Next;
1104 1.1.1.1.2.2 bouyer
1105 1.1.1.1.2.2 bouyer /*
1106 1.1.1.1.2.2 bouyer * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
1107 1.1.1.1.2.2 bouyer * 0xFFFF or greater
1108 1.1.1.1.2.2 bouyer */
1109 1.1.1.1.2.2 bouyer if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
1110 1.1.1.1.2.2 bouyer (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) &&
1111 1.1.1.1.2.2 bouyer (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER))
1112 1.1.1.1.2.2 bouyer {
1113 1.1.1.1.2.2 bouyer break;
1114 1.1.1.1.2.2 bouyer }
1115 1.1.1.1.2.2 bouyer
1116 1.1.1.1.2.2 bouyer /*
1117 1.1.1.1.2.2 bouyer * The operation could timeout. If the return value is not used
1118 1.1.1.1.2.2 bouyer * (indicates timeout occurred), issue a warning
1119 1.1.1.1.2.2 bouyer */
1120 1.1.1.1.2.2 bouyer if (!AnIsResultUsed (Op))
1121 1.1.1.1.2.2 bouyer {
1122 1.1.1.1.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode,
1123 1.1.1.1.2.2 bouyer Op->Asl.ExternalName);
1124 1.1.1.1.2.2 bouyer }
1125 1.1.1.1.2.2 bouyer break;
1126 1.1.1.1.2.2 bouyer
1127 1.1.1.1.2.2 bouyer case PARSEOP_CREATEFIELD:
1128 1.1.1.1.2.2 bouyer /*
1129 1.1.1.1.2.2 bouyer * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
1130 1.1.1.1.2.2 bouyer */
1131 1.1.1.1.2.2 bouyer ArgNode = Op->Asl.Child;
1132 1.1.1.1.2.2 bouyer ArgNode = ArgNode->Asl.Next;
1133 1.1.1.1.2.2 bouyer ArgNode = ArgNode->Asl.Next;
1134 1.1.1.1.2.2 bouyer
1135 1.1.1.1.2.2 bouyer if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) ||
1136 1.1.1.1.2.2 bouyer ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) &&
1137 1.1.1.1.2.2 bouyer (ArgNode->Asl.Value.Integer == 0)))
1138 1.1.1.1.2.2 bouyer {
1139 1.1.1.1.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL);
1140 1.1.1.1.2.2 bouyer }
1141 1.1.1.1.2.2 bouyer break;
1142 1.1.1.1.2.2 bouyer
1143 1.1.1.1.2.2 bouyer default:
1144 1.1.1.1.2.2 bouyer break;
1145 1.1.1.1.2.2 bouyer }
1146 1.1.1.1.2.2 bouyer
1147 1.1.1.1.2.2 bouyer return (AE_OK);
1148 1.1.1.1.2.2 bouyer }
1149