Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20131218
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: dsfield - Dispatcher field routines
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41  * POSSIBILITY OF SUCH DAMAGES.
  42  */
  43 
  44 #define __DSFIELD_C__
  45 
  46 #include "acpi.h"
  47 #include "accommon.h"
  48 #include "amlcode.h"
  49 #include "acdispat.h"
  50 #include "acinterp.h"
  51 #include "acnamesp.h"
  52 #include "acparser.h"
  53 
  54 
  55 #define _COMPONENT          ACPI_DISPATCHER
  56         ACPI_MODULE_NAME    ("dsfield")
  57 
  58 /* Local prototypes */
  59 



  60 static ACPI_STATUS









  61 AcpiDsGetFieldNames (
  62     ACPI_CREATE_FIELD_INFO  *Info,
  63     ACPI_WALK_STATE         *WalkState,
  64     ACPI_PARSE_OBJECT       *Arg);
  65 
  66 

  67 /*******************************************************************************
  68  *






























































  69  * FUNCTION:    AcpiDsCreateBufferField
  70  *
  71  * PARAMETERS:  Op                  - Current parse op (CreateXXField)
  72  *              WalkState           - Current state
  73  *
  74  * RETURN:      Status
  75  *
  76  * DESCRIPTION: Execute the CreateField operators:
  77  *              CreateBitFieldOp,
  78  *              CreateByteFieldOp,
  79  *              CreateWordFieldOp,
  80  *              CreateDWordFieldOp,
  81  *              CreateQWordFieldOp,
  82  *              CreateFieldOp       (all of which define a field in a buffer)
  83  *
  84  ******************************************************************************/
  85 
  86 ACPI_STATUS
  87 AcpiDsCreateBufferField (
  88     ACPI_PARSE_OBJECT       *Op,
  89     ACPI_WALK_STATE         *WalkState)
  90 {
  91     ACPI_PARSE_OBJECT       *Arg;
  92     ACPI_NAMESPACE_NODE     *Node;
  93     ACPI_STATUS             Status;
  94     ACPI_OPERAND_OBJECT     *ObjDesc;
  95     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
  96     UINT32                  Flags;
  97 
  98 
  99     ACPI_FUNCTION_TRACE (DsCreateBufferField);
 100 
 101 


 226  *
 227  * PARAMETERS:  Info            - CreateField info structure
 228  *  `           WalkState       - Current method state
 229  *              Arg             - First parser arg for the field name list
 230  *
 231  * RETURN:      Status
 232  *
 233  * DESCRIPTION: Process all named fields in a field declaration.  Names are
 234  *              entered into the namespace.
 235  *
 236  ******************************************************************************/
 237 
 238 static ACPI_STATUS
 239 AcpiDsGetFieldNames (
 240     ACPI_CREATE_FIELD_INFO  *Info,
 241     ACPI_WALK_STATE         *WalkState,
 242     ACPI_PARSE_OBJECT       *Arg)
 243 {
 244     ACPI_STATUS             Status;
 245     UINT64                  Position;

 246 
 247 
 248     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
 249 
 250 
 251     /* First field starts at bit zero */
 252 
 253     Info->FieldBitPosition = 0;
 254 
 255     /* Process all elements in the field list (of parse nodes) */
 256 
 257     while (Arg)
 258     {
 259         /*
 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

 264          */
 265         switch (Arg->Common.AmlOpcode)
 266         {
 267         case AML_INT_RESERVEDFIELD_OP:
 268 
 269             Position = (UINT64) Info->FieldBitPosition
 270                         + (UINT64) Arg->Common.Value.Size;
 271 
 272             if (Position > ACPI_UINT32_MAX)
 273             {
 274                 ACPI_ERROR ((AE_INFO,
 275                     "Bit offset within field too large (> 0xFFFFFFFF)"));
 276                 return_ACPI_STATUS (AE_SUPPORT);
 277             }
 278 
 279             Info->FieldBitPosition = (UINT32) Position;
 280             break;
 281 
 282 
 283         case AML_INT_ACCESSFIELD_OP:
 284 
 285             /*
 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.


 289              *
 290              * In FieldFlags, preserve the flag bits other than the
 291              * ACCESS_TYPE bits
 292              */



 293             Info->FieldFlags = (UINT8)
 294                 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
 295                 ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8)));
 296 
 297             Info->Attribute = (UINT8) (Arg->Common.Value.Integer);






 298             break;
 299 







 300 


























 301         case AML_INT_NAMEDFIELD_OP:
 302 
 303             /* Lookup the name, it should already exist */
 304 
 305             Status = AcpiNsLookup (WalkState->ScopeInfo,
 306                         (char *) &Arg->Named.Name, Info->FieldType,
 307                         ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
 308                         WalkState, &Info->FieldNode);
 309             if (ACPI_FAILURE (Status))
 310             {
 311                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
 312                 return_ACPI_STATUS (Status);
 313             }
 314             else
 315             {
 316                 Arg->Common.Node = Info->FieldNode;
 317                 Info->FieldBitLength = Arg->Common.Value.Size;
 318 
 319                 /*
 320                  * If there is no object attached to the node, this node was


 331                     }
 332                 }
 333             }
 334 
 335             /* Keep track of bit position for the next field */
 336 
 337             Position = (UINT64) Info->FieldBitPosition
 338                         + (UINT64) Arg->Common.Value.Size;
 339 
 340             if (Position > ACPI_UINT32_MAX)
 341             {
 342                 ACPI_ERROR ((AE_INFO,
 343                     "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
 344                     ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
 345                 return_ACPI_STATUS (AE_SUPPORT);
 346             }
 347 
 348             Info->FieldBitPosition += Info->FieldBitLength;
 349             break;
 350 
 351 
 352         default:
 353 
 354             ACPI_ERROR ((AE_INFO,
 355                 "Invalid opcode in field list: 0x%X", Arg->Common.AmlOpcode));
 356             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 357         }
 358 
 359         Arg = Arg->Common.Next;
 360     }
 361 
 362     return_ACPI_STATUS (AE_OK);
 363 }
 364 
 365 
 366 /*******************************************************************************
 367  *
 368  * FUNCTION:    AcpiDsCreateField
 369  *
 370  * PARAMETERS:  Op              - Op containing the Field definition and args
 371  *              RegionNode      - Object for the containing Operation Region


 377  *
 378  ******************************************************************************/
 379 
 380 ACPI_STATUS
 381 AcpiDsCreateField (
 382     ACPI_PARSE_OBJECT       *Op,
 383     ACPI_NAMESPACE_NODE     *RegionNode,
 384     ACPI_WALK_STATE         *WalkState)
 385 {
 386     ACPI_STATUS             Status;
 387     ACPI_PARSE_OBJECT       *Arg;
 388     ACPI_CREATE_FIELD_INFO  Info;
 389 
 390 
 391     ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
 392 
 393 
 394     /* First arg is the name of the parent OpRegion (must already exist) */
 395 
 396     Arg = Op->Common.Value.Arg;

 397     if (!RegionNode)
 398     {
 399         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
 400                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
 401                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);




 402         if (ACPI_FAILURE (Status))
 403         {
 404             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
 405             return_ACPI_STATUS (Status);
 406         }
 407     }
 408 


 409     /* Second arg is the field flags */
 410 
 411     Arg = Arg->Common.Next;
 412     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
 413     Info.Attribute = 0;
 414 
 415     /* Each remaining arg is a Named Field */
 416 
 417     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
 418     Info.RegionNode = RegionNode;
 419 
 420     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
 421 
 422     return_ACPI_STATUS (Status);
 423 }
 424 
 425 
 426 /*******************************************************************************
 427  *
 428  * FUNCTION:    AcpiDsInitFieldObjects
 429  *
 430  * PARAMETERS:  Op              - Op containing the Field definition and args
 431  *  `           WalkState       - Current method state
 432  *
 433  * RETURN:      Status
 434  *
 435  * DESCRIPTION: For each "Field Unit" name in the argument list that is
 436  *              part of the field declaration, enter the name into the
 437  *              namespace.
 438  *
 439  ******************************************************************************/
 440 
 441 ACPI_STATUS


 457 
 458     if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
 459     {
 460         if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
 461         {
 462             /* BankField Op is deferred, just return OK */
 463 
 464             return_ACPI_STATUS (AE_OK);
 465         }
 466 
 467         return_ACPI_STATUS (AE_AML_INTERNAL);
 468     }
 469 
 470     /*
 471      * Get the FieldList argument for this opcode. This is the start of the
 472      * list of field elements.
 473      */
 474     switch (WalkState->Opcode)
 475     {
 476     case AML_FIELD_OP:

 477         Arg = AcpiPsGetArg (Op, 2);
 478         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
 479         break;
 480 
 481     case AML_BANK_FIELD_OP:

 482         Arg = AcpiPsGetArg (Op, 4);
 483         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
 484         break;
 485 
 486     case AML_INDEX_FIELD_OP:

 487         Arg = AcpiPsGetArg (Op, 3);
 488         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
 489         break;
 490 
 491     default:

 492         return_ACPI_STATUS (AE_BAD_PARAMETER);
 493     }
 494 
 495     /* Creating new namespace node(s), should not already exist */
 496 
 497     Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
 498             ACPI_NS_ERROR_IF_FOUND;
 499 
 500     /*
 501      * Mark node(s) temporary if we are executing a normal control
 502      * method. (Don't mark if this is a module-level code method)
 503      */
 504     if (WalkState->MethodNode &&
 505         !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
 506     {
 507         Flags |= ACPI_NS_TEMPORARY;
 508     }
 509 
 510     /*
 511      * Walk the list of entries in the FieldList
 512      * Note: FieldList can be of zero length. In this case, Arg will be NULL.
 513      */
 514     while (Arg)
 515     {
 516         /*
 517          * Ignore OFFSET and ACCESSAS terms here; we are only interested in the
 518          * field names in order to enter them into the namespace.
 519          */
 520         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
 521         {
 522             Status = AcpiNsLookup (WalkState->ScopeInfo,
 523                         (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
 524                         Flags, WalkState, &Node);
 525             if (ACPI_FAILURE (Status))
 526             {
 527                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
 528                 if (Status != AE_ALREADY_EXISTS)
 529                 {
 530                     return_ACPI_STATUS (Status);
 531                 }
 532 
 533                 /* Name already exists, just ignore this error */
 534 
 535                 Status = AE_OK;
 536             }
 537 
 538             Arg->Common.Node = Node;


 566     ACPI_PARSE_OBJECT       *Op,
 567     ACPI_NAMESPACE_NODE     *RegionNode,
 568     ACPI_WALK_STATE         *WalkState)
 569 {
 570     ACPI_STATUS             Status;
 571     ACPI_PARSE_OBJECT       *Arg;
 572     ACPI_CREATE_FIELD_INFO  Info;
 573 
 574 
 575     ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
 576 
 577 
 578     /* First arg is the name of the parent OpRegion (must already exist) */
 579 
 580     Arg = Op->Common.Value.Arg;
 581     if (!RegionNode)
 582     {
 583         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
 584                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
 585                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);




 586         if (ACPI_FAILURE (Status))
 587         {
 588             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
 589             return_ACPI_STATUS (Status);
 590         }
 591     }
 592 
 593     /* Second arg is the Bank Register (Field) (must already exist) */
 594 
 595     Arg = Arg->Common.Next;
 596     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 597                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 598                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
 599     if (ACPI_FAILURE (Status))
 600     {
 601         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 602         return_ACPI_STATUS (Status);
 603     }
 604 
 605     /*


 680     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 681                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 682                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
 683     if (ACPI_FAILURE (Status))
 684     {
 685         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 686         return_ACPI_STATUS (Status);
 687     }
 688 
 689     /* Next arg is the field flags */
 690 
 691     Arg = Arg->Common.Next;
 692     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
 693 
 694     /* Each remaining arg is a Named Field */
 695 
 696     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
 697     Info.RegionNode = RegionNode;
 698 
 699     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
 700 
 701     return_ACPI_STATUS (Status);
 702 }
 703 
 704 
   1 /******************************************************************************
   2  *
   3  * Module Name: dsfield - Dispatcher field routines
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41  * POSSIBILITY OF SUCH DAMAGES.
  42  */
  43 
  44 #define __DSFIELD_C__
  45 
  46 #include "acpi.h"
  47 #include "accommon.h"
  48 #include "amlcode.h"
  49 #include "acdispat.h"
  50 #include "acinterp.h"
  51 #include "acnamesp.h"
  52 #include "acparser.h"
  53 
  54 
  55 #define _COMPONENT          ACPI_DISPATCHER
  56         ACPI_MODULE_NAME    ("dsfield")
  57 
  58 /* Local prototypes */
  59 
  60 #ifdef ACPI_ASL_COMPILER
  61 #include "acdisasm.h"
  62 
  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
  73 AcpiDsGetFieldNames (
  74     ACPI_CREATE_FIELD_INFO  *Info,
  75     ACPI_WALK_STATE         *WalkState,
  76     ACPI_PARSE_OBJECT       *Arg);
  77 
  78 
  79 #ifdef ACPI_ASL_COMPILER
  80 /*******************************************************************************
  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  *
 144  * FUNCTION:    AcpiDsCreateBufferField
 145  *
 146  * PARAMETERS:  Op                  - Current parse op (CreateXXField)
 147  *              WalkState           - Current state
 148  *
 149  * RETURN:      Status
 150  *
 151  * DESCRIPTION: Execute the CreateField operators:
 152  *              CreateBitFieldOp,
 153  *              CreateByteFieldOp,
 154  *              CreateWordFieldOp,
 155  *              CreateDwordFieldOp,
 156  *              CreateQwordFieldOp,
 157  *              CreateFieldOp       (all of which define a field in a buffer)
 158  *
 159  ******************************************************************************/
 160 
 161 ACPI_STATUS
 162 AcpiDsCreateBufferField (
 163     ACPI_PARSE_OBJECT       *Op,
 164     ACPI_WALK_STATE         *WalkState)
 165 {
 166     ACPI_PARSE_OBJECT       *Arg;
 167     ACPI_NAMESPACE_NODE     *Node;
 168     ACPI_STATUS             Status;
 169     ACPI_OPERAND_OBJECT     *ObjDesc;
 170     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
 171     UINT32                  Flags;
 172 
 173 
 174     ACPI_FUNCTION_TRACE (DsCreateBufferField);
 175 
 176 


 301  *
 302  * PARAMETERS:  Info            - CreateField info structure
 303  *  `           WalkState       - Current method state
 304  *              Arg             - First parser arg for the field name list
 305  *
 306  * RETURN:      Status
 307  *
 308  * DESCRIPTION: Process all named fields in a field declaration. Names are
 309  *              entered into the namespace.
 310  *
 311  ******************************************************************************/
 312 
 313 static ACPI_STATUS
 314 AcpiDsGetFieldNames (
 315     ACPI_CREATE_FIELD_INFO  *Info,
 316     ACPI_WALK_STATE         *WalkState,
 317     ACPI_PARSE_OBJECT       *Arg)
 318 {
 319     ACPI_STATUS             Status;
 320     UINT64                  Position;
 321     ACPI_PARSE_OBJECT       *Child;
 322 
 323 
 324     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
 325 
 326 
 327     /* First field starts at bit zero */
 328 
 329     Info->FieldBitPosition = 0;
 330 
 331     /* Process all elements in the field list (of parse nodes) */
 332 
 333     while (Arg)
 334     {
 335         /*
 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
 341          */
 342         switch (Arg->Common.AmlOpcode)
 343         {
 344         case AML_INT_RESERVEDFIELD_OP:
 345 
 346             Position = (UINT64) Info->FieldBitPosition
 347                         + (UINT64) Arg->Common.Value.Size;
 348 
 349             if (Position > ACPI_UINT32_MAX)
 350             {
 351                 ACPI_ERROR ((AE_INFO,
 352                     "Bit offset within field too large (> 0xFFFFFFFF)"));
 353                 return_ACPI_STATUS (AE_SUPPORT);
 354             }
 355 
 356             Info->FieldBitPosition = (UINT32) Position;
 357             break;
 358 

 359         case AML_INT_ACCESSFIELD_OP:
 360         case AML_INT_EXTACCESSFIELD_OP:
 361             /*
 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.
 367              *
 368              * In FieldFlags, preserve the flag bits other than the
 369              * ACCESS_TYPE bits.
 370              */
 371 
 372             /* AccessType (ByteAcc, WordAcc, etc.) */
 373 
 374             Info->FieldFlags = (UINT8)
 375                 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
 376                 ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
 377 
 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);
 385             break;
 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;
 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 
 421         case AML_INT_NAMEDFIELD_OP:
 422 
 423             /* Lookup the name, it should already exist */
 424 
 425             Status = AcpiNsLookup (WalkState->ScopeInfo,
 426                         (char *) &Arg->Named.Name, Info->FieldType,
 427                         ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
 428                         WalkState, &Info->FieldNode);
 429             if (ACPI_FAILURE (Status))
 430             {
 431                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
 432                 return_ACPI_STATUS (Status);
 433             }
 434             else
 435             {
 436                 Arg->Common.Node = Info->FieldNode;
 437                 Info->FieldBitLength = Arg->Common.Value.Size;
 438 
 439                 /*
 440                  * If there is no object attached to the node, this node was


 451                     }
 452                 }
 453             }
 454 
 455             /* Keep track of bit position for the next field */
 456 
 457             Position = (UINT64) Info->FieldBitPosition
 458                         + (UINT64) Arg->Common.Value.Size;
 459 
 460             if (Position > ACPI_UINT32_MAX)
 461             {
 462                 ACPI_ERROR ((AE_INFO,
 463                     "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
 464                     ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
 465                 return_ACPI_STATUS (AE_SUPPORT);
 466             }
 467 
 468             Info->FieldBitPosition += Info->FieldBitLength;
 469             break;
 470 

 471         default:
 472 
 473             ACPI_ERROR ((AE_INFO,
 474                 "Invalid opcode in field list: 0x%X", Arg->Common.AmlOpcode));
 475             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
 476         }
 477 
 478         Arg = Arg->Common.Next;
 479     }
 480 
 481     return_ACPI_STATUS (AE_OK);
 482 }
 483 
 484 
 485 /*******************************************************************************
 486  *
 487  * FUNCTION:    AcpiDsCreateField
 488  *
 489  * PARAMETERS:  Op              - Op containing the Field definition and args
 490  *              RegionNode      - Object for the containing Operation Region


 496  *
 497  ******************************************************************************/
 498 
 499 ACPI_STATUS
 500 AcpiDsCreateField (
 501     ACPI_PARSE_OBJECT       *Op,
 502     ACPI_NAMESPACE_NODE     *RegionNode,
 503     ACPI_WALK_STATE         *WalkState)
 504 {
 505     ACPI_STATUS             Status;
 506     ACPI_PARSE_OBJECT       *Arg;
 507     ACPI_CREATE_FIELD_INFO  Info;
 508 
 509 
 510     ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
 511 
 512 
 513     /* First arg is the name of the parent OpRegion (must already exist) */
 514 
 515     Arg = Op->Common.Value.Arg;
 516 
 517     if (!RegionNode)
 518     {
 519         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
 520                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
 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
 526         if (ACPI_FAILURE (Status))
 527         {
 528             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
 529             return_ACPI_STATUS (Status);
 530         }
 531     }
 532 
 533     ACPI_MEMSET (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
 534 
 535     /* Second arg is the field flags */
 536 
 537     Arg = Arg->Common.Next;
 538     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
 539     Info.Attribute = 0;
 540 
 541     /* Each remaining arg is a Named Field */
 542 
 543     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
 544     Info.RegionNode = RegionNode;
 545 
 546     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);

 547     return_ACPI_STATUS (Status);
 548 }
 549 
 550 
 551 /*******************************************************************************
 552  *
 553  * FUNCTION:    AcpiDsInitFieldObjects
 554  *
 555  * PARAMETERS:  Op              - Op containing the Field definition and args
 556  *  `           WalkState       - Current method state
 557  *
 558  * RETURN:      Status
 559  *
 560  * DESCRIPTION: For each "Field Unit" name in the argument list that is
 561  *              part of the field declaration, enter the name into the
 562  *              namespace.
 563  *
 564  ******************************************************************************/
 565 
 566 ACPI_STATUS


 582 
 583     if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
 584     {
 585         if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
 586         {
 587             /* BankField Op is deferred, just return OK */
 588 
 589             return_ACPI_STATUS (AE_OK);
 590         }
 591 
 592         return_ACPI_STATUS (AE_AML_INTERNAL);
 593     }
 594 
 595     /*
 596      * Get the FieldList argument for this opcode. This is the start of the
 597      * list of field elements.
 598      */
 599     switch (WalkState->Opcode)
 600     {
 601     case AML_FIELD_OP:
 602 
 603         Arg = AcpiPsGetArg (Op, 2);
 604         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
 605         break;
 606 
 607     case AML_BANK_FIELD_OP:
 608 
 609         Arg = AcpiPsGetArg (Op, 4);
 610         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
 611         break;
 612 
 613     case AML_INDEX_FIELD_OP:
 614 
 615         Arg = AcpiPsGetArg (Op, 3);
 616         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
 617         break;
 618 
 619     default:
 620 
 621         return_ACPI_STATUS (AE_BAD_PARAMETER);
 622     }
 623 
 624     /* Creating new namespace node(s), should not already exist */
 625 
 626     Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
 627             ACPI_NS_ERROR_IF_FOUND;
 628 
 629     /*
 630      * Mark node(s) temporary if we are executing a normal control
 631      * method. (Don't mark if this is a module-level code method)
 632      */
 633     if (WalkState->MethodNode &&
 634         !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
 635     {
 636         Flags |= ACPI_NS_TEMPORARY;
 637     }
 638 
 639     /*
 640      * Walk the list of entries in the FieldList
 641      * Note: FieldList can be of zero length. In this case, Arg will be NULL.
 642      */
 643     while (Arg)
 644     {
 645         /*
 646          * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
 647          * in the field names in order to enter them into the namespace.
 648          */
 649         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
 650         {
 651             Status = AcpiNsLookup (WalkState->ScopeInfo,
 652                         (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
 653                         Flags, WalkState, &Node);
 654             if (ACPI_FAILURE (Status))
 655             {
 656                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
 657                 if (Status != AE_ALREADY_EXISTS)
 658                 {
 659                     return_ACPI_STATUS (Status);
 660                 }
 661 
 662                 /* Name already exists, just ignore this error */
 663 
 664                 Status = AE_OK;
 665             }
 666 
 667             Arg->Common.Node = Node;


 695     ACPI_PARSE_OBJECT       *Op,
 696     ACPI_NAMESPACE_NODE     *RegionNode,
 697     ACPI_WALK_STATE         *WalkState)
 698 {
 699     ACPI_STATUS             Status;
 700     ACPI_PARSE_OBJECT       *Arg;
 701     ACPI_CREATE_FIELD_INFO  Info;
 702 
 703 
 704     ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
 705 
 706 
 707     /* First arg is the name of the parent OpRegion (must already exist) */
 708 
 709     Arg = Op->Common.Value.Arg;
 710     if (!RegionNode)
 711     {
 712         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
 713                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
 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
 719         if (ACPI_FAILURE (Status))
 720         {
 721             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
 722             return_ACPI_STATUS (Status);
 723         }
 724     }
 725 
 726     /* Second arg is the Bank Register (Field) (must already exist) */
 727 
 728     Arg = Arg->Common.Next;
 729     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 730                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 731                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
 732     if (ACPI_FAILURE (Status))
 733     {
 734         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 735         return_ACPI_STATUS (Status);
 736     }
 737 
 738     /*


 813     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 814                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 815                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
 816     if (ACPI_FAILURE (Status))
 817     {
 818         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 819         return_ACPI_STATUS (Status);
 820     }
 821 
 822     /* Next arg is the field flags */
 823 
 824     Arg = Arg->Common.Next;
 825     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
 826 
 827     /* Each remaining arg is a Named Field */
 828 
 829     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
 830     Info.RegionNode = RegionNode;
 831 
 832     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);

 833     return_ACPI_STATUS (Status);
 834 }