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