1 /*******************************************************************************
3 * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
4 * ACPI Object evaluation interfaces
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
46 #define __NSXFEVAL_C__
47 #define EXPORT_ACPI_INTERFACES
55 #define _COMPONENT ACPI_NAMESPACE
56 ACPI_MODULE_NAME ("nsxfeval")
58 /* Local prototypes */
61 AcpiNsResolveReferences (
62 ACPI_EVALUATE_INFO
*Info
);
65 /*******************************************************************************
67 * FUNCTION: AcpiEvaluateObjectTyped
69 * PARAMETERS: Handle - Object handle (optional)
70 * Pathname - Object pathname (optional)
71 * ExternalParams - List of parameters to pass to method,
72 * terminated by NULL. May be NULL
73 * if no parameters are being passed.
74 * ReturnBuffer - Where to put method's return value (if
75 * any). If NULL, no value is returned.
76 * ReturnType - Expected type of return object
80 * DESCRIPTION: Find and evaluate the given object, passing the given
81 * parameters if necessary. One of "Handle" or "Pathname" must
84 ******************************************************************************/
87 AcpiEvaluateObjectTyped (
90 ACPI_OBJECT_LIST
*ExternalParams
,
91 ACPI_BUFFER
*ReturnBuffer
,
92 ACPI_OBJECT_TYPE ReturnType
)
95 BOOLEAN MustFree
= FALSE
;
98 ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped
);
101 /* Return buffer must be valid */
105 return_ACPI_STATUS (AE_BAD_PARAMETER
);
108 if (ReturnBuffer
->Length
== ACPI_ALLOCATE_BUFFER
)
113 /* Evaluate the object */
115 Status
= AcpiEvaluateObject (Handle
, Pathname
, ExternalParams
, ReturnBuffer
);
116 if (ACPI_FAILURE (Status
))
118 return_ACPI_STATUS (Status
);
121 /* Type ANY means "don't care" */
123 if (ReturnType
== ACPI_TYPE_ANY
)
125 return_ACPI_STATUS (AE_OK
);
128 if (ReturnBuffer
->Length
== 0)
130 /* Error because caller specifically asked for a return value */
132 ACPI_ERROR ((AE_INFO
, "No return value"));
133 return_ACPI_STATUS (AE_NULL_OBJECT
);
136 /* Examine the object type returned from EvaluateObject */
138 if (((ACPI_OBJECT
*) ReturnBuffer
->Pointer
)->Type
== ReturnType
)
140 return_ACPI_STATUS (AE_OK
);
143 /* Return object type does not match requested type */
145 ACPI_ERROR ((AE_INFO
,
146 "Incorrect return type [%s] requested [%s]",
147 AcpiUtGetTypeName (((ACPI_OBJECT
*) ReturnBuffer
->Pointer
)->Type
),
148 AcpiUtGetTypeName (ReturnType
)));
153 * Caller used ACPI_ALLOCATE_BUFFER, free the return buffer.
154 * Note: We use AcpiOsFree here because AcpiOsAllocate was used
155 * to allocate the buffer. This purposefully bypasses the internal
156 * allocation tracking mechanism (if it is enabled).
158 AcpiOsFree (ReturnBuffer
->Pointer
);
159 ReturnBuffer
->Pointer
= NULL
;
162 ReturnBuffer
->Length
= 0;
163 return_ACPI_STATUS (AE_TYPE
);
166 ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped
)
169 /*******************************************************************************
171 * FUNCTION: AcpiEvaluateObject
173 * PARAMETERS: Handle - Object handle (optional)
174 * Pathname - Object pathname (optional)
175 * ExternalParams - List of parameters to pass to method,
176 * terminated by NULL. May be NULL
177 * if no parameters are being passed.
178 * ReturnBuffer - Where to put method's return value (if
179 * any). If NULL, no value is returned.
183 * DESCRIPTION: Find and evaluate the given object, passing the given
184 * parameters if necessary. One of "Handle" or "Pathname" must
185 * be valid (non-null)
187 ******************************************************************************/
192 ACPI_STRING Pathname
,
193 ACPI_OBJECT_LIST
*ExternalParams
,
194 ACPI_BUFFER
*ReturnBuffer
)
197 ACPI_EVALUATE_INFO
*Info
;
198 ACPI_SIZE BufferSpaceNeeded
;
202 ACPI_FUNCTION_TRACE (AcpiEvaluateObject
);
205 /* Allocate and initialize the evaluation information block */
207 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
210 return_ACPI_STATUS (AE_NO_MEMORY
);
213 /* Convert and validate the device handle */
215 Info
->PrefixNode
= AcpiNsValidateHandle (Handle
);
216 if (!Info
->PrefixNode
)
218 Status
= AE_BAD_PARAMETER
;
223 * Get the actual namespace node for the target object.
224 * Handles these cases:
226 * 1) Null node, valid pathname from root (absolute path)
227 * 2) Node and valid pathname (path relative to Node)
228 * 3) Node, Null pathname
231 (ACPI_IS_ROOT_PREFIX (Pathname
[0])))
233 /* The path is fully qualified, just evaluate by name */
235 Info
->PrefixNode
= NULL
;
240 * A handle is optional iff a fully qualified pathname is specified.
241 * Since we've already handled fully qualified names above, this is
246 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
247 "Both Handle and Pathname are NULL"));
251 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
252 "Null Handle with relative pathname [%s]", Pathname
));
255 Status
= AE_BAD_PARAMETER
;
259 Info
->RelativePathname
= Pathname
;
262 * Convert all external objects passed as arguments to the
263 * internal version(s).
265 if (ExternalParams
&& ExternalParams
->Count
)
267 Info
->ParamCount
= (UINT16
) ExternalParams
->Count
;
269 /* Warn on impossible argument count */
271 if (Info
->ParamCount
> ACPI_METHOD_NUM_ARGS
)
273 ACPI_WARN_PREDEFINED ((AE_INFO
, Pathname
, ACPI_WARN_ALWAYS
,
274 "Excess arguments (%u) - using only %u",
275 Info
->ParamCount
, ACPI_METHOD_NUM_ARGS
));
277 Info
->ParamCount
= ACPI_METHOD_NUM_ARGS
;
281 * Allocate a new parameter block for the internal objects
282 * Add 1 to count to allow for null terminated internal list
284 Info
->Parameters
= ACPI_ALLOCATE_ZEROED (
285 ((ACPI_SIZE
) Info
->ParamCount
+ 1) * sizeof (void *));
286 if (!Info
->Parameters
)
288 Status
= AE_NO_MEMORY
;
292 /* Convert each external object in the list to an internal object */
294 for (i
= 0; i
< Info
->ParamCount
; i
++)
296 Status
= AcpiUtCopyEobjectToIobject (
297 &ExternalParams
->Pointer
[i
], &Info
->Parameters
[i
]);
298 if (ACPI_FAILURE (Status
))
304 Info
->Parameters
[Info
->ParamCount
] = NULL
;
311 * Begin incoming argument count analysis. Check for too few args
315 switch (AcpiNsGetType (Info
->Node
))
317 case ACPI_TYPE_METHOD
:
319 /* Check incoming argument count against the method definition */
321 if (Info
->ObjDesc
->Method
.ParamCount
> Info
->ParamCount
)
323 ACPI_ERROR ((AE_INFO
,
324 "Insufficient arguments (%u) - %u are required",
326 Info
->ObjDesc
->Method
.ParamCount
));
328 Status
= AE_MISSING_ARGUMENTS
;
332 else if (Info
->ObjDesc
->Method
.ParamCount
< Info
->ParamCount
)
334 ACPI_WARNING ((AE_INFO
,
335 "Excess arguments (%u) - only %u are required",
337 Info
->ObjDesc
->Method
.ParamCount
));
339 /* Just pass the required number of arguments */
341 Info
->ParamCount
= Info
->ObjDesc
->Method
.ParamCount
;
345 * Any incoming external objects to be passed as arguments to the
346 * method must be converted to internal objects
348 if (Info
->ParamCount
)
351 * Allocate a new parameter block for the internal objects
352 * Add 1 to count to allow for null terminated internal list
354 Info
->Parameters
= ACPI_ALLOCATE_ZEROED (
355 ((ACPI_SIZE
) Info
->ParamCount
+ 1) * sizeof (void *));
356 if (!Info
->Parameters
)
358 Status
= AE_NO_MEMORY
;
362 /* Convert each external object in the list to an internal object */
364 for (i
= 0; i
< Info
->ParamCount
; i
++)
366 Status
= AcpiUtCopyEobjectToIobject (
367 &ExternalParams
->Pointer
[i
], &Info
->Parameters
[i
]);
368 if (ACPI_FAILURE (Status
))
374 Info
->Parameters
[Info
->ParamCount
] = NULL
;
380 /* Warn if arguments passed to an object that is not a method */
382 if (Info
->ParamCount
)
384 ACPI_WARNING ((AE_INFO
,
385 "%u arguments were passed to a non-method ACPI object",
394 /* Now we can evaluate the object */
396 Status
= AcpiNsEvaluate (Info
);
399 * If we are expecting a return value, and all went well above,
400 * copy the return value to an external object.
404 if (!Info
->ReturnObject
)
406 ReturnBuffer
->Length
= 0;
410 if (ACPI_GET_DESCRIPTOR_TYPE (Info
->ReturnObject
) ==
411 ACPI_DESC_TYPE_NAMED
)
414 * If we received a NS Node as a return object, this means that
415 * the object we are evaluating has nothing interesting to
416 * return (such as a mutex, etc.) We return an error because
417 * these types are essentially unsupported by this interface.
418 * We don't check up front because this makes it easier to add
419 * support for various types at a later date if necessary.
422 Info
->ReturnObject
= NULL
; /* No need to delete a NS Node */
423 ReturnBuffer
->Length
= 0;
426 if (ACPI_SUCCESS (Status
))
428 /* Dereference Index and RefOf references */
430 AcpiNsResolveReferences (Info
);
432 /* Get the size of the returned object */
434 Status
= AcpiUtGetObjectSize (Info
->ReturnObject
,
436 if (ACPI_SUCCESS (Status
))
438 /* Validate/Allocate/Clear caller buffer */
440 Status
= AcpiUtInitializeBuffer (ReturnBuffer
,
442 if (ACPI_FAILURE (Status
))
445 * Caller's buffer is too small or a new one can't
448 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
449 "Needed buffer size %X, %s\n",
450 (UINT32
) BufferSpaceNeeded
,
451 AcpiFormatException (Status
)));
455 /* We have enough space for the object, build it */
457 Status
= AcpiUtCopyIobjectToEobject (Info
->ReturnObject
,
465 if (Info
->ReturnObject
)
468 * Delete the internal return object. NOTE: Interpreter must be
469 * locked to avoid race condition.
471 AcpiExEnterInterpreter ();
473 /* Remove one reference on the return object (should delete it) */
475 AcpiUtRemoveReference (Info
->ReturnObject
);
476 AcpiExExitInterpreter ();
482 /* Free the input parameter list (if we created one) */
484 if (Info
->Parameters
)
486 /* Free the allocated parameter block */
488 AcpiUtDeleteInternalObjectList (Info
->Parameters
);
492 return_ACPI_STATUS (Status
);
495 ACPI_EXPORT_SYMBOL (AcpiEvaluateObject
)
498 /*******************************************************************************
500 * FUNCTION: AcpiNsResolveReferences
502 * PARAMETERS: Info - Evaluation info block
504 * RETURN: Info->ReturnObject is replaced with the dereferenced object
506 * DESCRIPTION: Dereference certain reference objects. Called before an
507 * internal return object is converted to an external ACPI_OBJECT.
509 * Performs an automatic dereference of Index and RefOf reference objects.
510 * These reference objects are not supported by the ACPI_OBJECT, so this is a
511 * last resort effort to return something useful. Also, provides compatibility
512 * with other ACPI implementations.
514 * NOTE: does not handle references within returned package objects or nested
515 * references, but this support could be added later if found to be necessary.
517 ******************************************************************************/
520 AcpiNsResolveReferences (
521 ACPI_EVALUATE_INFO
*Info
)
523 ACPI_OPERAND_OBJECT
*ObjDesc
= NULL
;
524 ACPI_NAMESPACE_NODE
*Node
;
527 /* We are interested in reference objects only */
529 if ((Info
->ReturnObject
)->Common
.Type
!= ACPI_TYPE_LOCAL_REFERENCE
)
535 * Two types of references are supported - those created by Index and
536 * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
537 * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
538 * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
541 switch (Info
->ReturnObject
->Reference
.Class
)
543 case ACPI_REFCLASS_INDEX
:
545 ObjDesc
= *(Info
->ReturnObject
->Reference
.Where
);
548 case ACPI_REFCLASS_REFOF
:
550 Node
= Info
->ReturnObject
->Reference
.Object
;
553 ObjDesc
= Node
->Object
;
562 /* Replace the existing reference object */
566 AcpiUtAddReference (ObjDesc
);
567 AcpiUtRemoveReference (Info
->ReturnObject
);
568 Info
->ReturnObject
= ObjDesc
;
575 /*******************************************************************************
577 * FUNCTION: AcpiWalkNamespace
579 * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
580 * StartObject - Handle in namespace where search begins
581 * MaxDepth - Depth to which search is to reach
582 * DescendingCallback - Called during tree descent
583 * when an object of "Type" is found
584 * AscendingCallback - Called during tree ascent
585 * when an object of "Type" is found
586 * Context - Passed to user function(s) above
587 * ReturnValue - Location where return value of
588 * UserFunction is put if terminated early
590 * RETURNS Return value from the UserFunction if terminated early.
591 * Otherwise, returns NULL.
593 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
594 * starting (and ending) at the object specified by StartHandle.
595 * The callback function is called whenever an object that matches
596 * the type parameter is found. If the callback function returns
597 * a non-zero value, the search is terminated immediately and this
598 * value is returned to the caller.
600 * The point of this procedure is to provide a generic namespace
601 * walk routine that can be called from multiple places to
602 * provide multiple services; the callback function(s) can be
603 * tailored to each task, whether it is a print function,
604 * a compare function, etc.
606 ******************************************************************************/
610 ACPI_OBJECT_TYPE Type
,
611 ACPI_HANDLE StartObject
,
613 ACPI_WALK_CALLBACK DescendingCallback
,
614 ACPI_WALK_CALLBACK AscendingCallback
,
621 ACPI_FUNCTION_TRACE (AcpiWalkNamespace
);
624 /* Parameter validation */
626 if ((Type
> ACPI_TYPE_LOCAL_MAX
) ||
628 (!DescendingCallback
&& !AscendingCallback
))
630 return_ACPI_STATUS (AE_BAD_PARAMETER
);
634 * Need to acquire the namespace reader lock to prevent interference
635 * with any concurrent table unloads (which causes the deletion of
636 * namespace objects). We cannot allow the deletion of a namespace node
637 * while the user function is using it. The exception to this are the
638 * nodes created and deleted during control method execution -- these
639 * nodes are marked as temporary nodes and are ignored by the namespace
640 * walk. Thus, control methods can be executed while holding the
641 * namespace deletion lock (and the user function can execute control
644 Status
= AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock
);
645 if (ACPI_FAILURE (Status
))
647 return_ACPI_STATUS (Status
);
651 * Lock the namespace around the walk. The namespace will be
652 * unlocked/locked around each call to the user function - since the user
653 * function must be allowed to make ACPICA calls itself (for example, it
654 * will typically execute control methods during device enumeration.)
656 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
657 if (ACPI_FAILURE (Status
))
662 /* Now we can validate the starting node */
664 if (!AcpiNsValidateHandle (StartObject
))
666 Status
= AE_BAD_PARAMETER
;
670 Status
= AcpiNsWalkNamespace (Type
, StartObject
, MaxDepth
,
671 ACPI_NS_WALK_UNLOCK
, DescendingCallback
,
672 AscendingCallback
, Context
, ReturnValue
);
675 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
678 (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock
);
679 return_ACPI_STATUS (Status
);
682 ACPI_EXPORT_SYMBOL (AcpiWalkNamespace
)
685 /*******************************************************************************
687 * FUNCTION: AcpiNsGetDeviceCallback
689 * PARAMETERS: Callback from AcpiGetDevice
693 * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
694 * present devices, or if they specified a HID, it filters based
697 ******************************************************************************/
700 AcpiNsGetDeviceCallback (
701 ACPI_HANDLE ObjHandle
,
706 ACPI_GET_DEVICES_INFO
*Info
= Context
;
708 ACPI_NAMESPACE_NODE
*Node
;
710 ACPI_PNP_DEVICE_ID
*Hid
;
711 ACPI_PNP_DEVICE_ID_LIST
*Cid
;
717 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
718 if (ACPI_FAILURE (Status
))
723 Node
= AcpiNsValidateHandle (ObjHandle
);
724 Status
= AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
725 if (ACPI_FAILURE (Status
))
732 return (AE_BAD_PARAMETER
);
736 * First, filter based on the device HID and CID.
738 * 01/2010: For this case where a specific HID is requested, we don't
739 * want to run _STA until we have an actual HID match. Thus, we will
740 * not unnecessarily execute _STA on devices for which the caller
741 * doesn't care about. Previously, _STA was executed unconditionally
742 * on all devices found here.
744 * A side-effect of this change is that now we will continue to search
745 * for a matching HID even under device trees where the parent device
746 * would have returned a _STA that indicates it is not present or
747 * not functioning (thus aborting the search on that branch).
749 if (Info
->Hid
!= NULL
)
751 Status
= AcpiUtExecute_HID (Node
, &Hid
);
752 if (Status
== AE_NOT_FOUND
)
756 else if (ACPI_FAILURE (Status
))
758 return (AE_CTRL_DEPTH
);
761 NoMatch
= ACPI_STRCMP (Hid
->String
, Info
->Hid
);
767 * HID does not match, attempt match within the
768 * list of Compatible IDs (CIDs)
770 Status
= AcpiUtExecute_CID (Node
, &Cid
);
771 if (Status
== AE_NOT_FOUND
)
775 else if (ACPI_FAILURE (Status
))
777 return (AE_CTRL_DEPTH
);
780 /* Walk the CID list */
783 for (i
= 0; i
< Cid
->Count
; i
++)
785 if (ACPI_STRCMP (Cid
->Ids
[i
].String
, Info
->Hid
) == 0)
787 /* Found a matching CID */
802 /* Run _STA to determine if device is present */
804 Status
= AcpiUtExecute_STA (Node
, &Flags
);
805 if (ACPI_FAILURE (Status
))
807 return (AE_CTRL_DEPTH
);
810 if (!(Flags
& ACPI_STA_DEVICE_PRESENT
) &&
811 !(Flags
& ACPI_STA_DEVICE_FUNCTIONING
))
814 * Don't examine the children of the device only when the
815 * device is neither present nor functional. See ACPI spec,
816 * description of _STA for more information.
818 return (AE_CTRL_DEPTH
);
821 /* We have a valid device, invoke the user function */
823 Status
= Info
->UserFunction (ObjHandle
, NestingLevel
, Info
->Context
,
829 /*******************************************************************************
831 * FUNCTION: AcpiGetDevices
833 * PARAMETERS: HID - HID to search for. Can be NULL.
834 * UserFunction - Called when a matching object is found
835 * Context - Passed to user function
836 * ReturnValue - Location where return value of
837 * UserFunction is put if terminated early
839 * RETURNS Return value from the UserFunction if terminated early.
840 * Otherwise, returns NULL.
842 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
843 * starting (and ending) at the object specified by StartHandle.
844 * The UserFunction is called whenever an object of type
845 * Device is found. If the user function returns
846 * a non-zero value, the search is terminated immediately and this
847 * value is returned to the caller.
849 * This is a wrapper for WalkNamespace, but the callback performs
850 * additional filtering. Please see AcpiNsGetDeviceCallback.
852 ******************************************************************************/
857 ACPI_WALK_CALLBACK UserFunction
,
862 ACPI_GET_DEVICES_INFO Info
;
865 ACPI_FUNCTION_TRACE (AcpiGetDevices
);
868 /* Parameter validation */
872 return_ACPI_STATUS (AE_BAD_PARAMETER
);
876 * We're going to call their callback from OUR callback, so we need
877 * to know what it is, and their context parameter.
880 Info
.Context
= Context
;
881 Info
.UserFunction
= UserFunction
;
884 * Lock the namespace around the walk.
885 * The namespace will be unlocked/locked around each call
886 * to the user function - since this function
887 * must be allowed to make Acpi calls itself.
889 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
890 if (ACPI_FAILURE (Status
))
892 return_ACPI_STATUS (Status
);
895 Status
= AcpiNsWalkNamespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
,
896 ACPI_UINT32_MAX
, ACPI_NS_WALK_UNLOCK
,
897 AcpiNsGetDeviceCallback
, NULL
, &Info
, ReturnValue
);
899 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
900 return_ACPI_STATUS (Status
);
903 ACPI_EXPORT_SYMBOL (AcpiGetDevices
)
906 /*******************************************************************************
908 * FUNCTION: AcpiAttachData
910 * PARAMETERS: ObjHandle - Namespace node
911 * Handler - Handler for this attachment
912 * Data - Pointer to data to be attached
916 * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
918 ******************************************************************************/
922 ACPI_HANDLE ObjHandle
,
923 ACPI_OBJECT_HANDLER Handler
,
926 ACPI_NAMESPACE_NODE
*Node
;
930 /* Parameter validation */
936 return (AE_BAD_PARAMETER
);
939 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
940 if (ACPI_FAILURE (Status
))
945 /* Convert and validate the handle */
947 Node
= AcpiNsValidateHandle (ObjHandle
);
950 Status
= AE_BAD_PARAMETER
;
954 Status
= AcpiNsAttachData (Node
, Handler
, Data
);
957 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
961 ACPI_EXPORT_SYMBOL (AcpiAttachData
)
964 /*******************************************************************************
966 * FUNCTION: AcpiDetachData
968 * PARAMETERS: ObjHandle - Namespace node handle
969 * Handler - Handler used in call to AcpiAttachData
973 * DESCRIPTION: Remove data that was previously attached to a node.
975 ******************************************************************************/
979 ACPI_HANDLE ObjHandle
,
980 ACPI_OBJECT_HANDLER Handler
)
982 ACPI_NAMESPACE_NODE
*Node
;
986 /* Parameter validation */
991 return (AE_BAD_PARAMETER
);
994 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
995 if (ACPI_FAILURE (Status
))
1000 /* Convert and validate the handle */
1002 Node
= AcpiNsValidateHandle (ObjHandle
);
1005 Status
= AE_BAD_PARAMETER
;
1009 Status
= AcpiNsDetachData (Node
, Handler
);
1012 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
1016 ACPI_EXPORT_SYMBOL (AcpiDetachData
)
1019 /*******************************************************************************
1021 * FUNCTION: AcpiGetData
1023 * PARAMETERS: ObjHandle - Namespace node
1024 * Handler - Handler used in call to AttachData
1025 * Data - Where the data is returned
1029 * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
1031 ******************************************************************************/
1035 ACPI_HANDLE ObjHandle
,
1036 ACPI_OBJECT_HANDLER Handler
,
1039 ACPI_NAMESPACE_NODE
*Node
;
1043 /* Parameter validation */
1049 return (AE_BAD_PARAMETER
);
1052 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
1053 if (ACPI_FAILURE (Status
))
1058 /* Convert and validate the handle */
1060 Node
= AcpiNsValidateHandle (ObjHandle
);
1063 Status
= AE_BAD_PARAMETER
;
1067 Status
= AcpiNsGetAttachedData (Node
, Handler
, Data
);
1070 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
1074 ACPI_EXPORT_SYMBOL (AcpiGetData
)