diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 53432abd8..30a84f6ba 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.167 $ + * $Revision: 1.168 $ * *****************************************************************************/ @@ -623,7 +623,7 @@ AcpiExDumpNode ( } } - AcpiOsPrintf ("%20s : %4.4s\n", "Name", Node->Name.Ascii); + AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); AcpiExOutInteger ("Flags", Node->Flags); AcpiExOutInteger ("Owner Id", Node->OwnerId); diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c index c6c6119ef..7521e3e53 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.88 $ + * $Revision: 1.98 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. * All rights reserved. * * 2. License @@ -139,7 +139,8 @@ * RETURN: Status * * DESCRIPTION: Common processing for AcpiExExtractFromField and - * AcpiExInsertIntoField. Initialize the + * AcpiExInsertIntoField. Initialize the Region if necessary and + * validate the request. * ******************************************************************************/ @@ -157,6 +158,8 @@ AcpiExSetupRegion ( RgnDesc = ObjDesc->CommonField.RegionObj; + /* We must have a valid region */ + if (ACPI_GET_OBJECT_TYPE (RgnDesc) != ACPI_TYPE_REGION) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X (%s)\n", @@ -170,7 +173,7 @@ AcpiExSetupRegion ( * If the Region Address and Length have not been previously evaluated, * evaluate them now and save the results. */ - if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID)) + if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID)) { Status = AcpiDsGetRegionArguments (RgnDesc); if (ACPI_FAILURE (Status)) @@ -179,6 +182,27 @@ AcpiExSetupRegion ( } } + if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + /* SMBus has a non-linear address space */ + + return_ACPI_STATUS (AE_OK); + } + +#ifdef ACPI_UNDER_DEVELOPMENT + /* + * If the Field access is AnyAcc, we can now compute the optimal + * access (because we know know the length of the parent region) + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } +#endif + /* * Validate the request. The entire request from the byte offset for a * length of one field datum (access width) must fit within the region. @@ -197,8 +221,9 @@ AcpiExSetupRegion ( */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", - ObjDesc->CommonField.Node->Name.Ascii, ObjDesc->CommonField.AccessByteWidth, - RgnDesc->Region.Node->Name.Ascii, RgnDesc->Region.Length)); + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); } /* @@ -207,9 +232,10 @@ 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", - ObjDesc->CommonField.Node->Name.Ascii, ObjDesc->CommonField.BaseByteOffset, + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, - RgnDesc->Region.Node->Name.Ascii, RgnDesc->Region.Length)); + AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); return_ACPI_STATUS (AE_AML_REGION_LIMIT); } @@ -225,8 +251,10 @@ AcpiExSetupRegion ( * PARAMETERS: *ObjDesc - Field to be read * FieldDatumByteOffset - Byte offset of this datum within the * parent field - * *Value - Where to store value (must be 32 bits) - * ReadWrite - Read or Write flag + * *Value - Where to store value (must at least + * the size of ACPI_INTEGER) + * Function - Read or Write flag plus other region- + * dependent flags * * RETURN: Status * @@ -239,7 +267,7 @@ AcpiExAccessRegion ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, ACPI_INTEGER *Value, - UINT32 ReadWrite) + UINT32 Function) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *RgnDesc; @@ -249,6 +277,16 @@ AcpiExAccessRegion ( ACPI_FUNCTION_TRACE ("ExAccessRegion"); + /* + * Ensure that the region operands are fully evaluated and verify + * the validity of the request + */ + Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* * The physical address of this field datum is: * @@ -261,7 +299,7 @@ AcpiExAccessRegion ( + ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset; - if (ReadWrite == ACPI_READ) + if ((Function & ACPI_IO_MASK) == ACPI_READ) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); } @@ -271,7 +309,7 @@ AcpiExAccessRegion ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, - " Region[%s-%X] Access %X Base:Off %X:%X at %8.8X%8.8X\n", + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId, ObjDesc->CommonField.AccessByteWidth, @@ -281,7 +319,7 @@ AcpiExAccessRegion ( /* Invoke the appropriate AddressSpace/OpRegion handler */ - Status = AcpiEvAddressSpaceDispatch (RgnDesc, ReadWrite, + Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) @@ -293,7 +331,6 @@ AcpiExAccessRegion ( AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); } - else if (Status == AE_NOT_EXIST) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, @@ -402,10 +439,10 @@ AcpiExFieldDatumIo ( /* * The four types of fields are: * - * BufferFields - Read/write from/to a Buffer - * RegionFields - Read/write from/to a Operation Region. - * BankFields - Write to a Bank Register, then read/write from/to an OpRegion - * IndexFields - Write to an Index Register, then read/write from/to a Data Register + * BufferField - Read/write from/to a Buffer + * RegionField - Read/write from/to a Operation Region. + * BankField - Write to a Bank Register, then read/write from/to an OpRegion + * IndexField - Write to an Index Register, then read/write from/to a Data Register */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -450,7 +487,7 @@ AcpiExFieldDatumIo ( break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: /* Ensure that the BankValue is not beyond the capacity of the register */ @@ -480,23 +517,17 @@ AcpiExFieldDatumIo ( /*lint -fallthrough */ - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: /* * For simple RegionFields, we just directly access the owning * Operation Region. */ - Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, ReadWrite); break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: /* Ensure that the IndexValue is not beyond the capacity of the register */ @@ -509,27 +540,37 @@ AcpiExFieldDatumIo ( /* Write the index value to the IndexRegister (itself a RegionField) */ + FieldDatumByteOffset += ObjDesc->IndexField.Value; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Index Register: Value %8.8X\n", + FieldDatumByteOffset)); + Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, - &ObjDesc->IndexField.Value, - sizeof (ObjDesc->IndexField.Value)); + &FieldDatumByteOffset, + sizeof (FieldDatumByteOffset)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "I/O to Data Register: ValuePtr %p\n", + Value)); + if (ReadWrite == ACPI_READ) { /* Read the datum from the DataRegister */ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, - Value, ObjDesc->CommonField.AccessByteWidth); + Value, sizeof (ACPI_INTEGER)); } else { - /* Write the datum to the Data register */ + /* Write the datum to the DataRegister */ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, - Value, ObjDesc->CommonField.AccessByteWidth); + Value, sizeof (ACPI_INTEGER)); } break; @@ -546,13 +587,15 @@ AcpiExFieldDatumIo ( { if (ReadWrite == ACPI_READ) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n", - ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value))); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read %8.8X%8.8X, Width %d\n", + ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value), + ObjDesc->CommonField.AccessByteWidth)); } else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n", - ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value))); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written %8.8X%8.8X, Width %d\n", + ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value), + ObjDesc->CommonField.AccessByteWidth)); } } @@ -614,6 +657,11 @@ AcpiExWriteWithUpdateRule ( */ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, &CurrentValue, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + MergedValue |= (CurrentValue & ~Mask); } break; @@ -633,6 +681,7 @@ AcpiExWriteWithUpdateRule ( break; default: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WriteWithUpdateRule: Unknown UpdateRule setting: %X\n", (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); @@ -640,18 +689,19 @@ AcpiExWriteWithUpdateRule ( } } + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", + ACPI_HIDWORD (Mask), ACPI_LODWORD (Mask), + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth, + ACPI_HIDWORD (FieldValue), ACPI_LODWORD (FieldValue), + ACPI_HIDWORD (MergedValue),ACPI_LODWORD (MergedValue))); + /* Write the merged value */ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, &MergedValue, ACPI_WRITE); - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Mask %8.8X%8.8X DatumOffset %X Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", - ACPI_HIDWORD (Mask), ACPI_LODWORD (Mask), - FieldDatumByteOffset, - ACPI_HIDWORD (FieldValue), ACPI_LODWORD (FieldValue), - ACPI_HIDWORD (MergedValue),ACPI_LODWORD (MergedValue))); - return_ACPI_STATUS (Status); } @@ -662,9 +712,10 @@ AcpiExWriteWithUpdateRule ( * * PARAMETERS: Datum - Where the Datum is returned * Buffer - Raw field buffer + * BufferLength - Entire length (used for big-endian only) * ByteGranularity - 1/2/4/8 Granularity of the field * (aka Datum Size) - * Offset - Datum offset into the buffer + * BufferOffset - Datum offset into the buffer * * RETURN: none * @@ -674,42 +725,53 @@ AcpiExWriteWithUpdateRule ( ******************************************************************************/ void -AcpiExGetBufferDatum( +AcpiExGetBufferDatum ( ACPI_INTEGER *Datum, void *Buffer, + UINT32 BufferLength, UINT32 ByteGranularity, - UINT32 Offset) + UINT32 BufferOffset) { + UINT32 Index; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE_U32 ("ExGetBufferDatum", ByteGranularity); + + + /* Get proper index into buffer (handles big/little endian) */ + + Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); + + /* Move the requested number of bytes */ switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: - *Datum = ((UINT8 *) Buffer) [Offset]; + *Datum = ((UINT8 *) Buffer) [Index]; break; case ACPI_FIELD_WORD_GRANULARITY: - ACPI_MOVE_UNALIGNED16_TO_32 (Datum, &(((UINT16 *) Buffer) [Offset])); + ACPI_MOVE_16_TO_64 (Datum, &(((UINT16 *) Buffer) [Index])); break; case ACPI_FIELD_DWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset])); + ACPI_MOVE_32_TO_64 (Datum, &(((UINT32 *) Buffer) [Index])); break; case ACPI_FIELD_QWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset])); + ACPI_MOVE_64_TO_64 (Datum, &(((UINT64 *) Buffer) [Index])); break; default: /* Should not get here */ break; } + + return_VOID; } @@ -719,9 +781,10 @@ AcpiExGetBufferDatum( * * PARAMETERS: MergedDatum - Value to store * Buffer - Receiving buffer + * BufferLength - Entire length (used for big-endian only) * ByteGranularity - 1/2/4/8 Granularity of the field * (aka Datum Size) - * Offset - Datum offset into the buffer + * BufferOffset - Datum offset into the buffer * * RETURN: none * @@ -734,39 +797,50 @@ void AcpiExSetBufferDatum ( ACPI_INTEGER MergedDatum, void *Buffer, + UINT32 BufferLength, UINT32 ByteGranularity, - UINT32 Offset) + UINT32 BufferOffset) { + UINT32 Index; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE_U32 ("ExSetBufferDatum", ByteGranularity); + + + /* Get proper index into buffer (handles big/little endian) */ + + Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); + + /* Move the requested number of bytes */ switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: - ((UINT8 *) Buffer) [Offset] = (UINT8) MergedDatum; + ((UINT8 *) Buffer) [Index] = (UINT8) MergedDatum; break; case ACPI_FIELD_WORD_GRANULARITY: - ACPI_MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_16 (&(((UINT16 *) Buffer)[Index]), &MergedDatum); break; case ACPI_FIELD_DWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_32 (&(((UINT32 *) Buffer)[Index]), &MergedDatum); break; case ACPI_FIELD_QWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_64 (&(((UINT64 *) Buffer)[Index]), &MergedDatum); break; default: /* Should not get here */ break; } + + return_VOID; } @@ -821,7 +895,7 @@ AcpiExExtractFromField ( ObjDesc->CommonField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "ByteLen=%X, DatumLen=%X, ByteGran=%X\n", + "ByteLen %X, DatumLen %X, ByteGran %X\n", ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth)); /* @@ -862,8 +936,8 @@ AcpiExExtractFromField ( /* Store the datum to the caller buffer */ - AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, - DatumOffset); + AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, + ObjDesc->CommonField.AccessByteWidth, DatumOffset); return_ACPI_STATUS (AE_OK); } @@ -942,7 +1016,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, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -996,21 +1070,28 @@ AcpiExInsertIntoField ( * larger than the field, this typically happens when an integer is * written to a field that is actually smaller than an integer. */ - ByteFieldLength = ACPI_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_BFIELD, "Buffer length %X too small for field %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Buffer length %X too small for field %X\n", BufferLength, ByteFieldLength)); return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } + ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.StartFieldBitOffset + + ObjDesc->CommonField.BitLength); + /* Convert byte count to datum count, round up if necessary */ - DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth); + DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, + ObjDesc->CommonField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "ByteLen=%X, DatumLen=%X, ByteGran=%X\n", + "Bytes %X, Datums %X, ByteGran %X\n", ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth)); /* @@ -1024,7 +1105,7 @@ AcpiExInsertIntoField ( /* Get a single datum from the caller's buffer */ - AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, + AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -1063,6 +1144,10 @@ AcpiExInsertIntoField ( return_ACPI_STATUS (Status); } + /* We just wrote the first datum */ + + DatumOffset++; + /* If the entire field fits within one datum, we are done. */ if ((DatumCount == 1) && @@ -1084,14 +1169,13 @@ AcpiExInsertIntoField ( */ while (DatumOffset < DatumCount) { - DatumOffset++; FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; /* * Get the next raw buffer datum. It may contain bits of the previous * field datum */ - AcpiExGetBufferDatum (&ThisRawDatum, Buffer, + AcpiExGetBufferDatum (&ThisRawDatum, Buffer, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* Create the field datum based on the field alignment */ @@ -1118,37 +1202,37 @@ AcpiExInsertIntoField ( * a datum boundary. Update Rule must be applied to the bits outside * the field. */ - if (DatumOffset == DatumCount) + DatumOffset++; + if ((DatumOffset == DatumCount) && + (ObjDesc->CommonField.EndFieldValidBits)) { /* * If there are dangling non-aligned bits, perform one more merged write * Else - field is aligned at the end, no need for any more writes */ - if (ObjDesc->CommonField.EndFieldValidBits) + + /* + * Part3: + * This is the last datum and the field does not end on a datum boundary. + * Build the partial datum and write with the update rule. + * + * Mask off the unused bits above (after) the end-of-field + */ + Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); + MergedDatum &= Mask; + + /* Write the last datum with the update rule */ + + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, + FieldDatumByteOffset); + if (ACPI_FAILURE (Status)) { - /* - * Part3: - * This is the last datum and the field does not end on a datum boundary. - * Build the partial datum and write with the update rule. - * - * Mask off the unused bits above (after) the end-of-field - */ - Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - MergedDatum &= Mask; - - /* Write the last datum with the update rule */ - - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, - FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + return_ACPI_STATUS (Status); } } else { - /* Normal case -- write the completed datum */ + /* Normal (aligned) case -- write the completed datum */ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, &MergedDatum, ACPI_WRITE); diff --git a/source/components/executer/exmutex.c b/source/components/executer/exmutex.c index f376fc84c..5d7093b58 100644 --- a/source/components/executer/exmutex.c +++ b/source/components/executer/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 1.27 $ + * $Revision: 1.19 $ * *****************************************************************************/ @@ -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 - 2003, Intel Corp. * All rights reserved. * * 2. License @@ -128,9 +128,9 @@ * * FUNCTION: AcpiExUnlinkMutex * - * PARAMETERS: ObjDesc - The mutex to be unlinked + * PARAMETERS: *ObjDesc - The mutex to be unlinked * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list * @@ -148,8 +148,6 @@ AcpiExUnlinkMutex ( return; } - /* Doubly linked list */ - if (ObjDesc->Mutex.Next) { (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; @@ -170,16 +168,16 @@ AcpiExUnlinkMutex ( * * FUNCTION: AcpiExLinkMutex * - * PARAMETERS: ObjDesc - The mutex to be linked - * Thread - Current executing thread object + * PARAMETERS: *ObjDesc - The mutex to be linked + * *ListHead - head of the "AcquiredMutex" list * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk * ******************************************************************************/ -static void +void AcpiExLinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread) @@ -211,9 +209,8 @@ AcpiExLinkMutex ( * * FUNCTION: AcpiExAcquireMutex * - * PARAMETERS: TimeDesc - Timeout integer - * ObjDesc - Mutex object - * WalkState - Current method execution state + * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor + * *ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -243,7 +240,7 @@ AcpiExAcquireMutex ( if (!WalkState->Thread) { ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -253,30 +250,24 @@ AcpiExAcquireMutex ( */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { - ACPI_REPORT_ERROR (( - "Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* Support for multiple acquires by the owning thread */ + /* + * Support for multiple acquires by the owning thread + */ - if (ObjDesc->Mutex.OwnerThread) + if ((ObjDesc->Mutex.OwnerThread) && + (ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId)) { - /* Special case for Global Lock, allow all threads */ - - if ((ObjDesc->Mutex.OwnerThread->ThreadId == - WalkState->Thread->ThreadId) || - (ObjDesc->Mutex.Semaphore == - AcpiGbl_GlobalLockSemaphore)) - { - /* - * The mutex is already owned by this thread, - * just increment the acquisition depth - */ - ObjDesc->Mutex.AcquisitionDepth++; - return_ACPI_STATUS (AE_OK); - } + /* + * The mutex is already owned by this thread, + * just increment the acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); } /* Acquire the mutex, wait if necessary */ @@ -289,11 +280,10 @@ AcpiExAcquireMutex ( return_ACPI_STATUS (Status); } - /* Have the mutex: update mutex and walk info and save the SyncLevel */ + /* Have the mutex, update mutex and walk info */ - ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.AcquisitionDepth = 1; - ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.AcquisitionDepth = 1; WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; @@ -309,8 +299,7 @@ AcpiExAcquireMutex ( * * FUNCTION: AcpiExReleaseMutex * - * PARAMETERS: ObjDesc - The object descriptor for this op - * WalkState - Current method execution state + * PARAMETERS: *ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -352,12 +341,9 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_INTERNAL); } - /* - * The Mutex is owned, but this thread must be the owner. - * Special case for Global Lock, any thread can release - */ - if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && - (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) + /* The Mutex is owned, but this thread must be the owner */ + + if (ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) { ACPI_REPORT_ERROR (( "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", @@ -373,14 +359,14 @@ AcpiExReleaseMutex ( */ if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { - ACPI_REPORT_ERROR (( - "Cannot release Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* Match multiple Acquires with multiple Releases */ - + /* + * Match multiple Acquires with multiple Releases + */ ObjDesc->Mutex.AcquisitionDepth--; if (ObjDesc->Mutex.AcquisitionDepth != 0) { @@ -397,10 +383,10 @@ AcpiExReleaseMutex ( Status = AcpiExSystemReleaseMutex (ObjDesc); - /* Update the mutex and walk state, restore SyncLevel before acquire */ + /* Update the mutex and walk state */ ObjDesc->Mutex.OwnerThread = NULL; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; return_ACPI_STATUS (Status); } @@ -410,11 +396,11 @@ AcpiExReleaseMutex ( * * FUNCTION: AcpiExReleaseAllMutexes * - * PARAMETERS: Thread - Current executing thread object + * PARAMETERS: *MutexList - Head of the mutex list * * RETURN: Status * - * DESCRIPTION: Release all mutexes held by this thread + * DESCRIPTION: Release all mutexes in the list * ******************************************************************************/ @@ -430,8 +416,9 @@ AcpiExReleaseAllMutexes ( ACPI_FUNCTION_ENTRY (); - /* Traverse the list of owned mutexes, releasing each one */ - + /* + * Traverse the list of owned mutexes, releasing each one. + */ while (Next) { This = Next; @@ -451,11 +438,7 @@ AcpiExReleaseAllMutexes ( /* Mark mutex unowned */ - This->Mutex.OwnerThread = NULL; - - /* Update Thread SyncLevel (Last mutex is the important one) */ - - Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel; + This->Mutex.OwnerThread = NULL; } } diff --git a/source/components/executer/exoparg1.c b/source/components/executer/exoparg1.c index f011eb4ad..b9175d94f 100644 --- a/source/components/executer/exoparg1.c +++ b/source/components/executer/exoparg1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * $Revision: 1.134 $ + * $Revision: 1.150 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. * All rights reserved. * * 2. License @@ -151,7 +151,6 @@ * fully resolved operands. !*/ - /******************************************************************************* * * FUNCTION: AcpiExOpcode_1A_0T_0R @@ -299,14 +298,14 @@ AcpiExOpcode_1A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; UINT32 Temp32; UINT32 i; - UINT32 j; + UINT32 PowerOfTen; ACPI_INTEGER Digit; ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); - /* Create a return object of type Integer for most opcodes */ + /* Examine the AML opcode */ switch (WalkState->Opcode) { @@ -317,6 +316,8 @@ AcpiExOpcode_1A_1T_1R ( case AML_TO_BCD_OP: case AML_COND_REF_OF_OP: + /* Create a return object of type Integer for these opcodes */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { @@ -324,163 +325,164 @@ AcpiExOpcode_1A_1T_1R ( goto Cleanup; } - break; - } - - /* Examine the AML opcode */ - - switch (WalkState->Opcode) - { - - case AML_BIT_NOT_OP: /* Not (Operand, Result) */ - - ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; - break; - - - case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ - - ReturnDesc->Integer.Value = Operand[0]->Integer.Value; - - /* - * 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) + switch (WalkState->Opcode) { - ReturnDesc->Integer.Value >>= 1; - } + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ - ReturnDesc->Integer.Value = Temp32; - break; + ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; + break; - case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ - ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; - /* - * 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; - } - - /* 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 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) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n", - (UINT32) Digit)); + 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; + + /* + * 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; + } + + /* 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 characters + * (if table is 32-bit, integer can hold 8 BCD characters) + * Convert each 4-bit BCD value + */ + PowerOfTen = 1; + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Convert each BCD digit (each is one nybble wide) */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + /* Get the least significant 4-bit BCD digit */ + + Temp32 = ((UINT32) Digit) & 0xF; + + /* Check the range of the digit */ + + if (Temp32 > 9) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "BCD digit too large (not decimal): 0x%X\n", + Temp32)); + + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + /* Sum the digit into the result with the current power of 10 */ + + ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * PowerOfTen); + + /* Shift to next BCD digit */ + + Digit >>= 4; + + /* Next power of 10 */ + + PowerOfTen *= 10; + } + break; + + + case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ + + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Each BCD digit is one nybble wide */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32); + + /* Insert the BCD digit that resides in the remainder from above */ + + ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << (i * 4)); + } + + /* Overflow if there is any data left in Digit */ + + if (Digit > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n", + ACPI_HIDWORD(Operand[0]->Integer.Value), + ACPI_LODWORD(Operand[0]->Integer.Value))); 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; + 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; + case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ /* - * Must delete the result descriptor since there is no reference - * being returned + * 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) */ - AcpiUtRemoveReference (Operand[1]); + 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; + goto Cleanup; + } + + /* Get the object reference, store it, and remove our reference */ + + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); + AcpiUtRemoveReference (ReturnDesc2); + + /* The object exists in the namespace, return TRUE */ + + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; goto Cleanup; + + + default: + /* No other opcodes get here */ + break; } - - /* Get the object reference and store it */ - - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); - if (ACPI_FAILURE (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; + break; case AML_STORE_OP: /* Store (Source, Target) */ @@ -496,14 +498,19 @@ AcpiExOpcode_1A_1T_1R ( 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 */ + /* It is possible that the Store already produced a return object */ + + if (!WalkState->ResultObj) + { + /* + * 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); @@ -568,7 +575,10 @@ AcpiExOpcode_1A_1T_1R ( Cleanup: - WalkState->ResultObj = ReturnDesc; + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } /* Delete return object on error */ @@ -605,7 +615,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_INTEGER Value; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -633,7 +643,7 @@ AcpiExOpcode_1A_0T_1R ( * can be either a NS Node or an internal object. */ ReturnDesc = Operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_INTERNAL) + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_OPERAND) { /* Internal reference object - prevent deletion */ @@ -674,84 +684,12 @@ AcpiExOpcode_1A_0T_1R ( case AML_TYPE_OP: /* ObjectType (SourceObject) */ - if (INTERNAL_TYPE_REFERENCE == Operand[0]->Common.Type) + /* Get the type of the base object */ + + Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); + if (ACPI_FAILURE (Status)) { - /* - * Not a Name -- an indirect name pointer would have - * been converted to a direct name pointer in ResolveOperands - */ - 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 Integer */ - - Type = ACPI_TYPE_INTEGER; - break; - - - case AML_DEBUG_OP: - - /* The Debug Object is of type "DebugObject" */ - - Type = ACPI_TYPE_DEBUG_OBJECT; - break; - - - case AML_INDEX_OP: - - /* Get the type of this reference (index into another object) */ - - Type = Operand[0]->Reference.TargetType; - if (Type == ACPI_TYPE_PACKAGE) - { - /* - * The main object is a package, we want to get the type - * of the individual package element that is referenced by - * the index. - */ - Type = (*(Operand[0]->Reference.Where))->Common.Type; - } - break; - - - case AML_LOCAL_OP: - case AML_ARG_OP: - - Type = AcpiDsMethodDataGetType (Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, WalkState); - break; - - - default: - - 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_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; - } - + goto Cleanup; } /* Allocate a descriptor to hold the type. */ @@ -769,43 +707,38 @@ AcpiExOpcode_1A_0T_1R ( case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ - TempDesc = Operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + /* Get the base object */ + + Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); + if (ACPI_FAILURE (Status)) { - TempDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); + goto Cleanup; } - if (!TempDesc) + /* + * 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 (Type) { - Value = 0; - } - else - { - /* - * 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 = TempDesc->Buffer.Length; - break; + case ACPI_TYPE_BUFFER: + Value = TempDesc->Buffer.Length; + break; - case ACPI_TYPE_STRING: - Value = TempDesc->String.Length; - break; + case ACPI_TYPE_STRING: + Value = TempDesc->String.Length; + break; - case ACPI_TYPE_PACKAGE: - Value = TempDesc->Package.Count; - break; + case ACPI_TYPE_PACKAGE: + Value = TempDesc->Package.Count; + break; - default: - 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; - } + default: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n", + AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; } /* @@ -841,7 +774,7 @@ AcpiExOpcode_1A_0T_1R ( { switch (ACPI_GET_OBJECT_TYPE (Operand[0])) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: /* * This is a DerefOf (LocalX | ArgX) * @@ -854,8 +787,12 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ - AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, WalkState, &TempDesc); + Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, WalkState, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } /* * Delete our reference to the input object and @@ -865,6 +802,15 @@ AcpiExOpcode_1A_0T_1R ( Operand[0] = TempDesc; break; + case AML_REF_OF_OP: + + /* Get the object to which the reference refers */ + + TempDesc = Operand[0]->Reference.Object; + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + default: /* Must be an Index op - handled below */ @@ -882,14 +828,16 @@ AcpiExOpcode_1A_0T_1R ( * 2) Dereference the node to an actual object. Could be a Field, so we nee * to resolve the node to a value. */ - Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, WalkState->ScopeInfo->Scope.Node, - ACPI_NS_SEARCH_PARENT, (ACPI_NAMESPACE_NODE **) &ReturnDesc); + Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, + WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc)); if (ACPI_FAILURE (Status)) { goto Cleanup; } - Status = AcpiExResolveNodeToValue ((ACPI_NAMESPACE_NODE **) &ReturnDesc, WalkState); + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState); goto Cleanup; @@ -928,10 +876,12 @@ AcpiExOpcode_1A_0T_1R ( switch (Operand[0]->Reference.TargetType) { case ACPI_TYPE_BUFFER_FIELD: + + TempDesc = Operand[0]->Reference.Object; + /* - * The target is a buffer, we must create a new object that - * contains one element of the buffer, the element pointed - * to by the index. + * Create a new object that contains one element of the + * buffer -- the element pointed to by the index. * * NOTE: index into a buffer is NOT a pointer to a * sub-buffer of the main buffer, it is only a pointer to a @@ -949,7 +899,6 @@ AcpiExOpcode_1A_0T_1R ( * 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; @@ -958,9 +907,8 @@ AcpiExOpcode_1A_0T_1R ( case 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. + * Return the referenced element of the package. We must add + * another reference to the referenced object, however. */ ReturnDesc = *(Operand[0]->Reference.Where); if (!ReturnDesc) @@ -994,6 +942,12 @@ AcpiExOpcode_1A_0T_1R ( ReturnDesc = Operand[0]->Reference.Object; + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) + { + + ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc); + } + /* Add another reference to the object! */ AcpiUtAddReference (ReturnDesc);