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