Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/exprep.c need to be fixed.

0001 
0002 /******************************************************************************
0003  *
0004  * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights.  You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code.  No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision.  In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change.  Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee.  Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution.  In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government.  In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************/
0116 
0117 #define __EXPREP_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acinterp.h"
0122 #include "amlcode.h"
0123 #include "acnamesp.h"
0124 
0125 
0126 #define _COMPONENT          ACPI_EXECUTER
0127         ACPI_MODULE_NAME    ("exprep")
0128 
0129 /* Local prototypes */
0130 
0131 static UINT32
0132 AcpiExDecodeFieldAccess (
0133     ACPI_OPERAND_OBJECT     *ObjDesc,
0134     UINT8                   FieldFlags,
0135     UINT32                  *ReturnByteAlignment);
0136 
0137 
0138 #ifdef ACPI_UNDER_DEVELOPMENT
0139 
0140 static UINT32
0141 AcpiExGenerateAccess (
0142     UINT32                  FieldBitOffset,
0143     UINT32                  FieldBitLength,
0144     UINT32                  RegionLength);
0145 
0146 /*******************************************************************************
0147  *
0148  * FUNCTION:    AcpiExGenerateAccess
0149  *
0150  * PARAMETERS:  FieldBitOffset      - Start of field within parent region/buffer
0151  *              FieldBitLength      - Length of field in bits
0152  *              RegionLength        - Length of parent in bytes
0153  *
0154  * RETURN:      Field granularity (8, 16, 32 or 64) and
0155  *              ByteAlignment (1, 2, 3, or 4)
0156  *
0157  * DESCRIPTION: Generate an optimal access width for fields defined with the
0158  *              AnyAcc keyword.
0159  *
0160  * NOTE: Need to have the RegionLength in order to check for boundary
0161  *       conditions (end-of-region).  However, the RegionLength is a deferred
0162  *       operation.  Therefore, to complete this implementation, the generation
0163  *       of this access width must be deferred until the region length has
0164  *       been evaluated.
0165  *
0166  ******************************************************************************/
0167 
0168 static UINT32
0169 AcpiExGenerateAccess (
0170     UINT32                  FieldBitOffset,
0171     UINT32                  FieldBitLength,
0172     UINT32                  RegionLength)
0173 {
0174     UINT32                  FieldByteLength;
0175     UINT32                  FieldByteOffset;
0176     UINT32                  FieldByteEndOffset;
0177     UINT32                  AccessByteWidth;
0178     UINT32                  FieldStartOffset;
0179     UINT32                  FieldEndOffset;
0180     UINT32                  MinimumAccessWidth = 0xFFFFFFFF;
0181     UINT32                  MinimumAccesses = 0xFFFFFFFF;
0182     UINT32                  Accesses;
0183 
0184 
0185     ACPI_FUNCTION_TRACE (ExGenerateAccess);
0186 
0187 
0188     /* Round Field start offset and length to "minimal" byte boundaries */
0189 
0190     FieldByteOffset    = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
0191     FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP   (FieldBitLength +
0192                                                       FieldBitOffset, 8));
0193     FieldByteLength    = FieldByteEndOffset - FieldByteOffset;
0194 
0195     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0196             "Bit length %d, Bit offset %d\n",
0197             FieldBitLength, FieldBitOffset));
0198 
0199     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0200             "Byte Length %d, Byte Offset %d, End Offset %d\n",
0201             FieldByteLength, FieldByteOffset, FieldByteEndOffset));
0202 
0203     /*
0204      * Iterative search for the maximum access width that is both aligned
0205      * and does not go beyond the end of the region
0206      *
0207      * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
0208      */
0209     for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
0210     {
0211         /*
0212          * 1) Round end offset up to next access boundary and make sure that
0213          *    this does not go beyond the end of the parent region.
0214          * 2) When the Access width is greater than the FieldByteLength, we
0215          *    are done. (This does not optimize for the perfectly aligned
0216          *    case yet).
0217          */
0218         if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
0219         {
0220             FieldStartOffset =
0221                 ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
0222                 AccessByteWidth;
0223 
0224             FieldEndOffset =
0225                 ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
0226                     AccessByteWidth) / AccessByteWidth;
0227 
0228             Accesses = FieldEndOffset - FieldStartOffset;
0229 
0230             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0231                     "AccessWidth %d end is within region\n", AccessByteWidth));
0232 
0233             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0234                     "Field Start %d, Field End %d -- requires %d accesses\n",
0235                     FieldStartOffset, FieldEndOffset, Accesses));
0236 
0237             /* Single access is optimal */
0238 
0239             if (Accesses <= 1)
0240             {
0241                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0242                     "Entire field can be accessed with one operation of size %d\n",
0243                     AccessByteWidth));
0244                 return_VALUE (AccessByteWidth);
0245             }
0246 
0247             /*
0248              * Fits in the region, but requires more than one read/write.
0249              * try the next wider access on next iteration
0250              */
0251             if (Accesses < MinimumAccesses)
0252             {
0253                 MinimumAccesses    = Accesses;
0254                 MinimumAccessWidth = AccessByteWidth;
0255             }
0256         }
0257         else
0258         {
0259             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0260                 "AccessWidth %d end is NOT within region\n", AccessByteWidth));
0261             if (AccessByteWidth == 1)
0262             {
0263                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0264                         "Field goes beyond end-of-region!\n"));
0265 
0266                 /* Field does not fit in the region at all */
0267 
0268                 return_VALUE (0);
0269             }
0270 
0271             /*
0272              * This width goes beyond the end-of-region, back off to
0273              * previous access
0274              */
0275             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0276                     "Backing off to previous optimal access width of %d\n",
0277                     MinimumAccessWidth));
0278             return_VALUE (MinimumAccessWidth);
0279         }
0280     }
0281 
0282     /*
0283      * Could not read/write field with one operation,
0284      * just use max access width
0285      */
0286     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0287             "Cannot access field in one operation, using width 8\n"));
0288     return_VALUE (8);
0289 }
0290 #endif /* ACPI_UNDER_DEVELOPMENT */
0291 
0292 
0293 /*******************************************************************************
0294  *
0295  * FUNCTION:    AcpiExDecodeFieldAccess
0296  *
0297  * PARAMETERS:  ObjDesc             - Field object
0298  *              FieldFlags          - Encoded fieldflags (contains access bits)
0299  *              ReturnByteAlignment - Where the byte alignment is returned
0300  *
0301  * RETURN:      Field granularity (8, 16, 32 or 64) and
0302  *              ByteAlignment (1, 2, 3, or 4)
0303  *
0304  * DESCRIPTION: Decode the AccessType bits of a field definition.
0305  *
0306  ******************************************************************************/
0307 
0308 static UINT32
0309 AcpiExDecodeFieldAccess (
0310     ACPI_OPERAND_OBJECT     *ObjDesc,
0311     UINT8                   FieldFlags,
0312     UINT32                  *ReturnByteAlignment)
0313 {
0314     UINT32                  Access;
0315     UINT32                  ByteAlignment;
0316     UINT32                  BitLength;
0317 
0318 
0319     ACPI_FUNCTION_TRACE (ExDecodeFieldAccess);
0320 
0321 
0322     Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
0323 
0324     switch (Access)
0325     {
0326     case AML_FIELD_ACCESS_ANY:
0327 
0328 #ifdef ACPI_UNDER_DEVELOPMENT
0329         ByteAlignment =
0330             AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
0331                 ObjDesc->CommonField.BitLength,
0332                 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
0333         BitLength = ByteAlignment * 8;
0334 #endif
0335 
0336         ByteAlignment = 1;
0337         BitLength = 8;
0338         break;
0339 
0340     case AML_FIELD_ACCESS_BYTE:
0341     case AML_FIELD_ACCESS_BUFFER:   /* ACPI 2.0 (SMBus Buffer) */
0342         ByteAlignment = 1;
0343         BitLength     = 8;
0344         break;
0345 
0346     case AML_FIELD_ACCESS_WORD:
0347         ByteAlignment = 2;
0348         BitLength     = 16;
0349         break;
0350 
0351     case AML_FIELD_ACCESS_DWORD:
0352         ByteAlignment = 4;
0353         BitLength     = 32;
0354         break;
0355 
0356     case AML_FIELD_ACCESS_QWORD:    /* ACPI 2.0 */
0357         ByteAlignment = 8;
0358         BitLength     = 64;
0359         break;
0360 
0361     default:
0362         /* Invalid field access type */
0363 
0364         ACPI_ERROR ((AE_INFO,
0365             "Unknown field access type %X",
0366             Access));
0367         return_UINT32 (0);
0368     }
0369 
0370     if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
0371     {
0372         /*
0373          * BufferField access can be on any byte boundary, so the
0374          * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
0375          * implied by the field access type.
0376          */
0377         ByteAlignment = 1;
0378     }
0379 
0380     *ReturnByteAlignment = ByteAlignment;
0381     return_UINT32 (BitLength);
0382 }
0383 
0384 
0385 /*******************************************************************************
0386  *
0387  * FUNCTION:    AcpiExPrepCommonFieldObject
0388  *
0389  * PARAMETERS:  ObjDesc             - The field object
0390  *              FieldFlags          - Access, LockRule, and UpdateRule.
0391  *                                    The format of a FieldFlag is described
0392  *                                    in the ACPI specification
0393  *              FieldAttribute      - Special attributes (not used)
0394  *              FieldBitPosition    - Field start position
0395  *              FieldBitLength      - Field length in number of bits
0396  *
0397  * RETURN:      Status
0398  *
0399  * DESCRIPTION: Initialize the areas of the field object that are common
0400  *              to the various types of fields.  Note: This is very "sensitive"
0401  *              code because we are solving the general case for field
0402  *              alignment.
0403  *
0404  ******************************************************************************/
0405 
0406 ACPI_STATUS
0407 AcpiExPrepCommonFieldObject (
0408     ACPI_OPERAND_OBJECT     *ObjDesc,
0409     UINT8                   FieldFlags,
0410     UINT8                   FieldAttribute,
0411     UINT32                  FieldBitPosition,
0412     UINT32                  FieldBitLength)
0413 {
0414     UINT32                  AccessBitWidth;
0415     UINT32                  ByteAlignment;
0416     UINT32                  NearestByteAddress;
0417 
0418 
0419     ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
0420 
0421 
0422     /*
0423      * Note: the structure being initialized is the
0424      * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
0425      * area are initialized by this procedure.
0426      */
0427     ObjDesc->CommonField.FieldFlags = FieldFlags;
0428     ObjDesc->CommonField.Attribute  = FieldAttribute;
0429     ObjDesc->CommonField.BitLength  = FieldBitLength;
0430 
0431     /*
0432      * Decode the access type so we can compute offsets.  The access type gives
0433      * two pieces of information - the width of each field access and the
0434      * necessary ByteAlignment (address granularity) of the access.
0435      *
0436      * For AnyAcc, the AccessBitWidth is the largest width that is both
0437      * necessary and possible in an attempt to access the whole field in one
0438      * I/O operation.  However, for AnyAcc, the ByteAlignment is always one
0439      * byte.
0440      *
0441      * For all Buffer Fields, the ByteAlignment is always one byte.
0442      *
0443      * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
0444      * the same (equivalent) as the ByteAlignment.
0445      */
0446     AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
0447                                 &ByteAlignment);
0448     if (!AccessBitWidth)
0449     {
0450         return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
0451     }
0452 
0453     /* Setup width (access granularity) fields */
0454 
0455     ObjDesc->CommonField.AccessByteWidth = (UINT8)
0456             ACPI_DIV_8 (AccessBitWidth);            /* 1,  2,  4,  8 */
0457 
0458     ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth;
0459 
0460     /*
0461      * BaseByteOffset is the address of the start of the field within the
0462      * region.  It is the byte address of the first *datum* (field-width data
0463      * unit) of the field. (i.e., the first datum that contains at least the
0464      * first *bit* of the field.)
0465      *
0466      * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
0467      * (Byte access), and it defines the addressing granularity of the parent
0468      * region or buffer.
0469      */
0470     NearestByteAddress =
0471             ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
0472     ObjDesc->CommonField.BaseByteOffset = (UINT32)
0473             ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
0474 
0475     /*
0476      * StartFieldBitOffset is the offset of the first bit of the field within
0477      * a field datum.
0478      */
0479     ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
0480         (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
0481 
0482     /*
0483      * Does the entire field fit within a single field access element? (datum)
0484      * (i.e., without crossing a datum boundary)
0485      */
0486     if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <=
0487             (UINT16) AccessBitWidth)
0488     {
0489         ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM;
0490     }
0491 
0492     return_ACPI_STATUS (AE_OK);
0493 }
0494 
0495 
0496 /*******************************************************************************
0497  *
0498  * FUNCTION:    AcpiExPrepFieldValue
0499  *
0500  * PARAMETERS:  Info    - Contains all field creation info
0501  *
0502  * RETURN:      Status
0503  *
0504  * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
0505  *              connect it to the parent Node.
0506  *
0507  ******************************************************************************/
0508 
0509 ACPI_STATUS
0510 AcpiExPrepFieldValue (
0511     ACPI_CREATE_FIELD_INFO  *Info)
0512 {
0513     ACPI_OPERAND_OBJECT     *ObjDesc;
0514     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
0515     UINT32                  Type;
0516     ACPI_STATUS             Status;
0517 
0518 
0519     ACPI_FUNCTION_TRACE (ExPrepFieldValue);
0520 
0521 
0522     /* Parameter validation */
0523 
0524     if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
0525     {
0526         if (!Info->RegionNode)
0527         {
0528             ACPI_ERROR ((AE_INFO, "Null RegionNode"));
0529             return_ACPI_STATUS (AE_AML_NO_OPERAND);
0530         }
0531 
0532         Type = AcpiNsGetType (Info->RegionNode);
0533         if (Type != ACPI_TYPE_REGION)
0534         {
0535             ACPI_ERROR ((AE_INFO,
0536                 "Needed Region, found type %X (%s)",
0537                 Type, AcpiUtGetTypeName (Type)));
0538 
0539             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0540         }
0541     }
0542 
0543     /* Allocate a new field object */
0544 
0545     ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
0546     if (!ObjDesc)
0547     {
0548         return_ACPI_STATUS (AE_NO_MEMORY);
0549     }
0550 
0551     /* Initialize areas of the object that are common to all fields */
0552 
0553     ObjDesc->CommonField.Node = Info->FieldNode;
0554     Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags,
0555                 Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength);
0556     if (ACPI_FAILURE (Status))
0557     {
0558         AcpiUtDeleteObjectDesc (ObjDesc);
0559         return_ACPI_STATUS (Status);
0560     }
0561 
0562     /* Initialize areas of the object that are specific to the field type */
0563 
0564     switch (Info->FieldType)
0565     {
0566     case ACPI_TYPE_LOCAL_REGION_FIELD:
0567 
0568         ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
0569 
0570         /* An additional reference for the container */
0571 
0572         AcpiUtAddReference (ObjDesc->Field.RegionObj);
0573 
0574         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0575             "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
0576             ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
0577             ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
0578         break;
0579 
0580 
0581     case ACPI_TYPE_LOCAL_BANK_FIELD:
0582 
0583         ObjDesc->BankField.Value     = Info->BankValue;
0584         ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (
0585                                             Info->RegionNode);
0586         ObjDesc->BankField.BankObj   = AcpiNsGetAttachedObject (
0587                                             Info->RegisterNode);
0588 
0589         /* An additional reference for the attached objects */
0590 
0591         AcpiUtAddReference (ObjDesc->BankField.RegionObj);
0592         AcpiUtAddReference (ObjDesc->BankField.BankObj);
0593 
0594         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0595             "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
0596             ObjDesc->BankField.StartFieldBitOffset,
0597             ObjDesc->BankField.BaseByteOffset,
0598             ObjDesc->Field.AccessByteWidth,
0599             ObjDesc->BankField.RegionObj,
0600             ObjDesc->BankField.BankObj));
0601 
0602         /*
0603          * Remember location in AML stream of the field unit
0604          * opcode and operands -- since the BankValue
0605          * operands must be evaluated.
0606          */
0607         SecondDesc                  = ObjDesc->Common.NextObject;
0608         SecondDesc->Extra.AmlStart  = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Data;
0609         SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Length;
0610 
0611         break;
0612 
0613 
0614     case ACPI_TYPE_LOCAL_INDEX_FIELD:
0615 
0616         /* Get the Index and Data registers */
0617 
0618         ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (
0619                                             Info->RegisterNode);
0620         ObjDesc->IndexField.DataObj  = AcpiNsGetAttachedObject (
0621                                             Info->DataRegisterNode);
0622 
0623         if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
0624         {
0625             ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
0626             AcpiUtDeleteObjectDesc (ObjDesc);
0627             return_ACPI_STATUS (AE_AML_INTERNAL);
0628         }
0629 
0630         /* An additional reference for the attached objects */
0631 
0632         AcpiUtAddReference (ObjDesc->IndexField.DataObj);
0633         AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
0634 
0635         /*
0636          * April 2006: Changed to match MS behavior
0637          *
0638          * The value written to the Index register is the byte offset of the
0639          * target field in units of the granularity of the IndexField
0640          *
0641          * Previously, the value was calculated as an index in terms of the
0642          * width of the Data register, as below:
0643          *
0644          *      ObjDesc->IndexField.Value = (UINT32)
0645          *          (Info->FieldBitPosition / ACPI_MUL_8 (
0646          *              ObjDesc->Field.AccessByteWidth));
0647          *
0648          * February 2006: Tried value as a byte offset:
0649          *      ObjDesc->IndexField.Value = (UINT32)
0650          *          ACPI_DIV_8 (Info->FieldBitPosition);
0651          */
0652         ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
0653             ACPI_DIV_8 (Info->FieldBitPosition),
0654             ObjDesc->IndexField.AccessByteWidth);
0655 
0656         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
0657             "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
0658             ObjDesc->IndexField.StartFieldBitOffset,
0659             ObjDesc->IndexField.BaseByteOffset,
0660             ObjDesc->IndexField.Value,
0661             ObjDesc->Field.AccessByteWidth,
0662             ObjDesc->IndexField.IndexObj,
0663             ObjDesc->IndexField.DataObj));
0664         break;
0665 
0666     default:
0667         /* No other types should get here */
0668         break;
0669     }
0670 
0671     /*
0672      * Store the constructed descriptor (ObjDesc) into the parent Node,
0673      * preserving the current type of that NamedObj.
0674      */
0675     Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
0676                     AcpiNsGetType (Info->FieldNode));
0677 
0678     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
0679             Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
0680 
0681     /* Remove local reference to the object */
0682 
0683     AcpiUtRemoveReference (ObjDesc);
0684     return_ACPI_STATUS (Status);
0685 }
0686