aslwalks.c revision 1.3.2.2 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.2 christos * Module Name: aslwalks.c - Miscellaneous analytical parse tree walks
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1 jruoho /*
8 1.3.2.2 skrll * Copyright (C) 2000 - 2016, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1 jruoho * modification, are permitted provided that the following conditions
13 1.1 jruoho * are met:
14 1.1 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1 jruoho * without modification.
17 1.1 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1 jruoho * binary redistribution.
22 1.1 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1 jruoho * from this software without specific prior written permission.
25 1.1 jruoho *
26 1.1 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1 jruoho * Software Foundation.
29 1.1 jruoho *
30 1.1 jruoho * NO WARRANTY
31 1.1 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "aslcompiler.h"
45 1.1 jruoho #include "aslcompiler.y.h"
46 1.1 jruoho #include "acparser.h"
47 1.1 jruoho #include "amlcode.h"
48 1.1 jruoho
49 1.1 jruoho
50 1.1 jruoho #define _COMPONENT ACPI_COMPILER
51 1.1 jruoho ACPI_MODULE_NAME ("aslwalks")
52 1.1 jruoho
53 1.1 jruoho
54 1.3.2.2 skrll /* Local prototypes */
55 1.3.2.2 skrll
56 1.3.2.2 skrll static void
57 1.3.2.2 skrll AnAnalyzeStoreOperator (
58 1.3.2.2 skrll ACPI_PARSE_OBJECT *Op);
59 1.3.2.2 skrll
60 1.3.2.2 skrll
61 1.1 jruoho /*******************************************************************************
62 1.1 jruoho *
63 1.1 jruoho * FUNCTION: AnMethodTypingWalkEnd
64 1.1 jruoho *
65 1.1 jruoho * PARAMETERS: ASL_WALK_CALLBACK
66 1.1 jruoho *
67 1.1 jruoho * RETURN: Status
68 1.1 jruoho *
69 1.1 jruoho * DESCRIPTION: Ascending callback for typing walk. Complete the method
70 1.1 jruoho * return analysis. Check methods for:
71 1.1 jruoho * 1) Initialized local variables
72 1.1 jruoho * 2) Valid arguments
73 1.1 jruoho * 3) Return types
74 1.1 jruoho *
75 1.1 jruoho ******************************************************************************/
76 1.1 jruoho
77 1.1 jruoho ACPI_STATUS
78 1.1 jruoho AnMethodTypingWalkEnd (
79 1.1 jruoho ACPI_PARSE_OBJECT *Op,
80 1.1 jruoho UINT32 Level,
81 1.1 jruoho void *Context)
82 1.1 jruoho {
83 1.3.2.2 skrll UINT32 ThisOpBtype;
84 1.1 jruoho
85 1.1 jruoho
86 1.1 jruoho switch (Op->Asl.ParseOpcode)
87 1.1 jruoho {
88 1.1 jruoho case PARSEOP_METHOD:
89 1.1 jruoho
90 1.1 jruoho Op->Asl.CompileFlags |= NODE_METHOD_TYPED;
91 1.1 jruoho break;
92 1.1 jruoho
93 1.1 jruoho case PARSEOP_RETURN:
94 1.1 jruoho
95 1.1 jruoho if ((Op->Asl.Child) &&
96 1.1 jruoho (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
97 1.1 jruoho {
98 1.3.2.2 skrll ThisOpBtype = AnGetBtype (Op->Asl.Child);
99 1.1 jruoho
100 1.1 jruoho if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
101 1.3.2.2 skrll (ThisOpBtype == (ACPI_UINT32_MAX -1)))
102 1.1 jruoho {
103 1.1 jruoho /*
104 1.1 jruoho * The called method is untyped at this time (typically a
105 1.1 jruoho * forward reference).
106 1.1 jruoho *
107 1.1 jruoho * Check for a recursive method call first.
108 1.1 jruoho */
109 1.1 jruoho if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)
110 1.1 jruoho {
111 1.1 jruoho /* We must type the method here */
112 1.1 jruoho
113 1.1 jruoho TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
114 1.1 jruoho ASL_WALK_VISIT_UPWARD, NULL,
115 1.1 jruoho AnMethodTypingWalkEnd, NULL);
116 1.1 jruoho
117 1.3.2.2 skrll ThisOpBtype = AnGetBtype (Op->Asl.Child);
118 1.1 jruoho }
119 1.1 jruoho }
120 1.1 jruoho
121 1.1 jruoho /* Returns a value, save the value type */
122 1.1 jruoho
123 1.1 jruoho if (Op->Asl.ParentMethod)
124 1.1 jruoho {
125 1.3.2.2 skrll Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype;
126 1.1 jruoho }
127 1.1 jruoho }
128 1.1 jruoho break;
129 1.1 jruoho
130 1.1 jruoho default:
131 1.2 christos
132 1.1 jruoho break;
133 1.1 jruoho }
134 1.1 jruoho
135 1.1 jruoho return (AE_OK);
136 1.1 jruoho }
137 1.1 jruoho
138 1.1 jruoho
139 1.1 jruoho /*******************************************************************************
140 1.1 jruoho *
141 1.1 jruoho * FUNCTION: AnOperandTypecheckWalkEnd
142 1.1 jruoho *
143 1.1 jruoho * PARAMETERS: ASL_WALK_CALLBACK
144 1.1 jruoho *
145 1.1 jruoho * RETURN: Status
146 1.1 jruoho *
147 1.1 jruoho * DESCRIPTION: Ascending callback for analysis walk. Complete method
148 1.1 jruoho * return analysis.
149 1.1 jruoho *
150 1.1 jruoho ******************************************************************************/
151 1.1 jruoho
152 1.1 jruoho ACPI_STATUS
153 1.1 jruoho AnOperandTypecheckWalkEnd (
154 1.1 jruoho ACPI_PARSE_OBJECT *Op,
155 1.1 jruoho UINT32 Level,
156 1.1 jruoho void *Context)
157 1.1 jruoho {
158 1.1 jruoho const ACPI_OPCODE_INFO *OpInfo;
159 1.1 jruoho UINT32 RuntimeArgTypes;
160 1.1 jruoho UINT32 RuntimeArgTypes2;
161 1.1 jruoho UINT32 RequiredBtypes;
162 1.1 jruoho UINT32 ThisNodeBtype;
163 1.1 jruoho UINT32 CommonBtypes;
164 1.1 jruoho UINT32 OpcodeClass;
165 1.1 jruoho ACPI_PARSE_OBJECT *ArgOp;
166 1.1 jruoho UINT32 ArgType;
167 1.1 jruoho
168 1.1 jruoho
169 1.1 jruoho switch (Op->Asl.AmlOpcode)
170 1.1 jruoho {
171 1.1 jruoho case AML_RAW_DATA_BYTE:
172 1.1 jruoho case AML_RAW_DATA_WORD:
173 1.1 jruoho case AML_RAW_DATA_DWORD:
174 1.1 jruoho case AML_RAW_DATA_QWORD:
175 1.1 jruoho case AML_RAW_DATA_BUFFER:
176 1.1 jruoho case AML_RAW_DATA_CHAIN:
177 1.1 jruoho case AML_PACKAGE_LENGTH:
178 1.1 jruoho case AML_UNASSIGNED_OPCODE:
179 1.1 jruoho case AML_DEFAULT_ARG_OP:
180 1.1 jruoho
181 1.1 jruoho /* Ignore the internal (compiler-only) AML opcodes */
182 1.1 jruoho
183 1.1 jruoho return (AE_OK);
184 1.1 jruoho
185 1.1 jruoho default:
186 1.2 christos
187 1.1 jruoho break;
188 1.1 jruoho }
189 1.1 jruoho
190 1.1 jruoho OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
191 1.1 jruoho if (!OpInfo)
192 1.1 jruoho {
193 1.1 jruoho return (AE_OK);
194 1.1 jruoho }
195 1.1 jruoho
196 1.3.2.2 skrll ArgOp = Op->Asl.Child;
197 1.3.2.2 skrll OpcodeClass = OpInfo->Class;
198 1.1 jruoho RuntimeArgTypes = OpInfo->RuntimeArgs;
199 1.1 jruoho
200 1.1 jruoho #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
201 1.1 jruoho /*
202 1.1 jruoho * Update 11/2008: In practice, we can't perform this check. A simple
203 1.1 jruoho * analysis is not sufficient. Also, it can cause errors when compiling
204 1.1 jruoho * disassembled code because of the way Switch operators are implemented
205 1.1 jruoho * (a While(One) loop with a named temp variable created within.)
206 1.1 jruoho */
207 1.1 jruoho
208 1.1 jruoho /*
209 1.1 jruoho * If we are creating a named object, check if we are within a while loop
210 1.1 jruoho * by checking if the parent is a WHILE op. This is a simple analysis, but
211 1.1 jruoho * probably sufficient for many cases.
212 1.1 jruoho *
213 1.1 jruoho * Allow Scope(), Buffer(), and Package().
214 1.1 jruoho */
215 1.1 jruoho if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) ||
216 1.1 jruoho ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE)))
217 1.1 jruoho {
218 1.1 jruoho if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP)
219 1.1 jruoho {
220 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL);
221 1.1 jruoho }
222 1.1 jruoho }
223 1.1 jruoho #endif
224 1.1 jruoho
225 1.1 jruoho /*
226 1.1 jruoho * Special case for control opcodes IF/RETURN/WHILE since they
227 1.1 jruoho * have no runtime arg list (at this time)
228 1.1 jruoho */
229 1.1 jruoho switch (Op->Asl.AmlOpcode)
230 1.1 jruoho {
231 1.1 jruoho case AML_IF_OP:
232 1.1 jruoho case AML_WHILE_OP:
233 1.1 jruoho case AML_RETURN_OP:
234 1.1 jruoho
235 1.1 jruoho if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
236 1.1 jruoho {
237 1.1 jruoho /* Check for an internal method */
238 1.1 jruoho
239 1.1 jruoho if (AnIsInternalMethod (ArgOp))
240 1.1 jruoho {
241 1.1 jruoho return (AE_OK);
242 1.1 jruoho }
243 1.1 jruoho
244 1.1 jruoho /* The lone arg is a method call, check it */
245 1.1 jruoho
246 1.1 jruoho RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
247 1.1 jruoho if (Op->Asl.AmlOpcode == AML_RETURN_OP)
248 1.1 jruoho {
249 1.1 jruoho RequiredBtypes = 0xFFFFFFFF;
250 1.1 jruoho }
251 1.1 jruoho
252 1.1 jruoho ThisNodeBtype = AnGetBtype (ArgOp);
253 1.1 jruoho if (ThisNodeBtype == ACPI_UINT32_MAX)
254 1.1 jruoho {
255 1.1 jruoho return (AE_OK);
256 1.1 jruoho }
257 1.3.2.2 skrll
258 1.1 jruoho AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
259 1.1 jruoho RequiredBtypes, ThisNodeBtype);
260 1.1 jruoho }
261 1.1 jruoho return (AE_OK);
262 1.1 jruoho
263 1.3.2.1 skrll case AML_EXTERNAL_OP:
264 1.3.2.1 skrll /*
265 1.3.2.1 skrll * Not really a "runtime" opcode since it used by disassembler only.
266 1.3.2.1 skrll * The parser will find any issues with the operands.
267 1.3.2.1 skrll */
268 1.3.2.1 skrll return (AE_OK);
269 1.3.2.1 skrll
270 1.1 jruoho default:
271 1.2 christos
272 1.1 jruoho break;
273 1.1 jruoho }
274 1.1 jruoho
275 1.1 jruoho /* Ignore the non-executable opcodes */
276 1.1 jruoho
277 1.1 jruoho if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
278 1.1 jruoho {
279 1.1 jruoho return (AE_OK);
280 1.1 jruoho }
281 1.1 jruoho
282 1.3.2.2 skrll /*
283 1.3.2.2 skrll * Special handling for certain opcodes.
284 1.3.2.2 skrll */
285 1.3.2.2 skrll switch (Op->Asl.AmlOpcode)
286 1.3.2.2 skrll {
287 1.3.2.2 skrll /* BankField has one TermArg */
288 1.3.2.2 skrll
289 1.3.2.2 skrll case AML_BANK_FIELD_OP:
290 1.3.2.2 skrll
291 1.3.2.2 skrll OpcodeClass = AML_CLASS_EXECUTE;
292 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
293 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
294 1.3.2.2 skrll break;
295 1.3.2.2 skrll
296 1.3.2.2 skrll /* Operation Region has 2 TermArgs */
297 1.3.2.2 skrll
298 1.3.2.2 skrll case AML_REGION_OP:
299 1.3.2.2 skrll
300 1.3.2.2 skrll OpcodeClass = AML_CLASS_EXECUTE;
301 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
302 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
303 1.3.2.2 skrll break;
304 1.3.2.2 skrll
305 1.3.2.2 skrll /* DataTableRegion has 3 TermArgs */
306 1.3.2.2 skrll
307 1.3.2.2 skrll case AML_DATA_REGION_OP:
308 1.3.2.2 skrll
309 1.3.2.2 skrll OpcodeClass = AML_CLASS_EXECUTE;
310 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
311 1.3.2.2 skrll break;
312 1.3.2.2 skrll
313 1.3.2.2 skrll /* Buffers/Packages have a length that is a TermArg */
314 1.3.2.2 skrll
315 1.3.2.2 skrll case AML_BUFFER_OP:
316 1.3.2.2 skrll case AML_PACKAGE_OP:
317 1.3.2.2 skrll case AML_VAR_PACKAGE_OP:
318 1.3.2.2 skrll
319 1.3.2.2 skrll /* If length is a constant, we are done */
320 1.3.2.2 skrll
321 1.3.2.2 skrll if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
322 1.3.2.2 skrll (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA))
323 1.3.2.2 skrll {
324 1.3.2.2 skrll return (AE_OK);
325 1.3.2.2 skrll }
326 1.3.2.2 skrll break;
327 1.3.2.2 skrll
328 1.3.2.2 skrll /* Store can write any object to the Debug object */
329 1.3.2.2 skrll
330 1.3.2.2 skrll case AML_STORE_OP:
331 1.3.2.2 skrll /*
332 1.3.2.2 skrll * If this is a Store() to the Debug object, we don't need
333 1.3.2.2 skrll * to perform any further validation -- because a Store of
334 1.3.2.2 skrll * any object to Debug is permitted and supported.
335 1.3.2.2 skrll */
336 1.3.2.2 skrll if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP)
337 1.3.2.2 skrll {
338 1.3.2.2 skrll return (AE_OK);
339 1.3.2.2 skrll }
340 1.3.2.2 skrll break;
341 1.3.2.2 skrll
342 1.3.2.2 skrll default:
343 1.3.2.2 skrll break;
344 1.3.2.2 skrll }
345 1.3.2.2 skrll
346 1.1 jruoho switch (OpcodeClass)
347 1.1 jruoho {
348 1.1 jruoho case AML_CLASS_EXECUTE:
349 1.1 jruoho case AML_CLASS_CREATE:
350 1.1 jruoho case AML_CLASS_CONTROL:
351 1.1 jruoho case AML_CLASS_RETURN_VALUE:
352 1.1 jruoho
353 1.1 jruoho /* Reverse the runtime argument list */
354 1.1 jruoho
355 1.1 jruoho RuntimeArgTypes2 = 0;
356 1.1 jruoho while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
357 1.1 jruoho {
358 1.1 jruoho RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
359 1.1 jruoho RuntimeArgTypes2 |= ArgType;
360 1.1 jruoho INCREMENT_ARG_LIST (RuntimeArgTypes);
361 1.1 jruoho }
362 1.1 jruoho
363 1.3.2.2 skrll /* Typecheck each argument */
364 1.3.2.2 skrll
365 1.1 jruoho while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
366 1.1 jruoho {
367 1.3.2.2 skrll /* Get the required type(s) for the argument */
368 1.3.2.2 skrll
369 1.1 jruoho RequiredBtypes = AnMapArgTypeToBtype (ArgType);
370 1.1 jruoho
371 1.3.2.1 skrll if (!ArgOp)
372 1.3.2.1 skrll {
373 1.3.2.1 skrll AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
374 1.3.2.1 skrll "Null ArgOp in argument loop");
375 1.3.2.1 skrll AslAbort ();
376 1.3.2.1 skrll }
377 1.3.2.1 skrll
378 1.3.2.2 skrll /* Get the actual type of the argument */
379 1.3.2.2 skrll
380 1.1 jruoho ThisNodeBtype = AnGetBtype (ArgOp);
381 1.1 jruoho if (ThisNodeBtype == ACPI_UINT32_MAX)
382 1.1 jruoho {
383 1.1 jruoho goto NextArgument;
384 1.1 jruoho }
385 1.1 jruoho
386 1.1 jruoho /* Examine the arg based on the required type of the arg */
387 1.1 jruoho
388 1.1 jruoho switch (ArgType)
389 1.1 jruoho {
390 1.1 jruoho case ARGI_TARGETREF:
391 1.1 jruoho
392 1.1 jruoho if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
393 1.1 jruoho {
394 1.1 jruoho /* ZERO is the placeholder for "don't store result" */
395 1.1 jruoho
396 1.1 jruoho ThisNodeBtype = RequiredBtypes;
397 1.1 jruoho break;
398 1.1 jruoho }
399 1.1 jruoho
400 1.3.2.2 skrll /* Fallthrough */
401 1.3.2.2 skrll
402 1.3.2.2 skrll case ARGI_STORE_TARGET:
403 1.3.2.2 skrll
404 1.1 jruoho if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
405 1.1 jruoho {
406 1.1 jruoho /*
407 1.1 jruoho * This is the case where an original reference to a resource
408 1.1 jruoho * descriptor field has been replaced by an (Integer) offset.
409 1.1 jruoho * These named fields are supported at compile-time only;
410 1.1 jruoho * the names are not passed to the interpreter (via the AML).
411 1.1 jruoho */
412 1.1 jruoho if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
413 1.1 jruoho (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
414 1.1 jruoho {
415 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD,
416 1.3.2.2 skrll ArgOp, NULL);
417 1.1 jruoho }
418 1.1 jruoho else
419 1.1 jruoho {
420 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
421 1.3.2.2 skrll ArgOp, NULL);
422 1.1 jruoho }
423 1.1 jruoho }
424 1.1 jruoho break;
425 1.1 jruoho
426 1.1 jruoho
427 1.3.2.2 skrll #ifdef __FUTURE_IMPLEMENTATION
428 1.3.2.2 skrll /*
429 1.3.2.2 skrll * Possible future typechecking support
430 1.3.2.2 skrll */
431 1.1 jruoho case ARGI_REFERENCE: /* References */
432 1.1 jruoho case ARGI_INTEGER_REF:
433 1.1 jruoho case ARGI_OBJECT_REF:
434 1.1 jruoho case ARGI_DEVICE_REF:
435 1.1 jruoho
436 1.1 jruoho switch (ArgOp->Asl.ParseOpcode)
437 1.1 jruoho {
438 1.1 jruoho case PARSEOP_LOCAL0:
439 1.1 jruoho case PARSEOP_LOCAL1:
440 1.1 jruoho case PARSEOP_LOCAL2:
441 1.1 jruoho case PARSEOP_LOCAL3:
442 1.1 jruoho case PARSEOP_LOCAL4:
443 1.1 jruoho case PARSEOP_LOCAL5:
444 1.1 jruoho case PARSEOP_LOCAL6:
445 1.1 jruoho case PARSEOP_LOCAL7:
446 1.1 jruoho
447 1.1 jruoho /* TBD: implement analysis of current value (type) of the local */
448 1.1 jruoho /* For now, just treat any local as a typematch */
449 1.1 jruoho
450 1.1 jruoho /*ThisNodeBtype = RequiredBtypes;*/
451 1.1 jruoho break;
452 1.1 jruoho
453 1.1 jruoho case PARSEOP_ARG0:
454 1.1 jruoho case PARSEOP_ARG1:
455 1.1 jruoho case PARSEOP_ARG2:
456 1.1 jruoho case PARSEOP_ARG3:
457 1.1 jruoho case PARSEOP_ARG4:
458 1.1 jruoho case PARSEOP_ARG5:
459 1.1 jruoho case PARSEOP_ARG6:
460 1.1 jruoho
461 1.3.2.2 skrll /* Hard to analyze argument types, so we won't */
462 1.3.2.2 skrll /* for now. Just treat any arg as a typematch */
463 1.1 jruoho
464 1.1 jruoho /* ThisNodeBtype = RequiredBtypes; */
465 1.1 jruoho break;
466 1.1 jruoho
467 1.1 jruoho case PARSEOP_DEBUG:
468 1.1 jruoho case PARSEOP_REFOF:
469 1.1 jruoho case PARSEOP_INDEX:
470 1.1 jruoho default:
471 1.2 christos
472 1.1 jruoho break;
473 1.1 jruoho }
474 1.1 jruoho break;
475 1.3.2.2 skrll #endif
476 1.1 jruoho case ARGI_INTEGER:
477 1.1 jruoho default:
478 1.2 christos
479 1.1 jruoho break;
480 1.1 jruoho }
481 1.1 jruoho
482 1.1 jruoho
483 1.3.2.2 skrll /* Check for a type mismatch (required versus actual) */
484 1.3.2.2 skrll
485 1.1 jruoho CommonBtypes = ThisNodeBtype & RequiredBtypes;
486 1.1 jruoho
487 1.1 jruoho if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
488 1.1 jruoho {
489 1.1 jruoho if (AnIsInternalMethod (ArgOp))
490 1.1 jruoho {
491 1.1 jruoho return (AE_OK);
492 1.1 jruoho }
493 1.1 jruoho
494 1.1 jruoho /* Check a method call for a valid return value */
495 1.1 jruoho
496 1.1 jruoho AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
497 1.1 jruoho RequiredBtypes, ThisNodeBtype);
498 1.1 jruoho }
499 1.1 jruoho
500 1.1 jruoho /*
501 1.1 jruoho * Now check if the actual type(s) match at least one
502 1.1 jruoho * bit to the required type
503 1.1 jruoho */
504 1.1 jruoho else if (!CommonBtypes)
505 1.1 jruoho {
506 1.1 jruoho /* No match -- this is a type mismatch error */
507 1.1 jruoho
508 1.1 jruoho AnFormatBtype (StringBuffer, ThisNodeBtype);
509 1.1 jruoho AnFormatBtype (StringBuffer2, RequiredBtypes);
510 1.1 jruoho
511 1.2 christos snprintf (MsgBuffer, sizeof(MsgBuffer), "[%s] found, %s operator requires [%s]",
512 1.3.2.2 skrll StringBuffer, OpInfo->Name, StringBuffer2);
513 1.1 jruoho
514 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
515 1.3.2.2 skrll ArgOp, MsgBuffer);
516 1.1 jruoho }
517 1.1 jruoho
518 1.1 jruoho NextArgument:
519 1.1 jruoho ArgOp = ArgOp->Asl.Next;
520 1.1 jruoho INCREMENT_ARG_LIST (RuntimeArgTypes2);
521 1.1 jruoho }
522 1.1 jruoho break;
523 1.1 jruoho
524 1.1 jruoho default:
525 1.2 christos
526 1.1 jruoho break;
527 1.1 jruoho }
528 1.1 jruoho
529 1.1 jruoho return (AE_OK);
530 1.1 jruoho }
531 1.1 jruoho
532 1.1 jruoho
533 1.1 jruoho /*******************************************************************************
534 1.1 jruoho *
535 1.1 jruoho * FUNCTION: AnOtherSemanticAnalysisWalkBegin
536 1.1 jruoho *
537 1.1 jruoho * PARAMETERS: ASL_WALK_CALLBACK
538 1.1 jruoho *
539 1.1 jruoho * RETURN: Status
540 1.1 jruoho *
541 1.1 jruoho * DESCRIPTION: Descending callback for the analysis walk. Checks for
542 1.1 jruoho * miscellaneous issues in the code.
543 1.1 jruoho *
544 1.1 jruoho ******************************************************************************/
545 1.1 jruoho
546 1.1 jruoho ACPI_STATUS
547 1.1 jruoho AnOtherSemanticAnalysisWalkBegin (
548 1.1 jruoho ACPI_PARSE_OBJECT *Op,
549 1.1 jruoho UINT32 Level,
550 1.1 jruoho void *Context)
551 1.1 jruoho {
552 1.3.2.2 skrll ACPI_PARSE_OBJECT *ArgOp;
553 1.3.2.2 skrll ACPI_PARSE_OBJECT *PrevArgOp = NULL;
554 1.1 jruoho const ACPI_OPCODE_INFO *OpInfo;
555 1.2 christos ACPI_NAMESPACE_NODE *Node;
556 1.1 jruoho
557 1.1 jruoho
558 1.1 jruoho OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
559 1.1 jruoho
560 1.3.2.2 skrll
561 1.1 jruoho /*
562 1.1 jruoho * Determine if an execution class operator actually does something by
563 1.1 jruoho * checking if it has a target and/or the function return value is used.
564 1.1 jruoho * (Target is optional, so a standalone statement can actually do nothing.)
565 1.1 jruoho */
566 1.1 jruoho if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
567 1.1 jruoho (OpInfo->Flags & AML_HAS_RETVAL) &&
568 1.1 jruoho (!AnIsResultUsed (Op)))
569 1.1 jruoho {
570 1.1 jruoho if (OpInfo->Flags & AML_HAS_TARGET)
571 1.1 jruoho {
572 1.1 jruoho /*
573 1.3.2.2 skrll * Find the target node, it is always the last child. If the target
574 1.1 jruoho * is not specified in the ASL, a default node of type Zero was
575 1.1 jruoho * created by the parser.
576 1.1 jruoho */
577 1.3.2.2 skrll ArgOp = Op->Asl.Child;
578 1.3.2.2 skrll while (ArgOp->Asl.Next)
579 1.1 jruoho {
580 1.3.2.2 skrll PrevArgOp = ArgOp;
581 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
582 1.1 jruoho }
583 1.1 jruoho
584 1.1 jruoho /* Divide() is the only weird case, it has two targets */
585 1.1 jruoho
586 1.1 jruoho if (Op->Asl.AmlOpcode == AML_DIVIDE_OP)
587 1.1 jruoho {
588 1.3.2.2 skrll if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) &&
589 1.3.2.2 skrll (PrevArgOp) &&
590 1.3.2.2 skrll (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO))
591 1.1 jruoho {
592 1.2 christos AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
593 1.1 jruoho Op, Op->Asl.ExternalName);
594 1.1 jruoho }
595 1.1 jruoho }
596 1.3.2.2 skrll
597 1.3.2.2 skrll else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
598 1.1 jruoho {
599 1.2 christos AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
600 1.1 jruoho Op, Op->Asl.ExternalName);
601 1.1 jruoho }
602 1.1 jruoho }
603 1.1 jruoho else
604 1.1 jruoho {
605 1.1 jruoho /*
606 1.1 jruoho * Has no target and the result is not used. Only a couple opcodes
607 1.1 jruoho * can have this combination.
608 1.1 jruoho */
609 1.1 jruoho switch (Op->Asl.ParseOpcode)
610 1.1 jruoho {
611 1.1 jruoho case PARSEOP_ACQUIRE:
612 1.1 jruoho case PARSEOP_WAIT:
613 1.1 jruoho case PARSEOP_LOADTABLE:
614 1.2 christos
615 1.1 jruoho break;
616 1.1 jruoho
617 1.1 jruoho default:
618 1.2 christos
619 1.2 christos AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
620 1.1 jruoho Op, Op->Asl.ExternalName);
621 1.1 jruoho break;
622 1.1 jruoho }
623 1.1 jruoho }
624 1.1 jruoho }
625 1.1 jruoho
626 1.1 jruoho
627 1.1 jruoho /*
628 1.1 jruoho * Semantic checks for individual ASL operators
629 1.1 jruoho */
630 1.1 jruoho switch (Op->Asl.ParseOpcode)
631 1.1 jruoho {
632 1.3.2.2 skrll case PARSEOP_STORE:
633 1.3.2.2 skrll
634 1.3.2.2 skrll if (Gbl_DoTypechecking)
635 1.3.2.2 skrll {
636 1.3.2.2 skrll AnAnalyzeStoreOperator (Op);
637 1.3.2.2 skrll }
638 1.3.2.2 skrll break;
639 1.3.2.2 skrll
640 1.3.2.2 skrll
641 1.1 jruoho case PARSEOP_ACQUIRE:
642 1.1 jruoho case PARSEOP_WAIT:
643 1.1 jruoho /*
644 1.1 jruoho * Emit a warning if the timeout parameter for these operators is not
645 1.1 jruoho * ACPI_WAIT_FOREVER, and the result value from the operator is not
646 1.1 jruoho * checked, meaning that a timeout could happen, but the code
647 1.1 jruoho * would not know about it.
648 1.1 jruoho */
649 1.1 jruoho
650 1.1 jruoho /* First child is the namepath, 2nd child is timeout */
651 1.1 jruoho
652 1.3.2.2 skrll ArgOp = Op->Asl.Child;
653 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
654 1.1 jruoho
655 1.1 jruoho /*
656 1.1 jruoho * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
657 1.1 jruoho * 0xFFFF or greater
658 1.1 jruoho */
659 1.3.2.2 skrll if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
660 1.3.2.2 skrll (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)) &&
661 1.3.2.2 skrll (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER))
662 1.1 jruoho {
663 1.1 jruoho break;
664 1.1 jruoho }
665 1.1 jruoho
666 1.1 jruoho /*
667 1.1 jruoho * The operation could timeout. If the return value is not used
668 1.1 jruoho * (indicates timeout occurred), issue a warning
669 1.1 jruoho */
670 1.1 jruoho if (!AnIsResultUsed (Op))
671 1.1 jruoho {
672 1.3.2.2 skrll AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp,
673 1.1 jruoho Op->Asl.ExternalName);
674 1.1 jruoho }
675 1.1 jruoho break;
676 1.1 jruoho
677 1.1 jruoho case PARSEOP_CREATEFIELD:
678 1.1 jruoho /*
679 1.1 jruoho * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
680 1.1 jruoho */
681 1.3.2.2 skrll ArgOp = Op->Asl.Child;
682 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
683 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
684 1.3.2.2 skrll
685 1.3.2.2 skrll if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
686 1.3.2.2 skrll ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) &&
687 1.3.2.2 skrll (ArgOp->Asl.Value.Integer == 0)))
688 1.1 jruoho {
689 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL);
690 1.1 jruoho }
691 1.1 jruoho break;
692 1.1 jruoho
693 1.2 christos case PARSEOP_CONNECTION:
694 1.2 christos /*
695 1.2 christos * Ensure that the referenced operation region has the correct SPACE_ID.
696 1.2 christos * From the grammar/parser, we know the parent is a FIELD definition.
697 1.2 christos */
698 1.3.2.2 skrll ArgOp = Op->Asl.Parent; /* Field definition */
699 1.3.2.2 skrll ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */
700 1.3.2.2 skrll Node = ArgOp->Asl.Node; /* OpRegion namespace node */
701 1.3 christos if (!Node)
702 1.3 christos {
703 1.3 christos break;
704 1.3 christos }
705 1.2 christos
706 1.3.2.2 skrll ArgOp = Node->Op; /* OpRegion definition */
707 1.3.2.2 skrll ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */
708 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */
709 1.2 christos
710 1.2 christos /*
711 1.2 christos * The Connection() operator is only valid for the following operation
712 1.2 christos * region SpaceIds: GeneralPurposeIo and GenericSerialBus.
713 1.2 christos */
714 1.3.2.2 skrll if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
715 1.3.2.2 skrll (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
716 1.2 christos {
717 1.2 christos AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL);
718 1.2 christos }
719 1.2 christos break;
720 1.2 christos
721 1.2 christos case PARSEOP_FIELD:
722 1.2 christos /*
723 1.2 christos * Ensure that fields for GeneralPurposeIo and GenericSerialBus
724 1.2 christos * contain at least one Connection() operator
725 1.2 christos */
726 1.3.2.2 skrll ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */
727 1.3.2.2 skrll Node = ArgOp->Asl.Node; /* OpRegion namespace node */
728 1.2 christos if (!Node)
729 1.2 christos {
730 1.2 christos break;
731 1.2 christos }
732 1.2 christos
733 1.3.2.2 skrll ArgOp = Node->Op; /* OpRegion definition */
734 1.3.2.2 skrll ArgOp = ArgOp->Asl.Child; /* First child is the OpRegion Name */
735 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* Next peer is the SPACE_ID (what we want) */
736 1.2 christos
737 1.2 christos /* We are only interested in GeneralPurposeIo and GenericSerialBus */
738 1.2 christos
739 1.3.2.2 skrll if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
740 1.3.2.2 skrll (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
741 1.2 christos {
742 1.2 christos break;
743 1.2 christos }
744 1.2 christos
745 1.3.2.2 skrll ArgOp = Op->Asl.Child; /* 1st child is the OpRegion Name */
746 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* AccessType */
747 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* LockRule */
748 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* UpdateRule */
749 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next; /* Start of FieldUnitList */
750 1.2 christos
751 1.2 christos /* Walk the FieldUnitList */
752 1.2 christos
753 1.3.2.2 skrll while (ArgOp)
754 1.2 christos {
755 1.3.2.2 skrll if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION)
756 1.2 christos {
757 1.2 christos break;
758 1.2 christos }
759 1.3.2.2 skrll else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG)
760 1.2 christos {
761 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL);
762 1.2 christos break;
763 1.2 christos }
764 1.2 christos
765 1.3.2.2 skrll ArgOp = ArgOp->Asl.Next;
766 1.2 christos }
767 1.2 christos break;
768 1.2 christos
769 1.1 jruoho default:
770 1.2 christos
771 1.1 jruoho break;
772 1.1 jruoho }
773 1.1 jruoho
774 1.1 jruoho return (AE_OK);
775 1.1 jruoho }
776 1.3.2.2 skrll
777 1.3.2.2 skrll
778 1.3.2.2 skrll /*******************************************************************************
779 1.3.2.2 skrll *
780 1.3.2.2 skrll * FUNCTION: AnAnalyzeStoreOperator
781 1.3.2.2 skrll *
782 1.3.2.2 skrll * PARAMETERS: Op - Store() operator
783 1.3.2.2 skrll *
784 1.3.2.2 skrll * RETURN: None
785 1.3.2.2 skrll *
786 1.3.2.2 skrll * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package
787 1.3.2.2 skrll * objects where there are more restrictions than other data
788 1.3.2.2 skrll * types.
789 1.3.2.2 skrll *
790 1.3.2.2 skrll ******************************************************************************/
791 1.3.2.2 skrll
792 1.3.2.2 skrll static void
793 1.3.2.2 skrll AnAnalyzeStoreOperator (
794 1.3.2.2 skrll ACPI_PARSE_OBJECT *Op)
795 1.3.2.2 skrll {
796 1.3.2.2 skrll ACPI_NAMESPACE_NODE *SourceNode;
797 1.3.2.2 skrll ACPI_NAMESPACE_NODE *TargetNode;
798 1.3.2.2 skrll ACPI_PARSE_OBJECT *SourceOperandOp;
799 1.3.2.2 skrll ACPI_PARSE_OBJECT *TargetOperandOp;
800 1.3.2.2 skrll UINT32 SourceOperandBtype;
801 1.3.2.2 skrll UINT32 TargetOperandBtype;
802 1.3.2.2 skrll
803 1.3.2.2 skrll
804 1.3.2.2 skrll /* Extract the two operands for STORE */
805 1.3.2.2 skrll
806 1.3.2.2 skrll SourceOperandOp = Op->Asl.Child;
807 1.3.2.2 skrll TargetOperandOp = SourceOperandOp->Asl.Next;
808 1.3.2.2 skrll
809 1.3.2.2 skrll /*
810 1.3.2.2 skrll * Ignore these Source operand opcodes, they cannot be typechecked,
811 1.3.2.2 skrll * the actual result is unknown here.
812 1.3.2.2 skrll */
813 1.3.2.2 skrll switch (SourceOperandOp->Asl.ParseOpcode)
814 1.3.2.2 skrll {
815 1.3.2.2 skrll /* For these, type of the returned value is unknown at compile time */
816 1.3.2.2 skrll
817 1.3.2.2 skrll case PARSEOP_DEREFOF:
818 1.3.2.2 skrll case PARSEOP_METHODCALL:
819 1.3.2.2 skrll case PARSEOP_STORE:
820 1.3.2.2 skrll case PARSEOP_COPYOBJECT:
821 1.3.2.2 skrll
822 1.3.2.2 skrll return;
823 1.3.2.2 skrll
824 1.3.2.2 skrll case PARSEOP_INDEX:
825 1.3.2.2 skrll case PARSEOP_REFOF:
826 1.3.2.2 skrll
827 1.3.2.2 skrll if (!Gbl_EnableReferenceTypechecking)
828 1.3.2.2 skrll {
829 1.3.2.2 skrll return;
830 1.3.2.2 skrll }
831 1.3.2.2 skrll
832 1.3.2.2 skrll /*
833 1.3.2.2 skrll * These opcodes always return an object reference, and thus
834 1.3.2.2 skrll * the result can only be stored to a Local, Arg, or Debug.
835 1.3.2.2 skrll */
836 1.3.2.2 skrll if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP)
837 1.3.2.2 skrll {
838 1.3.2.2 skrll return;
839 1.3.2.2 skrll }
840 1.3.2.2 skrll
841 1.3.2.2 skrll if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) ||
842 1.3.2.2 skrll (TargetOperandOp->Asl.AmlOpcode > AML_ARG6))
843 1.3.2.2 skrll {
844 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
845 1.3.2.2 skrll "Source [Reference], Target must be [Local/Arg/Debug]");
846 1.3.2.2 skrll }
847 1.3.2.2 skrll return;
848 1.3.2.2 skrll
849 1.3.2.2 skrll default:
850 1.3.2.2 skrll break;
851 1.3.2.2 skrll }
852 1.3.2.2 skrll
853 1.3.2.2 skrll /*
854 1.3.2.2 skrll * Ignore these Target operand opcodes, they cannot be typechecked
855 1.3.2.2 skrll */
856 1.3.2.2 skrll switch (TargetOperandOp->Asl.ParseOpcode)
857 1.3.2.2 skrll {
858 1.3.2.2 skrll case PARSEOP_DEBUG:
859 1.3.2.2 skrll case PARSEOP_DEREFOF:
860 1.3.2.2 skrll case PARSEOP_REFOF:
861 1.3.2.2 skrll case PARSEOP_INDEX:
862 1.3.2.2 skrll case PARSEOP_METHODCALL:
863 1.3.2.2 skrll
864 1.3.2.2 skrll return;
865 1.3.2.2 skrll
866 1.3.2.2 skrll default:
867 1.3.2.2 skrll break;
868 1.3.2.2 skrll }
869 1.3.2.2 skrll
870 1.3.2.2 skrll /*
871 1.3.2.2 skrll * Ignore typecheck for External() operands of type "UnknownObj",
872 1.3.2.2 skrll * we don't know the actual type (source or target).
873 1.3.2.2 skrll */
874 1.3.2.2 skrll SourceNode = SourceOperandOp->Asl.Node;
875 1.3.2.2 skrll if (SourceNode &&
876 1.3.2.2 skrll (SourceNode->Flags & ANOBJ_IS_EXTERNAL) &&
877 1.3.2.2 skrll (SourceNode->Type == ACPI_TYPE_ANY))
878 1.3.2.2 skrll {
879 1.3.2.2 skrll return;
880 1.3.2.2 skrll }
881 1.3.2.2 skrll
882 1.3.2.2 skrll TargetNode = TargetOperandOp->Asl.Node;
883 1.3.2.2 skrll if (TargetNode &&
884 1.3.2.2 skrll (TargetNode->Flags & ANOBJ_IS_EXTERNAL) &&
885 1.3.2.2 skrll (TargetNode->Type == ACPI_TYPE_ANY))
886 1.3.2.2 skrll {
887 1.3.2.2 skrll return;
888 1.3.2.2 skrll }
889 1.3.2.2 skrll
890 1.3.2.2 skrll /*
891 1.3.2.2 skrll * A NULL node with a namepath AML opcode indicates non-existent
892 1.3.2.2 skrll * name. Just return, the error message is generated elsewhere.
893 1.3.2.2 skrll */
894 1.3.2.2 skrll if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) ||
895 1.3.2.2 skrll (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)))
896 1.3.2.2 skrll {
897 1.3.2.2 skrll return;
898 1.3.2.2 skrll }
899 1.3.2.2 skrll
900 1.3.2.2 skrll /*
901 1.3.2.2 skrll * Simple check for source same as target via NS node.
902 1.3.2.2 skrll * -- Could be expanded to locals and args.
903 1.3.2.2 skrll */
904 1.3.2.2 skrll if (SourceNode && TargetNode)
905 1.3.2.2 skrll {
906 1.3.2.2 skrll if (SourceNode == TargetNode)
907 1.3.2.2 skrll {
908 1.3.2.2 skrll AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM,
909 1.3.2.2 skrll TargetOperandOp, "Source is the same as Target");
910 1.3.2.2 skrll return;
911 1.3.2.2 skrll }
912 1.3.2.2 skrll }
913 1.3.2.2 skrll
914 1.3.2.2 skrll /* Ignore typecheck if either source or target is a local or arg */
915 1.3.2.2 skrll
916 1.3.2.2 skrll if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
917 1.3.2.2 skrll (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6))
918 1.3.2.2 skrll {
919 1.3.2.2 skrll return; /* Cannot type a local/arg at compile time */
920 1.3.2.2 skrll }
921 1.3.2.2 skrll
922 1.3.2.2 skrll if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
923 1.3.2.2 skrll (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6))
924 1.3.2.2 skrll {
925 1.3.2.2 skrll return; /* Cannot type a local/arg at compile time */
926 1.3.2.2 skrll }
927 1.3.2.2 skrll
928 1.3.2.2 skrll /*
929 1.3.2.2 skrll * Package objects are a special case because they cannot by implicitly
930 1.3.2.2 skrll * converted to/from anything. Check for these two illegal cases:
931 1.3.2.2 skrll *
932 1.3.2.2 skrll * Store (non-package, package)
933 1.3.2.2 skrll * Store (package, non-package)
934 1.3.2.2 skrll */
935 1.3.2.2 skrll SourceOperandBtype = AnGetBtype (SourceOperandOp);
936 1.3.2.2 skrll TargetOperandBtype = AnGetBtype (TargetOperandOp);
937 1.3.2.2 skrll
938 1.3.2.2 skrll /* Check source first for (package, non-package) case */
939 1.3.2.2 skrll
940 1.3.2.2 skrll if (SourceOperandBtype & ACPI_BTYPE_PACKAGE)
941 1.3.2.2 skrll {
942 1.3.2.2 skrll /* If Source is PACKAGE-->Target must be PACKAGE */
943 1.3.2.2 skrll
944 1.3.2.2 skrll if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE))
945 1.3.2.2 skrll {
946 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
947 1.3.2.2 skrll "Source is [Package], Target must be a package also");
948 1.3.2.2 skrll }
949 1.3.2.2 skrll }
950 1.3.2.2 skrll
951 1.3.2.2 skrll /* Else check target for (non-package, package) case */
952 1.3.2.2 skrll
953 1.3.2.2 skrll else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE)
954 1.3.2.2 skrll {
955 1.3.2.2 skrll /* If Target is PACKAGE, Source must be PACKAGE */
956 1.3.2.2 skrll
957 1.3.2.2 skrll if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE))
958 1.3.2.2 skrll {
959 1.3.2.2 skrll AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp,
960 1.3.2.2 skrll "Target is [Package], Source must be a package also");
961 1.3.2.2 skrll }
962 1.3.2.2 skrll }
963 1.3.2.2 skrll }
964