ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

exprep.c
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  *
00004  * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
00005  *
00006  *****************************************************************************/
00007 
00008 /******************************************************************************
00009  *
00010  * 1. Copyright Notice
00011  *
00012  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00013  * All rights reserved.
00014  *
00015  * 2. License
00016  *
00017  * 2.1. This is your license from Intel Corp. under its intellectual property
00018  * rights.  You may have additional license terms from the party that provided
00019  * you this software, covering your right to use that party's intellectual
00020  * property rights.
00021  *
00022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00023  * copy of the source code appearing in this file ("Covered Code") an
00024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00025  * base code distributed originally by Intel ("Original Intel Code") to copy,
00026  * make derivatives, distribute, use and display any portion of the Covered
00027  * Code in any form, with the right to sublicense such rights; and
00028  *
00029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00030  * license (with the right to sublicense), under only those claims of Intel
00031  * patents that are infringed by the Original Intel Code, to make, use, sell,
00032  * offer to sell, and import the Covered Code and derivative works thereof
00033  * solely to the minimum extent necessary to exercise the above copyright
00034  * license, and in no event shall the patent license extend to any additions
00035  * to or modifications of the Original Intel Code.  No other license or right
00036  * is granted directly or by implication, estoppel or otherwise;
00037  *
00038  * The above copyright and patent license is granted only if the following
00039  * conditions are met:
00040  *
00041  * 3. Conditions
00042  *
00043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00044  * Redistribution of source code of any substantial portion of the Covered
00045  * Code or modification with rights to further distribute source must include
00046  * the above Copyright Notice, the above License, this list of Conditions,
00047  * and the following Disclaimer and Export Compliance provision.  In addition,
00048  * Licensee must cause all Covered Code to which Licensee contributes to
00049  * contain a file documenting the changes Licensee made to create that Covered
00050  * Code and the date of any change.  Licensee must include in that file the
00051  * documentation of any changes made by any predecessor Licensee.  Licensee
00052  * must include a prominent statement that the modification is derived,
00053  * directly or indirectly, from Original Intel Code.
00054  *
00055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00056  * Redistribution of source code of any substantial portion of the Covered
00057  * Code or modification without rights to further distribute source must
00058  * include the following Disclaimer and Export Compliance provision in the
00059  * documentation and/or other materials provided with distribution.  In
00060  * addition, Licensee may not authorize further sublicense of source of any
00061  * portion of the Covered Code, and must include terms to the effect that the
00062  * license from Licensee to its licensee is limited to the intellectual
00063  * property embodied in the software Licensee provides to its licensee, and
00064  * not to intellectual property embodied in modifications its licensee may
00065  * make.
00066  *
00067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00068  * substantial portion of the Covered Code or modification must reproduce the
00069  * above Copyright Notice, and the following Disclaimer and Export Compliance
00070  * provision in the documentation and/or other materials provided with the
00071  * distribution.
00072  *
00073  * 3.4. Intel retains all right, title, and interest in and to the Original
00074  * Intel Code.
00075  *
00076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00077  * Intel shall be used in advertising or otherwise to promote the sale, use or
00078  * other dealings in products derived from or relating to the Covered Code
00079  * without prior written authorization from Intel.
00080  *
00081  * 4. Disclaimer and Export Compliance
00082  *
00083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00089  * PARTICULAR PURPOSE.
00090  *
00091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00098  * LIMITED REMEDY.
00099  *
00100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00101  * software or system incorporating such software without first obtaining any
00102  * required license or other approval from the U. S. Department of Commerce or
00103  * any other agency or department of the United States Government.  In the
00104  * event Licensee exports any such software from the United States or
00105  * re-exports any such software from a foreign destination, Licensee shall
00106  * ensure that the distribution and export/re-export of the software is in
00107  * compliance with all laws, regulations, orders, or other restrictions of the
00108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00109  * any of its subsidiaries will export/re-export any technical data, process,
00110  * software, or service, directly or indirectly, to any country for which the
00111  * United States government or any agency thereof requires an export license,
00112  * other governmental approval, or letter of assurance, without first obtaining
00113  * such license, approval or letter.
00114  *
00115  *****************************************************************************/
00116 
00117 #define __EXPREP_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acinterp.h"
00122 #include "amlcode.h"
00123 #include "acnamesp.h"
00124 
00125 
00126 #define _COMPONENT          ACPI_EXECUTER
00127         ACPI_MODULE_NAME    ("exprep")
00128 
00129 /* Local prototypes */
00130 
00131 static UINT32
00132 AcpiExDecodeFieldAccess (
00133     ACPI_OPERAND_OBJECT     *ObjDesc,
00134     UINT8                   FieldFlags,
00135     UINT32                  *ReturnByteAlignment);
00136 
00137 
00138 #ifdef ACPI_UNDER_DEVELOPMENT
00139 
00140 static UINT32
00141 AcpiExGenerateAccess (
00142     UINT32                  FieldBitOffset,
00143     UINT32                  FieldBitLength,
00144     UINT32                  RegionLength);
00145 
00146 /*******************************************************************************
00147  *
00148  * FUNCTION:    AcpiExGenerateAccess
00149  *
00150  * PARAMETERS:  FieldBitOffset      - Start of field within parent region/buffer
00151  *              FieldBitLength      - Length of field in bits
00152  *              RegionLength        - Length of parent in bytes
00153  *
00154  * RETURN:      Field granularity (8, 16, 32 or 64) and
00155  *              ByteAlignment (1, 2, 3, or 4)
00156  *
00157  * DESCRIPTION: Generate an optimal access width for fields defined with the
00158  *              AnyAcc keyword.
00159  *
00160  * NOTE: Need to have the RegionLength in order to check for boundary
00161  *       conditions (end-of-region).  However, the RegionLength is a deferred
00162  *       operation.  Therefore, to complete this implementation, the generation
00163  *       of this access width must be deferred until the region length has
00164  *       been evaluated.
00165  *
00166  ******************************************************************************/
00167 
00168 static UINT32
00169 AcpiExGenerateAccess (
00170     UINT32                  FieldBitOffset,
00171     UINT32                  FieldBitLength,
00172     UINT32                  RegionLength)
00173 {
00174     UINT32                  FieldByteLength;
00175     UINT32                  FieldByteOffset;
00176     UINT32                  FieldByteEndOffset;
00177     UINT32                  AccessByteWidth;
00178     UINT32                  FieldStartOffset;
00179     UINT32                  FieldEndOffset;
00180     UINT32                  MinimumAccessWidth = 0xFFFFFFFF;
00181     UINT32                  MinimumAccesses = 0xFFFFFFFF;
00182     UINT32                  Accesses;
00183 
00184 
00185     ACPI_FUNCTION_TRACE (ExGenerateAccess);
00186 
00187 
00188     /* Round Field start offset and length to "minimal" byte boundaries */
00189 
00190     FieldByteOffset    = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
00191     FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP   (FieldBitLength +
00192                                                       FieldBitOffset, 8));
00193     FieldByteLength    = FieldByteEndOffset - FieldByteOffset;
00194 
00195     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00196         "Bit length %u, Bit offset %u\n",
00197         FieldBitLength, FieldBitOffset));
00198 
00199     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00200         "Byte Length %u, Byte Offset %u, End Offset %u\n",
00201         FieldByteLength, FieldByteOffset, FieldByteEndOffset));
00202 
00203     /*
00204      * Iterative search for the maximum access width that is both aligned
00205      * and does not go beyond the end of the region
00206      *
00207      * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
00208      */
00209     for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
00210     {
00211         /*
00212          * 1) Round end offset up to next access boundary and make sure that
00213          *    this does not go beyond the end of the parent region.
00214          * 2) When the Access width is greater than the FieldByteLength, we
00215          *    are done. (This does not optimize for the perfectly aligned
00216          *    case yet).
00217          */
00218         if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
00219         {
00220             FieldStartOffset =
00221                 ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
00222                 AccessByteWidth;
00223 
00224             FieldEndOffset =
00225                 ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
00226                     AccessByteWidth) / AccessByteWidth;
00227 
00228             Accesses = FieldEndOffset - FieldStartOffset;
00229 
00230             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00231                 "AccessWidth %u end is within region\n", AccessByteWidth));
00232 
00233             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00234                 "Field Start %u, Field End %u -- requires %u accesses\n",
00235                 FieldStartOffset, FieldEndOffset, Accesses));
00236 
00237             /* Single access is optimal */
00238 
00239             if (Accesses <= 1)
00240             {
00241                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00242                     "Entire field can be accessed with one operation of size %u\n",
00243                     AccessByteWidth));
00244                 return_VALUE (AccessByteWidth);
00245             }
00246 
00247             /*
00248              * Fits in the region, but requires more than one read/write.
00249              * try the next wider access on next iteration
00250              */
00251             if (Accesses < MinimumAccesses)
00252             {
00253                 MinimumAccesses    = Accesses;
00254                 MinimumAccessWidth = AccessByteWidth;
00255             }
00256         }
00257         else
00258         {
00259             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00260                 "AccessWidth %u end is NOT within region\n", AccessByteWidth));
00261             if (AccessByteWidth == 1)
00262             {
00263                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00264                     "Field goes beyond end-of-region!\n"));
00265 
00266                 /* Field does not fit in the region at all */
00267 
00268                 return_VALUE (0);
00269             }
00270 
00271             /*
00272              * This width goes beyond the end-of-region, back off to
00273              * previous access
00274              */
00275             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00276                 "Backing off to previous optimal access width of %u\n",
00277                 MinimumAccessWidth));
00278             return_VALUE (MinimumAccessWidth);
00279         }
00280     }
00281 
00282     /*
00283      * Could not read/write field with one operation,
00284      * just use max access width
00285      */
00286     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00287         "Cannot access field in one operation, using width 8\n"));
00288     return_VALUE (8);
00289 }
00290 #endif /* ACPI_UNDER_DEVELOPMENT */
00291 
00292 
00293 /*******************************************************************************
00294  *
00295  * FUNCTION:    AcpiExDecodeFieldAccess
00296  *
00297  * PARAMETERS:  ObjDesc             - Field object
00298  *              FieldFlags          - Encoded fieldflags (contains access bits)
00299  *              ReturnByteAlignment - Where the byte alignment is returned
00300  *
00301  * RETURN:      Field granularity (8, 16, 32 or 64) and
00302  *              ByteAlignment (1, 2, 3, or 4)
00303  *
00304  * DESCRIPTION: Decode the AccessType bits of a field definition.
00305  *
00306  ******************************************************************************/
00307 
00308 static UINT32
00309 AcpiExDecodeFieldAccess (
00310     ACPI_OPERAND_OBJECT     *ObjDesc,
00311     UINT8                   FieldFlags,
00312     UINT32                  *ReturnByteAlignment)
00313 {
00314     UINT32                  Access;
00315     UINT32                  ByteAlignment;
00316     UINT32                  BitLength;
00317 
00318 
00319     ACPI_FUNCTION_TRACE (ExDecodeFieldAccess);
00320 
00321 
00322     Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
00323 
00324     switch (Access)
00325     {
00326     case AML_FIELD_ACCESS_ANY:
00327 
00328 #ifdef ACPI_UNDER_DEVELOPMENT
00329         ByteAlignment =
00330             AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
00331                 ObjDesc->CommonField.BitLength,
00332                 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
00333         BitLength = ByteAlignment * 8;
00334 #endif
00335 
00336         ByteAlignment = 1;
00337         BitLength = 8;
00338         break;
00339 
00340     case AML_FIELD_ACCESS_BYTE:
00341     case AML_FIELD_ACCESS_BUFFER:   /* ACPI 2.0 (SMBus Buffer) */
00342         ByteAlignment = 1;
00343         BitLength     = 8;
00344         break;
00345 
00346     case AML_FIELD_ACCESS_WORD:
00347         ByteAlignment = 2;
00348         BitLength     = 16;
00349         break;
00350 
00351     case AML_FIELD_ACCESS_DWORD:
00352         ByteAlignment = 4;
00353         BitLength     = 32;
00354         break;
00355 
00356     case AML_FIELD_ACCESS_QWORD:    /* ACPI 2.0 */
00357         ByteAlignment = 8;
00358         BitLength     = 64;
00359         break;
00360 
00361     default:
00362         /* Invalid field access type */
00363 
00364         ACPI_ERROR ((AE_INFO,
00365             "Unknown field access type 0x%X",
00366             Access));
00367         return_UINT32 (0);
00368     }
00369 
00370     if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
00371     {
00372         /*
00373          * BufferField access can be on any byte boundary, so the
00374          * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
00375          * implied by the field access type.
00376          */
00377         ByteAlignment = 1;
00378     }
00379 
00380     *ReturnByteAlignment = ByteAlignment;
00381     return_UINT32 (BitLength);
00382 }
00383 
00384 
00385 /*******************************************************************************
00386  *
00387  * FUNCTION:    AcpiExPrepCommonFieldObject
00388  *
00389  * PARAMETERS:  ObjDesc             - The field object
00390  *              FieldFlags          - Access, LockRule, and UpdateRule.
00391  *                                    The format of a FieldFlag is described
00392  *                                    in the ACPI specification
00393  *              FieldAttribute      - Special attributes (not used)
00394  *              FieldBitPosition    - Field start position
00395  *              FieldBitLength      - Field length in number of bits
00396  *
00397  * RETURN:      Status
00398  *
00399  * DESCRIPTION: Initialize the areas of the field object that are common
00400  *              to the various types of fields.  Note: This is very "sensitive"
00401  *              code because we are solving the general case for field
00402  *              alignment.
00403  *
00404  ******************************************************************************/
00405 
00406 ACPI_STATUS
00407 AcpiExPrepCommonFieldObject (
00408     ACPI_OPERAND_OBJECT     *ObjDesc,
00409     UINT8                   FieldFlags,
00410     UINT8                   FieldAttribute,
00411     UINT32                  FieldBitPosition,
00412     UINT32                  FieldBitLength)
00413 {
00414     UINT32                  AccessBitWidth;
00415     UINT32                  ByteAlignment;
00416     UINT32                  NearestByteAddress;
00417 
00418 
00419     ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
00420 
00421 
00422     /*
00423      * Note: the structure being initialized is the
00424      * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
00425      * area are initialized by this procedure.
00426      */
00427     ObjDesc->CommonField.FieldFlags = FieldFlags;
00428     ObjDesc->CommonField.Attribute  = FieldAttribute;
00429     ObjDesc->CommonField.BitLength  = FieldBitLength;
00430 
00431     /*
00432      * Decode the access type so we can compute offsets.  The access type gives
00433      * two pieces of information - the width of each field access and the
00434      * necessary ByteAlignment (address granularity) of the access.
00435      *
00436      * For AnyAcc, the AccessBitWidth is the largest width that is both
00437      * necessary and possible in an attempt to access the whole field in one
00438      * I/O operation.  However, for AnyAcc, the ByteAlignment is always one
00439      * byte.
00440      *
00441      * For all Buffer Fields, the ByteAlignment is always one byte.
00442      *
00443      * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
00444      * the same (equivalent) as the ByteAlignment.
00445      */
00446     AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
00447                         &ByteAlignment);
00448     if (!AccessBitWidth)
00449     {
00450         return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
00451     }
00452 
00453     /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
00454 
00455     ObjDesc->CommonField.AccessByteWidth = (UINT8)
00456         ACPI_DIV_8 (AccessBitWidth);
00457 
00458     /*
00459      * BaseByteOffset is the address of the start of the field within the
00460      * region.  It is the byte address of the first *datum* (field-width data
00461      * unit) of the field. (i.e., the first datum that contains at least the
00462      * first *bit* of the field.)
00463      *
00464      * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
00465      * (Byte access), and it defines the addressing granularity of the parent
00466      * region or buffer.
00467      */
00468     NearestByteAddress =
00469         ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
00470     ObjDesc->CommonField.BaseByteOffset = (UINT32)
00471         ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
00472 
00473     /*
00474      * StartFieldBitOffset is the offset of the first bit of the field within
00475      * a field datum.
00476      */
00477     ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
00478         (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
00479 
00480     return_ACPI_STATUS (AE_OK);
00481 }
00482 
00483 
00484 /*******************************************************************************
00485  *
00486  * FUNCTION:    AcpiExPrepFieldValue
00487  *
00488  * PARAMETERS:  Info    - Contains all field creation info
00489  *
00490  * RETURN:      Status
00491  *
00492  * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
00493  *              connect it to the parent Node.
00494  *
00495  ******************************************************************************/
00496 
00497 ACPI_STATUS
00498 AcpiExPrepFieldValue (
00499     ACPI_CREATE_FIELD_INFO  *Info)
00500 {
00501     ACPI_OPERAND_OBJECT     *ObjDesc;
00502     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
00503     ACPI_STATUS             Status;
00504     UINT32                  AccessByteWidth;
00505     UINT32                  Type;
00506 
00507 
00508     ACPI_FUNCTION_TRACE (ExPrepFieldValue);
00509 
00510 
00511     /* Parameter validation */
00512 
00513     if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
00514     {
00515         if (!Info->RegionNode)
00516         {
00517             ACPI_ERROR ((AE_INFO, "Null RegionNode"));
00518             return_ACPI_STATUS (AE_AML_NO_OPERAND);
00519         }
00520 
00521         Type = AcpiNsGetType (Info->RegionNode);
00522         if (Type != ACPI_TYPE_REGION)
00523         {
00524             ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
00525                 Type, AcpiUtGetTypeName (Type)));
00526 
00527             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
00528         }
00529     }
00530 
00531     /* Allocate a new field object */
00532 
00533     ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
00534     if (!ObjDesc)
00535     {
00536         return_ACPI_STATUS (AE_NO_MEMORY);
00537     }
00538 
00539     /* Initialize areas of the object that are common to all fields */
00540 
00541     ObjDesc->CommonField.Node = Info->FieldNode;
00542     Status = AcpiExPrepCommonFieldObject (ObjDesc,
00543                 Info->FieldFlags, Info->Attribute,
00544                 Info->FieldBitPosition, Info->FieldBitLength);
00545     if (ACPI_FAILURE (Status))
00546     {
00547         AcpiUtDeleteObjectDesc (ObjDesc);
00548         return_ACPI_STATUS (Status);
00549     }
00550 
00551     /* Initialize areas of the object that are specific to the field type */
00552 
00553     switch (Info->FieldType)
00554     {
00555     case ACPI_TYPE_LOCAL_REGION_FIELD:
00556 
00557         ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
00558 
00559         /* Allow full data read from EC address space */
00560 
00561         if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
00562             (ObjDesc->CommonField.BitLength > 8))
00563         {
00564             AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
00565                 ObjDesc->CommonField.BitLength);
00566 
00567             /* Maximum byte width supported is 255 */
00568 
00569             if (AccessByteWidth < 256)
00570             {
00571                 ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth;
00572             }
00573         }
00574 
00575         /* An additional reference for the container */
00576 
00577         AcpiUtAddReference (ObjDesc->Field.RegionObj);
00578 
00579         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00580             "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
00581             ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
00582             ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
00583         break;
00584 
00585 
00586     case ACPI_TYPE_LOCAL_BANK_FIELD:
00587 
00588         ObjDesc->BankField.Value = Info->BankValue;
00589         ObjDesc->BankField.RegionObj =
00590             AcpiNsGetAttachedObject (Info->RegionNode);
00591         ObjDesc->BankField.BankObj =
00592             AcpiNsGetAttachedObject (Info->RegisterNode);
00593 
00594         /* An additional reference for the attached objects */
00595 
00596         AcpiUtAddReference (ObjDesc->BankField.RegionObj);
00597         AcpiUtAddReference (ObjDesc->BankField.BankObj);
00598 
00599         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00600             "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
00601             ObjDesc->BankField.StartFieldBitOffset,
00602             ObjDesc->BankField.BaseByteOffset,
00603             ObjDesc->Field.AccessByteWidth,
00604             ObjDesc->BankField.RegionObj,
00605             ObjDesc->BankField.BankObj));
00606 
00607         /*
00608          * Remember location in AML stream of the field unit
00609          * opcode and operands -- since the BankValue
00610          * operands must be evaluated.
00611          */
00612         SecondDesc = ObjDesc->Common.NextObject;
00613         SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
00614             Info->DataRegisterNode)->Named.Data;
00615         SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
00616             Info->DataRegisterNode)->Named.Length;
00617 
00618         break;
00619 
00620 
00621     case ACPI_TYPE_LOCAL_INDEX_FIELD:
00622 
00623         /* Get the Index and Data registers */
00624 
00625         ObjDesc->IndexField.IndexObj =
00626             AcpiNsGetAttachedObject (Info->RegisterNode);
00627         ObjDesc->IndexField.DataObj =
00628             AcpiNsGetAttachedObject (Info->DataRegisterNode);
00629 
00630         if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
00631         {
00632             ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
00633             AcpiUtDeleteObjectDesc (ObjDesc);
00634             return_ACPI_STATUS (AE_AML_INTERNAL);
00635         }
00636 
00637         /* An additional reference for the attached objects */
00638 
00639         AcpiUtAddReference (ObjDesc->IndexField.DataObj);
00640         AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
00641 
00642         /*
00643          * April 2006: Changed to match MS behavior
00644          *
00645          * The value written to the Index register is the byte offset of the
00646          * target field in units of the granularity of the IndexField
00647          *
00648          * Previously, the value was calculated as an index in terms of the
00649          * width of the Data register, as below:
00650          *
00651          *      ObjDesc->IndexField.Value = (UINT32)
00652          *          (Info->FieldBitPosition / ACPI_MUL_8 (
00653          *              ObjDesc->Field.AccessByteWidth));
00654          *
00655          * February 2006: Tried value as a byte offset:
00656          *      ObjDesc->IndexField.Value = (UINT32)
00657          *          ACPI_DIV_8 (Info->FieldBitPosition);
00658          */
00659         ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
00660             ACPI_DIV_8 (Info->FieldBitPosition),
00661             ObjDesc->IndexField.AccessByteWidth);
00662 
00663         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
00664             "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
00665             ObjDesc->IndexField.StartFieldBitOffset,
00666             ObjDesc->IndexField.BaseByteOffset,
00667             ObjDesc->IndexField.Value,
00668             ObjDesc->Field.AccessByteWidth,
00669             ObjDesc->IndexField.IndexObj,
00670             ObjDesc->IndexField.DataObj));
00671         break;
00672 
00673     default:
00674         /* No other types should get here */
00675         break;
00676     }
00677 
00678     /*
00679      * Store the constructed descriptor (ObjDesc) into the parent Node,
00680      * preserving the current type of that NamedObj.
00681      */
00682     Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
00683                 AcpiNsGetType (Info->FieldNode));
00684 
00685     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
00686         Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
00687 
00688     /* Remove local reference to the object */
00689 
00690     AcpiUtRemoveReference (ObjDesc);
00691     return_ACPI_STATUS (Status);
00692 }
00693 

Generated on Sun May 27 2012 04:27:17 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.