2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
|
2004-02-28 20:23:30 +00:00
|
|
|
* $Revision: 127 $
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 1. Copyright Notice
|
|
|
|
*
|
2004-02-28 20:23:30 +00:00
|
|
|
* Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* 2. License
|
|
|
|
*
|
|
|
|
* 2.1. This is your license from Intel Corp. under its intellectual property
|
|
|
|
* rights. You may have additional license terms from the party that provided
|
|
|
|
* you this software, covering your right to use that party's intellectual
|
|
|
|
* property rights.
|
|
|
|
*
|
|
|
|
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
|
|
|
|
* copy of the source code appearing in this file ("Covered Code") an
|
|
|
|
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
|
|
|
|
* base code distributed originally by Intel ("Original Intel Code") to copy,
|
|
|
|
* make derivatives, distribute, use and display any portion of the Covered
|
|
|
|
* Code in any form, with the right to sublicense such rights; and
|
|
|
|
*
|
|
|
|
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
|
|
|
|
* license (with the right to sublicense), under only those claims of Intel
|
|
|
|
* patents that are infringed by the Original Intel Code, to make, use, sell,
|
|
|
|
* offer to sell, and import the Covered Code and derivative works thereof
|
|
|
|
* solely to the minimum extent necessary to exercise the above copyright
|
|
|
|
* license, and in no event shall the patent license extend to any additions
|
|
|
|
* to or modifications of the Original Intel Code. No other license or right
|
|
|
|
* is granted directly or by implication, estoppel or otherwise;
|
|
|
|
*
|
|
|
|
* The above copyright and patent license is granted only if the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* 3. Conditions
|
|
|
|
*
|
|
|
|
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification with rights to further distribute source must include
|
|
|
|
* the above Copyright Notice, the above License, this list of Conditions,
|
|
|
|
* and the following Disclaimer and Export Compliance provision. In addition,
|
|
|
|
* Licensee must cause all Covered Code to which Licensee contributes to
|
|
|
|
* contain a file documenting the changes Licensee made to create that Covered
|
|
|
|
* Code and the date of any change. Licensee must include in that file the
|
|
|
|
* documentation of any changes made by any predecessor Licensee. Licensee
|
|
|
|
* must include a prominent statement that the modification is derived,
|
|
|
|
* directly or indirectly, from Original Intel Code.
|
|
|
|
*
|
|
|
|
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification without rights to further distribute source must
|
|
|
|
* include the following Disclaimer and Export Compliance provision in the
|
|
|
|
* documentation and/or other materials provided with distribution. In
|
|
|
|
* addition, Licensee may not authorize further sublicense of source of any
|
|
|
|
* portion of the Covered Code, and must include terms to the effect that the
|
|
|
|
* license from Licensee to its licensee is limited to the intellectual
|
|
|
|
* property embodied in the software Licensee provides to its licensee, and
|
|
|
|
* not to intellectual property embodied in modifications its licensee may
|
|
|
|
* make.
|
|
|
|
*
|
|
|
|
* 3.3. Redistribution of Executable. Redistribution in executable form of any
|
|
|
|
* substantial portion of the Covered Code or modification must reproduce the
|
|
|
|
* above Copyright Notice, and the following Disclaimer and Export Compliance
|
|
|
|
* provision in the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3.4. Intel retains all right, title, and interest in and to the Original
|
|
|
|
* Intel Code.
|
|
|
|
*
|
|
|
|
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
|
|
|
|
* Intel shall be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in products derived from or relating to the Covered Code
|
|
|
|
* without prior written authorization from Intel.
|
|
|
|
*
|
|
|
|
* 4. Disclaimer and Export Compliance
|
|
|
|
*
|
|
|
|
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
|
|
|
|
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
|
|
|
|
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
|
|
|
|
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
|
|
|
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
|
|
|
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
|
|
|
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
|
|
|
|
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
|
|
|
|
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
|
|
|
|
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
|
|
|
|
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
|
|
|
|
* LIMITED REMEDY.
|
|
|
|
*
|
|
|
|
* 4.3. Licensee shall not export, either directly or indirectly, any of this
|
|
|
|
* software or system incorporating such software without first obtaining any
|
|
|
|
* required license or other approval from the U. S. Department of Commerce or
|
|
|
|
* any other agency or department of the United States Government. In the
|
|
|
|
* event Licensee exports any such software from the United States or
|
|
|
|
* re-exports any such software from a foreign destination, Licensee shall
|
|
|
|
* ensure that the distribution and export/re-export of the software is in
|
|
|
|
* compliance with all laws, regulations, orders, or other restrictions of the
|
|
|
|
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
|
|
|
|
* any of its subsidiaries will export/re-export any technical data, process,
|
|
|
|
* software, or service, directly or indirectly, to any country for which the
|
|
|
|
* United States government or any agency thereof requires an export license,
|
|
|
|
* other governmental approval, or letter of assurance, without first obtaining
|
|
|
|
* such license, approval or letter.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define __EXPREP_C__
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
#include "acpi.h"
|
|
|
|
#include "acinterp.h"
|
|
|
|
#include "amlcode.h"
|
|
|
|
#include "acnamesp.h"
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_EXECUTER
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("exprep")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
#ifdef ACPI_UNDER_DEVELOPMENT
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiExGenerateAccess
|
|
|
|
*
|
|
|
|
* PARAMETERS: FieldBitOffset - Start of field within parent region/buffer
|
|
|
|
* FieldBitLength - Length of field in bits
|
|
|
|
* RegionLength - Length of parent in bytes
|
|
|
|
*
|
|
|
|
* RETURN: Field granularity (8, 16, 32 or 64) and
|
|
|
|
* ByteAlignment (1, 2, 3, or 4)
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Generate an optimal access width for fields defined with the
|
|
|
|
* AnyAcc keyword.
|
|
|
|
*
|
|
|
|
* NOTE: Need to have the RegionLength in order to check for boundary
|
|
|
|
* conditions (end-of-region). However, the RegionLength is a deferred
|
|
|
|
* operation. Therefore, to complete this implementation, the generation
|
|
|
|
* of this access width must be deferred until the region length has
|
|
|
|
* been evaluated.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static UINT32
|
|
|
|
AcpiExGenerateAccess (
|
|
|
|
UINT32 FieldBitOffset,
|
|
|
|
UINT32 FieldBitLength,
|
|
|
|
UINT32 RegionLength)
|
|
|
|
{
|
|
|
|
UINT32 FieldByteLength;
|
|
|
|
UINT32 FieldByteOffset;
|
|
|
|
UINT32 FieldByteEndOffset;
|
|
|
|
UINT32 AccessByteWidth;
|
|
|
|
UINT32 FieldStartOffset;
|
|
|
|
UINT32 FieldEndOffset;
|
|
|
|
UINT32 MinimumAccessWidth = 0xFFFFFFFF;
|
|
|
|
UINT32 MinimumAccesses = 0xFFFFFFFF;
|
|
|
|
UINT32 Accesses;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE ("ExGenerateAccess");
|
|
|
|
|
|
|
|
|
|
|
|
/* Round Field start offset and length to "minimal" byte boundaries */
|
|
|
|
|
|
|
|
FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
|
|
|
|
FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + FieldBitOffset, 8));
|
|
|
|
FieldByteLength = FieldByteEndOffset - FieldByteOffset;
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Bit length %d, Bit offset %d\n",
|
|
|
|
FieldBitLength, FieldBitOffset));
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Byte Length %d, Byte Offset %d, End Offset %d\n",
|
|
|
|
FieldByteLength, FieldByteOffset, FieldByteEndOffset));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterative search for the maximum access width that is both aligned
|
|
|
|
* and does not go beyond the end of the region
|
|
|
|
*
|
|
|
|
* Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
|
|
|
|
*/
|
|
|
|
for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 1) Round end offset up to next access boundary and make sure that this
|
|
|
|
* does not go beyond the end of the parent region.
|
|
|
|
* 2) When the Access width is greater than the FieldByteLength, we are done.
|
|
|
|
* (This does not optimize for the perfectly aligned case yet).
|
|
|
|
*/
|
|
|
|
if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
|
|
|
|
{
|
|
|
|
FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
|
|
|
|
AccessByteWidth;
|
|
|
|
FieldEndOffset = ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
|
|
|
|
AccessByteWidth) / AccessByteWidth;
|
|
|
|
Accesses = FieldEndOffset - FieldStartOffset;
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"AccessWidth %d end is within region\n", AccessByteWidth));
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Field Start %d, Field End %d -- requires %d accesses\n",
|
|
|
|
FieldStartOffset, FieldEndOffset, Accesses));
|
|
|
|
|
|
|
|
/* Single access is optimal */
|
|
|
|
|
|
|
|
if (Accesses <= 1)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Entire field can be accessed with one operation of size %d\n",
|
|
|
|
AccessByteWidth));
|
|
|
|
return_VALUE (AccessByteWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fits in the region, but requires more than one read/write.
|
|
|
|
* try the next wider access on next iteration
|
|
|
|
*/
|
|
|
|
if (Accesses < MinimumAccesses)
|
|
|
|
{
|
|
|
|
MinimumAccesses = Accesses;
|
|
|
|
MinimumAccessWidth = AccessByteWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"AccessWidth %d end is NOT within region\n", AccessByteWidth));
|
|
|
|
if (AccessByteWidth == 1)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Field goes beyond end-of-region!\n"));
|
|
|
|
return_VALUE (0); /* Field does not fit in the region at all */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This width goes beyond the end-of-region, back off to previous access */
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Backing off to previous optimal access width of %d\n",
|
|
|
|
MinimumAccessWidth));
|
|
|
|
return_VALUE (MinimumAccessWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Could not read/write field with one operation, just use max access width */
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
|
|
|
"Cannot access field in one operation, using width 8\n"));
|
|
|
|
return_VALUE (8);
|
|
|
|
}
|
|
|
|
#endif /* ACPI_UNDER_DEVELOPMENT */
|
|
|
|
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-11-28 04:29:40 +00:00
|
|
|
* FUNCTION: AcpiExDecodeFieldAccess
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS: Access - Encoded field access bits
|
2001-05-29 19:52:40 +00:00
|
|
|
* Length - Field length.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-11-28 04:29:40 +00:00
|
|
|
* RETURN: Field granularity (8, 16, 32 or 64) and
|
|
|
|
* ByteAlignment (1, 2, 3, or 4)
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Decode the AccessType bits of a field definition.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2000-12-01 09:36:25 +00:00
|
|
|
static UINT32
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiExDecodeFieldAccess (
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc,
|
|
|
|
UINT8 FieldFlags,
|
|
|
|
UINT32 *ReturnByteAlignment)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
UINT32 Access;
|
2003-12-09 02:45:16 +00:00
|
|
|
UINT32 ByteAlignment;
|
|
|
|
UINT32 BitLength;
|
2001-11-28 04:29:40 +00:00
|
|
|
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("ExDecodeFieldAccess");
|
2001-11-28 04:29:40 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
switch (Access)
|
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
case AML_FIELD_ACCESS_ANY:
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
#ifdef ACPI_UNDER_DEVELOPMENT
|
|
|
|
ByteAlignment = AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
|
|
|
|
ObjDesc->CommonField.BitLength,
|
|
|
|
0xFFFFFFFF /* Temp until we pass RegionLength as param */);
|
|
|
|
BitLength = ByteAlignment * 8;
|
|
|
|
#endif
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
ByteAlignment = 1;
|
2002-03-16 02:18:13 +00:00
|
|
|
BitLength = 8;
|
2001-11-28 04:29:40 +00:00
|
|
|
break;
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
case AML_FIELD_ACCESS_BYTE:
|
2002-11-27 18:07:48 +00:00
|
|
|
case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
|
2001-11-28 04:29:40 +00:00
|
|
|
ByteAlignment = 1;
|
2002-11-27 18:07:48 +00:00
|
|
|
BitLength = 8;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
case AML_FIELD_ACCESS_WORD:
|
|
|
|
ByteAlignment = 2;
|
2002-11-27 18:07:48 +00:00
|
|
|
BitLength = 16;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
case AML_FIELD_ACCESS_DWORD:
|
|
|
|
ByteAlignment = 4;
|
2002-11-27 18:07:48 +00:00
|
|
|
BitLength = 32;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
2002-11-27 18:07:48 +00:00
|
|
|
case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
|
2001-11-28 04:29:40 +00:00
|
|
|
ByteAlignment = 8;
|
2002-11-27 18:07:48 +00:00
|
|
|
BitLength = 64;
|
2001-05-29 19:52:40 +00:00
|
|
|
break;
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
default:
|
|
|
|
/* Invalid field access type */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
|
2002-07-09 17:51:31 +00:00
|
|
|
"Unknown field access type %X\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
Access));
|
2003-12-09 02:45:16 +00:00
|
|
|
return_VALUE (0);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2001-11-28 04:29:40 +00:00
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD)
|
2001-11-28 04:29:40 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* BufferField access can be on any byte boundary, so the
|
|
|
|
* ByteAlignment is always 1 byte -- regardless of any ByteAlignment
|
|
|
|
* implied by the field access type.
|
|
|
|
*/
|
|
|
|
ByteAlignment = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ReturnByteAlignment = ByteAlignment;
|
2003-12-09 02:45:16 +00:00
|
|
|
return_VALUE (BitLength);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiExPrepCommonFieldObject
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS: ObjDesc - The field object
|
2001-05-29 19:52:40 +00:00
|
|
|
* FieldFlags - Access, LockRule, and UpdateRule.
|
2000-10-28 05:01:06 +00:00
|
|
|
* The format of a FieldFlag is described
|
|
|
|
* in the ACPI specification
|
2001-05-29 19:52:40 +00:00
|
|
|
* FieldBitPosition - Field start position
|
|
|
|
* FieldBitLength - Field length in number of bits
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize the areas of the field object that are common
|
2001-11-28 04:29:40 +00:00
|
|
|
* to the various types of fields. Note: This is very "sensitive"
|
|
|
|
* code because we are solving the general case for field
|
|
|
|
* alignment.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_STATUS
|
|
|
|
AcpiExPrepCommonFieldObject (
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc,
|
|
|
|
UINT8 FieldFlags,
|
2001-11-28 04:29:40 +00:00
|
|
|
UINT8 FieldAttribute,
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 FieldBitPosition,
|
|
|
|
UINT32 FieldBitLength)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 AccessBitWidth;
|
2001-11-28 04:29:40 +00:00
|
|
|
UINT32 ByteAlignment;
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 NearestByteAddress;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("ExPrepCommonFieldObject");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/*
|
|
|
|
* Note: the structure being initialized is the
|
2001-11-28 04:29:40 +00:00
|
|
|
* ACPI_COMMON_FIELD_INFO; No structure fields outside of the common
|
|
|
|
* area are initialized by this procedure.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->CommonField.FieldFlags = FieldFlags;
|
|
|
|
ObjDesc->CommonField.Attribute = FieldAttribute;
|
2002-02-23 05:10:40 +00:00
|
|
|
ObjDesc->CommonField.BitLength = FieldBitLength;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
/*
|
2001-07-21 03:55:17 +00:00
|
|
|
* Decode the access type so we can compute offsets. The access type gives
|
|
|
|
* two pieces of information - the width of each field access and the
|
2002-02-23 05:10:40 +00:00
|
|
|
* necessary ByteAlignment (address granularity) of the access.
|
|
|
|
*
|
2002-08-29 01:51:24 +00:00
|
|
|
* For AnyAcc, the AccessBitWidth is the largest width that is both
|
2002-06-30 17:50:46 +00:00
|
|
|
* necessary and possible in an attempt to access the whole field in one
|
2002-08-29 01:51:24 +00:00
|
|
|
* I/O operation. However, for AnyAcc, the ByteAlignment is always one
|
2002-06-30 17:50:46 +00:00
|
|
|
* byte.
|
2002-02-23 05:10:40 +00:00
|
|
|
*
|
2001-11-28 04:29:40 +00:00
|
|
|
* For all Buffer Fields, the ByteAlignment is always one byte.
|
|
|
|
*
|
2002-08-29 01:51:24 +00:00
|
|
|
* For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
|
2002-06-30 17:50:46 +00:00
|
|
|
* the same (equivalent) as the ByteAlignment.
|
2001-07-21 03:55:17 +00:00
|
|
|
*/
|
2002-08-29 01:51:24 +00:00
|
|
|
AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
|
2002-06-30 17:50:46 +00:00
|
|
|
&ByteAlignment);
|
2001-05-29 19:52:40 +00:00
|
|
|
if (!AccessBitWidth)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
|
|
|
|
}
|
|
|
|
|
2001-06-29 20:11:04 +00:00
|
|
|
/* Setup width (access granularity) fields */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->CommonField.AccessByteWidth = (UINT8)
|
2002-06-30 17:50:46 +00:00
|
|
|
ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
/*
|
2002-08-29 01:51:24 +00:00
|
|
|
* BaseByteOffset is the address of the start of the field within the
|
|
|
|
* region. It is the byte address of the first *datum* (field-width data
|
|
|
|
* unit) of the field. (i.e., the first datum that contains at least the
|
2002-06-30 17:50:46 +00:00
|
|
|
* first *bit* of the field.)
|
|
|
|
*
|
2002-08-29 01:51:24 +00:00
|
|
|
* Note: ByteAlignment is always either equal to the AccessBitWidth or 8
|
|
|
|
* (Byte access), and it defines the addressing granularity of the parent
|
2002-06-30 17:50:46 +00:00
|
|
|
* region or buffer.
|
2001-05-29 19:52:40 +00:00
|
|
|
*/
|
2002-08-29 01:51:24 +00:00
|
|
|
NearestByteAddress =
|
2002-06-30 17:50:46 +00:00
|
|
|
ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
|
2003-12-09 02:45:16 +00:00
|
|
|
ObjDesc->CommonField.BaseByteOffset = (UINT32)
|
2002-06-30 17:50:46 +00:00
|
|
|
ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
|
2001-05-29 19:52:40 +00:00
|
|
|
|
|
|
|
/*
|
2002-08-29 01:51:24 +00:00
|
|
|
* StartFieldBitOffset is the offset of the first bit of the field within
|
2002-06-30 17:50:46 +00:00
|
|
|
* a field datum.
|
2001-05-29 19:52:40 +00:00
|
|
|
*/
|
2002-06-30 17:50:46 +00:00
|
|
|
ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
|
|
|
|
(FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
/*
|
2001-05-29 19:52:40 +00:00
|
|
|
* Valid bits -- the number of bits that compose a partial datum,
|
2002-08-29 01:51:24 +00:00
|
|
|
* 1) At the end of the field within the region (arbitrary starting bit
|
2002-06-30 17:50:46 +00:00
|
|
|
* offset)
|
2002-08-29 01:51:24 +00:00
|
|
|
* 2) At the end of a buffer used to contain the field (starting offset
|
2002-06-30 17:50:46 +00:00
|
|
|
* always zero)
|
2001-05-29 19:52:40 +00:00
|
|
|
*/
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->CommonField.EndFieldValidBits = (UINT8)
|
2002-06-30 17:50:46 +00:00
|
|
|
((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) %
|
2001-11-28 04:29:40 +00:00
|
|
|
AccessBitWidth);
|
2002-06-30 17:50:46 +00:00
|
|
|
/* StartBufferBitOffset always = 0 */
|
|
|
|
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->CommonField.EndBufferValidBits = (UINT8)
|
2002-06-30 17:50:46 +00:00
|
|
|
(FieldBitLength % AccessBitWidth);
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
/*
|
2002-08-29 01:51:24 +00:00
|
|
|
* DatumValidBits is the number of valid field bits in the first
|
2002-06-30 17:50:46 +00:00
|
|
|
* field datum.
|
2001-11-28 04:29:40 +00:00
|
|
|
*/
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->CommonField.DatumValidBits = (UINT8)
|
2002-06-30 17:50:46 +00:00
|
|
|
(AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
|
2001-05-29 19:52:40 +00:00
|
|
|
|
|
|
|
/*
|
2001-11-28 04:29:40 +00:00
|
|
|
* Does the entire field fit within a single field access element? (datum)
|
|
|
|
* (i.e., without crossing a datum boundary)
|
2001-05-29 19:52:40 +00:00
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <=
|
2002-06-30 17:50:46 +00:00
|
|
|
(UINT16) AccessBitWidth)
|
2001-05-29 19:52:40 +00:00
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM;
|
2001-05-29 19:52:40 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-10-31 02:32:29 +00:00
|
|
|
* FUNCTION: AcpiExPrepFieldValue
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* PARAMETERS: Node - Owning Node
|
|
|
|
* RegionNode - Region in which field is being defined
|
|
|
|
* FieldFlags - Access, LockRule, and UpdateRule.
|
|
|
|
* FieldBitPosition - Field start position
|
|
|
|
* FieldBitLength - Field length in number of bits
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2001-10-31 02:32:29 +00:00
|
|
|
* DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
|
2000-10-28 05:01:06 +00:00
|
|
|
* connect it to the parent Node.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiExPrepFieldValue (
|
|
|
|
ACPI_CREATE_FIELD_INFO *Info)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
|
|
|
UINT32 Type;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("ExPrepFieldValue");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2002-11-27 18:07:48 +00:00
|
|
|
if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-10-31 02:32:29 +00:00
|
|
|
if (!Info->RegionNode)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null RegionNode\n"));
|
|
|
|
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
Type = AcpiNsGetType (Info->RegionNode);
|
|
|
|
if (Type != ACPI_TYPE_REGION)
|
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
|
2003-12-09 02:45:16 +00:00
|
|
|
"Needed Region, found type %X (%s)\n",
|
2001-10-31 02:32:29 +00:00
|
|
|
Type, AcpiUtGetTypeName (Type)));
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
/* Allocate a new field object */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (!ObjDesc)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize areas of the object that are common to all fields */
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->CommonField.Node = Info->FieldNode;
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags,
|
2001-11-28 04:29:40 +00:00
|
|
|
Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtDeleteObjectDesc (ObjDesc);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
/* Initialize areas of the object that are specific to the field type */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
switch (Info->FieldType)
|
|
|
|
{
|
2002-11-27 18:07:48 +00:00
|
|
|
case ACPI_TYPE_LOCAL_REGION_FIELD:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
/* An additional reference for the container */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->Field.RegionObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-06-30 17:50:46 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
2003-12-09 02:45:16 +00:00
|
|
|
"RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
|
2001-10-31 02:32:29 +00:00
|
|
|
ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
|
2002-02-23 05:10:40 +00:00
|
|
|
ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
|
2001-10-31 02:32:29 +00:00
|
|
|
break;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-11-27 18:07:48 +00:00
|
|
|
case ACPI_TYPE_LOCAL_BANK_FIELD:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->BankField.Value = Info->BankValue;
|
|
|
|
ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
|
|
|
|
ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject (Info->RegisterNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
/* An additional reference for the attached objects */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->BankField.RegionObj);
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->BankField.BankObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-08-29 01:51:24 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
2003-12-09 02:45:16 +00:00
|
|
|
"Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->BankField.StartFieldBitOffset,
|
2002-06-30 17:50:46 +00:00
|
|
|
ObjDesc->BankField.BaseByteOffset,
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->Field.AccessByteWidth,
|
2002-06-30 17:50:46 +00:00
|
|
|
ObjDesc->BankField.RegionObj,
|
2001-11-28 04:29:40 +00:00
|
|
|
ObjDesc->BankField.BankObj));
|
2001-10-31 02:32:29 +00:00
|
|
|
break;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-11-27 18:07:48 +00:00
|
|
|
case ACPI_TYPE_LOCAL_INDEX_FIELD:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (Info->RegisterNode);
|
|
|
|
ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject (Info->DataRegisterNode);
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->IndexField.Value = (UINT32)
|
2002-06-30 17:50:46 +00:00
|
|
|
(Info->FieldBitPosition / ACPI_MUL_8 (ObjDesc->Field.AccessByteWidth));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
|
|
|
|
{
|
2004-02-28 20:23:30 +00:00
|
|
|
ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
|
2001-10-31 02:32:29 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_INTERNAL);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
/* An additional reference for the attached objects */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->IndexField.DataObj);
|
|
|
|
AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-08-29 01:51:24 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
2003-12-09 02:45:16 +00:00
|
|
|
"IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->IndexField.StartFieldBitOffset,
|
2002-06-30 17:50:46 +00:00
|
|
|
ObjDesc->IndexField.BaseByteOffset,
|
2003-12-09 02:45:16 +00:00
|
|
|
ObjDesc->IndexField.Value,
|
2002-08-29 01:51:24 +00:00
|
|
|
ObjDesc->Field.AccessByteWidth,
|
2002-06-30 17:50:46 +00:00
|
|
|
ObjDesc->IndexField.IndexObj,
|
2001-10-31 02:32:29 +00:00
|
|
|
ObjDesc->IndexField.DataObj));
|
|
|
|
break;
|
2002-07-09 17:51:31 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
/* No other types should get here */
|
|
|
|
break;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-29 19:52:40 +00:00
|
|
|
* Store the constructed descriptor (ObjDesc) into the parent Node,
|
|
|
|
* preserving the current type of that NamedObj.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
|
2002-02-23 05:10:40 +00:00
|
|
|
AcpiNsGetType (Info->FieldNode));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
|
|
|
|
Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
/* Remove local reference to the object */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtRemoveReference (ObjDesc);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|