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