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