major overhaul of ACPI_TYPE and the use of internal types. Most were

no longer necessary.  Improved handling of the Scope operator for both the
compiler and the interpreter.


date	2002.10.10.22.48.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 18:18:10 +00:00
parent efd0a85211
commit 1e17431e98
3 changed files with 184 additions and 233 deletions

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: nsaccess - Top-level functions for accessing ACPI namespace
* $Revision: 1.161 $
* $Revision: 1.162 $
*
******************************************************************************/
@ -408,29 +408,9 @@ AcpiNsLookup (
}
}
/*
* This check is explicitly split to relax the TypeToCheckFor
* conditions for BankFieldDefn. Originally, both BankFieldDefn and
* DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION,
* but the BankFieldDefn may also check for a Field definition as well
* as an OperationRegion.
*/
if (INTERNAL_TYPE_FIELD_DEFN == Type)
{
/* DefFieldDefn defines fields in a Region */
/* Save type TBD: may be no longer necessary */
TypeToCheckFor = ACPI_TYPE_REGION;
}
else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)
{
/* BankFieldDefn defines data fields in a Field Object */
TypeToCheckFor = ACPI_TYPE_ANY;
}
else
{
TypeToCheckFor = Type;
}
TypeToCheckFor = Type;
/*
* Begin examination of the actual pathname
@ -651,6 +631,7 @@ AcpiNsLookup (
CurrentNode));
}
*ReturnNode = ThisNode;
return_ACPI_STATUS (Status);
}
@ -661,28 +642,25 @@ AcpiNsLookup (
* 2) And we are looking for a specific type
* (Not checking for TYPE_ANY)
* 3) Which is not an alias
* 4) Which is not a local type (TYPE_DEF_ANY)
* 5) Which is not a local type (TYPE_SCOPE)
* 6) Which is not a local type (TYPE_INDEX_FIELD_DEFN)
* 7) And the type of target object is known (not TYPE_ANY)
* 8) And target object does not match what we are looking for
* 4) Which is not a local type (TYPE_SCOPE)
* 5) And the type of target object is known (not TYPE_ANY)
* 6) And target object does not match what we are looking for
*
* Then we have a type mismatch. Just warn and ignore it.
*/
if ((NumSegments == 0) &&
(TypeToCheckFor != ACPI_TYPE_ANY) &&
(TypeToCheckFor != INTERNAL_TYPE_ALIAS) &&
(TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) &&
(TypeToCheckFor != INTERNAL_TYPE_SCOPE) &&
(TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) &&
(TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
(TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
(ThisNode->Type != ACPI_TYPE_ANY) &&
(ThisNode->Type != TypeToCheckFor))
{
/* Complain about a type mismatch */
ACPI_REPORT_WARNING (
("NsLookup: %4.4s, type %X, checking for type %X\n",
(char *) &SimpleName, ThisNode->Type, TypeToCheckFor));
("NsLookup: Type mismatch on %4.4s (%s), searching for (%s)\n",
(char *) &SimpleName, AcpiUtGetTypeName (ThisNode->Type),
AcpiUtGetTypeName (TypeToCheckFor)));
}
/*

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: nsalloc - Namespace allocation and deletion utilities
* $Revision: 1.73 $
* $Revision: 1.75 $
*
******************************************************************************/
@ -223,6 +223,58 @@ AcpiNsDeleteNode (
}
/*******************************************************************************
*
* FUNCTION: AcpiNsCompareNames
*
* PARAMETERS: Name1 - First name to compare
* Name2 - Second name to compare
*
* RETURN: value from strncmp
*
* DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
* underscore are forced to be alphabetically first.
*
******************************************************************************/
int
AcpiNsCompareNames (
char *Name1,
char *Name2)
{
char ReversedName1[ACPI_NAME_SIZE];
char ReversedName2[ACPI_NAME_SIZE];
UINT32 i;
UINT32 j;
/*
* Replace all instances of "underscore" with a value that is smaller so
* that all names that are prefixed with underscore(s) are alphabetically
* first.
*
* Reverse the name bytewise so we can just do a 32-bit compare instead
* of a strncmp.
*/
for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--)
{
ReversedName1[j] = Name1[i];
if (Name1[i] == '_')
{
ReversedName1[j] = '*';
}
ReversedName2[j] = Name2[i];
if (Name2[i] == '_')
{
ReversedName2[j] = '*';
}
}
return (*(INT32 *) ReversedName1 - *(INT32 *) ReversedName2);
}
/*******************************************************************************
*
* FUNCTION: AcpiNsInstallNode
@ -237,8 +289,10 @@ AcpiNsDeleteNode (
* DESCRIPTION: Initialize a new namespace node and install it amongst
* its peers.
*
* Note: Current namespace lookup is linear search, so the nodes
* are not linked in any particular order.
* Note: Current namespace lookup is linear search. However, the
* nodes are linked in alphabetical order to 1) put all reserved
* names (start with underscore) first, and to 2) make a readable
* namespace dump.
*
******************************************************************************/
@ -251,6 +305,7 @@ AcpiNsInstallNode (
{
UINT16 OwnerId = TABLE_ID_DSDT;
ACPI_NAMESPACE_NODE *ChildNode;
ACPI_NAMESPACE_NODE *PreviousChildNode;
ACPI_FUNCTION_TRACE ("NsInstallNode");
@ -272,71 +327,74 @@ AcpiNsInstallNode (
if (!ChildNode)
{
ParentNode->Child = Node;
Node->Flags |= ANOBJ_END_OF_PEER_LIST;
Node->Peer = ParentNode;
}
else
{
while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST))
/*
* Walk the list whilst searching for the the correct
* alphabetic placement.
*/
PreviousChildNode = NULL;
while (AcpiNsCompareNames (ChildNode->Name.Ascii, Node->Name.Ascii) < 0)
{
if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)
{
/* Last peer; Clear end-of-list flag */
ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST;
/* This node is the new peer to the child node */
ChildNode->Peer = Node;
/* This node is the new end-of-list */
Node->Flags |= ANOBJ_END_OF_PEER_LIST;
Node->Peer = ParentNode;
break;
}
/* Get next peer */
PreviousChildNode = ChildNode;
ChildNode = ChildNode->Peer;
}
ChildNode->Peer = Node;
/* Did the node get inserted at the end-of-list? */
/* Clear end-of-list flag */
if (!(Node->Flags & ANOBJ_END_OF_PEER_LIST))
{
/*
* Loop above terminated without reaching the end-of-list.
* Insert the new node at the current location
*/
if (PreviousChildNode)
{
/* Insert node alphabetically */
ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST;
Node->Peer = ChildNode;
PreviousChildNode->Peer = Node;
}
else
{
/* Insert node alphabetically at start of list */
Node->Peer = ChildNode;
ParentNode->Child = Node;
}
}
}
/* Init the new entry */
Node->OwnerId = OwnerId;
Node->Flags |= ANOBJ_END_OF_PEER_LIST;
Node->Peer = ParentNode;
Node->OwnerId = OwnerId;
Node->Type = (UINT8) Type;
/*
* If adding a name with unknown type, or having to
* add the region in order to define fields in it, we
* have a forward reference.
*/
if ((ACPI_TYPE_ANY == Type) ||
(INTERNAL_TYPE_FIELD_DEFN == Type) ||
(INTERNAL_TYPE_BANK_FIELD_DEFN == Type))
{
/*
* We don't want to abort here, however!
* We will fill in the actual type when the
* real definition is found later.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] is a forward reference\n",
Node->Name.Ascii));
}
/*
* The DefFieldDefn and BankFieldDefn cases are actually
* looking up the Region in which the field will be defined
*/
if ((INTERNAL_TYPE_FIELD_DEFN == Type) ||
(INTERNAL_TYPE_BANK_FIELD_DEFN == Type))
{
Type = ACPI_TYPE_REGION;
}
/*
* Scope, DefAny, and IndexFieldDefn are bogus "types" which do
* not actually have anything to do with the type of the name
* being looked up. Save any other value of Type as the type of
* the entry.
*/
if ((Type != INTERNAL_TYPE_SCOPE) &&
(Type != INTERNAL_TYPE_DEF_ANY) &&
(Type != INTERNAL_TYPE_INDEX_FIELD_DEFN))
{
Node->Type = (UINT8) Type;
}
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s added to %p at %p\n",
Node->Name.Ascii, ParentNode, Node));
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) added to %4.4s (%s) %p at %p\n",
Node->Name.Ascii, AcpiUtGetTypeName (Node->Type),
ParentNode->Name.Ascii, AcpiUtGetTypeName (ParentNode->Type), ParentNode, Node));
/*
* Increment the reference count(s) of all parents up to
@ -448,7 +506,7 @@ AcpiNsDeleteChildren (
*
******************************************************************************/
ACPI_STATUS
void
AcpiNsDeleteNamespaceSubtree (
ACPI_NAMESPACE_NODE *ParentNode)
{
@ -461,7 +519,7 @@ AcpiNsDeleteNamespaceSubtree (
if (!ParentNode)
{
return_ACPI_STATUS (AE_OK);
return_VOID;
}
/*
@ -517,7 +575,7 @@ AcpiNsDeleteNamespaceSubtree (
}
}
return_ACPI_STATUS (AE_OK);
return_VOID;
}
@ -591,7 +649,7 @@ AcpiNsRemoveReference (
*
******************************************************************************/
ACPI_STATUS
void
AcpiNsDeleteNamespaceByOwner (
UINT16 OwnerId)
{
@ -678,7 +736,7 @@ AcpiNsDeleteNamespaceByOwner (
}
}
return_ACPI_STATUS (AE_OK);
return_VOID;
}

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: nsdump - table dumping routines for debug
* $Revision: 1.130 $
* $Revision: 1.142 $
*
*****************************************************************************/
@ -125,7 +125,7 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsdump")
#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*******************************************************************************
@ -214,7 +214,7 @@ AcpiNsDumpPathname (
Status = AcpiNsHandleToPathname (Handle, &Buffer);
if (ACPI_SUCCESS (Status))
{
AcpiOsPrintf ("%s %s (Node %p)\n", Msg, Buffer.Pointer, Handle);
AcpiOsPrintf ("%s %s (Node %p)\n", Msg, (char *) Buffer.Pointer, Handle);
ACPI_MEM_FREE (Buffer.Pointer);
}
@ -307,12 +307,12 @@ AcpiNsDumpOneObject (
{
if (AcpiNsExistDownstreamSibling (ThisNode + 1))
{
DownstreamSiblingMask |= (1 << (Level - 1));
DownstreamSiblingMask |= ((UINT32) 1 << (Level - 1));
AcpiOsPrintf ("+");
}
else
{
DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1));
DownstreamSiblingMask &= ACPI_UINT32_MAX ^ ((UINT32) 1 << (Level - 1));
AcpiOsPrintf ("+");
}
@ -333,9 +333,9 @@ AcpiNsDumpOneObject (
/* Check the integrity of our data */
if (Type > INTERNAL_TYPE_MAX)
if (Type > ACPI_TYPE_LOCAL_MAX)
{
Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */
ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type));
}
if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
@ -369,31 +369,31 @@ AcpiNsDumpOneObject (
switch (Type)
{
case ACPI_TYPE_PROCESSOR:
AcpiOsPrintf (" ID %d Addr %.4X Len %.4X\n",
AcpiOsPrintf (" ID %X Len %.4X Addr %p\n",
ObjDesc->Processor.ProcId,
ObjDesc->Processor.Address,
ObjDesc->Processor.Length);
ObjDesc->Processor.Length,
(char *) ObjDesc->Processor.Address);
break;
case ACPI_TYPE_DEVICE:
AcpiOsPrintf (" Notification object: %p", ObjDesc);
break;
case ACPI_TYPE_METHOD:
AcpiOsPrintf (" Args %d Len %.4X Aml %p \n",
ObjDesc->Method.ParamCount,
AcpiOsPrintf (" Args %X Len %.4X Aml %p\n",
(UINT32) ObjDesc->Method.ParamCount,
ObjDesc->Method.AmlLength,
ObjDesc->Method.AmlStart);
break;
case ACPI_TYPE_INTEGER:
AcpiOsPrintf (" = %8.8X%8.8X\n",
ACPI_HIDWORD (ObjDesc->Integer.Value),
ACPI_LODWORD (ObjDesc->Integer.Value));
@ -428,7 +428,7 @@ AcpiNsDumpOneObject (
AcpiOsPrintf (" =");
for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
{
AcpiOsPrintf (" %.2X", ObjDesc->Buffer.Pointer[i]);
AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
}
}
AcpiOsPrintf ("\n");
@ -441,7 +441,7 @@ AcpiNsDumpOneObject (
case ACPI_TYPE_STRING:
AcpiOsPrintf (" Len %.2X", ObjDesc->String.Length);
if (ObjDesc->String.Length > 0)
@ -457,7 +457,7 @@ AcpiNsDumpOneObject (
case ACPI_TYPE_REGION:
AcpiOsPrintf (" [%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
{
@ -473,15 +473,15 @@ AcpiNsDumpOneObject (
break;
case INTERNAL_TYPE_REFERENCE:
case ACPI_TYPE_LOCAL_REFERENCE:
AcpiOsPrintf (" [%s]\n",
AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
break;
case ACPI_TYPE_BUFFER_FIELD:
if (ObjDesc->BufferField.BufferObj &&
ObjDesc->BufferField.BufferObj->Buffer.Node)
{
@ -491,31 +491,36 @@ AcpiNsDumpOneObject (
break;
case INTERNAL_TYPE_REGION_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
AcpiOsPrintf (" Rgn [%4.4s]",
ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii);
break;
case INTERNAL_TYPE_BANK_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
AcpiOsPrintf (" Rgn [%4.4s] Bnk [%4.4s]",
ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii,
ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii);
break;
case INTERNAL_TYPE_INDEX_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
AcpiOsPrintf (" Idx [%4.4s] Dat [%4.4s]",
ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii,
ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii);
break;
case ACPI_TYPE_LOCAL_ALIAS:
AcpiOsPrintf (" Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc);
break;
default:
AcpiOsPrintf (" Object %p\n", ObjDesc);
break;
}
@ -525,16 +530,17 @@ AcpiNsDumpOneObject (
switch (Type)
{
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2d\n",
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2hd\n",
(ObjDesc->CommonField.BaseByteOffset * 8)
+ ObjDesc->CommonField.StartFieldBitOffset,
ObjDesc->CommonField.BitLength,
ObjDesc->CommonField.AccessByteWidth);
break;
default:
break;
}
@ -608,16 +614,16 @@ AcpiNsDumpOneObject (
/* If there is an attached object, display it */
DbgLevel = AcpiDbgLevel;
DbgLevel = AcpiDbgLevel;
AcpiDbgLevel = 0;
ObjDesc = AcpiNsGetAttachedObject (ThisNode);
ObjDesc = AcpiNsGetAttachedObject (ThisNode);
AcpiDbgLevel = DbgLevel;
/* Dump attached objects */
while (ObjDesc)
{
ObjType = INTERNAL_TYPE_INVALID;
ObjType = ACPI_TYPE_INVALID;
AcpiOsPrintf (" Attached Object %p: ", ObjDesc);
/* Decode the type of attached object and dump the contents */
@ -631,19 +637,19 @@ AcpiNsDumpOneObject (
break;
case ACPI_DESC_TYPE_INTERNAL:
case ACPI_DESC_TYPE_OPERAND:
ObjType = ObjDesc->Common.Type;
ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
if (ObjType > INTERNAL_TYPE_MAX)
if (ObjType > ACPI_TYPE_LOCAL_MAX)
{
AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
BytesToDump = 32;
}
else
{
AcpiOsPrintf ("(Ptr to ACPI Object type %2.2X [%s])\n",
ObjType, AcpiUtGetTypeName (ObjType));
AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n",
AcpiUtGetTypeName (ObjType), ObjType);
BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
}
break;
@ -660,7 +666,7 @@ AcpiNsDumpOneObject (
/* If value is NOT an internal object, we are done */
if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_INTERNAL)
if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
{
goto Cleanup;
}
@ -690,15 +696,15 @@ AcpiNsDumpOneObject (
ObjDesc = (void *) ObjDesc->Method.AmlStart;
break;
case INTERNAL_TYPE_REGION_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
ObjDesc = (void *) ObjDesc->Field.RegionObj;
break;
case INTERNAL_TYPE_BANK_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
ObjDesc = (void *) ObjDesc->BankField.RegionObj;
break;
case INTERNAL_TYPE_INDEX_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
break;
@ -706,7 +712,7 @@ AcpiNsDumpOneObject (
goto Cleanup;
}
ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */
ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
}
Cleanup:
@ -750,103 +756,12 @@ AcpiNsDumpObjects (
Info.DisplayType = DisplayType;
(void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
(void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
(void *) &Info, NULL);
}
#ifndef _ACPI_ASL_COMPILER
/*******************************************************************************
*
* FUNCTION: AcpiNsDumpOneDevice
*
* PARAMETERS: Handle - Node to be dumped
* Level - Nesting level of the handle
* Context - Passed into WalkNamespace
*
* DESCRIPTION: Dump a single Node that represents a device
* This procedure is a UserFunction called by AcpiNsWalkNamespace.
*
******************************************************************************/
ACPI_STATUS
AcpiNsDumpOneDevice (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_DEVICE_INFO Info;
ACPI_STATUS Status;
UINT32 i;
ACPI_FUNCTION_NAME ("NsDumpOneDevice");
Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
Status = AcpiGetObjectInfo (ObjHandle, &Info);
if (ACPI_SUCCESS (Status))
{
for (i = 0; i < Level; i++)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " HID: %s, ADR: %8.8X%8.8X, Status: %x\n",
Info.HardwareId,
ACPI_HIDWORD (Info.Address), ACPI_LODWORD (Info.Address),
Info.CurrentStatus));
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiNsDumpRootDevices
*
* PARAMETERS: None
*
* DESCRIPTION: Dump all objects of type "device"
*
******************************************************************************/
void
AcpiNsDumpRootDevices (void)
{
ACPI_HANDLE SysBusHandle;
ACPI_STATUS Status;
ACPI_FUNCTION_NAME ("NsDumpRootDevices");
/* Only dump the table if tracing is enabled */
if (!(ACPI_LV_TABLES & AcpiDbgLevel))
{
return;
}
Status = AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
if (ACPI_FAILURE (Status))
{
return;
}
ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle,
ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
AcpiNsDumpOneDevice, NULL, NULL);
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiNsDumpTables
@ -877,7 +792,7 @@ AcpiNsDumpTables (
* If the name space has not been initialized,
* there is nothing to dump.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "name space not initialized!\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
return_VOID;
}