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