From cc64c75258cdd65688e8a27806ad0417bec44bb0 Mon Sep 17 00:00:00 2001 From: msmith Date: Mon, 5 Mar 2001 02:15:19 +0000 Subject: Belated vendor update to the Intel ACPI CA 20010208 snapshot. --- sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c | 766 +++++++++++---------- sys/contrib/dev/acpica/Subsystem/Common/cmobject.c | 287 ++++---- sys/contrib/dev/acpica/Subsystem/Common/cmutils.c | 280 +++++++- sys/contrib/dev/acpica/Subsystem/Common/cmxface.c | 12 +- sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c | 74 +- .../dev/acpica/Subsystem/Debugger/dbfileio.c | 6 +- .../dev/acpica/Subsystem/Debugger/dbinput.c | 10 +- .../dev/acpica/Subsystem/Dispatcher/dsobject.c | 7 +- .../dev/acpica/Subsystem/Dispatcher/dsopcode.c | 5 +- sys/contrib/dev/acpica/Subsystem/Events/evevent.c | 91 ++- sys/contrib/dev/acpica/Subsystem/Events/evregion.c | 3 +- .../dev/acpica/Subsystem/Hardware/hwsleep.c | 11 +- .../dev/acpica/Subsystem/Hardware/hwtimer.c | 11 +- .../dev/acpica/Subsystem/Include/accommon.h | 63 +- .../dev/acpica/Subsystem/Include/acconfig.h | 9 +- sys/contrib/dev/acpica/Subsystem/Include/acdebug.h | 7 +- sys/contrib/dev/acpica/Subsystem/Include/acgcc.h | 7 +- .../dev/acpica/Subsystem/Include/acinterp.h | 8 +- sys/contrib/dev/acpica/Subsystem/Include/aclinux.h | 11 +- sys/contrib/dev/acpica/Subsystem/Include/aclocal.h | 21 +- .../dev/acpica/Subsystem/Include/acnamesp.h | 9 +- .../dev/acpica/Subsystem/Include/acoutput.h | 3 +- sys/contrib/dev/acpica/Subsystem/Include/actypes.h | 25 +- .../dev/acpica/Subsystem/Interpreter/amfldio.c | 5 +- .../dev/acpica/Subsystem/Interpreter/amstore.c | 7 +- .../dev/acpica/Subsystem/Interpreter/amstorob.c | 31 +- .../dev/acpica/Subsystem/Interpreter/amutils.c | 176 +---- .../dev/acpica/Subsystem/Namespace/nseval.c | 35 +- .../dev/acpica/Subsystem/Namespace/nsinit.c | 29 +- .../dev/acpica/Subsystem/Namespace/nsnames.c | 68 +- .../dev/acpica/Subsystem/Namespace/nsxfobj.c | 15 +- .../dev/acpica/Subsystem/Resources/rscalc.c | 30 +- .../dev/acpica/Subsystem/Resources/rscreate.c | 92 ++- .../dev/acpica/Subsystem/Resources/rsdump.c | 14 +- .../dev/acpica/Subsystem/Resources/rslist.c | 5 +- sys/contrib/dev/acpica/acconfig.h | 9 +- sys/contrib/dev/acpica/acdebug.h | 7 +- sys/contrib/dev/acpica/acgcc.h | 7 +- sys/contrib/dev/acpica/acinterp.h | 8 +- sys/contrib/dev/acpica/aclocal.h | 21 +- sys/contrib/dev/acpica/acnamesp.h | 9 +- sys/contrib/dev/acpica/acoutput.h | 3 +- sys/contrib/dev/acpica/actypes.h | 25 +- sys/contrib/dev/acpica/acutils.h | 63 +- sys/contrib/dev/acpica/dbcmds.c | 74 +- sys/contrib/dev/acpica/dbfileio.c | 6 +- sys/contrib/dev/acpica/dbinput.c | 10 +- sys/contrib/dev/acpica/dsobject.c | 7 +- sys/contrib/dev/acpica/dsopcode.c | 5 +- sys/contrib/dev/acpica/evevent.c | 91 ++- sys/contrib/dev/acpica/evregion.c | 3 +- sys/contrib/dev/acpica/exfldio.c | 5 +- sys/contrib/dev/acpica/exstore.c | 7 +- sys/contrib/dev/acpica/exstorob.c | 31 +- sys/contrib/dev/acpica/exutils.c | 176 +---- sys/contrib/dev/acpica/hwsleep.c | 11 +- sys/contrib/dev/acpica/hwtimer.c | 11 +- sys/contrib/dev/acpica/nseval.c | 35 +- sys/contrib/dev/acpica/nsinit.c | 29 +- sys/contrib/dev/acpica/nsnames.c | 68 +- sys/contrib/dev/acpica/nsxfobj.c | 15 +- sys/contrib/dev/acpica/rscalc.c | 30 +- sys/contrib/dev/acpica/rscreate.c | 92 ++- sys/contrib/dev/acpica/rsdump.c | 14 +- sys/contrib/dev/acpica/rslist.c | 5 +- sys/contrib/dev/acpica/utcopy.c | 766 +++++++++++---------- sys/contrib/dev/acpica/utmisc.c | 280 +++++++- sys/contrib/dev/acpica/utobject.c | 287 ++++---- sys/contrib/dev/acpica/utxface.c | 12 +- 69 files changed, 2530 insertions(+), 1925 deletions(-) (limited to 'sys/contrib/dev') diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c index f27d724..a081e83 100644 --- a/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmcopy - Internal to external object translation utilities - * $Revision: 62 $ + * $Revision: 66 $ * *****************************************************************************/ @@ -119,54 +119,43 @@ #include "acpi.h" #include "acinterp.h" #include "acnamesp.h" +#include "amlcode.h" #define _COMPONENT MISCELLANEOUS MODULE_NAME ("cmcopy") -typedef struct Search_st -{ - ACPI_OPERAND_OBJECT *InternalObj; - UINT32 Index; - ACPI_OBJECT *ExternalObj; - -} PKG_SEARCH_INFO; - - -/* Used to traverse nested packages */ -PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH]; - -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalSimpleObject + * FUNCTION: AcpiCmCopyIsimpleToEsimple * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *Buffer - Where the object is returned - * *SpaceUsed - Where the data length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *Buffer - Where the object is returned + * *SpaceUsed - Where the data length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to place a simple object in a user - * buffer. + * buffer. * * The buffer is assumed to have sufficient space for the object. * ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildExternalSimpleObject ( - ACPI_OPERAND_OBJECT *InternalObj, - ACPI_OBJECT *ExternalObj, +AcpiCmCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, UINT32 *BufferSpaceUsed) { UINT32 Length = 0; - UINT8 *SourcePtr = NULL; + ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("CmBuildExternalSimpleObject"); + FUNCTION_TRACE ("CmCopyIsimpleToEsimple"); /* @@ -174,7 +163,7 @@ AcpiCmBuildExternalSimpleObject ( * package element */ - if (!InternalObj) + if (!InternalObject) { *BufferSpaceUsed = 0; return_ACPI_STATUS (AE_OK); @@ -182,110 +171,217 @@ AcpiCmBuildExternalSimpleObject ( /* Always clear the external object */ - MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT)); + MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); /* * In general, the external object will be the same type as * the internal object */ - ExternalObj->Type = InternalObj->Common.Type; + ExternalObject->Type = InternalObject->Common.Type; /* However, only a limited number of external types are supported */ - switch (ExternalObj->Type) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: - Length = InternalObj->String.Length + 1; - ExternalObj->String.Length = InternalObj->String.Length; - ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace; - SourcePtr = (UINT8 *) InternalObj->String.Pointer; + Length = InternalObject->String.Length + 1; + ExternalObject->String.Length = InternalObject->String.Length; + ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; + MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, Length); break; case ACPI_TYPE_BUFFER: - Length = InternalObj->Buffer.Length; - ExternalObj->Buffer.Length = InternalObj->Buffer.Length; - ExternalObj->Buffer.Pointer = DataSpace; - SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer; + Length = InternalObject->Buffer.Length; + ExternalObject->Buffer.Length = InternalObject->Buffer.Length; + ExternalObject->Buffer.Pointer = DataSpace; + MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, Length); break; case ACPI_TYPE_INTEGER: - ExternalObj->Integer.Value= InternalObj->Integer.Value; + ExternalObject->Integer.Value= InternalObject->Integer.Value; break; case INTERNAL_TYPE_REFERENCE: /* - * This is an object reference. We use the object type of "Any" - * to indicate a reference object containing a handle to an ACPI - * named object. + * This is an object reference. Attempt to dereference it. */ - ExternalObj->Type = ACPI_TYPE_ANY; - ExternalObj->Reference.Handle = InternalObj->Reference.Node; + switch (InternalObject->Reference.OpCode) + { + case AML_ZERO_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = 0; + break; + + case AML_ONE_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = 1; + break; + + case AML_ONES_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = ACPI_INTEGER_MAX; + break; + + case AML_NAMEPATH_OP: + /* + * This is a named reference, get the string. We already know that + * we have room for it, use max length + */ + Length = MAX_STRING_LENGTH; + ExternalObject->Type = ACPI_TYPE_STRING; + ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; + Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) InternalObject->Reference.Node, + &Length, (char *) DataSpace); + break; + + default: + /* + * Use the object type of "Any" to indicate a reference + * to object containing a handle to an ACPI named object. + */ + ExternalObject->Type = ACPI_TYPE_ANY; + ExternalObject->Reference.Handle = InternalObject->Reference.Node; + break; + } break; case ACPI_TYPE_PROCESSOR: - ExternalObj->Processor.ProcId = - InternalObj->Processor.ProcId; - - ExternalObj->Processor.PblkAddress = - InternalObj->Processor.Address; - - ExternalObj->Processor.PblkLength = - InternalObj->Processor.Length; + ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; break; + case ACPI_TYPE_POWER: - ExternalObj->PowerResource.SystemLevel = - InternalObj->PowerResource.SystemLevel; + ExternalObject->PowerResource.SystemLevel = + InternalObject->PowerResource.SystemLevel; - ExternalObj->PowerResource.ResourceOrder = - InternalObj->PowerResource.ResourceOrder; + ExternalObject->PowerResource.ResourceOrder = + InternalObject->PowerResource.ResourceOrder; break; + default: - return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + /* + * There is no corresponding external object type + */ + return_ACPI_STATUS (AE_SUPPORT); break; } - /* Copy data if necessary (strings or buffers) */ - if (Length) + *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIelementToEelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + UINT32 ObjectSpace; + UINT32 ThisIndex; + ACPI_OBJECT *TargetObject; + + + + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + + + switch (ObjectType) { + case 0: + /* - * Copy the return data to the caller's buffer + * This is a simple or null object -- get the size */ - MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length); + + Status = AcpiCmCopyIsimpleToEsimple (SourceObject, + TargetObject, Info->FreeSpace, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + break; + + case 1: + + /* + * Build the package object + */ + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = (ACPI_OBJECT *) Info->FreeSpace; + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( + TargetObject->Package.Count * sizeof (ACPI_OBJECT)); + break; + + default: + return (AE_BAD_PARAMETER); } - *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; - return_ACPI_STATUS (AE_OK); + return (Status); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalPackageObject + * FUNCTION: AcpiCmCopyIpackageToEpackage * - * PARAMETERS: *InternalObj - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *SpaceUsed - Where the object length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the object length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to place a package object in a user * buffer. A package object by definition contains other objects. @@ -297,52 +393,37 @@ AcpiCmBuildExternalSimpleObject ( ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildExternalPackageObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, UINT32 *SpaceUsed) { - UINT8 *FreeSpace; - ACPI_OBJECT *ExternalObj; - UINT32 CurrentDepth = 0; + ACPI_OBJECT *ExternalObject; ACPI_STATUS Status; - UINT32 Length = 0; - UINT32 ThisIndex; - UINT32 ObjectSpace; - ACPI_OPERAND_OBJECT *ThisInternalObj; - ACPI_OBJECT *ThisExternalObj; - PKG_SEARCH_INFO *LevelPtr; + ACPI_PKG_INFO Info; - FUNCTION_TRACE ("CmBuildExternalPackageObject"); + FUNCTION_TRACE ("CmCopyIpackageToEpackage"); /* * First package at head of the buffer */ - ExternalObj = (ACPI_OBJECT *) Buffer; + ExternalObject = (ACPI_OBJECT *) Buffer; /* * Free space begins right after the first package */ - FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + Info.FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - /* - * Initialize the working variables - */ - MEMSET ((void *) Level, 0, sizeof (Level)); - - Level[0].InternalObj = InternalObj; - Level[0].ExternalObj = ExternalObj; - Level[0].Index = 0; - LevelPtr = &Level[0]; - CurrentDepth = 0; - - ExternalObj->Type = InternalObj->Common.Type; - ExternalObj->Package.Count = InternalObj->Package.Count; - ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = (ACPI_OBJECT *) Info.FreeSpace; /* @@ -350,144 +431,27 @@ AcpiCmBuildExternalPackageObject ( * and move the free space past it */ - FreeSpace += ExternalObj->Package.Count * - ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - - - while (1) - { - ThisIndex = LevelPtr->Index; - ThisInternalObj = - (ACPI_OPERAND_OBJECT *) - LevelPtr->InternalObj->Package.Elements[ThisIndex]; - ThisExternalObj = - (ACPI_OBJECT *) - &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - + Info.FreeSpace += ExternalObject->Package.Count * + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - /* - * Check for - * 1) Null object -- OK, this can happen if package - * element is never initialized - * 2) Not an internal object - can be Node instead - * 3) Any internal object other than a package. - * - * The more complex package case is handled later - */ - if ((!ThisInternalObj) || - (!VALID_DESCRIPTOR_TYPE ( - ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) || - (!IS_THIS_OBJECT_TYPE ( - ThisInternalObj, ACPI_TYPE_PACKAGE))) - { - /* - * This is a simple or null object -- get the size - */ + Status = AcpiCmWalkPackageTree (InternalObject, ExternalObject, + AcpiCmCopyIelementToEelement, &Info); - Status = - AcpiCmBuildExternalSimpleObject (ThisInternalObj, - ThisExternalObj, - FreeSpace, - &ObjectSpace); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= - LevelPtr->InternalObj->Package.Count) - { - /* - * We've handled all of the objects at this - * level. This means that we have just - * completed a package. That package may - * have contained one or more packages - * itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add - * the length of the package objects - * and get out - */ - *SpaceUsed = Length; - return_ACPI_STATUS (AE_OK); - } - - /* - * go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->Index++; - } - } + *SpaceUsed = Info.Length; + return_ACPI_STATUS (Status); - else - { - /* - * This object is a package - * -- we must go one level deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages - * for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("CmBuildPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - - /* - * Build the package object - */ - ThisExternalObj->Type = ACPI_TYPE_PACKAGE; - ThisExternalObj->Package.Count = - ThisInternalObj->Package.Count; - ThisExternalObj->Package.Elements = - (ACPI_OBJECT *) FreeSpace; - - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( - ThisExternalObj->Package.Count * - sizeof (ACPI_OBJECT)); - - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - CurrentDepth++; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->InternalObj = ThisInternalObj; - LevelPtr->ExternalObj = ThisExternalObj; - LevelPtr->Index = 0; - } - } } - -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalObject + * FUNCTION: AcpiCmCopyIobjectToEobject * - * PARAMETERS: *InternalObj - The internal object to be converted - * *BufferPtr - Where the object is returned + * PARAMETERS: *InternalObject - The internal object to be converted + * *BufferPtr - Where the object is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to build an API object to be returned to * the caller. @@ -495,26 +459,24 @@ AcpiCmBuildExternalPackageObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildExternalObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *InternalObject, ACPI_BUFFER *RetBuffer) { ACPI_STATUS Status; - FUNCTION_TRACE ("CmBuildExternalObject"); + FUNCTION_TRACE ("CmCopyIobjectToEobject"); - if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE)) + if (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE)) { /* - * Package objects contain other objects (which can be objects) - * buildpackage does it all + * Package object: Copy all subobjects (including + * nested packages) */ - Status = - AcpiCmBuildExternalPackageObject (InternalObj, - RetBuffer->Pointer, - &RetBuffer->Length); + Status = AcpiCmCopyIpackageToEpackage (InternalObject, + RetBuffer->Pointer, &RetBuffer->Length); } else @@ -522,13 +484,11 @@ AcpiCmBuildExternalObject ( /* * Build a simple object (no nested objects) */ - Status = - AcpiCmBuildExternalSimpleObject (InternalObj, - (ACPI_OBJECT *) RetBuffer->Pointer, - ((UINT8 *) RetBuffer->Pointer + - ROUND_UP_TO_NATIVE_WORD ( - sizeof (ACPI_OBJECT))), - &RetBuffer->Length); + Status = AcpiCmCopyIsimpleToEsimple (InternalObject, + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); /* * build simple does not include the object size in the length * so we add it in here @@ -540,14 +500,15 @@ AcpiCmBuildExternalObject ( } -/****************************************************************************** + +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalSimpleObject + * FUNCTION: AcpiCmCopyEsimpleToIsimple * - * PARAMETERS: *ExternalObj - The external object to be converted - * *InternalObj - Where the internal object is returned + * PARAMETERS: *ExternalObject - The external object to be converted + * *InternalObject - Where the internal object is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function copies an external object to an internal one. * NOTE: Pointers can be copied, we don't need to copy data. @@ -557,30 +518,30 @@ AcpiCmBuildExternalObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildInternalSimpleObject ( - ACPI_OBJECT *ExternalObj, - ACPI_OPERAND_OBJECT *InternalObj) +AcpiCmCopyEsimpleToIsimple ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT *InternalObject) { - FUNCTION_TRACE ("CmBuildInternalSimpleObject"); + FUNCTION_TRACE ("CmCopyEsimpleToIsimple"); - InternalObj->Common.Type = (UINT8) ExternalObj->Type; + InternalObject->Common.Type = (UINT8) ExternalObject->Type; - switch (ExternalObj->Type) + switch (ExternalObject->Type) { case ACPI_TYPE_STRING: - InternalObj->String.Length = ExternalObj->String.Length; - InternalObj->String.Pointer = ExternalObj->String.Pointer; + InternalObject->String.Length = ExternalObject->String.Length; + InternalObject->String.Pointer = ExternalObject->String.Pointer; break; case ACPI_TYPE_BUFFER: - InternalObj->Buffer.Length = ExternalObj->Buffer.Length; - InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer; + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + InternalObject->Buffer.Pointer = ExternalObject->Buffer.Pointer; break; @@ -588,7 +549,7 @@ AcpiCmBuildInternalSimpleObject ( /* * Number is included in the object itself */ - InternalObj->Integer.Value = ExternalObj->Integer.Value; + InternalObject->Integer.Value = ExternalObject->Integer.Value; break; @@ -606,11 +567,11 @@ AcpiCmBuildInternalSimpleObject ( /* Code to convert packages that are parameters to control methods */ -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalPackageObject + * FUNCTION: AcpiCmCopyEpackageToIpackage * - * PARAMETERS: *InternalObj - Pointer to the object we are returning + * PARAMETERS: *InternalObject - Pointer to the object we are returning * *Buffer - Where the object is returned * *SpaceUsed - Where the length of the object is returned * @@ -626,29 +587,27 @@ AcpiCmBuildInternalSimpleObject ( ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildInternalPackageObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyEpackageToIpackage ( + ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, UINT32 *SpaceUsed) { UINT8 *FreeSpace; - ACPI_OBJECT *ExternalObj; - UINT32 CurrentDepth = 0; + ACPI_OBJECT *ExternalObject; UINT32 Length = 0; UINT32 ThisIndex; UINT32 ObjectSpace = 0; ACPI_OPERAND_OBJECT *ThisInternalObj; ACPI_OBJECT *ThisExternalObj; - PKG_SEARCH_INFO *LevelPtr; - FUNCTION_TRACE ("CmBuildInternalPackageObject"); + FUNCTION_TRACE ("CmCopyEpackageToIpackage"); /* * First package at head of the buffer */ - ExternalObj = (ACPI_OBJECT *)Buffer; + ExternalObject = (ACPI_OBJECT *)Buffer; /* * Free space begins right after the first package @@ -656,20 +615,9 @@ AcpiCmBuildInternalPackageObject ( FreeSpace = Buffer + sizeof(ACPI_OBJECT); - /* - * Initialize the working variables - */ - - MEMSET ((void *) Level, 0, sizeof(Level)); - - Level[0].InternalObj = InternalObj; - Level[0].ExternalObj = ExternalObj; - LevelPtr = &Level[0]; - CurrentDepth = 0; - - ExternalObj->Type = InternalObj->Common.Type; - ExternalObj->Package.Count = InternalObj->Package.Count; - ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace; + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace; /* @@ -677,108 +625,21 @@ AcpiCmBuildInternalPackageObject ( * and move the free space past it */ - FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT); - - - while (1) - { - ThisIndex = LevelPtr->Index; - - ThisInternalObj = (ACPI_OPERAND_OBJECT *) - &LevelPtr->InternalObj->Package.Elements[ThisIndex]; - - ThisExternalObj = (ACPI_OBJECT *) - &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - - if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE)) - { - /* - * If this object is a package then we go one deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("CmBuildPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } + FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT); - /* - * Build the package object - */ - ThisExternalObj->Type = ACPI_TYPE_PACKAGE; - ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; - ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = ThisExternalObj->Package.Count * - sizeof (ACPI_OBJECT); + /* Call WalkPackage */ - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - CurrentDepth++; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->InternalObj = ThisInternalObj; - LevelPtr->ExternalObj = ThisExternalObj; - LevelPtr->Index = 0; - - } /* if object is a package */ - - else - { - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= - LevelPtr->InternalObj->Package.Count) - { - /* - * We've handled all of the objects at - * this level, This means that we have - * just completed a package. That package - * may have contained one or more packages - * itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add - * the length of the package objects - * and get out - */ - *SpaceUsed = Length; - return_ACPI_STATUS (AE_OK); - } - - /* - * go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->Index++; - } - } /* else object is NOT a package */ - } /* while (1) */ } #endif /* Future implementation */ -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalObject + * FUNCTION: AcpiCmCopyEobjectToIobject * - * PARAMETERS: *InternalObj - The external object to be converted + * PARAMETERS: *InternalObject - The external object to be converted * *BufferPtr - Where the internal object is returned * * RETURN: Status - the status of the call @@ -788,17 +649,17 @@ AcpiCmBuildInternalPackageObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildInternalObject ( - ACPI_OBJECT *ExternalObj, - ACPI_OPERAND_OBJECT *InternalObj) +AcpiCmCopyEobjectToIobject ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT *InternalObject) { ACPI_STATUS Status; - FUNCTION_TRACE ("CmBuildInternalObject"); + FUNCTION_TRACE ("AcpiCmCopyEobjectToIobject"); - if (ExternalObj->Type == ACPI_TYPE_PACKAGE) + if (ExternalObject->Type == ACPI_TYPE_PACKAGE) { /* * Package objects contain other objects (which can be objects) @@ -809,12 +670,12 @@ AcpiCmBuildInternalObject ( * control methods only. This is a very, very rare case. */ /* - Status = AcpiCmBuildInternalPackageObject(InternalObj, + Status = AcpiCmCopyEpackageToIpackage(InternalObject, RetBuffer->Pointer, &RetBuffer->Length); */ DEBUG_PRINT (ACPI_ERROR, - ("CmBuildInternalObject: Packages as parameters not implemented!\n")); + ("AcpiCmCopyEobjectToIobject: Packages as parameters not implemented!\n")); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } @@ -824,7 +685,7 @@ AcpiCmBuildInternalObject ( /* * Build a simple object (no nested objects) */ - Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj); + Status = AcpiCmCopyEsimpleToIsimple (ExternalObject, InternalObject); /* * build simple does not include the object size in the length * so we add it in here @@ -834,3 +695,146 @@ AcpiCmBuildInternalObject ( return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIelementToIelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT **ThisTargetPtr; + ACPI_OPERAND_OBJECT *TargetObject; + + + + ThisIndex = State->Pkg.Index; + ThisTargetPtr = (ACPI_OPERAND_OBJECT **) + &State->Pkg.DestObject->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case 0: + + /* + * This is a simple object, just copy it + */ + TargetObject = AcpiCmCreateInternalObject (SourceObject->Common.Type); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + Status = AcpiAmlStoreObjectToObject (SourceObject, TargetObject, + (ACPI_WALK_STATE *) Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *ThisTargetPtr = TargetObject; + break; + + + case 1: + /* + * This object is a package - go down another nesting level + * Create and build the package object + */ + TargetObject = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!TargetObject) + { + /* TBD: must delete package created up to this point */ + + return (AE_NO_MEMORY); + } + + TargetObject->Package.Count = SourceObject->Package.Count; + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Store the object pointer in the parent package object + */ + *ThisTargetPtr = TargetObject; + break; + + default: + return (AE_BAD_PARAMETER); + } + + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIpackageToIpackage + * + * PARAMETERS: *SourceObj - Pointer to the source package object + * *DestObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + FUNCTION_TRACE ("CmCopyIpackageToIpackage"); + + + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Package.Count = SourceObj->Package.Count; + + + /* + * Create the object array and walk the source package tree + */ + + DestObj->Package.Elements = AcpiCmCallocate ((SourceObj->Package.Count + 1) * + sizeof (void *)); + DestObj->Package.NextElement = DestObj->Package.Elements; + + if (!DestObj->Package.Elements) + { + REPORT_ERROR ( + ("AmlBuildCopyInternalPackageObject: Package allocation failure\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + Status = AcpiCmWalkPackageTree (SourceObj, DestObj, + AcpiCmCopyIelementToIelement, WalkState); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c index dd8bf22..13869b3 100644 --- a/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmobject - ACPI object create/delete/size/cache routines - * $Revision: 35 $ + * $Revision: 36 $ * *****************************************************************************/ @@ -127,7 +127,7 @@ MODULE_NAME ("cmobject") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: _CmCreateInternalObject * @@ -141,11 +141,11 @@ * * DESCRIPTION: Create and initialize a new internal object. * - * NOTE: - * We always allocate the worst-case object descriptor because these - * objects are cached, and we want them to be one-size-satisifies-any-request. - * This in itself may not be the most memory efficient, but the efficiency - * of the object cache should more than make up for this! + * NOTE: We always allocate the worst-case object descriptor because + * these objects are cached, and we want them to be + * one-size-satisifies-any-request. This in itself may not be + * the most memory efficient, but the efficiency of the object + * cache should more than make up for this! * ******************************************************************************/ @@ -187,7 +187,7 @@ _CmCreateInternalObject ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmValidInternalObject * @@ -195,7 +195,7 @@ _CmCreateInternalObject ( * * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT * - *****************************************************************************/ + ******************************************************************************/ BOOLEAN AcpiCmValidInternalObject ( @@ -257,7 +257,7 @@ AcpiCmValidInternalObject ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: _CmAllocateObjectDesc * @@ -271,7 +271,7 @@ AcpiCmValidInternalObject ( * DESCRIPTION: Allocate a new object descriptor. Gracefully handle * error conditions. * - ****************************************************************************/ + ******************************************************************************/ void * _CmAllocateObjectDesc ( @@ -341,7 +341,7 @@ _CmAllocateObjectDesc ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmDeleteObjectDesc * @@ -351,7 +351,7 @@ _CmAllocateObjectDesc ( * * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache * - ****************************************************************************/ + ******************************************************************************/ void AcpiCmDeleteObjectDesc ( @@ -414,7 +414,7 @@ AcpiCmDeleteObjectDesc ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmDeleteObjectCache * @@ -461,7 +461,7 @@ AcpiCmDeleteObjectCache ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmInitStaticObject * @@ -473,7 +473,7 @@ AcpiCmDeleteObjectCache ( * DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic * deletion of the object. * - ****************************************************************************/ + ******************************************************************************/ void AcpiCmInitStaticObject ( @@ -512,14 +512,14 @@ AcpiCmInitStaticObject ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmGetSimpleObjectSize * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain a simple object for return to an API user. @@ -531,19 +531,19 @@ AcpiCmInitStaticObject ( ACPI_STATUS AcpiCmGetSimpleObjectSize ( - ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OPERAND_OBJECT *InternalObject, UINT32 *ObjLength) { UINT32 Length; ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObj); + FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObject); /* Handle a null object (Could be a uninitialized package element -- which is legal) */ - if (!InternalObj) + if (!InternalObject) { *ObjLength = 0; return_ACPI_STATUS (AE_OK); @@ -554,7 +554,7 @@ AcpiCmGetSimpleObjectSize ( Length = sizeof (ACPI_OBJECT); - if (VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_NAMED)) + if (VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_NAMED)) { /* Object is a named object (reference), just return the length */ @@ -571,18 +571,18 @@ AcpiCmGetSimpleObjectSize ( * TBD:[Investigate] do strings and buffers require alignment also? */ - switch (InternalObj->Common.Type) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: - Length += InternalObj->String.Length + 1; + Length += InternalObject->String.Length + 1; break; case ACPI_TYPE_BUFFER: - Length += InternalObj->Buffer.Length; + Length += InternalObject->Buffer.Length; break; @@ -602,11 +602,11 @@ AcpiCmGetSimpleObjectSize ( * The only type that should be here is opcode AML_NAMEPATH_OP -- since * this means an object reference */ - if (InternalObj->Reference.OpCode != AML_NAMEPATH_OP) + if (InternalObject->Reference.OpCode != AML_NAMEPATH_OP) { DEBUG_PRINT (ACPI_ERROR, ("CmGetSimpleObjectSize: Unsupported Reference opcode=%X in object %p\n", - InternalObj->Reference.OpCode, InternalObj)); + InternalObject->Reference.OpCode, InternalObject)); Status = AE_TYPE; } break; @@ -616,7 +616,7 @@ AcpiCmGetSimpleObjectSize ( DEBUG_PRINT (ACPI_ERROR, ("CmGetSimpleObjectSize: Unsupported type=%X in object %p\n", - InternalObj->Common.Type, InternalObj)); + InternalObject->Common.Type, InternalObject)); Status = AE_TYPE; break; } @@ -634,161 +634,124 @@ AcpiCmGetSimpleObjectSize ( } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmGetPackageObjectSize + * FUNCTION: AcpiCmCopyPackageToInternal * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length is returned + * PARAMETERS: ACPI_PKG_CALLBACK * * RETURN: Status - the status of the call * - * DESCRIPTION: This function is called to determine the space required to contain - * a package object for return to an API user. - * - * This is moderately complex since a package contains other objects - * including packages. + * DESCRIPTION: * ******************************************************************************/ ACPI_STATUS -AcpiCmGetPackageObjectSize ( - ACPI_OPERAND_OBJECT *InternalObj, - UINT32 *ObjLength) +AcpiCmGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) { - - ACPI_OPERAND_OBJECT *ThisInternalObj; - ACPI_OPERAND_OBJECT *ParentObj[MAX_PACKAGE_DEPTH]; - ACPI_OPERAND_OBJECT *ThisParent; - UINT32 ThisIndex; - UINT32 Index[MAX_PACKAGE_DEPTH]; - UINT32 Length = 0; + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; UINT32 ObjectSpace; - UINT32 CurrentDepth = 0; - UINT32 PackageCount = 1; - ACPI_STATUS Status; - FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj); + switch (ObjectType) + { + case 0: + /* + * Simple object - just get the size (Null object/entry is handled + * here also) and sum it into the running package length + */ + Status = AcpiCmGetSimpleObjectSize (SourceObject, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - /* Init the package stack TBD: replace with linked list */ + Info->Length += ObjectSpace; + break; - MEMSET(ParentObj, 0, MAX_PACKAGE_DEPTH); - MEMSET(Index, 0, MAX_PACKAGE_DEPTH); - ParentObj[0] = InternalObj; + case 1: + /* Package - nothing much to do here, let the walk handle it */ - while (1) - { - ThisParent = ParentObj[CurrentDepth]; - ThisIndex = Index[CurrentDepth]; - ThisInternalObj = ThisParent->Package.Elements[ThisIndex]; + Info->NumPackages++; + State->Pkg.ThisTargetObj = NULL; + break; + default: + return (AE_BAD_PARAMETER); + } - /* - * Check for 1) An uninitialized package element. It is completely - * legal to declare a package and leave it uninitialized - * 2) Any type other than a package. Packages are handled - * below. - */ - if ((!ThisInternalObj) || - (!IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))) - { - /* - * Simple object - just get the size (Null object/entry handled - * also) - */ - - Status = - AcpiCmGetSimpleObjectSize (ThisInternalObj, &ObjectSpace); - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length += ObjectSpace; - - Index[CurrentDepth]++; - while (Index[CurrentDepth] >= - ParentObj[CurrentDepth]->Package.Count) - { - /* - * We've handled all of the objects at - * this level, This means that we have - * just completed a package. That package - * may have contained one or more packages - * itself. - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add the - * length of the package objects and - * get out. Round up to the next machine - * word. - */ - Length += - ROUND_UP_TO_NATIVE_WORD ( - sizeof (ACPI_OBJECT)) * - PackageCount; - - *ObjLength = Length; - - return_ACPI_STATUS (AE_OK); - } - - /* - * Go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - Index[CurrentDepth]++; - } - } + return (Status); +} - else - { - /* - * This object is a package - * -- go one level deeper - */ - PackageCount++; - if (CurrentDepth < MAX_PACKAGE_DEPTH-1) - { - CurrentDepth++; - ParentObj[CurrentDepth] = ThisInternalObj; - Index[CurrentDepth] = 0; - } - - else - { - /* - * Too many nested levels of packages for us - * to handle - */ - - DEBUG_PRINT (ACPI_ERROR, - ("CmGetPackageObjectSize: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - } - } + +/******************************************************************************* + * + * FUNCTION: AcpiCmGetPackageObjectSize + * + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a package object for return to an API user. + * + * This is moderately complex since a package contains other + * objects including packages. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT32 *ObjLength) +{ + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObject); + + + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + Status = AcpiCmWalkPackageTree (InternalObject, NULL, + AcpiCmGetElementLength, &Info); + + /* + * We have handled all of the objects in all levels of the package. + * just add the length of the package objects themselves. + * Round up to the next machine word. + */ + Info.Length += ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * + Info.NumPackages; + + /* Return the total package length */ + + *ObjLength = Info.Length; + return_ACPI_STATUS (Status); } -/****************************************************************************** + +/******************************************************************************* * * FUNCTION: AcpiCmGetObjectSize * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length will be returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length will be returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain an object for return to an API user. @@ -797,23 +760,21 @@ AcpiCmGetPackageObjectSize ( ACPI_STATUS AcpiCmGetObjectSize( - ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OPERAND_OBJECT *InternalObject, UINT32 *ObjLength) { ACPI_STATUS Status; - if ((VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_INTERNAL)) && - (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))) + if ((VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_INTERNAL)) && + (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE))) { - Status = - AcpiCmGetPackageObjectSize (InternalObj, ObjLength); + Status = AcpiCmGetPackageObjectSize (InternalObject, ObjLength); } else { - Status = - AcpiCmGetSimpleObjectSize (InternalObj, ObjLength); + Status = AcpiCmGetSimpleObjectSize (InternalObject, ObjLength); } return (Status); diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c index 2c9c60d..123e4e1 100644 --- a/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: cmutils - common utility procedures - * $Revision: 23 $ + * $Revision: 27 $ * ******************************************************************************/ @@ -476,6 +476,44 @@ AcpiCmCreateUpdateStateAndPush ( /******************************************************************************* * + * FUNCTION: AcpiCmCreatePkgStateAndPush + * + * PARAMETERS: *Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: None + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + + State = AcpiCmCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + + AcpiCmPushGenericState (StateList, State); + return (AE_OK); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiCmPushGenericState * * PARAMETERS: ListHead - Head of the state stack @@ -650,6 +688,54 @@ AcpiCmCreateUpdateState ( /******************************************************************************* * + * FUNCTION: AcpiCmCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the + * state + * Action - Update action to be performed + * + * RETURN: Status + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmCreatePkgState", InternalObject); + + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + /* Init fields specific to the update struct */ + + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index = Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiCmCreateControlState * * PARAMETERS: None @@ -793,19 +879,24 @@ ACPI_STATUS AcpiCmResolvePackageReferences ( ACPI_OPERAND_OBJECT *ObjDesc) { - UINT32 Count; - ACPI_OPERAND_OBJECT *SubObject; + UINT32 Count; + ACPI_OPERAND_OBJECT *SubObject; + FUNCTION_TRACE ("AcpiCmResolvePackageReferences"); + if (ObjDesc->Common.Type != ACPI_TYPE_PACKAGE) { - /* Must be a package */ + /* The object must be a package */ REPORT_ERROR (("Must resolve Package Refs on a Package\n")); return_ACPI_STATUS(AE_ERROR); } + /* + * TBD: what about nested packages? */ + for (Count = 0; Count < ObjDesc->Package.Count; Count++) { SubObject = ObjDesc->Package.Elements[Count]; @@ -833,6 +924,181 @@ AcpiCmResolvePackageReferences ( return_ACPI_STATUS(AE_OK); } +#ifdef ACPI_DEBUG + +/****************************************************************************** + * + * FUNCTION: AcpiCmDisplayInitPathname + * + * PARAMETERS: ObjHandle - Handle whose pathname will be displayed + * Path - Additional path string to be appended + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY + * + *****************************************************************************/ + +void +AcpiCmDisplayInitPathname ( + ACPI_HANDLE ObjHandle, + char *Path) +{ + ACPI_STATUS Status; + UINT32 Length = 128; + char Buffer[128]; + + + Status = AcpiNsHandleToPathname (ObjHandle, &Length, Buffer); + if (ACPI_SUCCESS (Status)) + { + if (Path) + { + DEBUG_PRINT (TRACE_INIT, ("%s.%s\n", Buffer, Path)) + } + else + { + DEBUG_PRINT (TRACE_INIT, ("%s\n", Buffer)) + } + } +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiCmWalkPackageTree + * + * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT *ThisSourceObj; + + + FUNCTION_TRACE ("AcpiCmWalkPackageTree"); + + + State = AcpiCmCreatePkgState (SourceObject, TargetObject, 0); + if (!State) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + while (State) + { + ThisIndex = State->Pkg.Index; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) + State->Pkg.SourceObject->Package.Elements[ThisIndex]; + + /* + * Check for + * 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Not an internal object - can be a namespace node instead + * 3) Any type other than a package. Packages are handled in else case below. + */ + if ((!ThisSourceObj) || + (!VALID_DESCRIPTOR_TYPE ( + ThisSourceObj, ACPI_DESC_TYPE_INTERNAL)) || + (!IS_THIS_OBJECT_TYPE ( + ThisSourceObj, ACPI_TYPE_PACKAGE))) + { + + Status = WalkCallback (0, ThisSourceObj, State, Context); + if (ACPI_FAILURE (Status)) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (Status); + } + + State->Pkg.Index++; + while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + { + /* + * We've handled all of the objects at this level, This means + * that we have just completed a package. That package may + * have contained one or more packages itself. + * + * Delete this state and pop the previous state (package). + */ + AcpiCmDeleteGenericState (State); + State = AcpiCmPopGenericState (&StateList); + + + /* Finished when there are no more states */ + + if (!State) + { + /* + * We have handled all of the objects in the top level + * package just add the length of the package objects + * and exit + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index past the just + * completed package object. + */ + State->Pkg.Index++; + } + } + + else + { + /* This is a sub-object of type package */ + + Status = WalkCallback (1, ThisSourceObj, State, Context); + if (ACPI_FAILURE (Status)) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (Status); + } + + + /* + * The callback above returned a new target package object. + */ + + /* + * Push the current state and create a new one + */ + AcpiCmPushGenericState (&StateList, State); + State = AcpiCmCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0); + if (!State) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + } + + /* We should never get here */ + + return (AE_AML_INTERNAL); + +} + + /******************************************************************************* * @@ -845,7 +1111,7 @@ AcpiCmResolvePackageReferences ( * * RETURN: None * - * DESCRIPTION: Print error message from KD table + * DESCRIPTION: Print error message * ******************************************************************************/ @@ -872,7 +1138,7 @@ _ReportError ( * * RETURN: None * - * DESCRIPTION: Print warning message from KD table + * DESCRIPTION: Print warning message * ******************************************************************************/ @@ -898,7 +1164,7 @@ _ReportWarning ( * * RETURN: None * - * DESCRIPTION: Print information message from KD table + * DESCRIPTION: Print information message * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c index 2376295..92312b9 100644 --- a/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmxface - External interfaces for "global" ACPI functions - * $Revision: 62 $ + * $Revision: 64 $ * *****************************************************************************/ @@ -272,9 +272,8 @@ AcpiEnableSubsystem ( Status = AcpiEnable (); if (ACPI_FAILURE (Status)) { - /* TBD: workaround. Old Lions don't enable properly */ DEBUG_PRINT(ACPI_WARN, ("AcpiEnable failed.\n")); - /*return_ACPI_STATUS (Status);*/ + return_ACPI_STATUS (Status); } } @@ -299,15 +298,14 @@ AcpiEnableSubsystem ( /* * Initialize all device objects in the namespace - * This runs the _STA, _INI, and _HID methods, and detects - * the PCI root bus(es) + * This runs the _STA and _INI methods. */ if (!(Flags & ACPI_NO_DEVICE_INIT)) { DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Devices\n")); - Status = AcpiNsInitializeDevices (Flags & ACPI_NO_PCI_INIT); + Status = AcpiNsInitializeDevices (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -316,7 +314,7 @@ AcpiEnableSubsystem ( /* - * Initialize the objects that remain unitialized. This + * Initialize the objects that remain uninitialized. This * runs the executable AML that is part of the declaration of OpRegions * and Fields. */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c index 33f8481..b48e7ea 100644 --- a/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * $Revision: 45 $ + * $Revision: 46 $ * ******************************************************************************/ @@ -995,4 +995,76 @@ AcpiDbSetScope ( AcpiOsPrintf ("New scope: %s\n", ScopeBuf); } + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResources + * + * PARAMETERS: ObjectArg - String with hex value of the object + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +void +AcpiDbDisplayResources ( + NATIVE_CHAR *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_BUFFER ReturnObj; + PCI_ROUTING_TABLE *Prt; + UINT32 i; + + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + + /* Convert string to object pointer */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); + + /* Prepare for a return object of arbitrary size */ + + ReturnObj.Pointer = Buffer; + ReturnObj.Length = BUFFER_SIZE; + + Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiCmFormatException (Status)); + goto Cleanup; + } + + ReturnObj.Pointer = Buffer; + ReturnObj.Length = BUFFER_SIZE; + + Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiCmFormatException (Status)); + goto Cleanup; + } + + Prt = (PCI_ROUTING_TABLE *) Buffer; + i = 0; + while ((char *) Prt < (Buffer + ReturnObj.Length)) + { + AcpiOsPrintf ("Prt[%d] Src=%s: Addr=%X\n", i, Prt->Source, Prt->Address); + i++; + Prt = (PCI_ROUTING_TABLE *) (((char *) Prt) + Prt->Length); + } + +Cleanup: + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return; + +} + + + + + #endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c index 367a838..e547839 100644 --- a/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c @@ -2,7 +2,7 @@ * * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * $Revision: 37 $ + * $Revision: 38 $ * ******************************************************************************/ @@ -240,6 +240,10 @@ AcpiDbOpenDebugFile ( STRCPY (DebugFilename, Name); OutputToFile = TRUE; } + else + { + AcpiOsPrintf ("Could not open debug file %s\n", Name); + } #endif } diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c index 0d191c6..812dbfe 100644 --- a/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * $Revision: 54 $ + * $Revision: 56 $ * ******************************************************************************/ @@ -153,6 +153,7 @@ BOOLEAN opt_disasm = FALSE; BOOLEAN opt_stats = FALSE; BOOLEAN opt_parse_jit = FALSE; BOOLEAN opt_verbose = TRUE; +BOOLEAN opt_ini_methods = TRUE; /* @@ -199,6 +200,7 @@ enum AcpiAmlDebuggerCommands CMD_PREFIX, CMD_QUIT, CMD_REFERENCES, + CMD_RESOURCES, CMD_RESULTS, CMD_SET, CMD_STATS, @@ -251,6 +253,7 @@ COMMAND_INFO Commands[] = {"PREFIX", 0}, {"QUIT", 0}, {"REFERENCES", 1}, + {"RESOURCES", 1}, {"RESULTS", 0}, {"SET", 3}, {"STATS", 0}, @@ -337,6 +340,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); AcpiOsPrintf ("References Find all references to object at addr\n"); + AcpiOsPrintf ("Resources xxx Get and display resources\n"); AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); AcpiOsPrintf ("Thread Spawn threads to execute method(s)\n"); return; @@ -765,6 +769,10 @@ AcpiDbCommandDispatch ( AcpiDbFindReferences (Args[1]); break; + case CMD_RESOURCES: + AcpiDbDisplayResources (Args[1]); + break; + case CMD_RESULTS: AcpiDbDisplayResults (); break; diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c index 870fd32..13bf56a 100644 --- a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 56 $ + * $Revision: 57 $ * *****************************************************************************/ @@ -194,7 +194,10 @@ AcpiDsInitOneObject ( Info->MethodCount++; - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } /* * Set the execution data width (32 or 64) based upon the diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c index 1a736ff..5153537 100644 --- a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 30 $ + * $Revision: 32 $ * *****************************************************************************/ @@ -169,6 +169,7 @@ AcpiDsGetFieldUnitArguments ( ExtraDesc = ObjDesc->FieldUnit.Extra; Node = ObjDesc->FieldUnit.Node; + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, " [Field]")); DEBUG_PRINT (TRACE_EXEC, ("DsGetFieldUnitArguments: [%4.4s] FieldUnit JIT Init\n", &Node->Name)); @@ -289,6 +290,8 @@ AcpiDsGetRegionArguments ( ExtraDesc = ObjDesc->Region.Extra; Node = ObjDesc->Region.Node; + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, " [Operation Region]")); + DEBUG_PRINT (TRACE_EXEC, ("DsGetRegionArguments: [%4.4s] OpRegion Init at AML %p[%x]\n", &Node->Name, ExtraDesc->Extra.Pcode, *(UINT32*) ExtraDesc->Extra.Pcode)); diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evevent.c b/sys/contrib/dev/acpica/Subsystem/Events/evevent.c index 30f06e0..2738ea8 100644 --- a/sys/contrib/dev/acpica/Subsystem/Events/evevent.c +++ b/sys/contrib/dev/acpica/Subsystem/Events/evevent.c @@ -2,7 +2,7 @@ * * Module Name: evevent - Fixed and General Purpose AcpiEvent * handling and dispatch - * $Revision: 33 $ + * $Revision: 34 $ * *****************************************************************************/ @@ -149,7 +149,7 @@ AcpiEvInitialize ( FUNCTION_TRACE ("EvInitialize"); - /* Make sure we've got ACPI tables */ + /* Make sure we have ACPI tables */ if (!AcpiGbl_DSDT) { @@ -871,7 +871,7 @@ UINT32 AcpiEvGpeDispatch ( UINT32 GpeNumber) { - ACPI_GPE_LEVEL_INFO GpeInfo; + ACPI_GPE_LEVEL_INFO GpeInfo; FUNCTION_TRACE ("EvGpeDispatch"); @@ -891,65 +891,64 @@ AcpiEvGpeDispatch ( */ AcpiHwDisableGpe (GpeNumber); - GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; + GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; - /* - * Edge-Triggered? - * --------------- - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if (GpeInfo.Type & ACPI_EVENT_EDGE_TRIGGERED) + /* + * Edge-Triggered? + * --------------- + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if (GpeInfo.Type & ACPI_EVENT_EDGE_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } - + AcpiHwClearGpe (GpeNumber); + } /* * Function Handler (e.g. EC)? */ - if (GpeInfo.Handler) + if (GpeInfo.Handler) { - /* Invoke function handler (at interrupt level). */ - GpeInfo.Handler (GpeInfo.Context); + /* Invoke function handler (at interrupt level). */ + GpeInfo.Handler (GpeInfo.Context); - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) + /* Level-Triggered? */ + if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } - - /* Enable GPE */ - AcpiHwEnableGpe (GpeNumber); + AcpiHwClearGpe (GpeNumber); } - /* - * Method Handler (e.g. _Exx/_Lxx)? - */ - else if (GpeInfo.MethodHandle) + + /* Enable GPE */ + AcpiHwEnableGpe (GpeNumber); + } + /* + * Method Handler (e.g. _Exx/_Lxx)? + */ + else if (GpeInfo.MethodHandle) { - if (ACPI_FAILURE(AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + if (ACPI_FAILURE(AcpiOsQueueForExecution (OSD_PRIORITY_GPE, AcpiEvAsynchExecuteGpeMethod, (void*)(NATIVE_UINT)GpeNumber))) - { - /* - * Shoudn't occur, but if it does report an error. Note that - * the GPE will remain disabled until the ACPI Core Subsystem - * is restarted, or the handler is removed/reinstalled. - */ - REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE bit [%X]\n", GpeNumber)); - } + { + /* + * Shoudn't occur, but if it does report an error. Note that + * the GPE will remain disabled until the ACPI Core Subsystem + * is restarted, or the handler is removed/reinstalled. + */ + REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE bit [%X]\n", GpeNumber)); } - /* - * No Handler? Report an error and leave the GPE disabled. - */ - else + } + /* + * No Handler? Report an error and leave the GPE disabled. + */ + else { - REPORT_ERROR (("AcpiEvGpeDispatch: No installed handler for GPE [%X]\n", GpeNumber)); + REPORT_ERROR (("AcpiEvGpeDispatch: No installed handler for GPE [%X]\n", GpeNumber)); - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) + /* Level-Triggered? */ + if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } + AcpiHwClearGpe (GpeNumber); } + } return_VALUE (INTERRUPT_HANDLED); } diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evregion.c b/sys/contrib/dev/acpica/Subsystem/Events/evregion.c index 49d5d3f..e9ebad9 100644 --- a/sys/contrib/dev/acpica/Subsystem/Events/evregion.c +++ b/sys/contrib/dev/acpica/Subsystem/Events/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 94 $ + * $Revision: 96 $ * *****************************************************************************/ @@ -262,6 +262,7 @@ AcpiEvExecuteRegMethod ( /* * Execute the method, no return value */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (RegionObj->Region.Extra->Extra.Method_REG, " [Method]")); Status = AcpiNsEvaluateByHandle (RegionObj->Region.Extra->Extra.Method_REG, Params, NULL); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwsleep.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwsleep.c index 81305a8..ba7b341 100644 --- a/sys/contrib/dev/acpica/Subsystem/Hardware/hwsleep.c +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 5 $ + * $Revision: 7 $ * *****************************************************************************/ @@ -282,15 +282,14 @@ AcpiEnterSleepState ( DEBUG_PRINT(ACPI_OK, ("Entering S%d\n", SleepState)); - /* the old version was disabling interrupts. let's try it without - * and see how that works - */ - /*disable();*/ + disable(); AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1A_CONTROL, PM1AControl); AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1B_CONTROL, PM1BControl); + AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1_CONTROL, + (1 << AcpiHwGetBitShift (SLP_EN_MASK))); - /*enable();*/ + enable(); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwtimer.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwtimer.c index 197c65c..52139ed 100644 --- a/sys/contrib/dev/acpica/Subsystem/Hardware/hwtimer.c +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwtimer.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * $Revision: 4 $ + * $Revision: 5 $ * *****************************************************************************/ @@ -235,7 +235,7 @@ AcpiGetTimerDuration ( /* * Compute Tick Delta: * ------------------- - * Handle timer rollovers on 24- versus 32-bit timers. + * Handle (max one) timer rollovers on 24- versus 32-bit timers. */ if (StartTicks < EndTicks) { @@ -246,7 +246,7 @@ AcpiGetTimerDuration ( /* 24-bit Timer */ if (0 == AcpiGbl_FADT->TmrValExt) { - DeltaTicks = (0x00FFFFFF - StartTicks) + EndTicks; + DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); } /* 32-bit Timer */ else @@ -254,6 +254,11 @@ AcpiGetTimerDuration ( DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; } } + else + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } /* * Compute Duration: diff --git a/sys/contrib/dev/acpica/Subsystem/Include/accommon.h b/sys/contrib/dev/acpica/Subsystem/Include/accommon.h index 7ae0299..3872386 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/accommon.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/accommon.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures - * $Revision: 87 $ + * $Revision: 90 $ * *****************************************************************************/ @@ -118,6 +118,32 @@ #define _ACCOMMON_H + +typedef +ACPI_STATUS (*ACPI_PKG_CALLBACK) ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + + + +ACPI_STATUS +AcpiCmWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + + +typedef struct acpi_pkg_info +{ + UINT8 *FreeSpace; + UINT32 Length; + UINT32 ObjectSpace; + UINT32 NumPackages; +} ACPI_PKG_INFO; + #define REF_INCREMENT (UINT16) 0 #define REF_DECREMENT (UINT16) 1 #define REF_FORCE_DELETE (UINT16) 2 @@ -285,29 +311,30 @@ AcpiCmBuildPackageObject ( UINT32 *SpaceUsed); ACPI_STATUS -AcpiCmBuildExternalObject ( +AcpiCmCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *Obj, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiCmBuildInternalSimpleObject( +AcpiCmCopyEsimpleToIsimple( ACPI_OBJECT *UserObj, ACPI_OPERAND_OBJECT *Obj); ACPI_STATUS -AcpiCmBuildInternalObject ( +AcpiCmCopyEobjectToIobject ( ACPI_OBJECT *Obj, ACPI_OPERAND_OBJECT *InternalObj); ACPI_STATUS -AcpiCmCopyInternalSimpleObject ( +AcpiCmCopyISimpleToIsimple ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj); ACPI_STATUS -AcpiCmBuildCopyInternalPackageObject ( +AcpiCmCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj); + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); /* @@ -617,12 +644,25 @@ AcpiCmCreateUpdateState ( ACPI_OPERAND_OBJECT *Object, UINT16 Action); +ACPI_GENERIC_STATE * +AcpiCmCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index); + ACPI_STATUS AcpiCmCreateUpdateStateAndPush ( ACPI_OPERAND_OBJECT *Object, UINT16 Action, ACPI_GENERIC_STATE **StateList); +ACPI_STATUS +AcpiCmCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList); + ACPI_GENERIC_STATE * AcpiCmCreateControlState ( void); @@ -655,6 +695,15 @@ ACPI_STATUS AcpiCmResolvePackageReferences ( ACPI_OPERAND_OBJECT *ObjDesc); +#ifdef ACPI_DEBUG + +void +AcpiCmDisplayInitPathname ( + ACPI_HANDLE ObjHandle, + char *Path); + +#endif + /* * Memory allocation functions and related macros. diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h b/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h index 77b4916..b3c7ed6 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * $Revision: 53 $ + * $Revision: 55 $ * *****************************************************************************/ @@ -144,7 +144,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20010125 +#define ACPI_CA_VERSION 0x20010208 /* Maximum objects in the various object caches */ @@ -240,10 +240,5 @@ #define RSDP_SCAN_STEP 16 -/* Maximum nesting of package objects */ - -#define MAX_PACKAGE_DEPTH 16 - - #endif /* _ACCONFIG_H */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h b/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h index 453710e..88a41b6 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * $Revision: 39 $ + * $Revision: 41 $ * *****************************************************************************/ @@ -134,6 +134,7 @@ extern BOOLEAN opt_disasm; extern BOOLEAN opt_stats; extern BOOLEAN opt_parse_jit; extern BOOLEAN opt_verbose; +extern BOOLEAN opt_ini_methods; extern NATIVE_CHAR *Args[DB_MAX_ARGS]; @@ -289,6 +290,10 @@ void AcpiDbFindReferences ( NATIVE_CHAR *ObjectArg); +void +AcpiDbDisplayResources ( + NATIVE_CHAR *ObjectArg); + /* * dbdisasm - AML disassembler diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h b/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h index 55073fd..eb2f4ce 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * $Revision: 4 $ + * $Revision: 5 $ * *****************************************************************************/ @@ -117,12 +117,12 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ -#define COMPILER_DEPENDENT_UINT64 unsigned long long #ifdef __ia64__ #define _IA64 +#define COMPILER_DEPENDENT_UINT64 unsigned long /* Single threaded */ #define ACPI_APPLICATION @@ -186,8 +186,7 @@ #else /* DO IA32 */ - - +#define COMPILER_DEPENDENT_UINT64 unsigned long long #define ACPI_ASM_MACROS #define causeinterrupt(level) #define BREAKPOINT3 diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h b/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h index 52cc897..6ebdd17 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 91 $ + * $Revision: 92 $ * *****************************************************************************/ @@ -650,12 +650,6 @@ AcpiAmlUnsignedIntegerToString ( ACPI_INTEGER Value, NATIVE_CHAR *OutString); -ACPI_STATUS -AcpiAmlBuildCopyInternalPackageObject ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState); - /* * amregion - default OpRegion handlers diff --git a/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h b/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h index ecf809a..39b6423e 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclinux.h - OS specific defines, etc. - * $Revision: 7 $ + * $Revision: 9 $ * *****************************************************************************/ @@ -117,7 +117,6 @@ #ifndef __ACLINUX_H__ #define __ACLINUX_H__ - #define ACPI_OS_NAME "Linux" #include @@ -126,6 +125,7 @@ #include #include #include +#include /* Linux uses GCC */ @@ -134,9 +134,14 @@ #undef DEBUGGER_THREADING #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED -/* Linux ia32 can't do int64 well */ #ifndef _IA64 +/* Linux ia32 can't do int64 well */ #define ACPI_NO_INTEGER64_SUPPORT +/* And the ia32 kernel doesn't include 64-bit divide support */ +#define ACPI_DIV64(dividend, divisor) do_div(dividend, divisor) +#else +#define ACPI_DIV64(dividend, divisor) ACPI_DIVIDE(dividend, divisor) #endif + #endif /* __ACLINUX_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h b/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h index 869737b..e021acc 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 100 $ + * $Revision: 104 $ * *****************************************************************************/ @@ -459,6 +459,23 @@ typedef struct acpi_update_state } ACPI_UPDATE_STATE; + +/* + * Pkg state - used to traverse nested package structures + */ +typedef struct acpi_pkg_state +{ + ACPI_STATE_COMMON + union acpi_operand_obj *SourceObject; + union acpi_operand_obj *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; + UINT16 Index; + +} ACPI_PKG_STATE; + + /* * Control state - one per if/else and while constructs. * Allows nesting of these constructs @@ -519,6 +536,7 @@ typedef union acpi_gen_state ACPI_UPDATE_STATE Update; ACPI_SCOPE_STATE Scope; ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; ACPI_RESULT_VALUES Results; } ACPI_GENERIC_STATE; @@ -741,7 +759,6 @@ typedef struct acpi_init_walk_info typedef struct acpi_device_walk_info { - UINT32 Flags; UINT16 DeviceCount; UINT16 Num_STA; UINT16 Num_INI; diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h b/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h index 1f5695d..7302295 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 101 $ + * $Revision: 103 $ * *****************************************************************************/ @@ -163,7 +163,7 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - UINT32 Flags); + void); /* Namespace init - nsxfinit */ @@ -408,6 +408,11 @@ AcpiNsGetNode ( ACPI_NAMESPACE_NODE *InPrefixNode, ACPI_NAMESPACE_NODE **OutNode); +UINT32 +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node); + + /* * Object management for NTEs - nsobject */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h b/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h index c5b048c..00f4918 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * $Revision: 69 $ + * $Revision: 70 $ * *****************************************************************************/ @@ -187,6 +187,7 @@ #define TRACE_USER_REQUESTS 0x01000000 #define TRACE_PACKAGE 0x02000000 #define TRACE_MUTEX 0x04000000 +#define TRACE_INIT 0x08000000 #define TRACE_ALL 0x0FFFFF00 diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actypes.h b/sys/contrib/dev/acpica/Subsystem/Include/actypes.h index d2ddb8b..7e8db54 100644 --- a/sys/contrib/dev/acpica/Subsystem/Include/actypes.h +++ b/sys/contrib/dev/acpica/Subsystem/Include/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 163 $ + * $Revision: 165 $ * *****************************************************************************/ @@ -328,8 +328,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NO_EVENT_INIT 0x04 #define ACPI_NO_ACPI_ENABLE 0x08 #define ACPI_NO_DEVICE_INIT 0x10 -#define ACPI_NO_PCI_INIT 0x20 -#define ACPI_NO_OBJECT_INIT 0x40 +#define ACPI_NO_OBJECT_INIT 0x20 /* @@ -759,6 +758,8 @@ ACPI_STATUS (*WALK_CALLBACK) ( void **ReturnValue); + + /* Interrupt handler return values */ #define INTERRUPT_NOT_HANDLED 0x00 @@ -1120,22 +1121,14 @@ typedef struct _resource_tag * END: Definitions for Resource Attributes */ -/* - * Definitions for PCI Routing tables - */ -typedef struct -{ - ACPI_INTEGER Address; - UINT32 Pin; - UINT32 SourceIndex; - NATIVE_CHAR Source[1]; - -} PRT_ENTRY; -typedef struct _prt_tag +typedef struct pci_routing_table { UINT32 Length; - PRT_ENTRY Data; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + NATIVE_CHAR Source[4]; /* pad to 64 bits so sizeof() works in all cases */ } PCI_ROUTING_TABLE; diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c index ad40aec..24c9a2a 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amfldio - Aml Field I/O - * $Revision: 37 $ + * $Revision: 39 $ * *****************************************************************************/ @@ -572,7 +572,8 @@ AcpiAmlWriteFieldDataWithUpdateRule ( /* Check if update rule needs to be applied (not if mask is all ones) */ - if (((1 << BitGranularity) -1) & ~Mask) + /* The left shift drops the bits we want to ignore. */ + if ((~Mask << (sizeof(Mask)*8 - BitGranularity)) != 0) { /* * Read the current contents of the byte/word/dword containing diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c index 71d1dfb..c2c29d71 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstore - AML Interpreter object store support - * $Revision: 121 $ + * $Revision: 123 $ * *****************************************************************************/ @@ -407,8 +407,7 @@ AcpiAmlStoreObjectToIndex ( */ if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type) { - Status = AcpiAmlBuildCopyInternalPackageObject ( - ValDesc, ObjDesc, WalkState); + Status = AcpiCmCopyIpackageToIpackage (ValDesc, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { AcpiCmRemoveReference (ObjDesc); @@ -718,7 +717,7 @@ AcpiAmlStoreObjectToObject ( */ ACPI_ASSERT((DestDesc) && (SourceDesc)); - DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to (%p)%s\n", + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to %p(%s)\n", SourceDesc, AcpiCmGetTypeName (SourceDesc->Common.Type), DestDesc, AcpiCmGetTypeName (DestDesc->Common.Type))); diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c index 0825891..a4bd94d 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstorob - AML Interpreter object store support, store to object - * $Revision: 22 $ + * $Revision: 23 $ * *****************************************************************************/ @@ -160,6 +160,21 @@ AcpiAmlCopyBufferToBuffer ( Length = SourceDesc->Buffer.Length; /* + * If target is a buffer of length zero, allocate a new + * buffer of the proper length + */ + if (TargetDesc->Buffer.Length == 0) + { + TargetDesc->Buffer.Pointer = AcpiCmAllocate (Length); + if (!TargetDesc->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + + TargetDesc->Buffer.Length = Length; + } + + /* * Buffer is a static allocation, * only place what will fit in the buffer. */ @@ -171,7 +186,7 @@ AcpiAmlCopyBufferToBuffer ( MEMCPY(TargetDesc->Buffer.Pointer, Buffer, Length); } - else + else { /* * Truncate the source, copy only what will fit @@ -179,7 +194,7 @@ AcpiAmlCopyBufferToBuffer ( MEMCPY(TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: Truncating src buffer from %X to %X\n", + ("AmlCopyBufferToBuffer: Truncating src buffer from %X to %X\n", Length, TargetDesc->Buffer.Length)); } @@ -244,12 +259,12 @@ AcpiAmlCopyStringToString ( } TargetDesc->String.Pointer = AcpiCmAllocate (Length + 1); - TargetDesc->String.Length = Length; - if (!TargetDesc->String.Pointer) { return (AE_NO_MEMORY); } + TargetDesc->String.Length = Length; + MEMCPY(TargetDesc->String.Pointer, Buffer, Length); } @@ -306,14 +321,14 @@ AcpiAmlCopyIntegerToIndexField ( sizeof (SourceDesc->Integer.Value)); DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: IndexField: set data returned %s\n", + ("AmlCopyIntegerToIndexField: IndexField: set data returned %s\n", AcpiCmFormatException (Status))); } else { DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: IndexField: set index returned %s\n", + ("AmlCopyIntegerToIndexField: IndexField: set index returned %s\n", AcpiCmFormatException (Status))); } @@ -379,7 +394,7 @@ AcpiAmlCopyIntegerToBankField ( else { DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: BankField: set bakn returned %s\n", + ("AmlCopyIntegerToBankField: BankField: set bakn returned %s\n", AcpiCmFormatException (Status))); } diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c index e106bfb..7f17991 100644 --- a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amutils - interpreter/scanner utilities - * $Revision: 68 $ + * $Revision: 69 $ * *****************************************************************************/ @@ -128,20 +128,6 @@ MODULE_NAME ("amutils") -typedef struct Internal_Search_st -{ - ACPI_OPERAND_OBJECT *DestObj; - UINT32 Index; - ACPI_OPERAND_OBJECT *SourceObj; - -} INTERNAL_PKG_SEARCH_INFO; - - -/* Used to traverse nested packages when copying*/ -/* TBD: This must be removed! */ - -INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; - /******************************************************************************* * @@ -504,167 +490,7 @@ AcpiAmlUnsignedIntegerToString ( } -/******************************************************************************* - * - * FUNCTION: AcpiAmlBuildCopyInternalPackageObject - * - * PARAMETERS: *SourceObj - Pointer to the source package object - * *DestObj - Where the internal object is returned - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to copy an internal package object - * into another internal package object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAmlBuildCopyInternalPackageObject ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState) -{ - UINT32 CurrentDepth = 0; - ACPI_STATUS Status = AE_OK; - UINT32 Length = 0; - UINT32 ThisIndex; - UINT32 ObjectSpace = 0; - ACPI_OPERAND_OBJECT *ThisDestObj; - ACPI_OPERAND_OBJECT *ThisSourceObj; - INTERNAL_PKG_SEARCH_INFO *LevelPtr; - - - FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject"); - - /* - * Initialize the working variables - */ - MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel)); - - CopyLevel[0].DestObj = DestObj; - CopyLevel[0].SourceObj = SourceObj; - LevelPtr = &CopyLevel[0]; - CurrentDepth = 0; - - DestObj->Common.Type = SourceObj->Common.Type; - DestObj->Package.Count = SourceObj->Package.Count; - - - /* - * Build an array of ACPI_OBJECTS in the buffer - * and move the free space past it - */ - - DestObj->Package.Elements = AcpiCmCallocate ( - (DestObj->Package.Count + 1) * - sizeof (void *)); - if (!DestObj->Package.Elements) - { - /* Package vector allocation failure */ - - REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n")); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - DestObj->Package.NextElement = DestObj->Package.Elements; - - - while (1) - { - ThisIndex = LevelPtr->Index; - ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex]; - ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex]; - - if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE)) - { - /* - * If this object is a package then we go one deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - - /* - * Build the package object - */ - ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); - LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; - - - ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE; - ThisDestObj->Package.Count = ThisDestObj->Package.Count; - - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = ThisDestObj->Package.Count * - sizeof (ACPI_OPERAND_OBJECT); - Length += ObjectSpace; - CurrentDepth++; - LevelPtr = &CopyLevel[CurrentDepth]; - LevelPtr->DestObj = ThisDestObj; - LevelPtr->SourceObj = ThisSourceObj; - LevelPtr->Index = 0; - - } /* if object is a package */ - - else - { - - ThisDestObj = AcpiCmCreateInternalObject ( - ThisSourceObj->Common.Type); - LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; - - Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState); - - if (ACPI_FAILURE (Status)) - { - /* - * Failure get out - */ - return_ACPI_STATUS (Status); - } - - Length +=ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= LevelPtr->DestObj->Package.Count) - { - /* - * We've handled all of the objects at this level, This means - * that we have just completed a package. That package may - * have contained one or more packages itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects in the top level - * package just add the length of the package objects - * and exit - */ - return_ACPI_STATUS (AE_OK); - } - - /* - * Go back up a level and move the index past the just - * completed package object. - */ - CurrentDepth--; - LevelPtr = &CopyLevel[CurrentDepth]; - LevelPtr->Index++; - } - } /* else object is NOT a package */ - } /* while (1) */ -} diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c index 10b1eb4..5c34853 100644 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 81 $ + * $Revision: 83 $ * ******************************************************************************/ @@ -388,8 +388,8 @@ AcpiNsEvaluateByHandle ( Node = AcpiNsConvertHandleToEntry (Handle); if (!Node) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -456,12 +456,6 @@ AcpiNsEvaluateByHandle ( * so we just return */ return_ACPI_STATUS (Status); - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); } @@ -497,6 +491,16 @@ AcpiNsExecuteControlMethod ( FUNCTION_TRACE ("NsExecuteControlMethod"); + /* + * Unlock the namespace before execution. This allows namespace access + * via the external Acpi* interfaces while a method is being executed. + * However, any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of the + * namespace that is being deleted. + */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + /* Verify that there is a method associated with this object */ ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); @@ -518,19 +522,8 @@ AcpiNsExecuteControlMethod ( DEBUG_PRINT (TRACE_NAMES, ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); - - /* - * Unlock the namespace before execution. This allows namespace access - * via the external Acpi* interfaces while a method is being executed. - * However, any namespace deletion must acquire both the namespace and - * interpreter locks to ensure that no thread is using the portion of the - * namespace that is being deleted. - */ - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - /* - * Excecute the method via the interpreter + * Execute the method via the interpreter */ Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c index c8b463c..672bbeb 100644 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 12 $ + * $Revision: 15 $ * *****************************************************************************/ @@ -203,7 +203,7 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - UINT32 Flags) + void) { ACPI_STATUS Status; ACPI_DEVICE_WALK_INFO Info; @@ -212,7 +212,6 @@ AcpiNsInitializeDevices ( FUNCTION_TRACE ("NsInitializeDevices"); - Info.Flags = Flags; Info.DeviceCount = 0; Info.Num_STA = 0; Info.Num_INI = 0; @@ -304,7 +303,11 @@ AcpiNsInitOneObject ( AcpiCmFormatException (Status), &Node->Name)); } - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + break; @@ -324,7 +327,11 @@ AcpiNsInitOneObject ( DEBUG_PRINT (ACPI_ERROR, ("%s while getting field arguments [%4.4s]\n", AcpiCmFormatException (Status), &Node->Name)); } - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + break; @@ -344,7 +351,7 @@ AcpiNsInitOneObject ( * * FUNCTION: AcpiNsInitOneDevice * - * PARAMETERS: The usual "I'm a namespace callback" stuff + * PARAMETERS: WALK_CALLBACK * * RETURN: ACPI_STATUS * @@ -370,7 +377,11 @@ AcpiNsInitOneDevice ( FUNCTION_TRACE ("AcpiNsInitOneDevice"); - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + Info->DeviceCount++; AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); @@ -388,6 +399,7 @@ AcpiNsInitOneDevice ( * Run _STA to determine if we can run _INI on the device. */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, "_STA [Method]")); Status = AcpiCmExecute_STA (Node, &Flags); if (ACPI_FAILURE (Status)) { @@ -404,10 +416,13 @@ AcpiNsInitOneDevice ( return_ACPI_STATUS(AE_CTRL_DEPTH); } + + /* * The device is present. Run _INI. */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (ObjHandle, "_INI [Method]")); Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); if (AE_NOT_FOUND == Status) { diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c index 04662f5..b7cc321 100644 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * $Revision: 53 $ + * $Revision: 54 $ * ******************************************************************************/ @@ -219,6 +219,48 @@ AcpiNsGetTablePathname ( /******************************************************************************* * + * FUNCTION: AcpiNsGetPathnameLength + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Length of path, including prefix + * + * DESCRIPTION: Get the length of the pathname string for this node + * + ******************************************************************************/ + +UINT32 +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node) +{ + UINT32 Size; + ACPI_NAMESPACE_NODE *NextNode; + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + for (Size = 0, NextNode = Node; + AcpiNsGetParentObject (NextNode); + NextNode = AcpiNsGetParentObject (NextNode)) + { + Size += PATH_SEGMENT_LENGTH; + } + + /* Special case for size still 0 - no parent for "special" nodes */ + + if (!Size) + { + Size = PATH_SEGMENT_LENGTH; + } + + return (Size + 1); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiNsHandleToPathname * * PARAMETERS: TargetHandle - Handle of named object whose name is @@ -242,11 +284,10 @@ AcpiNsHandleToPathname ( { ACPI_STATUS Status = AE_OK; ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *NextNode; UINT32 PathLength; - UINT32 Size; UINT32 UserBufSize; ACPI_NAME Name; + UINT32 Size; FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); @@ -267,27 +308,12 @@ AcpiNsHandleToPathname ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - for (Size = 0, NextNode = Node; - AcpiNsGetParentObject (NextNode); - NextNode = AcpiNsGetParentObject (NextNode)) - { - Size += PATH_SEGMENT_LENGTH; - } - - /* Special case for size still 0 - no parent for "special" nodes */ - - if (!Size) - { - Size = PATH_SEGMENT_LENGTH; - } /* Set return length to the required path length */ - PathLength = Size + 1; + PathLength = AcpiNsGetPathnameLength (Node); + Size = PathLength - 1; + UserBufSize = *BufSize; *BufSize = PathLength; diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c index dd266bf..b90c31a 100644 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c @@ -2,7 +2,7 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * $Revision: 78 $ + * $Revision: 80 $ * ******************************************************************************/ @@ -217,9 +217,8 @@ AcpiEvaluateObject ( */ for (i = 0; i < Count; i++) { - Status = - AcpiCmBuildInternalObject (&ParamObjects->Pointer[i], - ParamPtr[i]); + Status = AcpiCmCopyEobjectToIobject (&ParamObjects->Pointer[i], + ParamPtr[i]); if (ACPI_FAILURE (Status)) { @@ -362,7 +361,7 @@ AcpiEvaluateObject ( /* * We have enough space for the object, build it */ - Status = AcpiCmBuildExternalObject (ReturnObj, + Status = AcpiCmCopyIobjectToEobject (ReturnObj, ReturnBuffer); ReturnBuffer->Length = BufferSpaceNeeded; } @@ -725,14 +724,14 @@ AcpiNsGetDeviceCallback ( AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); Node = AcpiNsConvertHandleToEntry (ObjHandle); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + if (!Node) { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - /* * Run _STA to determine if device is present */ diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c index 9053fa3..2f03cf4 100644 --- a/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c @@ -2,7 +2,7 @@ * * Module Name: rscalc - AcpiRsCalculateByteStreamLength * AcpiRsCalculateListLength - * $Revision: 18 $ + * $Revision: 21 $ * ******************************************************************************/ @@ -119,6 +119,8 @@ #include "acpi.h" #include "acresrc.h" +#include "amlcode.h" +#include "acnamesp.h" #define _COMPONENT RESOURCE_MANAGER MODULE_NAME ("rscalc") @@ -825,6 +827,7 @@ AcpiRsCalculateListLength ( */ BytesConsumed = 2; StructureSize = RESOURCE_LENGTH; + ByteStreamBufferLength = BytesParsed; break; @@ -936,7 +939,9 @@ AcpiRsCalculatePciRoutingTableLength ( for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) { - if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + if ((ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) || + ((INTERNAL_TYPE_REFERENCE == (*SubObjectList)->Common.Type) && + ((*SubObjectList)->Reference.OpCode == AML_NAMEPATH_OP))) { NameFound = TRUE; } @@ -950,18 +955,25 @@ AcpiRsCalculatePciRoutingTableLength ( } } - TempSizeNeeded += (sizeof (PCI_ROUTING_TABLE) - 1); + TempSizeNeeded += (sizeof (PCI_ROUTING_TABLE) - 4); /* * Was a String type found? */ if (TRUE == NameFound) { - /* - * The length String.Length field includes the - * terminating NULL - */ - TempSizeNeeded += (*SubObjectList)->String.Length; + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + /* + * The length String.Length field includes the + * terminating NULL + */ + TempSizeNeeded += (*SubObjectList)->String.Length; + } + else + { + TempSizeNeeded += AcpiNsGetPathnameLength ((*SubObjectList)->Reference.Node); + } } else @@ -985,7 +997,7 @@ AcpiRsCalculatePciRoutingTableLength ( } - *BufferSizeNeeded = TempSizeNeeded + sizeof (PCI_ROUTING_TABLE); + *BufferSizeNeeded = TempSizeNeeded; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c index 093b7a4..73d60b8 100644 --- a/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c @@ -3,7 +3,7 @@ * Module Name: rscreate - AcpiRsCreateResourceList * AcpiRsCreatePciRoutingTable * AcpiRsCreateByteStream - * $Revision: 24 $ + * $Revision: 25 $ * ******************************************************************************/ @@ -121,6 +121,8 @@ #include "acpi.h" #include "acresrc.h" +#include "amlcode.h" +#include "acnamesp.h" #define _COMPONENT RESOURCE_MANAGER MODULE_NAME ("rscreate") @@ -266,6 +268,7 @@ AcpiRsCreatePciRoutingTable ( UINT32 NumberOfElements = 0; UINT32 Index = 0; PCI_ROUTING_TABLE *UserPrt = NULL; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; @@ -321,10 +324,10 @@ AcpiRsCreatePciRoutingTable ( /* * Fill in the Length field with the information we * have at this point. - * The minus one is to subtract the size of the - * UINT8 Source[1] member because it is added below. + * 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) - 1); + UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) -4); /* * Dereference the sub-package @@ -339,71 +342,99 @@ AcpiRsCreatePciRoutingTable ( SubObjectList = PackageElement->Package.Elements; /* - * Dereference the Address + * 1) First subobject: Dereference the Address */ if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.Address = - (*SubObjectList)->Integer.Value; + UserPrt->Address = (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } /* - * Dereference the Pin + * 2) Second subobject: Dereference the Pin */ SubObjectList++; if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.Pin = + UserPrt->Pin = (UINT32) (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } /* - * Dereference the Source Name + * 3) Third subobject: Dereference the Source Name */ SubObjectList++; - if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + switch ((*SubObjectList)->Common.Type) { - STRCPY (UserPrt->Data.Source, + case INTERNAL_TYPE_REFERENCE: + if ((*SubObjectList)->Reference.OpCode != AML_NAMEPATH_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need name, found reference op %X\n", + (*SubObjectList)->Reference.OpCode)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Node = (*SubObjectList)->Reference.Node; + + /* TBD: use *remaining* length of the buffer! */ + + Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node, + OutputBufferLength, UserPrt->Source); + + UserPrt->Length += STRLEN (UserPrt->Source) + 1; /* include null terminator */ + break; + + + case ACPI_TYPE_STRING: + + STRCPY (UserPrt->Source, (*SubObjectList)->String.Pointer); /* * Add to the Length field the length of the string */ UserPrt->Length += (*SubObjectList)->String.Length; - } + break; - else - { + + 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. */ - if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) - { - /* - * Add to the Length field the length of - * the UINT32 NULL - */ - UserPrt->Length += sizeof (UINT32); - } + /* + * Add to the Length field the length of + * the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + break; - else - { - return_ACPI_STATUS (AE_BAD_DATA); - } + + default: + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); + return_ACPI_STATUS (AE_BAD_DATA); + break; } /* Now align the current length */ @@ -411,18 +442,21 @@ AcpiRsCreatePciRoutingTable ( UserPrt->Length = ROUND_UP_TO_64BITS (UserPrt->Length); /* - * Dereference the Source Index + * 4) Fourth subobject: Dereference the Source Index */ SubObjectList++; if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.SourceIndex = + UserPrt->SourceIndex = (UINT32) (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c index 94d28b9..70127ee 100644 --- a/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsdump - Functions do dump out the resource structures. - * $Revision: 15 $ + * $Revision: 16 $ * ******************************************************************************/ @@ -1013,25 +1013,25 @@ AcpiRsDumpIrqList ( if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) { - PrtElement = (PCI_ROUTING_TABLE *)Buffer; + PrtElement = (PCI_ROUTING_TABLE *) Buffer; while (!Done) { AcpiOsPrintf ("\tPCI IRQ Routing Table structure %X.\n", Count++); AcpiOsPrintf ("\t\tAddress: %X\n", - PrtElement->Data.Address); + PrtElement->Address); - AcpiOsPrintf ("\t\tPin: %X\n", PrtElement->Data.Pin); + AcpiOsPrintf ("\t\tPin: %X\n", PrtElement->Pin); - AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Data.Source); + AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Source); AcpiOsPrintf ("\t\tSourceIndex: %X\n", - PrtElement->Data.SourceIndex); + PrtElement->SourceIndex); Buffer += PrtElement->Length; - PrtElement = (PCI_ROUTING_TABLE *)Buffer; + PrtElement = (PCI_ROUTING_TABLE *) Buffer; if(0 == PrtElement->Length) { diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c index 0647d63..60e10b4 100644 --- a/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c @@ -2,7 +2,7 @@ * * Module Name: rslist - AcpiRsByteStreamToList * AcpiListToByteStream - * $Revision: 10 $ + * $Revision: 11 $ * ******************************************************************************/ @@ -399,8 +399,7 @@ AcpiRsByteStreamToList ( /* * Check the reason for exiting the while loop */ - if (!(ByteStreamBufferLength == BytesParsed) || - (TRUE != EndTagProcessed)) + if (TRUE != EndTagProcessed) { return_ACPI_STATUS (AE_AML_ERROR); } diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h index 77b4916..b3c7ed6 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: 53 $ + * $Revision: 55 $ * *****************************************************************************/ @@ -144,7 +144,7 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20010125 +#define ACPI_CA_VERSION 0x20010208 /* Maximum objects in the various object caches */ @@ -240,10 +240,5 @@ #define RSDP_SCAN_STEP 16 -/* Maximum nesting of package objects */ - -#define MAX_PACKAGE_DEPTH 16 - - #endif /* _ACCONFIG_H */ diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h index 453710e..88a41b6 100644 --- a/sys/contrib/dev/acpica/acdebug.h +++ b/sys/contrib/dev/acpica/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * $Revision: 39 $ + * $Revision: 41 $ * *****************************************************************************/ @@ -134,6 +134,7 @@ extern BOOLEAN opt_disasm; extern BOOLEAN opt_stats; extern BOOLEAN opt_parse_jit; extern BOOLEAN opt_verbose; +extern BOOLEAN opt_ini_methods; extern NATIVE_CHAR *Args[DB_MAX_ARGS]; @@ -289,6 +290,10 @@ void AcpiDbFindReferences ( NATIVE_CHAR *ObjectArg); +void +AcpiDbDisplayResources ( + NATIVE_CHAR *ObjectArg); + /* * dbdisasm - AML disassembler diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h index 55073fd..eb2f4ce 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: 4 $ + * $Revision: 5 $ * *****************************************************************************/ @@ -117,12 +117,12 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ -#define COMPILER_DEPENDENT_UINT64 unsigned long long #ifdef __ia64__ #define _IA64 +#define COMPILER_DEPENDENT_UINT64 unsigned long /* Single threaded */ #define ACPI_APPLICATION @@ -186,8 +186,7 @@ #else /* DO IA32 */ - - +#define COMPILER_DEPENDENT_UINT64 unsigned long long #define ACPI_ASM_MACROS #define causeinterrupt(level) #define BREAKPOINT3 diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h index 52cc897..6ebdd17 100644 --- a/sys/contrib/dev/acpica/acinterp.h +++ b/sys/contrib/dev/acpica/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 91 $ + * $Revision: 92 $ * *****************************************************************************/ @@ -650,12 +650,6 @@ AcpiAmlUnsignedIntegerToString ( ACPI_INTEGER Value, NATIVE_CHAR *OutString); -ACPI_STATUS -AcpiAmlBuildCopyInternalPackageObject ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState); - /* * amregion - default OpRegion handlers diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h index 869737b..e021acc 100644 --- a/sys/contrib/dev/acpica/aclocal.h +++ b/sys/contrib/dev/acpica/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 100 $ + * $Revision: 104 $ * *****************************************************************************/ @@ -459,6 +459,23 @@ typedef struct acpi_update_state } ACPI_UPDATE_STATE; + +/* + * Pkg state - used to traverse nested package structures + */ +typedef struct acpi_pkg_state +{ + ACPI_STATE_COMMON + union acpi_operand_obj *SourceObject; + union acpi_operand_obj *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; + UINT16 Index; + +} ACPI_PKG_STATE; + + /* * Control state - one per if/else and while constructs. * Allows nesting of these constructs @@ -519,6 +536,7 @@ typedef union acpi_gen_state ACPI_UPDATE_STATE Update; ACPI_SCOPE_STATE Scope; ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; ACPI_RESULT_VALUES Results; } ACPI_GENERIC_STATE; @@ -741,7 +759,6 @@ typedef struct acpi_init_walk_info typedef struct acpi_device_walk_info { - UINT32 Flags; UINT16 DeviceCount; UINT16 Num_STA; UINT16 Num_INI; diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h index 1f5695d..7302295 100644 --- a/sys/contrib/dev/acpica/acnamesp.h +++ b/sys/contrib/dev/acpica/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 101 $ + * $Revision: 103 $ * *****************************************************************************/ @@ -163,7 +163,7 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - UINT32 Flags); + void); /* Namespace init - nsxfinit */ @@ -408,6 +408,11 @@ AcpiNsGetNode ( ACPI_NAMESPACE_NODE *InPrefixNode, ACPI_NAMESPACE_NODE **OutNode); +UINT32 +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node); + + /* * Object management for NTEs - nsobject */ diff --git a/sys/contrib/dev/acpica/acoutput.h b/sys/contrib/dev/acpica/acoutput.h index c5b048c..00f4918 100644 --- a/sys/contrib/dev/acpica/acoutput.h +++ b/sys/contrib/dev/acpica/acoutput.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * $Revision: 69 $ + * $Revision: 70 $ * *****************************************************************************/ @@ -187,6 +187,7 @@ #define TRACE_USER_REQUESTS 0x01000000 #define TRACE_PACKAGE 0x02000000 #define TRACE_MUTEX 0x04000000 +#define TRACE_INIT 0x08000000 #define TRACE_ALL 0x0FFFFF00 diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h index d2ddb8b..7e8db54 100644 --- a/sys/contrib/dev/acpica/actypes.h +++ b/sys/contrib/dev/acpica/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 163 $ + * $Revision: 165 $ * *****************************************************************************/ @@ -328,8 +328,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NO_EVENT_INIT 0x04 #define ACPI_NO_ACPI_ENABLE 0x08 #define ACPI_NO_DEVICE_INIT 0x10 -#define ACPI_NO_PCI_INIT 0x20 -#define ACPI_NO_OBJECT_INIT 0x40 +#define ACPI_NO_OBJECT_INIT 0x20 /* @@ -759,6 +758,8 @@ ACPI_STATUS (*WALK_CALLBACK) ( void **ReturnValue); + + /* Interrupt handler return values */ #define INTERRUPT_NOT_HANDLED 0x00 @@ -1120,22 +1121,14 @@ typedef struct _resource_tag * END: Definitions for Resource Attributes */ -/* - * Definitions for PCI Routing tables - */ -typedef struct -{ - ACPI_INTEGER Address; - UINT32 Pin; - UINT32 SourceIndex; - NATIVE_CHAR Source[1]; - -} PRT_ENTRY; -typedef struct _prt_tag +typedef struct pci_routing_table { UINT32 Length; - PRT_ENTRY Data; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + NATIVE_CHAR Source[4]; /* pad to 64 bits so sizeof() works in all cases */ } PCI_ROUTING_TABLE; diff --git a/sys/contrib/dev/acpica/acutils.h b/sys/contrib/dev/acpica/acutils.h index 7ae0299..3872386 100644 --- a/sys/contrib/dev/acpica/acutils.h +++ b/sys/contrib/dev/acpica/acutils.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures - * $Revision: 87 $ + * $Revision: 90 $ * *****************************************************************************/ @@ -118,6 +118,32 @@ #define _ACCOMMON_H + +typedef +ACPI_STATUS (*ACPI_PKG_CALLBACK) ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + + + +ACPI_STATUS +AcpiCmWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + + +typedef struct acpi_pkg_info +{ + UINT8 *FreeSpace; + UINT32 Length; + UINT32 ObjectSpace; + UINT32 NumPackages; +} ACPI_PKG_INFO; + #define REF_INCREMENT (UINT16) 0 #define REF_DECREMENT (UINT16) 1 #define REF_FORCE_DELETE (UINT16) 2 @@ -285,29 +311,30 @@ AcpiCmBuildPackageObject ( UINT32 *SpaceUsed); ACPI_STATUS -AcpiCmBuildExternalObject ( +AcpiCmCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *Obj, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiCmBuildInternalSimpleObject( +AcpiCmCopyEsimpleToIsimple( ACPI_OBJECT *UserObj, ACPI_OPERAND_OBJECT *Obj); ACPI_STATUS -AcpiCmBuildInternalObject ( +AcpiCmCopyEobjectToIobject ( ACPI_OBJECT *Obj, ACPI_OPERAND_OBJECT *InternalObj); ACPI_STATUS -AcpiCmCopyInternalSimpleObject ( +AcpiCmCopyISimpleToIsimple ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj); ACPI_STATUS -AcpiCmBuildCopyInternalPackageObject ( +AcpiCmCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj); + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); /* @@ -617,12 +644,25 @@ AcpiCmCreateUpdateState ( ACPI_OPERAND_OBJECT *Object, UINT16 Action); +ACPI_GENERIC_STATE * +AcpiCmCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index); + ACPI_STATUS AcpiCmCreateUpdateStateAndPush ( ACPI_OPERAND_OBJECT *Object, UINT16 Action, ACPI_GENERIC_STATE **StateList); +ACPI_STATUS +AcpiCmCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList); + ACPI_GENERIC_STATE * AcpiCmCreateControlState ( void); @@ -655,6 +695,15 @@ ACPI_STATUS AcpiCmResolvePackageReferences ( ACPI_OPERAND_OBJECT *ObjDesc); +#ifdef ACPI_DEBUG + +void +AcpiCmDisplayInitPathname ( + ACPI_HANDLE ObjHandle, + char *Path); + +#endif + /* * Memory allocation functions and related macros. diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c index 33f8481..b48e7ea 100644 --- a/sys/contrib/dev/acpica/dbcmds.c +++ b/sys/contrib/dev/acpica/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * $Revision: 45 $ + * $Revision: 46 $ * ******************************************************************************/ @@ -995,4 +995,76 @@ AcpiDbSetScope ( AcpiOsPrintf ("New scope: %s\n", ScopeBuf); } + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResources + * + * PARAMETERS: ObjectArg - String with hex value of the object + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +void +AcpiDbDisplayResources ( + NATIVE_CHAR *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_BUFFER ReturnObj; + PCI_ROUTING_TABLE *Prt; + UINT32 i; + + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + + /* Convert string to object pointer */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); + + /* Prepare for a return object of arbitrary size */ + + ReturnObj.Pointer = Buffer; + ReturnObj.Length = BUFFER_SIZE; + + Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiCmFormatException (Status)); + goto Cleanup; + } + + ReturnObj.Pointer = Buffer; + ReturnObj.Length = BUFFER_SIZE; + + Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiCmFormatException (Status)); + goto Cleanup; + } + + Prt = (PCI_ROUTING_TABLE *) Buffer; + i = 0; + while ((char *) Prt < (Buffer + ReturnObj.Length)) + { + AcpiOsPrintf ("Prt[%d] Src=%s: Addr=%X\n", i, Prt->Source, Prt->Address); + i++; + Prt = (PCI_ROUTING_TABLE *) (((char *) Prt) + Prt->Length); + } + +Cleanup: + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return; + +} + + + + + #endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbfileio.c b/sys/contrib/dev/acpica/dbfileio.c index 367a838..e547839 100644 --- a/sys/contrib/dev/acpica/dbfileio.c +++ b/sys/contrib/dev/acpica/dbfileio.c @@ -2,7 +2,7 @@ * * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * $Revision: 37 $ + * $Revision: 38 $ * ******************************************************************************/ @@ -240,6 +240,10 @@ AcpiDbOpenDebugFile ( STRCPY (DebugFilename, Name); OutputToFile = TRUE; } + else + { + AcpiOsPrintf ("Could not open debug file %s\n", Name); + } #endif } diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c index 0d191c6..812dbfe 100644 --- a/sys/contrib/dev/acpica/dbinput.c +++ b/sys/contrib/dev/acpica/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * $Revision: 54 $ + * $Revision: 56 $ * ******************************************************************************/ @@ -153,6 +153,7 @@ BOOLEAN opt_disasm = FALSE; BOOLEAN opt_stats = FALSE; BOOLEAN opt_parse_jit = FALSE; BOOLEAN opt_verbose = TRUE; +BOOLEAN opt_ini_methods = TRUE; /* @@ -199,6 +200,7 @@ enum AcpiAmlDebuggerCommands CMD_PREFIX, CMD_QUIT, CMD_REFERENCES, + CMD_RESOURCES, CMD_RESULTS, CMD_SET, CMD_STATS, @@ -251,6 +253,7 @@ COMMAND_INFO Commands[] = {"PREFIX", 0}, {"QUIT", 0}, {"REFERENCES", 1}, + {"RESOURCES", 1}, {"RESULTS", 0}, {"SET", 3}, {"STATS", 0}, @@ -337,6 +340,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); AcpiOsPrintf ("References Find all references to object at addr\n"); + AcpiOsPrintf ("Resources xxx Get and display resources\n"); AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); AcpiOsPrintf ("Thread Spawn threads to execute method(s)\n"); return; @@ -765,6 +769,10 @@ AcpiDbCommandDispatch ( AcpiDbFindReferences (Args[1]); break; + case CMD_RESOURCES: + AcpiDbDisplayResources (Args[1]); + break; + case CMD_RESULTS: AcpiDbDisplayResults (); break; diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c index 870fd32..13bf56a 100644 --- a/sys/contrib/dev/acpica/dsobject.c +++ b/sys/contrib/dev/acpica/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 56 $ + * $Revision: 57 $ * *****************************************************************************/ @@ -194,7 +194,10 @@ AcpiDsInitOneObject ( Info->MethodCount++; - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } /* * Set the execution data width (32 or 64) based upon the diff --git a/sys/contrib/dev/acpica/dsopcode.c b/sys/contrib/dev/acpica/dsopcode.c index 1a736ff..5153537 100644 --- a/sys/contrib/dev/acpica/dsopcode.c +++ b/sys/contrib/dev/acpica/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 30 $ + * $Revision: 32 $ * *****************************************************************************/ @@ -169,6 +169,7 @@ AcpiDsGetFieldUnitArguments ( ExtraDesc = ObjDesc->FieldUnit.Extra; Node = ObjDesc->FieldUnit.Node; + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, " [Field]")); DEBUG_PRINT (TRACE_EXEC, ("DsGetFieldUnitArguments: [%4.4s] FieldUnit JIT Init\n", &Node->Name)); @@ -289,6 +290,8 @@ AcpiDsGetRegionArguments ( ExtraDesc = ObjDesc->Region.Extra; Node = ObjDesc->Region.Node; + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, " [Operation Region]")); + DEBUG_PRINT (TRACE_EXEC, ("DsGetRegionArguments: [%4.4s] OpRegion Init at AML %p[%x]\n", &Node->Name, ExtraDesc->Extra.Pcode, *(UINT32*) ExtraDesc->Extra.Pcode)); diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c index 30f06e0..2738ea8 100644 --- a/sys/contrib/dev/acpica/evevent.c +++ b/sys/contrib/dev/acpica/evevent.c @@ -2,7 +2,7 @@ * * Module Name: evevent - Fixed and General Purpose AcpiEvent * handling and dispatch - * $Revision: 33 $ + * $Revision: 34 $ * *****************************************************************************/ @@ -149,7 +149,7 @@ AcpiEvInitialize ( FUNCTION_TRACE ("EvInitialize"); - /* Make sure we've got ACPI tables */ + /* Make sure we have ACPI tables */ if (!AcpiGbl_DSDT) { @@ -871,7 +871,7 @@ UINT32 AcpiEvGpeDispatch ( UINT32 GpeNumber) { - ACPI_GPE_LEVEL_INFO GpeInfo; + ACPI_GPE_LEVEL_INFO GpeInfo; FUNCTION_TRACE ("EvGpeDispatch"); @@ -891,65 +891,64 @@ AcpiEvGpeDispatch ( */ AcpiHwDisableGpe (GpeNumber); - GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; + GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; - /* - * Edge-Triggered? - * --------------- - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if (GpeInfo.Type & ACPI_EVENT_EDGE_TRIGGERED) + /* + * Edge-Triggered? + * --------------- + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if (GpeInfo.Type & ACPI_EVENT_EDGE_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } - + AcpiHwClearGpe (GpeNumber); + } /* * Function Handler (e.g. EC)? */ - if (GpeInfo.Handler) + if (GpeInfo.Handler) { - /* Invoke function handler (at interrupt level). */ - GpeInfo.Handler (GpeInfo.Context); + /* Invoke function handler (at interrupt level). */ + GpeInfo.Handler (GpeInfo.Context); - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) + /* Level-Triggered? */ + if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } - - /* Enable GPE */ - AcpiHwEnableGpe (GpeNumber); + AcpiHwClearGpe (GpeNumber); } - /* - * Method Handler (e.g. _Exx/_Lxx)? - */ - else if (GpeInfo.MethodHandle) + + /* Enable GPE */ + AcpiHwEnableGpe (GpeNumber); + } + /* + * Method Handler (e.g. _Exx/_Lxx)? + */ + else if (GpeInfo.MethodHandle) { - if (ACPI_FAILURE(AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + if (ACPI_FAILURE(AcpiOsQueueForExecution (OSD_PRIORITY_GPE, AcpiEvAsynchExecuteGpeMethod, (void*)(NATIVE_UINT)GpeNumber))) - { - /* - * Shoudn't occur, but if it does report an error. Note that - * the GPE will remain disabled until the ACPI Core Subsystem - * is restarted, or the handler is removed/reinstalled. - */ - REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE bit [%X]\n", GpeNumber)); - } + { + /* + * Shoudn't occur, but if it does report an error. Note that + * the GPE will remain disabled until the ACPI Core Subsystem + * is restarted, or the handler is removed/reinstalled. + */ + REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE bit [%X]\n", GpeNumber)); } - /* - * No Handler? Report an error and leave the GPE disabled. - */ - else + } + /* + * No Handler? Report an error and leave the GPE disabled. + */ + else { - REPORT_ERROR (("AcpiEvGpeDispatch: No installed handler for GPE [%X]\n", GpeNumber)); + REPORT_ERROR (("AcpiEvGpeDispatch: No installed handler for GPE [%X]\n", GpeNumber)); - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) + /* Level-Triggered? */ + if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) { - AcpiHwClearGpe (GpeNumber); - } + AcpiHwClearGpe (GpeNumber); } + } return_VALUE (INTERRUPT_HANDLED); } diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c index 49d5d3f..e9ebad9 100644 --- a/sys/contrib/dev/acpica/evregion.c +++ b/sys/contrib/dev/acpica/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 94 $ + * $Revision: 96 $ * *****************************************************************************/ @@ -262,6 +262,7 @@ AcpiEvExecuteRegMethod ( /* * Execute the method, no return value */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (RegionObj->Region.Extra->Extra.Method_REG, " [Method]")); Status = AcpiNsEvaluateByHandle (RegionObj->Region.Extra->Extra.Method_REG, Params, NULL); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index ad40aec..24c9a2a 100644 --- a/sys/contrib/dev/acpica/exfldio.c +++ b/sys/contrib/dev/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: amfldio - Aml Field I/O - * $Revision: 37 $ + * $Revision: 39 $ * *****************************************************************************/ @@ -572,7 +572,8 @@ AcpiAmlWriteFieldDataWithUpdateRule ( /* Check if update rule needs to be applied (not if mask is all ones) */ - if (((1 << BitGranularity) -1) & ~Mask) + /* The left shift drops the bits we want to ignore. */ + if ((~Mask << (sizeof(Mask)*8 - BitGranularity)) != 0) { /* * Read the current contents of the byte/word/dword containing diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 71d1dfb..c2c29d71 100644 --- a/sys/contrib/dev/acpica/exstore.c +++ b/sys/contrib/dev/acpica/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstore - AML Interpreter object store support - * $Revision: 121 $ + * $Revision: 123 $ * *****************************************************************************/ @@ -407,8 +407,7 @@ AcpiAmlStoreObjectToIndex ( */ if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type) { - Status = AcpiAmlBuildCopyInternalPackageObject ( - ValDesc, ObjDesc, WalkState); + Status = AcpiCmCopyIpackageToIpackage (ValDesc, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { AcpiCmRemoveReference (ObjDesc); @@ -718,7 +717,7 @@ AcpiAmlStoreObjectToObject ( */ ACPI_ASSERT((DestDesc) && (SourceDesc)); - DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to (%p)%s\n", + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to %p(%s)\n", SourceDesc, AcpiCmGetTypeName (SourceDesc->Common.Type), DestDesc, AcpiCmGetTypeName (DestDesc->Common.Type))); diff --git a/sys/contrib/dev/acpica/exstorob.c b/sys/contrib/dev/acpica/exstorob.c index 0825891..a4bd94d 100644 --- a/sys/contrib/dev/acpica/exstorob.c +++ b/sys/contrib/dev/acpica/exstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amstorob - AML Interpreter object store support, store to object - * $Revision: 22 $ + * $Revision: 23 $ * *****************************************************************************/ @@ -160,6 +160,21 @@ AcpiAmlCopyBufferToBuffer ( Length = SourceDesc->Buffer.Length; /* + * If target is a buffer of length zero, allocate a new + * buffer of the proper length + */ + if (TargetDesc->Buffer.Length == 0) + { + TargetDesc->Buffer.Pointer = AcpiCmAllocate (Length); + if (!TargetDesc->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + + TargetDesc->Buffer.Length = Length; + } + + /* * Buffer is a static allocation, * only place what will fit in the buffer. */ @@ -171,7 +186,7 @@ AcpiAmlCopyBufferToBuffer ( MEMCPY(TargetDesc->Buffer.Pointer, Buffer, Length); } - else + else { /* * Truncate the source, copy only what will fit @@ -179,7 +194,7 @@ AcpiAmlCopyBufferToBuffer ( MEMCPY(TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: Truncating src buffer from %X to %X\n", + ("AmlCopyBufferToBuffer: Truncating src buffer from %X to %X\n", Length, TargetDesc->Buffer.Length)); } @@ -244,12 +259,12 @@ AcpiAmlCopyStringToString ( } TargetDesc->String.Pointer = AcpiCmAllocate (Length + 1); - TargetDesc->String.Length = Length; - if (!TargetDesc->String.Pointer) { return (AE_NO_MEMORY); } + TargetDesc->String.Length = Length; + MEMCPY(TargetDesc->String.Pointer, Buffer, Length); } @@ -306,14 +321,14 @@ AcpiAmlCopyIntegerToIndexField ( sizeof (SourceDesc->Integer.Value)); DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: IndexField: set data returned %s\n", + ("AmlCopyIntegerToIndexField: IndexField: set data returned %s\n", AcpiCmFormatException (Status))); } else { DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: IndexField: set index returned %s\n", + ("AmlCopyIntegerToIndexField: IndexField: set index returned %s\n", AcpiCmFormatException (Status))); } @@ -379,7 +394,7 @@ AcpiAmlCopyIntegerToBankField ( else { DEBUG_PRINT (ACPI_INFO, - ("AmlStoreObjectToNode: BankField: set bakn returned %s\n", + ("AmlCopyIntegerToBankField: BankField: set bakn returned %s\n", AcpiCmFormatException (Status))); } diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c index e106bfb..7f17991 100644 --- a/sys/contrib/dev/acpica/exutils.c +++ b/sys/contrib/dev/acpica/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amutils - interpreter/scanner utilities - * $Revision: 68 $ + * $Revision: 69 $ * *****************************************************************************/ @@ -128,20 +128,6 @@ MODULE_NAME ("amutils") -typedef struct Internal_Search_st -{ - ACPI_OPERAND_OBJECT *DestObj; - UINT32 Index; - ACPI_OPERAND_OBJECT *SourceObj; - -} INTERNAL_PKG_SEARCH_INFO; - - -/* Used to traverse nested packages when copying*/ -/* TBD: This must be removed! */ - -INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; - /******************************************************************************* * @@ -504,167 +490,7 @@ AcpiAmlUnsignedIntegerToString ( } -/******************************************************************************* - * - * FUNCTION: AcpiAmlBuildCopyInternalPackageObject - * - * PARAMETERS: *SourceObj - Pointer to the source package object - * *DestObj - Where the internal object is returned - * - * RETURN: Status - the status of the call - * - * DESCRIPTION: This function is called to copy an internal package object - * into another internal package object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAmlBuildCopyInternalPackageObject ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState) -{ - UINT32 CurrentDepth = 0; - ACPI_STATUS Status = AE_OK; - UINT32 Length = 0; - UINT32 ThisIndex; - UINT32 ObjectSpace = 0; - ACPI_OPERAND_OBJECT *ThisDestObj; - ACPI_OPERAND_OBJECT *ThisSourceObj; - INTERNAL_PKG_SEARCH_INFO *LevelPtr; - - - FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject"); - - /* - * Initialize the working variables - */ - MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel)); - - CopyLevel[0].DestObj = DestObj; - CopyLevel[0].SourceObj = SourceObj; - LevelPtr = &CopyLevel[0]; - CurrentDepth = 0; - - DestObj->Common.Type = SourceObj->Common.Type; - DestObj->Package.Count = SourceObj->Package.Count; - - - /* - * Build an array of ACPI_OBJECTS in the buffer - * and move the free space past it - */ - - DestObj->Package.Elements = AcpiCmCallocate ( - (DestObj->Package.Count + 1) * - sizeof (void *)); - if (!DestObj->Package.Elements) - { - /* Package vector allocation failure */ - - REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n")); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - DestObj->Package.NextElement = DestObj->Package.Elements; - - - while (1) - { - ThisIndex = LevelPtr->Index; - ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex]; - ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex]; - - if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE)) - { - /* - * If this object is a package then we go one deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - - /* - * Build the package object - */ - ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); - LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; - - - ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE; - ThisDestObj->Package.Count = ThisDestObj->Package.Count; - - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = ThisDestObj->Package.Count * - sizeof (ACPI_OPERAND_OBJECT); - Length += ObjectSpace; - CurrentDepth++; - LevelPtr = &CopyLevel[CurrentDepth]; - LevelPtr->DestObj = ThisDestObj; - LevelPtr->SourceObj = ThisSourceObj; - LevelPtr->Index = 0; - - } /* if object is a package */ - - else - { - - ThisDestObj = AcpiCmCreateInternalObject ( - ThisSourceObj->Common.Type); - LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; - - Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState); - - if (ACPI_FAILURE (Status)) - { - /* - * Failure get out - */ - return_ACPI_STATUS (Status); - } - - Length +=ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= LevelPtr->DestObj->Package.Count) - { - /* - * We've handled all of the objects at this level, This means - * that we have just completed a package. That package may - * have contained one or more packages itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects in the top level - * package just add the length of the package objects - * and exit - */ - return_ACPI_STATUS (AE_OK); - } - - /* - * Go back up a level and move the index past the just - * completed package object. - */ - CurrentDepth--; - LevelPtr = &CopyLevel[CurrentDepth]; - LevelPtr->Index++; - } - } /* else object is NOT a package */ - } /* while (1) */ -} diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index 81305a8..ba7b341 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: 5 $ + * $Revision: 7 $ * *****************************************************************************/ @@ -282,15 +282,14 @@ AcpiEnterSleepState ( DEBUG_PRINT(ACPI_OK, ("Entering S%d\n", SleepState)); - /* the old version was disabling interrupts. let's try it without - * and see how that works - */ - /*disable();*/ + disable(); AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1A_CONTROL, PM1AControl); AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1B_CONTROL, PM1BControl); + AcpiHwRegisterWrite(ACPI_MTX_LOCK, PM1_CONTROL, + (1 << AcpiHwGetBitShift (SLP_EN_MASK))); - /*enable();*/ + enable(); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/hwtimer.c b/sys/contrib/dev/acpica/hwtimer.c index 197c65c..52139ed 100644 --- a/sys/contrib/dev/acpica/hwtimer.c +++ b/sys/contrib/dev/acpica/hwtimer.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * $Revision: 4 $ + * $Revision: 5 $ * *****************************************************************************/ @@ -235,7 +235,7 @@ AcpiGetTimerDuration ( /* * Compute Tick Delta: * ------------------- - * Handle timer rollovers on 24- versus 32-bit timers. + * Handle (max one) timer rollovers on 24- versus 32-bit timers. */ if (StartTicks < EndTicks) { @@ -246,7 +246,7 @@ AcpiGetTimerDuration ( /* 24-bit Timer */ if (0 == AcpiGbl_FADT->TmrValExt) { - DeltaTicks = (0x00FFFFFF - StartTicks) + EndTicks; + DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); } /* 32-bit Timer */ else @@ -254,6 +254,11 @@ AcpiGetTimerDuration ( DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; } } + else + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } /* * Compute Duration: diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index 10b1eb4..5c34853 100644 --- a/sys/contrib/dev/acpica/nseval.c +++ b/sys/contrib/dev/acpica/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 81 $ + * $Revision: 83 $ * ******************************************************************************/ @@ -388,8 +388,8 @@ AcpiNsEvaluateByHandle ( Node = AcpiNsConvertHandleToEntry (Handle); if (!Node) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -456,12 +456,6 @@ AcpiNsEvaluateByHandle ( * so we just return */ return_ACPI_STATUS (Status); - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); } @@ -497,6 +491,16 @@ AcpiNsExecuteControlMethod ( FUNCTION_TRACE ("NsExecuteControlMethod"); + /* + * Unlock the namespace before execution. This allows namespace access + * via the external Acpi* interfaces while a method is being executed. + * However, any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of the + * namespace that is being deleted. + */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + /* Verify that there is a method associated with this object */ ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); @@ -518,19 +522,8 @@ AcpiNsExecuteControlMethod ( DEBUG_PRINT (TRACE_NAMES, ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); - - /* - * Unlock the namespace before execution. This allows namespace access - * via the external Acpi* interfaces while a method is being executed. - * However, any namespace deletion must acquire both the namespace and - * interpreter locks to ensure that no thread is using the portion of the - * namespace that is being deleted. - */ - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - /* - * Excecute the method via the interpreter + * Execute the method via the interpreter */ Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c index c8b463c..672bbeb 100644 --- a/sys/contrib/dev/acpica/nsinit.c +++ b/sys/contrib/dev/acpica/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 12 $ + * $Revision: 15 $ * *****************************************************************************/ @@ -203,7 +203,7 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - UINT32 Flags) + void) { ACPI_STATUS Status; ACPI_DEVICE_WALK_INFO Info; @@ -212,7 +212,6 @@ AcpiNsInitializeDevices ( FUNCTION_TRACE ("NsInitializeDevices"); - Info.Flags = Flags; Info.DeviceCount = 0; Info.Num_STA = 0; Info.Num_INI = 0; @@ -304,7 +303,11 @@ AcpiNsInitOneObject ( AcpiCmFormatException (Status), &Node->Name)); } - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + break; @@ -324,7 +327,11 @@ AcpiNsInitOneObject ( DEBUG_PRINT (ACPI_ERROR, ("%s while getting field arguments [%4.4s]\n", AcpiCmFormatException (Status), &Node->Name)); } - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + break; @@ -344,7 +351,7 @@ AcpiNsInitOneObject ( * * FUNCTION: AcpiNsInitOneDevice * - * PARAMETERS: The usual "I'm a namespace callback" stuff + * PARAMETERS: WALK_CALLBACK * * RETURN: ACPI_STATUS * @@ -370,7 +377,11 @@ AcpiNsInitOneDevice ( FUNCTION_TRACE ("AcpiNsInitOneDevice"); - DEBUG_PRINT_RAW (ACPI_OK, (".")); + if (!(AcpiDbgLevel & TRACE_INIT)) + { + DEBUG_PRINT_RAW (ACPI_OK, (".")); + } + Info->DeviceCount++; AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); @@ -388,6 +399,7 @@ AcpiNsInitOneDevice ( * Run _STA to determine if we can run _INI on the device. */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, "_STA [Method]")); Status = AcpiCmExecute_STA (Node, &Flags); if (ACPI_FAILURE (Status)) { @@ -404,10 +416,13 @@ AcpiNsInitOneDevice ( return_ACPI_STATUS(AE_CTRL_DEPTH); } + + /* * The device is present. Run _INI. */ + DEBUG_EXEC(AcpiCmDisplayInitPathname (ObjHandle, "_INI [Method]")); Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); if (AE_NOT_FOUND == Status) { diff --git a/sys/contrib/dev/acpica/nsnames.c b/sys/contrib/dev/acpica/nsnames.c index 04662f5..b7cc321 100644 --- a/sys/contrib/dev/acpica/nsnames.c +++ b/sys/contrib/dev/acpica/nsnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * $Revision: 53 $ + * $Revision: 54 $ * ******************************************************************************/ @@ -219,6 +219,48 @@ AcpiNsGetTablePathname ( /******************************************************************************* * + * FUNCTION: AcpiNsGetPathnameLength + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Length of path, including prefix + * + * DESCRIPTION: Get the length of the pathname string for this node + * + ******************************************************************************/ + +UINT32 +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node) +{ + UINT32 Size; + ACPI_NAMESPACE_NODE *NextNode; + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + for (Size = 0, NextNode = Node; + AcpiNsGetParentObject (NextNode); + NextNode = AcpiNsGetParentObject (NextNode)) + { + Size += PATH_SEGMENT_LENGTH; + } + + /* Special case for size still 0 - no parent for "special" nodes */ + + if (!Size) + { + Size = PATH_SEGMENT_LENGTH; + } + + return (Size + 1); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiNsHandleToPathname * * PARAMETERS: TargetHandle - Handle of named object whose name is @@ -242,11 +284,10 @@ AcpiNsHandleToPathname ( { ACPI_STATUS Status = AE_OK; ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *NextNode; UINT32 PathLength; - UINT32 Size; UINT32 UserBufSize; ACPI_NAME Name; + UINT32 Size; FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); @@ -267,27 +308,12 @@ AcpiNsHandleToPathname ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - for (Size = 0, NextNode = Node; - AcpiNsGetParentObject (NextNode); - NextNode = AcpiNsGetParentObject (NextNode)) - { - Size += PATH_SEGMENT_LENGTH; - } - - /* Special case for size still 0 - no parent for "special" nodes */ - - if (!Size) - { - Size = PATH_SEGMENT_LENGTH; - } /* Set return length to the required path length */ - PathLength = Size + 1; + PathLength = AcpiNsGetPathnameLength (Node); + Size = PathLength - 1; + UserBufSize = *BufSize; *BufSize = PathLength; diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c index dd266bf..b90c31a 100644 --- a/sys/contrib/dev/acpica/nsxfobj.c +++ b/sys/contrib/dev/acpica/nsxfobj.c @@ -2,7 +2,7 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * $Revision: 78 $ + * $Revision: 80 $ * ******************************************************************************/ @@ -217,9 +217,8 @@ AcpiEvaluateObject ( */ for (i = 0; i < Count; i++) { - Status = - AcpiCmBuildInternalObject (&ParamObjects->Pointer[i], - ParamPtr[i]); + Status = AcpiCmCopyEobjectToIobject (&ParamObjects->Pointer[i], + ParamPtr[i]); if (ACPI_FAILURE (Status)) { @@ -362,7 +361,7 @@ AcpiEvaluateObject ( /* * We have enough space for the object, build it */ - Status = AcpiCmBuildExternalObject (ReturnObj, + Status = AcpiCmCopyIobjectToEobject (ReturnObj, ReturnBuffer); ReturnBuffer->Length = BufferSpaceNeeded; } @@ -725,14 +724,14 @@ AcpiNsGetDeviceCallback ( AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); Node = AcpiNsConvertHandleToEntry (ObjHandle); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + if (!Node) { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - /* * Run _STA to determine if device is present */ diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c index 9053fa3..2f03cf4 100644 --- a/sys/contrib/dev/acpica/rscalc.c +++ b/sys/contrib/dev/acpica/rscalc.c @@ -2,7 +2,7 @@ * * Module Name: rscalc - AcpiRsCalculateByteStreamLength * AcpiRsCalculateListLength - * $Revision: 18 $ + * $Revision: 21 $ * ******************************************************************************/ @@ -119,6 +119,8 @@ #include "acpi.h" #include "acresrc.h" +#include "amlcode.h" +#include "acnamesp.h" #define _COMPONENT RESOURCE_MANAGER MODULE_NAME ("rscalc") @@ -825,6 +827,7 @@ AcpiRsCalculateListLength ( */ BytesConsumed = 2; StructureSize = RESOURCE_LENGTH; + ByteStreamBufferLength = BytesParsed; break; @@ -936,7 +939,9 @@ AcpiRsCalculatePciRoutingTableLength ( for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) { - if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + if ((ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) || + ((INTERNAL_TYPE_REFERENCE == (*SubObjectList)->Common.Type) && + ((*SubObjectList)->Reference.OpCode == AML_NAMEPATH_OP))) { NameFound = TRUE; } @@ -950,18 +955,25 @@ AcpiRsCalculatePciRoutingTableLength ( } } - TempSizeNeeded += (sizeof (PCI_ROUTING_TABLE) - 1); + TempSizeNeeded += (sizeof (PCI_ROUTING_TABLE) - 4); /* * Was a String type found? */ if (TRUE == NameFound) { - /* - * The length String.Length field includes the - * terminating NULL - */ - TempSizeNeeded += (*SubObjectList)->String.Length; + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + /* + * The length String.Length field includes the + * terminating NULL + */ + TempSizeNeeded += (*SubObjectList)->String.Length; + } + else + { + TempSizeNeeded += AcpiNsGetPathnameLength ((*SubObjectList)->Reference.Node); + } } else @@ -985,7 +997,7 @@ AcpiRsCalculatePciRoutingTableLength ( } - *BufferSizeNeeded = TempSizeNeeded + sizeof (PCI_ROUTING_TABLE); + *BufferSizeNeeded = TempSizeNeeded; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c index 093b7a4..73d60b8 100644 --- a/sys/contrib/dev/acpica/rscreate.c +++ b/sys/contrib/dev/acpica/rscreate.c @@ -3,7 +3,7 @@ * Module Name: rscreate - AcpiRsCreateResourceList * AcpiRsCreatePciRoutingTable * AcpiRsCreateByteStream - * $Revision: 24 $ + * $Revision: 25 $ * ******************************************************************************/ @@ -121,6 +121,8 @@ #include "acpi.h" #include "acresrc.h" +#include "amlcode.h" +#include "acnamesp.h" #define _COMPONENT RESOURCE_MANAGER MODULE_NAME ("rscreate") @@ -266,6 +268,7 @@ AcpiRsCreatePciRoutingTable ( UINT32 NumberOfElements = 0; UINT32 Index = 0; PCI_ROUTING_TABLE *UserPrt = NULL; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; @@ -321,10 +324,10 @@ AcpiRsCreatePciRoutingTable ( /* * Fill in the Length field with the information we * have at this point. - * The minus one is to subtract the size of the - * UINT8 Source[1] member because it is added below. + * 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) - 1); + UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) -4); /* * Dereference the sub-package @@ -339,71 +342,99 @@ AcpiRsCreatePciRoutingTable ( SubObjectList = PackageElement->Package.Elements; /* - * Dereference the Address + * 1) First subobject: Dereference the Address */ if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.Address = - (*SubObjectList)->Integer.Value; + UserPrt->Address = (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } /* - * Dereference the Pin + * 2) Second subobject: Dereference the Pin */ SubObjectList++; if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.Pin = + UserPrt->Pin = (UINT32) (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } /* - * Dereference the Source Name + * 3) Third subobject: Dereference the Source Name */ SubObjectList++; - if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + switch ((*SubObjectList)->Common.Type) { - STRCPY (UserPrt->Data.Source, + case INTERNAL_TYPE_REFERENCE: + if ((*SubObjectList)->Reference.OpCode != AML_NAMEPATH_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need name, found reference op %X\n", + (*SubObjectList)->Reference.OpCode)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Node = (*SubObjectList)->Reference.Node; + + /* TBD: use *remaining* length of the buffer! */ + + Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node, + OutputBufferLength, UserPrt->Source); + + UserPrt->Length += STRLEN (UserPrt->Source) + 1; /* include null terminator */ + break; + + + case ACPI_TYPE_STRING: + + STRCPY (UserPrt->Source, (*SubObjectList)->String.Pointer); /* * Add to the Length field the length of the string */ UserPrt->Length += (*SubObjectList)->String.Length; - } + break; - else - { + + 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. */ - if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) - { - /* - * Add to the Length field the length of - * the UINT32 NULL - */ - UserPrt->Length += sizeof (UINT32); - } + /* + * Add to the Length field the length of + * the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + break; - else - { - return_ACPI_STATUS (AE_BAD_DATA); - } + + default: + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); + return_ACPI_STATUS (AE_BAD_DATA); + break; } /* Now align the current length */ @@ -411,18 +442,21 @@ AcpiRsCreatePciRoutingTable ( UserPrt->Length = ROUND_UP_TO_64BITS (UserPrt->Length); /* - * Dereference the Source Index + * 4) Fourth subobject: Dereference the Source Index */ SubObjectList++; if (ACPI_TYPE_INTEGER == (*SubObjectList)->Common.Type) { - UserPrt->Data.SourceIndex = + UserPrt->SourceIndex = (UINT32) (*SubObjectList)->Integer.Value; } else { + DEBUG_PRINT (ACPI_ERROR, + ("CreatePciRoutingTable: Need Integer, found %s\n", + AcpiCmGetTypeName ((*SubObjectList)->Common.Type))); return_ACPI_STATUS (AE_BAD_DATA); } diff --git a/sys/contrib/dev/acpica/rsdump.c b/sys/contrib/dev/acpica/rsdump.c index 94d28b9..70127ee 100644 --- a/sys/contrib/dev/acpica/rsdump.c +++ b/sys/contrib/dev/acpica/rsdump.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsdump - Functions do dump out the resource structures. - * $Revision: 15 $ + * $Revision: 16 $ * ******************************************************************************/ @@ -1013,25 +1013,25 @@ AcpiRsDumpIrqList ( if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) { - PrtElement = (PCI_ROUTING_TABLE *)Buffer; + PrtElement = (PCI_ROUTING_TABLE *) Buffer; while (!Done) { AcpiOsPrintf ("\tPCI IRQ Routing Table structure %X.\n", Count++); AcpiOsPrintf ("\t\tAddress: %X\n", - PrtElement->Data.Address); + PrtElement->Address); - AcpiOsPrintf ("\t\tPin: %X\n", PrtElement->Data.Pin); + AcpiOsPrintf ("\t\tPin: %X\n", PrtElement->Pin); - AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Data.Source); + AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Source); AcpiOsPrintf ("\t\tSourceIndex: %X\n", - PrtElement->Data.SourceIndex); + PrtElement->SourceIndex); Buffer += PrtElement->Length; - PrtElement = (PCI_ROUTING_TABLE *)Buffer; + PrtElement = (PCI_ROUTING_TABLE *) Buffer; if(0 == PrtElement->Length) { diff --git a/sys/contrib/dev/acpica/rslist.c b/sys/contrib/dev/acpica/rslist.c index 0647d63..60e10b4 100644 --- a/sys/contrib/dev/acpica/rslist.c +++ b/sys/contrib/dev/acpica/rslist.c @@ -2,7 +2,7 @@ * * Module Name: rslist - AcpiRsByteStreamToList * AcpiListToByteStream - * $Revision: 10 $ + * $Revision: 11 $ * ******************************************************************************/ @@ -399,8 +399,7 @@ AcpiRsByteStreamToList ( /* * Check the reason for exiting the while loop */ - if (!(ByteStreamBufferLength == BytesParsed) || - (TRUE != EndTagProcessed)) + if (TRUE != EndTagProcessed) { return_ACPI_STATUS (AE_AML_ERROR); } diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c index f27d724..a081e83 100644 --- a/sys/contrib/dev/acpica/utcopy.c +++ b/sys/contrib/dev/acpica/utcopy.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmcopy - Internal to external object translation utilities - * $Revision: 62 $ + * $Revision: 66 $ * *****************************************************************************/ @@ -119,54 +119,43 @@ #include "acpi.h" #include "acinterp.h" #include "acnamesp.h" +#include "amlcode.h" #define _COMPONENT MISCELLANEOUS MODULE_NAME ("cmcopy") -typedef struct Search_st -{ - ACPI_OPERAND_OBJECT *InternalObj; - UINT32 Index; - ACPI_OBJECT *ExternalObj; - -} PKG_SEARCH_INFO; - - -/* Used to traverse nested packages */ -PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH]; - -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalSimpleObject + * FUNCTION: AcpiCmCopyIsimpleToEsimple * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *Buffer - Where the object is returned - * *SpaceUsed - Where the data length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *Buffer - Where the object is returned + * *SpaceUsed - Where the data length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to place a simple object in a user - * buffer. + * buffer. * * The buffer is assumed to have sufficient space for the object. * ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildExternalSimpleObject ( - ACPI_OPERAND_OBJECT *InternalObj, - ACPI_OBJECT *ExternalObj, +AcpiCmCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, UINT32 *BufferSpaceUsed) { UINT32 Length = 0; - UINT8 *SourcePtr = NULL; + ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("CmBuildExternalSimpleObject"); + FUNCTION_TRACE ("CmCopyIsimpleToEsimple"); /* @@ -174,7 +163,7 @@ AcpiCmBuildExternalSimpleObject ( * package element */ - if (!InternalObj) + if (!InternalObject) { *BufferSpaceUsed = 0; return_ACPI_STATUS (AE_OK); @@ -182,110 +171,217 @@ AcpiCmBuildExternalSimpleObject ( /* Always clear the external object */ - MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT)); + MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); /* * In general, the external object will be the same type as * the internal object */ - ExternalObj->Type = InternalObj->Common.Type; + ExternalObject->Type = InternalObject->Common.Type; /* However, only a limited number of external types are supported */ - switch (ExternalObj->Type) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: - Length = InternalObj->String.Length + 1; - ExternalObj->String.Length = InternalObj->String.Length; - ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace; - SourcePtr = (UINT8 *) InternalObj->String.Pointer; + Length = InternalObject->String.Length + 1; + ExternalObject->String.Length = InternalObject->String.Length; + ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; + MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, Length); break; case ACPI_TYPE_BUFFER: - Length = InternalObj->Buffer.Length; - ExternalObj->Buffer.Length = InternalObj->Buffer.Length; - ExternalObj->Buffer.Pointer = DataSpace; - SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer; + Length = InternalObject->Buffer.Length; + ExternalObject->Buffer.Length = InternalObject->Buffer.Length; + ExternalObject->Buffer.Pointer = DataSpace; + MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, Length); break; case ACPI_TYPE_INTEGER: - ExternalObj->Integer.Value= InternalObj->Integer.Value; + ExternalObject->Integer.Value= InternalObject->Integer.Value; break; case INTERNAL_TYPE_REFERENCE: /* - * This is an object reference. We use the object type of "Any" - * to indicate a reference object containing a handle to an ACPI - * named object. + * This is an object reference. Attempt to dereference it. */ - ExternalObj->Type = ACPI_TYPE_ANY; - ExternalObj->Reference.Handle = InternalObj->Reference.Node; + switch (InternalObject->Reference.OpCode) + { + case AML_ZERO_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = 0; + break; + + case AML_ONE_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = 1; + break; + + case AML_ONES_OP: + ExternalObject->Type = ACPI_TYPE_INTEGER; + ExternalObject->Integer.Value = ACPI_INTEGER_MAX; + break; + + case AML_NAMEPATH_OP: + /* + * This is a named reference, get the string. We already know that + * we have room for it, use max length + */ + Length = MAX_STRING_LENGTH; + ExternalObject->Type = ACPI_TYPE_STRING; + ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; + Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) InternalObject->Reference.Node, + &Length, (char *) DataSpace); + break; + + default: + /* + * Use the object type of "Any" to indicate a reference + * to object containing a handle to an ACPI named object. + */ + ExternalObject->Type = ACPI_TYPE_ANY; + ExternalObject->Reference.Handle = InternalObject->Reference.Node; + break; + } break; case ACPI_TYPE_PROCESSOR: - ExternalObj->Processor.ProcId = - InternalObj->Processor.ProcId; - - ExternalObj->Processor.PblkAddress = - InternalObj->Processor.Address; - - ExternalObj->Processor.PblkLength = - InternalObj->Processor.Length; + ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; break; + case ACPI_TYPE_POWER: - ExternalObj->PowerResource.SystemLevel = - InternalObj->PowerResource.SystemLevel; + ExternalObject->PowerResource.SystemLevel = + InternalObject->PowerResource.SystemLevel; - ExternalObj->PowerResource.ResourceOrder = - InternalObj->PowerResource.ResourceOrder; + ExternalObject->PowerResource.ResourceOrder = + InternalObject->PowerResource.ResourceOrder; break; + default: - return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + /* + * There is no corresponding external object type + */ + return_ACPI_STATUS (AE_SUPPORT); break; } - /* Copy data if necessary (strings or buffers) */ - if (Length) + *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIelementToEelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + UINT32 ObjectSpace; + UINT32 ThisIndex; + ACPI_OBJECT *TargetObject; + + + + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + + + switch (ObjectType) { + case 0: + /* - * Copy the return data to the caller's buffer + * This is a simple or null object -- get the size */ - MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length); + + Status = AcpiCmCopyIsimpleToEsimple (SourceObject, + TargetObject, Info->FreeSpace, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + break; + + case 1: + + /* + * Build the package object + */ + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = (ACPI_OBJECT *) Info->FreeSpace; + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( + TargetObject->Package.Count * sizeof (ACPI_OBJECT)); + break; + + default: + return (AE_BAD_PARAMETER); } - *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; - return_ACPI_STATUS (AE_OK); + return (Status); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalPackageObject + * FUNCTION: AcpiCmCopyIpackageToEpackage * - * PARAMETERS: *InternalObj - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *SpaceUsed - Where the object length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the object length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to place a package object in a user * buffer. A package object by definition contains other objects. @@ -297,52 +393,37 @@ AcpiCmBuildExternalSimpleObject ( ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildExternalPackageObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, UINT32 *SpaceUsed) { - UINT8 *FreeSpace; - ACPI_OBJECT *ExternalObj; - UINT32 CurrentDepth = 0; + ACPI_OBJECT *ExternalObject; ACPI_STATUS Status; - UINT32 Length = 0; - UINT32 ThisIndex; - UINT32 ObjectSpace; - ACPI_OPERAND_OBJECT *ThisInternalObj; - ACPI_OBJECT *ThisExternalObj; - PKG_SEARCH_INFO *LevelPtr; + ACPI_PKG_INFO Info; - FUNCTION_TRACE ("CmBuildExternalPackageObject"); + FUNCTION_TRACE ("CmCopyIpackageToEpackage"); /* * First package at head of the buffer */ - ExternalObj = (ACPI_OBJECT *) Buffer; + ExternalObject = (ACPI_OBJECT *) Buffer; /* * Free space begins right after the first package */ - FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + Info.FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - /* - * Initialize the working variables - */ - MEMSET ((void *) Level, 0, sizeof (Level)); - - Level[0].InternalObj = InternalObj; - Level[0].ExternalObj = ExternalObj; - Level[0].Index = 0; - LevelPtr = &Level[0]; - CurrentDepth = 0; - - ExternalObj->Type = InternalObj->Common.Type; - ExternalObj->Package.Count = InternalObj->Package.Count; - ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = (ACPI_OBJECT *) Info.FreeSpace; /* @@ -350,144 +431,27 @@ AcpiCmBuildExternalPackageObject ( * and move the free space past it */ - FreeSpace += ExternalObj->Package.Count * - ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - - - while (1) - { - ThisIndex = LevelPtr->Index; - ThisInternalObj = - (ACPI_OPERAND_OBJECT *) - LevelPtr->InternalObj->Package.Elements[ThisIndex]; - ThisExternalObj = - (ACPI_OBJECT *) - &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - + Info.FreeSpace += ExternalObject->Package.Count * + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - /* - * Check for - * 1) Null object -- OK, this can happen if package - * element is never initialized - * 2) Not an internal object - can be Node instead - * 3) Any internal object other than a package. - * - * The more complex package case is handled later - */ - if ((!ThisInternalObj) || - (!VALID_DESCRIPTOR_TYPE ( - ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) || - (!IS_THIS_OBJECT_TYPE ( - ThisInternalObj, ACPI_TYPE_PACKAGE))) - { - /* - * This is a simple or null object -- get the size - */ + Status = AcpiCmWalkPackageTree (InternalObject, ExternalObject, + AcpiCmCopyIelementToEelement, &Info); - Status = - AcpiCmBuildExternalSimpleObject (ThisInternalObj, - ThisExternalObj, - FreeSpace, - &ObjectSpace); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= - LevelPtr->InternalObj->Package.Count) - { - /* - * We've handled all of the objects at this - * level. This means that we have just - * completed a package. That package may - * have contained one or more packages - * itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add - * the length of the package objects - * and get out - */ - *SpaceUsed = Length; - return_ACPI_STATUS (AE_OK); - } - - /* - * go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->Index++; - } - } + *SpaceUsed = Info.Length; + return_ACPI_STATUS (Status); - else - { - /* - * This object is a package - * -- we must go one level deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages - * for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("CmBuildPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - - /* - * Build the package object - */ - ThisExternalObj->Type = ACPI_TYPE_PACKAGE; - ThisExternalObj->Package.Count = - ThisInternalObj->Package.Count; - ThisExternalObj->Package.Elements = - (ACPI_OBJECT *) FreeSpace; - - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( - ThisExternalObj->Package.Count * - sizeof (ACPI_OBJECT)); - - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - CurrentDepth++; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->InternalObj = ThisInternalObj; - LevelPtr->ExternalObj = ThisExternalObj; - LevelPtr->Index = 0; - } - } } - -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildExternalObject + * FUNCTION: AcpiCmCopyIobjectToEobject * - * PARAMETERS: *InternalObj - The internal object to be converted - * *BufferPtr - Where the object is returned + * PARAMETERS: *InternalObject - The internal object to be converted + * *BufferPtr - Where the object is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to build an API object to be returned to * the caller. @@ -495,26 +459,24 @@ AcpiCmBuildExternalPackageObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildExternalObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *InternalObject, ACPI_BUFFER *RetBuffer) { ACPI_STATUS Status; - FUNCTION_TRACE ("CmBuildExternalObject"); + FUNCTION_TRACE ("CmCopyIobjectToEobject"); - if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE)) + if (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE)) { /* - * Package objects contain other objects (which can be objects) - * buildpackage does it all + * Package object: Copy all subobjects (including + * nested packages) */ - Status = - AcpiCmBuildExternalPackageObject (InternalObj, - RetBuffer->Pointer, - &RetBuffer->Length); + Status = AcpiCmCopyIpackageToEpackage (InternalObject, + RetBuffer->Pointer, &RetBuffer->Length); } else @@ -522,13 +484,11 @@ AcpiCmBuildExternalObject ( /* * Build a simple object (no nested objects) */ - Status = - AcpiCmBuildExternalSimpleObject (InternalObj, - (ACPI_OBJECT *) RetBuffer->Pointer, - ((UINT8 *) RetBuffer->Pointer + - ROUND_UP_TO_NATIVE_WORD ( - sizeof (ACPI_OBJECT))), - &RetBuffer->Length); + Status = AcpiCmCopyIsimpleToEsimple (InternalObject, + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); /* * build simple does not include the object size in the length * so we add it in here @@ -540,14 +500,15 @@ AcpiCmBuildExternalObject ( } -/****************************************************************************** + +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalSimpleObject + * FUNCTION: AcpiCmCopyEsimpleToIsimple * - * PARAMETERS: *ExternalObj - The external object to be converted - * *InternalObj - Where the internal object is returned + * PARAMETERS: *ExternalObject - The external object to be converted + * *InternalObject - Where the internal object is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function copies an external object to an internal one. * NOTE: Pointers can be copied, we don't need to copy data. @@ -557,30 +518,30 @@ AcpiCmBuildExternalObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildInternalSimpleObject ( - ACPI_OBJECT *ExternalObj, - ACPI_OPERAND_OBJECT *InternalObj) +AcpiCmCopyEsimpleToIsimple ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT *InternalObject) { - FUNCTION_TRACE ("CmBuildInternalSimpleObject"); + FUNCTION_TRACE ("CmCopyEsimpleToIsimple"); - InternalObj->Common.Type = (UINT8) ExternalObj->Type; + InternalObject->Common.Type = (UINT8) ExternalObject->Type; - switch (ExternalObj->Type) + switch (ExternalObject->Type) { case ACPI_TYPE_STRING: - InternalObj->String.Length = ExternalObj->String.Length; - InternalObj->String.Pointer = ExternalObj->String.Pointer; + InternalObject->String.Length = ExternalObject->String.Length; + InternalObject->String.Pointer = ExternalObject->String.Pointer; break; case ACPI_TYPE_BUFFER: - InternalObj->Buffer.Length = ExternalObj->Buffer.Length; - InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer; + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + InternalObject->Buffer.Pointer = ExternalObject->Buffer.Pointer; break; @@ -588,7 +549,7 @@ AcpiCmBuildInternalSimpleObject ( /* * Number is included in the object itself */ - InternalObj->Integer.Value = ExternalObj->Integer.Value; + InternalObject->Integer.Value = ExternalObject->Integer.Value; break; @@ -606,11 +567,11 @@ AcpiCmBuildInternalSimpleObject ( /* Code to convert packages that are parameters to control methods */ -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalPackageObject + * FUNCTION: AcpiCmCopyEpackageToIpackage * - * PARAMETERS: *InternalObj - Pointer to the object we are returning + * PARAMETERS: *InternalObject - Pointer to the object we are returning * *Buffer - Where the object is returned * *SpaceUsed - Where the length of the object is returned * @@ -626,29 +587,27 @@ AcpiCmBuildInternalSimpleObject ( ******************************************************************************/ static ACPI_STATUS -AcpiCmBuildInternalPackageObject ( - ACPI_OPERAND_OBJECT *InternalObj, +AcpiCmCopyEpackageToIpackage ( + ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, UINT32 *SpaceUsed) { UINT8 *FreeSpace; - ACPI_OBJECT *ExternalObj; - UINT32 CurrentDepth = 0; + ACPI_OBJECT *ExternalObject; UINT32 Length = 0; UINT32 ThisIndex; UINT32 ObjectSpace = 0; ACPI_OPERAND_OBJECT *ThisInternalObj; ACPI_OBJECT *ThisExternalObj; - PKG_SEARCH_INFO *LevelPtr; - FUNCTION_TRACE ("CmBuildInternalPackageObject"); + FUNCTION_TRACE ("CmCopyEpackageToIpackage"); /* * First package at head of the buffer */ - ExternalObj = (ACPI_OBJECT *)Buffer; + ExternalObject = (ACPI_OBJECT *)Buffer; /* * Free space begins right after the first package @@ -656,20 +615,9 @@ AcpiCmBuildInternalPackageObject ( FreeSpace = Buffer + sizeof(ACPI_OBJECT); - /* - * Initialize the working variables - */ - - MEMSET ((void *) Level, 0, sizeof(Level)); - - Level[0].InternalObj = InternalObj; - Level[0].ExternalObj = ExternalObj; - LevelPtr = &Level[0]; - CurrentDepth = 0; - - ExternalObj->Type = InternalObj->Common.Type; - ExternalObj->Package.Count = InternalObj->Package.Count; - ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace; + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace; /* @@ -677,108 +625,21 @@ AcpiCmBuildInternalPackageObject ( * and move the free space past it */ - FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT); - - - while (1) - { - ThisIndex = LevelPtr->Index; - - ThisInternalObj = (ACPI_OPERAND_OBJECT *) - &LevelPtr->InternalObj->Package.Elements[ThisIndex]; - - ThisExternalObj = (ACPI_OBJECT *) - &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - - if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE)) - { - /* - * If this object is a package then we go one deeper - */ - if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) - { - /* - * Too many nested levels of packages for us to handle - */ - DEBUG_PRINT (ACPI_ERROR, - ("CmBuildPackageObject: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } + FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT); - /* - * Build the package object - */ - ThisExternalObj->Type = ACPI_TYPE_PACKAGE; - ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; - ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; - /* - * Save space for the array of objects (Package elements) - * update the buffer length counter - */ - ObjectSpace = ThisExternalObj->Package.Count * - sizeof (ACPI_OBJECT); + /* Call WalkPackage */ - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - CurrentDepth++; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->InternalObj = ThisInternalObj; - LevelPtr->ExternalObj = ThisExternalObj; - LevelPtr->Index = 0; - - } /* if object is a package */ - - else - { - FreeSpace += ObjectSpace; - Length += ObjectSpace; - - LevelPtr->Index++; - while (LevelPtr->Index >= - LevelPtr->InternalObj->Package.Count) - { - /* - * We've handled all of the objects at - * this level, This means that we have - * just completed a package. That package - * may have contained one or more packages - * itself - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add - * the length of the package objects - * and get out - */ - *SpaceUsed = Length; - return_ACPI_STATUS (AE_OK); - } - - /* - * go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - LevelPtr = &Level[CurrentDepth]; - LevelPtr->Index++; - } - } /* else object is NOT a package */ - } /* while (1) */ } #endif /* Future implementation */ -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmBuildInternalObject + * FUNCTION: AcpiCmCopyEobjectToIobject * - * PARAMETERS: *InternalObj - The external object to be converted + * PARAMETERS: *InternalObject - The external object to be converted * *BufferPtr - Where the internal object is returned * * RETURN: Status - the status of the call @@ -788,17 +649,17 @@ AcpiCmBuildInternalPackageObject ( ******************************************************************************/ ACPI_STATUS -AcpiCmBuildInternalObject ( - ACPI_OBJECT *ExternalObj, - ACPI_OPERAND_OBJECT *InternalObj) +AcpiCmCopyEobjectToIobject ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT *InternalObject) { ACPI_STATUS Status; - FUNCTION_TRACE ("CmBuildInternalObject"); + FUNCTION_TRACE ("AcpiCmCopyEobjectToIobject"); - if (ExternalObj->Type == ACPI_TYPE_PACKAGE) + if (ExternalObject->Type == ACPI_TYPE_PACKAGE) { /* * Package objects contain other objects (which can be objects) @@ -809,12 +670,12 @@ AcpiCmBuildInternalObject ( * control methods only. This is a very, very rare case. */ /* - Status = AcpiCmBuildInternalPackageObject(InternalObj, + Status = AcpiCmCopyEpackageToIpackage(InternalObject, RetBuffer->Pointer, &RetBuffer->Length); */ DEBUG_PRINT (ACPI_ERROR, - ("CmBuildInternalObject: Packages as parameters not implemented!\n")); + ("AcpiCmCopyEobjectToIobject: Packages as parameters not implemented!\n")); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } @@ -824,7 +685,7 @@ AcpiCmBuildInternalObject ( /* * Build a simple object (no nested objects) */ - Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj); + Status = AcpiCmCopyEsimpleToIsimple (ExternalObject, InternalObject); /* * build simple does not include the object size in the length * so we add it in here @@ -834,3 +695,146 @@ AcpiCmBuildInternalObject ( return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIelementToIelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT **ThisTargetPtr; + ACPI_OPERAND_OBJECT *TargetObject; + + + + ThisIndex = State->Pkg.Index; + ThisTargetPtr = (ACPI_OPERAND_OBJECT **) + &State->Pkg.DestObject->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case 0: + + /* + * This is a simple object, just copy it + */ + TargetObject = AcpiCmCreateInternalObject (SourceObject->Common.Type); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + Status = AcpiAmlStoreObjectToObject (SourceObject, TargetObject, + (ACPI_WALK_STATE *) Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *ThisTargetPtr = TargetObject; + break; + + + case 1: + /* + * This object is a package - go down another nesting level + * Create and build the package object + */ + TargetObject = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!TargetObject) + { + /* TBD: must delete package created up to this point */ + + return (AE_NO_MEMORY); + } + + TargetObject->Package.Count = SourceObject->Package.Count; + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Store the object pointer in the parent package object + */ + *ThisTargetPtr = TargetObject; + break; + + default: + return (AE_BAD_PARAMETER); + } + + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCopyIpackageToIpackage + * + * PARAMETERS: *SourceObj - Pointer to the source package object + * *DestObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + FUNCTION_TRACE ("CmCopyIpackageToIpackage"); + + + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Package.Count = SourceObj->Package.Count; + + + /* + * Create the object array and walk the source package tree + */ + + DestObj->Package.Elements = AcpiCmCallocate ((SourceObj->Package.Count + 1) * + sizeof (void *)); + DestObj->Package.NextElement = DestObj->Package.Elements; + + if (!DestObj->Package.Elements) + { + REPORT_ERROR ( + ("AmlBuildCopyInternalPackageObject: Package allocation failure\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + Status = AcpiCmWalkPackageTree (SourceObj, DestObj, + AcpiCmCopyIelementToIelement, WalkState); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c index 2c9c60d..123e4e1 100644 --- a/sys/contrib/dev/acpica/utmisc.c +++ b/sys/contrib/dev/acpica/utmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: cmutils - common utility procedures - * $Revision: 23 $ + * $Revision: 27 $ * ******************************************************************************/ @@ -476,6 +476,44 @@ AcpiCmCreateUpdateStateAndPush ( /******************************************************************************* * + * FUNCTION: AcpiCmCreatePkgStateAndPush + * + * PARAMETERS: *Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: None + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + + State = AcpiCmCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + + AcpiCmPushGenericState (StateList, State); + return (AE_OK); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiCmPushGenericState * * PARAMETERS: ListHead - Head of the state stack @@ -650,6 +688,54 @@ AcpiCmCreateUpdateState ( /******************************************************************************* * + * FUNCTION: AcpiCmCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the + * state + * Action - Update action to be performed + * + * RETURN: Status + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmCreatePkgState", InternalObject); + + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + /* Init fields specific to the update struct */ + + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index = Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + + +/******************************************************************************* + * * FUNCTION: AcpiCmCreateControlState * * PARAMETERS: None @@ -793,19 +879,24 @@ ACPI_STATUS AcpiCmResolvePackageReferences ( ACPI_OPERAND_OBJECT *ObjDesc) { - UINT32 Count; - ACPI_OPERAND_OBJECT *SubObject; + UINT32 Count; + ACPI_OPERAND_OBJECT *SubObject; + FUNCTION_TRACE ("AcpiCmResolvePackageReferences"); + if (ObjDesc->Common.Type != ACPI_TYPE_PACKAGE) { - /* Must be a package */ + /* The object must be a package */ REPORT_ERROR (("Must resolve Package Refs on a Package\n")); return_ACPI_STATUS(AE_ERROR); } + /* + * TBD: what about nested packages? */ + for (Count = 0; Count < ObjDesc->Package.Count; Count++) { SubObject = ObjDesc->Package.Elements[Count]; @@ -833,6 +924,181 @@ AcpiCmResolvePackageReferences ( return_ACPI_STATUS(AE_OK); } +#ifdef ACPI_DEBUG + +/****************************************************************************** + * + * FUNCTION: AcpiCmDisplayInitPathname + * + * PARAMETERS: ObjHandle - Handle whose pathname will be displayed + * Path - Additional path string to be appended + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY + * + *****************************************************************************/ + +void +AcpiCmDisplayInitPathname ( + ACPI_HANDLE ObjHandle, + char *Path) +{ + ACPI_STATUS Status; + UINT32 Length = 128; + char Buffer[128]; + + + Status = AcpiNsHandleToPathname (ObjHandle, &Length, Buffer); + if (ACPI_SUCCESS (Status)) + { + if (Path) + { + DEBUG_PRINT (TRACE_INIT, ("%s.%s\n", Buffer, Path)) + } + else + { + DEBUG_PRINT (TRACE_INIT, ("%s\n", Buffer)) + } + } +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiCmWalkPackageTree + * + * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT *ThisSourceObj; + + + FUNCTION_TRACE ("AcpiCmWalkPackageTree"); + + + State = AcpiCmCreatePkgState (SourceObject, TargetObject, 0); + if (!State) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + while (State) + { + ThisIndex = State->Pkg.Index; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) + State->Pkg.SourceObject->Package.Elements[ThisIndex]; + + /* + * Check for + * 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Not an internal object - can be a namespace node instead + * 3) Any type other than a package. Packages are handled in else case below. + */ + if ((!ThisSourceObj) || + (!VALID_DESCRIPTOR_TYPE ( + ThisSourceObj, ACPI_DESC_TYPE_INTERNAL)) || + (!IS_THIS_OBJECT_TYPE ( + ThisSourceObj, ACPI_TYPE_PACKAGE))) + { + + Status = WalkCallback (0, ThisSourceObj, State, Context); + if (ACPI_FAILURE (Status)) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (Status); + } + + State->Pkg.Index++; + while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + { + /* + * We've handled all of the objects at this level, This means + * that we have just completed a package. That package may + * have contained one or more packages itself. + * + * Delete this state and pop the previous state (package). + */ + AcpiCmDeleteGenericState (State); + State = AcpiCmPopGenericState (&StateList); + + + /* Finished when there are no more states */ + + if (!State) + { + /* + * We have handled all of the objects in the top level + * package just add the length of the package objects + * and exit + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index past the just + * completed package object. + */ + State->Pkg.Index++; + } + } + + else + { + /* This is a sub-object of type package */ + + Status = WalkCallback (1, ThisSourceObj, State, Context); + if (ACPI_FAILURE (Status)) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (Status); + } + + + /* + * The callback above returned a new target package object. + */ + + /* + * Push the current state and create a new one + */ + AcpiCmPushGenericState (&StateList, State); + State = AcpiCmCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0); + if (!State) + { + /* TBD: must delete package created up to this point */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + } + + /* We should never get here */ + + return (AE_AML_INTERNAL); + +} + + /******************************************************************************* * @@ -845,7 +1111,7 @@ AcpiCmResolvePackageReferences ( * * RETURN: None * - * DESCRIPTION: Print error message from KD table + * DESCRIPTION: Print error message * ******************************************************************************/ @@ -872,7 +1138,7 @@ _ReportError ( * * RETURN: None * - * DESCRIPTION: Print warning message from KD table + * DESCRIPTION: Print warning message * ******************************************************************************/ @@ -898,7 +1164,7 @@ _ReportWarning ( * * RETURN: None * - * DESCRIPTION: Print information message from KD table + * DESCRIPTION: Print information message * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/utobject.c b/sys/contrib/dev/acpica/utobject.c index dd8bf22..13869b3 100644 --- a/sys/contrib/dev/acpica/utobject.c +++ b/sys/contrib/dev/acpica/utobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmobject - ACPI object create/delete/size/cache routines - * $Revision: 35 $ + * $Revision: 36 $ * *****************************************************************************/ @@ -127,7 +127,7 @@ MODULE_NAME ("cmobject") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: _CmCreateInternalObject * @@ -141,11 +141,11 @@ * * DESCRIPTION: Create and initialize a new internal object. * - * NOTE: - * We always allocate the worst-case object descriptor because these - * objects are cached, and we want them to be one-size-satisifies-any-request. - * This in itself may not be the most memory efficient, but the efficiency - * of the object cache should more than make up for this! + * NOTE: We always allocate the worst-case object descriptor because + * these objects are cached, and we want them to be + * one-size-satisifies-any-request. This in itself may not be + * the most memory efficient, but the efficiency of the object + * cache should more than make up for this! * ******************************************************************************/ @@ -187,7 +187,7 @@ _CmCreateInternalObject ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmValidInternalObject * @@ -195,7 +195,7 @@ _CmCreateInternalObject ( * * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT * - *****************************************************************************/ + ******************************************************************************/ BOOLEAN AcpiCmValidInternalObject ( @@ -257,7 +257,7 @@ AcpiCmValidInternalObject ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: _CmAllocateObjectDesc * @@ -271,7 +271,7 @@ AcpiCmValidInternalObject ( * DESCRIPTION: Allocate a new object descriptor. Gracefully handle * error conditions. * - ****************************************************************************/ + ******************************************************************************/ void * _CmAllocateObjectDesc ( @@ -341,7 +341,7 @@ _CmAllocateObjectDesc ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmDeleteObjectDesc * @@ -351,7 +351,7 @@ _CmAllocateObjectDesc ( * * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache * - ****************************************************************************/ + ******************************************************************************/ void AcpiCmDeleteObjectDesc ( @@ -414,7 +414,7 @@ AcpiCmDeleteObjectDesc ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmDeleteObjectCache * @@ -461,7 +461,7 @@ AcpiCmDeleteObjectCache ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmInitStaticObject * @@ -473,7 +473,7 @@ AcpiCmDeleteObjectCache ( * DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic * deletion of the object. * - ****************************************************************************/ + ******************************************************************************/ void AcpiCmInitStaticObject ( @@ -512,14 +512,14 @@ AcpiCmInitStaticObject ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiCmGetSimpleObjectSize * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length is returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain a simple object for return to an API user. @@ -531,19 +531,19 @@ AcpiCmInitStaticObject ( ACPI_STATUS AcpiCmGetSimpleObjectSize ( - ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OPERAND_OBJECT *InternalObject, UINT32 *ObjLength) { UINT32 Length; ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObj); + FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObject); /* Handle a null object (Could be a uninitialized package element -- which is legal) */ - if (!InternalObj) + if (!InternalObject) { *ObjLength = 0; return_ACPI_STATUS (AE_OK); @@ -554,7 +554,7 @@ AcpiCmGetSimpleObjectSize ( Length = sizeof (ACPI_OBJECT); - if (VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_NAMED)) + if (VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_NAMED)) { /* Object is a named object (reference), just return the length */ @@ -571,18 +571,18 @@ AcpiCmGetSimpleObjectSize ( * TBD:[Investigate] do strings and buffers require alignment also? */ - switch (InternalObj->Common.Type) + switch (InternalObject->Common.Type) { case ACPI_TYPE_STRING: - Length += InternalObj->String.Length + 1; + Length += InternalObject->String.Length + 1; break; case ACPI_TYPE_BUFFER: - Length += InternalObj->Buffer.Length; + Length += InternalObject->Buffer.Length; break; @@ -602,11 +602,11 @@ AcpiCmGetSimpleObjectSize ( * The only type that should be here is opcode AML_NAMEPATH_OP -- since * this means an object reference */ - if (InternalObj->Reference.OpCode != AML_NAMEPATH_OP) + if (InternalObject->Reference.OpCode != AML_NAMEPATH_OP) { DEBUG_PRINT (ACPI_ERROR, ("CmGetSimpleObjectSize: Unsupported Reference opcode=%X in object %p\n", - InternalObj->Reference.OpCode, InternalObj)); + InternalObject->Reference.OpCode, InternalObject)); Status = AE_TYPE; } break; @@ -616,7 +616,7 @@ AcpiCmGetSimpleObjectSize ( DEBUG_PRINT (ACPI_ERROR, ("CmGetSimpleObjectSize: Unsupported type=%X in object %p\n", - InternalObj->Common.Type, InternalObj)); + InternalObject->Common.Type, InternalObject)); Status = AE_TYPE; break; } @@ -634,161 +634,124 @@ AcpiCmGetSimpleObjectSize ( } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiCmGetPackageObjectSize + * FUNCTION: AcpiCmCopyPackageToInternal * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length is returned + * PARAMETERS: ACPI_PKG_CALLBACK * * RETURN: Status - the status of the call * - * DESCRIPTION: This function is called to determine the space required to contain - * a package object for return to an API user. - * - * This is moderately complex since a package contains other objects - * including packages. + * DESCRIPTION: * ******************************************************************************/ ACPI_STATUS -AcpiCmGetPackageObjectSize ( - ACPI_OPERAND_OBJECT *InternalObj, - UINT32 *ObjLength) +AcpiCmGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) { - - ACPI_OPERAND_OBJECT *ThisInternalObj; - ACPI_OPERAND_OBJECT *ParentObj[MAX_PACKAGE_DEPTH]; - ACPI_OPERAND_OBJECT *ThisParent; - UINT32 ThisIndex; - UINT32 Index[MAX_PACKAGE_DEPTH]; - UINT32 Length = 0; + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; UINT32 ObjectSpace; - UINT32 CurrentDepth = 0; - UINT32 PackageCount = 1; - ACPI_STATUS Status; - FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj); + switch (ObjectType) + { + case 0: + /* + * Simple object - just get the size (Null object/entry is handled + * here also) and sum it into the running package length + */ + Status = AcpiCmGetSimpleObjectSize (SourceObject, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - /* Init the package stack TBD: replace with linked list */ + Info->Length += ObjectSpace; + break; - MEMSET(ParentObj, 0, MAX_PACKAGE_DEPTH); - MEMSET(Index, 0, MAX_PACKAGE_DEPTH); - ParentObj[0] = InternalObj; + case 1: + /* Package - nothing much to do here, let the walk handle it */ - while (1) - { - ThisParent = ParentObj[CurrentDepth]; - ThisIndex = Index[CurrentDepth]; - ThisInternalObj = ThisParent->Package.Elements[ThisIndex]; + Info->NumPackages++; + State->Pkg.ThisTargetObj = NULL; + break; + default: + return (AE_BAD_PARAMETER); + } - /* - * Check for 1) An uninitialized package element. It is completely - * legal to declare a package and leave it uninitialized - * 2) Any type other than a package. Packages are handled - * below. - */ - if ((!ThisInternalObj) || - (!IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))) - { - /* - * Simple object - just get the size (Null object/entry handled - * also) - */ - - Status = - AcpiCmGetSimpleObjectSize (ThisInternalObj, &ObjectSpace); - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length += ObjectSpace; - - Index[CurrentDepth]++; - while (Index[CurrentDepth] >= - ParentObj[CurrentDepth]->Package.Count) - { - /* - * We've handled all of the objects at - * this level, This means that we have - * just completed a package. That package - * may have contained one or more packages - * itself. - */ - if (CurrentDepth == 0) - { - /* - * We have handled all of the objects - * in the top level package just add the - * length of the package objects and - * get out. Round up to the next machine - * word. - */ - Length += - ROUND_UP_TO_NATIVE_WORD ( - sizeof (ACPI_OBJECT)) * - PackageCount; - - *ObjLength = Length; - - return_ACPI_STATUS (AE_OK); - } - - /* - * Go back up a level and move the index - * past the just completed package object. - */ - CurrentDepth--; - Index[CurrentDepth]++; - } - } + return (Status); +} - else - { - /* - * This object is a package - * -- go one level deeper - */ - PackageCount++; - if (CurrentDepth < MAX_PACKAGE_DEPTH-1) - { - CurrentDepth++; - ParentObj[CurrentDepth] = ThisInternalObj; - Index[CurrentDepth] = 0; - } - - else - { - /* - * Too many nested levels of packages for us - * to handle - */ - - DEBUG_PRINT (ACPI_ERROR, - ("CmGetPackageObjectSize: Pkg nested too deep (max %X)\n", - MAX_PACKAGE_DEPTH)); - return_ACPI_STATUS (AE_LIMIT); - } - } - } + +/******************************************************************************* + * + * FUNCTION: AcpiCmGetPackageObjectSize + * + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a package object for return to an API user. + * + * This is moderately complex since a package contains other + * objects including packages. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT32 *ObjLength) +{ + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObject); + + + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + Status = AcpiCmWalkPackageTree (InternalObject, NULL, + AcpiCmGetElementLength, &Info); + + /* + * We have handled all of the objects in all levels of the package. + * just add the length of the package objects themselves. + * Round up to the next machine word. + */ + Info.Length += ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * + Info.NumPackages; + + /* Return the total package length */ + + *ObjLength = Info.Length; + return_ACPI_STATUS (Status); } -/****************************************************************************** + +/******************************************************************************* * * FUNCTION: AcpiCmGetObjectSize * - * PARAMETERS: *InternalObj - Pointer to the object we are examining - * *RetLength - Where the length will be returned + * PARAMETERS: *InternalObject - Pointer to the object we are examining + * *RetLength - Where the length will be returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain an object for return to an API user. @@ -797,23 +760,21 @@ AcpiCmGetPackageObjectSize ( ACPI_STATUS AcpiCmGetObjectSize( - ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OPERAND_OBJECT *InternalObject, UINT32 *ObjLength) { ACPI_STATUS Status; - if ((VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_INTERNAL)) && - (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))) + if ((VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_INTERNAL)) && + (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE))) { - Status = - AcpiCmGetPackageObjectSize (InternalObj, ObjLength); + Status = AcpiCmGetPackageObjectSize (InternalObject, ObjLength); } else { - Status = - AcpiCmGetSimpleObjectSize (InternalObj, ObjLength); + Status = AcpiCmGetSimpleObjectSize (InternalObject, ObjLength); } return (Status); diff --git a/sys/contrib/dev/acpica/utxface.c b/sys/contrib/dev/acpica/utxface.c index 2376295..92312b9 100644 --- a/sys/contrib/dev/acpica/utxface.c +++ b/sys/contrib/dev/acpica/utxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmxface - External interfaces for "global" ACPI functions - * $Revision: 62 $ + * $Revision: 64 $ * *****************************************************************************/ @@ -272,9 +272,8 @@ AcpiEnableSubsystem ( Status = AcpiEnable (); if (ACPI_FAILURE (Status)) { - /* TBD: workaround. Old Lions don't enable properly */ DEBUG_PRINT(ACPI_WARN, ("AcpiEnable failed.\n")); - /*return_ACPI_STATUS (Status);*/ + return_ACPI_STATUS (Status); } } @@ -299,15 +298,14 @@ AcpiEnableSubsystem ( /* * Initialize all device objects in the namespace - * This runs the _STA, _INI, and _HID methods, and detects - * the PCI root bus(es) + * This runs the _STA and _INI methods. */ if (!(Flags & ACPI_NO_DEVICE_INIT)) { DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Devices\n")); - Status = AcpiNsInitializeDevices (Flags & ACPI_NO_PCI_INIT); + Status = AcpiNsInitializeDevices (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -316,7 +314,7 @@ AcpiEnableSubsystem ( /* - * Initialize the objects that remain unitialized. This + * Initialize the objects that remain uninitialized. This * runs the executable AML that is part of the declaration of OpRegions * and Fields. */ -- cgit v1.1