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
↓ 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;
↓ 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              {
↓ 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  
↓ 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
↓ 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
↓ 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)
↓ 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;
↓ 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