xref: /freebsd/sys/contrib/dev/acpica/compiler/asloperands.c (revision 7697e6c4df7188ee3a2aa66f73c572c27479bdf2)
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 - 2026, Intel Corp.
12  * All rights reserved.
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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include <contrib/dev/acpica/compiler/aslcompiler.h>
153 #include "aslcompiler.y.h"
154 #include <contrib/dev/acpica/include/amlcode.h>
155 
156 #define _COMPONENT          ACPI_COMPILER
157         ACPI_MODULE_NAME    ("asloperands")
158 
159 /* Local prototypes */
160 
161 static void
162 OpnDoField (
163     ACPI_PARSE_OBJECT       *Op);
164 
165 static void
166 OpnDoBankField (
167     ACPI_PARSE_OBJECT       *Op);
168 
169 static void
170 OpnDoBuffer (
171     ACPI_PARSE_OBJECT       *Op);
172 
173 static void
174 OpnDoDefinitionBlock (
175     ACPI_PARSE_OBJECT       *Op);
176 
177 static void
178 OpnDoFieldCommon (
179     ACPI_PARSE_OBJECT       *FieldOp,
180     ACPI_PARSE_OBJECT       *Op);
181 
182 static void
183 OpnDoIndexField (
184     ACPI_PARSE_OBJECT       *Op);
185 
186 static void
187 OpnDoLoadTable (
188     ACPI_PARSE_OBJECT       *Op);
189 
190 static void
191 OpnDoMethod (
192     ACPI_PARSE_OBJECT       *Op);
193 
194 static void
195 OpnDoMutex (
196     ACPI_PARSE_OBJECT       *Op);
197 
198 static void
199 OpnDoRegion (
200     ACPI_PARSE_OBJECT       *Op);
201 
202 static void
203 OpnAttachNameToNode (
204     ACPI_PARSE_OBJECT       *Op);
205 
206 
207 /*******************************************************************************
208  *
209  * FUNCTION:    OpnDoMutex
210  *
211  * PARAMETERS:  Op        - The parent parse node
212  *
213  * RETURN:      None
214  *
215  * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
216  *
217  ******************************************************************************/
218 
219 static void
OpnDoMutex(ACPI_PARSE_OBJECT * Op)220 OpnDoMutex (
221     ACPI_PARSE_OBJECT       *Op)
222 {
223     ACPI_PARSE_OBJECT       *Next;
224 
225 
226     Next = Op->Asl.Child;
227     Next = Next->Asl.Next;
228 
229     if (Next->Asl.Value.Integer > 15)
230     {
231         AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
232     }
233     return;
234 }
235 
236 
237 /*******************************************************************************
238  *
239  * FUNCTION:    OpnDoMethod
240  *
241  * PARAMETERS:  Op        - The parent parse node
242  *
243  * RETURN:      None
244  *
245  * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
246  *
247  ******************************************************************************/
248 
249 static void
OpnDoMethod(ACPI_PARSE_OBJECT * Op)250 OpnDoMethod (
251     ACPI_PARSE_OBJECT       *Op)
252 {
253     ACPI_PARSE_OBJECT       *Next;
254 
255     /* Optional arguments for this opcode with defaults */
256 
257     UINT8                   NumArgs = 0;
258     UINT8                   Serialized = 0;
259     UINT8                   Concurrency = 0;
260     UINT8                   MethodFlags;
261 
262 
263     /* Opcode and package length first */
264     /* Method name */
265 
266     Next = Op->Asl.Child;
267 
268     /* Num args */
269 
270     Next = Next->Asl.Next;
271     if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
272     {
273         NumArgs = (UINT8) Next->Asl.Value.Integer;
274         Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
275     }
276 
277     /* Serialized Flag */
278 
279     Next = Next->Asl.Next;
280     if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
281     {
282         Serialized = (UINT8) Next->Asl.Value.Integer;
283         Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
284     }
285 
286     /* Concurrency value (valid values are 0-15) */
287 
288     Next = Next->Asl.Next;
289     if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
290     {
291         /* This is a ByteConstExpr, so eval the constant now */
292 
293         OpcAmlConstantWalk (Next, 0, NULL);
294 
295         if (Next->Asl.Value.Integer > 15)
296         {
297             AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
298         }
299 
300         Concurrency = (UINT8) Next->Asl.Value.Integer;
301     }
302 
303     /* Put the bits in their proper places */
304 
305     MethodFlags = (UINT8)
306         ((NumArgs & 0x7) |
307         ((Serialized & 0x1) << 3) |
308         ((Concurrency & 0xF) << 4));
309 
310     /* Use the last node for the combined flags byte */
311 
312     Next->Asl.Value.Integer = MethodFlags;
313     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
314     Next->Asl.AmlLength = 1;
315     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
316 
317     /* Save the arg count in the first node */
318 
319     Op->Asl.Extra = NumArgs;
320 }
321 
322 
323 /*******************************************************************************
324  *
325  * FUNCTION:    OpnDoFieldCommon
326  *
327  * PARAMETERS:  FieldOp       - Node for an ASL field
328  *              Op            - The parent parse node
329  *
330  * RETURN:      None
331  *
332  * DESCRIPTION: Construct the AML operands for the various field keywords,
333  *              FIELD, BANKFIELD, INDEXFIELD
334  *
335  ******************************************************************************/
336 
337 static void
OpnDoFieldCommon(ACPI_PARSE_OBJECT * FieldOp,ACPI_PARSE_OBJECT * Op)338 OpnDoFieldCommon (
339     ACPI_PARSE_OBJECT       *FieldOp,
340     ACPI_PARSE_OBJECT       *Op)
341 {
342     ACPI_PARSE_OBJECT       *Next;
343     ACPI_PARSE_OBJECT       *PkgLengthNode;
344     UINT32                  CurrentBitOffset;
345     UINT32                  NewBitOffset;
346     UINT8                   AccessType;
347     UINT8                   LockRule;
348     UINT8                   UpdateRule;
349     UINT8                   FieldFlags;
350     UINT32                  MinimumLength;
351 
352 
353     /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
354 
355     AccessType = (UINT8) Op->Asl.Value.Integer;
356     Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
357 
358     /* Set the access type in the parent (field) node for use later */
359 
360     FieldOp->Asl.Value.Integer = AccessType;
361 
362     /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
363 
364     Next = Op->Asl.Next;
365     LockRule = (UINT8) Next->Asl.Value.Integer;
366     Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
367 
368     /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
369 
370     Next = Next->Asl.Next;
371     UpdateRule = (UINT8) Next->Asl.Value.Integer;
372 
373     /*
374      * Generate the flags byte. The various fields are already
375      * in the right bit position via translation from the
376      * keywords by the parser.
377      */
378     FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
379 
380     /* Use the previous node to be the FieldFlags node */
381 
382     /* Set the node to RAW_DATA */
383 
384     Next->Asl.Value.Integer = FieldFlags;
385     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
386     Next->Asl.AmlLength = 1;
387     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
388 
389     /* Process the FieldUnitList */
390 
391     Next = Next->Asl.Next;
392     CurrentBitOffset = 0;
393 
394     while (Next)
395     {
396         /* Save the offset of this field unit */
397 
398         Next->Asl.ExtraValue = CurrentBitOffset;
399 
400         switch (Next->Asl.ParseOpcode)
401         {
402         case PARSEOP_ACCESSAS:
403 
404             PkgLengthNode = Next->Asl.Child;
405             AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
406 
407             /* Nothing additional to do */
408             break;
409 
410         case PARSEOP_OFFSET:
411 
412             /* New offset into the field */
413 
414             PkgLengthNode = Next->Asl.Child;
415             NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
416 
417             /*
418              * Examine the specified offset in relation to the
419              * current offset counter.
420              */
421             if (NewBitOffset < CurrentBitOffset)
422             {
423                 /*
424                  * Not allowed to specify a backwards offset!
425                  * Issue error and ignore this node.
426                  */
427                 AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode,
428                     NULL);
429                 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
430                 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
431             }
432 #ifdef _OBSOLETE_CODE
433             /*
434              * January 2022: removed this check due to complaints by users
435              * for too many (invalid) remarks.
436              */
437             else if (NewBitOffset == CurrentBitOffset)
438             {
439                 /*
440                  * This Offset() operator is redundant and not needed,
441                  * because the offset value is the same as the current
442                  * offset.
443                  */
444                 AslError (ASL_REMARK, ASL_MSG_OFFSET, PkgLengthNode, NULL);
445 
446                 if (AslGbl_OptimizeTrivialParseNodes)
447                 {
448                     /*
449                      * Optimize this Offset() operator by removing/ignoring
450                      * it. Set the related nodes to default.
451                      */
452                     Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
453                     PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
454 
455                     AslError (ASL_OPTIMIZATION, ASL_MSG_OFFSET, PkgLengthNode,
456                         "Optimizer has removed statement");
457                 }
458                 else
459                 {
460                     /* Optimization is disabled, treat as a valid Offset */
461 
462                     PkgLengthNode->Asl.Value.Integer =
463                         NewBitOffset - CurrentBitOffset;
464                     CurrentBitOffset = NewBitOffset;
465                 }
466             }
467 #endif
468             else
469             {
470                 /*
471                  * Valid new offset - set the value to be inserted into the AML
472                  * and update the offset counter.
473                  */
474                 PkgLengthNode->Asl.Value.Integer =
475                     NewBitOffset - CurrentBitOffset;
476                 CurrentBitOffset = NewBitOffset;
477             }
478             break;
479 
480         case PARSEOP_NAMESEG:
481         case PARSEOP_RESERVED_BYTES:
482 
483             /* Named or reserved field entry */
484 
485             PkgLengthNode = Next->Asl.Child;
486             NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer;
487             CurrentBitOffset += NewBitOffset;
488 
489             if ((NewBitOffset == 0) &&
490                 (Next->Asl.ParseOpcode == PARSEOP_RESERVED_BYTES) &&
491                 AslGbl_OptimizeTrivialParseNodes)
492             {
493                 /*
494                  * Unnamed field with a bit length of zero. We can
495                  * safely just ignore this. However, we will not ignore
496                  * a named field of zero length, we don't want to just
497                  * toss out a name.
498                  */
499                 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
500                 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
501                 break;
502             }
503 
504             /* Save the current AccessAs value for error checking later */
505 
506             switch (AccessType)
507             {
508                 case AML_FIELD_ACCESS_ANY:
509                 case AML_FIELD_ACCESS_BYTE:
510                 case AML_FIELD_ACCESS_BUFFER:
511                 default:
512 
513                     MinimumLength = 8;
514                     break;
515 
516                 case AML_FIELD_ACCESS_WORD:
517                     MinimumLength = 16;
518                     break;
519 
520                 case AML_FIELD_ACCESS_DWORD:
521                     MinimumLength = 32;
522                     break;
523 
524                 case AML_FIELD_ACCESS_QWORD:
525                     MinimumLength = 64;
526                     break;
527             }
528 
529             PkgLengthNode->Asl.ExtraValue = MinimumLength;
530             break;
531 
532         default:
533 
534             /* All supported field opcodes must appear above */
535 
536             break;
537         }
538 
539         /* Move on to next entry in the field list */
540 
541         Next = Next->Asl.Next;
542     }
543 }
544 
545 
546 /*******************************************************************************
547  *
548  * FUNCTION:    OpnDoField
549  *
550  * PARAMETERS:  Op        - The parent parse node
551  *
552  * RETURN:      None
553  *
554  * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
555  *
556  ******************************************************************************/
557 
558 static void
OpnDoField(ACPI_PARSE_OBJECT * Op)559 OpnDoField (
560     ACPI_PARSE_OBJECT       *Op)
561 {
562     ACPI_PARSE_OBJECT       *Next;
563 
564 
565     /* Opcode is parent node */
566     /* First child is field name */
567 
568     Next = Op->Asl.Child;
569 
570     /* Second child is the AccessType */
571 
572     OpnDoFieldCommon (Op, Next->Asl.Next);
573 }
574 
575 
576 /*******************************************************************************
577  *
578  * FUNCTION:    OpnDoIndexField
579  *
580  * PARAMETERS:  Op        - The parent parse node
581  *
582  * RETURN:      None
583  *
584  * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
585  *
586  ******************************************************************************/
587 
588 static void
OpnDoIndexField(ACPI_PARSE_OBJECT * Op)589 OpnDoIndexField (
590     ACPI_PARSE_OBJECT       *Op)
591 {
592     ACPI_PARSE_OBJECT       *Next;
593 
594 
595     /* Opcode is parent node */
596     /* First child is the index name */
597 
598     Next = Op->Asl.Child;
599 
600     /* Second child is the data name */
601 
602     Next = Next->Asl.Next;
603 
604     /* Third child is the AccessType */
605 
606     OpnDoFieldCommon (Op, Next->Asl.Next);
607 }
608 
609 
610 /*******************************************************************************
611  *
612  * FUNCTION:    OpnDoBankField
613  *
614  * PARAMETERS:  Op        - The parent parse node
615  *
616  * RETURN:      None
617  *
618  * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
619  *
620  ******************************************************************************/
621 
622 static void
OpnDoBankField(ACPI_PARSE_OBJECT * Op)623 OpnDoBankField (
624     ACPI_PARSE_OBJECT       *Op)
625 {
626     ACPI_PARSE_OBJECT       *Next;
627 
628 
629     /* Opcode is parent node */
630     /* First child is the region name */
631 
632     Next = Op->Asl.Child;
633 
634     /* Second child is the bank name */
635 
636     Next = Next->Asl.Next;
637 
638     /* Third child is the bank value */
639 
640     Next = Next->Asl.Next;
641 
642     /* Fourth child is the AccessType */
643 
644     OpnDoFieldCommon (Op, Next->Asl.Next);
645 }
646 
647 
648 /*******************************************************************************
649  *
650  * FUNCTION:    OpnDoRegion
651  *
652  * PARAMETERS:  Op        - The parent parse node
653  *
654  * RETURN:      None
655  *
656  * DESCRIPTION: Tries to get the length of the region. Can only do this at
657  *              compile time if the length is a constant.
658  *
659  ******************************************************************************/
660 
661 static void
OpnDoRegion(ACPI_PARSE_OBJECT * Op)662 OpnDoRegion (
663     ACPI_PARSE_OBJECT       *Op)
664 {
665     ACPI_PARSE_OBJECT       *Next;
666     ACPI_ADR_SPACE_TYPE     SpaceId;
667 
668 
669     /* Opcode is parent node */
670     /* First child is the region name */
671 
672     Next = Op->Asl.Child;
673 
674     /* Second child is the space ID */
675 
676     Next = Next->Asl.Next;
677     SpaceId = (ACPI_ADR_SPACE_TYPE) Next->Common.Value.Integer;
678 
679     /* Third child is the region offset */
680 
681     Next = Next->Asl.Next;
682 
683     /* Fourth child is the region length */
684 
685     Next = Next->Asl.Next;
686     if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
687     {
688         /* Check for zero length */
689 
690         Op->Asl.Value.Integer = Next->Asl.Value.Integer;
691         if (!Op->Asl.Value.Integer && (SpaceId < ACPI_NUM_PREDEFINED_REGIONS))
692         {
693             AslError (ASL_ERROR, ASL_MSG_REGION_LENGTH, Op, NULL);
694         }
695     }
696     else
697     {
698         Op->Asl.Value.Integer = ACPI_UINT64_MAX;
699     }
700 }
701 
702 
703 /*******************************************************************************
704  *
705  * FUNCTION:    OpnDoBuffer
706  *
707  * PARAMETERS:  Op        - The parent parse node
708  *
709  * RETURN:      None
710  *
711  * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
712  *              build a single raw byte buffer from the initialization nodes,
713  *              each parse node contains a buffer byte.
714  *
715  ******************************************************************************/
716 
717 static void
OpnDoBuffer(ACPI_PARSE_OBJECT * Op)718 OpnDoBuffer (
719     ACPI_PARSE_OBJECT       *Op)
720 {
721     ACPI_PARSE_OBJECT       *InitializerOp;
722     ACPI_PARSE_OBJECT       *BufferLengthOp;
723 
724     /* Optional arguments for this opcode with defaults */
725 
726     UINT32                  BufferLength = 0;
727 
728 
729     /* Opcode and package length first */
730     /* Buffer Length is next, followed by the initializer list */
731 
732     BufferLengthOp = Op->Asl.Child;
733     InitializerOp = BufferLengthOp->Asl.Next;
734 
735     /*
736      * If the BufferLength is not an INTEGER or was not specified in the ASL
737      * (DEFAULT_ARG), it is a TermArg that is
738      * evaluated at run-time, and we are therefore finished.
739      */
740     if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
741         (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
742     {
743         return;
744     }
745 
746     /*
747      * We want to count the number of items in the initializer list, because if
748      * it is larger than the buffer length, we will define the buffer size
749      * to be the size of the initializer list (as per the ACPI Specification)
750      */
751     switch (InitializerOp->Asl.ParseOpcode)
752     {
753     case PARSEOP_INTEGER:
754     case PARSEOP_BYTECONST:
755     case PARSEOP_WORDCONST:
756     case PARSEOP_DWORDCONST:
757 
758         /* The peer list contains the byte list (if any...) */
759 
760         while (InitializerOp)
761         {
762             /* For buffers, this is a list of raw bytes */
763 
764             InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
765             InitializerOp->Asl.AmlLength = 1;
766             InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
767 
768             BufferLength++;
769             InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
770         }
771         break;
772 
773     case PARSEOP_STRING_LITERAL:
774 
775         /*
776          * Only one initializer, the string. Buffer must be big enough to hold
777          * the string plus the null termination byte
778          */
779         BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
780 
781         InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
782         InitializerOp->Asl.AmlLength = BufferLength;
783         InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
784         break;
785 
786     case PARSEOP_RAW_DATA:
787 
788         /* Buffer nodes are already initialized (e.g. Unicode operator) */
789         return;
790 
791     case PARSEOP_DEFAULT_ARG:
792         break;
793 
794     default:
795 
796         AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
797             "Unknown buffer initializer opcode");
798         printf ("Unknown buffer initializer opcode [%s]\n",
799             UtGetOpName (InitializerOp->Asl.ParseOpcode));
800         return;
801     }
802 
803     /* Check if initializer list is longer than the buffer length */
804 
805     if (BufferLengthOp->Asl.Value.Integer > BufferLength)
806     {
807         BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
808     }
809 
810     if (!BufferLength)
811     {
812         /* No length AND no items -- issue notice */
813 
814         AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
815 
816         /* But go ahead and put the buffer length of zero into the AML */
817     }
818 
819     /*
820      * Just set the buffer size node to be the buffer length, regardless
821      * of whether it was previously an integer or a default_arg placeholder
822      */
823     BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
824     BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
825     BufferLengthOp->Asl.Value.Integer = BufferLength;
826 
827     (void) OpcSetOptimalIntegerSize (BufferLengthOp);
828     UtSetParseOpName (BufferLengthOp);
829 
830     /* Remaining nodes are handled via the tree walk */
831 }
832 
833 
834 /*******************************************************************************
835  *
836  * FUNCTION:    OpnDoPackage
837  *
838  * PARAMETERS:  Op        - The parent parse node
839  *
840  * RETURN:      None
841  *
842  * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
843  *              can only be called after constants have been folded, to ensure
844  *              that the PackageLength operand has been fully reduced.
845  *
846  ******************************************************************************/
847 
848 void
OpnDoPackage(ACPI_PARSE_OBJECT * Op)849 OpnDoPackage (
850     ACPI_PARSE_OBJECT       *Op)
851 {
852     ACPI_PARSE_OBJECT       *InitializerOp;
853     ACPI_PARSE_OBJECT       *PackageLengthOp;
854     UINT64                  DeclaredLength;
855     UINT32                  PackageLength = 0;
856     UINT32                  MaxEncodedLength = 0x0FFFFFFF; /* Max AML package length encoding (28 bits) */
857 
858 
859     /* Opcode and package length first, followed by the initializer list */
860 
861     PackageLengthOp = Op->Asl.Child;
862     InitializerOp = PackageLengthOp->Asl.Next;
863 
864     /* Count the number of items in the initializer list */
865 
866     if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
867     {
868         /* The peer list contains the byte list (if any...) */
869 
870         while (InitializerOp)
871         {
872             PackageLength++;
873             InitializerOp = InitializerOp->Asl.Next;
874         }
875     }
876 
877     /* If package length is a constant, compare to the initializer list */
878 
879     if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
880         (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)   ||
881         (PackageLengthOp->Asl.ParseOpcode == PARSEOP_PACKAGE_LENGTH))
882     {
883         DeclaredLength = PackageLengthOp->Asl.Value.Integer;
884 
885         /* Guard against values that cannot be encoded in AML package length format */
886 
887         if (DeclaredLength > MaxEncodedLength)
888         {
889             AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, PackageLengthOp, NULL);
890             DeclaredLength = MaxEncodedLength;
891             PackageLengthOp->Asl.Value.Integer = DeclaredLength;
892         }
893 
894         if (DeclaredLength > PackageLength)
895         {
896             /*
897              * Allow package length to be longer than the initializer
898              * list -- but if the length of initializer list is nonzero,
899              * issue a message since this is probably a coding error,
900              * even though technically legal.
901              */
902             if (PackageLength > 0)
903             {
904                 AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
905                     PackageLengthOp, NULL);
906             }
907 
908             PackageLength = (UINT32) DeclaredLength;
909         }
910         else if (DeclaredLength < PackageLength)
911         {
912             /*
913              * The package length is smaller than the length of the
914              * initializer list. This is an error as per the ACPI spec.
915              */
916             AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
917                 PackageLengthOp, NULL);
918         }
919     }
920 
921     if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
922     {
923         /*
924          * This is the case if the PackageLength was left empty - Package()
925          * The package length becomes the length of the initializer list
926          */
927         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
928         Op->Asl.Child->Asl.Value.Integer = PackageLength;
929         UtSetParseOpName (Op);
930 
931         /* Set the AML opcode */
932 
933         (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
934     }
935 
936     /* If not a variable-length package, check for a zero package length */
937 
938     if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
939         (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)   ||
940         (PackageLengthOp->Asl.ParseOpcode == PARSEOP_ZERO)         ||
941         (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
942     {
943         if (!PackageLength)
944         {
945             /* No length AND no initializer list -- issue a remark */
946 
947             AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
948                 PackageLengthOp, NULL);
949 
950             /* But go ahead and put the buffer length of zero into the AML */
951         }
952     }
953 
954     /*
955      * If the PackageLength is a constant <= 255, we can change the
956      * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
957      */
958     if (((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
959             (Op->Asl.Child->Asl.Value.Integer <= 255))  ||
960         (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONE) ||
961         (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONES)||
962         (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ZERO))
963     {
964         Op->Asl.AmlOpcode = AML_PACKAGE_OP;
965         Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
966 
967         /*
968          * Just set the package size node to be the package length, regardless
969          * of whether it was previously an integer or a default_arg placeholder
970          */
971         PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
972         PackageLengthOp->Asl.AmlLength = 1;
973         PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
974         PackageLengthOp->Asl.Value.Integer = PackageLength;
975     }
976 
977     /* Remaining nodes are handled via the tree walk */
978 }
979 
980 
981 /*******************************************************************************
982  *
983  * FUNCTION:    OpnDoLoadTable
984  *
985  * PARAMETERS:  Op        - The parent parse node
986  *
987  * RETURN:      None
988  *
989  * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
990  *
991  ******************************************************************************/
992 
993 static void
OpnDoLoadTable(ACPI_PARSE_OBJECT * Op)994 OpnDoLoadTable (
995     ACPI_PARSE_OBJECT       *Op)
996 {
997     ACPI_PARSE_OBJECT       *Next;
998 
999 
1000     /* Opcode is parent node */
1001     /* First child is the table signature */
1002 
1003     Next = Op->Asl.Child;
1004 
1005     /* Second child is the OEM ID*/
1006 
1007     Next = Next->Asl.Next;
1008 
1009     /* Third child is the OEM table ID */
1010 
1011     Next = Next->Asl.Next;
1012 
1013     /* Fourth child is the RootPath string */
1014 
1015     Next = Next->Asl.Next;
1016     if ((Next->Asl.ParseOpcode == PARSEOP_ZERO)           ||
1017         ((Next->Asl.Value.Integer == 0) &&
1018             ((Next->Asl.ParseOpcode == PARSEOP_INTEGER)   ||
1019              (Next->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
1020              (Next->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
1021              (Next->Asl.ParseOpcode == PARSEOP_DWORDCONST)||
1022              (Next->Asl.ParseOpcode == PARSEOP_QWORDCONST))))
1023     {
1024         Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
1025         Next->Asl.Value.String = "\\";
1026         Next->Asl.AmlLength = 2;
1027         OpcGenerateAmlOpcode (Next);
1028     }
1029 
1030 #ifdef ASL_FUTURE_IMPLEMENTATION
1031 
1032     /* TBD: NOT IMPLEMENTED */
1033     /* Fifth child is the [optional] ParameterPathString */
1034     /* Sixth child is the [optional] ParameterData */
1035 
1036     Next = Next->Asl.Next;
1037     if (Next->Asl.ParseOpcode == DEFAULT_ARG)
1038     {
1039         Next->Asl.AmlLength = 1;
1040         Next->Asl.ParseOpcode = ZERO;
1041         OpcGenerateAmlOpcode (Next);
1042     }
1043 
1044 
1045     Next = Next->Asl.Next;
1046     if (Next->Asl.ParseOpcode == DEFAULT_ARG)
1047     {
1048         Next->Asl.AmlLength = 1;
1049         Next->Asl.ParseOpcode = ZERO;
1050         OpcGenerateAmlOpcode (Next);
1051     }
1052 #endif
1053 }
1054 
1055 
1056 /*******************************************************************************
1057  *
1058  * FUNCTION:    OpnDoDefinitionBlock
1059  *
1060  * PARAMETERS:  Op        - The parent parse node
1061  *
1062  * RETURN:      None
1063  *
1064  * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
1065  *
1066  ******************************************************************************/
1067 
1068 static void
OpnDoDefinitionBlock(ACPI_PARSE_OBJECT * Op)1069 OpnDoDefinitionBlock (
1070     ACPI_PARSE_OBJECT       *Op)
1071 {
1072     ACPI_PARSE_OBJECT       *Child;
1073     ACPI_SIZE               Length;
1074     UINT32                  i;
1075     char                    *Filename;
1076     ACPI_STATUS             Status;
1077 
1078 
1079     /*
1080      * These nodes get stuffed into the table header. They are special
1081      * cased when the table is written to the output file.
1082      *
1083      * Mark all of these nodes as non-usable so they won't get output
1084      * as AML opcodes!
1085      */
1086 
1087     /* Get AML filename. Use it if non-null */
1088 
1089     Child = Op->Asl.Child;
1090     if (Child->Asl.Value.Buffer  &&
1091         *Child->Asl.Value.Buffer &&
1092         (AslGbl_UseDefaultAmlFilename))
1093     {
1094         /*
1095          * The walk may traverse multiple definition blocks. Switch files
1096          * to ensure that the correct files are manipulated.
1097          */
1098         FlSwitchFileSet (Op->Asl.Filename);
1099 
1100         /*
1101          * We will use the AML filename that is embedded in the source file
1102          * for the output filename.
1103          */
1104         Filename = UtLocalCacheCalloc (strlen (AslGbl_DirectoryPath) +
1105             strlen ((char *) Child->Asl.Value.Buffer) + 1);
1106 
1107         /* Prepend the current directory path */
1108 
1109         strcpy (Filename, AslGbl_DirectoryPath);
1110         strcat (Filename, (char *) Child->Asl.Value.Buffer);
1111 
1112         AslGbl_OutputFilenamePrefix = Filename;
1113         UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
1114 
1115         /*
1116          * Use the definition block file parameter instead of the input
1117          * filename. Since all files were opened previously, remove the
1118          * existing file and open a new file with the name of this
1119          * definition block parameter. Since AML code generation has yet
1120          * to happen, the previous file can be removed without any impacts.
1121          */
1122         FlCloseFile (ASL_FILE_AML_OUTPUT);
1123         FlDeleteFile (ASL_FILE_AML_OUTPUT);
1124         Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix);
1125         if (ACPI_FAILURE (Status))
1126         {
1127             AslError (ASL_ERROR, ASL_MSG_OUTPUT_FILE_OPEN, NULL, NULL);
1128             return;
1129         }
1130     }
1131 
1132     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1133 
1134     /* Signature */
1135 
1136     Child = Child->Asl.Next;
1137     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1138     if (Child->Asl.Value.String)
1139     {
1140         AslGbl_FilesList->TableSignature = Child->Asl.Value.String;
1141         AslGbl_TableSignature = Child->Asl.Value.String;
1142         if (strlen (AslGbl_TableSignature) != ACPI_NAMESEG_SIZE)
1143         {
1144             AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
1145                 "Length must be exactly 4 characters");
1146         }
1147 
1148         for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
1149         {
1150             if (!isalnum ((int) AslGbl_TableSignature[i]))
1151             {
1152                 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
1153                     "Contains non-alphanumeric characters");
1154             }
1155         }
1156     }
1157 
1158     /* Revision */
1159 
1160     Child = Child->Asl.Next;
1161     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1162 
1163     /*
1164      * We used the revision to set the integer width earlier
1165      */
1166 
1167     /* OEMID */
1168 
1169     Child = Child->Asl.Next;
1170     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1171     if (Child->Asl.Value.String &&
1172         strlen (Child->Asl.Value.String) > ACPI_OEM_ID_SIZE)
1173     {
1174         AslError (ASL_ERROR, ASL_MSG_OEM_ID, Child,
1175             "Length cannot exceed 6 characters");
1176     }
1177 
1178     /* OEM TableID */
1179 
1180     Child = Child->Asl.Next;
1181     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1182     if (Child->Asl.Value.String)
1183     {
1184         Length = strlen (Child->Asl.Value.String);
1185         if (Length > ACPI_OEM_TABLE_ID_SIZE)
1186         {
1187             AslError (ASL_ERROR, ASL_MSG_OEM_TABLE_ID, Child,
1188                 "Length cannot exceed 8 characters");
1189         }
1190 
1191         AslGbl_TableId = UtLocalCacheCalloc (Length + 1);
1192         strcpy (AslGbl_TableId, Child->Asl.Value.String);
1193         AslGbl_FilesList->TableId = AslGbl_TableId;
1194 
1195         /*
1196          * Convert anything non-alphanumeric to an underscore. This
1197          * allows us to use the TableID to generate unique C symbols.
1198          */
1199         for (i = 0; i < Length; i++)
1200         {
1201             if (!isalnum ((int) AslGbl_TableId[i]))
1202             {
1203                 AslGbl_TableId[i] = '_';
1204             }
1205         }
1206     }
1207 
1208     /* OEM Revision */
1209 
1210     Child = Child->Asl.Next;
1211     Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1212 }
1213 
1214 
1215 /*******************************************************************************
1216  *
1217  * FUNCTION:    UtGetArg
1218  *
1219  * PARAMETERS:  Op              - Get an argument for this op
1220  *              Argn            - Nth argument to get
1221  *
1222  * RETURN:      The argument (as an Op object). NULL if argument does not exist
1223  *
1224  * DESCRIPTION: Get the specified op's argument (peer)
1225  *
1226  ******************************************************************************/
1227 
1228 ACPI_PARSE_OBJECT *
UtGetArg(ACPI_PARSE_OBJECT * Op,UINT32 Argn)1229 UtGetArg (
1230     ACPI_PARSE_OBJECT       *Op,
1231     UINT32                  Argn)
1232 {
1233     ACPI_PARSE_OBJECT       *Arg = NULL;
1234 
1235 
1236     /* Get the requested argument object */
1237 
1238     Arg = Op->Asl.Child;
1239     while (Arg && Argn)
1240     {
1241         Argn--;
1242         Arg = Arg->Asl.Next;
1243     }
1244 
1245     return (Arg);
1246 }
1247 
1248 
1249 /*******************************************************************************
1250  *
1251  * FUNCTION:    OpnAttachNameToNode
1252  *
1253  * PARAMETERS:  Op        - The parent parse node
1254  *
1255  * RETURN:      None
1256  *
1257  * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1258  *              argument list and attach it to the parent node so that we
1259  *              can get to it quickly later.
1260  *
1261  ******************************************************************************/
1262 
1263 static void
OpnAttachNameToNode(ACPI_PARSE_OBJECT * Op)1264 OpnAttachNameToNode (
1265     ACPI_PARSE_OBJECT       *Op)
1266 {
1267     ACPI_PARSE_OBJECT       *Child = NULL;
1268 
1269 
1270     switch (Op->Asl.AmlOpcode)
1271     {
1272     case AML_DATA_REGION_OP:
1273     case AML_DEVICE_OP:
1274     case AML_EVENT_OP:
1275     case AML_EXTERNAL_OP:
1276     case AML_METHOD_OP:
1277     case AML_MUTEX_OP:
1278     case AML_REGION_OP:
1279     case AML_POWER_RESOURCE_OP:
1280     case AML_PROCESSOR_OP:
1281     case AML_THERMAL_ZONE_OP:
1282     case AML_NAME_OP:
1283     case AML_SCOPE_OP:
1284 
1285         Child = UtGetArg (Op, 0);
1286         break;
1287 
1288     case AML_ALIAS_OP:
1289 
1290         Child = UtGetArg (Op, 1);
1291         break;
1292 
1293     case AML_CREATE_BIT_FIELD_OP:
1294     case AML_CREATE_BYTE_FIELD_OP:
1295     case AML_CREATE_WORD_FIELD_OP:
1296     case AML_CREATE_DWORD_FIELD_OP:
1297     case AML_CREATE_QWORD_FIELD_OP:
1298 
1299         Child = UtGetArg (Op, 2);
1300         break;
1301 
1302     case AML_CREATE_FIELD_OP:
1303 
1304         Child = UtGetArg (Op, 3);
1305         break;
1306 
1307     case AML_BANK_FIELD_OP:
1308     case AML_INDEX_FIELD_OP:
1309     case AML_FIELD_OP:
1310 
1311         return;
1312 
1313     default:
1314 
1315         return;
1316     }
1317 
1318     if (Child)
1319     {
1320         UtAttachNamepathToOwner (Op, Child);
1321     }
1322 }
1323 
1324 
1325 /*******************************************************************************
1326  *
1327  * FUNCTION:    OpnGenerateAmlOperands
1328  *
1329  * PARAMETERS:  Op        - The parent parse node
1330  *
1331  * RETURN:      None
1332  *
1333  * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1334  *              complex AML opcodes require processing of the child nodes
1335  *              (arguments/operands).
1336  *
1337  ******************************************************************************/
1338 
1339 void
OpnGenerateAmlOperands(ACPI_PARSE_OBJECT * Op)1340 OpnGenerateAmlOperands (
1341     ACPI_PARSE_OBJECT       *Op)
1342 {
1343 
1344 
1345     if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
1346     {
1347         return;
1348     }
1349 
1350     switch (Op->Asl.ParseOpcode)
1351     {
1352     case PARSEOP_DEFINITION_BLOCK:
1353 
1354         OpnDoDefinitionBlock (Op);
1355         break;
1356 
1357     case PARSEOP_METHOD:
1358 
1359         OpnDoMethod (Op);
1360         break;
1361 
1362     case PARSEOP_MUTEX:
1363 
1364         OpnDoMutex (Op);
1365         break;
1366 
1367     case PARSEOP_FIELD:
1368 
1369         OpnDoField (Op);
1370         break;
1371 
1372     case PARSEOP_INDEXFIELD:
1373 
1374         OpnDoIndexField (Op);
1375         break;
1376 
1377     case PARSEOP_BANKFIELD:
1378 
1379         OpnDoBankField (Op);
1380         break;
1381 
1382     case PARSEOP_BUFFER:
1383 
1384         OpnDoBuffer (Op);
1385         break;
1386 
1387     case PARSEOP_LOADTABLE:
1388 
1389         OpnDoLoadTable (Op);
1390         break;
1391 
1392     case PARSEOP_OPERATIONREGION:
1393 
1394         OpnDoRegion (Op);
1395         break;
1396 
1397     case PARSEOP_RESOURCETEMPLATE:
1398 
1399         RsDoResourceTemplate (Op);
1400         break;
1401 
1402     case PARSEOP_NAMESEG:
1403     case PARSEOP_NAMESTRING:
1404     case PARSEOP_METHODCALL:
1405     case PARSEOP_STRING_LITERAL:
1406     default:
1407 
1408         break;
1409     }
1410 
1411     /* TBD: move */
1412 
1413     OpnAttachNameToNode (Op);
1414 }
1415