diff options
| author | Mike Smith <msmith@FreeBSD.org> | 2001-01-31 09:17:50 +0000 |
|---|---|---|
| committer | Mike Smith <msmith@FreeBSD.org> | 2001-01-31 09:17:50 +0000 |
| commit | 3cb266413f01ccce58cd713a52415dbab44176e0 (patch) | |
| tree | 1ad77674b14ce3ce86e9037887bfde558fe33cc8 /sys/contrib/dev/acpica/Subsystem/Interpreter | |
| parent | ace858085f792f9675fc086e7a87c605696a7154 (diff) | |
| parent | 838fd87dd9b819087519e35200f1a995d83772b0 (diff) | |
Notes
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Interpreter')
21 files changed, 2095 insertions, 1189 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c index 765cb6224046..b69170ec7bac 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 27 $ + * $Revision: 29 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -169,7 +169,8 @@ AcpiAmlExecLoadTable ( for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) { Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, - i, 8, (UINT32 *) ((UINT8 *) &TableHeader + i)); + (ACPI_PHYSICAL_ADDRESS) i, 8, + (UINT32 *) ((UINT8 *) &TableHeader + i)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -195,7 +196,8 @@ AcpiAmlExecLoadTable ( for (i = 0; i < TableHeader.Length; i++) { Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, - i, 8, (UINT32 *) (TableDataPtr + i)); + (ACPI_PHYSICAL_ADDRESS)i, 8, + (UINT32 *) (TableDataPtr + i)); if (ACPI_FAILURE (Status)) { goto Cleanup; diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amconvrt.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconvrt.c new file mode 100644 index 000000000000..9aa444effee5 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconvrt.c @@ -0,0 +1,653 @@ +/****************************************************************************** + * + * Module Name: amconvrt - Object conversion routines + * $Revision: 3 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * All rights reserved. + * + * 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. + * + *****************************************************************************/ + + +#define __AMCONVRT_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amconvrt") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlConvertToTargetType + * + * PARAMETERS: *ObjDesc - Object to be converted. + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlConvertToTargetType ( + OBJECT_TYPE_INTERNAL DestinationType, + ACPI_OPERAND_OBJECT **ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AmlConvertToTargetType"); + + + /* + * If required by the target, + * perform implicit conversion on the source before we store it. + */ + + switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) + { + case ARGI_SIMPLE_TARGET: + case ARGI_FIXED_TARGET: + case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ + + switch (DestinationType) + { + case INTERNAL_TYPE_DEF_FIELD: + /* + * Named field can always handle conversions + */ + break; + + default: + /* No conversion allowed for these types */ + + if (DestinationType != (*ObjDesc)->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlConvertToTargetType: Target does not allow conversion of type %s to %s\n", + AcpiCmGetTypeName ((*ObjDesc)->Common.Type), + AcpiCmGetTypeName (DestinationType))); + Status = AE_TYPE; + } + } + break; + + + case ARGI_TARGETREF: + + switch (DestinationType) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_FIELD_UNIT: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + /* + * These types require an Integer operand. We can convert + * a Buffer or a String to an Integer if necessary. + */ + Status = AcpiAmlConvertToInteger (ObjDesc, WalkState); + break; + + + case ACPI_TYPE_STRING: + + /* + * The operand must be a String. We can convert an + * Integer or Buffer if necessary + */ + Status = AcpiAmlConvertToString (ObjDesc, WalkState); + break; + + + case ACPI_TYPE_BUFFER: + + /* + * The operand must be a String. We can convert an + * Integer or Buffer if necessary + */ + Status = AcpiAmlConvertToBuffer (ObjDesc, WalkState); + break; + } + break; + + + case ARGI_REFERENCE: + /* + * CreateXxxxField cases - we are storing the field object into the name + */ + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlConvertToTargetType: Unknown Target type ID 0x%X Op %s DestType %s\n", + GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), + WalkState->OpInfo->Name, + AcpiCmGetTypeName (DestinationType))); + + Status = AE_AML_INTERNAL; + } + + + /* + * Source-to-Target conversion semantics: + * + * If conversion to the target type cannot be performed, then simply + * overwrite the target with the new object and type. + */ + if (Status == AE_TYPE) + { + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlConvertToInteger + * + * PARAMETERS: *ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to an integer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlConvertToInteger ( + ACPI_OPERAND_OBJECT **ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_OPERAND_OBJECT *RetDesc; + UINT32 Count; + char *Pointer; + ACPI_INTEGER Result; + UINT32 IntegerSize = sizeof (ACPI_INTEGER); + + + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_INTEGER: + return (AE_OK); + + case ACPI_TYPE_STRING: + Pointer = (*ObjDesc)->String.Pointer; + Count = (*ObjDesc)->String.Length; + break; + + case ACPI_TYPE_BUFFER: + Pointer = (char *) (*ObjDesc)->Buffer.Pointer; + Count = (*ObjDesc)->Buffer.Length; + break; + + default: + return (AE_TYPE); + } + + /* + * Create a new integer + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + + /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ + + if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper 32-bit field + */ + IntegerSize = sizeof (UINT32); + } + + + /* + * Convert the buffer/string to an integer. Note that both buffers and + * strings are treated as raw data - we don't convert ascii to hex for + * strings. + * + * There are two terminating conditions for the loop: + * 1) The size of an integer has been reached, or + * 2) The end of the buffer or string has been reached + */ + Result = 0; + + /* Transfer no more than an integer's worth of data */ + + if (Count > IntegerSize) + { + Count = IntegerSize; + } + + /* + * String conversion is different than Buffer conversion + */ + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_STRING: + + /* TBD: Need to use 64-bit STRTOUL */ + + /* + * Convert string to an integer + * String must be hexadecimal as per the ACPI specification + */ + + Result = STRTOUL (Pointer, NULL, 16); + break; + + + case ACPI_TYPE_BUFFER: + + /* + * Buffer conversion - we simply grab enough raw data from the + * buffer to fill an integer + */ + for (i = 0; i < Count; i++) + { + /* + * Get next byte and shift it into the Result. + * Little endian is used, meaning that the first byte of the buffer + * is the LSB of the integer + */ + Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); + } + + break; + } + + /* Save the Result, delete original descriptor, store new descriptor */ + + RetDesc->Integer.Value = Result; + + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiCmRemoveReference (*ObjDesc); + } + + *ObjDesc = RetDesc; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlConvertToBuffer + * + * PARAMETERS: *ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to an Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlConvertToBuffer ( + ACPI_OPERAND_OBJECT **ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *RetDesc; + UINT32 i; + UINT32 IntegerSize = sizeof (ACPI_INTEGER); + UINT8 *NewBuf; + + + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* + * Create a new Buffer + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ + + if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper + * 32-bit field + */ + IntegerSize = sizeof (UINT32); + } + + /* Need enough space for one integers */ + + RetDesc->Buffer.Length = IntegerSize; + NewBuf = AcpiCmCallocate (IntegerSize); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + AcpiCmRemoveReference (RetDesc); + return (AE_NO_MEMORY); + } + + /* Copy the integer to the buffer */ + + for (i = 0; i < IntegerSize; i++) + { + NewBuf[i] = (UINT8) ((*ObjDesc)->Integer.Value >> (i * 8)); + } + RetDesc->Buffer.Pointer = NewBuf; + + /* Return the new buffer descriptor */ + + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiCmRemoveReference (*ObjDesc); + } + *ObjDesc = RetDesc; + break; + + + case ACPI_TYPE_STRING: + break; + + + case ACPI_TYPE_BUFFER: + break; + + + default: + return (AE_TYPE); + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlConvertToString + * + * PARAMETERS: *ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a string + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlConvertToString ( + ACPI_OPERAND_OBJECT **ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *RetDesc; + UINT32 i; + UINT32 Index; + UINT32 IntegerSize = sizeof (ACPI_INTEGER); + UINT8 *NewBuf; + UINT8 *Pointer; + + + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* + * Create a new String + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ + + if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper + * 32-bit field + */ + IntegerSize = sizeof (UINT32); + } + + /* Need enough space for one ASCII integer plus null terminator */ + + RetDesc->String.Length = (IntegerSize * 2) + 1; + NewBuf = AcpiCmCallocate (RetDesc->String.Length); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + AcpiCmRemoveReference (RetDesc); + return (AE_NO_MEMORY); + } + + /* Copy the integer to the buffer */ + + for (i = 0; i < (IntegerSize * 2); i++) + { + NewBuf[i] = AcpiGbl_HexToAscii [((*ObjDesc)->Integer.Value >> (i * 4)) & 0xF]; + } + + /* Null terminate */ + + NewBuf [i] = 0; + RetDesc->Buffer.Pointer = NewBuf; + + /* Return the new buffer descriptor */ + + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiCmRemoveReference (*ObjDesc); + } + *ObjDesc = RetDesc; + + return (AE_OK); + + + case ACPI_TYPE_BUFFER: + + if (((*ObjDesc)->Buffer.Length * 3) > ACPI_MAX_STRING_CONVERSION) + { + return (AE_AML_STRING_LIMIT); + } + + /* + * Create a new String + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + /* Need enough space for one ASCII integer plus null terminator */ + + RetDesc->String.Length = (*ObjDesc)->Buffer.Length * 3; + NewBuf = AcpiCmCallocate (RetDesc->String.Length + 1); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + AcpiCmRemoveReference (RetDesc); + return (AE_NO_MEMORY); + } + + /* + * Convert each byte of the buffer to two ASCII characters plus a space. + */ + Pointer = (*ObjDesc)->Buffer.Pointer; + Index = 0; + for (i = 0; i < (*ObjDesc)->Buffer.Length; i++) + { + NewBuf[Index + 0] = AcpiGbl_HexToAscii [Pointer[i] & 0x0F]; + NewBuf[Index + 1] = AcpiGbl_HexToAscii [(Pointer[i] >> 4) & 0x0F]; + NewBuf[Index + 2] = ' '; + Index += 3; + } + + /* Null terminate */ + + NewBuf [Index] = 0; + RetDesc->Buffer.Pointer = NewBuf; + + /* Return the new buffer descriptor */ + + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiCmRemoveReference (*ObjDesc); + } + *ObjDesc = RetDesc; + break; + + + case ACPI_TYPE_STRING: + break; + + + default: + return (AE_TYPE); + break; + } + + return (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c index 4dbf3d829826..e02df3c1bb00 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amcreate - Named object creation - * $Revision: 52 $ + * $Revision: 53 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -477,7 +477,7 @@ AcpiAmlExecCreateMutex ( goto Cleanup; } - ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value; + ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Integer.Value; /* ObjDesc was on the stack top, and the name is below it */ diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c index c766a0606ab2..37f67f8aff68 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amdump - Interpreter debug output routines - * $Revision: 97 $ + * $Revision: 100 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -130,7 +130,7 @@ * The following routines are used for debug output only */ -#ifdef ACPI_DEBUG +#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) /***************************************************************************** * @@ -334,12 +334,12 @@ AcpiAmlDumpOperand ( DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Arg%d", EntryDesc->Reference.Offset)); - if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + if (ACPI_TYPE_INTEGER == EntryDesc->Common.Type) { /* Value is a Number */ DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", - EntryDesc->Number.Value)); + EntryDesc->Integer.Value)); } DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); @@ -351,13 +351,13 @@ AcpiAmlDumpOperand ( DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Local%d", EntryDesc->Reference.Offset)); - if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + if (ACPI_TYPE_INTEGER == EntryDesc->Common.Type) { /* Value is a Number */ DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", - EntryDesc->Number.Value)); + EntryDesc->Integer.Value)); } DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); @@ -412,24 +412,24 @@ AcpiAmlDumpOperand ( break; - case ACPI_TYPE_NUMBER: + case ACPI_TYPE_INTEGER: DEBUG_PRINT_RAW (ACPI_INFO, ("Number %lX\n", - EntryDesc->Number.Value)); + EntryDesc->Integer.Value)); break; case INTERNAL_TYPE_IF: DEBUG_PRINT_RAW (ACPI_INFO, ("If [Number] %lX\n", - EntryDesc->Number.Value)); + EntryDesc->Integer.Value)); break; case INTERNAL_TYPE_WHILE: DEBUG_PRINT_RAW (ACPI_INFO, ("While [Number] %lX\n", - EntryDesc->Number.Value)); + EntryDesc->Integer.Value)); break; @@ -763,10 +763,10 @@ AcpiAmlDumpObjectDescriptor ( switch (ObjDesc->Common.Type) { - case ACPI_TYPE_NUMBER: + case ACPI_TYPE_INTEGER: AcpiOsPrintf ("%20s : %s\n", "Type", "Number"); - AcpiOsPrintf ("%20s : %X\n", "Value", ObjDesc->Number.Value); + AcpiOsPrintf ("%20s : %X\n", "Value", ObjDesc->Integer.Value); break; @@ -782,7 +782,6 @@ AcpiAmlDumpObjectDescriptor ( AcpiOsPrintf ("%20s : %s\n", "Type", "Buffer"); AcpiOsPrintf ("%20s : %X\n", "Length", ObjDesc->Buffer.Length); - AcpiOsPrintf ("%20s : %X\n", "Sequence", ObjDesc->Buffer.Sequence); AcpiOsPrintf ("%20s : %p\n", "Pointer", ObjDesc->Buffer.Pointer); break; diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c index f0b87ec8e7a3..c80d929955de 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators - * $Revision: 69 $ + * $Revision: 71 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -130,7 +130,183 @@ MODULE_NAME ("amdyadic") -/***************************************************************************** +/******************************************************************************* + * + * FUNCTION: AcpiAmlDoConcatenate + * + * PARAMETERS: *ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlDoConcatenate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualRetDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 i; + ACPI_INTEGER ThisInteger; + ACPI_OPERAND_OBJECT *RetDesc; + NATIVE_CHAR *NewBuf; + UINT32 IntegerSize = sizeof (ACPI_INTEGER); + + + /* + * There are three cases to handle: + * 1) Two Integers concatenated to produce a buffer + * 2) Two Strings concatenated to produce a string + * 3) Two Buffers concatenated to produce a buffer + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ + + if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper + * 32-bit field + */ + IntegerSize = sizeof (UINT32); + } + + /* Result of two integers is a buffer */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + /* Need enough space for two integers */ + + RetDesc->Buffer.Length = IntegerSize * 2; + NewBuf = AcpiCmCallocate (RetDesc->Buffer.Length); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Buffer.Pointer = (UINT8 *) NewBuf; + + /* Convert the first integer */ + + ThisInteger = ObjDesc->Integer.Value; + for (i = 0; i < IntegerSize; i++) + { + NewBuf[i] = (UINT8) ThisInteger; + ThisInteger >>= 8; + } + + /* Convert the second integer */ + + ThisInteger = ObjDesc2->Integer.Value; + for (; i < (IntegerSize * 2); i++) + { + NewBuf[i] = (UINT8) ThisInteger; + ThisInteger >>= 8; + } + + break; + + + case ACPI_TYPE_STRING: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + /* Operand1 is string */ + + NewBuf = AcpiCmAllocate (ObjDesc->String.Length + + ObjDesc2->String.Length + 1); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: String allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + STRCPY (NewBuf, ObjDesc->String.Pointer); + STRCPY (NewBuf + ObjDesc->String.Length, + ObjDesc2->String.Pointer); + + /* Point the return object to the new string */ + + RetDesc->String.Pointer = NewBuf; + RetDesc->String.Length = ObjDesc->String.Length += + ObjDesc2->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + /* Operand1 is a buffer */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + if (!RetDesc) + { + return (AE_NO_MEMORY); + } + + NewBuf = AcpiCmAllocate (ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + MEMCPY (NewBuf, ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer, + ObjDesc2->Buffer.Length); + + /* + * Point the return object to the new buffer + */ + + RetDesc->Buffer.Pointer = (UINT8 *) NewBuf; + RetDesc->Buffer.Length = ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length; + break; + + default: + Status = AE_AML_INTERNAL; + RetDesc = NULL; + } + + + *ActualRetDesc = RetDesc; + return (AE_OK); + + +Cleanup: + + AcpiCmRemoveReference (RetDesc); + return (Status); +} + + +/******************************************************************************* * * FUNCTION: AcpiAmlExecDyadic1 * @@ -143,7 +319,7 @@ * * ALLOCATION: Deletes both operands * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiAmlExecDyadic1 ( @@ -211,7 +387,7 @@ AcpiAmlExecDyadic1 ( /* Dispatch the notify to the appropriate handler */ - AcpiEvNotifyDispatch (Node, (UINT32) ValDesc->Number.Value); + AcpiEvNotifyDispatch (Node, (UINT32) ValDesc->Integer.Value); break; default: @@ -244,7 +420,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiAmlExecDyadic2R * @@ -257,7 +433,7 @@ Cleanup: * * ALLOCATION: Deletes one operand descriptor -- other remains on stack * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiAmlExecDyadic2R ( @@ -273,7 +449,6 @@ AcpiAmlExecDyadic2R ( ACPI_OPERAND_OBJECT *RetDesc2 = NULL; ACPI_STATUS Status = AE_OK; UINT32 NumOperands = 3; - NATIVE_CHAR *NewBuf; FUNCTION_TRACE_U32 ("AmlExecDyadic2R", Opcode); @@ -322,7 +497,7 @@ AcpiAmlExecDyadic2R ( case AML_SHIFT_RIGHT_OP: case AML_SUBTRACT_OP: - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -344,8 +519,8 @@ AcpiAmlExecDyadic2R ( case AML_ADD_OP: - RetDesc->Number.Value = ObjDesc->Number.Value + - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value + + ObjDesc2->Integer.Value; break; @@ -353,8 +528,8 @@ AcpiAmlExecDyadic2R ( case AML_BIT_AND_OP: - RetDesc->Number.Value = ObjDesc->Number.Value & - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value & + ObjDesc2->Integer.Value; break; @@ -362,8 +537,8 @@ AcpiAmlExecDyadic2R ( case AML_BIT_NAND_OP: - RetDesc->Number.Value = ~(ObjDesc->Number.Value & - ObjDesc2->Number.Value); + RetDesc->Integer.Value = ~(ObjDesc->Integer.Value & + ObjDesc2->Integer.Value); break; @@ -371,8 +546,8 @@ AcpiAmlExecDyadic2R ( case AML_BIT_OR_OP: - RetDesc->Number.Value = ObjDesc->Number.Value | - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value | + ObjDesc2->Integer.Value; break; @@ -380,8 +555,8 @@ AcpiAmlExecDyadic2R ( case AML_BIT_NOR_OP: - RetDesc->Number.Value = ~(ObjDesc->Number.Value | - ObjDesc2->Number.Value); + RetDesc->Integer.Value = ~(ObjDesc->Integer.Value | + ObjDesc2->Integer.Value); break; @@ -389,16 +564,16 @@ AcpiAmlExecDyadic2R ( case AML_BIT_XOR_OP: - RetDesc->Number.Value = ObjDesc->Number.Value ^ - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value ^ + ObjDesc2->Integer.Value; break; - /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */ + /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */ case AML_DIVIDE_OP: - if (!ObjDesc2->Number.Value) + if (!ObjDesc2->Integer.Value) { REPORT_ERROR (("AmlExecDyadic2R/DivideOp: Divide by zero\n")); @@ -407,7 +582,7 @@ AcpiAmlExecDyadic2R ( goto Cleanup; } - RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc2) { Status = AE_NO_MEMORY; @@ -416,13 +591,13 @@ AcpiAmlExecDyadic2R ( /* Remainder (modulo) */ - RetDesc->Number.Value = ACPI_MODULO (ObjDesc->Number.Value, - ObjDesc2->Number.Value); + RetDesc->Integer.Value = ACPI_MODULO (ObjDesc->Integer.Value, + ObjDesc2->Integer.Value); /* Result (what we used to call the quotient) */ - RetDesc2->Number.Value = ACPI_DIVIDE (ObjDesc->Number.Value, - ObjDesc2->Number.Value); + RetDesc2->Integer.Value = ACPI_DIVIDE (ObjDesc->Integer.Value, + ObjDesc2->Integer.Value); break; @@ -430,8 +605,8 @@ AcpiAmlExecDyadic2R ( case AML_MULTIPLY_OP: - RetDesc->Number.Value = ObjDesc->Number.Value * - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value * + ObjDesc2->Integer.Value; break; @@ -439,8 +614,8 @@ AcpiAmlExecDyadic2R ( case AML_SHIFT_LEFT_OP: - RetDesc->Number.Value = ObjDesc->Number.Value << - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value << + ObjDesc2->Integer.Value; break; @@ -448,8 +623,8 @@ AcpiAmlExecDyadic2R ( case AML_SHIFT_RIGHT_OP: - RetDesc->Number.Value = ObjDesc->Number.Value >> - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value >> + ObjDesc2->Integer.Value; break; @@ -457,8 +632,8 @@ AcpiAmlExecDyadic2R ( case AML_SUBTRACT_OP: - RetDesc->Number.Value = ObjDesc->Number.Value - - ObjDesc2->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value - + ObjDesc2->Integer.Value; break; @@ -466,89 +641,56 @@ AcpiAmlExecDyadic2R ( case AML_CONCAT_OP: - if (ObjDesc2->Common.Type != ObjDesc->Common.Type) - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecDyadic2R/ConcatOp: operand type mismatch %X != %X\n", - ObjDesc->Common.Type, ObjDesc2->Common.Type)); - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - /* Both operands are now known to be the same */ + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism above. + */ - if (ACPI_TYPE_STRING == ObjDesc->Common.Type) + switch (ObjDesc->Common.Type) { - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Operand1 is string */ - - NewBuf = AcpiCmAllocate (ObjDesc->String.Length + - ObjDesc2->String.Length + 1); - if (!NewBuf) - { - REPORT_ERROR - (("AmlExecDyadic2R/ConcatOp: String allocation failure\n")); - Status = AE_NO_MEMORY; - goto Cleanup; - } + case ACPI_TYPE_INTEGER: + Status = AcpiAmlConvertToInteger (&ObjDesc2, WalkState); + break; - STRCPY (NewBuf, ObjDesc->String.Pointer); - STRCPY (NewBuf + ObjDesc->String.Length, - ObjDesc2->String.Pointer); + case ACPI_TYPE_STRING: + Status = AcpiAmlConvertToString (&ObjDesc2, WalkState); + break; - /* Point the return object to the new string */ + case ACPI_TYPE_BUFFER: + Status = AcpiAmlConvertToBuffer (&ObjDesc2, WalkState); + break; - RetDesc->String.Pointer = NewBuf; - RetDesc->String.Length = ObjDesc->String.Length += - ObjDesc2->String.Length; + default: + Status = AE_AML_INTERNAL; } - else + if (ACPI_FAILURE (Status)) { - /* Operand1 is not a string ==> must be a buffer */ - - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = AcpiCmAllocate (ObjDesc->Buffer.Length + - ObjDesc2->Buffer.Length); - if (!NewBuf) - { - REPORT_ERROR - (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); - Status = AE_NO_MEMORY; - goto Cleanup; - } - - MEMCPY (NewBuf, ObjDesc->Buffer.Pointer, - ObjDesc->Buffer.Length); - MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer, - ObjDesc2->Buffer.Length); + goto Cleanup; + } - /* - * Point the return object to the new buffer - */ - RetDesc->Buffer.Pointer = (UINT8 *) NewBuf; - RetDesc->Buffer.Length = ObjDesc->Buffer.Length + - ObjDesc2->Buffer.Length; + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ + Status = AcpiAmlDoConcatenate (ObjDesc, ObjDesc2, &RetDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; } break; default: - REPORT_ERROR (("AcpiAmlExecDyadic2R: Unknown dyadic opcode %X\n", Opcode)); + REPORT_ERROR (("AcpiAmlExecDyadic2R: Unknown dyadic opcode %X\n", + Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -612,7 +754,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiAmlExecDyadic2S * @@ -624,7 +766,7 @@ Cleanup: * * ALLOCATION: Deletes one operand descriptor -- other remains on stack * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiAmlExecDyadic2S ( @@ -665,7 +807,7 @@ AcpiAmlExecDyadic2S ( /* Create the internal return object */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -674,7 +816,7 @@ AcpiAmlExecDyadic2S ( /* Default return value is FALSE, operation did not time out */ - RetDesc->Number.Value = 0; + RetDesc->Integer.Value = 0; /* Examine the opcode */ @@ -713,7 +855,7 @@ AcpiAmlExecDyadic2S ( if (Status == AE_TIME) { - RetDesc->Number.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */ + RetDesc->Integer.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */ Status = AE_OK; } @@ -742,7 +884,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiAmlExecDyadic2 * @@ -756,7 +898,7 @@ Cleanup: * ALLOCATION: Deletes one operand descriptor -- other remains on stack * containing result value * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiAmlExecDyadic2 ( @@ -798,7 +940,7 @@ AcpiAmlExecDyadic2 ( /* Create the internal return object */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -817,8 +959,8 @@ AcpiAmlExecDyadic2 ( case AML_LAND_OP: - Lboolean = (BOOLEAN) (ObjDesc->Number.Value && - ObjDesc2->Number.Value); + Lboolean = (BOOLEAN) (ObjDesc->Integer.Value && + ObjDesc2->Integer.Value); break; @@ -826,8 +968,8 @@ AcpiAmlExecDyadic2 ( case AML_LEQUAL_OP: - Lboolean = (BOOLEAN) (ObjDesc->Number.Value == - ObjDesc2->Number.Value); + Lboolean = (BOOLEAN) (ObjDesc->Integer.Value == + ObjDesc2->Integer.Value); break; @@ -835,8 +977,8 @@ AcpiAmlExecDyadic2 ( case AML_LGREATER_OP: - Lboolean = (BOOLEAN) (ObjDesc->Number.Value > - ObjDesc2->Number.Value); + Lboolean = (BOOLEAN) (ObjDesc->Integer.Value > + ObjDesc2->Integer.Value); break; @@ -844,8 +986,8 @@ AcpiAmlExecDyadic2 ( case AML_LLESS_OP: - Lboolean = (BOOLEAN) (ObjDesc->Number.Value < - ObjDesc2->Number.Value); + Lboolean = (BOOLEAN) (ObjDesc->Integer.Value < + ObjDesc2->Integer.Value); break; @@ -853,8 +995,8 @@ AcpiAmlExecDyadic2 ( case AML_LOR_OP: - Lboolean = (BOOLEAN) (ObjDesc->Number.Value || - ObjDesc2->Number.Value); + Lboolean = (BOOLEAN) (ObjDesc->Integer.Value || + ObjDesc2->Integer.Value); break; @@ -871,11 +1013,11 @@ AcpiAmlExecDyadic2 ( if (Lboolean) { - RetDesc->Number.Value = ACPI_INTEGER_MAX; + RetDesc->Integer.Value = ACPI_INTEGER_MAX; } else { - RetDesc->Number.Value = 0; + RetDesc->Integer.Value = 0; } diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c index b99df95c2d24..62c77a7e576e 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 75 $ + * $Revision: 77 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -293,7 +293,8 @@ AcpiAmlAccessNamedField ( FUNCTION_TRACE_PTR ("AmlAccessNamedField", NamedField); - /* Basic data checking */ + /* Parameter validation */ + if ((!NamedField) || (ACPI_READ == Mode && !Buffer)) { DEBUG_PRINT (ACPI_ERROR, @@ -375,7 +376,7 @@ AcpiAmlAccessNamedField ( /* TBD: should these round down to a power of 2? */ - if (DIV_8(BitGranularity) > ByteFieldLength) + if (DIV_8 (BitGranularity) > ByteFieldLength) { DEBUG_PRINT (ACPI_INFO, ("AmlAccessNamedField: Bit granularity %X truncated to %X\n", diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c index 66d60434a19b..ad40aec984e4 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amfldio - Aml Field I/O - * $Revision: 33 $ + * $Revision: 37 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -254,7 +254,7 @@ AcpiAmlReadField ( UINT32 ThisFieldByteOffset; UINT32 ThisFieldDatumOffset; UINT32 PreviousRawDatum; - UINT32 ThisRawDatum; + UINT32 ThisRawDatum = 0; UINT32 ValidFieldBits; UINT32 Mask; UINT32 MergedDatum = 0; @@ -331,32 +331,46 @@ AcpiAmlReadField ( while (ThisFieldDatumOffset < DatumLength) { /* - * Get the next raw datum, it contains bits of the current - * field datum + * If the field is aligned on a byte boundary, we don't want + * to perform a final read, since this would potentially read + * past the end of the region. + * + * TBD: [Investigate] It may make more sense to just split the aligned + * and non-aligned cases since the aligned case is so very simple, */ - - Status = AcpiAmlReadFieldData (ObjDesc, - ThisFieldByteOffset + ByteGranularity, - BitGranularity, &ThisRawDatum); - if (ACPI_FAILURE (Status)) + if ((ObjDesc->Field.BitOffset != 0) || + ((ObjDesc->Field.BitOffset == 0) && + (ThisFieldDatumOffset < (DatumLength -1)))) { - goto Cleanup; + /* + * Get the next raw datum, it contains some or all bits + * of the current field datum + */ + + Status = AcpiAmlReadFieldData (ObjDesc, + ThisFieldByteOffset + ByteGranularity, + BitGranularity, &ThisRawDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Before merging the data, make sure the unused bits are clear */ + + switch (ByteGranularity) + { + case 1: + ThisRawDatum &= 0x000000FF; + PreviousRawDatum &= 0x000000FF; + break; + + case 2: + ThisRawDatum &= 0x0000FFFF; + PreviousRawDatum &= 0x0000FFFF; + break; + } } - /* Before merging the data, make sure the unused bits are clear */ - - switch (ByteGranularity) - { - case 1: - ThisRawDatum &= 0x000000FF; - PreviousRawDatum &= 0x000000FF; - break; - - case 2: - ThisRawDatum &= 0x0000FFFF; - PreviousRawDatum &= 0x0000FFFF; - break; - } /* * Put together bits of the two raw data to make a complete @@ -547,7 +561,6 @@ AcpiAmlWriteFieldDataWithUpdateRule ( MergedValue = FieldValue; - /* Check if update rule needs to be applied (not if mask is all ones) */ /* Decode the update rule */ @@ -557,13 +570,18 @@ AcpiAmlWriteFieldDataWithUpdateRule ( case UPDATE_PRESERVE: - /* - * Read the current contents of the byte/word/dword containing - * the field, and merge with the new field value. - */ - Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, - BitGranularity, &CurrentValue); - MergedValue |= (CurrentValue & ~Mask); + /* Check if update rule needs to be applied (not if mask is all ones) */ + + if (((1 << BitGranularity) -1) & ~Mask) + { + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, + BitGranularity, &CurrentValue); + MergedValue |= (CurrentValue & ~Mask); + } break; diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c index 1757bc7b78ac..505d9d4d322f 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 72 $ + * $Revision: 73 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -190,7 +190,7 @@ AcpiAmlExecFatal ( DEBUG_PRINT (ACPI_INFO, ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", - TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value)); + TypeDesc->Integer.Value, CodeDesc->Integer.Value, ArgDesc->Integer.Value)); /* @@ -296,7 +296,7 @@ AcpiAmlExecIndex ( { /* Object to be indexed is a Package */ - if (IdxDesc->Number.Value >= ObjDesc->Package.Count) + if (IdxDesc->Integer.Value >= ObjDesc->Package.Count) { DEBUG_PRINT (ACPI_ERROR, ("AmlExecIndex: Index value out of range\n")); @@ -323,7 +323,7 @@ AcpiAmlExecIndex ( * we are after. */ - TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value]; + TmpDesc = ObjDesc->Package.Elements[IdxDesc->Integer.Value]; RetDesc->Reference.OpCode = AML_INDEX_OP; RetDesc->Reference.TargetType = TmpDesc->Common.Type; RetDesc->Reference.Object = TmpDesc; @@ -338,14 +338,14 @@ AcpiAmlExecIndex ( */ RetDesc->Reference.OpCode = AML_INDEX_OP; RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value]; + RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Integer.Value]; } else { /* Object to be indexed is a Buffer */ - if (IdxDesc->Number.Value >= ObjDesc->Buffer.Length) + if (IdxDesc->Integer.Value >= ObjDesc->Buffer.Length) { DEBUG_PRINT (ACPI_ERROR, ("AmlExecIndex: Index value out of range\n")); @@ -356,7 +356,7 @@ AcpiAmlExecIndex ( RetDesc->Reference.OpCode = AML_INDEX_OP; RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; RetDesc->Reference.Object = ObjDesc; - RetDesc->Reference.Offset = (UINT32) IdxDesc->Number.Value; + RetDesc->Reference.Offset = (UINT32) IdxDesc->Integer.Value; Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); } @@ -460,8 +460,8 @@ AcpiAmlExecMatch ( /* Validate match comparison sub-opcodes */ - if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) || - (Op2Desc->Number.Value > MAX_MATCH_OPERATOR)) + if ((Op1Desc->Integer.Value > MAX_MATCH_OPERATOR) || + (Op2Desc->Integer.Value > MAX_MATCH_OPERATOR)) { DEBUG_PRINT (ACPI_ERROR, ("AmlExecMatch: operation encoding out of range\n")); @@ -469,7 +469,7 @@ AcpiAmlExecMatch ( goto Cleanup; } - Index = (UINT32) StartDesc->Number.Value; + Index = (UINT32) StartDesc->Integer.Value; if (Index >= (UINT32) PkgDesc->Package.Count) { DEBUG_PRINT (ACPI_ERROR, @@ -478,7 +478,7 @@ AcpiAmlExecMatch ( goto Cleanup; } - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -504,7 +504,7 @@ AcpiAmlExecMatch ( * should we examine its value? */ if (!PkgDesc->Package.Elements[Index] || - ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type) + ACPI_TYPE_INTEGER != PkgDesc->Package.Elements[Index]->Common.Type) { continue; } @@ -515,7 +515,7 @@ AcpiAmlExecMatch ( * "continue" (proceed to next iteration of enclosing * "for" loop) signifies a non-match. */ - switch (Op1Desc->Number.Value) + switch (Op1Desc->Integer.Value) { case MATCH_MTR: /* always true */ @@ -525,8 +525,8 @@ AcpiAmlExecMatch ( case MATCH_MEQ: /* true if equal */ - if (PkgDesc->Package.Elements[Index]->Number.Value - != V1Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + != V1Desc->Integer.Value) { continue; } @@ -535,8 +535,8 @@ AcpiAmlExecMatch ( case MATCH_MLE: /* true if less than or equal */ - if (PkgDesc->Package.Elements[Index]->Number.Value - > V1Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + > V1Desc->Integer.Value) { continue; } @@ -545,8 +545,8 @@ AcpiAmlExecMatch ( case MATCH_MLT: /* true if less than */ - if (PkgDesc->Package.Elements[Index]->Number.Value - >= V1Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + >= V1Desc->Integer.Value) { continue; } @@ -555,8 +555,8 @@ AcpiAmlExecMatch ( case MATCH_MGE: /* true if greater than or equal */ - if (PkgDesc->Package.Elements[Index]->Number.Value - < V1Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + < V1Desc->Integer.Value) { continue; } @@ -565,8 +565,8 @@ AcpiAmlExecMatch ( case MATCH_MGT: /* true if greater than */ - if (PkgDesc->Package.Elements[Index]->Number.Value - <= V1Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + <= V1Desc->Integer.Value) { continue; } @@ -579,7 +579,7 @@ AcpiAmlExecMatch ( } - switch(Op2Desc->Number.Value) + switch(Op2Desc->Integer.Value) { case MATCH_MTR: @@ -589,8 +589,8 @@ AcpiAmlExecMatch ( case MATCH_MEQ: - if (PkgDesc->Package.Elements[Index]->Number.Value - != V2Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + != V2Desc->Integer.Value) { continue; } @@ -599,8 +599,8 @@ AcpiAmlExecMatch ( case MATCH_MLE: - if (PkgDesc->Package.Elements[Index]->Number.Value - > V2Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + > V2Desc->Integer.Value) { continue; } @@ -609,8 +609,8 @@ AcpiAmlExecMatch ( case MATCH_MLT: - if (PkgDesc->Package.Elements[Index]->Number.Value - >= V2Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + >= V2Desc->Integer.Value) { continue; } @@ -619,8 +619,8 @@ AcpiAmlExecMatch ( case MATCH_MGE: - if (PkgDesc->Package.Elements[Index]->Number.Value - < V2Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + < V2Desc->Integer.Value) { continue; } @@ -629,8 +629,8 @@ AcpiAmlExecMatch ( case MATCH_MGT: - if (PkgDesc->Package.Elements[Index]->Number.Value - <= V2Desc->Number.Value) + if (PkgDesc->Package.Elements[Index]->Integer.Value + <= V2Desc->Integer.Value) { continue; } @@ -650,7 +650,7 @@ AcpiAmlExecMatch ( /* MatchValue is the return value */ - RetDesc->Number.Value = MatchValue; + RetDesc->Integer.Value = MatchValue; Cleanup: diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c index 4dcf02163bb4..394780f286a1 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators - * $Revision: 88 $ + * $Revision: 89 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -296,7 +296,7 @@ AcpiAmlExecMonadic1 ( case AML_SLEEP_OP: - AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Number.Value); + AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Integer.Value); break; @@ -304,7 +304,7 @@ AcpiAmlExecMonadic1 ( case AML_STALL_OP: - AcpiAmlSystemDoStall ((UINT32) ObjDesc->Number.Value); + AcpiAmlSystemDoStall ((UINT32) ObjDesc->Integer.Value); break; @@ -395,7 +395,7 @@ AcpiAmlExecMonadic2R ( case AML_TO_BCD_OP: case AML_COND_REF_OF_OP: - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -412,7 +412,7 @@ AcpiAmlExecMonadic2R ( case AML_BIT_NOT_OP: - RetDesc->Number.Value = ~ObjDesc->Number.Value; + RetDesc->Integer.Value = ~ObjDesc->Integer.Value; break; @@ -420,18 +420,18 @@ AcpiAmlExecMonadic2R ( case AML_FIND_SET_LEFT_BIT_OP: - RetDesc->Number.Value = ObjDesc->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value; /* * Acpi specification describes Integer type as a little * endian unsigned value, so this boundry condition is valid. */ - for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + for (ResVal = 0; RetDesc->Integer.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) { - RetDesc->Number.Value >>= 1; + RetDesc->Integer.Value >>= 1; } - RetDesc->Number.Value = ResVal; + RetDesc->Integer.Value = ResVal; break; @@ -439,20 +439,20 @@ AcpiAmlExecMonadic2R ( case AML_FIND_SET_RIGHT_BIT_OP: - RetDesc->Number.Value = ObjDesc->Number.Value; + RetDesc->Integer.Value = ObjDesc->Integer.Value; /* * Acpi specification describes Integer type as a little * endian unsigned value, so this boundry condition is valid. */ - for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + for (ResVal = 0; RetDesc->Integer.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) { - RetDesc->Number.Value <<= 1; + RetDesc->Integer.Value <<= 1; } /* Since returns must be 1-based, subtract from 33 (65) */ - RetDesc->Number.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal; + RetDesc->Integer.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal; break; @@ -463,12 +463,12 @@ AcpiAmlExecMonadic2R ( /* * The 64-bit ACPI integer can hold 16 4-bit BCD integers */ - RetDesc->Number.Value = 0; + RetDesc->Integer.Value = 0; for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { /* Get one BCD digit */ - Digit = (ACPI_INTEGER) ((ObjDesc->Number.Value >> (i * 4)) & 0xF); + Digit = (ACPI_INTEGER) ((ObjDesc->Integer.Value >> (i * 4)) & 0xF); /* Check the range of the digit */ @@ -490,7 +490,7 @@ AcpiAmlExecMonadic2R ( Digit *= 10; } - RetDesc->Number.Value += Digit; + RetDesc->Integer.Value += Digit; } } break; @@ -501,20 +501,20 @@ AcpiAmlExecMonadic2R ( case AML_TO_BCD_OP: - if (ObjDesc->Number.Value > ACPI_MAX_BCD_VALUE) + if (ObjDesc->Integer.Value > ACPI_MAX_BCD_VALUE) { DEBUG_PRINT (ACPI_ERROR, ("Monadic2R/ToBCDOp: BCD overflow: %d\n", - ObjDesc->Number.Value)); + ObjDesc->Integer.Value)); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; } - RetDesc->Number.Value = 0; + RetDesc->Integer.Value = 0; for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { /* Divide by nth factor of 10 */ - Digit = ObjDesc->Number.Value; + Digit = ObjDesc->Integer.Value; for (j = 0; j < i; j++) { Digit /= 10; @@ -524,7 +524,7 @@ AcpiAmlExecMonadic2R ( if (Digit > 0) { - RetDesc->Number.Value += (ACPI_MODULO (Digit, 10) << (i * 4)); + RetDesc->Integer.Value += (ACPI_MODULO (Digit, 10) << (i * 4)); } } break; @@ -547,7 +547,7 @@ AcpiAmlExecMonadic2R ( * return FALSE */ - RetDesc->Number.Value = 0; + RetDesc->Integer.Value = 0; /* * Must delete the result descriptor since there is no reference @@ -570,7 +570,7 @@ AcpiAmlExecMonadic2R ( /* The object exists in the namespace, return TRUE */ - RetDesc->Number.Value = ACPI_INTEGER_MAX; + RetDesc->Integer.Value = ACPI_INTEGER_MAX; goto Cleanup; break; @@ -750,14 +750,14 @@ AcpiAmlExecMonadic2 ( case AML_LNOT_OP: - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = !ObjDesc->Number.Value; + RetDesc->Integer.Value = !ObjDesc->Integer.Value; break; @@ -819,11 +819,11 @@ AcpiAmlExecMonadic2 ( if (AML_INCREMENT_OP == Opcode) { - RetDesc->Number.Value++; + RetDesc->Integer.Value++; } else { - RetDesc->Number.Value--; + RetDesc->Integer.Value--; } /* Store the result back in the original descriptor */ @@ -855,7 +855,7 @@ AcpiAmlExecMonadic2 ( /* Constants are of type Number */ - Type = ACPI_TYPE_NUMBER; + Type = ACPI_TYPE_INTEGER; break; @@ -918,14 +918,14 @@ AcpiAmlExecMonadic2 ( /* Allocate a descriptor to hold the type. */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = Type; + RetDesc->Integer.Value = Type; break; @@ -985,14 +985,14 @@ AcpiAmlExecMonadic2 ( * object to hold the value */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = Value; + RetDesc->Integer.Value = Value; break; @@ -1112,7 +1112,7 @@ AcpiAmlExecMonadic2 ( * sub-buffer of the main buffer, it is only a pointer to a * single element (byte) of the buffer! */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { Status = AE_NO_MEMORY; @@ -1120,7 +1120,7 @@ AcpiAmlExecMonadic2 ( } TmpDesc = ObjDesc->Reference.Object; - RetDesc->Number.Value = + RetDesc->Integer.Value = TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset]; /* TBD: [Investigate] (see below) Don't add an additional diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c index 60ea50d3905a..9054e2e39bc4 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amnames - interpreter/scanner name load/execute - * $Revision: 72 $ + * $Revision: 73 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c index b0aa97934db0..13c7d0415118 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities - * $Revision: 72 $ + * $Revision: 73 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c index d85b8e4da769..ca019744f26f 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amregion - ACPI default OpRegion (address space) handlers - * $Revision: 42 $ + * $Revision: 44 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -198,8 +198,8 @@ AcpiAmlSystemMemorySpaceHandler ( */ if ((Address < MemInfo->MappedPhysicalAddress) || - ((Address + Length) > - (MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + (((ACPI_INTEGER) Address + Length) > + ((ACPI_INTEGER) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) { /* * The request cannot be resolved by the current memory mapping; @@ -240,7 +240,7 @@ AcpiAmlSystemMemorySpaceHandler ( /* TBD: should these pointers go to 64-bit in all cases ? */ LogicalAddrPtr = MemInfo->MappedLogicalAddress + - (Address - MemInfo->MappedPhysicalAddress); + ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); /* Perform the memory read or write */ diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c index 3ed35cb6a511..659d6f6ba944 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amresnte - AML Interpreter object resolution - * $Revision: 26 $ + * $Revision: 27 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -147,7 +147,7 @@ * can be either a pointer to an actual internal object or a pointer into the * AML stream itself. These types are currently: * - * ACPI_TYPE_NUMBER + * ACPI_TYPE_INTEGER * ACPI_TYPE_STRING * ACPI_TYPE_BUFFER * ACPI_TYPE_MUTEX @@ -335,7 +335,7 @@ AcpiAmlResolveNodeToValue ( break; - case ACPI_TYPE_NUMBER: + case ACPI_TYPE_INTEGER: DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n")); @@ -344,7 +344,7 @@ AcpiAmlResolveNodeToValue ( * number */ - if (ACPI_TYPE_NUMBER != ValDesc->Common.Type) + if (ACPI_TYPE_INTEGER != ValDesc->Common.Type) { DEBUG_PRINT (ACPI_ERROR, ("AmlResolveToValue: Object not a Number, type %X\n", @@ -379,7 +379,7 @@ AcpiAmlResolveNodeToValue ( } else { - ObjectType = ACPI_TYPE_NUMBER; + ObjectType = ACPI_TYPE_INTEGER; } /* @@ -423,7 +423,7 @@ AcpiAmlResolveNodeToValue ( return_ACPI_STATUS (Status); } - ObjDesc->Number.Value = TempVal; + ObjDesc->Integer.Value = TempVal; } @@ -484,13 +484,13 @@ AcpiAmlResolveNodeToValue ( /* Create an object for the result */ - ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - ObjDesc->Number.Value = TempVal; + ObjDesc->Integer.Value = TempVal; break; @@ -542,13 +542,13 @@ AcpiAmlResolveNodeToValue ( /* Create an object for the result */ - ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - ObjDesc->Number.Value = TempVal; + ObjDesc->Integer.Value = TempVal; break; @@ -660,13 +660,13 @@ AcpiAmlResolveNodeToValue ( /* Create object for result */ - ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - ObjDesc->Number.Value = TempVal; + ObjDesc->Integer.Value = TempVal; /* Truncate value if we are executing from a 32-bit ACPI table */ diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c index f43b15f81f6d..26ecd3185f53 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amresolv - AML Interpreter object resolution - * $Revision: 79 $ + * $Revision: 81 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -230,19 +230,19 @@ AcpiAmlGetFieldUnitValue ( Mask = ACPI_UINT32_MAX; } - ResultDesc->Number.Type = (UINT8) ACPI_TYPE_NUMBER; + ResultDesc->Integer.Type = (UINT8) ACPI_TYPE_INTEGER; /* Get the 32 bit value at the location */ - MOVE_UNALIGNED32_TO_32 (&ResultDesc->Number.Value, Location); + MOVE_UNALIGNED32_TO_32 (&ResultDesc->Integer.Value, Location); /* * Shift the 32-bit word containing the field, and mask off the * resulting value */ - ResultDesc->Number.Value = - (ResultDesc->Number.Value >> FieldDesc->FieldUnit.BitOffset) & Mask; + ResultDesc->Integer.Value = + (ResultDesc->Integer.Value >> FieldDesc->FieldUnit.BitOffset) & Mask; DEBUG_PRINT (ACPI_INFO, ("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n", @@ -250,7 +250,7 @@ AcpiAmlGetFieldUnitValue ( FieldDesc->FieldUnit.Offset, FieldDesc->FieldUnit.BitOffset, FieldDesc->FieldUnit.Length, - Location, Mask, ResultDesc->Number.Value)); + Location, Mask, ResultDesc->Integer.Value)); /* Release global lock if we acquired it earlier */ @@ -270,7 +270,7 @@ AcpiAmlGetFieldUnitValue ( * * RETURN: Status * - * DESCRIPTION: Convert Reference entries on ObjStack to Rvalues + * DESCRIPTION: Convert Reference objects to values * ******************************************************************************/ @@ -419,13 +419,13 @@ AcpiAmlResolveObjectToValue ( ("AmlResolveObjectToValue: [Local%d] ValueObj is %p\n", Index, ObjDesc)); - if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + if (ACPI_TYPE_INTEGER == ObjDesc->Common.Type) { /* Value is a Number */ DEBUG_PRINT (ACPI_INFO, ("AmlResolveObjectToValue: [Local%d] value=%X \n", - Index, ObjDesc->Number.Value)); + Index, ObjDesc->Integer.Value)); } break; @@ -460,13 +460,13 @@ AcpiAmlResolveObjectToValue ( ("AmlResolveObjectToValue: [Arg%d] ValueObj is %p\n", Index, ObjDesc)); - if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + if (ACPI_TYPE_INTEGER == ObjDesc->Common.Type) { /* Value is a Number */ DEBUG_PRINT (ACPI_INFO, ("AmlResolveObjectToValue: [Arg%d] value=%X\n", - Index, ObjDesc->Number.Value)); + Index, ObjDesc->Integer.Value)); } break; @@ -479,22 +479,22 @@ AcpiAmlResolveObjectToValue ( case AML_ZERO_OP: - StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; - StackDesc->Number.Value = 0; + StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER; + StackDesc->Integer.Value = 0; break; case AML_ONE_OP: - StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; - StackDesc->Number.Value = 1; + StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER; + StackDesc->Integer.Value = 1; break; case AML_ONES_OP: - StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; - StackDesc->Number.Value = ACPI_INTEGER_MAX; + StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER; + StackDesc->Integer.Value = ACPI_INTEGER_MAX; /* Truncate value if we are executing from a 32-bit ACPI table */ diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c index 9c524349b16f..d57d2fb785b8 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amresop - AML Interpreter operand/object resolution - * $Revision: 19 $ + * $Revision: 22 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -350,8 +350,13 @@ AcpiAmlResolveOperands ( switch (ThisArgType) { - case ARGI_REFERENCE: /* Reference */ - case ARGI_TARGETREF: + case ARGI_REFERENCE: /* References */ + case ARGI_INTEGER_REF: + case ARGI_OBJECT_REF: + case ARGI_DEVICE_REF: + case ARGI_TARGETREF: /* TBD: must implement implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ /* Need an operand of type INTERNAL_TYPE_REFERENCE */ @@ -423,20 +428,6 @@ AcpiAmlResolveOperands ( * For the simple cases, only one type of resolved object * is allowed */ - case ARGI_NUMBER: /* Number */ - - /* Need an operand of type ACPI_TYPE_NUMBER */ - - TypeNeeded = ACPI_TYPE_NUMBER; - break; - - case ARGI_BUFFER: - - /* Need an operand of type ACPI_TYPE_BUFFER */ - - TypeNeeded = ACPI_TYPE_BUFFER; - break; - case ARGI_MUTEX: /* Need an operand of type ACPI_TYPE_MUTEX */ @@ -484,15 +475,91 @@ AcpiAmlResolveOperands ( * The more complex cases allow multiple resolved object types */ + case ARGI_INTEGER: /* Number */ + + /* + * Need an operand of type ACPI_TYPE_INTEGER, + * But we can implicitly convert from a STRING or BUFFER + */ + Status = AcpiAmlConvertToInteger (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n", + AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + goto NextOperand; + break; + + + case ARGI_BUFFER: + + /* + * Need an operand of type ACPI_TYPE_BUFFER, + * But we can implicitly convert from a STRING or INTEGER + */ + Status = AcpiAmlConvertToBuffer (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n", + AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + goto NextOperand; + break; + + case ARGI_STRING: - /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */ + /* + * Need an operand of type ACPI_TYPE_STRING, + * But we can implicitly convert from a BUFFER or INTEGER + */ + Status = AcpiAmlConvertToString (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n", + AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + goto NextOperand; + break; + + + case ARGI_COMPUTEDATA: + + /* Need an operand of type INTEGER, STRING or BUFFER */ - if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) && + if ((ACPI_TYPE_INTEGER != (*StackPtr)->Common.Type) && + (ACPI_TYPE_STRING != (*StackPtr)->Common.Type) && (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)) { DEBUG_PRINT (ACPI_INFO, - ("AmlResolveOperands: Needed [String or Buffer], found [%s] %p\n", + ("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n", AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c index 51f1bb65e988..71d1dfb82aa5 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstore - AML Interpreter object store support - * $Revision: 118 $ + * $Revision: 121 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -130,6 +130,10 @@ MODULE_NAME ("amstore") + + + + /******************************************************************************* * * FUNCTION: AcpiAmlExecStore @@ -156,18 +160,10 @@ AcpiAmlExecStore ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *DeleteDestDesc = NULL; - ACPI_OPERAND_OBJECT *TmpDesc; - ACPI_NAMESPACE_NODE *Node = NULL; - UINT8 Value = 0; - UINT32 Length; - UINT32 i; - + ACPI_OPERAND_OBJECT *RefDesc = DestDesc; - FUNCTION_TRACE ("AmlExecStore"); - DEBUG_PRINT (ACPI_INFO, ("entered AcpiAmlExecStore: Val=%p, Dest=%p\n", - ValDesc, DestDesc)); + FUNCTION_TRACE_PTR ("AmlExecStore", DestDesc); /* Validate parameters */ @@ -179,80 +175,185 @@ AcpiAmlExecStore ( return_ACPI_STATUS (AE_AML_NO_OPERAND); } - /* Examine the datatype of the DestDesc */ + /* DestDesc can be either a namespace node or an ACPI object */ if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED)) { - /* Dest is an ACPI_HANDLE, create a new object */ - - Node = (ACPI_NAMESPACE_NODE *) DestDesc; - DestDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!DestDesc) - { - /* Allocation failure */ - - return_ACPI_STATUS (AE_NO_MEMORY); - } + /* + * Dest is a namespace node, + * Storing an object into a Name "container" + */ + Status = AcpiAmlStoreObjectToNode (ValDesc, + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); - /* Build a new Reference wrapper around the handle */ + /* All done, that's it */ - DestDesc->Reference.OpCode = AML_NAME_OP; - DestDesc->Reference.Object = Node; + return_ACPI_STATUS (Status); } - else - { - DEBUG_PRINT (ACPI_INFO, - ("AmlExecStore: Dest is object (not handle) - may be deleted!\n")); - } - /* Destination object must be of type Reference */ + /* Destination object must be an object of type Reference */ if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE) { /* Destination is not an Reference */ DEBUG_PRINT (ACPI_ERROR, - ("AmlExecStore: Destination is not an Reference [%p]\n", DestDesc)); + ("AmlExecStore: Destination is not a ReferenceObj [%p]\n", DestDesc)); DUMP_STACK_ENTRY (ValDesc); DUMP_STACK_ENTRY (DestDesc); DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore", - 2, "target not Reference"); + 2, "Target is not a ReferenceObj"); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* Examine the Reference opcode */ - switch (DestDesc->Reference.OpCode) + /* + * Examine the Reference opcode. These cases are handled: + * + * 1) Store to Name (Change the object associated with a name) + * 2) Store to an indexed area of a Buffer or Package + * 3) Store to a Method Local or Arg + * 4) Store to the debug object + * 5) Store to a constant -- a noop + */ + + switch (RefDesc->Reference.OpCode) { case AML_NAME_OP: - /* - * Storing into a Name - */ - DeleteDestDesc = DestDesc; - Status = AcpiAmlStoreObjectToNode (ValDesc, DestDesc->Reference.Object, - WalkState); + /* Storing an object into a Name "container" */ - break; /* Case NameOp */ + Status = AcpiAmlStoreObjectToNode (ValDesc, RefDesc->Reference.Object, + WalkState); + break; case AML_INDEX_OP: - DeleteDestDesc = DestDesc; + /* Storing to an Index (pointer into a packager or buffer) */ + + Status = AcpiAmlStoreObjectToIndex (ValDesc, RefDesc, WalkState); + break; + + + case AML_LOCAL_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, + (RefDesc->Reference.Offset), ValDesc, WalkState); + break; + + + case AML_ARG_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, + (RefDesc->Reference.Offset), ValDesc, WalkState); + break; + + + case AML_DEBUG_OP: /* - * Valid source value and destination reference pointer. + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification * - * ACPI Specification 1.0B section 15.2.3.4.2.13: - * Destination should point to either a buffer or a package + * TBD: print known object types "prettier". */ + DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n")); + + if (ValDesc->Common.Type == ACPI_TYPE_STRING) + { + DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer)); + } + else + { + DUMP_STACK_ENTRY (ValDesc); + } + + break; + + + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: /* - * Actually, storing to a package is not so simple. The source must be + * Storing to a constant is a no-op -- see ACPI Specification + * Delete the reference descriptor, however + */ + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Internal error - Unknown Reference subtype %02x\n", + RefDesc->Reference.OpCode)); + + /* TBD: [Restructure] use object dump routine !! */ + + DUMP_BUFFER (RefDesc, sizeof (ACPI_OPERAND_OBJECT)); + + Status = AE_AML_INTERNAL; + break; + + } /* switch (RefDesc->Reference.OpCode) */ + + + + /* Always delete the reference descriptor object */ + + if (RefDesc) + { + AcpiCmRemoveReference (RefDesc); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToIndex + * + * PARAMETERS: *ValDesc - Value to be stored + * *Node - Named object to recieve the value + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Length; + UINT32 i; + UINT8 Value = 0; + + + FUNCTION_TRACE ("AcpiAmlStoreObjectToIndex"); + + + /* + * Destination must be a reference pointer, and + * must point to either a buffer or a package + */ + + switch (DestDesc->Reference.TargetType) + { + case ACPI_TYPE_PACKAGE: + /* + * Storing to a package element is not simple. The source must be * evaluated and converted to the type of the destination and then the * source is copied into the destination - we can't just point to the * source object. @@ -263,8 +364,8 @@ AcpiAmlExecStore ( * The object at *(DestDesc->Reference.Where) is the * element within the package that is to be modified. */ - TmpDesc = *(DestDesc->Reference.Where); - if (TmpDesc) + ObjDesc = *(DestDesc->Reference.Where); + if (ObjDesc) { /* * If the Destination element is a package, we will delete @@ -274,46 +375,44 @@ AcpiAmlExecStore ( * to be packages? * && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE) */ - if (TmpDesc->Common.Type == ACPI_TYPE_PACKAGE) + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) { /* * Take away the reference for being part of a package and * delete */ - AcpiCmRemoveReference (TmpDesc); - AcpiCmRemoveReference (TmpDesc); + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (ObjDesc); - TmpDesc = NULL; + ObjDesc = NULL; } } - if (!TmpDesc) + if (!ObjDesc) { /* - * If the TmpDesc is NULL, that means an uninitialized package - * has been used as a destination, therefore, we must create - * the destination element to match the type of the source - * element NOTE: ValDesc can be of any type. + * If the ObjDesc is NULL, it means that an uninitialized package + * element has been used as a destination (this is OK), therefore, + * we must create the destination element to match the type of the + * source element NOTE: ValDesc can be of any type. */ - TmpDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type); - if (!TmpDesc) + ObjDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type); + if (!ObjDesc) { - Status = AE_NO_MEMORY; - goto Cleanup; + return_ACPI_STATUS (AE_NO_MEMORY); } /* * If the source is a package, copy the source to the new dest */ - if (ACPI_TYPE_PACKAGE == TmpDesc->Common.Type) + if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type) { Status = AcpiAmlBuildCopyInternalPackageObject ( - ValDesc, TmpDesc, WalkState); + ValDesc, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { - AcpiCmRemoveReference (TmpDesc); - TmpDesc = NULL; - goto Cleanup; + AcpiCmRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); } } @@ -323,18 +422,18 @@ AcpiAmlExecStore ( * part of the parent package */ - *(DestDesc->Reference.Where) = TmpDesc; - AcpiCmAddReference (TmpDesc); + *(DestDesc->Reference.Where) = ObjDesc; + AcpiCmAddReference (ObjDesc); } - if (ACPI_TYPE_PACKAGE != TmpDesc->Common.Type) + if (ACPI_TYPE_PACKAGE != ObjDesc->Common.Type) { /* * The destination element is not a package, so we need to * convert the contents of the source (ValDesc) and copy into - * the destination (TmpDesc) + * the destination (ObjDesc) */ - Status = AcpiAmlStoreObjectToObject (ValDesc, TmpDesc, + Status = AcpiAmlStoreObjectToObject (ValDesc, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { @@ -344,22 +443,14 @@ AcpiAmlExecStore ( */ DEBUG_PRINT (ACPI_ERROR, ("AmlExecStore/Index: Unable to copy the internal object\n")); - Status = AE_AML_OPERAND_TYPE; + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } } - - break; } + break; - /* - * Check that the destination is a Buffer Field type - */ - if (DestDesc->Reference.TargetType != ACPI_TYPE_BUFFER_FIELD) - { - Status = AE_AML_OPERAND_TYPE; - break; - } + case ACPI_TYPE_BUFFER_FIELD: /* * Storing into a buffer at a location defined by an Index. * @@ -368,14 +459,12 @@ AcpiAmlExecStore ( */ /* - * Set the TmpDesc to the destination object and type check. + * Set the ObjDesc to the destination object and type check. */ - TmpDesc = DestDesc->Reference.Object; - - if (TmpDesc->Common.Type != ACPI_TYPE_BUFFER) + ObjDesc = DestDesc->Reference.Object; + if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER) { - Status = AE_AML_OPERAND_TYPE; - break; + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* @@ -386,16 +475,16 @@ AcpiAmlExecStore ( switch (ValDesc->Common.Type) { /* - * If the type is Integer, the Length is 4. + * If the type is Integer, assign bytewise * This loop to assign each of the elements is somewhat - * backward because of the Big Endian-ness of IA-64 + * backward because of the Big Endian-ness of IA-64 */ - case ACPI_TYPE_NUMBER: - Length = 4; + case ACPI_TYPE_INTEGER: + Length = sizeof (ACPI_INTEGER); for (i = Length; i != 0; i--) { - Value = (UINT8)(ValDesc->Number.Value >> (MUL_8 (i - 1))); - TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + Value = (UINT8)(ValDesc->Integer.Value >> (MUL_8 (i - 1))); + ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; } break; @@ -408,7 +497,7 @@ AcpiAmlExecStore ( for (i = 0; i < Length; i++) { Value = *(ValDesc->Buffer.Pointer + i); - TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; } break; @@ -421,7 +510,7 @@ AcpiAmlExecStore ( for (i = 0; i < Length; i++) { Value = *(ValDesc->String.Pointer + i); - TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; } break; @@ -435,97 +524,242 @@ AcpiAmlExecStore ( Status = AE_AML_OPERAND_TYPE; break; } + break; - /* - * If we had an error, break out of this case statement. - */ - if (ACPI_FAILURE (Status)) - { - break; - } - - /* - * Set the return pointer - */ - DestDesc = TmpDesc; + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStoreIndex: Target is not a Package or BufferField\n")); + Status = AE_AML_OPERAND_TYPE; break; + } - case AML_ZERO_OP: - case AML_ONE_OP: - case AML_ONES_OP: - /* - * Storing to a constant is a no-op -- see ACPI Specification - * Delete the result descriptor. - */ + return_ACPI_STATUS (Status); +} - DeleteDestDesc = DestDesc; - break; - case AML_LOCAL_OP: - Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, - (DestDesc->Reference.Offset), ValDesc, WalkState); - DeleteDestDesc = DestDesc; - break; +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToNode + * + * PARAMETERS: *SourceDesc - Value to be stored + * *Node - Named object to recieve the value + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The val passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * NOTE: the global lock is acquired early. This will result + * in the global lock being held a bit longer. Also, if the + * function fails during set up we may get the lock when we + * don't really need it. I don't think we care. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TargetDesc; + OBJECT_TYPE_INTERNAL TargetType = ACPI_TYPE_ANY; - case AML_ARG_OP: - Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, - (DestDesc->Reference.Offset), ValDesc, WalkState); - DeleteDestDesc = DestDesc; + FUNCTION_TRACE ("AmlStoreObjectToNode"); + + /* + * Assuming the parameters were already validated + */ + ACPI_ASSERT((Node) && (SourceDesc)); + + + /* + * Get current type of the node, and object attached to Node + */ + TargetType = AcpiNsGetType (Node); + TargetDesc = AcpiNsGetAttachedObject (Node); + + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNode: Storing %p(%s) into node %p(%s)\n", + Node, AcpiCmGetTypeName (SourceDesc->Common.Type), + SourceDesc, AcpiCmGetTypeName (TargetType))); + + + /* + * Resolve the source object to an actual value + * (If it is a reference object) + */ + Status = AcpiAmlResolveObject (&SourceDesc, TargetType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* + * Do the actual store operation + */ + switch (TargetType) + { + case INTERNAL_TYPE_DEF_FIELD: + + /* Raw data copy for target types Integer/String/Buffer */ + + Status = AcpiAmlCopyDataToNamedField (SourceDesc, Node); break; - case AML_DEBUG_OP: + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_FIELD_UNIT: - /* - * Storing to the Debug object causes the value stored to be - * displayed and otherwise has no effect -- see ACPI Specification + /* + * These target types are all of type Integer/String/Buffer, and + * therefore support implicit conversion before the store. + * + * Copy and/or convert the source object to a new target object */ - DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n")); - if (ValDesc->Common.Type == ACPI_TYPE_STRING) - { - DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer)); - } - else + Status = AcpiAmlStoreObject (SourceDesc, TargetType, &TargetDesc, WalkState); + if (ACPI_FAILURE (Status)) { - DUMP_STACK_ENTRY (ValDesc); + return_ACPI_STATUS (Status); } - DeleteDestDesc = DestDesc; + /* + * Store the new TargetDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * SourceDesc reference count is incremented by AttachObject. + */ + Status = AcpiNsAttachObject (Node, TargetDesc, TargetType); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: Store %s into %s via Convert/Attach\n", + AcpiCmGetTypeName (TargetDesc->Common.Type), + AcpiCmGetTypeName (TargetType))); break; - + default: - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecStore: Internal error - Unknown Reference subtype %02x\n", - DestDesc->Reference.OpCode)); + /* No conversions for all other types. Just attach the source object */ - /* TBD: [Restructure] use object dump routine !! */ + Status = AcpiNsAttachObject (Node, SourceDesc, SourceDesc->Common.Type); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: Store %s into %s via Attach only\n", + AcpiCmGetTypeName (SourceDesc->Common.Type), + AcpiCmGetTypeName (SourceDesc->Common.Type))); + break; + } - DUMP_BUFFER (DestDesc, sizeof (ACPI_OPERAND_OBJECT)); - DeleteDestDesc = DestDesc; - Status = AE_AML_INTERNAL; + return_ACPI_STATUS (Status); +} - } /* switch(DestDesc->Reference.OpCode) */ -Cleanup: +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToObject + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Object to receive the value + * + * RETURN: Status + * + * DESCRIPTION: Store an object to another object. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The val passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * This module allows destination types of Number, String, + * and Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type; + + + FUNCTION_TRACE ("AmlStoreObjectToObject"); + + + /* + * Assuming the parameters are valid! + */ + ACPI_ASSERT((DestDesc) && (SourceDesc)); - /* Cleanup and exit*/ + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to (%p)%s\n", + SourceDesc, AcpiCmGetTypeName (SourceDesc->Common.Type), + DestDesc, AcpiCmGetTypeName (DestDesc->Common.Type))); - if (DeleteDestDesc) + + /* + * From this interface, we only support Integers/Strings/Buffers + */ + switch (DestinationType) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + break; + + default: + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToObject: Store into %s not implemented\n", + AcpiCmGetTypeName (DestDesc->Common.Type))); + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + + + /* + * Resolve the source object to an actual value + * (If it is a reference object) + */ + Status = AcpiAmlResolveObject (&SourceDesc, DestinationType, WalkState); + if (ACPI_FAILURE (Status)) { - AcpiCmRemoveReference (DeleteDestDesc); + return_ACPI_STATUS (Status); } + + /* + * Copy and/or convert the source object to the destination object + */ + Status = AcpiAmlStoreObject (SourceDesc, DestinationType, &DestDesc, WalkState); + + return_ACPI_STATUS (Status); } - diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c index 57e02ff30df1..b6bd010b62fc 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c @@ -2,8 +2,8 @@ /****************************************************************************** * * Module Name: amstoren - AML Interpreter object store support, - * Store to Node (namespace object) - * $Revision: 25 $ + * Store to Node (namespace object) + * $Revision: 28 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -131,557 +131,226 @@ MODULE_NAME ("amstoren") + + /******************************************************************************* * - * FUNCTION: AcpiAmlStoreObjectToNode + * FUNCTION: AcpiAmlResolveObject * - * PARAMETERS: *ValDesc - Value to be stored - * *Node - Named object to recieve the value - * - * RETURN: Status + * PARAMETERS: SourceDescPtr - Pointer to the source object + * TargetType - Current type of the target + * WalkState - Current walk state * - * DESCRIPTION: Store the object to the named object. + * RETURN: Status, resolved object in SourceDescPtr. * - * The Assignment of an object to a named object is handled here - * The val passed in will replace the current value (if any) - * with the input value. - * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. - * - * NOTE: the global lock is acquired early. This will result - * in the global lock being held a bit longer. Also, if the - * function fails during set up we may get the lock when we - * don't really need it. I don't think we care. + * DESCRIPTION: Resolve an object. If the object is a reference, dereference + * it and return the actual object in the SourceDescPtr. * ******************************************************************************/ ACPI_STATUS -AcpiAmlStoreObjectToNode ( - ACPI_OPERAND_OBJECT *ValDesc, - ACPI_NAMESPACE_NODE *Node, +AcpiAmlResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + OBJECT_TYPE_INTERNAL TargetType, ACPI_WALK_STATE *WalkState) { + ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; ACPI_STATUS Status = AE_OK; - UINT8 *Buffer = NULL; - UINT32 Length = 0; - UINT32 Mask; - UINT32 NewValue; - BOOLEAN Locked = FALSE; - UINT8 *Location=NULL; - ACPI_OPERAND_OBJECT *DestDesc; - OBJECT_TYPE_INTERNAL DestinationType = ACPI_TYPE_ANY; - FUNCTION_TRACE ("AmlStoreObjectToNte"); + FUNCTION_TRACE ("AmlResolveObject"); - DEBUG_PRINT (ACPI_INFO, - ("entered AcpiAmlStoreObjectToNode: NamedObj=%p, Obj=%p\n", - Node, ValDesc)); /* - * Assuming the parameters are valid!!! + * Ensure we have a Source that can be stored in the target */ - ACPI_ASSERT((Node) && (ValDesc)); - - DestinationType = AcpiNsGetType (Node); + switch (TargetType) + { - DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNte: Storing %s into %s\n", - AcpiCmGetTypeName (ValDesc->Common.Type), - AcpiCmGetTypeName (DestinationType))); + /* This case handles the "interchangeable" types Integer, String, and Buffer. */ /* - * First ensure we have a value that can be stored in the target + * These cases all require only Integers or values that + * can be converted to Integers (Strings or Buffers) */ - switch (DestinationType) - { - /* Type of Name's existing value */ - - case INTERNAL_TYPE_ALIAS: - - /* - * Aliases are resolved by AcpiAmlPrepOperands - */ - - DEBUG_PRINT (ACPI_WARN, - ("AmlStoreObjectToNte: Store into Alias - should never happen\n")); - Status = AE_AML_INTERNAL; - break; - - + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_FIELD_UNIT: case INTERNAL_TYPE_BANK_FIELD: case INTERNAL_TYPE_INDEX_FIELD: - case ACPI_TYPE_FIELD_UNIT: - case ACPI_TYPE_NUMBER: - - /* - * These cases all require only number values or values that - * can be converted to numbers. - * - * If value is not a Number, try to resolve it to one. - */ - - if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) - { - /* - * Initially not a number, convert - */ - Status = AcpiAmlResolveToValue (&ValDesc, WalkState); - if (ACPI_SUCCESS (Status) && - (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) - { - /* - * Conversion successful but still not a number - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToNte: Value assigned to %s must be Number, not %s\n", - AcpiCmGetTypeName (DestinationType), - AcpiCmGetTypeName (ValDesc->Common.Type))); - Status = AE_AML_OPERAND_TYPE; - } - } - - break; + /* + * Stores into a Field/Region or into a Buffer/String + * are all essentially the same. + */ case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: case INTERNAL_TYPE_DEF_FIELD: /* - * Storing into a Field in a region or into a buffer or into - * a string all is essentially the same. - * - * If value is not a valid type, try to resolve it to one. + * If SourceDesc is not a valid type, try to resolve it to one. */ - - if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && - (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && - (ValDesc->Common.Type != ACPI_TYPE_STRING)) + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING)) { /* - * Initially not a valid type, convert + * Initially not a valid type, convert */ - Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + Status = AcpiAmlResolveToValue (SourceDescPtr, WalkState); if (ACPI_SUCCESS (Status) && - (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && - (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && - (ValDesc->Common.Type != ACPI_TYPE_STRING)) + (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING)) { /* - * Conversion successful but still not a valid type + * Conversion successful but still not a valid type */ DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToNte: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", - AcpiCmGetTypeName (ValDesc->Common.Type), - AcpiCmGetTypeName (DestinationType))); + ("AmlResolveObject: Cannot assign type %s to %s (must be type Int/Str/Buf)\n", + AcpiCmGetTypeName ((*SourceDescPtr)->Common.Type), + AcpiCmGetTypeName (TargetType))); Status = AE_AML_OPERAND_TYPE; } } break; - case ACPI_TYPE_PACKAGE: + case INTERNAL_TYPE_ALIAS: /* - * TBD: [Unhandled] Not real sure what to do here + * Aliases are resolved by AcpiAmlPrepOperands */ - Status = AE_NOT_IMPLEMENTED; + DEBUG_PRINT (ACPI_WARN, + ("AmlResolveObject: Store into Alias - should never happen\n")); + + Status = AE_AML_INTERNAL; break; + case ACPI_TYPE_PACKAGE: default: /* - * All other types than Alias and the various Fields come here. - * Store ValDesc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * ValDesc reference count is incremented by AttachObject. + * All other types than Alias and the various Fields come here, + * including the untyped case - ACPI_TYPE_ANY. */ + break; + } - Status = AcpiNsAttachObject (Node, ValDesc, ValDesc->Common.Type); + return_ACPI_STATUS (Status); +} - DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNte: Store %s into %s via Attach\n", - AcpiCmGetTypeName (ValDesc->Common.Type), - AcpiCmGetTypeName (DestinationType))); - goto CleanUpAndBailOut; - break; - } - /* Exit now if failure above */ - if (ACPI_FAILURE (Status)) - { - goto CleanUpAndBailOut; - } +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObject + * + * PARAMETERS: SourceDesc - Object to store + * TargetType - Current type of the target + * TargetDescPtr - Pointer to the target + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: "Store" an object to another object. This may include + * converting the source type to the target type (implicit + * conversion), and a copy of the value of the source to + * the target. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + OBJECT_TYPE_INTERNAL TargetType, + ACPI_OPERAND_OBJECT **TargetDescPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *TargetDesc = *TargetDescPtr; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlStoreObject"); - /* - * Get descriptor for object attached to Node - */ - DestDesc = AcpiNsGetAttachedObject (Node); - if (!DestDesc) - { - /* - * There is no existing object attached to this Node - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToNte: Internal error - no destination object for %4.4s type %X\n", - &Node->Name, DestinationType)); - Status = AE_AML_INTERNAL; - goto CleanUpAndBailOut; - } /* - * Make sure the destination Object is the same as the Node + * Perform the "implicit conversion" of the source to the current type + * of the target - As per the ACPI specification. + * + * If no conversion performed, SourceDesc is left alone, otherwise it + * is updated with a new object. */ - if (DestDesc->Common.Type != (UINT8) DestinationType) + Status = AcpiAmlConvertToTargetType (TargetType, &SourceDesc, WalkState); + if (ACPI_FAILURE (Status)) { - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToNte: Internal error - Name %4.4s type %X does not match value-type %X at %p\n", - &Node->Name, AcpiNsGetType (Node), - DestDesc->Common.Type, DestDesc)); - Status = AE_AML_INTERNAL; - goto CleanUpAndBailOut; + return_ACPI_STATUS (Status); } + /* - * AcpiEverything is ready to execute now, We have - * a value we can handle, just perform the update + * We now have two objects of identical types, and we can perform a + * copy of the *value* of the source object. */ - - switch (DestinationType) + switch (TargetType) { - /* Type of Name's existing value */ - - case INTERNAL_TYPE_BANK_FIELD: - - /* - * Get the global lock if needed - */ - Locked = AcpiAmlAcquireGlobalLock (DestDesc->BankField.LockRule); - - /* - * Set Bank value to select proper Bank - * Perform the update (Set Bank Select) + case ACPI_TYPE_ANY: + case INTERNAL_TYPE_DEF_ANY: + + /* + * The target namespace node is uninitialized (has no target object), + * and will take on the type of the source object */ - Status = AcpiAmlAccessNamedField (ACPI_WRITE, - DestDesc->BankField.BankSelect, - &DestDesc->BankField.Value, - sizeof (DestDesc->BankField.Value)); - if (ACPI_SUCCESS (Status)) - { - /* Set bank select successful, set data value */ - - Status = AcpiAmlAccessNamedField (ACPI_WRITE, - DestDesc->BankField.BankSelect, - &ValDesc->BankField.Value, - sizeof (ValDesc->BankField.Value)); - } - + *TargetDescPtr = SourceDesc; break; - case INTERNAL_TYPE_DEF_FIELD: - - /* - * Get the global lock if needed - */ - Locked = AcpiAmlAcquireGlobalLock (ValDesc->Field.LockRule); - - /* - * Perform the update - */ - - switch (ValDesc->Common.Type) - { - case ACPI_TYPE_NUMBER: - Buffer = (UINT8 *) &ValDesc->Number.Value; - Length = sizeof (ValDesc->Number.Value); - break; - - case ACPI_TYPE_BUFFER: - Buffer = (UINT8 *) ValDesc->Buffer.Pointer; - Length = ValDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - Buffer = (UINT8 *) ValDesc->String.Pointer; - Length = ValDesc->String.Length; - break; - } - - Status = AcpiAmlAccessNamedField (ACPI_WRITE, - Node, Buffer, Length); + case ACPI_TYPE_INTEGER: - break; /* Global Lock released below */ + TargetDesc->Integer.Value = SourceDesc->Integer.Value; + /* Truncate value if we are executing from a 32-bit ACPI table */ - case ACPI_TYPE_STRING: - - /* - * Perform the update - */ - - switch (ValDesc->Common.Type) - { - case ACPI_TYPE_NUMBER: - Buffer = (UINT8 *) &ValDesc->Number.Value; - Length = sizeof (ValDesc->Number.Value); - break; - - case ACPI_TYPE_BUFFER: - Buffer = (UINT8 *) ValDesc->Buffer.Pointer; - Length = ValDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - Buffer = (UINT8 *) ValDesc->String.Pointer; - Length = ValDesc->String.Length; - break; - } - - /* - * Setting a string value replaces the old string - */ - - if (Length < DestDesc->String.Length) - { - /* - * Zero fill, not willing to do pointer arithmetic for - * archetecture independance. Just clear the whole thing - */ - MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); - MEMCPY(DestDesc->String.Pointer, Buffer, Length); - } - else - { - /* - * Free the current buffer, then allocate a buffer - * large enough to hold the value - */ - if ( DestDesc->String.Pointer && - !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) - { - /* - * Only free if not a pointer into the DSDT - */ - - AcpiCmFree(DestDesc->String.Pointer); - } + AcpiAmlTruncateFor32bitTable (TargetDesc, WalkState); + break; - DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); - DestDesc->String.Length = Length; - if (!DestDesc->String.Pointer) - { - Status = AE_NO_MEMORY; - goto CleanUpAndBailOut; - } + case ACPI_TYPE_FIELD_UNIT: - MEMCPY(DestDesc->String.Pointer, Buffer, Length); - } + Status = AcpiAmlCopyIntegerToFieldUnit (SourceDesc, TargetDesc); break; - case ACPI_TYPE_BUFFER: - - /* - * Perform the update to the buffer - */ - - switch (ValDesc->Common.Type) - { - case ACPI_TYPE_NUMBER: - Buffer = (UINT8 *) &ValDesc->Number.Value; - Length = sizeof (ValDesc->Number.Value); - break; - - case ACPI_TYPE_BUFFER: - Buffer = (UINT8 *) ValDesc->Buffer.Pointer; - Length = ValDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - Buffer = (UINT8 *) ValDesc->String.Pointer; - Length = ValDesc->String.Length; - break; - } + case INTERNAL_TYPE_BANK_FIELD: - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ - if (Length <= DestDesc->Buffer.Length) - { - /* - * Zero fill first, not willing to do pointer arithmetic for - * archetecture independence. Just clear the whole thing - */ - MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); - MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); - } - else - { - /* - * truncate, copy only what will fit - */ - MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); - DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNte: Truncating src buffer from %X to %X\n", - Length, DestDesc->Buffer.Length)); - } + Status = AcpiAmlCopyIntegerToBankField (SourceDesc, TargetDesc); break; case INTERNAL_TYPE_INDEX_FIELD: - /* - * Get the global lock if needed - */ - Locked = AcpiAmlAcquireGlobalLock (DestDesc->IndexField.LockRule); - - /* - * Set Index value to select proper Data register - * perform the update (Set index) - */ - - Status = AcpiAmlAccessNamedField (ACPI_WRITE, - DestDesc->IndexField.Index, - &DestDesc->IndexField.Value, - sizeof (DestDesc->IndexField.Value)); - - DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNte: IndexField: set index returned %s\n", - AcpiCmFormatException (Status))); - - if (ACPI_SUCCESS (Status)) - { - /* set index successful, next set Data value */ - - Status = AcpiAmlAccessNamedField (ACPI_WRITE, - DestDesc->IndexField.Data, - &ValDesc->Number.Value, - sizeof (ValDesc->Number.Value)); - DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNte: IndexField: set data returned %s\n", - AcpiCmFormatException (Status))); - } + Status = AcpiAmlCopyIntegerToIndexField (SourceDesc, TargetDesc); break; - case ACPI_TYPE_FIELD_UNIT: - - - /* - * If the Field Buffer and Index have not been previously evaluated, - * evaluate them and save the results. - */ - if (!(DestDesc->Common.Flags & AOPOBJ_DATA_VALID)) - { - Status = AcpiDsGetFieldUnitArguments (DestDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - if ((!DestDesc->FieldUnit.Container || - ACPI_TYPE_BUFFER != DestDesc->FieldUnit.Container->Common.Type)) - { - DUMP_PATHNAME (Node, - "AmlStoreObjectToNte: FieldUnit: Bad container in ", - ACPI_ERROR, _COMPONENT); - DUMP_ENTRY (Node, ACPI_ERROR); - DEBUG_PRINT (ACPI_ERROR, - ("Container: %p", DestDesc->FieldUnit.Container)); - - if (DestDesc->FieldUnit.Container) - { - DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %X", - DestDesc->FieldUnit.Container->Common.Type)); - } - DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); - - Status = AE_AML_INTERNAL; - goto CleanUpAndBailOut; - } - - /* - * Get the global lock if needed - */ - Locked = AcpiAmlAcquireGlobalLock (DestDesc->FieldUnit.LockRule); - - /* - * TBD: [Unhandled] REMOVE this limitation - * Make sure the operation is within the limits of our implementation - * this is not a Spec limitation!! - */ - if (DestDesc->FieldUnit.Length + DestDesc->FieldUnit.BitOffset > 32) - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToNte: FieldUnit: Implementation limitation - Field exceeds UINT32\n")); - Status = AE_NOT_IMPLEMENTED; - goto CleanUpAndBailOut; - } - - /* Field location is (base of buffer) + (byte offset) */ - - Location = DestDesc->FieldUnit.Container->Buffer.Pointer - + DestDesc->FieldUnit.Offset; - - /* - * Construct Mask with 1 bits where the field is, - * 0 bits elsewhere - */ - Mask = ((UINT32) 1 << DestDesc->FieldUnit.Length) - ((UINT32)1 - << DestDesc->FieldUnit.BitOffset); - - DEBUG_PRINT (TRACE_EXEC, - ("** Store %lx in buffer %p byte %ld bit %X width %d addr %p mask %08lx\n", - ValDesc->Number.Value, - DestDesc->FieldUnit.Container->Buffer.Pointer, - DestDesc->FieldUnit.Offset, DestDesc->FieldUnit.BitOffset, - DestDesc->FieldUnit.Length,Location, Mask)); - - /* Zero out the field in the buffer */ - - MOVE_UNALIGNED32_TO_32 (&NewValue, Location); - NewValue &= ~Mask; - - /* - * Shift and mask the new value into position, - * and or it into the buffer. - */ - NewValue |= (ValDesc->Number.Value << DestDesc->FieldUnit.BitOffset) & - Mask; - - /* Store back the value */ - - MOVE_UNALIGNED32_TO_32 (Location, &NewValue); + case ACPI_TYPE_STRING: - DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue)); + Status = AcpiAmlCopyStringToString (SourceDesc, TargetDesc); break; - case ACPI_TYPE_NUMBER: - - - DestDesc->Number.Value = ValDesc->Number.Value; - - /* Truncate value if we are executing from a 32-bit ACPI table */ + case ACPI_TYPE_BUFFER: - AcpiAmlTruncateFor32bitTable (DestDesc, WalkState); + Status = AcpiAmlCopyBufferToBuffer (SourceDesc, TargetDesc); break; case ACPI_TYPE_PACKAGE: /* - * TBD: [Unhandled] Not real sure what to do here + * TBD: [Unhandled] Not real sure what to do here */ Status = AE_NOT_IMPLEMENTED; break; @@ -690,28 +359,17 @@ AcpiAmlStoreObjectToNode ( default: /* - * All other types than Alias and the various Fields come here. - * Store ValDesc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * ValDesc reference count is incremented by AttachObject. + * All other types come here. */ - DEBUG_PRINT (ACPI_WARN, - ("AmlStoreObjectToNte: Store into %s not implemented\n", - AcpiCmGetTypeName (AcpiNsGetType (Node)))); + ("AmlStoreObject: Store into type %s not implemented\n", + AcpiCmGetTypeName (TargetType))); Status = AE_NOT_IMPLEMENTED; break; } -CleanUpAndBailOut: - - /* - * Release global lock if we acquired it earlier - */ - AcpiAmlReleaseGlobalLock (Locked); - return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c index 675288b7dc0b..08258912d5a8 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstorob - AML Interpreter object store support, store to object - * $Revision: 19 $ + * $Revision: 22 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -130,317 +130,452 @@ MODULE_NAME ("amstorob") + /******************************************************************************* * - * FUNCTION: AcpiAmlStoreObjectToObject + * FUNCTION: AcpiAmlCopyBufferToBuffer * - * PARAMETERS: *ValDesc - Value to be stored - * *DestDesc - Object to receive the value + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy * * RETURN: Status * - * DESCRIPTION: Store an object to another object. + * DESCRIPTION: Copy a buffer object to another buffer object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlCopyBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + /* + * We know that SourceDesc is a buffer by now + */ + Buffer = (UINT8 *) SourceDesc->Buffer.Pointer; + Length = SourceDesc->Buffer.Length; + + /* + * Buffer is a static allocation, + * only place what will fit in the buffer. + */ + if (Length <= TargetDesc->Buffer.Length) + { + /* Clear existing buffer and copy in the new one */ + + MEMSET(TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + MEMCPY(TargetDesc->Buffer.Pointer, Buffer, Length); + } + + else + { + /* + * Truncate the source, copy only what will fit + */ + MEMCPY(TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: Truncating src buffer from %X to %X\n", + Length, TargetDesc->Buffer.Length)); + } + + return (AE_OK); +} + + + + +/******************************************************************************* * - * The Assignment of an object to another (not named) object - * is handled here. - * The val passed in will replace the current value (if any) - * with the input value. + * FUNCTION: AcpiAmlCopyStringToString * - * When storing into an object the data is converted to the - * target object type then stored in the object. This means - * that the target object type (for an initialized target) will - * not be changed by a store operation. + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy * - * This module allows destination types of Number, String, - * and Buffer. + * RETURN: Status + * + * DESCRIPTION: Copy a String object to another String object * ******************************************************************************/ ACPI_STATUS -AcpiAmlStoreObjectToObject ( - ACPI_OPERAND_OBJECT *ValDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState) +AcpiAmlCopyStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) { - ACPI_STATUS Status = AE_OK; - UINT8 *Buffer = NULL; - UINT32 Length = 0; - OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type; - - - FUNCTION_TRACE ("AmlStoreObjectToObject"); + UINT32 Length; + UINT8 *Buffer; - DEBUG_PRINT (ACPI_INFO, - ("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n", - DestDesc, ValDesc)); /* - * Assuming the parameters are valid!!! + * We know that SourceDesc is a string by now. */ - ACPI_ASSERT((DestDesc) && (ValDesc)); - - DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n", - AcpiCmGetTypeName (ValDesc->Common.Type), - AcpiCmGetTypeName (DestDesc->Common.Type))); + Buffer = (UINT8 *) SourceDesc->String.Pointer; + Length = SourceDesc->String.Length; /* - * First ensure we have a value that can be stored in the target + * Setting a string value replaces the old string */ - switch (DestinationType) + if (Length < TargetDesc->String.Length) { - /* Type of Name's existing value */ + /* Clear old string and copy in the new one */ - case ACPI_TYPE_NUMBER: + MEMSET(TargetDesc->String.Pointer, 0, TargetDesc->String.Length); + MEMCPY(TargetDesc->String.Pointer, Buffer, Length); + } + else + { /* - * These cases all require only number values or values that - * can be converted to numbers. - * - * If value is not a Number, try to resolve it to one. + * Free the current buffer, then allocate a buffer + * large enough to hold the value */ - - if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) + if (TargetDesc->String.Pointer && + !AcpiTbSystemTablePointer (TargetDesc->String.Pointer)) { /* - * Initially not a number, convert + * Only free if not a pointer into the DSDT */ - Status = AcpiAmlResolveToValue (&ValDesc, WalkState); - if (ACPI_SUCCESS (Status) && - (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) - { - /* - * Conversion successful but still not a number - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n", - AcpiCmGetTypeName (DestinationType), - AcpiCmGetTypeName (ValDesc->Common.Type))); - Status = AE_AML_OPERAND_TYPE; - } + AcpiCmFree(TargetDesc->String.Pointer); } - break; + TargetDesc->String.Pointer = AcpiCmAllocate (Length + 1); + TargetDesc->String.Length = Length; - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* - * Storing into a Field in a region or into a buffer or into - * a string all is essentially the same. - * - * If value is not a valid type, try to resolve it to one. - */ - - if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && - (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && - (ValDesc->Common.Type != ACPI_TYPE_STRING)) + if (!TargetDesc->String.Pointer) { - /* - * Initially not a valid type, convert - */ - Status = AcpiAmlResolveToValue (&ValDesc, WalkState); - if (ACPI_SUCCESS (Status) && - (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && - (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && - (ValDesc->Common.Type != ACPI_TYPE_STRING)) - { - /* - * Conversion successful but still not a valid type - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", - AcpiCmGetTypeName (ValDesc->Common.Type), - AcpiCmGetTypeName (DestinationType))); - Status = AE_AML_OPERAND_TYPE; - } + return (AE_NO_MEMORY); } - break; + MEMCPY(TargetDesc->String.Pointer, Buffer, Length); + } - default: + return (AE_OK); +} - /* - * TBD: [Unhandled] What other combinations must be implemented? - */ - Status = AE_NOT_IMPLEMENTED; - break; + + + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlCopyIntegerToIndexField + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Write an Integer to an Index Field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlCopyIntegerToIndexField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + ACPI_STATUS Status; + BOOLEAN Locked; + + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (TargetDesc->IndexField.LockRule); + + /* + * Set Index value to select proper Data register + * perform the update (Set index) + */ + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + TargetDesc->IndexField.Index, + &TargetDesc->IndexField.Value, + sizeof (TargetDesc->IndexField.Value)); + if (ACPI_SUCCESS (Status)) + { + /* SetIndex was successful, next set Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + TargetDesc->IndexField.Data, + &SourceDesc->Integer.Value, + sizeof (SourceDesc->Integer.Value)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: IndexField: set data returned %s\n", + AcpiCmFormatException (Status))); + } + + else + { + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: IndexField: set index returned %s\n", + AcpiCmFormatException (Status))); } - /* Exit now if failure above */ - if (ACPI_FAILURE (Status)) + /* + * Release global lock if we acquired it earlier + */ + AcpiAmlReleaseGlobalLock (Locked); + + return (Status); +} + + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlCopyIntegerToBankField + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Write an Integer to a Bank Field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlCopyIntegerToBankField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + ACPI_STATUS Status; + BOOLEAN Locked; + + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (TargetDesc->IndexField.LockRule); + + + + /* + * Set Bank value to select proper Bank + * Perform the update (Set Bank Select) + */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + TargetDesc->BankField.BankSelect, + &TargetDesc->BankField.Value, + sizeof (TargetDesc->BankField.Value)); + if (ACPI_SUCCESS (Status)) + { + /* Set bank select successful, set data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + TargetDesc->BankField.BankSelect, + &SourceDesc->BankField.Value, + sizeof (SourceDesc->BankField.Value)); + } + + else { - goto CleanUpAndBailOut; + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNode: BankField: set bakn returned %s\n", + AcpiCmFormatException (Status))); } + /* - * AcpiEverything is ready to execute now, We have - * a value we can handle, just perform the update + * Release global lock if we acquired it earlier */ + AcpiAmlReleaseGlobalLock (Locked); + + return (Status); +} + + + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlCopyDataToNamedField + * + * PARAMETERS: SourceDesc - Source object to copy + * Node - Destination Namespace node + * + * RETURN: Status + * + * DESCRIPTION: Copy raw data to a Named Field. No implicit conversion + * is performed on the source object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlCopyDataToNamedField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + BOOLEAN Locked; + UINT32 Length; + UINT8 *Buffer; + - switch (DestinationType) + /* + * Named fields (CreateXxxField) - We don't perform any conversions on the + * source operand, just use the raw data + */ + switch (SourceDesc->Common.Type) { + case ACPI_TYPE_INTEGER: + Buffer = (UINT8 *) &SourceDesc->Integer.Value; + Length = sizeof (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) SourceDesc->Buffer.Pointer; + Length = SourceDesc->Buffer.Length; + break; case ACPI_TYPE_STRING: + Buffer = (UINT8 *) SourceDesc->String.Pointer; + Length = SourceDesc->String.Length; + break; - /* - * Perform the update - */ + default: + return (AE_TYPE); + } - switch (ValDesc->Common.Type) - { - case ACPI_TYPE_NUMBER: - Buffer = (UINT8 *) &ValDesc->Number.Value; - Length = sizeof (ValDesc->Number.Value); - break; - - case ACPI_TYPE_BUFFER: - Buffer = (UINT8 *) ValDesc->Buffer.Pointer; - Length = ValDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - Buffer = (UINT8 *) ValDesc->String.Pointer; - Length = ValDesc->String.Length; - break; - } + /* + * Get the global lock if needed before the update + * TBD: not needed! + */ + Locked = AcpiAmlAcquireGlobalLock (SourceDesc->Field.LockRule); - /* - * Setting a string value replaces the old string - */ + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + Node, Buffer, Length); - if (Length < DestDesc->String.Length) - { - /* - * Zero fill, not willing to do pointer arithmetic for - * architecture independence. Just clear the whole thing - */ - MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); - MEMCPY(DestDesc->String.Pointer, Buffer, Length); - } - else - { - /* - * Free the current buffer, then allocate a buffer - * large enough to hold the value - */ - if ( DestDesc->String.Pointer && - !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) - { - /* - * Only free if not a pointer into the DSDT - */ - - AcpiCmFree(DestDesc->String.Pointer); - } - - DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); - DestDesc->String.Length = Length; - - if (!DestDesc->String.Pointer) - { - Status = AE_NO_MEMORY; - goto CleanUpAndBailOut; - } - - MEMCPY(DestDesc->String.Pointer, Buffer, Length); - } - break; + AcpiAmlReleaseGlobalLock (Locked); + return (Status); +} - case ACPI_TYPE_BUFFER: - /* - * Perform the update to the buffer - */ - switch (ValDesc->Common.Type) - { - case ACPI_TYPE_NUMBER: - Buffer = (UINT8 *) &ValDesc->Number.Value; - Length = sizeof (ValDesc->Number.Value); - break; - - case ACPI_TYPE_BUFFER: - Buffer = (UINT8 *) ValDesc->Buffer.Pointer; - Length = ValDesc->Buffer.Length; - break; - - case ACPI_TYPE_STRING: - Buffer = (UINT8 *) ValDesc->String.Pointer; - Length = ValDesc->String.Length; - break; - } - /* - * If the buffer is uninitialized, - * memory needs to be allocated for the copy. - */ - if(0 == DestDesc->Buffer.Length) +/******************************************************************************* + * + * FUNCTION: AcpiAmlCopyIntegerToFieldUnit + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Write an Integer to a Field Unit. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlCopyIntegerToFieldUnit ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *Location = NULL; + UINT32 Mask; + UINT32 NewValue; + BOOLEAN Locked = FALSE; + + + + FUNCTION_TRACE ("AmlCopyIntegerToFieldUnit"); + + /* + * If the Field Buffer and Index have not been previously evaluated, + * evaluate them and save the results. + */ + if (!(TargetDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetFieldUnitArguments (TargetDesc); + if (ACPI_FAILURE (Status)) { - DestDesc->Buffer.Pointer = AcpiCmCallocate(Length); - DestDesc->Buffer.Length = Length; - - if (!DestDesc->Buffer.Pointer) - { - Status = AE_NO_MEMORY; - goto CleanUpAndBailOut; - } + return_ACPI_STATUS (Status); } + } - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ - if (Length <= DestDesc->Buffer.Length) + if ((!TargetDesc->FieldUnit.Container || + ACPI_TYPE_BUFFER != TargetDesc->FieldUnit.Container->Common.Type)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Null Container or wrong type: %p", TargetDesc->FieldUnit.Container)); + + if (TargetDesc->FieldUnit.Container) { - /* - * Zero fill first, not willing to do pointer arithmetic for - * architecture independence. Just clear the whole thing - */ - MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); - MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); + DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %X", + TargetDesc->FieldUnit.Container->Common.Type)); } - else - { - /* - * truncate, copy only what will fit - */ - MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); - DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToObject: Truncating src buffer from %X to %X\n", - Length, DestDesc->Buffer.Length)); - } - break; + DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); - case ACPI_TYPE_NUMBER: + return_ACPI_STATUS (AE_AML_INTERNAL); + } - DestDesc->Number.Value = ValDesc->Number.Value; + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (TargetDesc->FieldUnit.LockRule); - /* Truncate value if we are executing from a 32-bit ACPI table */ + /* + * TBD: [Unhandled] REMOVE this limitation + * Make sure the operation is within the limits of our implementation + * this is not a Spec limitation!! + */ + if (TargetDesc->FieldUnit.Length + TargetDesc->FieldUnit.BitOffset > 32) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlCopyIntegerToFieldUnit: FieldUnit: Implementation limitation - Field exceeds UINT32\n")); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } - AcpiAmlTruncateFor32bitTable (DestDesc, WalkState); - break; + /* Field location is (base of buffer) + (byte offset) */ - default: + Location = TargetDesc->FieldUnit.Container->Buffer.Pointer + + TargetDesc->FieldUnit.Offset; - /* - * All other types than Alias and the various Fields come here. - * Store ValDesc as the new value of the Name, and set - * the Name's type to that of the value being stored in it. - * ValDesc reference count is incremented by AttachObject. - */ + /* + * Construct Mask with 1 bits where the field is, + * 0 bits elsewhere + */ + Mask = ((UINT32) 1 << TargetDesc->FieldUnit.Length) - ((UINT32)1 + << TargetDesc->FieldUnit.BitOffset); - DEBUG_PRINT (ACPI_WARN, - ("AmlStoreObjectToObject: Store into %s not implemented\n", - AcpiCmGetTypeName (DestDesc->Common.Type))); + DEBUG_PRINT (TRACE_EXEC, + ("** Store %lx in buffer %p byte %ld bit %X width %d addr %p mask %08lx\n", + SourceDesc->Integer.Value, + TargetDesc->FieldUnit.Container->Buffer.Pointer, + TargetDesc->FieldUnit.Offset, TargetDesc->FieldUnit.BitOffset, + TargetDesc->FieldUnit.Length,Location, Mask)); - Status = AE_NOT_IMPLEMENTED; - break; - } + /* Zero out the field in the buffer */ -CleanUpAndBailOut: + MOVE_UNALIGNED32_TO_32 (&NewValue, Location); + NewValue &= ~Mask; + + /* + * Shift and mask the new value into position, + * and or it into the buffer. + */ + NewValue |= (SourceDesc->Integer.Value << TargetDesc->FieldUnit.BitOffset) & + Mask; - return_ACPI_STATUS (Status); + /* Store back the value */ + + MOVE_UNALIGNED32_TO_32 (Location, &NewValue); + + DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue)); + return_ACPI_STATUS (AE_OK); } + + + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c index d7b5fd8bb926..e1f64ea00ec3 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amsystem - Interface to OS services - * $Revision: 53 $ + * $Revision: 54 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -307,7 +307,7 @@ AcpiAmlSystemAcquireMutex ( } Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, - (UINT32) TimeDesc->Number.Value); + (UINT32) TimeDesc->Integer.Value); return_ACPI_STATUS (Status); } @@ -417,7 +417,7 @@ AcpiAmlSystemWaitEvent ( if (ObjDesc) { Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Event.Semaphore, - (UINT32) TimeDesc->Number.Value); + (UINT32) TimeDesc->Integer.Value); } diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c index f009e02971bb..e106bfbe585b 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amutils - interpreter/scanner utilities - * $Revision: 66 $ + * $Revision: 68 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License @@ -138,14 +138,11 @@ typedef struct Internal_Search_st /* Used to traverse nested packages when copying*/ +/* TBD: This must be removed! */ INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; -static NATIVE_CHAR hex[] = - {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - - /******************************************************************************* * * FUNCTION: AcpiAmlEnterInterpreter @@ -252,7 +249,7 @@ AcpiAmlTruncateFor32bitTable ( */ if ((!ObjDesc) || - (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) || + (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) || (!WalkState->MethodNode)) { return; @@ -264,7 +261,7 @@ AcpiAmlTruncateFor32bitTable ( * We are running a method that exists in a 32-bit ACPI table. * Truncate the value to 32 bits by zeroing out the upper 32-bit field */ - ObjDesc->Number.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; + ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; } } @@ -463,10 +460,10 @@ AcpiAmlEisaIdToString ( OutString[0] = (char) ('@' + ((id >> 26) & 0x1f)); OutString[1] = (char) ('@' + ((id >> 21) & 0x1f)); OutString[2] = (char) ('@' + ((id >> 16) & 0x1f)); - OutString[3] = hex[(id >> 12) & 0xf]; - OutString[4] = hex[(id >> 8) & 0xf]; - OutString[5] = hex[(id >> 4) & 0xf]; - OutString[6] = hex[id & 0xf]; + OutString[3] = AcpiGbl_HexToAscii[(id >> 12) & 0xf]; + OutString[4] = AcpiGbl_HexToAscii[(id >> 8) & 0xf]; + OutString[5] = AcpiGbl_HexToAscii[(id >> 4) & 0xf]; + OutString[6] = AcpiGbl_HexToAscii[id & 0xf]; OutString[7] = 0; return (AE_OK); diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c index 514940315d5e..960677eb8745 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amxface - External interpreter interfaces - * $Revision: 23 $ + * $Revision: 24 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. + * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. * All rights reserved. * * 2. License |
