Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/executer/exprep.c
          +++ new/usr/src/common/acpica/components/executer/exprep.c
   1      -
   2    1  /******************************************************************************
   3    2   *
   4    3   * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
   5    4   *
   6    5   *****************************************************************************/
   7    6  
   8    7  /*
   9      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, Intel Corp.
  10    9   * All rights reserved.
  11   10   *
  12   11   * Redistribution and use in source and binary forms, with or without
  13   12   * modification, are permitted provided that the following conditions
  14   13   * are met:
  15   14   * 1. Redistributions of source code must retain the above copyright
  16   15   *    notice, this list of conditions, and the following disclaimer,
  17   16   *    without modification.
  18   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 22 lines elided ↑ open up ↑
  42   41   * POSSIBILITY OF SUCH DAMAGES.
  43   42   */
  44   43  
  45   44  #define __EXPREP_C__
  46   45  
  47   46  #include "acpi.h"
  48   47  #include "accommon.h"
  49   48  #include "acinterp.h"
  50   49  #include "amlcode.h"
  51   50  #include "acnamesp.h"
       51 +#include "acdispat.h"
  52   52  
  53   53  
  54   54  #define _COMPONENT          ACPI_EXECUTER
  55   55          ACPI_MODULE_NAME    ("exprep")
  56   56  
  57   57  /* Local prototypes */
  58   58  
  59   59  static UINT32
  60   60  AcpiExDecodeFieldAccess (
  61   61      ACPI_OPERAND_OBJECT     *ObjDesc,
↓ open down ↓ 17 lines elided ↑ open up ↑
  79   79   *              FieldBitLength      - Length of field in bits
  80   80   *              RegionLength        - Length of parent in bytes
  81   81   *
  82   82   * RETURN:      Field granularity (8, 16, 32 or 64) and
  83   83   *              ByteAlignment (1, 2, 3, or 4)
  84   84   *
  85   85   * DESCRIPTION: Generate an optimal access width for fields defined with the
  86   86   *              AnyAcc keyword.
  87   87   *
  88   88   * NOTE: Need to have the RegionLength in order to check for boundary
  89      - *       conditions (end-of-region).  However, the RegionLength is a deferred
  90      - *       operation.  Therefore, to complete this implementation, the generation
       89 + *       conditions (end-of-region). However, the RegionLength is a deferred
       90 + *       operation. Therefore, to complete this implementation, the generation
  91   91   *       of this access width must be deferred until the region length has
  92   92   *       been evaluated.
  93   93   *
  94   94   ******************************************************************************/
  95   95  
  96   96  static UINT32
  97   97  AcpiExGenerateAccess (
  98   98      UINT32                  FieldBitOffset,
  99   99      UINT32                  FieldBitLength,
 100  100      UINT32                  RegionLength)
↓ open down ↓ 159 lines elided ↑ open up ↑
 260  260                  0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
 261  261          BitLength = ByteAlignment * 8;
 262  262  #endif
 263  263  
 264  264          ByteAlignment = 1;
 265  265          BitLength = 8;
 266  266          break;
 267  267  
 268  268      case AML_FIELD_ACCESS_BYTE:
 269  269      case AML_FIELD_ACCESS_BUFFER:   /* ACPI 2.0 (SMBus Buffer) */
      270 +
 270  271          ByteAlignment = 1;
 271  272          BitLength     = 8;
 272  273          break;
 273  274  
 274  275      case AML_FIELD_ACCESS_WORD:
      276 +
 275  277          ByteAlignment = 2;
 276  278          BitLength     = 16;
 277  279          break;
 278  280  
 279  281      case AML_FIELD_ACCESS_DWORD:
      282 +
 280  283          ByteAlignment = 4;
 281  284          BitLength     = 32;
 282  285          break;
 283  286  
 284  287      case AML_FIELD_ACCESS_QWORD:    /* ACPI 2.0 */
      288 +
 285  289          ByteAlignment = 8;
 286  290          BitLength     = 64;
 287  291          break;
 288  292  
 289  293      default:
      294 +
 290  295          /* Invalid field access type */
 291  296  
 292  297          ACPI_ERROR ((AE_INFO,
 293  298              "Unknown field access type 0x%X",
 294  299              Access));
 295  300          return_UINT32 (0);
 296  301      }
 297  302  
 298  303      if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
 299  304      {
↓ open down ↓ 18 lines elided ↑ open up ↑
 318  323   *              FieldFlags          - Access, LockRule, and UpdateRule.
 319  324   *                                    The format of a FieldFlag is described
 320  325   *                                    in the ACPI specification
 321  326   *              FieldAttribute      - Special attributes (not used)
 322  327   *              FieldBitPosition    - Field start position
 323  328   *              FieldBitLength      - Field length in number of bits
 324  329   *
 325  330   * RETURN:      Status
 326  331   *
 327  332   * DESCRIPTION: Initialize the areas of the field object that are common
 328      - *              to the various types of fields.  Note: This is very "sensitive"
      333 + *              to the various types of fields. Note: This is very "sensitive"
 329  334   *              code because we are solving the general case for field
 330  335   *              alignment.
 331  336   *
 332  337   ******************************************************************************/
 333  338  
 334  339  ACPI_STATUS
 335  340  AcpiExPrepCommonFieldObject (
 336  341      ACPI_OPERAND_OBJECT     *ObjDesc,
 337  342      UINT8                   FieldFlags,
 338  343      UINT8                   FieldAttribute,
↓ open down ↓ 11 lines elided ↑ open up ↑
 350  355      /*
 351  356       * Note: the structure being initialized is the
 352  357       * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
 353  358       * area are initialized by this procedure.
 354  359       */
 355  360      ObjDesc->CommonField.FieldFlags = FieldFlags;
 356  361      ObjDesc->CommonField.Attribute  = FieldAttribute;
 357  362      ObjDesc->CommonField.BitLength  = FieldBitLength;
 358  363  
 359  364      /*
 360      -     * Decode the access type so we can compute offsets.  The access type gives
      365 +     * Decode the access type so we can compute offsets. The access type gives
 361  366       * two pieces of information - the width of each field access and the
 362  367       * necessary ByteAlignment (address granularity) of the access.
 363  368       *
 364  369       * For AnyAcc, the AccessBitWidth is the largest width that is both
 365  370       * necessary and possible in an attempt to access the whole field in one
 366      -     * I/O operation.  However, for AnyAcc, the ByteAlignment is always one
      371 +     * I/O operation. However, for AnyAcc, the ByteAlignment is always one
 367  372       * byte.
 368  373       *
 369  374       * For all Buffer Fields, the ByteAlignment is always one byte.
 370  375       *
 371  376       * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
 372  377       * the same (equivalent) as the ByteAlignment.
 373  378       */
 374  379      AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
 375  380                          &ByteAlignment);
 376  381      if (!AccessBitWidth)
↓ open down ↓ 1 lines elided ↑ open up ↑
 378  383          return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
 379  384      }
 380  385  
 381  386      /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
 382  387  
 383  388      ObjDesc->CommonField.AccessByteWidth = (UINT8)
 384  389          ACPI_DIV_8 (AccessBitWidth);
 385  390  
 386  391      /*
 387  392       * BaseByteOffset is the address of the start of the field within the
 388      -     * region.  It is the byte address of the first *datum* (field-width data
      393 +     * region. It is the byte address of the first *datum* (field-width data
 389  394       * unit) of the field. (i.e., the first datum that contains at least the
 390  395       * first *bit* of the field.)
 391  396       *
 392  397       * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
 393  398       * (Byte access), and it defines the addressing granularity of the parent
 394  399       * region or buffer.
 395  400       */
 396  401      NearestByteAddress =
 397  402          ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
 398  403      ObjDesc->CommonField.BaseByteOffset = (UINT32)
↓ open down ↓ 11 lines elided ↑ open up ↑
 410  415  
 411  416  
 412  417  /*******************************************************************************
 413  418   *
 414  419   * FUNCTION:    AcpiExPrepFieldValue
 415  420   *
 416  421   * PARAMETERS:  Info    - Contains all field creation info
 417  422   *
 418  423   * RETURN:      Status
 419  424   *
 420      - * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
 421      - *              connect it to the parent Node.
      425 + * DESCRIPTION: Construct an object of type ACPI_OPERAND_OBJECT with a
      426 + *              subtype of DefField and connect it to the parent Node.
 422  427   *
 423  428   ******************************************************************************/
 424  429  
 425  430  ACPI_STATUS
 426  431  AcpiExPrepFieldValue (
 427  432      ACPI_CREATE_FIELD_INFO  *Info)
 428  433  {
 429  434      ACPI_OPERAND_OBJECT     *ObjDesc;
 430  435      ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
 431  436      ACPI_STATUS             Status;
↓ open down ↓ 45 lines elided ↑ open up ↑
 477  482      }
 478  483  
 479  484      /* Initialize areas of the object that are specific to the field type */
 480  485  
 481  486      switch (Info->FieldType)
 482  487      {
 483  488      case ACPI_TYPE_LOCAL_REGION_FIELD:
 484  489  
 485  490          ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
 486  491  
      492 +        /* Fields specific to GenericSerialBus fields */
      493 +
      494 +        ObjDesc->Field.AccessLength = Info->AccessLength;
      495 +
      496 +        if (Info->ConnectionNode)
      497 +        {
      498 +            SecondDesc = Info->ConnectionNode->Object;
      499 +            if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID))
      500 +            {
      501 +                Status = AcpiDsGetBufferArguments (SecondDesc);
      502 +                if (ACPI_FAILURE (Status))
      503 +                {
      504 +                    AcpiUtDeleteObjectDesc (ObjDesc);
      505 +                    return_ACPI_STATUS (Status);
      506 +                }
      507 +            }
      508 +
      509 +            ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer;
      510 +            ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length;
      511 +        }
      512 +        else if (Info->ResourceBuffer)
      513 +        {
      514 +            ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer;
      515 +            ObjDesc->Field.ResourceLength = Info->ResourceLength;
      516 +        }
      517 +
 487  518          /* Allow full data read from EC address space */
 488  519  
 489  520          if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
 490  521              (ObjDesc->CommonField.BitLength > 8))
 491  522          {
 492  523              AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
 493  524                  ObjDesc->CommonField.BitLength);
 494  525  
 495  526              /* Maximum byte width supported is 255 */
 496  527  
↓ open down ↓ 6 lines elided ↑ open up ↑
 503  534          /* An additional reference for the container */
 504  535  
 505  536          AcpiUtAddReference (ObjDesc->Field.RegionObj);
 506  537  
 507  538          ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
 508  539              "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
 509  540              ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
 510  541              ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
 511  542          break;
 512  543  
 513      -
 514  544      case ACPI_TYPE_LOCAL_BANK_FIELD:
 515  545  
 516  546          ObjDesc->BankField.Value = Info->BankValue;
 517  547          ObjDesc->BankField.RegionObj =
 518  548              AcpiNsGetAttachedObject (Info->RegionNode);
 519  549          ObjDesc->BankField.BankObj =
 520  550              AcpiNsGetAttachedObject (Info->RegisterNode);
 521  551  
 522  552          /* An additional reference for the attached objects */
 523  553  
↓ open down ↓ 14 lines elided ↑ open up ↑
 538  568           * operands must be evaluated.
 539  569           */
 540  570          SecondDesc = ObjDesc->Common.NextObject;
 541  571          SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
 542  572              Info->DataRegisterNode)->Named.Data;
 543  573          SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
 544  574              Info->DataRegisterNode)->Named.Length;
 545  575  
 546  576          break;
 547  577  
 548      -
 549  578      case ACPI_TYPE_LOCAL_INDEX_FIELD:
 550  579  
 551  580          /* Get the Index and Data registers */
 552  581  
 553  582          ObjDesc->IndexField.IndexObj =
 554  583              AcpiNsGetAttachedObject (Info->RegisterNode);
 555  584          ObjDesc->IndexField.DataObj =
 556  585              AcpiNsGetAttachedObject (Info->DataRegisterNode);
 557  586  
 558  587          if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
↓ open down ↓ 33 lines elided ↑ open up ↑
 592  621              "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
 593  622              ObjDesc->IndexField.StartFieldBitOffset,
 594  623              ObjDesc->IndexField.BaseByteOffset,
 595  624              ObjDesc->IndexField.Value,
 596  625              ObjDesc->Field.AccessByteWidth,
 597  626              ObjDesc->IndexField.IndexObj,
 598  627              ObjDesc->IndexField.DataObj));
 599  628          break;
 600  629  
 601  630      default:
      631 +
 602  632          /* No other types should get here */
      633 +
 603  634          break;
 604  635      }
 605  636  
 606  637      /*
 607  638       * Store the constructed descriptor (ObjDesc) into the parent Node,
 608  639       * preserving the current type of that NamedObj.
 609  640       */
 610  641      Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
 611  642                  AcpiNsGetType (Info->FieldNode));
 612  643  
 613  644      ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
 614  645          Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
 615  646  
 616  647      /* Remove local reference to the object */
 617  648  
 618  649      AcpiUtRemoveReference (ObjDesc);
 619  650      return_ACPI_STATUS (Status);
 620  651  }
 621      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX