diff options
author | Mike Gerdts <mike.gerdts@joyent.com> | 2018-01-18 15:37:09 +0000 |
---|---|---|
committer | Mike Gerdts <mike.gerdts@joyent.com> | 2018-02-13 16:56:03 +0000 |
commit | ed0e03ac24c4a80fc1dca6c059801da8356cd81a (patch) | |
tree | 9b520f8bd6948b706dd7363726f44942659fa74c /usr/src/uts/intel/io/acpica/namespace | |
parent | 59e5084aaf2a76c156e349393b383154de8f2e16 (diff) | |
download | illumos-joyent-ed0e03ac24c4a80fc1dca6c059801da8356cd81a.tar.gz |
OS-6465 add iasl
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approvced by: Jerry Jelinek <jerry.jelinek@joyent.com>
Diffstat (limited to 'usr/src/uts/intel/io/acpica/namespace')
22 files changed, 0 insertions, 12733 deletions
diff --git a/usr/src/uts/intel/io/acpica/namespace/nsaccess.c b/usr/src/uts/intel/io/acpica/namespace/nsaccess.c deleted file mode 100644 index eb6fed6230..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsaccess.c +++ /dev/null @@ -1,704 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdispat.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsaccess") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsRootInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Allocate and initialize the default root named objects - * - * MUTEX: Locks namespace for entire execution - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsRootInitialize ( - void) -{ - ACPI_STATUS Status; - const ACPI_PREDEFINED_NAMES *InitVal = NULL; - ACPI_NAMESPACE_NODE *NewNode; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STRING Val = NULL; - - - ACPI_FUNCTION_TRACE (NsRootInitialize); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * The global root ptr is initially NULL, so a non-NULL value indicates - * that AcpiNsRootInitialize() has already been called; just return. - */ - if (AcpiGbl_RootNode) - { - Status = AE_OK; - goto UnlockAndExit; - } - - /* - * Tell the rest of the subsystem that the root is initialized - * (This is OK because the namespace is locked) - */ - AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; - - /* Enter the pre-defined names in the name table */ - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Entering predefined entries into namespace\n")); - - for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) - { - /* _OSI is optional for now, will be permanent later */ - - if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) - { - continue; - } - - Status = AcpiNsLookup (NULL, ACPI_CAST_PTR (char, InitVal->Name), - InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - NULL, &NewNode); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not create predefined name %s", - InitVal->Name)); - continue; - } - - /* - * Name entered successfully. If entry in PreDefinedNames[] specifies - * an initial value, create the initial value. - */ - if (InitVal->Val) - { - Status = AcpiOsPredefinedOverride (InitVal, &Val); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not override predefined %s", - InitVal->Name)); - } - - if (!Val) - { - Val = InitVal->Val; - } - - /* - * Entry requests an initial value, allocate a - * descriptor for it. - */ - ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* - * Convert value string from table entry to - * internal representation. Only types actually - * used for initial values are implemented here. - */ - switch (InitVal->Type) - { - case ACPI_TYPE_METHOD: - - ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); - ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; - -#if defined (ACPI_ASL_COMPILER) - - /* Save the parameter count for the iASL compiler */ - - NewNode->Value = ObjDesc->Method.ParamCount; -#else - /* Mark this as a very SPECIAL method */ - - ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY; - ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation; -#endif - break; - - case ACPI_TYPE_INTEGER: - - ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); - break; - - case ACPI_TYPE_STRING: - - /* Build an object around the static string */ - - ObjDesc->String.Length = (UINT32) strlen (Val); - ObjDesc->String.Pointer = Val; - ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; - break; - - case ACPI_TYPE_MUTEX: - - ObjDesc->Mutex.Node = NewNode; - ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); - - /* Create a mutex */ - - Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ObjDesc); - goto UnlockAndExit; - } - - /* Special case for ACPI Global Lock */ - - if (strcmp (InitVal->Name, "_GL_") == 0) - { - AcpiGbl_GlobalLockMutex = ObjDesc; - - /* Create additional counting semaphore for global lock */ - - Status = AcpiOsCreateSemaphore ( - 1, 0, &AcpiGbl_GlobalLockSemaphore); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ObjDesc); - goto UnlockAndExit; - } - } - break; - - default: - - ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X", - InitVal->Type)); - AcpiUtRemoveReference (ObjDesc); - ObjDesc = NULL; - continue; - } - - /* Store pointer to value descriptor in the Node */ - - Status = AcpiNsAttachObject (NewNode, ObjDesc, - ObjDesc->Common.Type); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - } - } - - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - /* Save a handle to "_GPE", it is always present */ - - if (ACPI_SUCCESS (Status)) - { - Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, - &AcpiGbl_FadtGpeDevice); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsLookup - * - * PARAMETERS: ScopeInfo - Current scope info block - * Pathname - Search pathname, in internal format - * (as represented in the AML stream) - * Type - Type associated with name - * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found - * Flags - Flags describing the search restrictions - * WalkState - Current state of the walk - * ReturnNode - Where the Node is placed (if found - * or created successfully) - * - * RETURN: Status - * - * DESCRIPTION: Find or enter the passed name in the name space. - * Log an error if name not found in Exec mode. - * - * MUTEX: Assumes namespace is locked. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsLookup ( - ACPI_GENERIC_STATE *ScopeInfo, - char *Pathname, - ACPI_OBJECT_TYPE Type, - ACPI_INTERPRETER_MODE InterpreterMode, - UINT32 Flags, - ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - char *Path = Pathname; - ACPI_NAMESPACE_NODE *PrefixNode; - ACPI_NAMESPACE_NODE *CurrentNode = NULL; - ACPI_NAMESPACE_NODE *ThisNode = NULL; - UINT32 NumSegments; - UINT32 NumCarats; - ACPI_NAME SimpleName; - ACPI_OBJECT_TYPE TypeToCheckFor; - ACPI_OBJECT_TYPE ThisSearchType; - UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; - UINT32 LocalFlags; - - - ACPI_FUNCTION_TRACE (NsLookup); - - - if (!ReturnNode) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - LocalFlags = Flags & - ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND | - ACPI_NS_SEARCH_PARENT); - *ReturnNode = ACPI_ENTRY_NOT_FOUND; - AcpiGbl_NsLookupCount++; - - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - /* Get the prefix scope. A null scope means use the root scope */ - - if ((!ScopeInfo) || - (!ScopeInfo->Scope.Node)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Null scope prefix, using root node (%p)\n", - AcpiGbl_RootNode)); - - PrefixNode = AcpiGbl_RootNode; - } - else - { - PrefixNode = ScopeInfo->Scope.Node; - if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) - { - ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", - PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) - { - /* - * This node might not be a actual "scope" node (such as a - * Device/Method, etc.) It could be a Package or other object - * node. Backup up the tree to find the containing scope node. - */ - while (!AcpiNsOpensScope (PrefixNode->Type) && - PrefixNode->Type != ACPI_TYPE_ANY) - { - PrefixNode = PrefixNode->Parent; - } - } - } - - /* Save type. TBD: may be no longer necessary */ - - TypeToCheckFor = Type; - - /* - * Begin examination of the actual pathname - */ - if (!Pathname) - { - /* A Null NamePath is allowed and refers to the root */ - - NumSegments = 0; - ThisNode = AcpiGbl_RootNode; - Path = ""; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Null Pathname (Zero segments), Flags=%X\n", Flags)); - } - else - { - /* - * Name pointer is valid (and must be in internal name format) - * - * Check for scope prefixes: - * - * As represented in the AML stream, a namepath consists of an - * optional scope prefix followed by a name segment part. - * - * If present, the scope prefix is either a Root Prefix (in - * which case the name is fully qualified), or one or more - * Parent Prefixes (in which case the name's scope is relative - * to the current scope). - */ - if (*Path == (UINT8) AML_ROOT_PREFIX) - { - /* Pathname is fully qualified, start from the root */ - - ThisNode = AcpiGbl_RootNode; - SearchParentFlag = ACPI_NS_NO_UPSEARCH; - - /* Point to name segment part */ - - Path++; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Path is absolute from root [%p]\n", ThisNode)); - } - else - { - /* Pathname is relative to current scope, start there */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching relative to prefix scope [%4.4s] (%p)\n", - AcpiUtGetNodeName (PrefixNode), PrefixNode)); - - /* - * Handle multiple Parent Prefixes (carat) by just getting - * the parent node for each prefix instance. - */ - ThisNode = PrefixNode; - NumCarats = 0; - while (*Path == (UINT8) AML_PARENT_PREFIX) - { - /* Name is fully qualified, no search rules apply */ - - SearchParentFlag = ACPI_NS_NO_UPSEARCH; - - /* - * Point past this prefix to the name segment - * part or the next Parent Prefix - */ - Path++; - - /* Backup to the parent node */ - - NumCarats++; - ThisNode = ThisNode->Parent; - if (!ThisNode) - { - /* Current scope has no parent scope */ - - ACPI_ERROR ((AE_INFO, - "%s: Path has too many parent prefixes (^) " - "- reached beyond root node", Pathname)); - return_ACPI_STATUS (AE_NOT_FOUND); - } - } - - if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Search scope is [%4.4s], path has %u carat(s)\n", - AcpiUtGetNodeName (ThisNode), NumCarats)); - } - } - - /* - * Determine the number of ACPI name segments in this pathname. - * - * The segment part consists of either: - * - A Null name segment (0) - * - A DualNamePrefix followed by two 4-byte name segments - * - A MultiNamePrefix followed by a byte indicating the - * number of segments and the segments themselves. - * - A single 4-byte name segment - * - * Examine the name prefix opcode, if any, to determine the number of - * segments. - */ - switch (*Path) - { - case 0: - /* - * Null name after a root or parent prefixes. We already - * have the correct target node and there are no name segments. - */ - NumSegments = 0; - Type = ThisNode->Type; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Prefix-only Pathname (Zero name segments), Flags=%X\n", - Flags)); - break; - - case AML_DUAL_NAME_PREFIX: - - /* More than one NameSeg, search rules do not apply */ - - SearchParentFlag = ACPI_NS_NO_UPSEARCH; - - /* Two segments, point to first name segment */ - - NumSegments = 2; - Path++; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Dual Pathname (2 segments, Flags=%X)\n", Flags)); - break; - - case AML_MULTI_NAME_PREFIX_OP: - - /* More than one NameSeg, search rules do not apply */ - - SearchParentFlag = ACPI_NS_NO_UPSEARCH; - - /* Extract segment count, point to first name segment */ - - Path++; - NumSegments = (UINT32) (UINT8) *Path; - Path++; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Multi Pathname (%u Segments, Flags=%X)\n", - NumSegments, Flags)); - break; - - default: - /* - * Not a Null name, no Dual or Multi prefix, hence there is - * only one name segment and Pathname is already pointing to it. - */ - NumSegments = 1; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Simple Pathname (1 segment, Flags=%X)\n", Flags)); - break; - } - - ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); - } - - - /* - * Search namespace for each segment of the name. Loop through and - * verify (or add to the namespace) each name segment. - * - * The object type is significant only at the last name - * segment. (We don't care about the types along the path, only - * the type of the final target object.) - */ - ThisSearchType = ACPI_TYPE_ANY; - CurrentNode = ThisNode; - while (NumSegments && CurrentNode) - { - NumSegments--; - if (!NumSegments) - { - /* This is the last segment, enable typechecking */ - - ThisSearchType = Type; - - /* - * Only allow automatic parent search (search rules) if the caller - * requested it AND we have a single, non-fully-qualified NameSeg - */ - if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && - (Flags & ACPI_NS_SEARCH_PARENT)) - { - LocalFlags |= ACPI_NS_SEARCH_PARENT; - } - - /* Set error flag according to caller */ - - if (Flags & ACPI_NS_ERROR_IF_FOUND) - { - LocalFlags |= ACPI_NS_ERROR_IF_FOUND; - } - - /* Set override flag according to caller */ - - if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) - { - LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND; - } - } - - /* Extract one ACPI name from the front of the pathname */ - - ACPI_MOVE_32_TO_32 (&SimpleName, Path); - - /* Try to find the single (4 character) ACPI name */ - - Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, - InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_NOT_FOUND) - { - /* Name not found in ACPI namespace */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] not found in scope [%4.4s] %p\n", - (char *) &SimpleName, (char *) &CurrentNode->Name, - CurrentNode)); - } - - *ReturnNode = ThisNode; - return_ACPI_STATUS (Status); - } - - /* More segments to follow? */ - - if (NumSegments > 0) - { - /* - * If we have an alias to an object that opens a scope (such as a - * device or processor), we need to dereference the alias here so - * that we can access any children of the original node (via the - * remaining segments). - */ - if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) - { - if (!ThisNode->Object) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } - - if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) - ThisNode->Object)->Type)) - { - ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; - } - } - } - - /* Special handling for the last segment (NumSegments == 0) */ - - else - { - /* - * Sanity typecheck of the target object: - * - * If 1) This is the last segment (NumSegments == 0) - * 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_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 ((TypeToCheckFor != ACPI_TYPE_ANY) && - (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && - (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && - (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && - (ThisNode->Type != ACPI_TYPE_ANY) && - (ThisNode->Type != TypeToCheckFor)) - { - /* Complain about a type mismatch */ - - ACPI_WARNING ((AE_INFO, - "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", - ACPI_CAST_PTR (char, &SimpleName), - AcpiUtGetTypeName (ThisNode->Type), - AcpiUtGetTypeName (TypeToCheckFor))); - } - - /* - * If this is the last name segment and we are not looking for a - * specific type, but the type of found object is known, use that - * type to (later) see if it opens a scope. - */ - if (Type == ACPI_TYPE_ANY) - { - Type = ThisNode->Type; - } - } - - /* Point to next name segment and make this node current */ - - Path += ACPI_NAME_SIZE; - CurrentNode = ThisNode; - } - - /* Always check if we need to open a new scope */ - - if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) - { - /* - * If entry is a type which opens a scope, push the new scope on the - * scope stack. - */ - if (AcpiNsOpensScope (Type)) - { - Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - - *ReturnNode = ThisNode; - return_ACPI_STATUS (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsalloc.c b/usr/src/uts/intel/io/acpica/namespace/nsalloc.c deleted file mode 100644 index 72a974f5b4..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsalloc.c +++ /dev/null @@ -1,595 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsalloc - Namespace allocation and deletion utilities - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsalloc") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCreateNode - * - * PARAMETERS: Name - Name of the new node (4 char ACPI name) - * - * RETURN: New namespace node (Null on failure) - * - * DESCRIPTION: Create a namespace node - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsCreateNode ( - UINT32 Name) -{ - ACPI_NAMESPACE_NODE *Node; -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - UINT32 Temp; -#endif - - - ACPI_FUNCTION_TRACE (NsCreateNode); - - - Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); - if (!Node) - { - return_PTR (NULL); - } - - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - Temp = AcpiGbl_NsNodeList->TotalAllocated - - AcpiGbl_NsNodeList->TotalFreed; - if (Temp > AcpiGbl_NsNodeList->MaxOccupied) - { - AcpiGbl_NsNodeList->MaxOccupied = Temp; - } -#endif - - Node->Name.Integer = Name; - ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); - return_PTR (Node); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNode - * - * PARAMETERS: Node - Node to be deleted - * - * RETURN: None - * - * DESCRIPTION: Delete a namespace node. All node deletions must come through - * here. Detaches any attached objects, including any attached - * data. If a handler is associated with attached data, it is - * invoked before the node is deleted. - * - ******************************************************************************/ - -void -AcpiNsDeleteNode ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *NextDesc; - - - ACPI_FUNCTION_NAME (NsDeleteNode); - - - /* Detach an object if there is one */ - - AcpiNsDetachObject (Node); - - /* - * Delete an attached data object list if present (objects that were - * attached via AcpiAttachData). Note: After any normal object is - * detached above, the only possible remaining object(s) are data - * objects, in a linked list. - */ - ObjDesc = Node->Object; - while (ObjDesc && - (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - /* Invoke the attached data deletion handler if present */ - - if (ObjDesc->Data.Handler) - { - ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); - } - - NextDesc = ObjDesc->Common.NextObject; - AcpiUtRemoveReference (ObjDesc); - ObjDesc = NextDesc; - } - - /* Special case for the statically allocated root node */ - - if (Node == AcpiGbl_RootNode) - { - return; - } - - /* Now we can delete the node */ - - (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); - - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", - Node, AcpiGbl_CurrentNodeCount)); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsRemoveNode - * - * PARAMETERS: Node - Node to be removed/deleted - * - * RETURN: None - * - * DESCRIPTION: Remove (unlink) and delete a namespace node - * - ******************************************************************************/ - -void -AcpiNsRemoveNode ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_NAMESPACE_NODE *PrevNode; - ACPI_NAMESPACE_NODE *NextNode; - - - ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); - - - ParentNode = Node->Parent; - - PrevNode = NULL; - NextNode = ParentNode->Child; - - /* Find the node that is the previous peer in the parent's child list */ - - while (NextNode != Node) - { - PrevNode = NextNode; - NextNode = NextNode->Peer; - } - - if (PrevNode) - { - /* Node is not first child, unlink it */ - - PrevNode->Peer = Node->Peer; - } - else - { - /* - * Node is first child (has no previous peer). - * Link peer list to parent - */ - ParentNode->Child = Node->Peer; - } - - /* Delete the node and any attached objects */ - - AcpiNsDeleteNode (Node); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInstallNode - * - * PARAMETERS: WalkState - Current state of the walk - * ParentNode - The parent of the new Node - * Node - The new Node to install - * Type - ACPI object type of the new Node - * - * RETURN: None - * - * DESCRIPTION: Initialize a new namespace node and install it amongst - * its peers. - * - * Note: Current namespace lookup is linear search. This appears - * to be sufficient as namespace searches consume only a small - * fraction of the execution time of the ACPI subsystem. - * - ******************************************************************************/ - -void -AcpiNsInstallNode ( - ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ - ACPI_NAMESPACE_NODE *Node, /* New Child*/ - ACPI_OBJECT_TYPE Type) -{ - ACPI_OWNER_ID OwnerId = 0; - ACPI_NAMESPACE_NODE *ChildNode; - - - ACPI_FUNCTION_TRACE (NsInstallNode); - - - if (WalkState) - { - /* - * Get the owner ID from the Walk state. The owner ID is used to - * track table deletion and deletion of objects created by methods. - */ - OwnerId = WalkState->OwnerId; - - if ((WalkState->MethodDesc) && - (ParentNode != WalkState->MethodNode)) - { - /* - * A method is creating a new node that is not a child of the - * method (it is non-local). Mark the executing method as having - * modified the namespace. This is used for cleanup when the - * method exits. - */ - WalkState->MethodDesc->Method.InfoFlags |= - ACPI_METHOD_MODIFIED_NAMESPACE; - } - } - - /* Link the new entry into the parent and existing children */ - - Node->Peer = NULL; - Node->Parent = ParentNode; - ChildNode = ParentNode->Child; - - if (!ChildNode) - { - ParentNode->Child = Node; - } - else - { - /* Add node to the end of the peer list */ - - while (ChildNode->Peer) - { - ChildNode = ChildNode->Peer; - } - - ChildNode->Peer = Node; - } - - /* Init the new entry */ - - Node->OwnerId = OwnerId; - Node->Type = (UINT8) Type; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", - AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, - AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), - ParentNode)); - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteChildren - * - * PARAMETERS: ParentNode - Delete this objects children - * - * RETURN: None. - * - * DESCRIPTION: Delete all children of the parent object. In other words, - * deletes a "scope". - * - ******************************************************************************/ - -void -AcpiNsDeleteChildren ( - ACPI_NAMESPACE_NODE *ParentNode) -{ - ACPI_NAMESPACE_NODE *NextNode; - ACPI_NAMESPACE_NODE *NodeToDelete; - - - ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); - - - if (!ParentNode) - { - return_VOID; - } - - /* Deallocate all children at this level */ - - NextNode = ParentNode->Child; - while (NextNode) - { - /* Grandchildren should have all been deleted already */ - - if (NextNode->Child) - { - ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", - ParentNode, NextNode)); - } - - /* - * Delete this child node and move on to the next child in the list. - * No need to unlink the node since we are deleting the entire branch. - */ - NodeToDelete = NextNode; - NextNode = NextNode->Peer; - AcpiNsDeleteNode (NodeToDelete); - }; - - /* Clear the parent's child pointer */ - - ParentNode->Child = NULL; - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNamespaceSubtree - * - * PARAMETERS: ParentNode - Root of the subtree to be deleted - * - * RETURN: None. - * - * DESCRIPTION: Delete a subtree of the namespace. This includes all objects - * stored within the subtree. - * - ******************************************************************************/ - -void -AcpiNsDeleteNamespaceSubtree ( - ACPI_NAMESPACE_NODE *ParentNode) -{ - ACPI_NAMESPACE_NODE *ChildNode = NULL; - UINT32 Level = 1; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); - - - if (!ParentNode) - { - return_VOID; - } - - /* Lock namespace for possible update */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_VOID; - } - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - while (Level > 0) - { - /* Get the next node in this scope (NULL if none) */ - - ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); - if (ChildNode) - { - /* Found a child node - detach any attached object */ - - AcpiNsDetachObject (ChildNode); - - /* Check if this node has any children */ - - if (ChildNode->Child) - { - /* - * There is at least one child of this node, - * visit the node - */ - Level++; - ParentNode = ChildNode; - ChildNode = NULL; - } - } - else - { - /* - * No more children of this parent node. - * Move up to the grandparent. - */ - Level--; - - /* - * Now delete all of the children of this parent - * all at the same time. - */ - AcpiNsDeleteChildren (ParentNode); - - /* New "last child" is this parent node */ - - ChildNode = ParentNode; - - /* Move up the tree to the grandparent */ - - ParentNode = ParentNode->Parent; - } - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNamespaceByOwner - * - * PARAMETERS: OwnerId - All nodes with this owner will be deleted - * - * RETURN: Status - * - * DESCRIPTION: Delete entries within the namespace that are owned by a - * specific ID. Used to delete entire ACPI tables. All - * reference counts are updated. - * - * MUTEX: Locks namespace during deletion walk. - * - ******************************************************************************/ - -void -AcpiNsDeleteNamespaceByOwner ( - ACPI_OWNER_ID OwnerId) -{ - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_NAMESPACE_NODE *DeletionNode; - ACPI_NAMESPACE_NODE *ParentNode; - UINT32 Level; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); - - - if (OwnerId == 0) - { - return_VOID; - } - - /* Lock namespace for possible update */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_VOID; - } - - DeletionNode = NULL; - ParentNode = AcpiGbl_RootNode; - ChildNode = NULL; - Level = 1; - - /* - * Traverse the tree of nodes until we bubble back up - * to where we started. - */ - while (Level > 0) - { - /* - * Get the next child of this parent node. When ChildNode is NULL, - * the first child of the parent is returned - */ - ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); - - if (DeletionNode) - { - AcpiNsDeleteChildren (DeletionNode); - AcpiNsRemoveNode (DeletionNode); - DeletionNode = NULL; - } - - if (ChildNode) - { - if (ChildNode->OwnerId == OwnerId) - { - /* Found a matching child node - detach any attached object */ - - AcpiNsDetachObject (ChildNode); - } - - /* Check if this node has any children */ - - if (ChildNode->Child) - { - /* - * There is at least one child of this node, - * visit the node - */ - Level++; - ParentNode = ChildNode; - ChildNode = NULL; - } - else if (ChildNode->OwnerId == OwnerId) - { - DeletionNode = ChildNode; - } - } - else - { - /* - * No more children of this parent node. - * Move up to the grandparent. - */ - Level--; - if (Level != 0) - { - if (ParentNode->OwnerId == OwnerId) - { - DeletionNode = ParentNode; - } - } - - /* New "last child" is this parent node */ - - ChildNode = ParentNode; - - /* Move up the tree to the grandparent */ - - ParentNode = ParentNode->Parent; - } - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_VOID; -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsarguments.c b/usr/src/uts/intel/io/acpica/namespace/nsarguments.c deleted file mode 100644 index 1483e8121b..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsarguments.c +++ /dev/null @@ -1,305 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsarguments - Validation of args for ACPI predefined methods - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acpredef.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsarguments") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckArgumentTypes - * - * PARAMETERS: Info - Method execution information block - * - * RETURN: None - * - * DESCRIPTION: Check the incoming argument count and all argument types - * against the argument type list for a predefined name. - * - ******************************************************************************/ - -void -AcpiNsCheckArgumentTypes ( - ACPI_EVALUATE_INFO *Info) -{ - UINT16 ArgTypeList; - UINT8 ArgCount; - UINT8 ArgType; - UINT8 UserArgType; - UINT32 i; - - - /* If not a predefined name, cannot typecheck args */ - - if (!Info->Predefined) - { - return; - } - - ArgTypeList = Info->Predefined->Info.ArgumentList; - ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList); - - /* Typecheck all arguments */ - - for (i = 0; ((i < ArgCount) && (i < Info->ParamCount)); i++) - { - ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList); - UserArgType = Info->Parameters[i]->Common.Type; - - if (UserArgType != ArgType) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS, - "Argument #%u type mismatch - " - "Found [%s], ACPI requires [%s]", (i + 1), - AcpiUtGetTypeName (UserArgType), - AcpiUtGetTypeName (ArgType))); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckAcpiCompliance - * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) - * Node - Namespace node for the method/object - * Predefined - Pointer to entry in predefined name table - * - * RETURN: None - * - * DESCRIPTION: Check that the declared parameter count (in ASL/AML) for a - * predefined name is what is expected (matches what is defined in - * the ACPI specification for this predefined name.) - * - ******************************************************************************/ - -void -AcpiNsCheckAcpiCompliance ( - char *Pathname, - ACPI_NAMESPACE_NODE *Node, - const ACPI_PREDEFINED_INFO *Predefined) -{ - UINT32 AmlParamCount; - UINT32 RequiredParamCount; - - - if (!Predefined) - { - return; - } - - /* Get the ACPI-required arg count from the predefined info table */ - - RequiredParamCount = - METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); - - /* - * If this object is not a control method, we can check if the ACPI - * spec requires that it be a method. - */ - if (Node->Type != ACPI_TYPE_METHOD) - { - if (RequiredParamCount > 0) - { - /* Object requires args, must be implemented as a method */ - - ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Object (%s) must be a control method with %u arguments", - AcpiUtGetTypeName (Node->Type), RequiredParamCount)); - } - else if (!RequiredParamCount && !Predefined->Info.ExpectedBtypes) - { - /* Object requires no args and no return value, must be a method */ - - ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Object (%s) must be a control method " - "with no arguments and no return value", - AcpiUtGetTypeName (Node->Type))); - } - - return; - } - - /* - * This is a control method. - * Check that the ASL/AML-defined parameter count for this method - * matches the ACPI-required parameter count - * - * Some methods are allowed to have a "minimum" number of args (_SCP) - * because their definition in ACPI has changed over time. - * - * Note: These are BIOS errors in the declaration of the object - */ - AmlParamCount = Node->Object->Method.ParamCount; - - if (AmlParamCount < RequiredParamCount) - { - ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Insufficient arguments - " - "ASL declared %u, ACPI requires %u", - AmlParamCount, RequiredParamCount)); - } - else if ((AmlParamCount > RequiredParamCount) && - !(Predefined->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) - { - ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Excess arguments - " - "ASL declared %u, ACPI requires %u", - AmlParamCount, RequiredParamCount)); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckArgumentCount - * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) - * Node - Namespace node for the method/object - * UserParamCount - Number of args passed in by the caller - * Predefined - Pointer to entry in predefined name table - * - * RETURN: None - * - * DESCRIPTION: Check that incoming argument count matches the declared - * parameter count (in the ASL/AML) for an object. - * - ******************************************************************************/ - -void -AcpiNsCheckArgumentCount ( - char *Pathname, - ACPI_NAMESPACE_NODE *Node, - UINT32 UserParamCount, - const ACPI_PREDEFINED_INFO *Predefined) -{ - UINT32 AmlParamCount; - UINT32 RequiredParamCount; - - - if (!Predefined) - { - /* - * Not a predefined name. Check the incoming user argument count - * against the count that is specified in the method/object. - */ - if (Node->Type != ACPI_TYPE_METHOD) - { - if (UserParamCount) - { - ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "%u arguments were passed to a non-method ACPI object (%s)", - UserParamCount, AcpiUtGetTypeName (Node->Type))); - } - - return; - } - - /* - * This is a control method. Check the parameter count. - * We can only check the incoming argument count against the - * argument count declared for the method in the ASL/AML. - * - * Emit a message if too few or too many arguments have been passed - * by the caller. - * - * Note: Too many arguments will not cause the method to - * fail. However, the method will fail if there are too few - * arguments and the method attempts to use one of the missing ones. - */ - AmlParamCount = Node->Object->Method.ParamCount; - - if (UserParamCount < AmlParamCount) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Insufficient arguments - " - "Caller passed %u, method requires %u", - UserParamCount, AmlParamCount)); - } - else if (UserParamCount > AmlParamCount) - { - ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Excess arguments - " - "Caller passed %u, method requires %u", - UserParamCount, AmlParamCount)); - } - - return; - } - - /* - * This is a predefined name. Validate the user-supplied parameter - * count against the ACPI specification. We don't validate against - * the method itself because what is important here is that the - * caller is in conformance with the spec. (The arg count for the - * method was checked against the ACPI spec earlier.) - * - * Some methods are allowed to have a "minimum" number of args (_SCP) - * because their definition in ACPI has changed over time. - */ - RequiredParamCount = - METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); - - if (UserParamCount < RequiredParamCount) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Insufficient arguments - " - "Caller passed %u, ACPI requires %u", - UserParamCount, RequiredParamCount)); - } - else if ((UserParamCount > RequiredParamCount) && - !(Predefined->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) - { - ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Excess arguments - " - "Caller passed %u, ACPI requires %u", - UserParamCount, RequiredParamCount)); - } -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsconvert.c b/usr/src/uts/intel/io/acpica/namespace/nsconvert.c deleted file mode 100644 index 2fa182eddc..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsconvert.c +++ /dev/null @@ -1,566 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsconvert - Object conversions for objects returned by - * predefined methods - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "acpredef.h" -#include "amlresrc.h" - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsconvert") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToInteger - * - * PARAMETERS: OriginalObject - Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful. - * - * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToInteger ( - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject; - ACPI_STATUS Status; - UINT64 Value = 0; - UINT32 i; - - - switch (OriginalObject->Common.Type) - { - case ACPI_TYPE_STRING: - - /* String-to-Integer conversion */ - - Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - case ACPI_TYPE_BUFFER: - - /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ - - if (OriginalObject->Buffer.Length > 8) - { - return (AE_AML_OPERAND_TYPE); - } - - /* Extract each buffer byte to create the integer */ - - for (i = 0; i < OriginalObject->Buffer.Length; i++) - { - Value |= ((UINT64) - OriginalObject->Buffer.Pointer[i] << (i * 8)); - } - break; - - default: - - return (AE_AML_OPERAND_TYPE); - } - - NewObject = AcpiUtCreateIntegerObject (Value); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - *ReturnObject = NewObject; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToString - * - * PARAMETERS: OriginalObject - Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful. - * - * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToString ( - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject; - ACPI_SIZE Length; - ACPI_STATUS Status; - - - switch (OriginalObject->Common.Type) - { - case ACPI_TYPE_INTEGER: - /* - * Integer-to-String conversion. Commonly, convert - * an integer of value 0 to a NULL string. The last element of - * _BIF and _BIX packages occasionally need this fix. - */ - if (OriginalObject->Integer.Value == 0) - { - /* Allocate a new NULL string object */ - - NewObject = AcpiUtCreateStringObject (0); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - } - else - { - Status = AcpiExConvertToString (OriginalObject, - &NewObject, ACPI_IMPLICIT_CONVERT_HEX); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - break; - - case ACPI_TYPE_BUFFER: - /* - * Buffer-to-String conversion. Use a ToString - * conversion, no transform performed on the buffer data. The best - * example of this is the _BIF method, where the string data from - * the battery is often (incorrectly) returned as buffer object(s). - */ - Length = 0; - while ((Length < OriginalObject->Buffer.Length) && - (OriginalObject->Buffer.Pointer[Length])) - { - Length++; - } - - /* Allocate a new string object */ - - NewObject = AcpiUtCreateStringObject (Length); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - /* - * Copy the raw buffer data with no transform. String is already NULL - * terminated at Length+1. - */ - memcpy (NewObject->String.Pointer, - OriginalObject->Buffer.Pointer, Length); - break; - - default: - - return (AE_AML_OPERAND_TYPE); - } - - *ReturnObject = NewObject; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToBuffer - * - * PARAMETERS: OriginalObject - Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful. - * - * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToBuffer ( - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Elements; - UINT32 *DwordBuffer; - UINT32 Count; - UINT32 i; - - - switch (OriginalObject->Common.Type) - { - case ACPI_TYPE_INTEGER: - /* - * Integer-to-Buffer conversion. - * Convert the Integer to a packed-byte buffer. _MAT and other - * objects need this sometimes, if a read has been performed on a - * Field object that is less than or equal to the global integer - * size (32 or 64 bits). - */ - Status = AcpiExConvertToBuffer (OriginalObject, &NewObject); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - case ACPI_TYPE_STRING: - - /* String-to-Buffer conversion. Simple data copy */ - - NewObject = AcpiUtCreateBufferObject - (OriginalObject->String.Length); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - memcpy (NewObject->Buffer.Pointer, - OriginalObject->String.Pointer, OriginalObject->String.Length); - break; - - case ACPI_TYPE_PACKAGE: - /* - * This case is often seen for predefined names that must return a - * Buffer object with multiple DWORD integers within. For example, - * _FDE and _GTM. The Package can be converted to a Buffer. - */ - - /* All elements of the Package must be integers */ - - Elements = OriginalObject->Package.Elements; - Count = OriginalObject->Package.Count; - - for (i = 0; i < Count; i++) - { - if ((!*Elements) || - ((*Elements)->Common.Type != ACPI_TYPE_INTEGER)) - { - return (AE_AML_OPERAND_TYPE); - } - Elements++; - } - - /* Create the new buffer object to replace the Package */ - - NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count)); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - /* Copy the package elements (integers) to the buffer as DWORDs */ - - Elements = OriginalObject->Package.Elements; - DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer); - - for (i = 0; i < Count; i++) - { - *DwordBuffer = (UINT32) (*Elements)->Integer.Value; - DwordBuffer++; - Elements++; - } - break; - - default: - - return (AE_AML_OPERAND_TYPE); - } - - *ReturnObject = NewObject; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToUnicode - * - * PARAMETERS: Scope - Namespace node for the method/object - * OriginalObject - ASCII String Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful. - * - * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToUnicode ( - ACPI_NAMESPACE_NODE *Scope, - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject; - char *AsciiString; - UINT16 *UnicodeBuffer; - UINT32 UnicodeLength; - UINT32 i; - - - if (!OriginalObject) - { - return (AE_OK); - } - - /* If a Buffer was returned, it must be at least two bytes long */ - - if (OriginalObject->Common.Type == ACPI_TYPE_BUFFER) - { - if (OriginalObject->Buffer.Length < 2) - { - return (AE_AML_OPERAND_VALUE); - } - - *ReturnObject = NULL; - return (AE_OK); - } - - /* - * The original object is an ASCII string. Convert this string to - * a unicode buffer. - */ - AsciiString = OriginalObject->String.Pointer; - UnicodeLength = (OriginalObject->String.Length * 2) + 2; - - /* Create a new buffer object for the Unicode data */ - - NewObject = AcpiUtCreateBufferObject (UnicodeLength); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - UnicodeBuffer = ACPI_CAST_PTR (UINT16, NewObject->Buffer.Pointer); - - /* Convert ASCII to Unicode */ - - for (i = 0; i < OriginalObject->String.Length; i++) - { - UnicodeBuffer[i] = (UINT16) AsciiString[i]; - } - - *ReturnObject = NewObject; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToResource - * - * PARAMETERS: Scope - Namespace node for the method/object - * OriginalObject - Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful - * - * DESCRIPTION: Attempt to convert a Integer object to a ResourceTemplate - * Buffer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToResource ( - ACPI_NAMESPACE_NODE *Scope, - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject; - UINT8 *Buffer; - - - /* - * We can fix the following cases for an expected resource template: - * 1. No return value (interpreter slack mode is disabled) - * 2. A "Return (Zero)" statement - * 3. A "Return empty buffer" statement - * - * We will return a buffer containing a single EndTag - * resource descriptor. - */ - if (OriginalObject) - { - switch (OriginalObject->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* We can only repair an Integer==0 */ - - if (OriginalObject->Integer.Value) - { - return (AE_AML_OPERAND_TYPE); - } - break; - - case ACPI_TYPE_BUFFER: - - if (OriginalObject->Buffer.Length) - { - /* Additional checks can be added in the future */ - - *ReturnObject = NULL; - return (AE_OK); - } - break; - - case ACPI_TYPE_STRING: - default: - - return (AE_AML_OPERAND_TYPE); - } - } - - /* Create the new buffer object for the resource descriptor */ - - NewObject = AcpiUtCreateBufferObject (2); - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - Buffer = ACPI_CAST_PTR (UINT8, NewObject->Buffer.Pointer); - - /* Initialize the Buffer with a single EndTag descriptor */ - - Buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE); - Buffer[1] = 0x00; - - *ReturnObject = NewObject; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertToReference - * - * PARAMETERS: Scope - Namespace node for the method/object - * OriginalObject - Object to be converted - * ReturnObject - Where the new converted object is returned - * - * RETURN: Status. AE_OK if conversion was successful - * - * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference. - * Buffer. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsConvertToReference ( - ACPI_NAMESPACE_NODE *Scope, - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_OPERAND_OBJECT *NewObject = NULL; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_GENERIC_STATE ScopeInfo; - char *Name; - - - ACPI_FUNCTION_NAME (NsConvertToReference); - - - /* Convert path into internal presentation */ - - Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Find the namespace node */ - - ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope); - Status = AcpiNsLookup (&ScopeInfo, Name, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); - if (ACPI_FAILURE (Status)) - { - /* Check if we are resolving a named reference within a package */ - - ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status); - goto ErrorExit; - } - - /* Create and init a new internal ACPI object */ - - NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); - if (!NewObject) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } - NewObject->Reference.Node = Node; - NewObject->Reference.Object = Node->Object; - NewObject->Reference.Class = ACPI_REFCLASS_NAME; - - /* - * Increase reference of the object if needed (the object is likely a - * null for device nodes). - */ - AcpiUtAddReference (Node->Object); - -ErrorExit: - ACPI_FREE (Name); - *ReturnObject = NewObject; - return (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsdump.c b/usr/src/uts/intel/io/acpica/namespace/nsdump.c deleted file mode 100644 index 32ada86001..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsdump.c +++ /dev/null @@ -1,947 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsdump - table dumping routines for debug - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acoutput.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsdump") - -/* Local prototypes */ - -#ifdef ACPI_OBSOLETE_FUNCTIONS -void -AcpiNsDumpRootDevices ( - void); - -static ACPI_STATUS -AcpiNsDumpOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); -#endif - - -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - -static ACPI_STATUS -AcpiNsDumpOneObjectPath ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiNsGetMaxDepth ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsPrintPathname - * - * PARAMETERS: NumSegments - Number of ACPI name segments - * Pathname - The compressed (internal) path - * - * RETURN: None - * - * DESCRIPTION: Print an object's full namespace pathname - * - ******************************************************************************/ - -void -AcpiNsPrintPathname ( - UINT32 NumSegments, - const char *Pathname) -{ - UINT32 i; - - - ACPI_FUNCTION_NAME (NsPrintPathname); - - - /* Check if debug output enabled */ - - if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE)) - { - return; - } - - /* Print the entire name */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); - - while (NumSegments) - { - for (i = 0; i < 4; i++) - { - isprint ((int) Pathname[i]) ? - AcpiOsPrintf ("%c", Pathname[i]) : - AcpiOsPrintf ("?"); - } - - Pathname += ACPI_NAME_SIZE; - NumSegments--; - if (NumSegments) - { - AcpiOsPrintf ("."); - } - } - - AcpiOsPrintf ("]\n"); -} - - -#ifdef ACPI_OBSOLETE_FUNCTIONS -/* Not used at this time, perhaps later */ - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpPathname - * - * PARAMETERS: Handle - Object - * Msg - Prefix message - * Level - Desired debug level - * Component - Caller's component ID - * - * RETURN: None - * - * DESCRIPTION: Print an object's full namespace pathname - * Manages allocation/freeing of a pathname buffer - * - ******************************************************************************/ - -void -AcpiNsDumpPathname ( - ACPI_HANDLE Handle, - const char *Msg, - UINT32 Level, - UINT32 Component) -{ - - ACPI_FUNCTION_TRACE (NsDumpPathname); - - - /* Do this only if the requested debug level and component are enabled */ - - if (!ACPI_IS_DEBUG_ENABLED (Level, Component)) - { - return_VOID; - } - - /* Convert handle to a full pathname and print it (with supplied message) */ - - AcpiNsPrintNodePathname (Handle, Msg); - AcpiOsPrintf ("\n"); - return_VOID; -} -#endif - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpOneObject - * - * PARAMETERS: ObjHandle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into WalkNamespace - * ReturnValue - Not used - * - * RETURN: Status - * - * DESCRIPTION: Dump a single Node - * This procedure is a UserFunction called by AcpiNsWalkNamespace. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsDumpOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; - ACPI_NAMESPACE_NODE *ThisNode; - ACPI_OPERAND_OBJECT *ObjDesc = NULL; - ACPI_OBJECT_TYPE ObjType; - ACPI_OBJECT_TYPE Type; - UINT32 BytesToDump; - UINT32 DbgLevel; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsDumpOneObject); - - - /* Is output enabled? */ - - if (!(AcpiDbgLevel & Info->DebugLevel)) - { - return (AE_OK); - } - - if (!ObjHandle) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); - return (AE_OK); - } - - ThisNode = AcpiNsValidateHandle (ObjHandle); - if (!ThisNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", - ObjHandle)); - return (AE_OK); - } - - Type = ThisNode->Type; - - /* Check if the owner matches */ - - if ((Info->OwnerId != ACPI_OWNER_ID_MAX) && - (Info->OwnerId != ThisNode->OwnerId)) - { - return (AE_OK); - } - - if (!(Info->DisplayType & ACPI_DISPLAY_SHORT)) - { - /* Indent the object according to the level */ - - AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); - - /* Check the node type and name */ - - if (Type > ACPI_TYPE_LOCAL_MAX) - { - ACPI_WARNING ((AE_INFO, - "Invalid ACPI Object Type 0x%08X", Type)); - } - - AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); - } - - /* Now we can print out the pertinent information */ - - AcpiOsPrintf (" %-12s %p %2.2X ", - AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); - - DbgLevel = AcpiDbgLevel; - AcpiDbgLevel = 0; - ObjDesc = AcpiNsGetAttachedObject (ThisNode); - AcpiDbgLevel = DbgLevel; - - /* Temp nodes are those nodes created by a control method */ - - if (ThisNode->Flags & ANOBJ_TEMPORARY) - { - AcpiOsPrintf ("(T) "); - } - - switch (Info->DisplayType & ACPI_DISPLAY_MASK) - { - case ACPI_DISPLAY_SUMMARY: - - if (!ObjDesc) - { - /* No attached object. Some types should always have an object */ - - switch (Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_METHOD: - - AcpiOsPrintf ("<No attached object>"); - break; - - default: - - break; - } - - AcpiOsPrintf ("\n"); - return (AE_OK); - } - - switch (Type) - { - case ACPI_TYPE_PROCESSOR: - - AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n", - ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, - ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address)); - break; - - case ACPI_TYPE_DEVICE: - - AcpiOsPrintf ("Notify Object: %p\n", ObjDesc); - break; - - case ACPI_TYPE_METHOD: - - 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_FORMAT_UINT64 (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_PACKAGE: - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - AcpiOsPrintf ("Elements %.2X\n", - ObjDesc->Package.Count); - } - else - { - AcpiOsPrintf ("[Length not yet evaluated]\n"); - } - break; - - case ACPI_TYPE_BUFFER: - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - AcpiOsPrintf ("Len %.2X", - ObjDesc->Buffer.Length); - - /* Dump some of the buffer */ - - if (ObjDesc->Buffer.Length > 0) - { - AcpiOsPrintf (" ="); - for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++) - { - AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]); - } - } - AcpiOsPrintf ("\n"); - } - else - { - AcpiOsPrintf ("[Length not yet evaluated]\n"); - } - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); - AcpiUtPrintString (ObjDesc->String.Pointer, 80); - AcpiOsPrintf ("\n"); - break; - - case ACPI_TYPE_REGION: - - AcpiOsPrintf ("[%s]", - AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); - if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) - { - AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), - ObjDesc->Region.Length); - } - else - { - AcpiOsPrintf (" [Address/Length not yet evaluated]\n"); - } - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc)); - break; - - case ACPI_TYPE_BUFFER_FIELD: - - if (ObjDesc->BufferField.BufferObj && - ObjDesc->BufferField.BufferObj->Buffer.Node) - { - AcpiOsPrintf ("Buf [%4.4s]", - AcpiUtGetNodeName ( - ObjDesc->BufferField.BufferObj->Buffer.Node)); - } - break; - - case ACPI_TYPE_LOCAL_REGION_FIELD: - - AcpiOsPrintf ("Rgn [%4.4s]", - AcpiUtGetNodeName ( - ObjDesc->CommonField.RegionObj->Region.Node)); - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", - AcpiUtGetNodeName ( - ObjDesc->CommonField.RegionObj->Region.Node), - AcpiUtGetNodeName ( - ObjDesc->BankField.BankObj->CommonField.Node)); - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", - AcpiUtGetNodeName ( - ObjDesc->IndexField.IndexObj->CommonField.Node), - AcpiUtGetNodeName ( - ObjDesc->IndexField.DataObj->CommonField.Node)); - break; - - case ACPI_TYPE_LOCAL_ALIAS: - case ACPI_TYPE_LOCAL_METHOD_ALIAS: - - AcpiOsPrintf ("Target %4.4s (%p)\n", - AcpiUtGetNodeName (ObjDesc), ObjDesc); - break; - - default: - - AcpiOsPrintf ("Object %p\n", ObjDesc); - break; - } - - /* Common field handling */ - - switch (Type) - { - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", - (ObjDesc->CommonField.BaseByteOffset * 8) - + ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.AccessByteWidth); - break; - - default: - - break; - } - break; - - case ACPI_DISPLAY_OBJECTS: - - AcpiOsPrintf ("O:%p", ObjDesc); - if (!ObjDesc) - { - /* No attached object, we are done */ - - AcpiOsPrintf ("\n"); - return (AE_OK); - } - - AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount); - - switch (Type) - { - case ACPI_TYPE_METHOD: - - /* Name is a Method and its AML offset/length are set */ - - AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength); - break; - - case ACPI_TYPE_INTEGER: - - AcpiOsPrintf (" I:%8.8X8.8%X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_STRING: - - AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, - ObjDesc->String.Length); - break; - - case ACPI_TYPE_BUFFER: - - AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, - ObjDesc->Buffer.Length); - break; - - default: - - AcpiOsPrintf ("\n"); - break; - } - break; - - default: - AcpiOsPrintf ("\n"); - break; - } - - /* If debug turned off, done */ - - if (!(AcpiDbgLevel & ACPI_LV_VALUES)) - { - return (AE_OK); - } - - /* If there is an attached object, display it */ - - DbgLevel = AcpiDbgLevel; - AcpiDbgLevel = 0; - ObjDesc = AcpiNsGetAttachedObject (ThisNode); - AcpiDbgLevel = DbgLevel; - - /* Dump attached objects */ - - while (ObjDesc) - { - ObjType = ACPI_TYPE_INVALID; - AcpiOsPrintf ("Attached Object %p: ", ObjDesc); - - /* Decode the type of attached object and dump the contents */ - - switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) - { - case ACPI_DESC_TYPE_NAMED: - - AcpiOsPrintf ("(Ptr to Node)\n"); - BytesToDump = sizeof (ACPI_NAMESPACE_NODE); - ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); - break; - - case ACPI_DESC_TYPE_OPERAND: - - ObjType = ObjDesc->Common.Type; - - if (ObjType > ACPI_TYPE_LOCAL_MAX) - { - AcpiOsPrintf ( - "(Pointer to ACPI Object type %.2X [UNKNOWN])\n", - ObjType); - - BytesToDump = 32; - } - else - { - AcpiOsPrintf ( - "(Pointer to ACPI Object type %.2X [%s])\n", - ObjType, AcpiUtGetTypeName (ObjType)); - - BytesToDump = sizeof (ACPI_OPERAND_OBJECT); - } - - ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); - break; - - default: - - break; - } - - /* If value is NOT an internal object, we are done */ - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) - { - goto Cleanup; - } - - /* Valid object, get the pointer to next level, if any */ - - switch (ObjType) - { - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_STRING: - /* - * NOTE: takes advantage of common fields between string/buffer - */ - BytesToDump = ObjDesc->String.Length; - ObjDesc = (void *) ObjDesc->String.Pointer; - - AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n", - ObjDesc, BytesToDump); - ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); - goto Cleanup; - - case ACPI_TYPE_BUFFER_FIELD: - - ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; - break; - - case ACPI_TYPE_PACKAGE: - - ObjDesc = (void *) ObjDesc->Package.Elements; - break; - - case ACPI_TYPE_METHOD: - - ObjDesc = (void *) ObjDesc->Method.AmlStart; - break; - - case ACPI_TYPE_LOCAL_REGION_FIELD: - - ObjDesc = (void *) ObjDesc->Field.RegionObj; - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - ObjDesc = (void *) ObjDesc->BankField.RegionObj; - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - ObjDesc = (void *) ObjDesc->IndexField.IndexObj; - break; - - default: - - goto Cleanup; - } - - ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ - } - -Cleanup: - AcpiOsPrintf ("\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpObjects - * - * PARAMETERS: Type - Object type to be dumped - * DisplayType - 0 or ACPI_DISPLAY_SUMMARY - * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX - * for an effectively unlimited depth. - * OwnerId - Dump only objects owned by this ID. Use - * ACPI_UINT32_MAX to match all owners. - * StartHandle - Where in namespace to start/end search - * - * RETURN: None - * - * DESCRIPTION: Dump typed objects within the loaded namespace. Uses - * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. - * - ******************************************************************************/ - -void -AcpiNsDumpObjects ( - ACPI_OBJECT_TYPE Type, - UINT8 DisplayType, - UINT32 MaxDepth, - ACPI_OWNER_ID OwnerId, - ACPI_HANDLE StartHandle) -{ - ACPI_WALK_INFO Info; - ACPI_STATUS Status; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * Just lock the entire namespace for the duration of the dump. - * We don't want any changes to the namespace during this time, - * especially the temporary nodes since we are going to display - * them also. - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not acquire namespace mutex\n"); - return; - } - - Info.DebugLevel = ACPI_LV_TABLES; - Info.OwnerId = OwnerId; - Info.DisplayType = DisplayType; - - (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth - * - * PARAMETERS: ObjHandle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into WalkNamespace - * ReturnValue - Not used - * - * RETURN: Status - * - * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth - * computes the maximum nesting depth in the namespace tree, in - * order to simplify formatting in AcpiNsDumpOneObjectPath. - * These procedures are UserFunctions called by AcpiNsWalkNamespace. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsDumpOneObjectPath ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - UINT32 MaxLevel = *((UINT32 *) Context); - char *Pathname; - ACPI_NAMESPACE_NODE *Node; - int PathIndent; - - - if (!ObjHandle) - { - return (AE_OK); - } - - Node = AcpiNsValidateHandle (ObjHandle); - if (!Node) - { - /* Ignore bad node during namespace walk */ - - return (AE_OK); - } - - Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); - - PathIndent = 1; - if (Level <= MaxLevel) - { - PathIndent = MaxLevel - Level + 1; - } - - AcpiOsPrintf ("%2d%*s%-12s%*s", - Level, Level, " ", AcpiUtGetTypeName (Node->Type), - PathIndent, " "); - - AcpiOsPrintf ("%s\n", &Pathname[1]); - ACPI_FREE (Pathname); - return (AE_OK); -} - - -static ACPI_STATUS -AcpiNsGetMaxDepth ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - UINT32 *MaxLevel = (UINT32 *) Context; - - - if (Level > *MaxLevel) - { - *MaxLevel = Level; - } - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpObjectPaths - * - * PARAMETERS: Type - Object type to be dumped - * DisplayType - 0 or ACPI_DISPLAY_SUMMARY - * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX - * for an effectively unlimited depth. - * OwnerId - Dump only objects owned by this ID. Use - * ACPI_UINT32_MAX to match all owners. - * StartHandle - Where in namespace to start/end search - * - * RETURN: None - * - * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses - * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath. - * - ******************************************************************************/ - -void -AcpiNsDumpObjectPaths ( - ACPI_OBJECT_TYPE Type, - UINT8 DisplayType, - UINT32 MaxDepth, - ACPI_OWNER_ID OwnerId, - ACPI_HANDLE StartHandle) -{ - ACPI_STATUS Status; - UINT32 MaxLevel = 0; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * Just lock the entire namespace for the duration of the dump. - * We don't want any changes to the namespace during this time, - * especially the temporary nodes since we are going to display - * them also. - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not acquire namespace mutex\n"); - return; - } - - /* Get the max depth of the namespace tree, for formatting later */ - - (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL); - - /* Now dump the entire namespace */ - - (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpEntry - * - * PARAMETERS: Handle - Node to be dumped - * DebugLevel - Output level - * - * RETURN: None - * - * DESCRIPTION: Dump a single Node - * - ******************************************************************************/ - -void -AcpiNsDumpEntry ( - ACPI_HANDLE Handle, - UINT32 DebugLevel) -{ - ACPI_WALK_INFO Info; - - - ACPI_FUNCTION_ENTRY (); - - - Info.DebugLevel = DebugLevel; - Info.OwnerId = ACPI_OWNER_ID_MAX; - Info.DisplayType = ACPI_DISPLAY_SUMMARY; - - (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); -} - - -#ifdef ACPI_ASL_COMPILER -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpTables - * - * PARAMETERS: SearchBase - Root of subtree to be dumped, or - * NS_ALL to dump the entire namespace - * MaxDepth - Maximum depth of dump. Use INT_MAX - * for an effectively unlimited depth. - * - * RETURN: None - * - * DESCRIPTION: Dump the name space, or a portion of it. - * - ******************************************************************************/ - -void -AcpiNsDumpTables ( - ACPI_HANDLE SearchBase, - UINT32 MaxDepth) -{ - ACPI_HANDLE SearchHandle = SearchBase; - - - ACPI_FUNCTION_TRACE (NsDumpTables); - - - if (!AcpiGbl_RootNode) - { - /* - * If the name space has not been initialized, - * there is nothing to dump. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "namespace not initialized!\n")); - return_VOID; - } - - if (ACPI_NS_ALL == SearchBase) - { - /* Entire namespace */ - - SearchHandle = AcpiGbl_RootNode; - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); - } - - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, - ACPI_OWNER_ID_MAX, SearchHandle); - return_VOID; -} -#endif -#endif diff --git a/usr/src/uts/intel/io/acpica/namespace/nsdumpdv.c b/usr/src/uts/intel/io/acpica/namespace/nsdumpdv.c deleted file mode 100644 index ea143fb5b4..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsdumpdv.c +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsdump - table dumping routines for debug - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" - - -/* TBD: This entire module is apparently obsolete and should be removed */ - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsdumpdv") - -#ifdef ACPI_OBSOLETE_FUNCTIONS -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - -#include "acnamesp.h" - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpOneDevice - * - * PARAMETERS: Handle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into WalkNamespace - * ReturnValue - Not used - * - * RETURN: Status - * - * DESCRIPTION: Dump a single Node that represents a device - * This procedure is a UserFunction called by AcpiNsWalkNamespace. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsDumpOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - ACPI_BUFFER Buffer; - ACPI_DEVICE_INFO *Info; - ACPI_STATUS Status; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsDumpOneDevice); - - - Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); - - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (ObjHandle, &Buffer); - if (ACPI_SUCCESS (Status)) - { - Info = Buffer.Pointer; - 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.Value, ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus)); - ACPI_FREE (Info); - } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpRootDevices - * - * PARAMETERS: None - * - * RETURN: 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 (NULL, METHOD_NAME__SB_, &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, NULL); -} - -#endif -#endif diff --git a/usr/src/uts/intel/io/acpica/namespace/nseval.c b/usr/src/uts/intel/io/acpica/namespace/nseval.c deleted file mode 100644 index 63051b8a52..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nseval.c +++ /dev/null @@ -1,524 +0,0 @@ -/******************************************************************************* - * - * Module Name: nseval - Object evaluation, includes control method execution - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acparser.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nseval") - -/* Local prototypes */ - -static void -AcpiNsExecModuleCode ( - ACPI_OPERAND_OBJECT *MethodObj, - ACPI_EVALUATE_INFO *Info); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluate - * - * PARAMETERS: Info - Evaluation info block, contains these fields - * and more: - * PrefixNode - Prefix or Method/Object Node to execute - * RelativePath - Name of method to execute, If NULL, the - * Node is the object to execute - * Parameters - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * ParameterType - Type of Parameter list - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * Flags - ACPI_IGNORE_RETURN_VALUE to delete return - * - * RETURN: Status - * - * DESCRIPTION: Execute a control method or return the current value of an - * ACPI namespace object. - * - * MUTEX: Locks interpreter - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluate ( - ACPI_EVALUATE_INFO *Info) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsEvaluate); - - - if (!Info) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!Info->Node) - { - /* - * Get the actual namespace node for the target object if we - * need to. Handles these cases: - * - * 1) Null node, valid pathname from root (absolute path) - * 2) Node and valid pathname (path relative to Node) - * 3) Node, Null pathname - */ - Status = AcpiNsGetNode (Info->PrefixNode, Info->RelativePathname, - ACPI_NS_NO_UPSEARCH, &Info->Node); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* - * For a method alias, we must grab the actual method node so that - * proper scoping context will be established before execution. - */ - if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) - { - Info->Node = ACPI_CAST_PTR ( - ACPI_NAMESPACE_NODE, Info->Node->Object); - } - - /* Complete the info block initialization */ - - Info->ReturnObject = NULL; - Info->NodeFlags = Info->Node->Flags; - Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node); - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - Info->RelativePathname, Info->Node, - AcpiNsGetAttachedObject (Info->Node))); - - /* Get info if we have a predefined name (_HID, etc.) */ - - Info->Predefined = AcpiUtMatchPredefinedMethod (Info->Node->Name.Ascii); - - /* Get the full pathname to the object, for use in warning messages */ - - Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE); - if (!Info->FullPathname) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Count the number of arguments being passed in */ - - Info->ParamCount = 0; - if (Info->Parameters) - { - while (Info->Parameters[Info->ParamCount]) - { - Info->ParamCount++; - } - - /* Warn on impossible argument count */ - - if (Info->ParamCount > ACPI_METHOD_NUM_ARGS) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS, - "Excess arguments (%u) - using only %u", - Info->ParamCount, ACPI_METHOD_NUM_ARGS)); - - Info->ParamCount = ACPI_METHOD_NUM_ARGS; - } - } - - /* - * For predefined names: Check that the declared argument count - * matches the ACPI spec -- otherwise this is a BIOS error. - */ - AcpiNsCheckAcpiCompliance (Info->FullPathname, Info->Node, - Info->Predefined); - - /* - * For all names: Check that the incoming argument count for - * this method/object matches the actual ASL/AML definition. - */ - AcpiNsCheckArgumentCount (Info->FullPathname, Info->Node, - Info->ParamCount, Info->Predefined); - - /* For predefined names: Typecheck all incoming arguments */ - - AcpiNsCheckArgumentTypes (Info); - - /* - * Three major evaluation cases: - * - * 1) Object types that cannot be evaluated by definition - * 2) The object is a control method -- execute it - * 3) The object is not a method -- just return it's current value - */ - switch (AcpiNsGetType (Info->Node)) - { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_EVENT: - case ACPI_TYPE_MUTEX: - case ACPI_TYPE_REGION: - case ACPI_TYPE_THERMAL: - case ACPI_TYPE_LOCAL_SCOPE: - /* - * 1) Disallow evaluation of certain object types. For these, - * object evaluation is undefined and not supported. - */ - ACPI_ERROR ((AE_INFO, - "%s: Evaluation of object type [%s] is not supported", - Info->FullPathname, - AcpiUtGetTypeName (Info->Node->Type))); - - Status = AE_TYPE; - goto Cleanup; - - case ACPI_TYPE_METHOD: - /* - * 2) Object is a control method - execute it - */ - - /* Verify that there is a method object associated with this node */ - - if (!Info->ObjDesc) - { - ACPI_ERROR ((AE_INFO, "%s: Method has no attached sub-object", - Info->FullPathname)); - Status = AE_NULL_OBJECT; - goto Cleanup; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Execute method [%s] at AML address %p length %X\n", - Info->FullPathname, - Info->ObjDesc->Method.AmlStart + 1, - Info->ObjDesc->Method.AmlLength - 1)); - - /* - * 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. - * - * Execute the method via the interpreter. The interpreter is locked - * here before calling into the AML parser - */ - AcpiExEnterInterpreter (); - Status = AcpiPsExecuteMethod (Info); - AcpiExExitInterpreter (); - break; - - default: - /* - * 3) All other non-method objects -- get the current object value - */ - - /* - * Some objects require additional resolution steps (e.g., the Node - * may be a field that must be read, etc.) -- we can't just grab - * the object out of the node. - * - * Use ResolveNodeToValue() to get the associated value. - * - * NOTE: we can get away with passing in NULL for a walk state because - * the Node is guaranteed to not be a reference to either a method - * local or a method argument (because this interface is never called - * from a running method.) - * - * Even though we do not directly invoke the interpreter for object - * resolution, we must lock it because we could access an OpRegion. - * The OpRegion access code assumes that the interpreter is locked. - */ - AcpiExEnterInterpreter (); - - /* TBD: ResolveNodeToValue has a strange interface, fix */ - - Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->Node); - - Status = AcpiExResolveNodeToValue (ACPI_CAST_INDIRECT_PTR ( - ACPI_NAMESPACE_NODE, &Info->ReturnObject), NULL); - AcpiExExitInterpreter (); - - if (ACPI_FAILURE (Status)) - { - Info->ReturnObject = NULL; - goto Cleanup; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returned object %p [%s]\n", - Info->ReturnObject, - AcpiUtGetObjectTypeName (Info->ReturnObject))); - - Status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */ - break; - } - - /* - * For predefined names, check the return value against the ACPI - * specification. Some incorrect return value types are repaired. - */ - (void) AcpiNsCheckReturnValue (Info->Node, Info, Info->ParamCount, - Status, &Info->ReturnObject); - - /* Check if there is a return value that must be dealt with */ - - if (Status == AE_CTRL_RETURN_VALUE) - { - /* If caller does not want the return value, delete it */ - - if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) - { - AcpiUtRemoveReference (Info->ReturnObject); - Info->ReturnObject = NULL; - } - - /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ - - Status = AE_OK; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "*** Completed evaluation of object %s ***\n", - Info->RelativePathname)); - -Cleanup: - /* - * Namespace was unlocked by the handling AcpiNs* function, so we - * just free the pathname and return - */ - ACPI_FREE (Info->FullPathname); - Info->FullPathname = NULL; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsExecModuleCodeList - * - * PARAMETERS: None - * - * RETURN: None. Exceptions during method execution are ignored, since - * we cannot abort a table load. - * - * DESCRIPTION: Execute all elements of the global module-level code list. - * Each element is executed as a single control method. - * - ******************************************************************************/ - -void -AcpiNsExecModuleCodeList ( - void) -{ - ACPI_OPERAND_OBJECT *Prev; - ACPI_OPERAND_OBJECT *Next; - ACPI_EVALUATE_INFO *Info; - UINT32 MethodCount = 0; - - - ACPI_FUNCTION_TRACE (NsExecModuleCodeList); - - - /* Exit now if the list is empty */ - - Next = AcpiGbl_ModuleCodeList; - if (!Next) - { - return_VOID; - } - - /* Allocate the evaluation information block */ - - Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); - if (!Info) - { - return_VOID; - } - - /* Walk the list, executing each "method" */ - - while (Next) - { - Prev = Next; - Next = Next->Method.Mutex; - - /* Clear the link field and execute the method */ - - Prev->Method.Mutex = NULL; - AcpiNsExecModuleCode (Prev, Info); - MethodCount++; - - /* Delete the (temporary) method object */ - - AcpiUtRemoveReference (Prev); - } - - ACPI_INFO (( - "Executed %u blocks of module-level executable AML code", - MethodCount)); - - ACPI_FREE (Info); - AcpiGbl_ModuleCodeList = NULL; - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsExecModuleCode - * - * PARAMETERS: MethodObj - Object container for the module-level code - * Info - Info block for method evaluation - * - * RETURN: None. Exceptions during method execution are ignored, since - * we cannot abort a table load. - * - * DESCRIPTION: Execute a control method containing a block of module-level - * executable AML code. The control method is temporarily - * installed to the root node, then evaluated. - * - ******************************************************************************/ - -static void -AcpiNsExecModuleCode ( - ACPI_OPERAND_OBJECT *MethodObj, - ACPI_EVALUATE_INFO *Info) -{ - ACPI_OPERAND_OBJECT *ParentObj; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_OBJECT_TYPE Type; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsExecModuleCode); - - - /* - * Get the parent node. We cheat by using the NextObject field - * of the method object descriptor. - */ - ParentNode = ACPI_CAST_PTR ( - ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject); - Type = AcpiNsGetType (ParentNode); - - /* - * Get the region handler and save it in the method object. We may need - * this if an operation region declaration causes a _REG method to be run. - * - * We can't do this in AcpiPsLinkModuleCode because - * AcpiGbl_RootNode->Object is NULL at PASS1. - */ - if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) - { - MethodObj->Method.Dispatch.Handler = - ParentNode->Object->Device.Handler; - } - - /* Must clear NextObject (AcpiNsAttachObject needs the field) */ - - MethodObj->Method.NextObject = NULL; - - /* Initialize the evaluation information block */ - - memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = ParentNode; - - /* - * Get the currently attached parent object. Add a reference, - * because the ref count will be decreased when the method object - * is installed to the parent node. - */ - ParentObj = AcpiNsGetAttachedObject (ParentNode); - if (ParentObj) - { - AcpiUtAddReference (ParentObj); - } - - /* Install the method (module-level code) in the parent node */ - - Status = AcpiNsAttachObject (ParentNode, MethodObj, ACPI_TYPE_METHOD); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* Execute the parent node as a control method */ - - Status = AcpiNsEvaluate (Info); - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES, - "Executed module-level code at %p\n", - MethodObj->Method.AmlStart)); - - /* Delete a possible implicit return value (in slack mode) */ - - if (Info->ReturnObject) - { - AcpiUtRemoveReference (Info->ReturnObject); - } - - /* Detach the temporary method object */ - - AcpiNsDetachObject (ParentNode); - - /* Restore the original parent object */ - - if (ParentObj) - { - Status = AcpiNsAttachObject (ParentNode, ParentObj, Type); - } - else - { - ParentNode->Type = (UINT8) Type; - } - -Exit: - if (ParentObj) - { - AcpiUtRemoveReference (ParentObj); - } - return_VOID; -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsinit.c b/usr/src/uts/intel/io/acpica/namespace/nsinit.c deleted file mode 100644 index dbe6c7c09f..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsinit.c +++ /dev/null @@ -1,719 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsinit - namespace initialization - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acevents.h" - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsinit") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiNsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiNsInitOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiNsFindIniMethods ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInitializeObjects - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Walk the entire namespace and perform any necessary - * initialization on the objects found therein - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsInitializeObjects ( - void) -{ - ACPI_STATUS Status; - ACPI_INIT_WALK_INFO Info; - - - ACPI_FUNCTION_TRACE (NsInitializeObjects); - - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Completing Region/Field/Buffer/Package initialization:\n")); - - /* Set all init info to zero */ - - memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); - - /* Walk entire namespace from the supplied root */ - - Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, - &Info, NULL); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - " Initialized %u/%u Regions %u/%u Fields %u/%u " - "Buffers %u/%u Packages (%u nodes)\n", - Info.OpRegionInit, Info.OpRegionCount, - Info.FieldInit, Info.FieldCount, - Info.BufferInit, Info.BufferCount, - Info.PackageInit, Info.PackageCount, Info.ObjectCount)); - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%u Control Methods found\n%u Op Regions found\n", - Info.MethodCount, Info.OpRegionCount)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInitializeDevices - * - * PARAMETERS: None - * - * RETURN: ACPI_STATUS - * - * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. - * This means running _INI on all present devices. - * - * Note: We install PCI config space handler on region access, - * not here. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsInitializeDevices ( - UINT32 Flags) -{ - ACPI_STATUS Status = AE_OK; - ACPI_DEVICE_WALK_INFO Info; - ACPI_HANDLE Handle; - - - ACPI_FUNCTION_TRACE (NsInitializeDevices); - - - if (!(Flags & ACPI_NO_DEVICE_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI Devices\n")); - - /* Init counters */ - - Info.DeviceCount = 0; - Info.Num_STA = 0; - Info.Num_INI = 0; - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Initializing Device/Processor/Thermal objects " - "and executing _INI/_STA methods:\n")); - - /* Tree analysis: find all subtrees that contain _INI methods */ - - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* Allocate the evaluation information block */ - - Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); - if (!Info.EvaluateInfo) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } - - /* - * Execute the "global" _INI method that may appear at the root. - * This support is provided for Windows compatibility (Vista+) and - * is not part of the ACPI specification. - */ - Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; - Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; - Info.EvaluateInfo->Parameters = NULL; - Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; - - Status = AcpiNsEvaluate (Info.EvaluateInfo); - if (ACPI_SUCCESS (Status)) - { - Info.Num_INI++; - } - - /* - * Execute \_SB._INI. - * There appears to be a strict order requirement for \_SB._INI, - * which should be evaluated before any _REG evaluations. - */ - Status = AcpiGetHandle (NULL, "\\_SB", &Handle); - if (ACPI_SUCCESS (Status)) - { - memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); - Info.EvaluateInfo->PrefixNode = Handle; - Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; - Info.EvaluateInfo->Parameters = NULL; - Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; - - Status = AcpiNsEvaluate (Info.EvaluateInfo); - if (ACPI_SUCCESS (Status)) - { - Info.Num_INI++; - } - } - } - - /* - * Run all _REG methods - * - * Note: Any objects accessed by the _REG methods will be automatically - * initialized, even if they contain executable AML (see the call to - * AcpiNsInitializeObjects below). - * - * Note: According to the ACPI specification, we actually needn't execute - * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config - * operation regions, it is required to evaluate _REG for those on a PCI - * root bus that doesn't contain _BBN object. So this code is kept here - * in order not to break things. - */ - if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Executing _REG OpRegion methods\n")); - - Status = AcpiEvInitializeOpRegions (); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - } - - if (!(Flags & ACPI_NO_DEVICE_INIT)) - { - /* Walk namespace to execute all _INIs on present devices */ - - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); - - /* - * Any _OSI requests should be completed by now. If the BIOS has - * requested any Windows OSI strings, we will always truncate - * I/O addresses to 16 bits -- for Windows compatibility. - */ - if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) - { - AcpiGbl_TruncateIoAddresses = TRUE; - } - - ACPI_FREE (Info.EvaluateInfo); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - " Executed %u _INI methods requiring %u _STA executions " - "(examined %u objects)\n", - Info.Num_INI, Info.Num_STA, Info.DeviceCount)); - } - - return_ACPI_STATUS (Status); - - -ErrorExit: - ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInitOneObject - * - * PARAMETERS: ObjHandle - Node - * Level - Current nesting level - * Context - Points to a init info struct - * ReturnValue - Not used - * - * RETURN: Status - * - * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object - * within the namespace. - * - * Currently, the only objects that require initialization are: - * 1) Methods - * 2) Op Regions - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - ACPI_OBJECT_TYPE Type; - ACPI_STATUS Status = AE_OK; - ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_NAME (NsInitOneObject); - - - Info->ObjectCount++; - - /* And even then, we are only interested in a few object types */ - - Type = AcpiNsGetType (ObjHandle); - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc) - { - return (AE_OK); - } - - /* Increment counters for object types we are looking for */ - - switch (Type) - { - case ACPI_TYPE_REGION: - - Info->OpRegionCount++; - break; - - case ACPI_TYPE_BUFFER_FIELD: - - Info->FieldCount++; - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - Info->FieldCount++; - break; - - case ACPI_TYPE_BUFFER: - - Info->BufferCount++; - break; - - case ACPI_TYPE_PACKAGE: - - Info->PackageCount++; - break; - - default: - - /* No init required, just exit now */ - - return (AE_OK); - } - - /* If the object is already initialized, nothing else to do */ - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - return (AE_OK); - } - - /* Must lock the interpreter before executing AML code */ - - AcpiExEnterInterpreter (); - - /* - * Each of these types can contain executable AML code within the - * declaration. - */ - switch (Type) - { - case ACPI_TYPE_REGION: - - Info->OpRegionInit++; - Status = AcpiDsGetRegionArguments (ObjDesc); - break; - - case ACPI_TYPE_BUFFER_FIELD: - - Info->FieldInit++; - Status = AcpiDsGetBufferFieldArguments (ObjDesc); - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - - Info->FieldInit++; - Status = AcpiDsGetBankFieldArguments (ObjDesc); - break; - - case ACPI_TYPE_BUFFER: - - Info->BufferInit++; - Status = AcpiDsGetBufferArguments (ObjDesc); - break; - - case ACPI_TYPE_PACKAGE: - - Info->PackageInit++; - Status = AcpiDsGetPackageArguments (ObjDesc); - break; - - default: - - /* No other types can get here */ - - break; - } - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not execute arguments for [%4.4s] (%s)", - AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); - } - - /* - * We ignore errors from above, and always return OK, since we don't want - * to abort the walk on any single error. - */ - AcpiExExitInterpreter (); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsFindIniMethods - * - * PARAMETERS: ACPI_WALK_CALLBACK - * - * RETURN: ACPI_STATUS - * - * DESCRIPTION: Called during namespace walk. Finds objects named _INI under - * device/processor/thermal objects, and marks the entire subtree - * with a SUBTREE_HAS_INI flag. This flag is used during the - * subsequent device initialization walk to avoid entire subtrees - * that do not contain an _INI. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsFindIniMethods ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); - ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *ParentNode; - - - /* Keep count of device/processor/thermal objects */ - - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - if ((Node->Type == ACPI_TYPE_DEVICE) || - (Node->Type == ACPI_TYPE_PROCESSOR) || - (Node->Type == ACPI_TYPE_THERMAL)) - { - Info->DeviceCount++; - return (AE_OK); - } - - /* We are only looking for methods named _INI */ - - if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI)) - { - return (AE_OK); - } - - /* - * The only _INI methods that we care about are those that are - * present under Device, Processor, and Thermal objects. - */ - ParentNode = Node->Parent; - switch (ParentNode->Type) - { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - - /* Mark parent and bubble up the INI present flag to the root */ - - while (ParentNode) - { - ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; - ParentNode = ParentNode->Parent; - } - break; - - default: - - break; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInitOneDevice - * - * PARAMETERS: ACPI_WALK_CALLBACK - * - * RETURN: ACPI_STATUS - * - * DESCRIPTION: This is called once per device soon after ACPI is enabled - * to initialize each device. It determines if the device is - * present, and if so, calls _INI. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsInitOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); - ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; - UINT32 Flags; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *DeviceNode; - - - ACPI_FUNCTION_TRACE (NsInitOneDevice); - - - /* We are interested in Devices, Processors and ThermalZones only */ - - DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && - (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && - (DeviceNode->Type != ACPI_TYPE_THERMAL)) - { - return_ACPI_STATUS (AE_OK); - } - - /* - * Because of an earlier namespace analysis, all subtrees that contain an - * _INI method are tagged. - * - * If this device subtree does not contain any _INI methods, we - * can exit now and stop traversing this entire subtree. - */ - if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) - { - return_ACPI_STATUS (AE_CTRL_DEPTH); - } - - /* - * Run _STA to determine if this device is present and functioning. We - * must know this information for two important reasons (from ACPI spec): - * - * 1) We can only run _INI if the device is present. - * 2) We must abort the device tree walk on this subtree if the device is - * not present and is not functional (we will not examine the children) - * - * The _STA method is not required to be present under the device, we - * assume the device is present if _STA does not exist. - */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); - - Status = AcpiUtExecute_STA (DeviceNode, &Flags); - if (ACPI_FAILURE (Status)) - { - /* Ignore error and move on to next device */ - - return_ACPI_STATUS (AE_OK); - } - - /* - * Flags == -1 means that _STA was not found. In this case, we assume that - * the device is both present and functional. - * - * From the ACPI spec, description of _STA: - * - * "If a device object (including the processor object) does not have an - * _STA object, then OSPM assumes that all of the above bits are set (in - * other words, the device is present, ..., and functioning)" - */ - if (Flags != ACPI_UINT32_MAX) - { - WalkInfo->Num_STA++; - } - - /* - * Examine the PRESENT and FUNCTIONING status bits - * - * Note: ACPI spec does not seem to specify behavior for the present but - * not functioning case, so we assume functioning if present. - */ - if (!(Flags & ACPI_STA_DEVICE_PRESENT)) - { - /* Device is not present, we must examine the Functioning bit */ - - if (Flags & ACPI_STA_DEVICE_FUNCTIONING) - { - /* - * Device is not present but is "functioning". In this case, - * we will not run _INI, but we continue to examine the children - * of this device. - * - * From the ACPI spec, description of _STA: (Note - no mention - * of whether to run _INI or not on the device in question) - * - * "_STA may return bit 0 clear (not present) with bit 3 set - * (device is functional). This case is used to indicate a valid - * device for which no device driver should be loaded (for example, - * a bridge device.) Children of this device may be present and - * valid. OSPM should continue enumeration below a device whose - * _STA returns this bit combination" - */ - return_ACPI_STATUS (AE_OK); - } - else - { - /* - * Device is not present and is not functioning. We must abort the - * walk of this subtree immediately -- don't look at the children - * of such a device. - * - * From the ACPI spec, description of _INI: - * - * "If the _STA method indicates that the device is not present, - * OSPM will not run the _INI and will not examine the children - * of the device for _INI methods" - */ - return_ACPI_STATUS (AE_CTRL_DEPTH); - } - } - - /* - * The device is present or is assumed present if no _STA exists. - * Run the _INI if it exists (not required to exist) - * - * Note: We know there is an _INI within this subtree, but it may not be - * under this particular device, it may be lower in the branch. - */ - if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") || - DeviceNode->Parent != AcpiGbl_RootNode) - { - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - - memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = DeviceNode; - Info->RelativePathname = METHOD_NAME__INI; - Info->Parameters = NULL; - Info->Flags = ACPI_IGNORE_RETURN_VALUE; - - Status = AcpiNsEvaluate (Info); - if (ACPI_SUCCESS (Status)) - { - WalkInfo->Num_INI++; - } - -#ifdef ACPI_DEBUG_OUTPUT - else if (Status != AE_NOT_FOUND) - { - /* Ignore error and move on to next device */ - - char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); - - ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", - ScopeName)); - ACPI_FREE (ScopeName); - } -#endif - } - - /* Ignore errors from above */ - - Status = AE_OK; - - /* - * The _INI method has been run if present; call the Global Initialization - * Handler for this device. - */ - if (AcpiGbl_InitHandler) - { - Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); - } - - return_ACPI_STATUS (Status); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsload.c b/usr/src/uts/intel/io/acpica/namespace/nsload.c deleted file mode 100644 index 9c899e7846..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsload.c +++ /dev/null @@ -1,384 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsload - namespace loading/expanding/contracting procedures - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acdispat.h" -#include "actables.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsload") - -/* Local prototypes */ - -#ifdef ACPI_FUTURE_IMPLEMENTATION -ACPI_STATUS -AcpiNsUnloadNamespace ( - ACPI_HANDLE Handle); - -static ACPI_STATUS -AcpiNsDeleteSubtree ( - ACPI_HANDLE StartHandle); -#endif - - -#ifndef ACPI_NO_METHOD_EXECUTION -/******************************************************************************* - * - * FUNCTION: AcpiNsLoadTable - * - * PARAMETERS: TableIndex - Index for table to be loaded - * Node - Owning NS node - * - * RETURN: Status - * - * DESCRIPTION: Load one ACPI table into the namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsLoadTable ( - UINT32 TableIndex, - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsLoadTable); - - - /* - * Parse the table and load the namespace with all named - * objects found within. Control methods are NOT parsed - * at this time. In fact, the control methods cannot be - * parsed until the entire namespace is loaded, because - * if a control method makes a forward reference (call) - * to another control method, we can't continue parsing - * because we don't know how many arguments to parse next! - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* If table already loaded into namespace, just return */ - - if (AcpiTbIsTableLoaded (TableIndex)) - { - Status = AE_ALREADY_EXISTS; - goto Unlock; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Loading table into namespace ****\n")); - - Status = AcpiTbAllocateOwnerId (TableIndex); - if (ACPI_FAILURE (Status)) - { - goto Unlock; - } - - Status = AcpiNsParseTable (TableIndex, Node); - if (ACPI_SUCCESS (Status)) - { - AcpiTbSetTableLoadedFlag (TableIndex, TRUE); - } - else - { - /* - * On error, delete any namespace objects created by this table. - * We cannot initialize these objects, so delete them. There are - * a couple of expecially bad cases: - * AE_ALREADY_EXISTS - namespace collision. - * AE_NOT_FOUND - the target of a Scope operator does not - * exist. This target of Scope must already exist in the - * namespace, as per the ACPI specification. - */ - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - AcpiNsDeleteNamespaceByOwner ( - AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); - - AcpiTbReleaseOwnerId (TableIndex); - return_ACPI_STATUS (Status); - } - -Unlock: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Now we can parse the control methods. We always parse - * them here for a sanity check, and if configured for - * just-in-time parsing, we delete the control method - * parse trees. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Begin Table Object Initialization\n")); - - Status = AcpiDsInitializeObjects (TableIndex, Node); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Completed Table Object Initialization\n")); - - /* - * Execute any module-level code that was detected during the table load - * phase. Although illegal since ACPI 2.0, there are many machines that - * contain this type of code. Each block of detected executable AML code - * outside of any control method is wrapped with a temporary control - * method object and placed on a global list. The methods on this list - * are executed below. - * - * This case executes the module-level code for each table immediately - * after the table has been loaded. This provides compatibility with - * other ACPI implementations. Optionally, the execution can be deferred - * until later, see AcpiInitializeObjects. - */ - if (!AcpiGbl_GroupModuleLevelCode) - { - AcpiNsExecModuleCodeList (); - } - - return_ACPI_STATUS (Status); -} - - -#ifdef ACPI_OBSOLETE_FUNCTIONS -/******************************************************************************* - * - * FUNCTION: AcpiLoadNamespace - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. - * (DSDT points to either the BIOS or a buffer.) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsLoadNamespace ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiLoadNameSpace); - - - /* There must be at least a DSDT installed */ - - if (AcpiGbl_DSDT == NULL) - { - ACPI_ERROR ((AE_INFO, "DSDT is not in memory")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* - * Load the namespace. The DSDT is required, - * but the SSDT and PSDT tables are optional. - */ - Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Ignore exceptions from these */ - - (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT); - (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT); - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "ACPI Namespace successfully loaded at root %p\n", - AcpiGbl_RootNode)); - - return_ACPI_STATUS (Status); -} -#endif - -#ifdef ACPI_FUTURE_IMPLEMENTATION -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteSubtree - * - * PARAMETERS: StartHandle - Handle in namespace where search begins - * - * RETURNS Status - * - * DESCRIPTION: Walks the namespace starting at the given handle and deletes - * all objects, entries, and scopes in the entire subtree. - * - * Namespace/Interpreter should be locked or the subsystem should - * be in shutdown before this routine is called. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsDeleteSubtree ( - ACPI_HANDLE StartHandle) -{ - ACPI_STATUS Status; - ACPI_HANDLE ChildHandle; - ACPI_HANDLE ParentHandle; - ACPI_HANDLE NextChildHandle; - ACPI_HANDLE Dummy; - UINT32 Level; - - - ACPI_FUNCTION_TRACE (NsDeleteSubtree); - - - ParentHandle = StartHandle; - ChildHandle = NULL; - Level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - while (Level > 0) - { - /* Attempt to get the next object in this scope */ - - Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, - ChildHandle, &NextChildHandle); - - ChildHandle = NextChildHandle; - - /* Did we get a new object? */ - - if (ACPI_SUCCESS (Status)) - { - /* Check if this object has any children */ - - if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, - NULL, &Dummy))) - { - /* - * There is at least one child of this object, - * visit the object - */ - Level++; - ParentHandle = ChildHandle; - ChildHandle = NULL; - } - } - else - { - /* - * No more children in this object, go back up to - * the object's parent - */ - Level--; - - /* Delete all children now */ - - AcpiNsDeleteChildren (ChildHandle); - - ChildHandle = ParentHandle; - Status = AcpiGetParent (ParentHandle, &ParentHandle); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - - /* Now delete the starting object, and we are done */ - - AcpiNsRemoveNode (ChildHandle); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsUnloadNameSpace - * - * PARAMETERS: Handle - Root of namespace subtree to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Shrinks the namespace, typically in response to an undocking - * event. Deletes an entire subtree starting from (and - * including) the given handle. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsUnloadNamespace ( - ACPI_HANDLE Handle) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsUnloadNameSpace); - - - /* Parameter validation */ - - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - if (!Handle) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* This function does the real work */ - - Status = AcpiNsDeleteSubtree (Handle); - return_ACPI_STATUS (Status); -} -#endif -#endif diff --git a/usr/src/uts/intel/io/acpica/namespace/nsnames.c b/usr/src/uts/intel/io/acpica/namespace/nsnames.c deleted file mode 100644 index 95f8c8db97..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsnames.c +++ /dev/null @@ -1,346 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsnames - Name manipulation and search - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsnames") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetExternalPathname - * - * PARAMETERS: Node - Namespace node whose pathname is needed - * - * RETURN: Pointer to storage containing the fully qualified name of - * the node, In external format (name segments separated by path - * separators.) - * - * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually - * for error and debug statements. - * - ******************************************************************************/ - -char * -AcpiNsGetExternalPathname ( - ACPI_NAMESPACE_NODE *Node) -{ - char *NameBuffer; - - - ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); - - - NameBuffer = AcpiNsGetNormalizedPathname (Node, FALSE); - return_PTR (NameBuffer); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetPathnameLength - * - * PARAMETERS: Node - Namespace node - * - * RETURN: Length of path, including prefix - * - * DESCRIPTION: Get the length of the pathname string for this node - * - ******************************************************************************/ - -ACPI_SIZE -AcpiNsGetPathnameLength ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_SIZE Size; - - - ACPI_FUNCTION_ENTRY (); - - - Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, FALSE); - return (Size); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsHandleToPathname - * - * PARAMETERS: TargetHandle - Handle of named object whose name is - * to be found - * Buffer - Where the pathname is returned - * NoTrailing - Remove trailing '_' for each name - * segment - * - * RETURN: Status, Buffer is filled with pathname if status is AE_OK - * - * DESCRIPTION: Build and return a full namespace pathname - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsHandleToPathname ( - ACPI_HANDLE TargetHandle, - ACPI_BUFFER *Buffer, - BOOLEAN NoTrailing) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_SIZE RequiredSize; - - - ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); - - - Node = AcpiNsValidateHandle (TargetHandle); - if (!Node) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Determine size required for the caller buffer */ - - RequiredSize = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); - if (!RequiredSize) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (Buffer, RequiredSize); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Build the path in the caller buffer */ - - (void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer, - RequiredSize, NoTrailing); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", - (char *) Buffer->Pointer, (UINT32) RequiredSize)); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsBuildNormalizedPath - * - * PARAMETERS: Node - Namespace node - * FullPath - Where the path name is returned - * PathSize - Size of returned path name buffer - * NoTrailing - Remove trailing '_' from each name segment - * - * RETURN: Return 1 if the AML path is empty, otherwise returning (length - * of pathname + 1) which means the 'FullPath' contains a trailing - * null. - * - * DESCRIPTION: Build and return a full namespace pathname. - * Note that if the size of 'FullPath' isn't large enough to - * contain the namespace node's path name, the actual required - * buffer length is returned, and it should be greater than - * 'PathSize'. So callers are able to check the returning value - * to determine the buffer size of 'FullPath'. - * - ******************************************************************************/ - -UINT32 -AcpiNsBuildNormalizedPath ( - ACPI_NAMESPACE_NODE *Node, - char *FullPath, - UINT32 PathSize, - BOOLEAN NoTrailing) -{ - UINT32 Length = 0, i; - char Name[ACPI_NAME_SIZE]; - BOOLEAN DoNoTrailing; - char c, *Left, *Right; - ACPI_NAMESPACE_NODE *NextNode; - - - ACPI_FUNCTION_TRACE_PTR (NsBuildNormalizedPath, Node); - - -#define ACPI_PATH_PUT8(Path, Size, Byte, Length) \ - do { \ - if ((Length) < (Size)) \ - { \ - (Path)[(Length)] = (Byte); \ - } \ - (Length)++; \ - } while (0) - - /* - * Make sure the PathSize is correct, so that we don't need to - * validate both FullPath and PathSize. - */ - if (!FullPath) - { - PathSize = 0; - } - - if (!Node) - { - goto BuildTrailingNull; - } - - NextNode = Node; - while (NextNode && NextNode != AcpiGbl_RootNode) - { - if (NextNode != Node) - { - ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length); - } - - ACPI_MOVE_32_TO_32 (Name, &NextNode->Name); - DoNoTrailing = NoTrailing; - for (i = 0; i < 4; i++) - { - c = Name[4-i-1]; - if (DoNoTrailing && c != '_') - { - DoNoTrailing = FALSE; - } - if (!DoNoTrailing) - { - ACPI_PATH_PUT8(FullPath, PathSize, c, Length); - } - } - - NextNode = NextNode->Parent; - } - - ACPI_PATH_PUT8(FullPath, PathSize, AML_ROOT_PREFIX, Length); - - /* Reverse the path string */ - - if (Length <= PathSize) - { - Left = FullPath; - Right = FullPath+Length - 1; - - while (Left < Right) - { - c = *Left; - *Left++ = *Right; - *Right-- = c; - } - } - - /* Append the trailing null */ - -BuildTrailingNull: - ACPI_PATH_PUT8 (FullPath, PathSize, '\0', Length); - -#undef ACPI_PATH_PUT8 - - return_UINT32 (Length); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetNormalizedPathname - * - * PARAMETERS: Node - Namespace node whose pathname is needed - * NoTrailing - Remove trailing '_' from each name segment - * - * RETURN: Pointer to storage containing the fully qualified name of - * the node, In external format (name segments separated by path - * separators.) - * - * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually - * for error and debug statements. All trailing '_' will be - * removed from the full pathname if 'NoTrailing' is specified.. - * - ******************************************************************************/ - -char * -AcpiNsGetNormalizedPathname ( - ACPI_NAMESPACE_NODE *Node, - BOOLEAN NoTrailing) -{ - char *NameBuffer; - ACPI_SIZE Size; - - - ACPI_FUNCTION_TRACE_PTR (NsGetNormalizedPathname, Node); - - - /* Calculate required buffer size based on depth below root */ - - Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); - if (!Size) - { - return_PTR (NULL); - } - - /* Allocate a buffer to be returned to caller */ - - NameBuffer = ACPI_ALLOCATE_ZEROED (Size); - if (!NameBuffer) - { - ACPI_ERROR ((AE_INFO, - "Could not allocate %u bytes", (UINT32) Size)); - return_PTR (NULL); - } - - /* Build the path in the allocated buffer */ - - (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing); - - return_PTR (NameBuffer); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsobject.c b/usr/src/uts/intel/io/acpica/namespace/nsobject.c deleted file mode 100644 index cf2436155b..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsobject.c +++ /dev/null @@ -1,515 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsobject - Utilities for objects attached to namespace - * table entries - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsobject") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsAttachObject - * - * PARAMETERS: Node - Parent Node - * Object - Object to be attached - * Type - Type of object, or ACPI_TYPE_ANY if not - * known - * - * RETURN: Status - * - * DESCRIPTION: Record the given object as the value associated with the - * name whose ACPI_HANDLE is passed. If Object is NULL - * and Type is ACPI_TYPE_ANY, set the name as having no value. - * Note: Future may require that the Node->Flags field be passed - * as a parameter. - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsAttachObject ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT *Object, - ACPI_OBJECT_TYPE Type) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *LastObjDesc; - ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; - - - ACPI_FUNCTION_TRACE (NsAttachObject); - - - /* - * Parameter validation - */ - if (!Node) - { - /* Invalid handle */ - - ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!Object && (ACPI_TYPE_ANY != Type)) - { - /* Null object */ - - ACPI_ERROR ((AE_INFO, - "Null object, but type not ACPI_TYPE_ANY")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) - { - /* Not a name handle */ - - ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", - Node, AcpiUtGetDescriptorName (Node))); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Check if this object is already attached */ - - if (Node->Object == Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj %p already installed in NameObj %p\n", - Object, Node)); - - return_ACPI_STATUS (AE_OK); - } - - /* If null object, we will just install it */ - - if (!Object) - { - ObjDesc = NULL; - ObjectType = ACPI_TYPE_ANY; - } - - /* - * If the source object is a namespace Node with an attached object, - * we will use that (attached) object - */ - else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && - ((ACPI_NAMESPACE_NODE *) Object)->Object) - { - /* - * Value passed is a name handle and that name has a - * non-null value. Use that name's value and type. - */ - ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; - ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; - } - - /* - * Otherwise, we will use the parameter object, but we must type - * it first - */ - else - { - ObjDesc = (ACPI_OPERAND_OBJECT *) Object; - - /* Use the given type */ - - ObjectType = Type; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", - ObjDesc, Node, AcpiUtGetNodeName (Node))); - - /* Detach an existing attached object if present */ - - if (Node->Object) - { - AcpiNsDetachObject (Node); - } - - if (ObjDesc) - { - /* - * Must increment the new value's reference count - * (if it is an internal object) - */ - AcpiUtAddReference (ObjDesc); - - /* - * Handle objects with multiple descriptors - walk - * to the end of the descriptor list - */ - LastObjDesc = ObjDesc; - while (LastObjDesc->Common.NextObject) - { - LastObjDesc = LastObjDesc->Common.NextObject; - } - - /* Install the object at the front of the object list */ - - LastObjDesc->Common.NextObject = Node->Object; - } - - Node->Type = (UINT8) ObjectType; - Node->Object = ObjDesc; - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDetachObject - * - * PARAMETERS: Node - A Namespace node whose object will be detached - * - * RETURN: None. - * - * DESCRIPTION: Detach/delete an object associated with a namespace node. - * if the object is an allocated object, it is freed. - * Otherwise, the field is simply cleared. - * - ******************************************************************************/ - -void -AcpiNsDetachObject ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE (NsDetachObject); - - - ObjDesc = Node->Object; - - if (!ObjDesc || - (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - return_VOID; - } - - if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) - { - /* Free the dynamic aml buffer */ - - if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) - { - ACPI_FREE (ObjDesc->Method.AmlStart); - } - } - - /* Clear the Node entry in all cases */ - - Node->Object = NULL; - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) - { - /* Unlink object from front of possible object list */ - - Node->Object = ObjDesc->Common.NextObject; - - /* Handle possible 2-descriptor object */ - - if (Node->Object && - (Node->Object->Common.Type != ACPI_TYPE_LOCAL_DATA)) - { - Node->Object = Node->Object->Common.NextObject; - } - - /* - * Detach the object from any data objects (which are still held by - * the namespace node) - */ - if (ObjDesc->Common.NextObject && - ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - ObjDesc->Common.NextObject = NULL; - } - } - - /* Reset the node type to untyped */ - - Node->Type = ACPI_TYPE_ANY; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", - Node, AcpiUtGetNodeName (Node), ObjDesc)); - - /* Remove one reference on the object (and all subobjects) */ - - AcpiUtRemoveReference (ObjDesc); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetAttachedObject - * - * PARAMETERS: Node - Namespace node - * - * RETURN: Current value of the object field from the Node whose - * handle is passed - * - * DESCRIPTION: Obtain the object attached to a namespace node. - * - ******************************************************************************/ - -ACPI_OPERAND_OBJECT * -AcpiNsGetAttachedObject ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); - - - if (!Node) - { - ACPI_WARNING ((AE_INFO, "Null Node ptr")); - return_PTR (NULL); - } - - if (!Node->Object || - ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || - ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - return_PTR (NULL); - } - - return_PTR (Node->Object); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetSecondaryObject - * - * PARAMETERS: Node - Namespace node - * - * RETURN: Current value of the object field from the Node whose - * handle is passed. - * - * DESCRIPTION: Obtain a secondary object associated with a namespace node. - * - ******************************************************************************/ - -ACPI_OPERAND_OBJECT * -AcpiNsGetSecondaryObject ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); - - - if ((!ObjDesc) || - (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || - (!ObjDesc->Common.NextObject) || - ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) - { - return_PTR (NULL); - } - - return_PTR (ObjDesc->Common.NextObject); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsAttachData - * - * PARAMETERS: Node - Namespace node - * Handler - Handler to be associated with the data - * Data - Data to be attached - * - * RETURN: Status - * - * DESCRIPTION: Low-level attach data. Create and attach a Data object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsAttachData ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OBJECT_HANDLER Handler, - void *Data) -{ - ACPI_OPERAND_OBJECT *PrevObjDesc; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *DataDesc; - - - /* We only allow one attachment per handler */ - - PrevObjDesc = NULL; - ObjDesc = Node->Object; - while (ObjDesc) - { - if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && - (ObjDesc->Data.Handler == Handler)) - { - return (AE_ALREADY_EXISTS); - } - - PrevObjDesc = ObjDesc; - ObjDesc = ObjDesc->Common.NextObject; - } - - /* Create an internal object for the data */ - - DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); - if (!DataDesc) - { - return (AE_NO_MEMORY); - } - - DataDesc->Data.Handler = Handler; - DataDesc->Data.Pointer = Data; - - /* Install the data object */ - - if (PrevObjDesc) - { - PrevObjDesc->Common.NextObject = DataDesc; - } - else - { - Node->Object = DataDesc; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDetachData - * - * PARAMETERS: Node - Namespace node - * Handler - Handler associated with the data - * - * RETURN: Status - * - * DESCRIPTION: Low-level detach data. Delete the data node, but the caller - * is responsible for the actual data. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsDetachData ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OBJECT_HANDLER Handler) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *PrevObjDesc; - - - PrevObjDesc = NULL; - ObjDesc = Node->Object; - while (ObjDesc) - { - if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && - (ObjDesc->Data.Handler == Handler)) - { - if (PrevObjDesc) - { - PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; - } - else - { - Node->Object = ObjDesc->Common.NextObject; - } - - AcpiUtRemoveReference (ObjDesc); - return (AE_OK); - } - - PrevObjDesc = ObjDesc; - ObjDesc = ObjDesc->Common.NextObject; - } - - return (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetAttachedData - * - * PARAMETERS: Node - Namespace node - * Handler - Handler associated with the data - * Data - Where the data is returned - * - * RETURN: Status - * - * DESCRIPTION: Low level interface to obtain data previously associated with - * a namespace node. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsGetAttachedData ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OBJECT_HANDLER Handler, - void **Data) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - - - ObjDesc = Node->Object; - while (ObjDesc) - { - if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && - (ObjDesc->Data.Handler == Handler)) - { - *Data = ObjDesc->Data.Pointer; - return (AE_OK); - } - - ObjDesc = ObjDesc->Common.NextObject; - } - - return (AE_NOT_FOUND); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsparse.c b/usr/src/uts/intel/io/acpica/namespace/nsparse.c deleted file mode 100644 index 1ff33362ed..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsparse.c +++ /dev/null @@ -1,228 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsparse - namespace interface to AML parser - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acparser.h" -#include "acdispat.h" -#include "actables.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsparse") - - -/******************************************************************************* - * - * FUNCTION: NsOneCompleteParse - * - * PARAMETERS: PassNumber - 1 or 2 - * TableDesc - The table to be parsed. - * - * RETURN: Status - * - * DESCRIPTION: Perform one complete parse of an ACPI/AML table. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsOneCompleteParse ( - UINT32 PassNumber, - UINT32 TableIndex, - ACPI_NAMESPACE_NODE *StartNode) -{ - ACPI_PARSE_OBJECT *ParseRoot; - ACPI_STATUS Status; - UINT32 AmlLength; - UINT8 *AmlStart; - ACPI_WALK_STATE *WalkState; - ACPI_TABLE_HEADER *Table; - ACPI_OWNER_ID OwnerId; - - - ACPI_FUNCTION_TRACE (NsOneCompleteParse); - - - Status = AcpiGetTableByIndex (TableIndex, &Table); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Table must consist of at least a complete header */ - - if (Table->Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_BAD_HEADER); - } - - AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); - - Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Create and init a Root Node */ - - ParseRoot = AcpiPsCreateScopeOp (AmlStart); - if (!ParseRoot) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Create and initialize a new walk state */ - - WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); - if (!WalkState) - { - AcpiPsFreeOp (ParseRoot); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, - AmlStart, AmlLength, NULL, (UINT8) PassNumber); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; - } - - /* Found OSDT table, enable the namespace override feature */ - - if (ACPI_COMPARE_NAME(Table->Signature, ACPI_SIG_OSDT) && - PassNumber == ACPI_IMODE_LOAD_PASS1) - { - WalkState->NamespaceOverride = TRUE; - } - - /* StartNode is the default location to load the table */ - - if (StartNode && StartNode != AcpiGbl_RootNode) - { - Status = AcpiDsScopeStackPush ( - StartNode, ACPI_TYPE_METHOD, WalkState); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; - } - } - - /* Parse the AML */ - - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "*PARSE* pass %u parse\n", PassNumber)); - Status = AcpiPsParseAml (WalkState); - -Cleanup: - AcpiPsDeleteParseTree (ParseRoot); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsParseTable - * - * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse - * StartNode - Where to enter the table into the namespace - * - * RETURN: Status - * - * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsParseTable ( - UINT32 TableIndex, - ACPI_NAMESPACE_NODE *StartNode) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsParseTable); - - - /* - * AML Parse, pass 1 - * - * In this pass, we load most of the namespace. Control methods - * are not parsed until later. A parse tree is not created. Instead, - * each Parser Op subtree is deleted when it is finished. This saves - * a great deal of memory, and allows a small cache of parse objects - * to service the entire parse. The second pass of the parse then - * performs another complete parse of the AML. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); - - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, - TableIndex, StartNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * AML Parse, pass 2 - * - * In this pass, we resolve forward references and other things - * that could not be completed during the first pass. - * Another complete parse of the AML is performed, but the - * overhead of this is compensated for by the fact that the - * parse objects are all cached. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, - TableIndex, StartNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - return_ACPI_STATUS (Status); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nspredef.c b/usr/src/uts/intel/io/acpica/namespace/nspredef.c deleted file mode 100644 index ccd4aba8f2..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nspredef.c +++ /dev/null @@ -1,435 +0,0 @@ -/****************************************************************************** - * - * Module Name: nspredef - Validation of ACPI predefined methods and objects - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#define ACPI_CREATE_PREDEFINED_TABLE - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acpredef.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nspredef") - - -/******************************************************************************* - * - * This module validates predefined ACPI objects that appear in the namespace, - * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this - * validation is to detect problems with BIOS-exposed predefined ACPI objects - * before the results are returned to the ACPI-related drivers. - * - * There are several areas that are validated: - * - * 1) The number of input arguments as defined by the method/object in the - * ASL is validated against the ACPI specification. - * 2) The type of the return object (if any) is validated against the ACPI - * specification. - * 3) For returned package objects, the count of package elements is - * validated, as well as the type of each package element. Nested - * packages are supported. - * - * For any problems found, a warning message is issued. - * - ******************************************************************************/ - - -/* Local prototypes */ - -static ACPI_STATUS -AcpiNsCheckReference ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT *ReturnObject); - -static UINT32 -AcpiNsGetBitmappedType ( - ACPI_OPERAND_OBJECT *ReturnObject); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckReturnValue - * - * PARAMETERS: Node - Namespace node for the method/object - * Info - Method execution information block - * UserParamCount - Number of parameters actually passed - * ReturnStatus - Status from the object evaluation - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status - * - * DESCRIPTION: Check the value returned from a predefined name. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsCheckReturnValue ( - ACPI_NAMESPACE_NODE *Node, - ACPI_EVALUATE_INFO *Info, - UINT32 UserParamCount, - ACPI_STATUS ReturnStatus, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_STATUS Status; - const ACPI_PREDEFINED_INFO *Predefined; - - - /* If not a predefined name, we cannot validate the return object */ - - Predefined = Info->Predefined; - if (!Predefined) - { - return (AE_OK); - } - - /* - * If the method failed or did not actually return an object, we cannot - * validate the return object - */ - if ((ReturnStatus != AE_OK) && - (ReturnStatus != AE_CTRL_RETURN_VALUE)) - { - return (AE_OK); - } - - /* - * Return value validation and possible repair. - * - * 1) Don't perform return value validation/repair if this feature - * has been disabled via a global option. - * - * 2) We have a return value, but if one wasn't expected, just exit, - * this is not a problem. For example, if the "Implicit Return" - * feature is enabled, methods will always return a value. - * - * 3) If the return value can be of any type, then we cannot perform - * any validation, just exit. - */ - if (AcpiGbl_DisableAutoRepair || - (!Predefined->Info.ExpectedBtypes) || - (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) - { - return (AE_OK); - } - - /* - * Check that the type of the main return object is what is expected - * for this predefined name - */ - Status = AcpiNsCheckObjectType (Info, ReturnObjectPtr, - Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - - /* - * - * 4) If there is no return value and it is optional, just return - * AE_OK (_WAK). - */ - if (!(*ReturnObjectPtr)) - { - goto Exit; - } - - /* - * For returned Package objects, check the type of all sub-objects. - * Note: Package may have been newly created by call above. - */ - if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE) - { - Info->ParentPackage = *ReturnObjectPtr; - Status = AcpiNsCheckPackage (Info, ReturnObjectPtr); - if (ACPI_FAILURE (Status)) - { - /* We might be able to fix some errors */ - - if ((Status != AE_AML_OPERAND_TYPE) && - (Status != AE_AML_OPERAND_VALUE)) - { - goto Exit; - } - } - } - - /* - * The return object was OK, or it was successfully repaired above. - * Now make some additional checks such as verifying that package - * objects are sorted correctly (if required) or buffer objects have - * the correct data width (bytes vs. dwords). These repairs are - * performed on a per-name basis, i.e., the code is specific to - * particular predefined names. - */ - Status = AcpiNsComplexRepairs (Info, Node, Status, ReturnObjectPtr); - -Exit: - /* - * If the object validation failed or if we successfully repaired one - * or more objects, mark the parent node to suppress further warning - * messages during the next evaluation of the same method/object. - */ - if (ACPI_FAILURE (Status) || - (Info->ReturnFlags & ACPI_OBJECT_REPAIRED)) - { - Node->Flags |= ANOBJ_EVALUATED; - } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckObjectType - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * ExpectedBtypes - Bitmap of expected return type(s) - * PackageIndex - Index of object within parent package (if - * applicable - ACPI_NOT_PACKAGE_ELEMENT - * otherwise) - * - * RETURN: Status - * - * DESCRIPTION: Check the type of the return object against the expected object - * type(s). Use of Btype allows multiple expected object types. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsCheckObjectType ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr, - UINT32 ExpectedBtypes, - UINT32 PackageIndex) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_STATUS Status = AE_OK; - char TypeBuffer[96]; /* Room for 10 types */ - - - /* A Namespace node should not get here, but make sure */ - - if (ReturnObject && - ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Invalid return type - Found a Namespace node [%4.4s] type %s", - ReturnObject->Node.Name.Ascii, - AcpiUtGetTypeName (ReturnObject->Node.Type))); - return (AE_AML_OPERAND_TYPE); - } - - /* - * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. - * The bitmapped type allows multiple possible return types. - * - * Note, the cases below must handle all of the possible types returned - * from all of the predefined names (including elements of returned - * packages) - */ - Info->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject); - if (Info->ReturnBtype == ACPI_RTYPE_ANY) - { - /* Not one of the supported objects, must be incorrect */ - goto TypeErrorExit; - } - - /* For reference objects, check that the reference type is correct */ - - if ((Info->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE) - { - Status = AcpiNsCheckReference (Info, ReturnObject); - return (Status); - } - - /* Attempt simple repair of the returned object if necessary */ - - Status = AcpiNsSimpleRepair (Info, ExpectedBtypes, - PackageIndex, ReturnObjectPtr); - if (ACPI_SUCCESS (Status)) - { - return (AE_OK); /* Successful repair */ - } - - -TypeErrorExit: - - /* Create a string with all expected types for this predefined object */ - - AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes); - - if (!ReturnObject) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Expected return object of type %s", - TypeBuffer)); - } - else if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return type mismatch - found %s, expected %s", - AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); - } - else - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Package type mismatch at index %u - " - "found %s, expected %s", PackageIndex, - AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); - } - - return (AE_AML_OPERAND_TYPE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckReference - * - * PARAMETERS: Info - Method execution information block - * ReturnObject - Object returned from the evaluation of a - * method or object - * - * RETURN: Status - * - * DESCRIPTION: Check a returned reference object for the correct reference - * type. The only reference type that can be returned from a - * predefined method is a named reference. All others are invalid. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsCheckReference ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT *ReturnObject) -{ - - /* - * Check the reference object for the correct reference type (opcode). - * The only type of reference that can be converted to an ACPI_OBJECT is - * a reference to a named object (reference class: NAME) - */ - if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME) - { - return (AE_OK); - } - - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return type mismatch - unexpected reference object type [%s] %2.2X", - AcpiUtGetReferenceName (ReturnObject), - ReturnObject->Reference.Class)); - - return (AE_AML_OPERAND_TYPE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetBitmappedType - * - * PARAMETERS: ReturnObject - Object returned from method/obj evaluation - * - * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object - * type is not supported. ACPI_RTYPE_NONE indicates that no - * object was returned (ReturnObject is NULL). - * - * DESCRIPTION: Convert object type into a bitmapped object return type. - * - ******************************************************************************/ - -static UINT32 -AcpiNsGetBitmappedType ( - ACPI_OPERAND_OBJECT *ReturnObject) -{ - UINT32 ReturnBtype; - - - if (!ReturnObject) - { - return (ACPI_RTYPE_NONE); - } - - /* Map ACPI_OBJECT_TYPE to internal bitmapped type */ - - switch (ReturnObject->Common.Type) - { - case ACPI_TYPE_INTEGER: - - ReturnBtype = ACPI_RTYPE_INTEGER; - break; - - case ACPI_TYPE_BUFFER: - - ReturnBtype = ACPI_RTYPE_BUFFER; - break; - - case ACPI_TYPE_STRING: - - ReturnBtype = ACPI_RTYPE_STRING; - break; - - case ACPI_TYPE_PACKAGE: - - ReturnBtype = ACPI_RTYPE_PACKAGE; - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - ReturnBtype = ACPI_RTYPE_REFERENCE; - break; - - default: - - /* Not one of the supported objects, must be incorrect */ - - ReturnBtype = ACPI_RTYPE_ANY; - break; - } - - return (ReturnBtype); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsprepkg.c b/usr/src/uts/intel/io/acpica/namespace/nsprepkg.c deleted file mode 100644 index ae75c1a018..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsprepkg.c +++ /dev/null @@ -1,788 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsprepkg - Validation of package objects for predefined names - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acpredef.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsprepkg") - - -/* Local prototypes */ - -static ACPI_STATUS -AcpiNsCheckPackageList ( - ACPI_EVALUATE_INFO *Info, - const ACPI_PREDEFINED_INFO *Package, - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count); - -static ACPI_STATUS -AcpiNsCheckPackageElements ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **Elements, - UINT8 Type1, - UINT32 Count1, - UINT8 Type2, - UINT32 Count2, - UINT32 StartIndex); - -static ACPI_STATUS -AcpiNsCustomPackage ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckPackage - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status - * - * DESCRIPTION: Check a returned package object for the correct count and - * correct type of all sub-objects. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsCheckPackage ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - const ACPI_PREDEFINED_INFO *Package; - ACPI_OPERAND_OBJECT **Elements; - ACPI_STATUS Status = AE_OK; - UINT32 ExpectedCount; - UINT32 Count; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsCheckPackage); - - - /* The package info for this name is in the next table entry */ - - Package = Info->Predefined + 1; - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "%s Validating return Package of Type %X, Count %X\n", - Info->FullPathname, Package->RetInfo.Type, - ReturnObject->Package.Count)); - - /* - * For variable-length Packages, we can safely remove all embedded - * and trailing NULL package elements - */ - AcpiNsRemoveNullElements (Info, Package->RetInfo.Type, ReturnObject); - - /* Extract package count and elements array */ - - Elements = ReturnObject->Package.Elements; - Count = ReturnObject->Package.Count; - - /* - * Most packages must have at least one element. The only exception - * is the variable-length package (ACPI_PTYPE1_VAR). - */ - if (!Count) - { - if (Package->RetInfo.Type == ACPI_PTYPE1_VAR) - { - return (AE_OK); - } - - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Package has no elements (empty)")); - - return (AE_AML_OPERAND_VALUE); - } - - /* - * Decode the type of the expected package contents - * - * PTYPE1 packages contain no subpackages - * PTYPE2 packages contain subpackages - */ - switch (Package->RetInfo.Type) - { - case ACPI_PTYPE_CUSTOM: - - Status = AcpiNsCustomPackage (Info, Elements, Count); - break; - - case ACPI_PTYPE1_FIXED: - /* - * The package count is fixed and there are no subpackages - * - * If package is too small, exit. - * If package is larger than expected, issue warning but continue - */ - ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; - if (Count < ExpectedCount) - { - goto PackageTooSmall; - } - else if (Count > ExpectedCount) - { - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Return Package is larger than needed - " - "found %u, expected %u\n", - Info->FullPathname, Count, ExpectedCount)); - } - - /* Validate all elements of the returned package */ - - Status = AcpiNsCheckPackageElements (Info, Elements, - Package->RetInfo.ObjectType1, Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); - break; - - case ACPI_PTYPE1_VAR: - /* - * The package count is variable, there are no subpackages, and all - * elements must be of the same type - */ - for (i = 0; i < Count; i++) - { - Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo.ObjectType1, i); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Elements++; - } - break; - - case ACPI_PTYPE1_OPTION: - /* - * The package count is variable, there are no subpackages. There are - * a fixed number of required elements, and a variable number of - * optional elements. - * - * Check if package is at least as large as the minimum required - */ - ExpectedCount = Package->RetInfo3.Count; - if (Count < ExpectedCount) - { - goto PackageTooSmall; - } - - /* Variable number of sub-objects */ - - for (i = 0; i < Count; i++) - { - if (i < Package->RetInfo3.Count) - { - /* These are the required package elements (0, 1, or 2) */ - - Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.ObjectType[i], i); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else - { - /* These are the optional package elements */ - - Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.TailObjectType, i); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - - Elements++; - } - break; - - case ACPI_PTYPE2_REV_FIXED: - - /* First element is the (Integer) revision */ - - Status = AcpiNsCheckObjectType ( - Info, Elements, ACPI_RTYPE_INTEGER, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Elements++; - Count--; - - /* Examine the subpackages */ - - Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); - break; - - case ACPI_PTYPE2_PKG_COUNT: - - /* First element is the (Integer) count of subpackages to follow */ - - Status = AcpiNsCheckObjectType ( - Info, Elements, ACPI_RTYPE_INTEGER, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * Count cannot be larger than the parent package length, but allow it - * to be smaller. The >= accounts for the Integer above. - */ - ExpectedCount = (UINT32) (*Elements)->Integer.Value; - if (ExpectedCount >= Count) - { - goto PackageTooSmall; - } - - Count = ExpectedCount; - Elements++; - - /* Examine the subpackages */ - - Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); - break; - - case ACPI_PTYPE2: - case ACPI_PTYPE2_FIXED: - case ACPI_PTYPE2_MIN: - case ACPI_PTYPE2_COUNT: - case ACPI_PTYPE2_FIX_VAR: - /* - * These types all return a single Package that consists of a - * variable number of subpackages. - * - * First, ensure that the first element is a subpackage. If not, - * the BIOS may have incorrectly returned the object as a single - * package instead of a Package of Packages (a common error if - * there is only one entry). We may be able to repair this by - * wrapping the returned Package with a new outer Package. - */ - if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)) - { - /* Create the new outer package and populate it */ - - Status = AcpiNsWrapWithPackage ( - Info, ReturnObject, ReturnObjectPtr); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Update locals to point to the new package (of 1 element) */ - - ReturnObject = *ReturnObjectPtr; - Elements = ReturnObject->Package.Elements; - Count = 1; - } - - /* Examine the subpackages */ - - Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); - break; - - case ACPI_PTYPE2_VAR_VAR: - /* - * Returns a variable list of packages, each with a variable list - * of objects. - */ - break; - - case ACPI_PTYPE2_UUID_PAIR: - - /* The package must contain pairs of (UUID + type) */ - - if (Count & 1) - { - ExpectedCount = Count + 1; - goto PackageTooSmall; - } - - while (Count > 0) - { - Status = AcpiNsCheckObjectType(Info, Elements, - Package->RetInfo.ObjectType1, 0); - if (ACPI_FAILURE(Status)) - { - return (Status); - } - - /* Validate length of the UUID buffer */ - - if ((*Elements)->Buffer.Length != 16) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, - Info->NodeFlags, "Invalid length for UUID Buffer")); - return (AE_AML_OPERAND_VALUE); - } - - Status = AcpiNsCheckObjectType(Info, Elements + 1, - Package->RetInfo.ObjectType2, 0); - if (ACPI_FAILURE(Status)) - { - return (Status); - } - - Elements += 2; - Count -= 2; - } - break; - - default: - - /* Should not get here if predefined info table is correct */ - - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Invalid internal return type in table entry: %X", - Package->RetInfo.Type)); - - return (AE_AML_INTERNAL); - } - - return (Status); - - -PackageTooSmall: - - /* Error exit for the case with an incorrect package count */ - - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Package is too small - found %u elements, expected %u", - Count, ExpectedCount)); - - return (AE_AML_OPERAND_VALUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckPackageList - * - * PARAMETERS: Info - Method execution information block - * Package - Pointer to package-specific info for method - * Elements - Element list of parent package. All elements - * of this list should be of type Package. - * Count - Count of subpackages - * - * RETURN: Status - * - * DESCRIPTION: Examine a list of subpackages - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsCheckPackageList ( - ACPI_EVALUATE_INFO *Info, - const ACPI_PREDEFINED_INFO *Package, - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count) -{ - ACPI_OPERAND_OBJECT *SubPackage; - ACPI_OPERAND_OBJECT **SubElements; - ACPI_STATUS Status; - UINT32 ExpectedCount; - UINT32 i; - UINT32 j; - - - /* - * Validate each subpackage in the parent Package - * - * NOTE: assumes list of subpackages contains no NULL elements. - * Any NULL elements should have been removed by earlier call - * to AcpiNsRemoveNullElements. - */ - for (i = 0; i < Count; i++) - { - SubPackage = *Elements; - SubElements = SubPackage->Package.Elements; - Info->ParentPackage = SubPackage; - - /* Each sub-object must be of type Package */ - - Status = AcpiNsCheckObjectType (Info, &SubPackage, - ACPI_RTYPE_PACKAGE, i); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Examine the different types of expected subpackages */ - - Info->ParentPackage = SubPackage; - switch (Package->RetInfo.Type) - { - case ACPI_PTYPE2: - case ACPI_PTYPE2_PKG_COUNT: - case ACPI_PTYPE2_REV_FIXED: - - /* Each subpackage has a fixed number of elements */ - - ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; - if (SubPackage->Package.Count < ExpectedCount) - { - goto PackageTooSmall; - } - - Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - case ACPI_PTYPE2_FIX_VAR: - /* - * Each subpackage has a fixed number of elements and an - * optional element - */ - ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; - if (SubPackage->Package.Count < ExpectedCount) - { - goto PackageTooSmall; - } - - Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - SubPackage->Package.Count - Package->RetInfo.Count1, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - case ACPI_PTYPE2_VAR_VAR: - /* - * Each subpackage has a fixed or variable number of elements - */ - break; - - case ACPI_PTYPE2_FIXED: - - /* Each subpackage has a fixed length */ - - ExpectedCount = Package->RetInfo2.Count; - if (SubPackage->Package.Count < ExpectedCount) - { - goto PackageTooSmall; - } - - /* Check the type of each subpackage element */ - - for (j = 0; j < ExpectedCount; j++) - { - Status = AcpiNsCheckObjectType (Info, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - break; - - case ACPI_PTYPE2_MIN: - - /* Each subpackage has a variable but minimum length */ - - ExpectedCount = Package->RetInfo.Count1; - if (SubPackage->Package.Count < ExpectedCount) - { - goto PackageTooSmall; - } - - /* Check the type of each subpackage element */ - - Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - case ACPI_PTYPE2_COUNT: - /* - * First element is the (Integer) count of elements, including - * the count field (the ACPI name is NumElements) - */ - Status = AcpiNsCheckObjectType (Info, SubElements, - ACPI_RTYPE_INTEGER, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * Make sure package is large enough for the Count and is - * is as large as the minimum size - */ - ExpectedCount = (UINT32) (*SubElements)->Integer.Value; - if (SubPackage->Package.Count < ExpectedCount) - { - goto PackageTooSmall; - } - - if (SubPackage->Package.Count < Package->RetInfo.Count1) - { - ExpectedCount = Package->RetInfo.Count1; - goto PackageTooSmall; - } - - if (ExpectedCount == 0) - { - /* - * Either the NumEntries element was originally zero or it was - * a NULL element and repaired to an Integer of value zero. - * In either case, repair it by setting NumEntries to be the - * actual size of the subpackage. - */ - ExpectedCount = SubPackage->Package.Count; - (*SubElements)->Integer.Value = ExpectedCount; - } - - /* Check the type of each subpackage element */ - - Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - - default: /* Should not get here, type was validated by caller */ - - return (AE_AML_INTERNAL); - } - - Elements++; - } - - return (AE_OK); - - -PackageTooSmall: - - /* The subpackage count was smaller than required */ - - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return SubPackage[%u] is too small - found %u elements, expected %u", - i, SubPackage->Package.Count, ExpectedCount)); - - return (AE_AML_OPERAND_VALUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCustomPackage - * - * PARAMETERS: Info - Method execution information block - * Elements - Pointer to the package elements array - * Count - Element count for the package - * - * RETURN: Status - * - * DESCRIPTION: Check a returned package object for the correct count and - * correct type of all sub-objects. - * - * NOTE: Currently used for the _BIX method only. When needed for two or more - * methods, probably a detect/dispatch mechanism will be required. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsCustomPackage ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count) -{ - UINT32 ExpectedCount; - UINT32 Version; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_NAME (NsCustomPackage); - - - /* Get version number, must be Integer */ - - if ((*Elements)->Common.Type != ACPI_TYPE_INTEGER) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Package has invalid object type for version number")); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - Version = (UINT32) (*Elements)->Integer.Value; - ExpectedCount = 21; /* Version 1 */ - - if (Version == 0) - { - ExpectedCount = 20; /* Version 0 */ - } - - if (Count < ExpectedCount) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Package is too small - found %u elements, expected %u", - Count, ExpectedCount)); - return_ACPI_STATUS (AE_AML_OPERAND_VALUE); - } - else if (Count > ExpectedCount) - { - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Return Package is larger than needed - " - "found %u, expected %u\n", - Info->FullPathname, Count, ExpectedCount)); - } - - /* Validate all elements of the returned package */ - - Status = AcpiNsCheckPackageElements (Info, Elements, - ACPI_RTYPE_INTEGER, 16, - ACPI_RTYPE_STRING, 4, 0); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Version 1 has a single trailing integer */ - - if (Version > 0) - { - Status = AcpiNsCheckPackageElements (Info, Elements + 20, - ACPI_RTYPE_INTEGER, 1, 0, 0, 20); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCheckPackageElements - * - * PARAMETERS: Info - Method execution information block - * Elements - Pointer to the package elements array - * Type1 - Object type for first group - * Count1 - Count for first group - * Type2 - Object type for second group - * Count2 - Count for second group - * StartIndex - Start of the first group of elements - * - * RETURN: Status - * - * DESCRIPTION: Check that all elements of a package are of the correct object - * type. Supports up to two groups of different object types. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsCheckPackageElements ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **Elements, - UINT8 Type1, - UINT32 Count1, - UINT8 Type2, - UINT32 Count2, - UINT32 StartIndex) -{ - ACPI_OPERAND_OBJECT **ThisElement = Elements; - ACPI_STATUS Status; - UINT32 i; - - - /* - * Up to two groups of package elements are supported by the data - * structure. All elements in each group must be of the same type. - * The second group can have a count of zero. - */ - for (i = 0; i < Count1; i++) - { - Status = AcpiNsCheckObjectType (Info, ThisElement, - Type1, i + StartIndex); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ThisElement++; - } - - for (i = 0; i < Count2; i++) - { - Status = AcpiNsCheckObjectType (Info, ThisElement, - Type2, (i + Count1 + StartIndex)); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ThisElement++; - } - - return (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsrepair.c b/usr/src/uts/intel/io/acpica/namespace/nsrepair.c deleted file mode 100644 index 524fcf6671..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsrepair.c +++ /dev/null @@ -1,641 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsrepair - Repair for objects returned by predefined methods - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "acpredef.h" -#include "amlresrc.h" - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsrepair") - - -/******************************************************************************* - * - * This module attempts to repair or convert objects returned by the - * predefined methods to an object type that is expected, as per the ACPI - * specification. The need for this code is dictated by the many machines that - * return incorrect types for the standard predefined methods. Performing these - * conversions here, in one place, eliminates the need for individual ACPI - * device drivers to do the same. Note: Most of these conversions are different - * than the internal object conversion routines used for implicit object - * conversion. - * - * The following conversions can be performed as necessary: - * - * Integer -> String - * Integer -> Buffer - * String -> Integer - * String -> Buffer - * Buffer -> Integer - * Buffer -> String - * Buffer -> Package of Integers - * Package -> Package of one Package - * - * Additional conversions that are available: - * Convert a null return or zero return value to an EndTag descriptor - * Convert an ASCII string to a Unicode buffer - * - * An incorrect standalone object is wrapped with required outer package - * - * Additional possible repairs: - * Required package elements that are NULL replaced by Integer/String/Buffer - * - ******************************************************************************/ - - -/* Local prototypes */ - -static const ACPI_SIMPLE_REPAIR_INFO * -AcpiNsMatchSimpleRepair ( - ACPI_NAMESPACE_NODE *Node, - UINT32 ReturnBtype, - UINT32 PackageIndex); - - -/* - * Special but simple repairs for some names. - * - * 2nd argument: Unexpected types that can be repaired - */ -static const ACPI_SIMPLE_REPAIR_INFO AcpiObjectRepairInfo[] = -{ - /* Resource descriptor conversions */ - - { "_CRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE, - ACPI_NOT_PACKAGE_ELEMENT, - AcpiNsConvertToResource }, - { "_DMA", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE, - ACPI_NOT_PACKAGE_ELEMENT, - AcpiNsConvertToResource }, - { "_PRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE, - ACPI_NOT_PACKAGE_ELEMENT, - AcpiNsConvertToResource }, - - /* Object reference conversions */ - - { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS, - AcpiNsConvertToReference }, - - /* Unicode conversions */ - - { "_MLS", ACPI_RTYPE_STRING, 1, - AcpiNsConvertToUnicode }, - { "_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, - ACPI_NOT_PACKAGE_ELEMENT, - AcpiNsConvertToUnicode }, - { {0,0,0,0}, 0, 0, NULL } /* Table terminator */ -}; - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSimpleRepair - * - * PARAMETERS: Info - Method execution information block - * ExpectedBtypes - Object types expected - * PackageIndex - Index of object within parent package (if - * applicable - ACPI_NOT_PACKAGE_ELEMENT - * otherwise) - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if repair was successful. - * - * DESCRIPTION: Attempt to repair/convert a return object of a type that was - * not expected. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsSimpleRepair ( - ACPI_EVALUATE_INFO *Info, - UINT32 ExpectedBtypes, - UINT32 PackageIndex, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT *NewObject = NULL; - ACPI_STATUS Status; - const ACPI_SIMPLE_REPAIR_INFO *Predefined; - - - ACPI_FUNCTION_NAME (NsSimpleRepair); - - - /* - * Special repairs for certain names that are in the repair table. - * Check if this name is in the list of repairable names. - */ - Predefined = AcpiNsMatchSimpleRepair (Info->Node, - Info->ReturnBtype, PackageIndex); - if (Predefined) - { - if (!ReturnObject) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, - ACPI_WARN_ALWAYS, "Missing expected return value")); - } - - Status = Predefined->ObjectConverter (Info->Node, ReturnObject, - &NewObject); - if (ACPI_FAILURE (Status)) - { - /* A fatal error occurred during a conversion */ - - ACPI_EXCEPTION ((AE_INFO, Status, - "During return object analysis")); - return (Status); - } - if (NewObject) - { - goto ObjectRepaired; - } - } - - /* - * Do not perform simple object repair unless the return type is not - * expected. - */ - if (Info->ReturnBtype & ExpectedBtypes) - { - return (AE_OK); - } - - /* - * At this point, we know that the type of the returned object was not - * one of the expected types for this predefined name. Attempt to - * repair the object by converting it to one of the expected object - * types for this predefined name. - */ - - /* - * If there is no return value, check if we require a return value for - * this predefined name. Either one return value is expected, or none, - * for both methods and other objects. - * - * Try to fix if there was no return object. Warning if failed to fix. - */ - if (!ReturnObject) - { - if (ExpectedBtypes && (!(ExpectedBtypes & ACPI_RTYPE_NONE))) - { - if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, - ACPI_WARN_ALWAYS, "Found unexpected NULL package element")); - - Status = AcpiNsRepairNullElement (Info, ExpectedBtypes, - PackageIndex, ReturnObjectPtr); - if (ACPI_SUCCESS (Status)) - { - return (AE_OK); /* Repair was successful */ - } - } - else - { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, - ACPI_WARN_ALWAYS, "Missing expected return value")); - } - - return (AE_AML_NO_RETURN_VALUE); - } - } - - if (ExpectedBtypes & ACPI_RTYPE_INTEGER) - { - Status = AcpiNsConvertToInteger (ReturnObject, &NewObject); - if (ACPI_SUCCESS (Status)) - { - goto ObjectRepaired; - } - } - if (ExpectedBtypes & ACPI_RTYPE_STRING) - { - Status = AcpiNsConvertToString (ReturnObject, &NewObject); - if (ACPI_SUCCESS (Status)) - { - goto ObjectRepaired; - } - } - if (ExpectedBtypes & ACPI_RTYPE_BUFFER) - { - Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject); - if (ACPI_SUCCESS (Status)) - { - goto ObjectRepaired; - } - } - if (ExpectedBtypes & ACPI_RTYPE_PACKAGE) - { - /* - * A package is expected. We will wrap the existing object with a - * new package object. It is often the case that if a variable-length - * package is required, but there is only a single object needed, the - * BIOS will return that object instead of wrapping it with a Package - * object. Note: after the wrapping, the package will be validated - * for correct contents (expected object type or types). - */ - Status = AcpiNsWrapWithPackage (Info, ReturnObject, &NewObject); - if (ACPI_SUCCESS (Status)) - { - /* - * The original object just had its reference count - * incremented for being inserted into the new package. - */ - *ReturnObjectPtr = NewObject; /* New Package object */ - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - return (AE_OK); - } - } - - /* We cannot repair this object */ - - return (AE_AML_OPERAND_TYPE); - - -ObjectRepaired: - - /* Object was successfully repaired */ - - if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) - { - /* - * The original object is a package element. We need to - * decrement the reference count of the original object, - * for removing it from the package. - * - * However, if the original object was just wrapped with a - * package object as part of the repair, we don't need to - * change the reference count. - */ - if (!(Info->ReturnFlags & ACPI_OBJECT_WRAPPED)) - { - NewObject->Common.ReferenceCount = - ReturnObject->Common.ReferenceCount; - - if (ReturnObject->Common.ReferenceCount > 1) - { - ReturnObject->Common.ReferenceCount--; - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Converted %s to expected %s at Package index %u\n", - Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject), - AcpiUtGetObjectTypeName (NewObject), PackageIndex)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Converted %s to expected %s\n", - Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject), - AcpiUtGetObjectTypeName (NewObject))); - } - - /* Delete old object, install the new return object */ - - AcpiUtRemoveReference (ReturnObject); - *ReturnObjectPtr = NewObject; - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsMatchSimpleRepair - * - * PARAMETERS: Node - Namespace node for the method/object - * ReturnBtype - Object type that was returned - * PackageIndex - Index of object within parent package (if - * applicable - ACPI_NOT_PACKAGE_ELEMENT - * otherwise) - * - * RETURN: Pointer to entry in repair table. NULL indicates not found. - * - * DESCRIPTION: Check an object name against the repairable object list. - * - *****************************************************************************/ - -static const ACPI_SIMPLE_REPAIR_INFO * -AcpiNsMatchSimpleRepair ( - ACPI_NAMESPACE_NODE *Node, - UINT32 ReturnBtype, - UINT32 PackageIndex) -{ - const ACPI_SIMPLE_REPAIR_INFO *ThisName; - - - /* Search info table for a repairable predefined method/object name */ - - ThisName = AcpiObjectRepairInfo; - while (ThisName->ObjectConverter) - { - if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name)) - { - /* Check if we can actually repair this name/type combination */ - - if ((ReturnBtype & ThisName->UnexpectedBtypes) && - (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS || - PackageIndex == ThisName->PackageIndex)) - { - return (ThisName); - } - - return (NULL); - } - - ThisName++; - } - - return (NULL); /* Name was not found in the repair table */ -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsRepairNullElement - * - * PARAMETERS: Info - Method execution information block - * ExpectedBtypes - Object types expected - * PackageIndex - Index of object within parent package (if - * applicable - ACPI_NOT_PACKAGE_ELEMENT - * otherwise) - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if repair was successful. - * - * DESCRIPTION: Attempt to repair a NULL element of a returned Package object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsRepairNullElement ( - ACPI_EVALUATE_INFO *Info, - UINT32 ExpectedBtypes, - UINT32 PackageIndex, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT *NewObject; - - - ACPI_FUNCTION_NAME (NsRepairNullElement); - - - /* No repair needed if return object is non-NULL */ - - if (ReturnObject) - { - return (AE_OK); - } - - /* - * Attempt to repair a NULL element of a Package object. This applies to - * predefined names that return a fixed-length package and each element - * is required. It does not apply to variable-length packages where NULL - * elements are allowed, especially at the end of the package. - */ - if (ExpectedBtypes & ACPI_RTYPE_INTEGER) - { - /* Need an Integer - create a zero-value integer */ - - NewObject = AcpiUtCreateIntegerObject ((UINT64) 0); - } - else if (ExpectedBtypes & ACPI_RTYPE_STRING) - { - /* Need a String - create a NULL string */ - - NewObject = AcpiUtCreateStringObject (0); - } - else if (ExpectedBtypes & ACPI_RTYPE_BUFFER) - { - /* Need a Buffer - create a zero-length buffer */ - - NewObject = AcpiUtCreateBufferObject (0); - } - else - { - /* Error for all other expected types */ - - return (AE_AML_OPERAND_TYPE); - } - - if (!NewObject) - { - return (AE_NO_MEMORY); - } - - /* Set the reference count according to the parent Package object */ - - NewObject->Common.ReferenceCount = - Info->ParentPackage->Common.ReferenceCount; - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Converted NULL package element to expected %s at index %u\n", - Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), - PackageIndex)); - - *ReturnObjectPtr = NewObject; - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRemoveNullElements - * - * PARAMETERS: Info - Method execution information block - * PackageType - An AcpiReturnPackageTypes value - * ObjDesc - A Package object - * - * RETURN: None. - * - * DESCRIPTION: Remove all NULL package elements from packages that contain - * a variable number of subpackages. For these types of - * packages, NULL elements can be safely removed. - * - *****************************************************************************/ - -void -AcpiNsRemoveNullElements ( - ACPI_EVALUATE_INFO *Info, - UINT8 PackageType, - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_OPERAND_OBJECT **Source; - ACPI_OPERAND_OBJECT **Dest; - UINT32 Count; - UINT32 NewCount; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsRemoveNullElements); - - - /* - * We can safely remove all NULL elements from these package types: - * PTYPE1_VAR packages contain a variable number of simple data types. - * PTYPE2 packages contain a variable number of subpackages. - */ - switch (PackageType) - { - case ACPI_PTYPE1_VAR: - case ACPI_PTYPE2: - case ACPI_PTYPE2_COUNT: - case ACPI_PTYPE2_PKG_COUNT: - case ACPI_PTYPE2_FIXED: - case ACPI_PTYPE2_MIN: - case ACPI_PTYPE2_REV_FIXED: - case ACPI_PTYPE2_FIX_VAR: - break; - - default: - case ACPI_PTYPE2_VAR_VAR: - case ACPI_PTYPE1_FIXED: - case ACPI_PTYPE1_OPTION: - return; - } - - Count = ObjDesc->Package.Count; - NewCount = Count; - - Source = ObjDesc->Package.Elements; - Dest = Source; - - /* Examine all elements of the package object, remove nulls */ - - for (i = 0; i < Count; i++) - { - if (!*Source) - { - NewCount--; - } - else - { - *Dest = *Source; - Dest++; - } - - Source++; - } - - /* Update parent package if any null elements were removed */ - - if (NewCount < Count) - { - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Found and removed %u NULL elements\n", - Info->FullPathname, (Count - NewCount))); - - /* NULL terminate list and update the package count */ - - *Dest = NULL; - ObjDesc->Package.Count = NewCount; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsWrapWithPackage - * - * PARAMETERS: Info - Method execution information block - * OriginalObject - Pointer to the object to repair. - * ObjDescPtr - The new package object is returned here - * - * RETURN: Status, new object in *ObjDescPtr - * - * DESCRIPTION: Repair a common problem with objects that are defined to - * return a variable-length Package of sub-objects. If there is - * only one sub-object, some BIOS code mistakenly simply declares - * the single object instead of a Package with one sub-object. - * This function attempts to repair this error by wrapping a - * Package object around the original object, creating the - * correct and expected Package with one sub-object. - * - * Names that can be repaired in this manner include: - * _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS, - * _BCL, _DOD, _FIX, _Sx - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsWrapWithPackage ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT *OriginalObject, - ACPI_OPERAND_OBJECT **ObjDescPtr) -{ - ACPI_OPERAND_OBJECT *PkgObjDesc; - - - ACPI_FUNCTION_NAME (NsWrapWithPackage); - - - /* - * Create the new outer package and populate it. The new - * package will have a single element, the lone sub-object. - */ - PkgObjDesc = AcpiUtCreatePackageObject (1); - if (!PkgObjDesc) - { - return (AE_NO_MEMORY); - } - - PkgObjDesc->Package.Elements[0] = OriginalObject; - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Wrapped %s with expected Package object\n", - Info->FullPathname, AcpiUtGetObjectTypeName (OriginalObject))); - - /* Return the new object in the object pointer */ - - *ObjDescPtr = PkgObjDesc; - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; - return (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsrepair2.c b/usr/src/uts/intel/io/acpica/namespace/nsrepair2.c deleted file mode 100644 index d8625899a6..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsrepair2.c +++ /dev/null @@ -1,1083 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsrepair2 - Repair for objects returned by specific - * predefined methods - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsrepair2") - - -/* - * Information structure and handler for ACPI predefined names that can - * be repaired on a per-name basis. - */ -typedef -ACPI_STATUS (*ACPI_REPAIR_FUNCTION) ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -typedef struct acpi_repair_info -{ - char Name[ACPI_NAME_SIZE]; - ACPI_REPAIR_FUNCTION RepairFunction; - -} ACPI_REPAIR_INFO; - - -/* Local prototypes */ - -static const ACPI_REPAIR_INFO * -AcpiNsMatchComplexRepair ( - ACPI_NAMESPACE_NODE *Node); - -static ACPI_STATUS -AcpiNsRepair_ALR ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_CID ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_CST ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_FDE ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_HID ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_PRT ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_PSS ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsRepair_TSS ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); - -static ACPI_STATUS -AcpiNsCheckSortedList ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT *ReturnObject, - UINT32 StartIndex, - UINT32 ExpectedCount, - UINT32 SortIndex, - UINT8 SortDirection, - char *SortKeyName); - -/* Values for SortDirection above */ - -#define ACPI_SORT_ASCENDING 0 -#define ACPI_SORT_DESCENDING 1 - -static void -AcpiNsRemoveElement ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Index); - -static void -AcpiNsSortList ( - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count, - UINT32 Index, - UINT8 SortDirection); - - -/* - * This table contains the names of the predefined methods for which we can - * perform more complex repairs. - * - * As necessary: - * - * _ALR: Sort the list ascending by AmbientIlluminance - * _CID: Strings: uppercase all, remove any leading asterisk - * _CST: Sort the list ascending by C state type - * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs - * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs - * _HID: Strings: uppercase all, remove any leading asterisk - * _PRT: Fix reversed SourceName and SourceIndex - * _PSS: Sort the list descending by Power - * _TSS: Sort the list descending by Power - * - * Names that must be packages, but cannot be sorted: - * - * _BCL: Values are tied to the Package index where they appear, and cannot - * be moved or sorted. These index values are used for _BQC and _BCM. - * However, we can fix the case where a buffer is returned, by converting - * it to a Package of integers. - */ -static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] = -{ - {"_ALR", AcpiNsRepair_ALR}, - {"_CID", AcpiNsRepair_CID}, - {"_CST", AcpiNsRepair_CST}, - {"_FDE", AcpiNsRepair_FDE}, - {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */ - {"_HID", AcpiNsRepair_HID}, - {"_PRT", AcpiNsRepair_PRT}, - {"_PSS", AcpiNsRepair_PSS}, - {"_TSS", AcpiNsRepair_TSS}, - {{0,0,0,0}, NULL} /* Table terminator */ -}; - - -#define ACPI_FDE_FIELD_COUNT 5 -#define ACPI_FDE_BYTE_BUFFER_SIZE 5 -#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32)) - - -/****************************************************************************** - * - * FUNCTION: AcpiNsComplexRepairs - * - * PARAMETERS: Info - Method execution information block - * Node - Namespace node for the method/object - * ValidateStatus - Original status of earlier validation - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if repair was successful. If name is not - * matched, ValidateStatus is returned. - * - * DESCRIPTION: Attempt to repair/convert a return object of a type that was - * not expected. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiNsComplexRepairs ( - ACPI_EVALUATE_INFO *Info, - ACPI_NAMESPACE_NODE *Node, - ACPI_STATUS ValidateStatus, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - const ACPI_REPAIR_INFO *Predefined; - ACPI_STATUS Status; - - - /* Check if this name is in the list of repairable names */ - - Predefined = AcpiNsMatchComplexRepair (Node); - if (!Predefined) - { - return (ValidateStatus); - } - - Status = Predefined->RepairFunction (Info, ReturnObjectPtr); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsMatchComplexRepair - * - * PARAMETERS: Node - Namespace node for the method/object - * - * RETURN: Pointer to entry in repair table. NULL indicates not found. - * - * DESCRIPTION: Check an object name against the repairable object list. - * - *****************************************************************************/ - -static const ACPI_REPAIR_INFO * -AcpiNsMatchComplexRepair ( - ACPI_NAMESPACE_NODE *Node) -{ - const ACPI_REPAIR_INFO *ThisName; - - - /* Search info table for a repairable predefined method/object name */ - - ThisName = AcpiNsRepairableNames; - while (ThisName->RepairFunction) - { - if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name)) - { - return (ThisName); - } - - ThisName++; - } - - return (NULL); /* Not found */ -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_ALR - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list - * ascending by the ambient illuminance values. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_ALR ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_STATUS Status; - - - Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 2, 1, - ACPI_SORT_ASCENDING, "AmbientIlluminance"); - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_FDE - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return - * value is a Buffer of 5 DWORDs. This function repairs a common - * problem where the return value is a Buffer of BYTEs, not - * DWORDs. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_FDE ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT *BufferObject; - UINT8 *ByteBuffer; - UINT32 *DwordBuffer; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsRepair_FDE); - - - switch (ReturnObject->Common.Type) - { - case ACPI_TYPE_BUFFER: - - /* This is the expected type. Length should be (at least) 5 DWORDs */ - - if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE) - { - return (AE_OK); - } - - /* We can only repair if we have exactly 5 BYTEs */ - - if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) - { - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "Incorrect return buffer length %u, expected %u", - ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); - - return (AE_AML_OPERAND_TYPE); - } - - /* Create the new (larger) buffer object */ - - BufferObject = AcpiUtCreateBufferObject ( - ACPI_FDE_DWORD_BUFFER_SIZE); - if (!BufferObject) - { - return (AE_NO_MEMORY); - } - - /* Expand each byte to a DWORD */ - - ByteBuffer = ReturnObject->Buffer.Pointer; - DwordBuffer = ACPI_CAST_PTR (UINT32, - BufferObject->Buffer.Pointer); - - for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) - { - *DwordBuffer = (UINT32) *ByteBuffer; - DwordBuffer++; - ByteBuffer++; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s Expanded Byte Buffer to expected DWord Buffer\n", - Info->FullPathname)); - break; - - default: - - return (AE_AML_OPERAND_TYPE); - } - - /* Delete the original return object, return the new buffer object */ - - AcpiUtRemoveReference (ReturnObject); - *ReturnObjectPtr = BufferObject; - - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_CID - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _CID object. If a string, ensure that all - * letters are uppercase and that there is no leading asterisk. - * If a Package, ensure same for all string elements. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_CID ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT **ElementPtr; - ACPI_OPERAND_OBJECT *OriginalElement; - UINT16 OriginalRefCount; - UINT32 i; - - - /* Check for _CID as a simple string */ - - if (ReturnObject->Common.Type == ACPI_TYPE_STRING) - { - Status = AcpiNsRepair_HID (Info, ReturnObjectPtr); - return (Status); - } - - /* Exit if not a Package */ - - if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) - { - return (AE_OK); - } - - /* Examine each element of the _CID package */ - - ElementPtr = ReturnObject->Package.Elements; - for (i = 0; i < ReturnObject->Package.Count; i++) - { - OriginalElement = *ElementPtr; - OriginalRefCount = OriginalElement->Common.ReferenceCount; - - Status = AcpiNsRepair_HID (Info, ElementPtr); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Take care with reference counts */ - - if (OriginalElement != *ElementPtr) - { - /* Element was replaced */ - - (*ElementPtr)->Common.ReferenceCount = - OriginalRefCount; - - AcpiUtRemoveReference (OriginalElement); - } - - ElementPtr++; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_CST - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _CST object: - * 1. Sort the list ascending by C state type - * 2. Ensure type cannot be zero - * 3. A subpackage count of zero means _CST is meaningless - * 4. Count must match the number of C state subpackages - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_CST ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT **OuterElements; - UINT32 OuterElementCount; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - BOOLEAN Removing; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsRepair_CST); - - - /* - * Check if the C-state type values are proportional. - */ - OuterElementCount = ReturnObject->Package.Count - 1; - i = 0; - while (i < OuterElementCount) - { - OuterElements = &ReturnObject->Package.Elements[i + 1]; - Removing = FALSE; - - if ((*OuterElements)->Package.Count == 0) - { - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "SubPackage[%u] - removing entry due to zero count", i)); - Removing = TRUE; - goto RemoveElement; - } - - ObjDesc = (*OuterElements)->Package.Elements[1]; /* Index1 = Type */ - if ((UINT32) ObjDesc->Integer.Value == 0) - { - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "SubPackage[%u] - removing entry due to invalid Type(0)", i)); - Removing = TRUE; - } - -RemoveElement: - if (Removing) - { - AcpiNsRemoveElement (ReturnObject, i + 1); - OuterElementCount--; - } - else - { - i++; - } - } - - /* Update top-level package count, Type "Integer" checked elsewhere */ - - ObjDesc = ReturnObject->Package.Elements[0]; - ObjDesc->Integer.Value = OuterElementCount; - - /* - * Entries (subpackages) in the _CST Package must be sorted by the - * C-state type, in ascending order. - */ - Status = AcpiNsCheckSortedList (Info, ReturnObject, 1, 4, 1, - ACPI_SORT_ASCENDING, "C-State Type"); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_HID - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _HID object. If a string, ensure that all - * letters are uppercase and that there is no leading asterisk. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_HID ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT *NewString; - char *Source; - char *Dest; - - - ACPI_FUNCTION_NAME (NsRepair_HID); - - - /* We only care about string _HID objects (not integers) */ - - if (ReturnObject->Common.Type != ACPI_TYPE_STRING) - { - return (AE_OK); - } - - if (ReturnObject->String.Length == 0) - { - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "Invalid zero-length _HID or _CID string")); - - /* Return AE_OK anyway, let driver handle it */ - - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - return (AE_OK); - } - - /* It is simplest to always create a new string object */ - - NewString = AcpiUtCreateStringObject (ReturnObject->String.Length); - if (!NewString) - { - return (AE_NO_MEMORY); - } - - /* - * Remove a leading asterisk if present. For some unknown reason, there - * are many machines in the field that contains IDs like this. - * - * Examples: "*PNP0C03", "*ACPI0003" - */ - Source = ReturnObject->String.Pointer; - if (*Source == '*') - { - Source++; - NewString->String.Length--; - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Removed invalid leading asterisk\n", Info->FullPathname)); - } - - /* - * Copy and uppercase the string. From the ACPI 5.0 specification: - * - * A valid PNP ID must be of the form "AAA####" where A is an uppercase - * letter and # is a hex digit. A valid ACPI ID must be of the form - * "NNNN####" where N is an uppercase letter or decimal digit, and - * # is a hex digit. - */ - for (Dest = NewString->String.Pointer; *Source; Dest++, Source++) - { - *Dest = (char) toupper ((int) *Source); - } - - AcpiUtRemoveReference (ReturnObject); - *ReturnObjectPtr = NewString; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_PRT - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _PRT object. If necessary, fix reversed - * SourceName and SourceIndex field, a common BIOS bug. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_PRT ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *PackageObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT **TopObjectList; - ACPI_OPERAND_OBJECT **SubObjectList; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *SubPackage; - UINT32 ElementCount; - UINT32 Index; - - - /* Each element in the _PRT package is a subpackage */ - - TopObjectList = PackageObject->Package.Elements; - ElementCount = PackageObject->Package.Count; - - /* Examine each subpackage */ - - for (Index = 0; Index < ElementCount; Index++, TopObjectList++) - { - SubPackage = *TopObjectList; - SubObjectList = SubPackage->Package.Elements; - - /* Check for minimum required element count */ - - if (SubPackage->Package.Count < 4) - { - continue; - } - - /* - * If the BIOS has erroneously reversed the _PRT SourceName (index 2) - * and the SourceIndex (index 3), fix it. _PRT is important enough to - * workaround this BIOS error. This also provides compatibility with - * other ACPI implementations. - */ - ObjDesc = SubObjectList[3]; - if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) - { - SubObjectList[3] = SubObjectList[2]; - SubObjectList[2] = ObjDesc; - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "PRT[%X]: Fixed reversed SourceName and SourceIndex", - Index)); - } - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_PSS - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list - * by the CPU frequencies. Check that the power dissipation values - * are all proportional to CPU frequency (i.e., sorting by - * frequency should be the same as sorting by power.) - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_PSS ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT **OuterElements; - UINT32 OuterElementCount; - ACPI_OPERAND_OBJECT **Elements; - ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 PreviousValue; - ACPI_STATUS Status; - UINT32 i; - - - /* - * Entries (subpackages) in the _PSS Package must be sorted by power - * dissipation, in descending order. If it appears that the list is - * incorrectly sorted, sort it. We sort by CpuFrequency, since this - * should be proportional to the power. - */ - Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0, - ACPI_SORT_DESCENDING, "CpuFrequency"); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * We now know the list is correctly sorted by CPU frequency. Check if - * the power dissipation values are proportional. - */ - PreviousValue = ACPI_UINT32_MAX; - OuterElements = ReturnObject->Package.Elements; - OuterElementCount = ReturnObject->Package.Count; - - for (i = 0; i < OuterElementCount; i++) - { - Elements = (*OuterElements)->Package.Elements; - ObjDesc = Elements[1]; /* Index1 = PowerDissipation */ - - if ((UINT32) ObjDesc->Integer.Value > PreviousValue) - { - ACPI_WARN_PREDEFINED ((AE_INFO, - Info->FullPathname, Info->NodeFlags, - "SubPackage[%u,%u] - suspicious power dissipation values", - i-1, i)); - } - - PreviousValue = (UINT32) ObjDesc->Integer.Value; - OuterElements++; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRepair_TSS - * - * PARAMETERS: Info - Method execution information block - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object - * - * RETURN: Status. AE_OK if object is OK or was repaired successfully - * - * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list - * descending by the power dissipation values. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsRepair_TSS ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) -{ - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - - - /* - * We can only sort the _TSS return package if there is no _PSS in the - * same scope. This is because if _PSS is present, the ACPI specification - * dictates that the _TSS Power Dissipation field is to be ignored, and - * therefore some BIOSs leave garbage values in the _TSS Power field(s). - * In this case, it is best to just return the _TSS package as-is. - * (May, 2011) - */ - Status = AcpiNsGetNode (Info->Node, "^_PSS", - ACPI_NS_NO_UPSEARCH, &Node); - if (ACPI_SUCCESS (Status)) - { - return (AE_OK); - } - - Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 5, 1, - ACPI_SORT_DESCENDING, "PowerDissipation"); - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsCheckSortedList - * - * PARAMETERS: Info - Method execution information block - * ReturnObject - Pointer to the top-level returned object - * StartIndex - Index of the first subpackage - * ExpectedCount - Minimum length of each subpackage - * SortIndex - Subpackage entry to sort on - * SortDirection - Ascending or descending - * SortKeyName - Name of the SortIndex field - * - * RETURN: Status. AE_OK if the list is valid and is sorted correctly or - * has been repaired by sorting the list. - * - * DESCRIPTION: Check if the package list is valid and sorted correctly by the - * SortIndex. If not, then sort the list. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiNsCheckSortedList ( - ACPI_EVALUATE_INFO *Info, - ACPI_OPERAND_OBJECT *ReturnObject, - UINT32 StartIndex, - UINT32 ExpectedCount, - UINT32 SortIndex, - UINT8 SortDirection, - char *SortKeyName) -{ - UINT32 OuterElementCount; - ACPI_OPERAND_OBJECT **OuterElements; - ACPI_OPERAND_OBJECT **Elements; - ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 i; - UINT32 PreviousValue; - - - ACPI_FUNCTION_NAME (NsCheckSortedList); - - - /* The top-level object must be a package */ - - if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) - { - return (AE_AML_OPERAND_TYPE); - } - - /* - * NOTE: assumes list of subpackages contains no NULL elements. - * Any NULL elements should have been removed by earlier call - * to AcpiNsRemoveNullElements. - */ - OuterElementCount = ReturnObject->Package.Count; - if (!OuterElementCount || StartIndex >= OuterElementCount) - { - return (AE_AML_PACKAGE_LIMIT); - } - - OuterElements = &ReturnObject->Package.Elements[StartIndex]; - OuterElementCount -= StartIndex; - - PreviousValue = 0; - if (SortDirection == ACPI_SORT_DESCENDING) - { - PreviousValue = ACPI_UINT32_MAX; - } - - /* Examine each subpackage */ - - for (i = 0; i < OuterElementCount; i++) - { - /* Each element of the top-level package must also be a package */ - - if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE) - { - return (AE_AML_OPERAND_TYPE); - } - - /* Each subpackage must have the minimum length */ - - if ((*OuterElements)->Package.Count < ExpectedCount) - { - return (AE_AML_PACKAGE_LIMIT); - } - - Elements = (*OuterElements)->Package.Elements; - ObjDesc = Elements[SortIndex]; - - if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) - { - return (AE_AML_OPERAND_TYPE); - } - - /* - * The list must be sorted in the specified order. If we detect a - * discrepancy, sort the entire list. - */ - if (((SortDirection == ACPI_SORT_ASCENDING) && - (ObjDesc->Integer.Value < PreviousValue)) || - ((SortDirection == ACPI_SORT_DESCENDING) && - (ObjDesc->Integer.Value > PreviousValue))) - { - AcpiNsSortList (&ReturnObject->Package.Elements[StartIndex], - OuterElementCount, SortIndex, SortDirection); - - Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - - ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, - "%s: Repaired unsorted list - now sorted by %s\n", - Info->FullPathname, SortKeyName)); - return (AE_OK); - } - - PreviousValue = (UINT32) ObjDesc->Integer.Value; - OuterElements++; - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsSortList - * - * PARAMETERS: Elements - Package object element list - * Count - Element count for above - * Index - Sort by which package element - * SortDirection - Ascending or Descending sort - * - * RETURN: None - * - * DESCRIPTION: Sort the objects that are in a package element list. - * - * NOTE: Assumes that all NULL elements have been removed from the package, - * and that all elements have been verified to be of type Integer. - * - *****************************************************************************/ - -static void -AcpiNsSortList ( - ACPI_OPERAND_OBJECT **Elements, - UINT32 Count, - UINT32 Index, - UINT8 SortDirection) -{ - ACPI_OPERAND_OBJECT *ObjDesc1; - ACPI_OPERAND_OBJECT *ObjDesc2; - ACPI_OPERAND_OBJECT *TempObj; - UINT32 i; - UINT32 j; - - - /* Simple bubble sort */ - - for (i = 1; i < Count; i++) - { - for (j = (Count - 1); j >= i; j--) - { - ObjDesc1 = Elements[j-1]->Package.Elements[Index]; - ObjDesc2 = Elements[j]->Package.Elements[Index]; - - if (((SortDirection == ACPI_SORT_ASCENDING) && - (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) || - - ((SortDirection == ACPI_SORT_DESCENDING) && - (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value))) - { - TempObj = Elements[j-1]; - Elements[j-1] = Elements[j]; - Elements[j] = TempObj; - } - } - } -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsRemoveElement - * - * PARAMETERS: ObjDesc - Package object element list - * Index - Index of element to remove - * - * RETURN: None - * - * DESCRIPTION: Remove the requested element of a package and delete it. - * - *****************************************************************************/ - -static void -AcpiNsRemoveElement ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 Index) -{ - ACPI_OPERAND_OBJECT **Source; - ACPI_OPERAND_OBJECT **Dest; - UINT32 Count; - UINT32 NewCount; - UINT32 i; - - - ACPI_FUNCTION_NAME (NsRemoveElement); - - - Count = ObjDesc->Package.Count; - NewCount = Count - 1; - - Source = ObjDesc->Package.Elements; - Dest = Source; - - /* Examine all elements of the package object, remove matched index */ - - for (i = 0; i < Count; i++) - { - if (i == Index) - { - AcpiUtRemoveReference (*Source); /* Remove one ref for being in pkg */ - AcpiUtRemoveReference (*Source); - } - else - { - *Dest = *Source; - Dest++; - } - - Source++; - } - - /* NULL terminate list and update the package count */ - - *Dest = NULL; - ObjDesc->Package.Count = NewCount; -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nssearch.c b/usr/src/uts/intel/io/acpica/namespace/nssearch.c deleted file mode 100644 index 3a0fe90ea4..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nssearch.c +++ /dev/null @@ -1,453 +0,0 @@ -/******************************************************************************* - * - * Module Name: nssearch - Namespace search - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - -#ifdef ACPI_ASL_COMPILER -#include "amlcode.h" -#endif - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nssearch") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiNsSearchParentTree ( - UINT32 TargetName, - ACPI_NAMESPACE_NODE *Node, - ACPI_OBJECT_TYPE Type, - ACPI_NAMESPACE_NODE **ReturnNode); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSearchOneScope - * - * PARAMETERS: TargetName - Ascii ACPI name to search for - * ParentNode - Starting node where search will begin - * Type - Object type to match - * ReturnNode - Where the matched Named obj is returned - * - * RETURN: Status - * - * DESCRIPTION: Search a single level of the namespace. Performs a - * simple search of the specified level, and does not add - * entries or search parents. - * - * - * Named object lists are built (and subsequently dumped) in the - * order in which the names are encountered during the namespace load; - * - * All namespace searching is linear in this implementation, but - * could be easily modified to support any improved search - * algorithm. However, the linear search was chosen for simplicity - * and because the trees are small and the other interpreter - * execution overhead is relatively high. - * - * Note: CPU execution analysis has shown that the AML interpreter spends - * a very small percentage of its time searching the namespace. Therefore, - * the linear search seems to be sufficient, as there would seem to be - * little value in improving the search. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsSearchOneScope ( - UINT32 TargetName, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_OBJECT_TYPE Type, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_NAMESPACE_NODE *Node; - - - ACPI_FUNCTION_TRACE (NsSearchOneScope); - - -#ifdef ACPI_DEBUG_OUTPUT - if (ACPI_LV_NAMES & AcpiDbgLevel) - { - char *ScopeName; - - ScopeName = AcpiNsGetNormalizedPathname (ParentNode, TRUE); - if (ScopeName) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching %s (%p) For [%4.4s] (%s)\n", - ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), - AcpiUtGetTypeName (Type))); - - ACPI_FREE (ScopeName); - } - } -#endif - - /* - * Search for name at this namespace level, which is to say that we - * must search for the name among the children of this object - */ - Node = ParentNode->Child; - while (Node) - { - /* Check for match against the name */ - - if (Node->Name.Integer == TargetName) - { - /* Resolve a control method alias if any */ - - if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) - { - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); - } - - /* Found matching entry */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", - ACPI_CAST_PTR (char, &TargetName), - AcpiUtGetTypeName (Node->Type), - Node, AcpiUtGetNodeName (ParentNode), ParentNode)); - - *ReturnNode = Node; - return_ACPI_STATUS (AE_OK); - } - - /* Didn't match name, move on to the next peer object */ - - Node = Node->Peer; - } - - /* Searched entire namespace level, not found */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Name [%4.4s] (%s) not found in search in scope [%4.4s] " - "%p first child %p\n", - ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), - AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); - - return_ACPI_STATUS (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSearchParentTree - * - * PARAMETERS: TargetName - Ascii ACPI name to search for - * Node - Starting node where search will begin - * Type - Object type to match - * ReturnNode - Where the matched Node is returned - * - * RETURN: Status - * - * DESCRIPTION: Called when a name has not been found in the current namespace - * level. Before adding it or giving up, ACPI scope rules require - * searching enclosing scopes in cases identified by AcpiNsLocal(). - * - * "A name is located by finding the matching name in the current - * name space, and then in the parent name space. If the parent - * name space does not contain the name, the search continues - * recursively until either the name is found or the name space - * does not have a parent (the root of the name space). This - * indicates that the name is not found" (From ACPI Specification, - * section 5.3) - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsSearchParentTree ( - UINT32 TargetName, - ACPI_NAMESPACE_NODE *Node, - ACPI_OBJECT_TYPE Type, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_TRACE (NsSearchParentTree); - - - ParentNode = Node->Parent; - - /* - * If there is no parent (i.e., we are at the root) or type is "local", - * we won't be searching the parent tree. - */ - if (!ParentNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", - ACPI_CAST_PTR (char, &TargetName))); - return_ACPI_STATUS (AE_NOT_FOUND); - } - - if (AcpiNsLocal (Type)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "[%4.4s] type [%s] must be local to this scope (no parent search)\n", - ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); - return_ACPI_STATUS (AE_NOT_FOUND); - } - - /* Search the parent tree */ - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching parent [%4.4s] for [%4.4s]\n", - AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); - - /* Search parents until target is found or we have backed up to the root */ - - while (ParentNode) - { - /* - * Search parent scope. Use TYPE_ANY because we don't care about the - * object type at this point, we only care about the existence of - * the actual name we are searching for. Typechecking comes later. - */ - Status = AcpiNsSearchOneScope ( - TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); - if (ACPI_SUCCESS (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Not found here, go up another level (until we reach the root) */ - - ParentNode = ParentNode->Parent; - } - - /* Not found in parent tree */ - - return_ACPI_STATUS (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSearchAndEnter - * - * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) - * WalkState - Current state of the walk - * Node - Starting node where search will begin - * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. - * Otherwise,search only. - * Type - Object type to match - * Flags - Flags describing the search restrictions - * ReturnNode - Where the Node is returned - * - * RETURN: Status - * - * DESCRIPTION: Search for a name segment in a single namespace level, - * optionally adding it if it is not found. If the passed - * Type is not Any and the type previously stored in the - * entry was Any (i.e. unknown), update the stored type. - * - * In ACPI_IMODE_EXECUTE, search only. - * In other modes, search and add if not found. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsSearchAndEnter ( - UINT32 TargetName, - ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE *Node, - ACPI_INTERPRETER_MODE InterpreterMode, - ACPI_OBJECT_TYPE Type, - UINT32 Flags, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *NewNode; - - - ACPI_FUNCTION_TRACE (NsSearchAndEnter); - - - /* Parameter validation */ - - if (!Node || !TargetName || !ReturnNode) - { - ACPI_ERROR ((AE_INFO, - "Null parameter: Node %p Name 0x%X ReturnNode %p", - Node, TargetName, ReturnNode)); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Name must consist of valid ACPI characters. We will repair the name if - * necessary because we don't want to abort because of this, but we want - * all namespace names to be printable. A warning message is appropriate. - * - * This issue came up because there are in fact machines that exhibit - * this problem, and we want to be able to enable ACPI support for them, - * even though there are a few bad names. - */ - AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); - - /* Try to find the name in the namespace level specified by the caller */ - - *ReturnNode = ACPI_ENTRY_NOT_FOUND; - Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); - if (Status != AE_NOT_FOUND) - { - /* - * If we found it AND the request specifies that a find is an error, - * return the error - */ - if (Status == AE_OK) - { - /* The node was found in the namespace */ - - /* - * If the namespace override feature is enabled for this node, - * delete any existing attached sub-object and make the node - * look like a new node that is owned by the override table. - */ - if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Namespace override: %4.4s pass %u type %X Owner %X\n", - ACPI_CAST_PTR(char, &TargetName), InterpreterMode, - (*ReturnNode)->Type, WalkState->OwnerId)); - - AcpiNsDeleteChildren (*ReturnNode); - if (AcpiGbl_RuntimeNamespaceOverride) - { - AcpiUtRemoveReference ((*ReturnNode)->Object); - (*ReturnNode)->Object = NULL; - (*ReturnNode)->OwnerId = WalkState->OwnerId; - } - else - { - AcpiNsRemoveNode (*ReturnNode); - *ReturnNode = ACPI_ENTRY_NOT_FOUND; - } - } - - /* Return an error if we don't expect to find the object */ - - else if (Flags & ACPI_NS_ERROR_IF_FOUND) - { - Status = AE_ALREADY_EXISTS; - } - } - -#ifdef ACPI_ASL_COMPILER - if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) - { - (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; - } -#endif - - /* Either found it or there was an error: finished either way */ - - return_ACPI_STATUS (Status); - } - - /* - * The name was not found. If we are NOT performing the first pass - * (name entry) of loading the namespace, search the parent tree (all the - * way to the root if necessary.) We don't want to perform the parent - * search when the namespace is actually being loaded. We want to perform - * the search when namespace references are being resolved (load pass 2) - * and during the execution phase. - */ - if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && - (Flags & ACPI_NS_SEARCH_PARENT)) - { - /* - * Not found at this level - search parent tree according to the - * ACPI specification - */ - Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); - if (ACPI_SUCCESS (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* In execute mode, just search, never add names. Exit now */ - - if (InterpreterMode == ACPI_IMODE_EXECUTE) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "%4.4s Not found in %p [Not adding]\n", - ACPI_CAST_PTR (char, &TargetName), Node)); - - return_ACPI_STATUS (AE_NOT_FOUND); - } - - /* Create the new named object */ - - NewNode = AcpiNsCreateNode (TargetName); - if (!NewNode) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - -#ifdef ACPI_ASL_COMPILER - - /* Node is an object defined by an External() statement */ - - if (Flags & ACPI_NS_EXTERNAL || - (WalkState && WalkState->Opcode == AML_SCOPE_OP)) - { - NewNode->Flags |= ANOBJ_IS_EXTERNAL; - } -#endif - - if (Flags & ACPI_NS_TEMPORARY) - { - NewNode->Flags |= ANOBJ_TEMPORARY; - } - - /* Install the new object into the parent's list of children */ - - AcpiNsInstallNode (WalkState, Node, NewNode, Type); - *ReturnNode = NewNode; - return_ACPI_STATUS (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsutils.c b/usr/src/uts/intel/io/acpica/namespace/nsutils.c deleted file mode 100644 index 72f9105ef5..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsutils.c +++ /dev/null @@ -1,866 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing - * parents and siblings and Scope manipulation - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "amlcode.h" - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsutils") - -/* Local prototypes */ - -#ifdef ACPI_OBSOLETE_FUNCTIONS -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *NodeToSearch); -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiNsPrintNodePathname - * - * PARAMETERS: Node - Object - * Message - Prefix message - * - * DESCRIPTION: Print an object's full namespace pathname - * Manages allocation/freeing of a pathname buffer - * - ******************************************************************************/ - -void -AcpiNsPrintNodePathname ( - ACPI_NAMESPACE_NODE *Node, - const char *Message) -{ - ACPI_BUFFER Buffer; - ACPI_STATUS Status; - - - if (!Node) - { - AcpiOsPrintf ("[NULL NAME]"); - return; - } - - /* Convert handle to full pathname and print it (with supplied message) */ - - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - - Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE); - if (ACPI_SUCCESS (Status)) - { - if (Message) - { - AcpiOsPrintf ("%s ", Message); - } - - AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); - ACPI_FREE (Buffer.Pointer); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetType - * - * PARAMETERS: Node - Parent Node to be examined - * - * RETURN: Type field from Node whose handle is passed - * - * DESCRIPTION: Return the type of a Namespace node - * - ******************************************************************************/ - -ACPI_OBJECT_TYPE -AcpiNsGetType ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_FUNCTION_TRACE (NsGetType); - - - if (!Node) - { - ACPI_WARNING ((AE_INFO, "Null Node parameter")); - return_UINT8 (ACPI_TYPE_ANY); - } - - return_UINT8 (Node->Type); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsLocal - * - * PARAMETERS: Type - A namespace object type - * - * RETURN: LOCAL if names must be found locally in objects of the - * passed type, 0 if enclosing scopes should be searched - * - * DESCRIPTION: Returns scope rule for the given object type. - * - ******************************************************************************/ - -UINT32 -AcpiNsLocal ( - ACPI_OBJECT_TYPE Type) -{ - ACPI_FUNCTION_TRACE (NsLocal); - - - if (!AcpiUtValidObjectType (Type)) - { - /* Type code out of range */ - - ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type)); - return_UINT32 (ACPI_NS_NORMAL); - } - - return_UINT32 (AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetInternalNameLength - * - * PARAMETERS: Info - Info struct initialized with the - * external name pointer. - * - * RETURN: None - * - * DESCRIPTION: Calculate the length of the internal (AML) namestring - * corresponding to the external (ASL) namestring. - * - ******************************************************************************/ - -void -AcpiNsGetInternalNameLength ( - ACPI_NAMESTRING_INFO *Info) -{ - const char *NextExternalChar; - UINT32 i; - - - ACPI_FUNCTION_ENTRY (); - - - NextExternalChar = Info->ExternalName; - Info->NumCarats = 0; - Info->NumSegments = 0; - Info->FullyQualified = FALSE; - - /* - * For the internal name, the required length is 4 bytes per segment, - * plus 1 each for RootPrefix, MultiNamePrefixOp, segment count, - * trailing null (which is not really needed, but no there's harm in - * putting it there) - * - * strlen() + 1 covers the first NameSeg, which has no path separator - */ - if (ACPI_IS_ROOT_PREFIX (*NextExternalChar)) - { - Info->FullyQualified = TRUE; - NextExternalChar++; - - /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */ - - while (ACPI_IS_ROOT_PREFIX (*NextExternalChar)) - { - NextExternalChar++; - } - } - else - { - /* Handle Carat prefixes */ - - while (ACPI_IS_PARENT_PREFIX (*NextExternalChar)) - { - Info->NumCarats++; - NextExternalChar++; - } - } - - /* - * Determine the number of ACPI name "segments" by counting the number of - * path separators within the string. Start with one segment since the - * segment count is [(# separators) + 1], and zero separators is ok. - */ - if (*NextExternalChar) - { - Info->NumSegments = 1; - for (i = 0; NextExternalChar[i]; i++) - { - if (ACPI_IS_PATH_SEPARATOR (NextExternalChar[i])) - { - Info->NumSegments++; - } - } - } - - Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + - 4 + Info->NumCarats; - - Info->NextExternalChar = NextExternalChar; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsBuildInternalName - * - * PARAMETERS: Info - Info struct fully initialized - * - * RETURN: Status - * - * DESCRIPTION: Construct the internal (AML) namestring - * corresponding to the external (ASL) namestring. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsBuildInternalName ( - ACPI_NAMESTRING_INFO *Info) -{ - UINT32 NumSegments = Info->NumSegments; - char *InternalName = Info->InternalName; - const char *ExternalName = Info->NextExternalChar; - char *Result = NULL; - UINT32 i; - - - ACPI_FUNCTION_TRACE (NsBuildInternalName); - - - /* Setup the correct prefixes, counts, and pointers */ - - if (Info->FullyQualified) - { - InternalName[0] = AML_ROOT_PREFIX; - - if (NumSegments <= 1) - { - Result = &InternalName[1]; - } - else if (NumSegments == 2) - { - InternalName[1] = AML_DUAL_NAME_PREFIX; - Result = &InternalName[2]; - } - else - { - InternalName[1] = AML_MULTI_NAME_PREFIX_OP; - InternalName[2] = (char) NumSegments; - Result = &InternalName[3]; - } - } - else - { - /* - * Not fully qualified. - * Handle Carats first, then append the name segments - */ - i = 0; - if (Info->NumCarats) - { - for (i = 0; i < Info->NumCarats; i++) - { - InternalName[i] = AML_PARENT_PREFIX; - } - } - - if (NumSegments <= 1) - { - Result = &InternalName[i]; - } - else if (NumSegments == 2) - { - InternalName[i] = AML_DUAL_NAME_PREFIX; - Result = &InternalName[(ACPI_SIZE) i+1]; - } - else - { - InternalName[i] = AML_MULTI_NAME_PREFIX_OP; - InternalName[(ACPI_SIZE) i+1] = (char) NumSegments; - Result = &InternalName[(ACPI_SIZE) i+2]; - } - } - - /* Build the name (minus path separators) */ - - for (; NumSegments; NumSegments--) - { - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (ACPI_IS_PATH_SEPARATOR (*ExternalName) || - (*ExternalName == 0)) - { - /* Pad the segment with underscore(s) if segment is short */ - - Result[i] = '_'; - } - else - { - /* Convert the character to uppercase and save it */ - - Result[i] = (char) toupper ((int) *ExternalName); - ExternalName++; - } - } - - /* Now we must have a path separator, or the pathname is bad */ - - if (!ACPI_IS_PATH_SEPARATOR (*ExternalName) && - (*ExternalName != 0)) - { - return_ACPI_STATUS (AE_BAD_PATHNAME); - } - - /* Move on the next segment */ - - ExternalName++; - Result += ACPI_NAME_SIZE; - } - - /* Terminate the string */ - - *Result = 0; - - if (Info->FullyQualified) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", - InternalName, InternalName)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", - InternalName, InternalName)); - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsInternalizeName - * - * PARAMETERS: *ExternalName - External representation of name - * **Converted Name - Where to return the resulting - * internal represention of the name - * - * RETURN: Status - * - * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") - * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * - *******************************************************************************/ - -ACPI_STATUS -AcpiNsInternalizeName ( - const char *ExternalName, - char **ConvertedName) -{ - char *InternalName; - ACPI_NAMESTRING_INFO Info; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsInternalizeName); - - - if ((!ExternalName) || - (*ExternalName == 0) || - (!ConvertedName)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Get the length of the new internal name */ - - Info.ExternalName = ExternalName; - AcpiNsGetInternalNameLength (&Info); - - /* We need a segment to store the internal name */ - - InternalName = ACPI_ALLOCATE_ZEROED (Info.Length); - if (!InternalName) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Build the name */ - - Info.InternalName = InternalName; - Status = AcpiNsBuildInternalName (&Info); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (InternalName); - return_ACPI_STATUS (Status); - } - - *ConvertedName = InternalName; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsExternalizeName - * - * PARAMETERS: InternalNameLength - Lenth of the internal name below - * InternalName - Internal representation of name - * ConvertedNameLength - Where the length is returned - * ConvertedName - Where the resulting external name - * is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external (printable) form (e.g. "\_PR_.CPU0") - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsExternalizeName ( - UINT32 InternalNameLength, - const char *InternalName, - UINT32 *ConvertedNameLength, - char **ConvertedName) -{ - UINT32 NamesIndex = 0; - UINT32 NumSegments = 0; - UINT32 RequiredLength; - UINT32 PrefixLength = 0; - UINT32 i = 0; - UINT32 j = 0; - - - ACPI_FUNCTION_TRACE (NsExternalizeName); - - - if (!InternalNameLength || - !InternalName || - !ConvertedName) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Check for a prefix (one '\' | one or more '^') */ - - switch (InternalName[0]) - { - case AML_ROOT_PREFIX: - - PrefixLength = 1; - break; - - case AML_PARENT_PREFIX: - - for (i = 0; i < InternalNameLength; i++) - { - if (ACPI_IS_PARENT_PREFIX (InternalName[i])) - { - PrefixLength = i + 1; - } - else - { - break; - } - } - - if (i == InternalNameLength) - { - PrefixLength = i; - } - - break; - - default: - - break; - } - - /* - * Check for object names. Note that there could be 0-255 of these - * 4-byte elements. - */ - if (PrefixLength < InternalNameLength) - { - switch (InternalName[PrefixLength]) - { - case AML_MULTI_NAME_PREFIX_OP: - - /* <count> 4-byte names */ - - NamesIndex = PrefixLength + 2; - NumSegments = (UINT8) - InternalName[(ACPI_SIZE) PrefixLength + 1]; - break; - - case AML_DUAL_NAME_PREFIX: - - /* Two 4-byte names */ - - NamesIndex = PrefixLength + 1; - NumSegments = 2; - break; - - case 0: - - /* NullName */ - - NamesIndex = 0; - NumSegments = 0; - break; - - default: - - /* one 4-byte name */ - - NamesIndex = PrefixLength; - NumSegments = 1; - break; - } - } - - /* - * Calculate the length of ConvertedName, which equals the length - * of the prefix, length of all object names, length of any required - * punctuation ('.') between object names, plus the NULL terminator. - */ - 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 (RequiredLength > InternalNameLength) - { - ACPI_ERROR ((AE_INFO, "Invalid internal name")); - return_ACPI_STATUS (AE_BAD_PATHNAME); - } - - /* Build the ConvertedName */ - - *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); - if (!(*ConvertedName)) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - j = 0; - - for (i = 0; i < PrefixLength; i++) - { - (*ConvertedName)[j++] = InternalName[i]; - } - - if (NumSegments > 0) - { - for (i = 0; i < NumSegments; i++) - { - if (i > 0) - { - (*ConvertedName)[j++] = '.'; - } - - /* Copy and validate the 4-char name segment */ - - ACPI_MOVE_NAME (&(*ConvertedName)[j], - &InternalName[NamesIndex]); - AcpiUtRepairName (&(*ConvertedName)[j]); - - j += ACPI_NAME_SIZE; - NamesIndex += ACPI_NAME_SIZE; - } - } - - if (ConvertedNameLength) - { - *ConvertedNameLength = (UINT32) RequiredLength; - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsValidateHandle - * - * PARAMETERS: Handle - Handle to be validated and typecast to a - * namespace node. - * - * RETURN: A pointer to a namespace node - * - * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special - * cases for the root node. - * - * NOTE: Real integer handles would allow for more verification - * and keep all pointers within this subsystem - however this introduces - * more overhead and has not been necessary to this point. Drivers - * holding handles are typically notified before a node becomes invalid - * due to a table unload. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsValidateHandle ( - ACPI_HANDLE Handle) -{ - - ACPI_FUNCTION_ENTRY (); - - - /* Parameter validation */ - - if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) - { - return (AcpiGbl_RootNode); - } - - /* We can at least attempt to verify the handle */ - - if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) - { - return (NULL); - } - - return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle)); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsTerminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for namespace and ACPI table storage. - * - ******************************************************************************/ - -void -AcpiNsTerminate ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (NsTerminate); - - -#ifdef ACPI_EXEC_APP - { - ACPI_OPERAND_OBJECT *Prev; - ACPI_OPERAND_OBJECT *Next; - - /* Delete any module-level code blocks */ - - Next = AcpiGbl_ModuleCodeList; - while (Next) - { - Prev = Next; - Next = Next->Method.Mutex; - Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */ - AcpiUtRemoveReference (Prev); - } - } -#endif - - /* - * Free the entire namespace -- all nodes and all objects - * attached to the nodes - */ - AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); - - /* Delete any objects attached to the root node */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_VOID; - } - - AcpiNsDeleteNode (AcpiGbl_RootNode); - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsOpensScope - * - * PARAMETERS: Type - A valid namespace type - * - * RETURN: NEWSCOPE if the passed type "opens a name scope" according - * to the ACPI specification, else 0 - * - ******************************************************************************/ - -UINT32 -AcpiNsOpensScope ( - ACPI_OBJECT_TYPE Type) -{ - ACPI_FUNCTION_ENTRY (); - - - if (Type > ACPI_TYPE_LOCAL_MAX) - { - /* type code out of range */ - - ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type)); - return (ACPI_NS_NORMAL); - } - - return (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetNode - * - * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The - * \ (backslash) and ^ (carat) prefixes, and the - * . (period) to separate segments are supported. - * PrefixNode - Root of subtree to be searched, or NS_ALL for the - * 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 - * corresponding Node. NOTE: Scope can be null. - * - * MUTEX: Locks namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsGetNode ( - ACPI_NAMESPACE_NODE *PrefixNode, - const char *Pathname, - UINT32 Flags, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_GENERIC_STATE ScopeInfo; - ACPI_STATUS Status; - char *InternalPath; - - - ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); - - - /* Simplest case is a null pathname */ - - if (!Pathname) - { - *ReturnNode = PrefixNode; - if (!PrefixNode) - { - *ReturnNode = AcpiGbl_RootNode; - } - - return_ACPI_STATUS (AE_OK); - } - - /* Quick check for a reference to the root */ - - if (ACPI_IS_ROOT_PREFIX (Pathname[0]) && (!Pathname[1])) - { - *ReturnNode = AcpiGbl_RootNode; - return_ACPI_STATUS (AE_OK); - } - - /* Convert path to internal representation */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Must lock namespace during lookup */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Setup lookup scope (search starting point) */ - - ScopeInfo.Scope.Node = PrefixNode; - - /* Lookup the name in the namespace */ - - Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), - NULL, ReturnNode); - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", - Pathname, AcpiFormatException (Status))); - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - -Cleanup: - ACPI_FREE (InternalPath); - return_ACPI_STATUS (Status); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nswalk.c b/usr/src/uts/intel/io/acpica/namespace/nswalk.c deleted file mode 100644 index 08637a6eee..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nswalk.c +++ /dev/null @@ -1,381 +0,0 @@ -/****************************************************************************** - * - * Module Name: nswalk - Functions for walking the ACPI namespace - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nswalk") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetNextNode - * - * PARAMETERS: ParentNode - Parent node whose children we are - * getting - * ChildNode - Previous child that was found. - * The NEXT child will be returned - * - * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if - * none is found. - * - * DESCRIPTION: Return the next peer node within the namespace. If Handle - * is valid, Scope is ignored. Otherwise, the first node - * within Scope is returned. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsGetNextNode ( - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_FUNCTION_ENTRY (); - - - if (!ChildNode) - { - /* It's really the parent's _scope_ that we want */ - - return (ParentNode->Child); - } - - /* Otherwise just return the next peer */ - - return (ChildNode->Peer); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetNextNodeTyped - * - * PARAMETERS: Type - Type of node to be searched for - * ParentNode - Parent node whose children we are - * getting - * ChildNode - Previous child that was found. - * The NEXT child will be returned - * - * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if - * none is found. - * - * DESCRIPTION: Return the next peer node within the namespace. If Handle - * is valid, Scope is ignored. Otherwise, the first node - * within Scope is returned. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsGetNextNodeTyped ( - ACPI_OBJECT_TYPE Type, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *NextNode = NULL; - - - ACPI_FUNCTION_ENTRY (); - - - NextNode = AcpiNsGetNextNode (ParentNode, ChildNode); - - /* If any type is OK, we are done */ - - if (Type == ACPI_TYPE_ANY) - { - /* NextNode is NULL if we are at the end-of-list */ - - return (NextNode); - } - - /* Must search for the node -- but within this scope only */ - - while (NextNode) - { - /* If type matches, we are done */ - - if (NextNode->Type == Type) - { - return (NextNode); - } - - /* Otherwise, move on to the next peer node */ - - NextNode = NextNode->Peer; - } - - /* Not found */ - - return (NULL); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsWalkNamespace - * - * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for - * StartNode - Handle in namespace where search begins - * MaxDepth - Depth to which search is to reach - * Flags - Whether to unlock the NS before invoking - * the callback routine - * DescendingCallback - Called during tree descent - * when an object of "Type" is found - * AscendingCallback - Called during tree ascent - * when an object of "Type" is found - * Context - Passed to user function(s) above - * ReturnValue - from the UserFunction if terminated - * early. Otherwise, returns NULL. - * RETURNS: Status - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the node specified by StartHandle. - * The callback function is called whenever a node that matches - * the type parameter is found. If the callback function returns - * a non-zero value, the search is terminated immediately and - * this value is returned to the caller. - * - * The point of this procedure is to provide a generic namespace - * walk routine that can be called from multiple places to - * provide multiple services; the callback function(s) can be - * tailored to each task, whether it is a print function, - * a compare function, etc. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsWalkNamespace ( - ACPI_OBJECT_TYPE Type, - ACPI_HANDLE StartNode, - UINT32 MaxDepth, - UINT32 Flags, - ACPI_WALK_CALLBACK DescendingCallback, - ACPI_WALK_CALLBACK AscendingCallback, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - ACPI_STATUS MutexStatus; - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_OBJECT_TYPE ChildType; - UINT32 Level; - BOOLEAN NodePreviouslyVisited = FALSE; - - - ACPI_FUNCTION_TRACE (NsWalkNamespace); - - - /* Special case for the namespace Root Node */ - - if (StartNode == ACPI_ROOT_OBJECT) - { - StartNode = AcpiGbl_RootNode; - } - - /* Null child means "get first node" */ - - ParentNode = StartNode; - ChildNode = AcpiNsGetNextNode (ParentNode, NULL); - ChildType = ACPI_TYPE_ANY; - Level = 1; - - /* - * Traverse the tree of nodes until we bubble back up to where we - * started. When Level is zero, the loop is done because we have - * bubbled up to (and passed) the original parent handle (StartEntry) - */ - while (Level > 0 && ChildNode) - { - Status = AE_OK; - - /* Found next child, get the type if we are not searching for ANY */ - - if (Type != ACPI_TYPE_ANY) - { - ChildType = ChildNode->Type; - } - - /* - * Ignore all temporary namespace nodes (created during control - * method execution) unless told otherwise. These temporary nodes - * can cause a race condition because they can be deleted during - * the execution of the user function (if the namespace is - * unlocked before invocation of the user function.) Only the - * debugger namespace dump will examine the temporary nodes. - */ - if ((ChildNode->Flags & ANOBJ_TEMPORARY) && - !(Flags & ACPI_NS_WALK_TEMP_NODES)) - { - Status = AE_CTRL_DEPTH; - } - - /* Type must match requested type */ - - else if (ChildType == Type) - { - /* - * Found a matching node, invoke the user callback function. - * Unlock the namespace if flag is set. - */ - if (Flags & ACPI_NS_WALK_UNLOCK) - { - MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (MutexStatus)) - { - return_ACPI_STATUS (MutexStatus); - } - } - - /* - * Invoke the user function, either descending, ascending, - * or both. - */ - if (!NodePreviouslyVisited) - { - if (DescendingCallback) - { - Status = DescendingCallback (ChildNode, Level, - Context, ReturnValue); - } - } - else - { - if (AscendingCallback) - { - Status = AscendingCallback (ChildNode, Level, - Context, ReturnValue); - } - } - - if (Flags & ACPI_NS_WALK_UNLOCK) - { - MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (MutexStatus)) - { - return_ACPI_STATUS (MutexStatus); - } - } - - switch (Status) - { - case AE_OK: - case AE_CTRL_DEPTH: - - /* Just keep going */ - break; - - case AE_CTRL_TERMINATE: - - /* Exit now, with OK status */ - - return_ACPI_STATUS (AE_OK); - - default: - - /* All others are valid exceptions */ - - return_ACPI_STATUS (Status); - } - } - - /* - * Depth first search: Attempt to go down another level in the - * namespace if we are allowed to. Don't go any further if we have - * reached the caller specified maximum depth or if the user - * function has specified that the maximum depth has been reached. - */ - if (!NodePreviouslyVisited && - (Level < MaxDepth) && - (Status != AE_CTRL_DEPTH)) - { - if (ChildNode->Child) - { - /* There is at least one child of this node, visit it */ - - Level++; - ParentNode = ChildNode; - ChildNode = AcpiNsGetNextNode (ParentNode, NULL); - continue; - } - } - - /* No more children, re-visit this node */ - - if (!NodePreviouslyVisited) - { - NodePreviouslyVisited = TRUE; - continue; - } - - /* No more children, visit peers */ - - ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); - if (ChildNode) - { - NodePreviouslyVisited = FALSE; - } - - /* No peers, re-visit parent */ - - else - { - /* - * No more children of this node (AcpiNsGetNextNode failed), go - * back upwards in the namespace tree to the node's parent. - */ - Level--; - ChildNode = ParentNode; - ParentNode = ParentNode->Parent; - - NodePreviouslyVisited = TRUE; - } - } - - /* Complete walk, not terminated by user function */ - - return_ACPI_STATUS (AE_OK); -} diff --git a/usr/src/uts/intel/io/acpica/namespace/nsxfeval.c b/usr/src/uts/intel/io/acpica/namespace/nsxfeval.c deleted file mode 100644 index b88ecf507e..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsxfeval.c +++ /dev/null @@ -1,1078 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsxfeval - Public interfaces to the ACPI subsystem - * ACPI Object evaluation interfaces - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#define EXPORT_ACPI_INTERFACES - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acinterp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfeval") - -/* Local prototypes */ - -static void -AcpiNsResolveReferences ( - ACPI_EVALUATE_INFO *Info); - - -/******************************************************************************* - * - * FUNCTION: AcpiEvaluateObjectTyped - * - * PARAMETERS: Handle - Object handle (optional) - * Pathname - Object pathname (optional) - * ExternalParams - List of parameters to pass to method, - * terminated by NULL. May be NULL - * if no parameters are being passed. - * ReturnBuffer - Where to put method's return value (if - * any). If NULL, no value is returned. - * ReturnType - Expected type of return object - * - * RETURN: Status - * - * DESCRIPTION: Find and evaluate the given object, passing the given - * parameters if necessary. One of "Handle" or "Pathname" must - * be valid (non-null) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvaluateObjectTyped ( - ACPI_HANDLE Handle, - ACPI_STRING Pathname, - ACPI_OBJECT_LIST *ExternalParams, - ACPI_BUFFER *ReturnBuffer, - ACPI_OBJECT_TYPE ReturnType) -{ - ACPI_STATUS Status; - BOOLEAN FreeBufferOnError = FALSE; - - - ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); - - - /* Return buffer must be valid */ - - if (!ReturnBuffer) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) - { - FreeBufferOnError = TRUE; - } - - /* Evaluate the object */ - - Status = AcpiEvaluateObject (Handle, Pathname, - ExternalParams, ReturnBuffer); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Type ANY means "don't care" */ - - if (ReturnType == ACPI_TYPE_ANY) - { - return_ACPI_STATUS (AE_OK); - } - - if (ReturnBuffer->Length == 0) - { - /* Error because caller specifically asked for a return value */ - - ACPI_ERROR ((AE_INFO, "No return value")); - return_ACPI_STATUS (AE_NULL_OBJECT); - } - - /* Examine the object type returned from EvaluateObject */ - - if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) - { - return_ACPI_STATUS (AE_OK); - } - - /* Return object type does not match requested type */ - - ACPI_ERROR ((AE_INFO, - "Incorrect return type [%s] requested [%s]", - AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), - AcpiUtGetTypeName (ReturnType))); - - if (FreeBufferOnError) - { - /* - * Free a buffer created via ACPI_ALLOCATE_BUFFER. - * Note: We use AcpiOsFree here because AcpiOsAllocate was used - * to allocate the buffer. This purposefully bypasses the - * (optionally enabled) allocation tracking mechanism since we - * only want to track internal allocations. - */ - AcpiOsFree (ReturnBuffer->Pointer); - ReturnBuffer->Pointer = NULL; - } - - ReturnBuffer->Length = 0; - return_ACPI_STATUS (AE_TYPE); -} - -ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped) - - -/******************************************************************************* - * - * FUNCTION: AcpiEvaluateObject - * - * PARAMETERS: Handle - Object handle (optional) - * Pathname - Object pathname (optional) - * ExternalParams - List of parameters to pass to method, - * terminated by NULL. May be NULL - * if no parameters are being passed. - * ReturnBuffer - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Find and evaluate the given object, passing the given - * parameters if necessary. One of "Handle" or "Pathname" must - * be valid (non-null) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvaluateObject ( - ACPI_HANDLE Handle, - ACPI_STRING Pathname, - ACPI_OBJECT_LIST *ExternalParams, - ACPI_BUFFER *ReturnBuffer) -{ - ACPI_STATUS Status; - ACPI_EVALUATE_INFO *Info; - ACPI_SIZE BufferSpaceNeeded; - UINT32 i; - - - ACPI_FUNCTION_TRACE (AcpiEvaluateObject); - - - /* Allocate and initialize the evaluation information block */ - - Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); - if (!Info) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Convert and validate the device handle */ - - Info->PrefixNode = AcpiNsValidateHandle (Handle); - if (!Info->PrefixNode) - { - Status = AE_BAD_PARAMETER; - goto Cleanup; - } - - /* - * Get the actual namespace node for the target object. - * Handles these cases: - * - * 1) Null node, valid pathname from root (absolute path) - * 2) Node and valid pathname (path relative to Node) - * 3) Node, Null pathname - */ - if ((Pathname) && - (ACPI_IS_ROOT_PREFIX (Pathname[0]))) - { - /* The path is fully qualified, just evaluate by name */ - - Info->PrefixNode = NULL; - } - else if (!Handle) - { - /* - * A handle is optional iff a fully qualified pathname is specified. - * Since we've already handled fully qualified names above, this is - * an error. - */ - if (!Pathname) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Both Handle and Pathname are NULL")); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Null Handle with relative pathname [%s]", Pathname)); - } - - Status = AE_BAD_PARAMETER; - goto Cleanup; - } - - Info->RelativePathname = Pathname; - - /* - * Convert all external objects passed as arguments to the - * internal version(s). - */ - if (ExternalParams && ExternalParams->Count) - { - Info->ParamCount = (UINT16) ExternalParams->Count; - - /* Warn on impossible argument count */ - - if (Info->ParamCount > ACPI_METHOD_NUM_ARGS) - { - ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, - "Excess arguments (%u) - using only %u", - Info->ParamCount, ACPI_METHOD_NUM_ARGS)); - - Info->ParamCount = ACPI_METHOD_NUM_ARGS; - } - - /* - * Allocate a new parameter block for the internal objects - * Add 1 to count to allow for null terminated internal list - */ - Info->Parameters = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) Info->ParamCount + 1) * sizeof (void *)); - if (!Info->Parameters) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Convert each external object in the list to an internal object */ - - for (i = 0; i < Info->ParamCount; i++) - { - Status = AcpiUtCopyEobjectToIobject ( - &ExternalParams->Pointer[i], &Info->Parameters[i]); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } - - Info->Parameters[Info->ParamCount] = NULL; - } - - -#ifdef _FUTURE_FEATURE - - /* - * Begin incoming argument count analysis. Check for too few args - * and too many args. - */ - switch (AcpiNsGetType (Info->Node)) - { - case ACPI_TYPE_METHOD: - - /* Check incoming argument count against the method definition */ - - if (Info->ObjDesc->Method.ParamCount > Info->ParamCount) - { - ACPI_ERROR ((AE_INFO, - "Insufficient arguments (%u) - %u are required", - Info->ParamCount, - Info->ObjDesc->Method.ParamCount)); - - Status = AE_MISSING_ARGUMENTS; - goto Cleanup; - } - - else if (Info->ObjDesc->Method.ParamCount < Info->ParamCount) - { - ACPI_WARNING ((AE_INFO, - "Excess arguments (%u) - only %u are required", - Info->ParamCount, - Info->ObjDesc->Method.ParamCount)); - - /* Just pass the required number of arguments */ - - Info->ParamCount = Info->ObjDesc->Method.ParamCount; - } - - /* - * Any incoming external objects to be passed as arguments to the - * method must be converted to internal objects - */ - if (Info->ParamCount) - { - /* - * Allocate a new parameter block for the internal objects - * Add 1 to count to allow for null terminated internal list - */ - Info->Parameters = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) Info->ParamCount + 1) * sizeof (void *)); - if (!Info->Parameters) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Convert each external object in the list to an internal object */ - - for (i = 0; i < Info->ParamCount; i++) - { - Status = AcpiUtCopyEobjectToIobject ( - &ExternalParams->Pointer[i], &Info->Parameters[i]); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } - - Info->Parameters[Info->ParamCount] = NULL; - } - break; - - default: - - /* Warn if arguments passed to an object that is not a method */ - - if (Info->ParamCount) - { - ACPI_WARNING ((AE_INFO, - "%u arguments were passed to a non-method ACPI object", - Info->ParamCount)); - } - break; - } - -#endif - - - /* Now we can evaluate the object */ - - Status = AcpiNsEvaluate (Info); - - /* - * If we are expecting a return value, and all went well above, - * copy the return value to an external object. - */ - if (!ReturnBuffer) - { - goto CleanupReturnObject; - } - - if (!Info->ReturnObject) - { - ReturnBuffer->Length = 0; - goto Cleanup; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == - ACPI_DESC_TYPE_NAMED) - { - /* - * If we received a NS Node as a return object, this means that - * the object we are evaluating has nothing interesting to - * return (such as a mutex, etc.) We return an error because - * these types are essentially unsupported by this interface. - * We don't check up front because this makes it easier to add - * support for various types at a later date if necessary. - */ - Status = AE_TYPE; - Info->ReturnObject = NULL; /* No need to delete a NS Node */ - ReturnBuffer->Length = 0; - } - - if (ACPI_FAILURE (Status)) - { - goto CleanupReturnObject; - } - - /* Dereference Index and RefOf references */ - - AcpiNsResolveReferences (Info); - - /* Get the size of the returned object */ - - Status = AcpiUtGetObjectSize (Info->ReturnObject, - &BufferSpaceNeeded); - if (ACPI_SUCCESS (Status)) - { - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (ReturnBuffer, - BufferSpaceNeeded); - if (ACPI_FAILURE (Status)) - { - /* - * Caller's buffer is too small or a new one can't - * be allocated - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Needed buffer size %X, %s\n", - (UINT32) BufferSpaceNeeded, - AcpiFormatException (Status))); - } - else - { - /* We have enough space for the object, build it */ - - Status = AcpiUtCopyIobjectToEobject ( - Info->ReturnObject, ReturnBuffer); - } - } - -CleanupReturnObject: - - if (Info->ReturnObject) - { - /* - * Delete the internal return object. NOTE: Interpreter must be - * locked to avoid race condition. - */ - AcpiExEnterInterpreter (); - - /* Remove one reference on the return object (should delete it) */ - - AcpiUtRemoveReference (Info->ReturnObject); - AcpiExExitInterpreter (); - } - - -Cleanup: - - /* Free the input parameter list (if we created one) */ - - if (Info->Parameters) - { - /* Free the allocated parameter block */ - - AcpiUtDeleteInternalObjectList (Info->Parameters); - } - - ACPI_FREE (Info); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) - - -/******************************************************************************* - * - * FUNCTION: AcpiNsResolveReferences - * - * PARAMETERS: Info - Evaluation info block - * - * RETURN: Info->ReturnObject is replaced with the dereferenced object - * - * DESCRIPTION: Dereference certain reference objects. Called before an - * internal return object is converted to an external ACPI_OBJECT. - * - * Performs an automatic dereference of Index and RefOf reference objects. - * These reference objects are not supported by the ACPI_OBJECT, so this is a - * last resort effort to return something useful. Also, provides compatibility - * with other ACPI implementations. - * - * NOTE: does not handle references within returned package objects or nested - * references, but this support could be added later if found to be necessary. - * - ******************************************************************************/ - -static void -AcpiNsResolveReferences ( - ACPI_EVALUATE_INFO *Info) -{ - ACPI_OPERAND_OBJECT *ObjDesc = NULL; - ACPI_NAMESPACE_NODE *Node; - - - /* We are interested in reference objects only */ - - if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) - { - return; - } - - /* - * Two types of references are supported - those created by Index and - * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted - * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle - * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to - * an ACPI_OBJECT. - */ - switch (Info->ReturnObject->Reference.Class) - { - case ACPI_REFCLASS_INDEX: - - ObjDesc = *(Info->ReturnObject->Reference.Where); - break; - - case ACPI_REFCLASS_REFOF: - - Node = Info->ReturnObject->Reference.Object; - if (Node) - { - ObjDesc = Node->Object; - } - break; - - default: - - return; - } - - /* Replace the existing reference object */ - - if (ObjDesc) - { - AcpiUtAddReference (ObjDesc); - AcpiUtRemoveReference (Info->ReturnObject); - Info->ReturnObject = ObjDesc; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiWalkNamespace - * - * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for - * StartObject - Handle in namespace where search begins - * MaxDepth - Depth to which search is to reach - * DescendingCallback - Called during tree descent - * when an object of "Type" is found - * AscendingCallback - Called during tree ascent - * when an object of "Type" is found - * Context - Passed to user function(s) above - * ReturnValue - Location where return value of - * UserFunction is put if terminated early - * - * RETURNS Return value from the UserFunction if terminated early. - * Otherwise, returns NULL. - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the object specified by StartHandle. - * The callback function is called whenever an object that matches - * the type parameter is found. If the callback function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. - * - * The point of this procedure is to provide a generic namespace - * walk routine that can be called from multiple places to - * provide multiple services; the callback function(s) can be - * tailored to each task, whether it is a print function, - * a compare function, etc. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiWalkNamespace ( - ACPI_OBJECT_TYPE Type, - ACPI_HANDLE StartObject, - UINT32 MaxDepth, - ACPI_WALK_CALLBACK DescendingCallback, - ACPI_WALK_CALLBACK AscendingCallback, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiWalkNamespace); - - - /* Parameter validation */ - - if ((Type > ACPI_TYPE_LOCAL_MAX) || - (!MaxDepth) || - (!DescendingCallback && !AscendingCallback)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Need to acquire the namespace reader lock to prevent interference - * with any concurrent table unloads (which causes the deletion of - * namespace objects). We cannot allow the deletion of a namespace node - * while the user function is using it. The exception to this are the - * nodes created and deleted during control method execution -- these - * nodes are marked as temporary nodes and are ignored by the namespace - * walk. Thus, control methods can be executed while holding the - * namespace deletion lock (and the user function can execute control - * methods.) - */ - Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Lock the namespace around the walk. The namespace will be - * unlocked/locked around each call to the user function - since the user - * function must be allowed to make ACPICA calls itself (for example, it - * will typically execute control methods during device enumeration.) - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Now we can validate the starting node */ - - if (!AcpiNsValidateHandle (StartObject)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit2; - } - - Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, - ACPI_NS_WALK_UNLOCK, DescendingCallback, - AscendingCallback, Context, ReturnValue); - -UnlockAndExit2: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - -UnlockAndExit: - (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiWalkNamespace) - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetDeviceCallback - * - * PARAMETERS: Callback from AcpiGetDevice - * - * RETURN: Status - * - * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- - * present devices, or if they specified a HID, it filters based - * on that. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsGetDeviceCallback ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_GET_DEVICES_INFO *Info = Context; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - UINT32 Flags; - ACPI_PNP_DEVICE_ID *Hid; - ACPI_PNP_DEVICE_ID_LIST *Cid; - UINT32 i; - BOOLEAN Found; - int NoMatch; - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Node = AcpiNsValidateHandle (ObjHandle); - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (!Node) - { - return (AE_BAD_PARAMETER); - } - - /* - * First, filter based on the device HID and CID. - * - * 01/2010: For this case where a specific HID is requested, we don't - * want to run _STA until we have an actual HID match. Thus, we will - * not unnecessarily execute _STA on devices for which the caller - * doesn't care about. Previously, _STA was executed unconditionally - * on all devices found here. - * - * A side-effect of this change is that now we will continue to search - * for a matching HID even under device trees where the parent device - * would have returned a _STA that indicates it is not present or - * not functioning (thus aborting the search on that branch). - */ - if (Info->Hid != NULL) - { - Status = AcpiUtExecute_HID (Node, &Hid); - if (Status == AE_NOT_FOUND) - { - return (AE_OK); - } - else if (ACPI_FAILURE (Status)) - { - return (AE_CTRL_DEPTH); - } - - NoMatch = strcmp (Hid->String, Info->Hid); - ACPI_FREE (Hid); - - if (NoMatch) - { - /* - * HID does not match, attempt match within the - * list of Compatible IDs (CIDs) - */ - Status = AcpiUtExecute_CID (Node, &Cid); - if (Status == AE_NOT_FOUND) - { - return (AE_OK); - } - else if (ACPI_FAILURE (Status)) - { - return (AE_CTRL_DEPTH); - } - - /* Walk the CID list */ - - Found = FALSE; - for (i = 0; i < Cid->Count; i++) - { - if (strcmp (Cid->Ids[i].String, Info->Hid) == 0) - { - /* Found a matching CID */ - - Found = TRUE; - break; - } - } - - ACPI_FREE (Cid); - if (!Found) - { - return (AE_OK); - } - } - } - - /* Run _STA to determine if device is present */ - - Status = AcpiUtExecute_STA (Node, &Flags); - if (ACPI_FAILURE (Status)) - { - return (AE_CTRL_DEPTH); - } - - if (!(Flags & ACPI_STA_DEVICE_PRESENT) && - !(Flags & ACPI_STA_DEVICE_FUNCTIONING)) - { - /* - * Don't examine the children of the device only when the - * device is neither present nor functional. See ACPI spec, - * description of _STA for more information. - */ - return (AE_CTRL_DEPTH); - } - - /* We have a valid device, invoke the user function */ - - Status = Info->UserFunction (ObjHandle, NestingLevel, - Info->Context, ReturnValue); - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiGetDevices - * - * PARAMETERS: HID - HID to search for. Can be NULL. - * UserFunction - Called when a matching object is found - * Context - Passed to user function - * ReturnValue - Location where return value of - * UserFunction is put if terminated early - * - * RETURNS Return value from the UserFunction if terminated early. - * Otherwise, returns NULL. - * - * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, - * starting (and ending) at the object specified by StartHandle. - * The UserFunction is called whenever an object of type - * Device is found. If the user function returns - * a non-zero value, the search is terminated immediately and this - * value is returned to the caller. - * - * This is a wrapper for WalkNamespace, but the callback performs - * additional filtering. Please see AcpiNsGetDeviceCallback. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetDevices ( - char *HID, - ACPI_WALK_CALLBACK UserFunction, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - ACPI_GET_DEVICES_INFO Info; - - - ACPI_FUNCTION_TRACE (AcpiGetDevices); - - - /* Parameter validation */ - - if (!UserFunction) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * We're going to call their callback from OUR callback, so we need - * to know what it is, and their context parameter. - */ - Info.Hid = HID; - Info.Context = Context; - Info.UserFunction = UserFunction; - - /* - * Lock the namespace around the walk. - * The namespace will be unlocked/locked around each call - * to the user function - since this function - * must be allowed to make Acpi calls itself. - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetDevices) - - -/******************************************************************************* - * - * FUNCTION: AcpiAttachData - * - * PARAMETERS: ObjHandle - Namespace node - * Handler - Handler for this attachment - * Data - Pointer to data to be attached - * - * RETURN: Status - * - * DESCRIPTION: Attach arbitrary data and handler to a namespace node. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiAttachData ( - ACPI_HANDLE ObjHandle, - ACPI_OBJECT_HANDLER Handler, - void *Data) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - /* Parameter validation */ - - if (!ObjHandle || - !Handler || - !Data) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Convert and validate the handle */ - - Node = AcpiNsValidateHandle (ObjHandle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - Status = AcpiNsAttachData (Node, Handler, Data); - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiAttachData) - - -/******************************************************************************* - * - * FUNCTION: AcpiDetachData - * - * PARAMETERS: ObjHandle - Namespace node handle - * Handler - Handler used in call to AcpiAttachData - * - * RETURN: Status - * - * DESCRIPTION: Remove data that was previously attached to a node. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDetachData ( - ACPI_HANDLE ObjHandle, - ACPI_OBJECT_HANDLER Handler) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - /* Parameter validation */ - - if (!ObjHandle || - !Handler) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Convert and validate the handle */ - - Node = AcpiNsValidateHandle (ObjHandle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - Status = AcpiNsDetachData (Node, Handler); - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiDetachData) - - -/******************************************************************************* - * - * FUNCTION: AcpiGetData - * - * PARAMETERS: ObjHandle - Namespace node - * Handler - Handler used in call to AttachData - * Data - Where the data is returned - * - * RETURN: Status - * - * DESCRIPTION: Retrieve data that was previously attached to a namespace node. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetData ( - ACPI_HANDLE ObjHandle, - ACPI_OBJECT_HANDLER Handler, - void **Data) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - /* Parameter validation */ - - if (!ObjHandle || - !Handler || - !Data) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Convert and validate the handle */ - - Node = AcpiNsValidateHandle (ObjHandle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - Status = AcpiNsGetAttachedData (Node, Handler, Data); - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetData) diff --git a/usr/src/uts/intel/io/acpica/namespace/nsxfname.c b/usr/src/uts/intel/io/acpica/namespace/nsxfname.c deleted file mode 100644 index cfd6937f49..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsxfname.c +++ /dev/null @@ -1,738 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsxfname - Public interfaces to the ACPI subsystem - * ACPI Namespace oriented interfaces - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#define EXPORT_ACPI_INTERFACES - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" -#include "acparser.h" -#include "amlcode.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfname") - -/* Local prototypes */ - -static char * -AcpiNsCopyDeviceId ( - ACPI_PNP_DEVICE_ID *Dest, - ACPI_PNP_DEVICE_ID *Source, - char *StringArea); - - -/****************************************************************************** - * - * FUNCTION: AcpiGetHandle - * - * PARAMETERS: Parent - Object to search under (search scope). - * Pathname - Pointer to an asciiz string containing the - * name - * RetHandle - Where the return handle is returned - * - * RETURN: Status - * - * DESCRIPTION: This routine will search for a caller specified name in the - * name space. The caller can restrict the search region by - * specifying a non NULL parent. The parent value is itself a - * namespace handle. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetHandle ( - ACPI_HANDLE Parent, - ACPI_STRING Pathname, - ACPI_HANDLE *RetHandle) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; - ACPI_NAMESPACE_NODE *PrefixNode = NULL; - - - ACPI_FUNCTION_ENTRY (); - - - /* Parameter Validation */ - - if (!RetHandle || !Pathname) - { - return (AE_BAD_PARAMETER); - } - - /* Convert a parent handle to a prefix node */ - - if (Parent) - { - PrefixNode = AcpiNsValidateHandle (Parent); - if (!PrefixNode) - { - return (AE_BAD_PARAMETER); - } - } - - /* - * Valid cases are: - * 1) Fully qualified pathname - * 2) Parent + Relative pathname - * - * Error for <null Parent + relative path> - */ - if (ACPI_IS_ROOT_PREFIX (Pathname[0])) - { - /* Pathname is fully qualified (starts with '\') */ - - /* Special case for root-only, since we can't search for it */ - - if (!strcmp (Pathname, ACPI_NS_ROOT_PATH)) - { - *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); - return (AE_OK); - } - } - else if (!PrefixNode) - { - /* Relative path with null prefix is disallowed */ - - return (AE_BAD_PARAMETER); - } - - /* Find the Node and convert to a handle */ - - Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); - if (ACPI_SUCCESS (Status)) - { - *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); - } - - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetHandle) - - -/****************************************************************************** - * - * FUNCTION: AcpiGetName - * - * PARAMETERS: Handle - Handle to be converted to a pathname - * NameType - Full pathname or single segment - * Buffer - Buffer for returned path - * - * RETURN: Pointer to a string containing the fully qualified Name. - * - * DESCRIPTION: This routine returns the fully qualified name associated with - * the Handle parameter. This and the AcpiPathnameToHandle are - * complementary functions. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetName ( - ACPI_HANDLE Handle, - UINT32 NameType, - ACPI_BUFFER *Buffer) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - const char *NodeName; - - - /* Parameter validation */ - - if (NameType > ACPI_NAME_TYPE_MAX) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtValidateBuffer (Buffer); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (NameType == ACPI_FULL_PATHNAME || - NameType == ACPI_FULL_PATHNAME_NO_TRAILING) - { - /* Get the full pathname (From the namespace root) */ - - Status = AcpiNsHandleToPathname (Handle, Buffer, - NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); - return (Status); - } - - /* - * Wants the single segment ACPI name. - * Validate handle and convert to a namespace Node - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Node = AcpiNsValidateHandle (Handle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Just copy the ACPI name from the Node and zero terminate it */ - - NodeName = AcpiUtGetNodeName (Node); - ACPI_MOVE_NAME (Buffer->Pointer, NodeName); - ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; - Status = AE_OK; - - -UnlockAndExit: - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetName) - - -/****************************************************************************** - * - * FUNCTION: AcpiNsCopyDeviceId - * - * PARAMETERS: Dest - Pointer to the destination PNP_DEVICE_ID - * Source - Pointer to the source PNP_DEVICE_ID - * StringArea - Pointer to where to copy the dest string - * - * RETURN: Pointer to the next string area - * - * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data. - * - ******************************************************************************/ - -static char * -AcpiNsCopyDeviceId ( - ACPI_PNP_DEVICE_ID *Dest, - ACPI_PNP_DEVICE_ID *Source, - char *StringArea) -{ - /* Create the destination PNP_DEVICE_ID */ - - Dest->String = StringArea; - Dest->Length = Source->Length; - - /* Copy actual string and return a pointer to the next string area */ - - memcpy (StringArea, Source->String, Source->Length); - return (StringArea + Source->Length); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiGetObjectInfo - * - * PARAMETERS: Handle - Object Handle - * ReturnBuffer - Where the info is returned - * - * RETURN: Status - * - * DESCRIPTION: Returns information about an object as gleaned from the - * namespace node and possibly by running several standard - * control methods (Such as in the case of a device.) - * - * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, - * _CLS, _ADR, _SxW, and _SxD methods. - * - * Note: Allocates the return buffer, must be freed by the caller. - * - * Note: This interface is intended to be used during the initial device - * discovery namespace traversal. Therefore, no complex methods can be - * executed, especially those that access operation regions. Therefore, do - * not add any additional methods that could cause problems in this area. - * this was the fate of the _SUB method which was found to cause such - * problems and was removed (11/2015). - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetObjectInfo ( - ACPI_HANDLE Handle, - ACPI_DEVICE_INFO **ReturnBuffer) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_DEVICE_INFO *Info; - ACPI_PNP_DEVICE_ID_LIST *CidList = NULL; - ACPI_PNP_DEVICE_ID *Hid = NULL; - ACPI_PNP_DEVICE_ID *Uid = NULL; - ACPI_PNP_DEVICE_ID *Cls = NULL; - char *NextIdString; - ACPI_OBJECT_TYPE Type; - ACPI_NAME Name; - UINT8 ParamCount= 0; - UINT16 Valid = 0; - UINT32 InfoSize; - UINT32 i; - ACPI_STATUS Status; - - - /* Parameter validation */ - - if (!Handle || !ReturnBuffer) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Node = AcpiNsValidateHandle (Handle); - if (!Node) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - /* Get the namespace node data while the namespace is locked */ - - InfoSize = sizeof (ACPI_DEVICE_INFO); - Type = Node->Type; - Name = Node->Name.Integer; - - if (Node->Type == ACPI_TYPE_METHOD) - { - ParamCount = Node->Object->Method.ParamCount; - } - - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if ((Type == ACPI_TYPE_DEVICE) || - (Type == ACPI_TYPE_PROCESSOR)) - { - /* - * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, _CLS, and _CID methods. - * - * Note: none of these methods are required, so they may or may - * not be present for this device. The Info->Valid bitfield is used - * to indicate which methods were found and run successfully. - */ - - /* Execute the Device._HID method */ - - Status = AcpiUtExecute_HID (Node, &Hid); - if (ACPI_SUCCESS (Status)) - { - InfoSize += Hid->Length; - Valid |= ACPI_VALID_HID; - } - - /* Execute the Device._UID method */ - - Status = AcpiUtExecute_UID (Node, &Uid); - if (ACPI_SUCCESS (Status)) - { - InfoSize += Uid->Length; - Valid |= ACPI_VALID_UID; - } - - /* Execute the Device._CID method */ - - Status = AcpiUtExecute_CID (Node, &CidList); - if (ACPI_SUCCESS (Status)) - { - /* Add size of CID strings and CID pointer array */ - - InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST)); - Valid |= ACPI_VALID_CID; - } - - /* Execute the Device._CLS method */ - - Status = AcpiUtExecute_CLS (Node, &Cls); - if (ACPI_SUCCESS (Status)) - { - InfoSize += Cls->Length; - Valid |= ACPI_VALID_CLS; - } - } - - /* - * Now that we have the variable-length data, we can allocate the - * return buffer - */ - Info = ACPI_ALLOCATE_ZEROED (InfoSize); - if (!Info) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Get the fixed-length data */ - - if ((Type == ACPI_TYPE_DEVICE) || - (Type == ACPI_TYPE_PROCESSOR)) - { - /* - * Get extra info for ACPI Device/Processor objects only: - * Run the _STA, _ADR and, SxW, and _SxD methods. - * - * Notes: none of these methods are required, so they may or may - * not be present for this device. The Info->Valid bitfield is used - * to indicate which methods were found and run successfully. - * - * For _STA, if the method does not exist, then (as per the ACPI - * specification), the returned CurrentStatus flags will indicate - * that the device is present/functional/enabled. Otherwise, the - * CurrentStatus flags reflect the value returned from _STA. - */ - - /* Execute the Device._STA method */ - - Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); - if (ACPI_SUCCESS (Status)) - { - Valid |= ACPI_VALID_STA; - } - - /* Execute the Device._ADR method */ - - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info->Address); - if (ACPI_SUCCESS (Status)) - { - Valid |= ACPI_VALID_ADR; - } - - /* Execute the Device._SxW methods */ - - Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, - Info->LowestDstates); - if (ACPI_SUCCESS (Status)) - { - Valid |= ACPI_VALID_SXWS; - } - - /* Execute the Device._SxD methods */ - - Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, - Info->HighestDstates); - if (ACPI_SUCCESS (Status)) - { - Valid |= ACPI_VALID_SXDS; - } - } - - /* - * Create a pointer to the string area of the return buffer. - * Point to the end of the base ACPI_DEVICE_INFO structure. - */ - NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); - if (CidList) - { - /* Point past the CID PNP_DEVICE_ID array */ - - NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_PNP_DEVICE_ID)); - } - - /* - * Copy the HID, UID, and CIDs to the return buffer. The variable-length - * strings are copied to the reserved area at the end of the buffer. - * - * For HID and CID, check if the ID is a PCI Root Bridge. - */ - if (Hid) - { - NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, - Hid, NextIdString); - - if (AcpiUtIsPciRootBridge (Hid->String)) - { - Info->Flags |= ACPI_PCI_ROOT_BRIDGE; - } - } - - if (Uid) - { - NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, - Uid, NextIdString); - } - - if (CidList) - { - Info->CompatibleIdList.Count = CidList->Count; - Info->CompatibleIdList.ListSize = CidList->ListSize; - - /* Copy each CID */ - - for (i = 0; i < CidList->Count; i++) - { - NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], - &CidList->Ids[i], NextIdString); - - if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) - { - Info->Flags |= ACPI_PCI_ROOT_BRIDGE; - } - } - } - - if (Cls) - { - NextIdString = AcpiNsCopyDeviceId (&Info->ClassCode, - Cls, NextIdString); - } - - /* Copy the fixed-length data */ - - Info->InfoSize = InfoSize; - Info->Type = Type; - Info->Name = Name; - Info->ParamCount = ParamCount; - Info->Valid = Valid; - - *ReturnBuffer = Info; - Status = AE_OK; - - -Cleanup: - if (Hid) - { - ACPI_FREE (Hid); - } - if (Uid) - { - ACPI_FREE (Uid); - } - if (CidList) - { - ACPI_FREE (CidList); - } - if (Cls) - { - ACPI_FREE (Cls); - } - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) - - -/****************************************************************************** - * - * FUNCTION: AcpiInstallMethod - * - * PARAMETERS: Buffer - An ACPI table containing one control method - * - * RETURN: Status - * - * DESCRIPTION: Install a control method into the namespace. If the method - * name already exists in the namespace, it is overwritten. The - * input buffer must contain a valid DSDT or SSDT containing a - * single control method. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallMethod ( - UINT8 *Buffer) -{ - ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); - UINT8 *AmlBuffer; - UINT8 *AmlStart; - char *Path; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *MethodObj; - ACPI_PARSE_STATE ParserState; - UINT32 AmlLength; - UINT16 Opcode; - UINT8 MethodFlags; - ACPI_STATUS Status; - - - /* Parameter validation */ - - if (!Buffer) - { - return (AE_BAD_PARAMETER); - } - - /* Table must be a DSDT or SSDT */ - - if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) && - !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) - { - return (AE_BAD_HEADER); - } - - /* First AML opcode in the table must be a control method */ - - ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); - Opcode = AcpiPsPeekOpcode (&ParserState); - if (Opcode != AML_METHOD_OP) - { - return (AE_BAD_PARAMETER); - } - - /* Extract method information from the raw AML */ - - ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); - ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); - Path = AcpiPsGetNextNamestring (&ParserState); - - MethodFlags = *ParserState.Aml++; - AmlStart = ParserState.Aml; - AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); - - /* - * Allocate resources up-front. We don't want to have to delete a new - * node from the namespace if we cannot allocate memory. - */ - AmlBuffer = ACPI_ALLOCATE (AmlLength); - if (!AmlBuffer) - { - return (AE_NO_MEMORY); - } - - MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); - if (!MethodObj) - { - ACPI_FREE (AmlBuffer); - return (AE_NO_MEMORY); - } - - /* Lock namespace for AcpiNsLookup, we may be creating a new node */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* The lookup either returns an existing node or creates a new one */ - - Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) /* NsLookup */ - { - if (Status != AE_ALREADY_EXISTS) - { - goto ErrorExit; - } - - /* Node existed previously, make sure it is a method node */ - - if (Node->Type != ACPI_TYPE_METHOD) - { - Status = AE_TYPE; - goto ErrorExit; - } - } - - /* Copy the method AML to the local buffer */ - - memcpy (AmlBuffer, AmlStart, AmlLength); - - /* Initialize the method object with the new method's information */ - - MethodObj->Method.AmlStart = AmlBuffer; - MethodObj->Method.AmlLength = AmlLength; - - MethodObj->Method.ParamCount = (UINT8) - (MethodFlags & AML_METHOD_ARG_COUNT); - - if (MethodFlags & AML_METHOD_SERIALIZED) - { - MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED; - - MethodObj->Method.SyncLevel = (UINT8) - ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); - } - - /* - * Now that it is complete, we can attach the new method object to - * the method Node (detaches/deletes any existing object) - */ - Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD); - - /* - * Flag indicates AML buffer is dynamic, must be deleted later. - * Must be set only after attach above. - */ - Node->Flags |= ANOBJ_ALLOCATED_BUFFER; - - /* Remove local reference to the method object */ - - AcpiUtRemoveReference (MethodObj); - return (Status); - - -ErrorExit: - - ACPI_FREE (AmlBuffer); - ACPI_FREE (MethodObj); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiInstallMethod) diff --git a/usr/src/uts/intel/io/acpica/namespace/nsxfobj.c b/usr/src/uts/intel/io/acpica/namespace/nsxfobj.c deleted file mode 100644 index f006047431..0000000000 --- a/usr/src/uts/intel/io/acpica/namespace/nsxfobj.c +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsxfobj - Public interfaces to the ACPI subsystem - * ACPI Object oriented interfaces - * - ******************************************************************************/ - -/* - * Copyright (C) 2000 - 2016, Intel Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * substantially similar to the "NO WARRANTY" disclaimer below - * ("Disclaimer") and any redistribution must be conditioned upon - * including a substantially similar Disclaimer requirement for further - * binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - */ - -#define EXPORT_ACPI_INTERFACES - -#include "acpi.h" -#include "accommon.h" -#include "acnamesp.h" - - -#define _COMPONENT ACPI_NAMESPACE - ACPI_MODULE_NAME ("nsxfobj") - -/******************************************************************************* - * - * FUNCTION: AcpiGetType - * - * PARAMETERS: Handle - Handle of object whose type is desired - * RetType - Where the type will be placed - * - * RETURN: Status - * - * DESCRIPTION: This routine returns the type associatd with a particular handle - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetType ( - ACPI_HANDLE Handle, - ACPI_OBJECT_TYPE *RetType) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - /* Parameter Validation */ - - if (!RetType) - { - return (AE_BAD_PARAMETER); - } - - /* Special case for the predefined Root Node (return type ANY) */ - - if (Handle == ACPI_ROOT_OBJECT) - { - *RetType = ACPI_TYPE_ANY; - return (AE_OK); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Convert and validate the handle */ - - Node = AcpiNsValidateHandle (Handle); - if (!Node) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - *RetType = Node->Type; - - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetType) - - -/******************************************************************************* - * - * FUNCTION: AcpiGetParent - * - * PARAMETERS: Handle - Handle of object whose parent is desired - * RetHandle - Where the parent handle will be placed - * - * RETURN: Status - * - * DESCRIPTION: Returns a handle to the parent of the object represented by - * Handle. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetParent ( - ACPI_HANDLE Handle, - ACPI_HANDLE *RetHandle) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_STATUS Status; - - - if (!RetHandle) - { - return (AE_BAD_PARAMETER); - } - - /* Special case for the predefined Root Node (no parent) */ - - if (Handle == ACPI_ROOT_OBJECT) - { - return (AE_NULL_ENTRY); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Convert and validate the handle */ - - Node = AcpiNsValidateHandle (Handle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Get the parent entry */ - - ParentNode = Node->Parent; - *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode); - - /* Return exception if parent is null */ - - if (!ParentNode) - { - Status = AE_NULL_ENTRY; - } - - -UnlockAndExit: - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetParent) - - -/******************************************************************************* - * - * FUNCTION: AcpiGetNextObject - * - * PARAMETERS: Type - Type of object to be searched for - * Parent - Parent object whose children we are getting - * LastChild - Previous child that was found. - * The NEXT child will be returned - * RetHandle - Where handle to the next object is placed - * - * RETURN: Status - * - * DESCRIPTION: Return the next peer object within the namespace. If Handle is - * valid, Scope is ignored. Otherwise, the first object within - * Scope is returned. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetNextObject ( - ACPI_OBJECT_TYPE Type, - ACPI_HANDLE Parent, - ACPI_HANDLE Child, - ACPI_HANDLE *RetHandle) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *ParentNode = NULL; - ACPI_NAMESPACE_NODE *ChildNode = NULL; - - - /* Parameter validation */ - - if (Type > ACPI_TYPE_EXTERNAL_MAX) - { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* If null handle, use the parent */ - - if (!Child) - { - /* Start search at the beginning of the specified scope */ - - ParentNode = AcpiNsValidateHandle (Parent); - if (!ParentNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - else - { - /* Non-null handle, ignore the parent */ - /* Convert and validate the handle */ - - ChildNode = AcpiNsValidateHandle (Child); - if (!ChildNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - - /* Internal function does the real work */ - - Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode); - if (!Node) - { - Status = AE_NOT_FOUND; - goto UnlockAndExit; - } - - if (RetHandle) - { - *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); - } - - -UnlockAndExit: - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetNextObject) |