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