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