1 /*******************************************************************************
3 * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
4 * ACPI Object evaluation interfaces
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #define __NSXFEVAL_C__
121 #include "accommon.h"
122 #include "acnamesp.h"
123 #include "acinterp.h"
126 #define _COMPONENT ACPI_NAMESPACE
127 ACPI_MODULE_NAME ("nsxfeval")
129 /* Local prototypes */
132 AcpiNsResolveReferences (
133 ACPI_EVALUATE_INFO
*Info
);
136 /*******************************************************************************
138 * FUNCTION: AcpiEvaluateObjectTyped
140 * PARAMETERS: Handle - Object handle (optional)
141 * Pathname - Object pathname (optional)
142 * ExternalParams - List of parameters to pass to method,
143 * terminated by NULL. May be NULL
144 * if no parameters are being passed.
145 * ReturnBuffer - Where to put method's return value (if
146 * any). If NULL, no value is returned.
147 * ReturnType - Expected type of return object
151 * DESCRIPTION: Find and evaluate the given object, passing the given
152 * parameters if necessary. One of "Handle" or "Pathname" must
153 * be valid (non-null)
155 ******************************************************************************/
158 AcpiEvaluateObjectTyped (
160 ACPI_STRING Pathname
,
161 ACPI_OBJECT_LIST
*ExternalParams
,
162 ACPI_BUFFER
*ReturnBuffer
,
163 ACPI_OBJECT_TYPE ReturnType
)
166 BOOLEAN MustFree
= FALSE
;
169 ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped
);
172 /* Return buffer must be valid */
176 return_ACPI_STATUS (AE_BAD_PARAMETER
);
179 if (ReturnBuffer
->Length
== ACPI_ALLOCATE_BUFFER
)
184 /* Evaluate the object */
186 Status
= AcpiEvaluateObject (Handle
, Pathname
, ExternalParams
, ReturnBuffer
);
187 if (ACPI_FAILURE (Status
))
189 return_ACPI_STATUS (Status
);
192 /* Type ANY means "don't care" */
194 if (ReturnType
== ACPI_TYPE_ANY
)
196 return_ACPI_STATUS (AE_OK
);
199 if (ReturnBuffer
->Length
== 0)
201 /* Error because caller specifically asked for a return value */
203 ACPI_ERROR ((AE_INFO
, "No return value"));
204 return_ACPI_STATUS (AE_NULL_OBJECT
);
207 /* Examine the object type returned from EvaluateObject */
209 if (((ACPI_OBJECT
*) ReturnBuffer
->Pointer
)->Type
== ReturnType
)
211 return_ACPI_STATUS (AE_OK
);
214 /* Return object type does not match requested type */
216 ACPI_ERROR ((AE_INFO
,
217 "Incorrect return type [%s] requested [%s]",
218 AcpiUtGetTypeName (((ACPI_OBJECT
*) ReturnBuffer
->Pointer
)->Type
),
219 AcpiUtGetTypeName (ReturnType
)));
223 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
225 AcpiOsFree (ReturnBuffer
->Pointer
);
226 ReturnBuffer
->Pointer
= NULL
;
229 ReturnBuffer
->Length
= 0;
230 return_ACPI_STATUS (AE_TYPE
);
233 ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped
)
236 /*******************************************************************************
238 * FUNCTION: AcpiEvaluateObject
240 * PARAMETERS: Handle - Object handle (optional)
241 * Pathname - Object pathname (optional)
242 * ExternalParams - List of parameters to pass to method,
243 * terminated by NULL. May be NULL
244 * if no parameters are being passed.
245 * ReturnBuffer - Where to put method's return value (if
246 * any). If NULL, no value is returned.
250 * DESCRIPTION: Find and evaluate the given object, passing the given
251 * parameters if necessary. One of "Handle" or "Pathname" must
252 * be valid (non-null)
254 ******************************************************************************/
259 ACPI_STRING Pathname
,
260 ACPI_OBJECT_LIST
*ExternalParams
,
261 ACPI_BUFFER
*ReturnBuffer
)
264 ACPI_EVALUATE_INFO
*Info
;
265 ACPI_SIZE BufferSpaceNeeded
;
269 ACPI_FUNCTION_TRACE (AcpiEvaluateObject
);
272 /* Allocate and initialize the evaluation information block */
274 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
277 return_ACPI_STATUS (AE_NO_MEMORY
);
280 Info
->Pathname
= Pathname
;
282 /* Convert and validate the device handle */
284 Info
->PrefixNode
= AcpiNsValidateHandle (Handle
);
285 if (!Info
->PrefixNode
)
287 Status
= AE_BAD_PARAMETER
;
292 * If there are parameters to be passed to a control method, the external
293 * objects must all be converted to internal objects
295 if (ExternalParams
&& ExternalParams
->Count
)
298 * Allocate a new parameter block for the internal objects
299 * Add 1 to count to allow for null terminated internal list
301 Info
->Parameters
= ACPI_ALLOCATE_ZEROED (
302 ((ACPI_SIZE
) ExternalParams
->Count
+ 1) * sizeof (void *));
303 if (!Info
->Parameters
)
305 Status
= AE_NO_MEMORY
;
309 /* Convert each external object in the list to an internal object */
311 for (i
= 0; i
< ExternalParams
->Count
; i
++)
313 Status
= AcpiUtCopyEobjectToIobject (
314 &ExternalParams
->Pointer
[i
], &Info
->Parameters
[i
]);
315 if (ACPI_FAILURE (Status
))
320 Info
->Parameters
[ExternalParams
->Count
] = NULL
;
325 * 1) Fully qualified pathname
326 * 2) No handle, not fully qualified pathname (error)
330 (AcpiNsValidRootPrefix (Pathname
[0])))
332 /* The path is fully qualified, just evaluate by name */
334 Info
->PrefixNode
= NULL
;
335 Status
= AcpiNsEvaluate (Info
);
340 * A handle is optional iff a fully qualified pathname is specified.
341 * Since we've already handled fully qualified names above, this is
346 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
347 "Both Handle and Pathname are NULL"));
351 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
352 "Null Handle with relative pathname [%s]", Pathname
));
355 Status
= AE_BAD_PARAMETER
;
359 /* We have a namespace a node and a possible relative path */
361 Status
= AcpiNsEvaluate (Info
);
365 * If we are expecting a return value, and all went well above,
366 * copy the return value to an external object.
370 if (!Info
->ReturnObject
)
372 ReturnBuffer
->Length
= 0;
376 if (ACPI_GET_DESCRIPTOR_TYPE (Info
->ReturnObject
) ==
377 ACPI_DESC_TYPE_NAMED
)
380 * If we received a NS Node as a return object, this means that
381 * the object we are evaluating has nothing interesting to
382 * return (such as a mutex, etc.) We return an error because
383 * these types are essentially unsupported by this interface.
384 * We don't check up front because this makes it easier to add
385 * support for various types at a later date if necessary.
388 Info
->ReturnObject
= NULL
; /* No need to delete a NS Node */
389 ReturnBuffer
->Length
= 0;
392 if (ACPI_SUCCESS (Status
))
394 /* Dereference Index and RefOf references */
396 AcpiNsResolveReferences (Info
);
398 /* Get the size of the returned object */
400 Status
= AcpiUtGetObjectSize (Info
->ReturnObject
,
402 if (ACPI_SUCCESS (Status
))
404 /* Validate/Allocate/Clear caller buffer */
406 Status
= AcpiUtInitializeBuffer (ReturnBuffer
,
408 if (ACPI_FAILURE (Status
))
411 * Caller's buffer is too small or a new one can't
414 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
415 "Needed buffer size %X, %s\n",
416 (UINT32
) BufferSpaceNeeded
,
417 AcpiFormatException (Status
)));
421 /* We have enough space for the object, build it */
423 Status
= AcpiUtCopyIobjectToEobject (Info
->ReturnObject
,
431 if (Info
->ReturnObject
)
434 * Delete the internal return object. NOTE: Interpreter must be
435 * locked to avoid race condition.
437 AcpiExEnterInterpreter ();
439 /* Remove one reference on the return object (should delete it) */
441 AcpiUtRemoveReference (Info
->ReturnObject
);
442 AcpiExExitInterpreter ();
448 /* Free the input parameter list (if we created one) */
450 if (Info
->Parameters
)
452 /* Free the allocated parameter block */
454 AcpiUtDeleteInternalObjectList (Info
->Parameters
);
458 return_ACPI_STATUS (Status
);
461 ACPI_EXPORT_SYMBOL (AcpiEvaluateObject
)
464 /*******************************************************************************
466 * FUNCTION: AcpiNsResolveReferences
468 * PARAMETERS: Info - Evaluation info block
470 * RETURN: Info->ReturnObject is replaced with the dereferenced object
472 * DESCRIPTION: Dereference certain reference objects. Called before an
473 * internal return object is converted to an external ACPI_OBJECT.
475 * Performs an automatic dereference of Index and RefOf reference objects.
476 * These reference objects are not supported by the ACPI_OBJECT, so this is a
477 * last resort effort to return something useful. Also, provides compatibility
478 * with other ACPI implementations.
480 * NOTE: does not handle references within returned package objects or nested
481 * references, but this support could be added later if found to be necessary.
483 ******************************************************************************/
486 AcpiNsResolveReferences (
487 ACPI_EVALUATE_INFO
*Info
)
489 ACPI_OPERAND_OBJECT
*ObjDesc
= NULL
;
490 ACPI_NAMESPACE_NODE
*Node
;
493 /* We are interested in reference objects only */
495 if ((Info
->ReturnObject
)->Common
.Type
!= ACPI_TYPE_LOCAL_REFERENCE
)
501 * Two types of references are supported - those created by Index and
502 * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
503 * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
504 * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
507 switch (Info
->ReturnObject
->Reference
.Class
)
509 case ACPI_REFCLASS_INDEX
:
511 ObjDesc
= *(Info
->ReturnObject
->Reference
.Where
);
514 case ACPI_REFCLASS_REFOF
:
516 Node
= Info
->ReturnObject
->Reference
.Object
;
519 ObjDesc
= Node
->Object
;
527 /* Replace the existing reference object */
531 AcpiUtAddReference (ObjDesc
);
532 AcpiUtRemoveReference (Info
->ReturnObject
);
533 Info
->ReturnObject
= ObjDesc
;
540 /*******************************************************************************
542 * FUNCTION: AcpiWalkNamespace
544 * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
545 * StartObject - Handle in namespace where search begins
546 * MaxDepth - Depth to which search is to reach
547 * PreOrderVisit - Called during tree pre-order visit
548 * when an object of "Type" is found
549 * PostOrderVisit - Called during tree post-order visit
550 * when an object of "Type" is found
551 * Context - Passed to user function(s) above
552 * ReturnValue - Location where return value of
553 * UserFunction is put if terminated early
555 * RETURNS Return value from the UserFunction if terminated early.
556 * Otherwise, returns NULL.
558 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
559 * starting (and ending) at the object specified by StartHandle.
560 * The callback function is called whenever an object that matches
561 * the type parameter is found. If the callback function returns
562 * a non-zero value, the search is terminated immediately and this
563 * value is returned to the caller.
565 * The point of this procedure is to provide a generic namespace
566 * walk routine that can be called from multiple places to
567 * provide multiple services; the callback function(s) can be
568 * tailored to each task, whether it is a print function,
569 * a compare function, etc.
571 ******************************************************************************/
575 ACPI_OBJECT_TYPE Type
,
576 ACPI_HANDLE StartObject
,
578 ACPI_WALK_CALLBACK PreOrderVisit
,
579 ACPI_WALK_CALLBACK PostOrderVisit
,
586 ACPI_FUNCTION_TRACE (AcpiWalkNamespace
);
589 /* Parameter validation */
591 if ((Type
> ACPI_TYPE_LOCAL_MAX
) ||
593 (!PreOrderVisit
&& !PostOrderVisit
))
595 return_ACPI_STATUS (AE_BAD_PARAMETER
);
599 * Need to acquire the namespace reader lock to prevent interference
600 * with any concurrent table unloads (which causes the deletion of
601 * namespace objects). We cannot allow the deletion of a namespace node
602 * while the user function is using it. The exception to this are the
603 * nodes created and deleted during control method execution -- these
604 * nodes are marked as temporary nodes and are ignored by the namespace
605 * walk. Thus, control methods can be executed while holding the
606 * namespace deletion lock (and the user function can execute control
609 Status
= AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock
);
610 if (ACPI_FAILURE (Status
))
616 * Lock the namespace around the walk. The namespace will be
617 * unlocked/locked around each call to the user function - since the user
618 * function must be allowed to make ACPICA calls itself (for example, it
619 * will typically execute control methods during device enumeration.)
621 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
622 if (ACPI_FAILURE (Status
))
627 Status
= AcpiNsWalkNamespace (Type
, StartObject
, MaxDepth
,
628 ACPI_NS_WALK_UNLOCK
, PreOrderVisit
,
629 PostOrderVisit
, Context
, ReturnValue
);
631 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
634 (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock
);
635 return_ACPI_STATUS (Status
);
638 ACPI_EXPORT_SYMBOL (AcpiWalkNamespace
)
641 /*******************************************************************************
643 * FUNCTION: AcpiNsGetDeviceCallback
645 * PARAMETERS: Callback from AcpiGetDevice
649 * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
650 * present devices, or if they specified a HID, it filters based
653 ******************************************************************************/
656 AcpiNsGetDeviceCallback (
657 ACPI_HANDLE ObjHandle
,
662 ACPI_GET_DEVICES_INFO
*Info
= Context
;
664 ACPI_NAMESPACE_NODE
*Node
;
667 ACPI_DEVICE_ID_LIST
*Cid
;
673 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
674 if (ACPI_FAILURE (Status
))
679 Node
= AcpiNsValidateHandle (ObjHandle
);
680 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
681 if (ACPI_FAILURE (Status
))
688 return (AE_BAD_PARAMETER
);
691 /* Run _STA to determine if device is present */
693 Status
= AcpiUtExecute_STA (Node
, &Flags
);
694 if (ACPI_FAILURE (Status
))
696 return (AE_CTRL_DEPTH
);
699 if (!(Flags
& ACPI_STA_DEVICE_PRESENT
) &&
700 !(Flags
& ACPI_STA_DEVICE_FUNCTIONING
))
703 * Don't examine the children of the device only when the
704 * device is neither present nor functional. See ACPI spec,
705 * description of _STA for more information.
707 return (AE_CTRL_DEPTH
);
710 /* Filter based on device HID & CID */
712 if (Info
->Hid
!= NULL
)
714 Status
= AcpiUtExecute_HID (Node
, &Hid
);
715 if (Status
== AE_NOT_FOUND
)
719 else if (ACPI_FAILURE (Status
))
721 return (AE_CTRL_DEPTH
);
724 NoMatch
= ACPI_STRCMP (Hid
->String
, Info
->Hid
);
730 * HID does not match, attempt match within the
731 * list of Compatible IDs (CIDs)
733 Status
= AcpiUtExecute_CID (Node
, &Cid
);
734 if (Status
== AE_NOT_FOUND
)
738 else if (ACPI_FAILURE (Status
))
740 return (AE_CTRL_DEPTH
);
743 /* Walk the CID list */
746 for (i
= 0; i
< Cid
->Count
; i
++)
748 if (ACPI_STRCMP (Cid
->Ids
[i
].String
, Info
->Hid
) == 0)
750 /* Found a matching CID */
765 /* We have a valid device, invoke the user function */
767 Status
= Info
->UserFunction (ObjHandle
, NestingLevel
, Info
->Context
,
773 /*******************************************************************************
775 * FUNCTION: AcpiGetDevices
777 * PARAMETERS: HID - HID to search for. Can be NULL.
778 * UserFunction - Called when a matching object is found
779 * Context - Passed to user function
780 * ReturnValue - Location where return value of
781 * UserFunction is put if terminated early
783 * RETURNS Return value from the UserFunction if terminated early.
784 * Otherwise, returns NULL.
786 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
787 * starting (and ending) at the object specified by StartHandle.
788 * The UserFunction is called whenever an object of type
789 * Device is found. If the user function returns
790 * a non-zero value, the search is terminated immediately and this
791 * value is returned to the caller.
793 * This is a wrapper for WalkNamespace, but the callback performs
794 * additional filtering. Please see AcpiNsGetDeviceCallback.
796 ******************************************************************************/
801 ACPI_WALK_CALLBACK UserFunction
,
806 ACPI_GET_DEVICES_INFO Info
;
809 ACPI_FUNCTION_TRACE (AcpiGetDevices
);
812 /* Parameter validation */
816 return_ACPI_STATUS (AE_BAD_PARAMETER
);
820 * We're going to call their callback from OUR callback, so we need
821 * to know what it is, and their context parameter.
824 Info
.Context
= Context
;
825 Info
.UserFunction
= UserFunction
;
828 * Lock the namespace around the walk.
829 * The namespace will be unlocked/locked around each call
830 * to the user function - since this function
831 * must be allowed to make Acpi calls itself.
833 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
834 if (ACPI_FAILURE (Status
))
836 return_ACPI_STATUS (Status
);
839 Status
= AcpiNsWalkNamespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
,
840 ACPI_UINT32_MAX
, ACPI_NS_WALK_UNLOCK
,
841 AcpiNsGetDeviceCallback
, NULL
, &Info
, ReturnValue
);
843 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
844 return_ACPI_STATUS (Status
);
847 ACPI_EXPORT_SYMBOL (AcpiGetDevices
)
850 /*******************************************************************************
852 * FUNCTION: AcpiAttachData
854 * PARAMETERS: ObjHandle - Namespace node
855 * Handler - Handler for this attachment
856 * Data - Pointer to data to be attached
860 * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
862 ******************************************************************************/
866 ACPI_HANDLE ObjHandle
,
867 ACPI_OBJECT_HANDLER Handler
,
870 ACPI_NAMESPACE_NODE
*Node
;
874 /* Parameter validation */
880 return (AE_BAD_PARAMETER
);
883 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
884 if (ACPI_FAILURE (Status
))
889 /* Convert and validate the handle */
891 Node
= AcpiNsValidateHandle (ObjHandle
);
894 Status
= AE_BAD_PARAMETER
;
898 Status
= AcpiNsAttachData (Node
, Handler
, Data
);
901 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
905 ACPI_EXPORT_SYMBOL (AcpiAttachData
)
908 /*******************************************************************************
910 * FUNCTION: AcpiDetachData
912 * PARAMETERS: ObjHandle - Namespace node handle
913 * Handler - Handler used in call to AcpiAttachData
917 * DESCRIPTION: Remove data that was previously attached to a node.
919 ******************************************************************************/
923 ACPI_HANDLE ObjHandle
,
924 ACPI_OBJECT_HANDLER Handler
)
926 ACPI_NAMESPACE_NODE
*Node
;
930 /* Parameter validation */
935 return (AE_BAD_PARAMETER
);
938 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
939 if (ACPI_FAILURE (Status
))
944 /* Convert and validate the handle */
946 Node
= AcpiNsValidateHandle (ObjHandle
);
949 Status
= AE_BAD_PARAMETER
;
953 Status
= AcpiNsDetachData (Node
, Handler
);
956 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
960 ACPI_EXPORT_SYMBOL (AcpiDetachData
)
963 /*******************************************************************************
965 * FUNCTION: AcpiGetData
967 * PARAMETERS: ObjHandle - Namespace node
968 * Handler - Handler used in call to AttachData
969 * Data - Where the data is returned
973 * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
975 ******************************************************************************/
979 ACPI_HANDLE ObjHandle
,
980 ACPI_OBJECT_HANDLER Handler
,
983 ACPI_NAMESPACE_NODE
*Node
;
987 /* Parameter validation */
993 return (AE_BAD_PARAMETER
);
996 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
997 if (ACPI_FAILURE (Status
))
1002 /* Convert and validate the handle */
1004 Node
= AcpiNsValidateHandle (ObjHandle
);
1007 Status
= AE_BAD_PARAMETER
;
1011 Status
= AcpiNsGetAttachedData (Node
, Handler
, Data
);
1014 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
1018 ACPI_EXPORT_SYMBOL (AcpiGetData
)