nsxfeval.c revision 1.3.2.2 1 1.3.2.2 bouyer /*******************************************************************************
2 1.3.2.2 bouyer *
3 1.3.2.2 bouyer * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
4 1.3.2.2 bouyer * ACPI Object evaluation interfaces
5 1.3.2.2 bouyer *
6 1.3.2.2 bouyer ******************************************************************************/
7 1.3.2.2 bouyer
8 1.3.2.2 bouyer /*
9 1.3.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
10 1.3.2.2 bouyer * All rights reserved.
11 1.3.2.2 bouyer *
12 1.3.2.2 bouyer * Redistribution and use in source and binary forms, with or without
13 1.3.2.2 bouyer * modification, are permitted provided that the following conditions
14 1.3.2.2 bouyer * are met:
15 1.3.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
16 1.3.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
17 1.3.2.2 bouyer * without modification.
18 1.3.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.3.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
20 1.3.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
21 1.3.2.2 bouyer * including a substantially similar Disclaimer requirement for further
22 1.3.2.2 bouyer * binary redistribution.
23 1.3.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
24 1.3.2.2 bouyer * of any contributors may be used to endorse or promote products derived
25 1.3.2.2 bouyer * from this software without specific prior written permission.
26 1.3.2.2 bouyer *
27 1.3.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
28 1.3.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
29 1.3.2.2 bouyer * Software Foundation.
30 1.3.2.2 bouyer *
31 1.3.2.2 bouyer * NO WARRANTY
32 1.3.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.3.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.3.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.3.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.3.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.3.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.3.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.3.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.3.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.3.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.3.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
43 1.3.2.2 bouyer */
44 1.3.2.2 bouyer
45 1.3.2.2 bouyer
46 1.3.2.2 bouyer #define __NSXFEVAL_C__
47 1.3.2.2 bouyer
48 1.3.2.2 bouyer #include "acpi.h"
49 1.3.2.2 bouyer #include "accommon.h"
50 1.3.2.2 bouyer #include "acnamesp.h"
51 1.3.2.2 bouyer #include "acinterp.h"
52 1.3.2.2 bouyer
53 1.3.2.2 bouyer
54 1.3.2.2 bouyer #define _COMPONENT ACPI_NAMESPACE
55 1.3.2.2 bouyer ACPI_MODULE_NAME ("nsxfeval")
56 1.3.2.2 bouyer
57 1.3.2.2 bouyer /* Local prototypes */
58 1.3.2.2 bouyer
59 1.3.2.2 bouyer static void
60 1.3.2.2 bouyer AcpiNsResolveReferences (
61 1.3.2.2 bouyer ACPI_EVALUATE_INFO *Info);
62 1.3.2.2 bouyer
63 1.3.2.2 bouyer
64 1.3.2.2 bouyer /*******************************************************************************
65 1.3.2.2 bouyer *
66 1.3.2.2 bouyer * FUNCTION: AcpiEvaluateObjectTyped
67 1.3.2.2 bouyer *
68 1.3.2.2 bouyer * PARAMETERS: Handle - Object handle (optional)
69 1.3.2.2 bouyer * Pathname - Object pathname (optional)
70 1.3.2.2 bouyer * ExternalParams - List of parameters to pass to method,
71 1.3.2.2 bouyer * terminated by NULL. May be NULL
72 1.3.2.2 bouyer * if no parameters are being passed.
73 1.3.2.2 bouyer * ReturnBuffer - Where to put method's return value (if
74 1.3.2.2 bouyer * any). If NULL, no value is returned.
75 1.3.2.2 bouyer * ReturnType - Expected type of return object
76 1.3.2.2 bouyer *
77 1.3.2.2 bouyer * RETURN: Status
78 1.3.2.2 bouyer *
79 1.3.2.2 bouyer * DESCRIPTION: Find and evaluate the given object, passing the given
80 1.3.2.2 bouyer * parameters if necessary. One of "Handle" or "Pathname" must
81 1.3.2.2 bouyer * be valid (non-null)
82 1.3.2.2 bouyer *
83 1.3.2.2 bouyer ******************************************************************************/
84 1.3.2.2 bouyer
85 1.3.2.2 bouyer ACPI_STATUS
86 1.3.2.2 bouyer AcpiEvaluateObjectTyped (
87 1.3.2.2 bouyer ACPI_HANDLE Handle,
88 1.3.2.2 bouyer ACPI_CONST_STRING Pathname,
89 1.3.2.2 bouyer ACPI_OBJECT_LIST *ExternalParams,
90 1.3.2.2 bouyer ACPI_BUFFER *ReturnBuffer,
91 1.3.2.2 bouyer ACPI_OBJECT_TYPE ReturnType)
92 1.3.2.2 bouyer {
93 1.3.2.2 bouyer ACPI_STATUS Status;
94 1.3.2.2 bouyer BOOLEAN MustFree = FALSE;
95 1.3.2.2 bouyer
96 1.3.2.2 bouyer ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped);
97 1.3.2.2 bouyer
98 1.3.2.2 bouyer
99 1.3.2.2 bouyer /* Return buffer must be valid */
100 1.3.2.2 bouyer
101 1.3.2.2 bouyer if (!ReturnBuffer)
102 1.3.2.2 bouyer {
103 1.3.2.2 bouyer return_ACPI_STATUS (AE_BAD_PARAMETER);
104 1.3.2.2 bouyer }
105 1.3.2.2 bouyer
106 1.3.2.2 bouyer if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER)
107 1.3.2.2 bouyer {
108 1.3.2.2 bouyer MustFree = TRUE;
109 1.3.2.2 bouyer }
110 1.3.2.2 bouyer
111 1.3.2.2 bouyer /* Evaluate the object */
112 1.3.2.2 bouyer
113 1.3.2.2 bouyer Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer);
114 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
115 1.3.2.2 bouyer {
116 1.3.2.2 bouyer return_ACPI_STATUS (Status);
117 1.3.2.2 bouyer }
118 1.3.2.2 bouyer
119 1.3.2.2 bouyer /* Type ANY means "don't care" */
120 1.3.2.2 bouyer
121 1.3.2.2 bouyer if (ReturnType == ACPI_TYPE_ANY)
122 1.3.2.2 bouyer {
123 1.3.2.2 bouyer return_ACPI_STATUS (AE_OK);
124 1.3.2.2 bouyer }
125 1.3.2.2 bouyer
126 1.3.2.2 bouyer if (ReturnBuffer->Length == 0)
127 1.3.2.2 bouyer {
128 1.3.2.2 bouyer /* Error because caller specifically asked for a return value */
129 1.3.2.2 bouyer
130 1.3.2.2 bouyer ACPI_ERROR ((AE_INFO, "No return value"));
131 1.3.2.2 bouyer return_ACPI_STATUS (AE_NULL_OBJECT);
132 1.3.2.2 bouyer }
133 1.3.2.2 bouyer
134 1.3.2.2 bouyer /* Examine the object type returned from EvaluateObject */
135 1.3.2.2 bouyer
136 1.3.2.2 bouyer if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType)
137 1.3.2.2 bouyer {
138 1.3.2.2 bouyer return_ACPI_STATUS (AE_OK);
139 1.3.2.2 bouyer }
140 1.3.2.2 bouyer
141 1.3.2.2 bouyer /* Return object type does not match requested type */
142 1.3.2.2 bouyer
143 1.3.2.2 bouyer ACPI_ERROR ((AE_INFO,
144 1.3.2.2 bouyer "Incorrect return type [%s] requested [%s]",
145 1.3.2.2 bouyer AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type),
146 1.3.2.2 bouyer AcpiUtGetTypeName (ReturnType)));
147 1.3.2.2 bouyer
148 1.3.2.2 bouyer if (MustFree)
149 1.3.2.2 bouyer {
150 1.3.2.2 bouyer /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
151 1.3.2.2 bouyer
152 1.3.2.2 bouyer AcpiOsFree (ReturnBuffer->Pointer);
153 1.3.2.2 bouyer ReturnBuffer->Pointer = NULL;
154 1.3.2.2 bouyer }
155 1.3.2.2 bouyer
156 1.3.2.2 bouyer ReturnBuffer->Length = 0;
157 1.3.2.2 bouyer return_ACPI_STATUS (AE_TYPE);
158 1.3.2.2 bouyer }
159 1.3.2.2 bouyer
160 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped)
161 1.3.2.2 bouyer
162 1.3.2.2 bouyer
163 1.3.2.2 bouyer /*******************************************************************************
164 1.3.2.2 bouyer *
165 1.3.2.2 bouyer * FUNCTION: AcpiEvaluateObject
166 1.3.2.2 bouyer *
167 1.3.2.2 bouyer * PARAMETERS: Handle - Object handle (optional)
168 1.3.2.2 bouyer * Pathname - Object pathname (optional)
169 1.3.2.2 bouyer * ExternalParams - List of parameters to pass to method,
170 1.3.2.2 bouyer * terminated by NULL. May be NULL
171 1.3.2.2 bouyer * if no parameters are being passed.
172 1.3.2.2 bouyer * ReturnBuffer - Where to put method's return value (if
173 1.3.2.2 bouyer * any). If NULL, no value is returned.
174 1.3.2.2 bouyer *
175 1.3.2.2 bouyer * RETURN: Status
176 1.3.2.2 bouyer *
177 1.3.2.2 bouyer * DESCRIPTION: Find and evaluate the given object, passing the given
178 1.3.2.2 bouyer * parameters if necessary. One of "Handle" or "Pathname" must
179 1.3.2.2 bouyer * be valid (non-null)
180 1.3.2.2 bouyer *
181 1.3.2.2 bouyer ******************************************************************************/
182 1.3.2.2 bouyer
183 1.3.2.2 bouyer ACPI_STATUS
184 1.3.2.2 bouyer AcpiEvaluateObject (
185 1.3.2.2 bouyer ACPI_HANDLE Handle,
186 1.3.2.2 bouyer ACPI_CONST_STRING Pathname,
187 1.3.2.2 bouyer ACPI_OBJECT_LIST *ExternalParams,
188 1.3.2.2 bouyer ACPI_BUFFER *ReturnBuffer)
189 1.3.2.2 bouyer {
190 1.3.2.2 bouyer ACPI_STATUS Status;
191 1.3.2.2 bouyer ACPI_EVALUATE_INFO *Info;
192 1.3.2.2 bouyer ACPI_SIZE BufferSpaceNeeded;
193 1.3.2.2 bouyer UINT32 i;
194 1.3.2.2 bouyer
195 1.3.2.2 bouyer
196 1.3.2.2 bouyer ACPI_FUNCTION_TRACE (AcpiEvaluateObject);
197 1.3.2.2 bouyer
198 1.3.2.2 bouyer
199 1.3.2.2 bouyer /* Allocate and initialize the evaluation information block */
200 1.3.2.2 bouyer
201 1.3.2.2 bouyer Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
202 1.3.2.2 bouyer if (!Info)
203 1.3.2.2 bouyer {
204 1.3.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
205 1.3.2.2 bouyer }
206 1.3.2.2 bouyer
207 1.3.2.2 bouyer Info->Pathname = __UNCONST(Pathname);
208 1.3.2.2 bouyer
209 1.3.2.2 bouyer /* Convert and validate the device handle */
210 1.3.2.2 bouyer
211 1.3.2.2 bouyer Info->PrefixNode = AcpiNsValidateHandle (Handle);
212 1.3.2.2 bouyer if (!Info->PrefixNode)
213 1.3.2.2 bouyer {
214 1.3.2.2 bouyer Status = AE_BAD_PARAMETER;
215 1.3.2.2 bouyer goto Cleanup;
216 1.3.2.2 bouyer }
217 1.3.2.2 bouyer
218 1.3.2.2 bouyer /*
219 1.3.2.2 bouyer * If there are parameters to be passed to a control method, the external
220 1.3.2.2 bouyer * objects must all be converted to internal objects
221 1.3.2.2 bouyer */
222 1.3.2.2 bouyer if (ExternalParams && ExternalParams->Count)
223 1.3.2.2 bouyer {
224 1.3.2.2 bouyer /*
225 1.3.2.2 bouyer * Allocate a new parameter block for the internal objects
226 1.3.2.2 bouyer * Add 1 to count to allow for null terminated internal list
227 1.3.2.2 bouyer */
228 1.3.2.2 bouyer Info->Parameters = ACPI_ALLOCATE_ZEROED (
229 1.3.2.2 bouyer ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *));
230 1.3.2.2 bouyer if (!Info->Parameters)
231 1.3.2.2 bouyer {
232 1.3.2.2 bouyer Status = AE_NO_MEMORY;
233 1.3.2.2 bouyer goto Cleanup;
234 1.3.2.2 bouyer }
235 1.3.2.2 bouyer
236 1.3.2.2 bouyer /* Convert each external object in the list to an internal object */
237 1.3.2.2 bouyer
238 1.3.2.2 bouyer for (i = 0; i < ExternalParams->Count; i++)
239 1.3.2.2 bouyer {
240 1.3.2.2 bouyer Status = AcpiUtCopyEobjectToIobject (
241 1.3.2.2 bouyer &ExternalParams->Pointer[i], &Info->Parameters[i]);
242 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
243 1.3.2.2 bouyer {
244 1.3.2.2 bouyer goto Cleanup;
245 1.3.2.2 bouyer }
246 1.3.2.2 bouyer }
247 1.3.2.2 bouyer Info->Parameters[ExternalParams->Count] = NULL;
248 1.3.2.2 bouyer }
249 1.3.2.2 bouyer
250 1.3.2.2 bouyer /*
251 1.3.2.2 bouyer * Three major cases:
252 1.3.2.2 bouyer * 1) Fully qualified pathname
253 1.3.2.2 bouyer * 2) No handle, not fully qualified pathname (error)
254 1.3.2.2 bouyer * 3) Valid handle
255 1.3.2.2 bouyer */
256 1.3.2.2 bouyer if ((Pathname) &&
257 1.3.2.2 bouyer (AcpiNsValidRootPrefix (Pathname[0])))
258 1.3.2.2 bouyer {
259 1.3.2.2 bouyer /* The path is fully qualified, just evaluate by name */
260 1.3.2.2 bouyer
261 1.3.2.2 bouyer Info->PrefixNode = NULL;
262 1.3.2.2 bouyer Status = AcpiNsEvaluate (Info);
263 1.3.2.2 bouyer }
264 1.3.2.2 bouyer else if (!Handle)
265 1.3.2.2 bouyer {
266 1.3.2.2 bouyer /*
267 1.3.2.2 bouyer * A handle is optional iff a fully qualified pathname is specified.
268 1.3.2.2 bouyer * Since we've already handled fully qualified names above, this is
269 1.3.2.2 bouyer * an error
270 1.3.2.2 bouyer */
271 1.3.2.2 bouyer if (!Pathname)
272 1.3.2.2 bouyer {
273 1.3.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
274 1.3.2.2 bouyer "Both Handle and Pathname are NULL"));
275 1.3.2.2 bouyer }
276 1.3.2.2 bouyer else
277 1.3.2.2 bouyer {
278 1.3.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
279 1.3.2.2 bouyer "Null Handle with relative pathname [%s]", Pathname));
280 1.3.2.2 bouyer }
281 1.3.2.2 bouyer
282 1.3.2.2 bouyer Status = AE_BAD_PARAMETER;
283 1.3.2.2 bouyer }
284 1.3.2.2 bouyer else
285 1.3.2.2 bouyer {
286 1.3.2.2 bouyer /* We have a namespace a node and a possible relative path */
287 1.3.2.2 bouyer
288 1.3.2.2 bouyer Status = AcpiNsEvaluate (Info);
289 1.3.2.2 bouyer }
290 1.3.2.2 bouyer
291 1.3.2.2 bouyer /*
292 1.3.2.2 bouyer * If we are expecting a return value, and all went well above,
293 1.3.2.2 bouyer * copy the return value to an external object.
294 1.3.2.2 bouyer */
295 1.3.2.2 bouyer if (ReturnBuffer)
296 1.3.2.2 bouyer {
297 1.3.2.2 bouyer if (!Info->ReturnObject)
298 1.3.2.2 bouyer {
299 1.3.2.2 bouyer ReturnBuffer->Length = 0;
300 1.3.2.2 bouyer }
301 1.3.2.2 bouyer else
302 1.3.2.2 bouyer {
303 1.3.2.2 bouyer if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
304 1.3.2.2 bouyer ACPI_DESC_TYPE_NAMED)
305 1.3.2.2 bouyer {
306 1.3.2.2 bouyer /*
307 1.3.2.2 bouyer * If we received a NS Node as a return object, this means that
308 1.3.2.2 bouyer * the object we are evaluating has nothing interesting to
309 1.3.2.2 bouyer * return (such as a mutex, etc.) We return an error because
310 1.3.2.2 bouyer * these types are essentially unsupported by this interface.
311 1.3.2.2 bouyer * We don't check up front because this makes it easier to add
312 1.3.2.2 bouyer * support for various types at a later date if necessary.
313 1.3.2.2 bouyer */
314 1.3.2.2 bouyer Status = AE_TYPE;
315 1.3.2.2 bouyer Info->ReturnObject = NULL; /* No need to delete a NS Node */
316 1.3.2.2 bouyer ReturnBuffer->Length = 0;
317 1.3.2.2 bouyer }
318 1.3.2.2 bouyer
319 1.3.2.2 bouyer if (ACPI_SUCCESS (Status))
320 1.3.2.2 bouyer {
321 1.3.2.2 bouyer /* Dereference Index and RefOf references */
322 1.3.2.2 bouyer
323 1.3.2.2 bouyer AcpiNsResolveReferences (Info);
324 1.3.2.2 bouyer
325 1.3.2.2 bouyer /* Get the size of the returned object */
326 1.3.2.2 bouyer
327 1.3.2.2 bouyer Status = AcpiUtGetObjectSize (Info->ReturnObject,
328 1.3.2.2 bouyer &BufferSpaceNeeded);
329 1.3.2.2 bouyer if (ACPI_SUCCESS (Status))
330 1.3.2.2 bouyer {
331 1.3.2.2 bouyer /* Validate/Allocate/Clear caller buffer */
332 1.3.2.2 bouyer
333 1.3.2.2 bouyer Status = AcpiUtInitializeBuffer (ReturnBuffer,
334 1.3.2.2 bouyer BufferSpaceNeeded);
335 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
336 1.3.2.2 bouyer {
337 1.3.2.2 bouyer /*
338 1.3.2.2 bouyer * Caller's buffer is too small or a new one can't
339 1.3.2.2 bouyer * be allocated
340 1.3.2.2 bouyer */
341 1.3.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
342 1.3.2.2 bouyer "Needed buffer size %X, %s\n",
343 1.3.2.2 bouyer (UINT32) BufferSpaceNeeded,
344 1.3.2.2 bouyer AcpiFormatException (Status)));
345 1.3.2.2 bouyer }
346 1.3.2.2 bouyer else
347 1.3.2.2 bouyer {
348 1.3.2.2 bouyer /* We have enough space for the object, build it */
349 1.3.2.2 bouyer
350 1.3.2.2 bouyer Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject,
351 1.3.2.2 bouyer ReturnBuffer);
352 1.3.2.2 bouyer }
353 1.3.2.2 bouyer }
354 1.3.2.2 bouyer }
355 1.3.2.2 bouyer }
356 1.3.2.2 bouyer }
357 1.3.2.2 bouyer
358 1.3.2.2 bouyer if (Info->ReturnObject)
359 1.3.2.2 bouyer {
360 1.3.2.2 bouyer /*
361 1.3.2.2 bouyer * Delete the internal return object. NOTE: Interpreter must be
362 1.3.2.2 bouyer * locked to avoid race condition.
363 1.3.2.2 bouyer */
364 1.3.2.2 bouyer AcpiExEnterInterpreter ();
365 1.3.2.2 bouyer
366 1.3.2.2 bouyer /* Remove one reference on the return object (should delete it) */
367 1.3.2.2 bouyer
368 1.3.2.2 bouyer AcpiUtRemoveReference (Info->ReturnObject);
369 1.3.2.2 bouyer AcpiExExitInterpreter ();
370 1.3.2.2 bouyer }
371 1.3.2.2 bouyer
372 1.3.2.2 bouyer
373 1.3.2.2 bouyer Cleanup:
374 1.3.2.2 bouyer
375 1.3.2.2 bouyer /* Free the input parameter list (if we created one) */
376 1.3.2.2 bouyer
377 1.3.2.2 bouyer if (Info->Parameters)
378 1.3.2.2 bouyer {
379 1.3.2.2 bouyer /* Free the allocated parameter block */
380 1.3.2.2 bouyer
381 1.3.2.2 bouyer AcpiUtDeleteInternalObjectList (Info->Parameters);
382 1.3.2.2 bouyer }
383 1.3.2.2 bouyer
384 1.3.2.2 bouyer ACPI_FREE (Info);
385 1.3.2.2 bouyer return_ACPI_STATUS (Status);
386 1.3.2.2 bouyer }
387 1.3.2.2 bouyer
388 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiEvaluateObject)
389 1.3.2.2 bouyer
390 1.3.2.2 bouyer
391 1.3.2.2 bouyer /*******************************************************************************
392 1.3.2.2 bouyer *
393 1.3.2.2 bouyer * FUNCTION: AcpiNsResolveReferences
394 1.3.2.2 bouyer *
395 1.3.2.2 bouyer * PARAMETERS: Info - Evaluation info block
396 1.3.2.2 bouyer *
397 1.3.2.2 bouyer * RETURN: Info->ReturnObject is replaced with the dereferenced object
398 1.3.2.2 bouyer *
399 1.3.2.2 bouyer * DESCRIPTION: Dereference certain reference objects. Called before an
400 1.3.2.2 bouyer * internal return object is converted to an external ACPI_OBJECT.
401 1.3.2.2 bouyer *
402 1.3.2.2 bouyer * Performs an automatic dereference of Index and RefOf reference objects.
403 1.3.2.2 bouyer * These reference objects are not supported by the ACPI_OBJECT, so this is a
404 1.3.2.2 bouyer * last resort effort to return something useful. Also, provides compatibility
405 1.3.2.2 bouyer * with other ACPI implementations.
406 1.3.2.2 bouyer *
407 1.3.2.2 bouyer * NOTE: does not handle references within returned package objects or nested
408 1.3.2.2 bouyer * references, but this support could be added later if found to be necessary.
409 1.3.2.2 bouyer *
410 1.3.2.2 bouyer ******************************************************************************/
411 1.3.2.2 bouyer
412 1.3.2.2 bouyer static void
413 1.3.2.2 bouyer AcpiNsResolveReferences (
414 1.3.2.2 bouyer ACPI_EVALUATE_INFO *Info)
415 1.3.2.2 bouyer {
416 1.3.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc = NULL;
417 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
418 1.3.2.2 bouyer
419 1.3.2.2 bouyer
420 1.3.2.2 bouyer /* We are interested in reference objects only */
421 1.3.2.2 bouyer
422 1.3.2.2 bouyer if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
423 1.3.2.2 bouyer {
424 1.3.2.2 bouyer return;
425 1.3.2.2 bouyer }
426 1.3.2.2 bouyer
427 1.3.2.2 bouyer /*
428 1.3.2.2 bouyer * Two types of references are supported - those created by Index and
429 1.3.2.2 bouyer * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
430 1.3.2.2 bouyer * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
431 1.3.2.2 bouyer * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
432 1.3.2.2 bouyer * an ACPI_OBJECT.
433 1.3.2.2 bouyer */
434 1.3.2.2 bouyer switch (Info->ReturnObject->Reference.Class)
435 1.3.2.2 bouyer {
436 1.3.2.2 bouyer case ACPI_REFCLASS_INDEX:
437 1.3.2.2 bouyer
438 1.3.2.2 bouyer ObjDesc = *(Info->ReturnObject->Reference.Where);
439 1.3.2.2 bouyer break;
440 1.3.2.2 bouyer
441 1.3.2.2 bouyer case ACPI_REFCLASS_REFOF:
442 1.3.2.2 bouyer
443 1.3.2.2 bouyer Node = Info->ReturnObject->Reference.Object;
444 1.3.2.2 bouyer if (Node)
445 1.3.2.2 bouyer {
446 1.3.2.2 bouyer ObjDesc = Node->Object;
447 1.3.2.2 bouyer }
448 1.3.2.2 bouyer break;
449 1.3.2.2 bouyer
450 1.3.2.2 bouyer default:
451 1.3.2.2 bouyer return;
452 1.3.2.2 bouyer }
453 1.3.2.2 bouyer
454 1.3.2.2 bouyer /* Replace the existing reference object */
455 1.3.2.2 bouyer
456 1.3.2.2 bouyer if (ObjDesc)
457 1.3.2.2 bouyer {
458 1.3.2.2 bouyer AcpiUtAddReference (ObjDesc);
459 1.3.2.2 bouyer AcpiUtRemoveReference (Info->ReturnObject);
460 1.3.2.2 bouyer Info->ReturnObject = ObjDesc;
461 1.3.2.2 bouyer }
462 1.3.2.2 bouyer
463 1.3.2.2 bouyer return;
464 1.3.2.2 bouyer }
465 1.3.2.2 bouyer
466 1.3.2.2 bouyer
467 1.3.2.2 bouyer /*******************************************************************************
468 1.3.2.2 bouyer *
469 1.3.2.2 bouyer * FUNCTION: AcpiWalkNamespace
470 1.3.2.2 bouyer *
471 1.3.2.2 bouyer * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
472 1.3.2.2 bouyer * StartObject - Handle in namespace where search begins
473 1.3.2.2 bouyer * MaxDepth - Depth to which search is to reach
474 1.3.2.2 bouyer * PreOrderVisit - Called during tree pre-order visit
475 1.3.2.2 bouyer * when an object of "Type" is found
476 1.3.2.2 bouyer * PostOrderVisit - Called during tree post-order visit
477 1.3.2.2 bouyer * when an object of "Type" is found
478 1.3.2.2 bouyer * Context - Passed to user function(s) above
479 1.3.2.2 bouyer * ReturnValue - Location where return value of
480 1.3.2.2 bouyer * UserFunction is put if terminated early
481 1.3.2.2 bouyer *
482 1.3.2.2 bouyer * RETURNS Return value from the UserFunction if terminated early.
483 1.3.2.2 bouyer * Otherwise, returns NULL.
484 1.3.2.2 bouyer *
485 1.3.2.2 bouyer * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
486 1.3.2.2 bouyer * starting (and ending) at the object specified by StartHandle.
487 1.3.2.2 bouyer * The callback function is called whenever an object that matches
488 1.3.2.2 bouyer * the type parameter is found. If the callback function returns
489 1.3.2.2 bouyer * a non-zero value, the search is terminated immediately and this
490 1.3.2.2 bouyer * value is returned to the caller.
491 1.3.2.2 bouyer *
492 1.3.2.2 bouyer * The point of this procedure is to provide a generic namespace
493 1.3.2.2 bouyer * walk routine that can be called from multiple places to
494 1.3.2.2 bouyer * provide multiple services; the callback function(s) can be
495 1.3.2.2 bouyer * tailored to each task, whether it is a print function,
496 1.3.2.2 bouyer * a compare function, etc.
497 1.3.2.2 bouyer *
498 1.3.2.2 bouyer ******************************************************************************/
499 1.3.2.2 bouyer
500 1.3.2.2 bouyer ACPI_STATUS
501 1.3.2.2 bouyer AcpiWalkNamespace (
502 1.3.2.2 bouyer ACPI_OBJECT_TYPE Type,
503 1.3.2.2 bouyer ACPI_HANDLE StartObject,
504 1.3.2.2 bouyer UINT32 MaxDepth,
505 1.3.2.2 bouyer ACPI_WALK_CALLBACK PreOrderVisit,
506 1.3.2.2 bouyer ACPI_WALK_CALLBACK PostOrderVisit,
507 1.3.2.2 bouyer void *Context,
508 1.3.2.2 bouyer void **ReturnValue)
509 1.3.2.2 bouyer {
510 1.3.2.2 bouyer ACPI_STATUS Status;
511 1.3.2.2 bouyer
512 1.3.2.2 bouyer
513 1.3.2.2 bouyer ACPI_FUNCTION_TRACE (AcpiWalkNamespace);
514 1.3.2.2 bouyer
515 1.3.2.2 bouyer
516 1.3.2.2 bouyer /* Parameter validation */
517 1.3.2.2 bouyer
518 1.3.2.2 bouyer if ((Type > ACPI_TYPE_LOCAL_MAX) ||
519 1.3.2.2 bouyer (!MaxDepth) ||
520 1.3.2.2 bouyer (!PreOrderVisit && !PostOrderVisit))
521 1.3.2.2 bouyer {
522 1.3.2.2 bouyer return_ACPI_STATUS (AE_BAD_PARAMETER);
523 1.3.2.2 bouyer }
524 1.3.2.2 bouyer
525 1.3.2.2 bouyer /*
526 1.3.2.2 bouyer * Need to acquire the namespace reader lock to prevent interference
527 1.3.2.2 bouyer * with any concurrent table unloads (which causes the deletion of
528 1.3.2.2 bouyer * namespace objects). We cannot allow the deletion of a namespace node
529 1.3.2.2 bouyer * while the user function is using it. The exception to this are the
530 1.3.2.2 bouyer * nodes created and deleted during control method execution -- these
531 1.3.2.2 bouyer * nodes are marked as temporary nodes and are ignored by the namespace
532 1.3.2.2 bouyer * walk. Thus, control methods can be executed while holding the
533 1.3.2.2 bouyer * namespace deletion lock (and the user function can execute control
534 1.3.2.2 bouyer * methods.)
535 1.3.2.2 bouyer */
536 1.3.2.2 bouyer Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock);
537 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
538 1.3.2.2 bouyer {
539 1.3.2.2 bouyer return (Status);
540 1.3.2.2 bouyer }
541 1.3.2.2 bouyer
542 1.3.2.2 bouyer /*
543 1.3.2.2 bouyer * Lock the namespace around the walk. The namespace will be
544 1.3.2.2 bouyer * unlocked/locked around each call to the user function - since the user
545 1.3.2.2 bouyer * function must be allowed to make ACPICA calls itself (for example, it
546 1.3.2.2 bouyer * will typically execute control methods during device enumeration.)
547 1.3.2.2 bouyer */
548 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
549 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
550 1.3.2.2 bouyer {
551 1.3.2.2 bouyer goto UnlockAndExit;
552 1.3.2.2 bouyer }
553 1.3.2.2 bouyer
554 1.3.2.2 bouyer Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth,
555 1.3.2.2 bouyer ACPI_NS_WALK_UNLOCK, PreOrderVisit,
556 1.3.2.2 bouyer PostOrderVisit, Context, ReturnValue);
557 1.3.2.2 bouyer
558 1.3.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
559 1.3.2.2 bouyer
560 1.3.2.2 bouyer UnlockAndExit:
561 1.3.2.2 bouyer (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock);
562 1.3.2.2 bouyer return_ACPI_STATUS (Status);
563 1.3.2.2 bouyer }
564 1.3.2.2 bouyer
565 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiWalkNamespace)
566 1.3.2.2 bouyer
567 1.3.2.2 bouyer
568 1.3.2.2 bouyer /*******************************************************************************
569 1.3.2.2 bouyer *
570 1.3.2.2 bouyer * FUNCTION: AcpiNsGetDeviceCallback
571 1.3.2.2 bouyer *
572 1.3.2.2 bouyer * PARAMETERS: Callback from AcpiGetDevice
573 1.3.2.2 bouyer *
574 1.3.2.2 bouyer * RETURN: Status
575 1.3.2.2 bouyer *
576 1.3.2.2 bouyer * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
577 1.3.2.2 bouyer * present devices, or if they specified a HID, it filters based
578 1.3.2.2 bouyer * on that.
579 1.3.2.2 bouyer *
580 1.3.2.2 bouyer ******************************************************************************/
581 1.3.2.2 bouyer
582 1.3.2.2 bouyer static ACPI_STATUS
583 1.3.2.2 bouyer AcpiNsGetDeviceCallback (
584 1.3.2.2 bouyer ACPI_HANDLE ObjHandle,
585 1.3.2.2 bouyer UINT32 NestingLevel,
586 1.3.2.2 bouyer void *Context,
587 1.3.2.2 bouyer void **ReturnValue)
588 1.3.2.2 bouyer {
589 1.3.2.2 bouyer ACPI_GET_DEVICES_INFO *Info = Context;
590 1.3.2.2 bouyer ACPI_STATUS Status;
591 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
592 1.3.2.2 bouyer UINT32 Flags;
593 1.3.2.2 bouyer ACPI_DEVICE_ID *Hid;
594 1.3.2.2 bouyer ACPI_DEVICE_ID_LIST *Cid;
595 1.3.2.2 bouyer UINT32 i;
596 1.3.2.2 bouyer BOOLEAN Found;
597 1.3.2.2 bouyer int NoMatch;
598 1.3.2.2 bouyer
599 1.3.2.2 bouyer
600 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
601 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
602 1.3.2.2 bouyer {
603 1.3.2.2 bouyer return (Status);
604 1.3.2.2 bouyer }
605 1.3.2.2 bouyer
606 1.3.2.2 bouyer Node = AcpiNsValidateHandle (ObjHandle);
607 1.3.2.2 bouyer Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
608 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
609 1.3.2.2 bouyer {
610 1.3.2.2 bouyer return (Status);
611 1.3.2.2 bouyer }
612 1.3.2.2 bouyer
613 1.3.2.2 bouyer if (!Node)
614 1.3.2.2 bouyer {
615 1.3.2.2 bouyer return (AE_BAD_PARAMETER);
616 1.3.2.2 bouyer }
617 1.3.2.2 bouyer
618 1.3.2.2 bouyer /*
619 1.3.2.2 bouyer * First, filter based on the device HID and CID.
620 1.3.2.2 bouyer *
621 1.3.2.2 bouyer * 01/2010: For this case where a specific HID is requested, we don't
622 1.3.2.2 bouyer * want to run _STA until we have an actual HID match. Thus, we will
623 1.3.2.2 bouyer * not unnecessarily execute _STA on devices for which the caller
624 1.3.2.2 bouyer * doesn't care about. Previously, _STA was executed unconditionally
625 1.3.2.2 bouyer * on all devices found here.
626 1.3.2.2 bouyer *
627 1.3.2.2 bouyer * A side-effect of this change is that now we will continue to search
628 1.3.2.2 bouyer * for a matching HID even under device trees where the parent device
629 1.3.2.2 bouyer * would have returned a _STA that indicates it is not present or
630 1.3.2.2 bouyer * not functioning (thus aborting the search on that branch).
631 1.3.2.2 bouyer */
632 1.3.2.2 bouyer if (Info->Hid != NULL)
633 1.3.2.2 bouyer {
634 1.3.2.2 bouyer Status = AcpiUtExecute_HID (Node, &Hid);
635 1.3.2.2 bouyer if (Status == AE_NOT_FOUND)
636 1.3.2.2 bouyer {
637 1.3.2.2 bouyer return (AE_OK);
638 1.3.2.2 bouyer }
639 1.3.2.2 bouyer else if (ACPI_FAILURE (Status))
640 1.3.2.2 bouyer {
641 1.3.2.2 bouyer return (AE_CTRL_DEPTH);
642 1.3.2.2 bouyer }
643 1.3.2.2 bouyer
644 1.3.2.2 bouyer NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
645 1.3.2.2 bouyer ACPI_FREE (Hid);
646 1.3.2.2 bouyer
647 1.3.2.2 bouyer if (NoMatch)
648 1.3.2.2 bouyer {
649 1.3.2.2 bouyer /*
650 1.3.2.2 bouyer * HID does not match, attempt match within the
651 1.3.2.2 bouyer * list of Compatible IDs (CIDs)
652 1.3.2.2 bouyer */
653 1.3.2.2 bouyer Status = AcpiUtExecute_CID (Node, &Cid);
654 1.3.2.2 bouyer if (Status == AE_NOT_FOUND)
655 1.3.2.2 bouyer {
656 1.3.2.2 bouyer return (AE_OK);
657 1.3.2.2 bouyer }
658 1.3.2.2 bouyer else if (ACPI_FAILURE (Status))
659 1.3.2.2 bouyer {
660 1.3.2.2 bouyer return (AE_CTRL_DEPTH);
661 1.3.2.2 bouyer }
662 1.3.2.2 bouyer
663 1.3.2.2 bouyer /* Walk the CID list */
664 1.3.2.2 bouyer
665 1.3.2.2 bouyer Found = FALSE;
666 1.3.2.2 bouyer for (i = 0; i < Cid->Count; i++)
667 1.3.2.2 bouyer {
668 1.3.2.2 bouyer if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0)
669 1.3.2.2 bouyer {
670 1.3.2.2 bouyer /* Found a matching CID */
671 1.3.2.2 bouyer
672 1.3.2.2 bouyer Found = TRUE;
673 1.3.2.2 bouyer break;
674 1.3.2.2 bouyer }
675 1.3.2.2 bouyer }
676 1.3.2.2 bouyer
677 1.3.2.2 bouyer ACPI_FREE (Cid);
678 1.3.2.2 bouyer if (!Found)
679 1.3.2.2 bouyer {
680 1.3.2.2 bouyer return (AE_OK);
681 1.3.2.2 bouyer }
682 1.3.2.2 bouyer }
683 1.3.2.2 bouyer }
684 1.3.2.2 bouyer
685 1.3.2.2 bouyer /* Run _STA to determine if device is present */
686 1.3.2.2 bouyer
687 1.3.2.2 bouyer Status = AcpiUtExecute_STA (Node, &Flags);
688 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
689 1.3.2.2 bouyer {
690 1.3.2.2 bouyer return (AE_CTRL_DEPTH);
691 1.3.2.2 bouyer }
692 1.3.2.2 bouyer
693 1.3.2.2 bouyer if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&
694 1.3.2.2 bouyer !(Flags & ACPI_STA_DEVICE_FUNCTIONING))
695 1.3.2.2 bouyer {
696 1.3.2.2 bouyer /*
697 1.3.2.2 bouyer * Don't examine the children of the device only when the
698 1.3.2.2 bouyer * device is neither present nor functional. See ACPI spec,
699 1.3.2.2 bouyer * description of _STA for more information.
700 1.3.2.2 bouyer */
701 1.3.2.2 bouyer return (AE_CTRL_DEPTH);
702 1.3.2.2 bouyer }
703 1.3.2.2 bouyer
704 1.3.2.2 bouyer /* We have a valid device, invoke the user function */
705 1.3.2.2 bouyer
706 1.3.2.2 bouyer Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context,
707 1.3.2.2 bouyer ReturnValue);
708 1.3.2.2 bouyer return (Status);
709 1.3.2.2 bouyer }
710 1.3.2.2 bouyer
711 1.3.2.2 bouyer
712 1.3.2.2 bouyer /*******************************************************************************
713 1.3.2.2 bouyer *
714 1.3.2.2 bouyer * FUNCTION: AcpiGetDevices
715 1.3.2.2 bouyer *
716 1.3.2.2 bouyer * PARAMETERS: HID - HID to search for. Can be NULL.
717 1.3.2.2 bouyer * UserFunction - Called when a matching object is found
718 1.3.2.2 bouyer * Context - Passed to user function
719 1.3.2.2 bouyer * ReturnValue - Location where return value of
720 1.3.2.2 bouyer * UserFunction is put if terminated early
721 1.3.2.2 bouyer *
722 1.3.2.2 bouyer * RETURNS Return value from the UserFunction if terminated early.
723 1.3.2.2 bouyer * Otherwise, returns NULL.
724 1.3.2.2 bouyer *
725 1.3.2.2 bouyer * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
726 1.3.2.2 bouyer * starting (and ending) at the object specified by StartHandle.
727 1.3.2.2 bouyer * The UserFunction is called whenever an object of type
728 1.3.2.2 bouyer * Device is found. If the user function returns
729 1.3.2.2 bouyer * a non-zero value, the search is terminated immediately and this
730 1.3.2.2 bouyer * value is returned to the caller.
731 1.3.2.2 bouyer *
732 1.3.2.2 bouyer * This is a wrapper for WalkNamespace, but the callback performs
733 1.3.2.2 bouyer * additional filtering. Please see AcpiNsGetDeviceCallback.
734 1.3.2.2 bouyer *
735 1.3.2.2 bouyer ******************************************************************************/
736 1.3.2.2 bouyer
737 1.3.2.2 bouyer ACPI_STATUS
738 1.3.2.2 bouyer AcpiGetDevices (
739 1.3.2.2 bouyer char *HID,
740 1.3.2.2 bouyer ACPI_WALK_CALLBACK UserFunction,
741 1.3.2.2 bouyer void *Context,
742 1.3.2.2 bouyer void **ReturnValue)
743 1.3.2.2 bouyer {
744 1.3.2.2 bouyer ACPI_STATUS Status;
745 1.3.2.2 bouyer ACPI_GET_DEVICES_INFO Info;
746 1.3.2.2 bouyer
747 1.3.2.2 bouyer
748 1.3.2.2 bouyer ACPI_FUNCTION_TRACE (AcpiGetDevices);
749 1.3.2.2 bouyer
750 1.3.2.2 bouyer
751 1.3.2.2 bouyer /* Parameter validation */
752 1.3.2.2 bouyer
753 1.3.2.2 bouyer if (!UserFunction)
754 1.3.2.2 bouyer {
755 1.3.2.2 bouyer return_ACPI_STATUS (AE_BAD_PARAMETER);
756 1.3.2.2 bouyer }
757 1.3.2.2 bouyer
758 1.3.2.2 bouyer /*
759 1.3.2.2 bouyer * We're going to call their callback from OUR callback, so we need
760 1.3.2.2 bouyer * to know what it is, and their context parameter.
761 1.3.2.2 bouyer */
762 1.3.2.2 bouyer Info.Hid = HID;
763 1.3.2.2 bouyer Info.Context = Context;
764 1.3.2.2 bouyer Info.UserFunction = UserFunction;
765 1.3.2.2 bouyer
766 1.3.2.2 bouyer /*
767 1.3.2.2 bouyer * Lock the namespace around the walk.
768 1.3.2.2 bouyer * The namespace will be unlocked/locked around each call
769 1.3.2.2 bouyer * to the user function - since this function
770 1.3.2.2 bouyer * must be allowed to make Acpi calls itself.
771 1.3.2.2 bouyer */
772 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
773 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
774 1.3.2.2 bouyer {
775 1.3.2.2 bouyer return_ACPI_STATUS (Status);
776 1.3.2.2 bouyer }
777 1.3.2.2 bouyer
778 1.3.2.2 bouyer Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
779 1.3.2.2 bouyer ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
780 1.3.2.2 bouyer AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
781 1.3.2.2 bouyer
782 1.3.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
783 1.3.2.2 bouyer return_ACPI_STATUS (Status);
784 1.3.2.2 bouyer }
785 1.3.2.2 bouyer
786 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiGetDevices)
787 1.3.2.2 bouyer
788 1.3.2.2 bouyer
789 1.3.2.2 bouyer /*******************************************************************************
790 1.3.2.2 bouyer *
791 1.3.2.2 bouyer * FUNCTION: AcpiAttachData
792 1.3.2.2 bouyer *
793 1.3.2.2 bouyer * PARAMETERS: ObjHandle - Namespace node
794 1.3.2.2 bouyer * Handler - Handler for this attachment
795 1.3.2.2 bouyer * Data - Pointer to data to be attached
796 1.3.2.2 bouyer *
797 1.3.2.2 bouyer * RETURN: Status
798 1.3.2.2 bouyer *
799 1.3.2.2 bouyer * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
800 1.3.2.2 bouyer *
801 1.3.2.2 bouyer ******************************************************************************/
802 1.3.2.2 bouyer
803 1.3.2.2 bouyer ACPI_STATUS
804 1.3.2.2 bouyer AcpiAttachData (
805 1.3.2.2 bouyer ACPI_HANDLE ObjHandle,
806 1.3.2.2 bouyer ACPI_OBJECT_HANDLER Handler,
807 1.3.2.2 bouyer void *Data)
808 1.3.2.2 bouyer {
809 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
810 1.3.2.2 bouyer ACPI_STATUS Status;
811 1.3.2.2 bouyer
812 1.3.2.2 bouyer
813 1.3.2.2 bouyer /* Parameter validation */
814 1.3.2.2 bouyer
815 1.3.2.2 bouyer if (!ObjHandle ||
816 1.3.2.2 bouyer !Handler ||
817 1.3.2.2 bouyer !Data)
818 1.3.2.2 bouyer {
819 1.3.2.2 bouyer return (AE_BAD_PARAMETER);
820 1.3.2.2 bouyer }
821 1.3.2.2 bouyer
822 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
823 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
824 1.3.2.2 bouyer {
825 1.3.2.2 bouyer return (Status);
826 1.3.2.2 bouyer }
827 1.3.2.2 bouyer
828 1.3.2.2 bouyer /* Convert and validate the handle */
829 1.3.2.2 bouyer
830 1.3.2.2 bouyer Node = AcpiNsValidateHandle (ObjHandle);
831 1.3.2.2 bouyer if (!Node)
832 1.3.2.2 bouyer {
833 1.3.2.2 bouyer Status = AE_BAD_PARAMETER;
834 1.3.2.2 bouyer goto UnlockAndExit;
835 1.3.2.2 bouyer }
836 1.3.2.2 bouyer
837 1.3.2.2 bouyer Status = AcpiNsAttachData (Node, Handler, Data);
838 1.3.2.2 bouyer
839 1.3.2.2 bouyer UnlockAndExit:
840 1.3.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
841 1.3.2.2 bouyer return (Status);
842 1.3.2.2 bouyer }
843 1.3.2.2 bouyer
844 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiAttachData)
845 1.3.2.2 bouyer
846 1.3.2.2 bouyer
847 1.3.2.2 bouyer /*******************************************************************************
848 1.3.2.2 bouyer *
849 1.3.2.2 bouyer * FUNCTION: AcpiDetachData
850 1.3.2.2 bouyer *
851 1.3.2.2 bouyer * PARAMETERS: ObjHandle - Namespace node handle
852 1.3.2.2 bouyer * Handler - Handler used in call to AcpiAttachData
853 1.3.2.2 bouyer *
854 1.3.2.2 bouyer * RETURN: Status
855 1.3.2.2 bouyer *
856 1.3.2.2 bouyer * DESCRIPTION: Remove data that was previously attached to a node.
857 1.3.2.2 bouyer *
858 1.3.2.2 bouyer ******************************************************************************/
859 1.3.2.2 bouyer
860 1.3.2.2 bouyer ACPI_STATUS
861 1.3.2.2 bouyer AcpiDetachData (
862 1.3.2.2 bouyer ACPI_HANDLE ObjHandle,
863 1.3.2.2 bouyer ACPI_OBJECT_HANDLER Handler)
864 1.3.2.2 bouyer {
865 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
866 1.3.2.2 bouyer ACPI_STATUS Status;
867 1.3.2.2 bouyer
868 1.3.2.2 bouyer
869 1.3.2.2 bouyer /* Parameter validation */
870 1.3.2.2 bouyer
871 1.3.2.2 bouyer if (!ObjHandle ||
872 1.3.2.2 bouyer !Handler)
873 1.3.2.2 bouyer {
874 1.3.2.2 bouyer return (AE_BAD_PARAMETER);
875 1.3.2.2 bouyer }
876 1.3.2.2 bouyer
877 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
878 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
879 1.3.2.2 bouyer {
880 1.3.2.2 bouyer return (Status);
881 1.3.2.2 bouyer }
882 1.3.2.2 bouyer
883 1.3.2.2 bouyer /* Convert and validate the handle */
884 1.3.2.2 bouyer
885 1.3.2.2 bouyer Node = AcpiNsValidateHandle (ObjHandle);
886 1.3.2.2 bouyer if (!Node)
887 1.3.2.2 bouyer {
888 1.3.2.2 bouyer Status = AE_BAD_PARAMETER;
889 1.3.2.2 bouyer goto UnlockAndExit;
890 1.3.2.2 bouyer }
891 1.3.2.2 bouyer
892 1.3.2.2 bouyer Status = AcpiNsDetachData (Node, Handler);
893 1.3.2.2 bouyer
894 1.3.2.2 bouyer UnlockAndExit:
895 1.3.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
896 1.3.2.2 bouyer return (Status);
897 1.3.2.2 bouyer }
898 1.3.2.2 bouyer
899 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiDetachData)
900 1.3.2.2 bouyer
901 1.3.2.2 bouyer
902 1.3.2.2 bouyer /*******************************************************************************
903 1.3.2.2 bouyer *
904 1.3.2.2 bouyer * FUNCTION: AcpiGetData
905 1.3.2.2 bouyer *
906 1.3.2.2 bouyer * PARAMETERS: ObjHandle - Namespace node
907 1.3.2.2 bouyer * Handler - Handler used in call to AttachData
908 1.3.2.2 bouyer * Data - Where the data is returned
909 1.3.2.2 bouyer *
910 1.3.2.2 bouyer * RETURN: Status
911 1.3.2.2 bouyer *
912 1.3.2.2 bouyer * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
913 1.3.2.2 bouyer *
914 1.3.2.2 bouyer ******************************************************************************/
915 1.3.2.2 bouyer
916 1.3.2.2 bouyer ACPI_STATUS
917 1.3.2.2 bouyer AcpiGetData (
918 1.3.2.2 bouyer ACPI_HANDLE ObjHandle,
919 1.3.2.2 bouyer ACPI_OBJECT_HANDLER Handler,
920 1.3.2.2 bouyer void **Data)
921 1.3.2.2 bouyer {
922 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
923 1.3.2.2 bouyer ACPI_STATUS Status;
924 1.3.2.2 bouyer
925 1.3.2.2 bouyer
926 1.3.2.2 bouyer /* Parameter validation */
927 1.3.2.2 bouyer
928 1.3.2.2 bouyer if (!ObjHandle ||
929 1.3.2.2 bouyer !Handler ||
930 1.3.2.2 bouyer !Data)
931 1.3.2.2 bouyer {
932 1.3.2.2 bouyer return (AE_BAD_PARAMETER);
933 1.3.2.2 bouyer }
934 1.3.2.2 bouyer
935 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
936 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
937 1.3.2.2 bouyer {
938 1.3.2.2 bouyer return (Status);
939 1.3.2.2 bouyer }
940 1.3.2.2 bouyer
941 1.3.2.2 bouyer /* Convert and validate the handle */
942 1.3.2.2 bouyer
943 1.3.2.2 bouyer Node = AcpiNsValidateHandle (ObjHandle);
944 1.3.2.2 bouyer if (!Node)
945 1.3.2.2 bouyer {
946 1.3.2.2 bouyer Status = AE_BAD_PARAMETER;
947 1.3.2.2 bouyer goto UnlockAndExit;
948 1.3.2.2 bouyer }
949 1.3.2.2 bouyer
950 1.3.2.2 bouyer Status = AcpiNsGetAttachedData (Node, Handler, Data);
951 1.3.2.2 bouyer
952 1.3.2.2 bouyer UnlockAndExit:
953 1.3.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
954 1.3.2.2 bouyer return (Status);
955 1.3.2.2 bouyer }
956 1.3.2.2 bouyer
957 1.3.2.2 bouyer ACPI_EXPORT_SYMBOL (AcpiGetData)
958 1.3.2.2 bouyer
959 1.3.2.2 bouyer
960