xref: /freebsd/sys/contrib/dev/acpica/compiler/aslopcodes.c (revision fba7fc7e34e95963b681b882698b951b35d1ba48)
153289f6aSNate Lawson 
253289f6aSNate Lawson /******************************************************************************
353289f6aSNate Lawson  *
453289f6aSNate Lawson  * Module Name: aslopcode - AML opcode generation
5fba7fc7eSJung-uk Kim  *              $Revision: 1.71 $
653289f6aSNate Lawson  *
753289f6aSNate Lawson  *****************************************************************************/
853289f6aSNate Lawson 
953289f6aSNate Lawson /******************************************************************************
1053289f6aSNate Lawson  *
1153289f6aSNate Lawson  * 1. Copyright Notice
1253289f6aSNate Lawson  *
13fba7fc7eSJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
1453289f6aSNate Lawson  * All rights reserved.
1553289f6aSNate Lawson  *
1653289f6aSNate Lawson  * 2. License
1753289f6aSNate Lawson  *
1853289f6aSNate Lawson  * 2.1. This is your license from Intel Corp. under its intellectual property
1953289f6aSNate Lawson  * rights.  You may have additional license terms from the party that provided
2053289f6aSNate Lawson  * you this software, covering your right to use that party's intellectual
2153289f6aSNate Lawson  * property rights.
2253289f6aSNate Lawson  *
2353289f6aSNate Lawson  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2453289f6aSNate Lawson  * copy of the source code appearing in this file ("Covered Code") an
2553289f6aSNate Lawson  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2653289f6aSNate Lawson  * base code distributed originally by Intel ("Original Intel Code") to copy,
2753289f6aSNate Lawson  * make derivatives, distribute, use and display any portion of the Covered
2853289f6aSNate Lawson  * Code in any form, with the right to sublicense such rights; and
2953289f6aSNate Lawson  *
3053289f6aSNate Lawson  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3153289f6aSNate Lawson  * license (with the right to sublicense), under only those claims of Intel
3253289f6aSNate Lawson  * patents that are infringed by the Original Intel Code, to make, use, sell,
3353289f6aSNate Lawson  * offer to sell, and import the Covered Code and derivative works thereof
3453289f6aSNate Lawson  * solely to the minimum extent necessary to exercise the above copyright
3553289f6aSNate Lawson  * license, and in no event shall the patent license extend to any additions
3653289f6aSNate Lawson  * to or modifications of the Original Intel Code.  No other license or right
3753289f6aSNate Lawson  * is granted directly or by implication, estoppel or otherwise;
3853289f6aSNate Lawson  *
3953289f6aSNate Lawson  * The above copyright and patent license is granted only if the following
4053289f6aSNate Lawson  * conditions are met:
4153289f6aSNate Lawson  *
4253289f6aSNate Lawson  * 3. Conditions
4353289f6aSNate Lawson  *
4453289f6aSNate Lawson  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4553289f6aSNate Lawson  * Redistribution of source code of any substantial portion of the Covered
4653289f6aSNate Lawson  * Code or modification with rights to further distribute source must include
4753289f6aSNate Lawson  * the above Copyright Notice, the above License, this list of Conditions,
4853289f6aSNate Lawson  * and the following Disclaimer and Export Compliance provision.  In addition,
4953289f6aSNate Lawson  * Licensee must cause all Covered Code to which Licensee contributes to
5053289f6aSNate Lawson  * contain a file documenting the changes Licensee made to create that Covered
5153289f6aSNate Lawson  * Code and the date of any change.  Licensee must include in that file the
5253289f6aSNate Lawson  * documentation of any changes made by any predecessor Licensee.  Licensee
5353289f6aSNate Lawson  * must include a prominent statement that the modification is derived,
5453289f6aSNate Lawson  * directly or indirectly, from Original Intel Code.
5553289f6aSNate Lawson  *
5653289f6aSNate Lawson  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5753289f6aSNate Lawson  * Redistribution of source code of any substantial portion of the Covered
5853289f6aSNate Lawson  * Code or modification without rights to further distribute source must
5953289f6aSNate Lawson  * include the following Disclaimer and Export Compliance provision in the
6053289f6aSNate Lawson  * documentation and/or other materials provided with distribution.  In
6153289f6aSNate Lawson  * addition, Licensee may not authorize further sublicense of source of any
6253289f6aSNate Lawson  * portion of the Covered Code, and must include terms to the effect that the
6353289f6aSNate Lawson  * license from Licensee to its licensee is limited to the intellectual
6453289f6aSNate Lawson  * property embodied in the software Licensee provides to its licensee, and
6553289f6aSNate Lawson  * not to intellectual property embodied in modifications its licensee may
6653289f6aSNate Lawson  * make.
6753289f6aSNate Lawson  *
6853289f6aSNate Lawson  * 3.3. Redistribution of Executable. Redistribution in executable form of any
6953289f6aSNate Lawson  * substantial portion of the Covered Code or modification must reproduce the
7053289f6aSNate Lawson  * above Copyright Notice, and the following Disclaimer and Export Compliance
7153289f6aSNate Lawson  * provision in the documentation and/or other materials provided with the
7253289f6aSNate Lawson  * distribution.
7353289f6aSNate Lawson  *
7453289f6aSNate Lawson  * 3.4. Intel retains all right, title, and interest in and to the Original
7553289f6aSNate Lawson  * Intel Code.
7653289f6aSNate Lawson  *
7753289f6aSNate Lawson  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7853289f6aSNate Lawson  * Intel shall be used in advertising or otherwise to promote the sale, use or
7953289f6aSNate Lawson  * other dealings in products derived from or relating to the Covered Code
8053289f6aSNate Lawson  * without prior written authorization from Intel.
8153289f6aSNate Lawson  *
8253289f6aSNate Lawson  * 4. Disclaimer and Export Compliance
8353289f6aSNate Lawson  *
8453289f6aSNate Lawson  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8553289f6aSNate Lawson  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8653289f6aSNate Lawson  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8753289f6aSNate Lawson  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8853289f6aSNate Lawson  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8953289f6aSNate Lawson  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9053289f6aSNate Lawson  * PARTICULAR PURPOSE.
9153289f6aSNate Lawson  *
9253289f6aSNate Lawson  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9353289f6aSNate Lawson  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9453289f6aSNate Lawson  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9553289f6aSNate Lawson  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9653289f6aSNate Lawson  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9753289f6aSNate Lawson  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9853289f6aSNate Lawson  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9953289f6aSNate Lawson  * LIMITED REMEDY.
10053289f6aSNate Lawson  *
10153289f6aSNate Lawson  * 4.3. Licensee shall not export, either directly or indirectly, any of this
10253289f6aSNate Lawson  * software or system incorporating such software without first obtaining any
10353289f6aSNate Lawson  * required license or other approval from the U. S. Department of Commerce or
10453289f6aSNate Lawson  * any other agency or department of the United States Government.  In the
10553289f6aSNate Lawson  * event Licensee exports any such software from the United States or
10653289f6aSNate Lawson  * re-exports any such software from a foreign destination, Licensee shall
10753289f6aSNate Lawson  * ensure that the distribution and export/re-export of the software is in
10853289f6aSNate Lawson  * compliance with all laws, regulations, orders, or other restrictions of the
10953289f6aSNate Lawson  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11053289f6aSNate Lawson  * any of its subsidiaries will export/re-export any technical data, process,
11153289f6aSNate Lawson  * software, or service, directly or indirectly, to any country for which the
11253289f6aSNate Lawson  * United States government or any agency thereof requires an export license,
11353289f6aSNate Lawson  * other governmental approval, or letter of assurance, without first obtaining
11453289f6aSNate Lawson  * such license, approval or letter.
11553289f6aSNate Lawson  *
11653289f6aSNate Lawson  *****************************************************************************/
11753289f6aSNate Lawson 
11853289f6aSNate Lawson 
119fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
12053289f6aSNate Lawson #include "aslcompiler.y.h"
121fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/amlcode.h>
12253289f6aSNate Lawson 
12353289f6aSNate Lawson #define _COMPONENT          ACPI_COMPILER
12453289f6aSNate Lawson         ACPI_MODULE_NAME    ("aslopcodes")
12553289f6aSNate Lawson 
12653289f6aSNate Lawson 
127fba7fc7eSJung-uk Kim /* UUID support */
128fba7fc7eSJung-uk Kim 
129fba7fc7eSJung-uk Kim static UINT8 OpcMapToUUID[16] =
130fba7fc7eSJung-uk Kim {
131fba7fc7eSJung-uk Kim     6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34
132fba7fc7eSJung-uk Kim };
133fba7fc7eSJung-uk Kim 
134fba7fc7eSJung-uk Kim /* Local prototypes */
135fba7fc7eSJung-uk Kim 
136fba7fc7eSJung-uk Kim static void
137fba7fc7eSJung-uk Kim OpcDoAccessAs (
138fba7fc7eSJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
139fba7fc7eSJung-uk Kim 
140fba7fc7eSJung-uk Kim static void
141fba7fc7eSJung-uk Kim OpcDoUnicode (
142fba7fc7eSJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
143fba7fc7eSJung-uk Kim 
144fba7fc7eSJung-uk Kim static void
145fba7fc7eSJung-uk Kim OpcDoEisaId (
146fba7fc7eSJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
147fba7fc7eSJung-uk Kim 
148fba7fc7eSJung-uk Kim static void
149fba7fc7eSJung-uk Kim OpcDoUuId (
150fba7fc7eSJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
151fba7fc7eSJung-uk Kim 
152fba7fc7eSJung-uk Kim 
153fba7fc7eSJung-uk Kim /*******************************************************************************
154fba7fc7eSJung-uk Kim  *
155fba7fc7eSJung-uk Kim  * FUNCTION:    OpcAmlOpcodeUpdateWalk
156fba7fc7eSJung-uk Kim  *
157fba7fc7eSJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
158fba7fc7eSJung-uk Kim  *
159fba7fc7eSJung-uk Kim  * RETURN:      Status
160fba7fc7eSJung-uk Kim  *
161fba7fc7eSJung-uk Kim  * DESCRIPTION: Opcode update walk, ascending callback
162fba7fc7eSJung-uk Kim  *
163fba7fc7eSJung-uk Kim  ******************************************************************************/
164fba7fc7eSJung-uk Kim 
165fba7fc7eSJung-uk Kim ACPI_STATUS
166fba7fc7eSJung-uk Kim OpcAmlOpcodeUpdateWalk (
167fba7fc7eSJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
168fba7fc7eSJung-uk Kim     UINT32                  Level,
169fba7fc7eSJung-uk Kim     void                    *Context)
170fba7fc7eSJung-uk Kim {
171fba7fc7eSJung-uk Kim 
172fba7fc7eSJung-uk Kim     /*
173fba7fc7eSJung-uk Kim      * Handle the Package() case where the actual opcode cannot be determined
174fba7fc7eSJung-uk Kim      * until the PackageLength operand has been folded and minimized.
175fba7fc7eSJung-uk Kim      * (PackageOp versus VarPackageOp)
176fba7fc7eSJung-uk Kim      *
177fba7fc7eSJung-uk Kim      * This is (as of ACPI 3.0) the only case where the AML opcode can change
178fba7fc7eSJung-uk Kim      * based upon the value of a parameter.
179fba7fc7eSJung-uk Kim      *
180fba7fc7eSJung-uk Kim      * The parser always inserts a VarPackage opcode, which can possibly be
181fba7fc7eSJung-uk Kim      * optimized to a Package opcode.
182fba7fc7eSJung-uk Kim      */
183fba7fc7eSJung-uk Kim     if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)
184fba7fc7eSJung-uk Kim     {
185fba7fc7eSJung-uk Kim         OpnDoPackage (Op);
186fba7fc7eSJung-uk Kim     }
187fba7fc7eSJung-uk Kim 
188fba7fc7eSJung-uk Kim     return (AE_OK);
189fba7fc7eSJung-uk Kim }
190fba7fc7eSJung-uk Kim 
191fba7fc7eSJung-uk Kim 
19253289f6aSNate Lawson /*******************************************************************************
19353289f6aSNate Lawson  *
19453289f6aSNate Lawson  * FUNCTION:    OpcAmlOpcodeWalk
19553289f6aSNate Lawson  *
19653289f6aSNate Lawson  * PARAMETERS:  ASL_WALK_CALLBACK
19753289f6aSNate Lawson  *
19853289f6aSNate Lawson  * RETURN:      Status
19953289f6aSNate Lawson  *
20053289f6aSNate Lawson  * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
20153289f6aSNate Lawson  *              operands.
20253289f6aSNate Lawson  *
20353289f6aSNate Lawson  ******************************************************************************/
20453289f6aSNate Lawson 
20553289f6aSNate Lawson ACPI_STATUS
20653289f6aSNate Lawson OpcAmlOpcodeWalk (
20753289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op,
20853289f6aSNate Lawson     UINT32                  Level,
20953289f6aSNate Lawson     void                    *Context)
21053289f6aSNate Lawson {
21153289f6aSNate Lawson 
21253289f6aSNate Lawson     TotalParseNodes++;
21353289f6aSNate Lawson 
21453289f6aSNate Lawson     OpcGenerateAmlOpcode (Op);
21553289f6aSNate Lawson     OpnGenerateAmlOperands (Op);
21653289f6aSNate Lawson 
21753289f6aSNate Lawson     return (AE_OK);
21853289f6aSNate Lawson }
21953289f6aSNate Lawson 
22053289f6aSNate Lawson 
22153289f6aSNate Lawson /*******************************************************************************
22253289f6aSNate Lawson  *
22353289f6aSNate Lawson  * FUNCTION:    OpcGetIntegerWidth
22453289f6aSNate Lawson  *
22553289f6aSNate Lawson  * PARAMETERS:  Op          - DEFINITION BLOCK op
22653289f6aSNate Lawson  *
22753289f6aSNate Lawson  * RETURN:      none
22853289f6aSNate Lawson  *
22953289f6aSNate Lawson  * DESCRIPTION: Extract integer width from the table revision
23053289f6aSNate Lawson  *
23153289f6aSNate Lawson  ******************************************************************************/
23253289f6aSNate Lawson 
23353289f6aSNate Lawson void
23453289f6aSNate Lawson OpcGetIntegerWidth (
23553289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
23653289f6aSNate Lawson {
23753289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Child;
23853289f6aSNate Lawson 
239fba7fc7eSJung-uk Kim 
24053289f6aSNate Lawson     if (!Op)
24153289f6aSNate Lawson     {
24253289f6aSNate Lawson         return;
24353289f6aSNate Lawson     }
24453289f6aSNate Lawson 
245fba7fc7eSJung-uk Kim     if (Gbl_RevisionOverride)
246fba7fc7eSJung-uk Kim     {
247fba7fc7eSJung-uk Kim         AcpiUtSetIntegerWidth (Gbl_RevisionOverride);
248fba7fc7eSJung-uk Kim     }
249fba7fc7eSJung-uk Kim     else
250fba7fc7eSJung-uk Kim     {
25153289f6aSNate Lawson         Child = Op->Asl.Child;
25253289f6aSNate Lawson         Child = Child->Asl.Next;
25353289f6aSNate Lawson         Child = Child->Asl.Next;
25453289f6aSNate Lawson 
25553289f6aSNate Lawson         /* Use the revision to set the integer width */
25653289f6aSNate Lawson 
25753289f6aSNate Lawson         AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
25853289f6aSNate Lawson     }
259fba7fc7eSJung-uk Kim }
26053289f6aSNate Lawson 
26153289f6aSNate Lawson 
26253289f6aSNate Lawson /*******************************************************************************
26353289f6aSNate Lawson  *
26453289f6aSNate Lawson  * FUNCTION:    OpcSetOptimalIntegerSize
26553289f6aSNate Lawson  *
26653289f6aSNate Lawson  * PARAMETERS:  Op        - A parse tree node
26753289f6aSNate Lawson  *
26853289f6aSNate Lawson  * RETURN:      Integer width, in bytes.  Also sets the node AML opcode to the
26953289f6aSNate Lawson  *              optimal integer AML prefix opcode.
27053289f6aSNate Lawson  *
27153289f6aSNate Lawson  * DESCRIPTION: Determine the optimal AML encoding of an integer.  All leading
27253289f6aSNate Lawson  *              zeros can be truncated to squeeze the integer into the
27353289f6aSNate Lawson  *              minimal number of AML bytes.
27453289f6aSNate Lawson  *
27553289f6aSNate Lawson  ******************************************************************************/
27653289f6aSNate Lawson 
27753289f6aSNate Lawson UINT32
27853289f6aSNate Lawson OpcSetOptimalIntegerSize (
27953289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
28053289f6aSNate Lawson {
28153289f6aSNate Lawson 
282fba7fc7eSJung-uk Kim #if 0
28353289f6aSNate Lawson     /*
284fba7fc7eSJung-uk Kim      * TBD: - we don't want to optimize integers in the block header, but the
285fba7fc7eSJung-uk Kim      * code below does not work correctly.
286fba7fc7eSJung-uk Kim      */
287c8466860SMark Santcroos     if (Op->Asl.Parent &&
288c8466860SMark Santcroos         Op->Asl.Parent->Asl.Parent &&
289c8466860SMark Santcroos        (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK))
290c8466860SMark Santcroos     {
291c8466860SMark Santcroos         return 0;
292c8466860SMark Santcroos     }
293fba7fc7eSJung-uk Kim #endif
294c8466860SMark Santcroos 
295c8466860SMark Santcroos     /*
29653289f6aSNate Lawson      * Check for the special AML integers first - Zero, One, Ones.
29753289f6aSNate Lawson      * These are single-byte opcodes that are the smallest possible
29853289f6aSNate Lawson      * representation of an integer.
29953289f6aSNate Lawson      *
30053289f6aSNate Lawson      * This optimization is optional.
30153289f6aSNate Lawson      */
30253289f6aSNate Lawson     if (Gbl_IntegerOptimizationFlag)
30353289f6aSNate Lawson     {
30453289f6aSNate Lawson         switch (Op->Asl.Value.Integer)
30553289f6aSNate Lawson         {
30653289f6aSNate Lawson         case 0:
30753289f6aSNate Lawson 
30853289f6aSNate Lawson             Op->Asl.AmlOpcode = AML_ZERO_OP;
309fba7fc7eSJung-uk Kim             AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
310fba7fc7eSJung-uk Kim                 Op, "Zero");
31153289f6aSNate Lawson             return 1;
31253289f6aSNate Lawson 
31353289f6aSNate Lawson         case 1:
31453289f6aSNate Lawson 
31553289f6aSNate Lawson             Op->Asl.AmlOpcode = AML_ONE_OP;
316fba7fc7eSJung-uk Kim             AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
317fba7fc7eSJung-uk Kim                 Op, "One");
31853289f6aSNate Lawson             return 1;
31953289f6aSNate Lawson 
32053289f6aSNate Lawson         case ACPI_UINT32_MAX:
32153289f6aSNate Lawson 
32253289f6aSNate Lawson             /* Check for table integer width (32 or 64) */
32353289f6aSNate Lawson 
32453289f6aSNate Lawson             if (AcpiGbl_IntegerByteWidth == 4)
32553289f6aSNate Lawson             {
32653289f6aSNate Lawson                 Op->Asl.AmlOpcode = AML_ONES_OP;
327fba7fc7eSJung-uk Kim                 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
328fba7fc7eSJung-uk Kim                     Op, "Ones");
32953289f6aSNate Lawson                 return 1;
33053289f6aSNate Lawson             }
33153289f6aSNate Lawson             break;
33253289f6aSNate Lawson 
33353289f6aSNate Lawson         case ACPI_INTEGER_MAX:
33453289f6aSNate Lawson 
33553289f6aSNate Lawson             /* Check for table integer width (32 or 64) */
33653289f6aSNate Lawson 
33753289f6aSNate Lawson             if (AcpiGbl_IntegerByteWidth == 8)
33853289f6aSNate Lawson             {
33953289f6aSNate Lawson                 Op->Asl.AmlOpcode = AML_ONES_OP;
340fba7fc7eSJung-uk Kim                 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
341fba7fc7eSJung-uk Kim                     Op, "Ones");
34253289f6aSNate Lawson                 return 1;
34353289f6aSNate Lawson             }
34453289f6aSNate Lawson             break;
34553289f6aSNate Lawson 
34653289f6aSNate Lawson         default:
34753289f6aSNate Lawson             break;
34853289f6aSNate Lawson         }
34953289f6aSNate Lawson     }
35053289f6aSNate Lawson 
35153289f6aSNate Lawson     /* Find the best fit using the various AML integer prefixes */
35253289f6aSNate Lawson 
35353289f6aSNate Lawson     if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
35453289f6aSNate Lawson     {
35553289f6aSNate Lawson         Op->Asl.AmlOpcode = AML_BYTE_OP;
35653289f6aSNate Lawson         return 1;
35753289f6aSNate Lawson     }
35853289f6aSNate Lawson     if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
35953289f6aSNate Lawson     {
36053289f6aSNate Lawson         Op->Asl.AmlOpcode = AML_WORD_OP;
36153289f6aSNate Lawson         return 2;
36253289f6aSNate Lawson     }
36353289f6aSNate Lawson     if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
36453289f6aSNate Lawson     {
36553289f6aSNate Lawson         Op->Asl.AmlOpcode = AML_DWORD_OP;
36653289f6aSNate Lawson         return 4;
36753289f6aSNate Lawson     }
36853289f6aSNate Lawson     else
36953289f6aSNate Lawson     {
370fba7fc7eSJung-uk Kim         if (AcpiGbl_IntegerByteWidth == 4)
371fba7fc7eSJung-uk Kim         {
372fba7fc7eSJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH,
373fba7fc7eSJung-uk Kim                 Op, NULL);
374fba7fc7eSJung-uk Kim 
375fba7fc7eSJung-uk Kim             if (!Gbl_IgnoreErrors)
376fba7fc7eSJung-uk Kim             {
377fba7fc7eSJung-uk Kim                 /* Truncate the integer to 32-bit */
378fba7fc7eSJung-uk Kim                 Op->Asl.AmlOpcode = AML_DWORD_OP;
379fba7fc7eSJung-uk Kim                 return 4;
380fba7fc7eSJung-uk Kim             }
381fba7fc7eSJung-uk Kim         }
382fba7fc7eSJung-uk Kim 
38353289f6aSNate Lawson         Op->Asl.AmlOpcode = AML_QWORD_OP;
38453289f6aSNate Lawson         return 8;
38553289f6aSNate Lawson     }
38653289f6aSNate Lawson }
38753289f6aSNate Lawson 
38853289f6aSNate Lawson 
38953289f6aSNate Lawson /*******************************************************************************
39053289f6aSNate Lawson  *
39153289f6aSNate Lawson  * FUNCTION:    OpcDoAccessAs
39253289f6aSNate Lawson  *
39353289f6aSNate Lawson  * PARAMETERS:  Op        - Parse node
39453289f6aSNate Lawson  *
39553289f6aSNate Lawson  * RETURN:      None
39653289f6aSNate Lawson  *
39753289f6aSNate Lawson  * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
39853289f6aSNate Lawson  *
39953289f6aSNate Lawson  ******************************************************************************/
40053289f6aSNate Lawson 
401fba7fc7eSJung-uk Kim static void
40253289f6aSNate Lawson OpcDoAccessAs (
40353289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
40453289f6aSNate Lawson {
40553289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Next;
40653289f6aSNate Lawson 
40753289f6aSNate Lawson 
40853289f6aSNate Lawson     Op->Asl.AmlOpcodeLength = 1;
40953289f6aSNate Lawson     Next = Op->Asl.Child;
41053289f6aSNate Lawson 
41153289f6aSNate Lawson     /* First child is the access type */
41253289f6aSNate Lawson 
41353289f6aSNate Lawson     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
41453289f6aSNate Lawson     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
41553289f6aSNate Lawson 
41653289f6aSNate Lawson     /* Second child is the optional access attribute */
41753289f6aSNate Lawson 
41853289f6aSNate Lawson     Next = Next->Asl.Next;
41953289f6aSNate Lawson     if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
42053289f6aSNate Lawson     {
42153289f6aSNate Lawson         Next->Asl.Value.Integer = 0;
42253289f6aSNate Lawson     }
42353289f6aSNate Lawson     Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
42453289f6aSNate Lawson     Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
42553289f6aSNate Lawson }
42653289f6aSNate Lawson 
42753289f6aSNate Lawson 
42853289f6aSNate Lawson /*******************************************************************************
42953289f6aSNate Lawson  *
43053289f6aSNate Lawson  * FUNCTION:    OpcDoUnicode
43153289f6aSNate Lawson  *
43253289f6aSNate Lawson  * PARAMETERS:  Op        - Parse node
43353289f6aSNate Lawson  *
43453289f6aSNate Lawson  * RETURN:      None
43553289f6aSNate Lawson  *
43653289f6aSNate Lawson  * DESCRIPTION: Implement the UNICODE ASL "macro".  Convert the input string
43753289f6aSNate Lawson  *              to a unicode buffer.  There is no Unicode AML opcode.
43853289f6aSNate Lawson  *
43953289f6aSNate Lawson  * Note:  The Unicode string is 16 bits per character, no leading signature,
44053289f6aSNate Lawson  *        with a 16-bit terminating NULL.
44153289f6aSNate Lawson  *
44253289f6aSNate Lawson  ******************************************************************************/
44353289f6aSNate Lawson 
444fba7fc7eSJung-uk Kim static void
44553289f6aSNate Lawson OpcDoUnicode (
44653289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
44753289f6aSNate Lawson {
44853289f6aSNate Lawson     ACPI_PARSE_OBJECT       *InitializerOp;
44953289f6aSNate Lawson     UINT32                  Length;
45053289f6aSNate Lawson     UINT32                  Count;
45153289f6aSNate Lawson     UINT32                  i;
45253289f6aSNate Lawson     UINT8                   *AsciiString;
45353289f6aSNate Lawson     UINT16                  *UnicodeString;
45453289f6aSNate Lawson     ACPI_PARSE_OBJECT       *BufferLengthOp;
45553289f6aSNate Lawson 
45653289f6aSNate Lawson 
45753289f6aSNate Lawson     /* Change op into a buffer object */
45853289f6aSNate Lawson 
45953289f6aSNate Lawson     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
46053289f6aSNate Lawson     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
46153289f6aSNate Lawson     UtSetParseOpName (Op);
46253289f6aSNate Lawson 
46353289f6aSNate Lawson     /* Buffer Length is first, followed by the string */
46453289f6aSNate Lawson 
46553289f6aSNate Lawson     BufferLengthOp = Op->Asl.Child;
46653289f6aSNate Lawson     InitializerOp = BufferLengthOp->Asl.Next;
46753289f6aSNate Lawson 
46853289f6aSNate Lawson     AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
46953289f6aSNate Lawson 
47053289f6aSNate Lawson     /* Create a new buffer for the Unicode string */
47153289f6aSNate Lawson 
47253289f6aSNate Lawson     Count = strlen (InitializerOp->Asl.Value.String) + 1;
47353289f6aSNate Lawson     Length = Count * sizeof (UINT16);
47453289f6aSNate Lawson     UnicodeString = UtLocalCalloc (Length);
47553289f6aSNate Lawson 
47653289f6aSNate Lawson     /* Convert to Unicode string (including null terminator) */
47753289f6aSNate Lawson 
47853289f6aSNate Lawson     for (i = 0; i < Count; i++)
47953289f6aSNate Lawson     {
48053289f6aSNate Lawson         UnicodeString[i] = (UINT16) AsciiString[i];
48153289f6aSNate Lawson     }
48253289f6aSNate Lawson 
48353289f6aSNate Lawson     /*
48453289f6aSNate Lawson      * Just set the buffer size node to be the buffer length, regardless
48553289f6aSNate Lawson      * of whether it was previously an integer or a default_arg placeholder
48653289f6aSNate Lawson      */
48753289f6aSNate Lawson     BufferLengthOp->Asl.ParseOpcode   = PARSEOP_INTEGER;
48853289f6aSNate Lawson     BufferLengthOp->Asl.AmlOpcode     = AML_DWORD_OP;
48953289f6aSNate Lawson     BufferLengthOp->Asl.Value.Integer = Length;
49053289f6aSNate Lawson     UtSetParseOpName (BufferLengthOp);
49153289f6aSNate Lawson 
49253289f6aSNate Lawson     (void) OpcSetOptimalIntegerSize (BufferLengthOp);
49353289f6aSNate Lawson 
49453289f6aSNate Lawson     /* The Unicode string is a raw data buffer */
49553289f6aSNate Lawson 
49653289f6aSNate Lawson     InitializerOp->Asl.Value.Buffer   = (UINT8 *) UnicodeString;
49753289f6aSNate Lawson     InitializerOp->Asl.AmlOpcode      = AML_RAW_DATA_BUFFER;
49853289f6aSNate Lawson     InitializerOp->Asl.AmlLength      = Length;
49953289f6aSNate Lawson     InitializerOp->Asl.ParseOpcode    = PARSEOP_RAW_DATA;
50053289f6aSNate Lawson     InitializerOp->Asl.Child          = NULL;
50153289f6aSNate Lawson     UtSetParseOpName (InitializerOp);
50253289f6aSNate Lawson }
50353289f6aSNate Lawson 
50453289f6aSNate Lawson 
50553289f6aSNate Lawson /*******************************************************************************
50653289f6aSNate Lawson  *
50753289f6aSNate Lawson  * FUNCTION:    OpcDoEisaId
50853289f6aSNate Lawson  *
50953289f6aSNate Lawson  * PARAMETERS:  Op        - Parse node
51053289f6aSNate Lawson  *
51153289f6aSNate Lawson  * RETURN:      None
51253289f6aSNate Lawson  *
51353289f6aSNate Lawson  * DESCRIPTION: Convert a string EISA ID to numeric representation.  See the
51453289f6aSNate Lawson  *              Pnp BIOS Specification for details.  Here is an excerpt:
51553289f6aSNate Lawson  *
51653289f6aSNate Lawson  *              A seven character ASCII representation of the product
51753289f6aSNate Lawson  *              identifier compressed into a 32-bit identifier.  The seven
51853289f6aSNate Lawson  *              character ID consists of a three character manufacturer code,
51953289f6aSNate Lawson  *              a three character hexadecimal product identifier, and a one
52053289f6aSNate Lawson  *              character hexadecimal revision number.  The manufacturer code
52153289f6aSNate Lawson  *              is a 3 uppercase character code that is compressed into 3 5-bit
52253289f6aSNate Lawson  *              values as follows:
52353289f6aSNate Lawson  *                  1) Find hex ASCII value for each letter
52453289f6aSNate Lawson  *                  2) Subtract 40h from each ASCII value
52553289f6aSNate Lawson  *                  3) Retain 5 least signficant bits for each letter by
52653289f6aSNate Lawson  *                     discarding upper 3 bits because they are always 0.
52753289f6aSNate Lawson  *                  4) Compressed code = concatenate 0 and the 3 5-bit values
52853289f6aSNate Lawson  *
52953289f6aSNate Lawson  *              The format of the compressed product identifier is as follows:
53053289f6aSNate Lawson  *              Byte 0: Bit 7       - Reserved (0)
53153289f6aSNate Lawson  *                      Bits 6-2:   - 1st character of compressed mfg code
53253289f6aSNate Lawson  *                      Bits 1-0    - Upper 2 bits of 2nd character of mfg code
53353289f6aSNate Lawson  *              Byte 1: Bits 7-5    - Lower 3 bits of 2nd character of mfg code
53453289f6aSNate Lawson  *                      Bits 4-0    - 3rd character of mfg code
53553289f6aSNate Lawson  *              Byte 2: Bits 7-4    - 1st hex digit of product number
53653289f6aSNate Lawson  *                      Bits 3-0    - 2nd hex digit of product number
53753289f6aSNate Lawson  *              Byte 3: Bits 7-4    - 3st hex digit of product number
53853289f6aSNate Lawson  *                      Bits 3-0    - Hex digit of the revision number
53953289f6aSNate Lawson  *
54053289f6aSNate Lawson  ******************************************************************************/
54153289f6aSNate Lawson 
542fba7fc7eSJung-uk Kim static void
54353289f6aSNate Lawson OpcDoEisaId (
54453289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
54553289f6aSNate Lawson {
54653289f6aSNate Lawson     UINT32                  EisaId = 0;
54753289f6aSNate Lawson     UINT32                  BigEndianId;
54853289f6aSNate Lawson     char                    *InString;
54953289f6aSNate Lawson     ACPI_STATUS             Status = AE_OK;
55053289f6aSNate Lawson     ACPI_NATIVE_UINT        i;
55153289f6aSNate Lawson 
55253289f6aSNate Lawson 
55353289f6aSNate Lawson     InString = (char *) Op->Asl.Value.String;
55453289f6aSNate Lawson 
55553289f6aSNate Lawson     /*
55653289f6aSNate Lawson      * The EISAID string must be exactly 7 characters and of the form
557fba7fc7eSJung-uk Kim      * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
55853289f6aSNate Lawson      */
55953289f6aSNate Lawson     if (ACPI_STRLEN (InString) != 7)
56053289f6aSNate Lawson     {
56153289f6aSNate Lawson         Status = AE_BAD_PARAMETER;
56253289f6aSNate Lawson     }
56353289f6aSNate Lawson     else
56453289f6aSNate Lawson     {
56553289f6aSNate Lawson         /* Check all 7 characters for correct format */
56653289f6aSNate Lawson 
56753289f6aSNate Lawson         for (i = 0; i < 7; i++)
56853289f6aSNate Lawson         {
569c8466860SMark Santcroos             /* First 3 characters must be uppercase letters */
57053289f6aSNate Lawson 
57153289f6aSNate Lawson             if (i < 3)
57253289f6aSNate Lawson             {
573c8466860SMark Santcroos                 if (!isupper (InString[i]))
57453289f6aSNate Lawson                 {
57553289f6aSNate Lawson                     Status = AE_BAD_PARAMETER;
57653289f6aSNate Lawson                 }
57753289f6aSNate Lawson             }
57853289f6aSNate Lawson 
57953289f6aSNate Lawson             /* Last 4 characters must be hex digits */
58053289f6aSNate Lawson 
58153289f6aSNate Lawson             else if (!isxdigit (InString[i]))
58253289f6aSNate Lawson             {
58353289f6aSNate Lawson                 Status = AE_BAD_PARAMETER;
58453289f6aSNate Lawson             }
58553289f6aSNate Lawson         }
58653289f6aSNate Lawson     }
58753289f6aSNate Lawson 
58853289f6aSNate Lawson     if (ACPI_FAILURE (Status))
58953289f6aSNate Lawson     {
59053289f6aSNate Lawson         AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
59153289f6aSNate Lawson     }
59253289f6aSNate Lawson     else
59353289f6aSNate Lawson     {
59453289f6aSNate Lawson         /* Create ID big-endian first (bits are contiguous) */
59553289f6aSNate Lawson 
59653289f6aSNate Lawson         BigEndianId  =  (UINT32) (InString[0] - 0x40) << 26 |
59753289f6aSNate Lawson                         (UINT32) (InString[1] - 0x40) << 21 |
59853289f6aSNate Lawson                         (UINT32) (InString[2] - 0x40) << 16 |
59953289f6aSNate Lawson 
60053289f6aSNate Lawson                         (UtHexCharToValue (InString[3])) << 12 |
60153289f6aSNate Lawson                         (UtHexCharToValue (InString[4])) << 8  |
60253289f6aSNate Lawson                         (UtHexCharToValue (InString[5])) << 4  |
60353289f6aSNate Lawson                          UtHexCharToValue (InString[6]);
60453289f6aSNate Lawson 
60553289f6aSNate Lawson         /* Swap to little-endian to get final ID (see function header) */
60653289f6aSNate Lawson 
60753289f6aSNate Lawson         EisaId = AcpiUtDwordByteSwap (BigEndianId);
60853289f6aSNate Lawson     }
60953289f6aSNate Lawson 
61053289f6aSNate Lawson     /*
61153289f6aSNate Lawson      * Morph the Op into an integer, regardless of whether there
61253289f6aSNate Lawson      * was an error in the EISAID string
61353289f6aSNate Lawson      */
61453289f6aSNate Lawson     Op->Asl.Value.Integer = EisaId;
61553289f6aSNate Lawson 
61653289f6aSNate Lawson     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
61753289f6aSNate Lawson     Op->Asl.ParseOpcode = PARSEOP_INTEGER;
61853289f6aSNate Lawson     (void) OpcSetOptimalIntegerSize (Op);
61953289f6aSNate Lawson 
62053289f6aSNate Lawson     /* Op is now an integer */
62153289f6aSNate Lawson 
62253289f6aSNate Lawson     UtSetParseOpName (Op);
62353289f6aSNate Lawson }
62453289f6aSNate Lawson 
62553289f6aSNate Lawson 
62653289f6aSNate Lawson /*******************************************************************************
62753289f6aSNate Lawson  *
628c8466860SMark Santcroos  * FUNCTION:    OpcDoUiId
629c8466860SMark Santcroos  *
630c8466860SMark Santcroos  * PARAMETERS:  Op        - Parse node
631c8466860SMark Santcroos  *
632c8466860SMark Santcroos  * RETURN:      None
633c8466860SMark Santcroos  *
634fba7fc7eSJung-uk Kim  * DESCRIPTION: Convert UUID string to 16-byte buffer
635c8466860SMark Santcroos  *
636c8466860SMark Santcroos  ******************************************************************************/
637c8466860SMark Santcroos 
638fba7fc7eSJung-uk Kim static void
639c8466860SMark Santcroos OpcDoUuId (
640c8466860SMark Santcroos     ACPI_PARSE_OBJECT       *Op)
641c8466860SMark Santcroos {
642c8466860SMark Santcroos     char                    *InString;
643c8466860SMark Santcroos     char                    *Buffer;
644c8466860SMark Santcroos     ACPI_STATUS             Status = AE_OK;
645c8466860SMark Santcroos     ACPI_NATIVE_UINT        i;
646c8466860SMark Santcroos     ACPI_PARSE_OBJECT       *NewOp;
647c8466860SMark Santcroos 
648c8466860SMark Santcroos 
649c8466860SMark Santcroos     InString = (char *) Op->Asl.Value.String;
650c8466860SMark Santcroos 
651c8466860SMark Santcroos     if (ACPI_STRLEN (InString) != 36)
652c8466860SMark Santcroos     {
653c8466860SMark Santcroos         Status = AE_BAD_PARAMETER;
654c8466860SMark Santcroos     }
655c8466860SMark Santcroos     else
656c8466860SMark Santcroos     {
657c8466860SMark Santcroos         /* Check all 36 characters for correct format */
658c8466860SMark Santcroos 
659c8466860SMark Santcroos         for (i = 0; i < 36; i++)
660c8466860SMark Santcroos         {
661c8466860SMark Santcroos             if ((i == 8) || (i == 13) || (i == 18) || (i == 23))
662c8466860SMark Santcroos             {
663c8466860SMark Santcroos                 if (InString[i] != '-')
664c8466860SMark Santcroos                 {
665c8466860SMark Santcroos                     Status = AE_BAD_PARAMETER;
666c8466860SMark Santcroos                 }
667c8466860SMark Santcroos             }
668c8466860SMark Santcroos             else
669c8466860SMark Santcroos             {
670c8466860SMark Santcroos                 if (!isxdigit (InString[i]))
671c8466860SMark Santcroos                 {
672c8466860SMark Santcroos                     Status = AE_BAD_PARAMETER;
673c8466860SMark Santcroos                 }
674c8466860SMark Santcroos             }
675c8466860SMark Santcroos         }
676c8466860SMark Santcroos     }
677c8466860SMark Santcroos 
678c8466860SMark Santcroos     Buffer = UtLocalCalloc (16);
679c8466860SMark Santcroos 
680c8466860SMark Santcroos     if (ACPI_FAILURE (Status))
681c8466860SMark Santcroos     {
682c8466860SMark Santcroos         AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String);
683c8466860SMark Santcroos     }
684c8466860SMark Santcroos     else for (i = 0; i < 16; i++)
685c8466860SMark Santcroos     {
686c8466860SMark Santcroos         Buffer[i]  = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4);
687fba7fc7eSJung-uk Kim         Buffer[i] |= (char)  UtHexCharToValue (InString[OpcMapToUUID[i] + 1]);
688c8466860SMark Santcroos     }
689c8466860SMark Santcroos 
690c8466860SMark Santcroos     /* Change Op to a Buffer */
691c8466860SMark Santcroos 
692c8466860SMark Santcroos     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
693c8466860SMark Santcroos     Op->Common.AmlOpcode = AML_BUFFER_OP;
694fba7fc7eSJung-uk Kim 
695fba7fc7eSJung-uk Kim     /* Disable further optimization */
696fba7fc7eSJung-uk Kim 
697fba7fc7eSJung-uk Kim     Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
698c8466860SMark Santcroos     UtSetParseOpName (Op);
699c8466860SMark Santcroos 
700c8466860SMark Santcroos     /* Child node is the buffer length */
701c8466860SMark Santcroos 
702c8466860SMark Santcroos     NewOp = TrAllocateNode (PARSEOP_INTEGER);
703c8466860SMark Santcroos 
704c8466860SMark Santcroos     NewOp->Asl.AmlOpcode     = AML_BYTE_OP;
705c8466860SMark Santcroos     NewOp->Asl.Value.Integer = 16;
706c8466860SMark Santcroos     NewOp->Asl.Parent        = Op;
707c8466860SMark Santcroos 
708c8466860SMark Santcroos     Op->Asl.Child = NewOp;
709c8466860SMark Santcroos     Op = NewOp;
710c8466860SMark Santcroos 
711c8466860SMark Santcroos     /* Peer to the child is the raw buffer data */
712c8466860SMark Santcroos 
713c8466860SMark Santcroos     NewOp = TrAllocateNode (PARSEOP_RAW_DATA);
714c8466860SMark Santcroos     NewOp->Asl.AmlOpcode     = AML_RAW_DATA_BUFFER;
715c8466860SMark Santcroos     NewOp->Asl.AmlLength     = 16;
716c8466860SMark Santcroos     NewOp->Asl.Value.String  = (char *) Buffer;
717c8466860SMark Santcroos     NewOp->Asl.Parent        = Op->Asl.Parent;
718c8466860SMark Santcroos 
719c8466860SMark Santcroos     Op->Asl.Next = NewOp;
720c8466860SMark Santcroos }
721c8466860SMark Santcroos 
722c8466860SMark Santcroos 
723c8466860SMark Santcroos /*******************************************************************************
724c8466860SMark Santcroos  *
72553289f6aSNate Lawson  * FUNCTION:    OpcGenerateAmlOpcode
72653289f6aSNate Lawson  *
72753289f6aSNate Lawson  * PARAMETERS:  Op        - Parse node
72853289f6aSNate Lawson  *
72953289f6aSNate Lawson  * RETURN:      None
73053289f6aSNate Lawson  *
73153289f6aSNate Lawson  * DESCRIPTION: Generate the AML opcode associated with the node and its
73253289f6aSNate Lawson  *              parse (lex/flex) keyword opcode.  Essentially implements
73353289f6aSNate Lawson  *              a mapping between the parse opcodes and the actual AML opcodes.
73453289f6aSNate Lawson  *
73553289f6aSNate Lawson  ******************************************************************************/
73653289f6aSNate Lawson 
73753289f6aSNate Lawson void
73853289f6aSNate Lawson OpcGenerateAmlOpcode (
73953289f6aSNate Lawson     ACPI_PARSE_OBJECT       *Op)
74053289f6aSNate Lawson {
74153289f6aSNate Lawson 
74253289f6aSNate Lawson     UINT16                  Index;
74353289f6aSNate Lawson 
74453289f6aSNate Lawson 
74553289f6aSNate Lawson     Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
74653289f6aSNate Lawson 
74753289f6aSNate Lawson     Op->Asl.AmlOpcode     = AslKeywordMapping[Index].AmlOpcode;
74853289f6aSNate Lawson     Op->Asl.AcpiBtype     = AslKeywordMapping[Index].AcpiBtype;
74953289f6aSNate Lawson     Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
75053289f6aSNate Lawson 
75153289f6aSNate Lawson     if (!Op->Asl.Value.Integer)
75253289f6aSNate Lawson     {
75353289f6aSNate Lawson         Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
75453289f6aSNate Lawson     }
75553289f6aSNate Lawson 
75653289f6aSNate Lawson     /* Special handling for some opcodes */
75753289f6aSNate Lawson 
75853289f6aSNate Lawson     switch (Op->Asl.ParseOpcode)
75953289f6aSNate Lawson     {
76053289f6aSNate Lawson     case PARSEOP_INTEGER:
76153289f6aSNate Lawson         /*
76253289f6aSNate Lawson          * Set the opcode based on the size of the integer
76353289f6aSNate Lawson          */
76453289f6aSNate Lawson         (void) OpcSetOptimalIntegerSize (Op);
76553289f6aSNate Lawson         break;
76653289f6aSNate Lawson 
76753289f6aSNate Lawson     case PARSEOP_OFFSET:
76853289f6aSNate Lawson 
76953289f6aSNate Lawson         Op->Asl.AmlOpcodeLength = 1;
77053289f6aSNate Lawson         break;
77153289f6aSNate Lawson 
77253289f6aSNate Lawson     case PARSEOP_ACCESSAS:
77353289f6aSNate Lawson 
77453289f6aSNate Lawson         OpcDoAccessAs (Op);
77553289f6aSNate Lawson         break;
77653289f6aSNate Lawson 
77753289f6aSNate Lawson     case PARSEOP_EISAID:
77853289f6aSNate Lawson 
77953289f6aSNate Lawson         OpcDoEisaId (Op);
78053289f6aSNate Lawson         break;
78153289f6aSNate Lawson 
782c8466860SMark Santcroos     case PARSEOP_TOUUID:
783c8466860SMark Santcroos 
784c8466860SMark Santcroos         OpcDoUuId (Op);
785c8466860SMark Santcroos         break;
786c8466860SMark Santcroos 
78753289f6aSNate Lawson     case PARSEOP_UNICODE:
78853289f6aSNate Lawson 
78953289f6aSNate Lawson         OpcDoUnicode (Op);
79053289f6aSNate Lawson         break;
79153289f6aSNate Lawson 
79253289f6aSNate Lawson     case PARSEOP_INCLUDE:
79353289f6aSNate Lawson 
79453289f6aSNate Lawson         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
79553289f6aSNate Lawson         Gbl_HasIncludeFiles = TRUE;
79653289f6aSNate Lawson         break;
79753289f6aSNate Lawson 
79853289f6aSNate Lawson     case PARSEOP_EXTERNAL:
79953289f6aSNate Lawson 
80053289f6aSNate Lawson         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
80153289f6aSNate Lawson         Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
80253289f6aSNate Lawson         break;
80353289f6aSNate Lawson 
80453289f6aSNate Lawson     default:
80553289f6aSNate Lawson         /* Nothing to do for other opcodes */
80653289f6aSNate Lawson         break;
80753289f6aSNate Lawson     }
80853289f6aSNate Lawson 
80953289f6aSNate Lawson     return;
81053289f6aSNate Lawson }
81153289f6aSNate Lawson 
81253289f6aSNate Lawson 
813