Prefixed component IDs with "ACPI_"

date	2001.03.07.19.28.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 19:01:53 +00:00
parent f26d2676a0
commit cbe66edf02
10 changed files with 602 additions and 218 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmalloc - local memory allocation routines
* $Revision: 1.85 $
* $Revision: 1.86 $
*
*****************************************************************************/
@ -122,7 +122,7 @@
#include "acnamesp.h"
#include "acglobal.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmalloc")

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmcopy - Internal to external object translation utilities
* $Revision: 1.68 $
* $Revision: 1.71 $
*
*****************************************************************************/
@ -122,7 +122,7 @@
#include "amlcode.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmcopy")
@ -241,6 +241,10 @@ AcpiCmCopyIsimpleToEsimple (
ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace;
Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) InternalObject->Reference.Node,
&Length, (char *) DataSpace);
/* Converted (external) string length is returned from above */
ExternalObject->String.Length = Length;
break;
default:
@ -321,7 +325,7 @@ AcpiCmCopyIelementToEelement (
switch (ObjectType)
{
case 0:
case ACPI_COPY_TYPE_SIMPLE:
/*
* This is a simple or null object -- get the size
@ -336,7 +340,7 @@ AcpiCmCopyIelementToEelement (
break;
case 1:
case ACPI_COPY_TYPE_PACKAGE:
/*
* Build the package object

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmdebug - Debug print routines
* $Revision: 1.64 $
* $Revision: 1.65 $
*
*****************************************************************************/
@ -118,7 +118,7 @@
#include "acpi.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmdebug")

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: cmdelete - object deletion and reference count utilities
* $Revision: 1.62 $
* $Revision: 1.64 $
*
******************************************************************************/
@ -122,7 +122,7 @@
#include "actables.h"
#include "acparser.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmdelete")
@ -210,6 +210,7 @@ AcpiCmDeleteInternalObj (
("CmDeleteInternalObj: ***** Mutex %p, Semaphore %p\n",
Object, Object->Mutex.Semaphore));
AcpiAmlUnlinkMutex (Object);
AcpiOsDeleteSemaphore (Object->Mutex.Semaphore);
break;

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmeval - Object evaluation
* $Revision: 1.21 $
* $Revision: 1.22 $
*
*****************************************************************************/
@ -121,7 +121,7 @@
#include "acinterp.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmeval")

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmglobal - Global variables for the ACPI subsystem
* $Revision: 1.116 $
* $Revision: 1.117 $
*
*****************************************************************************/
@ -124,7 +124,7 @@
#include "amlcode.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmglobal")
@ -149,7 +149,7 @@ UINT32 AcpiDbgLevel = NORMAL_DEFAULT;
/* Debug switch - layer (component) mask */
UINT32 AcpiDbgLayer = COMPONENT_DEFAULT;
UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
UINT32 AcpiGbl_NestingLevel = 0;

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cminit - Common ACPI subsystem initialization
* $Revision: 1.93 $
* $Revision: 1.94 $
*
*****************************************************************************/
@ -124,7 +124,7 @@
#include "acparser.h"
#include "acdispat.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cminit")

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: cmutils - common utility procedures
* $Revision: 1.23 $
* $Revision: 1.33 $
*
******************************************************************************/
@ -126,7 +126,7 @@
#include "acdebug.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmutils")
@ -358,27 +358,63 @@ AcpiCmAcquireMutex (
ACPI_MUTEX_HANDLE MutexId)
{
ACPI_STATUS Status;
UINT32 i;
UINT32 ThisThreadId;
DEBUG_PRINT (TRACE_MUTEX,
("Acquiring Mutex [%s]\n", AcpiCmGetMutexName (MutexId)));
if (MutexId > MAX_MTX)
{
return (AE_BAD_PARAMETER);
}
ThisThreadId = AcpiOsGetThreadId ();
/*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than or equal to this one. If so, the thread has violated
* the mutex ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
for (i = MutexId; i < MAX_MTX; i++)
{
if (AcpiGbl_AcpiMutexInfo[i].OwnerId == ThisThreadId)
{
if (i == MutexId)
{
DEBUG_PRINT (ACPI_ERROR,
("Mutex [%s] already acquired by this thread [%X]\n",
AcpiCmGetMutexName (MutexId), ThisThreadId));
return (AE_ALREADY_ACQUIRED);
}
DEBUG_PRINT (ACPI_ERROR,
("Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
ThisThreadId, AcpiCmGetMutexName (i),
AcpiCmGetMutexName (MutexId)));
return (AE_ACQUIRE_DEADLOCK);
}
}
DEBUG_PRINT (TRACE_MUTEX,
("Thread %X acquiring Mutex [%s]\n",
ThisThreadId, AcpiCmGetMutexName (MutexId)));
Status = AcpiOsWaitSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex,
1, WAIT_FOREVER);
DEBUG_PRINT (TRACE_MUTEX, ("Acquired Mutex [%s] Status %s\n",
AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status)));
DEBUG_PRINT (TRACE_MUTEX, ("Thread %X acquired Mutex [%s] Status %s\n",
ThisThreadId, AcpiCmGetMutexName (MutexId),
AcpiCmFormatException (Status)));
if (ACPI_SUCCESS (Status))
{
AcpiGbl_AcpiMutexInfo[MutexId].Locked = TRUE;
AcpiGbl_AcpiMutexInfo[MutexId].UseCount++;
AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ThisThreadId;
}
return (Status);
@ -402,6 +438,8 @@ AcpiCmReleaseMutex (
ACPI_MUTEX_HANDLE MutexId)
{
ACPI_STATUS Status;
UINT32 i;
UINT32 ThisThreadId;
DEBUG_PRINT (TRACE_MUTEX,
@ -413,7 +451,45 @@ AcpiCmReleaseMutex (
}
/*
* Mutex must be acquired in order to release it!
*/
if (!AcpiGbl_AcpiMutexInfo[MutexId].Locked)
{
DEBUG_PRINT (ACPI_ERROR,
("Mutex [%s] is not acquired, cannot release\n",
AcpiCmGetMutexName (MutexId)));
return (AE_NOT_ACQUIRED);
}
/*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than this one. If so, the thread has violated
* the mutex ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
ThisThreadId = AcpiOsGetThreadId ();
for (i = MutexId; i < MAX_MTX; i++)
{
if (AcpiGbl_AcpiMutexInfo[i].OwnerId == ThisThreadId)
{
if (i == MutexId)
{
continue;
}
DEBUG_PRINT (ACPI_ERROR,
("Invalid release order: owns [%s], releasing [%s]\n",
AcpiCmGetMutexName (i), AcpiCmGetMutexName (MutexId)));
return (AE_RELEASE_DEADLOCK);
}
}
AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; /* Mark before unlocking */
AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = 0;
Status = AcpiOsSignalSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, 1);
@ -474,6 +550,42 @@ 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
@ -648,6 +760,53 @@ 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
@ -793,36 +952,43 @@ 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];
if (SubObject->Common.Type == INTERNAL_TYPE_REFERENCE)
{
if (SubObject->Reference.OpCode == AML_ZERO_OP)
if (SubObject->Reference.Opcode == AML_ZERO_OP)
{
SubObject->Common.Type = ACPI_TYPE_INTEGER;
SubObject->Integer.Value = 0;
}
else if (SubObject->Reference.OpCode == AML_ONE_OP)
else if (SubObject->Reference.Opcode == AML_ONE_OP)
{
SubObject->Common.Type = ACPI_TYPE_INTEGER;
SubObject->Integer.Value = 1;
}
else if (SubObject->Reference.OpCode == AML_ONES_OP)
else if (SubObject->Reference.Opcode == AML_ONES_OP)
{
SubObject->Common.Type = ACPI_TYPE_INTEGER;
SubObject->Integer.Value = ACPI_INTEGER_MAX;
@ -833,6 +999,184 @@ 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 (ACPI_COPY_TYPE_SIMPLE, 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 (ACPI_COPY_TYPE_PACKAGE, 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 +1189,7 @@ AcpiCmResolvePackageReferences (
*
* RETURN: None
*
* DESCRIPTION: Print error message from KD table
* DESCRIPTION: Print error message
*
******************************************************************************/
@ -872,7 +1216,7 @@ _ReportError (
*
* RETURN: None
*
* DESCRIPTION: Print warning message from KD table
* DESCRIPTION: Print warning message
*
******************************************************************************/
@ -898,7 +1242,7 @@ _ReportWarning (
*
* RETURN: None
*
* DESCRIPTION: Print information message from KD table
* DESCRIPTION: Print information message
*
******************************************************************************/

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmobject - ACPI object create/delete/size/cache routines
* $Revision: 1.35 $
* $Revision: 1.40 $
*
*****************************************************************************/
@ -123,11 +123,11 @@
#include "amlcode.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
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 */
@ -566,23 +566,22 @@ AcpiCmGetSimpleObjectSize (
/*
* The final length depends on the object type
* Strings and Buffers are packed right up against the parent object and
* must be accessed bytewise or there may be alignment problems.
*
* TBD:[Investigate] do strings and buffers require alignment also?
* must be accessed bytewise or there may be alignment problems on
* certain processors
*/
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,13 +601,22 @@ 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;
}
else
{
/*
* Get the actual length of the full pathname to this object.
* The reference will be converted to the pathname to the object
*/
Length += ROUND_UP_TO_NATIVE_WORD (AcpiNsGetPathnameLength (InternalObject->Reference.Node));
}
break;
@ -616,7 +624,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 +642,123 @@ AcpiCmGetSimpleObjectSize (
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: AcpiCmGetPackageObjectSize
* FUNCTION: AcpiCmGetElementLength
*
* 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.
* DESCRIPTION: Get the length of one package element.
*
* This is moderately complex since a package contains other objects
* including packages.
******************************************************************************/
ACPI_STATUS
AcpiCmGetElementLength (
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;
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);
}
Info->Length += ObjectSpace;
break;
case 1:
/* Package - nothing much to do here, let the walk handle it */
Info->NumPackages++;
State->Pkg.ThisTargetObj = NULL;
break;
default:
return (AE_BAD_PARAMETER);
}
return (Status);
}
/*******************************************************************************
*
* 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 *InternalObj,
ACPI_OPERAND_OBJECT *InternalObject,
UINT32 *ObjLength)
{
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;
UINT32 ObjectSpace;
UINT32 CurrentDepth = 0;
UINT32 PackageCount = 1;
ACPI_STATUS Status;
ACPI_PKG_INFO Info;
FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj);
FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObject);
/* Init the package stack TBD: replace with linked list */
Info.Length = 0;
Info.ObjectSpace = 0;
Info.NumPackages = 1;
MEMSET(ParentObj, 0, MAX_PACKAGE_DEPTH);
MEMSET(Index, 0, MAX_PACKAGE_DEPTH);
Status = AcpiCmWalkPackageTree (InternalObject, NULL,
AcpiCmGetElementLength, &Info);
ParentObj[0] = InternalObj;
/*
* 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;
while (1)
{
ThisParent = ParentObj[CurrentDepth];
ThisIndex = Index[CurrentDepth];
ThisInternalObj = ThisParent->Package.Elements[ThisIndex];
/* Return the total package length */
/*
* 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]++;
}
}
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);
}
}
}
*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 +767,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);

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmxface - External interfaces for "global" ACPI functions
* $Revision: 1.58 $
* $Revision: 1.68 $
*
*****************************************************************************/
@ -126,7 +126,7 @@
#include "acdebug.h"
#define _COMPONENT MISCELLANEOUS
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("cmxface")
@ -149,13 +149,8 @@ AcpiInitializeSubsystem (
{
ACPI_STATUS Status;
FUNCTION_TRACE ("AcpiInitializeSubsystem");
DEBUG_PRINT_RAW (ACPI_OK,
("ACPI: Core Subsystem version [%s]\n", ACPI_CA_VERSION));
DEBUG_PRINT (ACPI_INFO, ("Initializing ACPI Subsystem...\n"));
/* Initialize all globals used by the subsystem */
@ -277,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);
}
}
@ -304,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);
@ -321,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.
*/
@ -442,16 +435,25 @@ AcpiGetSystemInfo (
OutBuffer->Length = sizeof (ACPI_SYSTEM_INFO);
InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
/* TBD [Future]: need a version number, or use the version string */
InfoPtr->AcpiCaVersion = 0x1234;
InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
/* System flags (ACPI capabilities) */
InfoPtr->Flags = AcpiGbl_SystemFlags;
/* Timer resolution - 24 or 32 bits */
InfoPtr->TimerResolution = AcpiHwPmtResolution ();
if (!AcpiGbl_FADT)
{
InfoPtr->TimerResolution = 0;
}
else if (AcpiGbl_FADT->TmrValExt == 0)
{
InfoPtr->TimerResolution = 24;
}
else
{
InfoPtr->TimerResolution = 32;
}
/* Clear the reserved fields */
@ -493,7 +495,7 @@ AcpiFormatException (
ACPI_STATUS Exception,
ACPI_BUFFER *OutBuffer)
{
UINT32 Length;
NATIVE_UINT Length;
NATIVE_CHAR *FormattedException;
@ -533,3 +535,68 @@ AcpiFormatException (
return_ACPI_STATUS (AE_OK);
}
/*****************************************************************************
*
* FUNCTION: AcpiAllocate
*
* PARAMETERS: Size - Size of the allocation
*
* RETURN: Address of the allocated memory on success, NULL on failure.
*
* DESCRIPTION: The subsystem's equivalent of malloc.
* External front-end to the Cm* memory manager
*
****************************************************************************/
void *
AcpiAllocate (
UINT32 Size)
{
return (AcpiCmAllocate (Size));
}
/*****************************************************************************
*
* FUNCTION: AcpiCallocate
*
* PARAMETERS: Size - Size of the allocation
*
* RETURN: Address of the allocated memory on success, NULL on failure.
*
* DESCRIPTION: The subsystem's equivalent of calloc.
* External front-end to the Cm* memory manager
*
****************************************************************************/
void *
AcpiCallocate (
UINT32 Size)
{
return (AcpiCmCallocate (Size));
}
/*****************************************************************************
*
* FUNCTION: AcpiFree
*
* PARAMETERS: Address - Address of the memory to deallocate
*
* RETURN: None
*
* DESCRIPTION: Frees the memory at Address
* External front-end to the Cm* memory manager
*
****************************************************************************/
void
AcpiFree (
void *Address)
{
AcpiCmFree (Address);
}