From b62825800352ee7a707465324bf5bdd6bd873381 Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 17:24:40 +0000 Subject: [PATCH] Prefixed C library macros (MEMSET, etc.) with "ACPI_". date 2002.02.13.18.54.00; author rmoore1; state Exp; --- source/components/executer/exdump.c | 69 +- source/components/executer/exfield.c | 41 +- source/components/executer/exfldio.c | 99 +- source/components/executer/exmisc.c | 1009 +++++++++---------- source/components/executer/exnames.c | 461 ++++----- source/components/executer/exoparg1.c | 1331 +++++++++++-------------- source/components/executer/exoparg3.c | 54 +- 7 files changed, 1386 insertions(+), 1678 deletions(-) diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 8bee7a9b4..90e803913 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * $Revision: 1.142 $ + * $Revision: 1.145 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -124,7 +124,7 @@ #include "acparser.h" #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("exdump") + ACPI_MODULE_NAME ("exdump") /* @@ -161,7 +161,7 @@ AcpiExShowHexValue ( UINT8 *CurrentAmlPtr = NULL; /* Pointer to current byte of AML value */ - FUNCTION_TRACE ("ExShowHexValue"); + ACPI_FUNCTION_TRACE ("ExShowHexValue"); if (!((ACPI_LV_LOAD & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) @@ -171,7 +171,7 @@ AcpiExShowHexValue ( if (!AmlStart) { - REPORT_ERROR (("ExShowHexValue: null pointer\n")); + ACPI_REPORT_ERROR (("ExShowHexValue: null pointer\n")); return; } @@ -248,7 +248,7 @@ AcpiExDumpOperand ( UINT32 i; - PROC_NAME ("ExDumpOperand") + ACPI_FUNCTION_NAME ("ExDumpOperand") if (!((ACPI_LV_INFO & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) @@ -270,14 +270,14 @@ AcpiExDumpOperand ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p NS Node: ", ObjDesc)); - DUMP_ENTRY (ObjDesc, ACPI_LV_INFO); + ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_INFO); return (AE_OK); } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_INTERNAL) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p is not a local object\n", ObjDesc)); - DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); + ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); return (AE_OK); } @@ -323,9 +323,9 @@ AcpiExDumpOperand ( case AML_NAME_OP: - DUMP_PATHNAME (ObjDesc->Reference.Object, "Reference: Name: ", + ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); - DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); + ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); break; @@ -346,8 +346,8 @@ AcpiExDumpOperand ( /* Value is a Number */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - HIDWORD(ObjDesc->Integer.Value), - LODWORD(ObjDesc->Integer.Value)); + ACPI_HIDWORD(ObjDesc->Integer.Value), + ACPI_LODWORD(ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -365,8 +365,8 @@ AcpiExDumpOperand ( /* Value is a Number */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - HIDWORD(ObjDesc->Integer.Value), - LODWORD(ObjDesc->Integer.Value)); + ACPI_HIDWORD(ObjDesc->Integer.Value), + ACPI_LODWORD(ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -423,24 +423,24 @@ AcpiExDumpOperand ( case ACPI_TYPE_INTEGER: AcpiOsPrintf ("Integer %8.8X%8.8X\n", - HIDWORD (ObjDesc->Integer.Value), - LODWORD (ObjDesc->Integer.Value)); + ACPI_HIDWORD (ObjDesc->Integer.Value), + ACPI_LODWORD (ObjDesc->Integer.Value)); break; case INTERNAL_TYPE_IF: AcpiOsPrintf ("If [Integer] %8.8X%8.8X\n", - HIDWORD (ObjDesc->Integer.Value), - LODWORD (ObjDesc->Integer.Value)); + ACPI_HIDWORD (ObjDesc->Integer.Value), + ACPI_LODWORD (ObjDesc->Integer.Value)); break; case INTERNAL_TYPE_WHILE: AcpiOsPrintf ("While [Integer] %8.8X%8.8X\n", - HIDWORD (ObjDesc->Integer.Value), - LODWORD (ObjDesc->Integer.Value)); + ACPI_HIDWORD (ObjDesc->Integer.Value), + ACPI_LODWORD (ObjDesc->Integer.Value)); break; @@ -490,8 +490,8 @@ AcpiExDumpOperand ( else { AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", - HIDWORD(ObjDesc->Region.Address), - LODWORD(ObjDesc->Region.Address), + ACPI_HIDWORD (ObjDesc->Region.Address), + ACPI_LODWORD (ObjDesc->Region.Address), ObjDesc->Region.Length); } break; @@ -523,10 +523,10 @@ AcpiExDumpOperand ( AcpiOsPrintf ( "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", ObjDesc->Field.BitLength, ObjDesc->Field.AccessByteWidth, - ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, + ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); - DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj); + ACPI_DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj); break; @@ -556,7 +556,7 @@ AcpiExDumpOperand ( else { - DUMP_STACK_ENTRY (ObjDesc->BufferField.BufferObj); + ACPI_DUMP_STACK_ENTRY (ObjDesc->BufferField.BufferObj); } break; @@ -634,7 +634,7 @@ AcpiExDumpOperand ( void AcpiExDumpOperands ( ACPI_OPERAND_OBJECT **Operands, - OPERATING_MODE InterpreterMode, + ACPI_INTERPRETER_MODE InterpreterMode, NATIVE_CHAR *Ident, UINT32 NumLevels, NATIVE_CHAR *Note, @@ -645,7 +645,7 @@ AcpiExDumpOperands ( ACPI_OPERAND_OBJECT **ObjDesc; - PROC_NAME ("ExDumpOperands"); + ACPI_FUNCTION_NAME ("ExDumpOperands"); if (!Ident) @@ -733,7 +733,7 @@ AcpiExOutAddress ( AcpiOsPrintf ("%20s : %p\n", Title, Value); #else AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, - HIDWORD (Value), LODWORD (Value)); + ACPI_HIDWORD (Value), ACPI_LODWORD (Value)); #endif } @@ -755,7 +755,7 @@ AcpiExDumpNode ( UINT32 Flags) { - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); if (!Flags) @@ -767,8 +767,8 @@ AcpiExDumpNode ( } - AcpiOsPrintf ("%20s : %4.4s\n", "Name", (char*)&Node->Name); - AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); + AcpiOsPrintf ("%20s : %4.4s\n", "Name", (char *) &Node->Name); + AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); AcpiExOutInteger ("Flags", Node->Flags); AcpiExOutInteger ("Owner Id", Node->OwnerId); AcpiExOutInteger ("Reference Count", Node->ReferenceCount); @@ -798,7 +798,7 @@ AcpiExDumpObjectDescriptor ( UINT32 i; - FUNCTION_TRACE ("ExDumpObjectDescriptor"); + ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor"); if (!Flags) @@ -827,8 +827,9 @@ AcpiExDumpObjectDescriptor ( { case ACPI_TYPE_INTEGER: - AcpiOsPrintf ("%20s : %X%8.8X\n", "Value", HIDWORD (ObjDesc->Integer.Value), - LODWORD (ObjDesc->Integer.Value)); + AcpiOsPrintf ("%20s : %X%8.8X\n", "Value", + ACPI_HIDWORD (ObjDesc->Integer.Value), + ACPI_LODWORD (ObjDesc->Integer.Value)); break; diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c index 870b983b0..53062d46b 100644 --- a/source/components/executer/exfield.c +++ b/source/components/executer/exfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 1.100 $ + * $Revision: 1.105 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -127,21 +127,20 @@ #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("exfield") + ACPI_MODULE_NAME ("exfield") /******************************************************************************* * * FUNCTION: AcpiExReadDataFromField * - * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE - * *FieldNode - Parent node for field to be accessed - * *Buffer - Value(s) to be read or written - * BufferLength - Number of bytes to transfer + * PARAMETERS: ObjDesc - The named field + * RetBufferDesc - Where the return data object is stored * - * RETURN: Status3 + * RETURN: Status * - * DESCRIPTION: Read or write a named field + * DESCRIPTION: Read from a named field. Returns either an Integer or a + * Buffer, depending on the size of the field. * ******************************************************************************/ @@ -157,7 +156,7 @@ AcpiExReadDataFromField ( BOOLEAN Locked; - FUNCTION_TRACE_PTR ("ExReadDataFromField", ObjDesc); + ACPI_FUNCTION_TRACE_PTR ("ExReadDataFromField", ObjDesc); /* Parameter validation */ @@ -193,7 +192,7 @@ AcpiExReadDataFromField ( * * Note: Field.length is in bits. */ - Length = ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + Length = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); if (Length > sizeof (ACPI_INTEGER)) { @@ -217,7 +216,6 @@ AcpiExReadDataFromField ( BufferDesc->Buffer.Length = Length; Buffer = BufferDesc->Buffer.Pointer; } - else { /* Field will fit within an Integer (normal case) */ @@ -252,12 +250,10 @@ AcpiExReadDataFromField ( */ AcpiExReleaseGlobalLock (Locked); - if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (BufferDesc); } - else if (RetBufferDesc) { *RetBufferDesc = BufferDesc; @@ -271,14 +267,12 @@ AcpiExReadDataFromField ( * * FUNCTION: AcpiExWriteDataToField * - * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE - * *FieldNode - Parent node for field to be accessed - * *Buffer - Value(s) to be read or written - * BufferLength - Number of bytes to transfer + * PARAMETERS: SourceDesc - Contains data to write + * ObjDesc - The named field * * RETURN: Status * - * DESCRIPTION: Read or write a named field + * DESCRIPTION: Write to a named field * ******************************************************************************/ @@ -295,7 +289,7 @@ AcpiExWriteDataToField ( BOOLEAN Locked; - FUNCTION_TRACE_PTR ("ExWriteDataToField", ObjDesc); + ACPI_FUNCTION_TRACE_PTR ("ExWriteDataToField", ObjDesc); /* Parameter validation */ @@ -321,7 +315,6 @@ AcpiExWriteDataToField ( } } - /* * Get a pointer to the data to be written */ @@ -348,12 +341,12 @@ AcpiExWriteDataToField ( /* * We must have a buffer that is at least as long as the field - * we are writing to. This is because individual fields are + * we are writing to. This is because individual fields are * indivisible and partial writes are not supported -- as per * the ACPI specification. */ NewBuffer = NULL; - RequiredLength = ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); if (Length < RequiredLength) { @@ -370,7 +363,7 @@ AcpiExWriteDataToField ( * at Byte zero. All unused (upper) bytes of the * buffer will be 0. */ - MEMCPY ((char *) NewBuffer, (char *) Buffer, Length); + ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, Length); Buffer = NewBuffer; Length = RequiredLength; } diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c index 4a615dd49..263b38f67 100644 --- a/source/components/executer/exfldio.c +++ b/source/components/executer/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 1.78 $ + * $Revision: 1.82 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -127,7 +127,7 @@ #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("exfldio") + ACPI_MODULE_NAME ("exfldio") /******************************************************************************* @@ -154,7 +154,7 @@ AcpiExSetupRegion ( ACPI_OPERAND_OBJECT *RgnDesc; - FUNCTION_TRACE_U32 ("ExSetupRegion", FieldDatumByteOffset); + ACPI_FUNCTION_TRACE_U32 ("ExSetupRegion", FieldDatumByteOffset); RgnDesc = ObjDesc->CommonField.RegionObj; @@ -197,7 +197,7 @@ AcpiExSetupRegion ( */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", - (char *) &ObjDesc->CommonField.Node->Name, ObjDesc->CommonField.AccessByteWidth, + (char *) &ObjDesc->CommonField.Node->Name, ObjDesc->CommonField.AccessByteWidth, (char *) &RgnDesc->Region.Node->Name, RgnDesc->Region.Length)); } @@ -207,8 +207,8 @@ AcpiExSetupRegion ( */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", - (char *) &ObjDesc->CommonField.Node->Name, ObjDesc->CommonField.BaseByteOffset, - FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, + (char *) &ObjDesc->CommonField.Node->Name, ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, (char *) &RgnDesc->Region.Node->Name, RgnDesc->Region.Length)); return_ACPI_STATUS (AE_AML_REGION_LIMIT); @@ -246,7 +246,7 @@ AcpiExAccessRegion ( ACPI_PHYSICAL_ADDRESS Address; - FUNCTION_TRACE ("AcpiExAccessRegion"); + ACPI_FUNCTION_TRACE ("AcpiExAccessRegion"); /* @@ -277,12 +277,12 @@ AcpiExAccessRegion ( ObjDesc->CommonField.AccessByteWidth, ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, - HIDWORD (Address), LODWORD (Address))); + ACPI_HIDWORD (Address), ACPI_LODWORD (Address))); /* Invoke the appropriate AddressSpace/OpRegion handler */ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ReadWrite, - Address, MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -333,7 +333,7 @@ AcpiExRegisterOverflow ( if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) { /* - * The field is large enough to hold the maximum integer, so we can + * The field is large enough to hold the maximum integer, so we can * never overflow it. */ return (FALSE); @@ -383,7 +383,7 @@ AcpiExFieldDatumIo ( ACPI_INTEGER LocalValue; - FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset); + ACPI_FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset); if (ReadWrite == ACPI_READ) @@ -429,7 +429,7 @@ AcpiExFieldDatumIo ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ACPI_MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth); @@ -440,7 +440,7 @@ AcpiExFieldDatumIo ( * Copy the data to the target buffer. * Length is the field width in bytes. */ - MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset, Value, ObjDesc->CommonField.AccessByteWidth); @@ -547,12 +547,12 @@ AcpiExFieldDatumIo ( if (ReadWrite == ACPI_READ) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n", - HIDWORD(*Value), LODWORD(*Value))); + ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value))); } else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n", - HIDWORD(*Value), LODWORD(*Value))); + ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value))); } } @@ -585,7 +585,7 @@ AcpiExWriteWithUpdateRule ( ACPI_INTEGER CurrentValue; - FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask); + ACPI_FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask); /* Start with the new bits */ @@ -605,8 +605,8 @@ AcpiExWriteWithUpdateRule ( * Check if update rule needs to be applied (not if mask is all * ones) The left shift drops the bits we want to ignore. */ - if ((~Mask << (MUL_8 (sizeof (Mask)) - - MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) + if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) { /* * Read the current contents of the byte/word/dword containing @@ -637,7 +637,6 @@ AcpiExWriteWithUpdateRule ( "WriteWithUpdateRule: Unknown UpdateRule setting: %x\n", (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); return_ACPI_STATUS (AE_AML_OPERAND_VALUE); - break; } } @@ -648,10 +647,10 @@ AcpiExWriteWithUpdateRule ( ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Mask %8.8X%8.8X DatumOffset %X Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", - HIDWORD(Mask), LODWORD(Mask), + ACPI_HIDWORD (Mask), ACPI_LODWORD (Mask), FieldDatumByteOffset, - HIDWORD(FieldValue), LODWORD(FieldValue), - HIDWORD(MergedValue),LODWORD(MergedValue))); + ACPI_HIDWORD (FieldValue), ACPI_LODWORD (FieldValue), + ACPI_HIDWORD (MergedValue),ACPI_LODWORD (MergedValue))); return_ACPI_STATUS (Status); } @@ -682,25 +681,29 @@ AcpiExGetBufferDatum( UINT32 Offset) { - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: + *Datum = ((UINT8 *) Buffer) [Offset]; break; case ACPI_FIELD_WORD_GRANULARITY: - MOVE_UNALIGNED16_TO_32 (Datum, &(((UINT16 *) Buffer) [Offset])); + + ACPI_MOVE_UNALIGNED16_TO_32 (Datum, &(((UINT16 *) Buffer) [Offset])); break; case ACPI_FIELD_DWORD_GRANULARITY: - MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset])); + + ACPI_MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset])); break; case ACPI_FIELD_QWORD_GRANULARITY: - MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset])); + + ACPI_MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset])); break; } } @@ -731,25 +734,29 @@ AcpiExSetBufferDatum ( UINT32 Offset) { - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: + ((UINT8 *) Buffer) [Offset] = (UINT8) MergedDatum; break; case ACPI_FIELD_WORD_GRANULARITY: - MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[Offset]), &MergedDatum); + + ACPI_MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[Offset]), &MergedDatum); break; case ACPI_FIELD_DWORD_GRANULARITY: - MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum); + + ACPI_MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum); break; case ACPI_FIELD_QWORD_GRANULARITY: - MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum); + + ACPI_MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum); break; } } @@ -784,16 +791,16 @@ AcpiExExtractFromField ( UINT32 DatumCount; - FUNCTION_TRACE ("ExExtractFromField"); + ACPI_FUNCTION_TRACE ("ExExtractFromField"); /* * The field must fit within the caller's buffer */ - ByteFieldLength = ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); + ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); if (ByteFieldLength > BufferLength) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Field size %X (bytes) too large for buffer (%X)\n", ByteFieldLength, BufferLength)); @@ -802,7 +809,7 @@ AcpiExExtractFromField ( /* Convert field byte count to datum count, round up if necessary */ - DatumCount = ROUND_UP_TO (ByteFieldLength, + DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, @@ -814,7 +821,7 @@ AcpiExExtractFromField ( * This is very important, especially in the cases where a byte is read, * but the buffer is really a UINT32 (4 bytes). */ - MEMSET (Buffer, 0, BufferLength); + ACPI_MEMSET (Buffer, 0, BufferLength); /* Read the first raw datum to prime the loop */ @@ -842,7 +849,7 @@ AcpiExExtractFromField ( if (ObjDesc->CommonField.EndBufferValidBits) { - MergedDatum &= MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); + MergedDatum &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); } /* Store the datum to the caller buffer */ @@ -865,7 +872,7 @@ AcpiExExtractFromField ( * to perform a final read, since this would potentially read * past the end of the region. * - * We could just split the aligned and non-aligned cases since the + * We could just split the aligned and non-aligned cases since the * aligned case is so very simple, but this would require more code. */ if ((ObjDesc->CommonField.StartFieldBitOffset != 0) || @@ -918,7 +925,7 @@ AcpiExExtractFromField ( if (ObjDesc->CommonField.EndBufferValidBits) { MergedDatum &= - MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); + ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); } } } @@ -927,7 +934,7 @@ AcpiExExtractFromField ( * Store the merged field datum in the caller's buffer, according to * the granularity of the field (size of each datum). */ - AcpiExSetBufferDatum (MergedDatum, Buffer, + AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -972,7 +979,7 @@ AcpiExInsertIntoField ( UINT32 DatumCount; - FUNCTION_TRACE ("ExInsertIntoField"); + ACPI_FUNCTION_TRACE ("ExInsertIntoField"); /* @@ -981,7 +988,7 @@ AcpiExInsertIntoField ( * larger than the field, this typically happens when an integer is * written to a field that is actually smaller than an integer. */ - ByteFieldLength = ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); + ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); if (BufferLength < ByteFieldLength) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer length %X too small for field %X\n", @@ -992,7 +999,7 @@ AcpiExInsertIntoField ( /* Convert byte count to datum count, round up if necessary */ - DatumCount = ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth); + DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteLen=%x, DatumLen=%x, ByteGran=%x\n", @@ -1022,7 +1029,7 @@ AcpiExInsertIntoField ( * * Mask off bits that are "below" the field (if any) */ - Mask = MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); /* If the field fits in one datum, may need to mask upper bits */ @@ -1031,7 +1038,7 @@ AcpiExInsertIntoField ( { /* There are bits above the field, mask them off also */ - Mask &= MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); + Mask &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); } /* Shift and mask the value into the field position */ @@ -1118,7 +1125,7 @@ AcpiExInsertIntoField ( * * Mask off the unused bits above (after) the end-of-field */ - Mask = MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); + Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); MergedDatum &= Mask; /* Write the last datum with the update rule */ diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c index 5a168c451..bd4a8e881 100644 --- a/source/components/executer/exmisc.c +++ b/source/components/executer/exmisc.c @@ -1,8 +1,8 @@ /****************************************************************************** * - * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 1.71 $ + * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes + * $Revision: 1.100 $ * *****************************************************************************/ @@ -10,8 +10,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * All rights reserved. * * 2. License * @@ -116,7 +116,7 @@ * *****************************************************************************/ -#define __AMMISC_C__ +#define __EXMISC_C__ #include "acpi.h" #include "acparser.h" @@ -125,558 +125,531 @@ #include "acdispat.h" -#define _COMPONENT INTERPRETER - MODULE_NAME ("ammisc") +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmisc") /******************************************************************************* * - * FUNCTION: AcpiAmlExecFatal + * FUNCTION: AcpiExGetObjectReference * - * PARAMETERS: none + * PARAMETERS: ObjDesc - Create a reference to this object + * ReturnDesc - Where to store the reference * - * RETURN: Status. If the OS returns from the OSD call, we just keep - * on going. + * RETURN: Status * - * DESCRIPTION: Execute Fatal operator - * - * ACPI SPECIFICATION REFERENCES: - * DefFatal := FatalOp FatalType FatalCode FatalArg - * FatalType := ByteData - * FatalCode := DWordData - * FatalArg := TermArg=>Integer + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. * ******************************************************************************/ ACPI_STATUS -AcpiAmlExecFatal ( +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, ACPI_WALK_STATE *WalkState) { - ACPI_OPERAND_OBJECT *TypeDesc; - ACPI_OPERAND_OBJECT *CodeDesc; - ACPI_OPERAND_OBJECT *ArgDesc; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("AmlExecFatal"); + ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc); - /* Resolve operands */ - - Status = AcpiAmlResolveOperands (AML_FATAL_OP, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (AML_FATAL_OP), - 3, "after AcpiAmlResolveOperands"); - - /* Get operands */ - - Status |= AcpiDsObjStackPopObject (&ArgDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&CodeDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&TypeDesc, WalkState); - if (ACPI_FAILURE (Status)) + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { - /* Invalid parameters on object stack */ + case ACPI_DESC_TYPE_INTERNAL: - DEBUG_PRINT (ACPI_ERROR, - ("AcpiAmlExecFatal/AML_FATAL_OP: bad operand(s) (Status=%X)\n", - Status)); - - goto Cleanup; - } - - - /* DefFatal := FatalOp FatalType FatalCode FatalArg */ - - - DEBUG_PRINT (ACPI_INFO, - ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", - TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value)); - - - /* - * TBD: [Unhandled] call OSD interface to notify OS of fatal error - * requiring shutdown! - */ - - -Cleanup: - - /* Free the operands */ - - AcpiCmRemoveReference (ArgDesc); - AcpiCmRemoveReference (CodeDesc); - AcpiCmRemoveReference (TypeDesc); - - - /* If we get back from the OS call, we might as well keep going. */ - - REPORT_WARNING (("An AML \"Fatal\" Opcode (FatalOp) was executed\n")); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiAmlExecIndex - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Execute Index operator - * - * ALLOCATION: Deletes one operand descriptor -- other remains on stack - * - * ACPI SPECIFICATION REFERENCES: - * DefIndex := IndexOp BuffPkgObj IndexValue Result - * IndexValue := TermArg=>Integer - * NameString := | - * Result := SuperName - * SuperName := NameString | ArgObj | LocalObj | DebugObj | DefIndex - * Local4Op | Local5Op | Local6Op | Local7Op - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAmlExecIndex ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *IdxDesc; - ACPI_OPERAND_OBJECT *ResDesc; - ACPI_OPERAND_OBJECT *RetDesc = NULL; - ACPI_OPERAND_OBJECT *TmpDesc; - ACPI_STATUS Status; - - - FUNCTION_TRACE ("AmlExecIndex"); - - - /* Resolve operands */ - /* First operand can be either a package or a buffer */ - - Status = AcpiAmlResolveOperands (AML_INDEX_OP, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (AML_INDEX_OP), - 3, "after AcpiAmlResolveOperands"); - - /* Get all operands */ - - Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - /* Invalid parameters on object stack */ - - DEBUG_PRINT (ACPI_ERROR, - ("AcpiAmlExecIndex/AML_INDEX_OP: bad operand(s) (Status=%X)\n", - Status)); - - goto Cleanup; - } - - - /* Create the internal return object */ - - RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - - /* - * At this point, the ObjDesc operand is either a Package or a Buffer - */ - - if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Object to be indexed is a Package */ - - if (IdxDesc->Number.Value >= ObjDesc->Package.Count) + if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE) { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecIndex: Index value out of range\n")); - Status = AE_AML_PACKAGE_LIMIT; + *ReturnDesc = NULL; + Status = AE_TYPE; goto Cleanup; } - if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && - (ResDesc->Reference.OpCode == AML_ZERO_OP)) - { - /* - * There is no actual result descriptor (the ZeroOp Result - * descriptor is a placeholder), so just delete the placeholder and - * return a reference to the package element - */ - - AcpiCmRemoveReference (ResDesc); - } - - else - { - /* - * Each element of the package is an internal object. Get the one - * we are after. - */ - - TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value]; - RetDesc->Reference.OpCode = AML_INDEX_OP; - RetDesc->Reference.TargetType = TmpDesc->Common.Type; - RetDesc->Reference.Object = TmpDesc; - - Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); - RetDesc->Reference.Object = NULL; - } - /* - * The local return object must always be a reference to the package element, - * not the element itself. + * Not a Name -- an indirect name pointer would have + * been converted to a direct name pointer in AcpiExResolveOperands */ - RetDesc->Reference.OpCode = AML_INDEX_OP; - RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; - RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value]; - } - - else - { - /* Object to be indexed is a Buffer */ - - if (IdxDesc->Number.Value >= ObjDesc->Buffer.Length) + switch (ObjDesc->Reference.Opcode) { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecIndex: Index value out of range\n")); - Status = AE_AML_BUFFER_LIMIT; - goto Cleanup; - } - - RetDesc->Reference.OpCode = AML_INDEX_OP; - RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - RetDesc->Reference.Object = ObjDesc; - RetDesc->Reference.Offset = (UINT32) IdxDesc->Number.Value; - - Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); - } - - -Cleanup: - - /* Always delete operands */ - - AcpiCmRemoveReference (ObjDesc); - AcpiCmRemoveReference (IdxDesc); - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiCmRemoveReference (ResDesc); - - if (RetDesc) - { - AcpiCmRemoveReference (RetDesc); - RetDesc = NULL; - } - } - - /* Set the return object and exit */ - - *ReturnDesc = RetDesc; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiAmlExecMatch - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Execute Match operator - * - * ACPI SPECIFICATION REFERENCES: - * DefMatch := MatchOp SearchPkg Opcode1 Operand1 - * Opcode2 Operand2 StartIndex - * Opcode1 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT - * Opcode2 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT - * Operand1 := TermArg=>Integer - * Operand2 := TermArg=>Integer - * SearchPkg := TermArg=>PackageObject - * StartIndex := TermArg=>Integer - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAmlExecMatch ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_OPERAND_OBJECT *PkgDesc; - ACPI_OPERAND_OBJECT *Op1Desc; - ACPI_OPERAND_OBJECT *V1Desc; - ACPI_OPERAND_OBJECT *Op2Desc; - ACPI_OPERAND_OBJECT *V2Desc; - ACPI_OPERAND_OBJECT *StartDesc; - ACPI_OPERAND_OBJECT *RetDesc = NULL; - ACPI_STATUS Status; - UINT32 Index; - UINT32 MatchValue = (UINT32) -1; - - - FUNCTION_TRACE ("AmlExecMatch"); - - - /* Resolve all operands */ - - Status = AcpiAmlResolveOperands (AML_MATCH_OP, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (AML_MATCH_OP), - 6, "after AcpiAmlResolveOperands"); - - /* Get all operands */ - - Status |= AcpiDsObjStackPopObject (&StartDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&V2Desc, WalkState); - Status |= AcpiDsObjStackPopObject (&Op2Desc, WalkState); - Status |= AcpiDsObjStackPopObject (&V1Desc, WalkState); - Status |= AcpiDsObjStackPopObject (&Op1Desc, WalkState); - Status |= AcpiDsObjStackPopObject (&PkgDesc, WalkState); - - if (ACPI_FAILURE (Status)) - { - /* Invalid parameters on object stack */ - - DEBUG_PRINT (ACPI_ERROR, - ("ExecMatch/AML_MATCH_OP: bad operand(s) (Status=%X)\n", - Status)); - - goto Cleanup; - } - - /* Validate match comparison sub-opcodes */ - - if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) || - (Op2Desc->Number.Value > MAX_MATCH_OPERATOR)) - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMatch: operation encoding out of range\n")); - Status = AE_AML_OPERAND_VALUE; - goto Cleanup; - } - - Index = (UINT32) StartDesc->Number.Value; - if (Index >= (UINT32) PkgDesc->Package.Count) - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMatch: start position value out of range\n")); - Status = AE_AML_PACKAGE_LIMIT; - goto Cleanup; - } - - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - - } - - /* - * Examine each element until a match is found. Within the loop, - * "continue" signifies that the current element does not match - * and the next should be examined. - * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", MatchValue will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. - */ - - for ( ; Index < PkgDesc->Package.Count; ++Index) - { - /* - * Treat any NULL or non-numeric elements as non-matching. - * TBD [Unhandled] - if an element is a Name, - * should we examine its value? - */ - if (!PkgDesc->Package.Elements[Index] || - ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type) - { - continue; - } - - /* - * Within these switch statements: - * "break" (exit from the switch) signifies a match; - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. - */ - switch (Op1Desc->Number.Value) - { - - case MATCH_MTR: /* always true */ + case AML_LOCAL_OP: + case AML_ARG_OP: + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Opcode, + ObjDesc->Reference.Offset, WalkState, + (ACPI_NAMESPACE_NODE **) ReturnDesc); break; - - case MATCH_MEQ: /* true if equal */ - - if (PkgDesc->Package.Elements[Index]->Number.Value - != V1Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MLE: /* true if less than or equal */ - - if (PkgDesc->Package.Elements[Index]->Number.Value - > V1Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MLT: /* true if less than */ - - if (PkgDesc->Package.Elements[Index]->Number.Value - >= V1Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MGE: /* true if greater than or equal */ - - if (PkgDesc->Package.Elements[Index]->Number.Value - < V1Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MGT: /* true if greater than */ - - if (PkgDesc->Package.Elements[Index]->Number.Value - <= V1Desc->Number.Value) - { - continue; - } - break; - - - default: /* undefined */ - - continue; - } - - - switch(Op2Desc->Number.Value) - { - - case MATCH_MTR: - - break; - - - case MATCH_MEQ: - - if (PkgDesc->Package.Elements[Index]->Number.Value - != V2Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MLE: - - if (PkgDesc->Package.Elements[Index]->Number.Value - > V2Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MLT: - - if (PkgDesc->Package.Elements[Index]->Number.Value - >= V2Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MGE: - - if (PkgDesc->Package.Elements[Index]->Number.Value - < V2Desc->Number.Value) - { - continue; - } - break; - - - case MATCH_MGT: - - if (PkgDesc->Package.Elements[Index]->Number.Value - <= V2Desc->Number.Value) - { - continue; - } - break; - - default: - continue; + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(Internal) Unknown Ref subtype %02x\n", + ObjDesc->Reference.Opcode)); + *ReturnDesc = NULL; + Status = AE_AML_INTERNAL; + goto Cleanup; } + break; - /* Match found: exit from loop */ - MatchValue = Index; + case ACPI_DESC_TYPE_NAMED: + + /* Must be a named object; Just return the Node */ + + *ReturnDesc = ObjDesc; + break; + + + default: + + *ReturnDesc = NULL; + Status = AE_TYPE; break; } - /* MatchValue is the return value */ - - RetDesc->Number.Value = MatchValue; - Cleanup: - /* Free the operands */ - - AcpiCmRemoveReference (StartDesc); - AcpiCmRemoveReference (V2Desc); - AcpiCmRemoveReference (Op2Desc); - AcpiCmRemoveReference (V1Desc); - AcpiCmRemoveReference (Op1Desc); - AcpiCmRemoveReference (PkgDesc); - - - /* Delete return object on error */ - - if (ACPI_FAILURE (Status) && - (RetDesc)) - { - AcpiCmRemoveReference (RetDesc); - RetDesc = NULL; - } - - - /* Set the return object and exit */ - - *ReturnDesc = RetDesc; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p Ref=%p\n", ObjDesc, *ReturnDesc)); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: *ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *ObjDesc1, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + NATIVE_CHAR *NewBuf; + UINT8 *EndTag1; + UINT8 *EndTag2; + ACPI_SIZE Length1; + ACPI_SIZE Length2; + + + ACPI_FUNCTION_TRACE ("ExConcatTemplate"); + + + /* Find the EndTags in each resource template */ + + EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1); + EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2); + if (!EndTag1 || !EndTag2) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Create a new buffer object for the result */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Allocate a new buffer for the result */ + + Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer); + Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) + + 2; /* Size of END_TAG */ + + NewBuf = ACPI_MEM_ALLOCATE (Length1 + Length2); + if (!NewBuf) + { + ACPI_REPORT_ERROR + (("ExConcatTemplate: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Copy the templates to the new descriptor */ + + ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1); + ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2); + + /* + * Point the return object to the new buffer + */ + ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; + ReturnDesc->Buffer.Length = Length1 + Length2; + + /* Compute the new checksum */ + + NewBuf[ReturnDesc->Buffer.Length - 1] = + AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer, + (ReturnDesc->Buffer.Length - 1)); + + /* Return the completed template descriptor */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); + + +Cleanup: + + AcpiUtRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: ObjDesc1 - First source object + * ObjDesc2 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *ObjDesc1, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 i; + ACPI_INTEGER ThisInteger; + ACPI_OPERAND_OBJECT *ReturnDesc; + NATIVE_CHAR *NewBuf; + UINT32 IntegerSize = sizeof (ACPI_INTEGER); + + + ACPI_FUNCTION_ENTRY (); + + + /* + * 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 (ObjDesc1->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 */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!ReturnDesc) + { + return (AE_NO_MEMORY); + } + + /* Need enough space for two integers */ + + ReturnDesc->Buffer.Length = IntegerSize * 2; + NewBuf = ACPI_MEM_CALLOCATE (ReturnDesc->Buffer.Length); + if (!NewBuf) + { + ACPI_REPORT_ERROR + (("ExDoConcatenate: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; + + /* Convert the first integer */ + + ThisInteger = ObjDesc1->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: + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!ReturnDesc) + { + return (AE_NO_MEMORY); + } + + /* Operand0 is string */ + + NewBuf = ACPI_MEM_ALLOCATE (ObjDesc1->String.Length + + ObjDesc2->String.Length + 1); + if (!NewBuf) + { + ACPI_REPORT_ERROR + (("ExDoConcatenate: String allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer); + ACPI_STRCPY (NewBuf + ObjDesc1->String.Length, + ObjDesc2->String.Pointer); + + /* Point the return object to the new string */ + + ReturnDesc->String.Pointer = NewBuf; + ReturnDesc->String.Length = ObjDesc1->String.Length + + ObjDesc2->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + /* Operand0 is a buffer */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!ReturnDesc) + { + return (AE_NO_MEMORY); + } + + NewBuf = ACPI_MEM_ALLOCATE (ObjDesc1->Buffer.Length + + ObjDesc2->Buffer.Length); + if (!NewBuf) + { + ACPI_REPORT_ERROR + (("ExDoConcatenate: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, + ObjDesc1->Buffer.Length); + ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer, + ObjDesc2->Buffer.Length); + + /* + * Point the return object to the new buffer + */ + + ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; + ReturnDesc->Buffer.Length = ObjDesc1->Buffer.Length + + ObjDesc2->Buffer.Length; + break; + + + default: + Status = AE_AML_INTERNAL; + ReturnDesc = NULL; + } + + *ActualReturnDesc = ReturnDesc; + return (AE_OK); + + +Cleanup: + + AcpiUtRemoveReference (ReturnDesc); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMathOp + * + * PARAMETERS: Opcode - AML opcode + * Operand0 - Integer operand #0 + * Operand1 - Integer operand #1 + * + * RETURN: Integer result of the operation + * + * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the + * math functions here is to prevent a lot of pointer dereferencing + * to obtain the operands. + * + ******************************************************************************/ + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Operand0, + ACPI_INTEGER Operand1) +{ + + + switch (Opcode) + { + case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */ + + return (Operand0 + Operand1); + + + case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */ + + return (Operand0 & Operand1); + + + case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */ + + return (~(Operand0 & Operand1)); + + + case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */ + + return (Operand0 | Operand1); + + + case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */ + + return (~(Operand0 | Operand1)); + + + case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */ + + return (Operand0 ^ Operand1); + + + case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */ + + return (Operand0 * Operand1); + + + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ + + return (Operand0 << Operand1); + + + case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ + + return (Operand0 >> Operand1); + + + case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */ + + return (Operand0 - Operand1); + + default: + + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalOp + * + * PARAMETERS: Opcode - AML opcode + * Operand0 - Integer operand #0 + * Operand1 - Integer operand #1 + * + * RETURN: TRUE/FALSE result of the operation + * + * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the + * functions here is to prevent a lot of pointer dereferencing + * to obtain the operands and to simplify the generation of the + * logical value. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Operand0 == Operand1); + * + ******************************************************************************/ + +BOOLEAN +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_INTEGER Operand0, + ACPI_INTEGER Operand1) +{ + + + switch (Opcode) + { + + case AML_LAND_OP: /* LAnd (Operand0, Operand1) */ + + if (Operand0 && Operand1) + { + return (TRUE); + } + break; + + + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + if (Operand0 == Operand1) + { + return (TRUE); + } + break; + + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Operand0 > Operand1) + { + return (TRUE); + } + break; + + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Operand0 < Operand1) + { + return (TRUE); + } + break; + + + case AML_LOR_OP: /* LOr (Operand0, Operand1) */ + + if (Operand0 || Operand1) + { + return (TRUE); + } + break; + } + + return (FALSE); +} + + diff --git a/source/components/executer/exnames.c b/source/components/executer/exnames.c index ae4d33763..baeafbeeb 100644 --- a/source/components/executer/exnames.c +++ b/source/components/executer/exnames.c @@ -1,7 +1,8 @@ /****************************************************************************** - * - * Module Name: isnames - interpreter/scanner name load/execute + * + * Module Name: exnames - interpreter/scanner name load/execute + * $Revision: 1.90 $ * *****************************************************************************/ @@ -9,8 +10,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * All rights reserved. * * 2. License * @@ -38,9 +39,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 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, @@ -48,11 +49,11 @@ * 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 + * 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. + * 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 @@ -86,7 +87,7 @@ * 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. + * 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 @@ -114,26 +115,28 @@ * *****************************************************************************/ -#define __ISNAMES_C__ +#define __EXNAMES_C__ -#include -#include -#include -#include +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" -#define _COMPONENT INTERPRETER - MODULE_NAME ("isnames"); +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exnames") -#define PKG_Type1 64 /* or 0x40 Max encoding size = 0x3F */ -#define PKG_Type2 16384 /* or 0x4000 Max encoding size = 0xFFF */ -#define PKG_Type3 4194304 /* or 0x400000 Max encoding size = 0xFFFFF */ -#define PKG_Type4 1073741824 /* or 0x40000000 Max encoding size = 0xFFFFFFF */ +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AmlAllocateNameString + * FUNCTION: AcpiExAllocateNameString * * PARAMETERS: PrefixCount - Count of parent levels. Special cases: * (-1) = root, 0 = none @@ -142,208 +145,95 @@ * RETURN: A pointer to the allocated string segment. This segment must * be deleted by the caller. * - * DESCRIPTION: Ensure allocated name string is long enough, - * and set up prefix if any. + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. * - ****************************************************************************/ + ******************************************************************************/ -char * -AmlAllocateNameString ( - INT32 PrefixCount, - INT32 NumNameSegs) +NATIVE_CHAR * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) { - char *TempPtr; - char *NameString; - INT32 SizeNeeded; + NATIVE_CHAR *TempPtr; + NATIVE_CHAR *NameString; + UINT32 SizeNeeded; + + ACPI_FUNCTION_TRACE ("ExAllocateNameString"); - FUNCTION_TRACE ("AmlAllocateNameString"); - - /* + /* * Allow room for all \ and ^ prefixes, all segments, and a MultiNamePrefix. + * Also, one byte for the null terminator. * This may actually be somewhat longer than needed. */ - - if (PrefixCount < 0) + if (PrefixCount == ACPI_UINT32_MAX) { - SizeNeeded = 1 /* root */ + (ACPI_NAME_SIZE * NumNameSegs) + 2; + /* Special case for root */ + + SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; } else { - SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2; + SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; } - /* + /* * Allocate a buffer for the name. * This buffer must be deleted by the caller! */ - - NameString = CmAllocate ((ACPI_SIZE) SizeNeeded); + NameString = ACPI_MEM_ALLOCATE (SizeNeeded); if (!NameString) { - /* Allocation failure */ - - REPORT_ERROR ("AmlAllocateNameString: name allocation failure"); - return_VALUE (NULL); + ACPI_REPORT_ERROR (("ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); + return_PTR (NULL); } TempPtr = NameString; /* Set up Root or Parent prefixes if needed */ - if (PrefixCount < 0) + if (PrefixCount == ACPI_UINT32_MAX) { - *TempPtr++ = AML_RootPrefix; + *TempPtr++ = AML_ROOT_PREFIX; } - else { while (PrefixCount--) { - *TempPtr++ = AML_ParentPrefix; + *TempPtr++ = AML_PARENT_PREFIX; } } /* Set up Dual or Multi prefixes if needed */ - + if (NumNameSegs > 2) { /* Set up multi prefixes */ - *TempPtr++ = AML_MultiNamePrefixOp; + *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; *TempPtr++ = (char) NumNameSegs; } - else if (2 == NumNameSegs) { /* Set up dual prefixes */ - *TempPtr++ = AML_DualNamePrefix; + *TempPtr++ = AML_DUAL_NAME_PREFIX; } - /* Terminate string following prefixes. AmlExecNameSegment() will append the segment(s) */ - + /* + * Terminate string following prefixes. AcpiExNameSegment() will + * append the segment(s) + */ *TempPtr = 0; - return_VALUE (NameString); + return_PTR (NameString); } - -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AmlGoodName - * - * PARAMETERS: Character - The character to be examined - * - * RETURN: 1 if Character may appear in a name, else 0 - * - * DESCRIPTION: Check for a printable character - * - ****************************************************************************/ - -BOOLEAN -AmlGoodName ( - UINT32 Name) -{ - char *NamePtr = (char *) &Name; - UINT32 i; - - - - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!((NamePtr[i] == '_') || - (NamePtr[i] >= 'A' && NamePtr[i] <= 'Z') || - (NamePtr[i] >= '0' && NamePtr[i] <= '9'))) - { - return FALSE; - } - } - - - return TRUE; -} - - -/***************************************************************************** - * - * FUNCTION: AmlGoodChar - * - * PARAMETERS: Character - The character to be examined - * - * RETURN: 1 if Character may appear in a name, else 0 - * - * DESCRIPTION: Check for a printable character - * - ****************************************************************************/ - -INT32 -AmlGoodChar ( - INT32 Character) -{ - - return ((Character == '_') || - (Character >= 'A' && Character <= 'Z') || - (Character >= '0' && Character <= '9')); -} - - -/***************************************************************************** - * - * FUNCTION: AmlDecodePackageLength - * - * PARAMETERS: LastPkgLen - latest value decoded by DoPkgLength() for - * most recently examined package or field - * - * RETURN: Number of bytes contained in package length encoding - * - * DESCRIPTION: Decodes the Package Length. Upper 2 bits are are used to - * tell if type 1, 2, 3, or 4. - * 0x3F = Max 1 byte encoding, - * 0xFFF = Max 2 byte encoding, - * 0xFFFFF = Max 3 Byte encoding, - * 0xFFFFFFFFF = Max 4 Byte encoding. - * - ****************************************************************************/ - -INT32 -AmlDecodePackageLength ( - INT32 LastPkgLen) -{ - INT32 NumBytes = 0; - - - FUNCTION_TRACE ("AmlDecodePackageLength"); - - - if (LastPkgLen < PKG_Type1) - { - NumBytes = 1; - } - - else if (LastPkgLen < PKG_Type2) - { - NumBytes = 2; - } - - else if (LastPkgLen < PKG_Type3) - { - NumBytes = 3; - } - - else if (LastPkgLen < PKG_Type4) - { - NumBytes = 4; - } - - return_VALUE (NumBytes); -} - - -/***************************************************************************** - * - * FUNCTION: AmlExecNameSegment + * FUNCTION: AcpiExNameSegment * * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) * @@ -351,38 +241,42 @@ AmlDecodePackageLength ( * * DESCRIPTION: Execute a name segment (4 bytes) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS -AmlExecNameSegment ( +AcpiExNameSegment ( UINT8 **InAmlAddress, - char *NameString) + NATIVE_CHAR *NameString) { UINT8 *AmlAddress = *InAmlAddress; ACPI_STATUS Status = AE_OK; - INT32 Index; - char CharBuf[5]; + UINT32 Index; + NATIVE_CHAR CharBuf[5]; - FUNCTION_TRACE ("AmlExecNameSegment"); + ACPI_FUNCTION_TRACE ("ExNameSegment"); - /* If first character is a digit, we aren't looking at a valid name segment */ - + /* + * If first character is a digit, then we know that we aren't looking at a + * valid name segment + */ CharBuf[0] = *AmlAddress; if ('0' <= CharBuf[0] && CharBuf[0] <= '9') { - DEBUG_PRINT (ACPI_ERROR, ("AmlExecNameSegment: leading digit: %c\n", CharBuf[0])); - return_ACPI_STATUS (AE_PENDING); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); } - DEBUG_PRINT (TRACE_LOAD, ("AmlExecNameSegment: Bytes from stream:\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); - for (Index = 4; Index > 0 && AmlGoodChar (*AmlAddress); --Index) + for (Index = 4; + (Index > 0) && (AcpiUtValidAcpiCharacter (*AmlAddress)); + Index--) { CharBuf[4 - Index] = *AmlAddress++; - DEBUG_PRINT (TRACE_LOAD, ("%c\n", CharBuf[4 - Index])); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[4 - Index])); } @@ -391,51 +285,49 @@ AmlExecNameSegment ( if (0 == Index) { /* Found 4 valid characters */ - + CharBuf[4] = '\0'; if (NameString) { - STRCAT (NameString, CharBuf); - DEBUG_PRINT (TRACE_NAMES, ("AmlExecNameSegment: Appended to - %s \n", NameString)); + ACPI_STRCAT (NameString, CharBuf); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Appended to - %s \n", NameString)); } - else { - DEBUG_PRINT (TRACE_NAMES, ("AmlExecNameSegment: No Name string - %s \n", CharBuf)); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "No Name string - %s \n", CharBuf)); } } - else if (4 == Index) { - /* + /* * First character was not a valid name character, * so we are looking at something other than a name. */ - DEBUG_PRINT (ACPI_INFO, ("AmlExecNameSegment: Leading char not alpha: %02Xh (not a name)\n", CharBuf[0])); - Status = AE_PENDING; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Leading character is not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; } - else { /* Segment started with one or more valid characters, but fewer than 4 */ - - Status = AE_AML_ERROR; - DEBUG_PRINT (ACPI_ERROR, ("AmlExecNameSegment: Bad char %02x in name, at %p\n", *AmlAddress, AmlAddress)); - } - DEBUG_PRINT (TRACE_EXEC, ("Leave AmlExecNameSegment %s \n", Gbl_ExceptionNames[Status])); + Status = AE_AML_BAD_NAME; + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n", + *AmlAddress, AmlAddress)); + } *InAmlAddress = AmlAddress; - return_ACPI_STATUS (Status); } - -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AmlGetNameString + * FUNCTION: AcpiExGetNameString * * PARAMETERS: DataType - Data type to be associated with this name * @@ -443,153 +335,160 @@ AmlExecNameSegment ( * * DESCRIPTION: Get a name, including any prefixes. * - ****************************************************************************/ - + ******************************************************************************/ ACPI_STATUS -AmlGetNameString ( - ACPI_OBJECT_TYPE DataType, +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, UINT8 *InAmlAddress, - char **OutNameString, - UINT32 *OutNameLength) + NATIVE_CHAR **OutNameString, + UINT32 *OutNameLength) { ACPI_STATUS Status = AE_OK; UINT8 *AmlAddress = InAmlAddress; - char *NameString = NULL; - INT32 NumSegments; - INT32 PrefixCount = 0; - UINT8 Prefix = 0; + NATIVE_CHAR *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + BOOLEAN HasPrefix = FALSE; - FUNCTION_TRACE_PTR ("AmlGetNameString", AmlAddress); + ACPI_FUNCTION_TRACE_PTR ("ExGetNameString", AmlAddress); - if (INTERNAL_TYPE_DefField == DataType || - INTERNAL_TYPE_BankField == DataType || - INTERNAL_TYPE_IndexField == DataType) - { - /* Disallow prefixes for types associated with field names */ + if (INTERNAL_TYPE_REGION_FIELD == DataType || + INTERNAL_TYPE_BANK_FIELD == DataType || + INTERNAL_TYPE_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with FieldUnit names */ - NameString = AmlAllocateNameString (0, 1); + NameString = AcpiExAllocateNameString (0, 1); if (!NameString) { Status = AE_NO_MEMORY; } else { - Status = AmlExecNameSegment (&AmlAddress, NameString); + Status = AcpiExNameSegment (&AmlAddress, NameString); } } - else - { - /* DataType is not a field name */ - + { + /* + * DataType is not a field name. + * Examine first character of name for root or parent prefix operators + */ switch (*AmlAddress) - { - /* Examine first character of name for root or parent prefix operators */ + { + case AML_ROOT_PREFIX: - case AML_RootPrefix: + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", AmlAddress)); - Prefix = *AmlAddress++; - DEBUG_PRINT (TRACE_LOAD, ("RootPrefix: %x\n", Prefix)); - - /* + /* * Remember that we have a RootPrefix -- - * see comment in AmlAllocateNameString() + * see comment in AcpiExAllocateNameString() */ - PrefixCount = -1; + AmlAddress++; + PrefixCount = ACPI_UINT32_MAX; + HasPrefix = TRUE; break; - case AML_ParentPrefix: + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ do { - Prefix = *AmlAddress++; - DEBUG_PRINT (TRACE_LOAD, ("ParentPrefix: %x\n", Prefix)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", AmlAddress)); - ++PrefixCount; + AmlAddress++; + PrefixCount++; - } while (*AmlAddress == AML_ParentPrefix); - + } while (*AmlAddress == AML_PARENT_PREFIX); + + HasPrefix = TRUE; break; default: + /* Not a prefix character */ + break; } + /* Examine first character of name for name segment prefix operator */ switch (*AmlAddress) { - /* Examine first character of name for name segment prefix operator */ - - case AML_DualNamePrefix: + case AML_DUAL_NAME_PREFIX: - Prefix = *AmlAddress++; - DEBUG_PRINT (TRACE_LOAD, ("DualNamePrefix: %x\n", Prefix)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", AmlAddress)); - NameString = AmlAllocateNameString (PrefixCount, 2); + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 2); if (!NameString) { Status = AE_NO_MEMORY; break; } - /* Ensure PrefixCount != 0 to remember processing a prefix */ - - PrefixCount += 2; + /* Indicate that we processed a prefix */ - if ((Status = AmlExecNameSegment (&AmlAddress, NameString)) == AE_OK) + HasPrefix = TRUE; + + Status = AcpiExNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) { - Status = AmlExecNameSegment (&AmlAddress, NameString); + Status = AcpiExNameSegment (&AmlAddress, NameString); } break; - case AML_MultiNamePrefixOp: + case AML_MULTI_NAME_PREFIX_OP: - Prefix = *AmlAddress++; - DEBUG_PRINT (TRACE_LOAD, ("MultiNamePrefix: %x\n", Prefix)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", AmlAddress)); - NumSegments = *AmlAddress++; /* fetch count of segments */ + /* Fetch count of segments remaining in name path */ - NameString = AmlAllocateNameString (PrefixCount, NumSegments); + AmlAddress++; + NumSegments = *AmlAddress; + + NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); if (!NameString) { Status = AE_NO_MEMORY; break; } - /* Ensure PrefixCount != 0 to remember processing a prefix */ - - PrefixCount += 2; + /* Indicate that we processed a prefix */ - while (NumSegments && (Status = AmlExecNameSegment (&AmlAddress, NameString)) == AE_OK) + AmlAddress++; + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == AE_OK) { - --NumSegments; + NumSegments--; } break; - case 0: - + case 0: + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ - - if (-1 == PrefixCount) + + if (PrefixCount == ACPI_UINT32_MAX) { - /* RootPrefix followed by NULL */ - - DEBUG_PRINT (TRACE_EXEC, - ("AmlDoName: NameSeg is \"\\\" followed by NULL\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "NameSeg is \"\\\" followed by NULL\n")); } - AmlAddress++; /* consume NULL byte */ - NameString = AmlAllocateNameString (PrefixCount, 0); + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 0); if (!NameString) { Status = AE_NO_MEMORY; @@ -603,31 +502,27 @@ AmlGetNameString ( /* Name segment string */ - NameString = AmlAllocateNameString (PrefixCount, 1); + NameString = AcpiExAllocateNameString (PrefixCount, 1); if (!NameString) { Status = AE_NO_MEMORY; break; } - Status = AmlExecNameSegment (&AmlAddress, NameString); + Status = AcpiExNameSegment (&AmlAddress, NameString); break; - - } /* Switch (PeekOp ()) */ + } } - - if (AE_PENDING == Status && PrefixCount != 0) + if (AE_CTRL_PENDING == Status && HasPrefix) { /* Ran out of segments after processing a prefix */ - DEBUG_PRINT (ACPI_ERROR, ("AmlDoName: Malformed Name\n")); - REPORT_ERROR ("Ran out of segments after processing a prefix"); - - Status = AE_AML_ERROR; + ACPI_REPORT_ERROR ( + ("ExDoName: Malformed Name at %p\n", NameString)); + Status = AE_AML_BAD_NAME; } - *OutNameString = NameString; *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); @@ -635,5 +530,3 @@ AmlGetNameString ( } - - diff --git a/source/components/executer/exoparg1.c b/source/components/executer/exoparg1.c index dc555278e..f011eb4ad 100644 --- a/source/components/executer/exoparg1.c +++ b/source/components/executer/exoparg1.c @@ -1,8 +1,8 @@ /****************************************************************************** * - * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators - * $Revision: 1.84 $ + * Module Name: exoparg1 - AML execution - opcodes with 1 argument + * $Revision: 1.134 $ * *****************************************************************************/ @@ -10,8 +10,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * All rights reserved. * * 2. License * @@ -115,7 +115,7 @@ * *****************************************************************************/ -#define __AMMONAD_C__ +#define __EXOPARG1_C__ #include "acpi.h" #include "acparser.h" @@ -125,104 +125,38 @@ #include "acnamesp.h" -#define _COMPONENT INTERPRETER - MODULE_NAME ("ammonad") +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg1") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ /******************************************************************************* * - * FUNCTION: AcpiAmlGetObjectReference + * FUNCTION: AcpiExOpcode_1A_0T_0R * - * PARAMETERS: ObjDesc - Create a reference to this object - * RetDesc - Where to store the reference - * - * RETURN: Status - * - * DESCRIPTION: Obtain and return a "reference" to the target object - * Common code for the RefOfOp and the CondRefOfOp. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiAmlGetObjectReference ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **RetDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE_PTR ("AmlGetObjectReference", ObjDesc); - - - if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) - { - if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE) - { - *RetDesc = NULL; - Status = AE_TYPE; - goto Cleanup; - } - - /* - * Not a Name -- an indirect name pointer would have - * been converted to a direct name pointer in AcpiAmlResolveOperands - */ - switch (ObjDesc->Reference.OpCode) - { - case AML_LOCAL_OP: - - *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_LOCAL, - (ObjDesc->Reference.Offset), WalkState); - break; - - - case AML_ARG_OP: - - *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_ARG, - (ObjDesc->Reference.Offset), WalkState); - break; - - - default: - - DEBUG_PRINT (ACPI_ERROR, - ("AmlGetObjectReference: (Internal) Unknown Ref subtype %02x\n", - ObjDesc->Reference.OpCode)); - *RetDesc = NULL; - Status = AE_AML_INTERNAL; - goto Cleanup; - } - - } - - else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) - { - /* Must be a named object; Just return the Node */ - - *RetDesc = ObjDesc; - } - - else - { - *RetDesc = NULL; - Status = AE_TYPE; - } - - -Cleanup: - - DEBUG_PRINT (TRACE_EXEC, - ("AmlGetObjectReference: Obj=%p Ref=%p\n", ObjDesc, *RetDesc)); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiAmlExecMonadic1 - * - * PARAMETERS: Opcode - The opcode to be executed + * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * @@ -232,610 +166,536 @@ Cleanup: ******************************************************************************/ ACPI_STATUS -AcpiAmlExecMonadic1 ( - UINT16 Opcode, +AcpiExOpcode_1A_0T_0R ( ACPI_WALK_STATE *WalkState) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE_PTR ("AmlExecMonadic1", WALK_OPERANDS); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); - /* Resolve all operands */ + /* Examine the AML opcode */ - Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (Opcode), - 1, "after AcpiAmlResolveOperands"); - - /* Get all operands */ - - Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); - if (ACPI_FAILURE (Status)) + switch (WalkState->Opcode) { - DEBUG_PRINT (ACPI_ERROR, - ("ExecMonadic1/%s: bad operand(s) (Status=%X)\n", - AcpiPsGetOpcodeName (Opcode), Status)); + case AML_RELEASE_OP: /* Release (MutexObject) */ - goto Cleanup; - } - - - /* Examine the opcode */ - - switch (Opcode) - { - - /* DefRelease := ReleaseOp MutexObject */ - - case AML_RELEASE_OP: - - Status = AcpiAmlSystemReleaseMutex (ObjDesc); + Status = AcpiExReleaseMutex (Operand[0], WalkState); break; - /* DefReset := ResetOp AcpiEventObject */ + case AML_RESET_OP: /* Reset (EventObject) */ - case AML_RESET_OP: - - Status = AcpiAmlSystemResetEvent (ObjDesc); + Status = AcpiExSystemResetEvent (Operand[0]); break; - /* DefSignal := SignalOp AcpiEventObject */ + case AML_SIGNAL_OP: /* Signal (EventObject) */ - case AML_SIGNAL_OP: - - Status = AcpiAmlSystemSignalEvent (ObjDesc); + Status = AcpiExSystemSignalEvent (Operand[0]); break; - /* DefSleep := SleepOp MsecTime */ + case AML_SLEEP_OP: /* Sleep (MsecTime) */ - case AML_SLEEP_OP: - - AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Number.Value); + Status = AcpiExSystemDoSuspend ((UINT32) Operand[0]->Integer.Value); break; - /* DefStall := StallOp UsecTime */ + case AML_STALL_OP: /* Stall (UsecTime) */ - case AML_STALL_OP: - - AcpiAmlSystemDoStall ((UINT32) ObjDesc->Number.Value); + Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); break; - /* Unknown opcode */ + case AML_UNLOAD_OP: /* Unload (Handle) */ - default: + Status = AcpiExUnloadTable (Operand[0]); + break; - REPORT_ERROR (("AcpiAmlExecMonadic1: Unknown monadic opcode %X\n", - Opcode)); + + default: /* Unknown opcode */ + + ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_0R: Unknown opcode %X\n", + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; - - } /* switch */ - - -Cleanup: - - /* Always delete the operand */ - - AcpiCmRemoveReference (ObjDesc); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiAmlExecMonadic2R - * - * PARAMETERS: Opcode - The opcode to be executed - * - * RETURN: Status - * - * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and - * result operand on operand stack - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAmlExecMonadic2R ( - UINT16 Opcode, - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *ResDesc; - ACPI_OPERAND_OBJECT *RetDesc = NULL; - ACPI_OPERAND_OBJECT *RetDesc2 = NULL; - UINT32 ResVal; - ACPI_STATUS Status; - UINT32 d0; - UINT32 d1; - UINT32 d2; - UINT32 d3; - - - FUNCTION_TRACE_PTR ("AmlExecMonadic2R", WALK_OPERANDS); - - - /* Resolve all operands */ - - Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (Opcode), - 2, "after AcpiAmlResolveOperands"); - - /* Get all operands */ - - Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); - Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("ExecMonadic2R/%s: bad operand(s) (Status=%X)\n", - AcpiPsGetOpcodeName (Opcode), Status)); - - goto Cleanup; } - - /* Create a return object of type NUMBER for most opcodes */ - - switch (Opcode) - { - case AML_BIT_NOT_OP: - case AML_FIND_SET_LEFT_BIT_OP: - case AML_FIND_SET_RIGHT_BIT_OP: - case AML_FROM_BCD_OP: - case AML_TO_BCD_OP: - case AML_COND_REF_OF_OP: - - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - break; - } - - - switch (Opcode) - { - /* DefNot := NotOp Operand Result */ - - case AML_BIT_NOT_OP: - - RetDesc->Number.Value = ~ObjDesc->Number.Value; - break; - - - /* DefFindSetLeftBit := FindSetLeftBitOp Operand Result */ - - case AML_FIND_SET_LEFT_BIT_OP: - - RetDesc->Number.Value = ObjDesc->Number.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) - { - RetDesc->Number.Value >>= 1; - } - - RetDesc->Number.Value = ResVal; - break; - - - /* DefFindSetRightBit := FindSetRightBitOp Operand Result */ - - case AML_FIND_SET_RIGHT_BIT_OP: - - RetDesc->Number.Value = ObjDesc->Number.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) - { - RetDesc->Number.Value <<= 1; - } - - /* Since returns must be 1-based, subtract from 33 (65) */ - - RetDesc->Number.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal; - break; - - - /* DefFromBDC := FromBCDOp BCDValue Result */ - - case AML_FROM_BCD_OP: - - /* TBD: for ACPI 2.0, expand to 64 bits */ - - d0 = (UINT32) (ObjDesc->Number.Value & 15); - d1 = (UINT32) (ObjDesc->Number.Value >> 4 & 15); - d2 = (UINT32) (ObjDesc->Number.Value >> 8 & 15); - d3 = (UINT32) (ObjDesc->Number.Value >> 12 & 15); - - if (d0 > 9 || d1 > 9 || d2 > 9 || d3 > 9) - { - DEBUG_PRINT (ACPI_ERROR, - ("Monadic2R/FromBCDOp: BCD digit too large %d %d %d %d\n", - d3, d2, d1, d0)); - Status = AE_AML_NUMERIC_OVERFLOW; - goto Cleanup; - } - - RetDesc->Number.Value = d0 + d1 * 10 + d2 * 100 + d3 * 1000; - break; - - - /* DefToBDC := ToBCDOp Operand Result */ - - case AML_TO_BCD_OP: - - /* TBD: for ACPI 2.0, expand to 64 bits */ - - if (ObjDesc->Number.Value > 9999) - { - DEBUG_PRINT (ACPI_ERROR, ("Monadic2R/ToBCDOp: BCD overflow: %d\n", - ObjDesc->Number.Value)); - Status = AE_AML_NUMERIC_OVERFLOW; - goto Cleanup; - } - - RetDesc->Number.Value - = ACPI_MODULO (ObjDesc->Number.Value, 10) - + (ACPI_MODULO (ACPI_DIVIDE (ObjDesc->Number.Value, 10), 10) << 4) - + (ACPI_MODULO (ACPI_DIVIDE (ObjDesc->Number.Value, 100), 10) << 8) - + (ACPI_MODULO (ACPI_DIVIDE (ObjDesc->Number.Value, 1000), 10) << 12); - - break; - - - /* DefCondRefOf := CondRefOfOp SourceObject Result */ - - case AML_COND_REF_OF_OP: - - /* - * This op is a little strange because the internal return value is - * different than the return value stored in the result descriptor - * (There are really two return values) - */ - - if ((ACPI_NAMESPACE_NODE *) ObjDesc == AcpiGbl_RootNode) - { - /* - * This means that the object does not exist in the namespace, - * return FALSE - */ - - RetDesc->Number.Value = 0; - - /* - * Must delete the result descriptor since there is no reference - * being returned - */ - - AcpiCmRemoveReference (ResDesc); - goto Cleanup; - } - - /* Get the object reference and store it */ - - Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc2, WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiAmlExecStore (RetDesc2, ResDesc, WalkState); - - /* The object exists in the namespace, return TRUE */ - - RetDesc->Number.Value = ACPI_INTEGER_MAX - goto Cleanup; - break; - - - case AML_STORE_OP: - - /* - * A store operand is typically a number, string, buffer or lvalue - * TBD: [Unhandled] What about a store to a package? - */ - - /* - * Do the store, and be careful about deleting the source object, - * since the object itself may have been stored. - */ - - Status = AcpiAmlExecStore (ObjDesc, ResDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - /* On failure, just delete the ObjDesc */ - - AcpiCmRemoveReference (ObjDesc); - } - - else - { - /* - * Normally, we would remove a reference on the ObjDesc parameter; - * But since it is being used as the internal return object - * (meaning we would normally increment it), the two cancel out, - * and we simply don't do anything. - */ - *ReturnDesc = ObjDesc; - } - - ObjDesc = NULL; - return_ACPI_STATUS (Status); - - break; - - - case AML_DEBUG_OP: - - /* Reference, returning an Reference */ - - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMonadic2R: DebugOp should never get here!\n")); - return_ACPI_STATUS (AE_OK); - break; - - - /* - * These are obsolete opcodes - */ - - /* DefShiftLeftBit := ShiftLeftBitOp Source BitNum */ - /* DefShiftRightBit := ShiftRightBitOp Source BitNum */ - - case AML_SHIFT_LEFT_BIT_OP: - case AML_SHIFT_RIGHT_BIT_OP: - - DEBUG_PRINT (ACPI_ERROR, ("AmlExecMonadic2R: %s unimplemented\n", - AcpiPsGetOpcodeName (Opcode))); - Status = AE_SUPPORT; - goto Cleanup; - break; - - - default: - - REPORT_ERROR (("AcpiAmlExecMonadic2R: Unknown monadic opcode %X\n", - Opcode)); - Status = AE_AML_BAD_OPCODE; - goto Cleanup; - } - - - Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); - - -Cleanup: - /* Always delete the operand object */ - - AcpiCmRemoveReference (ObjDesc); - - /* Delete return object(s) on error */ - - if (ACPI_FAILURE (Status)) - { - AcpiCmRemoveReference (ResDesc); /* Result descriptor */ - if (RetDesc) - { - AcpiCmRemoveReference (RetDesc); - RetDesc = NULL; - } - } - - /* Set the return object and exit */ - - *ReturnDesc = RetDesc; return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiAmlExecMonadic2 + * FUNCTION: AcpiExOpcode_1A_1T_0R * - * PARAMETERS: Opcode - The opcode to be executed + * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * - * DESCRIPTION: Execute Type 2 monadic operator with numeric operand: - * DerefOfOp, RefOfOp, SizeOfOp, TypeOp, IncrementOp, - * DecrementOp, LNotOp, + * DESCRIPTION: Execute opcode with one argument, one target, and no + * return value. * ******************************************************************************/ ACPI_STATUS -AcpiAmlExecMonadic2 ( - UINT16 Opcode, - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *TmpDesc; - ACPI_OPERAND_OBJECT *RetDesc = NULL; - ACPI_STATUS ResolveStatus; - ACPI_STATUS Status; - UINT32 Type; - ACPI_INTEGER Value; + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - FUNCTION_TRACE_PTR ("AmlExecMonadic2", WALK_OPERANDS); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); - /* Attempt to resolve the operands */ + /* Examine the AML opcode */ - ResolveStatus = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (Opcode), - 1, "after AcpiAmlResolveOperands"); - - /* Always get all operands */ - - Status = AcpiDsObjStackPopObject (&ObjDesc, WalkState); - - - /* Now we can check the status codes */ - - if (ACPI_FAILURE (ResolveStatus)) + switch (WalkState->Opcode) { - DEBUG_PRINT (ACPI_ERROR, - ("ExecMonadic2[%s]: Could not resolve operands, %s\n", - AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (ResolveStatus))); + case AML_LOAD_OP: - goto Cleanup; - } + Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); + break; - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("ExecMonadic2[%s]: Bad operand(s), %s\n", - AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (Status))); + default: /* Unknown opcode */ + ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_0R: Unknown opcode %X\n", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; goto Cleanup; } - /* Get the operand and decode the opcode */ +Cleanup: + + return_ACPI_STATUS (Status); +} - switch (Opcode) +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and a + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + UINT32 Temp32; + UINT32 i; + UINT32 j; + ACPI_INTEGER Digit; + + + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Create a return object of type Integer for most opcodes */ + + switch (WalkState->Opcode) { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: - /* DefLNot := LNotOp Operand */ - - case AML_LNOT_OP: - - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); - if (!RetDesc) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = !ObjDesc->Number.Value; + break; + } + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ + + ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; break; - /* DefDecrement := DecrementOp Target */ - /* DefIncrement := IncrementOp Target */ + case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ - case AML_DECREMENT_OP: - case AML_INCREMENT_OP: + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; /* - * Since we are expecting an Reference on the top of the stack, it - * can be either an Node or an internal object. - * - * TBD: [Future] This may be the prototype code for all cases where - * an Reference is expected!! 10/99 + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. */ - - if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) - { - RetDesc = ObjDesc; - } - - else - { - /* - * Duplicate the Reference in a new object so that we can resolve it - * without destroying the original Reference object - */ - - RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!RetDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - RetDesc->Reference.OpCode = ObjDesc->Reference.OpCode; - RetDesc->Reference.Offset = ObjDesc->Reference.Offset; - RetDesc->Reference.Object = ObjDesc->Reference.Object; + for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value >>= 1; } + ReturnDesc->Integer.Value = Temp32; + break; + + + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; /* - * Convert the RetDesc Reference to a Number - * (This deletes the original RetDesc) + * The Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. */ + for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value <<= 1; + } - Status = AcpiAmlResolveOperands (AML_LNOT_OP, &RetDesc, WalkState); + /* Since the bit position is one-based, subtract from 33 (65) */ + + ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + break; + + + case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ + + /* + * The 64-bit ACPI integer can hold 16 4-bit BCD integers + */ + ReturnDesc->Integer.Value = 0; + for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) + { + /* Get one BCD digit */ + + Digit = (ACPI_INTEGER) ((Operand[0]->Integer.Value >> (i * 4)) & 0xF); + + /* Check the range of the digit */ + + if (Digit > 9) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n", + (UINT32) Digit)); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + if (Digit > 0) + { + /* Sum into the result with the appropriate power of 10 */ + + for (j = 0; j < i; j++) + { + Digit *= 10; + } + + ReturnDesc->Integer.Value += Digit; + } + } + break; + + + case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ + + if (Operand[0]->Integer.Value > ACPI_MAX_BCD_VALUE) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n", + ACPI_HIDWORD(Operand[0]->Integer.Value), + ACPI_LODWORD(Operand[0]->Integer.Value))); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + ReturnDesc->Integer.Value = 0; + for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) + { + /* Divide by nth factor of 10 */ + + Temp32 = 0; + Digit = Operand[0]->Integer.Value; + for (j = 0; j < i; j++) + { + AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32); + } + + /* Create the BCD digit from the remainder above */ + + if (Digit > 0) + { + ReturnDesc->Integer.Value += ((ACPI_INTEGER) Temp32 << (i * 4)); + } + } + break; + + + case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + ReturnDesc->Integer.Value = 0; + + /* + * Must delete the result descriptor since there is no reference + * being returned + */ + AcpiUtRemoveReference (Operand[1]); + goto Cleanup; + } + + /* Get the object reference and store it */ + + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { - DEBUG_PRINT (ACPI_ERROR, - ("ExecMonadic2/%s: bad operand(s) (Status=%X)\n", - AcpiPsGetOpcodeName (Opcode), Status)); + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); + + /* The object exists in the namespace, return TRUE */ + + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + goto Cleanup; + + + case AML_STORE_OP: /* Store (Source, Target) */ + + /* + * A store operand is typically a number, string, buffer or lvalue + * Be careful about deleting the source object, + * since the object itself may have been stored. + */ + Status = AcpiExStore (Operand[0], Operand[1], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Normally, we would remove a reference on the Operand[0] parameter; + * But since it is being used as the internal return object + * (meaning we would normally increment it), the two cancel out, + * and we simply don't do anything. + */ + WalkState->ResultObj = Operand[0]; + WalkState->Operands[0] = NULL; /* Prevent deletion */ + return_ACPI_STATUS (Status); + + + /* + * ACPI 2.0 Opcodes + */ + case AML_COPY_OP: /* Copy (Source, Target) */ + + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, WalkState); + break; + + + case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 10, ACPI_UINT32_MAX, WalkState); + break; + + + case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 16, ACPI_UINT32_MAX, WalkState); + break; + + + case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ + + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc, WalkState); + break; + + + case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ + + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, WalkState); + break; + + + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + + /* + * These are two obsolete opcodes + */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", + AcpiPsGetOpcodeName (WalkState->Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + + + default: /* Unknown opcode */ + + ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_1R: Unknown opcode %X\n", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* + * Store the return value computed above into the target object + */ + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + + +Cleanup: + + WalkState->ResultObj = ReturnDesc; + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *TempDesc; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 Type; + ACPI_INTEGER Value; + + + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LNOT_OP: /* LNot (Operand) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = !Operand[0]->Integer.Value; + break; + + + case AML_DECREMENT_OP: /* Decrement (Operand) */ + case AML_INCREMENT_OP: /* Increment (Operand) */ + + /* + * Since we are expecting a Reference operand, it + * can be either a NS Node or an internal object. + */ + ReturnDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_INTERNAL) + { + /* Internal reference object - prevent deletion */ + + AcpiUtAddReference (ReturnDesc); + } + + /* + * Convert the ReturnDesc Reference to a Number + * (This removes a reference on the ReturnDesc object) + */ + Status = AcpiExResolveOperands (AML_LNOT_OP, &ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", + AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status))); goto Cleanup; } - /* Do the actual increment or decrement */ - - if (AML_INCREMENT_OP == Opcode) + /* + * ReturnDesc is now guaranteed to be an Integer object + * Do the actual increment or decrement + */ + if (AML_INCREMENT_OP == WalkState->Opcode) { - RetDesc->Number.Value++; + ReturnDesc->Integer.Value++; } else { - RetDesc->Number.Value--; + ReturnDesc->Integer.Value--; } /* Store the result back in the original descriptor */ - Status = AcpiAmlExecStore (RetDesc, ObjDesc, WalkState); - - /* Objdesc was just deleted (because it is an Reference) */ - - ObjDesc = NULL; - + Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; - /* DefObjectType := ObjectTypeOp SourceObject */ + case AML_TYPE_OP: /* ObjectType (SourceObject) */ - case AML_TYPE_OP: - - if (INTERNAL_TYPE_REFERENCE == ObjDesc->Common.Type) + if (INTERNAL_TYPE_REFERENCE == Operand[0]->Common.Type) { /* * Not a Name -- an indirect name pointer would have * been converted to a direct name pointer in ResolveOperands */ - switch (ObjDesc->Reference.OpCode) + switch (Operand[0]->Reference.Opcode) { case AML_ZERO_OP: case AML_ONE_OP: case AML_ONES_OP: + case AML_REVISION_OP: - /* Constants are of type Number */ + /* Constants are of type Integer */ - Type = ACPI_TYPE_NUMBER; + Type = ACPI_TYPE_INTEGER; break; case AML_DEBUG_OP: - /* Per 1.0b spec, Debug object is of type DebugObject */ + /* The Debug Object is of type "DebugObject" */ Type = ACPI_TYPE_DEBUG_OBJECT; break; @@ -845,7 +705,7 @@ AcpiAmlExecMonadic2 ( /* Get the type of this reference (index into another object) */ - Type = ObjDesc->Reference.TargetType; + Type = Operand[0]->Reference.TargetType; if (Type == ACPI_TYPE_PACKAGE) { /* @@ -853,102 +713,96 @@ AcpiAmlExecMonadic2 ( * of the individual package element that is referenced by * the index. */ - Type = (*(ObjDesc->Reference.Where))->Common.Type; + Type = (*(Operand[0]->Reference.Where))->Common.Type; } - break; case AML_LOCAL_OP: - - Type = AcpiDsMethodDataGetType (MTH_TYPE_LOCAL, - (ObjDesc->Reference.Offset), WalkState); - break; - - case AML_ARG_OP: - Type = AcpiDsMethodDataGetType (MTH_TYPE_ARG, - (ObjDesc->Reference.Offset), WalkState); + Type = AcpiDsMethodDataGetType (Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, WalkState); break; default: - REPORT_ERROR (("AcpiAmlExecMonadic2/TypeOp: Internal error - Unknown Reference subtype %X\n", - ObjDesc->Reference.OpCode)); + ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_1R/TypeOp: Internal error - Unknown Reference subtype %X\n", + Operand[0]->Reference.Opcode)); Status = AE_AML_INTERNAL; goto Cleanup; } } - else { /* * It's not a Reference, so it must be a direct name pointer. */ - Type = AcpiNsGetType ((ACPI_HANDLE) ObjDesc); + Type = AcpiNsGetType ((ACPI_NAMESPACE_NODE *) Operand[0]); + + /* Convert internal types to external types */ + + switch (Type) + { + case INTERNAL_TYPE_REGION_FIELD: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + Type = ACPI_TYPE_FIELD_UNIT; + } + } /* Allocate a descriptor to hold the type. */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); - if (!RetDesc) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = Type; + ReturnDesc->Integer.Value = Type; break; - /* DefSizeOf := SizeOfOp SourceObject */ + case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ - case AML_SIZE_OF_OP: - - if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) { - ObjDesc = AcpiNsGetAttachedObject (ObjDesc); + TempDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); } - if (!ObjDesc) + if (!TempDesc) { Value = 0; } - else { - switch (ObjDesc->Common.Type) + /* + * Type is guaranteed to be a buffer, string, or package at this + * point (even if the original operand was an object reference, it + * will be resolved and typechecked during operand resolution.) + */ + switch (TempDesc->Common.Type) { - case ACPI_TYPE_BUFFER: - - Value = ObjDesc->Buffer.Length; + Value = TempDesc->Buffer.Length; break; - case ACPI_TYPE_STRING: - - Value = ObjDesc->String.Length; + Value = TempDesc->String.Length; break; - case ACPI_TYPE_PACKAGE: - - Value = ObjDesc->Package.Count; - break; - - case INTERNAL_TYPE_REFERENCE: - - Value = 4; + Value = TempDesc->Package.Count; break; default: - - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMonadic2: Not Buf/Str/Pkg - found type %X\n", - ObjDesc->Common.Type)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n", + AcpiUtGetTypeName (TempDesc->Common.Type))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } @@ -958,23 +812,20 @@ AcpiAmlExecMonadic2 ( * Now that we have the size of the object, create a result * object to hold the value */ - - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); - if (!RetDesc) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - RetDesc->Number.Value = Value; + ReturnDesc->Integer.Value = Value; break; - /* DefRefOf := RefOfOp SourceObject */ + case AML_REF_OF_OP: /* RefOf (SourceObject) */ - case AML_REF_OF_OP: - - Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc, WalkState); + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -982,101 +833,101 @@ AcpiAmlExecMonadic2 ( break; - /* DefDerefOf := DerefOfOp ObjReference */ + case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ - case AML_DEREF_OF_OP: + /* Check for a method local or argument, or standalone String */ - - /* Check for a method local or argument */ - - if (!VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) { - /* - * Must resolve/dereference the local/arg reference first - */ - switch (ObjDesc->Reference.OpCode) + switch (ACPI_GET_OBJECT_TYPE (Operand[0])) { - /* Set ObjDesc to the value of the local/arg */ - - case AML_LOCAL_OP: - - AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, - (ObjDesc->Reference.Offset), WalkState, &TmpDesc); - + case INTERNAL_TYPE_REFERENCE: /* - * Delete our reference to the input object and - * point to the object just retrieved + * This is a DerefOf (LocalX | ArgX) + * + * Must resolve/dereference the local/arg reference first */ - AcpiCmRemoveReference (ObjDesc); - ObjDesc = TmpDesc; + switch (Operand[0]->Reference.Opcode) + { + case AML_LOCAL_OP: + case AML_ARG_OP: + + /* Set Operand[0] to the value of the local/arg */ + + AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, WalkState, &TempDesc); + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + default: + + /* Must be an Index op - handled below */ + break; + } break; - case AML_ARG_OP: - - AcpiDsMethodDataGetValue (MTH_TYPE_ARG, - (ObjDesc->Reference.Offset), WalkState, &TmpDesc); + case ACPI_TYPE_STRING: /* - * Delete our reference to the input object and - * point to the object just retrieved + * This is a DerefOf (String). The string is a reference to a named ACPI object. + * + * 1) Find the owning Node + * 2) Dereference the node to an actual object. Could be a Field, so we nee + * to resolve the node to a value. */ - AcpiCmRemoveReference (ObjDesc); - ObjDesc = TmpDesc; - break; + Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, WalkState->ScopeInfo->Scope.Node, + ACPI_NS_SEARCH_PARENT, (ACPI_NAMESPACE_NODE **) &ReturnDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExResolveNodeToValue ((ACPI_NAMESPACE_NODE **) &ReturnDesc, WalkState); + goto Cleanup; + default: - /* Index op - handled below */ - break; + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; } } + /* Operand[0] may have changed from the code above */ - /* ObjDesc may have changed from the code above */ - - if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) { - /* Get the actual object from the Node (This is the dereference) */ - - RetDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object; - - /* Returning a pointer to the object, add another reference! */ - - AcpiCmAddReference (RetDesc); + /* + * This is a DerefOf (ObjectReference) + * Get the actual object from the Node (This is the dereference). + * -- This case may only happen when a LocalX or ArgX is dereferenced above. + */ + ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); } - else { /* - * This must be a reference object produced by the Index - * ASL operation -- check internal opcode + * This must be a reference object produced by either the Index() or + * RefOf() operator */ - - if ((ObjDesc->Reference.OpCode != AML_INDEX_OP) && - (ObjDesc->Reference.OpCode != AML_REF_OF_OP)) - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMonadic2: DerefOf, invalid obj ref %p\n", - ObjDesc)); - - Status = AE_TYPE; - goto Cleanup; - } - - - switch (ObjDesc->Reference.OpCode) + switch (Operand[0]->Reference.Opcode) { case AML_INDEX_OP: /* - * Supported target types for the Index operator are - * 1) A Buffer - * 2) A Package + * The target type for the Index operator must be + * either a Buffer or a Package */ - - if (ObjDesc->Reference.TargetType == ACPI_TYPE_BUFFER_FIELD) + switch (Operand[0]->Reference.TargetType) { + case ACPI_TYPE_BUFFER_FIELD: /* * The target is a buffer, we must create a new object that * contains one element of the buffer, the element pointed @@ -1086,79 +937,84 @@ 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); - if (!RetDesc) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - TmpDesc = ObjDesc->Reference.Object; - RetDesc->Number.Value = - TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset]; - - /* TBD: [Investigate] (see below) Don't add an additional - * ref! + /* + * Since we are returning the value of the buffer at the + * indexed location, we don't need to add an additional + * reference to the buffer itself. */ - } + TempDesc = Operand[0]->Reference.Object; + ReturnDesc->Integer.Value = + TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset]; + break; + + + case ACPI_TYPE_PACKAGE: - else if (ObjDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) - { /* * The target is a package, we want to return the referenced * element of the package. We must add another reference to * this object, however. */ - - RetDesc = *(ObjDesc->Reference.Where); - if (!RetDesc) + ReturnDesc = *(Operand[0]->Reference.Where); + if (!ReturnDesc) { /* * We can't return a NULL dereferenced value. This is * an uninitialized package element and is thus a * severe error. */ - - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMonadic2: DerefOf, NULL package element obj %p\n", - ObjDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n", + Operand[0])); Status = AE_AML_UNINITIALIZED_ELEMENT; goto Cleanup; } - AcpiCmAddReference (RetDesc); - } + AcpiUtAddReference (ReturnDesc); + break; - else - { - DEBUG_PRINT (ACPI_ERROR, - ("AmlExecMonadic2: DerefOf, Unknown TargetType %X in obj %p\n", - ObjDesc->Reference.TargetType, ObjDesc)); + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index TargetType %X in obj %p\n", + Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } - break; case AML_REF_OF_OP: - RetDesc = ObjDesc->Reference.Object; + ReturnDesc = Operand[0]->Reference.Object; /* Add another reference to the object! */ - AcpiCmAddReference (RetDesc); + AcpiUtAddReference (ReturnDesc); break; + + + default: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n", + Operand[0], Operand[0]->Reference.Opcode)); + + Status = AE_TYPE; + goto Cleanup; } } - break; default: - REPORT_ERROR (("AcpiAmlExecMonadic2: Unknown monadic opcode %X\n", - Opcode)); + ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_1R: Unknown opcode %X\n", + WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } @@ -1166,21 +1022,14 @@ AcpiAmlExecMonadic2 ( Cleanup: - if (ObjDesc) - { - AcpiCmRemoveReference (ObjDesc); - } - /* Delete return object on error */ - if (ACPI_FAILURE (Status) && - (RetDesc)) + if (ACPI_FAILURE (Status)) { - AcpiCmRemoveReference (RetDesc); - RetDesc = NULL; + AcpiUtRemoveReference (ReturnDesc); } - *ReturnDesc = RetDesc; + WalkState->ResultObj = ReturnDesc; return_ACPI_STATUS (Status); } diff --git a/source/components/executer/exoparg3.c b/source/components/executer/exoparg3.c index eb9d15982..6466efac5 100644 --- a/source/components/executer/exoparg3.c +++ b/source/components/executer/exoparg3.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * $Revision: 1.23 $ + * $Revision: 1.9 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -172,20 +172,20 @@ AcpiExOpcode_3A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", - AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", - (UINT32) Operand[0]->Integer.Value, - (UINT32) Operand[1]->Integer.Value, + "FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (UINT32) Operand[0]->Integer.Value, (UINT32) Operand[1]->Integer.Value, (UINT32) Operand[2]->Integer.Value)); + Fatal = ACPI_MEM_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); if (Fatal) { @@ -194,9 +194,10 @@ AcpiExOpcode_3A_0T_0R ( Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } - /* Always signal the OS! */ - - Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); + /* + * Always signal the OS! + */ + AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); /* Might return while OS is shutting down, just continue */ @@ -239,24 +240,22 @@ AcpiExOpcode_3A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; char *Buffer; ACPI_STATUS Status = AE_OK; - ACPI_NATIVE_UINT Index; - ACPI_SIZE Length; + UINT32 Index; + UINT32 Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", - AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ /* * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ - ReturnDesc = AcpiUtCreateInternalObject ( - ACPI_GET_OBJECT_TYPE (Operand[0])); + ReturnDesc = AcpiUtCreateInternalObject (Operand[0]->Common.Type); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -265,8 +264,8 @@ AcpiExOpcode_3A_1T_1R ( /* Get the Integer values from the objects */ - Index = (ACPI_NATIVE_UINT) Operand[1]->Integer.Value; - Length = (ACPI_SIZE) Operand[2]->Integer.Value; + Index = (UINT32) Operand[1]->Integer.Value; + Length = (UINT32) Operand[2]->Integer.Value; /* * If the index is beyond the length of the String/Buffer, or if the @@ -280,12 +279,12 @@ AcpiExOpcode_3A_1T_1R ( if ((Index + Length) > Operand[0]->String.Length) { - Length = (ACPI_SIZE) Operand[0]->String.Length - Index; + Length = Operand[0]->String.Length - Index; } /* Allocate a new buffer for the String/Buffer */ - Buffer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); + Buffer = ACPI_MEM_CALLOCATE (Length + 1); if (!Buffer) { Status = AE_NO_MEMORY; @@ -300,12 +299,8 @@ AcpiExOpcode_3A_1T_1R ( /* Set the length of the new String/Buffer */ ReturnDesc->String.Pointer = Buffer; - ReturnDesc->String.Length = (UINT32) Length; + ReturnDesc->String.Length = Length; } - - /* Mark buffer initialized */ - - ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; break; @@ -332,10 +327,7 @@ Cleanup: /* Set the return object and exit */ - if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } + WalkState->ResultObj = ReturnDesc; return_ACPI_STATUS (Status); }