Home | History | Annotate | Line # | Download | only in dispatcher
dsfield.c revision 1.1.1.20.6.1
      1           1.1    jruoho /******************************************************************************
      2           1.1    jruoho  *
      3           1.1    jruoho  * Module Name: dsfield - Dispatcher field routines
      4           1.1    jruoho  *
      5           1.1    jruoho  *****************************************************************************/
      6           1.1    jruoho 
      7  1.1.1.20.6.1  perseant /******************************************************************************
      8  1.1.1.20.6.1  perseant  *
      9  1.1.1.20.6.1  perseant  * 1. Copyright Notice
     10  1.1.1.20.6.1  perseant  *
     11  1.1.1.20.6.1  perseant  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
     12           1.1    jruoho  * All rights reserved.
     13           1.1    jruoho  *
     14  1.1.1.20.6.1  perseant  * 2. License
     15  1.1.1.20.6.1  perseant  *
     16  1.1.1.20.6.1  perseant  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.1.1.20.6.1  perseant  * rights. You may have additional license terms from the party that provided
     18  1.1.1.20.6.1  perseant  * you this software, covering your right to use that party's intellectual
     19  1.1.1.20.6.1  perseant  * property rights.
     20  1.1.1.20.6.1  perseant  *
     21  1.1.1.20.6.1  perseant  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.1.1.20.6.1  perseant  * copy of the source code appearing in this file ("Covered Code") an
     23  1.1.1.20.6.1  perseant  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.1.1.20.6.1  perseant  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.1.1.20.6.1  perseant  * make derivatives, distribute, use and display any portion of the Covered
     26  1.1.1.20.6.1  perseant  * Code in any form, with the right to sublicense such rights; and
     27  1.1.1.20.6.1  perseant  *
     28  1.1.1.20.6.1  perseant  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.1.1.20.6.1  perseant  * license (with the right to sublicense), under only those claims of Intel
     30  1.1.1.20.6.1  perseant  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.1.1.20.6.1  perseant  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.1.1.20.6.1  perseant  * solely to the minimum extent necessary to exercise the above copyright
     33  1.1.1.20.6.1  perseant  * license, and in no event shall the patent license extend to any additions
     34  1.1.1.20.6.1  perseant  * to or modifications of the Original Intel Code. No other license or right
     35  1.1.1.20.6.1  perseant  * is granted directly or by implication, estoppel or otherwise;
     36  1.1.1.20.6.1  perseant  *
     37  1.1.1.20.6.1  perseant  * The above copyright and patent license is granted only if the following
     38  1.1.1.20.6.1  perseant  * conditions are met:
     39  1.1.1.20.6.1  perseant  *
     40  1.1.1.20.6.1  perseant  * 3. Conditions
     41  1.1.1.20.6.1  perseant  *
     42  1.1.1.20.6.1  perseant  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.1.1.20.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     44  1.1.1.20.6.1  perseant  * Code or modification with rights to further distribute source must include
     45  1.1.1.20.6.1  perseant  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.1.1.20.6.1  perseant  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.1.1.20.6.1  perseant  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.1.1.20.6.1  perseant  * contain a file documenting the changes Licensee made to create that Covered
     49  1.1.1.20.6.1  perseant  * Code and the date of any change. Licensee must include in that file the
     50  1.1.1.20.6.1  perseant  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.1.1.20.6.1  perseant  * must include a prominent statement that the modification is derived,
     52  1.1.1.20.6.1  perseant  * directly or indirectly, from Original Intel Code.
     53  1.1.1.20.6.1  perseant  *
     54  1.1.1.20.6.1  perseant  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.1.1.20.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     56  1.1.1.20.6.1  perseant  * Code or modification without rights to further distribute source must
     57  1.1.1.20.6.1  perseant  * include the following Disclaimer and Export Compliance provision in the
     58  1.1.1.20.6.1  perseant  * documentation and/or other materials provided with distribution. In
     59  1.1.1.20.6.1  perseant  * addition, Licensee may not authorize further sublicense of source of any
     60  1.1.1.20.6.1  perseant  * portion of the Covered Code, and must include terms to the effect that the
     61  1.1.1.20.6.1  perseant  * license from Licensee to its licensee is limited to the intellectual
     62  1.1.1.20.6.1  perseant  * property embodied in the software Licensee provides to its licensee, and
     63  1.1.1.20.6.1  perseant  * not to intellectual property embodied in modifications its licensee may
     64  1.1.1.20.6.1  perseant  * make.
     65  1.1.1.20.6.1  perseant  *
     66  1.1.1.20.6.1  perseant  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.1.1.20.6.1  perseant  * substantial portion of the Covered Code or modification must reproduce the
     68  1.1.1.20.6.1  perseant  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.1.1.20.6.1  perseant  * provision in the documentation and/or other materials provided with the
     70  1.1.1.20.6.1  perseant  * distribution.
     71  1.1.1.20.6.1  perseant  *
     72  1.1.1.20.6.1  perseant  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.1.1.20.6.1  perseant  * Intel Code.
     74  1.1.1.20.6.1  perseant  *
     75  1.1.1.20.6.1  perseant  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.1.1.20.6.1  perseant  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.1.1.20.6.1  perseant  * other dealings in products derived from or relating to the Covered Code
     78  1.1.1.20.6.1  perseant  * without prior written authorization from Intel.
     79  1.1.1.20.6.1  perseant  *
     80  1.1.1.20.6.1  perseant  * 4. Disclaimer and Export Compliance
     81  1.1.1.20.6.1  perseant  *
     82  1.1.1.20.6.1  perseant  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.1.1.20.6.1  perseant  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.1.1.20.6.1  perseant  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.1.1.20.6.1  perseant  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.1.1.20.6.1  perseant  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.1.1.20.6.1  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.1.1.20.6.1  perseant  * PARTICULAR PURPOSE.
     89  1.1.1.20.6.1  perseant  *
     90  1.1.1.20.6.1  perseant  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.1.1.20.6.1  perseant  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.1.1.20.6.1  perseant  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.1.1.20.6.1  perseant  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.1.1.20.6.1  perseant  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.1.1.20.6.1  perseant  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.1.1.20.6.1  perseant  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.1.1.20.6.1  perseant  * LIMITED REMEDY.
     98  1.1.1.20.6.1  perseant  *
     99  1.1.1.20.6.1  perseant  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.1.1.20.6.1  perseant  * software or system incorporating such software without first obtaining any
    101  1.1.1.20.6.1  perseant  * required license or other approval from the U. S. Department of Commerce or
    102  1.1.1.20.6.1  perseant  * any other agency or department of the United States Government. In the
    103  1.1.1.20.6.1  perseant  * event Licensee exports any such software from the United States or
    104  1.1.1.20.6.1  perseant  * re-exports any such software from a foreign destination, Licensee shall
    105  1.1.1.20.6.1  perseant  * ensure that the distribution and export/re-export of the software is in
    106  1.1.1.20.6.1  perseant  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.1.1.20.6.1  perseant  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.1.1.20.6.1  perseant  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.1.1.20.6.1  perseant  * software, or service, directly or indirectly, to any country for which the
    110  1.1.1.20.6.1  perseant  * United States government or any agency thereof requires an export license,
    111  1.1.1.20.6.1  perseant  * other governmental approval, or letter of assurance, without first obtaining
    112  1.1.1.20.6.1  perseant  * such license, approval or letter.
    113  1.1.1.20.6.1  perseant  *
    114  1.1.1.20.6.1  perseant  *****************************************************************************
    115  1.1.1.20.6.1  perseant  *
    116  1.1.1.20.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    117  1.1.1.20.6.1  perseant  * following license:
    118  1.1.1.20.6.1  perseant  *
    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.17  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.20.6.1  perseant  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.1.1.20.6.1  perseant  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.1.1.20.6.1  perseant  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.1.1.20.6.1  perseant  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.1.1.20.6.1  perseant  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.1.1.20.6.1  perseant  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.1.1.20.6.1  perseant  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.1.1.20.6.1  perseant  *
    146  1.1.1.20.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    147  1.1.1.20.6.1  perseant  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.1.1.20.6.1  perseant  * Software Foundation.
    149  1.1.1.20.6.1  perseant  *
    150  1.1.1.20.6.1  perseant  *****************************************************************************/
    151           1.1    jruoho 
    152           1.1    jruoho #include "acpi.h"
    153           1.1    jruoho #include "accommon.h"
    154           1.1    jruoho #include "amlcode.h"
    155           1.1    jruoho #include "acdispat.h"
    156           1.1    jruoho #include "acinterp.h"
    157           1.1    jruoho #include "acnamesp.h"
    158           1.1    jruoho #include "acparser.h"
    159           1.1    jruoho 
    160      1.1.1.12  christos #ifdef ACPI_EXEC_APP
    161      1.1.1.12  christos #include "aecommon.h"
    162      1.1.1.12  christos #endif
    163      1.1.1.12  christos 
    164           1.1    jruoho 
    165           1.1    jruoho #define _COMPONENT          ACPI_DISPATCHER
    166           1.1    jruoho         ACPI_MODULE_NAME    ("dsfield")
    167           1.1    jruoho 
    168           1.1    jruoho /* Local prototypes */
    169           1.1    jruoho 
    170       1.1.1.3  christos #ifdef ACPI_ASL_COMPILER
    171       1.1.1.3  christos #include "acdisasm.h"
    172       1.1.1.3  christos 
    173       1.1.1.3  christos static ACPI_STATUS
    174       1.1.1.3  christos AcpiDsCreateExternalRegion (
    175       1.1.1.3  christos     ACPI_STATUS             LookupStatus,
    176       1.1.1.3  christos     ACPI_PARSE_OBJECT       *Op,
    177       1.1.1.3  christos     char                    *Path,
    178       1.1.1.3  christos     ACPI_WALK_STATE         *WalkState,
    179       1.1.1.3  christos     ACPI_NAMESPACE_NODE     **Node);
    180       1.1.1.3  christos #endif
    181       1.1.1.3  christos 
    182           1.1    jruoho static ACPI_STATUS
    183           1.1    jruoho AcpiDsGetFieldNames (
    184           1.1    jruoho     ACPI_CREATE_FIELD_INFO  *Info,
    185           1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    186           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg);
    187           1.1    jruoho 
    188           1.1    jruoho 
    189       1.1.1.3  christos #ifdef ACPI_ASL_COMPILER
    190       1.1.1.3  christos /*******************************************************************************
    191       1.1.1.3  christos  *
    192       1.1.1.3  christos  * FUNCTION:    AcpiDsCreateExternalRegion (iASL Disassembler only)
    193       1.1.1.3  christos  *
    194       1.1.1.3  christos  * PARAMETERS:  LookupStatus    - Status from NsLookup operation
    195       1.1.1.3  christos  *              Op              - Op containing the Field definition and args
    196       1.1.1.3  christos  *              Path            - Pathname of the region
    197       1.1.1.3  christos  *  `           WalkState       - Current method state
    198       1.1.1.3  christos  *              Node            - Where the new region node is returned
    199       1.1.1.3  christos  *
    200       1.1.1.3  christos  * RETURN:      Status
    201       1.1.1.3  christos  *
    202       1.1.1.3  christos  * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
    203       1.1.1.3  christos  *              region node/object.
    204       1.1.1.3  christos  *
    205       1.1.1.3  christos  ******************************************************************************/
    206       1.1.1.3  christos 
    207       1.1.1.3  christos static ACPI_STATUS
    208       1.1.1.3  christos AcpiDsCreateExternalRegion (
    209       1.1.1.3  christos     ACPI_STATUS             LookupStatus,
    210       1.1.1.3  christos     ACPI_PARSE_OBJECT       *Op,
    211       1.1.1.3  christos     char                    *Path,
    212       1.1.1.3  christos     ACPI_WALK_STATE         *WalkState,
    213       1.1.1.3  christos     ACPI_NAMESPACE_NODE     **Node)
    214       1.1.1.3  christos {
    215       1.1.1.3  christos     ACPI_STATUS             Status;
    216       1.1.1.3  christos     ACPI_OPERAND_OBJECT     *ObjDesc;
    217       1.1.1.3  christos 
    218       1.1.1.3  christos 
    219       1.1.1.3  christos     if (LookupStatus != AE_NOT_FOUND)
    220       1.1.1.3  christos     {
    221       1.1.1.3  christos         return (LookupStatus);
    222       1.1.1.3  christos     }
    223       1.1.1.3  christos 
    224       1.1.1.3  christos     /*
    225       1.1.1.3  christos      * Table disassembly:
    226       1.1.1.3  christos      * OperationRegion not found. Generate an External for it, and
    227       1.1.1.3  christos      * insert the name into the namespace.
    228       1.1.1.3  christos      */
    229       1.1.1.3  christos     AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0);
    230       1.1.1.7  christos 
    231       1.1.1.3  christos     Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION,
    232       1.1.1.3  christos        ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node);
    233       1.1.1.3  christos     if (ACPI_FAILURE (Status))
    234       1.1.1.3  christos     {
    235       1.1.1.3  christos         return (Status);
    236       1.1.1.3  christos     }
    237       1.1.1.3  christos 
    238       1.1.1.3  christos     /* Must create and install a region object for the new node */
    239       1.1.1.3  christos 
    240       1.1.1.3  christos     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
    241       1.1.1.3  christos     if (!ObjDesc)
    242       1.1.1.3  christos     {
    243       1.1.1.3  christos         return (AE_NO_MEMORY);
    244       1.1.1.3  christos     }
    245       1.1.1.3  christos 
    246       1.1.1.3  christos     ObjDesc->Region.Node = *Node;
    247       1.1.1.3  christos     Status = AcpiNsAttachObject (*Node, ObjDesc, ACPI_TYPE_REGION);
    248       1.1.1.3  christos     return (Status);
    249       1.1.1.3  christos }
    250       1.1.1.3  christos #endif
    251       1.1.1.3  christos 
    252       1.1.1.3  christos 
    253           1.1    jruoho /*******************************************************************************
    254           1.1    jruoho  *
    255           1.1    jruoho  * FUNCTION:    AcpiDsCreateBufferField
    256           1.1    jruoho  *
    257           1.1    jruoho  * PARAMETERS:  Op                  - Current parse op (CreateXXField)
    258           1.1    jruoho  *              WalkState           - Current state
    259           1.1    jruoho  *
    260           1.1    jruoho  * RETURN:      Status
    261           1.1    jruoho  *
    262           1.1    jruoho  * DESCRIPTION: Execute the CreateField operators:
    263           1.1    jruoho  *              CreateBitFieldOp,
    264           1.1    jruoho  *              CreateByteFieldOp,
    265           1.1    jruoho  *              CreateWordFieldOp,
    266       1.1.1.3  christos  *              CreateDwordFieldOp,
    267       1.1.1.3  christos  *              CreateQwordFieldOp,
    268           1.1    jruoho  *              CreateFieldOp       (all of which define a field in a buffer)
    269           1.1    jruoho  *
    270           1.1    jruoho  ******************************************************************************/
    271           1.1    jruoho 
    272           1.1    jruoho ACPI_STATUS
    273           1.1    jruoho AcpiDsCreateBufferField (
    274           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    275           1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    276           1.1    jruoho {
    277           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    278           1.1    jruoho     ACPI_NAMESPACE_NODE     *Node;
    279           1.1    jruoho     ACPI_STATUS             Status;
    280           1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    281           1.1    jruoho     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
    282           1.1    jruoho     UINT32                  Flags;
    283           1.1    jruoho 
    284           1.1    jruoho 
    285           1.1    jruoho     ACPI_FUNCTION_TRACE (DsCreateBufferField);
    286           1.1    jruoho 
    287           1.1    jruoho 
    288           1.1    jruoho     /*
    289           1.1    jruoho      * Get the NameString argument (name of the new BufferField)
    290           1.1    jruoho      */
    291           1.1    jruoho     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
    292           1.1    jruoho     {
    293           1.1    jruoho         /* For CreateField, name is the 4th argument */
    294           1.1    jruoho 
    295           1.1    jruoho         Arg = AcpiPsGetArg (Op, 3);
    296           1.1    jruoho     }
    297           1.1    jruoho     else
    298           1.1    jruoho     {
    299           1.1    jruoho         /* For all other CreateXXXField operators, name is the 3rd argument */
    300           1.1    jruoho 
    301           1.1    jruoho         Arg = AcpiPsGetArg (Op, 2);
    302           1.1    jruoho     }
    303           1.1    jruoho 
    304           1.1    jruoho     if (!Arg)
    305           1.1    jruoho     {
    306           1.1    jruoho         return_ACPI_STATUS (AE_AML_NO_OPERAND);
    307           1.1    jruoho     }
    308           1.1    jruoho 
    309           1.1    jruoho     if (WalkState->DeferredNode)
    310           1.1    jruoho     {
    311           1.1    jruoho         Node = WalkState->DeferredNode;
    312           1.1    jruoho     }
    313           1.1    jruoho     else
    314           1.1    jruoho     {
    315           1.1    jruoho         /* Execute flag should always be set when this function is entered */
    316           1.1    jruoho 
    317           1.1    jruoho         if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
    318           1.1    jruoho         {
    319       1.1.1.9  christos             ACPI_ERROR ((AE_INFO,
    320       1.1.1.9  christos                 "Parse execute mode is not set"));
    321           1.1    jruoho             return_ACPI_STATUS (AE_AML_INTERNAL);
    322           1.1    jruoho         }
    323           1.1    jruoho 
    324           1.1    jruoho         /* Creating new namespace node, should not already exist */
    325           1.1    jruoho 
    326           1.1    jruoho         Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
    327       1.1.1.7  christos             ACPI_NS_ERROR_IF_FOUND;
    328           1.1    jruoho 
    329           1.1    jruoho         /*
    330           1.1    jruoho          * Mark node temporary if we are executing a normal control
    331           1.1    jruoho          * method. (Don't mark if this is a module-level code method)
    332           1.1    jruoho          */
    333           1.1    jruoho         if (WalkState->MethodNode &&
    334           1.1    jruoho             !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    335           1.1    jruoho         {
    336           1.1    jruoho             Flags |= ACPI_NS_TEMPORARY;
    337           1.1    jruoho         }
    338           1.1    jruoho 
    339           1.1    jruoho         /* Enter the NameString into the namespace */
    340           1.1    jruoho 
    341       1.1.1.7  christos         Status = AcpiNsLookup (WalkState->ScopeInfo,
    342       1.1.1.7  christos             Arg->Common.Value.String, ACPI_TYPE_ANY,
    343       1.1.1.7  christos             ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
    344      1.1.1.16  christos         if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) &&
    345      1.1.1.16  christos             Status == AE_ALREADY_EXISTS)
    346      1.1.1.16  christos         {
    347      1.1.1.16  christos             Status = AE_OK;
    348      1.1.1.16  christos         }
    349      1.1.1.16  christos         else if (ACPI_FAILURE (Status))
    350           1.1    jruoho         {
    351      1.1.1.10  christos             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    352      1.1.1.10  christos                 Arg->Common.Value.String, Status);
    353           1.1    jruoho             return_ACPI_STATUS (Status);
    354           1.1    jruoho         }
    355           1.1    jruoho     }
    356           1.1    jruoho 
    357           1.1    jruoho     /*
    358           1.1    jruoho      * We could put the returned object (Node) on the object stack for later,
    359           1.1    jruoho      * but for now, we will put it in the "op" object that the parser uses,
    360           1.1    jruoho      * so we can get it again at the end of this scope.
    361           1.1    jruoho      */
    362           1.1    jruoho     Op->Common.Node = Node;
    363           1.1    jruoho 
    364           1.1    jruoho     /*
    365           1.1    jruoho      * If there is no object attached to the node, this node was just created
    366           1.1    jruoho      * and we need to create the field object. Otherwise, this was a lookup
    367           1.1    jruoho      * of an existing node and we don't want to create the field object again.
    368           1.1    jruoho      */
    369           1.1    jruoho     ObjDesc = AcpiNsGetAttachedObject (Node);
    370           1.1    jruoho     if (ObjDesc)
    371           1.1    jruoho     {
    372           1.1    jruoho         return_ACPI_STATUS (AE_OK);
    373           1.1    jruoho     }
    374           1.1    jruoho 
    375           1.1    jruoho     /*
    376           1.1    jruoho      * The Field definition is not fully parsed at this time.
    377           1.1    jruoho      * (We must save the address of the AML for the buffer and index operands)
    378           1.1    jruoho      */
    379           1.1    jruoho 
    380           1.1    jruoho     /* Create the buffer field object */
    381           1.1    jruoho 
    382           1.1    jruoho     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
    383           1.1    jruoho     if (!ObjDesc)
    384           1.1    jruoho     {
    385           1.1    jruoho         Status = AE_NO_MEMORY;
    386           1.1    jruoho         goto Cleanup;
    387           1.1    jruoho     }
    388           1.1    jruoho 
    389           1.1    jruoho     /*
    390       1.1.1.7  christos      * Remember location in AML stream of the field unit opcode and operands
    391       1.1.1.7  christos      * -- since the buffer and index operands must be evaluated.
    392           1.1    jruoho      */
    393       1.1.1.7  christos     SecondDesc = ObjDesc->Common.NextObject;
    394       1.1.1.7  christos     SecondDesc->Extra.AmlStart = Op->Named.Data;
    395           1.1    jruoho     SecondDesc->Extra.AmlLength = Op->Named.Length;
    396       1.1.1.7  christos     ObjDesc->BufferField.Node = Node;
    397           1.1    jruoho 
    398           1.1    jruoho     /* Attach constructed field descriptors to parent node */
    399           1.1    jruoho 
    400           1.1    jruoho     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD);
    401           1.1    jruoho     if (ACPI_FAILURE (Status))
    402           1.1    jruoho     {
    403           1.1    jruoho         goto Cleanup;
    404           1.1    jruoho     }
    405           1.1    jruoho 
    406           1.1    jruoho 
    407           1.1    jruoho Cleanup:
    408           1.1    jruoho 
    409           1.1    jruoho     /* Remove local reference to the object */
    410           1.1    jruoho 
    411           1.1    jruoho     AcpiUtRemoveReference (ObjDesc);
    412           1.1    jruoho     return_ACPI_STATUS (Status);
    413           1.1    jruoho }
    414           1.1    jruoho 
    415           1.1    jruoho 
    416           1.1    jruoho /*******************************************************************************
    417           1.1    jruoho  *
    418           1.1    jruoho  * FUNCTION:    AcpiDsGetFieldNames
    419           1.1    jruoho  *
    420           1.1    jruoho  * PARAMETERS:  Info            - CreateField info structure
    421      1.1.1.14  christos  *              WalkState       - Current method state
    422           1.1    jruoho  *              Arg             - First parser arg for the field name list
    423           1.1    jruoho  *
    424           1.1    jruoho  * RETURN:      Status
    425           1.1    jruoho  *
    426       1.1.1.3  christos  * DESCRIPTION: Process all named fields in a field declaration. Names are
    427           1.1    jruoho  *              entered into the namespace.
    428           1.1    jruoho  *
    429           1.1    jruoho  ******************************************************************************/
    430           1.1    jruoho 
    431           1.1    jruoho static ACPI_STATUS
    432           1.1    jruoho AcpiDsGetFieldNames (
    433           1.1    jruoho     ACPI_CREATE_FIELD_INFO  *Info,
    434           1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    435           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg)
    436           1.1    jruoho {
    437           1.1    jruoho     ACPI_STATUS             Status;
    438           1.1    jruoho     UINT64                  Position;
    439       1.1.1.3  christos     ACPI_PARSE_OBJECT       *Child;
    440           1.1    jruoho 
    441      1.1.1.12  christos #ifdef ACPI_EXEC_APP
    442      1.1.1.12  christos     ACPI_OPERAND_OBJECT     *ResultDesc;
    443      1.1.1.12  christos     ACPI_OPERAND_OBJECT     *ObjDesc;
    444      1.1.1.12  christos     char                    *NamePath;
    445      1.1.1.12  christos #endif
    446      1.1.1.12  christos 
    447           1.1    jruoho 
    448           1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
    449           1.1    jruoho 
    450           1.1    jruoho 
    451           1.1    jruoho     /* First field starts at bit zero */
    452           1.1    jruoho 
    453           1.1    jruoho     Info->FieldBitPosition = 0;
    454           1.1    jruoho 
    455           1.1    jruoho     /* Process all elements in the field list (of parse nodes) */
    456           1.1    jruoho 
    457           1.1    jruoho     while (Arg)
    458           1.1    jruoho     {
    459           1.1    jruoho         /*
    460       1.1.1.3  christos          * Four types of field elements are handled:
    461       1.1.1.3  christos          * 1) Name - Enters a new named field into the namespace
    462       1.1.1.3  christos          * 2) Offset - specifies a bit offset
    463       1.1.1.3  christos          * 3) AccessAs - changes the access mode/attributes
    464       1.1.1.3  christos          * 4) Connection - Associate a resource template with the field
    465           1.1    jruoho          */
    466           1.1    jruoho         switch (Arg->Common.AmlOpcode)
    467           1.1    jruoho         {
    468           1.1    jruoho         case AML_INT_RESERVEDFIELD_OP:
    469           1.1    jruoho 
    470       1.1.1.7  christos             Position = (UINT64) Info->FieldBitPosition +
    471       1.1.1.7  christos                 (UINT64) Arg->Common.Value.Size;
    472           1.1    jruoho 
    473           1.1    jruoho             if (Position > ACPI_UINT32_MAX)
    474           1.1    jruoho             {
    475           1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    476           1.1    jruoho                     "Bit offset within field too large (> 0xFFFFFFFF)"));
    477           1.1    jruoho                 return_ACPI_STATUS (AE_SUPPORT);
    478           1.1    jruoho             }
    479           1.1    jruoho 
    480           1.1    jruoho             Info->FieldBitPosition = (UINT32) Position;
    481           1.1    jruoho             break;
    482           1.1    jruoho 
    483           1.1    jruoho         case AML_INT_ACCESSFIELD_OP:
    484       1.1.1.3  christos         case AML_INT_EXTACCESSFIELD_OP:
    485           1.1    jruoho             /*
    486       1.1.1.3  christos              * Get new AccessType, AccessAttribute, and AccessLength fields
    487       1.1.1.3  christos              * -- to be used for all field units that follow, until the
    488       1.1.1.3  christos              * end-of-field or another AccessAs keyword is encountered.
    489       1.1.1.3  christos              * NOTE. These three bytes are encoded in the integer value
    490       1.1.1.3  christos              * of the parseop for convenience.
    491           1.1    jruoho              *
    492           1.1    jruoho              * In FieldFlags, preserve the flag bits other than the
    493       1.1.1.3  christos              * ACCESS_TYPE bits.
    494           1.1    jruoho              */
    495       1.1.1.3  christos 
    496       1.1.1.3  christos             /* AccessType (ByteAcc, WordAcc, etc.) */
    497       1.1.1.3  christos 
    498           1.1    jruoho             Info->FieldFlags = (UINT8)
    499           1.1    jruoho                 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
    500       1.1.1.3  christos                 ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
    501       1.1.1.3  christos 
    502       1.1.1.3  christos             /* AccessAttribute (AttribQuick, AttribByte, etc.) */
    503       1.1.1.3  christos 
    504       1.1.1.7  christos             Info->Attribute = (UINT8)
    505       1.1.1.7  christos                 ((Arg->Common.Value.Integer >> 8) & 0xFF);
    506           1.1    jruoho 
    507       1.1.1.3  christos             /* AccessLength (for serial/buffer protocols) */
    508       1.1.1.3  christos 
    509       1.1.1.7  christos             Info->AccessLength = (UINT8)
    510       1.1.1.7  christos                 ((Arg->Common.Value.Integer >> 16) & 0xFF);
    511           1.1    jruoho             break;
    512           1.1    jruoho 
    513       1.1.1.3  christos         case AML_INT_CONNECTION_OP:
    514       1.1.1.3  christos             /*
    515       1.1.1.3  christos              * Clear any previous connection. New connection is used for all
    516       1.1.1.3  christos              * fields that follow, similar to AccessAs
    517       1.1.1.3  christos              */
    518       1.1.1.3  christos             Info->ResourceBuffer = NULL;
    519       1.1.1.3  christos             Info->ConnectionNode = NULL;
    520       1.1.1.4  christos             Info->PinNumberIndex = 0;
    521       1.1.1.3  christos 
    522       1.1.1.3  christos             /*
    523       1.1.1.3  christos              * A Connection() is either an actual resource descriptor (buffer)
    524       1.1.1.3  christos              * or a named reference to a resource template
    525       1.1.1.3  christos              */
    526       1.1.1.3  christos             Child = Arg->Common.Value.Arg;
    527       1.1.1.3  christos             if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
    528       1.1.1.3  christos             {
    529       1.1.1.3  christos                 Info->ResourceBuffer = Child->Named.Data;
    530       1.1.1.3  christos                 Info->ResourceLength = (UINT16) Child->Named.Value.Integer;
    531       1.1.1.3  christos             }
    532       1.1.1.3  christos             else
    533       1.1.1.3  christos             {
    534       1.1.1.3  christos                 /* Lookup the Connection() namepath, it should already exist */
    535       1.1.1.3  christos 
    536       1.1.1.3  christos                 Status = AcpiNsLookup (WalkState->ScopeInfo,
    537       1.1.1.7  christos                     Child->Common.Value.Name, ACPI_TYPE_ANY,
    538       1.1.1.7  christos                     ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
    539       1.1.1.7  christos                     WalkState, &Info->ConnectionNode);
    540       1.1.1.3  christos                 if (ACPI_FAILURE (Status))
    541       1.1.1.3  christos                 {
    542      1.1.1.10  christos                     ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    543      1.1.1.10  christos                         Child->Common.Value.Name, Status);
    544       1.1.1.3  christos                     return_ACPI_STATUS (Status);
    545       1.1.1.3  christos                 }
    546       1.1.1.3  christos             }
    547       1.1.1.3  christos             break;
    548           1.1    jruoho 
    549           1.1    jruoho         case AML_INT_NAMEDFIELD_OP:
    550           1.1    jruoho 
    551           1.1    jruoho             /* Lookup the name, it should already exist */
    552           1.1    jruoho 
    553           1.1    jruoho             Status = AcpiNsLookup (WalkState->ScopeInfo,
    554       1.1.1.7  christos                 (char *) &Arg->Named.Name, Info->FieldType,
    555       1.1.1.7  christos                 ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
    556       1.1.1.7  christos                 WalkState, &Info->FieldNode);
    557           1.1    jruoho             if (ACPI_FAILURE (Status))
    558           1.1    jruoho             {
    559      1.1.1.10  christos                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    560      1.1.1.10  christos                     (char *) &Arg->Named.Name, Status);
    561           1.1    jruoho                 return_ACPI_STATUS (Status);
    562           1.1    jruoho             }
    563           1.1    jruoho             else
    564           1.1    jruoho             {
    565           1.1    jruoho                 Arg->Common.Node = Info->FieldNode;
    566           1.1    jruoho                 Info->FieldBitLength = Arg->Common.Value.Size;
    567           1.1    jruoho 
    568           1.1    jruoho                 /*
    569           1.1    jruoho                  * If there is no object attached to the node, this node was
    570           1.1    jruoho                  * just created and we need to create the field object.
    571           1.1    jruoho                  * Otherwise, this was a lookup of an existing node and we
    572           1.1    jruoho                  * don't want to create the field object again.
    573           1.1    jruoho                  */
    574           1.1    jruoho                 if (!AcpiNsGetAttachedObject (Info->FieldNode))
    575           1.1    jruoho                 {
    576           1.1    jruoho                     Status = AcpiExPrepFieldValue (Info);
    577           1.1    jruoho                     if (ACPI_FAILURE (Status))
    578           1.1    jruoho                     {
    579           1.1    jruoho                         return_ACPI_STATUS (Status);
    580           1.1    jruoho                     }
    581      1.1.1.12  christos #ifdef ACPI_EXEC_APP
    582      1.1.1.12  christos                     NamePath = AcpiNsGetExternalPathname (Info->FieldNode);
    583      1.1.1.14  christos                     if (ACPI_SUCCESS (AeLookupInitFileEntry (NamePath, &ObjDesc)))
    584      1.1.1.12  christos                     {
    585      1.1.1.12  christos                         AcpiExWriteDataToField (ObjDesc,
    586      1.1.1.12  christos                             AcpiNsGetAttachedObject (Info->FieldNode),
    587      1.1.1.12  christos                             &ResultDesc);
    588      1.1.1.14  christos                         AcpiUtRemoveReference (ObjDesc);
    589      1.1.1.12  christos                     }
    590      1.1.1.12  christos                     ACPI_FREE (NamePath);
    591      1.1.1.12  christos #endif
    592           1.1    jruoho                 }
    593           1.1    jruoho             }
    594           1.1    jruoho 
    595           1.1    jruoho             /* Keep track of bit position for the next field */
    596           1.1    jruoho 
    597       1.1.1.7  christos             Position = (UINT64) Info->FieldBitPosition +
    598       1.1.1.7  christos                 (UINT64) Arg->Common.Value.Size;
    599           1.1    jruoho 
    600           1.1    jruoho             if (Position > ACPI_UINT32_MAX)
    601           1.1    jruoho             {
    602           1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    603           1.1    jruoho                     "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
    604           1.1    jruoho                     ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
    605           1.1    jruoho                 return_ACPI_STATUS (AE_SUPPORT);
    606           1.1    jruoho             }
    607           1.1    jruoho 
    608           1.1    jruoho             Info->FieldBitPosition += Info->FieldBitLength;
    609       1.1.1.4  christos             Info->PinNumberIndex++; /* Index relative to previous Connection() */
    610           1.1    jruoho             break;
    611           1.1    jruoho 
    612           1.1    jruoho         default:
    613           1.1    jruoho 
    614           1.1    jruoho             ACPI_ERROR ((AE_INFO,
    615       1.1.1.7  christos                 "Invalid opcode in field list: 0x%X",
    616       1.1.1.7  christos                 Arg->Common.AmlOpcode));
    617           1.1    jruoho             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
    618           1.1    jruoho         }
    619           1.1    jruoho 
    620           1.1    jruoho         Arg = Arg->Common.Next;
    621           1.1    jruoho     }
    622           1.1    jruoho 
    623           1.1    jruoho     return_ACPI_STATUS (AE_OK);
    624           1.1    jruoho }
    625           1.1    jruoho 
    626           1.1    jruoho 
    627           1.1    jruoho /*******************************************************************************
    628           1.1    jruoho  *
    629           1.1    jruoho  * FUNCTION:    AcpiDsCreateField
    630           1.1    jruoho  *
    631           1.1    jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    632           1.1    jruoho  *              RegionNode      - Object for the containing Operation Region
    633           1.1    jruoho  *  `           WalkState       - Current method state
    634           1.1    jruoho  *
    635           1.1    jruoho  * RETURN:      Status
    636           1.1    jruoho  *
    637           1.1    jruoho  * DESCRIPTION: Create a new field in the specified operation region
    638           1.1    jruoho  *
    639           1.1    jruoho  ******************************************************************************/
    640           1.1    jruoho 
    641           1.1    jruoho ACPI_STATUS
    642           1.1    jruoho AcpiDsCreateField (
    643           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    644           1.1    jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    645           1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    646           1.1    jruoho {
    647           1.1    jruoho     ACPI_STATUS             Status;
    648           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    649           1.1    jruoho     ACPI_CREATE_FIELD_INFO  Info;
    650           1.1    jruoho 
    651           1.1    jruoho 
    652           1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
    653           1.1    jruoho 
    654           1.1    jruoho 
    655           1.1    jruoho     /* First arg is the name of the parent OpRegion (must already exist) */
    656           1.1    jruoho 
    657           1.1    jruoho     Arg = Op->Common.Value.Arg;
    658       1.1.1.3  christos 
    659           1.1    jruoho     if (!RegionNode)
    660           1.1    jruoho     {
    661           1.1    jruoho         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
    662       1.1.1.7  christos             ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
    663       1.1.1.7  christos             ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
    664       1.1.1.3  christos #ifdef ACPI_ASL_COMPILER
    665       1.1.1.3  christos         Status = AcpiDsCreateExternalRegion (Status, Arg,
    666       1.1.1.3  christos             Arg->Common.Value.Name, WalkState, &RegionNode);
    667       1.1.1.3  christos #endif
    668           1.1    jruoho         if (ACPI_FAILURE (Status))
    669           1.1    jruoho         {
    670      1.1.1.10  christos             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    671      1.1.1.10  christos                 Arg->Common.Value.Name, Status);
    672           1.1    jruoho             return_ACPI_STATUS (Status);
    673           1.1    jruoho         }
    674           1.1    jruoho     }
    675           1.1    jruoho 
    676       1.1.1.6  christos     memset (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
    677       1.1.1.3  christos 
    678           1.1    jruoho     /* Second arg is the field flags */
    679           1.1    jruoho 
    680           1.1    jruoho     Arg = Arg->Common.Next;
    681           1.1    jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    682           1.1    jruoho     Info.Attribute = 0;
    683           1.1    jruoho 
    684           1.1    jruoho     /* Each remaining arg is a Named Field */
    685           1.1    jruoho 
    686           1.1    jruoho     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
    687           1.1    jruoho     Info.RegionNode = RegionNode;
    688           1.1    jruoho 
    689           1.1    jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
    690      1.1.1.16  christos     if (ACPI_FAILURE (Status))
    691      1.1.1.13  christos     {
    692      1.1.1.16  christos         return_ACPI_STATUS (Status);
    693      1.1.1.13  christos     }
    694      1.1.1.16  christos 
    695      1.1.1.16  christos     if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)
    696      1.1.1.16  christos     {
    697      1.1.1.16  christos         RegionNode->Object->Field.InternalPccBuffer =
    698      1.1.1.16  christos             ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length);
    699      1.1.1.16  christos         if (!RegionNode->Object->Field.InternalPccBuffer)
    700      1.1.1.16  christos         {
    701      1.1.1.16  christos             return_ACPI_STATUS (AE_NO_MEMORY);
    702      1.1.1.16  christos         }
    703      1.1.1.16  christos     }
    704      1.1.1.16  christos 
    705           1.1    jruoho     return_ACPI_STATUS (Status);
    706           1.1    jruoho }
    707           1.1    jruoho 
    708           1.1    jruoho 
    709           1.1    jruoho /*******************************************************************************
    710           1.1    jruoho  *
    711           1.1    jruoho  * FUNCTION:    AcpiDsInitFieldObjects
    712           1.1    jruoho  *
    713           1.1    jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    714           1.1    jruoho  *  `           WalkState       - Current method state
    715           1.1    jruoho  *
    716           1.1    jruoho  * RETURN:      Status
    717           1.1    jruoho  *
    718           1.1    jruoho  * DESCRIPTION: For each "Field Unit" name in the argument list that is
    719           1.1    jruoho  *              part of the field declaration, enter the name into the
    720           1.1    jruoho  *              namespace.
    721           1.1    jruoho  *
    722           1.1    jruoho  ******************************************************************************/
    723           1.1    jruoho 
    724           1.1    jruoho ACPI_STATUS
    725           1.1    jruoho AcpiDsInitFieldObjects (
    726           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    727           1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    728           1.1    jruoho {
    729           1.1    jruoho     ACPI_STATUS             Status;
    730           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg = NULL;
    731           1.1    jruoho     ACPI_NAMESPACE_NODE     *Node;
    732           1.1    jruoho     UINT8                   Type = 0;
    733           1.1    jruoho     UINT32                  Flags;
    734           1.1    jruoho 
    735           1.1    jruoho 
    736           1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
    737           1.1    jruoho 
    738           1.1    jruoho 
    739           1.1    jruoho     /* Execute flag should always be set when this function is entered */
    740           1.1    jruoho 
    741           1.1    jruoho     if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
    742           1.1    jruoho     {
    743           1.1    jruoho         if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
    744           1.1    jruoho         {
    745           1.1    jruoho             /* BankField Op is deferred, just return OK */
    746           1.1    jruoho 
    747           1.1    jruoho             return_ACPI_STATUS (AE_OK);
    748           1.1    jruoho         }
    749           1.1    jruoho 
    750       1.1.1.9  christos         ACPI_ERROR ((AE_INFO,
    751       1.1.1.9  christos             "Parse deferred mode is not set"));
    752           1.1    jruoho         return_ACPI_STATUS (AE_AML_INTERNAL);
    753           1.1    jruoho     }
    754           1.1    jruoho 
    755           1.1    jruoho     /*
    756           1.1    jruoho      * Get the FieldList argument for this opcode. This is the start of the
    757           1.1    jruoho      * list of field elements.
    758           1.1    jruoho      */
    759           1.1    jruoho     switch (WalkState->Opcode)
    760           1.1    jruoho     {
    761           1.1    jruoho     case AML_FIELD_OP:
    762       1.1.1.3  christos 
    763           1.1    jruoho         Arg = AcpiPsGetArg (Op, 2);
    764           1.1    jruoho         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
    765           1.1    jruoho         break;
    766           1.1    jruoho 
    767           1.1    jruoho     case AML_BANK_FIELD_OP:
    768       1.1.1.3  christos 
    769           1.1    jruoho         Arg = AcpiPsGetArg (Op, 4);
    770           1.1    jruoho         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
    771           1.1    jruoho         break;
    772           1.1    jruoho 
    773           1.1    jruoho     case AML_INDEX_FIELD_OP:
    774       1.1.1.3  christos 
    775           1.1    jruoho         Arg = AcpiPsGetArg (Op, 3);
    776           1.1    jruoho         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
    777           1.1    jruoho         break;
    778           1.1    jruoho 
    779           1.1    jruoho     default:
    780       1.1.1.3  christos 
    781           1.1    jruoho         return_ACPI_STATUS (AE_BAD_PARAMETER);
    782           1.1    jruoho     }
    783           1.1    jruoho 
    784           1.1    jruoho     /* Creating new namespace node(s), should not already exist */
    785           1.1    jruoho 
    786           1.1    jruoho     Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
    787       1.1.1.7  christos         ACPI_NS_ERROR_IF_FOUND;
    788           1.1    jruoho 
    789           1.1    jruoho     /*
    790           1.1    jruoho      * Mark node(s) temporary if we are executing a normal control
    791           1.1    jruoho      * method. (Don't mark if this is a module-level code method)
    792           1.1    jruoho      */
    793           1.1    jruoho     if (WalkState->MethodNode &&
    794           1.1    jruoho         !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    795           1.1    jruoho     {
    796           1.1    jruoho         Flags |= ACPI_NS_TEMPORARY;
    797           1.1    jruoho     }
    798           1.1    jruoho 
    799      1.1.1.12  christos #ifdef ACPI_EXEC_APP
    800      1.1.1.18  christos     Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
    801      1.1.1.12  christos #endif
    802           1.1    jruoho     /*
    803           1.1    jruoho      * Walk the list of entries in the FieldList
    804           1.1    jruoho      * Note: FieldList can be of zero length. In this case, Arg will be NULL.
    805           1.1    jruoho      */
    806           1.1    jruoho     while (Arg)
    807           1.1    jruoho     {
    808           1.1    jruoho         /*
    809       1.1.1.3  christos          * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
    810       1.1.1.3  christos          * in the field names in order to enter them into the namespace.
    811           1.1    jruoho          */
    812           1.1    jruoho         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
    813           1.1    jruoho         {
    814           1.1    jruoho             Status = AcpiNsLookup (WalkState->ScopeInfo,
    815       1.1.1.7  christos                 (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
    816       1.1.1.7  christos                 Flags, WalkState, &Node);
    817           1.1    jruoho             if (ACPI_FAILURE (Status))
    818           1.1    jruoho             {
    819      1.1.1.10  christos                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    820      1.1.1.10  christos                     (char *) &Arg->Named.Name, Status);
    821           1.1    jruoho                 if (Status != AE_ALREADY_EXISTS)
    822           1.1    jruoho                 {
    823           1.1    jruoho                     return_ACPI_STATUS (Status);
    824           1.1    jruoho                 }
    825           1.1    jruoho 
    826           1.1    jruoho                 /* Name already exists, just ignore this error */
    827           1.1    jruoho             }
    828           1.1    jruoho 
    829           1.1    jruoho             Arg->Common.Node = Node;
    830           1.1    jruoho         }
    831           1.1    jruoho 
    832           1.1    jruoho         /* Get the next field element in the list */
    833           1.1    jruoho 
    834           1.1    jruoho         Arg = Arg->Common.Next;
    835           1.1    jruoho     }
    836           1.1    jruoho 
    837           1.1    jruoho     return_ACPI_STATUS (AE_OK);
    838           1.1    jruoho }
    839           1.1    jruoho 
    840           1.1    jruoho 
    841           1.1    jruoho /*******************************************************************************
    842           1.1    jruoho  *
    843           1.1    jruoho  * FUNCTION:    AcpiDsCreateBankField
    844           1.1    jruoho  *
    845           1.1    jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    846           1.1    jruoho  *              RegionNode      - Object for the containing Operation Region
    847           1.1    jruoho  *              WalkState       - Current method state
    848           1.1    jruoho  *
    849           1.1    jruoho  * RETURN:      Status
    850           1.1    jruoho  *
    851           1.1    jruoho  * DESCRIPTION: Create a new bank field in the specified operation region
    852           1.1    jruoho  *
    853           1.1    jruoho  ******************************************************************************/
    854           1.1    jruoho 
    855           1.1    jruoho ACPI_STATUS
    856           1.1    jruoho AcpiDsCreateBankField (
    857           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    858           1.1    jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    859           1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    860           1.1    jruoho {
    861           1.1    jruoho     ACPI_STATUS             Status;
    862           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    863           1.1    jruoho     ACPI_CREATE_FIELD_INFO  Info;
    864           1.1    jruoho 
    865           1.1    jruoho 
    866           1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
    867           1.1    jruoho 
    868           1.1    jruoho 
    869           1.1    jruoho     /* First arg is the name of the parent OpRegion (must already exist) */
    870           1.1    jruoho 
    871           1.1    jruoho     Arg = Op->Common.Value.Arg;
    872           1.1    jruoho     if (!RegionNode)
    873           1.1    jruoho     {
    874           1.1    jruoho         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
    875       1.1.1.7  christos             ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
    876       1.1.1.7  christos             ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
    877       1.1.1.3  christos #ifdef ACPI_ASL_COMPILER
    878       1.1.1.3  christos         Status = AcpiDsCreateExternalRegion (Status, Arg,
    879       1.1.1.3  christos             Arg->Common.Value.Name, WalkState, &RegionNode);
    880       1.1.1.3  christos #endif
    881           1.1    jruoho         if (ACPI_FAILURE (Status))
    882           1.1    jruoho         {
    883      1.1.1.10  christos             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    884      1.1.1.10  christos                 Arg->Common.Value.Name, Status);
    885           1.1    jruoho             return_ACPI_STATUS (Status);
    886           1.1    jruoho         }
    887           1.1    jruoho     }
    888           1.1    jruoho 
    889           1.1    jruoho     /* Second arg is the Bank Register (Field) (must already exist) */
    890           1.1    jruoho 
    891           1.1    jruoho     Arg = Arg->Common.Next;
    892           1.1    jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    893       1.1.1.7  christos         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    894       1.1.1.7  christos         ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
    895           1.1    jruoho     if (ACPI_FAILURE (Status))
    896           1.1    jruoho     {
    897      1.1.1.10  christos         ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    898      1.1.1.10  christos             Arg->Common.Value.String, Status);
    899           1.1    jruoho         return_ACPI_STATUS (Status);
    900           1.1    jruoho     }
    901           1.1    jruoho 
    902           1.1    jruoho     /*
    903           1.1    jruoho      * Third arg is the BankValue
    904           1.1    jruoho      * This arg is a TermArg, not a constant
    905           1.1    jruoho      * It will be evaluated later, by AcpiDsEvalBankFieldOperands
    906           1.1    jruoho      */
    907           1.1    jruoho     Arg = Arg->Common.Next;
    908           1.1    jruoho 
    909           1.1    jruoho     /* Fourth arg is the field flags */
    910           1.1    jruoho 
    911           1.1    jruoho     Arg = Arg->Common.Next;
    912           1.1    jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    913           1.1    jruoho 
    914           1.1    jruoho     /* Each remaining arg is a Named Field */
    915           1.1    jruoho 
    916           1.1    jruoho     Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
    917           1.1    jruoho     Info.RegionNode = RegionNode;
    918           1.1    jruoho 
    919           1.1    jruoho     /*
    920           1.1    jruoho      * Use Info.DataRegisterNode to store BankField Op
    921       1.1.1.7  christos      * It's safe because DataRegisterNode will never be used when create
    922       1.1.1.7  christos      * bank field \we store AmlStart and AmlLength in the BankField Op for
    923       1.1.1.7  christos      * late evaluation. Used in AcpiExPrepFieldValue(Info)
    924           1.1    jruoho      *
    925       1.1.1.7  christos      * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like
    926       1.1.1.7  christos      * "void *ParentOp"?
    927           1.1    jruoho      */
    928           1.1    jruoho     Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
    929           1.1    jruoho 
    930           1.1    jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
    931           1.1    jruoho     return_ACPI_STATUS (Status);
    932           1.1    jruoho }
    933           1.1    jruoho 
    934           1.1    jruoho 
    935           1.1    jruoho /*******************************************************************************
    936           1.1    jruoho  *
    937           1.1    jruoho  * FUNCTION:    AcpiDsCreateIndexField
    938           1.1    jruoho  *
    939           1.1    jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    940           1.1    jruoho  *              RegionNode      - Object for the containing Operation Region
    941           1.1    jruoho  *  `           WalkState       - Current method state
    942           1.1    jruoho  *
    943           1.1    jruoho  * RETURN:      Status
    944           1.1    jruoho  *
    945           1.1    jruoho  * DESCRIPTION: Create a new index field in the specified operation region
    946           1.1    jruoho  *
    947           1.1    jruoho  ******************************************************************************/
    948           1.1    jruoho 
    949           1.1    jruoho ACPI_STATUS
    950           1.1    jruoho AcpiDsCreateIndexField (
    951           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    952           1.1    jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    953           1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    954           1.1    jruoho {
    955           1.1    jruoho     ACPI_STATUS             Status;
    956           1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    957           1.1    jruoho     ACPI_CREATE_FIELD_INFO  Info;
    958           1.1    jruoho 
    959           1.1    jruoho 
    960           1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op);
    961           1.1    jruoho 
    962           1.1    jruoho 
    963           1.1    jruoho     /* First arg is the name of the Index register (must already exist) */
    964           1.1    jruoho 
    965           1.1    jruoho     Arg = Op->Common.Value.Arg;
    966           1.1    jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    967       1.1.1.7  christos         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    968       1.1.1.7  christos         ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
    969           1.1    jruoho     if (ACPI_FAILURE (Status))
    970           1.1    jruoho     {
    971      1.1.1.10  christos         ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    972      1.1.1.10  christos             Arg->Common.Value.String, Status);
    973           1.1    jruoho         return_ACPI_STATUS (Status);
    974           1.1    jruoho     }
    975           1.1    jruoho 
    976           1.1    jruoho     /* Second arg is the data register (must already exist) */
    977           1.1    jruoho 
    978           1.1    jruoho     Arg = Arg->Common.Next;
    979           1.1    jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    980       1.1.1.7  christos         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    981       1.1.1.7  christos         ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
    982           1.1    jruoho     if (ACPI_FAILURE (Status))
    983           1.1    jruoho     {
    984      1.1.1.10  christos         ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    985      1.1.1.10  christos             Arg->Common.Value.String, Status);
    986           1.1    jruoho         return_ACPI_STATUS (Status);
    987           1.1    jruoho     }
    988           1.1    jruoho 
    989           1.1    jruoho     /* Next arg is the field flags */
    990           1.1    jruoho 
    991           1.1    jruoho     Arg = Arg->Common.Next;
    992           1.1    jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    993           1.1    jruoho 
    994           1.1    jruoho     /* Each remaining arg is a Named Field */
    995           1.1    jruoho 
    996           1.1    jruoho     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
    997           1.1    jruoho     Info.RegionNode = RegionNode;
    998           1.1    jruoho 
    999           1.1    jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
   1000           1.1    jruoho     return_ACPI_STATUS (Status);
   1001           1.1    jruoho }
   1002