aslanalyze.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: aslanalyze.c - Support functions for parse tree walks
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind *****************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind
45 1.1.1.2.4.2 rmind #include "aslcompiler.h"
46 1.1.1.2.4.2 rmind #include "aslcompiler.y.h"
47 1.1.1.2.4.2 rmind #include <string.h>
48 1.1.1.2.4.2 rmind
49 1.1.1.2.4.2 rmind
50 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_COMPILER
51 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("aslanalyze")
52 1.1.1.2.4.2 rmind
53 1.1.1.2.4.2 rmind
54 1.1.1.2.4.2 rmind /*******************************************************************************
55 1.1.1.2.4.2 rmind *
56 1.1.1.2.4.2 rmind * FUNCTION: AnIsInternalMethod
57 1.1.1.2.4.2 rmind *
58 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current op
59 1.1.1.2.4.2 rmind *
60 1.1.1.2.4.2 rmind * RETURN: Boolean
61 1.1.1.2.4.2 rmind *
62 1.1.1.2.4.2 rmind * DESCRIPTION: Check for an internal control method.
63 1.1.1.2.4.2 rmind *
64 1.1.1.2.4.2 rmind ******************************************************************************/
65 1.1.1.2.4.2 rmind
66 1.1.1.2.4.2 rmind BOOLEAN
67 1.1.1.2.4.2 rmind AnIsInternalMethod (
68 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
69 1.1.1.2.4.2 rmind {
70 1.1.1.2.4.2 rmind
71 1.1.1.2.4.2 rmind if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
72 1.1.1.2.4.2 rmind (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
73 1.1.1.2.4.2 rmind {
74 1.1.1.2.4.2 rmind return (TRUE);
75 1.1.1.2.4.2 rmind }
76 1.1.1.2.4.2 rmind
77 1.1.1.2.4.2 rmind return (FALSE);
78 1.1.1.2.4.2 rmind }
79 1.1.1.2.4.2 rmind
80 1.1.1.2.4.2 rmind
81 1.1.1.2.4.2 rmind /*******************************************************************************
82 1.1.1.2.4.2 rmind *
83 1.1.1.2.4.2 rmind * FUNCTION: AnGetInternalMethodReturnType
84 1.1.1.2.4.2 rmind *
85 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current op
86 1.1.1.2.4.2 rmind *
87 1.1.1.2.4.2 rmind * RETURN: Btype
88 1.1.1.2.4.2 rmind *
89 1.1.1.2.4.2 rmind * DESCRIPTION: Get the return type of an internal method
90 1.1.1.2.4.2 rmind *
91 1.1.1.2.4.2 rmind ******************************************************************************/
92 1.1.1.2.4.2 rmind
93 1.1.1.2.4.2 rmind UINT32
94 1.1.1.2.4.2 rmind AnGetInternalMethodReturnType (
95 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
96 1.1.1.2.4.2 rmind {
97 1.1.1.2.4.2 rmind
98 1.1.1.2.4.2 rmind if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
99 1.1.1.2.4.2 rmind (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
100 1.1.1.2.4.2 rmind {
101 1.1.1.2.4.2 rmind return (ACPI_BTYPE_STRING);
102 1.1.1.2.4.2 rmind }
103 1.1.1.2.4.2 rmind
104 1.1.1.2.4.2 rmind return (0);
105 1.1.1.2.4.2 rmind }
106 1.1.1.2.4.2 rmind
107 1.1.1.2.4.2 rmind
108 1.1.1.2.4.2 rmind /*******************************************************************************
109 1.1.1.2.4.2 rmind *
110 1.1.1.2.4.2 rmind * FUNCTION: AnCheckId
111 1.1.1.2.4.2 rmind *
112 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current parse op
113 1.1.1.2.4.2 rmind * Type - HID or CID
114 1.1.1.2.4.2 rmind *
115 1.1.1.2.4.2 rmind * RETURN: None
116 1.1.1.2.4.2 rmind *
117 1.1.1.2.4.2 rmind * DESCRIPTION: Perform various checks on _HID and _CID strings. Only limited
118 1.1.1.2.4.2 rmind * checks can be performed on _CID strings.
119 1.1.1.2.4.2 rmind *
120 1.1.1.2.4.2 rmind ******************************************************************************/
121 1.1.1.2.4.2 rmind
122 1.1.1.2.4.2 rmind void
123 1.1.1.2.4.2 rmind AnCheckId (
124 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
125 1.1.1.2.4.2 rmind ACPI_NAME Type)
126 1.1.1.2.4.2 rmind {
127 1.1.1.2.4.2 rmind UINT32 i;
128 1.1.1.2.4.2 rmind ACPI_SIZE Length;
129 1.1.1.2.4.2 rmind UINT32 AlphaPrefixLength;
130 1.1.1.2.4.2 rmind
131 1.1.1.2.4.2 rmind
132 1.1.1.2.4.2 rmind /* Only care about string versions of _HID/_CID (integers are legal) */
133 1.1.1.2.4.2 rmind
134 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)
135 1.1.1.2.4.2 rmind {
136 1.1.1.2.4.2 rmind return;
137 1.1.1.2.4.2 rmind }
138 1.1.1.2.4.2 rmind
139 1.1.1.2.4.2 rmind /* For both _HID and _CID, the string must be non-null */
140 1.1.1.2.4.2 rmind
141 1.1.1.2.4.2 rmind Length = strlen (Op->Asl.Value.String);
142 1.1.1.2.4.2 rmind if (!Length)
143 1.1.1.2.4.2 rmind {
144 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NULL_STRING,
145 1.1.1.2.4.2 rmind Op, NULL);
146 1.1.1.2.4.2 rmind return;
147 1.1.1.2.4.2 rmind }
148 1.1.1.2.4.2 rmind
149 1.1.1.2.4.2 rmind /*
150 1.1.1.2.4.2 rmind * One of the things we want to catch here is the use of a leading
151 1.1.1.2.4.2 rmind * asterisk in the string -- an odd construct that certain platform
152 1.1.1.2.4.2 rmind * manufacturers are fond of. Technically, a leading asterisk is OK
153 1.1.1.2.4.2 rmind * for _CID, but a valid use of this has not been seen.
154 1.1.1.2.4.2 rmind */
155 1.1.1.2.4.2 rmind if (*Op->Asl.Value.String == '*')
156 1.1.1.2.4.2 rmind {
157 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_LEADING_ASTERISK,
158 1.1.1.2.4.2 rmind Op, Op->Asl.Value.String);
159 1.1.1.2.4.2 rmind return;
160 1.1.1.2.4.2 rmind }
161 1.1.1.2.4.2 rmind
162 1.1.1.2.4.2 rmind /* _CID strings are bus-specific, no more checks can be performed */
163 1.1.1.2.4.2 rmind
164 1.1.1.2.4.2 rmind if (Type == ASL_TYPE_CID)
165 1.1.1.2.4.2 rmind {
166 1.1.1.2.4.2 rmind return;
167 1.1.1.2.4.2 rmind }
168 1.1.1.2.4.2 rmind
169 1.1.1.2.4.2 rmind /* For _HID, all characters must be alphanumeric */
170 1.1.1.2.4.2 rmind
171 1.1.1.2.4.2 rmind for (i = 0; Op->Asl.Value.String[i]; i++)
172 1.1.1.2.4.2 rmind {
173 1.1.1.2.4.2 rmind if (!isalnum ((int) Op->Asl.Value.String[i]))
174 1.1.1.2.4.2 rmind {
175 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING,
176 1.1.1.2.4.2 rmind Op, Op->Asl.Value.String);
177 1.1.1.2.4.2 rmind break;
178 1.1.1.2.4.2 rmind }
179 1.1.1.2.4.2 rmind }
180 1.1.1.2.4.2 rmind
181 1.1.1.2.4.2 rmind /* _HID String must be of the form "XXX####" or "ACPI####" */
182 1.1.1.2.4.2 rmind
183 1.1.1.2.4.2 rmind if ((Length < 7) || (Length > 8))
184 1.1.1.2.4.2 rmind {
185 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_HID_LENGTH,
186 1.1.1.2.4.2 rmind Op, Op->Asl.Value.String);
187 1.1.1.2.4.2 rmind return;
188 1.1.1.2.4.2 rmind }
189 1.1.1.2.4.2 rmind
190 1.1.1.2.4.2 rmind /* _HID Length is valid, now check for uppercase (first 3 or 4 chars) */
191 1.1.1.2.4.2 rmind
192 1.1.1.2.4.2 rmind AlphaPrefixLength = 3;
193 1.1.1.2.4.2 rmind if (Length >= 8)
194 1.1.1.2.4.2 rmind {
195 1.1.1.2.4.2 rmind AlphaPrefixLength = 4;
196 1.1.1.2.4.2 rmind }
197 1.1.1.2.4.2 rmind
198 1.1.1.2.4.2 rmind /* Ensure the alphabetic prefix is all uppercase */
199 1.1.1.2.4.2 rmind
200 1.1.1.2.4.2 rmind for (i = 0; (i < AlphaPrefixLength) && Op->Asl.Value.String[i]; i++)
201 1.1.1.2.4.2 rmind {
202 1.1.1.2.4.2 rmind if (!isupper ((int) Op->Asl.Value.String[i]))
203 1.1.1.2.4.2 rmind {
204 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_UPPER_CASE,
205 1.1.1.2.4.2 rmind Op, &Op->Asl.Value.String[i]);
206 1.1.1.2.4.2 rmind break;
207 1.1.1.2.4.2 rmind }
208 1.1.1.2.4.2 rmind }
209 1.1.1.2.4.2 rmind }
210 1.1.1.2.4.2 rmind
211 1.1.1.2.4.2 rmind
212 1.1.1.2.4.2 rmind /*******************************************************************************
213 1.1.1.2.4.2 rmind *
214 1.1.1.2.4.2 rmind * FUNCTION: AnLastStatementIsReturn
215 1.1.1.2.4.2 rmind *
216 1.1.1.2.4.2 rmind * PARAMETERS: Op - A method parse node
217 1.1.1.2.4.2 rmind *
218 1.1.1.2.4.2 rmind * RETURN: TRUE if last statement is an ASL RETURN. False otherwise
219 1.1.1.2.4.2 rmind *
220 1.1.1.2.4.2 rmind * DESCRIPTION: Walk down the list of top level statements within a method
221 1.1.1.2.4.2 rmind * to find the last one. Check if that last statement is in
222 1.1.1.2.4.2 rmind * fact a RETURN statement.
223 1.1.1.2.4.2 rmind *
224 1.1.1.2.4.2 rmind ******************************************************************************/
225 1.1.1.2.4.2 rmind
226 1.1.1.2.4.2 rmind BOOLEAN
227 1.1.1.2.4.2 rmind AnLastStatementIsReturn (
228 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
229 1.1.1.2.4.2 rmind {
230 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Next;
231 1.1.1.2.4.2 rmind
232 1.1.1.2.4.2 rmind
233 1.1.1.2.4.2 rmind /* Check if last statement is a return */
234 1.1.1.2.4.2 rmind
235 1.1.1.2.4.2 rmind Next = ASL_GET_CHILD_NODE (Op);
236 1.1.1.2.4.2 rmind while (Next)
237 1.1.1.2.4.2 rmind {
238 1.1.1.2.4.2 rmind if ((!Next->Asl.Next) &&
239 1.1.1.2.4.2 rmind (Next->Asl.ParseOpcode == PARSEOP_RETURN))
240 1.1.1.2.4.2 rmind {
241 1.1.1.2.4.2 rmind return (TRUE);
242 1.1.1.2.4.2 rmind }
243 1.1.1.2.4.2 rmind
244 1.1.1.2.4.2 rmind Next = ASL_GET_PEER_NODE (Next);
245 1.1.1.2.4.2 rmind }
246 1.1.1.2.4.2 rmind
247 1.1.1.2.4.2 rmind return (FALSE);
248 1.1.1.2.4.2 rmind }
249 1.1.1.2.4.2 rmind
250 1.1.1.2.4.2 rmind
251 1.1.1.2.4.2 rmind /*******************************************************************************
252 1.1.1.2.4.2 rmind *
253 1.1.1.2.4.2 rmind * FUNCTION: AnCheckMethodReturnValue
254 1.1.1.2.4.2 rmind *
255 1.1.1.2.4.2 rmind * PARAMETERS: Op - Parent
256 1.1.1.2.4.2 rmind * OpInfo - Parent info
257 1.1.1.2.4.2 rmind * ArgOp - Method invocation op
258 1.1.1.2.4.2 rmind * RequiredBtypes - What caller requires
259 1.1.1.2.4.2 rmind * ThisNodeBtype - What this node returns (if anything)
260 1.1.1.2.4.2 rmind *
261 1.1.1.2.4.2 rmind * RETURN: None
262 1.1.1.2.4.2 rmind *
263 1.1.1.2.4.2 rmind * DESCRIPTION: Check a method invocation for 1) A return value and if it does
264 1.1.1.2.4.2 rmind * in fact return a value, 2) check the type of the return value.
265 1.1.1.2.4.2 rmind *
266 1.1.1.2.4.2 rmind ******************************************************************************/
267 1.1.1.2.4.2 rmind
268 1.1.1.2.4.2 rmind void
269 1.1.1.2.4.2 rmind AnCheckMethodReturnValue (
270 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
271 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *OpInfo,
272 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *ArgOp,
273 1.1.1.2.4.2 rmind UINT32 RequiredBtypes,
274 1.1.1.2.4.2 rmind UINT32 ThisNodeBtype)
275 1.1.1.2.4.2 rmind {
276 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *OwningOp;
277 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node;
278 1.1.1.2.4.2 rmind
279 1.1.1.2.4.2 rmind
280 1.1.1.2.4.2 rmind Node = ArgOp->Asl.Node;
281 1.1.1.2.4.2 rmind
282 1.1.1.2.4.2 rmind
283 1.1.1.2.4.2 rmind /* Examine the parent op of this method */
284 1.1.1.2.4.2 rmind
285 1.1.1.2.4.2 rmind OwningOp = Node->Op;
286 1.1.1.2.4.2 rmind if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL)
287 1.1.1.2.4.2 rmind {
288 1.1.1.2.4.2 rmind /* Method NEVER returns a value */
289 1.1.1.2.4.2 rmind
290 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName);
291 1.1.1.2.4.2 rmind }
292 1.1.1.2.4.2 rmind else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL)
293 1.1.1.2.4.2 rmind {
294 1.1.1.2.4.2 rmind /* Method SOMETIMES returns a value, SOMETIMES not */
295 1.1.1.2.4.2 rmind
296 1.1.1.2.4.2 rmind AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName);
297 1.1.1.2.4.2 rmind }
298 1.1.1.2.4.2 rmind else if (!(ThisNodeBtype & RequiredBtypes))
299 1.1.1.2.4.2 rmind {
300 1.1.1.2.4.2 rmind /* Method returns a value, but the type is wrong */
301 1.1.1.2.4.2 rmind
302 1.1.1.2.4.2 rmind AnFormatBtype (StringBuffer, ThisNodeBtype);
303 1.1.1.2.4.2 rmind AnFormatBtype (StringBuffer2, RequiredBtypes);
304 1.1.1.2.4.2 rmind
305 1.1.1.2.4.2 rmind /*
306 1.1.1.2.4.2 rmind * The case where the method does not return any value at all
307 1.1.1.2.4.2 rmind * was already handled in the namespace cross reference
308 1.1.1.2.4.2 rmind * -- Only issue an error if the method in fact returns a value,
309 1.1.1.2.4.2 rmind * but it is of the wrong type
310 1.1.1.2.4.2 rmind */
311 1.1.1.2.4.2 rmind if (ThisNodeBtype != 0)
312 1.1.1.2.4.2 rmind {
313 1.1.1.2.4.2 rmind sprintf (MsgBuffer,
314 1.1.1.2.4.2 rmind "Method returns [%s], %s operator requires [%s]",
315 1.1.1.2.4.2 rmind StringBuffer, OpInfo->Name, StringBuffer2);
316 1.1.1.2.4.2 rmind
317 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
318 1.1.1.2.4.2 rmind }
319 1.1.1.2.4.2 rmind }
320 1.1.1.2.4.2 rmind }
321 1.1.1.2.4.2 rmind
322 1.1.1.2.4.2 rmind
323 1.1.1.2.4.2 rmind /*******************************************************************************
324 1.1.1.2.4.2 rmind *
325 1.1.1.2.4.2 rmind * FUNCTION: AnIsResultUsed
326 1.1.1.2.4.2 rmind *
327 1.1.1.2.4.2 rmind * PARAMETERS: Op - Parent op for the operator
328 1.1.1.2.4.2 rmind *
329 1.1.1.2.4.2 rmind * RETURN: TRUE if result from this operation is actually consumed
330 1.1.1.2.4.2 rmind *
331 1.1.1.2.4.2 rmind * DESCRIPTION: Determine if the function result value from an operator is
332 1.1.1.2.4.2 rmind * used.
333 1.1.1.2.4.2 rmind *
334 1.1.1.2.4.2 rmind ******************************************************************************/
335 1.1.1.2.4.2 rmind
336 1.1.1.2.4.2 rmind BOOLEAN
337 1.1.1.2.4.2 rmind AnIsResultUsed (
338 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
339 1.1.1.2.4.2 rmind {
340 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Parent;
341 1.1.1.2.4.2 rmind
342 1.1.1.2.4.2 rmind
343 1.1.1.2.4.2 rmind switch (Op->Asl.ParseOpcode)
344 1.1.1.2.4.2 rmind {
345 1.1.1.2.4.2 rmind case PARSEOP_INCREMENT:
346 1.1.1.2.4.2 rmind case PARSEOP_DECREMENT:
347 1.1.1.2.4.2 rmind
348 1.1.1.2.4.2 rmind /* These are standalone operators, no return value */
349 1.1.1.2.4.2 rmind
350 1.1.1.2.4.2 rmind return (TRUE);
351 1.1.1.2.4.2 rmind
352 1.1.1.2.4.2 rmind default:
353 1.1.1.2.4.2 rmind break;
354 1.1.1.2.4.2 rmind }
355 1.1.1.2.4.2 rmind
356 1.1.1.2.4.2 rmind /* Examine parent to determine if the return value is used */
357 1.1.1.2.4.2 rmind
358 1.1.1.2.4.2 rmind Parent = Op->Asl.Parent;
359 1.1.1.2.4.2 rmind switch (Parent->Asl.ParseOpcode)
360 1.1.1.2.4.2 rmind {
361 1.1.1.2.4.2 rmind /* If/While - check if the operator is the predicate */
362 1.1.1.2.4.2 rmind
363 1.1.1.2.4.2 rmind case PARSEOP_IF:
364 1.1.1.2.4.2 rmind case PARSEOP_WHILE:
365 1.1.1.2.4.2 rmind
366 1.1.1.2.4.2 rmind /* First child is the predicate */
367 1.1.1.2.4.2 rmind
368 1.1.1.2.4.2 rmind if (Parent->Asl.Child == Op)
369 1.1.1.2.4.2 rmind {
370 1.1.1.2.4.2 rmind return (TRUE);
371 1.1.1.2.4.2 rmind }
372 1.1.1.2.4.2 rmind return (FALSE);
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind /* Not used if one of these is the parent */
375 1.1.1.2.4.2 rmind
376 1.1.1.2.4.2 rmind case PARSEOP_METHOD:
377 1.1.1.2.4.2 rmind case PARSEOP_DEFINITIONBLOCK:
378 1.1.1.2.4.2 rmind case PARSEOP_ELSE:
379 1.1.1.2.4.2 rmind
380 1.1.1.2.4.2 rmind return (FALSE);
381 1.1.1.2.4.2 rmind
382 1.1.1.2.4.2 rmind default:
383 1.1.1.2.4.2 rmind /* Any other type of parent means that the result is used */
384 1.1.1.2.4.2 rmind
385 1.1.1.2.4.2 rmind return (TRUE);
386 1.1.1.2.4.2 rmind }
387 1.1.1.2.4.2 rmind }
388 1.1.1.2.4.2 rmind
389 1.1.1.2.4.2 rmind
390 1.1.1.2.4.2 rmind /*******************************************************************************
391 1.1.1.2.4.2 rmind *
392 1.1.1.2.4.2 rmind * FUNCTION: ApCheckForGpeNameConflict
393 1.1.1.2.4.2 rmind *
394 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current parse op
395 1.1.1.2.4.2 rmind *
396 1.1.1.2.4.2 rmind * RETURN: None
397 1.1.1.2.4.2 rmind *
398 1.1.1.2.4.2 rmind * DESCRIPTION: Check for a conflict between GPE names within this scope.
399 1.1.1.2.4.2 rmind * Conflict means two GPE names with the same GPE number, but
400 1.1.1.2.4.2 rmind * different types -- such as _L1C and _E1C.
401 1.1.1.2.4.2 rmind *
402 1.1.1.2.4.2 rmind ******************************************************************************/
403 1.1.1.2.4.2 rmind
404 1.1.1.2.4.2 rmind void
405 1.1.1.2.4.2 rmind ApCheckForGpeNameConflict (
406 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
407 1.1.1.2.4.2 rmind {
408 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *NextOp;
409 1.1.1.2.4.2 rmind UINT32 GpeNumber;
410 1.1.1.2.4.2 rmind char Name[ACPI_NAME_SIZE + 1];
411 1.1.1.2.4.2 rmind char Target[ACPI_NAME_SIZE];
412 1.1.1.2.4.2 rmind
413 1.1.1.2.4.2 rmind
414 1.1.1.2.4.2 rmind /* Need a null-terminated string version of NameSeg */
415 1.1.1.2.4.2 rmind
416 1.1.1.2.4.2 rmind ACPI_MOVE_32_TO_32 (Name, &Op->Asl.NameSeg);
417 1.1.1.2.4.2 rmind Name[ACPI_NAME_SIZE] = 0;
418 1.1.1.2.4.2 rmind
419 1.1.1.2.4.2 rmind /*
420 1.1.1.2.4.2 rmind * For a GPE method:
421 1.1.1.2.4.2 rmind * 1st char must be underscore
422 1.1.1.2.4.2 rmind * 2nd char must be L or E
423 1.1.1.2.4.2 rmind * 3rd/4th chars must be a hex number
424 1.1.1.2.4.2 rmind */
425 1.1.1.2.4.2 rmind if ((Name[0] != '_') ||
426 1.1.1.2.4.2 rmind ((Name[1] != 'L') && (Name[1] != 'E')))
427 1.1.1.2.4.2 rmind {
428 1.1.1.2.4.2 rmind return;
429 1.1.1.2.4.2 rmind }
430 1.1.1.2.4.2 rmind
431 1.1.1.2.4.2 rmind /* Verify 3rd/4th chars are a valid hex value */
432 1.1.1.2.4.2 rmind
433 1.1.1.2.4.2 rmind GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
434 1.1.1.2.4.2 rmind if (GpeNumber == ACPI_UINT32_MAX)
435 1.1.1.2.4.2 rmind {
436 1.1.1.2.4.2 rmind return;
437 1.1.1.2.4.2 rmind }
438 1.1.1.2.4.2 rmind
439 1.1.1.2.4.2 rmind /*
440 1.1.1.2.4.2 rmind * We are now sure we have an _Lxx or _Exx.
441 1.1.1.2.4.2 rmind * Create the target name that would cause collision (Flip E/L)
442 1.1.1.2.4.2 rmind */
443 1.1.1.2.4.2 rmind ACPI_MOVE_32_TO_32 (Target, Name);
444 1.1.1.2.4.2 rmind
445 1.1.1.2.4.2 rmind /* Inject opposite letter ("L" versus "E") */
446 1.1.1.2.4.2 rmind
447 1.1.1.2.4.2 rmind if (Name[1] == 'L')
448 1.1.1.2.4.2 rmind {
449 1.1.1.2.4.2 rmind Target[1] = 'E';
450 1.1.1.2.4.2 rmind }
451 1.1.1.2.4.2 rmind else /* Name[1] == 'E' */
452 1.1.1.2.4.2 rmind {
453 1.1.1.2.4.2 rmind Target[1] = 'L';
454 1.1.1.2.4.2 rmind }
455 1.1.1.2.4.2 rmind
456 1.1.1.2.4.2 rmind /* Search all peers (objects within this scope) for target match */
457 1.1.1.2.4.2 rmind
458 1.1.1.2.4.2 rmind NextOp = Op->Asl.Next;
459 1.1.1.2.4.2 rmind while (NextOp)
460 1.1.1.2.4.2 rmind {
461 1.1.1.2.4.2 rmind /*
462 1.1.1.2.4.2 rmind * We mostly care about methods, but check Name() constructs also,
463 1.1.1.2.4.2 rmind * even though they will get another error for not being a method.
464 1.1.1.2.4.2 rmind * All GPE names must be defined as control methods.
465 1.1.1.2.4.2 rmind */
466 1.1.1.2.4.2 rmind if ((NextOp->Asl.ParseOpcode == PARSEOP_METHOD) ||
467 1.1.1.2.4.2 rmind (NextOp->Asl.ParseOpcode == PARSEOP_NAME))
468 1.1.1.2.4.2 rmind {
469 1.1.1.2.4.2 rmind if (ACPI_COMPARE_NAME (Target, NextOp->Asl.NameSeg))
470 1.1.1.2.4.2 rmind {
471 1.1.1.2.4.2 rmind /* Found both _Exy and _Lxy in the same scope, error */
472 1.1.1.2.4.2 rmind
473 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_GPE_NAME_CONFLICT, NextOp,
474 1.1.1.2.4.2 rmind Name);
475 1.1.1.2.4.2 rmind return;
476 1.1.1.2.4.2 rmind }
477 1.1.1.2.4.2 rmind }
478 1.1.1.2.4.2 rmind
479 1.1.1.2.4.2 rmind NextOp = NextOp->Asl.Next;
480 1.1.1.2.4.2 rmind }
481 1.1.1.2.4.2 rmind
482 1.1.1.2.4.2 rmind /* OK, no conflict found */
483 1.1.1.2.4.2 rmind
484 1.1.1.2.4.2 rmind return;
485 1.1.1.2.4.2 rmind }
486