diff options
Diffstat (limited to 'sys/contrib/dev/acpica/nsutils.c')
-rw-r--r-- | sys/contrib/dev/acpica/nsutils.c | 157 |
1 files changed, 75 insertions, 82 deletions
diff --git a/sys/contrib/dev/acpica/nsutils.c b/sys/contrib/dev/acpica/nsutils.c index c3d7cc1..f2966f9 100644 --- a/sys/contrib/dev/acpica/nsutils.c +++ b/sys/contrib/dev/acpica/nsutils.c @@ -2,7 +2,7 @@ * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * $Revision: 93 $ + * $Revision: 104 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -124,7 +124,7 @@ #include "actables.h" #define _COMPONENT ACPI_NAMESPACE - MODULE_NAME ("nsutils") + ACPI_MODULE_NAME ("nsutils") /******************************************************************************* @@ -179,20 +179,20 @@ AcpiNsValidPathSeparator ( * ******************************************************************************/ -ACPI_OBJECT_TYPE8 +ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node) { - FUNCTION_TRACE ("NsGetType"); + ACPI_FUNCTION_TRACE ("NsGetType"); if (!Node) { - REPORT_WARNING (("NsGetType: Null Node ptr")); + ACPI_REPORT_WARNING (("NsGetType: Null Node ptr")); return_VALUE (ACPI_TYPE_ANY); } - return_VALUE (Node->Type); + return_VALUE ((ACPI_OBJECT_TYPE) Node->Type); } @@ -209,20 +209,20 @@ AcpiNsGetType ( UINT32 AcpiNsLocal ( - ACPI_OBJECT_TYPE8 Type) + ACPI_OBJECT_TYPE Type) { - FUNCTION_TRACE ("NsLocal"); + ACPI_FUNCTION_TRACE ("NsLocal"); if (!AcpiUtValidObjectType (Type)) { /* Type code out of range */ - REPORT_WARNING (("NsLocal: Invalid Object Type\n")); - return_VALUE (NSP_NORMAL); + ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n")); + return_VALUE (ACPI_NS_NORMAL); } - return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & NSP_LOCAL); + return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); } @@ -248,7 +248,7 @@ AcpiNsGetInternalNameLength ( UINT32 i; - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); NextExternalChar = Info->ExternalName; @@ -270,7 +270,6 @@ AcpiNsGetInternalNameLength ( Info->FullyQualified = TRUE; NextExternalChar++; } - else { /* @@ -334,7 +333,7 @@ AcpiNsBuildInternalName ( UINT32 i; - FUNCTION_TRACE ("NsBuildInternalName"); + ACPI_FUNCTION_TRACE ("NsBuildInternalName"); /* Setup the correct prefixes, counts, and pointers */ @@ -375,17 +374,15 @@ AcpiNsBuildInternalName ( } } - if (NumSegments == 1) + if (NumSegments <= 1) { Result = &InternalName[i]; } - else if (NumSegments == 2) { InternalName[i] = AML_DUAL_NAME_PREFIX; Result = &InternalName[i+1]; } - else { InternalName[i] = AML_MULTI_NAME_PREFIX_OP; @@ -408,12 +405,11 @@ AcpiNsBuildInternalName ( Result[i] = '_'; } - else { /* Convert the character to uppercase and save it */ - Result[i] = (char) TOUPPER (*ExternalName); + Result[i] = (char) ACPI_TOUPPER (*ExternalName); ExternalName++; } } @@ -432,7 +428,6 @@ AcpiNsBuildInternalName ( Result += ACPI_NAME_SIZE; } - /* Terminate the string */ *Result = 0; @@ -477,7 +472,7 @@ AcpiNsInternalizeName ( ACPI_STATUS Status; - FUNCTION_TRACE ("NsInternalizeName"); + ACPI_FUNCTION_TRACE ("NsInternalizeName"); if ((!ExternalName) || @@ -487,7 +482,6 @@ AcpiNsInternalizeName ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the length of the new internal name */ Info.ExternalName = ExternalName; @@ -540,23 +534,22 @@ AcpiNsExternalizeName ( { UINT32 PrefixLength = 0; UINT32 NamesIndex = 0; - UINT32 NamesCount = 0; + UINT32 NumSegments = 0; UINT32 i = 0; UINT32 j = 0; + UINT32 RequiredLength; - FUNCTION_TRACE ("NsExternalizeName"); + ACPI_FUNCTION_TRACE ("NsExternalizeName"); if (!InternalNameLength || !InternalName || - !ConvertedNameLength || !ConvertedName) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* * Check for a prefix (one '\' | one or more '^'). */ @@ -591,36 +584,36 @@ AcpiNsExternalizeName ( { switch (InternalName[PrefixLength]) { + case AML_MULTI_NAME_PREFIX_OP: - /* <count> 4-byte names */ + /* <count> 4-byte names */ - case AML_MULTI_NAME_PREFIX_OP: NamesIndex = PrefixLength + 2; - NamesCount = (UINT32) InternalName[PrefixLength + 1]; + NumSegments = (UINT32) (UINT8) InternalName[PrefixLength + 1]; break; + case AML_DUAL_NAME_PREFIX: - /* two 4-byte names */ + /* Two 4-byte names */ - case AML_DUAL_NAME_PREFIX: NamesIndex = PrefixLength + 1; - NamesCount = 2; + NumSegments = 2; break; + case 0: - /* NullName */ + /* NullName */ - case 0: NamesIndex = 0; - NamesCount = 0; + NumSegments = 0; break; + default: - /* one 4-byte name */ + /* one 4-byte name */ - default: NamesIndex = PrefixLength; - NamesCount = 1; + NumSegments = 1; break; } } @@ -630,24 +623,23 @@ AcpiNsExternalizeName ( * of the prefix, length of all object names, length of any required * punctuation ('.') between object names, plus the NULL terminator. */ - *ConvertedNameLength = PrefixLength + (4 * NamesCount) + - ((NamesCount > 0) ? (NamesCount - 1) : 0) + 1; + RequiredLength = PrefixLength + (4 * NumSegments) + + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem * with InternalName (invalid format). */ - if (*ConvertedNameLength > InternalNameLength) + if (RequiredLength > InternalNameLength) { - REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); + ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); return_ACPI_STATUS (AE_BAD_PATHNAME); } /* * Build ConvertedName... */ - - (*ConvertedName) = ACPI_MEM_CALLOCATE (*ConvertedNameLength); + *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength); if (!(*ConvertedName)) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -660,9 +652,9 @@ AcpiNsExternalizeName ( (*ConvertedName)[j++] = InternalName[i]; } - if (NamesCount > 0) + if (NumSegments > 0) { - for (i = 0; i < NamesCount; i++) + for (i = 0; i < NumSegments; i++) { if (i > 0) { @@ -676,6 +668,11 @@ AcpiNsExternalizeName ( } } + if (ConvertedNameLength) + { + *ConvertedNameLength = RequiredLength; + } + return_ACPI_STATUS (AE_OK); } @@ -700,7 +697,7 @@ AcpiNsMapHandleToNode ( ACPI_HANDLE Handle) { - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); /* @@ -718,7 +715,7 @@ AcpiNsMapHandleToNode ( /* We can at least attempt to verify the handle */ - if (!VALID_DESCRIPTOR_TYPE (Handle, ACPI_DESC_TYPE_NAMED)) + if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) { return (NULL); } @@ -788,7 +785,7 @@ AcpiNsTerminate (void) ACPI_NAMESPACE_NODE *ThisNode; - FUNCTION_TRACE ("NsTerminate"); + ACPI_FUNCTION_TRACE ("NsTerminate"); ThisNode = AcpiGbl_RootNode; @@ -837,26 +834,26 @@ AcpiNsTerminate (void) UINT32 AcpiNsOpensScope ( - ACPI_OBJECT_TYPE8 Type) + ACPI_OBJECT_TYPE Type) { - FUNCTION_TRACE_U32 ("NsOpensScope", Type); + ACPI_FUNCTION_TRACE_U32 ("NsOpensScope", Type); if (!AcpiUtValidObjectType (Type)) { /* type code out of range */ - REPORT_WARNING (("NsOpensScope: Invalid Object Type\n")); - return_VALUE (NSP_NORMAL); + ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type)); + return_VALUE (ACPI_NS_NORMAL); } - return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & NSP_NEWSCOPE); + return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); } /******************************************************************************* * - * FUNCTION: AcpiNsGetNode + * FUNCTION: AcpiNsGetNodeByPath * * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The * \ (backslash) and ^ (carat) prefixes, and the @@ -865,6 +862,8 @@ AcpiNsOpensScope ( * root of the name space. If Name is fully * qualified (first INT8 is '\'), the passed value * of Scope will not be accessed. + * Flags - Used to indicate whether to perform upsearch or + * not. * ReturnNode - Where the Node is returned * * DESCRIPTION: Look up a name relative to a given scope and return the @@ -875,9 +874,10 @@ AcpiNsOpensScope ( ******************************************************************************/ ACPI_STATUS -AcpiNsGetNode ( +AcpiNsGetNodeByPath ( NATIVE_CHAR *Pathname, ACPI_NAMESPACE_NODE *StartNode, + UINT32 Flags, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_GENERIC_STATE ScopeInfo; @@ -885,22 +885,14 @@ AcpiNsGetNode ( NATIVE_CHAR *InternalPath = NULL; - FUNCTION_TRACE_PTR ("NsGetNode", Pathname); + ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname); - /* Ensure that the namespace has been initialized */ - - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - if (!Pathname) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Convert path to internal representation */ Status = AcpiNsInternalizeName (Pathname, &InternalPath); @@ -909,8 +901,13 @@ AcpiNsGetNode ( return_ACPI_STATUS (Status); } + /* Must lock namespace during lookup */ - AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Setup lookup scope (search starting point) */ @@ -919,21 +916,18 @@ AcpiNsGetNode ( /* Lookup the name in the namespace */ Status = AcpiNsLookup (&ScopeInfo, InternalPath, - ACPI_TYPE_ANY, IMODE_EXECUTE, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + (Flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, ReturnNode); - if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", InternalPath, AcpiFormatException (Status))); } - - AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - /* Cleanup */ + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); ACPI_MEM_FREE (InternalPath); return_ACPI_STATUS (Status); } @@ -960,18 +954,19 @@ AcpiNsFindParentName ( ACPI_NAMESPACE_NODE *ParentNode; - FUNCTION_TRACE ("NsFindParentName"); + ACPI_FUNCTION_TRACE ("NsFindParentName"); if (ChildNode) { /* Valid entry. Get the parent Node */ - ParentNode = AcpiNsGetParentObject (ChildNode); + ParentNode = AcpiNsGetParentNode (ChildNode); if (ParentNode) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n", - ChildNode, (char*)&ChildNode->Name, ParentNode, (char*)&ParentNode->Name)); + ChildNode, (char *) &ChildNode->Name, + ParentNode, (char *) &ParentNode->Name)); if (ParentNode->Name) { @@ -980,7 +975,7 @@ AcpiNsFindParentName ( } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n", - ChildNode, (char*)&ChildNode->Name)); + ChildNode, (char *) &ChildNode->Name)); } return_VALUE (ACPI_UNKNOWN_NAME); @@ -1028,7 +1023,7 @@ AcpiNsExistDownstreamSibling ( /******************************************************************************* * - * FUNCTION: AcpiNsGetParentObject + * FUNCTION: AcpiNsGetParentNode * * PARAMETERS: Node - Current table entry * @@ -1040,12 +1035,10 @@ AcpiNsExistDownstreamSibling ( ACPI_NAMESPACE_NODE * -AcpiNsGetParentObject ( +AcpiNsGetParentNode ( ACPI_NAMESPACE_NODE *Node) { - - - FUNCTION_ENTRY (); + ACPI_FUNCTION_ENTRY (); if (!Node) |