i386/identcpu.c: Add VIA Nano support
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / compiler / aslopcodes.c
1
2 /******************************************************************************
3  *
4  * Module Name: aslopcode - AML opcode generation
5  *              $Revision: 1.73 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117
118
119 #include "aslcompiler.h"
120 #include "aslcompiler.y.h"
121 #include "amlcode.h"
122
123 #define _COMPONENT          ACPI_COMPILER
124         ACPI_MODULE_NAME    ("aslopcodes")
125
126
127 /* UUID support */
128
129 static UINT8 OpcMapToUUID[16] =
130 {
131     6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34
132 };
133
134 /* Local prototypes */
135
136 static void
137 OpcDoAccessAs (
138     ACPI_PARSE_OBJECT       *Op);
139
140 static void
141 OpcDoUnicode (
142     ACPI_PARSE_OBJECT       *Op);
143
144 static void
145 OpcDoEisaId (
146     ACPI_PARSE_OBJECT       *Op);
147
148 static void
149 OpcDoUuId (
150     ACPI_PARSE_OBJECT       *Op);
151
152
153 /*******************************************************************************
154  *
155  * FUNCTION:    OpcAmlOpcodeUpdateWalk
156  *
157  * PARAMETERS:  ASL_WALK_CALLBACK
158  *
159  * RETURN:      Status
160  *
161  * DESCRIPTION: Opcode update walk, ascending callback
162  *
163  ******************************************************************************/
164
165 ACPI_STATUS
166 OpcAmlOpcodeUpdateWalk (
167     ACPI_PARSE_OBJECT       *Op,
168     UINT32                  Level,
169     void                    *Context)
170 {
171
172     /*
173      * Handle the Package() case where the actual opcode cannot be determined
174      * until the PackageLength operand has been folded and minimized.
175      * (PackageOp versus VarPackageOp)
176      *
177      * This is (as of ACPI 3.0) the only case where the AML opcode can change
178      * based upon the value of a parameter.
179      *
180      * The parser always inserts a VarPackage opcode, which can possibly be
181      * optimized to a Package opcode.
182      */
183     if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)
184     {
185         OpnDoPackage (Op);
186     }
187
188     return (AE_OK);
189 }
190
191
192 /*******************************************************************************
193  *
194  * FUNCTION:    OpcAmlOpcodeWalk
195  *
196  * PARAMETERS:  ASL_WALK_CALLBACK
197  *
198  * RETURN:      Status
199  *
200  * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
201  *              operands.
202  *
203  ******************************************************************************/
204
205 ACPI_STATUS
206 OpcAmlOpcodeWalk (
207     ACPI_PARSE_OBJECT       *Op,
208     UINT32                  Level,
209     void                    *Context)
210 {
211
212     TotalParseNodes++;
213
214     OpcGenerateAmlOpcode (Op);
215     OpnGenerateAmlOperands (Op);
216     return (AE_OK);
217 }
218
219
220 /*******************************************************************************
221  *
222  * FUNCTION:    OpcGetIntegerWidth
223  *
224  * PARAMETERS:  Op          - DEFINITION BLOCK op
225  *
226  * RETURN:      none
227  *
228  * DESCRIPTION: Extract integer width from the table revision
229  *
230  ******************************************************************************/
231
232 void
233 OpcGetIntegerWidth (
234     ACPI_PARSE_OBJECT       *Op)
235 {
236     ACPI_PARSE_OBJECT       *Child;
237
238
239     if (!Op)
240     {
241         return;
242     }
243
244     if (Gbl_RevisionOverride)
245     {
246         AcpiUtSetIntegerWidth (Gbl_RevisionOverride);
247     }
248     else
249     {
250         Child = Op->Asl.Child;
251         Child = Child->Asl.Next;
252         Child = Child->Asl.Next;
253
254         /* Use the revision to set the integer width */
255
256         AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
257     }
258 }
259
260
261 /*******************************************************************************
262  *
263  * FUNCTION:    OpcSetOptimalIntegerSize
264  *
265  * PARAMETERS:  Op        - A parse tree node
266  *
267  * RETURN:      Integer width, in bytes.  Also sets the node AML opcode to the
268  *              optimal integer AML prefix opcode.
269  *
270  * DESCRIPTION: Determine the optimal AML encoding of an integer.  All leading
271  *              zeros can be truncated to squeeze the integer into the
272  *              minimal number of AML bytes.
273  *
274  ******************************************************************************/
275
276 UINT32
277 OpcSetOptimalIntegerSize (
278     ACPI_PARSE_OBJECT       *Op)
279 {
280
281 #if 0
282     /*
283      * TBD: - we don't want to optimize integers in the block header, but the
284      * code below does not work correctly.
285      */
286     if (Op->Asl.Parent &&
287         Op->Asl.Parent->Asl.Parent &&
288        (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK))
289     {
290         return 0;
291     }
292 #endif
293
294     /*
295      * Check for the special AML integers first - Zero, One, Ones.
296      * These are single-byte opcodes that are the smallest possible
297      * representation of an integer.
298      *
299      * This optimization is optional.
300      */
301     if (Gbl_IntegerOptimizationFlag)
302     {
303         switch (Op->Asl.Value.Integer)
304         {
305         case 0:
306
307             Op->Asl.AmlOpcode = AML_ZERO_OP;
308             AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
309                 Op, "Zero");
310             return 1;
311
312         case 1:
313
314             Op->Asl.AmlOpcode = AML_ONE_OP;
315             AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
316                 Op, "One");
317             return 1;
318
319         case ACPI_UINT32_MAX:
320
321             /* Check for table integer width (32 or 64) */
322
323             if (AcpiGbl_IntegerByteWidth == 4)
324             {
325                 Op->Asl.AmlOpcode = AML_ONES_OP;
326                 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
327                     Op, "Ones");
328                 return 1;
329             }
330             break;
331
332         case ACPI_INTEGER_MAX:
333
334             /* Check for table integer width (32 or 64) */
335
336             if (AcpiGbl_IntegerByteWidth == 8)
337             {
338                 Op->Asl.AmlOpcode = AML_ONES_OP;
339                 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
340                     Op, "Ones");
341                 return 1;
342             }
343             break;
344
345         default:
346             break;
347         }
348     }
349
350     /* Find the best fit using the various AML integer prefixes */
351
352     if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
353     {
354         Op->Asl.AmlOpcode = AML_BYTE_OP;
355         return 1;
356     }
357     if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
358     {
359         Op->Asl.AmlOpcode = AML_WORD_OP;
360         return 2;
361     }
362     if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
363     {
364         Op->Asl.AmlOpcode = AML_DWORD_OP;
365         return 4;
366     }
367     else
368     {
369         if (AcpiGbl_IntegerByteWidth == 4)
370         {
371             AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH,
372                 Op, NULL);
373
374             if (!Gbl_IgnoreErrors)
375             {
376                 /* Truncate the integer to 32-bit */
377                 Op->Asl.AmlOpcode = AML_DWORD_OP;
378                 return 4;
379             }
380         }
381
382         Op->Asl.AmlOpcode = AML_QWORD_OP;
383         return 8;
384     }
385 }
386
387
388 /*******************************************************************************
389  *
390  * FUNCTION:    OpcDoAccessAs
391  *
392  * PARAMETERS:  Op        - Parse node
393  *
394  * RETURN:      None
395  *
396  * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
397  *
398  ******************************************************************************/
399
400 static void
401 OpcDoAccessAs (
402     ACPI_PARSE_OBJECT       *Op)
403 {
404     ACPI_PARSE_OBJECT       *Next;
405
406
407     Op->Asl.AmlOpcodeLength = 1;
408     Next = Op->Asl.Child;
409
410     /* First child is the access type */
411
412     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
413     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
414
415     /* Second child is the optional access attribute */
416
417     Next = Next->Asl.Next;
418     if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
419     {
420         Next->Asl.Value.Integer = 0;
421     }
422     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
423     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
424 }
425
426
427 /*******************************************************************************
428  *
429  * FUNCTION:    OpcDoUnicode
430  *
431  * PARAMETERS:  Op        - Parse node
432  *
433  * RETURN:      None
434  *
435  * DESCRIPTION: Implement the UNICODE ASL "macro".  Convert the input string
436  *              to a unicode buffer.  There is no Unicode AML opcode.
437  *
438  * Note:  The Unicode string is 16 bits per character, no leading signature,
439  *        with a 16-bit terminating NULL.
440  *
441  ******************************************************************************/
442
443 static void
444 OpcDoUnicode (
445     ACPI_PARSE_OBJECT       *Op)
446 {
447     ACPI_PARSE_OBJECT       *InitializerOp;
448     UINT32                  Length;
449     UINT32                  Count;
450     UINT32                  i;
451     UINT8                   *AsciiString;
452     UINT16                  *UnicodeString;
453     ACPI_PARSE_OBJECT       *BufferLengthOp;
454
455
456     /* Change op into a buffer object */
457
458     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
459     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
460     UtSetParseOpName (Op);
461
462     /* Buffer Length is first, followed by the string */
463
464     BufferLengthOp = Op->Asl.Child;
465     InitializerOp = BufferLengthOp->Asl.Next;
466
467     AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
468
469     /* Create a new buffer for the Unicode string */
470
471     Count = strlen (InitializerOp->Asl.Value.String) + 1;
472     Length = Count * sizeof (UINT16);
473     UnicodeString = UtLocalCalloc (Length);
474
475     /* Convert to Unicode string (including null terminator) */
476
477     for (i = 0; i < Count; i++)
478     {
479         UnicodeString[i] = (UINT16) AsciiString[i];
480     }
481
482     /*
483      * Just set the buffer size node to be the buffer length, regardless
484      * of whether it was previously an integer or a default_arg placeholder
485      */
486     BufferLengthOp->Asl.ParseOpcode   = PARSEOP_INTEGER;
487     BufferLengthOp->Asl.AmlOpcode     = AML_DWORD_OP;
488     BufferLengthOp->Asl.Value.Integer = Length;
489     UtSetParseOpName (BufferLengthOp);
490
491     (void) OpcSetOptimalIntegerSize (BufferLengthOp);
492
493     /* The Unicode string is a raw data buffer */
494
495     InitializerOp->Asl.Value.Buffer   = (UINT8 *) UnicodeString;
496     InitializerOp->Asl.AmlOpcode      = AML_RAW_DATA_BUFFER;
497     InitializerOp->Asl.AmlLength      = Length;
498     InitializerOp->Asl.ParseOpcode    = PARSEOP_RAW_DATA;
499     InitializerOp->Asl.Child          = NULL;
500     UtSetParseOpName (InitializerOp);
501 }
502
503
504 /*******************************************************************************
505  *
506  * FUNCTION:    OpcDoEisaId
507  *
508  * PARAMETERS:  Op        - Parse node
509  *
510  * RETURN:      None
511  *
512  * DESCRIPTION: Convert a string EISA ID to numeric representation.  See the
513  *              Pnp BIOS Specification for details.  Here is an excerpt:
514  *
515  *              A seven character ASCII representation of the product
516  *              identifier compressed into a 32-bit identifier.  The seven
517  *              character ID consists of a three character manufacturer code,
518  *              a three character hexadecimal product identifier, and a one
519  *              character hexadecimal revision number.  The manufacturer code
520  *              is a 3 uppercase character code that is compressed into 3 5-bit
521  *              values as follows:
522  *                  1) Find hex ASCII value for each letter
523  *                  2) Subtract 40h from each ASCII value
524  *                  3) Retain 5 least signficant bits for each letter by
525  *                     discarding upper 3 bits because they are always 0.
526  *                  4) Compressed code = concatenate 0 and the 3 5-bit values
527  *
528  *              The format of the compressed product identifier is as follows:
529  *              Byte 0: Bit 7       - Reserved (0)
530  *                      Bits 6-2:   - 1st character of compressed mfg code
531  *                      Bits 1-0    - Upper 2 bits of 2nd character of mfg code
532  *              Byte 1: Bits 7-5    - Lower 3 bits of 2nd character of mfg code
533  *                      Bits 4-0    - 3rd character of mfg code
534  *              Byte 2: Bits 7-4    - 1st hex digit of product number
535  *                      Bits 3-0    - 2nd hex digit of product number
536  *              Byte 3: Bits 7-4    - 3st hex digit of product number
537  *                      Bits 3-0    - Hex digit of the revision number
538  *
539  ******************************************************************************/
540
541 static void
542 OpcDoEisaId (
543     ACPI_PARSE_OBJECT       *Op)
544 {
545     UINT32                  EisaId = 0;
546     UINT32                  BigEndianId;
547     char                    *InString;
548     ACPI_STATUS             Status = AE_OK;
549     ACPI_NATIVE_UINT        i;
550
551
552     InString = (char *) Op->Asl.Value.String;
553
554     /*
555      * The EISAID string must be exactly 7 characters and of the form
556      * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
557      */
558     if (ACPI_STRLEN (InString) != 7)
559     {
560         Status = AE_BAD_PARAMETER;
561     }
562     else
563     {
564         /* Check all 7 characters for correct format */
565
566         for (i = 0; i < 7; i++)
567         {
568             /* First 3 characters must be uppercase letters */
569
570             if (i < 3)
571             {
572                 if (!isupper (InString[i]))
573                 {
574                     Status = AE_BAD_PARAMETER;
575                 }
576             }
577
578             /* Last 4 characters must be hex digits */
579
580             else if (!isxdigit (InString[i]))
581             {
582                 Status = AE_BAD_PARAMETER;
583             }
584         }
585     }
586
587     if (ACPI_FAILURE (Status))
588     {
589         AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
590     }
591     else
592     {
593         /* Create ID big-endian first (bits are contiguous) */
594
595         BigEndianId =
596             (UINT32) (InString[0] - 0x40) << 26 |
597             (UINT32) (InString[1] - 0x40) << 21 |
598             (UINT32) (InString[2] - 0x40) << 16 |
599
600             (UtHexCharToValue (InString[3])) << 12 |
601             (UtHexCharToValue (InString[4])) << 8  |
602             (UtHexCharToValue (InString[5])) << 4  |
603              UtHexCharToValue (InString[6]);
604
605         /* Swap to little-endian to get final ID (see function header) */
606
607         EisaId = AcpiUtDwordByteSwap (BigEndianId);
608     }
609
610     /*
611      * Morph the Op into an integer, regardless of whether there
612      * was an error in the EISAID string
613      */
614     Op->Asl.Value.Integer = EisaId;
615
616     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
617     Op->Asl.ParseOpcode = PARSEOP_INTEGER;
618     (void) OpcSetOptimalIntegerSize (Op);
619
620     /* Op is now an integer */
621
622     UtSetParseOpName (Op);
623 }
624
625
626 /*******************************************************************************
627  *
628  * FUNCTION:    OpcDoUiId
629  *
630  * PARAMETERS:  Op        - Parse node
631  *
632  * RETURN:      None
633  *
634  * DESCRIPTION: Convert UUID string to 16-byte buffer
635  *
636  ******************************************************************************/
637
638 static void
639 OpcDoUuId (
640     ACPI_PARSE_OBJECT       *Op)
641 {
642     char                    *InString;
643     char                    *Buffer;
644     ACPI_STATUS             Status = AE_OK;
645     ACPI_NATIVE_UINT        i;
646     ACPI_PARSE_OBJECT       *NewOp;
647
648
649     InString = (char *) Op->Asl.Value.String;
650
651     if (ACPI_STRLEN (InString) != 36)
652     {
653         Status = AE_BAD_PARAMETER;
654     }
655     else
656     {
657         /* Check all 36 characters for correct format */
658
659         for (i = 0; i < 36; i++)
660         {
661             if ((i == 8) || (i == 13) || (i == 18) || (i == 23))
662             {
663                 if (InString[i] != '-')
664                 {
665                     Status = AE_BAD_PARAMETER;
666                 }
667             }
668             else
669             {
670                 if (!isxdigit (InString[i]))
671                 {
672                     Status = AE_BAD_PARAMETER;
673                 }
674             }
675         }
676     }
677
678     Buffer = UtLocalCalloc (16);
679
680     if (ACPI_FAILURE (Status))
681     {
682         AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String);
683     }
684     else for (i = 0; i < 16; i++)
685     {
686         Buffer[i]  = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4);
687         Buffer[i] |= (char)  UtHexCharToValue (InString[OpcMapToUUID[i] + 1]);
688     }
689
690     /* Change Op to a Buffer */
691
692     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
693     Op->Common.AmlOpcode = AML_BUFFER_OP;
694
695     /* Disable further optimization */
696
697     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
698     UtSetParseOpName (Op);
699
700     /* Child node is the buffer length */
701
702     NewOp = TrAllocateNode (PARSEOP_INTEGER);
703
704     NewOp->Asl.AmlOpcode     = AML_BYTE_OP;
705     NewOp->Asl.Value.Integer = 16;
706     NewOp->Asl.Parent        = Op;
707
708     Op->Asl.Child = NewOp;
709     Op = NewOp;
710
711     /* Peer to the child is the raw buffer data */
712
713     NewOp = TrAllocateNode (PARSEOP_RAW_DATA);
714     NewOp->Asl.AmlOpcode     = AML_RAW_DATA_BUFFER;
715     NewOp->Asl.AmlLength     = 16;
716     NewOp->Asl.Value.String  = (char *) Buffer;
717     NewOp->Asl.Parent        = Op->Asl.Parent;
718
719     Op->Asl.Next = NewOp;
720 }
721
722
723 /*******************************************************************************
724  *
725  * FUNCTION:    OpcGenerateAmlOpcode
726  *
727  * PARAMETERS:  Op        - Parse node
728  *
729  * RETURN:      None
730  *
731  * DESCRIPTION: Generate the AML opcode associated with the node and its
732  *              parse (lex/flex) keyword opcode.  Essentially implements
733  *              a mapping between the parse opcodes and the actual AML opcodes.
734  *
735  ******************************************************************************/
736
737 void
738 OpcGenerateAmlOpcode (
739     ACPI_PARSE_OBJECT       *Op)
740 {
741
742     UINT16                  Index;
743
744
745     Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
746
747     Op->Asl.AmlOpcode     = AslKeywordMapping[Index].AmlOpcode;
748     Op->Asl.AcpiBtype     = AslKeywordMapping[Index].AcpiBtype;
749     Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
750
751     if (!Op->Asl.Value.Integer)
752     {
753         Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
754     }
755
756     /* Special handling for some opcodes */
757
758     switch (Op->Asl.ParseOpcode)
759     {
760     case PARSEOP_INTEGER:
761         /*
762          * Set the opcode based on the size of the integer
763          */
764         (void) OpcSetOptimalIntegerSize (Op);
765         break;
766
767     case PARSEOP_OFFSET:
768
769         Op->Asl.AmlOpcodeLength = 1;
770         break;
771
772     case PARSEOP_ACCESSAS:
773
774         OpcDoAccessAs (Op);
775         break;
776
777     case PARSEOP_EISAID:
778
779         OpcDoEisaId (Op);
780         break;
781
782     case PARSEOP_TOUUID:
783
784         OpcDoUuId (Op);
785         break;
786
787     case PARSEOP_UNICODE:
788
789         OpcDoUnicode (Op);
790         break;
791
792     case PARSEOP_INCLUDE:
793
794         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
795         Gbl_HasIncludeFiles = TRUE;
796         break;
797
798     case PARSEOP_EXTERNAL:
799
800         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
801         Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
802         break;
803
804     default:
805         /* Nothing to do for other opcodes */
806         break;
807     }
808
809     return;
810 }
811
812