diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h index 9a48eaa1dcac..9919a01933ea 100644 --- a/sys/contrib/dev/acpica/acconfig.h +++ b/sys/contrib/dev/acpica/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * $Revision: 78 $ + * $Revision: 90 $ * *****************************************************************************/ @@ -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 @@ -125,9 +125,9 @@ *****************************************************************************/ /* - * ACPI_DEBUG - This switch enables all the debug facilities of the - * ACPI subsystem. This includes the DEBUG_PRINT output - * statements. When disabled, all DEBUG_PRINT + * ACPI_DEBUG - This switch enables all the debug facilities of the + * ACPI subsystem. This includes the DEBUG_PRINT output + * statements. When disabled, all DEBUG_PRINT * statements are compiled out. * * ACPI_APPLICATION - Use this switch if the subsystem is going to be run @@ -145,13 +145,12 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20011120 +#define ACPI_CA_VERSION 0x20020214 /* Version of ACPI supported */ #define ACPI_CA_SUPPORT_LEVEL 2 - /* Maximum objects in the various object caches */ #define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ @@ -160,28 +159,30 @@ #define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ #define MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */ - /* String size constants */ #define MAX_STRING_LENGTH 512 #define PATHNAME_MAX 256 /* A full namespace pathname */ - /* Maximum count for a semaphore object */ #define MAX_SEMAPHORE_COUNT 256 - /* Max reference count (for debug only) */ #define MAX_REFERENCE_COUNT 0x400 - /* Size of cached memory mapping for system memory operation region */ #define SYSMEM_REGION_WINDOW_SIZE 4096 +/****************************************************************************** + * + * Configuration of subsystem behavior + * + *****************************************************************************/ + /* * Debugger threading model * Use single threaded if the entire subsystem is contained in an application @@ -190,7 +191,6 @@ * By default the model is single threaded if ACPI_APPLICATION is set, * multi-threaded if ACPI_APPLICATION is not set. */ - #define DEBUGGER_SINGLE_THREADED 0 #define DEBUGGER_MULTI_THREADED 1 @@ -203,16 +203,26 @@ #endif #endif +/* + * Should the subystem abort the loading of an ACPI table if the + * table checksum is incorrect? + */ +#define ACPI_CHECKSUM_ABORT FALSE + + /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification changes) * *****************************************************************************/ +/* Number of distinct GPE register blocks */ + +#define ACPI_MAX_GPE_BLOCKS 2 + /* * Method info (in WALK_STATE), containing local variables and argumetns */ - #define MTH_NUM_LOCALS 8 #define MTH_MAX_LOCAL 7 @@ -226,7 +236,6 @@ /* * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG */ - #define OBJ_NUM_OPERANDS 8 #define OBJ_MAX_OPERAND 7 @@ -236,7 +245,6 @@ #define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ #define PATH_SEPARATOR '.' - /* Constants used in searching for the RSDP in low memory */ #define LO_RSDP_WINDOW_BASE 0 /* Physical Address */ @@ -245,16 +253,33 @@ #define HI_RSDP_WINDOW_SIZE 0x20000 #define RSDP_SCAN_STEP 16 - /* Operation regions */ -#define ACPI_NUM_PREDEFINED_REGIONS 7 +#define ACPI_NUM_PREDEFINED_REGIONS 8 #define ACPI_USER_REGION_BEGIN 0x80 /* Maximum SpaceIds for Operation Regions */ #define ACPI_MAX_ADDRESS_SPACE 255 +/* RSDP checksums */ + +#define ACPI_RSDP_CHECKSUM_LENGTH 20 +#define ACPI_RSDP_XCHECKSUM_LENGTH 36 + + +/****************************************************************************** + * + * ACPI AML Debugger + * + *****************************************************************************/ + + +#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define ACPI_DEBUGGER_COMMAND_PROMPT '-' +#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' + #endif /* _ACCONFIG_H */ diff --git a/sys/contrib/dev/acpica/acfreebsd.h b/sys/contrib/dev/acpica/acfreebsd.h index d8ad90588c6d..6c9a8cbfe407 100644 --- a/sys/contrib/dev/acpica/acfreebsd.h +++ b/sys/contrib/dev/acpica/acfreebsd.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acfreebsd.h - OS specific defines, etc. - * $Revision: 6 $ + * $Revision: 7 $ * *****************************************************************************/ @@ -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 diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h index 5581e481c8b0..539131b5a00b 100644 --- a/sys/contrib/dev/acpica/acgcc.h +++ b/sys/contrib/dev/acpica/acgcc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * $Revision: 15 $ + * $Revision: 17 $ * *****************************************************************************/ @@ -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 @@ -128,8 +128,8 @@ #define ACPI_ASM_MACROS #define causeinterrupt(level) #define BREAKPOINT3 -#define disable() __cli() -#define enable() __sti() +#define acpi_disable_irqs() __cli() +#define acpi_enable_irqs() __sti() /*! [Begin] no source code translation */ @@ -189,8 +189,8 @@ #define ACPI_ASM_MACROS #define causeinterrupt(level) #define BREAKPOINT3 -#define disable() __cli() -#define enable() __sti() +#define acpi_disable_irqs() __cli() +#define acpi_enable_irqs() __sti() #define halt() __asm__ __volatile__ ("sti; hlt":::"memory") /*! [Begin] no source code translation diff --git a/sys/contrib/dev/acpica/acpi.h b/sys/contrib/dev/acpica/acpi.h index bdbb2012ca45..8e2023c1bb59 100644 --- a/sys/contrib/dev/acpica/acpi.h +++ b/sys/contrib/dev/acpica/acpi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acpi.h - Master include file, Publics and external data. - * $Revision: 54 $ + * $Revision: 55 $ * *****************************************************************************/ @@ -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 diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h index e7a8637aa61d..9985fc7590cc 100644 --- a/sys/contrib/dev/acpica/acpiosxf.h +++ b/sys/contrib/dev/acpica/acpiosxf.h @@ -12,7 +12,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 @@ -213,11 +213,7 @@ AcpiOsSignalSemaphore ( void * AcpiOsAllocate ( - UINT32 Size); - -void * -AcpiOsCallocate ( - UINT32 Size); + ACPI_SIZE Size); void AcpiOsFree ( @@ -226,13 +222,13 @@ AcpiOsFree ( ACPI_STATUS AcpiOsMapMemory ( ACPI_PHYSICAL_ADDRESS PhysicalAddress, - UINT32 Length, + ACPI_SIZE Size, void **LogicalAddress); void AcpiOsUnmapMemory ( void *LogicalAddress, - UINT32 Length); + ACPI_SIZE Size); ACPI_STATUS AcpiOsGetPhysicalAddress ( @@ -364,12 +360,12 @@ AcpiOsSignal ( * Debug print routines */ -INT32 +void AcpiOsPrintf ( const NATIVE_CHAR *Format, ...); -INT32 +void AcpiOsVprintf ( const NATIVE_CHAR *Format, va_list Args); diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h index ec03fb4b9592..5a02225b2637 100644 --- a/sys/contrib/dev/acpica/acpixf.h +++ b/sys/contrib/dev/acpica/acpixf.h @@ -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 @@ -356,11 +356,12 @@ AcpiInstallGpeHandler ( ACPI_STATUS AcpiAcquireGlobalLock ( - void); + UINT32 Timeout, + UINT32 *Handle); ACPI_STATUS AcpiReleaseGlobalLock ( - void); + UINT32 Handle); ACPI_STATUS AcpiRemoveGpeHandler ( diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index 7e60ea8be4dc..1bd79e7ba74c 100644 --- a/sys/contrib/dev/acpica/exfldio.c +++ b/sys/contrib/dev/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 75 $ + * $Revision: 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; @@ -196,8 +196,9 @@ AcpiExSetupRegion ( * byte, and a field with Dword access specified. */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field access width (%d bytes) too large for region size (%X)\n", - ObjDesc->CommonField.AccessByteWidth, RgnDesc->Region.Length)); + "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 *) &RgnDesc->Region.Node->Name, RgnDesc->Region.Length)); } /* @@ -205,10 +206,10 @@ AcpiExSetupRegion ( * exceeds region length, indicate an error */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field Base+Offset+Width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n", - ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, - ObjDesc->CommonField.AccessByteWidth, - RgnDesc->Region.Length, ObjDesc, RgnDesc)); + "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 *) &RgnDesc->Region.Node->Name, RgnDesc->Region.Length)); return_ACPI_STATUS (AE_AML_REGION_LIMIT); } @@ -245,7 +246,7 @@ AcpiExAccessRegion ( ACPI_PHYSICAL_ADDRESS Address; - FUNCTION_TRACE ("AcpiExAccessRegion"); + ACPI_FUNCTION_TRACE ("AcpiExAccessRegion"); /* @@ -270,18 +271,18 @@ AcpiExAccessRegion ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, - " Region[%s-%X] Width %X Base:Off %X:%X at %8.8X%8.8X\n", + " Region[%s-%X] Access %X Base:Off %X:%X at %8.8X%8.8X\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId, - ObjDesc->CommonField.AccessBitWidth, + 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, ObjDesc->CommonField.AccessBitWidth, Value); + Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -329,15 +330,26 @@ AcpiExRegisterOverflow ( ACPI_INTEGER Value) { - /* - * Is the Value larger than the maximum value that can fit into - * the field? - */ + if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) + { + /* + * The field is large enough to hold the maximum integer, so we can + * never overflow it. + */ + return (FALSE); + } + if (Value >= (ACPI_INTEGER) (1 << ObjDesc->CommonField.BitLength)) { + /* + * The Value is larger than the maximum value that can fit into + * the register. + */ return (TRUE); } + /* The Value will fit into the field with no truncation */ + return (FALSE); } @@ -371,7 +383,7 @@ AcpiExFieldDatumIo ( ACPI_INTEGER LocalValue; - FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset); + ACPI_FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset); if (ReadWrite == ACPI_READ) @@ -417,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); @@ -428,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); @@ -535,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))); } } @@ -573,7 +585,7 @@ AcpiExWriteWithUpdateRule ( ACPI_INTEGER CurrentValue; - FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask); + ACPI_FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask); /* Start with the new bits */ @@ -593,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 << (sizeof (Mask) * 8 - - ObjDesc->CommonField.AccessBitWidth)) != 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 @@ -625,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; } } @@ -636,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); } @@ -670,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; } } @@ -719,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; } } @@ -772,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)); @@ -790,20 +809,19 @@ 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, - "ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n", - ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, - ObjDesc->CommonField.AccessByteWidth)); + "ByteLen=%x, DatumLen=%x, ByteGran=%x\n", + ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth)); /* * Clear the caller's buffer (the whole buffer length as given) * 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 */ @@ -831,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 */ @@ -854,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) || @@ -907,7 +925,7 @@ AcpiExExtractFromField ( if (ObjDesc->CommonField.EndBufferValidBits) { MergedDatum &= - MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); + ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); } } } @@ -916,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); /* @@ -961,7 +979,7 @@ AcpiExInsertIntoField ( UINT32 DatumCount; - FUNCTION_TRACE ("ExInsertIntoField"); + ACPI_FUNCTION_TRACE ("ExInsertIntoField"); /* @@ -970,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", @@ -981,12 +999,11 @@ 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, BitGran=%x, ByteGran=%x\n", - ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, - ObjDesc->CommonField.AccessByteWidth)); + "ByteLen=%x, DatumLen=%x, ByteGran=%x\n", + ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth)); /* * Break the request into up to three parts (similar to an I/O request): @@ -1012,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 */ @@ -1021,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 */ @@ -1108,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/sys/contrib/dev/acpica/exsystem.c b/sys/contrib/dev/acpica/exsystem.c index b4625976ec8c..758567b000a6 100644 --- a/sys/contrib/dev/acpica/exsystem.c +++ b/sys/contrib/dev/acpica/exsystem.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exsystem - Interface to OS services - * $Revision: 67 $ + * $Revision: 71 $ * *****************************************************************************/ @@ -10,7 +10,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 "acevents.h" #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("exsystem") + ACPI_MODULE_NAME ("exsystem") /******************************************************************************* @@ -147,10 +147,11 @@ AcpiExSystemWaitSemaphore ( ACPI_HANDLE Semaphore, UINT32 Timeout) { - ACPI_STATUS Status, Status2; + ACPI_STATUS Status; + ACPI_STATUS Status2; - FUNCTION_TRACE ("ExSystemWaitSemaphore"); + ACPI_FUNCTION_TRACE ("ExSystemWaitSemaphore"); Status = AcpiOsWaitSemaphore (Semaphore, 1, 0); @@ -191,17 +192,20 @@ AcpiExSystemWaitSemaphore ( * * PARAMETERS: HowLong - The amount of time to stall * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Suspend running thread for specified amount of time. * ******************************************************************************/ -void +ACPI_STATUS AcpiExSystemDoStall ( UINT32 HowLong) { - FUNCTION_ENTRY (); + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_ENTRY (); if (HowLong > 1000) /* 1 millisecond */ @@ -214,13 +218,15 @@ AcpiExSystemDoStall ( /* And now we must get the interpreter again */ - AcpiExEnterInterpreter (); + Status = AcpiExEnterInterpreter (); } else { AcpiOsSleep (0, (HowLong / 1000) + 1); } + + return (Status); } @@ -236,12 +242,14 @@ AcpiExSystemDoStall ( * ******************************************************************************/ -void +ACPI_STATUS AcpiExSystemDoSuspend ( UINT32 HowLong) { + ACPI_STATUS Status; - FUNCTION_ENTRY (); + + ACPI_FUNCTION_ENTRY (); /* Since this thread will sleep, we must release the interpreter */ @@ -253,7 +261,8 @@ AcpiExSystemDoSuspend ( /* And now we must get the interpreter again */ - AcpiExEnterInterpreter (); + Status = AcpiExEnterInterpreter (); + return (Status); } @@ -280,7 +289,7 @@ AcpiExSystemAcquireMutex ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE_PTR ("ExSystemAcquireMutex", ObjDesc); + ACPI_FUNCTION_TRACE_PTR ("ExSystemAcquireMutex", ObjDesc); if (!ObjDesc) @@ -293,7 +302,7 @@ AcpiExSystemAcquireMutex ( */ if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) { - Status = AcpiEvAcquireGlobalLock (); + Status = AcpiEvAcquireGlobalLock ((UINT32) TimeDesc->Integer.Value); return_ACPI_STATUS (Status); } @@ -325,7 +334,7 @@ AcpiExSystemReleaseMutex ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("ExSystemReleaseMutex"); + ACPI_FUNCTION_TRACE ("ExSystemReleaseMutex"); if (!ObjDesc) @@ -367,7 +376,7 @@ AcpiExSystemSignalEvent ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("ExSystemSignalEvent"); + ACPI_FUNCTION_TRACE ("ExSystemSignalEvent"); if (ObjDesc) @@ -402,7 +411,7 @@ AcpiExSystemWaitEvent ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("ExSystemWaitEvent"); + ACPI_FUNCTION_TRACE ("ExSystemWaitEvent"); if (ObjDesc) @@ -411,7 +420,6 @@ AcpiExSystemWaitEvent ( (UINT32) TimeDesc->Integer.Value); } - return_ACPI_STATUS (Status); } @@ -436,7 +444,7 @@ AcpiExSystemResetEvent ( void *TempSemaphore; - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); /* diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index 2015b324460d..00ff2d5de140 100644 --- a/sys/contrib/dev/acpica/hwsleep.c +++ b/sys/contrib/dev/acpica/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 25 $ + * $Revision: 35 $ * *****************************************************************************/ @@ -10,7 +10,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 @@ -120,10 +120,7 @@ #include "achware.h" #define _COMPONENT ACPI_HARDWARE - MODULE_NAME ("hwsleep") - -static UINT8 SleepTypeA; -static UINT8 SleepTypeB; + ACPI_MODULE_NAME ("hwsleep") /****************************************************************************** @@ -133,7 +130,7 @@ static UINT8 SleepTypeB; * PARAMETERS: PhysicalAddress - Physical address of ACPI real mode * entry point. * - * RETURN: AE_OK or AE_ERROR + * RETURN: Status * * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS * @@ -144,25 +141,18 @@ AcpiSetFirmwareWakingVector ( ACPI_PHYSICAL_ADDRESS PhysicalAddress) { - FUNCTION_TRACE ("AcpiSetFirmwareWakingVector"); + ACPI_FUNCTION_TRACE ("AcpiSetFirmwareWakingVector"); - /* Make sure that we have an FACS */ - - if (!AcpiGbl_FACS) - { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - /* Set the vector */ - if (AcpiGbl_FACS->VectorWidth == 32) + if (AcpiGbl_CommonFACS.VectorWidth == 32) { - * (UINT32 *) AcpiGbl_FACS->FirmwareWakingVector = (UINT32) PhysicalAddress; + *(UINT32 *) AcpiGbl_CommonFACS.FirmwareWakingVector = (UINT32) PhysicalAddress; } else { - *AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; + *AcpiGbl_CommonFACS.FirmwareWakingVector = PhysicalAddress; } return_ACPI_STATUS (AE_OK); @@ -179,7 +169,7 @@ AcpiSetFirmwareWakingVector ( * * RETURN: Status * - * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * DESCRIPTION: Access function for FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -188,7 +178,7 @@ AcpiGetFirmwareWakingVector ( ACPI_PHYSICAL_ADDRESS *PhysicalAddress) { - FUNCTION_TRACE ("AcpiGetFirmwareWakingVector"); + ACPI_FUNCTION_TRACE ("AcpiGetFirmwareWakingVector"); if (!PhysicalAddress) @@ -196,22 +186,15 @@ AcpiGetFirmwareWakingVector ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Make sure that we have an FACS */ - - if (!AcpiGbl_FACS) - { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - /* Get the vector */ - if (AcpiGbl_FACS->VectorWidth == 32) + if (AcpiGbl_CommonFACS.VectorWidth == 32) { - *PhysicalAddress = * (UINT32 *) AcpiGbl_FACS->FirmwareWakingVector; + *PhysicalAddress = *(UINT32 *) AcpiGbl_CommonFACS.FirmwareWakingVector; } else { - *PhysicalAddress = *AcpiGbl_FACS->FirmwareWakingVector; + *PhysicalAddress = *AcpiGbl_CommonFACS.FirmwareWakingVector; } return_ACPI_STATUS (AE_OK); @@ -242,35 +225,45 @@ AcpiEnterSleepStatePrep ( ACPI_OBJECT Arg; - FUNCTION_TRACE ("AcpiEnterSleepStatePrep"); + ACPI_FUNCTION_TRACE ("AcpiEnterSleepStatePrep"); + /* * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ - Status = AcpiHwObtainSleepTypeRegisterData (SleepState, &SleepTypeA, &SleepTypeB); - if (!ACPI_SUCCESS (Status)) + Status = AcpiHwGetSleepTypeData (SleepState, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* run the _PTS and _GTS methods */ + /* Setup parameter object */ - MEMSET(&ArgList, 0, sizeof(ArgList)); ArgList.Count = 1; ArgList.Pointer = &Arg; - MEMSET(&Arg, 0, sizeof(Arg)); Arg.Type = ACPI_TYPE_INTEGER; Arg.Integer.Value = SleepState; - AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL); - AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL); + /* Run the _PTS and _GTS methods */ + + Status = AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } return_ACPI_STATUS (AE_OK); } - /****************************************************************************** * * FUNCTION: AcpiEnterSleepState @@ -286,86 +279,93 @@ AcpiEnterSleepStatePrep ( ACPI_STATUS AcpiEnterSleepState ( - UINT8 SleepState) + UINT8 SleepState) { - UINT16 PM1AControl; - UINT16 PM1BControl; - UINT32 Retry; + UINT16 PM1AControl; + UINT16 PM1BControl; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 Retry; - FUNCTION_TRACE ("AcpiEnterSleepState"); + ACPI_FUNCTION_TRACE ("AcpiEnterSleepState"); - if ((SleepTypeA > ACPI_SLEEP_TYPE_MAX) || - (SleepTypeB > ACPI_SLEEP_TYPE_MAX)) + + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) { - REPORT_ERROR (("Sleep values out of range: A=%x B=%x\n", - SleepTypeA, SleepTypeB)); - return_ACPI_STATUS (AE_ERROR); + ACPI_REPORT_ERROR (("Sleep values out of range: A=%x B=%x\n", + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } - /* clear wake status */ - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1); + SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A); + SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + /* Clear wake status */ + + AcpiHwBitRegisterWrite (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_LOCK); AcpiHwClearAcpiStatus(); - /* disable arbitration here? */ + /* TBD: Disable arbitration here? */ AcpiHwDisableNonWakeupGpes(); - PM1AControl = (UINT16) AcpiHwRegisterRead (ACPI_MTX_LOCK, PM1_CONTROL); + /* Get current value of PM1A control */ + PM1AControl = (UINT16) AcpiHwRegisterRead (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL); ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Entering S%d\n", SleepState)); - /* mask off SLP_EN and SLP_TYP fields */ + /* Clear SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SLP_TYPE_X_MASK | SLP_EN_MASK); + PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask); PM1BControl = PM1AControl; - /* mask in SLP_TYP */ + /* Insert SLP_TYP bits */ - PM1AControl |= (SleepTypeA << AcpiHwGetBitShift (SLP_TYPE_X_MASK)); - PM1BControl |= (SleepTypeB << AcpiHwGetBitShift (SLP_TYPE_X_MASK)); + PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); + PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); - /* write #1: fill in SLP_TYP data */ + /* Write #1: fill in SLP_TYP data */ - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1A_CONTROL, PM1AControl); - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1B_CONTROL, PM1BControl); + AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); - /* mask in SLP_EN */ + /* Insert SLP_ENABLE bit */ - PM1AControl |= (1 << AcpiHwGetBitShift (SLP_EN_MASK)); - PM1BControl |= (1 << AcpiHwGetBitShift (SLP_EN_MASK)); + PM1AControl |= SleepEnableRegInfo->AccessBitMask; + PM1BControl |= SleepEnableRegInfo->AccessBitMask; - /* write #2: SLP_TYP + SLP_EN */ + /* Write #2: SLP_TYP + SLP_EN */ - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1A_CONTROL, PM1AControl); - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1B_CONTROL, PM1BControl); + AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); /* * Wait a second, then try again. This is to get S4/5 to work on all machines. */ if (SleepState > ACPI_STATE_S3) { - AcpiOsStall(1000000); + AcpiOsStall (1000000); - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1_CONTROL, - (1 << AcpiHwGetBitShift (SLP_EN_MASK))); + AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL, + SleepEnableRegInfo->AccessBitMask); } - /* wait until we enter sleep state */ + /* Wait until we enter sleep state */ - /* spin until we wake */ + /* Spin until we wake */ Retry = 1000; - while (!AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, WAK_STS)) + while (!AcpiHwBitRegisterRead (ACPI_BITREG_WAKE_STATUS, ACPI_MTX_LOCK)) { - /* - * Some BIOSes don't set WAK_STS at all, - * give up waiting for wakeup if we time out. - */ - if (Retry-- == 0) { - break; /* giving up */ - } + /* + * Some BIOSes don't set WAK_STS at all, + * give up waiting for wakeup if we time out. + */ + if (Retry-- == 0) { + break; /* giving up */ + } } return_ACPI_STATUS (AE_OK); @@ -389,23 +389,37 @@ AcpiLeaveSleepState ( { ACPI_OBJECT_LIST ArgList; ACPI_OBJECT Arg; + ACPI_STATUS Status; - FUNCTION_TRACE ("AcpiLeaveSleepState"); + ACPI_FUNCTION_TRACE ("AcpiLeaveSleepState"); + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ - SleepTypeA = ACPI_SLEEP_TYPE_INVALID; - MEMSET (&ArgList, 0, sizeof(ArgList)); + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; + + /* Setup parameter object */ + ArgList.Count = 1; ArgList.Pointer = &Arg; - MEMSET (&Arg, 0, sizeof(Arg)); Arg.Type = ACPI_TYPE_INTEGER; Arg.Integer.Value = SleepState; - AcpiEvaluateObject (NULL, "\\_BFS", &ArgList, NULL); - AcpiEvaluateObject (NULL, "\\_WAK", &ArgList, NULL); + /* Ignore any errors from these methods */ + + Status = AcpiEvaluateObject (NULL, "\\_BFS", &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status))); + } + + Status = AcpiEvaluateObject (NULL, "\\_WAK", &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status))); + } /* _WAK returns stuff - do we want to look at it? */ diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c index 2cc8625729f6..d51d3adde6cf 100644 --- a/sys/contrib/dev/acpica/psparse.c +++ b/sys/contrib/dev/acpica/psparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines - * $Revision: 109 $ + * $Revision: 119 $ * *****************************************************************************/ @@ -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 @@ -133,7 +133,7 @@ #include "acinterp.h" #define _COMPONENT ACPI_PARSER - MODULE_NAME ("psparse") + ACPI_MODULE_NAME ("psparse") UINT32 AcpiGbl_Depth = 0; @@ -191,7 +191,7 @@ AcpiPsPeekOpcode ( Aml = ParserState->Aml; - Opcode = (UINT16) GET8 (Aml); + Opcode = (UINT16) ACPI_GET8 (Aml); if (Opcode == AML_EXTOP) @@ -199,7 +199,7 @@ AcpiPsPeekOpcode ( /* Extended opcode */ Aml++; - Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml)); + Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml)); } return (Opcode); @@ -285,9 +285,16 @@ AcpiPsCompleteThisOp ( ACPI_PARSE_OBJECT *ReplacementOp = NULL; - FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + ACPI_FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + /* Check for null Op, can happen if AML code is corrupt */ + + if (!Op) + { + return_VALUE (TRUE); + } + /* Delete this op and the subtree below it if asked to */ if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && @@ -429,11 +436,9 @@ AcpiPsNextParseState ( { ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; ACPI_STATUS Status = AE_CTRL_PENDING; - UINT8 *Start; - UINT32 PackageLength; - FUNCTION_TRACE_PTR ("PsNextParseState", Op); + ACPI_FUNCTION_TRACE_PTR ("PsNextParseState", Op); switch (CallbackStatus) @@ -449,17 +454,22 @@ AcpiPsNextParseState ( break; + case AE_CTRL_BREAK: + + ParserState->Aml = WalkState->AmlLastWhile; + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_BREAK; + break; + + case AE_CTRL_CONTINUE: + + + ParserState->Aml = WalkState->AmlLastWhile; + Status = AE_CTRL_CONTINUE; + break; + case AE_CTRL_PENDING: - /* - * Predicate of a WHILE was true and the loop just completed an - * execution. Go back to the start of the loop and reevaluate the - * predicate. - */ - - /* TBD: How to handle a break within a while. */ - /* This code attempts it */ - ParserState->Aml = WalkState->AmlLastWhile; break; @@ -469,13 +479,8 @@ AcpiPsNextParseState ( /* * Predicate of an IF was true, and we are at the matching ELSE. * Just close out this package - * - * Note: ParserState->Aml is modified by the package length procedure - * TBD: [Investigate] perhaps it shouldn't, too much trouble */ - Start = ParserState->Aml; - PackageLength = AcpiPsGetNextPackageLength (ParserState); - ParserState->Aml = Start + PackageLength; + ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState); break; @@ -551,14 +556,14 @@ AcpiPsParseLoop ( UINT8 *AmlOpStart; - FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); + ACPI_FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); ParserState = &WalkState->ParserState; WalkState->ArgTypes = 0; #ifndef PARSER_ONLY - if (WalkState->WalkType & WALK_METHOD_RESTART) + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) { /* We are restarting a preempted control method */ @@ -573,7 +578,7 @@ AcpiPsParseLoop ( (ParserState->Scope->ParseScope.Op->Opcode == AML_WHILE_OP)) && (WalkState->ControlState) && (WalkState->ControlState->Common.State == - CONTROL_PREDICATE_EXECUTING)) + ACPI_CONTROL_PREDICATE_EXECUTING)) { /* @@ -581,7 +586,7 @@ AcpiPsParseLoop ( * predicate and branch based on that value */ WalkState->Op = NULL; - Status = AcpiDsGetPredicateValue (WalkState, TRUE); + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); if (ACPI_FAILURE (Status) && ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) { @@ -654,7 +659,7 @@ AcpiPsParseLoop ( "Found unknown opcode %X at AML offset %X, ignoring\n", WalkState->Opcode, WalkState->AmlOffset)); - DUMP_BUFFER (ParserState->Aml, 128); + ACPI_DUMP_BUFFER (ParserState->Aml, 128); /* Assume one-byte bad opcode */ @@ -800,8 +805,8 @@ AcpiPsParseLoop ( if (WalkState->OpInfo) { ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Op=%p Opcode=%4.4X Aml %p Oft=%5.5X\n", - Op, Op->Opcode, ParserState->Aml, Op->AmlOffset)); + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + Op->Opcode, WalkState->OpInfo->Name, Op, ParserState->Aml, Op->AmlOffset)); } } @@ -863,9 +868,9 @@ AcpiPsParseLoop ( * because we don't have enough info in the first pass * to parse them correctly. */ - ((ACPI_PARSE2_OBJECT * ) Op)->Data = ParserState->Aml; - ((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->PkgEnd - - ParserState->Aml); + ((ACPI_PARSE2_OBJECT * ) Op)->Data = ParserState->Aml; + ((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->PkgEnd - + ParserState->Aml); /* * Skip body of method. For OpRegions, we must continue @@ -873,173 +878,212 @@ AcpiPsParseLoop ( * package (We don't know where the end is). */ ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; + WalkState->ArgCount = 0; + } + else if (Op->Opcode == AML_WHILE_OP) + { + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = ParserState->PkgEnd; + } } - break; } } - /* - * Zero ArgCount means that all arguments for this op have been processed - */ - if (!WalkState->ArgCount) + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) { - /* completed Op, prepare for next */ + /* There are arguments (complex ones), push Op and prepare for argument */ - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); - if (WalkState->OpInfo->Flags & AML_NAMED) + AcpiPsPushScope (ParserState, Op, WalkState->ArgTypes, WalkState->ArgCount); + Op = NULL; + continue; + } + + + /* All arguments have been processed -- Op is complete, prepare for next */ + + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) { - if (AcpiGbl_Depth) - { - AcpiGbl_Depth--; - } - - if (Op->Opcode == AML_REGION_OP) - { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - * - * Completed parsing an OpRegion declaration, we now - * know the length. - */ - ((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->Aml - - ((ACPI_PARSE2_OBJECT * ) Op)->Data); - } + AcpiGbl_Depth--; } - if (WalkState->OpInfo->Flags & AML_CREATE) + if (Op->Opcode == AML_REGION_OP) { /* - * Backup to beginning of CreateXXXfield declaration (1 for - * Opcode) + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. * - * BodyLength is unknown until we parse the body + * Completed parsing an OpRegion declaration, we now + * know the length. */ ((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->Aml - ((ACPI_PARSE2_OBJECT * ) Op)->Data); } + } - /* This op complete, notify the dispatcher */ + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + ((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->Aml - + ((ACPI_PARSE2_OBJECT * ) Op)->Data); + } - if (WalkState->AscendingCallback != NULL) + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Opcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) { - WalkState->Op = Op; - WalkState->Opcode = Op->Opcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } + Status = AE_OK; + goto CloseThisOp; } + } CloseThisOp: + /* + * Finished one argument of the containing scope + */ + ParserState->Scope->ParseScope.ArgCount--; + + /* Close this Op (may result in parse subtree deletion) */ + + if (AcpiPsCompleteThisOp (WalkState, Op)) + { + Op = NULL; + } + + switch (Status) + { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + /* - * Finished one argument of the containing scope + * We are about to transfer to a called method. */ - ParserState->Scope->ParseScope.ArgCount--; + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); - /* Close this Op (may result in parse subtree deletion) */ - if (AcpiPsCompleteThisOp (WalkState, Op)) + case AE_CTRL_END: + + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); + + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + WalkState->Opcode = Op->Opcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + + AcpiPsCompleteThisOp (WalkState, Op); + Op = NULL; + Status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!Op || (Op->Opcode != AML_WHILE_OP)) { - Op = NULL; + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); } - switch (Status) + /* Close this iteration of the While loop */ + + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + WalkState->Opcode = Op->Opcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + + AcpiPsCompleteThisOp (WalkState, Op); + Op = NULL; + + Status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + Status = AE_OK; + + /* Clean up */ + do { - case AE_OK: - break; - - - case AE_CTRL_TRANSFER: - - /* - * We are about to transfer to a called method. - */ - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; - return_ACPI_STATUS (Status); - break; - - - case AE_CTRL_END: - - AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); - - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); - WalkState->Opcode = Op->Opcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - - AcpiPsCompleteThisOp (WalkState, Op); - Op = NULL; - Status = AE_OK; - break; - - - case AE_CTRL_TERMINATE: - - Status = AE_OK; - - /* Clean up */ - do + if (Op) { - if (Op) - { - AcpiPsCompleteThisOp (WalkState, Op); - } - AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); - - } while (Op); - - return_ACPI_STATUS (Status); - break; - - - default: /* All other non-AE_OK status */ - - if (Op == NULL) - { - AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); + AcpiPsCompleteThisOp (WalkState, Op); } - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); - /* - * TBD: TEMP: - */ - return_ACPI_STATUS (Status); - break; - } + } while (Op); - /* This scope complete? */ + return_ACPI_STATUS (Status); - if (AcpiPsHasCompletedScope (ParserState)) + + default: /* All other non-AE_OK status */ + + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + + /* + * TBD: Cleanup parse ops on error + */ +#if 0 + if (Op == NULL) { AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); - } - else - { - Op = NULL; } +#endif + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); } else { - /* ArgCount is non-zero */ - /* complex argument, push Op and prepare for argument */ - - AcpiPsPushScope (ParserState, Op, WalkState->ArgTypes, WalkState->ArgCount); Op = NULL; } @@ -1137,7 +1181,7 @@ AcpiPsParseAml ( - FUNCTION_TRACE ("PsParseAml"); + ACPI_FUNCTION_TRACE ("PsParseAml"); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%X\n", WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize)); @@ -1154,8 +1198,9 @@ AcpiPsParseAml ( WalkState->Thread = Thread; AcpiDsPushWalkState (WalkState, Thread); - - /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + /* + * This global allows the AML debugger to get a handle to the currently + * executing control method. */ AcpiGbl_CurrentWalkList = Thread; @@ -1243,14 +1288,23 @@ AcpiPsParseAml ( { if (ACPI_SUCCESS (Status)) { - /* There is another walk state, restart it */ - /* - * If the method returned value is not used by the parent, + * There is another walk state, restart it. + * If the method return value is not used by the parent, * The object is deleted */ AcpiDsRestartControlMethod (WalkState, PreviousWalkState->ReturnDesc); - WalkState->WalkType |= WALK_METHOD_RESTART; + WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; + } + else + { + /* On error, delete any return object */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + + ACPI_REPORT_ERROR (("Method execution failed, %s\n", AcpiFormatException (Status))); + ACPI_DUMP_PATHNAME (WalkState->MethodNode, "Method pathname: ", + ACPI_LV_ERROR, _COMPONENT); } } diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c index 60edaa5826fe..51e9934074b9 100644 --- a/sys/contrib/dev/acpica/rscreate.c +++ b/sys/contrib/dev/acpica/rscreate.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscreate - Create resource lists/tables - * $Revision: 38 $ + * $Revision: 53 $ * ******************************************************************************/ @@ -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 @@ -123,7 +123,7 @@ #include "acnamesp.h" #define _COMPONENT ACPI_RESOURCES - MODULE_NAME ("rscreate") + ACPI_MODULE_NAME ("rscreate") /******************************************************************************* @@ -148,17 +148,16 @@ ACPI_STATUS AcpiRsCreateResourceList ( ACPI_OPERAND_OBJECT *ByteStreamBuffer, - UINT8 *OutputBuffer, - UINT32 *OutputBufferLength) + ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; UINT8 *ByteStreamStart; - UINT32 ListSizeNeeded = 0; + ACPI_SIZE ListSizeNeeded = 0; UINT32 ByteStreamBufferLength; - FUNCTION_TRACE ("RsCreateResourceList"); + ACPI_FUNCTION_TRACE ("RsCreateResourceList"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamBuffer = %p\n", ByteStreamBuffer)); @@ -183,29 +182,25 @@ AcpiRsCreateResourceList ( return_ACPI_STATUS (Status); } - /* - * Is caller buffer large enough? - */ - if (ListSizeNeeded > *OutputBufferLength) - { - *OutputBufferLength = ListSizeNeeded; - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); - } + /* Validate/Allocate/Clear caller buffer */ - /* - * Zero out the return buffer before proceeding - */ - MEMSET (OutputBuffer, 0x00, *OutputBufferLength); - - Status = AcpiRsByteStreamToList (ByteStreamStart, ByteStreamBufferLength, - &OutputBuffer); + Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer)); - *OutputBufferLength = ListSizeNeeded; + /* Do the conversion */ + + Status = AcpiRsByteStreamToList (ByteStreamStart, ByteStreamBufferLength, + OutputBuffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } @@ -221,71 +216,68 @@ AcpiRsCreateResourceList ( * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be - * AE_BUFFER_OVERFLOW and OutputBufferLength will point + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point * to the size buffer needed. * * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a * linked list of PCI interrupt descriptions * + * NOTE: It is the caller's responsibility to ensure that the start of the + * output buffer is aligned properly (if necessary). + * ******************************************************************************/ ACPI_STATUS AcpiRsCreatePciRoutingTable ( ACPI_OPERAND_OBJECT *PackageObject, - UINT8 *OutputBuffer, - UINT32 *OutputBufferLength) + ACPI_BUFFER *OutputBuffer) { - UINT8 *Buffer = OutputBuffer; + UINT8 *Buffer; ACPI_OPERAND_OBJECT **TopObjectList = NULL; ACPI_OPERAND_OBJECT **SubObjectList = NULL; ACPI_OPERAND_OBJECT *PackageElement = NULL; - UINT32 BufferSizeNeeded = 0; + ACPI_SIZE BufferSizeNeeded = 0; UINT32 NumberOfElements = 0; UINT32 Index = 0; - PCI_ROUTING_TABLE *UserPrt = NULL; + ACPI_PCI_ROUTING_TABLE *UserPrt = NULL; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; + ACPI_BUFFER PathBuffer; - FUNCTION_TRACE ("RsCreatePciRoutingTable"); + ACPI_FUNCTION_TRACE ("RsCreatePciRoutingTable"); + /* Params already validated, so we don't re-validate here */ + /* - * Params already validated, so we don't re-validate here + * Get the required buffer length */ Status = AcpiRsCalculatePciRoutingTableLength (PackageObject, &BufferSizeNeeded); - if (!ACPI_SUCCESS(Status)) + if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", BufferSizeNeeded)); - /* Is caller buffer large enough? */ + /* Validate/Allocate/Clear caller buffer */ - if (BufferSizeNeeded > *OutputBufferLength) + Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); + if (ACPI_FAILURE (Status)) { - *OutputBufferLength = BufferSizeNeeded; - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + return_ACPI_STATUS (Status); } /* - * Zero out the return buffer before proceeding - */ - MEMSET (OutputBuffer, 0x00, *OutputBufferLength); - - /* - * Loop through the ACPI_INTERNAL_OBJECTS - Each object should - * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8 - * SourceIndex. + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should contain an + * ACPI_INTEGER Address, a UINT8 Pin, a Name and a UINT8 SourceIndex. */ TopObjectList = PackageObject->Package.Elements; NumberOfElements = PackageObject->Package.Count; - UserPrt = (PCI_ROUTING_TABLE *) Buffer; - - - Buffer = ROUND_PTR_UP_TO_8 (Buffer, UINT8); + Buffer = OutputBuffer->Pointer; + UserPrt = (ACPI_PCI_ROUTING_TABLE *) Buffer; for (Index = 0; Index < NumberOfElements; Index++) { @@ -296,15 +288,14 @@ AcpiRsCreatePciRoutingTable ( * be zero because we cleared the return buffer earlier */ Buffer += UserPrt->Length; - UserPrt = (PCI_ROUTING_TABLE *) Buffer; + UserPrt = (ACPI_PCI_ROUTING_TABLE *) Buffer; /* - * Fill in the Length field with the information we - * have at this point. - * The minus four is to subtract the size of the - * UINT8 Source[4] member because it is added below. + * Fill in the Length field with the information we have at this point. + * The minus four is to subtract the size of the UINT8 Source[4] member + * because it is added below. */ - UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) -4); + UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) -4); /* * Dereference the sub-package @@ -312,9 +303,8 @@ AcpiRsCreatePciRoutingTable ( PackageElement = *TopObjectList; /* - * The SubObjectList will now point to an array of - * the four IRQ elements: Address, Pin, Source and - * SourceIndex + * The SubObjectList will now point to an array of the four IRQ + * elements: Address, Pin, Source and SourceIndex */ SubObjectList = PackageElement->Package.Elements; @@ -368,37 +358,33 @@ AcpiRsCreatePciRoutingTable ( /* Use *remaining* length of the buffer as max for pathname */ - BufferSizeNeeded = *OutputBufferLength - - (UINT32) ((UINT8 *) UserPrt->Source - OutputBuffer); + PathBuffer.Length = OutputBuffer->Length - + (UINT32) ((UINT8 *) UserPrt->Source - (UINT8 *) OutputBuffer->Pointer); + PathBuffer.Pointer = UserPrt->Source; - Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node, - &BufferSizeNeeded, UserPrt->Source); + Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node, &PathBuffer); - UserPrt->Length += STRLEN (UserPrt->Source) + 1; /* include null terminator */ + UserPrt->Length += ACPI_STRLEN (UserPrt->Source) + 1; /* include null terminator */ break; case ACPI_TYPE_STRING: - STRCPY (UserPrt->Source, + ACPI_STRCPY (UserPrt->Source, (*SubObjectList)->String.Pointer); - /* - * Add to the Length field the length of the string - */ + /* Add to the Length field the length of the string */ + UserPrt->Length += (*SubObjectList)->String.Length; break; case ACPI_TYPE_INTEGER: /* - * If this is a number, then the Source Name - * is NULL, since the entire buffer was zeroed - * out, we can leave this alone. - */ - /* - * Add to the Length field the length of - * the UINT32 NULL + * If this is a number, then the Source Name is NULL, since the + * entire buffer was zeroed out, we can leave this alone. + * + * Add to the Length field the length of the UINT32 NULL */ UserPrt->Length += sizeof (UINT32); break; @@ -409,12 +395,11 @@ AcpiRsCreatePciRoutingTable ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n", AcpiUtGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); - break; } /* Now align the current length */ - UserPrt->Length = ROUND_UP_TO_64BITS (UserPrt->Length); + UserPrt->Length = ACPI_ROUND_UP_TO_64BITS (UserPrt->Length); /* * 4) Fourth subobject: Dereference the Source Index @@ -432,16 +417,13 @@ AcpiRsCreatePciRoutingTable ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * Point to the next ACPI_OPERAND_OBJECT - */ + /* Point to the next ACPI_OPERAND_OBJECT */ + TopObjectList++; } - /* - * Report the amount of buffer used - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } @@ -452,11 +434,10 @@ AcpiRsCreatePciRoutingTable ( * * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list * OutputBuffer - Pointer to the user's buffer - * OutputBufferLength - Size of OutputBuffer * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be - * AE_BUFFER_OVERFLOW and OutputBufferLength will point + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point * to the size buffer needed. * * DESCRIPTION: Takes the linked list of device resources and @@ -468,14 +449,13 @@ AcpiRsCreatePciRoutingTable ( ACPI_STATUS AcpiRsCreateByteStream ( ACPI_RESOURCE *LinkedListBuffer, - UINT8 *OutputBuffer, - UINT32 *OutputBufferLength) + ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; - UINT32 ByteStreamSizeNeeded = 0; + ACPI_SIZE ByteStreamSizeNeeded = 0; - FUNCTION_TRACE ("RsCreateByteStream"); + ACPI_FUNCTION_TRACE ("RsCreateByteStream"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", LinkedListBuffer)); @@ -496,28 +476,25 @@ AcpiRsCreateByteStream ( return_ACPI_STATUS (Status); } - /* - * Is caller buffer large enough? - */ - if (ByteStreamSizeNeeded > *OutputBufferLength) - { - *OutputBufferLength = ByteStreamSizeNeeded; - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); - } + /* Validate/Allocate/Clear caller buffer */ - /* - * Zero out the return buffer before proceeding - */ - MEMSET (OutputBuffer, 0x00, *OutputBufferLength); - - Status = AcpiRsListToByteStream (LinkedListBuffer, ByteStreamSizeNeeded, - &OutputBuffer); + Status = AcpiUtInitializeBuffer (OutputBuffer, ByteStreamSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer)); + /* Do the conversion */ + + Status = AcpiRsListToByteStream (LinkedListBuffer, ByteStreamSizeNeeded, + OutputBuffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c index ff8538bf57c1..896af03642d0 100644 --- a/sys/contrib/dev/acpica/tbget.c +++ b/sys/contrib/dev/acpica/tbget.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbget - ACPI Table get* routines - * $Revision: 57 $ + * $Revision: 63 $ * *****************************************************************************/ @@ -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 @@ -117,14 +117,11 @@ #define __TBGET_C__ #include "acpi.h" -#include "achware.h" #include "actables.h" #define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbget") - -#define RSDP_CHECKSUM_LENGTH 20 + ACPI_MODULE_NAME ("tbget") /******************************************************************************* @@ -152,7 +149,7 @@ AcpiTbGetTablePtr ( UINT32 i; - FUNCTION_TRACE ("TbGetTablePtr"); + ACPI_FUNCTION_TRACE ("TbGetTablePtr"); if (!AcpiGbl_DSDT) @@ -165,7 +162,6 @@ AcpiTbGetTablePtr ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* * For all table types (Single/Multiple), the first * instance is always in the list head. @@ -180,7 +176,6 @@ AcpiTbGetTablePtr ( return_ACPI_STATUS (AE_OK); } - /* * Check for instance out of range */ @@ -238,7 +233,7 @@ AcpiTbGetTable ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("TbGetTable"); + ACPI_FUNCTION_TRACE ("TbGetTable"); if (!TableInfo) @@ -246,7 +241,6 @@ AcpiTbGetTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (BufferPtr) { /* @@ -272,14 +266,13 @@ AcpiTbGetTable ( /* Copy the entire table (including header) to the local buffer */ Size = TableHeader->Length; - MEMCPY (FullTable, BufferPtr, Size); + ACPI_MEMCPY (FullTable, BufferPtr, Size); /* Save allocation type */ Allocation = ACPI_MEM_ALLOCATED; } - /* * Not reading from a buffer, just map the table's physical memory * into our address space. @@ -299,7 +292,6 @@ AcpiTbGetTable ( Allocation = ACPI_MEM_MAPPED; } - /* Return values */ TableInfo->Pointer = FullTable; @@ -335,7 +327,7 @@ AcpiTbGetAllTables ( ACPI_TABLE_DESC TableInfo; - FUNCTION_TRACE ("TbGetAllTables"); + ACPI_FUNCTION_TRACE ("TbGetAllTables"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Number of tables: %d\n", NumberOfTables)); @@ -349,7 +341,7 @@ AcpiTbGetAllTables ( { /* Clear the TableInfo each time */ - MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); + ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); /* Get the table via the XSDT */ @@ -385,7 +377,6 @@ AcpiTbGetAllTables ( } } - /* * Convert the FADT to a common format. This allows earlier revisions of the * table to coexist with newer versions, using common access code. @@ -396,7 +387,6 @@ AcpiTbGetAllTables ( return_ACPI_STATUS (Status); } - /* * Get the minimum set of ACPI tables, namely: * @@ -434,7 +424,6 @@ AcpiTbGetAllTables ( return_ACPI_STATUS (Status); } - /* * Get the DSDT (We know that the FADT is valid now) */ @@ -458,19 +447,18 @@ AcpiTbGetAllTables ( /* Dump the DSDT Header */ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of DSDT Header:\n")); - DUMP_BUFFER ((UINT8 *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); + ACPI_DUMP_BUFFER ((UINT8 *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); /* Dump the entire DSDT */ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of DSDT (After header), size %d (%x)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length)); - DUMP_BUFFER ((UINT8 *) (AcpiGbl_DSDT + 1), AcpiGbl_DSDT->Length); + ACPI_DUMP_BUFFER ((UINT8 *) (AcpiGbl_DSDT + 1), AcpiGbl_DSDT->Length); /* Always delete the RSDP mapping, we are done with it */ AcpiTbDeleteAcpiTable (ACPI_TABLE_RSDP); - return_ACPI_STATUS (Status); } @@ -493,17 +481,17 @@ AcpiTbVerifyRsdp ( { ACPI_TABLE_DESC TableInfo; ACPI_STATUS Status; - UINT8 *TablePtr; + RSDP_DESCRIPTOR *Rsdp; - FUNCTION_TRACE ("TbVerifyRsdp"); + ACPI_FUNCTION_TRACE ("TbVerifyRsdp"); /* * Obtain access to the RSDP structure */ Status = AcpiOsMapMemory (RsdpPhysicalAddress, sizeof (RSDP_DESCRIPTOR), - (void **) &TablePtr); + (void **) &Rsdp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -512,7 +500,7 @@ AcpiTbVerifyRsdp ( /* * The signature and checksum must both be correct */ - if (STRNCMP ((NATIVE_CHAR *) TablePtr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + if (ACPI_STRNCMP ((NATIVE_CHAR *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ @@ -520,22 +508,32 @@ AcpiTbVerifyRsdp ( goto Cleanup; } - if (AcpiTbChecksum (TablePtr, RSDP_CHECKSUM_LENGTH) != 0) - { - /* Nope, BAD Checksum */ + /* Check the standard checksum */ + if (AcpiTbChecksum (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + { Status = AE_BAD_CHECKSUM; goto Cleanup; } - /* TBD: Check extended checksum if table version >= 2 */ + /* Check extended checksum if table version >= 2 */ + + if (Rsdp->Revision >= 2) + { + if (AcpiTbChecksum (Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) + { + Status = AE_BAD_CHECKSUM; + goto Cleanup; + } + } + /* The RSDP supplied is OK */ - TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Pointer = (ACPI_TABLE_HEADER *) Rsdp; TableInfo.Length = sizeof (RSDP_DESCRIPTOR); TableInfo.Allocation = ACPI_MEM_MAPPED; - TableInfo.BasePointer = TablePtr; + TableInfo.BasePointer = Rsdp; /* Save the table pointers and allocation info */ @@ -545,7 +543,6 @@ AcpiTbVerifyRsdp ( goto Cleanup; } - /* Save the RSDP in a global for easy access */ AcpiGbl_RSDP = (RSDP_DESCRIPTOR *) TableInfo.Pointer; @@ -555,7 +552,7 @@ AcpiTbVerifyRsdp ( /* Error exit */ Cleanup: - AcpiOsUnmapMemory (TablePtr, sizeof (RSDP_DESCRIPTOR)); + AcpiOsUnmapMemory (Rsdp, sizeof (RSDP_DESCRIPTOR)); return_ACPI_STATUS (Status); } @@ -579,7 +576,7 @@ AcpiTbGetRsdtAddress (void) ACPI_PHYSICAL_ADDRESS PhysicalAddress; - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); /* @@ -588,14 +585,8 @@ AcpiTbGetRsdtAddress (void) */ if (AcpiGbl_RSDP->Revision < 2) { -#ifdef _IA64 - /* 0.71 RSDP has 64bit Rsdt address field */ - PhysicalAddress = ((RSDP_DESCRIPTOR_REV071 *)AcpiGbl_RSDP)->RsdtPhysicalAddress; -#else PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) AcpiGbl_RSDP->RsdtPhysicalAddress; -#endif } - else { PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) @@ -625,32 +616,31 @@ AcpiTbValidateRsdt ( UINT32 NoMatch; - PROC_NAME ("TbValidateRsdt"); + ACPI_FUNCTION_NAME ("TbValidateRsdt"); /* * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 (and above), we use the XSDT + * For RSDP revision 2 and above, we use the XSDT */ if (AcpiGbl_RSDP->Revision < 2) { - NoMatch = STRNCMP ((char *) TablePtr, RSDT_SIG, + NoMatch = ACPI_STRNCMP ((char *) TablePtr, RSDT_SIG, sizeof (RSDT_SIG) -1); } else { - NoMatch = STRNCMP ((char *) TablePtr, XSDT_SIG, + NoMatch = ACPI_STRNCMP ((char *) TablePtr, XSDT_SIG, sizeof (XSDT_SIG) -1); } - if (NoMatch) { /* Invalid RSDT or XSDT signature */ - REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); + ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); - DUMP_BUFFER (AcpiGbl_RSDP, 20); + ACPI_DUMP_BUFFER (AcpiGbl_RSDP, 20); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "RSDT/XSDT signature at %X is invalid\n", @@ -687,7 +677,7 @@ AcpiTbGetTablePointer ( ACPI_STATUS Status; - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) @@ -695,12 +685,10 @@ AcpiTbGetTablePointer ( *Size = SIZE_IN_HEADER; Status = AcpiTbMapAcpiTable (PhysicalAddress, Size, TablePtr); } - else { *Size = 0; - *TablePtr = (ACPI_TABLE_HEADER *) (ACPI_TBLPTR) PhysicalAddress; - + *TablePtr = ACPI_PHYSADDR_TO_PTR (PhysicalAddress); Status = AE_OK; } @@ -729,7 +717,7 @@ AcpiTbGetTableRsdt ( ACPI_PHYSICAL_ADDRESS PhysicalAddress; - FUNCTION_TRACE ("TbGetTableRsdt"); + ACPI_FUNCTION_TRACE ("TbGetTableRsdt"); /* @@ -737,13 +725,12 @@ AcpiTbGetTableRsdt ( */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", - AcpiGbl_RSDP, HIDWORD(AcpiGbl_RSDP->RsdtPhysicalAddress), - LODWORD(AcpiGbl_RSDP->RsdtPhysicalAddress))); - + AcpiGbl_RSDP, + ACPI_HIDWORD (AcpiGbl_RSDP->RsdtPhysicalAddress), + ACPI_LODWORD (AcpiGbl_RSDP->RsdtPhysicalAddress))); PhysicalAddress = AcpiTbGetRsdtAddress (); - /* Get the RSDT/XSDT */ Status = AcpiTbGetTable (PhysicalAddress, NULL, &TableInfo); @@ -754,7 +741,6 @@ AcpiTbGetTableRsdt ( return_ACPI_STATUS (Status); } - /* Check the RSDT or XSDT signature */ Status = AcpiTbValidateRsdt (TableInfo.Pointer); @@ -763,14 +749,12 @@ AcpiTbGetTableRsdt ( return_ACPI_STATUS (Status); } - /* * Valid RSDT signature, verify the checksum. If it fails, just * print a warning and ignore it. */ Status = AcpiTbVerifyTableChecksum (TableInfo.Pointer); - /* Convert and/or copy to an XSDT structure */ Status = AcpiTbConvertToXsdt (&TableInfo, NumberOfTables); @@ -790,7 +774,6 @@ AcpiTbGetTableRsdt ( AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", AcpiGbl_XSDT)); - return_ACPI_STATUS (Status); } @@ -823,7 +806,7 @@ AcpiTbGetTableFacs ( ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("TbGetTableFacs"); + ACPI_FUNCTION_TRACE ("TbGetTableFacs"); /* Must have a valid FADT pointer */ @@ -846,13 +829,12 @@ AcpiTbGetTableFacs ( return_ACPI_STATUS (AE_NO_MEMORY); } - MEMCPY (TablePtr, BufferPtr, Size); + ACPI_MEMCPY (TablePtr, BufferPtr, Size); /* Save allocation type */ Allocation = ACPI_MEM_ALLOCATED; } - else { /* Just map the physical memory to our address space */ @@ -869,7 +851,6 @@ AcpiTbGetTableFacs ( Allocation = ACPI_MEM_MAPPED; } - /* Return values */ TableInfo->Pointer = TablePtr;