Home | History | Annotate | Line # | Download | only in dispatcher
dsfield.c revision 1.1.1.2.10.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.2  jruoho /*
      8  1.1.1.2.10.1    yamt  * Copyright (C) 2000 - 2013, Intel Corp.
      9           1.1  jruoho  * All rights reserved.
     10           1.1  jruoho  *
     11       1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     12       1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     13       1.1.1.2  jruoho  * are met:
     14       1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     15       1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     16       1.1.1.2  jruoho  *    without modification.
     17       1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     21       1.1.1.2  jruoho  *    binary redistribution.
     22       1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     24       1.1.1.2  jruoho  *    from this software without specific prior written permission.
     25       1.1.1.2  jruoho  *
     26       1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     27       1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1.1.2  jruoho  * Software Foundation.
     29       1.1.1.2  jruoho  *
     30       1.1.1.2  jruoho  * NO WARRANTY
     31       1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33       1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34       1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1.1.2  jruoho  */
     43           1.1  jruoho 
     44           1.1  jruoho #define __DSFIELD_C__
     45           1.1  jruoho 
     46           1.1  jruoho #include "acpi.h"
     47           1.1  jruoho #include "accommon.h"
     48           1.1  jruoho #include "amlcode.h"
     49           1.1  jruoho #include "acdispat.h"
     50           1.1  jruoho #include "acinterp.h"
     51           1.1  jruoho #include "acnamesp.h"
     52           1.1  jruoho #include "acparser.h"
     53           1.1  jruoho 
     54           1.1  jruoho 
     55           1.1  jruoho #define _COMPONENT          ACPI_DISPATCHER
     56           1.1  jruoho         ACPI_MODULE_NAME    ("dsfield")
     57           1.1  jruoho 
     58           1.1  jruoho /* Local prototypes */
     59           1.1  jruoho 
     60  1.1.1.2.10.1    yamt #ifdef ACPI_ASL_COMPILER
     61  1.1.1.2.10.1    yamt #include "acdisasm.h"
     62  1.1.1.2.10.1    yamt 
     63  1.1.1.2.10.1    yamt static ACPI_STATUS
     64  1.1.1.2.10.1    yamt AcpiDsCreateExternalRegion (
     65  1.1.1.2.10.1    yamt     ACPI_STATUS             LookupStatus,
     66  1.1.1.2.10.1    yamt     ACPI_PARSE_OBJECT       *Op,
     67  1.1.1.2.10.1    yamt     char                    *Path,
     68  1.1.1.2.10.1    yamt     ACPI_WALK_STATE         *WalkState,
     69  1.1.1.2.10.1    yamt     ACPI_NAMESPACE_NODE     **Node);
     70  1.1.1.2.10.1    yamt #endif
     71  1.1.1.2.10.1    yamt 
     72           1.1  jruoho static ACPI_STATUS
     73           1.1  jruoho AcpiDsGetFieldNames (
     74           1.1  jruoho     ACPI_CREATE_FIELD_INFO  *Info,
     75           1.1  jruoho     ACPI_WALK_STATE         *WalkState,
     76           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg);
     77           1.1  jruoho 
     78           1.1  jruoho 
     79  1.1.1.2.10.1    yamt #ifdef ACPI_ASL_COMPILER
     80  1.1.1.2.10.1    yamt /*******************************************************************************
     81  1.1.1.2.10.1    yamt  *
     82  1.1.1.2.10.1    yamt  * FUNCTION:    AcpiDsCreateExternalRegion (iASL Disassembler only)
     83  1.1.1.2.10.1    yamt  *
     84  1.1.1.2.10.1    yamt  * PARAMETERS:  LookupStatus    - Status from NsLookup operation
     85  1.1.1.2.10.1    yamt  *              Op              - Op containing the Field definition and args
     86  1.1.1.2.10.1    yamt  *              Path            - Pathname of the region
     87  1.1.1.2.10.1    yamt  *  `           WalkState       - Current method state
     88  1.1.1.2.10.1    yamt  *              Node            - Where the new region node is returned
     89  1.1.1.2.10.1    yamt  *
     90  1.1.1.2.10.1    yamt  * RETURN:      Status
     91  1.1.1.2.10.1    yamt  *
     92  1.1.1.2.10.1    yamt  * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
     93  1.1.1.2.10.1    yamt  *              region node/object.
     94  1.1.1.2.10.1    yamt  *
     95  1.1.1.2.10.1    yamt  ******************************************************************************/
     96  1.1.1.2.10.1    yamt 
     97  1.1.1.2.10.1    yamt static ACPI_STATUS
     98  1.1.1.2.10.1    yamt AcpiDsCreateExternalRegion (
     99  1.1.1.2.10.1    yamt     ACPI_STATUS             LookupStatus,
    100  1.1.1.2.10.1    yamt     ACPI_PARSE_OBJECT       *Op,
    101  1.1.1.2.10.1    yamt     char                    *Path,
    102  1.1.1.2.10.1    yamt     ACPI_WALK_STATE         *WalkState,
    103  1.1.1.2.10.1    yamt     ACPI_NAMESPACE_NODE     **Node)
    104  1.1.1.2.10.1    yamt {
    105  1.1.1.2.10.1    yamt     ACPI_STATUS             Status;
    106  1.1.1.2.10.1    yamt     ACPI_OPERAND_OBJECT     *ObjDesc;
    107  1.1.1.2.10.1    yamt 
    108  1.1.1.2.10.1    yamt 
    109  1.1.1.2.10.1    yamt     if (LookupStatus != AE_NOT_FOUND)
    110  1.1.1.2.10.1    yamt     {
    111  1.1.1.2.10.1    yamt         return (LookupStatus);
    112  1.1.1.2.10.1    yamt     }
    113  1.1.1.2.10.1    yamt 
    114  1.1.1.2.10.1    yamt     /*
    115  1.1.1.2.10.1    yamt      * Table disassembly:
    116  1.1.1.2.10.1    yamt      * OperationRegion not found. Generate an External for it, and
    117  1.1.1.2.10.1    yamt      * insert the name into the namespace.
    118  1.1.1.2.10.1    yamt      */
    119  1.1.1.2.10.1    yamt     AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0);
    120  1.1.1.2.10.1    yamt     Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION,
    121  1.1.1.2.10.1    yamt        ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node);
    122  1.1.1.2.10.1    yamt     if (ACPI_FAILURE (Status))
    123  1.1.1.2.10.1    yamt     {
    124  1.1.1.2.10.1    yamt         return (Status);
    125  1.1.1.2.10.1    yamt     }
    126  1.1.1.2.10.1    yamt 
    127  1.1.1.2.10.1    yamt     /* Must create and install a region object for the new node */
    128  1.1.1.2.10.1    yamt 
    129  1.1.1.2.10.1    yamt     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
    130  1.1.1.2.10.1    yamt     if (!ObjDesc)
    131  1.1.1.2.10.1    yamt     {
    132  1.1.1.2.10.1    yamt         return (AE_NO_MEMORY);
    133  1.1.1.2.10.1    yamt     }
    134  1.1.1.2.10.1    yamt 
    135  1.1.1.2.10.1    yamt     ObjDesc->Region.Node = *Node;
    136  1.1.1.2.10.1    yamt     Status = AcpiNsAttachObject (*Node, ObjDesc, ACPI_TYPE_REGION);
    137  1.1.1.2.10.1    yamt     return (Status);
    138  1.1.1.2.10.1    yamt }
    139  1.1.1.2.10.1    yamt #endif
    140  1.1.1.2.10.1    yamt 
    141  1.1.1.2.10.1    yamt 
    142           1.1  jruoho /*******************************************************************************
    143           1.1  jruoho  *
    144           1.1  jruoho  * FUNCTION:    AcpiDsCreateBufferField
    145           1.1  jruoho  *
    146           1.1  jruoho  * PARAMETERS:  Op                  - Current parse op (CreateXXField)
    147           1.1  jruoho  *              WalkState           - Current state
    148           1.1  jruoho  *
    149           1.1  jruoho  * RETURN:      Status
    150           1.1  jruoho  *
    151           1.1  jruoho  * DESCRIPTION: Execute the CreateField operators:
    152           1.1  jruoho  *              CreateBitFieldOp,
    153           1.1  jruoho  *              CreateByteFieldOp,
    154           1.1  jruoho  *              CreateWordFieldOp,
    155  1.1.1.2.10.1    yamt  *              CreateDwordFieldOp,
    156  1.1.1.2.10.1    yamt  *              CreateQwordFieldOp,
    157           1.1  jruoho  *              CreateFieldOp       (all of which define a field in a buffer)
    158           1.1  jruoho  *
    159           1.1  jruoho  ******************************************************************************/
    160           1.1  jruoho 
    161           1.1  jruoho ACPI_STATUS
    162           1.1  jruoho AcpiDsCreateBufferField (
    163           1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    164           1.1  jruoho     ACPI_WALK_STATE         *WalkState)
    165           1.1  jruoho {
    166           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg;
    167           1.1  jruoho     ACPI_NAMESPACE_NODE     *Node;
    168           1.1  jruoho     ACPI_STATUS             Status;
    169           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    170           1.1  jruoho     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
    171           1.1  jruoho     UINT32                  Flags;
    172           1.1  jruoho 
    173           1.1  jruoho 
    174           1.1  jruoho     ACPI_FUNCTION_TRACE (DsCreateBufferField);
    175           1.1  jruoho 
    176           1.1  jruoho 
    177           1.1  jruoho     /*
    178           1.1  jruoho      * Get the NameString argument (name of the new BufferField)
    179           1.1  jruoho      */
    180           1.1  jruoho     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
    181           1.1  jruoho     {
    182           1.1  jruoho         /* For CreateField, name is the 4th argument */
    183           1.1  jruoho 
    184           1.1  jruoho         Arg = AcpiPsGetArg (Op, 3);
    185           1.1  jruoho     }
    186           1.1  jruoho     else
    187           1.1  jruoho     {
    188           1.1  jruoho         /* For all other CreateXXXField operators, name is the 3rd argument */
    189           1.1  jruoho 
    190           1.1  jruoho         Arg = AcpiPsGetArg (Op, 2);
    191           1.1  jruoho     }
    192           1.1  jruoho 
    193           1.1  jruoho     if (!Arg)
    194           1.1  jruoho     {
    195           1.1  jruoho         return_ACPI_STATUS (AE_AML_NO_OPERAND);
    196           1.1  jruoho     }
    197           1.1  jruoho 
    198           1.1  jruoho     if (WalkState->DeferredNode)
    199           1.1  jruoho     {
    200           1.1  jruoho         Node = WalkState->DeferredNode;
    201           1.1  jruoho         Status = AE_OK;
    202           1.1  jruoho     }
    203           1.1  jruoho     else
    204           1.1  jruoho     {
    205           1.1  jruoho         /* Execute flag should always be set when this function is entered */
    206           1.1  jruoho 
    207           1.1  jruoho         if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
    208           1.1  jruoho         {
    209           1.1  jruoho             return_ACPI_STATUS (AE_AML_INTERNAL);
    210           1.1  jruoho         }
    211           1.1  jruoho 
    212           1.1  jruoho         /* Creating new namespace node, should not already exist */
    213           1.1  jruoho 
    214           1.1  jruoho         Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
    215           1.1  jruoho                 ACPI_NS_ERROR_IF_FOUND;
    216           1.1  jruoho 
    217           1.1  jruoho         /*
    218           1.1  jruoho          * Mark node temporary if we are executing a normal control
    219           1.1  jruoho          * method. (Don't mark if this is a module-level code method)
    220           1.1  jruoho          */
    221           1.1  jruoho         if (WalkState->MethodNode &&
    222           1.1  jruoho             !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    223           1.1  jruoho         {
    224           1.1  jruoho             Flags |= ACPI_NS_TEMPORARY;
    225           1.1  jruoho         }
    226           1.1  jruoho 
    227           1.1  jruoho         /* Enter the NameString into the namespace */
    228           1.1  jruoho 
    229           1.1  jruoho         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    230           1.1  jruoho                     ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
    231           1.1  jruoho                     Flags, WalkState, &Node);
    232           1.1  jruoho         if (ACPI_FAILURE (Status))
    233           1.1  jruoho         {
    234           1.1  jruoho             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
    235           1.1  jruoho             return_ACPI_STATUS (Status);
    236           1.1  jruoho         }
    237           1.1  jruoho     }
    238           1.1  jruoho 
    239           1.1  jruoho     /*
    240           1.1  jruoho      * We could put the returned object (Node) on the object stack for later,
    241           1.1  jruoho      * but for now, we will put it in the "op" object that the parser uses,
    242           1.1  jruoho      * so we can get it again at the end of this scope.
    243           1.1  jruoho      */
    244           1.1  jruoho     Op->Common.Node = Node;
    245           1.1  jruoho 
    246           1.1  jruoho     /*
    247           1.1  jruoho      * If there is no object attached to the node, this node was just created
    248           1.1  jruoho      * and we need to create the field object. Otherwise, this was a lookup
    249           1.1  jruoho      * of an existing node and we don't want to create the field object again.
    250           1.1  jruoho      */
    251           1.1  jruoho     ObjDesc = AcpiNsGetAttachedObject (Node);
    252           1.1  jruoho     if (ObjDesc)
    253           1.1  jruoho     {
    254           1.1  jruoho         return_ACPI_STATUS (AE_OK);
    255           1.1  jruoho     }
    256           1.1  jruoho 
    257           1.1  jruoho     /*
    258           1.1  jruoho      * The Field definition is not fully parsed at this time.
    259           1.1  jruoho      * (We must save the address of the AML for the buffer and index operands)
    260           1.1  jruoho      */
    261           1.1  jruoho 
    262           1.1  jruoho     /* Create the buffer field object */
    263           1.1  jruoho 
    264           1.1  jruoho     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
    265           1.1  jruoho     if (!ObjDesc)
    266           1.1  jruoho     {
    267           1.1  jruoho         Status = AE_NO_MEMORY;
    268           1.1  jruoho         goto Cleanup;
    269           1.1  jruoho     }
    270           1.1  jruoho 
    271           1.1  jruoho     /*
    272           1.1  jruoho      * Remember location in AML stream of the field unit opcode and operands --
    273           1.1  jruoho      * since the buffer and index operands must be evaluated.
    274           1.1  jruoho      */
    275           1.1  jruoho     SecondDesc                  = ObjDesc->Common.NextObject;
    276           1.1  jruoho     SecondDesc->Extra.AmlStart  = Op->Named.Data;
    277           1.1  jruoho     SecondDesc->Extra.AmlLength = Op->Named.Length;
    278           1.1  jruoho     ObjDesc->BufferField.Node   = Node;
    279           1.1  jruoho 
    280           1.1  jruoho     /* Attach constructed field descriptors to parent node */
    281           1.1  jruoho 
    282           1.1  jruoho     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD);
    283           1.1  jruoho     if (ACPI_FAILURE (Status))
    284           1.1  jruoho     {
    285           1.1  jruoho         goto Cleanup;
    286           1.1  jruoho     }
    287           1.1  jruoho 
    288           1.1  jruoho 
    289           1.1  jruoho Cleanup:
    290           1.1  jruoho 
    291           1.1  jruoho     /* Remove local reference to the object */
    292           1.1  jruoho 
    293           1.1  jruoho     AcpiUtRemoveReference (ObjDesc);
    294           1.1  jruoho     return_ACPI_STATUS (Status);
    295           1.1  jruoho }
    296           1.1  jruoho 
    297           1.1  jruoho 
    298           1.1  jruoho /*******************************************************************************
    299           1.1  jruoho  *
    300           1.1  jruoho  * FUNCTION:    AcpiDsGetFieldNames
    301           1.1  jruoho  *
    302           1.1  jruoho  * PARAMETERS:  Info            - CreateField info structure
    303           1.1  jruoho  *  `           WalkState       - Current method state
    304           1.1  jruoho  *              Arg             - First parser arg for the field name list
    305           1.1  jruoho  *
    306           1.1  jruoho  * RETURN:      Status
    307           1.1  jruoho  *
    308  1.1.1.2.10.1    yamt  * DESCRIPTION: Process all named fields in a field declaration. Names are
    309           1.1  jruoho  *              entered into the namespace.
    310           1.1  jruoho  *
    311           1.1  jruoho  ******************************************************************************/
    312           1.1  jruoho 
    313           1.1  jruoho static ACPI_STATUS
    314           1.1  jruoho AcpiDsGetFieldNames (
    315           1.1  jruoho     ACPI_CREATE_FIELD_INFO  *Info,
    316           1.1  jruoho     ACPI_WALK_STATE         *WalkState,
    317           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg)
    318           1.1  jruoho {
    319           1.1  jruoho     ACPI_STATUS             Status;
    320           1.1  jruoho     UINT64                  Position;
    321  1.1.1.2.10.1    yamt     ACPI_PARSE_OBJECT       *Child;
    322           1.1  jruoho 
    323           1.1  jruoho 
    324           1.1  jruoho     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
    325           1.1  jruoho 
    326           1.1  jruoho 
    327           1.1  jruoho     /* First field starts at bit zero */
    328           1.1  jruoho 
    329           1.1  jruoho     Info->FieldBitPosition = 0;
    330           1.1  jruoho 
    331           1.1  jruoho     /* Process all elements in the field list (of parse nodes) */
    332           1.1  jruoho 
    333           1.1  jruoho     while (Arg)
    334           1.1  jruoho     {
    335           1.1  jruoho         /*
    336  1.1.1.2.10.1    yamt          * Four types of field elements are handled:
    337  1.1.1.2.10.1    yamt          * 1) Name - Enters a new named field into the namespace
    338  1.1.1.2.10.1    yamt          * 2) Offset - specifies a bit offset
    339  1.1.1.2.10.1    yamt          * 3) AccessAs - changes the access mode/attributes
    340  1.1.1.2.10.1    yamt          * 4) Connection - Associate a resource template with the field
    341           1.1  jruoho          */
    342           1.1  jruoho         switch (Arg->Common.AmlOpcode)
    343           1.1  jruoho         {
    344           1.1  jruoho         case AML_INT_RESERVEDFIELD_OP:
    345           1.1  jruoho 
    346           1.1  jruoho             Position = (UINT64) Info->FieldBitPosition
    347           1.1  jruoho                         + (UINT64) Arg->Common.Value.Size;
    348           1.1  jruoho 
    349           1.1  jruoho             if (Position > ACPI_UINT32_MAX)
    350           1.1  jruoho             {
    351           1.1  jruoho                 ACPI_ERROR ((AE_INFO,
    352           1.1  jruoho                     "Bit offset within field too large (> 0xFFFFFFFF)"));
    353           1.1  jruoho                 return_ACPI_STATUS (AE_SUPPORT);
    354           1.1  jruoho             }
    355           1.1  jruoho 
    356           1.1  jruoho             Info->FieldBitPosition = (UINT32) Position;
    357           1.1  jruoho             break;
    358           1.1  jruoho 
    359           1.1  jruoho         case AML_INT_ACCESSFIELD_OP:
    360  1.1.1.2.10.1    yamt         case AML_INT_EXTACCESSFIELD_OP:
    361           1.1  jruoho             /*
    362  1.1.1.2.10.1    yamt              * Get new AccessType, AccessAttribute, and AccessLength fields
    363  1.1.1.2.10.1    yamt              * -- to be used for all field units that follow, until the
    364  1.1.1.2.10.1    yamt              * end-of-field or another AccessAs keyword is encountered.
    365  1.1.1.2.10.1    yamt              * NOTE. These three bytes are encoded in the integer value
    366  1.1.1.2.10.1    yamt              * of the parseop for convenience.
    367           1.1  jruoho              *
    368           1.1  jruoho              * In FieldFlags, preserve the flag bits other than the
    369  1.1.1.2.10.1    yamt              * ACCESS_TYPE bits.
    370           1.1  jruoho              */
    371  1.1.1.2.10.1    yamt 
    372  1.1.1.2.10.1    yamt             /* AccessType (ByteAcc, WordAcc, etc.) */
    373  1.1.1.2.10.1    yamt 
    374           1.1  jruoho             Info->FieldFlags = (UINT8)
    375           1.1  jruoho                 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
    376  1.1.1.2.10.1    yamt                 ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
    377  1.1.1.2.10.1    yamt 
    378  1.1.1.2.10.1    yamt             /* AccessAttribute (AttribQuick, AttribByte, etc.) */
    379  1.1.1.2.10.1    yamt 
    380  1.1.1.2.10.1    yamt             Info->Attribute = (UINT8) ((Arg->Common.Value.Integer >> 8) & 0xFF);
    381           1.1  jruoho 
    382  1.1.1.2.10.1    yamt             /* AccessLength (for serial/buffer protocols) */
    383  1.1.1.2.10.1    yamt 
    384  1.1.1.2.10.1    yamt             Info->AccessLength = (UINT8) ((Arg->Common.Value.Integer >> 16) & 0xFF);
    385           1.1  jruoho             break;
    386           1.1  jruoho 
    387  1.1.1.2.10.1    yamt         case AML_INT_CONNECTION_OP:
    388  1.1.1.2.10.1    yamt             /*
    389  1.1.1.2.10.1    yamt              * Clear any previous connection. New connection is used for all
    390  1.1.1.2.10.1    yamt              * fields that follow, similar to AccessAs
    391  1.1.1.2.10.1    yamt              */
    392  1.1.1.2.10.1    yamt             Info->ResourceBuffer = NULL;
    393  1.1.1.2.10.1    yamt             Info->ConnectionNode = NULL;
    394  1.1.1.2.10.1    yamt 
    395  1.1.1.2.10.1    yamt             /*
    396  1.1.1.2.10.1    yamt              * A Connection() is either an actual resource descriptor (buffer)
    397  1.1.1.2.10.1    yamt              * or a named reference to a resource template
    398  1.1.1.2.10.1    yamt              */
    399  1.1.1.2.10.1    yamt             Child = Arg->Common.Value.Arg;
    400  1.1.1.2.10.1    yamt             if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
    401  1.1.1.2.10.1    yamt             {
    402  1.1.1.2.10.1    yamt                 Info->ResourceBuffer = Child->Named.Data;
    403  1.1.1.2.10.1    yamt                 Info->ResourceLength = (UINT16) Child->Named.Value.Integer;
    404  1.1.1.2.10.1    yamt             }
    405  1.1.1.2.10.1    yamt             else
    406  1.1.1.2.10.1    yamt             {
    407  1.1.1.2.10.1    yamt                 /* Lookup the Connection() namepath, it should already exist */
    408  1.1.1.2.10.1    yamt 
    409  1.1.1.2.10.1    yamt                 Status = AcpiNsLookup (WalkState->ScopeInfo,
    410  1.1.1.2.10.1    yamt                             Child->Common.Value.Name, ACPI_TYPE_ANY,
    411  1.1.1.2.10.1    yamt                             ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
    412  1.1.1.2.10.1    yamt                             WalkState, &Info->ConnectionNode);
    413  1.1.1.2.10.1    yamt                 if (ACPI_FAILURE (Status))
    414  1.1.1.2.10.1    yamt                 {
    415  1.1.1.2.10.1    yamt                     ACPI_ERROR_NAMESPACE (Child->Common.Value.Name, Status);
    416  1.1.1.2.10.1    yamt                     return_ACPI_STATUS (Status);
    417  1.1.1.2.10.1    yamt                 }
    418  1.1.1.2.10.1    yamt             }
    419  1.1.1.2.10.1    yamt             break;
    420           1.1  jruoho 
    421           1.1  jruoho         case AML_INT_NAMEDFIELD_OP:
    422           1.1  jruoho 
    423           1.1  jruoho             /* Lookup the name, it should already exist */
    424           1.1  jruoho 
    425           1.1  jruoho             Status = AcpiNsLookup (WalkState->ScopeInfo,
    426           1.1  jruoho                         (char *) &Arg->Named.Name, Info->FieldType,
    427           1.1  jruoho                         ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
    428           1.1  jruoho                         WalkState, &Info->FieldNode);
    429           1.1  jruoho             if (ACPI_FAILURE (Status))
    430           1.1  jruoho             {
    431           1.1  jruoho                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
    432           1.1  jruoho                 return_ACPI_STATUS (Status);
    433           1.1  jruoho             }
    434           1.1  jruoho             else
    435           1.1  jruoho             {
    436           1.1  jruoho                 Arg->Common.Node = Info->FieldNode;
    437           1.1  jruoho                 Info->FieldBitLength = Arg->Common.Value.Size;
    438           1.1  jruoho 
    439           1.1  jruoho                 /*
    440           1.1  jruoho                  * If there is no object attached to the node, this node was
    441           1.1  jruoho                  * just created and we need to create the field object.
    442           1.1  jruoho                  * Otherwise, this was a lookup of an existing node and we
    443           1.1  jruoho                  * don't want to create the field object again.
    444           1.1  jruoho                  */
    445           1.1  jruoho                 if (!AcpiNsGetAttachedObject (Info->FieldNode))
    446           1.1  jruoho                 {
    447           1.1  jruoho                     Status = AcpiExPrepFieldValue (Info);
    448           1.1  jruoho                     if (ACPI_FAILURE (Status))
    449           1.1  jruoho                     {
    450           1.1  jruoho                         return_ACPI_STATUS (Status);
    451           1.1  jruoho                     }
    452           1.1  jruoho                 }
    453           1.1  jruoho             }
    454           1.1  jruoho 
    455           1.1  jruoho             /* Keep track of bit position for the next field */
    456           1.1  jruoho 
    457           1.1  jruoho             Position = (UINT64) Info->FieldBitPosition
    458           1.1  jruoho                         + (UINT64) Arg->Common.Value.Size;
    459           1.1  jruoho 
    460           1.1  jruoho             if (Position > ACPI_UINT32_MAX)
    461           1.1  jruoho             {
    462           1.1  jruoho                 ACPI_ERROR ((AE_INFO,
    463           1.1  jruoho                     "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
    464           1.1  jruoho                     ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
    465           1.1  jruoho                 return_ACPI_STATUS (AE_SUPPORT);
    466           1.1  jruoho             }
    467           1.1  jruoho 
    468           1.1  jruoho             Info->FieldBitPosition += Info->FieldBitLength;
    469           1.1  jruoho             break;
    470           1.1  jruoho 
    471           1.1  jruoho         default:
    472           1.1  jruoho 
    473           1.1  jruoho             ACPI_ERROR ((AE_INFO,
    474           1.1  jruoho                 "Invalid opcode in field list: 0x%X", Arg->Common.AmlOpcode));
    475           1.1  jruoho             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
    476           1.1  jruoho         }
    477           1.1  jruoho 
    478           1.1  jruoho         Arg = Arg->Common.Next;
    479           1.1  jruoho     }
    480           1.1  jruoho 
    481           1.1  jruoho     return_ACPI_STATUS (AE_OK);
    482           1.1  jruoho }
    483           1.1  jruoho 
    484           1.1  jruoho 
    485           1.1  jruoho /*******************************************************************************
    486           1.1  jruoho  *
    487           1.1  jruoho  * FUNCTION:    AcpiDsCreateField
    488           1.1  jruoho  *
    489           1.1  jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    490           1.1  jruoho  *              RegionNode      - Object for the containing Operation Region
    491           1.1  jruoho  *  `           WalkState       - Current method state
    492           1.1  jruoho  *
    493           1.1  jruoho  * RETURN:      Status
    494           1.1  jruoho  *
    495           1.1  jruoho  * DESCRIPTION: Create a new field in the specified operation region
    496           1.1  jruoho  *
    497           1.1  jruoho  ******************************************************************************/
    498           1.1  jruoho 
    499           1.1  jruoho ACPI_STATUS
    500           1.1  jruoho AcpiDsCreateField (
    501           1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    502           1.1  jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    503           1.1  jruoho     ACPI_WALK_STATE         *WalkState)
    504           1.1  jruoho {
    505           1.1  jruoho     ACPI_STATUS             Status;
    506           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg;
    507           1.1  jruoho     ACPI_CREATE_FIELD_INFO  Info;
    508           1.1  jruoho 
    509           1.1  jruoho 
    510           1.1  jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
    511           1.1  jruoho 
    512           1.1  jruoho 
    513           1.1  jruoho     /* First arg is the name of the parent OpRegion (must already exist) */
    514           1.1  jruoho 
    515           1.1  jruoho     Arg = Op->Common.Value.Arg;
    516  1.1.1.2.10.1    yamt 
    517           1.1  jruoho     if (!RegionNode)
    518           1.1  jruoho     {
    519           1.1  jruoho         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
    520           1.1  jruoho                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
    521           1.1  jruoho                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
    522  1.1.1.2.10.1    yamt #ifdef ACPI_ASL_COMPILER
    523  1.1.1.2.10.1    yamt         Status = AcpiDsCreateExternalRegion (Status, Arg,
    524  1.1.1.2.10.1    yamt             Arg->Common.Value.Name, WalkState, &RegionNode);
    525  1.1.1.2.10.1    yamt #endif
    526           1.1  jruoho         if (ACPI_FAILURE (Status))
    527           1.1  jruoho         {
    528           1.1  jruoho             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
    529           1.1  jruoho             return_ACPI_STATUS (Status);
    530           1.1  jruoho         }
    531           1.1  jruoho     }
    532           1.1  jruoho 
    533  1.1.1.2.10.1    yamt     ACPI_MEMSET (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
    534  1.1.1.2.10.1    yamt 
    535           1.1  jruoho     /* Second arg is the field flags */
    536           1.1  jruoho 
    537           1.1  jruoho     Arg = Arg->Common.Next;
    538           1.1  jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    539           1.1  jruoho     Info.Attribute = 0;
    540           1.1  jruoho 
    541           1.1  jruoho     /* Each remaining arg is a Named Field */
    542           1.1  jruoho 
    543           1.1  jruoho     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
    544           1.1  jruoho     Info.RegionNode = RegionNode;
    545           1.1  jruoho 
    546           1.1  jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
    547           1.1  jruoho     return_ACPI_STATUS (Status);
    548           1.1  jruoho }
    549           1.1  jruoho 
    550           1.1  jruoho 
    551           1.1  jruoho /*******************************************************************************
    552           1.1  jruoho  *
    553           1.1  jruoho  * FUNCTION:    AcpiDsInitFieldObjects
    554           1.1  jruoho  *
    555           1.1  jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    556           1.1  jruoho  *  `           WalkState       - Current method state
    557           1.1  jruoho  *
    558           1.1  jruoho  * RETURN:      Status
    559           1.1  jruoho  *
    560           1.1  jruoho  * DESCRIPTION: For each "Field Unit" name in the argument list that is
    561           1.1  jruoho  *              part of the field declaration, enter the name into the
    562           1.1  jruoho  *              namespace.
    563           1.1  jruoho  *
    564           1.1  jruoho  ******************************************************************************/
    565           1.1  jruoho 
    566           1.1  jruoho ACPI_STATUS
    567           1.1  jruoho AcpiDsInitFieldObjects (
    568           1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    569           1.1  jruoho     ACPI_WALK_STATE         *WalkState)
    570           1.1  jruoho {
    571           1.1  jruoho     ACPI_STATUS             Status;
    572           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg = NULL;
    573           1.1  jruoho     ACPI_NAMESPACE_NODE     *Node;
    574           1.1  jruoho     UINT8                   Type = 0;
    575           1.1  jruoho     UINT32                  Flags;
    576           1.1  jruoho 
    577           1.1  jruoho 
    578           1.1  jruoho     ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
    579           1.1  jruoho 
    580           1.1  jruoho 
    581           1.1  jruoho     /* Execute flag should always be set when this function is entered */
    582           1.1  jruoho 
    583           1.1  jruoho     if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
    584           1.1  jruoho     {
    585           1.1  jruoho         if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
    586           1.1  jruoho         {
    587           1.1  jruoho             /* BankField Op is deferred, just return OK */
    588           1.1  jruoho 
    589           1.1  jruoho             return_ACPI_STATUS (AE_OK);
    590           1.1  jruoho         }
    591           1.1  jruoho 
    592           1.1  jruoho         return_ACPI_STATUS (AE_AML_INTERNAL);
    593           1.1  jruoho     }
    594           1.1  jruoho 
    595           1.1  jruoho     /*
    596           1.1  jruoho      * Get the FieldList argument for this opcode. This is the start of the
    597           1.1  jruoho      * list of field elements.
    598           1.1  jruoho      */
    599           1.1  jruoho     switch (WalkState->Opcode)
    600           1.1  jruoho     {
    601           1.1  jruoho     case AML_FIELD_OP:
    602  1.1.1.2.10.1    yamt 
    603           1.1  jruoho         Arg = AcpiPsGetArg (Op, 2);
    604           1.1  jruoho         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
    605           1.1  jruoho         break;
    606           1.1  jruoho 
    607           1.1  jruoho     case AML_BANK_FIELD_OP:
    608  1.1.1.2.10.1    yamt 
    609           1.1  jruoho         Arg = AcpiPsGetArg (Op, 4);
    610           1.1  jruoho         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
    611           1.1  jruoho         break;
    612           1.1  jruoho 
    613           1.1  jruoho     case AML_INDEX_FIELD_OP:
    614  1.1.1.2.10.1    yamt 
    615           1.1  jruoho         Arg = AcpiPsGetArg (Op, 3);
    616           1.1  jruoho         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
    617           1.1  jruoho         break;
    618           1.1  jruoho 
    619           1.1  jruoho     default:
    620  1.1.1.2.10.1    yamt 
    621           1.1  jruoho         return_ACPI_STATUS (AE_BAD_PARAMETER);
    622           1.1  jruoho     }
    623           1.1  jruoho 
    624           1.1  jruoho     /* Creating new namespace node(s), should not already exist */
    625           1.1  jruoho 
    626           1.1  jruoho     Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
    627           1.1  jruoho             ACPI_NS_ERROR_IF_FOUND;
    628           1.1  jruoho 
    629           1.1  jruoho     /*
    630           1.1  jruoho      * Mark node(s) temporary if we are executing a normal control
    631           1.1  jruoho      * method. (Don't mark if this is a module-level code method)
    632           1.1  jruoho      */
    633           1.1  jruoho     if (WalkState->MethodNode &&
    634           1.1  jruoho         !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
    635           1.1  jruoho     {
    636           1.1  jruoho         Flags |= ACPI_NS_TEMPORARY;
    637           1.1  jruoho     }
    638           1.1  jruoho 
    639           1.1  jruoho     /*
    640           1.1  jruoho      * Walk the list of entries in the FieldList
    641           1.1  jruoho      * Note: FieldList can be of zero length. In this case, Arg will be NULL.
    642           1.1  jruoho      */
    643           1.1  jruoho     while (Arg)
    644           1.1  jruoho     {
    645           1.1  jruoho         /*
    646  1.1.1.2.10.1    yamt          * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
    647  1.1.1.2.10.1    yamt          * in the field names in order to enter them into the namespace.
    648           1.1  jruoho          */
    649           1.1  jruoho         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
    650           1.1  jruoho         {
    651           1.1  jruoho             Status = AcpiNsLookup (WalkState->ScopeInfo,
    652           1.1  jruoho                         (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
    653           1.1  jruoho                         Flags, WalkState, &Node);
    654           1.1  jruoho             if (ACPI_FAILURE (Status))
    655           1.1  jruoho             {
    656           1.1  jruoho                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
    657           1.1  jruoho                 if (Status != AE_ALREADY_EXISTS)
    658           1.1  jruoho                 {
    659           1.1  jruoho                     return_ACPI_STATUS (Status);
    660           1.1  jruoho                 }
    661           1.1  jruoho 
    662           1.1  jruoho                 /* Name already exists, just ignore this error */
    663           1.1  jruoho 
    664           1.1  jruoho                 Status = AE_OK;
    665           1.1  jruoho             }
    666           1.1  jruoho 
    667           1.1  jruoho             Arg->Common.Node = Node;
    668           1.1  jruoho         }
    669           1.1  jruoho 
    670           1.1  jruoho         /* Get the next field element in the list */
    671           1.1  jruoho 
    672           1.1  jruoho         Arg = Arg->Common.Next;
    673           1.1  jruoho     }
    674           1.1  jruoho 
    675           1.1  jruoho     return_ACPI_STATUS (AE_OK);
    676           1.1  jruoho }
    677           1.1  jruoho 
    678           1.1  jruoho 
    679           1.1  jruoho /*******************************************************************************
    680           1.1  jruoho  *
    681           1.1  jruoho  * FUNCTION:    AcpiDsCreateBankField
    682           1.1  jruoho  *
    683           1.1  jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    684           1.1  jruoho  *              RegionNode      - Object for the containing Operation Region
    685           1.1  jruoho  *              WalkState       - Current method state
    686           1.1  jruoho  *
    687           1.1  jruoho  * RETURN:      Status
    688           1.1  jruoho  *
    689           1.1  jruoho  * DESCRIPTION: Create a new bank field in the specified operation region
    690           1.1  jruoho  *
    691           1.1  jruoho  ******************************************************************************/
    692           1.1  jruoho 
    693           1.1  jruoho ACPI_STATUS
    694           1.1  jruoho AcpiDsCreateBankField (
    695           1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    696           1.1  jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    697           1.1  jruoho     ACPI_WALK_STATE         *WalkState)
    698           1.1  jruoho {
    699           1.1  jruoho     ACPI_STATUS             Status;
    700           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg;
    701           1.1  jruoho     ACPI_CREATE_FIELD_INFO  Info;
    702           1.1  jruoho 
    703           1.1  jruoho 
    704           1.1  jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
    705           1.1  jruoho 
    706           1.1  jruoho 
    707           1.1  jruoho     /* First arg is the name of the parent OpRegion (must already exist) */
    708           1.1  jruoho 
    709           1.1  jruoho     Arg = Op->Common.Value.Arg;
    710           1.1  jruoho     if (!RegionNode)
    711           1.1  jruoho     {
    712           1.1  jruoho         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
    713           1.1  jruoho                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
    714           1.1  jruoho                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
    715  1.1.1.2.10.1    yamt #ifdef ACPI_ASL_COMPILER
    716  1.1.1.2.10.1    yamt         Status = AcpiDsCreateExternalRegion (Status, Arg,
    717  1.1.1.2.10.1    yamt             Arg->Common.Value.Name, WalkState, &RegionNode);
    718  1.1.1.2.10.1    yamt #endif
    719           1.1  jruoho         if (ACPI_FAILURE (Status))
    720           1.1  jruoho         {
    721           1.1  jruoho             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
    722           1.1  jruoho             return_ACPI_STATUS (Status);
    723           1.1  jruoho         }
    724           1.1  jruoho     }
    725           1.1  jruoho 
    726           1.1  jruoho     /* Second arg is the Bank Register (Field) (must already exist) */
    727           1.1  jruoho 
    728           1.1  jruoho     Arg = Arg->Common.Next;
    729           1.1  jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    730           1.1  jruoho                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    731           1.1  jruoho                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
    732           1.1  jruoho     if (ACPI_FAILURE (Status))
    733           1.1  jruoho     {
    734           1.1  jruoho         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
    735           1.1  jruoho         return_ACPI_STATUS (Status);
    736           1.1  jruoho     }
    737           1.1  jruoho 
    738           1.1  jruoho     /*
    739           1.1  jruoho      * Third arg is the BankValue
    740           1.1  jruoho      * This arg is a TermArg, not a constant
    741           1.1  jruoho      * It will be evaluated later, by AcpiDsEvalBankFieldOperands
    742           1.1  jruoho      */
    743           1.1  jruoho     Arg = Arg->Common.Next;
    744           1.1  jruoho 
    745           1.1  jruoho     /* Fourth arg is the field flags */
    746           1.1  jruoho 
    747           1.1  jruoho     Arg = Arg->Common.Next;
    748           1.1  jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    749           1.1  jruoho 
    750           1.1  jruoho     /* Each remaining arg is a Named Field */
    751           1.1  jruoho 
    752           1.1  jruoho     Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
    753           1.1  jruoho     Info.RegionNode = RegionNode;
    754           1.1  jruoho 
    755           1.1  jruoho     /*
    756           1.1  jruoho      * Use Info.DataRegisterNode to store BankField Op
    757           1.1  jruoho      * It's safe because DataRegisterNode will never be used when create bank field
    758           1.1  jruoho      * We store AmlStart and AmlLength in the BankField Op for late evaluation
    759           1.1  jruoho      * Used in AcpiExPrepFieldValue(Info)
    760           1.1  jruoho      *
    761           1.1  jruoho      * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"?
    762           1.1  jruoho      */
    763           1.1  jruoho     Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
    764           1.1  jruoho 
    765           1.1  jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
    766           1.1  jruoho     return_ACPI_STATUS (Status);
    767           1.1  jruoho }
    768           1.1  jruoho 
    769           1.1  jruoho 
    770           1.1  jruoho /*******************************************************************************
    771           1.1  jruoho  *
    772           1.1  jruoho  * FUNCTION:    AcpiDsCreateIndexField
    773           1.1  jruoho  *
    774           1.1  jruoho  * PARAMETERS:  Op              - Op containing the Field definition and args
    775           1.1  jruoho  *              RegionNode      - Object for the containing Operation Region
    776           1.1  jruoho  *  `           WalkState       - Current method state
    777           1.1  jruoho  *
    778           1.1  jruoho  * RETURN:      Status
    779           1.1  jruoho  *
    780           1.1  jruoho  * DESCRIPTION: Create a new index field in the specified operation region
    781           1.1  jruoho  *
    782           1.1  jruoho  ******************************************************************************/
    783           1.1  jruoho 
    784           1.1  jruoho ACPI_STATUS
    785           1.1  jruoho AcpiDsCreateIndexField (
    786           1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    787           1.1  jruoho     ACPI_NAMESPACE_NODE     *RegionNode,
    788           1.1  jruoho     ACPI_WALK_STATE         *WalkState)
    789           1.1  jruoho {
    790           1.1  jruoho     ACPI_STATUS             Status;
    791           1.1  jruoho     ACPI_PARSE_OBJECT       *Arg;
    792           1.1  jruoho     ACPI_CREATE_FIELD_INFO  Info;
    793           1.1  jruoho 
    794           1.1  jruoho 
    795           1.1  jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op);
    796           1.1  jruoho 
    797           1.1  jruoho 
    798           1.1  jruoho     /* First arg is the name of the Index register (must already exist) */
    799           1.1  jruoho 
    800           1.1  jruoho     Arg = Op->Common.Value.Arg;
    801           1.1  jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    802           1.1  jruoho                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    803           1.1  jruoho                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
    804           1.1  jruoho     if (ACPI_FAILURE (Status))
    805           1.1  jruoho     {
    806           1.1  jruoho         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
    807           1.1  jruoho         return_ACPI_STATUS (Status);
    808           1.1  jruoho     }
    809           1.1  jruoho 
    810           1.1  jruoho     /* Second arg is the data register (must already exist) */
    811           1.1  jruoho 
    812           1.1  jruoho     Arg = Arg->Common.Next;
    813           1.1  jruoho     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
    814           1.1  jruoho                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    815           1.1  jruoho                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
    816           1.1  jruoho     if (ACPI_FAILURE (Status))
    817           1.1  jruoho     {
    818           1.1  jruoho         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
    819           1.1  jruoho         return_ACPI_STATUS (Status);
    820           1.1  jruoho     }
    821           1.1  jruoho 
    822           1.1  jruoho     /* Next arg is the field flags */
    823           1.1  jruoho 
    824           1.1  jruoho     Arg = Arg->Common.Next;
    825           1.1  jruoho     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
    826           1.1  jruoho 
    827           1.1  jruoho     /* Each remaining arg is a Named Field */
    828           1.1  jruoho 
    829           1.1  jruoho     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
    830           1.1  jruoho     Info.RegionNode = RegionNode;
    831           1.1  jruoho 
    832           1.1  jruoho     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
    833           1.1  jruoho     return_ACPI_STATUS (Status);
    834           1.1  jruoho }
    835