Home | History | Annotate | Line # | Download | only in compiler
aslxref.c revision 1.2.10.3
      1  1.2.10.2       tls /******************************************************************************
      2  1.2.10.2       tls  *
      3  1.2.10.2       tls  * Module Name: aslxref - Namespace cross-reference
      4  1.2.10.2       tls  *
      5  1.2.10.2       tls  *****************************************************************************/
      6  1.2.10.2       tls 
      7  1.2.10.2       tls /*
      8  1.2.10.3  jdolecek  * Copyright (C) 2000 - 2017, Intel Corp.
      9  1.2.10.2       tls  * All rights reserved.
     10  1.2.10.2       tls  *
     11  1.2.10.2       tls  * Redistribution and use in source and binary forms, with or without
     12  1.2.10.2       tls  * modification, are permitted provided that the following conditions
     13  1.2.10.2       tls  * are met:
     14  1.2.10.2       tls  * 1. Redistributions of source code must retain the above copyright
     15  1.2.10.2       tls  *    notice, this list of conditions, and the following disclaimer,
     16  1.2.10.2       tls  *    without modification.
     17  1.2.10.2       tls  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.2.10.2       tls  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.2.10.2       tls  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.2.10.2       tls  *    including a substantially similar Disclaimer requirement for further
     21  1.2.10.2       tls  *    binary redistribution.
     22  1.2.10.2       tls  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.2.10.2       tls  *    of any contributors may be used to endorse or promote products derived
     24  1.2.10.2       tls  *    from this software without specific prior written permission.
     25  1.2.10.2       tls  *
     26  1.2.10.2       tls  * Alternatively, this software may be distributed under the terms of the
     27  1.2.10.2       tls  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.2.10.2       tls  * Software Foundation.
     29  1.2.10.2       tls  *
     30  1.2.10.2       tls  * NO WARRANTY
     31  1.2.10.2       tls  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.2.10.2       tls  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.2.10.2       tls  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.2.10.2       tls  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.2.10.2       tls  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.2.10.2       tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.2.10.2       tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.2.10.2       tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.2.10.2       tls  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.2.10.2       tls  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.2.10.2       tls  * POSSIBILITY OF SUCH DAMAGES.
     42  1.2.10.2       tls  */
     43  1.2.10.2       tls 
     44  1.2.10.2       tls #include "aslcompiler.h"
     45  1.2.10.2       tls #include "aslcompiler.y.h"
     46  1.2.10.2       tls #include "acparser.h"
     47  1.2.10.2       tls #include "amlcode.h"
     48  1.2.10.2       tls #include "acnamesp.h"
     49  1.2.10.2       tls #include "acdispat.h"
     50  1.2.10.2       tls 
     51  1.2.10.2       tls 
     52  1.2.10.2       tls #define _COMPONENT          ACPI_COMPILER
     53  1.2.10.2       tls         ACPI_MODULE_NAME    ("aslxref")
     54  1.2.10.2       tls 
     55  1.2.10.2       tls /* Local prototypes */
     56  1.2.10.2       tls 
     57  1.2.10.2       tls static ACPI_STATUS
     58  1.2.10.2       tls XfNamespaceLocateBegin (
     59  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
     60  1.2.10.2       tls     UINT32                  Level,
     61  1.2.10.2       tls     void                    *Context);
     62  1.2.10.2       tls 
     63  1.2.10.2       tls static ACPI_STATUS
     64  1.2.10.2       tls XfNamespaceLocateEnd (
     65  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
     66  1.2.10.2       tls     UINT32                  Level,
     67  1.2.10.2       tls     void                    *Context);
     68  1.2.10.2       tls 
     69  1.2.10.3  jdolecek static ACPI_PARSE_OBJECT *
     70  1.2.10.3  jdolecek XfGetParentMethod (
     71  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op);
     72  1.2.10.3  jdolecek 
     73  1.2.10.2       tls static BOOLEAN
     74  1.2.10.2       tls XfObjectExists (
     75  1.2.10.2       tls     char                    *Name);
     76  1.2.10.2       tls 
     77  1.2.10.2       tls static ACPI_STATUS
     78  1.2.10.2       tls XfCompareOneNamespaceObject (
     79  1.2.10.2       tls     ACPI_HANDLE             ObjHandle,
     80  1.2.10.2       tls     UINT32                  Level,
     81  1.2.10.2       tls     void                    *Context,
     82  1.2.10.2       tls     void                    **ReturnValue);
     83  1.2.10.2       tls 
     84  1.2.10.2       tls static void
     85  1.2.10.2       tls XfCheckFieldRange (
     86  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
     87  1.2.10.2       tls     UINT32                  RegionBitLength,
     88  1.2.10.2       tls     UINT32                  FieldBitOffset,
     89  1.2.10.2       tls     UINT32                  FieldBitLength,
     90  1.2.10.2       tls     UINT32                  AccessBitWidth);
     91  1.2.10.2       tls 
     92  1.2.10.3  jdolecek #ifdef __UNDER_DEVELOPMENT
     93  1.2.10.3  jdolecek static ACPI_PARSE_OBJECT *
     94  1.2.10.3  jdolecek XfGetParentMethod (
     95  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op);
     96  1.2.10.3  jdolecek 
     97  1.2.10.3  jdolecek static void
     98  1.2.10.3  jdolecek XfCheckIllegalReference (
     99  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op,
    100  1.2.10.3  jdolecek     ACPI_NAMESPACE_NODE     *Node);
    101  1.2.10.3  jdolecek 
    102  1.2.10.3  jdolecek static BOOLEAN
    103  1.2.10.3  jdolecek XfIsObjectParental (
    104  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *MethodOp1,
    105  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *MethodOp2);
    106  1.2.10.3  jdolecek #endif
    107  1.2.10.3  jdolecek 
    108  1.2.10.2       tls 
    109  1.2.10.2       tls /*******************************************************************************
    110  1.2.10.2       tls  *
    111  1.2.10.2       tls  * FUNCTION:    XfCrossReferenceNamespace
    112  1.2.10.2       tls  *
    113  1.2.10.2       tls  * PARAMETERS:  None
    114  1.2.10.2       tls  *
    115  1.2.10.2       tls  * RETURN:      Status
    116  1.2.10.2       tls  *
    117  1.2.10.2       tls  * DESCRIPTION: Perform a cross reference check of the parse tree against the
    118  1.2.10.2       tls  *              namespace. Every named referenced within the parse tree
    119  1.2.10.2       tls  *              should be get resolved with a namespace lookup. If not, the
    120  1.2.10.2       tls  *              original reference in the ASL code is invalid -- i.e., refers
    121  1.2.10.2       tls  *              to a non-existent object.
    122  1.2.10.2       tls  *
    123  1.2.10.2       tls  * NOTE:  The ASL "External" operator causes the name to be inserted into the
    124  1.2.10.2       tls  *        namespace so that references to the external name will be resolved
    125  1.2.10.2       tls  *        correctly here.
    126  1.2.10.2       tls  *
    127  1.2.10.2       tls  ******************************************************************************/
    128  1.2.10.2       tls 
    129  1.2.10.2       tls ACPI_STATUS
    130  1.2.10.2       tls XfCrossReferenceNamespace (
    131  1.2.10.2       tls     void)
    132  1.2.10.2       tls {
    133  1.2.10.2       tls     ACPI_WALK_STATE         *WalkState;
    134  1.2.10.2       tls 
    135  1.2.10.2       tls 
    136  1.2.10.2       tls     /*
    137  1.2.10.2       tls      * Create a new walk state for use when looking up names
    138  1.2.10.2       tls      * within the namespace (Passed as context to the callbacks)
    139  1.2.10.2       tls      */
    140  1.2.10.2       tls     WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
    141  1.2.10.2       tls     if (!WalkState)
    142  1.2.10.2       tls     {
    143  1.2.10.2       tls         return (AE_NO_MEMORY);
    144  1.2.10.2       tls     }
    145  1.2.10.2       tls 
    146  1.2.10.2       tls     /* Walk the entire parse tree */
    147  1.2.10.2       tls 
    148  1.2.10.3  jdolecek     TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
    149  1.2.10.3  jdolecek         XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState);
    150  1.2.10.3  jdolecek 
    151  1.2.10.3  jdolecek     ACPI_FREE (WalkState);
    152  1.2.10.2       tls     return (AE_OK);
    153  1.2.10.2       tls }
    154  1.2.10.2       tls 
    155  1.2.10.2       tls 
    156  1.2.10.2       tls /*******************************************************************************
    157  1.2.10.2       tls  *
    158  1.2.10.2       tls  * FUNCTION:    XfObjectExists
    159  1.2.10.2       tls  *
    160  1.2.10.2       tls  * PARAMETERS:  Name            - 4 char ACPI name
    161  1.2.10.2       tls  *
    162  1.2.10.2       tls  * RETURN:      TRUE if name exists in namespace
    163  1.2.10.2       tls  *
    164  1.2.10.2       tls  * DESCRIPTION: Walk the namespace to find an object
    165  1.2.10.2       tls  *
    166  1.2.10.2       tls  ******************************************************************************/
    167  1.2.10.2       tls 
    168  1.2.10.2       tls static BOOLEAN
    169  1.2.10.2       tls XfObjectExists (
    170  1.2.10.2       tls     char                    *Name)
    171  1.2.10.2       tls {
    172  1.2.10.2       tls     ACPI_STATUS             Status;
    173  1.2.10.2       tls 
    174  1.2.10.2       tls 
    175  1.2.10.2       tls     /* Walk entire namespace from the supplied root */
    176  1.2.10.2       tls 
    177  1.2.10.2       tls     Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
    178  1.2.10.3  jdolecek         ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL,
    179  1.2.10.3  jdolecek         Name, NULL);
    180  1.2.10.2       tls     if (Status == AE_CTRL_TRUE)
    181  1.2.10.2       tls     {
    182  1.2.10.2       tls         /* At least one instance of the name was found */
    183  1.2.10.2       tls 
    184  1.2.10.2       tls         return (TRUE);
    185  1.2.10.2       tls     }
    186  1.2.10.2       tls 
    187  1.2.10.2       tls     return (FALSE);
    188  1.2.10.2       tls }
    189  1.2.10.2       tls 
    190  1.2.10.2       tls 
    191  1.2.10.2       tls /*******************************************************************************
    192  1.2.10.2       tls  *
    193  1.2.10.2       tls  * FUNCTION:    XfCompareOneNamespaceObject
    194  1.2.10.2       tls  *
    195  1.2.10.2       tls  * PARAMETERS:  ACPI_WALK_CALLBACK
    196  1.2.10.2       tls  *
    197  1.2.10.2       tls  * RETURN:      Status
    198  1.2.10.2       tls  *
    199  1.2.10.2       tls  * DESCRIPTION: Compare name of one object.
    200  1.2.10.2       tls  *
    201  1.2.10.2       tls  ******************************************************************************/
    202  1.2.10.2       tls 
    203  1.2.10.2       tls static ACPI_STATUS
    204  1.2.10.2       tls XfCompareOneNamespaceObject (
    205  1.2.10.2       tls     ACPI_HANDLE             ObjHandle,
    206  1.2.10.2       tls     UINT32                  Level,
    207  1.2.10.2       tls     void                    *Context,
    208  1.2.10.2       tls     void                    **ReturnValue)
    209  1.2.10.2       tls {
    210  1.2.10.2       tls     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
    211  1.2.10.2       tls 
    212  1.2.10.2       tls 
    213  1.2.10.2       tls     /* Simply check the name */
    214  1.2.10.2       tls 
    215  1.2.10.2       tls     if (*((UINT32 *) (Context)) == Node->Name.Integer)
    216  1.2.10.2       tls     {
    217  1.2.10.2       tls         /* Abort walk if we found one instance */
    218  1.2.10.2       tls 
    219  1.2.10.2       tls         return (AE_CTRL_TRUE);
    220  1.2.10.2       tls     }
    221  1.2.10.2       tls 
    222  1.2.10.2       tls     return (AE_OK);
    223  1.2.10.2       tls }
    224  1.2.10.2       tls 
    225  1.2.10.2       tls 
    226  1.2.10.2       tls /*******************************************************************************
    227  1.2.10.2       tls  *
    228  1.2.10.2       tls  * FUNCTION:    XfCheckFieldRange
    229  1.2.10.2       tls  *
    230  1.2.10.2       tls  * PARAMETERS:  RegionBitLength     - Length of entire parent region
    231  1.2.10.2       tls  *              FieldBitOffset      - Start of the field unit (within region)
    232  1.2.10.2       tls  *              FieldBitLength      - Entire length of field unit
    233  1.2.10.2       tls  *              AccessBitWidth      - Access width of the field unit
    234  1.2.10.2       tls  *
    235  1.2.10.2       tls  * RETURN:      None
    236  1.2.10.2       tls  *
    237  1.2.10.2       tls  * DESCRIPTION: Check one field unit to make sure it fits in the parent
    238  1.2.10.2       tls  *              op region.
    239  1.2.10.2       tls  *
    240  1.2.10.2       tls  * Note: AccessBitWidth must be either 8,16,32, or 64
    241  1.2.10.2       tls  *
    242  1.2.10.2       tls  ******************************************************************************/
    243  1.2.10.2       tls 
    244  1.2.10.2       tls static void
    245  1.2.10.2       tls XfCheckFieldRange (
    246  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
    247  1.2.10.2       tls     UINT32                  RegionBitLength,
    248  1.2.10.2       tls     UINT32                  FieldBitOffset,
    249  1.2.10.2       tls     UINT32                  FieldBitLength,
    250  1.2.10.2       tls     UINT32                  AccessBitWidth)
    251  1.2.10.2       tls {
    252  1.2.10.2       tls     UINT32                  FieldEndBitOffset;
    253  1.2.10.2       tls 
    254  1.2.10.2       tls 
    255  1.2.10.2       tls     /*
    256  1.2.10.2       tls      * Check each field unit against the region size. The entire
    257  1.2.10.2       tls      * field unit (start offset plus length) must fit within the
    258  1.2.10.2       tls      * region.
    259  1.2.10.2       tls      */
    260  1.2.10.2       tls     FieldEndBitOffset = FieldBitOffset + FieldBitLength;
    261  1.2.10.2       tls 
    262  1.2.10.2       tls     if (FieldEndBitOffset > RegionBitLength)
    263  1.2.10.2       tls     {
    264  1.2.10.2       tls         /* Field definition itself is beyond the end-of-region */
    265  1.2.10.2       tls 
    266  1.2.10.2       tls         AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
    267  1.2.10.2       tls         return;
    268  1.2.10.2       tls     }
    269  1.2.10.2       tls 
    270  1.2.10.2       tls     /*
    271  1.2.10.2       tls      * Now check that the field plus AccessWidth doesn't go beyond
    272  1.2.10.2       tls      * the end-of-region. Assumes AccessBitWidth is a power of 2
    273  1.2.10.2       tls      */
    274  1.2.10.2       tls     FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
    275  1.2.10.2       tls 
    276  1.2.10.2       tls     if (FieldEndBitOffset > RegionBitLength)
    277  1.2.10.2       tls     {
    278  1.2.10.2       tls         /* Field definition combined with the access is beyond EOR */
    279  1.2.10.2       tls 
    280  1.2.10.2       tls         AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
    281  1.2.10.2       tls     }
    282  1.2.10.2       tls }
    283  1.2.10.2       tls 
    284  1.2.10.3  jdolecek 
    285  1.2.10.3  jdolecek /*******************************************************************************
    286  1.2.10.3  jdolecek  *
    287  1.2.10.3  jdolecek  * FUNCTION:    XfGetParentMethod
    288  1.2.10.3  jdolecek  *
    289  1.2.10.3  jdolecek  * PARAMETERS:  Op                      - Parse Op to be checked
    290  1.2.10.3  jdolecek  *
    291  1.2.10.3  jdolecek  * RETURN:      Control method Op if found. NULL otherwise
    292  1.2.10.3  jdolecek  *
    293  1.2.10.3  jdolecek  * DESCRIPTION: Find the control method parent of a parse op. Returns NULL if
    294  1.2.10.3  jdolecek  *              the input Op is not within a control method.
    295  1.2.10.3  jdolecek  *
    296  1.2.10.3  jdolecek  ******************************************************************************/
    297  1.2.10.3  jdolecek 
    298  1.2.10.3  jdolecek static ACPI_PARSE_OBJECT *
    299  1.2.10.3  jdolecek XfGetParentMethod (
    300  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op)
    301  1.2.10.3  jdolecek {
    302  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *NextOp;
    303  1.2.10.3  jdolecek 
    304  1.2.10.3  jdolecek 
    305  1.2.10.3  jdolecek     NextOp = Op->Asl.Parent;
    306  1.2.10.3  jdolecek     while (NextOp)
    307  1.2.10.3  jdolecek     {
    308  1.2.10.3  jdolecek         if (NextOp->Asl.AmlOpcode == AML_METHOD_OP)
    309  1.2.10.3  jdolecek         {
    310  1.2.10.3  jdolecek             return (NextOp);
    311  1.2.10.3  jdolecek         }
    312  1.2.10.3  jdolecek 
    313  1.2.10.3  jdolecek         NextOp = NextOp->Asl.Parent;
    314  1.2.10.3  jdolecek     }
    315  1.2.10.3  jdolecek 
    316  1.2.10.3  jdolecek     return (NULL); /* No parent method found */
    317  1.2.10.3  jdolecek }
    318  1.2.10.3  jdolecek 
    319  1.2.10.2       tls /*******************************************************************************
    320  1.2.10.2       tls  *
    321  1.2.10.2       tls  * FUNCTION:    XfNamespaceLocateBegin
    322  1.2.10.2       tls  *
    323  1.2.10.2       tls  * PARAMETERS:  ASL_WALK_CALLBACK
    324  1.2.10.2       tls  *
    325  1.2.10.2       tls  * RETURN:      Status
    326  1.2.10.2       tls  *
    327  1.2.10.2       tls  * DESCRIPTION: Descending callback used during cross-reference. For named
    328  1.2.10.2       tls  *              object references, attempt to locate the name in the
    329  1.2.10.2       tls  *              namespace.
    330  1.2.10.2       tls  *
    331  1.2.10.2       tls  * NOTE: ASL references to named fields within resource descriptors are
    332  1.2.10.2       tls  *       resolved to integer values here. Therefore, this step is an
    333  1.2.10.2       tls  *       important part of the code generation. We don't know that the
    334  1.2.10.2       tls  *       name refers to a resource descriptor until now.
    335  1.2.10.2       tls  *
    336  1.2.10.2       tls  ******************************************************************************/
    337  1.2.10.2       tls 
    338  1.2.10.2       tls static ACPI_STATUS
    339  1.2.10.2       tls XfNamespaceLocateBegin (
    340  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
    341  1.2.10.2       tls     UINT32                  Level,
    342  1.2.10.2       tls     void                    *Context)
    343  1.2.10.2       tls {
    344  1.2.10.2       tls     ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context;
    345  1.2.10.2       tls     ACPI_NAMESPACE_NODE     *Node;
    346  1.2.10.2       tls     ACPI_STATUS             Status;
    347  1.2.10.2       tls     ACPI_OBJECT_TYPE        ObjectType;
    348  1.2.10.2       tls     char                    *Path;
    349  1.2.10.2       tls     UINT8                   PassedArgs;
    350  1.2.10.2       tls     ACPI_PARSE_OBJECT       *NextOp;
    351  1.2.10.2       tls     ACPI_PARSE_OBJECT       *OwningOp;
    352  1.2.10.2       tls     ACPI_PARSE_OBJECT       *SpaceIdOp;
    353  1.2.10.2       tls     UINT32                  MinimumLength;
    354  1.2.10.2       tls     UINT32                  Offset;
    355  1.2.10.2       tls     UINT32                  FieldBitLength;
    356  1.2.10.2       tls     UINT32                  TagBitLength;
    357  1.2.10.2       tls     UINT8                   Message = 0;
    358  1.2.10.2       tls     const ACPI_OPCODE_INFO  *OpInfo;
    359  1.2.10.2       tls     UINT32                  Flags;
    360  1.2.10.3  jdolecek     ASL_METHOD_LOCAL        *MethodLocals = NULL;
    361  1.2.10.3  jdolecek     ASL_METHOD_LOCAL        *MethodArgs = NULL;
    362  1.2.10.3  jdolecek     int                     RegisterNumber;
    363  1.2.10.3  jdolecek     UINT32                  i;
    364  1.2.10.2       tls 
    365  1.2.10.2       tls 
    366  1.2.10.2       tls     ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op);
    367  1.2.10.2       tls 
    368  1.2.10.3  jdolecek 
    369  1.2.10.3  jdolecek     if ((Op->Asl.AmlOpcode == AML_METHOD_OP) && Op->Asl.Node)
    370  1.2.10.3  jdolecek     {
    371  1.2.10.3  jdolecek         Node = Op->Asl.Node;
    372  1.2.10.3  jdolecek 
    373  1.2.10.3  jdolecek         /* Support for method LocalX/ArgX analysis */
    374  1.2.10.3  jdolecek 
    375  1.2.10.3  jdolecek         if (!Node->MethodLocals)
    376  1.2.10.3  jdolecek         {
    377  1.2.10.3  jdolecek             /* Create local/arg info blocks */
    378  1.2.10.3  jdolecek 
    379  1.2.10.3  jdolecek             MethodLocals = UtLocalCalloc (
    380  1.2.10.3  jdolecek                 sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_LOCALS);
    381  1.2.10.3  jdolecek             Node->MethodLocals = MethodLocals;
    382  1.2.10.3  jdolecek 
    383  1.2.10.3  jdolecek             MethodArgs = UtLocalCalloc (
    384  1.2.10.3  jdolecek                 sizeof (ASL_METHOD_LOCAL) * ACPI_METHOD_NUM_ARGS);
    385  1.2.10.3  jdolecek             Node->MethodArgs = MethodArgs;
    386  1.2.10.3  jdolecek 
    387  1.2.10.3  jdolecek             /*
    388  1.2.10.3  jdolecek              * Get the method argument count
    389  1.2.10.3  jdolecek              * First, get the name node
    390  1.2.10.3  jdolecek              */
    391  1.2.10.3  jdolecek             NextOp = Op->Asl.Child;
    392  1.2.10.3  jdolecek 
    393  1.2.10.3  jdolecek             /* Get the NumArguments node */
    394  1.2.10.3  jdolecek 
    395  1.2.10.3  jdolecek             NextOp = NextOp->Asl.Next;
    396  1.2.10.3  jdolecek             Node->ArgCount = (UINT8)
    397  1.2.10.3  jdolecek                 (((UINT8) NextOp->Asl.Value.Integer) & 0x07);
    398  1.2.10.3  jdolecek 
    399  1.2.10.3  jdolecek             /* We will track all posible ArgXs */
    400  1.2.10.3  jdolecek 
    401  1.2.10.3  jdolecek             for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
    402  1.2.10.3  jdolecek             {
    403  1.2.10.3  jdolecek                 if (i < Node->ArgCount)
    404  1.2.10.3  jdolecek                 {
    405  1.2.10.3  jdolecek                     /* Real Args are always "initialized" */
    406  1.2.10.3  jdolecek 
    407  1.2.10.3  jdolecek                     MethodArgs[i].Flags = ASL_ARG_INITIALIZED;
    408  1.2.10.3  jdolecek                 }
    409  1.2.10.3  jdolecek                 else
    410  1.2.10.3  jdolecek                 {
    411  1.2.10.3  jdolecek                     /* Other ArgXs can be used as locals */
    412  1.2.10.3  jdolecek 
    413  1.2.10.3  jdolecek                     MethodArgs[i].Flags = ASL_ARG_IS_LOCAL;
    414  1.2.10.3  jdolecek                 }
    415  1.2.10.3  jdolecek 
    416  1.2.10.3  jdolecek                 MethodArgs[i].Op = Op;
    417  1.2.10.3  jdolecek             }
    418  1.2.10.3  jdolecek         }
    419  1.2.10.3  jdolecek     }
    420  1.2.10.3  jdolecek 
    421  1.2.10.2       tls     /*
    422  1.2.10.2       tls      * If this node is the actual declaration of a name
    423  1.2.10.2       tls      * [such as the XXXX name in "Method (XXXX)"],
    424  1.2.10.2       tls      * we are not interested in it here. We only care about names that are
    425  1.2.10.2       tls      * references to other objects within the namespace and the parent objects
    426  1.2.10.2       tls      * of name declarations
    427  1.2.10.2       tls      */
    428  1.2.10.3  jdolecek     if (Op->Asl.CompileFlags & OP_IS_NAME_DECLARATION)
    429  1.2.10.2       tls     {
    430  1.2.10.2       tls         return_ACPI_STATUS (AE_OK);
    431  1.2.10.2       tls     }
    432  1.2.10.2       tls 
    433  1.2.10.2       tls     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
    434  1.2.10.2       tls 
    435  1.2.10.3  jdolecek     /* Check method LocalX variables */
    436  1.2.10.3  jdolecek 
    437  1.2.10.3  jdolecek     if (OpInfo->Type == AML_TYPE_LOCAL_VARIABLE)
    438  1.2.10.3  jdolecek     {
    439  1.2.10.3  jdolecek         /* Find parent method Op */
    440  1.2.10.3  jdolecek 
    441  1.2.10.3  jdolecek         NextOp = XfGetParentMethod (Op);
    442  1.2.10.3  jdolecek         if (!NextOp)
    443  1.2.10.3  jdolecek         {
    444  1.2.10.3  jdolecek             return_ACPI_STATUS (AE_OK);
    445  1.2.10.3  jdolecek         }
    446  1.2.10.3  jdolecek 
    447  1.2.10.3  jdolecek         /* Get method node */
    448  1.2.10.3  jdolecek 
    449  1.2.10.3  jdolecek         Node = NextOp->Asl.Node;
    450  1.2.10.3  jdolecek 
    451  1.2.10.3  jdolecek         RegisterNumber = Op->Asl.AmlOpcode & 0x0007; /* 0x60 through 0x67 */
    452  1.2.10.3  jdolecek         MethodLocals = Node->MethodLocals;
    453  1.2.10.3  jdolecek 
    454  1.2.10.3  jdolecek         if (Op->Asl.CompileFlags & OP_IS_TARGET)
    455  1.2.10.3  jdolecek         {
    456  1.2.10.3  jdolecek             /* Local is being initialized */
    457  1.2.10.3  jdolecek 
    458  1.2.10.3  jdolecek             MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_INITIALIZED;
    459  1.2.10.3  jdolecek             MethodLocals[RegisterNumber].Op = Op;
    460  1.2.10.3  jdolecek 
    461  1.2.10.3  jdolecek             return_ACPI_STATUS (AE_OK);
    462  1.2.10.3  jdolecek         }
    463  1.2.10.3  jdolecek 
    464  1.2.10.3  jdolecek         /* Mark this Local as referenced */
    465  1.2.10.3  jdolecek 
    466  1.2.10.3  jdolecek         MethodLocals[RegisterNumber].Flags |= ASL_LOCAL_REFERENCED;
    467  1.2.10.3  jdolecek         MethodLocals[RegisterNumber].Op = Op;
    468  1.2.10.3  jdolecek 
    469  1.2.10.3  jdolecek         return_ACPI_STATUS (AE_OK);
    470  1.2.10.3  jdolecek     }
    471  1.2.10.3  jdolecek 
    472  1.2.10.3  jdolecek     /* Check method ArgX variables */
    473  1.2.10.3  jdolecek 
    474  1.2.10.3  jdolecek     if (OpInfo->Type == AML_TYPE_METHOD_ARGUMENT)
    475  1.2.10.3  jdolecek     {
    476  1.2.10.3  jdolecek         /* Find parent method Op */
    477  1.2.10.3  jdolecek 
    478  1.2.10.3  jdolecek         NextOp = XfGetParentMethod (Op);
    479  1.2.10.3  jdolecek         if (!NextOp)
    480  1.2.10.3  jdolecek         {
    481  1.2.10.3  jdolecek             return_ACPI_STATUS (AE_OK);
    482  1.2.10.3  jdolecek         }
    483  1.2.10.3  jdolecek 
    484  1.2.10.3  jdolecek         /* Get method node */
    485  1.2.10.3  jdolecek 
    486  1.2.10.3  jdolecek         Node = NextOp->Asl.Node;
    487  1.2.10.3  jdolecek 
    488  1.2.10.3  jdolecek         /* Get Arg # */
    489  1.2.10.3  jdolecek 
    490  1.2.10.3  jdolecek         RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */
    491  1.2.10.3  jdolecek         MethodArgs = Node->MethodArgs;
    492  1.2.10.3  jdolecek 
    493  1.2.10.3  jdolecek         /* Mark this Arg as referenced */
    494  1.2.10.3  jdolecek 
    495  1.2.10.3  jdolecek         MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED;
    496  1.2.10.3  jdolecek         MethodArgs[RegisterNumber].Op = Op;
    497  1.2.10.3  jdolecek 
    498  1.2.10.3  jdolecek         if (Op->Asl.CompileFlags & OP_IS_TARGET)
    499  1.2.10.3  jdolecek         {
    500  1.2.10.3  jdolecek             /* Arg is being initialized */
    501  1.2.10.3  jdolecek 
    502  1.2.10.3  jdolecek             MethodArgs[RegisterNumber].Flags |= ASL_ARG_INITIALIZED;
    503  1.2.10.3  jdolecek         }
    504  1.2.10.3  jdolecek 
    505  1.2.10.3  jdolecek         return_ACPI_STATUS (AE_OK);
    506  1.2.10.3  jdolecek     }
    507  1.2.10.3  jdolecek 
    508  1.2.10.3  jdolecek     /*
    509  1.2.10.3  jdolecek      * After method ArgX and LocalX, we are only interested in opcodes
    510  1.2.10.3  jdolecek      * that have an associated name
    511  1.2.10.3  jdolecek      */
    512  1.2.10.2       tls     if ((!(OpInfo->Flags & AML_NAMED)) &&
    513  1.2.10.2       tls         (!(OpInfo->Flags & AML_CREATE)) &&
    514  1.2.10.2       tls         (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
    515  1.2.10.2       tls         (Op->Asl.ParseOpcode != PARSEOP_NAMESEG)    &&
    516  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) &&
    517  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
    518  1.2.10.2       tls     {
    519  1.2.10.2       tls         return_ACPI_STATUS (AE_OK);
    520  1.2.10.2       tls     }
    521  1.2.10.2       tls 
    522  1.2.10.2       tls     /*
    523  1.2.10.2       tls      * One special case: CondRefOf operator - we don't care if the name exists
    524  1.2.10.2       tls      * or not at this point, just ignore it, the point of the operator is to
    525  1.2.10.2       tls      * determine if the name exists at runtime.
    526  1.2.10.2       tls      */
    527  1.2.10.2       tls     if ((Op->Asl.Parent) &&
    528  1.2.10.2       tls         (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
    529  1.2.10.2       tls     {
    530  1.2.10.2       tls         return_ACPI_STATUS (AE_OK);
    531  1.2.10.2       tls     }
    532  1.2.10.2       tls 
    533  1.2.10.2       tls     /*
    534  1.2.10.2       tls      * We must enable the "search-to-root" for single NameSegs, but
    535  1.2.10.2       tls      * we have to be very careful about opening up scopes
    536  1.2.10.2       tls      */
    537  1.2.10.2       tls     Flags = ACPI_NS_SEARCH_PARENT;
    538  1.2.10.2       tls     if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
    539  1.2.10.2       tls         (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    ||
    540  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
    541  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
    542  1.2.10.2       tls     {
    543  1.2.10.2       tls         /*
    544  1.2.10.2       tls          * These are name references, do not push the scope stack
    545  1.2.10.2       tls          * for them.
    546  1.2.10.2       tls          */
    547  1.2.10.2       tls         Flags |= ACPI_NS_DONT_OPEN_SCOPE;
    548  1.2.10.2       tls     }
    549  1.2.10.2       tls 
    550  1.2.10.2       tls     /* Get the NamePath from the appropriate place */
    551  1.2.10.2       tls 
    552  1.2.10.2       tls     if (OpInfo->Flags & AML_NAMED)
    553  1.2.10.2       tls     {
    554  1.2.10.2       tls         /* For nearly all NAMED operators, the name reference is the first child */
    555  1.2.10.2       tls 
    556  1.2.10.2       tls         Path = Op->Asl.Child->Asl.Value.String;
    557  1.2.10.2       tls         if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
    558  1.2.10.2       tls         {
    559  1.2.10.2       tls             /*
    560  1.2.10.2       tls              * ALIAS is the only oddball opcode, the name declaration
    561  1.2.10.2       tls              * (alias name) is the second operand
    562  1.2.10.2       tls              */
    563  1.2.10.2       tls             Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
    564  1.2.10.2       tls         }
    565  1.2.10.2       tls     }
    566  1.2.10.2       tls     else if (OpInfo->Flags & AML_CREATE)
    567  1.2.10.2       tls     {
    568  1.2.10.2       tls         /* Name must appear as the last parameter */
    569  1.2.10.2       tls 
    570  1.2.10.2       tls         NextOp = Op->Asl.Child;
    571  1.2.10.3  jdolecek         while (!(NextOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
    572  1.2.10.2       tls         {
    573  1.2.10.2       tls             NextOp = NextOp->Asl.Next;
    574  1.2.10.2       tls         }
    575  1.2.10.3  jdolecek 
    576  1.2.10.2       tls         Path = NextOp->Asl.Value.String;
    577  1.2.10.2       tls     }
    578  1.2.10.2       tls     else
    579  1.2.10.2       tls     {
    580  1.2.10.2       tls         Path = Op->Asl.Value.String;
    581  1.2.10.2       tls     }
    582  1.2.10.2       tls 
    583  1.2.10.2       tls     ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
    584  1.2.10.2       tls     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
    585  1.2.10.2       tls         "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
    586  1.2.10.2       tls 
    587  1.2.10.2       tls     /*
    588  1.2.10.2       tls      * Lookup the name in the namespace. Name must exist at this point, or it
    589  1.2.10.2       tls      * is an invalid reference.
    590  1.2.10.2       tls      *
    591  1.2.10.2       tls      * The namespace is also used as a lookup table for references to resource
    592  1.2.10.2       tls      * descriptors and the fields within them.
    593  1.2.10.2       tls      */
    594  1.2.10.2       tls     Gbl_NsLookupCount++;
    595  1.2.10.2       tls 
    596  1.2.10.2       tls     Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
    597  1.2.10.3  jdolecek         ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
    598  1.2.10.2       tls     if (ACPI_FAILURE (Status))
    599  1.2.10.2       tls     {
    600  1.2.10.2       tls         if (Status == AE_NOT_FOUND)
    601  1.2.10.2       tls         {
    602  1.2.10.2       tls             /*
    603  1.2.10.2       tls              * We didn't find the name reference by path -- we can qualify this
    604  1.2.10.2       tls              * a little better before we print an error message
    605  1.2.10.2       tls              */
    606  1.2.10.2       tls             if (strlen (Path) == ACPI_NAME_SIZE)
    607  1.2.10.2       tls             {
    608  1.2.10.2       tls                 /* A simple, one-segment ACPI name */
    609  1.2.10.2       tls 
    610  1.2.10.2       tls                 if (XfObjectExists (Path))
    611  1.2.10.2       tls                 {
    612  1.2.10.2       tls                     /*
    613  1.2.10.2       tls                      * There exists such a name, but we couldn't get to it
    614  1.2.10.2       tls                      * from this scope
    615  1.2.10.2       tls                      */
    616  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op,
    617  1.2.10.2       tls                         Op->Asl.ExternalName);
    618  1.2.10.2       tls                 }
    619  1.2.10.2       tls                 else
    620  1.2.10.2       tls                 {
    621  1.2.10.2       tls                     /* The name doesn't exist, period */
    622  1.2.10.2       tls 
    623  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_NOT_EXIST,
    624  1.2.10.2       tls                         Op, Op->Asl.ExternalName);
    625  1.2.10.2       tls                 }
    626  1.2.10.2       tls             }
    627  1.2.10.2       tls             else
    628  1.2.10.2       tls             {
    629  1.2.10.2       tls                 /* Check for a fully qualified path */
    630  1.2.10.2       tls 
    631  1.2.10.2       tls                 if (Path[0] == AML_ROOT_PREFIX)
    632  1.2.10.2       tls                 {
    633  1.2.10.2       tls                     /* Gave full path, the object does not exist */
    634  1.2.10.2       tls 
    635  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op,
    636  1.2.10.2       tls                         Op->Asl.ExternalName);
    637  1.2.10.2       tls                 }
    638  1.2.10.2       tls                 else
    639  1.2.10.2       tls                 {
    640  1.2.10.2       tls                     /*
    641  1.2.10.2       tls                      * We can't tell whether it doesn't exist or just
    642  1.2.10.2       tls                      * can't be reached.
    643  1.2.10.2       tls                      */
    644  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
    645  1.2.10.2       tls                         Op->Asl.ExternalName);
    646  1.2.10.2       tls                 }
    647  1.2.10.2       tls             }
    648  1.2.10.2       tls 
    649  1.2.10.2       tls             Status = AE_OK;
    650  1.2.10.2       tls         }
    651  1.2.10.2       tls 
    652  1.2.10.2       tls         return_ACPI_STATUS (Status);
    653  1.2.10.2       tls     }
    654  1.2.10.2       tls 
    655  1.2.10.2       tls     /* Check for a reference vs. name declaration */
    656  1.2.10.2       tls 
    657  1.2.10.2       tls     if (!(OpInfo->Flags & AML_NAMED) &&
    658  1.2.10.2       tls         !(OpInfo->Flags & AML_CREATE))
    659  1.2.10.2       tls     {
    660  1.2.10.2       tls         /* This node has been referenced, mark it for reference check */
    661  1.2.10.2       tls 
    662  1.2.10.2       tls         Node->Flags |= ANOBJ_IS_REFERENCED;
    663  1.2.10.3  jdolecek 
    664  1.2.10.3  jdolecek #ifdef __UNDER_DEVELOPMENT
    665  1.2.10.3  jdolecek 
    666  1.2.10.3  jdolecek         /* Check for an illegal reference */
    667  1.2.10.3  jdolecek 
    668  1.2.10.3  jdolecek         XfCheckIllegalReference (Op, Node);
    669  1.2.10.3  jdolecek #endif
    670  1.2.10.2       tls     }
    671  1.2.10.2       tls 
    672  1.2.10.2       tls     /* Attempt to optimize the NamePath */
    673  1.2.10.2       tls 
    674  1.2.10.2       tls     OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
    675  1.2.10.2       tls 
    676  1.2.10.2       tls     /*
    677  1.2.10.2       tls      * 1) Dereference an alias (A name reference that is an alias)
    678  1.2.10.2       tls      *    Aliases are not nested, the alias always points to the final object
    679  1.2.10.2       tls      */
    680  1.2.10.2       tls     if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) &&
    681  1.2.10.2       tls         (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
    682  1.2.10.2       tls     {
    683  1.2.10.2       tls         /* This node points back to the original PARSEOP_ALIAS */
    684  1.2.10.2       tls 
    685  1.2.10.2       tls         NextOp = Node->Op;
    686  1.2.10.2       tls 
    687  1.2.10.2       tls         /* The first child is the alias target op */
    688  1.2.10.2       tls 
    689  1.2.10.2       tls         NextOp = NextOp->Asl.Child;
    690  1.2.10.2       tls 
    691  1.2.10.2       tls         /* That in turn points back to original target alias node */
    692  1.2.10.2       tls 
    693  1.2.10.2       tls         if (NextOp->Asl.Node)
    694  1.2.10.2       tls         {
    695  1.2.10.2       tls             Node = NextOp->Asl.Node;
    696  1.2.10.2       tls         }
    697  1.2.10.2       tls 
    698  1.2.10.2       tls         /* Else - forward reference to alias, will be resolved later */
    699  1.2.10.2       tls     }
    700  1.2.10.2       tls 
    701  1.2.10.2       tls     /* 2) Check for a reference to a resource descriptor */
    702  1.2.10.2       tls 
    703  1.2.10.2       tls     if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
    704  1.2.10.2       tls         (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
    705  1.2.10.2       tls     {
    706  1.2.10.2       tls         /*
    707  1.2.10.2       tls          * This was a reference to a field within a resource descriptor.
    708  1.2.10.2       tls          * Extract the associated field offset (either a bit or byte
    709  1.2.10.2       tls          * offset depending on the field type) and change the named
    710  1.2.10.2       tls          * reference into an integer for AML code generation
    711  1.2.10.2       tls          */
    712  1.2.10.2       tls         Offset = Node->Value;
    713  1.2.10.2       tls         TagBitLength = Node->Length;
    714  1.2.10.2       tls 
    715  1.2.10.2       tls         /*
    716  1.2.10.2       tls          * If a field is being created, generate the length (in bits) of
    717  1.2.10.2       tls          * the field. Note: Opcodes other than CreateXxxField and Index
    718  1.2.10.2       tls          * can come through here. For other opcodes, we just need to
    719  1.2.10.2       tls          * convert the resource tag reference to an integer offset.
    720  1.2.10.2       tls          */
    721  1.2.10.2       tls         switch (Op->Asl.Parent->Asl.AmlOpcode)
    722  1.2.10.2       tls         {
    723  1.2.10.2       tls         case AML_CREATE_FIELD_OP: /* Variable "Length" field, in bits */
    724  1.2.10.2       tls             /*
    725  1.2.10.2       tls              * We know the length operand is an integer constant because
    726  1.2.10.2       tls              * we know that it contains a reference to a resource
    727  1.2.10.2       tls              * descriptor tag.
    728  1.2.10.2       tls              */
    729  1.2.10.2       tls             FieldBitLength = (UINT32) Op->Asl.Next->Asl.Value.Integer;
    730  1.2.10.2       tls             break;
    731  1.2.10.2       tls 
    732  1.2.10.2       tls         case AML_CREATE_BIT_FIELD_OP:
    733  1.2.10.2       tls 
    734  1.2.10.2       tls             FieldBitLength = 1;
    735  1.2.10.2       tls             break;
    736  1.2.10.2       tls 
    737  1.2.10.2       tls         case AML_CREATE_BYTE_FIELD_OP:
    738  1.2.10.2       tls         case AML_INDEX_OP:
    739  1.2.10.2       tls 
    740  1.2.10.2       tls             FieldBitLength = 8;
    741  1.2.10.2       tls             break;
    742  1.2.10.2       tls 
    743  1.2.10.2       tls         case AML_CREATE_WORD_FIELD_OP:
    744  1.2.10.2       tls 
    745  1.2.10.2       tls             FieldBitLength = 16;
    746  1.2.10.2       tls             break;
    747  1.2.10.2       tls 
    748  1.2.10.2       tls         case AML_CREATE_DWORD_FIELD_OP:
    749  1.2.10.2       tls 
    750  1.2.10.2       tls             FieldBitLength = 32;
    751  1.2.10.2       tls             break;
    752  1.2.10.2       tls 
    753  1.2.10.2       tls         case AML_CREATE_QWORD_FIELD_OP:
    754  1.2.10.2       tls 
    755  1.2.10.2       tls             FieldBitLength = 64;
    756  1.2.10.2       tls             break;
    757  1.2.10.2       tls 
    758  1.2.10.2       tls         default:
    759  1.2.10.2       tls 
    760  1.2.10.2       tls             FieldBitLength = 0;
    761  1.2.10.2       tls             break;
    762  1.2.10.2       tls         }
    763  1.2.10.2       tls 
    764  1.2.10.2       tls         /* Check the field length against the length of the resource tag */
    765  1.2.10.2       tls 
    766  1.2.10.2       tls         if (FieldBitLength)
    767  1.2.10.2       tls         {
    768  1.2.10.2       tls             if (TagBitLength < FieldBitLength)
    769  1.2.10.2       tls             {
    770  1.2.10.2       tls                 Message = ASL_MSG_TAG_SMALLER;
    771  1.2.10.2       tls             }
    772  1.2.10.2       tls             else if (TagBitLength > FieldBitLength)
    773  1.2.10.2       tls             {
    774  1.2.10.2       tls                 Message = ASL_MSG_TAG_LARGER;
    775  1.2.10.2       tls             }
    776  1.2.10.2       tls 
    777  1.2.10.2       tls             if (Message)
    778  1.2.10.2       tls             {
    779  1.2.10.3  jdolecek                 snprintf (MsgBuffer, sizeof(MsgBuffer),
    780  1.2.10.3  jdolecek                     "Size mismatch, Tag: %u bit%s, Field: %u bit%s",
    781  1.2.10.2       tls                     TagBitLength, (TagBitLength > 1) ? "s" : "",
    782  1.2.10.2       tls                     FieldBitLength, (FieldBitLength > 1) ? "s" : "");
    783  1.2.10.2       tls 
    784  1.2.10.2       tls                 AslError (ASL_WARNING, Message, Op, MsgBuffer);
    785  1.2.10.2       tls             }
    786  1.2.10.2       tls         }
    787  1.2.10.2       tls 
    788  1.2.10.2       tls         /* Convert the BitOffset to a ByteOffset for certain opcodes */
    789  1.2.10.2       tls 
    790  1.2.10.2       tls         switch (Op->Asl.Parent->Asl.AmlOpcode)
    791  1.2.10.2       tls         {
    792  1.2.10.2       tls         case AML_CREATE_BYTE_FIELD_OP:
    793  1.2.10.2       tls         case AML_CREATE_WORD_FIELD_OP:
    794  1.2.10.2       tls         case AML_CREATE_DWORD_FIELD_OP:
    795  1.2.10.2       tls         case AML_CREATE_QWORD_FIELD_OP:
    796  1.2.10.2       tls         case AML_INDEX_OP:
    797  1.2.10.2       tls 
    798  1.2.10.2       tls             Offset = ACPI_DIV_8 (Offset);
    799  1.2.10.2       tls             break;
    800  1.2.10.2       tls 
    801  1.2.10.2       tls         default:
    802  1.2.10.2       tls 
    803  1.2.10.2       tls             break;
    804  1.2.10.2       tls         }
    805  1.2.10.2       tls 
    806  1.2.10.2       tls         /* Now convert this node to an integer whose value is the field offset */
    807  1.2.10.2       tls 
    808  1.2.10.2       tls         Op->Asl.AmlLength = 0;
    809  1.2.10.2       tls         Op->Asl.ParseOpcode = PARSEOP_INTEGER;
    810  1.2.10.2       tls         Op->Asl.Value.Integer = (UINT64) Offset;
    811  1.2.10.3  jdolecek         Op->Asl.CompileFlags |= OP_IS_RESOURCE_FIELD;
    812  1.2.10.2       tls 
    813  1.2.10.2       tls         OpcGenerateAmlOpcode (Op);
    814  1.2.10.2       tls     }
    815  1.2.10.2       tls 
    816  1.2.10.2       tls     /* 3) Check for a method invocation */
    817  1.2.10.2       tls 
    818  1.2.10.2       tls     else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
    819  1.2.10.2       tls                 (Node->Type == ACPI_TYPE_METHOD) &&
    820  1.2.10.2       tls                 (Op->Asl.Parent) &&
    821  1.2.10.2       tls                 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD))   ||
    822  1.2.10.2       tls 
    823  1.2.10.2       tls                 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
    824  1.2.10.2       tls     {
    825  1.2.10.2       tls         /*
    826  1.2.10.2       tls          * A reference to a method within one of these opcodes is not an
    827  1.2.10.2       tls          * invocation of the method, it is simply a reference to the method.
    828  1.2.10.3  jdolecek          *
    829  1.2.10.3  jdolecek          * September 2016: Removed DeRefOf from this list
    830  1.2.10.2       tls          */
    831  1.2.10.2       tls         if ((Op->Asl.Parent) &&
    832  1.2.10.3  jdolecek             ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF)     ||
    833  1.2.10.3  jdolecek             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE)    ||
    834  1.2.10.3  jdolecek             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)||
    835  1.2.10.2       tls             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
    836  1.2.10.2       tls         {
    837  1.2.10.2       tls             return_ACPI_STATUS (AE_OK);
    838  1.2.10.2       tls         }
    839  1.2.10.3  jdolecek 
    840  1.2.10.2       tls         /*
    841  1.2.10.2       tls          * There are two types of method invocation:
    842  1.2.10.2       tls          * 1) Invocation with arguments -- the parser recognizes this
    843  1.2.10.2       tls          *    as a METHODCALL.
    844  1.2.10.2       tls          * 2) Invocation with no arguments --the parser cannot determine that
    845  1.2.10.2       tls          *    this is a method invocation, therefore we have to figure it out
    846  1.2.10.2       tls          *    here.
    847  1.2.10.2       tls          */
    848  1.2.10.2       tls         if (Node->Type != ACPI_TYPE_METHOD)
    849  1.2.10.2       tls         {
    850  1.2.10.2       tls             snprintf (MsgBuffer, sizeof(MsgBuffer), "%s is a %s",
    851  1.2.10.3  jdolecek                 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
    852  1.2.10.2       tls 
    853  1.2.10.2       tls             AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
    854  1.2.10.2       tls             return_ACPI_STATUS (AE_OK);
    855  1.2.10.2       tls         }
    856  1.2.10.2       tls 
    857  1.2.10.2       tls         /* Save the method node in the caller's op */
    858  1.2.10.2       tls 
    859  1.2.10.2       tls         Op->Asl.Node = Node;
    860  1.2.10.2       tls         if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
    861  1.2.10.2       tls         {
    862  1.2.10.2       tls             return_ACPI_STATUS (AE_OK);
    863  1.2.10.2       tls         }
    864  1.2.10.2       tls 
    865  1.2.10.2       tls         /*
    866  1.2.10.2       tls          * This is a method invocation, with or without arguments.
    867  1.2.10.2       tls          * Count the number of arguments, each appears as a child
    868  1.2.10.2       tls          * under the parent node
    869  1.2.10.2       tls          */
    870  1.2.10.2       tls         Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
    871  1.2.10.2       tls         UtSetParseOpName (Op);
    872  1.2.10.2       tls 
    873  1.2.10.2       tls         PassedArgs = 0;
    874  1.2.10.3  jdolecek         NextOp = Op->Asl.Child;
    875  1.2.10.2       tls 
    876  1.2.10.2       tls         while (NextOp)
    877  1.2.10.2       tls         {
    878  1.2.10.2       tls             PassedArgs++;
    879  1.2.10.2       tls             NextOp = NextOp->Asl.Next;
    880  1.2.10.2       tls         }
    881  1.2.10.2       tls 
    882  1.2.10.3  jdolecek         if (Node->Value != ASL_EXTERNAL_METHOD &&
    883  1.2.10.3  jdolecek             Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL)
    884  1.2.10.2       tls         {
    885  1.2.10.2       tls             /*
    886  1.2.10.2       tls              * Check the parsed arguments with the number expected by the
    887  1.2.10.2       tls              * method declaration itself
    888  1.2.10.2       tls              */
    889  1.2.10.2       tls             if (PassedArgs != Node->Value)
    890  1.2.10.2       tls             {
    891  1.2.10.2       tls                 snprintf (MsgBuffer, sizeof(MsgBuffer), "%s requires %u", Op->Asl.ExternalName,
    892  1.2.10.2       tls                             Node->Value);
    893  1.2.10.2       tls 
    894  1.2.10.2       tls                 if (PassedArgs < Node->Value)
    895  1.2.10.2       tls                 {
    896  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
    897  1.2.10.2       tls                 }
    898  1.2.10.2       tls                 else
    899  1.2.10.2       tls                 {
    900  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
    901  1.2.10.2       tls                 }
    902  1.2.10.2       tls             }
    903  1.2.10.2       tls         }
    904  1.2.10.2       tls     }
    905  1.2.10.2       tls 
    906  1.2.10.2       tls     /* 4) Check for an ASL Field definition */
    907  1.2.10.2       tls 
    908  1.2.10.2       tls     else if ((Op->Asl.Parent) &&
    909  1.2.10.2       tls             ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD)     ||
    910  1.2.10.2       tls              (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
    911  1.2.10.2       tls     {
    912  1.2.10.2       tls         /*
    913  1.2.10.2       tls          * Offset checking for fields. If the parent operation region has a
    914  1.2.10.2       tls          * constant length (known at compile time), we can check fields
    915  1.2.10.2       tls          * defined in that region against the region length. This will catch
    916  1.2.10.2       tls          * fields and field units that cannot possibly fit within the region.
    917  1.2.10.2       tls          *
    918  1.2.10.2       tls          * Note: Index fields do not directly reference an operation region,
    919  1.2.10.2       tls          * thus they are not included in this check.
    920  1.2.10.2       tls          */
    921  1.2.10.2       tls         if (Op == Op->Asl.Parent->Asl.Child)
    922  1.2.10.2       tls         {
    923  1.2.10.2       tls             /*
    924  1.2.10.2       tls              * This is the first child of the field node, which is
    925  1.2.10.2       tls              * the name of the region. Get the parse node for the
    926  1.2.10.2       tls              * region -- which contains the length of the region.
    927  1.2.10.2       tls              */
    928  1.2.10.2       tls             OwningOp = Node->Op;
    929  1.2.10.2       tls             Op->Asl.Parent->Asl.ExtraValue =
    930  1.2.10.2       tls                 ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
    931  1.2.10.2       tls 
    932  1.2.10.2       tls             /* Examine the field access width */
    933  1.2.10.2       tls 
    934  1.2.10.2       tls             switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
    935  1.2.10.2       tls             {
    936  1.2.10.2       tls             case AML_FIELD_ACCESS_ANY:
    937  1.2.10.2       tls             case AML_FIELD_ACCESS_BYTE:
    938  1.2.10.2       tls             case AML_FIELD_ACCESS_BUFFER:
    939  1.2.10.2       tls             default:
    940  1.2.10.2       tls 
    941  1.2.10.2       tls                 MinimumLength = 1;
    942  1.2.10.2       tls                 break;
    943  1.2.10.2       tls 
    944  1.2.10.2       tls             case AML_FIELD_ACCESS_WORD:
    945  1.2.10.2       tls 
    946  1.2.10.2       tls                 MinimumLength = 2;
    947  1.2.10.2       tls                 break;
    948  1.2.10.2       tls 
    949  1.2.10.2       tls             case AML_FIELD_ACCESS_DWORD:
    950  1.2.10.2       tls 
    951  1.2.10.2       tls                 MinimumLength = 4;
    952  1.2.10.2       tls                 break;
    953  1.2.10.2       tls 
    954  1.2.10.2       tls             case AML_FIELD_ACCESS_QWORD:
    955  1.2.10.2       tls 
    956  1.2.10.2       tls                 MinimumLength = 8;
    957  1.2.10.2       tls                 break;
    958  1.2.10.2       tls             }
    959  1.2.10.2       tls 
    960  1.2.10.2       tls             /*
    961  1.2.10.2       tls              * Is the region at least as big as the access width?
    962  1.2.10.2       tls              * Note: DataTableRegions have 0 length
    963  1.2.10.2       tls              */
    964  1.2.10.2       tls             if (((UINT32) OwningOp->Asl.Value.Integer) &&
    965  1.2.10.2       tls                 ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
    966  1.2.10.2       tls             {
    967  1.2.10.2       tls                 AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
    968  1.2.10.2       tls             }
    969  1.2.10.2       tls 
    970  1.2.10.2       tls             /*
    971  1.2.10.2       tls              * Check EC/CMOS/SMBUS fields to make sure that the correct
    972  1.2.10.2       tls              * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
    973  1.2.10.2       tls              */
    974  1.2.10.2       tls             SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
    975  1.2.10.2       tls             switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
    976  1.2.10.2       tls             {
    977  1.2.10.2       tls             case ACPI_ADR_SPACE_EC:
    978  1.2.10.2       tls             case ACPI_ADR_SPACE_CMOS:
    979  1.2.10.2       tls             case ACPI_ADR_SPACE_GPIO:
    980  1.2.10.2       tls 
    981  1.2.10.3  jdolecek                 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer !=
    982  1.2.10.3  jdolecek                     AML_FIELD_ACCESS_BYTE)
    983  1.2.10.2       tls                 {
    984  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
    985  1.2.10.2       tls                 }
    986  1.2.10.2       tls                 break;
    987  1.2.10.2       tls 
    988  1.2.10.2       tls             case ACPI_ADR_SPACE_SMBUS:
    989  1.2.10.2       tls             case ACPI_ADR_SPACE_IPMI:
    990  1.2.10.2       tls             case ACPI_ADR_SPACE_GSBUS:
    991  1.2.10.2       tls 
    992  1.2.10.3  jdolecek                 if ((UINT8) Op->Asl.Parent->Asl.Value.Integer !=
    993  1.2.10.3  jdolecek                     AML_FIELD_ACCESS_BUFFER)
    994  1.2.10.2       tls                 {
    995  1.2.10.2       tls                     AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
    996  1.2.10.2       tls                 }
    997  1.2.10.2       tls                 break;
    998  1.2.10.2       tls 
    999  1.2.10.2       tls             default:
   1000  1.2.10.2       tls 
   1001  1.2.10.2       tls                 /* Nothing to do for other address spaces */
   1002  1.2.10.2       tls 
   1003  1.2.10.2       tls                 break;
   1004  1.2.10.2       tls             }
   1005  1.2.10.2       tls         }
   1006  1.2.10.2       tls         else
   1007  1.2.10.2       tls         {
   1008  1.2.10.2       tls             /*
   1009  1.2.10.2       tls              * This is one element of the field list. Check to make sure
   1010  1.2.10.2       tls              * that it does not go beyond the end of the parent operation region.
   1011  1.2.10.2       tls              *
   1012  1.2.10.2       tls              * In the code below:
   1013  1.2.10.2       tls              *    Op->Asl.Parent->Asl.ExtraValue      - Region Length (bits)
   1014  1.2.10.2       tls              *    Op->Asl.ExtraValue                  - Field start offset (bits)
   1015  1.2.10.2       tls              *    Op->Asl.Child->Asl.Value.Integer32  - Field length (bits)
   1016  1.2.10.2       tls              *    Op->Asl.Child->Asl.ExtraValue       - Field access width (bits)
   1017  1.2.10.2       tls              */
   1018  1.2.10.2       tls             if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
   1019  1.2.10.2       tls             {
   1020  1.2.10.2       tls                 XfCheckFieldRange (Op,
   1021  1.2.10.3  jdolecek                     Op->Asl.Parent->Asl.ExtraValue,
   1022  1.2.10.3  jdolecek                     Op->Asl.ExtraValue,
   1023  1.2.10.3  jdolecek                     (UINT32) Op->Asl.Child->Asl.Value.Integer,
   1024  1.2.10.3  jdolecek                     Op->Asl.Child->Asl.ExtraValue);
   1025  1.2.10.2       tls             }
   1026  1.2.10.2       tls         }
   1027  1.2.10.2       tls     }
   1028  1.2.10.2       tls 
   1029  1.2.10.3  jdolecek     /* 5) Check for a connection object */
   1030  1.2.10.3  jdolecek #if 0
   1031  1.2.10.3  jdolecek     else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION)
   1032  1.2.10.3  jdolecek     {
   1033  1.2.10.3  jdolecek         return_ACPI_STATUS (Status);
   1034  1.2.10.3  jdolecek     }
   1035  1.2.10.3  jdolecek #endif
   1036  1.2.10.3  jdolecek 
   1037  1.2.10.2       tls     Op->Asl.Node = Node;
   1038  1.2.10.2       tls     return_ACPI_STATUS (Status);
   1039  1.2.10.2       tls }
   1040  1.2.10.2       tls 
   1041  1.2.10.2       tls 
   1042  1.2.10.2       tls /*******************************************************************************
   1043  1.2.10.2       tls  *
   1044  1.2.10.2       tls  * FUNCTION:    XfNamespaceLocateEnd
   1045  1.2.10.2       tls  *
   1046  1.2.10.2       tls  * PARAMETERS:  ASL_WALK_CALLBACK
   1047  1.2.10.2       tls  *
   1048  1.2.10.2       tls  * RETURN:      Status
   1049  1.2.10.2       tls  *
   1050  1.2.10.2       tls  * DESCRIPTION: Ascending callback used during cross reference. We only
   1051  1.2.10.2       tls  *              need to worry about scope management here.
   1052  1.2.10.2       tls  *
   1053  1.2.10.2       tls  ******************************************************************************/
   1054  1.2.10.2       tls 
   1055  1.2.10.2       tls static ACPI_STATUS
   1056  1.2.10.2       tls XfNamespaceLocateEnd (
   1057  1.2.10.2       tls     ACPI_PARSE_OBJECT       *Op,
   1058  1.2.10.2       tls     UINT32                  Level,
   1059  1.2.10.2       tls     void                    *Context)
   1060  1.2.10.2       tls {
   1061  1.2.10.2       tls     ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context;
   1062  1.2.10.2       tls     const ACPI_OPCODE_INFO  *OpInfo;
   1063  1.2.10.2       tls 
   1064  1.2.10.2       tls 
   1065  1.2.10.2       tls     ACPI_FUNCTION_TRACE (XfNamespaceLocateEnd);
   1066  1.2.10.2       tls 
   1067  1.2.10.2       tls 
   1068  1.2.10.2       tls     /* We are only interested in opcodes that have an associated name */
   1069  1.2.10.2       tls 
   1070  1.2.10.2       tls     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
   1071  1.2.10.2       tls     if (!(OpInfo->Flags & AML_NAMED))
   1072  1.2.10.2       tls     {
   1073  1.2.10.2       tls         return_ACPI_STATUS (AE_OK);
   1074  1.2.10.2       tls     }
   1075  1.2.10.2       tls 
   1076  1.2.10.2       tls     /* Not interested in name references, we did not open a scope for them */
   1077  1.2.10.2       tls 
   1078  1.2.10.2       tls     if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
   1079  1.2.10.2       tls         (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    ||
   1080  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
   1081  1.2.10.3  jdolecek         (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
   1082  1.2.10.2       tls     {
   1083  1.2.10.2       tls         return_ACPI_STATUS (AE_OK);
   1084  1.2.10.2       tls     }
   1085  1.2.10.2       tls 
   1086  1.2.10.2       tls     /* Pop the scope stack if necessary */
   1087  1.2.10.2       tls 
   1088  1.2.10.2       tls     if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
   1089  1.2.10.2       tls     {
   1090  1.2.10.2       tls 
   1091  1.2.10.2       tls         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
   1092  1.2.10.2       tls             "%s: Popping scope for Op %p\n",
   1093  1.2.10.2       tls             AcpiUtGetTypeName (OpInfo->ObjectType), Op));
   1094  1.2.10.2       tls 
   1095  1.2.10.2       tls         (void) AcpiDsScopeStackPop (WalkState);
   1096  1.2.10.2       tls     }
   1097  1.2.10.2       tls 
   1098  1.2.10.2       tls     return_ACPI_STATUS (AE_OK);
   1099  1.2.10.2       tls }
   1100  1.2.10.3  jdolecek 
   1101  1.2.10.3  jdolecek 
   1102  1.2.10.3  jdolecek #ifdef __UNDER_DEVELOPMENT
   1103  1.2.10.3  jdolecek /*******************************************************************************
   1104  1.2.10.3  jdolecek  *
   1105  1.2.10.3  jdolecek  * FUNCTION:    XfIsObjectParental
   1106  1.2.10.3  jdolecek  *
   1107  1.2.10.3  jdolecek  * PARAMETERS:  ChildOp                 - Op to be checked
   1108  1.2.10.3  jdolecek  *              PossibleParentOp        - Determine if this op is in the family
   1109  1.2.10.3  jdolecek  *
   1110  1.2.10.3  jdolecek  * RETURN:      TRUE if ChildOp is a descendent of PossibleParentOp
   1111  1.2.10.3  jdolecek  *
   1112  1.2.10.3  jdolecek  * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to
   1113  1.2.10.3  jdolecek  *              detect if a method is declared within another method.
   1114  1.2.10.3  jdolecek  *
   1115  1.2.10.3  jdolecek  ******************************************************************************/
   1116  1.2.10.3  jdolecek 
   1117  1.2.10.3  jdolecek static BOOLEAN
   1118  1.2.10.3  jdolecek XfIsObjectParental (
   1119  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *ChildOp,
   1120  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *PossibleParentOp)
   1121  1.2.10.3  jdolecek {
   1122  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *ParentOp;
   1123  1.2.10.3  jdolecek 
   1124  1.2.10.3  jdolecek 
   1125  1.2.10.3  jdolecek     /* Search upwards through the tree for possible parent */
   1126  1.2.10.3  jdolecek 
   1127  1.2.10.3  jdolecek     ParentOp = ChildOp;
   1128  1.2.10.3  jdolecek     while (ParentOp)
   1129  1.2.10.3  jdolecek     {
   1130  1.2.10.3  jdolecek         if (ParentOp == PossibleParentOp)
   1131  1.2.10.3  jdolecek         {
   1132  1.2.10.3  jdolecek             return (TRUE);
   1133  1.2.10.3  jdolecek         }
   1134  1.2.10.3  jdolecek 
   1135  1.2.10.3  jdolecek         ParentOp = ParentOp->Asl.Parent;
   1136  1.2.10.3  jdolecek     }
   1137  1.2.10.3  jdolecek 
   1138  1.2.10.3  jdolecek     return (FALSE);
   1139  1.2.10.3  jdolecek }
   1140  1.2.10.3  jdolecek 
   1141  1.2.10.3  jdolecek 
   1142  1.2.10.3  jdolecek /*******************************************************************************
   1143  1.2.10.3  jdolecek  *
   1144  1.2.10.3  jdolecek  * FUNCTION:    XfGetParentMethod
   1145  1.2.10.3  jdolecek  *
   1146  1.2.10.3  jdolecek  * PARAMETERS:  Op                      - Op to be checked
   1147  1.2.10.3  jdolecek  *
   1148  1.2.10.3  jdolecek  * RETURN:      Op for parent method. NULL if object is not within a method.
   1149  1.2.10.3  jdolecek  *
   1150  1.2.10.3  jdolecek  * DESCRIPTION: Determine if an object is within a control method. Used to
   1151  1.2.10.3  jdolecek  *              implement special rules for named references from within a
   1152  1.2.10.3  jdolecek  *              control method.
   1153  1.2.10.3  jdolecek  *
   1154  1.2.10.3  jdolecek  * NOTE: It would be better to have the parser set a flag in the Op if possible.
   1155  1.2.10.3  jdolecek  *
   1156  1.2.10.3  jdolecek  ******************************************************************************/
   1157  1.2.10.3  jdolecek 
   1158  1.2.10.3  jdolecek static ACPI_PARSE_OBJECT *
   1159  1.2.10.3  jdolecek XfGetParentMethod (
   1160  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op)
   1161  1.2.10.3  jdolecek {
   1162  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *ParentOp;
   1163  1.2.10.3  jdolecek 
   1164  1.2.10.3  jdolecek 
   1165  1.2.10.3  jdolecek     if (!Op)
   1166  1.2.10.3  jdolecek     {
   1167  1.2.10.3  jdolecek         return (NULL);
   1168  1.2.10.3  jdolecek     }
   1169  1.2.10.3  jdolecek 
   1170  1.2.10.3  jdolecek     if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
   1171  1.2.10.3  jdolecek     {
   1172  1.2.10.3  jdolecek         return (NULL);
   1173  1.2.10.3  jdolecek     }
   1174  1.2.10.3  jdolecek 
   1175  1.2.10.3  jdolecek     /* Walk upwards through the parse tree, up to the root if necessary */
   1176  1.2.10.3  jdolecek 
   1177  1.2.10.3  jdolecek     ParentOp = Op;
   1178  1.2.10.3  jdolecek     while (ParentOp)
   1179  1.2.10.3  jdolecek     {
   1180  1.2.10.3  jdolecek         if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD)
   1181  1.2.10.3  jdolecek         {
   1182  1.2.10.3  jdolecek             return (ParentOp);
   1183  1.2.10.3  jdolecek         }
   1184  1.2.10.3  jdolecek 
   1185  1.2.10.3  jdolecek         ParentOp = ParentOp->Asl.Parent;
   1186  1.2.10.3  jdolecek     }
   1187  1.2.10.3  jdolecek 
   1188  1.2.10.3  jdolecek     /* Object is not within a method */
   1189  1.2.10.3  jdolecek 
   1190  1.2.10.3  jdolecek     return (NULL);
   1191  1.2.10.3  jdolecek }
   1192  1.2.10.3  jdolecek 
   1193  1.2.10.3  jdolecek 
   1194  1.2.10.3  jdolecek /*******************************************************************************
   1195  1.2.10.3  jdolecek  *
   1196  1.2.10.3  jdolecek  * FUNCTION:    XfCheckIllegalReference
   1197  1.2.10.3  jdolecek  *
   1198  1.2.10.3  jdolecek  * PARAMETERS:  Op                      - Op referring to the target
   1199  1.2.10.3  jdolecek  *              TargetNode              - Target of the reference
   1200  1.2.10.3  jdolecek  *
   1201  1.2.10.3  jdolecek  * RETURN:      None. Emits error message for an illegal reference
   1202  1.2.10.3  jdolecek  *
   1203  1.2.10.3  jdolecek  * DESCRIPTION: Determine if a named reference is legal. A "named" reference
   1204  1.2.10.3  jdolecek  *              is something like: Store(ABCD, ...), where ABCD is an AML
   1205  1.2.10.3  jdolecek  *              Nameseg or Namepath.
   1206  1.2.10.3  jdolecek  *
   1207  1.2.10.3  jdolecek  * NOTE: Caller must ensure that the name Op is in fact a reference, and not
   1208  1.2.10.3  jdolecek  *       an actual name declaration (creation of a named object).
   1209  1.2.10.3  jdolecek  *
   1210  1.2.10.3  jdolecek  ******************************************************************************/
   1211  1.2.10.3  jdolecek 
   1212  1.2.10.3  jdolecek static void
   1213  1.2.10.3  jdolecek XfCheckIllegalReference (
   1214  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *Op,
   1215  1.2.10.3  jdolecek     ACPI_NAMESPACE_NODE     *TargetNode)
   1216  1.2.10.3  jdolecek {
   1217  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *MethodOp1;
   1218  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *MethodOp2;
   1219  1.2.10.3  jdolecek     ACPI_PARSE_OBJECT       *TargetOp;
   1220  1.2.10.3  jdolecek 
   1221  1.2.10.3  jdolecek 
   1222  1.2.10.3  jdolecek     /*
   1223  1.2.10.3  jdolecek      * Check for an illegal reference to a named object:
   1224  1.2.10.3  jdolecek      *
   1225  1.2.10.3  jdolecek      * 1) References from one control method to another, non-parent
   1226  1.2.10.3  jdolecek      *    method are not allowed, they will fail at runtime.
   1227  1.2.10.3  jdolecek      *
   1228  1.2.10.3  jdolecek      * 2) Forward references within a control method are not allowed.
   1229  1.2.10.3  jdolecek      *    AML interpreters use a one-pass parse of control methods
   1230  1.2.10.3  jdolecek      *    so these forward references will fail at runtime.
   1231  1.2.10.3  jdolecek      */
   1232  1.2.10.3  jdolecek     TargetOp = TargetNode->Op;
   1233  1.2.10.3  jdolecek 
   1234  1.2.10.3  jdolecek     MethodOp1 = XfGetParentMethod (Op);
   1235  1.2.10.3  jdolecek     MethodOp2 = XfGetParentMethod (TargetOp);
   1236  1.2.10.3  jdolecek 
   1237  1.2.10.3  jdolecek     /* Are both objects within control method(s)? */
   1238  1.2.10.3  jdolecek 
   1239  1.2.10.3  jdolecek     if (!MethodOp1 || !MethodOp2)
   1240  1.2.10.3  jdolecek     {
   1241  1.2.10.3  jdolecek         return;
   1242  1.2.10.3  jdolecek     }
   1243  1.2.10.3  jdolecek 
   1244  1.2.10.3  jdolecek     /* Objects not in the same method? */
   1245  1.2.10.3  jdolecek 
   1246  1.2.10.3  jdolecek     if (MethodOp1 != MethodOp2)
   1247  1.2.10.3  jdolecek     {
   1248  1.2.10.3  jdolecek         /*
   1249  1.2.10.3  jdolecek          * 1) Cross-method named reference
   1250  1.2.10.3  jdolecek          *
   1251  1.2.10.3  jdolecek          * This is OK if and only if the target reference is within in a
   1252  1.2.10.3  jdolecek          * method that is a parent of current method
   1253  1.2.10.3  jdolecek          */
   1254  1.2.10.3  jdolecek         if (!XfIsObjectParental (MethodOp1, MethodOp2))
   1255  1.2.10.3  jdolecek         {
   1256  1.2.10.3  jdolecek             AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op,
   1257  1.2.10.3  jdolecek                 Op->Asl.ExternalName);
   1258  1.2.10.3  jdolecek         }
   1259  1.2.10.3  jdolecek     }
   1260  1.2.10.3  jdolecek 
   1261  1.2.10.3  jdolecek     /*
   1262  1.2.10.3  jdolecek      * 2) Both reference and target are in the same method. Check if this is
   1263  1.2.10.3  jdolecek      * an (illegal) forward reference by examining the exact source code
   1264  1.2.10.3  jdolecek      * location of each (the referenced object and the object declaration).
   1265  1.2.10.3  jdolecek      * This is a bit nasty, yet effective.
   1266  1.2.10.3  jdolecek      */
   1267  1.2.10.3  jdolecek     else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset)
   1268  1.2.10.3  jdolecek     {
   1269  1.2.10.3  jdolecek         AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
   1270  1.2.10.3  jdolecek             Op->Asl.ExternalName);
   1271  1.2.10.3  jdolecek     }
   1272  1.2.10.3  jdolecek 
   1273  1.2.10.3  jdolecek }
   1274  1.2.10.3  jdolecek #endif
   1275