Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | |
2 | * |
||
3 | * Module Name: asloperands - AML operand processing |
||
4 | * |
||
5 | *****************************************************************************/ |
||
6 | |||
7 | |||
8 | * |
||
9 | * 1. Copyright Notice |
||
10 | * |
||
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
||
2216 | Serge | 12 | * All rights reserved. |
1498 | serge | 13 | * |
14 | * 2. License |
||
15 | * |
||
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
||
17 | * rights. You may have additional license terms from the party that provided |
||
18 | * you this software, covering your right to use that party's intellectual |
||
19 | * property rights. |
||
20 | * |
||
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
||
22 | * copy of the source code appearing in this file ("Covered Code") an |
||
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
||
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
||
25 | * make derivatives, distribute, use and display any portion of the Covered |
||
26 | * Code in any form, with the right to sublicense such rights; and |
||
27 | * |
||
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
||
29 | * license (with the right to sublicense), under only those claims of Intel |
||
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
||
31 | * offer to sell, and import the Covered Code and derivative works thereof |
||
32 | * solely to the minimum extent necessary to exercise the above copyright |
||
33 | * license, and in no event shall the patent license extend to any additions |
||
34 | * to or modifications of the Original Intel Code. No other license or right |
||
35 | * is granted directly or by implication, estoppel or otherwise; |
||
36 | * |
||
37 | * The above copyright and patent license is granted only if the following |
||
38 | * conditions are met: |
||
39 | * |
||
40 | * 3. Conditions |
||
41 | * |
||
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
||
43 | * Redistribution of source code of any substantial portion of the Covered |
||
44 | * Code or modification with rights to further distribute source must include |
||
45 | * the above Copyright Notice, the above License, this list of Conditions, |
||
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
||
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
||
48 | * contain a file documenting the changes Licensee made to create that Covered |
||
49 | * Code and the date of any change. Licensee must include in that file the |
||
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
||
51 | * must include a prominent statement that the modification is derived, |
||
52 | * directly or indirectly, from Original Intel Code. |
||
53 | * |
||
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
||
55 | * Redistribution of source code of any substantial portion of the Covered |
||
56 | * Code or modification without rights to further distribute source must |
||
57 | * include the following Disclaimer and Export Compliance provision in the |
||
58 | * documentation and/or other materials provided with distribution. In |
||
59 | * addition, Licensee may not authorize further sublicense of source of any |
||
60 | * portion of the Covered Code, and must include terms to the effect that the |
||
61 | * license from Licensee to its licensee is limited to the intellectual |
||
62 | * property embodied in the software Licensee provides to its licensee, and |
||
63 | * not to intellectual property embodied in modifications its licensee may |
||
64 | * make. |
||
65 | * |
||
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
||
67 | * substantial portion of the Covered Code or modification must reproduce the |
||
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
||
69 | * provision in the documentation and/or other materials provided with the |
||
70 | * distribution. |
||
71 | * |
||
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
||
73 | * Intel Code. |
||
74 | * |
||
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
||
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
||
77 | * other dealings in products derived from or relating to the Covered Code |
||
78 | * without prior written authorization from Intel. |
||
79 | * |
||
80 | * 4. Disclaimer and Export Compliance |
||
81 | * |
||
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
||
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
||
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
||
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
||
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
||
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
||
88 | * PARTICULAR PURPOSE. |
||
89 | * |
||
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
||
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
||
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
||
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
||
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
||
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
||
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
||
97 | * LIMITED REMEDY. |
||
98 | * |
||
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
||
100 | * software or system incorporating such software without first obtaining any |
||
101 | * required license or other approval from the U. S. Department of Commerce or |
||
102 | * any other agency or department of the United States Government. In the |
||
103 | * event Licensee exports any such software from the United States or |
||
104 | * re-exports any such software from a foreign destination, Licensee shall |
||
105 | * ensure that the distribution and export/re-export of the software is in |
||
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
||
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
||
108 | * any of its subsidiaries will export/re-export any technical data, process, |
||
109 | * software, or service, directly or indirectly, to any country for which the |
||
110 | * United States government or any agency thereof requires an export license, |
||
111 | * other governmental approval, or letter of assurance, without first obtaining |
||
112 | * such license, approval or letter. |
||
113 | * |
||
114 | *****************************************************************************/ |
||
115 | |||
116 | |||
117 | |||
118 | #include "aslcompiler.y.h" |
||
119 | #include "amlcode.h" |
||
120 | |||
121 | |||
122 | ACPI_MODULE_NAME ("asloperands") |
||
123 | |||
124 | |||
125 | |||
126 | |||
127 | OpnDoField ( |
||
128 | ACPI_PARSE_OBJECT *Op); |
||
129 | |||
130 | |||
131 | OpnDoBankField ( |
||
132 | ACPI_PARSE_OBJECT *Op); |
||
133 | |||
134 | |||
135 | OpnDoBuffer ( |
||
136 | ACPI_PARSE_OBJECT *Op); |
||
137 | |||
138 | |||
139 | OpnDoDefinitionBlock ( |
||
140 | ACPI_PARSE_OBJECT *Op); |
||
141 | |||
142 | |||
143 | OpnDoFieldCommon ( |
||
144 | ACPI_PARSE_OBJECT *FieldOp, |
||
145 | ACPI_PARSE_OBJECT *Op); |
||
146 | |||
147 | |||
148 | OpnDoIndexField ( |
||
149 | ACPI_PARSE_OBJECT *Op); |
||
150 | |||
151 | |||
152 | OpnDoLoadTable ( |
||
153 | ACPI_PARSE_OBJECT *Op); |
||
154 | |||
155 | |||
156 | OpnDoMethod ( |
||
157 | ACPI_PARSE_OBJECT *Op); |
||
158 | |||
159 | |||
160 | OpnDoMutex ( |
||
161 | ACPI_PARSE_OBJECT *Op); |
||
162 | |||
163 | |||
164 | OpnDoRegion ( |
||
165 | ACPI_PARSE_OBJECT *Op); |
||
166 | |||
167 | |||
168 | OpnAttachNameToNode ( |
||
169 | ACPI_PARSE_OBJECT *Op); |
||
170 | |||
171 | |||
172 | |||
173 | * |
||
174 | * FUNCTION: OpnDoMutex |
||
175 | * |
||
176 | * PARAMETERS: Op - The parent parse node |
||
177 | * |
||
178 | * RETURN: None |
||
179 | * |
||
180 | * DESCRIPTION: Construct the operands for the MUTEX ASL keyword. |
||
181 | * |
||
182 | ******************************************************************************/ |
||
183 | |||
184 | |||
185 | OpnDoMutex ( |
||
186 | ACPI_PARSE_OBJECT *Op) |
||
187 | { |
||
188 | ACPI_PARSE_OBJECT *Next; |
||
189 | |||
190 | |||
191 | |||
192 | Next = Next->Asl.Next; |
||
193 | |||
194 | |||
195 | { |
||
196 | AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); |
||
197 | } |
||
198 | return; |
||
199 | } |
||
200 | |||
201 | |||
202 | |||
203 | * |
||
204 | * FUNCTION: OpnDoMethod |
||
205 | * |
||
206 | * PARAMETERS: Op - The parent parse node |
||
207 | * |
||
208 | * RETURN: None |
||
209 | * |
||
210 | * DESCRIPTION: Construct the operands for the METHOD ASL keyword. |
||
211 | * |
||
212 | ******************************************************************************/ |
||
213 | |||
214 | |||
215 | OpnDoMethod ( |
||
216 | ACPI_PARSE_OBJECT *Op) |
||
217 | { |
||
218 | ACPI_PARSE_OBJECT *Next; |
||
219 | |||
220 | |||
221 | |||
222 | |||
223 | UINT8 Serialized = 0; |
||
224 | UINT8 Concurrency = 0; |
||
225 | UINT8 MethodFlags; |
||
226 | |||
227 | |||
228 | |||
229 | /* Method name */ |
||
230 | |||
231 | |||
232 | |||
233 | |||
234 | |||
235 | |||
236 | if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) |
||
237 | { |
||
238 | NumArgs = (UINT8) Next->Asl.Value.Integer; |
||
239 | Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
240 | } |
||
241 | |||
242 | |||
243 | |||
244 | |||
245 | if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) |
||
246 | { |
||
247 | Serialized = (UINT8) Next->Asl.Value.Integer; |
||
248 | Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
249 | } |
||
250 | |||
251 | |||
252 | |||
253 | |||
254 | if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) |
||
255 | { |
||
256 | if (Next->Asl.Value.Integer > 15) |
||
257 | { |
||
258 | AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); |
||
259 | } |
||
260 | Concurrency = (UINT8) Next->Asl.Value.Integer; |
||
261 | } |
||
262 | |||
263 | |||
264 | |||
265 | |||
266 | ((Serialized & 0x1) << 3) | |
||
267 | ((Concurrency & 0xF) << 4)); |
||
268 | |||
269 | |||
270 | |||
271 | |||
272 | Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; |
||
273 | Next->Asl.AmlLength = 1; |
||
274 | Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; |
||
275 | |||
276 | |||
277 | |||
278 | |||
279 | } |
||
280 | |||
281 | |||
282 | |||
283 | * |
||
284 | * FUNCTION: OpnDoFieldCommon |
||
285 | * |
||
286 | * PARAMETERS: FieldOp - Node for an ASL field |
||
287 | * Op - The parent parse node |
||
288 | * |
||
289 | * RETURN: None |
||
290 | * |
||
291 | * DESCRIPTION: Construct the AML operands for the various field keywords, |
||
292 | * FIELD, BANKFIELD, INDEXFIELD |
||
293 | * |
||
294 | ******************************************************************************/ |
||
295 | |||
296 | |||
297 | OpnDoFieldCommon ( |
||
298 | ACPI_PARSE_OBJECT *FieldOp, |
||
299 | ACPI_PARSE_OBJECT *Op) |
||
300 | { |
||
301 | ACPI_PARSE_OBJECT *Next; |
||
302 | ACPI_PARSE_OBJECT *PkgLengthNode; |
||
303 | UINT32 CurrentBitOffset; |
||
304 | UINT32 NewBitOffset; |
||
305 | UINT8 AccessType; |
||
306 | UINT8 LockRule; |
||
307 | UINT8 UpdateRule; |
||
308 | UINT8 FieldFlags; |
||
309 | UINT32 MinimumLength; |
||
310 | |||
311 | |||
312 | |||
313 | |||
314 | |||
315 | Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
316 | |||
317 | |||
318 | |||
319 | |||
320 | |||
321 | |||
322 | |||
323 | |||
324 | LockRule = (UINT8) Next->Asl.Value.Integer; |
||
325 | Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
326 | |||
327 | |||
328 | |||
329 | |||
330 | UpdateRule = (UINT8) Next->Asl.Value.Integer; |
||
331 | |||
332 | |||
333 | * Generate the flags byte. The various fields are already |
||
334 | * in the right bit position via translation from the |
||
335 | * keywords by the parser. |
||
336 | */ |
||
337 | FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule); |
||
338 | |||
339 | |||
340 | |||
341 | |||
342 | |||
343 | |||
344 | Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; |
||
345 | Next->Asl.AmlLength = 1; |
||
346 | Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; |
||
347 | |||
348 | |||
349 | |||
350 | |||
351 | CurrentBitOffset = 0; |
||
352 | |||
353 | |||
354 | { |
||
355 | /* Save the offset of this field unit */ |
||
356 | |||
357 | |||
358 | |||
359 | |||
360 | { |
||
361 | case PARSEOP_ACCESSAS: |
||
362 | |||
363 | |||
364 | AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer; |
||
365 | |||
366 | |||
367 | break; |
||
368 | |||
369 | |||
370 | |||
371 | |||
372 | |||
373 | |||
374 | |||
375 | NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8; |
||
376 | |||
377 | |||
378 | * Examine the specified offset in relation to the |
||
379 | * current offset counter. |
||
380 | */ |
||
381 | if (NewBitOffset < CurrentBitOffset) |
||
382 | { |
||
383 | /* |
||
384 | * Not allowed to specify a backwards offset! |
||
385 | * Issue error and ignore this node. |
||
386 | */ |
||
387 | AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, |
||
388 | NULL); |
||
389 | Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
390 | PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
391 | } |
||
392 | else if (NewBitOffset == CurrentBitOffset) |
||
393 | { |
||
394 | /* |
||
395 | * Offset is redundant; we don't need to output an |
||
396 | * offset opcode. Just set these nodes to default |
||
397 | */ |
||
398 | Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
399 | PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
400 | } |
||
401 | else |
||
402 | { |
||
403 | /* |
||
404 | * Valid new offset - set the value to be inserted into the AML |
||
405 | * and update the offset counter. |
||
406 | */ |
||
407 | PkgLengthNode->Asl.Value.Integer = |
||
408 | NewBitOffset - CurrentBitOffset; |
||
409 | CurrentBitOffset = NewBitOffset; |
||
410 | } |
||
411 | break; |
||
412 | |||
413 | |||
414 | |||
415 | case PARSEOP_RESERVED_BYTES: |
||
416 | |||
417 | |||
418 | |||
419 | |||
420 | NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; |
||
421 | CurrentBitOffset += NewBitOffset; |
||
422 | |||
423 | |||
424 | |||
425 | |||
426 | { |
||
427 | case AML_FIELD_ACCESS_ANY: |
||
428 | case AML_FIELD_ACCESS_BYTE: |
||
429 | case AML_FIELD_ACCESS_BUFFER: |
||
430 | default: |
||
431 | MinimumLength = 8; |
||
432 | break; |
||
433 | |||
434 | |||
435 | MinimumLength = 16; |
||
436 | break; |
||
437 | |||
438 | |||
439 | MinimumLength = 32; |
||
440 | break; |
||
441 | |||
442 | |||
443 | MinimumLength = 64; |
||
444 | break; |
||
445 | } |
||
446 | |||
447 | |||
448 | break; |
||
449 | |||
450 | |||
451 | /* All supported field opcodes must appear above */ |
||
452 | break; |
||
453 | } |
||
454 | |||
455 | |||
456 | |||
457 | |||
458 | } |
||
459 | } |
||
460 | |||
461 | |||
462 | |||
463 | * |
||
464 | * FUNCTION: OpnDoField |
||
465 | * |
||
466 | * PARAMETERS: Op - The parent parse node |
||
467 | * |
||
468 | * RETURN: None |
||
469 | * |
||
470 | * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword |
||
471 | * |
||
472 | ******************************************************************************/ |
||
473 | |||
474 | |||
475 | OpnDoField ( |
||
476 | ACPI_PARSE_OBJECT *Op) |
||
477 | { |
||
478 | ACPI_PARSE_OBJECT *Next; |
||
479 | |||
480 | |||
481 | |||
482 | /* First child is field name */ |
||
483 | |||
484 | |||
485 | |||
486 | |||
487 | |||
488 | |||
489 | } |
||
490 | |||
491 | |||
492 | |||
493 | * |
||
494 | * FUNCTION: OpnDoIndexField |
||
495 | * |
||
496 | * PARAMETERS: Op - The parent parse node |
||
497 | * |
||
498 | * RETURN: None |
||
499 | * |
||
500 | * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword |
||
501 | * |
||
502 | ******************************************************************************/ |
||
503 | |||
504 | |||
505 | OpnDoIndexField ( |
||
506 | ACPI_PARSE_OBJECT *Op) |
||
507 | { |
||
508 | ACPI_PARSE_OBJECT *Next; |
||
509 | |||
510 | |||
511 | |||
512 | /* First child is the index name */ |
||
513 | |||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | |||
520 | |||
521 | |||
522 | |||
523 | } |
||
524 | |||
525 | |||
526 | |||
527 | * |
||
528 | * FUNCTION: OpnDoBankField |
||
529 | * |
||
530 | * PARAMETERS: Op - The parent parse node |
||
531 | * |
||
532 | * RETURN: None |
||
533 | * |
||
534 | * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword |
||
535 | * |
||
536 | ******************************************************************************/ |
||
537 | |||
538 | |||
539 | OpnDoBankField ( |
||
540 | ACPI_PARSE_OBJECT *Op) |
||
541 | { |
||
542 | ACPI_PARSE_OBJECT *Next; |
||
543 | |||
544 | |||
545 | |||
546 | /* First child is the region name */ |
||
547 | |||
548 | |||
549 | |||
550 | |||
551 | |||
552 | |||
553 | |||
554 | |||
555 | |||
556 | |||
557 | |||
558 | |||
559 | |||
560 | |||
561 | } |
||
562 | |||
563 | |||
564 | |||
565 | * |
||
566 | * FUNCTION: OpnDoRegion |
||
567 | * |
||
568 | * PARAMETERS: Op - The parent parse node |
||
569 | * |
||
570 | * RETURN: None |
||
571 | * |
||
572 | * DESCRIPTION: Tries to get the length of the region. Can only do this at |
||
573 | * compile time if the length is a constant. |
||
574 | * |
||
575 | ******************************************************************************/ |
||
576 | |||
577 | |||
578 | OpnDoRegion ( |
||
579 | ACPI_PARSE_OBJECT *Op) |
||
580 | { |
||
581 | ACPI_PARSE_OBJECT *Next; |
||
582 | |||
583 | |||
584 | |||
585 | /* First child is the region name */ |
||
586 | |||
587 | |||
588 | |||
589 | |||
590 | |||
591 | |||
592 | |||
593 | |||
594 | |||
595 | |||
596 | |||
597 | |||
598 | |||
599 | |||
600 | if (Next->Asl.ParseOpcode == PARSEOP_INTEGER) |
||
601 | { |
||
602 | Op->Asl.Value.Integer = Next->Asl.Value.Integer; |
||
603 | } |
||
604 | else |
||
605 | { |
||
606 | Op->Asl.Value.Integer = ACPI_UINT64_MAX; |
||
607 | } |
||
608 | } |
||
609 | |||
610 | |||
611 | |||
612 | * |
||
613 | * FUNCTION: OpnDoBuffer |
||
614 | * |
||
615 | * PARAMETERS: Op - The parent parse node |
||
616 | * |
||
617 | * RETURN: None |
||
618 | * |
||
619 | * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We |
||
620 | * build a single raw byte buffer from the initialization nodes, |
||
621 | * each parse node contains a buffer byte. |
||
622 | * |
||
623 | ******************************************************************************/ |
||
624 | |||
625 | |||
626 | OpnDoBuffer ( |
||
627 | ACPI_PARSE_OBJECT *Op) |
||
628 | { |
||
629 | ACPI_PARSE_OBJECT *InitializerOp; |
||
630 | ACPI_PARSE_OBJECT *BufferLengthOp; |
||
631 | |||
632 | |||
633 | |||
634 | |||
635 | |||
636 | |||
637 | |||
638 | /* Buffer Length is next, followed by the initializer list */ |
||
639 | |||
640 | |||
641 | InitializerOp = BufferLengthOp->Asl.Next; |
||
642 | |||
643 | |||
644 | * If the BufferLength is not an INTEGER or was not specified in the ASL |
||
645 | * (DEFAULT_ARG), it is a TermArg that is |
||
646 | * evaluated at run-time, and we are therefore finished. |
||
647 | */ |
||
648 | if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) && |
||
649 | (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) |
||
650 | { |
||
651 | return; |
||
652 | } |
||
653 | |||
654 | |||
655 | * We want to count the number of items in the initializer list, because if |
||
656 | * it is larger than the buffer length, we will define the buffer size |
||
657 | * to be the size of the initializer list (as per the ACPI Specification) |
||
658 | */ |
||
659 | switch (InitializerOp->Asl.ParseOpcode) |
||
660 | { |
||
661 | case PARSEOP_INTEGER: |
||
662 | case PARSEOP_BYTECONST: |
||
663 | case PARSEOP_WORDCONST: |
||
664 | case PARSEOP_DWORDCONST: |
||
665 | |||
666 | |||
667 | |||
668 | |||
669 | { |
||
670 | /* For buffers, this is a list of raw bytes */ |
||
671 | |||
672 | |||
673 | InitializerOp->Asl.AmlLength = 1; |
||
674 | InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; |
||
675 | |||
676 | |||
677 | InitializerOp = ASL_GET_PEER_NODE (InitializerOp); |
||
678 | } |
||
679 | break; |
||
680 | |||
681 | |||
682 | |||
683 | |||
684 | |||
685 | * Only one initializer, the string. Buffer must be big enough to hold |
||
686 | * the string plus the null termination byte |
||
687 | */ |
||
688 | BufferLength = strlen (InitializerOp->Asl.Value.String) + 1; |
||
689 | |||
690 | |||
691 | InitializerOp->Asl.AmlLength = BufferLength; |
||
692 | InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; |
||
693 | break; |
||
694 | |||
695 | |||
696 | |||
697 | |||
698 | |||
699 | return; |
||
700 | |||
701 | |||
702 | |||
703 | break; |
||
704 | |||
705 | |||
706 | |||
707 | AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp, |
||
708 | "Unknown buffer initializer opcode"); |
||
709 | printf ("Unknown buffer initializer opcode [%s]\n", |
||
710 | UtGetOpName (InitializerOp->Asl.ParseOpcode)); |
||
711 | return; |
||
712 | } |
||
713 | |||
714 | |||
715 | |||
716 | |||
717 | { |
||
718 | BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer; |
||
719 | } |
||
720 | |||
721 | |||
722 | { |
||
723 | /* No length AND no items -- issue notice */ |
||
724 | |||
725 | |||
726 | |||
727 | |||
728 | } |
||
729 | |||
730 | |||
731 | * Just set the buffer size node to be the buffer length, regardless |
||
732 | * of whether it was previously an integer or a default_arg placeholder |
||
733 | */ |
||
734 | BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; |
||
735 | BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; |
||
736 | BufferLengthOp->Asl.Value.Integer = BufferLength; |
||
737 | |||
738 | |||
739 | |||
740 | |||
741 | } |
||
742 | |||
743 | |||
744 | |||
745 | * |
||
746 | * FUNCTION: OpnDoPackage |
||
747 | * |
||
748 | * PARAMETERS: Op - The parent parse node |
||
749 | * |
||
750 | * RETURN: None |
||
751 | * |
||
752 | * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE: |
||
753 | * can only be called after constants have been folded, to ensure |
||
754 | * that the PackageLength operand has been fully reduced. |
||
755 | * |
||
756 | ******************************************************************************/ |
||
757 | |||
758 | |||
759 | OpnDoPackage ( |
||
760 | ACPI_PARSE_OBJECT *Op) |
||
761 | { |
||
762 | ACPI_PARSE_OBJECT *InitializerOp; |
||
763 | ACPI_PARSE_OBJECT *PackageLengthOp; |
||
764 | UINT32 PackageLength = 0; |
||
765 | |||
766 | |||
767 | |||
768 | |||
769 | |||
770 | InitializerOp = PackageLengthOp->Asl.Next; |
||
771 | |||
772 | |||
773 | |||
774 | |||
775 | { |
||
776 | /* The peer list contains the byte list (if any...) */ |
||
777 | |||
778 | |||
779 | { |
||
780 | PackageLength++; |
||
781 | InitializerOp = InitializerOp->Asl.Next; |
||
782 | } |
||
783 | } |
||
784 | |||
785 | |||
786 | |||
787 | |||
788 | (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)) |
||
789 | { |
||
790 | if (PackageLengthOp->Asl.Value.Integer > PackageLength) |
||
791 | { |
||
792 | /* |
||
793 | * Allow package length to be longer than the initializer |
||
794 | * list -- but if the length of initializer list is nonzero, |
||
795 | * issue a message since this is probably a coding error, |
||
796 | * even though technically legal. |
||
797 | */ |
||
798 | if (PackageLength > 0) |
||
799 | { |
||
800 | AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT, |
||
801 | PackageLengthOp, NULL); |
||
802 | } |
||
803 | |||
804 | |||
805 | } |
||
806 | else if (PackageLengthOp->Asl.Value.Integer < PackageLength) |
||
807 | { |
||
808 | /* |
||
809 | * The package length is smaller than the length of the |
||
810 | * initializer list. This is an error as per the ACPI spec. |
||
811 | */ |
||
812 | AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG, |
||
813 | PackageLengthOp, NULL); |
||
814 | } |
||
815 | } |
||
816 | |||
817 | |||
818 | { |
||
819 | /* |
||
820 | * This is the case if the PackageLength was left empty - Package() |
||
821 | * The package length becomes the length of the initializer list |
||
822 | */ |
||
823 | Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER; |
||
824 | Op->Asl.Child->Asl.Value.Integer = PackageLength; |
||
825 | |||
826 | |||
827 | |||
828 | |||
829 | } |
||
830 | |||
831 | |||
832 | |||
833 | |||
834 | (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) || |
||
835 | (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)) |
||
836 | { |
||
837 | if (!PackageLength) |
||
838 | { |
||
839 | /* No length AND no initializer list -- issue a remark */ |
||
840 | |||
841 | |||
842 | PackageLengthOp, NULL); |
||
843 | |||
844 | |||
845 | } |
||
846 | } |
||
847 | |||
848 | |||
849 | * If the PackageLength is a constant <= 255, we can change the |
||
850 | * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode. |
||
851 | */ |
||
852 | if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && |
||
853 | (Op->Asl.Child->Asl.Value.Integer <= 255)) |
||
854 | { |
||
855 | Op->Asl.AmlOpcode = AML_PACKAGE_OP; |
||
856 | Op->Asl.ParseOpcode = PARSEOP_PACKAGE; |
||
857 | |||
858 | |||
859 | * Just set the package size node to be the package length, regardless |
||
860 | * of whether it was previously an integer or a default_arg placeholder |
||
861 | */ |
||
862 | PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; |
||
863 | PackageLengthOp->Asl.AmlLength = 1; |
||
864 | PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; |
||
865 | PackageLengthOp->Asl.Value.Integer = PackageLength; |
||
866 | } |
||
867 | |||
868 | |||
869 | } |
||
870 | |||
871 | |||
872 | |||
873 | * |
||
874 | * FUNCTION: OpnDoLoadTable |
||
875 | * |
||
876 | * PARAMETERS: Op - The parent parse node |
||
877 | * |
||
878 | * RETURN: None |
||
879 | * |
||
880 | * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword. |
||
881 | * |
||
882 | ******************************************************************************/ |
||
883 | |||
884 | |||
885 | OpnDoLoadTable ( |
||
886 | ACPI_PARSE_OBJECT *Op) |
||
887 | { |
||
888 | ACPI_PARSE_OBJECT *Next; |
||
889 | |||
890 | |||
891 | |||
892 | /* First child is the table signature */ |
||
893 | |||
894 | |||
895 | |||
896 | |||
897 | |||
898 | |||
899 | |||
900 | |||
901 | |||
902 | |||
903 | |||
904 | |||
905 | |||
906 | |||
907 | if (Next->Asl.ParseOpcode == PARSEOP_ZERO) |
||
908 | { |
||
909 | Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; |
||
910 | Next->Asl.Value.String = "\\"; |
||
911 | Next->Asl.AmlLength = 2; |
||
912 | OpcGenerateAmlOpcode (Next); |
||
913 | } |
||
914 | |||
915 | |||
916 | |||
917 | |||
918 | /* Fifth child is the [optional] ParameterPathString */ |
||
919 | /* Sixth child is the [optional] ParameterData */ |
||
920 | |||
921 | |||
922 | if (Next->Asl.ParseOpcode == DEFAULT_ARG) |
||
923 | { |
||
924 | Next->Asl.AmlLength = 1; |
||
925 | Next->Asl.ParseOpcode = ZERO; |
||
926 | OpcGenerateAmlOpcode (Next); |
||
927 | } |
||
928 | |||
929 | |||
930 | |||
931 | if (Next->Asl.ParseOpcode == DEFAULT_ARG) |
||
932 | { |
||
933 | Next->Asl.AmlLength = 1; |
||
934 | Next->Asl.ParseOpcode = ZERO; |
||
935 | OpcGenerateAmlOpcode (Next); |
||
936 | } |
||
937 | #endif |
||
938 | } |
||
939 | |||
940 | |||
941 | |||
942 | * |
||
943 | * FUNCTION: OpnDoDefinitionBlock |
||
944 | * |
||
945 | * PARAMETERS: Op - The parent parse node |
||
946 | * |
||
947 | * RETURN: None |
||
948 | * |
||
949 | * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword |
||
950 | * |
||
951 | ******************************************************************************/ |
||
952 | |||
953 | |||
954 | OpnDoDefinitionBlock ( |
||
955 | ACPI_PARSE_OBJECT *Op) |
||
956 | { |
||
957 | ACPI_PARSE_OBJECT *Child; |
||
958 | ACPI_SIZE Length; |
||
959 | UINT32 i; |
||
960 | char *Filename; |
||
961 | |||
962 | |||
963 | |||
964 | * These nodes get stuffed into the table header. They are special |
||
965 | * cased when the table is written to the output file. |
||
966 | * |
||
967 | * Mark all of these nodes as non-usable so they won't get output |
||
968 | * as AML opcodes! |
||
969 | */ |
||
970 | |||
971 | |||
972 | |||
973 | |||
974 | if (Child->Asl.Value.Buffer && |
||
975 | *Child->Asl.Value.Buffer && |
||
976 | (Gbl_UseDefaultAmlFilename)) |
||
977 | { |
||
978 | /* |
||
979 | * We will use the AML filename that is embedded in the source file |
||
980 | * for the output filename. |
||
981 | */ |
||
982 | Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) + |
||
983 | strlen ((char *) Child->Asl.Value.Buffer) + 1); |
||
984 | |||
985 | |||
986 | |||
987 | |||
988 | strcat (Filename, (char *) Child->Asl.Value.Buffer); |
||
989 | |||
990 | |||
991 | } |
||
992 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
993 | |||
994 | |||
995 | |||
996 | |||
997 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
998 | if (Child->Asl.Value.String) |
||
999 | { |
||
1000 | Gbl_TableSignature = Child->Asl.Value.String; |
||
1001 | if (ACPI_STRLEN (Gbl_TableSignature) != 4) |
||
1002 | { |
||
1003 | AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, |
||
1004 | "Length not exactly 4"); |
||
1005 | } |
||
1006 | |||
1007 | |||
1008 | { |
||
1009 | if (!isalnum ((int) Gbl_TableSignature[i])) |
||
1010 | { |
||
1011 | AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, |
||
1012 | "Contains non-alphanumeric characters"); |
||
1013 | } |
||
1014 | } |
||
1015 | } |
||
1016 | |||
1017 | |||
1018 | |||
1019 | |||
1020 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
1021 | /* |
||
1022 | * We used the revision to set the integer width earlier |
||
1023 | */ |
||
1024 | |||
1025 | |||
1026 | |||
1027 | |||
1028 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
1029 | |||
1030 | |||
1031 | |||
1032 | |||
1033 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
1034 | if (Child->Asl.Value.String) |
||
1035 | { |
||
1036 | Length = ACPI_STRLEN (Child->Asl.Value.String); |
||
1037 | Gbl_TableId = AcpiOsAllocate (Length + 1); |
||
1038 | ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); |
||
1039 | |||
1040 | |||
1041 | { |
||
1042 | if (Gbl_TableId[i] == ' ') |
||
1043 | { |
||
1044 | Gbl_TableId[i] = 0; |
||
1045 | break; |
||
1046 | } |
||
1047 | } |
||
1048 | } |
||
1049 | |||
1050 | |||
1051 | |||
1052 | |||
1053 | Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; |
||
1054 | } |
||
1055 | |||
1056 | |||
1057 | |||
1058 | * |
||
1059 | * FUNCTION: UtGetArg |
||
1060 | * |
||
1061 | * PARAMETERS: Op - Get an argument for this op |
||
1062 | * Argn - Nth argument to get |
||
1063 | * |
||
1064 | * RETURN: The argument (as an Op object). NULL if argument does not exist |
||
1065 | * |
||
1066 | * DESCRIPTION: Get the specified op's argument (peer) |
||
1067 | * |
||
1068 | ******************************************************************************/ |
||
1069 | |||
1070 | |||
1071 | UtGetArg ( |
||
1072 | ACPI_PARSE_OBJECT *Op, |
||
1073 | UINT32 Argn) |
||
1074 | { |
||
1075 | ACPI_PARSE_OBJECT *Arg = NULL; |
||
1076 | |||
1077 | |||
1078 | |||
1079 | |||
1080 | |||
1081 | while (Arg && Argn) |
||
1082 | { |
||
1083 | Argn--; |
||
1084 | Arg = Arg->Asl.Next; |
||
1085 | } |
||
1086 | |||
1087 | |||
1088 | } |
||
1089 | |||
1090 | |||
1091 | |||
1092 | * |
||
1093 | * FUNCTION: OpnAttachNameToNode |
||
1094 | * |
||
1095 | * PARAMETERS: Op - The parent parse node |
||
1096 | * |
||
1097 | * RETURN: None |
||
1098 | * |
||
1099 | * DESCRIPTION: For the named ASL/AML operators, get the actual name from the |
||
1100 | * argument list and attach it to the parent node so that we |
||
1101 | * can get to it quickly later. |
||
1102 | * |
||
1103 | ******************************************************************************/ |
||
1104 | |||
1105 | |||
1106 | OpnAttachNameToNode ( |
||
1107 | ACPI_PARSE_OBJECT *Op) |
||
1108 | { |
||
1109 | ACPI_PARSE_OBJECT *Child = NULL; |
||
1110 | |||
1111 | |||
1112 | |||
1113 | { |
||
1114 | Child = UtGetArg (Op, 0); |
||
1115 | } |
||
1116 | else switch (Op->Asl.AmlOpcode) |
||
1117 | { |
||
1118 | case AML_DATA_REGION_OP: |
||
1119 | case AML_DEVICE_OP: |
||
1120 | case AML_EVENT_OP: |
||
1121 | case AML_METHOD_OP: |
||
1122 | case AML_MUTEX_OP: |
||
1123 | case AML_REGION_OP: |
||
1124 | case AML_POWER_RES_OP: |
||
1125 | case AML_PROCESSOR_OP: |
||
1126 | case AML_THERMAL_ZONE_OP: |
||
1127 | case AML_NAME_OP: |
||
1128 | case AML_SCOPE_OP: |
||
1129 | |||
1130 | |||
1131 | break; |
||
1132 | |||
1133 | |||
1134 | |||
1135 | |||
1136 | break; |
||
1137 | |||
1138 | |||
1139 | case AML_CREATE_BYTE_FIELD_OP: |
||
1140 | case AML_CREATE_WORD_FIELD_OP: |
||
1141 | case AML_CREATE_DWORD_FIELD_OP: |
||
1142 | case AML_CREATE_QWORD_FIELD_OP: |
||
1143 | |||
1144 | |||
1145 | break; |
||
1146 | |||
1147 | |||
1148 | |||
1149 | |||
1150 | break; |
||
1151 | |||
1152 | |||
1153 | case AML_INDEX_FIELD_OP: |
||
1154 | case AML_FIELD_OP: |
||
1155 | |||
1156 | |||
1157 | |||
1158 | |||
1159 | return; |
||
1160 | } |
||
1161 | |||
1162 | |||
1163 | { |
||
1164 | UtAttachNamepathToOwner (Op, Child); |
||
1165 | } |
||
1166 | } |
||
1167 | |||
1168 | |||
1169 | |||
1170 | * |
||
1171 | * FUNCTION: OpnGenerateAmlOperands |
||
1172 | * |
||
1173 | * PARAMETERS: Op - The parent parse node |
||
1174 | * |
||
1175 | * RETURN: None |
||
1176 | * |
||
1177 | * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more |
||
1178 | * complex AML opcodes require processing of the child nodes |
||
1179 | * (arguments/operands). |
||
1180 | * |
||
1181 | ******************************************************************************/ |
||
1182 | |||
1183 | |||
1184 | OpnGenerateAmlOperands ( |
||
1185 | ACPI_PARSE_OBJECT *Op) |
||
1186 | { |
||
1187 | |||
1188 | |||
1189 | |||
1190 | { |
||
1191 | return; |
||
1192 | } |
||
1193 | |||
1194 | |||
1195 | { |
||
1196 | case PARSEOP_DEFINITIONBLOCK: |
||
1197 | OpnDoDefinitionBlock (Op); |
||
1198 | break; |
||
1199 | |||
1200 | |||
1201 | OpnDoMethod (Op); |
||
1202 | break; |
||
1203 | |||
1204 | |||
1205 | OpnDoMutex (Op); |
||
1206 | break; |
||
1207 | |||
1208 | |||
1209 | OpnDoField (Op); |
||
1210 | break; |
||
1211 | |||
1212 | |||
1213 | OpnDoIndexField (Op); |
||
1214 | break; |
||
1215 | |||
1216 | |||
1217 | OpnDoBankField (Op); |
||
1218 | break; |
||
1219 | |||
1220 | |||
1221 | OpnDoBuffer (Op); |
||
1222 | break; |
||
1223 | |||
1224 | |||
1225 | OpnDoLoadTable (Op); |
||
1226 | break; |
||
1227 | |||
1228 | |||
1229 | OpnDoRegion (Op); |
||
1230 | break; |
||
1231 | |||
1232 | |||
1233 | RsDoResourceTemplate (Op); |
||
1234 | break; |
||
1235 | |||
1236 | |||
1237 | case PARSEOP_NAMESTRING: |
||
1238 | case PARSEOP_METHODCALL: |
||
1239 | case PARSEOP_STRING_LITERAL: |
||
1240 | break; |
||
1241 | |||
1242 | |||
1243 | break; |
||
1244 | } |
||
1245 | |||
1246 | |||
1247 | |||
1248 | |||
1249 | }>>=>=>>>><>><> |
||
1250 |