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
|
2001-08-26 22:28:18 +00:00
|
|
|
* $Revision: 93 $
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 1. Copyright Notice
|
|
|
|
*
|
2001-01-31 09:17:50 +00:00
|
|
|
* Some or all of this work - Copyright (c) 1999, 2000, 2001, 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"
|
|
|
|
#include "acparser.h"
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_EXECUTER
|
|
|
|
MODULE_NAME ("exprep")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiExDecodeFieldAccessType
|
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-08-26 22:28:18 +00:00
|
|
|
* RETURN: Field granularity (8, 16, 32 or 64)
|
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-05-29 19:52:40 +00:00
|
|
|
AcpiExDecodeFieldAccessType (
|
2000-12-21 06:56:46 +00:00
|
|
|
UINT32 Access,
|
2001-07-21 03:55:17 +00:00
|
|
|
UINT16 Length,
|
|
|
|
UINT32 *Alignment)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
PROC_NAME ("AcpiExDecodeFieldAccessType");
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
switch (Access)
|
|
|
|
{
|
|
|
|
case ACCESS_ANY_ACC:
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2001-07-21 03:55:17 +00:00
|
|
|
*Alignment = 8;
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/* Use the length to set the access type */
|
|
|
|
|
2000-12-21 06:56:46 +00:00
|
|
|
if (Length <= 8)
|
|
|
|
{
|
|
|
|
return (8);
|
|
|
|
}
|
|
|
|
else if (Length <= 16)
|
|
|
|
{
|
|
|
|
return (16);
|
|
|
|
}
|
|
|
|
else if (Length <= 32)
|
|
|
|
{
|
|
|
|
return (32);
|
|
|
|
}
|
2001-05-29 19:52:40 +00:00
|
|
|
else if (Length <= 64)
|
2000-12-21 06:56:46 +00:00
|
|
|
{
|
2001-05-29 19:52:40 +00:00
|
|
|
return (64);
|
2000-12-21 06:56:46 +00:00
|
|
|
}
|
2001-05-29 19:52:40 +00:00
|
|
|
|
|
|
|
/* Default is 8 (byte) */
|
|
|
|
|
|
|
|
return (8);
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACCESS_BYTE_ACC:
|
2001-07-21 03:55:17 +00:00
|
|
|
*Alignment = 8;
|
2000-10-28 05:01:06 +00:00
|
|
|
return (8);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACCESS_WORD_ACC:
|
2001-07-21 03:55:17 +00:00
|
|
|
*Alignment = 16;
|
2000-10-28 05:01:06 +00:00
|
|
|
return (16);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACCESS_DWORD_ACC:
|
2001-07-21 03:55:17 +00:00
|
|
|
*Alignment = 32;
|
2000-10-28 05:01:06 +00:00
|
|
|
return (32);
|
|
|
|
break;
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
case ACCESS_QWORD_ACC: /* ACPI 2.0 */
|
2001-07-21 03:55:17 +00:00
|
|
|
*Alignment = 64;
|
2001-05-29 19:52:40 +00:00
|
|
|
return (64);
|
|
|
|
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,
|
|
|
|
"Unknown field access type %x\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
Access));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
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
|
|
|
|
* to the various types of fields.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
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-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-07-21 03:55:17 +00:00
|
|
|
UINT32 Alignment;
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 NearestByteAddress;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
FUNCTION_TRACE ("ExPrepCommonFieldObject");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: the structure being initialized is the
|
2001-05-29 19:52:40 +00:00
|
|
|
* ACPI_COMMON_FIELD_INFO; No structure fields outside of the common area
|
2000-10-28 05:01:06 +00:00
|
|
|
* are initialized by this procedure.
|
|
|
|
*/
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/* Demultiplex the FieldFlags byte */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->CommonField.LockRule = (UINT8) ((FieldFlags & LOCK_RULE_MASK)
|
2000-10-28 05:01:06 +00:00
|
|
|
>> LOCK_RULE_SHIFT);
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->CommonField.UpdateRule = (UINT8) ((FieldFlags & UPDATE_RULE_MASK)
|
2000-10-28 05:01:06 +00:00
|
|
|
>> UPDATE_RULE_SHIFT);
|
|
|
|
/* Other misc fields */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->CommonField.BitLength = (UINT16) FieldBitLength;
|
2000-10-28 05:01:06 +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
|
|
|
|
* necessary alignment of the access. For AnyAcc, the width used is the
|
|
|
|
* largest necessary/possible in an attempt to access the whole field in one
|
|
|
|
* I/O operation. However, for AnyAcc, the alignment is 8. For all other
|
|
|
|
* access types (Byte, Word, Dword, Qword), the width is the same as the
|
|
|
|
* alignment.
|
|
|
|
*/
|
2001-05-29 19:52:40 +00:00
|
|
|
AccessBitWidth = AcpiExDecodeFieldAccessType (
|
|
|
|
((FieldFlags & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT),
|
2001-07-21 03:55:17 +00:00
|
|
|
ObjDesc->Field.BitLength, &Alignment);
|
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
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; /* 8, 16, 32, 64 */
|
|
|
|
ObjDesc->CommonField.AccessByteWidth = (UINT8) DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */
|
|
|
|
|
|
|
|
if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* BufferField access can be on any byte boundary, so the
|
2001-07-21 03:55:17 +00:00
|
|
|
* alignment is always 8 (regardless of any alignment implied by the
|
|
|
|
* field access type.)
|
2001-05-29 19:52:40 +00:00
|
|
|
*/
|
2001-07-21 03:55:17 +00:00
|
|
|
Alignment = 8;
|
2001-05-29 19:52:40 +00:00
|
|
|
}
|
|
|
|
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2001-05-29 19:52:40 +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 first *bit* of the field.)
|
|
|
|
*/
|
|
|
|
NearestByteAddress = ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
|
|
|
|
ObjDesc->CommonField.BaseByteOffset = ROUND_DOWN (NearestByteAddress,
|
2001-07-21 03:55:17 +00:00
|
|
|
DIV_8 (Alignment));
|
2001-05-29 19:52:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* StartFieldBitOffset is the offset of the first bit of the field within a field datum.
|
|
|
|
* This is calculated as the number of bits from the BaseByteOffset. In other words,
|
|
|
|
* the start of the field is relative to a byte address, regardless of the access type
|
|
|
|
* of the field.
|
|
|
|
*/
|
|
|
|
ObjDesc->CommonField.StartFieldBitOffset = (UINT8) (MOD_8 (FieldBitPosition));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DatumValidBits is the number of valid field bits in the first field datum.
|
|
|
|
*/
|
|
|
|
ObjDesc->CommonField.DatumValidBits = (UINT8) (AccessBitWidth -
|
|
|
|
ObjDesc->CommonField.StartFieldBitOffset);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid bits -- the number of bits that compose a partial datum,
|
|
|
|
* 1) At the end of the field within the region (arbitrary starting bit offset)
|
|
|
|
* 2) At the end of a buffer used to contain the field (starting offset always zero)
|
|
|
|
*/
|
|
|
|
ObjDesc->CommonField.EndFieldValidBits = (UINT8) ((ObjDesc->CommonField.StartFieldBitOffset +
|
|
|
|
FieldBitLength) % AccessBitWidth);
|
|
|
|
ObjDesc->CommonField.EndBufferValidBits = (UINT8) (FieldBitLength % AccessBitWidth); /* StartBufferBitOffset always = 0 */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Does the entire field fit within a single field access element
|
|
|
|
* (datum)? (without crossing a datum boundary)
|
|
|
|
*/
|
|
|
|
if ((ObjDesc->CommonField.StartFieldBitOffset + ObjDesc->CommonField.BitLength) <=
|
|
|
|
(UINT16) ObjDesc->CommonField.AccessBitWidth)
|
|
|
|
{
|
|
|
|
ObjDesc->CommonField.AccessFlags |= AFIELD_SINGLE_DATUM;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiExPrepRegionFieldValue
|
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
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
|
|
|
|
* connect it to the parent Node.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiExPrepRegionFieldValue (
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_NAMESPACE_NODE *Node,
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_HANDLE RegionNode,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT8 FieldFlags,
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 FieldBitPosition,
|
|
|
|
UINT32 FieldBitLength)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
|
|
|
UINT32 Type;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
FUNCTION_TRACE ("ExPrepRegionFieldValue");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
if (!RegionNode)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null RegionNode\n"));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
Type = AcpiNsGetType (RegionNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Type != ACPI_TYPE_REGION)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X %s\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
Type, AcpiUtGetTypeName (Type)));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a new object */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REGION_FIELD);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (!ObjDesc)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ObjDesc and Region valid */
|
|
|
|
|
|
|
|
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
|
2001-05-29 19:52:40 +00:00
|
|
|
"ExPrepRegionFieldValue", 1, "case RegionField");
|
|
|
|
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &RegionNode, IMODE_EXECUTE,
|
|
|
|
"ExPrepRegionFieldValue", 1, "case RegionField");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Initialize areas of the object that are common to all fields */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags,
|
|
|
|
FieldBitPosition, FieldBitLength);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize areas of the object that are specific to this field type */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (RegionNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* An additional reference for the container */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->Field.RegionObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Debug info */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Bitoff=%X Off=%X Gran=%X Region %p\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
|
|
|
|
ObjDesc->Field.AccessBitWidth, ObjDesc->Field.RegionObj));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "set NamedObj %p (%4.4s) val = %p\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
Node, &(Node->Name), ObjDesc));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
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-05-29 19:52:40 +00:00
|
|
|
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiExPrepBankFieldValue
|
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
|
|
|
|
* BankRegisterNode - Bank selection register node
|
2000-10-28 05:01:06 +00:00
|
|
|
* BankVal - Value to store in selection register
|
2001-05-29 19:52:40 +00:00
|
|
|
* 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-05-29 19:52:40 +00:00
|
|
|
* DESCRIPTION: Construct an object of type BankField and attach it to the
|
|
|
|
* parent Node.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiExPrepBankFieldValue (
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_NAMESPACE_NODE *Node,
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_NAMESPACE_NODE *RegionNode,
|
|
|
|
ACPI_NAMESPACE_NODE *BankRegisterNode,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT32 BankVal,
|
|
|
|
UINT8 FieldFlags,
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 FieldBitPosition,
|
|
|
|
UINT32 FieldBitLength)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
|
|
|
UINT32 Type;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
FUNCTION_TRACE ("ExPrepBankFieldValue");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
if (!RegionNode)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null RegionNode\n"));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
Type = AcpiNsGetType (RegionNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Type != ACPI_TYPE_REGION)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X %s\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
Type, AcpiUtGetTypeName (Type)));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a new object */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_BANK_FIELD);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (!ObjDesc)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ObjDesc and Region valid */
|
|
|
|
|
|
|
|
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
|
2001-05-29 19:52:40 +00:00
|
|
|
"ExPrepBankFieldValue", 1, "case BankField");
|
|
|
|
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &RegionNode, IMODE_EXECUTE,
|
|
|
|
"ExPrepBankFieldValue", 1, "case BankField");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Initialize areas of the object that are common to all fields */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags,
|
|
|
|
FieldBitPosition, FieldBitLength);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize areas of the object that are specific to this field type */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->BankField.Value = BankVal;
|
|
|
|
ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (RegionNode);
|
|
|
|
ObjDesc->BankField.BankRegisterObj = AcpiNsGetAttachedObject (BankRegisterNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/* An additional reference for the attached objects */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiUtAddReference (ObjDesc->BankField.RegionObj);
|
|
|
|
AcpiUtAddReference (ObjDesc->BankField.BankRegisterObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Debug info */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BitOff=%X Off=%X Gran=%X Region %p BankReg %p\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->BankField.StartFieldBitOffset, ObjDesc->BankField.BaseByteOffset,
|
|
|
|
ObjDesc->Field.AccessBitWidth, ObjDesc->BankField.RegionObj,
|
|
|
|
ObjDesc->BankField.BankRegisterObj));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Set NamedObj %p (%4.4s) val=%p\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
Node, &(Node->Name), ObjDesc));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
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-05-29 19:52:40 +00:00
|
|
|
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiExPrepIndexFieldValue
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* PARAMETERS: Node - Owning Node
|
2000-10-28 05:01:06 +00:00
|
|
|
* IndexReg - Index register
|
|
|
|
* DataReg - Data register
|
2001-05-29 19:52:40 +00:00
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type IndexField and
|
|
|
|
* connect it to the parent Node.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiExPrepIndexFieldValue (
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_NAMESPACE_NODE *Node,
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_NAMESPACE_NODE *IndexReg,
|
|
|
|
ACPI_NAMESPACE_NODE *DataReg,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT8 FieldFlags,
|
2001-05-29 19:52:40 +00:00
|
|
|
UINT32 FieldBitPosition,
|
|
|
|
UINT32 FieldBitLength)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
FUNCTION_TRACE ("ExPrepIndexFieldValue");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!IndexReg || !DataReg)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null handle\n"));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a new object descriptor */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_INDEX_FIELD);
|
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-05-29 19:52:40 +00:00
|
|
|
Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags,
|
|
|
|
FieldBitPosition, FieldBitLength);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize areas of the object that are specific to this field type */
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject (DataReg);
|
|
|
|
ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (IndexReg);
|
|
|
|
ObjDesc->IndexField.Value = (UINT32) (FieldBitPosition /
|
|
|
|
ObjDesc->Field.AccessBitWidth);
|
|
|
|
|
|
|
|
/* An additional reference for the attached objects */
|
|
|
|
|
|
|
|
AcpiUtAddReference (ObjDesc->IndexField.DataObj);
|
|
|
|
AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Debug info */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "bitoff=%X off=%X gran=%X Index %p Data %p\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc->IndexField.StartFieldBitOffset, ObjDesc->IndexField.BaseByteOffset,
|
|
|
|
ObjDesc->Field.AccessBitWidth, ObjDesc->IndexField.IndexObj,
|
|
|
|
ObjDesc->IndexField.DataObj));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "set NamedObj %p (%4.4s) val = %p\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
Node, &(Node->Name), ObjDesc));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
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-05-29 19:52:40 +00:00
|
|
|
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|