asltransform.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer
2 1.1.1.2.2.2 bouyer /******************************************************************************
3 1.1.1.2.2.2 bouyer *
4 1.1.1.2.2.2 bouyer * Module Name: asltransform - Parse tree transforms
5 1.1.1.2.2.2 bouyer *
6 1.1.1.2.2.2 bouyer *****************************************************************************/
7 1.1.1.2.2.2 bouyer
8 1.1.1.2.2.2 bouyer /*
9 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
10 1.1.1.2.2.2 bouyer * All rights reserved.
11 1.1.1.2.2.2 bouyer *
12 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
13 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
14 1.1.1.2.2.2 bouyer * are met:
15 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
16 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
17 1.1.1.2.2.2 bouyer * without modification.
18 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
22 1.1.1.2.2.2 bouyer * binary redistribution.
23 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
25 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
26 1.1.1.2.2.2 bouyer *
27 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
28 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1.1.2.2.2 bouyer * Software Foundation.
30 1.1.1.2.2.2 bouyer *
31 1.1.1.2.2.2 bouyer * NO WARRANTY
32 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
43 1.1.1.2.2.2 bouyer */
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "aslcompiler.h"
47 1.1.1.2.2.2 bouyer #include "aslcompiler.y.h"
48 1.1.1.2.2.2 bouyer
49 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_COMPILER
50 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("asltransform")
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer /* Local prototypes */
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer static void
55 1.1.1.2.2.2 bouyer TrTransformSubtree (
56 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op);
57 1.1.1.2.2.2 bouyer
58 1.1.1.2.2.2 bouyer static char *
59 1.1.1.2.2.2 bouyer TrAmlGetNextTempName (
60 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
61 1.1.1.2.2.2 bouyer UINT8 *TempCount);
62 1.1.1.2.2.2 bouyer
63 1.1.1.2.2.2 bouyer static void
64 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (
65 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
66 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Neighbor);
67 1.1.1.2.2.2 bouyer
68 1.1.1.2.2.2 bouyer static void
69 1.1.1.2.2.2 bouyer TrAmlInitNode (
70 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
71 1.1.1.2.2.2 bouyer UINT16 ParseOpcode);
72 1.1.1.2.2.2 bouyer
73 1.1.1.2.2.2 bouyer static void
74 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (
75 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
76 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Parent);
77 1.1.1.2.2.2 bouyer
78 1.1.1.2.2.2 bouyer static void
79 1.1.1.2.2.2 bouyer TrAmlInsertPeer (
80 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
81 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NewPeer);
82 1.1.1.2.2.2 bouyer
83 1.1.1.2.2.2 bouyer static void
84 1.1.1.2.2.2 bouyer TrDoDefinitionBlock (
85 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op);
86 1.1.1.2.2.2 bouyer
87 1.1.1.2.2.2 bouyer static void
88 1.1.1.2.2.2 bouyer TrDoSwitch (
89 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *StartNode);
90 1.1.1.2.2.2 bouyer
91 1.1.1.2.2.2 bouyer
92 1.1.1.2.2.2 bouyer /*******************************************************************************
93 1.1.1.2.2.2 bouyer *
94 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlGetNextTempName
95 1.1.1.2.2.2 bouyer *
96 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Current parse op
97 1.1.1.2.2.2 bouyer * TempCount - Current temporary counter. Was originally
98 1.1.1.2.2.2 bouyer * per-module; Currently per method, could be
99 1.1.1.2.2.2 bouyer * expanded to per-scope.
100 1.1.1.2.2.2 bouyer *
101 1.1.1.2.2.2 bouyer * RETURN: A pointer to name (allocated here).
102 1.1.1.2.2.2 bouyer *
103 1.1.1.2.2.2 bouyer * DESCRIPTION: Generate an ACPI name of the form _T_x. These names are
104 1.1.1.2.2.2 bouyer * reserved for use by the ASL compiler. (_T_0 through _T_Z)
105 1.1.1.2.2.2 bouyer *
106 1.1.1.2.2.2 bouyer ******************************************************************************/
107 1.1.1.2.2.2 bouyer
108 1.1.1.2.2.2 bouyer static char *
109 1.1.1.2.2.2 bouyer TrAmlGetNextTempName (
110 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
111 1.1.1.2.2.2 bouyer UINT8 *TempCount)
112 1.1.1.2.2.2 bouyer {
113 1.1.1.2.2.2 bouyer char *TempName;
114 1.1.1.2.2.2 bouyer
115 1.1.1.2.2.2 bouyer
116 1.1.1.2.2.2 bouyer if (*TempCount >= (10+26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */
117 1.1.1.2.2.2 bouyer {
118 1.1.1.2.2.2 bouyer /* Too many temps */
119 1.1.1.2.2.2 bouyer
120 1.1.1.2.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_TOO_MANY_TEMPS, Op, NULL);
121 1.1.1.2.2.2 bouyer return (NULL);
122 1.1.1.2.2.2 bouyer }
123 1.1.1.2.2.2 bouyer
124 1.1.1.2.2.2 bouyer TempName = UtLocalCalloc (5);
125 1.1.1.2.2.2 bouyer
126 1.1.1.2.2.2 bouyer if (*TempCount < 10) /* 0-9 */
127 1.1.1.2.2.2 bouyer {
128 1.1.1.2.2.2 bouyer TempName[3] = (char) (*TempCount + '0');
129 1.1.1.2.2.2 bouyer }
130 1.1.1.2.2.2 bouyer else /* 10-35: A-Z */
131 1.1.1.2.2.2 bouyer {
132 1.1.1.2.2.2 bouyer TempName[3] = (char) (*TempCount + ('A' - 10));
133 1.1.1.2.2.2 bouyer }
134 1.1.1.2.2.2 bouyer (*TempCount)++;
135 1.1.1.2.2.2 bouyer
136 1.1.1.2.2.2 bouyer /* First three characters are always "_T_" */
137 1.1.1.2.2.2 bouyer
138 1.1.1.2.2.2 bouyer TempName[0] = '_';
139 1.1.1.2.2.2 bouyer TempName[1] = 'T';
140 1.1.1.2.2.2 bouyer TempName[2] = '_';
141 1.1.1.2.2.2 bouyer
142 1.1.1.2.2.2 bouyer return (TempName);
143 1.1.1.2.2.2 bouyer }
144 1.1.1.2.2.2 bouyer
145 1.1.1.2.2.2 bouyer
146 1.1.1.2.2.2 bouyer /*******************************************************************************
147 1.1.1.2.2.2 bouyer *
148 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlInitLineNumbers
149 1.1.1.2.2.2 bouyer *
150 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Op to be initialized
151 1.1.1.2.2.2 bouyer * Neighbor - Op used for initialization values
152 1.1.1.2.2.2 bouyer *
153 1.1.1.2.2.2 bouyer * RETURN: None
154 1.1.1.2.2.2 bouyer *
155 1.1.1.2.2.2 bouyer * DESCRIPTION: Initialized the various line numbers for a parse node.
156 1.1.1.2.2.2 bouyer *
157 1.1.1.2.2.2 bouyer ******************************************************************************/
158 1.1.1.2.2.2 bouyer
159 1.1.1.2.2.2 bouyer static void
160 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (
161 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
162 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Neighbor)
163 1.1.1.2.2.2 bouyer {
164 1.1.1.2.2.2 bouyer
165 1.1.1.2.2.2 bouyer Op->Asl.EndLine = Neighbor->Asl.EndLine;
166 1.1.1.2.2.2 bouyer Op->Asl.EndLogicalLine = Neighbor->Asl.EndLogicalLine;
167 1.1.1.2.2.2 bouyer Op->Asl.LineNumber = Neighbor->Asl.LineNumber;
168 1.1.1.2.2.2 bouyer Op->Asl.LogicalByteOffset = Neighbor->Asl.LogicalByteOffset;
169 1.1.1.2.2.2 bouyer Op->Asl.LogicalLineNumber = Neighbor->Asl.LogicalLineNumber;
170 1.1.1.2.2.2 bouyer }
171 1.1.1.2.2.2 bouyer
172 1.1.1.2.2.2 bouyer
173 1.1.1.2.2.2 bouyer /*******************************************************************************
174 1.1.1.2.2.2 bouyer *
175 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlInitNode
176 1.1.1.2.2.2 bouyer *
177 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Op to be initialized
178 1.1.1.2.2.2 bouyer * ParseOpcode - Opcode for this node
179 1.1.1.2.2.2 bouyer *
180 1.1.1.2.2.2 bouyer * RETURN: None
181 1.1.1.2.2.2 bouyer *
182 1.1.1.2.2.2 bouyer * DESCRIPTION: Initialize a node with the parse opcode and opcode name.
183 1.1.1.2.2.2 bouyer *
184 1.1.1.2.2.2 bouyer ******************************************************************************/
185 1.1.1.2.2.2 bouyer
186 1.1.1.2.2.2 bouyer static void
187 1.1.1.2.2.2 bouyer TrAmlInitNode (
188 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
189 1.1.1.2.2.2 bouyer UINT16 ParseOpcode)
190 1.1.1.2.2.2 bouyer {
191 1.1.1.2.2.2 bouyer
192 1.1.1.2.2.2 bouyer Op->Asl.ParseOpcode = ParseOpcode;
193 1.1.1.2.2.2 bouyer UtSetParseOpName (Op);
194 1.1.1.2.2.2 bouyer }
195 1.1.1.2.2.2 bouyer
196 1.1.1.2.2.2 bouyer
197 1.1.1.2.2.2 bouyer /*******************************************************************************
198 1.1.1.2.2.2 bouyer *
199 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlSetSubtreeParent
200 1.1.1.2.2.2 bouyer *
201 1.1.1.2.2.2 bouyer * PARAMETERS: Op - First node in a list of peer nodes
202 1.1.1.2.2.2 bouyer * Parent - Parent of the subtree
203 1.1.1.2.2.2 bouyer *
204 1.1.1.2.2.2 bouyer * RETURN: None
205 1.1.1.2.2.2 bouyer *
206 1.1.1.2.2.2 bouyer * DESCRIPTION: Set the parent for all peer nodes in a subtree
207 1.1.1.2.2.2 bouyer *
208 1.1.1.2.2.2 bouyer ******************************************************************************/
209 1.1.1.2.2.2 bouyer
210 1.1.1.2.2.2 bouyer static void
211 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (
212 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
213 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Parent)
214 1.1.1.2.2.2 bouyer {
215 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Next;
216 1.1.1.2.2.2 bouyer
217 1.1.1.2.2.2 bouyer
218 1.1.1.2.2.2 bouyer Next = Op;
219 1.1.1.2.2.2 bouyer while (Next)
220 1.1.1.2.2.2 bouyer {
221 1.1.1.2.2.2 bouyer Next->Asl.Parent = Parent;
222 1.1.1.2.2.2 bouyer Next = Next->Asl.Next;
223 1.1.1.2.2.2 bouyer }
224 1.1.1.2.2.2 bouyer }
225 1.1.1.2.2.2 bouyer
226 1.1.1.2.2.2 bouyer
227 1.1.1.2.2.2 bouyer /*******************************************************************************
228 1.1.1.2.2.2 bouyer *
229 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlInsertPeer
230 1.1.1.2.2.2 bouyer *
231 1.1.1.2.2.2 bouyer * PARAMETERS: Op - First node in a list of peer nodes
232 1.1.1.2.2.2 bouyer * NewPeer - Peer node to insert
233 1.1.1.2.2.2 bouyer *
234 1.1.1.2.2.2 bouyer * RETURN: None
235 1.1.1.2.2.2 bouyer *
236 1.1.1.2.2.2 bouyer * DESCRIPTION: Insert a new peer node into a list of peers.
237 1.1.1.2.2.2 bouyer *
238 1.1.1.2.2.2 bouyer ******************************************************************************/
239 1.1.1.2.2.2 bouyer
240 1.1.1.2.2.2 bouyer static void
241 1.1.1.2.2.2 bouyer TrAmlInsertPeer (
242 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
243 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NewPeer)
244 1.1.1.2.2.2 bouyer {
245 1.1.1.2.2.2 bouyer
246 1.1.1.2.2.2 bouyer NewPeer->Asl.Next = Op->Asl.Next;
247 1.1.1.2.2.2 bouyer Op->Asl.Next = NewPeer;
248 1.1.1.2.2.2 bouyer }
249 1.1.1.2.2.2 bouyer
250 1.1.1.2.2.2 bouyer
251 1.1.1.2.2.2 bouyer /*******************************************************************************
252 1.1.1.2.2.2 bouyer *
253 1.1.1.2.2.2 bouyer * FUNCTION: TrAmlTransformWalk
254 1.1.1.2.2.2 bouyer *
255 1.1.1.2.2.2 bouyer * PARAMETERS: ASL_WALK_CALLBACK
256 1.1.1.2.2.2 bouyer *
257 1.1.1.2.2.2 bouyer * RETURN: None
258 1.1.1.2.2.2 bouyer *
259 1.1.1.2.2.2 bouyer * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
260 1.1.1.2.2.2 bouyer * operands.
261 1.1.1.2.2.2 bouyer *
262 1.1.1.2.2.2 bouyer ******************************************************************************/
263 1.1.1.2.2.2 bouyer
264 1.1.1.2.2.2 bouyer ACPI_STATUS
265 1.1.1.2.2.2 bouyer TrAmlTransformWalk (
266 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
267 1.1.1.2.2.2 bouyer UINT32 Level,
268 1.1.1.2.2.2 bouyer void *Context)
269 1.1.1.2.2.2 bouyer {
270 1.1.1.2.2.2 bouyer
271 1.1.1.2.2.2 bouyer TrTransformSubtree (Op);
272 1.1.1.2.2.2 bouyer return (AE_OK);
273 1.1.1.2.2.2 bouyer }
274 1.1.1.2.2.2 bouyer
275 1.1.1.2.2.2 bouyer
276 1.1.1.2.2.2 bouyer /*******************************************************************************
277 1.1.1.2.2.2 bouyer *
278 1.1.1.2.2.2 bouyer * FUNCTION: TrTransformSubtree
279 1.1.1.2.2.2 bouyer *
280 1.1.1.2.2.2 bouyer * PARAMETERS: Op - The parent parse node
281 1.1.1.2.2.2 bouyer *
282 1.1.1.2.2.2 bouyer * RETURN: None
283 1.1.1.2.2.2 bouyer *
284 1.1.1.2.2.2 bouyer * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
285 1.1.1.2.2.2 bouyer * complex AML opcodes require processing of the child nodes
286 1.1.1.2.2.2 bouyer * (arguments/operands).
287 1.1.1.2.2.2 bouyer *
288 1.1.1.2.2.2 bouyer ******************************************************************************/
289 1.1.1.2.2.2 bouyer
290 1.1.1.2.2.2 bouyer static void
291 1.1.1.2.2.2 bouyer TrTransformSubtree (
292 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
293 1.1.1.2.2.2 bouyer {
294 1.1.1.2.2.2 bouyer
295 1.1.1.2.2.2 bouyer if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
296 1.1.1.2.2.2 bouyer {
297 1.1.1.2.2.2 bouyer return;
298 1.1.1.2.2.2 bouyer }
299 1.1.1.2.2.2 bouyer
300 1.1.1.2.2.2 bouyer switch (Op->Asl.ParseOpcode)
301 1.1.1.2.2.2 bouyer {
302 1.1.1.2.2.2 bouyer case PARSEOP_DEFINITIONBLOCK:
303 1.1.1.2.2.2 bouyer TrDoDefinitionBlock (Op);
304 1.1.1.2.2.2 bouyer break;
305 1.1.1.2.2.2 bouyer
306 1.1.1.2.2.2 bouyer case PARSEOP_SWITCH:
307 1.1.1.2.2.2 bouyer TrDoSwitch (Op);
308 1.1.1.2.2.2 bouyer break;
309 1.1.1.2.2.2 bouyer
310 1.1.1.2.2.2 bouyer case PARSEOP_METHOD:
311 1.1.1.2.2.2 bouyer
312 1.1.1.2.2.2 bouyer /*
313 1.1.1.2.2.2 bouyer * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global,
314 1.1.1.2.2.2 bouyer * however
315 1.1.1.2.2.2 bouyer */
316 1.1.1.2.2.2 bouyer Gbl_TempCount = 0;
317 1.1.1.2.2.2 bouyer break;
318 1.1.1.2.2.2 bouyer
319 1.1.1.2.2.2 bouyer default:
320 1.1.1.2.2.2 bouyer /* Nothing to do here for other opcodes */
321 1.1.1.2.2.2 bouyer break;
322 1.1.1.2.2.2 bouyer }
323 1.1.1.2.2.2 bouyer }
324 1.1.1.2.2.2 bouyer
325 1.1.1.2.2.2 bouyer
326 1.1.1.2.2.2 bouyer /*******************************************************************************
327 1.1.1.2.2.2 bouyer *
328 1.1.1.2.2.2 bouyer * FUNCTION: TrDoDefinitionBlock
329 1.1.1.2.2.2 bouyer *
330 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Parse node
331 1.1.1.2.2.2 bouyer *
332 1.1.1.2.2.2 bouyer * RETURN: None
333 1.1.1.2.2.2 bouyer *
334 1.1.1.2.2.2 bouyer * DESCRIPTION: Find the end of the definition block and set a global to this
335 1.1.1.2.2.2 bouyer * node. It is used by the compiler to insert compiler-generated
336 1.1.1.2.2.2 bouyer * names at the root level of the namespace.
337 1.1.1.2.2.2 bouyer *
338 1.1.1.2.2.2 bouyer ******************************************************************************/
339 1.1.1.2.2.2 bouyer
340 1.1.1.2.2.2 bouyer static void
341 1.1.1.2.2.2 bouyer TrDoDefinitionBlock (
342 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
343 1.1.1.2.2.2 bouyer {
344 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Next;
345 1.1.1.2.2.2 bouyer UINT32 i;
346 1.1.1.2.2.2 bouyer
347 1.1.1.2.2.2 bouyer
348 1.1.1.2.2.2 bouyer Next = Op->Asl.Child;
349 1.1.1.2.2.2 bouyer for (i = 0; i < 5; i++)
350 1.1.1.2.2.2 bouyer {
351 1.1.1.2.2.2 bouyer Next = Next->Asl.Next;
352 1.1.1.2.2.2 bouyer if (i == 0)
353 1.1.1.2.2.2 bouyer {
354 1.1.1.2.2.2 bouyer /*
355 1.1.1.2.2.2 bouyer * This is the table signature. Only the DSDT can be assumed
356 1.1.1.2.2.2 bouyer * to be at the root of the namespace; Therefore, namepath
357 1.1.1.2.2.2 bouyer * optimization can only be performed on the DSDT.
358 1.1.1.2.2.2 bouyer */
359 1.1.1.2.2.2 bouyer if (!ACPI_COMPARE_NAME (Next->Asl.Value.String, ACPI_SIG_DSDT))
360 1.1.1.2.2.2 bouyer {
361 1.1.1.2.2.2 bouyer Gbl_ReferenceOptimizationFlag = FALSE;
362 1.1.1.2.2.2 bouyer }
363 1.1.1.2.2.2 bouyer }
364 1.1.1.2.2.2 bouyer }
365 1.1.1.2.2.2 bouyer
366 1.1.1.2.2.2 bouyer Gbl_FirstLevelInsertionNode = Next;
367 1.1.1.2.2.2 bouyer }
368 1.1.1.2.2.2 bouyer
369 1.1.1.2.2.2 bouyer
370 1.1.1.2.2.2 bouyer /*******************************************************************************
371 1.1.1.2.2.2 bouyer *
372 1.1.1.2.2.2 bouyer * FUNCTION: TrDoSwitch
373 1.1.1.2.2.2 bouyer *
374 1.1.1.2.2.2 bouyer * PARAMETERS: StartNode - Parse node for SWITCH
375 1.1.1.2.2.2 bouyer *
376 1.1.1.2.2.2 bouyer * RETURN: None
377 1.1.1.2.2.2 bouyer *
378 1.1.1.2.2.2 bouyer *
379 1.1.1.2.2.2 bouyer * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is
380 1.1.1.2.2.2 bouyer * no actual AML opcode for SWITCH -- it must be simulated.
381 1.1.1.2.2.2 bouyer *
382 1.1.1.2.2.2 bouyer ******************************************************************************/
383 1.1.1.2.2.2 bouyer
384 1.1.1.2.2.2 bouyer static void
385 1.1.1.2.2.2 bouyer TrDoSwitch (
386 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *StartNode)
387 1.1.1.2.2.2 bouyer {
388 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Next;
389 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *CaseOp = NULL;
390 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *CaseBlock = NULL;
391 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *DefaultOp = NULL;
392 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *CurrentParentNode;
393 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Conditional = NULL;
394 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Predicate;
395 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Peer;
396 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NewOp;
397 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NewOp2;
398 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *MethodOp;
399 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *StoreOp;
400 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *BreakOp;
401 1.1.1.2.2.2 bouyer char *PredicateValueName;
402 1.1.1.2.2.2 bouyer UINT16 Index;
403 1.1.1.2.2.2 bouyer UINT32 Btype;
404 1.1.1.2.2.2 bouyer
405 1.1.1.2.2.2 bouyer
406 1.1.1.2.2.2 bouyer /* Start node is the Switch() node */
407 1.1.1.2.2.2 bouyer
408 1.1.1.2.2.2 bouyer CurrentParentNode = StartNode;
409 1.1.1.2.2.2 bouyer
410 1.1.1.2.2.2 bouyer /* Create a new temp name of the form _T_x */
411 1.1.1.2.2.2 bouyer
412 1.1.1.2.2.2 bouyer PredicateValueName = TrAmlGetNextTempName (StartNode, &Gbl_TempCount);
413 1.1.1.2.2.2 bouyer if (!PredicateValueName)
414 1.1.1.2.2.2 bouyer {
415 1.1.1.2.2.2 bouyer return;
416 1.1.1.2.2.2 bouyer }
417 1.1.1.2.2.2 bouyer
418 1.1.1.2.2.2 bouyer /* First child is the Switch() predicate */
419 1.1.1.2.2.2 bouyer
420 1.1.1.2.2.2 bouyer Next = StartNode->Asl.Child;
421 1.1.1.2.2.2 bouyer
422 1.1.1.2.2.2 bouyer /*
423 1.1.1.2.2.2 bouyer * Examine the return type of the Switch Value -
424 1.1.1.2.2.2 bouyer * must be Integer/Buffer/String
425 1.1.1.2.2.2 bouyer */
426 1.1.1.2.2.2 bouyer Index = (UINT16) (Next->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
427 1.1.1.2.2.2 bouyer Btype = AslKeywordMapping[Index].AcpiBtype;
428 1.1.1.2.2.2 bouyer if ((Btype != ACPI_BTYPE_INTEGER) &&
429 1.1.1.2.2.2 bouyer (Btype != ACPI_BTYPE_STRING) &&
430 1.1.1.2.2.2 bouyer (Btype != ACPI_BTYPE_BUFFER))
431 1.1.1.2.2.2 bouyer {
432 1.1.1.2.2.2 bouyer AslError (ASL_WARNING, ASL_MSG_SWITCH_TYPE, Next, NULL);
433 1.1.1.2.2.2 bouyer Btype = ACPI_BTYPE_INTEGER;
434 1.1.1.2.2.2 bouyer }
435 1.1.1.2.2.2 bouyer
436 1.1.1.2.2.2 bouyer /* CASE statements start at next child */
437 1.1.1.2.2.2 bouyer
438 1.1.1.2.2.2 bouyer Peer = Next->Asl.Next;
439 1.1.1.2.2.2 bouyer while (Peer)
440 1.1.1.2.2.2 bouyer {
441 1.1.1.2.2.2 bouyer Next = Peer;
442 1.1.1.2.2.2 bouyer Peer = Next->Asl.Next;
443 1.1.1.2.2.2 bouyer
444 1.1.1.2.2.2 bouyer if (Next->Asl.ParseOpcode == PARSEOP_CASE)
445 1.1.1.2.2.2 bouyer {
446 1.1.1.2.2.2 bouyer if (CaseOp)
447 1.1.1.2.2.2 bouyer {
448 1.1.1.2.2.2 bouyer /* Add an ELSE to complete the previous CASE */
449 1.1.1.2.2.2 bouyer
450 1.1.1.2.2.2 bouyer if (!Conditional)
451 1.1.1.2.2.2 bouyer {
452 1.1.1.2.2.2 bouyer return;
453 1.1.1.2.2.2 bouyer }
454 1.1.1.2.2.2 bouyer NewOp = TrCreateLeafNode (PARSEOP_ELSE);
455 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = Conditional->Asl.Parent;
456 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent);
457 1.1.1.2.2.2 bouyer
458 1.1.1.2.2.2 bouyer /* Link ELSE node as a peer to the previous IF */
459 1.1.1.2.2.2 bouyer
460 1.1.1.2.2.2 bouyer TrAmlInsertPeer (Conditional, NewOp);
461 1.1.1.2.2.2 bouyer CurrentParentNode = NewOp;
462 1.1.1.2.2.2 bouyer }
463 1.1.1.2.2.2 bouyer
464 1.1.1.2.2.2 bouyer CaseOp = Next;
465 1.1.1.2.2.2 bouyer Conditional = CaseOp;
466 1.1.1.2.2.2 bouyer CaseBlock = CaseOp->Asl.Child->Asl.Next;
467 1.1.1.2.2.2 bouyer Conditional->Asl.Child->Asl.Next = NULL;
468 1.1.1.2.2.2 bouyer Predicate = CaseOp->Asl.Child;
469 1.1.1.2.2.2 bouyer
470 1.1.1.2.2.2 bouyer if ((Predicate->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
471 1.1.1.2.2.2 bouyer (Predicate->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
472 1.1.1.2.2.2 bouyer {
473 1.1.1.2.2.2 bouyer /*
474 1.1.1.2.2.2 bouyer * Convert the package declaration to this form:
475 1.1.1.2.2.2 bouyer *
476 1.1.1.2.2.2 bouyer * If (LNotEqual (Match (Package(<size>){<data>},
477 1.1.1.2.2.2 bouyer * MEQ, _T_x, MTR, Zero, Zero), Ones))
478 1.1.1.2.2.2 bouyer */
479 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);
480 1.1.1.2.2.2 bouyer Predicate->Asl.Next = NewOp2;
481 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
482 1.1.1.2.2.2 bouyer
483 1.1.1.2.2.2 bouyer NewOp = NewOp2;
484 1.1.1.2.2.2 bouyer NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
485 1.1.1.2.2.2 bouyer (UINT64) ACPI_TO_INTEGER (PredicateValueName));
486 1.1.1.2.2.2 bouyer NewOp->Asl.Next = NewOp2;
487 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Predicate);
488 1.1.1.2.2.2 bouyer
489 1.1.1.2.2.2 bouyer NewOp = NewOp2;
490 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);
491 1.1.1.2.2.2 bouyer NewOp->Asl.Next = NewOp2;
492 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Predicate);
493 1.1.1.2.2.2 bouyer
494 1.1.1.2.2.2 bouyer NewOp = NewOp2;
495 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_ZERO);
496 1.1.1.2.2.2 bouyer NewOp->Asl.Next = NewOp2;
497 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Predicate);
498 1.1.1.2.2.2 bouyer
499 1.1.1.2.2.2 bouyer NewOp = NewOp2;
500 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_ZERO);
501 1.1.1.2.2.2 bouyer NewOp->Asl.Next = NewOp2;
502 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Predicate);
503 1.1.1.2.2.2 bouyer
504 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_MATCH);
505 1.1.1.2.2.2 bouyer NewOp2->Asl.Child = Predicate; /* PARSEOP_PACKAGE */
506 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
507 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (Predicate, NewOp2);
508 1.1.1.2.2.2 bouyer
509 1.1.1.2.2.2 bouyer NewOp = NewOp2;
510 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_ONES);
511 1.1.1.2.2.2 bouyer NewOp->Asl.Next = NewOp2;
512 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
513 1.1.1.2.2.2 bouyer
514 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
515 1.1.1.2.2.2 bouyer NewOp2->Asl.Child = NewOp;
516 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = NewOp2;
517 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
518 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (NewOp, NewOp2);
519 1.1.1.2.2.2 bouyer
520 1.1.1.2.2.2 bouyer NewOp = NewOp2;
521 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_LNOT);
522 1.1.1.2.2.2 bouyer NewOp2->Asl.Child = NewOp;
523 1.1.1.2.2.2 bouyer NewOp2->Asl.Parent = Conditional;
524 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = NewOp2;
525 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
526 1.1.1.2.2.2 bouyer
527 1.1.1.2.2.2 bouyer Conditional->Asl.Child = NewOp2;
528 1.1.1.2.2.2 bouyer NewOp2->Asl.Next = CaseBlock;
529 1.1.1.2.2.2 bouyer }
530 1.1.1.2.2.2 bouyer else
531 1.1.1.2.2.2 bouyer {
532 1.1.1.2.2.2 bouyer /*
533 1.1.1.2.2.2 bouyer * Integer and Buffer case.
534 1.1.1.2.2.2 bouyer *
535 1.1.1.2.2.2 bouyer * Change CaseOp() to: If (LEqual (SwitchValue, CaseValue)) {...}
536 1.1.1.2.2.2 bouyer * Note: SwitchValue is first to allow the CaseValue to be implicitly
537 1.1.1.2.2.2 bouyer * converted to the type of SwitchValue if necessary.
538 1.1.1.2.2.2 bouyer *
539 1.1.1.2.2.2 bouyer * CaseOp->Child is the case value
540 1.1.1.2.2.2 bouyer * CaseOp->Child->Peer is the beginning of the case block
541 1.1.1.2.2.2 bouyer */
542 1.1.1.2.2.2 bouyer NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
543 1.1.1.2.2.2 bouyer (UINT64) ACPI_TO_INTEGER (PredicateValueName));
544 1.1.1.2.2.2 bouyer NewOp->Asl.Next = Predicate;
545 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp, Predicate);
546 1.1.1.2.2.2 bouyer
547 1.1.1.2.2.2 bouyer NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
548 1.1.1.2.2.2 bouyer NewOp2->Asl.Parent = Conditional;
549 1.1.1.2.2.2 bouyer NewOp2->Asl.Child = NewOp;
550 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp2, Conditional);
551 1.1.1.2.2.2 bouyer
552 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (NewOp, NewOp2);
553 1.1.1.2.2.2 bouyer
554 1.1.1.2.2.2 bouyer Predicate = NewOp2;
555 1.1.1.2.2.2 bouyer Predicate->Asl.Next = CaseBlock;
556 1.1.1.2.2.2 bouyer
557 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (Predicate, Conditional);
558 1.1.1.2.2.2 bouyer Conditional->Asl.Child = Predicate;
559 1.1.1.2.2.2 bouyer }
560 1.1.1.2.2.2 bouyer
561 1.1.1.2.2.2 bouyer /* Reinitialize the CASE node to an IF node */
562 1.1.1.2.2.2 bouyer
563 1.1.1.2.2.2 bouyer TrAmlInitNode (Conditional, PARSEOP_IF);
564 1.1.1.2.2.2 bouyer
565 1.1.1.2.2.2 bouyer /*
566 1.1.1.2.2.2 bouyer * The first CASE(IF) is not nested under an ELSE.
567 1.1.1.2.2.2 bouyer * All other CASEs are children of a parent ELSE.
568 1.1.1.2.2.2 bouyer */
569 1.1.1.2.2.2 bouyer if (CurrentParentNode == StartNode)
570 1.1.1.2.2.2 bouyer {
571 1.1.1.2.2.2 bouyer Conditional->Asl.Next = NULL;
572 1.1.1.2.2.2 bouyer }
573 1.1.1.2.2.2 bouyer else
574 1.1.1.2.2.2 bouyer {
575 1.1.1.2.2.2 bouyer /*
576 1.1.1.2.2.2 bouyer * The IF is a child of previous IF/ELSE. It
577 1.1.1.2.2.2 bouyer * is therefore without peer.
578 1.1.1.2.2.2 bouyer */
579 1.1.1.2.2.2 bouyer CurrentParentNode->Asl.Child = Conditional;
580 1.1.1.2.2.2 bouyer Conditional->Asl.Parent = CurrentParentNode;
581 1.1.1.2.2.2 bouyer Conditional->Asl.Next = NULL;
582 1.1.1.2.2.2 bouyer }
583 1.1.1.2.2.2 bouyer }
584 1.1.1.2.2.2 bouyer else if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT)
585 1.1.1.2.2.2 bouyer {
586 1.1.1.2.2.2 bouyer if (DefaultOp)
587 1.1.1.2.2.2 bouyer {
588 1.1.1.2.2.2 bouyer /*
589 1.1.1.2.2.2 bouyer * More than one Default
590 1.1.1.2.2.2 bouyer * (Parser does not catch this, must check here)
591 1.1.1.2.2.2 bouyer */
592 1.1.1.2.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_MULTIPLE_DEFAULT, Next, NULL);
593 1.1.1.2.2.2 bouyer }
594 1.1.1.2.2.2 bouyer else
595 1.1.1.2.2.2 bouyer {
596 1.1.1.2.2.2 bouyer /* Save the DEFAULT node for later, after CASEs */
597 1.1.1.2.2.2 bouyer
598 1.1.1.2.2.2 bouyer DefaultOp = Next;
599 1.1.1.2.2.2 bouyer }
600 1.1.1.2.2.2 bouyer }
601 1.1.1.2.2.2 bouyer else
602 1.1.1.2.2.2 bouyer {
603 1.1.1.2.2.2 bouyer /* Unknown peer opcode */
604 1.1.1.2.2.2 bouyer
605 1.1.1.2.2.2 bouyer AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%u)\n",
606 1.1.1.2.2.2 bouyer Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
607 1.1.1.2.2.2 bouyer }
608 1.1.1.2.2.2 bouyer }
609 1.1.1.2.2.2 bouyer
610 1.1.1.2.2.2 bouyer /* Add the default case at the end of the if/else construct */
611 1.1.1.2.2.2 bouyer
612 1.1.1.2.2.2 bouyer if (DefaultOp)
613 1.1.1.2.2.2 bouyer {
614 1.1.1.2.2.2 bouyer /* If no CASE statements, this is an error - see below */
615 1.1.1.2.2.2 bouyer
616 1.1.1.2.2.2 bouyer if (CaseOp)
617 1.1.1.2.2.2 bouyer {
618 1.1.1.2.2.2 bouyer /* Convert the DEFAULT node to an ELSE */
619 1.1.1.2.2.2 bouyer
620 1.1.1.2.2.2 bouyer if (!Conditional)
621 1.1.1.2.2.2 bouyer {
622 1.1.1.2.2.2 bouyer return;
623 1.1.1.2.2.2 bouyer }
624 1.1.1.2.2.2 bouyer
625 1.1.1.2.2.2 bouyer TrAmlInitNode (DefaultOp, PARSEOP_ELSE);
626 1.1.1.2.2.2 bouyer DefaultOp->Asl.Parent = Conditional->Asl.Parent;
627 1.1.1.2.2.2 bouyer
628 1.1.1.2.2.2 bouyer /* Link ELSE node as a peer to the previous IF */
629 1.1.1.2.2.2 bouyer
630 1.1.1.2.2.2 bouyer TrAmlInsertPeer (Conditional, DefaultOp);
631 1.1.1.2.2.2 bouyer }
632 1.1.1.2.2.2 bouyer }
633 1.1.1.2.2.2 bouyer
634 1.1.1.2.2.2 bouyer if (!CaseOp)
635 1.1.1.2.2.2 bouyer {
636 1.1.1.2.2.2 bouyer AslError (ASL_ERROR, ASL_MSG_NO_CASES, StartNode, NULL);
637 1.1.1.2.2.2 bouyer }
638 1.1.1.2.2.2 bouyer
639 1.1.1.2.2.2 bouyer
640 1.1.1.2.2.2 bouyer /*
641 1.1.1.2.2.2 bouyer * Create a Name(_T_x, ...) statement. This statement must appear at the
642 1.1.1.2.2.2 bouyer * method level, in case a loop surrounds the switch statement and could
643 1.1.1.2.2.2 bouyer * cause the name to be created twice (error).
644 1.1.1.2.2.2 bouyer */
645 1.1.1.2.2.2 bouyer
646 1.1.1.2.2.2 bouyer /* Create the Name node */
647 1.1.1.2.2.2 bouyer
648 1.1.1.2.2.2 bouyer Predicate = StartNode->Asl.Child;
649 1.1.1.2.2.2 bouyer NewOp = TrCreateLeafNode (PARSEOP_NAME);
650 1.1.1.2.2.2 bouyer
651 1.1.1.2.2.2 bouyer /* Find the parent method */
652 1.1.1.2.2.2 bouyer
653 1.1.1.2.2.2 bouyer Next = StartNode;
654 1.1.1.2.2.2 bouyer while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) &&
655 1.1.1.2.2.2 bouyer (Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK))
656 1.1.1.2.2.2 bouyer {
657 1.1.1.2.2.2 bouyer Next = Next->Asl.Parent;
658 1.1.1.2.2.2 bouyer }
659 1.1.1.2.2.2 bouyer MethodOp = Next;
660 1.1.1.2.2.2 bouyer
661 1.1.1.2.2.2 bouyer NewOp->Asl.CompileFlags |= NODE_COMPILER_EMITTED;
662 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = Next;
663 1.1.1.2.2.2 bouyer
664 1.1.1.2.2.2 bouyer /* Insert name after the method name and arguments */
665 1.1.1.2.2.2 bouyer
666 1.1.1.2.2.2 bouyer Next = Next->Asl.Child; /* Name */
667 1.1.1.2.2.2 bouyer Next = Next->Asl.Next; /* NumArgs */
668 1.1.1.2.2.2 bouyer Next = Next->Asl.Next; /* SerializeRule */
669 1.1.1.2.2.2 bouyer
670 1.1.1.2.2.2 bouyer /*
671 1.1.1.2.2.2 bouyer * If method is not Serialized, we must make is so, because of the way
672 1.1.1.2.2.2 bouyer * that Switch() must be implemented -- we cannot allow multiple threads
673 1.1.1.2.2.2 bouyer * to execute this method concurrently since we need to create local
674 1.1.1.2.2.2 bouyer * temporary name(s).
675 1.1.1.2.2.2 bouyer */
676 1.1.1.2.2.2 bouyer if (Next->Asl.ParseOpcode != PARSEOP_SERIALIZERULE_SERIAL)
677 1.1.1.2.2.2 bouyer {
678 1.1.1.2.2.2 bouyer AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, "Due to use of Switch operator");
679 1.1.1.2.2.2 bouyer Next->Asl.ParseOpcode = PARSEOP_SERIALIZERULE_SERIAL;
680 1.1.1.2.2.2 bouyer }
681 1.1.1.2.2.2 bouyer
682 1.1.1.2.2.2 bouyer Next = Next->Asl.Next; /* SyncLevel */
683 1.1.1.2.2.2 bouyer Next = Next->Asl.Next; /* ReturnType */
684 1.1.1.2.2.2 bouyer Next = Next->Asl.Next; /* ParameterTypes */
685 1.1.1.2.2.2 bouyer
686 1.1.1.2.2.2 bouyer TrAmlInsertPeer (Next, NewOp);
687 1.1.1.2.2.2 bouyer TrAmlInitLineNumbers (NewOp, Next);
688 1.1.1.2.2.2 bouyer
689 1.1.1.2.2.2 bouyer /* Create the NameSeg child for the Name node */
690 1.1.1.2.2.2 bouyer
691 1.1.1.2.2.2 bouyer NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
692 1.1.1.2.2.2 bouyer (UINT64) ACPI_TO_INTEGER (PredicateValueName));
693 1.1.1.2.2.2 bouyer NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION;
694 1.1.1.2.2.2 bouyer NewOp->Asl.Child = NewOp2;
695 1.1.1.2.2.2 bouyer
696 1.1.1.2.2.2 bouyer /* Create the initial value for the Name. Btype was already validated above */
697 1.1.1.2.2.2 bouyer
698 1.1.1.2.2.2 bouyer switch (Btype)
699 1.1.1.2.2.2 bouyer {
700 1.1.1.2.2.2 bouyer case ACPI_BTYPE_INTEGER:
701 1.1.1.2.2.2 bouyer NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO,
702 1.1.1.2.2.2 bouyer (UINT64) 0);
703 1.1.1.2.2.2 bouyer break;
704 1.1.1.2.2.2 bouyer
705 1.1.1.2.2.2 bouyer case ACPI_BTYPE_STRING:
706 1.1.1.2.2.2 bouyer NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL,
707 1.1.1.2.2.2 bouyer (UINT64) ACPI_TO_INTEGER (""));
708 1.1.1.2.2.2 bouyer break;
709 1.1.1.2.2.2 bouyer
710 1.1.1.2.2.2 bouyer case ACPI_BTYPE_BUFFER:
711 1.1.1.2.2.2 bouyer (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER,
712 1.1.1.2.2.2 bouyer (UINT64) 0));
713 1.1.1.2.2.2 bouyer Next = NewOp2->Asl.Next;
714 1.1.1.2.2.2 bouyer (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO,
715 1.1.1.2.2.2 bouyer (UINT64) 1));
716 1.1.1.2.2.2 bouyer (void) TrLinkPeerNode (Next->Asl.Child,
717 1.1.1.2.2.2 bouyer TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (UINT64) 0));
718 1.1.1.2.2.2 bouyer
719 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (Next->Asl.Child, Next);
720 1.1.1.2.2.2 bouyer break;
721 1.1.1.2.2.2 bouyer
722 1.1.1.2.2.2 bouyer default:
723 1.1.1.2.2.2 bouyer break;
724 1.1.1.2.2.2 bouyer }
725 1.1.1.2.2.2 bouyer
726 1.1.1.2.2.2 bouyer TrAmlSetSubtreeParent (NewOp2, NewOp);
727 1.1.1.2.2.2 bouyer
728 1.1.1.2.2.2 bouyer /*
729 1.1.1.2.2.2 bouyer * Transform the Switch() into a While(One)-Break node.
730 1.1.1.2.2.2 bouyer * And create a Store() node which will be used to save the
731 1.1.1.2.2.2 bouyer * Switch() value. The store is of the form: Store (Value, _T_x)
732 1.1.1.2.2.2 bouyer * where _T_x is the temp variable.
733 1.1.1.2.2.2 bouyer */
734 1.1.1.2.2.2 bouyer TrAmlInitNode (StartNode, PARSEOP_WHILE);
735 1.1.1.2.2.2 bouyer NewOp = TrCreateLeafNode (PARSEOP_ONE);
736 1.1.1.2.2.2 bouyer NewOp->Asl.Next = Predicate->Asl.Next;
737 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = StartNode;
738 1.1.1.2.2.2 bouyer StartNode->Asl.Child = NewOp;
739 1.1.1.2.2.2 bouyer
740 1.1.1.2.2.2 bouyer /* Create a Store() node */
741 1.1.1.2.2.2 bouyer
742 1.1.1.2.2.2 bouyer StoreOp = TrCreateLeafNode (PARSEOP_STORE);
743 1.1.1.2.2.2 bouyer StoreOp->Asl.Parent = StartNode;
744 1.1.1.2.2.2 bouyer TrAmlInsertPeer (NewOp, StoreOp);
745 1.1.1.2.2.2 bouyer
746 1.1.1.2.2.2 bouyer /* Complete the Store subtree */
747 1.1.1.2.2.2 bouyer
748 1.1.1.2.2.2 bouyer StoreOp->Asl.Child = Predicate;
749 1.1.1.2.2.2 bouyer Predicate->Asl.Parent = StoreOp;
750 1.1.1.2.2.2 bouyer
751 1.1.1.2.2.2 bouyer NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
752 1.1.1.2.2.2 bouyer (UINT64) ACPI_TO_INTEGER (PredicateValueName));
753 1.1.1.2.2.2 bouyer NewOp->Asl.Parent = StoreOp;
754 1.1.1.2.2.2 bouyer Predicate->Asl.Next = NewOp;
755 1.1.1.2.2.2 bouyer
756 1.1.1.2.2.2 bouyer /* Create a Break() node and insert it into the end of While() */
757 1.1.1.2.2.2 bouyer
758 1.1.1.2.2.2 bouyer Conditional = StartNode->Asl.Child;
759 1.1.1.2.2.2 bouyer while (Conditional->Asl.Next)
760 1.1.1.2.2.2 bouyer {
761 1.1.1.2.2.2 bouyer Conditional = Conditional->Asl.Next;
762 1.1.1.2.2.2 bouyer }
763 1.1.1.2.2.2 bouyer
764 1.1.1.2.2.2 bouyer BreakOp = TrCreateLeafNode (PARSEOP_BREAK);
765 1.1.1.2.2.2 bouyer BreakOp->Asl.Parent = StartNode;
766 1.1.1.2.2.2 bouyer TrAmlInsertPeer (Conditional, BreakOp);
767 1.1.1.2.2.2 bouyer }
768 1.1.1.2.2.2 bouyer
769 1.1.1.2.2.2 bouyer
770