diff options
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Namespace')
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c | 742 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c | 728 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c | 679 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c | 663 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c | 455 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c | 706 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c | 367 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c | 523 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c | 525 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c | 1048 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c | 384 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c | 409 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c | 852 |
13 files changed, 0 insertions, 8081 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c deleted file mode 100644 index 47e7785f8852c..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c +++ /dev/null @@ -1,742 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 119 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSACCESS_C__ - -#include "acpi.h" -#include "amlcode.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acdispat.h" - - -#define _COMPONENT NAMESPACE - 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 = AE_OK; - PREDEFINED_NAMES *InitVal = NULL; - ACPI_NAMESPACE_NODE *NewNode; - ACPI_OPERAND_OBJECT *ObjDesc; - - - FUNCTION_TRACE ("NsRootInitialize"); - - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* - * 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 */ - - DEBUG_PRINT (ACPI_INFO, - ("Entering predefined name table entries into namespace\n")); - - for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) - { - Status = AcpiNsLookup (NULL, InitVal->Name, - (OBJECT_TYPE_INTERNAL) InitVal->Type, - IMODE_LOAD_PASS2, NS_NO_UPSEARCH, - NULL, &NewNode); - - if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ - { - DEBUG_PRINT (ACPI_ERROR, - ("Could not create predefined name %s, %s\n", - InitVal->Name, AcpiCmFormatException (Status))); - } - - /* - * Name entered successfully. - * If entry in PreDefinedNames[] specifies an - * initial value, create the initial value. - */ - - if (InitVal->Val) - { - /* - * Entry requests an initial value, allocate a - * descriptor for it. - */ - - ObjDesc = AcpiCmCreateInternalObject ( - (OBJECT_TYPE_INTERNAL) 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_INTEGER: - - ObjDesc->Integer.Value = - (ACPI_INTEGER) STRTOUL (InitVal->Val, NULL, 10); - break; - - - case ACPI_TYPE_STRING: - - ObjDesc->String.Length = - (UINT16) STRLEN (InitVal->Val); - - /* - * Allocate a buffer for the string. All - * String.Pointers must be allocated buffers! - * (makes deletion simpler) - */ - ObjDesc->String.Pointer = AcpiCmAllocate ( - (ObjDesc->String.Length + 1)); - if (!ObjDesc->String.Pointer) - { - AcpiCmRemoveReference (ObjDesc); - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - STRCPY (ObjDesc->String.Pointer, InitVal->Val); - break; - - - case ACPI_TYPE_MUTEX: - - ObjDesc->Mutex.SyncLevel = - (UINT16) STRTOUL (InitVal->Val, NULL, 10); - - if (STRCMP (InitVal->Name, "_GL_") == 0) - { - /* - * Create a counting semaphore for the - * global lock - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, - 1, &ObjDesc->Mutex.Semaphore); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - /* - * We just created the mutex for the - * global lock, save it - */ - - AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; - } - - else - { - /* Create a mutex */ - - Status = AcpiOsCreateSemaphore (1, 1, - &ObjDesc->Mutex.Semaphore); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } - break; - - - default: - REPORT_ERROR (("Unsupported initial type value %X\n", - InitVal->Type)); - AcpiCmRemoveReference (ObjDesc); - ObjDesc = NULL; - continue; - } - - /* Store pointer to value descriptor in the Node */ - - AcpiNsAttachObject (NewNode, ObjDesc, - ObjDesc->Common.Type); - } - } - - -UnlockAndExit: - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsLookup - * - * PARAMETERS: PrefixNode - Search scope if name is not fully qualified - * 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, - NATIVE_CHAR *Pathname, - OBJECT_TYPE_INTERNAL Type, - OPERATING_MODE InterpreterMode, - UINT32 Flags, - ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *PrefixNode; - ACPI_NAMESPACE_NODE *CurrentNode = NULL; - ACPI_NAMESPACE_NODE *ScopeToPush = NULL; - ACPI_NAMESPACE_NODE *ThisNode = NULL; - UINT32 NumSegments; - ACPI_NAME SimpleName; - BOOLEAN NullNamePath = FALSE; - OBJECT_TYPE_INTERNAL TypeToCheckFor; - OBJECT_TYPE_INTERNAL ThisSearchType; - UINT32 LocalFlags = Flags & ~NS_ERROR_IF_FOUND; - - DEBUG_EXEC (UINT32 i;) - - - FUNCTION_TRACE ("NsLookup"); - - - if (!ReturnNode) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - AcpiGbl_NsLookupCount++; - - *ReturnNode = ENTRY_NOT_FOUND; - - - if (!AcpiGbl_RootNode) - { - return (AE_NO_NAMESPACE); - } - - /* - * Get the prefix scope. - * A null scope means use the root scope - */ - - if ((!ScopeInfo) || - (!ScopeInfo->Scope.Node)) - { - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Null scope prefix, using root node (%p)\n", AcpiGbl_RootNode)); - - PrefixNode = AcpiGbl_RootNode; - } - else - { - PrefixNode = ScopeInfo->Scope.Node; - } - - - /* - * This check is explicitly split provide relax the TypeToCheckFor - * conditions for BankFieldDefn. Originally, both BankFieldDefn and - * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION, - * but the BankFieldDefn may also check for a Field definition as well - * as an OperationRegion. - */ - - if (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) - { - /* DefFieldDefn defines fields in a Region */ - - TypeToCheckFor = ACPI_TYPE_REGION; - } - - else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type) - { - /* BankFieldDefn defines data fields in a Field Object */ - - TypeToCheckFor = ACPI_TYPE_ANY; - } - - else - { - TypeToCheckFor = Type; - } - - - /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ - - /* Examine the name pointer */ - - if (!Pathname) - { - /* 8-12-98 ASL Grammar Update supports null NamePath */ - - NullNamePath = TRUE; - NumSegments = 0; - ThisNode = AcpiGbl_RootNode; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Null Pathname (Zero segments), Flags=%x\n", Flags)); - } - - else - { - /* - * Valid name pointer (Internal name format) - * - * Check for prefixes. As represented in the AML stream, a - * Pathname consists of an optional scope prefix followed by - * a segment part. - * - * If present, the scope prefix is either a RootPrefix (in - * which case the name is fully qualified), or zero or more - * ParentPrefixes (in which case the name's scope is relative - * to the current scope). - * - * The segment part consists of either: - * - A single 4-byte name segment, or - * - A DualNamePrefix followed by two 4-byte name segments, or - * - A MultiNamePrefixOp, followed by a byte indicating the - * number of segments and the segments themselves. - */ - - if (*Pathname == AML_ROOT_PREFIX) - { - /* Pathname is fully qualified, look in root name table */ - - CurrentNode = AcpiGbl_RootNode; - - /* point to segment part */ - - Pathname++; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Searching from root [%p]\n", - CurrentNode)); - - /* Direct reference to root, "\" */ - - if (!(*Pathname)) - { - ThisNode = AcpiGbl_RootNode; - goto CheckForNewScopeAndExit; - } - } - - else - { - /* Pathname is relative to current scope, start there */ - - CurrentNode = PrefixNode; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Searching relative to pfx scope [%p]\n", - PrefixNode)); - - /* - * Handle up-prefix (carat). More than one prefix - * is supported - */ - - while (*Pathname == AML_PARENT_PREFIX) - { - /* Point to segment part or next ParentPrefix */ - - Pathname++; - - /* Backup to the parent's scope */ - - ThisNode = AcpiNsGetParentObject (CurrentNode); - if (!ThisNode) - { - /* Current scope has no parent scope */ - - REPORT_ERROR (("Too many parent prefixes (^) - reached root\n")); - return_ACPI_STATUS (AE_NOT_FOUND); - } - - CurrentNode = ThisNode; - } - } - - - /* - * Examine the name prefix opcode, if any, - * to determine the number of segments - */ - - if (*Pathname == AML_DUAL_NAME_PREFIX) - { - NumSegments = 2; - - /* point to first segment */ - - Pathname++; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Dual Pathname (2 segments, Flags=%X)\n", Flags)); - } - - else if (*Pathname == AML_MULTI_NAME_PREFIX_OP) - { - NumSegments = (UINT32)* (UINT8 *) ++Pathname; - - /* point to first segment */ - - Pathname++; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Multi Pathname (%d Segments, Flags=%X) \n", - NumSegments, Flags)); - } - - else - { - /* - * No Dual or Multi prefix, hence there is only one - * segment and Pathname is already pointing to it. - */ - NumSegments = 1; - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Simple Pathname (1 segment, Flags=%X)\n", Flags)); - } - -#ifdef ACPI_DEBUG - - /* TBD: [Restructure] Make this a procedure */ - - /* Debug only: print the entire name that we are about to lookup */ - - DEBUG_PRINT (TRACE_NAMES, ("NsLookup: [")); - - for (i = 0; i < NumSegments; i++) - { - DEBUG_PRINT_RAW (TRACE_NAMES, ("%4.4s/", &Pathname[i * 4])); - } - DEBUG_PRINT_RAW (TRACE_NAMES, ("]\n")); -#endif - } - - - /* - * Search namespace for each segment of the name. - * Loop through and verify/add each name segment. - */ - - - while (NumSegments-- && CurrentNode) - { - /* - * Search for the current name segment under the current - * named object. The Type is significant only at the last (topmost) - * level. (We don't care about the types along the path, only - * the type of the final target object.) - */ - ThisSearchType = ACPI_TYPE_ANY; - if (!NumSegments) - { - ThisSearchType = Type; - LocalFlags = Flags; - } - - /* Pluck one ACPI name from the front of the pathname */ - - MOVE_UNALIGNED32_TO_32 (&SimpleName, Pathname); - - /* Try to find the 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 */ - - DEBUG_PRINT (TRACE_NAMES, - ("NsLookup: Name [%4.4s] not found in scope %X\n", - &SimpleName, CurrentNode)); - } - - return_ACPI_STATUS (Status); - } - - - /* - * If 1) This is the last segment (NumSegments == 0) - * 2) and looking for a specific type - * (Not checking for TYPE_ANY) - * 3) Which is not an alias - * 4) which is not a local type (TYPE_DEF_ANY) - * 5) which is not a local type (TYPE_SCOPE) - * 6) which is not a local type (TYPE_INDEX_FIELD_DEFN) - * 7) and type of object is known (not TYPE_ANY) - * 8) and object does not match request - * - * Then we have a type mismatch. Just warn and ignore it. - */ - if ((NumSegments == 0) && - (TypeToCheckFor != ACPI_TYPE_ANY) && - (TypeToCheckFor != INTERNAL_TYPE_ALIAS) && - (TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) && - (TypeToCheckFor != INTERNAL_TYPE_SCOPE) && - (TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) && - (ThisNode->Type != ACPI_TYPE_ANY) && - (ThisNode->Type != TypeToCheckFor)) - { - /* Complain about a type mismatch */ - - REPORT_WARNING ( - ("NsLookup: %4.4s, type %X, checking for type %X\n", - &SimpleName, ThisNode->Type, 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 see if it opens a scope. - */ - - if ((0 == NumSegments) && (ACPI_TYPE_ANY == Type)) - { - Type = ThisNode->Type; - } - - if ((NumSegments || AcpiNsOpensScope (Type)) && - (ThisNode->Child == NULL)) - { - /* - * More segments or the type implies enclosed scope, - * and the next scope has not been allocated. - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsLookup: Load mode=%X ThisNode=%X\n", - InterpreterMode, ThisNode)); - } - - CurrentNode = ThisNode; - - /* point to next name segment */ - - Pathname += ACPI_NAME_SIZE; - } - - - /* - * Always check if we need to open a new scope - */ - -CheckForNewScopeAndExit: - - if (!(Flags & NS_DONT_OPEN_SCOPE) && (WalkState)) - { - /* - * If entry is a type which opens a scope, - * push the new scope on the scope stack. - */ - - if (AcpiNsOpensScope (TypeToCheckFor)) - { - /* 8-12-98 ASL Grammar Update supports null NamePath */ - - if (NullNamePath) - { - /* TBD: [Investigate] - is this the correct thing to do? */ - - ScopeToPush = NULL; - } - else - { - ScopeToPush = ThisNode; - } - - Status = AcpiDsScopeStackPush (ScopeToPush, Type, - WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - DEBUG_PRINT (ACPI_INFO, - ("NsLookup: Set global scope to %p\n", ScopeToPush)); - } - } - - *ReturnNode = ThisNode; - return_ACPI_STATUS (AE_OK); -} - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c deleted file mode 100644 index 3f90752149fe7..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c +++ /dev/null @@ -1,728 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 45 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __NSALLOC_C__ - -#include "acpi.h" -#include "acnamesp.h" -#include "acinterp.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsalloc") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsCreateNode - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsCreateNode ( - UINT32 AcpiName) -{ - ACPI_NAMESPACE_NODE *Node; - - FUNCTION_TRACE ("NsCreateNode"); - - - Node = AcpiCmCallocate (sizeof (ACPI_NAMESPACE_NODE)); - if (!Node) - { - return_PTR (NULL); - } - - INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - Node->DataType = ACPI_DESC_TYPE_NAMED; - Node->Name = AcpiName; - Node->ReferenceCount = 1; - - return_PTR (Node); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNode - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: - * - ******************************************************************************/ - -void -AcpiNsDeleteNode ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_NAMESPACE_NODE *PrevNode; - ACPI_NAMESPACE_NODE *NextNode; - - - FUNCTION_TRACE_PTR ("NsDeleteNode", Node); - - ParentNode = AcpiNsGetParentObject (Node); - - PrevNode = NULL; - NextNode = ParentNode->Child; - - while (NextNode != Node) - { - PrevNode = NextNode; - NextNode = PrevNode->Peer; - } - - if (PrevNode) - { - PrevNode->Peer = NextNode->Peer; - if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; - } - } - else - { - ParentNode->Child = NextNode->Peer; - } - - - DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - /* - * Detach an object if there is one - */ - - if (Node->Object) - { - AcpiNsDetachObject (Node); - } - - AcpiCmFree (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 entry within a namespace table. - * - ******************************************************************************/ - -void -AcpiNsInstallNode ( - ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ - ACPI_NAMESPACE_NODE *Node, /* New Child*/ - OBJECT_TYPE_INTERNAL Type) -{ - UINT16 OwnerId = TABLE_ID_DSDT; - ACPI_NAMESPACE_NODE *ChildNode; - - - FUNCTION_TRACE ("NsInstallNode"); - - - /* - * Get the owner ID from the Walk state - * The owner ID is used to track table deletion and - * deletion of objects created by methods - */ - if (WalkState) - { - OwnerId = WalkState->OwnerId; - } - - - /* link the new entry into the parent and existing children */ - - /* TBD: Could be first, last, or alphabetic */ - - ChildNode = ParentNode->Child; - if (!ChildNode) - { - ParentNode->Child = Node; - } - - else - { - while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) - { - ChildNode = ChildNode->Peer; - } - - ChildNode->Peer = Node; - - /* Clear end-of-list flag */ - - ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; - } - - /* Init the new entry */ - - Node->OwnerId = OwnerId; - Node->Flags |= ANOBJ_END_OF_PEER_LIST; - Node->Peer = ParentNode; - - - /* - * If adding a name with unknown type, or having to - * add the region in order to define fields in it, we - * have a forward reference. - */ - - if ((ACPI_TYPE_ANY == Type) || - (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - /* - * We don't want to abort here, however! - * We will fill in the actual type when the - * real definition is found later. - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsInstallNode: [%4.4s] is a forward reference\n", - &Node->Name)); - - } - - /* - * The DefFieldDefn and BankFieldDefn cases are actually - * looking up the Region in which the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - Type = ACPI_TYPE_REGION; - } - - /* - * Scope, DefAny, and IndexFieldDefn are bogus "types" which do - * not actually have anything to do with the type of the name - * being looked up. Save any other value of Type as the type of - * the entry. - */ - - if ((Type != INTERNAL_TYPE_SCOPE) && - (Type != INTERNAL_TYPE_DEF_ANY) && - (Type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) - { - Node->Type = (UINT8) Type; - } - - DEBUG_PRINT (TRACE_NAMES, - ("NsInstallNode: %4.4s added to %p at %p\n", - &Node->Name, ParentNode, Node)); - - /* - * Increment the reference count(s) of all parents up to - * the root! - */ - - while ((Node = AcpiNsGetParentObject (Node)) != NULL) - { - Node->ReferenceCount++; - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteChildren - * - * PARAMETERS: ParentNode - Delete this objects children - * - * RETURN: None. - * - * DESCRIPTION: Delete all children of the parent object. Deletes a - * "scope". - * - ******************************************************************************/ - -void -AcpiNsDeleteChildren ( - ACPI_NAMESPACE_NODE *ParentNode) -{ - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_NAMESPACE_NODE *NextNode; - UINT8 Flags; - - - FUNCTION_TRACE_PTR ("AcpiNsDeleteChildren", ParentNode); - - - if (!ParentNode) - { - return_VOID; - } - - /* If no children, all done! */ - - ChildNode = ParentNode->Child; - if (!ChildNode) - { - return_VOID; - } - - /* - * Deallocate all children at this level - */ - do - { - /* Get the things we need */ - - NextNode = ChildNode->Peer; - Flags = ChildNode->Flags; - - /* Grandchildren should have all been deleted already */ - - if (ChildNode->Child) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsDeleteChildren: Found a grandchild! P=%X C=%X\n", - ParentNode, ChildNode)); - } - - /* Now we can free this child object */ - - DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - - DEBUG_PRINT (ACPI_INFO, - ("AcpiNsDeleteChildren: Object %p, Remaining %X\n", - ChildNode, AcpiGbl_CurrentNodeCount)); - - /* - * Detach an object if there is one - */ - - if (ChildNode->Object) - { - AcpiNsDetachObject (ChildNode); - } - - AcpiCmFree (ChildNode); - - /* And move on to the next child in the list */ - - ChildNode = NextNode; - - } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); - - - /* Clear the parent's child pointer */ - - ParentNode->Child = NULL; - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNamespaceSubtree - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete a subtree of the namespace. This includes all objects - * stored within the subtree. Scope tables are deleted also - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsDeleteNamespaceSubtree ( - ACPI_NAMESPACE_NODE *ParentNode) -{ - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 Level; - - - FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); - - - if (!ParentNode) - { - return_ACPI_STATUS (AE_OK); - } - - - ChildNode = 0; - Level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - - while (Level > 0) - { - /* - * Get the next typed object in this scope. - * Null returned if not found - */ - - ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, - ChildNode); - if (ChildNode) - { - /* - * Found an object - delete the object within - * the Value field - */ - - ObjDesc = AcpiNsGetAttachedObject (ChildNode); - if (ObjDesc) - { - AcpiNsDetachObject (ChildNode); - AcpiCmRemoveReference (ObjDesc); - } - - - /* Check if this object has any children */ - - if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) - { - /* - * There is at least one child of this object, - * visit the object - */ - - Level++; - ParentNode = ChildNode; - ChildNode = 0; - } - } - - else - { - /* - * No more children in this object. - * We will 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 object */ - - ChildNode = ParentNode; - - /* Now we can move up the tree to the grandparent */ - - ParentNode = AcpiNsGetParentObject (ParentNode); - } - } - - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsRemoveReference - * - * PARAMETERS: Node - Named object whose reference count is to be - * decremented - * - * RETURN: None. - * - * DESCRIPTION: Remove a Node reference. Decrements the reference count - * of all parent Nodes up to the root. Any object along - * the way that reaches zero references is freed. - * - ******************************************************************************/ - -static void -AcpiNsRemoveReference ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_NAMESPACE_NODE *NextNode; - - - /* - * Decrement the reference count(s) of this object and all - * objects up to the root, Delete anything with zero remaining references. - */ - NextNode = Node; - while (NextNode) - { - /* Decrement the reference count on this object*/ - - NextNode->ReferenceCount--; - - /* Delete the object if no more references */ - - if (!NextNode->ReferenceCount) - { - /* Delete all children and delete the object */ - - AcpiNsDeleteChildren (NextNode); - AcpiNsDeleteNode (NextNode); - } - - /* Move up to parent */ - - NextNode = AcpiNsGetParentObject (NextNode); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDeleteNamespaceByOwner - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete entries within the namespace that are owned by a - * specific ID. Used to delete entire ACPI tables. All - * reference counts are updated. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsDeleteNamespaceByOwner ( - UINT16 OwnerId) -{ - ACPI_NAMESPACE_NODE *ChildNode; - UINT32 Level; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *ParentNode; - - - FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); - - - ParentNode = AcpiGbl_RootNode; - ChildNode = 0; - Level = 1; - - /* - * Traverse the tree of objects until we bubble back up - * to where we started. - */ - - while (Level > 0) - { - /* - * Get the next typed object in this scope. - * Null returned if not found - */ - - ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, - ChildNode); - - if (ChildNode) - { - if (ChildNode->OwnerId == OwnerId) - { - /* - * Found an object - delete the object within - * the Value field - */ - - ObjDesc = AcpiNsGetAttachedObject (ChildNode); - if (ObjDesc) - { - AcpiNsDetachObject (ChildNode); - AcpiCmRemoveReference (ObjDesc); - } - } - - /* Check if this object has any children */ - - if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) - { - /* - * There is at least one child of this object, - * visit the object - */ - - Level++; - ParentNode = ChildNode; - ChildNode = 0; - } - - else if (ChildNode->OwnerId == OwnerId) - { - AcpiNsRemoveReference (ChildNode); - } - } - - else - { - /* - * No more children in this object. Move up to grandparent. - */ - Level--; - - if (Level != 0) - { - if (ParentNode->OwnerId == OwnerId) - { - AcpiNsRemoveReference (ParentNode); - } - } - - /* New "last child" is this parent object */ - - ChildNode = ParentNode; - - /* Now we can move up the tree to the grandparent */ - - ParentNode = AcpiNsGetParentObject (ParentNode); - } - } - - - return_ACPI_STATUS (AE_OK); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c deleted file mode 100644 index eb907a3c8a7e5..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c +++ /dev/null @@ -1,679 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsdump - table dumping routines for debug - * $Revision: 85 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSDUMP_C__ - -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "actables.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsdump") - - -#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) - -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpPathname - * - * PARAMETERS: Handle - Object - * Msg - Prefix message - * Level - Desired debug level - * Component - Caller's component ID - * - * DESCRIPTION: Print an object's full namespace pathname - * Manages allocation/freeing of a pathname buffer - * - ***************************************************************************/ - -ACPI_STATUS -AcpiNsDumpPathname ( - ACPI_HANDLE Handle, - NATIVE_CHAR *Msg, - UINT32 Level, - UINT32 Component) -{ - NATIVE_CHAR *Buffer; - UINT32 Length; - - - FUNCTION_TRACE ("NsDumpPathname"); - - /* Do this only if the requested debug level and component are enabled */ - - if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) - { - return_ACPI_STATUS (AE_OK); - } - - Buffer = AcpiCmAllocate (PATHNAME_MAX); - if (!Buffer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Convert handle to a full pathname and print it (with supplied message) */ - - Length = PATHNAME_MAX; - if (ACPI_SUCCESS (AcpiNsHandleToPathname (Handle, &Length, Buffer))) - { - AcpiOsPrintf ("%s %s (%p)\n", Msg, Buffer, Handle); - } - - AcpiCmFree (Buffer); - - return_ACPI_STATUS (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpOneObject - * - * PARAMETERS: Handle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into WalkNamespace - * - * 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; - UINT8 *Value; - ACPI_OPERAND_OBJECT *ObjDesc = NULL; - OBJECT_TYPE_INTERNAL ObjType; - OBJECT_TYPE_INTERNAL Type; - UINT32 BytesToDump; - UINT32 DownstreamSiblingMask = 0; - UINT32 LevelTmp; - UINT32 WhichBit; - - - ThisNode = AcpiNsConvertHandleToEntry (ObjHandle); - - LevelTmp = Level; - Type = ThisNode->Type; - WhichBit = 1; - - - if (!(AcpiDbgLevel & Info->DebugLevel)) - { - return (AE_OK); - } - - if (!ObjHandle) - { - DEBUG_PRINT (ACPI_INFO, ("Null object handle\n")); - return (AE_OK); - } - - /* Check if the owner matches */ - - if ((Info->OwnerId != ACPI_UINT32_MAX) && - (Info->OwnerId != ThisNode->OwnerId)) - { - return (AE_OK); - } - - - /* Indent the object according to the level */ - - while (LevelTmp--) - { - - /* Print appropriate characters to form tree structure */ - - if (LevelTmp) - { - if (DownstreamSiblingMask & WhichBit) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("|")); - } - - else - { - DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); - } - - WhichBit <<= 1; - } - - else - { - if (AcpiNsExistDownstreamSibling (ThisNode + 1)) - { - DownstreamSiblingMask |= (1 << (Level - 1)); - DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); - } - - else - { - DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1)); - DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); - } - - if (ThisNode->Child == NULL) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); - } - - else if (AcpiNsExistDownstreamSibling (ThisNode->Child)) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); - } - - else - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); - } - } - } - - - /* Check the integrity of our data */ - - if (Type > INTERNAL_TYPE_MAX) - { - Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */ - } - - if (!AcpiCmValidAcpiName (ThisNode->Name)) - { - REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name)); - } - - /* - * Now we can print out the pertinent information - */ - - DEBUG_PRINT_RAW (TRACE_TABLES, (" %4.4s %-9s ", &ThisNode->Name, AcpiCmGetTypeName (Type))); - DEBUG_PRINT_RAW (TRACE_TABLES, ("%p S:%p O:%p", ThisNode, ThisNode->Child, ThisNode->Object)); - - - if (!ThisNode->Object) - { - /* No attached object, we are done */ - - DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); - return (AE_OK); - } - - switch (Type) - { - - case ACPI_TYPE_METHOD: - - /* Name is a Method and its AML offset/length are set */ - - DEBUG_PRINT_RAW (TRACE_TABLES, (" M:%p-%X\n", - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.Pcode, - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.PcodeLength)); - - break; - - - case ACPI_TYPE_INTEGER: - - DEBUG_PRINT_RAW (TRACE_TABLES, (" N:%X\n", - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Integer.Value)); - break; - - - case ACPI_TYPE_STRING: - - DEBUG_PRINT_RAW (TRACE_TABLES, (" S:%p-%X\n", - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Pointer, - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Length)); - break; - - - case ACPI_TYPE_BUFFER: - - DEBUG_PRINT_RAW (TRACE_TABLES, (" B:%p-%X\n", - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Pointer, - ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Length)); - break; - - - default: - - DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); - break; - } - - /* If debug turned off, done */ - - if (!(AcpiDbgLevel & TRACE_VALUES)) - { - return (AE_OK); - } - - - /* If there is an attached object, display it */ - - Value = ThisNode->Object; - - /* Dump attached objects */ - - while (Value) - { - ObjType = INTERNAL_TYPE_INVALID; - - /* Decode the type of attached object and dump the contents */ - - DEBUG_PRINT_RAW (TRACE_TABLES, (" Attached Object %p: ", Value)); - - if (AcpiTbSystemTablePointer (Value)) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to AML Code)\n")); - BytesToDump = 16; - } - - else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED)) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to Node)\n")); - BytesToDump = sizeof (ACPI_NAMESPACE_NODE); - } - - - else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_INTERNAL)) - { - ObjDesc = (ACPI_OPERAND_OBJECT *) Value; - ObjType = ObjDesc->Common.Type; - - if (ObjType > INTERNAL_TYPE_MAX) - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType)); - BytesToDump = 32; - } - - else - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type %X [%s])\n", - ObjType, AcpiCmGetTypeName (ObjType))); - BytesToDump = sizeof (ACPI_OPERAND_OBJECT); - } - } - - else - { - DEBUG_PRINT_RAW (TRACE_TABLES, ("(String or Buffer - not descriptor)\n", Value)); - BytesToDump = 16; - } - - DUMP_BUFFER (Value, BytesToDump); - - /* If value is NOT an internal object, we are done */ - - if ((AcpiTbSystemTablePointer (Value)) || - (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED))) - { - goto Cleanup; - } - - /* - * Valid object, get the pointer to next level, if any - */ - switch (ObjType) - { - case ACPI_TYPE_STRING: - Value = (UINT8 *) ObjDesc->String.Pointer; - break; - - case ACPI_TYPE_BUFFER: - Value = (UINT8 *) ObjDesc->Buffer.Pointer; - break; - - case ACPI_TYPE_PACKAGE: - Value = (UINT8 *) ObjDesc->Package.Elements; - break; - - case ACPI_TYPE_METHOD: - Value = (UINT8 *) ObjDesc->Method.Pcode; - break; - - case ACPI_TYPE_FIELD_UNIT: - Value = (UINT8 *) ObjDesc->FieldUnit.Container; - break; - - case INTERNAL_TYPE_DEF_FIELD: - Value = (UINT8 *) ObjDesc->Field.Container; - break; - - case INTERNAL_TYPE_BANK_FIELD: - Value = (UINT8 *) ObjDesc->BankField.Container; - break; - - case INTERNAL_TYPE_INDEX_FIELD: - Value = (UINT8 *) ObjDesc->IndexField.Index; - break; - - default: - goto Cleanup; - } - - ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */ - } - -Cleanup: - DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); - return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpObjects - * - * PARAMETERS: Type - Object type to be dumped - * 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 - * - * DESCRIPTION: Dump typed objects within the loaded namespace. - * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. - * - ***************************************************************************/ - -void -AcpiNsDumpObjects ( - OBJECT_TYPE_INTERNAL Type, - UINT32 MaxDepth, - UINT32 OwnerId, - ACPI_HANDLE StartHandle) -{ - ACPI_WALK_INFO Info; - - - Info.DebugLevel = TRACE_TABLES; - Info.OwnerId = OwnerId; - - AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, - (void *) &Info, NULL); -} - - -#ifndef _ACPI_ASL_COMPILER -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpOneDevice - * - * PARAMETERS: Handle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into WalkNamespace - * - * DESCRIPTION: Dump a single Node that represents a device - * This procedure is a UserFunction called by AcpiNsWalkNamespace. - * - ***************************************************************************/ - -ACPI_STATUS -AcpiNsDumpOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - ACPI_DEVICE_INFO Info; - ACPI_STATUS Status; - UINT32 i; - - - Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); - - Status = AcpiGetObjectInfo (ObjHandle, &Info); - if (ACPI_SUCCESS (Status)) - { - for (i = 0; i < Level; i++) - { - DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); - } - - DEBUG_PRINT_RAW (TRACE_TABLES, (" HID: %.8X, ADR: %.8X, Status: %x\n", - Info.HardwareId, Info.Address, Info.CurrentStatus)); - } - - return (Status); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpRootDevices - * - * PARAMETERS: None - * - * DESCRIPTION: Dump all objects of type "device" - * - ***************************************************************************/ - -void -AcpiNsDumpRootDevices (void) -{ - ACPI_HANDLE SysBusHandle; - - - /* Only dump the table if tracing is enabled */ - - if (!(TRACE_TABLES & AcpiDbgLevel)) - { - return; - } - - AcpiGetHandle (0, NS_SYSTEM_BUS, &SysBusHandle); - - DEBUG_PRINT (TRACE_TABLES, ("Display of all devices in the namespace:\n")); - AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK, - AcpiNsDumpOneDevice, NULL, NULL); -} - -#endif - -/**************************************************************************** - * - * 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. - * - * DESCRIPTION: Dump the name space, or a portion of it. - * - ***************************************************************************/ - -void -AcpiNsDumpTables ( - ACPI_HANDLE SearchBase, - UINT32 MaxDepth) -{ - ACPI_HANDLE SearchHandle = SearchBase; - - - FUNCTION_TRACE ("NsDumpTables"); - - - if (!AcpiGbl_RootNode) - { - /* - * If the name space has not been initialized, - * there is nothing to dump. - */ - DEBUG_PRINT (TRACE_TABLES, ("NsDumpTables: name space not initialized!\n")); - return_VOID; - } - - if (NS_ALL == SearchBase) - { - /* entire namespace */ - - SearchHandle = AcpiGbl_RootNode; - DEBUG_PRINT (TRACE_TABLES, ("\\\n")); - } - - - AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SearchHandle); - return_VOID; -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsDumpEntry - * - * PARAMETERS: Handle - Node to be dumped - * DebugLevel - Output level - * - * DESCRIPTION: Dump a single Node - * - ***************************************************************************/ - -void -AcpiNsDumpEntry ( - ACPI_HANDLE Handle, - UINT32 DebugLevel) -{ - ACPI_WALK_INFO Info; - - - FUNCTION_TRACE_PTR ("NsDumpEntry", Handle); - - Info.DebugLevel = DebugLevel; - Info.OwnerId = ACPI_UINT32_MAX; - - AcpiNsDumpOneObject (Handle, 1, &Info, NULL); - - DEBUG_PRINT (TRACE_EXEC, ("leave AcpiNsDumpEntry %p\n", Handle)); - return_VOID; -} - -#endif - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c deleted file mode 100644 index 5c348534c22ea..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c +++ /dev/null @@ -1,663 +0,0 @@ -/******************************************************************************* - * - * Module Name: nseval - Object evaluation interfaces -- includes control - * method lookup and execution. - * $Revision: 83 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSEVAL_C__ - -#include "acpi.h" -#include "amlcode.h" -#include "acparser.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nseval") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluateRelative - * - * PARAMETERS: Handle - The relative containing object - * *Pathname - Name of method to execute, If NULL, the - * handle is the object to execute - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * *ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Find and execute the requested method using the handle as a - * scope - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluateRelative ( - ACPI_NAMESPACE_NODE *Handle, - NATIVE_CHAR *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_NAMESPACE_NODE *PrefixNode; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; - NATIVE_CHAR *InternalPath = NULL; - ACPI_GENERIC_STATE ScopeInfo; - - - FUNCTION_TRACE ("NsEvaluateRelative"); - - - /* - * Must have a valid object handle - */ - if (!Handle) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Build an internal name string for the method */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the prefix handle and Node */ - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - PrefixNode = AcpiNsConvertHandleToEntry (Handle); - if (!PrefixNode) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - Status = AE_BAD_PARAMETER; - goto Cleanup; - } - - /* Lookup the name in the namespace */ - - ScopeInfo.Scope.Node = PrefixNode; - Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, - &Node); - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateRelative: Object [%s] not found [%.4X]\n", - Pathname, AcpiCmFormatException (Status))); - goto Cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateRelative: %s [%p] Value %p\n", - Pathname, Node, Node->Object)); - - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); - - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateRelative: *** Completed eval of object %s ***\n", - Pathname)); - -Cleanup: - - /* Cleanup */ - - AcpiCmFree (InternalPath); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluateByName - * - * PARAMETERS: Pathname - Fully qualified pathname to the object - * *ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * - * RETURN: Status - * - * DESCRIPTION: Find and execute the requested method passing the given - * parameters - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluateByName ( - NATIVE_CHAR *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; - NATIVE_CHAR *InternalPath = NULL; - - - FUNCTION_TRACE ("NsEvaluateByName"); - - - /* Build an internal name string for the method */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Lookup the name in the namespace */ - - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, - IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, - &Node); - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateByName: Object at [%s] was not found, status=%.4X\n", - Pathname, Status)); - goto Cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateByName: %s [%p] Value %p\n", - Pathname, Node, Node->Object)); - - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); - - DEBUG_PRINT (ACPI_INFO, - ("NsEvaluateByName: *** Completed eval of object %s ***\n", - Pathname)); - - -Cleanup: - - /* Cleanup */ - - if (InternalPath) - { - AcpiCmFree (InternalPath); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluateByHandle - * - * PARAMETERS: Handle - Method Node to execute - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * *ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Execute the requested method passing the given parameters - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluateByHandle ( - ACPI_NAMESPACE_NODE *Handle, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *LocalReturnObject; - - - FUNCTION_TRACE ("NsEvaluateByHandle"); - - - /* Check if namespace has been initialized */ - - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - /* Parameter Validation */ - - if (!Handle) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (ReturnObject) - { - /* Initialize the return value to an invalid object */ - - *ReturnObject = NULL; - } - - /* Get the prefix handle and Node */ - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - Node = AcpiNsConvertHandleToEntry (Handle); - if (!Node) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* - * Two major cases here: - * 1) The object is an actual control method -- execute it. - * 2) The object is not a method -- just return it's current - * value - * - * In both cases, the namespace is unlocked by the - * AcpiNs* procedure - */ - if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) - { - /* - * Case 1) We have an actual control method to execute - */ - Status = AcpiNsExecuteControlMethod (Node, Params, - &LocalReturnObject); - } - - else - { - /* - * Case 2) Object is NOT a method, just return its - * current value - */ - Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); - } - - - /* - * Check if there is a return value on the stack that must - * be dealt with - */ - if (Status == AE_CTRL_RETURN_VALUE) - { - /* - * If the Method returned a value and the caller - * provided a place to store a returned value, Copy - * the returned value to the object descriptor provided - * by the caller. - */ - if (ReturnObject) - { - /* - * Valid return object, copy the pointer to - * the returned object - */ - *ReturnObject = LocalReturnObject; - } - - - /* Map AE_RETURN_VALUE to AE_OK, we are done with it */ - - if (Status == AE_CTRL_RETURN_VALUE) - { - Status = AE_OK; - } - } - - /* - * Namespace was unlocked by the handling AcpiNs* function, - * so we just return - */ - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsExecuteControlMethod - * - * PARAMETERS: MethodNode - The object/method - * **Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * **ReturnObjDesc - List of result objects to be returned - * from the method. - * - * RETURN: Status - * - * DESCRIPTION: Execute the requested method passing the given parameters - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsExecuteControlMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - - - FUNCTION_TRACE ("NsExecuteControlMethod"); - - - /* - * Unlock the namespace before execution. This allows namespace access - * via the external Acpi* interfaces while a method is being executed. - * However, any namespace deletion must acquire both the namespace and - * interpreter locks to ensure that no thread is using the portion of the - * namespace that is being deleted. - */ - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - /* Verify that there is a method associated with this object */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); - if (!ObjDesc) - { - DEBUG_PRINT (ACPI_ERROR, - ("Control method is undefined (nil value)\n")); - return_ACPI_STATUS (AE_ERROR); - } - - - DEBUG_PRINT (ACPI_INFO, ("Control method at Offset %x Length %lx]\n", - ObjDesc->Method.Pcode + 1, - ObjDesc->Method.PcodeLength - 1)); - - DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", - TRACE_NAMES, _COMPONENT); - - DEBUG_PRINT (TRACE_NAMES, - ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); - - /* - * Execute the method via the interpreter - */ - Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetObjectValue - * - * PARAMETERS: Node - The object - * - * RETURN: Status - * - * DESCRIPTION: Return the current value of the object - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsGetObjectValue ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT **ReturnObjDesc) -{ - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *ValDesc; - - - FUNCTION_TRACE ("NsGetObjectValue"); - - - /* - * We take the value from certain objects directly - */ - - if ((Node->Type == ACPI_TYPE_PROCESSOR) || - (Node->Type == ACPI_TYPE_POWER)) - { - /* - * Create a Reference object to contain the object - */ - ObjDesc = AcpiCmCreateInternalObject (Node->Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* - * Get the attached object - */ - - ValDesc = AcpiNsGetAttachedObject (Node); - if (!ValDesc) - { - Status = AE_NULL_OBJECT; - goto UnlockAndExit; - } - - /* - * Just copy from the original to the return object - * - * TBD: [Future] - need a low-level object copy that handles - * the reference count automatically. (Don't want to copy it) - */ - - MEMCPY (ObjDesc, ValDesc, sizeof (ACPI_OPERAND_OBJECT)); - ObjDesc->Common.ReferenceCount = 1; - } - - - /* - * Other objects require a reference object wrapper which we - * then attempt to resolve. - */ - else - { - /* Create an Reference object to contain the object */ - - ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Construct a descriptor pointing to the name */ - - ObjDesc->Reference.OpCode = (UINT8) AML_NAME_OP; - ObjDesc->Reference.Object = (void *) Node; - - /* - * Use AcpiAmlResolveToValue() to get the associated value. - * The call to AcpiAmlResolveToValue causes - * ObjDesc (allocated above) to always be deleted. - * - * NOTE: we can get away with passing in NULL for a walk state - * because ObjDesc is guaranteed to not be a reference to either - * a method local or a method argument - * - * Even though we do not technically need to use the interpreter - * for this, we must enter it because we could hit an opregion. - * The opregion access code assumes it is in the interpreter. - */ - - AcpiAmlEnterInterpreter(); - - Status = AcpiAmlResolveToValue (&ObjDesc, NULL); - - AcpiAmlExitInterpreter(); - } - - /* - * If AcpiAmlResolveToValue() succeeded, the return value was - * placed in ObjDesc. - */ - - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_RETURN_VALUE; - - *ReturnObjDesc = ObjDesc; - DEBUG_PRINT (ACPI_INFO, - ("NsGetObjectValue: Returning obj %p\n", *ReturnObjDesc)); - } - - -UnlockAndExit: - - /* Unlock the namespace */ - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c deleted file mode 100644 index 672bbebc10334..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c +++ /dev/null @@ -1,455 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsinit - namespace initialization - * $Revision: 15 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __NSXFINIT_C__ - -#include "acpi.h" -#include "acnamesp.h" -#include "acdispat.h" - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsinit") - - -/******************************************************************************* - * - * 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; - - - FUNCTION_TRACE ("NsInitializeObjects"); - - - DEBUG_PRINT (TRACE_DISPATCH, - ("NsInitializeObjects: **** Starting initialization of namespace objects ****\n")); - DEBUG_PRINT_RAW (ACPI_OK, ("Completing Region and Field initialization:")); - - - Info.FieldCount = 0; - Info.FieldInit = 0; - Info.OpRegionCount = 0; - Info.OpRegionInit = 0; - Info.ObjectCount = 0; - - - /* Walk entire namespace from the supplied root */ - - Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiNsInitOneObject, - &Info, NULL); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsInitializeObjects: WalkNamespace failed! %x\n", Status)); - } - - DEBUG_PRINT_RAW (ACPI_OK, - ("\n%d/%d Regions, %d/%d Fields initialized (%d nodes total)\n", - Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.ObjectCount)); - DEBUG_PRINT (TRACE_DISPATCH, - ("NsInitializeObjects: %d Control Methods found\n", Info.MethodCount)); - DEBUG_PRINT (TRACE_DISPATCH, - ("NsInitializeObjects: %d Op Regions found\n", 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. - * - * Also: Install PCI config space handler for all PCI root bridges. - * A PCI root bridge is found by searching for devices containing - * a HID with the value EISAID("PNP0A03") - * - *****************************************************************************/ - -ACPI_STATUS -AcpiNsInitializeDevices ( - void) -{ - ACPI_STATUS Status; - ACPI_DEVICE_WALK_INFO Info; - - - FUNCTION_TRACE ("NsInitializeDevices"); - - - Info.DeviceCount = 0; - Info.Num_STA = 0; - Info.Num_INI = 0; - - - DEBUG_PRINT_RAW (ACPI_OK, ("Executing device _INI methods:")); - - Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - FALSE, AcpiNsInitOneDevice, &Info, NULL); - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsInitializeDevices: WalkNamespace failed! %x\n", Status)); - } - - - DEBUG_PRINT_RAW (ACPI_OK, - ("\n%d Devices found: %d _STA, %d _INI\n", - Info.DeviceCount, Info.Num_STA, Info.Num_INI)); - - 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 - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - OBJECT_TYPE_INTERNAL Type; - ACPI_STATUS Status; - ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_OPERAND_OBJECT *ObjDesc; - - - Info->ObjectCount++; - - - /* And even then, we are only interested in a few object types */ - - Type = AcpiNsGetType (ObjHandle); - ObjDesc = Node->Object; - if (!ObjDesc) - { - return (AE_OK); - } - - switch (Type) - { - - case ACPI_TYPE_REGION: - - Info->OpRegionCount++; - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - break; - } - - Info->OpRegionInit++; - Status = AcpiDsGetRegionArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); - DEBUG_PRINT (ACPI_ERROR, ("%s while getting region arguments [%4.4s]\n", - AcpiCmFormatException (Status), &Node->Name)); - } - - if (!(AcpiDbgLevel & TRACE_INIT)) - { - DEBUG_PRINT_RAW (ACPI_OK, (".")); - } - - break; - - - case ACPI_TYPE_FIELD_UNIT: - - Info->FieldCount++; - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - break; - } - - Info->FieldInit++; - Status = AcpiDsGetFieldUnitArguments (ObjDesc); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); - DEBUG_PRINT (ACPI_ERROR, ("%s while getting field arguments [%4.4s]\n", - AcpiCmFormatException (Status), &Node->Name)); - } - if (!(AcpiDbgLevel & TRACE_INIT)) - { - DEBUG_PRINT_RAW (ACPI_OK, (".")); - } - - - break; - - default: - break; - } - - /* - * We ignore errors from above, and always return OK, since - * we don't want to abort the walk on a single error. - */ - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsInitOneDevice - * - * PARAMETERS: 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. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiNsInitOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - UINT32 Flags; - ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; - - - FUNCTION_TRACE ("AcpiNsInitOneDevice"); - - - if (!(AcpiDbgLevel & TRACE_INIT)) - { - DEBUG_PRINT_RAW (ACPI_OK, (".")); - } - - Info->DeviceCount++; - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - Node = AcpiNsConvertHandleToEntry (ObjHandle); - if (!Node) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - /* - * Run _STA to determine if we can run _INI on the device. - */ - - DEBUG_EXEC(AcpiCmDisplayInitPathname (Node, "_STA [Method]")); - Status = AcpiCmExecute_STA (Node, &Flags); - if (ACPI_FAILURE (Status)) - { - /* Ignore error and move on to next device */ - - return_ACPI_STATUS (AE_OK); - } - - Info->Num_STA++; - - if (!(Flags & 0x01)) - { - /* don't look at children of a not present device */ - return_ACPI_STATUS(AE_CTRL_DEPTH); - } - - - - /* - * The device is present. Run _INI. - */ - - DEBUG_EXEC(AcpiCmDisplayInitPathname (ObjHandle, "_INI [Method]")); - Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); - if (AE_NOT_FOUND == Status) - { - /* No _INI means device requires no initialization */ - Status = AE_OK; - } - - else if (ACPI_FAILURE (Status)) - { - /* Ignore error and move on to next device */ - -#ifdef ACPI_DEBUG - NATIVE_CHAR *ScopeName = AcpiNsGetTablePathname (ObjHandle); - - DEBUG_PRINT (ACPI_WARN, ("%s._INI failed: %s\n", - ScopeName, AcpiCmFormatException (Status))); - - AcpiCmFree (ScopeName); -#endif - } - - else - { - /* Count of successfull INIs */ - - Info->Num_INI++; - } - - return_ACPI_STATUS (AE_OK); -} diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c deleted file mode 100644 index 2b49884e2ad47..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c +++ /dev/null @@ -1,706 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsload - namespace loading/expanding/contracting procedures - * $Revision: 35 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSLOAD_C__ - -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "amlcode.h" -#include "acparser.h" -#include "acdispat.h" -#include "acdebug.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsload") - - -/****************************************************************************** - * - * FUNCTION: AcpiLoadNamespace - * - * PARAMETERS: DisplayAmlDuringLoad - * - * 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; - - - FUNCTION_TRACE ("AcpiLoadNameSpace"); - - - /* There must be at least a DSDT installed */ - - if (AcpiGbl_DSDT == NULL) - { - DEBUG_PRINT (ACPI_ERROR, ("DSDT is not in memory\n")); - 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_DSDT); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Ignore exceptions from these */ - - AcpiNsLoadTableByType (ACPI_TABLE_SSDT); - AcpiNsLoadTableByType (ACPI_TABLE_PSDT); - - - DEBUG_PRINT_RAW (ACPI_OK, - ("ACPI Namespace successfully loaded at root %p\n", - AcpiGbl_RootNode)); - - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsOneParsePass - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsOneCompleteParse ( - UINT32 PassNumber, - ACPI_TABLE_DESC *TableDesc) -{ - ACPI_PARSE_DOWNWARDS DescendingCallback; - ACPI_PARSE_UPWARDS AscendingCallback; - ACPI_PARSE_OBJECT *ParseRoot; - ACPI_STATUS Status; - - - FUNCTION_TRACE ("NsOneCompleteParse"); - - - switch (PassNumber) - { - case 1: - DescendingCallback = AcpiDsLoad1BeginOp; - AscendingCallback = AcpiDsLoad1EndOp; - break; - - case 2: - DescendingCallback = AcpiDsLoad2BeginOp; - AscendingCallback = AcpiDsLoad2EndOp; - break; - - case 3: - DescendingCallback = AcpiDsExecBeginOp; - AscendingCallback = AcpiDsExecEndOp; - break; - - default: - return (AE_BAD_PARAMETER); - } - - /* Create and init a Root Node */ - - ParseRoot = AcpiPsAllocOp (AML_SCOPE_OP); - if (!ParseRoot) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ((ACPI_PARSE2_OBJECT *) ParseRoot)->Name = ACPI_ROOT_NAME; - - - /* Pass 1: Parse everything except control method bodies */ - - DEBUG_PRINT (TRACE_PARSE, - ("NsParseTable: *PARSE* pass %d parse\n", PassNumber)); - - Status = AcpiPsParseAml (ParseRoot, - TableDesc->AmlPointer, - TableDesc->AmlLength, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - NULL, NULL, NULL, - DescendingCallback, - AscendingCallback); - - 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 ( - ACPI_TABLE_DESC *TableDesc, - ACPI_NAMESPACE_NODE *StartNode) -{ - ACPI_STATUS Status; - - - 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.. - */ - - Status = AcpiNsOneCompleteParse (1, TableDesc); - 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. - */ - - Status = AcpiNsOneCompleteParse (2, TableDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - return_ACPI_STATUS (Status); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiNsLoadTable - * - * PARAMETERS: *PcodeAddr - Address of pcode block - * PcodeLength - Length of pcode block - * - * RETURN: Status - * - * DESCRIPTION: Load one ACPI table into the namespace - * - ****************************************************************************/ - -ACPI_STATUS -AcpiNsLoadTable ( - ACPI_TABLE_DESC *TableDesc, - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("NsLoadTable"); - - - if (!TableDesc->AmlPointer) - { - DEBUG_PRINT (ACPI_ERROR, ("NsLoadTable: Null AML pointer\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTable: AML block at %p\n", TableDesc->AmlPointer)); - - - if (!TableDesc->AmlLength) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsLoadTable: Zero-length AML block\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* - * 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! - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTable: **** Loading table into namespace ****\n")); - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - Status = AcpiNsParseTable (TableDesc, Node->Child); - AcpiCmReleaseMutex (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. - */ - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTable: **** Begin Table Method Parsing and Object Initialization ****\n")); - - Status = AcpiDsInitializeObjects (TableDesc, Node); - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTable: **** Completed Table Method Parsing and Object Initialization ****\n")); - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsLoadTableByType - * - * PARAMETERS: TableType - Id of the table type to load - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables - * of the given type are loaded. The mechanism allows this - * routine to be called repeatedly. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiNsLoadTableByType ( - ACPI_TABLE_TYPE TableType) -{ - UINT32 i; - ACPI_STATUS Status = AE_OK; - ACPI_TABLE_HEADER *TablePtr; - ACPI_TABLE_DESC *TableDesc; - - - FUNCTION_TRACE ("NsLoadTableByType"); - - - AcpiCmAcquireMutex (ACPI_MTX_TABLES); - - - /* - * Table types supported are: - * DSDT (one), SSDT/PSDT (multiple) - */ - - switch (TableType) - { - - case ACPI_TABLE_DSDT: - - DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading DSDT\n")); - - TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_DSDT]; - - /* If table already loaded into namespace, just return */ - - if (TableDesc->LoadedIntoNamespace) - { - goto UnlockAndExit; - } - - TableDesc->TableId = TABLE_ID_DSDT; - - /* Now load the single DSDT */ - - Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); - if (ACPI_SUCCESS (Status)) - { - TableDesc->LoadedIntoNamespace = TRUE; - } - - break; - - - case ACPI_TABLE_SSDT: - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTableByType: Loading %d SSDTs\n", - AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count)); - - /* - * Traverse list of SSDT tables - */ - - TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT]; - for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++) - { - TablePtr = TableDesc->Pointer; - - /* - * Only attempt to load table if it is not - * already loaded! - */ - - if (!TableDesc->LoadedIntoNamespace) - { - Status = AcpiNsLoadTable (TableDesc, - AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - break; - } - - TableDesc->LoadedIntoNamespace = TRUE; - } - - TableDesc = TableDesc->Next; - } - - break; - - - case ACPI_TABLE_PSDT: - - DEBUG_PRINT (ACPI_INFO, - ("NsLoadTableByType: Loading %d PSDTs\n", - AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count)); - - /* - * Traverse list of PSDT tables - */ - - TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT]; - - for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++) - { - TablePtr = TableDesc->Pointer; - - /* Only attempt to load table if it is not already loaded! */ - - if (!TableDesc->LoadedIntoNamespace) - { - Status = AcpiNsLoadTable (TableDesc, - AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - break; - } - - TableDesc->LoadedIntoNamespace = TRUE; - } - - TableDesc = TableDesc->Next; - } - - break; - - - default: - Status = AE_SUPPORT; - } - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_TABLES); - - return_ACPI_STATUS (Status); - -} - - -/****************************************************************************** - * - * 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. - * - * TBD: [Investigate] What if any part of this subtree is in use? - * (i.e. on one of the object stacks?) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsDeleteSubtree ( - ACPI_HANDLE StartHandle) -{ - ACPI_STATUS Status; - ACPI_HANDLE ChildHandle; - ACPI_HANDLE ParentHandle; - ACPI_HANDLE NextChildHandle; - ACPI_HANDLE Dummy; - UINT32 Level; - - - FUNCTION_TRACE ("NsDeleteSubtree"); - - - ParentHandle = StartHandle; - ChildHandle = 0; - 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, 0, - &Dummy))) - { - /* - * There is at least one child of this object, - * visit the object - */ - - Level++; - ParentHandle = ChildHandle; - ChildHandle = 0; - } - } - - else - { - /* - * No more children in this object, go back up to - * the object's parent - */ - Level--; - - /* Delete all children now */ - - AcpiNsDeleteChildren (ChildHandle); - - ChildHandle = ParentHandle; - AcpiGetParent (ParentHandle, &ParentHandle); - } - } - - /* Now delete the starting object, and we are done */ - - AcpiNsDeleteNode (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; - - - 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); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c deleted file mode 100644 index b7cc321a48312..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c +++ /dev/null @@ -1,367 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsnames - Name manipulation and search - * $Revision: 54 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSNAMES_C__ - -#include "acpi.h" -#include "amlcode.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsnames") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetTablePathname - * - * PARAMETERS: Node - Scope whose name is needed - * - * RETURN: Pointer to storage containing the fully qualified name of - * the scope, in Label format (all segments strung together - * with no separators) - * - * DESCRIPTION: Used for debug printing in AcpiNsSearchTable(). - * - ******************************************************************************/ - -NATIVE_CHAR * -AcpiNsGetTablePathname ( - ACPI_NAMESPACE_NODE *Node) -{ - NATIVE_CHAR *NameBuffer; - UINT32 Size; - ACPI_NAME Name; - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_NAMESPACE_NODE *ParentNode; - - - FUNCTION_TRACE_PTR ("AcpiNsGetTablePathname", Node); - - - if (!AcpiGbl_RootNode || !Node) - { - /* - * If the name space has not been initialized, - * this function should not have been called. - */ - return_PTR (NULL); - } - - ChildNode = Node->Child; - - - /* Calculate required buffer size based on depth below root */ - - Size = 1; - ParentNode = ChildNode; - while (ParentNode) - { - ParentNode = AcpiNsGetParentObject (ParentNode); - if (ParentNode) - { - Size += ACPI_NAME_SIZE; - } - } - - - /* Allocate a buffer to be returned to caller */ - - NameBuffer = AcpiCmCallocate (Size + 1); - if (!NameBuffer) - { - REPORT_ERROR (("NsGetTablePathname: allocation failure\n")); - return_PTR (NULL); - } - - - /* Store terminator byte, then build name backwards */ - - NameBuffer[Size] = '\0'; - while ((Size > ACPI_NAME_SIZE) && - AcpiNsGetParentObject (ChildNode)) - { - Size -= ACPI_NAME_SIZE; - Name = AcpiNsFindParentName (ChildNode); - - /* Put the name into the buffer */ - - MOVE_UNALIGNED32_TO_32 ((NameBuffer + Size), &Name); - ChildNode = AcpiNsGetParentObject (ChildNode); - } - - NameBuffer[--Size] = AML_ROOT_PREFIX; - - if (Size != 0) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsGetTablePathname: Bad pointer returned; size=%X\n", Size)); - } - - 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 - * - ******************************************************************************/ - -UINT32 -AcpiNsGetPathnameLength ( - ACPI_NAMESPACE_NODE *Node) -{ - UINT32 Size; - ACPI_NAMESPACE_NODE *NextNode; - - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - for (Size = 0, NextNode = Node; - AcpiNsGetParentObject (NextNode); - NextNode = AcpiNsGetParentObject (NextNode)) - { - Size += PATH_SEGMENT_LENGTH; - } - - /* Special case for size still 0 - no parent for "special" nodes */ - - if (!Size) - { - Size = PATH_SEGMENT_LENGTH; - } - - return (Size + 1); -} - - - -/******************************************************************************* - * - * FUNCTION: AcpiNsHandleToPathname - * - * PARAMETERS: TargetHandle - Handle of named object whose name is - * to be found - * BufSize - Size of the buffer provided - * UserBuffer - Where the pathname is returned - * - * RETURN: Status, Buffer is filled with pathname if status is AE_OK - * - * DESCRIPTION: Build and return a full namespace pathname - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsHandleToPathname ( - ACPI_HANDLE TargetHandle, - UINT32 *BufSize, - NATIVE_CHAR *UserBuffer) -{ - ACPI_STATUS Status = AE_OK; - ACPI_NAMESPACE_NODE *Node; - UINT32 PathLength; - UINT32 UserBufSize; - ACPI_NAME Name; - UINT32 Size; - - FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); - - - if (!AcpiGbl_RootNode || !TargetHandle) - { - /* - * If the name space has not been initialized, - * this function should not have been called. - */ - - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - Node = AcpiNsConvertHandleToEntry (TargetHandle); - if (!Node) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* Set return length to the required path length */ - - PathLength = AcpiNsGetPathnameLength (Node); - Size = PathLength - 1; - - UserBufSize = *BufSize; - *BufSize = PathLength; - - /* Check if the user buffer is sufficiently large */ - - if (PathLength > UserBufSize) - { - Status = AE_BUFFER_OVERFLOW; - goto Exit; - } - - /* Store null terminator */ - - UserBuffer[Size] = 0; - Size -= ACPI_NAME_SIZE; - - /* Put the original ACPI name at the end of the path */ - - MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), - &Node->Name); - - UserBuffer[--Size] = PATH_SEPARATOR; - - /* Build name backwards, putting "." between segments */ - - while ((Size > ACPI_NAME_SIZE) && Node) - { - Size -= ACPI_NAME_SIZE; - Name = AcpiNsFindParentName (Node); - MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), &Name); - - UserBuffer[--Size] = PATH_SEPARATOR; - Node = AcpiNsGetParentObject (Node); - } - - /* - * Overlay the "." preceding the first segment with - * the root name "\" - */ - - UserBuffer[Size] = '\\'; - - DEBUG_PRINT (TRACE_EXEC, - ("NsHandleToPathname: Len=%X, %s \n", - PathLength, UserBuffer)); - -Exit: - return_ACPI_STATUS (Status); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c deleted file mode 100644 index f0192fb3fc801..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c +++ /dev/null @@ -1,523 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsobject - Utilities for objects attached to namespace - * table entries - * $Revision: 49 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __NSOBJECT_C__ - -#include "acpi.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "actables.h" - - -#define _COMPONENT NAMESPACE - 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 - * - * 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. - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsAttachObject ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT *Object, - OBJECT_TYPE_INTERNAL Type) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *PreviousObjDesc; - OBJECT_TYPE_INTERNAL ObjType = ACPI_TYPE_ANY; - UINT8 Flags; - UINT16 Opcode; - - - FUNCTION_TRACE ("NsAttachObject"); - - - /* - * Parameter validation - */ - - if (!AcpiGbl_RootNode) - { - /* Name space not initialized */ - - REPORT_ERROR (("NsAttachObject: Namespace not initialized\n")); - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - if (!Node) - { - /* Invalid handle */ - - REPORT_ERROR (("NsAttachObject: Null NamedObj handle\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!Object && (ACPI_TYPE_ANY != Type)) - { - /* Null object */ - - REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!VALID_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED)) - { - /* Not a name handle */ - - REPORT_ERROR (("NsAttachObject: Invalid handle\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Check if this object is already attached */ - - if (Node->Object == Object) - { - DEBUG_PRINT (TRACE_EXEC, - ("NsAttachObject: Obj %p already installed in NameObj %p\n", - Object, Node)); - - return_ACPI_STATUS (AE_OK); - } - - - /* Get the current flags field of the Node */ - - Flags = Node->Flags; - Flags &= ~ANOBJ_AML_ATTACHMENT; - - - /* If null object, we will just install it */ - - if (!Object) - { - ObjDesc = NULL; - ObjType = ACPI_TYPE_ANY; - } - - /* - * If the object is an Node with an attached object, - * we will use that (attached) object - */ - - else if (VALID_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; - ObjType = ((ACPI_NAMESPACE_NODE *) Object)->Type; - - /* - * Copy appropriate flags - */ - - if (((ACPI_NAMESPACE_NODE *) Object)->Flags & ANOBJ_AML_ATTACHMENT) - { - Flags |= ANOBJ_AML_ATTACHMENT; - } - } - - - /* - * Otherwise, we will use the parameter object, but we must type - * it first - */ - - else - { - ObjDesc = (ACPI_OPERAND_OBJECT *) Object; - - - /* If a valid type (non-ANY) was given, just use it */ - - if (ACPI_TYPE_ANY != Type) - { - ObjType = Type; - } - - - /* - * Type is TYPE_Any, we must try to determinte the - * actual type of the object - */ - - /* - * Check if value points into the AML code - */ - else if (AcpiTbSystemTablePointer (Object)) - { - /* - * Object points into the AML stream. - * Set a flag bit in the Node to indicate this - */ - - Flags |= ANOBJ_AML_ATTACHMENT; - - /* - * The next byte (perhaps the next two bytes) - * will be the AML opcode - */ - - MOVE_UNALIGNED16_TO_16 (&Opcode, Object); - - /* Check for a recognized OpCode */ - - switch ((UINT8) Opcode) - { - - case AML_OP_PREFIX: - - if (Opcode != AML_REVISION_OP) - { - /* - * OpPrefix is unrecognized unless part - * of RevisionOp - */ - - break; - } - - /* Else fall through to set type as Number */ - - - case AML_ZERO_OP: case AML_ONES_OP: case AML_ONE_OP: - case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP: - - ObjType = ACPI_TYPE_INTEGER; - break; - - - case AML_STRING_OP: - - ObjType = ACPI_TYPE_STRING; - break; - - - case AML_BUFFER_OP: - - ObjType = ACPI_TYPE_BUFFER; - break; - - - case AML_MUTEX_OP: - - ObjType = ACPI_TYPE_MUTEX; - break; - - - case AML_PACKAGE_OP: - - ObjType = ACPI_TYPE_PACKAGE; - break; - - - default: - - DEBUG_PRINT (ACPI_ERROR, - ("AML Opcode/Type [%x] not supported in attach\n", - (UINT8) Opcode)); - - return_ACPI_STATUS (AE_TYPE); - break; - } - } - - else - { - /* - * Cannot figure out the type -- set to DefAny which - * will print as an error in the name table dump - */ - - if (GetDebugLevel () > 0) - { - DUMP_PATHNAME (Node, - "NsAttachObject confused: setting bogus type for ", - ACPI_INFO, _COMPONENT); - - if (AcpiTbSystemTablePointer (Object)) - { - DEBUG_PRINT (ACPI_INFO, - ("AML-stream code %02x\n", *(UINT8 *) Object)); - } - - else if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) - { - DUMP_PATHNAME (Object, - "name ", ACPI_INFO, - _COMPONENT); - } - - else - { - DUMP_PATHNAME (Object, "object ", - ACPI_INFO, _COMPONENT); - DUMP_STACK_ENTRY (Object); - } - } - - ObjType = INTERNAL_TYPE_DEF_ANY; - } - } - - - DEBUG_PRINT (TRACE_EXEC, - ("NsAttachObject: Installing obj %p into NameObj %p [%4.4s]\n", - ObjDesc, Node, &Node->Name)); - - - /* - * Must increment the new value's reference count - * (if it is an internal object) - */ - - AcpiCmAddReference (ObjDesc); - - /* Save the existing object (if any) for deletion later */ - - PreviousObjDesc = Node->Object; - - /* Install the object and set the type, flags */ - - Node->Object = ObjDesc; - Node->Type = (UINT8) ObjType; - Node->Flags |= Flags; - - - /* - * Delete an existing attached object. - */ - - if (PreviousObjDesc) - { - /* One for the attach to the Node */ - - AcpiCmRemoveReference (PreviousObjDesc); - - /* Now delete */ - - AcpiCmRemoveReference (PreviousObjDesc); - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDetachObject - * - * PARAMETERS: Node - An object whose Value will be deleted - * - * RETURN: None. - * - * DESCRIPTION: Delete the Value associated with a namespace object. If the - * Value is an allocated object, it is freed. Otherwise, the - * field is simply cleared. - * - ******************************************************************************/ - -void -AcpiNsDetachObject ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - - - FUNCTION_TRACE ("NsDetachObject"); - - ObjDesc = Node->Object; - if (!ObjDesc) - { - return_VOID; - } - - /* Clear the entry in all cases */ - - Node->Object = NULL; - - /* Found a valid value */ - - DEBUG_PRINT (ACPI_INFO, - ("NsDetachObject: Object=%p Value=%p Name %4.4s\n", - Node, ObjDesc, &Node->Name)); - - /* - * Not every value is an object allocated via AcpiCmCallocate, - * - must check - */ - - if (!AcpiTbSystemTablePointer (ObjDesc)) - { - /* Attempt to delete the object (and all subobjects) */ - - AcpiCmRemoveReference (ObjDesc); - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetAttachedObject - * - * PARAMETERS: Handle - Parent Node to be examined - * - * RETURN: Current value of the object field from the Node whose - * handle is passed - * - ******************************************************************************/ - -void * -AcpiNsGetAttachedObject ( - ACPI_HANDLE Handle) -{ - FUNCTION_TRACE_PTR ("NsGetAttachedObject", Handle); - - - if (!Handle) - { - /* handle invalid */ - - DEBUG_PRINT (ACPI_WARN, ("NsGetAttachedObject: Null handle\n")); - return_PTR (NULL); - } - - return_PTR (((ACPI_NAMESPACE_NODE *) Handle)->Object); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c deleted file mode 100644 index 3ecdf4ebb1430..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c +++ /dev/null @@ -1,525 +0,0 @@ -/******************************************************************************* - * - * Module Name: nssearch - Namespace search - * $Revision: 64 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSSEARCH_C__ - -#include "acpi.h" -#include "amlcode.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nssearch") - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSearchNode - * - * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting table where search will begin - * Type - Object type to match - * **ReturnNode - Where the matched Named obj is returned - * - * RETURN: Status - * - * DESCRIPTION: Search a single namespace table. Performs a simple search, - * 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. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsSearchNode ( - UINT32 TargetName, - ACPI_NAMESPACE_NODE *Node, - OBJECT_TYPE_INTERNAL Type, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_NAMESPACE_NODE *NextNode; - - - FUNCTION_TRACE ("NsSearchNode"); - - -#ifdef ACPI_DEBUG - if (TRACE_NAMES & AcpiDbgLevel) - { - NATIVE_CHAR *ScopeName; - - ScopeName = AcpiNsGetTablePathname (Node); - if (ScopeName) - { - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchNode: Searching %s [%p]\n", - ScopeName, Node)); - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchNode: For %4.4s (type %X)\n", - &TargetName, Type)); - - AcpiCmFree (ScopeName); - } - } -#endif - - - /* - * Search for name in this table, which is to say that we must search - * for the name among the children of this object - */ - - NextNode = Node->Child; - while (NextNode) - { - /* Check for match against the name */ - - if (NextNode->Name == TargetName) - { - /* - * Found matching entry. Capture type if - * appropriate before returning the entry. - */ - - /* - * The DefFieldDefn and BankFieldDefn cases - * are actually looking up the Region in which - * the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - Type = ACPI_TYPE_REGION; - } - - /* - * Scope, DefAny, and IndexFieldDefn are bogus - * "types" which do not actually have anything - * to do with the type of the name being looked - * up. For any other value of Type, if the type - * stored in the entry is Any (i.e. unknown), - * save the actual type. - */ - - if (Type != INTERNAL_TYPE_SCOPE && - Type != INTERNAL_TYPE_DEF_ANY && - Type != INTERNAL_TYPE_INDEX_FIELD_DEFN && - NextNode->Type == ACPI_TYPE_ANY) - { - NextNode->Type = (UINT8) Type; - } - - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchNode: Name %4.4s (actual type %X) found at %p\n", - &TargetName, NextNode->Type, NextNode)); - - *ReturnNode = NextNode; - return_ACPI_STATUS (AE_OK); - } - - - /* - * The last entry in the list points back to the parent, - * so a flag is used to indicate the end-of-list - */ - if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - /* Searched entire list, we are done */ - - break; - } - - /* Didn't match name, move on to the next peer object */ - - NextNode = NextNode->Peer; - } - - - /* Searched entire table, not found */ - - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchNode: Name %4.4s (type %X) not found at %p\n", - &TargetName, Type, NextNode)); - - - return_ACPI_STATUS (AE_NOT_FOUND); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsSearchParentTree - * - * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting table where search will begin - * Type - Object type to match - * **ReturnNode - Where the matched Named Obj is returned - * - * RETURN: Status - * - * DESCRIPTION: Called when a name has not been found in the current namespace - * table. 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, - OBJECT_TYPE_INTERNAL Type, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *ParentNode; - - - FUNCTION_TRACE ("NsSearchParentTree"); - - - ParentNode = AcpiNsGetParentObject (Node); - - /* - * If there is no parent (at the root) or type is "local", we won't be - * searching the parent tree. - */ - if ((AcpiNsLocal (Type)) || - (!ParentNode)) - { - if (!ParentNode) - { - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchParentTree: [%4.4s] has no parent\n", - &TargetName)); - } - - if (AcpiNsLocal (Type)) - { - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchParentTree: [%4.4s] (type %X) is local (no search)\n", - &TargetName, Type)); - } - - return_ACPI_STATUS (AE_NOT_FOUND); - } - - - /* Search the parent tree */ - - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchParentTree: Searching parent for %4.4s\n", - &TargetName)); - - /* - * Search parents until found the target or we have backed up to - * the root - */ - - while (ParentNode) - { - /* Search parent scope */ - /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ - - Status = AcpiNsSearchNode (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 = AcpiNsGetParentObject (ParentNode); - } - - - /* 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 table where search will begin - * InterpreterMode - Add names only in MODE_LoadPassX. - * 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 name table, - * 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 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, - OPERATING_MODE InterpreterMode, - OBJECT_TYPE_INTERNAL Type, - UINT32 Flags, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *NewNode; - - - FUNCTION_TRACE ("NsSearchAndEnter"); - - - /* Parameter validation */ - - if (!Node || !TargetName || !ReturnNode) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsSearchAndEnter: Null param: Table %p Name %p Return %p\n", - Node, TargetName, ReturnNode)); - - REPORT_ERROR (("NsSearchAndEnter: bad (null) parameter\n")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* Name must consist of printable characters */ - - if (!AcpiCmValidAcpiName (TargetName)) - { - DEBUG_PRINT (ACPI_ERROR, - ("NsSearchAndEnter: *** Bad character in name: %08lx *** \n", - TargetName)); - - REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name\n")); - return_ACPI_STATUS (AE_BAD_CHARACTER); - } - - - /* Try to find the name in the table specified by the caller */ - - *ReturnNode = ENTRY_NOT_FOUND; - Status = AcpiNsSearchNode (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) && - (Flags & NS_ERROR_IF_FOUND)) - { - Status = AE_EXIST; - } - - /* - * Either found it or there was an error - * -- finished either way - */ - return_ACPI_STATUS (Status); - } - - - /* - * Not found in the table. 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 != IMODE_LOAD_PASS1) && - (Flags & NS_SEARCH_PARENT)) - { - /* - * Not found in table - search parent tree according - * to 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 == IMODE_EXECUTE) - { - DEBUG_PRINT (TRACE_NAMES, - ("NsSearchAndEnter: %4.4s Not found in %p [Not adding]\n", - &TargetName, Node)); - - return_ACPI_STATUS (AE_NOT_FOUND); - } - - - /* Create the new named object */ - - NewNode = AcpiNsCreateNode (TargetName); - if (!NewNode) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* 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/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c deleted file mode 100644 index 936843c167475..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c +++ /dev/null @@ -1,1048 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing - * parents and siblings and Scope manipulation - * $Revision: 77 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSUTILS_C__ - -#include "acpi.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "amlcode.h" -#include "actables.h" - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsutils") - - -/**************************************************************************** - * - * FUNCTION: AcpiNsValidRootPrefix - * - * PARAMETERS: Prefix - Character to be checked - * - * RETURN: TRUE if a valid prefix - * - * DESCRIPTION: Check if a character is a valid ACPI Root prefix - * - ***************************************************************************/ - -BOOLEAN -AcpiNsValidRootPrefix ( - NATIVE_CHAR Prefix) -{ - - return ((BOOLEAN) (Prefix == '\\')); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsValidPathSeparator - * - * PARAMETERS: Sep - Character to be checked - * - * RETURN: TRUE if a valid path separator - * - * DESCRIPTION: Check if a character is a valid ACPI path separator - * - ***************************************************************************/ - -BOOLEAN -AcpiNsValidPathSeparator ( - NATIVE_CHAR Sep) -{ - - return ((BOOLEAN) (Sep == '.')); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsGetType - * - * PARAMETERS: Handle - Parent Node to be examined - * - * RETURN: Type field from Node whose handle is passed - * - ***************************************************************************/ - -OBJECT_TYPE_INTERNAL -AcpiNsGetType ( - ACPI_HANDLE handle) -{ - FUNCTION_TRACE ("NsGetType"); - - - if (!handle) - { - REPORT_WARNING (("NsGetType: Null handle\n")); - return_VALUE (ACPI_TYPE_ANY); - } - - return_VALUE (((ACPI_NAMESPACE_NODE *) handle)->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 - * - ***************************************************************************/ - -UINT32 -AcpiNsLocal ( - OBJECT_TYPE_INTERNAL Type) -{ - FUNCTION_TRACE ("NsLocal"); - - - if (!AcpiCmValidObjectType (Type)) - { - /* Type code out of range */ - - REPORT_WARNING (("NsLocal: Invalid Object Type\n")); - return_VALUE (NSP_NORMAL); - } - - return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & NSP_LOCAL); -} - - -/**************************************************************************** - * - * 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 ( - NATIVE_CHAR *ExternalName, - NATIVE_CHAR **ConvertedName) -{ - NATIVE_CHAR *Result = NULL; - NATIVE_CHAR *InternalName; - UINT32 NumSegments = 0; - BOOLEAN FullyQualified = FALSE; - UINT32 i; - UINT32 NumCarats = 0; - - - FUNCTION_TRACE ("NsInternalizeName"); - - - if ((!ExternalName) || - (*ExternalName == 0) || - (!ConvertedName)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* - * 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 (AcpiNsValidRootPrefix (ExternalName[0])) - { - FullyQualified = TRUE; - ExternalName++; - } - - else - { - /* - * Handle Carat prefixes - */ - - while (*ExternalName == '^') - { - NumCarats++; - ExternalName++; - } - } - - /* - * 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 (*ExternalName) - { - NumSegments = 1; - for (i = 0; ExternalName[i]; i++) - { - if (AcpiNsValidPathSeparator (ExternalName[i])) - { - NumSegments++; - } - } - } - - - /* We need a segment to store the internal version of the name */ - - InternalName = AcpiCmCallocate ((ACPI_NAME_SIZE * NumSegments) + 4 + NumCarats); - if (!InternalName) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - - /* Setup the correct prefixes, counts, and pointers */ - - if (FullyQualified) - { - InternalName[0] = '\\'; - - 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 (NumCarats) - { - for (i = 0; i < NumCarats; i++) - { - InternalName[i] = '^'; - } - } - - if (NumSegments == 1) - { - Result = &InternalName[i]; - } - - else if (NumSegments == 2) - { - InternalName[i] = AML_DUAL_NAME_PREFIX; - Result = &InternalName[i+1]; - } - - else - { - InternalName[i] = AML_MULTI_NAME_PREFIX_OP; - InternalName[i+1] = (char) NumSegments; - Result = &InternalName[i+2]; - } - } - - - /* Build the name (minus path separators) */ - - for (; NumSegments; NumSegments--) - { - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (AcpiNsValidPathSeparator (*ExternalName) || - (*ExternalName == 0)) - { - /* - * Pad the segment with underscore(s) if - * segment is short - */ - - Result[i] = '_'; - } - - else - { - /* Convert INT8 to uppercase and save it */ - - Result[i] = (char) TOUPPER (*ExternalName); - ExternalName++; - } - - } - - /* Now we must have a path separator, or the pathname is bad */ - - if (!AcpiNsValidPathSeparator (*ExternalName) && - (*ExternalName != 0)) - { - AcpiCmFree (InternalName); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Move on the next segment */ - - ExternalName++; - Result += ACPI_NAME_SIZE; - } - - - /* Return the completed name */ - - /* Terminate the string! */ - *Result = 0; - *ConvertedName = InternalName; - - - if (FullyQualified) - { - DEBUG_PRINT (TRACE_EXEC, - ("NsInternalizeName: returning [%p] (abs) \"\\%s\"\n", - InternalName, &InternalName[0])); - } - else - { - DEBUG_PRINT (TRACE_EXEC, - ("NsInternalizeName: returning [%p] (rel) \"%s\"\n", - InternalName, &InternalName[2])); - } - - return_ACPI_STATUS (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsExternalizeName - * - * PARAMETERS: *InternalName - Internal representation of name - * **ConvertedName - Where to return the resulting - * external representation of name - * - * RETURN: Status - * - * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external form (e.g. "\_PR_.CPU0") - * - ****************************************************************************/ - -ACPI_STATUS -AcpiNsExternalizeName ( - UINT32 InternalNameLength, - char *InternalName, - UINT32 *ConvertedNameLength, - char **ConvertedName) -{ - UINT32 PrefixLength = 0; - UINT32 NamesIndex = 0; - UINT32 NamesCount = 0; - UINT32 i = 0; - UINT32 j = 0; - - - FUNCTION_TRACE ("NsExternalizeName"); - - - if (!InternalNameLength || - !InternalName || - !ConvertedNameLength || - !ConvertedName) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* - * Check for a prefix (one '\' | one or more '^'). - */ - switch (InternalName[0]) - { - case '\\': - PrefixLength = 1; - break; - - case '^': - for (i = 0; i < InternalNameLength; i++) - { - if (InternalName[i] != '^') - { - PrefixLength = i + 1; - } - } - - if (i == InternalNameLength) - { - PrefixLength = i; - } - - break; - } - - /* - * Check for object names. Note that there could be 0-255 of these - * 4-byte elements. - */ - if (PrefixLength < InternalNameLength) - { - switch (InternalName[PrefixLength]) - { - - /* <count> 4-byte names */ - - case AML_MULTI_NAME_PREFIX_OP: - NamesIndex = PrefixLength + 2; - NamesCount = (UINT32) InternalName[PrefixLength + 1]; - break; - - - /* two 4-byte names */ - - case AML_DUAL_NAME_PREFIX: - NamesIndex = PrefixLength + 1; - NamesCount = 2; - break; - - - /* NullName */ - - case 0: - NamesIndex = 0; - NamesCount = 0; - break; - - - /* one 4-byte name */ - - default: - NamesIndex = PrefixLength; - NamesCount = 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. - */ - *ConvertedNameLength = PrefixLength + (4 * NamesCount) + - ((NamesCount > 0) ? (NamesCount - 1) : 0) + 1; - - /* - * Check to see if we're still in bounds. If not, there's a problem - * with InternalName (invalid format). - */ - if (*ConvertedNameLength > InternalNameLength) - { - REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); - return_ACPI_STATUS (AE_BAD_PATHNAME); - } - - /* - * Build ConvertedName... - */ - - (*ConvertedName) = AcpiCmCallocate (*ConvertedNameLength); - if (!(*ConvertedName)) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - j = 0; - - for (i = 0; i < PrefixLength; i++) - { - (*ConvertedName)[j++] = InternalName[i]; - } - - if (NamesCount > 0) - { - for (i = 0; i < NamesCount; i++) - { - if (i > 0) - { - (*ConvertedName)[j++] = '.'; - } - - (*ConvertedName)[j++] = InternalName[NamesIndex++]; - (*ConvertedName)[j++] = InternalName[NamesIndex++]; - (*ConvertedName)[j++] = InternalName[NamesIndex++]; - (*ConvertedName)[j++] = InternalName[NamesIndex++]; - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsConvertHandleToEntry - * - * PARAMETERS: Handle - Handle to be converted to an Node - * - * RETURN: A Name table entry pointer - * - * DESCRIPTION: Convert a namespace handle to a real Node - * - ****************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsConvertHandleToEntry ( - ACPI_HANDLE Handle) -{ - - /* - * Simple implementation for now; - * TBD: [Future] Real integer handles allow for more verification - * and keep all pointers within this subsystem! - */ - - if (!Handle) - { - return (NULL); - } - - if (Handle == ACPI_ROOT_OBJECT) - { - return (AcpiGbl_RootNode); - } - - - /* We can at least attempt to verify the handle */ - - if (!VALID_DESCRIPTOR_TYPE (Handle, ACPI_DESC_TYPE_NAMED)) - { - return (NULL); - } - - return ((ACPI_NAMESPACE_NODE *) Handle); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsConvertEntryToHandle - * - * PARAMETERS: Node - Node to be converted to a Handle - * - * RETURN: An USER ACPI_HANDLE - * - * DESCRIPTION: Convert a real Node to a namespace handle - * - ****************************************************************************/ - -ACPI_HANDLE -AcpiNsConvertEntryToHandle ( - ACPI_NAMESPACE_NODE *Node) -{ - - - /* - * Simple implementation for now; - * TBD: [Future] Real integer handles allow for more verification - * and keep all pointers within this subsystem! - */ - - return ((ACPI_HANDLE) Node); - - -/* --------------------------------------------------- - - if (!Node) - { - return (NULL); - } - - if (Node == AcpiGbl_RootNode) - { - return (ACPI_ROOT_OBJECT); - } - - - return ((ACPI_HANDLE) Node); -------------------------------------------------------*/ -} - - -/****************************************************************************** - * - * FUNCTION: AcpiNsTerminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for table storage. - * - ******************************************************************************/ - -void -AcpiNsTerminate (void) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *ThisNode; - - - FUNCTION_TRACE ("NsTerminate"); - - - ThisNode = AcpiGbl_RootNode; - - /* - * 1) Free the entire namespace -- all objects, tables, and stacks - */ - /* - * Delete all objects linked to the root - * (additional table descriptors) - */ - - AcpiNsDeleteNamespaceSubtree (ThisNode); - - /* Detach any object(s) attached to the root */ - - ObjDesc = AcpiNsGetAttachedObject (ThisNode); - if (ObjDesc) - { - AcpiNsDetachObject (ThisNode); - AcpiCmRemoveReference (ObjDesc); - } - - AcpiNsDeleteChildren (ThisNode); - - DEBUG_PRINT (ACPI_INFO, ("NsTerminate: Namespace freed\n")); - - - /* - * 2) Now we can delete the ACPI tables - */ - - AcpiTbDeleteAcpiTables (); - - DEBUG_PRINT (ACPI_INFO, ("NsTerminate: ACPI Tables 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 ( - OBJECT_TYPE_INTERNAL Type) -{ - FUNCTION_TRACE_U32 ("NsOpensScope", Type); - - - if (!AcpiCmValidObjectType (Type)) - { - /* type code out of range */ - - REPORT_WARNING (("NsOpensScope: Invalid Object Type\n")); - return_VALUE (NSP_NORMAL); - } - - return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & NSP_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. - * StartNode - 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. - * 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 ( - NATIVE_CHAR *Pathname, - ACPI_NAMESPACE_NODE *StartNode, - ACPI_NAMESPACE_NODE **ReturnNode) -{ - ACPI_GENERIC_STATE ScopeInfo; - ACPI_STATUS Status; - NATIVE_CHAR *InternalPath = NULL; - - - FUNCTION_TRACE_PTR ("NsGetNode", Pathname); - - - /* Ensure that the namespace has been initialized */ - - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - if (!Pathname) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* Convert path to internal representation */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Setup lookup scope (search starting point) */ - - ScopeInfo.Scope.Node = StartNode; - - /* Lookup the name in the namespace */ - - Status = AcpiNsLookup (&ScopeInfo, InternalPath, - ACPI_TYPE_ANY, IMODE_EXECUTE, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, ReturnNode); - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_INFO, ("NsGetNode: %s, %s\n", - InternalPath, AcpiCmFormatException (Status))); - } - - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - /* Cleanup */ - - AcpiCmFree (InternalPath); - - return_ACPI_STATUS (Status); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsFindParentName - * - * PARAMETERS: *ChildNode - Named Obj whose name is to be found - * - * RETURN: The ACPI name - * - * DESCRIPTION: Search for the given obj in its parent scope and return the - * name segment, or "????" if the parent name can't be found - * (which "should not happen"). - * - ***************************************************************************/ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *ParentNode; - - - FUNCTION_TRACE ("FindParentName"); - - - if (ChildNode) - { - /* Valid entry. Get the parent Node */ - - ParentNode = AcpiNsGetParentObject (ChildNode); - if (ParentNode) - { - DEBUG_PRINT (TRACE_EXEC, - ("Parent of %p [%4.4s] is %p [%4.4s]\n", - ChildNode, &ChildNode->Name, ParentNode, - &ParentNode->Name)); - - if (ParentNode->Name) - { - return_VALUE (ParentNode->Name); - } - } - - DEBUG_PRINT (TRACE_EXEC, - ("FindParentName: unable to find parent of %p (%4.4s)\n", - ChildNode, &ChildNode->Name)); - } - - - return_VALUE (ACPI_UNKNOWN_NAME); -} - - -#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) - -/**************************************************************************** - * - * FUNCTION: AcpiNsExistDownstreamSibling - * - * PARAMETERS: *Node - pointer to first Node to examine - * - * RETURN: TRUE if sibling is found, FALSE otherwise - * - * DESCRIPTION: Searches remainder of scope being processed to determine - * whether there is a downstream sibling to the current - * object. This function is used to determine what type of - * line drawing character to use when displaying namespace - * trees. - * - ***************************************************************************/ - -BOOLEAN -AcpiNsExistDownstreamSibling ( - ACPI_NAMESPACE_NODE *Node) -{ - - if (!Node) - { - return (FALSE); - } - - if (Node->Name) - { - return (TRUE); - } - - return (FALSE); -} - -#endif /* ACPI_DEBUG */ - - -/**************************************************************************** - * - * FUNCTION: AcpiNsGetParentObject - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Parent entry of the given entry - * - * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. - * - ***************************************************************************/ - - -ACPI_NAMESPACE_NODE * -AcpiNsGetParentObject ( - ACPI_NAMESPACE_NODE *Node) -{ - - - if (!Node) - { - return (NULL); - } - - /* - * Walk to the end of this peer list. - * The last entry is marked with a flag and the peer - * pointer is really a pointer back to the parent. - * This saves putting a parent back pointer in each and - * every named object! - */ - - while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) - { - Node = Node->Peer; - } - - - return (Node->Peer); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiNsGetNextValidObject - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Next valid object in the table. NULL if no more valid - * objects - * - * DESCRIPTION: Find the next valid object within a name table. - * Useful for implementing NULL-end-of-list loops. - * - ***************************************************************************/ - - -ACPI_NAMESPACE_NODE * -AcpiNsGetNextValidObject ( - ACPI_NAMESPACE_NODE *Node) -{ - - /* If we are at the end of this peer list, return NULL */ - - if (Node->Flags & ANOBJ_END_OF_PEER_LIST) - { - return NULL; - } - - /* Otherwise just return the next peer */ - - return (Node->Peer); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c deleted file mode 100644 index 2244489e08b36..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c +++ /dev/null @@ -1,384 +0,0 @@ -/****************************************************************************** - * - * Module Name: nswalk - Functions for walking the APCI namespace - * $Revision: 19 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __NSWALK_C__ - -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nswalk") - - -/**************************************************************************** - * - * 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 - * - * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if - * none is found. - * - * 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_NAMESPACE_NODE * -AcpiNsGetNextObject ( - OBJECT_TYPE_INTERNAL Type, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *NextNode = NULL; - - - if (!ChildNode) - { - - /* It's really the parent's _scope_ that we want */ - - if (ParentNode->Child) - { - NextNode = ParentNode->Child; - } - } - - else - { - /* Start search at the NEXT object */ - - NextNode = AcpiNsGetNextValidObject (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 object -- 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 object */ - - NextNode = AcpiNsGetNextValidObject (NextNode); - } - - - /* 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 - * UnlockBeforeCallback- Whether to unlock the NS before invoking - * the callback routine - * UserFunction - Called when an object of "Type" is found - * Context - Passed to user function - * - * 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 that matches - * the type parameter is found. If the user 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 User Function can be tailored - * to each task, whether it is a print function, a compare - * function, etc. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsWalkNamespace ( - OBJECT_TYPE_INTERNAL Type, - ACPI_HANDLE StartNode, - UINT32 MaxDepth, - BOOLEAN UnlockBeforeCallback, - WALK_CALLBACK UserFunction, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *ChildNode; - ACPI_NAMESPACE_NODE *ParentNode; - OBJECT_TYPE_INTERNAL ChildType; - UINT32 Level; - - - FUNCTION_TRACE ("NsWalkNamespace"); - - /* Special case for the namespace Root Node */ - - if (StartNode == ACPI_ROOT_OBJECT) - { - StartNode = AcpiGbl_RootNode; - } - - - /* Null child means "get first object" */ - - ParentNode = StartNode; - ChildNode = 0; - ChildType = ACPI_TYPE_ANY; - Level = 1; - - /* - * Traverse the tree of objects 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) - { - /* - * Get the next typed object in this scope. Null returned - * if not found - */ - - Status = AE_OK; - ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, - ParentNode, - ChildNode); - - if (ChildNode) - { - /* - * Found an object, Get the type if we are not - * searching for ANY - */ - - if (Type != ACPI_TYPE_ANY) - { - ChildType = ChildNode->Type; - } - - if (ChildType == Type) - { - /* - * Found a matching object, invoke the user - * callback function - */ - - if (UnlockBeforeCallback) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - } - - Status = UserFunction (ChildNode, Level, - Context, ReturnValue); - - if (UnlockBeforeCallback) - { - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - } - - 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); - break; - - default: - /* All others are valid exceptions */ - return_ACPI_STATUS (Status); - break; - } - } - - /* - * 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 ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) - { - if (AcpiNsGetNextObject (ACPI_TYPE_ANY, - ChildNode, 0)) - { - /* - * There is at least one child of this - * object, visit the object - */ - Level++; - ParentNode = ChildNode; - ChildNode = 0; - } - } - } - - else - { - /* - * No more children in this object (AcpiNsGetNextObject - * failed), go back upwards in the namespace tree to - * the object's parent. - */ - Level--; - ChildNode = ParentNode; - ParentNode = AcpiNsGetParentObject (ParentNode); - } - } - - /* Complete walk, not terminated by user function */ - return_ACPI_STATUS (AE_OK); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c deleted file mode 100644 index 257aafd182b8e..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c +++ /dev/null @@ -1,409 +0,0 @@ -/****************************************************************************** - * - * Module Name: nsxfname - Public interfaces to the ACPI subsystem - * ACPI Namespace oriented interfaces - * $Revision: 75 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __NSXFNAME_C__ - -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "amlcode.h" -#include "acparser.h" -#include "acdispat.h" -#include "acevents.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsxfname") - - -/**************************************************************************** - * - * 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 placed - * - * 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; - - - if (!RetHandle || !Pathname) - { - return (AE_BAD_PARAMETER); - } - - /* Convert a parent handle to a prefix node */ - - if (Parent) - { - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - PrefixNode = AcpiNsConvertHandleToEntry (Parent); - if (!PrefixNode) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - } - - /* Special case for root, since we can't search for it */ - - if (STRCMP (Pathname, NS_ROOT_PATH) == 0) - { - *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); - return (AE_OK); - } - - /* - * Find the Node and convert to a handle - */ - Status = AcpiNsGetNode (Pathname, PrefixNode, &Node); - - *RetHandle = NULL; - if (ACPI_SUCCESS (Status)) - { - *RetHandle = AcpiNsConvertEntryToHandle (Node); - } - - return (Status); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiGetPathname - * - * PARAMETERS: Handle - Handle to be converted to a pathname - * NameType - Full pathname or single segment - * RetPathPtr - 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 *RetPathPtr) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - - - /* Buffer pointer must be valid always */ - - if (!RetPathPtr || (NameType > ACPI_NAME_TYPE_MAX)) - { - return (AE_BAD_PARAMETER); - } - - /* Allow length to be zero and ignore the pointer */ - - if ((RetPathPtr->Length) && - (!RetPathPtr->Pointer)) - { - return (AE_BAD_PARAMETER); - } - - if (NameType == ACPI_FULL_PATHNAME) - { - /* Get the full pathname (From the namespace root) */ - - Status = AcpiNsHandleToPathname (Handle, &RetPathPtr->Length, - RetPathPtr->Pointer); - return (Status); - } - - /* - * Wants the single segment ACPI name. - * Validate handle and convert to an Node - */ - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - Node = AcpiNsConvertHandleToEntry (Handle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Check if name will fit in buffer */ - - if (RetPathPtr->Length < PATH_SEGMENT_LENGTH) - { - RetPathPtr->Length = PATH_SEGMENT_LENGTH; - Status = AE_BUFFER_OVERFLOW; - goto UnlockAndExit; - } - - /* Just copy the ACPI name from the Node and zero terminate it */ - - STRNCPY (RetPathPtr->Pointer, (NATIVE_CHAR *) &Node->Name, - ACPI_NAME_SIZE); - ((NATIVE_CHAR *) RetPathPtr->Pointer) [ACPI_NAME_SIZE] = 0; - Status = AE_OK; - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiGetObjectInfo - * - * PARAMETERS: Handle - Object Handle - * Info - 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.) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetObjectInfo ( - ACPI_HANDLE Handle, - ACPI_DEVICE_INFO *Info) -{ - DEVICE_ID Hid; - DEVICE_ID Uid; - ACPI_STATUS Status; - UINT32 DeviceStatus = 0; - ACPI_INTEGER Address = 0; - ACPI_NAMESPACE_NODE *Node; - - - /* Parameter validation */ - - if (!Handle || !Info) - { - return (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - Node = AcpiNsConvertHandleToEntry (Handle); - if (!Node) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - Info->Type = Node->Type; - Info->Name = Node->Name; - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - /* - * If not a device, we are all done. - */ - if (Info->Type != ACPI_TYPE_DEVICE) - { - return (AE_OK); - } - - - /* - * Get extra info for ACPI devices only. Run the - * _HID, _UID, _STA, and _ADR methods. Note: none - * of these methods are required, so they may or may - * not be present. The Info->Valid bits are used - * to indicate which methods ran successfully. - */ - - Info->Valid = 0; - - /* Execute the _HID method and save the result */ - - Status = AcpiCmExecute_HID (Node, &Hid); - if (ACPI_SUCCESS (Status)) - { - STRNCPY (Info->HardwareId, Hid.Buffer, sizeof(Info->HardwareId)); - - Info->Valid |= ACPI_VALID_HID; - } - - /* Execute the _UID method and save the result */ - - Status = AcpiCmExecute_UID (Node, &Uid); - if (ACPI_SUCCESS (Status)) - { - STRCPY (Info->UniqueId, Uid.Buffer); - - Info->Valid |= ACPI_VALID_UID; - } - - /* - * Execute the _STA method and save the result - * _STA is not always present - */ - - Status = AcpiCmExecute_STA (Node, &DeviceStatus); - if (ACPI_SUCCESS (Status)) - { - Info->CurrentStatus = DeviceStatus; - Info->Valid |= ACPI_VALID_STA; - } - - /* - * Execute the _ADR method and save result if successful - * _ADR is not always present - */ - - Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, - Node, &Address); - - if (ACPI_SUCCESS (Status)) - { - Info->Address = Address; - Info->Valid |= ACPI_VALID_ADR; - } - - return (AE_OK); -} - diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c deleted file mode 100644 index b90c31a5df071..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c +++ /dev/null @@ -1,852 +0,0 @@ -/******************************************************************************* - * - * Module Name: nsxfobj - Public interfaces to the ACPI subsystem - * ACPI Object oriented interfaces - * $Revision: 80 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __NSXFOBJ_C__ - -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acdispat.h" - - -#define _COMPONENT NAMESPACE - MODULE_NAME ("nsxfobj") - - -/******************************************************************************* - * - * FUNCTION: AcpiEvaluateObject - * - * PARAMETERS: Handle - Object handle (optional) - * *Pathname - Object pathname (optional) - * **Params - List of parameters to pass to - * method, terminated by NULL. - * Params itself may be NULL - * if no parameters are being - * passed. - * *ReturnObject - 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 *ParamObjects, - ACPI_BUFFER *ReturnBuffer) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **ParamPtr = NULL; - ACPI_OPERAND_OBJECT *ReturnObj = NULL; - ACPI_OPERAND_OBJECT *ObjectPtr = NULL; - UINT32 BufferSpaceNeeded; - UINT32 UserBufferLength; - UINT32 Count; - UINT32 i; - UINT32 ParamLength; - UINT32 ObjectLength; - - - FUNCTION_TRACE ("AcpiEvaluateObject"); - - - /* - * If there are parameters to be passed to the object - * (which must be a control method), the external objects - * must be converted to internal objects - */ - - if (ParamObjects && ParamObjects->Count) - { - /* - * Allocate a new parameter block for the internal objects - * Add 1 to count to allow for null terminated internal list - */ - - Count = ParamObjects->Count; - ParamLength = (Count + 1) * sizeof (void *); - ObjectLength = Count * sizeof (ACPI_OPERAND_OBJECT); - - ParamPtr = AcpiCmCallocate (ParamLength + /* Parameter List part */ - ObjectLength); /* Actual objects */ - if (!ParamPtr) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ObjectPtr = (ACPI_OPERAND_OBJECT *) ((UINT8 *) ParamPtr + - ParamLength); - - /* - * Init the param array of pointers and NULL terminate - * the list - */ - - for (i = 0; i < Count; i++) - { - ParamPtr[i] = &ObjectPtr[i]; - AcpiCmInitStaticObject (&ObjectPtr[i]); - } - ParamPtr[Count] = NULL; - - /* - * Convert each external object in the list to an - * internal object - */ - for (i = 0; i < Count; i++) - { - Status = AcpiCmCopyEobjectToIobject (&ParamObjects->Pointer[i], - ParamPtr[i]); - - if (ACPI_FAILURE (Status)) - { - AcpiCmDeleteInternalObjectList (ParamPtr); - return_ACPI_STATUS (Status); - } - } - } - - - /* - * Three major cases: - * 1) Fully qualified pathname - * 2) No handle, not fully qualified pathname (error) - * 3) Valid handle - */ - - if ((Pathname) && - (AcpiNsValidRootPrefix (Pathname[0]))) - { - /* - * The path is fully qualified, just evaluate by name - */ - Status = AcpiNsEvaluateByName (Pathname, ParamPtr, &ReturnObj); - } - - 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) - { - DEBUG_PRINT (ACPI_ERROR, - ("AcpiEvaluateObject: Both Handle and Pathname are NULL\n")); - } - - else - { - DEBUG_PRINT (ACPI_ERROR, - ("AcpiEvaluateObject: Handle is NULL and Pathname is relative\n")); - } - - Status = AE_BAD_PARAMETER; - } - - else - { - /* - * We get here if we have a handle -- and if we have a - * pathname it is relative. The handle will be validated - * in the lower procedures - */ - - if (!Pathname) - { - /* - * The null pathname case means the handle is for - * the actual object to be evaluated - */ - Status = AcpiNsEvaluateByHandle (Handle, ParamPtr, &ReturnObj); - } - - else - { - /* - * Both a Handle and a relative Pathname - */ - Status = AcpiNsEvaluateRelative (Handle, Pathname, ParamPtr, - &ReturnObj); - } - } - - - /* - * If we are expecting a return value, and all went well above, - * copy the return value to an external object. - */ - - if (ReturnBuffer) - { - UserBufferLength = ReturnBuffer->Length; - ReturnBuffer->Length = 0; - - if (ReturnObj) - { - if (VALID_DESCRIPTOR_TYPE (ReturnObj, ACPI_DESC_TYPE_NAMED)) - { - /* - * If we got an Node as a return object, - * this means 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; - ReturnObj = NULL; /* No need to delete an Node */ - } - - if (ACPI_SUCCESS (Status)) - { - /* - * Find out how large a buffer is needed - * to contain the returned object - */ - Status = AcpiCmGetObjectSize (ReturnObj, - &BufferSpaceNeeded); - if (ACPI_SUCCESS (Status)) - { - /* - * Check if there is enough room in the - * caller's buffer - */ - - if (UserBufferLength < BufferSpaceNeeded) - { - /* - * Caller's buffer is too small, can't - * give him partial results fail the call - * but return the buffer size needed - */ - - DEBUG_PRINT (ACPI_INFO, - ("AcpiEvaluateObject: Needed buffer size %X, received %X\n", - BufferSpaceNeeded, UserBufferLength)); - - ReturnBuffer->Length = BufferSpaceNeeded; - Status = AE_BUFFER_OVERFLOW; - } - - else - { - /* - * We have enough space for the object, build it - */ - Status = AcpiCmCopyIobjectToEobject (ReturnObj, - ReturnBuffer); - ReturnBuffer->Length = BufferSpaceNeeded; - } - } - } - } - } - - - /* Delete the return and parameter objects */ - - if (ReturnObj) - { - /* - * Delete the internal return object. (Or at least - * decrement the reference count by one) - */ - AcpiCmRemoveReference (ReturnObj); - } - - /* - * Free the input parameter list (if we created one), - */ - - if (ParamPtr) - { - /* Free the allocated parameter block */ - - AcpiCmDeleteInternalObjectList (ParamPtr); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * 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 = AE_OK; - ACPI_NAMESPACE_NODE *Node; - ACPI_NAMESPACE_NODE *ParentNode = NULL; - ACPI_NAMESPACE_NODE *ChildNode = NULL; - - - /* Parameter validation */ - - if (Type > ACPI_TYPE_MAX) - { - return (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* If null handle, use the parent */ - - if (!Child) - { - /* Start search at the beginning of the specified scope */ - - ParentNode = AcpiNsConvertHandleToEntry (Parent); - if (!ParentNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - - /* Non-null handle, ignore the parent */ - - else - { - /* Convert and validate the handle */ - - ChildNode = AcpiNsConvertHandleToEntry (Child); - if (!ChildNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - - - /* Internal function does the real work */ - - Node = AcpiNsGetNextObject ((OBJECT_TYPE_INTERNAL) Type, - ParentNode, ChildNode); - if (!Node) - { - Status = AE_NOT_FOUND; - goto UnlockAndExit; - } - - if (RetHandle) - { - *RetHandle = AcpiNsConvertEntryToHandle (Node); - } - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - - -/******************************************************************************* - * - * 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; - - - /* 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); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the handle */ - - Node = AcpiNsConvertHandleToEntry (Handle); - if (!Node) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); - } - - *RetType = Node->Type; - - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_OK); -} - - -/******************************************************************************* - * - * 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_STATUS Status = AE_OK; - - - /* No trace macro, too verbose */ - - - if (!RetHandle) - { - return (AE_BAD_PARAMETER); - } - - /* Special case for the predefined Root Node (no parent) */ - - if (Handle == ACPI_ROOT_OBJECT) - { - return (AE_NULL_ENTRY); - } - - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the handle */ - - Node = AcpiNsConvertHandleToEntry (Handle); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - - /* Get the parent entry */ - - *RetHandle = - AcpiNsConvertEntryToHandle (AcpiNsGetParentObject (Node)); - - /* Return exeption if parent is null */ - - if (!AcpiNsGetParentObject (Node)) - { - Status = AE_NULL_ENTRY; - } - - -UnlockAndExit: - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return (Status); -} - - -/******************************************************************************* - * - * 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 - * UserFunction - Called when an object of "Type" 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 that matches - * the type parameter is found. If the user 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 User Function 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, - WALK_CALLBACK UserFunction, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("AcpiWalkNamespace"); - - - /* Parameter validation */ - - if ((Type > ACPI_TYPE_MAX) || - (!MaxDepth) || - (!UserFunction)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * 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. - */ - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - Status = AcpiNsWalkNamespace ((OBJECT_TYPE_INTERNAL) Type, - StartObject, MaxDepth, - NS_WALK_UNLOCK, - UserFunction, Context, - ReturnValue); - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * 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_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - UINT32 Flags; - DEVICE_ID DeviceId; - ACPI_GET_DEVICES_INFO *Info; - - - Info = Context; - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - Node = AcpiNsConvertHandleToEntry (ObjHandle); - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - if (!Node) - { - return (AE_BAD_PARAMETER); - } - - /* - * Run _STA to determine if device is present - */ - - Status = AcpiCmExecute_STA (Node, &Flags); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (!(Flags & 0x01)) - { - /* don't return at the device or children of the device if not there */ - - return (AE_CTRL_DEPTH); - } - - /* - * Filter based on device HID - */ - if (Info->Hid != NULL) - { - Status = AcpiCmExecute_HID (Node, &DeviceId); - - if (Status == AE_NOT_FOUND) - { - return (AE_OK); - } - - else if (ACPI_FAILURE (Status)) - { - return (Status); - } - - if (STRNCMP (DeviceId.Buffer, Info->Hid, sizeof (DeviceId.Buffer)) != 0) - { - return (AE_OK); - } - } - - Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); - - return (AE_OK); -} - - -/******************************************************************************* - * - * 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 that matches - * the type parameter 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 AcpiGetDeviceCallback. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetDevices ( - NATIVE_CHAR *HID, - WALK_CALLBACK UserFunction, - void *Context, - void **ReturnValue) -{ - ACPI_STATUS Status; - ACPI_GET_DEVICES_INFO Info; - - - 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.Context = Context; - Info.UserFunction = UserFunction; - Info.Hid = HID; - - /* - * 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. - */ - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - NS_WALK_UNLOCK, - AcpiNsGetDeviceCallback, &Info, - ReturnValue); - - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - - return_ACPI_STATUS (Status); -} |