xref: /onnv-gate/usr/src/uts/intel/io/acpica/namespace/nsobject.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: nsobject - Utilities for objects attached to namespace
43446Smrj  *                         table entries
53446Smrj  *
63446Smrj  ******************************************************************************/
73446Smrj 
83446Smrj /******************************************************************************
93446Smrj  *
103446Smrj  * 1. Copyright Notice
113446Smrj  *
12*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
133446Smrj  * All rights reserved.
143446Smrj  *
153446Smrj  * 2. License
163446Smrj  *
173446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj  * rights.  You may have additional license terms from the party that provided
193446Smrj  * you this software, covering your right to use that party's intellectual
203446Smrj  * property rights.
213446Smrj  *
223446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj  * copy of the source code appearing in this file ("Covered Code") an
243446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj  * make derivatives, distribute, use and display any portion of the Covered
273446Smrj  * Code in any form, with the right to sublicense such rights; and
283446Smrj  *
293446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj  * license (with the right to sublicense), under only those claims of Intel
313446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj  * solely to the minimum extent necessary to exercise the above copyright
343446Smrj  * license, and in no event shall the patent license extend to any additions
353446Smrj  * to or modifications of the Original Intel Code.  No other license or right
363446Smrj  * is granted directly or by implication, estoppel or otherwise;
373446Smrj  *
383446Smrj  * The above copyright and patent license is granted only if the following
393446Smrj  * conditions are met:
403446Smrj  *
413446Smrj  * 3. Conditions
423446Smrj  *
433446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj  * Redistribution of source code of any substantial portion of the Covered
453446Smrj  * Code or modification with rights to further distribute source must include
463446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
483446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj  * contain a file documenting the changes Licensee made to create that Covered
503446Smrj  * Code and the date of any change.  Licensee must include in that file the
513446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
523446Smrj  * must include a prominent statement that the modification is derived,
533446Smrj  * directly or indirectly, from Original Intel Code.
543446Smrj  *
553446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj  * Redistribution of source code of any substantial portion of the Covered
573446Smrj  * Code or modification without rights to further distribute source must
583446Smrj  * include the following Disclaimer and Export Compliance provision in the
593446Smrj  * documentation and/or other materials provided with distribution.  In
603446Smrj  * addition, Licensee may not authorize further sublicense of source of any
613446Smrj  * portion of the Covered Code, and must include terms to the effect that the
623446Smrj  * license from Licensee to its licensee is limited to the intellectual
633446Smrj  * property embodied in the software Licensee provides to its licensee, and
643446Smrj  * not to intellectual property embodied in modifications its licensee may
653446Smrj  * make.
663446Smrj  *
673446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
683446Smrj  * substantial portion of the Covered Code or modification must reproduce the
693446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
703446Smrj  * provision in the documentation and/or other materials provided with the
713446Smrj  * distribution.
723446Smrj  *
733446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
743446Smrj  * Intel Code.
753446Smrj  *
763446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
773446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
783446Smrj  * other dealings in products derived from or relating to the Covered Code
793446Smrj  * without prior written authorization from Intel.
803446Smrj  *
813446Smrj  * 4. Disclaimer and Export Compliance
823446Smrj  *
833446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
843446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
853446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
863446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
873446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
883446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
893446Smrj  * PARTICULAR PURPOSE.
903446Smrj  *
913446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
923446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
933446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
943446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
953446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
963446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
973446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
983446Smrj  * LIMITED REMEDY.
993446Smrj  *
1003446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1013446Smrj  * software or system incorporating such software without first obtaining any
1023446Smrj  * required license or other approval from the U. S. Department of Commerce or
1033446Smrj  * any other agency or department of the United States Government.  In the
1043446Smrj  * event Licensee exports any such software from the United States or
1053446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1063446Smrj  * ensure that the distribution and export/re-export of the software is in
1073446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1083446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1093446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1103446Smrj  * software, or service, directly or indirectly, to any country for which the
1113446Smrj  * United States government or any agency thereof requires an export license,
1123446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1133446Smrj  * such license, approval or letter.
1143446Smrj  *
1153446Smrj  *****************************************************************************/
1163446Smrj 
1173446Smrj 
1183446Smrj #define __NSOBJECT_C__
1193446Smrj 
1203446Smrj #include "acpi.h"
121*9980SDana.Myers@Sun.COM #include "accommon.h"
1223446Smrj #include "acnamesp.h"
1233446Smrj 
1243446Smrj 
1253446Smrj #define _COMPONENT          ACPI_NAMESPACE
1263446Smrj         ACPI_MODULE_NAME    ("nsobject")
1273446Smrj 
1283446Smrj 
1293446Smrj /*******************************************************************************
1303446Smrj  *
1313446Smrj  * FUNCTION:    AcpiNsAttachObject
1323446Smrj  *
1333446Smrj  * PARAMETERS:  Node                - Parent Node
1343446Smrj  *              Object              - Object to be attached
1353446Smrj  *              Type                - Type of object, or ACPI_TYPE_ANY if not
1363446Smrj  *                                    known
1373446Smrj  *
1383446Smrj  * RETURN:      Status
1393446Smrj  *
1403446Smrj  * DESCRIPTION: Record the given object as the value associated with the
1413446Smrj  *              name whose ACPI_HANDLE is passed.  If Object is NULL
1423446Smrj  *              and Type is ACPI_TYPE_ANY, set the name as having no value.
1433446Smrj  *              Note: Future may require that the Node->Flags field be passed
1443446Smrj  *              as a parameter.
1453446Smrj  *
1463446Smrj  * MUTEX:       Assumes namespace is locked
1473446Smrj  *
1483446Smrj  ******************************************************************************/
1493446Smrj 
1503446Smrj ACPI_STATUS
AcpiNsAttachObject(ACPI_NAMESPACE_NODE * Node,ACPI_OPERAND_OBJECT * Object,ACPI_OBJECT_TYPE Type)1513446Smrj AcpiNsAttachObject (
1523446Smrj     ACPI_NAMESPACE_NODE     *Node,
1533446Smrj     ACPI_OPERAND_OBJECT     *Object,
1543446Smrj     ACPI_OBJECT_TYPE        Type)
1553446Smrj {
1563446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
1573446Smrj     ACPI_OPERAND_OBJECT     *LastObjDesc;
1583446Smrj     ACPI_OBJECT_TYPE        ObjectType = ACPI_TYPE_ANY;
1593446Smrj 
1603446Smrj 
1613446Smrj     ACPI_FUNCTION_TRACE (NsAttachObject);
1623446Smrj 
1633446Smrj 
1643446Smrj     /*
1653446Smrj      * Parameter validation
1663446Smrj      */
1673446Smrj     if (!Node)
1683446Smrj     {
1693446Smrj         /* Invalid handle */
1703446Smrj 
1713446Smrj         ACPI_ERROR ((AE_INFO, "Null NamedObj handle"));
1723446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
1733446Smrj     }
1743446Smrj 
1753446Smrj     if (!Object && (ACPI_TYPE_ANY != Type))
1763446Smrj     {
1773446Smrj         /* Null object */
1783446Smrj 
1793446Smrj         ACPI_ERROR ((AE_INFO,
1803446Smrj             "Null object, but type not ACPI_TYPE_ANY"));
1813446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
1823446Smrj     }
1833446Smrj 
1843446Smrj     if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1853446Smrj     {
1863446Smrj         /* Not a name handle */
1873446Smrj 
1883446Smrj         ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]",
1893446Smrj             Node, AcpiUtGetDescriptorName (Node)));
1903446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
1913446Smrj     }
1923446Smrj 
1933446Smrj     /* Check if this object is already attached */
1943446Smrj 
1953446Smrj     if (Node->Object == Object)
1963446Smrj     {
1973446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1983446Smrj             "Obj %p already installed in NameObj %p\n",
1993446Smrj             Object, Node));
2003446Smrj 
2013446Smrj         return_ACPI_STATUS (AE_OK);
2023446Smrj     }
2033446Smrj 
2043446Smrj     /* If null object, we will just install it */
2053446Smrj 
2063446Smrj     if (!Object)
2073446Smrj     {
2083446Smrj         ObjDesc    = NULL;
2093446Smrj         ObjectType = ACPI_TYPE_ANY;
2103446Smrj     }
2113446Smrj 
2123446Smrj     /*
2133446Smrj      * If the source object is a namespace Node with an attached object,
2143446Smrj      * we will use that (attached) object
2153446Smrj      */
2163446Smrj     else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) &&
2173446Smrj             ((ACPI_NAMESPACE_NODE *) Object)->Object)
2183446Smrj     {
2193446Smrj         /*
2203446Smrj          * Value passed is a name handle and that name has a
2213446Smrj          * non-null value.  Use that name's value and type.
2223446Smrj          */
2233446Smrj         ObjDesc    = ((ACPI_NAMESPACE_NODE *) Object)->Object;
2243446Smrj         ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type;
2253446Smrj     }
2263446Smrj 
2273446Smrj     /*
2283446Smrj      * Otherwise, we will use the parameter object, but we must type
2293446Smrj      * it first
2303446Smrj      */
2313446Smrj     else
2323446Smrj     {
2333446Smrj         ObjDesc = (ACPI_OPERAND_OBJECT  *) Object;
2343446Smrj 
2353446Smrj         /* Use the given type */
2363446Smrj 
2373446Smrj         ObjectType = Type;
2383446Smrj     }
2393446Smrj 
2403446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
2413446Smrj         ObjDesc, Node, AcpiUtGetNodeName (Node)));
2423446Smrj 
2433446Smrj     /* Detach an existing attached object if present */
2443446Smrj 
2453446Smrj     if (Node->Object)
2463446Smrj     {
2473446Smrj         AcpiNsDetachObject (Node);
2483446Smrj     }
2493446Smrj 
2503446Smrj     if (ObjDesc)
2513446Smrj     {
2523446Smrj         /*
2533446Smrj          * Must increment the new value's reference count
2543446Smrj          * (if it is an internal object)
2553446Smrj          */
2563446Smrj         AcpiUtAddReference (ObjDesc);
2573446Smrj 
2583446Smrj         /*
2593446Smrj          * Handle objects with multiple descriptors - walk
2603446Smrj          * to the end of the descriptor list
2613446Smrj          */
2623446Smrj         LastObjDesc = ObjDesc;
2633446Smrj         while (LastObjDesc->Common.NextObject)
2643446Smrj         {
2653446Smrj             LastObjDesc = LastObjDesc->Common.NextObject;
2663446Smrj         }
2673446Smrj 
2683446Smrj         /* Install the object at the front of the object list */
2693446Smrj 
2703446Smrj         LastObjDesc->Common.NextObject = Node->Object;
2713446Smrj     }
2723446Smrj 
2733446Smrj     Node->Type     = (UINT8) ObjectType;
2743446Smrj     Node->Object   = ObjDesc;
2753446Smrj 
2763446Smrj     return_ACPI_STATUS (AE_OK);
2773446Smrj }
2783446Smrj 
2793446Smrj 
2803446Smrj /*******************************************************************************
2813446Smrj  *
2823446Smrj  * FUNCTION:    AcpiNsDetachObject
2833446Smrj  *
2843446Smrj  * PARAMETERS:  Node           - A Namespace node whose object will be detached
2853446Smrj  *
2863446Smrj  * RETURN:      None.
2873446Smrj  *
2883446Smrj  * DESCRIPTION: Detach/delete an object associated with a namespace node.
2893446Smrj  *              if the object is an allocated object, it is freed.
2903446Smrj  *              Otherwise, the field is simply cleared.
2913446Smrj  *
2923446Smrj  ******************************************************************************/
2933446Smrj 
2943446Smrj void
AcpiNsDetachObject(ACPI_NAMESPACE_NODE * Node)2953446Smrj AcpiNsDetachObject (
2963446Smrj     ACPI_NAMESPACE_NODE     *Node)
2973446Smrj {
2983446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
2993446Smrj 
3003446Smrj 
3013446Smrj     ACPI_FUNCTION_TRACE (NsDetachObject);
3023446Smrj 
3033446Smrj 
3043446Smrj     ObjDesc = Node->Object;
3053446Smrj 
3063446Smrj     if (!ObjDesc ||
307*9980SDana.Myers@Sun.COM         (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
3083446Smrj     {
3093446Smrj         return_VOID;
3103446Smrj     }
3113446Smrj 
312*9980SDana.Myers@Sun.COM     if (Node->Flags & ANOBJ_ALLOCATED_BUFFER)
313*9980SDana.Myers@Sun.COM     {
314*9980SDana.Myers@Sun.COM         /* Free the dynamic aml buffer */
315*9980SDana.Myers@Sun.COM 
316*9980SDana.Myers@Sun.COM         if (ObjDesc->Common.Type == ACPI_TYPE_METHOD)
317*9980SDana.Myers@Sun.COM         {
318*9980SDana.Myers@Sun.COM             ACPI_FREE (ObjDesc->Method.AmlStart);
319*9980SDana.Myers@Sun.COM         }
320*9980SDana.Myers@Sun.COM     }
321*9980SDana.Myers@Sun.COM 
3223446Smrj     /* Clear the entry in all cases */
3233446Smrj 
3243446Smrj     Node->Object = NULL;
3253446Smrj     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
3263446Smrj     {
3273446Smrj         Node->Object = ObjDesc->Common.NextObject;
3283446Smrj         if (Node->Object &&
329*9980SDana.Myers@Sun.COM            ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA))
3303446Smrj         {
3313446Smrj             Node->Object = Node->Object->Common.NextObject;
3323446Smrj         }
3333446Smrj     }
3343446Smrj 
3353446Smrj     /* Reset the node type to untyped */
3363446Smrj 
3373446Smrj     Node->Type = ACPI_TYPE_ANY;
3383446Smrj 
3393446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
3403446Smrj         Node, AcpiUtGetNodeName (Node), ObjDesc));
3413446Smrj 
3423446Smrj     /* Remove one reference on the object (and all subobjects) */
3433446Smrj 
3443446Smrj     AcpiUtRemoveReference (ObjDesc);
3453446Smrj     return_VOID;
3463446Smrj }
3473446Smrj 
3483446Smrj 
3493446Smrj /*******************************************************************************
3503446Smrj  *
3513446Smrj  * FUNCTION:    AcpiNsGetAttachedObject
3523446Smrj  *
3533446Smrj  * PARAMETERS:  Node             - Namespace node
3543446Smrj  *
3553446Smrj  * RETURN:      Current value of the object field from the Node whose
3563446Smrj  *              handle is passed
3573446Smrj  *
3583446Smrj  * DESCRIPTION: Obtain the object attached to a namespace node.
3593446Smrj  *
3603446Smrj  ******************************************************************************/
3613446Smrj 
3623446Smrj ACPI_OPERAND_OBJECT *
AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE * Node)3633446Smrj AcpiNsGetAttachedObject (
3643446Smrj     ACPI_NAMESPACE_NODE     *Node)
3653446Smrj {
3663446Smrj     ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node);
3673446Smrj 
3683446Smrj 
3693446Smrj     if (!Node)
3703446Smrj     {
3713446Smrj         ACPI_WARNING ((AE_INFO, "Null Node ptr"));
3723446Smrj         return_PTR (NULL);
3733446Smrj     }
3743446Smrj 
3753446Smrj     if (!Node->Object ||
3763446Smrj             ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) &&
3773446Smrj              (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED))  ||
378*9980SDana.Myers@Sun.COM         ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA))
3793446Smrj     {
3803446Smrj         return_PTR (NULL);
3813446Smrj     }
3823446Smrj 
3833446Smrj     return_PTR (Node->Object);
3843446Smrj }
3853446Smrj 
3863446Smrj 
3873446Smrj /*******************************************************************************
3883446Smrj  *
3893446Smrj  * FUNCTION:    AcpiNsGetSecondaryObject
3903446Smrj  *
3913446Smrj  * PARAMETERS:  Node             - Namespace node
3923446Smrj  *
3933446Smrj  * RETURN:      Current value of the object field from the Node whose
3943446Smrj  *              handle is passed.
3953446Smrj  *
3963446Smrj  * DESCRIPTION: Obtain a secondary object associated with a namespace node.
3973446Smrj  *
3983446Smrj  ******************************************************************************/
3993446Smrj 
4003446Smrj ACPI_OPERAND_OBJECT *
AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT * ObjDesc)4013446Smrj AcpiNsGetSecondaryObject (
4023446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc)
4033446Smrj {
4043446Smrj     ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);
4053446Smrj 
4063446Smrj 
407*9980SDana.Myers@Sun.COM     if ((!ObjDesc)                                     ||
408*9980SDana.Myers@Sun.COM         (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA)  ||
409*9980SDana.Myers@Sun.COM         (!ObjDesc->Common.NextObject)                  ||
410*9980SDana.Myers@Sun.COM         ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
4113446Smrj     {
4123446Smrj         return_PTR (NULL);
4133446Smrj     }
4143446Smrj 
4153446Smrj     return_PTR (ObjDesc->Common.NextObject);
4163446Smrj }
4173446Smrj 
4183446Smrj 
4193446Smrj /*******************************************************************************
4203446Smrj  *
4213446Smrj  * FUNCTION:    AcpiNsAttachData
4223446Smrj  *
4233446Smrj  * PARAMETERS:  Node            - Namespace node
4243446Smrj  *              Handler         - Handler to be associated with the data
4253446Smrj  *              Data            - Data to be attached
4263446Smrj  *
4273446Smrj  * RETURN:      Status
4283446Smrj  *
4293446Smrj  * DESCRIPTION: Low-level attach data.  Create and attach a Data object.
4303446Smrj  *
4313446Smrj  ******************************************************************************/
4323446Smrj 
4333446Smrj ACPI_STATUS
AcpiNsAttachData(ACPI_NAMESPACE_NODE * Node,ACPI_OBJECT_HANDLER Handler,void * Data)4343446Smrj AcpiNsAttachData (
4353446Smrj     ACPI_NAMESPACE_NODE     *Node,
4363446Smrj     ACPI_OBJECT_HANDLER     Handler,
4373446Smrj     void                    *Data)
4383446Smrj {
4393446Smrj     ACPI_OPERAND_OBJECT     *PrevObjDesc;
4403446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
4413446Smrj     ACPI_OPERAND_OBJECT     *DataDesc;
4423446Smrj 
4433446Smrj 
4443446Smrj     /* We only allow one attachment per handler */
4453446Smrj 
4463446Smrj     PrevObjDesc = NULL;
4473446Smrj     ObjDesc = Node->Object;
4483446Smrj     while (ObjDesc)
4493446Smrj     {
450*9980SDana.Myers@Sun.COM         if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
4513446Smrj             (ObjDesc->Data.Handler == Handler))
4523446Smrj         {
4533446Smrj             return (AE_ALREADY_EXISTS);
4543446Smrj         }
4553446Smrj 
4563446Smrj         PrevObjDesc = ObjDesc;
4573446Smrj         ObjDesc = ObjDesc->Common.NextObject;
4583446Smrj     }
4593446Smrj 
4603446Smrj     /* Create an internal object for the data */
4613446Smrj 
4623446Smrj     DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA);
4633446Smrj     if (!DataDesc)
4643446Smrj     {
4653446Smrj         return (AE_NO_MEMORY);
4663446Smrj     }
4673446Smrj 
4683446Smrj     DataDesc->Data.Handler = Handler;
4693446Smrj     DataDesc->Data.Pointer = Data;
4703446Smrj 
4713446Smrj     /* Install the data object */
4723446Smrj 
4733446Smrj     if (PrevObjDesc)
4743446Smrj     {
4753446Smrj         PrevObjDesc->Common.NextObject = DataDesc;
4763446Smrj     }
4773446Smrj     else
4783446Smrj     {
4793446Smrj         Node->Object = DataDesc;
4803446Smrj     }
4813446Smrj 
4823446Smrj     return (AE_OK);
4833446Smrj }
4843446Smrj 
4853446Smrj 
4863446Smrj /*******************************************************************************
4873446Smrj  *
4883446Smrj  * FUNCTION:    AcpiNsDetachData
4893446Smrj  *
4903446Smrj  * PARAMETERS:  Node            - Namespace node
4913446Smrj  *              Handler         - Handler associated with the data
4923446Smrj  *
4933446Smrj  * RETURN:      Status
4943446Smrj  *
4953446Smrj  * DESCRIPTION: Low-level detach data.  Delete the data node, but the caller
4963446Smrj  *              is responsible for the actual data.
4973446Smrj  *
4983446Smrj  ******************************************************************************/
4993446Smrj 
5003446Smrj ACPI_STATUS
AcpiNsDetachData(ACPI_NAMESPACE_NODE * Node,ACPI_OBJECT_HANDLER Handler)5013446Smrj AcpiNsDetachData (
5023446Smrj     ACPI_NAMESPACE_NODE     *Node,
5033446Smrj     ACPI_OBJECT_HANDLER     Handler)
5043446Smrj {
5053446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
5063446Smrj     ACPI_OPERAND_OBJECT     *PrevObjDesc;
5073446Smrj 
5083446Smrj 
5093446Smrj     PrevObjDesc = NULL;
5103446Smrj     ObjDesc = Node->Object;
5113446Smrj     while (ObjDesc)
5123446Smrj     {
513*9980SDana.Myers@Sun.COM         if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
5143446Smrj             (ObjDesc->Data.Handler == Handler))
5153446Smrj         {
5163446Smrj             if (PrevObjDesc)
5173446Smrj             {
5183446Smrj                 PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
5193446Smrj             }
5203446Smrj             else
5213446Smrj             {
5223446Smrj                 Node->Object = ObjDesc->Common.NextObject;
5233446Smrj             }
5243446Smrj 
5253446Smrj             AcpiUtRemoveReference (ObjDesc);
5263446Smrj             return (AE_OK);
5273446Smrj         }
5283446Smrj 
5293446Smrj         PrevObjDesc = ObjDesc;
5303446Smrj         ObjDesc = ObjDesc->Common.NextObject;
5313446Smrj     }
5323446Smrj 
5333446Smrj     return (AE_NOT_FOUND);
5343446Smrj }
5353446Smrj 
5363446Smrj 
5373446Smrj /*******************************************************************************
5383446Smrj  *
5393446Smrj  * FUNCTION:    AcpiNsGetAttachedData
5403446Smrj  *
5413446Smrj  * PARAMETERS:  Node            - Namespace node
5423446Smrj  *              Handler         - Handler associated with the data
5433446Smrj  *              Data            - Where the data is returned
5443446Smrj  *
5453446Smrj  * RETURN:      Status
5463446Smrj  *
5473446Smrj  * DESCRIPTION: Low level interface to obtain data previously associated with
5483446Smrj  *              a namespace node.
5493446Smrj  *
5503446Smrj  ******************************************************************************/
5513446Smrj 
5523446Smrj ACPI_STATUS
AcpiNsGetAttachedData(ACPI_NAMESPACE_NODE * Node,ACPI_OBJECT_HANDLER Handler,void ** Data)5533446Smrj AcpiNsGetAttachedData (
5543446Smrj     ACPI_NAMESPACE_NODE     *Node,
5553446Smrj     ACPI_OBJECT_HANDLER     Handler,
5563446Smrj     void                    **Data)
5573446Smrj {
5583446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
5593446Smrj 
5603446Smrj 
5613446Smrj     ObjDesc = Node->Object;
5623446Smrj     while (ObjDesc)
5633446Smrj     {
564*9980SDana.Myers@Sun.COM         if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
5653446Smrj             (ObjDesc->Data.Handler == Handler))
5663446Smrj         {
5673446Smrj             *Data = ObjDesc->Data.Pointer;
5683446Smrj             return (AE_OK);
5693446Smrj         }
5703446Smrj 
5713446Smrj         ObjDesc = ObjDesc->Common.NextObject;
5723446Smrj     }
5733446Smrj 
5743446Smrj     return (AE_NOT_FOUND);
5753446Smrj }
5763446Smrj 
5773446Smrj 
578