aslopcodes.c revision 1.1.1.4.2.3 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: aslopcode - AML opcode generation
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.4.2.3 skrll * Copyright (C) 2000 - 2016, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "aslcompiler.h"
45 1.1 jruoho #include "aslcompiler.y.h"
46 1.1 jruoho #include "amlcode.h"
47 1.1 jruoho
48 1.1 jruoho #define _COMPONENT ACPI_COMPILER
49 1.1 jruoho ACPI_MODULE_NAME ("aslopcodes")
50 1.1 jruoho
51 1.1 jruoho
52 1.1 jruoho /* Local prototypes */
53 1.1 jruoho
54 1.1 jruoho static void
55 1.1 jruoho OpcDoAccessAs (
56 1.1 jruoho ACPI_PARSE_OBJECT *Op);
57 1.1 jruoho
58 1.1 jruoho static void
59 1.1.1.3 christos OpcDoConnection (
60 1.1.1.3 christos ACPI_PARSE_OBJECT *Op);
61 1.1.1.3 christos
62 1.1.1.3 christos static void
63 1.1 jruoho OpcDoUnicode (
64 1.1 jruoho ACPI_PARSE_OBJECT *Op);
65 1.1 jruoho
66 1.1 jruoho static void
67 1.1 jruoho OpcDoEisaId (
68 1.1 jruoho ACPI_PARSE_OBJECT *Op);
69 1.1 jruoho
70 1.1 jruoho static void
71 1.1.1.4.2.1 skrll OpcDoPld (
72 1.1.1.4.2.1 skrll ACPI_PARSE_OBJECT *Op);
73 1.1.1.4.2.1 skrll
74 1.1.1.4.2.1 skrll static void
75 1.1 jruoho OpcDoUuId (
76 1.1 jruoho ACPI_PARSE_OBJECT *Op);
77 1.1 jruoho
78 1.1.1.4.2.1 skrll static UINT8 *
79 1.1.1.4.2.1 skrll OpcEncodePldBuffer (
80 1.1.1.4.2.1 skrll ACPI_PLD_INFO *PldInfo);
81 1.1.1.4.2.1 skrll
82 1.1.1.4.2.1 skrll
83 1.1.1.4.2.1 skrll /* ToPld strings */
84 1.1.1.4.2.1 skrll
85 1.1.1.4.2.1 skrll static char *AslPldPanelList[] =
86 1.1.1.4.2.1 skrll {
87 1.1.1.4.2.1 skrll "TOP",
88 1.1.1.4.2.1 skrll "BOTTOM",
89 1.1.1.4.2.1 skrll "LEFT",
90 1.1.1.4.2.1 skrll "RIGHT",
91 1.1.1.4.2.1 skrll "FRONT",
92 1.1.1.4.2.1 skrll "BACK",
93 1.1.1.4.2.1 skrll "UNKNOWN",
94 1.1.1.4.2.1 skrll NULL
95 1.1.1.4.2.1 skrll };
96 1.1.1.4.2.1 skrll
97 1.1.1.4.2.1 skrll static char *AslPldVerticalPositionList[] =
98 1.1.1.4.2.1 skrll {
99 1.1.1.4.2.1 skrll "UPPER",
100 1.1.1.4.2.1 skrll "CENTER",
101 1.1.1.4.2.1 skrll "LOWER",
102 1.1.1.4.2.1 skrll NULL
103 1.1.1.4.2.1 skrll };
104 1.1.1.4.2.1 skrll
105 1.1.1.4.2.1 skrll static char *AslPldHorizontalPositionList[] =
106 1.1.1.4.2.1 skrll {
107 1.1.1.4.2.1 skrll "LEFT",
108 1.1.1.4.2.1 skrll "CENTER",
109 1.1.1.4.2.1 skrll "RIGHT",
110 1.1.1.4.2.1 skrll NULL
111 1.1.1.4.2.1 skrll };
112 1.1.1.4.2.1 skrll
113 1.1.1.4.2.1 skrll static char *AslPldShapeList[] =
114 1.1.1.4.2.1 skrll {
115 1.1.1.4.2.1 skrll "ROUND",
116 1.1.1.4.2.1 skrll "OVAL",
117 1.1.1.4.2.1 skrll "SQUARE",
118 1.1.1.4.2.1 skrll "VERTICALRECTANGLE",
119 1.1.1.4.2.1 skrll "HORIZONTALRECTANGLE",
120 1.1.1.4.2.1 skrll "VERTICALTRAPEZOID",
121 1.1.1.4.2.1 skrll "HORIZONTALTRAPEZOID",
122 1.1.1.4.2.1 skrll "UNKNOWN",
123 1.1.1.4.2.1 skrll "CHAMFERED",
124 1.1.1.4.2.1 skrll NULL
125 1.1.1.4.2.1 skrll };
126 1.1.1.4.2.1 skrll
127 1.1 jruoho
128 1.1 jruoho /*******************************************************************************
129 1.1 jruoho *
130 1.1 jruoho * FUNCTION: OpcAmlOpcodeUpdateWalk
131 1.1 jruoho *
132 1.1 jruoho * PARAMETERS: ASL_WALK_CALLBACK
133 1.1 jruoho *
134 1.1 jruoho * RETURN: Status
135 1.1 jruoho *
136 1.1 jruoho * DESCRIPTION: Opcode update walk, ascending callback
137 1.1 jruoho *
138 1.1 jruoho ******************************************************************************/
139 1.1 jruoho
140 1.1 jruoho ACPI_STATUS
141 1.1 jruoho OpcAmlOpcodeUpdateWalk (
142 1.1 jruoho ACPI_PARSE_OBJECT *Op,
143 1.1 jruoho UINT32 Level,
144 1.1 jruoho void *Context)
145 1.1 jruoho {
146 1.1 jruoho
147 1.1 jruoho /*
148 1.1 jruoho * Handle the Package() case where the actual opcode cannot be determined
149 1.1 jruoho * until the PackageLength operand has been folded and minimized.
150 1.1 jruoho * (PackageOp versus VarPackageOp)
151 1.1 jruoho *
152 1.1 jruoho * This is (as of ACPI 3.0) the only case where the AML opcode can change
153 1.1 jruoho * based upon the value of a parameter.
154 1.1 jruoho *
155 1.1 jruoho * The parser always inserts a VarPackage opcode, which can possibly be
156 1.1 jruoho * optimized to a Package opcode.
157 1.1 jruoho */
158 1.1 jruoho if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)
159 1.1 jruoho {
160 1.1 jruoho OpnDoPackage (Op);
161 1.1 jruoho }
162 1.1 jruoho
163 1.1 jruoho return (AE_OK);
164 1.1 jruoho }
165 1.1 jruoho
166 1.1 jruoho
167 1.1 jruoho /*******************************************************************************
168 1.1 jruoho *
169 1.1 jruoho * FUNCTION: OpcAmlOpcodeWalk
170 1.1 jruoho *
171 1.1 jruoho * PARAMETERS: ASL_WALK_CALLBACK
172 1.1 jruoho *
173 1.1 jruoho * RETURN: Status
174 1.1 jruoho *
175 1.1 jruoho * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
176 1.1 jruoho * operands.
177 1.1 jruoho *
178 1.1 jruoho ******************************************************************************/
179 1.1 jruoho
180 1.1 jruoho ACPI_STATUS
181 1.1 jruoho OpcAmlOpcodeWalk (
182 1.1 jruoho ACPI_PARSE_OBJECT *Op,
183 1.1 jruoho UINT32 Level,
184 1.1 jruoho void *Context)
185 1.1 jruoho {
186 1.1 jruoho
187 1.1 jruoho TotalParseNodes++;
188 1.1 jruoho
189 1.1 jruoho OpcGenerateAmlOpcode (Op);
190 1.1 jruoho OpnGenerateAmlOperands (Op);
191 1.1 jruoho return (AE_OK);
192 1.1 jruoho }
193 1.1 jruoho
194 1.1 jruoho
195 1.1 jruoho /*******************************************************************************
196 1.1 jruoho *
197 1.1 jruoho * FUNCTION: OpcGetIntegerWidth
198 1.1 jruoho *
199 1.1 jruoho * PARAMETERS: Op - DEFINITION BLOCK op
200 1.1 jruoho *
201 1.1 jruoho * RETURN: none
202 1.1 jruoho *
203 1.1 jruoho * DESCRIPTION: Extract integer width from the table revision
204 1.1 jruoho *
205 1.1 jruoho ******************************************************************************/
206 1.1 jruoho
207 1.1 jruoho void
208 1.1 jruoho OpcGetIntegerWidth (
209 1.1 jruoho ACPI_PARSE_OBJECT *Op)
210 1.1 jruoho {
211 1.1 jruoho ACPI_PARSE_OBJECT *Child;
212 1.1 jruoho
213 1.1 jruoho
214 1.1 jruoho if (!Op)
215 1.1 jruoho {
216 1.1 jruoho return;
217 1.1 jruoho }
218 1.1 jruoho
219 1.1 jruoho if (Gbl_RevisionOverride)
220 1.1 jruoho {
221 1.1 jruoho AcpiUtSetIntegerWidth (Gbl_RevisionOverride);
222 1.1 jruoho }
223 1.1 jruoho else
224 1.1 jruoho {
225 1.1 jruoho Child = Op->Asl.Child;
226 1.1 jruoho Child = Child->Asl.Next;
227 1.1 jruoho Child = Child->Asl.Next;
228 1.1 jruoho
229 1.1 jruoho /* Use the revision to set the integer width */
230 1.1 jruoho
231 1.1 jruoho AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
232 1.1 jruoho }
233 1.1 jruoho }
234 1.1 jruoho
235 1.1 jruoho
236 1.1 jruoho /*******************************************************************************
237 1.1 jruoho *
238 1.1 jruoho * FUNCTION: OpcSetOptimalIntegerSize
239 1.1 jruoho *
240 1.1 jruoho * PARAMETERS: Op - A parse tree node
241 1.1 jruoho *
242 1.1.1.3 christos * RETURN: Integer width, in bytes. Also sets the node AML opcode to the
243 1.1 jruoho * optimal integer AML prefix opcode.
244 1.1 jruoho *
245 1.1.1.3 christos * DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
246 1.1 jruoho * zeros can be truncated to squeeze the integer into the
247 1.1 jruoho * minimal number of AML bytes.
248 1.1 jruoho *
249 1.1 jruoho ******************************************************************************/
250 1.1 jruoho
251 1.1 jruoho UINT32
252 1.1 jruoho OpcSetOptimalIntegerSize (
253 1.1 jruoho ACPI_PARSE_OBJECT *Op)
254 1.1 jruoho {
255 1.1 jruoho
256 1.1 jruoho #if 0
257 1.1 jruoho /*
258 1.1 jruoho * TBD: - we don't want to optimize integers in the block header, but the
259 1.1 jruoho * code below does not work correctly.
260 1.1 jruoho */
261 1.1 jruoho if (Op->Asl.Parent &&
262 1.1 jruoho Op->Asl.Parent->Asl.Parent &&
263 1.1.1.4.2.3 skrll (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK))
264 1.1 jruoho {
265 1.1.1.3 christos return (0);
266 1.1 jruoho }
267 1.1 jruoho #endif
268 1.1 jruoho
269 1.1 jruoho /*
270 1.1 jruoho * Check for the special AML integers first - Zero, One, Ones.
271 1.1 jruoho * These are single-byte opcodes that are the smallest possible
272 1.1 jruoho * representation of an integer.
273 1.1 jruoho *
274 1.1 jruoho * This optimization is optional.
275 1.1 jruoho */
276 1.1 jruoho if (Gbl_IntegerOptimizationFlag)
277 1.1 jruoho {
278 1.1 jruoho switch (Op->Asl.Value.Integer)
279 1.1 jruoho {
280 1.1 jruoho case 0:
281 1.1 jruoho
282 1.1 jruoho Op->Asl.AmlOpcode = AML_ZERO_OP;
283 1.1 jruoho AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
284 1.1 jruoho Op, "Zero");
285 1.1.1.3 christos return (1);
286 1.1 jruoho
287 1.1 jruoho case 1:
288 1.1 jruoho
289 1.1 jruoho Op->Asl.AmlOpcode = AML_ONE_OP;
290 1.1 jruoho AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
291 1.1 jruoho Op, "One");
292 1.1.1.3 christos return (1);
293 1.1 jruoho
294 1.1 jruoho case ACPI_UINT32_MAX:
295 1.1 jruoho
296 1.1 jruoho /* Check for table integer width (32 or 64) */
297 1.1 jruoho
298 1.1 jruoho if (AcpiGbl_IntegerByteWidth == 4)
299 1.1 jruoho {
300 1.1 jruoho Op->Asl.AmlOpcode = AML_ONES_OP;
301 1.1 jruoho AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
302 1.1 jruoho Op, "Ones");
303 1.1.1.3 christos return (1);
304 1.1 jruoho }
305 1.1 jruoho break;
306 1.1 jruoho
307 1.1 jruoho case ACPI_UINT64_MAX:
308 1.1 jruoho
309 1.1 jruoho /* Check for table integer width (32 or 64) */
310 1.1 jruoho
311 1.1 jruoho if (AcpiGbl_IntegerByteWidth == 8)
312 1.1 jruoho {
313 1.1 jruoho Op->Asl.AmlOpcode = AML_ONES_OP;
314 1.1 jruoho AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
315 1.1 jruoho Op, "Ones");
316 1.1.1.3 christos return (1);
317 1.1 jruoho }
318 1.1 jruoho break;
319 1.1 jruoho
320 1.1 jruoho default:
321 1.1.1.3 christos
322 1.1 jruoho break;
323 1.1 jruoho }
324 1.1 jruoho }
325 1.1 jruoho
326 1.1 jruoho /* Find the best fit using the various AML integer prefixes */
327 1.1 jruoho
328 1.1 jruoho if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
329 1.1 jruoho {
330 1.1 jruoho Op->Asl.AmlOpcode = AML_BYTE_OP;
331 1.1.1.3 christos return (1);
332 1.1 jruoho }
333 1.1.1.4.2.3 skrll
334 1.1 jruoho if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
335 1.1 jruoho {
336 1.1 jruoho Op->Asl.AmlOpcode = AML_WORD_OP;
337 1.1.1.3 christos return (2);
338 1.1 jruoho }
339 1.1.1.4.2.3 skrll
340 1.1 jruoho if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
341 1.1 jruoho {
342 1.1 jruoho Op->Asl.AmlOpcode = AML_DWORD_OP;
343 1.1.1.3 christos return (4);
344 1.1 jruoho }
345 1.1 jruoho else
346 1.1 jruoho {
347 1.1 jruoho if (AcpiGbl_IntegerByteWidth == 4)
348 1.1 jruoho {
349 1.1 jruoho AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH,
350 1.1 jruoho Op, NULL);
351 1.1 jruoho
352 1.1 jruoho if (!Gbl_IgnoreErrors)
353 1.1 jruoho {
354 1.1 jruoho /* Truncate the integer to 32-bit */
355 1.1 jruoho Op->Asl.AmlOpcode = AML_DWORD_OP;
356 1.1.1.3 christos return (4);
357 1.1 jruoho }
358 1.1 jruoho }
359 1.1 jruoho
360 1.1 jruoho Op->Asl.AmlOpcode = AML_QWORD_OP;
361 1.1.1.3 christos return (8);
362 1.1 jruoho }
363 1.1 jruoho }
364 1.1 jruoho
365 1.1 jruoho
366 1.1 jruoho /*******************************************************************************
367 1.1 jruoho *
368 1.1 jruoho * FUNCTION: OpcDoAccessAs
369 1.1 jruoho *
370 1.1 jruoho * PARAMETERS: Op - Parse node
371 1.1 jruoho *
372 1.1 jruoho * RETURN: None
373 1.1 jruoho *
374 1.1 jruoho * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
375 1.1 jruoho *
376 1.1 jruoho ******************************************************************************/
377 1.1 jruoho
378 1.1 jruoho static void
379 1.1 jruoho OpcDoAccessAs (
380 1.1 jruoho ACPI_PARSE_OBJECT *Op)
381 1.1 jruoho {
382 1.1.1.3 christos ACPI_PARSE_OBJECT *TypeOp;
383 1.1.1.3 christos ACPI_PARSE_OBJECT *AttribOp;
384 1.1.1.3 christos ACPI_PARSE_OBJECT *LengthOp;
385 1.1.1.3 christos UINT8 Attribute;
386 1.1 jruoho
387 1.1 jruoho
388 1.1 jruoho Op->Asl.AmlOpcodeLength = 1;
389 1.1.1.3 christos TypeOp = Op->Asl.Child;
390 1.1 jruoho
391 1.1 jruoho /* First child is the access type */
392 1.1 jruoho
393 1.1.1.3 christos TypeOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
394 1.1.1.3 christos TypeOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
395 1.1 jruoho
396 1.1 jruoho /* Second child is the optional access attribute */
397 1.1 jruoho
398 1.1.1.3 christos AttribOp = TypeOp->Asl.Next;
399 1.1.1.3 christos if (AttribOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
400 1.1.1.3 christos {
401 1.1.1.3 christos AttribOp->Asl.Value.Integer = 0;
402 1.1.1.3 christos }
403 1.1.1.4.2.3 skrll
404 1.1.1.3 christos AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
405 1.1.1.3 christos AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
406 1.1.1.3 christos
407 1.1.1.3 christos /* Only a few AccessAttributes support AccessLength */
408 1.1.1.3 christos
409 1.1.1.3 christos Attribute = (UINT8) AttribOp->Asl.Value.Integer;
410 1.1.1.3 christos if ((Attribute != AML_FIELD_ATTRIB_MULTIBYTE) &&
411 1.1.1.3 christos (Attribute != AML_FIELD_ATTRIB_RAW_BYTES) &&
412 1.1.1.3 christos (Attribute != AML_FIELD_ATTRIB_RAW_PROCESS))
413 1.1.1.3 christos {
414 1.1.1.3 christos return;
415 1.1.1.3 christos }
416 1.1.1.3 christos
417 1.1.1.3 christos Op->Asl.AmlOpcode = AML_FIELD_EXT_ACCESS_OP;
418 1.1.1.3 christos
419 1.1.1.3 christos /*
420 1.1.1.3 christos * Child of Attributes is the AccessLength (required for Multibyte,
421 1.1.1.3 christos * RawBytes, RawProcess.)
422 1.1.1.3 christos */
423 1.1.1.3 christos LengthOp = AttribOp->Asl.Child;
424 1.1.1.3 christos if (!LengthOp)
425 1.1.1.3 christos {
426 1.1.1.3 christos return;
427 1.1.1.3 christos }
428 1.1.1.3 christos
429 1.1.1.3 christos /* TBD: probably can remove */
430 1.1.1.3 christos
431 1.1.1.3 christos if (LengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
432 1.1.1.3 christos {
433 1.1.1.3 christos LengthOp->Asl.Value.Integer = 16;
434 1.1.1.3 christos }
435 1.1.1.3 christos
436 1.1.1.3 christos LengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
437 1.1.1.3 christos LengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
438 1.1.1.3 christos }
439 1.1.1.3 christos
440 1.1.1.3 christos
441 1.1.1.3 christos /*******************************************************************************
442 1.1.1.3 christos *
443 1.1.1.3 christos * FUNCTION: OpcDoConnection
444 1.1.1.3 christos *
445 1.1.1.3 christos * PARAMETERS: Op - Parse node
446 1.1.1.3 christos *
447 1.1.1.3 christos * RETURN: None
448 1.1.1.3 christos *
449 1.1.1.3 christos * DESCRIPTION: Implement the Connection ASL keyword.
450 1.1.1.3 christos *
451 1.1.1.3 christos ******************************************************************************/
452 1.1.1.3 christos
453 1.1.1.3 christos static void
454 1.1.1.3 christos OpcDoConnection (
455 1.1.1.3 christos ACPI_PARSE_OBJECT *Op)
456 1.1.1.3 christos {
457 1.1.1.3 christos ASL_RESOURCE_NODE *Rnode;
458 1.1.1.3 christos ACPI_PARSE_OBJECT *BufferOp;
459 1.1.1.3 christos ACPI_PARSE_OBJECT *BufferLengthOp;
460 1.1.1.3 christos ACPI_PARSE_OBJECT *BufferDataOp;
461 1.1.1.4 christos ASL_RESOURCE_INFO Info;
462 1.1.1.3 christos UINT8 State;
463 1.1.1.3 christos
464 1.1.1.3 christos
465 1.1.1.3 christos Op->Asl.AmlOpcodeLength = 1;
466 1.1.1.3 christos
467 1.1.1.3 christos if (Op->Asl.Child->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)
468 1.1.1.3 christos {
469 1.1.1.3 christos return;
470 1.1.1.3 christos }
471 1.1.1.3 christos
472 1.1.1.3 christos BufferOp = Op->Asl.Child;
473 1.1.1.3 christos BufferLengthOp = BufferOp->Asl.Child;
474 1.1.1.3 christos BufferDataOp = BufferLengthOp->Asl.Next;
475 1.1.1.3 christos
476 1.1.1.4 christos Info.DescriptorTypeOp = BufferDataOp->Asl.Next;
477 1.1.1.4 christos Info.CurrentByteOffset = 0;
478 1.1.1.3 christos State = ACPI_RSTATE_NORMAL;
479 1.1.1.4 christos Rnode = RsDoOneResourceDescriptor (&Info, &State);
480 1.1.1.3 christos if (!Rnode)
481 1.1 jruoho {
482 1.1.1.3 christos return; /* error */
483 1.1 jruoho }
484 1.1.1.3 christos
485 1.1.1.3 christos /*
486 1.1.1.3 christos * Transform the nodes into the following
487 1.1.1.3 christos *
488 1.1.1.3 christos * Op -> AML_BUFFER_OP
489 1.1.1.3 christos * First Child -> BufferLength
490 1.1.1.3 christos * Second Child -> Descriptor Buffer (raw byte data)
491 1.1.1.3 christos */
492 1.1.1.4.2.3 skrll BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER;
493 1.1.1.4.2.3 skrll BufferOp->Asl.AmlOpcode = AML_BUFFER_OP;
494 1.1.1.4.2.3 skrll BufferOp->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC;
495 1.1.1.3 christos UtSetParseOpName (BufferOp);
496 1.1.1.3 christos
497 1.1.1.4.2.3 skrll BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
498 1.1.1.3 christos BufferLengthOp->Asl.Value.Integer = Rnode->BufferLength;
499 1.1.1.3 christos (void) OpcSetOptimalIntegerSize (BufferLengthOp);
500 1.1.1.3 christos UtSetParseOpName (BufferLengthOp);
501 1.1.1.3 christos
502 1.1.1.4.2.3 skrll BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
503 1.1.1.4.2.3 skrll BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
504 1.1.1.4.2.3 skrll BufferDataOp->Asl.AmlOpcodeLength = 0;
505 1.1.1.4.2.3 skrll BufferDataOp->Asl.AmlLength = Rnode->BufferLength;
506 1.1.1.4.2.3 skrll BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode;
507 1.1.1.3 christos UtSetParseOpName (BufferDataOp);
508 1.1 jruoho }
509 1.1 jruoho
510 1.1 jruoho
511 1.1 jruoho /*******************************************************************************
512 1.1 jruoho *
513 1.1 jruoho * FUNCTION: OpcDoUnicode
514 1.1 jruoho *
515 1.1 jruoho * PARAMETERS: Op - Parse node
516 1.1 jruoho *
517 1.1 jruoho * RETURN: None
518 1.1 jruoho *
519 1.1 jruoho * DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
520 1.1.1.3 christos * to a unicode buffer. There is no Unicode AML opcode.
521 1.1 jruoho *
522 1.1 jruoho * Note: The Unicode string is 16 bits per character, no leading signature,
523 1.1 jruoho * with a 16-bit terminating NULL.
524 1.1 jruoho *
525 1.1 jruoho ******************************************************************************/
526 1.1 jruoho
527 1.1 jruoho static void
528 1.1 jruoho OpcDoUnicode (
529 1.1 jruoho ACPI_PARSE_OBJECT *Op)
530 1.1 jruoho {
531 1.1 jruoho ACPI_PARSE_OBJECT *InitializerOp;
532 1.1 jruoho UINT32 Length;
533 1.1 jruoho UINT32 Count;
534 1.1 jruoho UINT32 i;
535 1.1 jruoho UINT8 *AsciiString;
536 1.1 jruoho UINT16 *UnicodeString;
537 1.1 jruoho ACPI_PARSE_OBJECT *BufferLengthOp;
538 1.1 jruoho
539 1.1 jruoho
540 1.1 jruoho /* Change op into a buffer object */
541 1.1 jruoho
542 1.1 jruoho Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
543 1.1 jruoho Op->Asl.ParseOpcode = PARSEOP_BUFFER;
544 1.1 jruoho UtSetParseOpName (Op);
545 1.1 jruoho
546 1.1 jruoho /* Buffer Length is first, followed by the string */
547 1.1 jruoho
548 1.1 jruoho BufferLengthOp = Op->Asl.Child;
549 1.1 jruoho InitializerOp = BufferLengthOp->Asl.Next;
550 1.1 jruoho
551 1.1 jruoho AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
552 1.1 jruoho
553 1.1 jruoho /* Create a new buffer for the Unicode string */
554 1.1 jruoho
555 1.1 jruoho Count = strlen (InitializerOp->Asl.Value.String) + 1;
556 1.1 jruoho Length = Count * sizeof (UINT16);
557 1.1 jruoho UnicodeString = UtLocalCalloc (Length);
558 1.1 jruoho
559 1.1 jruoho /* Convert to Unicode string (including null terminator) */
560 1.1 jruoho
561 1.1 jruoho for (i = 0; i < Count; i++)
562 1.1 jruoho {
563 1.1 jruoho UnicodeString[i] = (UINT16) AsciiString[i];
564 1.1 jruoho }
565 1.1 jruoho
566 1.1 jruoho /*
567 1.1 jruoho * Just set the buffer size node to be the buffer length, regardless
568 1.1 jruoho * of whether it was previously an integer or a default_arg placeholder
569 1.1 jruoho */
570 1.1.1.4.2.3 skrll BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
571 1.1.1.4.2.3 skrll BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
572 1.1 jruoho BufferLengthOp->Asl.Value.Integer = Length;
573 1.1 jruoho UtSetParseOpName (BufferLengthOp);
574 1.1 jruoho
575 1.1 jruoho (void) OpcSetOptimalIntegerSize (BufferLengthOp);
576 1.1 jruoho
577 1.1 jruoho /* The Unicode string is a raw data buffer */
578 1.1 jruoho
579 1.1.1.4.2.3 skrll InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
580 1.1.1.4.2.3 skrll InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
581 1.1.1.4.2.3 skrll InitializerOp->Asl.AmlLength = Length;
582 1.1.1.4.2.3 skrll InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
583 1.1.1.4.2.3 skrll InitializerOp->Asl.Child = NULL;
584 1.1 jruoho UtSetParseOpName (InitializerOp);
585 1.1 jruoho }
586 1.1 jruoho
587 1.1 jruoho
588 1.1 jruoho /*******************************************************************************
589 1.1 jruoho *
590 1.1 jruoho * FUNCTION: OpcDoEisaId
591 1.1 jruoho *
592 1.1 jruoho * PARAMETERS: Op - Parse node
593 1.1 jruoho *
594 1.1 jruoho * RETURN: None
595 1.1 jruoho *
596 1.1.1.3 christos * DESCRIPTION: Convert a string EISA ID to numeric representation. See the
597 1.1.1.3 christos * Pnp BIOS Specification for details. Here is an excerpt:
598 1.1 jruoho *
599 1.1 jruoho * A seven character ASCII representation of the product
600 1.1.1.3 christos * identifier compressed into a 32-bit identifier. The seven
601 1.1 jruoho * character ID consists of a three character manufacturer code,
602 1.1 jruoho * a three character hexadecimal product identifier, and a one
603 1.1.1.3 christos * character hexadecimal revision number. The manufacturer code
604 1.1 jruoho * is a 3 uppercase character code that is compressed into 3 5-bit
605 1.1 jruoho * values as follows:
606 1.1 jruoho * 1) Find hex ASCII value for each letter
607 1.1 jruoho * 2) Subtract 40h from each ASCII value
608 1.1.1.3 christos * 3) Retain 5 least significant bits for each letter by
609 1.1 jruoho * discarding upper 3 bits because they are always 0.
610 1.1 jruoho * 4) Compressed code = concatenate 0 and the 3 5-bit values
611 1.1 jruoho *
612 1.1 jruoho * The format of the compressed product identifier is as follows:
613 1.1 jruoho * Byte 0: Bit 7 - Reserved (0)
614 1.1 jruoho * Bits 6-2: - 1st character of compressed mfg code
615 1.1 jruoho * Bits 1-0 - Upper 2 bits of 2nd character of mfg code
616 1.1 jruoho * Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code
617 1.1 jruoho * Bits 4-0 - 3rd character of mfg code
618 1.1 jruoho * Byte 2: Bits 7-4 - 1st hex digit of product number
619 1.1 jruoho * Bits 3-0 - 2nd hex digit of product number
620 1.1 jruoho * Byte 3: Bits 7-4 - 3st hex digit of product number
621 1.1 jruoho * Bits 3-0 - Hex digit of the revision number
622 1.1 jruoho *
623 1.1 jruoho ******************************************************************************/
624 1.1 jruoho
625 1.1 jruoho static void
626 1.1 jruoho OpcDoEisaId (
627 1.1 jruoho ACPI_PARSE_OBJECT *Op)
628 1.1 jruoho {
629 1.1 jruoho UINT32 EisaId = 0;
630 1.1 jruoho UINT32 BigEndianId;
631 1.1 jruoho char *InString;
632 1.1 jruoho ACPI_STATUS Status = AE_OK;
633 1.1 jruoho UINT32 i;
634 1.1 jruoho
635 1.1 jruoho
636 1.1 jruoho InString = (char *) Op->Asl.Value.String;
637 1.1 jruoho
638 1.1 jruoho /*
639 1.1 jruoho * The EISAID string must be exactly 7 characters and of the form
640 1.1 jruoho * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
641 1.1 jruoho */
642 1.1.1.4.2.2 skrll if (strlen (InString) != 7)
643 1.1 jruoho {
644 1.1 jruoho Status = AE_BAD_PARAMETER;
645 1.1 jruoho }
646 1.1 jruoho else
647 1.1 jruoho {
648 1.1 jruoho /* Check all 7 characters for correct format */
649 1.1 jruoho
650 1.1 jruoho for (i = 0; i < 7; i++)
651 1.1 jruoho {
652 1.1 jruoho /* First 3 characters must be uppercase letters */
653 1.1 jruoho
654 1.1 jruoho if (i < 3)
655 1.1 jruoho {
656 1.1 jruoho if (!isupper ((int) InString[i]))
657 1.1 jruoho {
658 1.1 jruoho Status = AE_BAD_PARAMETER;
659 1.1 jruoho }
660 1.1 jruoho }
661 1.1 jruoho
662 1.1 jruoho /* Last 4 characters must be hex digits */
663 1.1 jruoho
664 1.1 jruoho else if (!isxdigit ((int) InString[i]))
665 1.1 jruoho {
666 1.1 jruoho Status = AE_BAD_PARAMETER;
667 1.1 jruoho }
668 1.1 jruoho }
669 1.1 jruoho }
670 1.1 jruoho
671 1.1 jruoho if (ACPI_FAILURE (Status))
672 1.1 jruoho {
673 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
674 1.1 jruoho }
675 1.1 jruoho else
676 1.1 jruoho {
677 1.1 jruoho /* Create ID big-endian first (bits are contiguous) */
678 1.1 jruoho
679 1.1 jruoho BigEndianId =
680 1.1.1.2 jruoho (UINT32) ((UINT8) (InString[0] - 0x40)) << 26 |
681 1.1.1.2 jruoho (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 |
682 1.1.1.2 jruoho (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 |
683 1.1 jruoho
684 1.1.1.4 christos (AcpiUtAsciiCharToHex (InString[3])) << 12 |
685 1.1.1.4 christos (AcpiUtAsciiCharToHex (InString[4])) << 8 |
686 1.1.1.4 christos (AcpiUtAsciiCharToHex (InString[5])) << 4 |
687 1.1.1.4 christos AcpiUtAsciiCharToHex (InString[6]);
688 1.1 jruoho
689 1.1 jruoho /* Swap to little-endian to get final ID (see function header) */
690 1.1 jruoho
691 1.1 jruoho EisaId = AcpiUtDwordByteSwap (BigEndianId);
692 1.1 jruoho }
693 1.1 jruoho
694 1.1 jruoho /*
695 1.1 jruoho * Morph the Op into an integer, regardless of whether there
696 1.1 jruoho * was an error in the EISAID string
697 1.1 jruoho */
698 1.1 jruoho Op->Asl.Value.Integer = EisaId;
699 1.1 jruoho
700 1.1 jruoho Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
701 1.1 jruoho Op->Asl.ParseOpcode = PARSEOP_INTEGER;
702 1.1 jruoho (void) OpcSetOptimalIntegerSize (Op);
703 1.1 jruoho
704 1.1 jruoho /* Op is now an integer */
705 1.1 jruoho
706 1.1 jruoho UtSetParseOpName (Op);
707 1.1 jruoho }
708 1.1 jruoho
709 1.1 jruoho
710 1.1 jruoho /*******************************************************************************
711 1.1 jruoho *
712 1.1.1.4.2.1 skrll * FUNCTION: OpcEncodePldBuffer
713 1.1.1.4.2.1 skrll *
714 1.1.1.4.2.1 skrll * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct)
715 1.1.1.4.2.1 skrll *
716 1.1.1.4.2.1 skrll * RETURN: Encode _PLD buffer suitable for return value from _PLD
717 1.1.1.4.2.1 skrll *
718 1.1.1.4.2.1 skrll * DESCRIPTION: Bit-packs a _PLD buffer struct.
719 1.1.1.4.2.1 skrll *
720 1.1.1.4.2.1 skrll ******************************************************************************/
721 1.1.1.4.2.1 skrll
722 1.1.1.4.2.1 skrll static UINT8 *
723 1.1.1.4.2.1 skrll OpcEncodePldBuffer (
724 1.1.1.4.2.1 skrll ACPI_PLD_INFO *PldInfo)
725 1.1.1.4.2.1 skrll {
726 1.1.1.4.2.1 skrll UINT32 *Buffer;
727 1.1.1.4.2.1 skrll UINT32 Dword;
728 1.1.1.4.2.1 skrll
729 1.1.1.4.2.1 skrll
730 1.1.1.4.2.1 skrll Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE);
731 1.1.1.4.2.1 skrll if (!Buffer)
732 1.1.1.4.2.1 skrll {
733 1.1.1.4.2.1 skrll return (NULL);
734 1.1.1.4.2.1 skrll }
735 1.1.1.4.2.1 skrll
736 1.1.1.4.2.1 skrll /* First 32 bits */
737 1.1.1.4.2.1 skrll
738 1.1.1.4.2.1 skrll Dword = 0;
739 1.1.1.4.2.1 skrll ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision);
740 1.1.1.4.2.1 skrll ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor);
741 1.1.1.4.2.1 skrll ACPI_PLD_SET_RED (&Dword, PldInfo->Red);
742 1.1.1.4.2.1 skrll ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green);
743 1.1.1.4.2.1 skrll ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue);
744 1.1.1.4.2.1 skrll ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword);
745 1.1.1.4.2.1 skrll
746 1.1.1.4.2.1 skrll /* Second 32 bits */
747 1.1.1.4.2.1 skrll
748 1.1.1.4.2.1 skrll Dword = 0;
749 1.1.1.4.2.1 skrll ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width);
750 1.1.1.4.2.1 skrll ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height);
751 1.1.1.4.2.1 skrll ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword);
752 1.1.1.4.2.1 skrll
753 1.1.1.4.2.1 skrll /* Third 32 bits */
754 1.1.1.4.2.1 skrll
755 1.1.1.4.2.1 skrll Dword = 0;
756 1.1.1.4.2.1 skrll ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible);
757 1.1.1.4.2.1 skrll ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock);
758 1.1.1.4.2.1 skrll ACPI_PLD_SET_LID (&Dword, PldInfo->Lid);
759 1.1.1.4.2.1 skrll ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel);
760 1.1.1.4.2.1 skrll ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition);
761 1.1.1.4.2.1 skrll ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition);
762 1.1.1.4.2.1 skrll ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape);
763 1.1.1.4.2.1 skrll ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation);
764 1.1.1.4.2.1 skrll ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken);
765 1.1.1.4.2.1 skrll ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition);
766 1.1.1.4.2.1 skrll ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay);
767 1.1.1.4.2.1 skrll ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword);
768 1.1.1.4.2.1 skrll
769 1.1.1.4.2.1 skrll /* Fourth 32 bits */
770 1.1.1.4.2.1 skrll
771 1.1.1.4.2.1 skrll Dword = 0;
772 1.1.1.4.2.1 skrll ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable);
773 1.1.1.4.2.1 skrll ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired);
774 1.1.1.4.2.1 skrll ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber);
775 1.1.1.4.2.1 skrll ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber);
776 1.1.1.4.2.1 skrll ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference);
777 1.1.1.4.2.1 skrll ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation);
778 1.1.1.4.2.1 skrll ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order);
779 1.1.1.4.2.1 skrll ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword);
780 1.1.1.4.2.1 skrll
781 1.1.1.4.2.1 skrll if (PldInfo->Revision >= 2)
782 1.1.1.4.2.1 skrll {
783 1.1.1.4.2.1 skrll /* Fifth 32 bits */
784 1.1.1.4.2.1 skrll
785 1.1.1.4.2.1 skrll Dword = 0;
786 1.1.1.4.2.1 skrll ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset);
787 1.1.1.4.2.1 skrll ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset);
788 1.1.1.4.2.1 skrll ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword);
789 1.1.1.4.2.1 skrll }
790 1.1.1.4.2.1 skrll
791 1.1.1.4.2.1 skrll return (ACPI_CAST_PTR (UINT8, Buffer));
792 1.1.1.4.2.1 skrll }
793 1.1.1.4.2.1 skrll
794 1.1.1.4.2.1 skrll
795 1.1.1.4.2.1 skrll /*******************************************************************************
796 1.1.1.4.2.1 skrll *
797 1.1.1.4.2.1 skrll * FUNCTION: OpcFindName
798 1.1.1.4.2.1 skrll *
799 1.1.1.4.2.1 skrll * PARAMETERS: List - Array of char strings to be searched
800 1.1.1.4.2.1 skrll * Name - Char string to string for
801 1.1.1.4.2.1 skrll * Index - Index value to set if found
802 1.1.1.4.2.1 skrll *
803 1.1.1.4.2.1 skrll * RETURN: TRUE if any names matched, FALSE otherwise
804 1.1.1.4.2.1 skrll *
805 1.1.1.4.2.1 skrll * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to
806 1.1.1.4.2.1 skrll * equivalent parameter value.
807 1.1.1.4.2.1 skrll *
808 1.1.1.4.2.1 skrll ******************************************************************************/
809 1.1.1.4.2.1 skrll
810 1.1.1.4.2.1 skrll static BOOLEAN
811 1.1.1.4.2.1 skrll OpcFindName (
812 1.1.1.4.2.1 skrll char **List,
813 1.1.1.4.2.1 skrll char *Name,
814 1.1.1.4.2.1 skrll UINT64 *Index)
815 1.1.1.4.2.1 skrll {
816 1.1.1.4.2.1 skrll char *Str;
817 1.1.1.4.2.1 skrll UINT32 i;
818 1.1.1.4.2.1 skrll
819 1.1.1.4.2.1 skrll
820 1.1.1.4.2.2 skrll AcpiUtStrupr (Name);
821 1.1.1.4.2.1 skrll
822 1.1.1.4.2.1 skrll for (i = 0, Str = List[0]; Str; i++, Str = List[i])
823 1.1.1.4.2.1 skrll {
824 1.1.1.4.2.2 skrll if (!(strncmp (Str, Name, strlen (Name))))
825 1.1.1.4.2.1 skrll {
826 1.1.1.4.2.1 skrll *Index = i;
827 1.1.1.4.2.1 skrll return (TRUE);
828 1.1.1.4.2.1 skrll }
829 1.1.1.4.2.1 skrll }
830 1.1.1.4.2.1 skrll
831 1.1.1.4.2.1 skrll return (FALSE);
832 1.1.1.4.2.1 skrll }
833 1.1.1.4.2.1 skrll
834 1.1.1.4.2.1 skrll
835 1.1.1.4.2.1 skrll /*******************************************************************************
836 1.1.1.4.2.1 skrll *
837 1.1.1.4.2.1 skrll * FUNCTION: OpcDoPld
838 1.1.1.4.2.1 skrll *
839 1.1.1.4.2.1 skrll * PARAMETERS: Op - Parse node
840 1.1.1.4.2.1 skrll *
841 1.1.1.4.2.1 skrll * RETURN: None
842 1.1.1.4.2.1 skrll *
843 1.1.1.4.2.1 skrll * DESCRIPTION: Convert ToPLD macro to 20-byte buffer
844 1.1.1.4.2.1 skrll *
845 1.1.1.4.2.1 skrll ******************************************************************************/
846 1.1.1.4.2.1 skrll
847 1.1.1.4.2.1 skrll static void
848 1.1.1.4.2.1 skrll OpcDoPld (
849 1.1.1.4.2.1 skrll ACPI_PARSE_OBJECT *Op)
850 1.1.1.4.2.1 skrll {
851 1.1.1.4.2.1 skrll UINT8 *Buffer;
852 1.1.1.4.2.1 skrll ACPI_PARSE_OBJECT *Node;
853 1.1.1.4.2.1 skrll ACPI_PLD_INFO PldInfo;
854 1.1.1.4.2.1 skrll ACPI_PARSE_OBJECT *NewOp;
855 1.1.1.4.2.1 skrll
856 1.1.1.4.2.1 skrll
857 1.1.1.4.2.1 skrll if (!Op)
858 1.1.1.4.2.1 skrll {
859 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL);
860 1.1.1.4.2.1 skrll return;
861 1.1.1.4.2.1 skrll }
862 1.1.1.4.2.1 skrll
863 1.1.1.4.2.1 skrll if (Op->Asl.ParseOpcode != PARSEOP_TOPLD)
864 1.1.1.4.2.1 skrll {
865 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL);
866 1.1.1.4.2.1 skrll return;
867 1.1.1.4.2.1 skrll }
868 1.1.1.4.2.1 skrll
869 1.1.1.4.2.2 skrll memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
870 1.1.1.4.2.1 skrll
871 1.1.1.4.2.1 skrll Node = Op->Asl.Child;
872 1.1.1.4.2.1 skrll while (Node)
873 1.1.1.4.2.1 skrll {
874 1.1.1.4.2.1 skrll switch (Node->Asl.ParseOpcode)
875 1.1.1.4.2.1 skrll {
876 1.1.1.4.2.1 skrll case PARSEOP_PLD_REVISION:
877 1.1.1.4.2.1 skrll
878 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
879 1.1.1.4.2.1 skrll {
880 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
881 1.1.1.4.2.1 skrll break;
882 1.1.1.4.2.1 skrll }
883 1.1.1.4.2.1 skrll
884 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 127)
885 1.1.1.4.2.1 skrll {
886 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
887 1.1.1.4.2.1 skrll break;
888 1.1.1.4.2.1 skrll }
889 1.1.1.4.2.1 skrll
890 1.1.1.4.2.1 skrll PldInfo.Revision = (UINT8) Node->Asl.Child->Asl.Value.Integer;
891 1.1.1.4.2.1 skrll break;
892 1.1.1.4.2.1 skrll
893 1.1.1.4.2.1 skrll case PARSEOP_PLD_IGNORECOLOR:
894 1.1.1.4.2.1 skrll
895 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
896 1.1.1.4.2.1 skrll {
897 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
898 1.1.1.4.2.1 skrll break;
899 1.1.1.4.2.1 skrll }
900 1.1.1.4.2.1 skrll
901 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 1)
902 1.1.1.4.2.1 skrll {
903 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
904 1.1.1.4.2.1 skrll break;
905 1.1.1.4.2.1 skrll }
906 1.1.1.4.2.1 skrll
907 1.1.1.4.2.1 skrll PldInfo.IgnoreColor = (UINT8) Node->Asl.Child->Asl.Value.Integer;
908 1.1.1.4.2.1 skrll break;
909 1.1.1.4.2.1 skrll
910 1.1.1.4.2.1 skrll case PARSEOP_PLD_RED:
911 1.1.1.4.2.1 skrll case PARSEOP_PLD_GREEN:
912 1.1.1.4.2.1 skrll case PARSEOP_PLD_BLUE:
913 1.1.1.4.2.1 skrll
914 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
915 1.1.1.4.2.1 skrll {
916 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
917 1.1.1.4.2.1 skrll break;
918 1.1.1.4.2.1 skrll }
919 1.1.1.4.2.1 skrll
920 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 255)
921 1.1.1.4.2.1 skrll {
922 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
923 1.1.1.4.2.1 skrll break;
924 1.1.1.4.2.1 skrll }
925 1.1.1.4.2.1 skrll
926 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_RED)
927 1.1.1.4.2.1 skrll {
928 1.1.1.4.2.1 skrll PldInfo.Red = (UINT8) Node->Asl.Child->Asl.Value.Integer;
929 1.1.1.4.2.1 skrll }
930 1.1.1.4.2.1 skrll else if (Node->Asl.ParseOpcode == PARSEOP_PLD_GREEN)
931 1.1.1.4.2.1 skrll {
932 1.1.1.4.2.1 skrll PldInfo.Green = (UINT8) Node->Asl.Child->Asl.Value.Integer;
933 1.1.1.4.2.1 skrll }
934 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_BLUE */
935 1.1.1.4.2.1 skrll {
936 1.1.1.4.2.1 skrll PldInfo.Blue = (UINT8) Node->Asl.Child->Asl.Value.Integer;
937 1.1.1.4.2.1 skrll }
938 1.1.1.4.2.1 skrll break;
939 1.1.1.4.2.1 skrll
940 1.1.1.4.2.1 skrll case PARSEOP_PLD_WIDTH:
941 1.1.1.4.2.1 skrll case PARSEOP_PLD_HEIGHT:
942 1.1.1.4.2.1 skrll
943 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
944 1.1.1.4.2.1 skrll {
945 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
946 1.1.1.4.2.1 skrll break;
947 1.1.1.4.2.1 skrll }
948 1.1.1.4.2.1 skrll
949 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 65535)
950 1.1.1.4.2.1 skrll {
951 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
952 1.1.1.4.2.1 skrll break;
953 1.1.1.4.2.1 skrll }
954 1.1.1.4.2.1 skrll
955 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_WIDTH)
956 1.1.1.4.2.1 skrll {
957 1.1.1.4.2.1 skrll PldInfo.Width = (UINT16) Node->Asl.Child->Asl.Value.Integer;
958 1.1.1.4.2.1 skrll }
959 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_HEIGHT */
960 1.1.1.4.2.1 skrll {
961 1.1.1.4.2.1 skrll PldInfo.Height = (UINT16) Node->Asl.Child->Asl.Value.Integer;
962 1.1.1.4.2.1 skrll }
963 1.1.1.4.2.1 skrll
964 1.1.1.4.2.1 skrll break;
965 1.1.1.4.2.1 skrll
966 1.1.1.4.2.1 skrll case PARSEOP_PLD_USERVISIBLE:
967 1.1.1.4.2.1 skrll case PARSEOP_PLD_DOCK:
968 1.1.1.4.2.1 skrll case PARSEOP_PLD_LID:
969 1.1.1.4.2.1 skrll
970 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
971 1.1.1.4.2.1 skrll {
972 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
973 1.1.1.4.2.1 skrll break;
974 1.1.1.4.2.1 skrll }
975 1.1.1.4.2.1 skrll
976 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 1)
977 1.1.1.4.2.1 skrll {
978 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
979 1.1.1.4.2.1 skrll break;
980 1.1.1.4.2.1 skrll }
981 1.1.1.4.2.1 skrll
982 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE)
983 1.1.1.4.2.1 skrll {
984 1.1.1.4.2.1 skrll PldInfo.UserVisible = (UINT8) Node->Asl.Child->Asl.Value.Integer;
985 1.1.1.4.2.1 skrll }
986 1.1.1.4.2.1 skrll else if (Node->Asl.ParseOpcode == PARSEOP_PLD_DOCK)
987 1.1.1.4.2.1 skrll {
988 1.1.1.4.2.1 skrll PldInfo.Dock = (UINT8) Node->Asl.Child->Asl.Value.Integer;
989 1.1.1.4.2.1 skrll }
990 1.1.1.4.2.1 skrll else
991 1.1.1.4.2.1 skrll {
992 1.1.1.4.2.1 skrll PldInfo.Lid = (UINT8) Node->Asl.Child->Asl.Value.Integer;
993 1.1.1.4.2.1 skrll }
994 1.1.1.4.2.1 skrll
995 1.1.1.4.2.1 skrll break;
996 1.1.1.4.2.1 skrll
997 1.1.1.4.2.1 skrll case PARSEOP_PLD_PANEL:
998 1.1.1.4.2.1 skrll
999 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER)
1000 1.1.1.4.2.1 skrll {
1001 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 6)
1002 1.1.1.4.2.1 skrll {
1003 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1004 1.1.1.4.2.1 skrll break;
1005 1.1.1.4.2.1 skrll }
1006 1.1.1.4.2.1 skrll }
1007 1.1.1.4.2.1 skrll else /* PARSEOP_STRING */
1008 1.1.1.4.2.1 skrll {
1009 1.1.1.4.2.1 skrll if (!OpcFindName(AslPldPanelList,
1010 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.String,
1011 1.1.1.4.2.1 skrll &Node->Asl.Child->Asl.Value.Integer))
1012 1.1.1.4.2.1 skrll {
1013 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL);
1014 1.1.1.4.2.1 skrll break;
1015 1.1.1.4.2.1 skrll }
1016 1.1.1.4.2.1 skrll }
1017 1.1.1.4.2.1 skrll
1018 1.1.1.4.2.1 skrll PldInfo.Panel = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1019 1.1.1.4.2.1 skrll break;
1020 1.1.1.4.2.1 skrll
1021 1.1.1.4.2.1 skrll case PARSEOP_PLD_VERTICALPOSITION:
1022 1.1.1.4.2.1 skrll
1023 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER)
1024 1.1.1.4.2.1 skrll {
1025 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 2)
1026 1.1.1.4.2.1 skrll {
1027 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1028 1.1.1.4.2.1 skrll break;
1029 1.1.1.4.2.1 skrll }
1030 1.1.1.4.2.1 skrll }
1031 1.1.1.4.2.1 skrll else /* PARSEOP_STRING */
1032 1.1.1.4.2.1 skrll {
1033 1.1.1.4.2.1 skrll if (!OpcFindName(AslPldVerticalPositionList,
1034 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.String,
1035 1.1.1.4.2.1 skrll &Node->Asl.Child->Asl.Value.Integer))
1036 1.1.1.4.2.1 skrll {
1037 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL);
1038 1.1.1.4.2.1 skrll break;
1039 1.1.1.4.2.1 skrll }
1040 1.1.1.4.2.1 skrll }
1041 1.1.1.4.2.1 skrll
1042 1.1.1.4.2.1 skrll PldInfo.VerticalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1043 1.1.1.4.2.1 skrll break;
1044 1.1.1.4.2.1 skrll
1045 1.1.1.4.2.1 skrll case PARSEOP_PLD_HORIZONTALPOSITION:
1046 1.1.1.4.2.1 skrll
1047 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER)
1048 1.1.1.4.2.1 skrll {
1049 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 2)
1050 1.1.1.4.2.1 skrll {
1051 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1052 1.1.1.4.2.1 skrll break;
1053 1.1.1.4.2.1 skrll }
1054 1.1.1.4.2.1 skrll }
1055 1.1.1.4.2.1 skrll else /* PARSEOP_STRING */
1056 1.1.1.4.2.1 skrll {
1057 1.1.1.4.2.1 skrll if (!OpcFindName(AslPldHorizontalPositionList,
1058 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.String,
1059 1.1.1.4.2.1 skrll &Node->Asl.Child->Asl.Value.Integer))
1060 1.1.1.4.2.1 skrll {
1061 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL);
1062 1.1.1.4.2.1 skrll break;
1063 1.1.1.4.2.1 skrll }
1064 1.1.1.4.2.1 skrll }
1065 1.1.1.4.2.1 skrll
1066 1.1.1.4.2.1 skrll PldInfo.HorizontalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1067 1.1.1.4.2.1 skrll break;
1068 1.1.1.4.2.1 skrll
1069 1.1.1.4.2.1 skrll case PARSEOP_PLD_SHAPE:
1070 1.1.1.4.2.1 skrll
1071 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER)
1072 1.1.1.4.2.1 skrll {
1073 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 8)
1074 1.1.1.4.2.1 skrll {
1075 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1076 1.1.1.4.2.1 skrll break;
1077 1.1.1.4.2.1 skrll }
1078 1.1.1.4.2.1 skrll }
1079 1.1.1.4.2.1 skrll else /* PARSEOP_STRING */
1080 1.1.1.4.2.1 skrll {
1081 1.1.1.4.2.1 skrll if (!OpcFindName(AslPldShapeList,
1082 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.String,
1083 1.1.1.4.2.1 skrll &Node->Asl.Child->Asl.Value.Integer))
1084 1.1.1.4.2.1 skrll {
1085 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL);
1086 1.1.1.4.2.1 skrll break;
1087 1.1.1.4.2.1 skrll }
1088 1.1.1.4.2.1 skrll }
1089 1.1.1.4.2.1 skrll
1090 1.1.1.4.2.1 skrll PldInfo.Shape = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1091 1.1.1.4.2.1 skrll break;
1092 1.1.1.4.2.1 skrll
1093 1.1.1.4.2.1 skrll case PARSEOP_PLD_GROUPORIENTATION:
1094 1.1.1.4.2.1 skrll
1095 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1096 1.1.1.4.2.1 skrll {
1097 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1098 1.1.1.4.2.1 skrll break;
1099 1.1.1.4.2.1 skrll }
1100 1.1.1.4.2.1 skrll
1101 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 1)
1102 1.1.1.4.2.1 skrll {
1103 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1104 1.1.1.4.2.1 skrll break;
1105 1.1.1.4.2.1 skrll }
1106 1.1.1.4.2.1 skrll
1107 1.1.1.4.2.1 skrll PldInfo.GroupOrientation = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1108 1.1.1.4.2.1 skrll break;
1109 1.1.1.4.2.1 skrll
1110 1.1.1.4.2.1 skrll case PARSEOP_PLD_GROUPTOKEN:
1111 1.1.1.4.2.1 skrll case PARSEOP_PLD_GROUPPOSITION:
1112 1.1.1.4.2.1 skrll
1113 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1114 1.1.1.4.2.1 skrll {
1115 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1116 1.1.1.4.2.1 skrll break;
1117 1.1.1.4.2.1 skrll }
1118 1.1.1.4.2.1 skrll
1119 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 255)
1120 1.1.1.4.2.1 skrll {
1121 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1122 1.1.1.4.2.1 skrll break;
1123 1.1.1.4.2.1 skrll }
1124 1.1.1.4.2.1 skrll
1125 1.1.1.4.2.1 skrll
1126 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN)
1127 1.1.1.4.2.1 skrll {
1128 1.1.1.4.2.1 skrll PldInfo.GroupToken = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1129 1.1.1.4.2.1 skrll }
1130 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_GROUPPOSITION */
1131 1.1.1.4.2.1 skrll {
1132 1.1.1.4.2.1 skrll PldInfo.GroupPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1133 1.1.1.4.2.1 skrll }
1134 1.1.1.4.2.1 skrll
1135 1.1.1.4.2.1 skrll break;
1136 1.1.1.4.2.1 skrll
1137 1.1.1.4.2.1 skrll case PARSEOP_PLD_BAY:
1138 1.1.1.4.2.1 skrll case PARSEOP_PLD_EJECTABLE:
1139 1.1.1.4.2.1 skrll case PARSEOP_PLD_EJECTREQUIRED:
1140 1.1.1.4.2.1 skrll
1141 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1142 1.1.1.4.2.1 skrll {
1143 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1144 1.1.1.4.2.1 skrll break;
1145 1.1.1.4.2.1 skrll }
1146 1.1.1.4.2.1 skrll
1147 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 1)
1148 1.1.1.4.2.1 skrll {
1149 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1150 1.1.1.4.2.1 skrll break;
1151 1.1.1.4.2.1 skrll }
1152 1.1.1.4.2.1 skrll
1153 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_BAY)
1154 1.1.1.4.2.1 skrll {
1155 1.1.1.4.2.1 skrll PldInfo.Bay = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1156 1.1.1.4.2.1 skrll }
1157 1.1.1.4.2.1 skrll else if (Node->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE)
1158 1.1.1.4.2.1 skrll {
1159 1.1.1.4.2.1 skrll PldInfo.Ejectable = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1160 1.1.1.4.2.1 skrll }
1161 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_EJECTREQUIRED */
1162 1.1.1.4.2.1 skrll {
1163 1.1.1.4.2.1 skrll PldInfo.OspmEjectRequired = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1164 1.1.1.4.2.1 skrll }
1165 1.1.1.4.2.1 skrll
1166 1.1.1.4.2.1 skrll break;
1167 1.1.1.4.2.1 skrll
1168 1.1.1.4.2.1 skrll case PARSEOP_PLD_CABINETNUMBER:
1169 1.1.1.4.2.1 skrll case PARSEOP_PLD_CARDCAGENUMBER:
1170 1.1.1.4.2.1 skrll
1171 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1172 1.1.1.4.2.1 skrll {
1173 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1174 1.1.1.4.2.1 skrll break;
1175 1.1.1.4.2.1 skrll }
1176 1.1.1.4.2.1 skrll
1177 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 255)
1178 1.1.1.4.2.1 skrll {
1179 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1180 1.1.1.4.2.1 skrll break;
1181 1.1.1.4.2.1 skrll }
1182 1.1.1.4.2.1 skrll
1183 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER)
1184 1.1.1.4.2.1 skrll {
1185 1.1.1.4.2.1 skrll PldInfo.CabinetNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1186 1.1.1.4.2.1 skrll }
1187 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_CARDCAGENUMBER */
1188 1.1.1.4.2.1 skrll {
1189 1.1.1.4.2.1 skrll PldInfo.CardCageNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1190 1.1.1.4.2.1 skrll }
1191 1.1.1.4.2.1 skrll
1192 1.1.1.4.2.1 skrll break;
1193 1.1.1.4.2.1 skrll
1194 1.1.1.4.2.1 skrll case PARSEOP_PLD_REFERENCE:
1195 1.1.1.4.2.1 skrll
1196 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1197 1.1.1.4.2.1 skrll {
1198 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1199 1.1.1.4.2.1 skrll break;
1200 1.1.1.4.2.1 skrll }
1201 1.1.1.4.2.1 skrll
1202 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 1)
1203 1.1.1.4.2.1 skrll {
1204 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1205 1.1.1.4.2.1 skrll break;
1206 1.1.1.4.2.1 skrll }
1207 1.1.1.4.2.1 skrll
1208 1.1.1.4.2.1 skrll PldInfo.Reference = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1209 1.1.1.4.2.1 skrll break;
1210 1.1.1.4.2.1 skrll
1211 1.1.1.4.2.1 skrll case PARSEOP_PLD_ROTATION:
1212 1.1.1.4.2.1 skrll
1213 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1214 1.1.1.4.2.1 skrll {
1215 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1216 1.1.1.4.2.1 skrll break;
1217 1.1.1.4.2.1 skrll }
1218 1.1.1.4.2.1 skrll
1219 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 7)
1220 1.1.1.4.2.1 skrll {
1221 1.1.1.4.2.1 skrll switch (Node->Asl.Child->Asl.Value.Integer)
1222 1.1.1.4.2.1 skrll {
1223 1.1.1.4.2.1 skrll case 45:
1224 1.1.1.4.2.1 skrll
1225 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 1;
1226 1.1.1.4.2.1 skrll break;
1227 1.1.1.4.2.1 skrll
1228 1.1.1.4.2.1 skrll case 90:
1229 1.1.1.4.2.1 skrll
1230 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 2;
1231 1.1.1.4.2.1 skrll break;
1232 1.1.1.4.2.1 skrll
1233 1.1.1.4.2.1 skrll case 135:
1234 1.1.1.4.2.1 skrll
1235 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 3;
1236 1.1.1.4.2.1 skrll break;
1237 1.1.1.4.2.1 skrll
1238 1.1.1.4.2.1 skrll case 180:
1239 1.1.1.4.2.1 skrll
1240 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 4;
1241 1.1.1.4.2.1 skrll break;
1242 1.1.1.4.2.1 skrll
1243 1.1.1.4.2.1 skrll case 225:
1244 1.1.1.4.2.1 skrll
1245 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 5;
1246 1.1.1.4.2.1 skrll break;
1247 1.1.1.4.2.1 skrll
1248 1.1.1.4.2.1 skrll case 270:
1249 1.1.1.4.2.1 skrll
1250 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 6;
1251 1.1.1.4.2.1 skrll break;
1252 1.1.1.4.2.1 skrll
1253 1.1.1.4.2.1 skrll case 315:
1254 1.1.1.4.2.1 skrll
1255 1.1.1.4.2.1 skrll Node->Asl.Child->Asl.Value.Integer = 7;
1256 1.1.1.4.2.1 skrll break;
1257 1.1.1.4.2.1 skrll
1258 1.1.1.4.2.1 skrll default:
1259 1.1.1.4.2.1 skrll
1260 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1261 1.1.1.4.2.1 skrll break;
1262 1.1.1.4.2.1 skrll }
1263 1.1.1.4.2.1 skrll }
1264 1.1.1.4.2.1 skrll
1265 1.1.1.4.2.1 skrll PldInfo.Rotation = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1266 1.1.1.4.2.1 skrll break;
1267 1.1.1.4.2.1 skrll
1268 1.1.1.4.2.1 skrll case PARSEOP_PLD_ORDER:
1269 1.1.1.4.2.1 skrll
1270 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1271 1.1.1.4.2.1 skrll {
1272 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1273 1.1.1.4.2.1 skrll break;
1274 1.1.1.4.2.1 skrll }
1275 1.1.1.4.2.1 skrll
1276 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 31)
1277 1.1.1.4.2.1 skrll {
1278 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1279 1.1.1.4.2.1 skrll break;
1280 1.1.1.4.2.1 skrll }
1281 1.1.1.4.2.1 skrll
1282 1.1.1.4.2.1 skrll PldInfo.Order = (UINT8) Node->Asl.Child->Asl.Value.Integer;
1283 1.1.1.4.2.1 skrll break;
1284 1.1.1.4.2.1 skrll
1285 1.1.1.4.2.1 skrll case PARSEOP_PLD_VERTICALOFFSET:
1286 1.1.1.4.2.1 skrll case PARSEOP_PLD_HORIZONTALOFFSET:
1287 1.1.1.4.2.1 skrll
1288 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER)
1289 1.1.1.4.2.1 skrll {
1290 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1291 1.1.1.4.2.1 skrll break;
1292 1.1.1.4.2.1 skrll }
1293 1.1.1.4.2.1 skrll
1294 1.1.1.4.2.1 skrll if (Node->Asl.Child->Asl.Value.Integer > 65535)
1295 1.1.1.4.2.1 skrll {
1296 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL);
1297 1.1.1.4.2.1 skrll break;
1298 1.1.1.4.2.1 skrll }
1299 1.1.1.4.2.1 skrll
1300 1.1.1.4.2.1 skrll if (Node->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET)
1301 1.1.1.4.2.1 skrll {
1302 1.1.1.4.2.1 skrll PldInfo.VerticalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer;
1303 1.1.1.4.2.1 skrll }
1304 1.1.1.4.2.1 skrll else /* PARSEOP_PLD_HORIZONTALOFFSET */
1305 1.1.1.4.2.1 skrll {
1306 1.1.1.4.2.1 skrll PldInfo.HorizontalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer;
1307 1.1.1.4.2.1 skrll }
1308 1.1.1.4.2.1 skrll
1309 1.1.1.4.2.1 skrll break;
1310 1.1.1.4.2.1 skrll
1311 1.1.1.4.2.1 skrll default:
1312 1.1.1.4.2.1 skrll
1313 1.1.1.4.2.1 skrll AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL);
1314 1.1.1.4.2.1 skrll break;
1315 1.1.1.4.2.1 skrll }
1316 1.1.1.4.2.1 skrll
1317 1.1.1.4.2.1 skrll Node = Node->Asl.Next;
1318 1.1.1.4.2.1 skrll }
1319 1.1.1.4.2.1 skrll
1320 1.1.1.4.2.1 skrll Buffer = OpcEncodePldBuffer(&PldInfo);
1321 1.1.1.4.2.1 skrll
1322 1.1.1.4.2.1 skrll /* Change Op to a Buffer */
1323 1.1.1.4.2.1 skrll
1324 1.1.1.4.2.1 skrll Op->Asl.ParseOpcode = PARSEOP_BUFFER;
1325 1.1.1.4.2.1 skrll Op->Common.AmlOpcode = AML_BUFFER_OP;
1326 1.1.1.4.2.1 skrll
1327 1.1.1.4.2.1 skrll /* Disable further optimization */
1328 1.1.1.4.2.1 skrll
1329 1.1.1.4.2.1 skrll Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
1330 1.1.1.4.2.1 skrll UtSetParseOpName (Op);
1331 1.1.1.4.2.1 skrll
1332 1.1.1.4.2.1 skrll /* Child node is the buffer length */
1333 1.1.1.4.2.1 skrll
1334 1.1.1.4.2.1 skrll NewOp = TrAllocateNode (PARSEOP_INTEGER);
1335 1.1.1.4.2.1 skrll
1336 1.1.1.4.2.3 skrll NewOp->Asl.AmlOpcode = AML_BYTE_OP;
1337 1.1.1.4.2.1 skrll NewOp->Asl.Value.Integer = 20;
1338 1.1.1.4.2.3 skrll NewOp->Asl.Parent = Op;
1339 1.1.1.4.2.1 skrll
1340 1.1.1.4.2.1 skrll Op->Asl.Child = NewOp;
1341 1.1.1.4.2.1 skrll Op = NewOp;
1342 1.1.1.4.2.1 skrll
1343 1.1.1.4.2.1 skrll /* Peer to the child is the raw buffer data */
1344 1.1.1.4.2.1 skrll
1345 1.1.1.4.2.1 skrll NewOp = TrAllocateNode (PARSEOP_RAW_DATA);
1346 1.1.1.4.2.3 skrll NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
1347 1.1.1.4.2.3 skrll NewOp->Asl.AmlLength = 20;
1348 1.1.1.4.2.3 skrll NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
1349 1.1.1.4.2.3 skrll NewOp->Asl.Parent = Op->Asl.Parent;
1350 1.1.1.4.2.1 skrll
1351 1.1.1.4.2.1 skrll Op->Asl.Next = NewOp;
1352 1.1.1.4.2.1 skrll }
1353 1.1.1.4.2.1 skrll
1354 1.1.1.4.2.1 skrll
1355 1.1.1.4.2.1 skrll /*******************************************************************************
1356 1.1.1.4.2.1 skrll *
1357 1.1.1.3 christos * FUNCTION: OpcDoUuId
1358 1.1 jruoho *
1359 1.1.1.4.2.1 skrll * PARAMETERS: Op - Parse node
1360 1.1 jruoho *
1361 1.1 jruoho * RETURN: None
1362 1.1 jruoho *
1363 1.1 jruoho * DESCRIPTION: Convert UUID string to 16-byte buffer
1364 1.1 jruoho *
1365 1.1 jruoho ******************************************************************************/
1366 1.1 jruoho
1367 1.1 jruoho static void
1368 1.1 jruoho OpcDoUuId (
1369 1.1 jruoho ACPI_PARSE_OBJECT *Op)
1370 1.1 jruoho {
1371 1.1 jruoho char *InString;
1372 1.1.1.4 christos UINT8 *Buffer;
1373 1.1 jruoho ACPI_STATUS Status = AE_OK;
1374 1.1 jruoho ACPI_PARSE_OBJECT *NewOp;
1375 1.1 jruoho
1376 1.1 jruoho
1377 1.1.1.4.2.1 skrll InString = ACPI_CAST_PTR (char, Op->Asl.Value.String);
1378 1.1 jruoho Buffer = UtLocalCalloc (16);
1379 1.1 jruoho
1380 1.1.1.2 jruoho Status = AuValidateUuid (InString);
1381 1.1 jruoho if (ACPI_FAILURE (Status))
1382 1.1 jruoho {
1383 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String);
1384 1.1 jruoho }
1385 1.1.1.2 jruoho else
1386 1.1 jruoho {
1387 1.1.1.4 christos AcpiUtConvertStringToUuid (InString, Buffer);
1388 1.1 jruoho }
1389 1.1 jruoho
1390 1.1 jruoho /* Change Op to a Buffer */
1391 1.1 jruoho
1392 1.1 jruoho Op->Asl.ParseOpcode = PARSEOP_BUFFER;
1393 1.1 jruoho Op->Common.AmlOpcode = AML_BUFFER_OP;
1394 1.1 jruoho
1395 1.1 jruoho /* Disable further optimization */
1396 1.1 jruoho
1397 1.1 jruoho Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
1398 1.1 jruoho UtSetParseOpName (Op);
1399 1.1 jruoho
1400 1.1 jruoho /* Child node is the buffer length */
1401 1.1 jruoho
1402 1.1 jruoho NewOp = TrAllocateNode (PARSEOP_INTEGER);
1403 1.1 jruoho
1404 1.1.1.4.2.3 skrll NewOp->Asl.AmlOpcode = AML_BYTE_OP;
1405 1.1 jruoho NewOp->Asl.Value.Integer = 16;
1406 1.1.1.4.2.3 skrll NewOp->Asl.Parent = Op;
1407 1.1 jruoho
1408 1.1 jruoho Op->Asl.Child = NewOp;
1409 1.1 jruoho Op = NewOp;
1410 1.1 jruoho
1411 1.1 jruoho /* Peer to the child is the raw buffer data */
1412 1.1 jruoho
1413 1.1 jruoho NewOp = TrAllocateNode (PARSEOP_RAW_DATA);
1414 1.1.1.4.2.3 skrll NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
1415 1.1.1.4.2.3 skrll NewOp->Asl.AmlLength = 16;
1416 1.1.1.4.2.3 skrll NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
1417 1.1.1.4.2.3 skrll NewOp->Asl.Parent = Op->Asl.Parent;
1418 1.1 jruoho
1419 1.1 jruoho Op->Asl.Next = NewOp;
1420 1.1 jruoho }
1421 1.1 jruoho
1422 1.1 jruoho
1423 1.1 jruoho /*******************************************************************************
1424 1.1 jruoho *
1425 1.1 jruoho * FUNCTION: OpcGenerateAmlOpcode
1426 1.1 jruoho *
1427 1.1.1.4.2.1 skrll * PARAMETERS: Op - Parse node
1428 1.1 jruoho *
1429 1.1 jruoho * RETURN: None
1430 1.1 jruoho *
1431 1.1 jruoho * DESCRIPTION: Generate the AML opcode associated with the node and its
1432 1.1.1.3 christos * parse (lex/flex) keyword opcode. Essentially implements
1433 1.1 jruoho * a mapping between the parse opcodes and the actual AML opcodes.
1434 1.1 jruoho *
1435 1.1 jruoho ******************************************************************************/
1436 1.1 jruoho
1437 1.1 jruoho void
1438 1.1 jruoho OpcGenerateAmlOpcode (
1439 1.1 jruoho ACPI_PARSE_OBJECT *Op)
1440 1.1 jruoho {
1441 1.1 jruoho UINT16 Index;
1442 1.1 jruoho
1443 1.1 jruoho
1444 1.1 jruoho Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
1445 1.1 jruoho
1446 1.1 jruoho Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
1447 1.1 jruoho Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
1448 1.1 jruoho Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
1449 1.1 jruoho
1450 1.1 jruoho if (!Op->Asl.Value.Integer)
1451 1.1 jruoho {
1452 1.1 jruoho Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
1453 1.1 jruoho }
1454 1.1 jruoho
1455 1.1 jruoho /* Special handling for some opcodes */
1456 1.1 jruoho
1457 1.1 jruoho switch (Op->Asl.ParseOpcode)
1458 1.1 jruoho {
1459 1.1 jruoho case PARSEOP_INTEGER:
1460 1.1 jruoho /*
1461 1.1 jruoho * Set the opcode based on the size of the integer
1462 1.1 jruoho */
1463 1.1 jruoho (void) OpcSetOptimalIntegerSize (Op);
1464 1.1 jruoho break;
1465 1.1 jruoho
1466 1.1 jruoho case PARSEOP_OFFSET:
1467 1.1 jruoho
1468 1.1 jruoho Op->Asl.AmlOpcodeLength = 1;
1469 1.1 jruoho break;
1470 1.1 jruoho
1471 1.1 jruoho case PARSEOP_ACCESSAS:
1472 1.1 jruoho
1473 1.1 jruoho OpcDoAccessAs (Op);
1474 1.1 jruoho break;
1475 1.1 jruoho
1476 1.1.1.3 christos case PARSEOP_CONNECTION:
1477 1.1.1.3 christos
1478 1.1.1.3 christos OpcDoConnection (Op);
1479 1.1.1.3 christos break;
1480 1.1.1.3 christos
1481 1.1 jruoho case PARSEOP_EISAID:
1482 1.1 jruoho
1483 1.1 jruoho OpcDoEisaId (Op);
1484 1.1 jruoho break;
1485 1.1 jruoho
1486 1.1.1.4.2.1 skrll case PARSEOP_PRINTF:
1487 1.1.1.4.2.1 skrll
1488 1.1.1.4.2.1 skrll OpcDoPrintf (Op);
1489 1.1.1.4.2.1 skrll break;
1490 1.1.1.4.2.1 skrll
1491 1.1.1.4.2.1 skrll case PARSEOP_FPRINTF:
1492 1.1.1.4.2.1 skrll
1493 1.1.1.4.2.1 skrll OpcDoFprintf (Op);
1494 1.1.1.4.2.1 skrll break;
1495 1.1.1.4.2.1 skrll
1496 1.1.1.4.2.1 skrll case PARSEOP_TOPLD:
1497 1.1.1.4.2.1 skrll
1498 1.1.1.4.2.1 skrll OpcDoPld (Op);
1499 1.1.1.4.2.1 skrll break;
1500 1.1.1.4.2.1 skrll
1501 1.1 jruoho case PARSEOP_TOUUID:
1502 1.1 jruoho
1503 1.1 jruoho OpcDoUuId (Op);
1504 1.1 jruoho break;
1505 1.1 jruoho
1506 1.1 jruoho case PARSEOP_UNICODE:
1507 1.1 jruoho
1508 1.1 jruoho OpcDoUnicode (Op);
1509 1.1 jruoho break;
1510 1.1 jruoho
1511 1.1 jruoho case PARSEOP_INCLUDE:
1512 1.1 jruoho
1513 1.1 jruoho Gbl_HasIncludeFiles = TRUE;
1514 1.1 jruoho break;
1515 1.1 jruoho
1516 1.1 jruoho case PARSEOP_EXTERNAL:
1517 1.1 jruoho
1518 1.1 jruoho Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1519 1.1 jruoho Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1520 1.1 jruoho break;
1521 1.1 jruoho
1522 1.1.1.3 christos case PARSEOP_TIMER:
1523 1.1.1.3 christos
1524 1.1.1.3 christos if (AcpiGbl_IntegerBitWidth == 32)
1525 1.1.1.3 christos {
1526 1.1.1.3 christos AslError (ASL_REMARK, ASL_MSG_TRUNCATION, Op, NULL);
1527 1.1.1.3 christos }
1528 1.1.1.3 christos break;
1529 1.1.1.3 christos
1530 1.1 jruoho default:
1531 1.1.1.3 christos
1532 1.1 jruoho /* Nothing to do for other opcodes */
1533 1.1.1.3 christos
1534 1.1 jruoho break;
1535 1.1 jruoho }
1536 1.1 jruoho
1537 1.1 jruoho return;
1538 1.1 jruoho }
1539