nsxfeval.c revision 1.5.2.3 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.4 christos #if 0
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
314 1.4 christos switch (AcpiNsGetType (Info->Node))
315 1.1 jruoho {
316 1.4 christos case ACPI_TYPE_METHOD:
317 1.4 christos
318 1.4 christos /* Check incoming argument count against the method definition */
319 1.4 christos
320 1.4 christos if (Info->ObjDesc->Method.ParamCount > Info->ParamCount)
321 1.4 christos {
322 1.4 christos ACPI_ERROR ((AE_INFO,
323 1.4 christos "Insufficient arguments (%u) - %u are required",
324 1.4 christos Info->ParamCount,
325 1.4 christos Info->ObjDesc->Method.ParamCount));
326 1.4 christos
327 1.4 christos Status = AE_MISSING_ARGUMENTS;
328 1.4 christos goto Cleanup;
329 1.4 christos }
330 1.4 christos
331 1.4 christos else if (Info->ObjDesc->Method.ParamCount < Info->ParamCount)
332 1.4 christos {
333 1.4 christos ACPI_WARNING ((AE_INFO,
334 1.4 christos "Excess arguments (%u) - only %u are required",
335 1.4 christos Info->ParamCount,
336 1.4 christos Info->ObjDesc->Method.ParamCount));
337 1.4 christos
338 1.4 christos /* Just pass the required number of arguments */
339 1.4 christos
340 1.4 christos Info->ParamCount = Info->ObjDesc->Method.ParamCount;
341 1.4 christos }
342 1.1 jruoho
343 1.1 jruoho /*
344 1.4 christos * Any incoming external objects to be passed as arguments to the
345 1.4 christos * method must be converted to internal objects
346 1.1 jruoho */
347 1.4 christos if (Info->ParamCount)
348 1.1 jruoho {
349 1.4 christos /*
350 1.4 christos * Allocate a new parameter block for the internal objects
351 1.4 christos * Add 1 to count to allow for null terminated internal list
352 1.4 christos */
353 1.4 christos Info->Parameters = ACPI_ALLOCATE_ZEROED (
354 1.4 christos ((ACPI_SIZE) Info->ParamCount + 1) * sizeof (void *));
355 1.4 christos if (!Info->Parameters)
356 1.4 christos {
357 1.4 christos Status = AE_NO_MEMORY;
358 1.4 christos goto Cleanup;
359 1.4 christos }
360 1.4 christos
361 1.4 christos /* Convert each external object in the list to an internal object */
362 1.4 christos
363 1.4 christos for (i = 0; i < Info->ParamCount; i++)
364 1.4 christos {
365 1.4 christos Status = AcpiUtCopyEobjectToIobject (
366 1.4 christos &ExternalParams->Pointer[i], &Info->Parameters[i]);
367 1.4 christos if (ACPI_FAILURE (Status))
368 1.4 christos {
369 1.4 christos goto Cleanup;
370 1.4 christos }
371 1.4 christos }
372 1.4 christos
373 1.4 christos Info->Parameters[Info->ParamCount] = NULL;
374 1.1 jruoho }
375 1.4 christos break;
376 1.4 christos
377 1.4 christos default:
378 1.4 christos
379 1.4 christos /* Warn if arguments passed to an object that is not a method */
380 1.4 christos
381 1.4 christos if (Info->ParamCount)
382 1.1 jruoho {
383 1.4 christos ACPI_WARNING ((AE_INFO,
384 1.4 christos "%u arguments were passed to a non-method ACPI object",
385 1.4 christos Info->ParamCount));
386 1.1 jruoho }
387 1.4 christos break;
388 1.4 christos }
389 1.1 jruoho
390 1.4 christos #endif
391 1.4 christos
392 1.4 christos
393 1.4 christos /* Now we can evaluate the object */
394 1.1 jruoho
395 1.4 christos Status = AcpiNsEvaluate (Info);
396 1.1 jruoho
397 1.1 jruoho /*
398 1.1 jruoho * If we are expecting a return value, and all went well above,
399 1.1 jruoho * copy the return value to an external object.
400 1.1 jruoho */
401 1.1 jruoho if (ReturnBuffer)
402 1.1 jruoho {
403 1.1 jruoho if (!Info->ReturnObject)
404 1.1 jruoho {
405 1.1 jruoho ReturnBuffer->Length = 0;
406 1.1 jruoho }
407 1.1 jruoho else
408 1.1 jruoho {
409 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
410 1.1 jruoho ACPI_DESC_TYPE_NAMED)
411 1.1 jruoho {
412 1.1 jruoho /*
413 1.1 jruoho * If we received a NS Node as a return object, this means that
414 1.1 jruoho * the object we are evaluating has nothing interesting to
415 1.1 jruoho * return (such as a mutex, etc.) We return an error because
416 1.1 jruoho * these types are essentially unsupported by this interface.
417 1.1 jruoho * We don't check up front because this makes it easier to add
418 1.1 jruoho * support for various types at a later date if necessary.
419 1.1 jruoho */
420 1.1 jruoho Status = AE_TYPE;
421 1.1 jruoho Info->ReturnObject = NULL; /* No need to delete a NS Node */
422 1.1 jruoho ReturnBuffer->Length = 0;
423 1.1 jruoho }
424 1.1 jruoho
425 1.1 jruoho if (ACPI_SUCCESS (Status))
426 1.1 jruoho {
427 1.1 jruoho /* Dereference Index and RefOf references */
428 1.1 jruoho
429 1.1 jruoho AcpiNsResolveReferences (Info);
430 1.1 jruoho
431 1.1 jruoho /* Get the size of the returned object */
432 1.1 jruoho
433 1.1 jruoho Status = AcpiUtGetObjectSize (Info->ReturnObject,
434 1.5.2.3 skrll &BufferSpaceNeeded);
435 1.1 jruoho if (ACPI_SUCCESS (Status))
436 1.1 jruoho {
437 1.1 jruoho /* Validate/Allocate/Clear caller buffer */
438 1.1 jruoho
439 1.1 jruoho Status = AcpiUtInitializeBuffer (ReturnBuffer,
440 1.5.2.3 skrll BufferSpaceNeeded);
441 1.1 jruoho if (ACPI_FAILURE (Status))
442 1.1 jruoho {
443 1.1 jruoho /*
444 1.1 jruoho * Caller's buffer is too small or a new one can't
445 1.1 jruoho * be allocated
446 1.1 jruoho */
447 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
448 1.1 jruoho "Needed buffer size %X, %s\n",
449 1.1 jruoho (UINT32) BufferSpaceNeeded,
450 1.1 jruoho AcpiFormatException (Status)));
451 1.1 jruoho }
452 1.1 jruoho else
453 1.1 jruoho {
454 1.1 jruoho /* We have enough space for the object, build it */
455 1.1 jruoho
456 1.5.2.3 skrll Status = AcpiUtCopyIobjectToEobject (
457 1.5.2.3 skrll Info->ReturnObject, ReturnBuffer);
458 1.1 jruoho }
459 1.1 jruoho }
460 1.1 jruoho }
461 1.1 jruoho }
462 1.1 jruoho }
463 1.1 jruoho
464 1.1 jruoho if (Info->ReturnObject)
465 1.1 jruoho {
466 1.1 jruoho /*
467 1.1 jruoho * Delete the internal return object. NOTE: Interpreter must be
468 1.1 jruoho * locked to avoid race condition.
469 1.1 jruoho */
470 1.1 jruoho AcpiExEnterInterpreter ();
471 1.1 jruoho
472 1.1 jruoho /* Remove one reference on the return object (should delete it) */
473 1.1 jruoho
474 1.1 jruoho AcpiUtRemoveReference (Info->ReturnObject);
475 1.1 jruoho AcpiExExitInterpreter ();
476 1.1 jruoho }
477 1.1 jruoho
478 1.1 jruoho
479 1.1 jruoho Cleanup:
480 1.1 jruoho
481 1.1 jruoho /* Free the input parameter list (if we created one) */
482 1.1 jruoho
483 1.1 jruoho if (Info->Parameters)
484 1.1 jruoho {
485 1.1 jruoho /* Free the allocated parameter block */
486 1.1 jruoho
487 1.1 jruoho AcpiUtDeleteInternalObjectList (Info->Parameters);
488 1.1 jruoho }
489 1.1 jruoho
490 1.1 jruoho ACPI_FREE (Info);
491 1.1 jruoho return_ACPI_STATUS (Status);
492 1.1 jruoho }
493 1.1 jruoho
494 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiEvaluateObject)
495 1.1 jruoho
496 1.1 jruoho
497 1.1 jruoho /*******************************************************************************
498 1.1 jruoho *
499 1.1 jruoho * FUNCTION: AcpiNsResolveReferences
500 1.1 jruoho *
501 1.1 jruoho * PARAMETERS: Info - Evaluation info block
502 1.1 jruoho *
503 1.1 jruoho * RETURN: Info->ReturnObject is replaced with the dereferenced object
504 1.1 jruoho *
505 1.1 jruoho * DESCRIPTION: Dereference certain reference objects. Called before an
506 1.1 jruoho * internal return object is converted to an external ACPI_OBJECT.
507 1.1 jruoho *
508 1.1 jruoho * Performs an automatic dereference of Index and RefOf reference objects.
509 1.1 jruoho * These reference objects are not supported by the ACPI_OBJECT, so this is a
510 1.1 jruoho * last resort effort to return something useful. Also, provides compatibility
511 1.1 jruoho * with other ACPI implementations.
512 1.1 jruoho *
513 1.1 jruoho * NOTE: does not handle references within returned package objects or nested
514 1.1 jruoho * references, but this support could be added later if found to be necessary.
515 1.1 jruoho *
516 1.1 jruoho ******************************************************************************/
517 1.1 jruoho
518 1.1 jruoho static void
519 1.1 jruoho AcpiNsResolveReferences (
520 1.1 jruoho ACPI_EVALUATE_INFO *Info)
521 1.1 jruoho {
522 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc = NULL;
523 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
524 1.1 jruoho
525 1.1 jruoho
526 1.1 jruoho /* We are interested in reference objects only */
527 1.1 jruoho
528 1.1 jruoho if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
529 1.1 jruoho {
530 1.1 jruoho return;
531 1.1 jruoho }
532 1.1 jruoho
533 1.1 jruoho /*
534 1.1 jruoho * Two types of references are supported - those created by Index and
535 1.1 jruoho * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
536 1.1 jruoho * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
537 1.1 jruoho * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
538 1.1 jruoho * an ACPI_OBJECT.
539 1.1 jruoho */
540 1.1 jruoho switch (Info->ReturnObject->Reference.Class)
541 1.1 jruoho {
542 1.1 jruoho case ACPI_REFCLASS_INDEX:
543 1.1 jruoho
544 1.1 jruoho ObjDesc = *(Info->ReturnObject->Reference.Where);
545 1.1 jruoho break;
546 1.1 jruoho
547 1.1 jruoho case ACPI_REFCLASS_REFOF:
548 1.1 jruoho
549 1.1 jruoho Node = Info->ReturnObject->Reference.Object;
550 1.1 jruoho if (Node)
551 1.1 jruoho {
552 1.1 jruoho ObjDesc = Node->Object;
553 1.1 jruoho }
554 1.1 jruoho break;
555 1.1 jruoho
556 1.1 jruoho default:
557 1.4 christos
558 1.1 jruoho return;
559 1.1 jruoho }
560 1.1 jruoho
561 1.1 jruoho /* Replace the existing reference object */
562 1.1 jruoho
563 1.1 jruoho if (ObjDesc)
564 1.1 jruoho {
565 1.1 jruoho AcpiUtAddReference (ObjDesc);
566 1.1 jruoho AcpiUtRemoveReference (Info->ReturnObject);
567 1.1 jruoho Info->ReturnObject = ObjDesc;
568 1.1 jruoho }
569 1.1 jruoho
570 1.1 jruoho return;
571 1.1 jruoho }
572 1.1 jruoho
573 1.1 jruoho
574 1.1 jruoho /*******************************************************************************
575 1.1 jruoho *
576 1.1 jruoho * FUNCTION: AcpiWalkNamespace
577 1.1 jruoho *
578 1.1 jruoho * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
579 1.1 jruoho * StartObject - Handle in namespace where search begins
580 1.1 jruoho * MaxDepth - Depth to which search is to reach
581 1.4 christos * DescendingCallback - Called during tree descent
582 1.1 jruoho * when an object of "Type" is found
583 1.4 christos * AscendingCallback - Called during tree ascent
584 1.1 jruoho * when an object of "Type" is found
585 1.1 jruoho * Context - Passed to user function(s) above
586 1.1 jruoho * ReturnValue - Location where return value of
587 1.1 jruoho * UserFunction is put if terminated early
588 1.1 jruoho *
589 1.1 jruoho * RETURNS Return value from the UserFunction if terminated early.
590 1.1 jruoho * Otherwise, returns NULL.
591 1.1 jruoho *
592 1.1 jruoho * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
593 1.1 jruoho * starting (and ending) at the object specified by StartHandle.
594 1.1 jruoho * The callback function is called whenever an object that matches
595 1.1 jruoho * the type parameter is found. If the callback function returns
596 1.1 jruoho * a non-zero value, the search is terminated immediately and this
597 1.1 jruoho * value is returned to the caller.
598 1.1 jruoho *
599 1.1 jruoho * The point of this procedure is to provide a generic namespace
600 1.1 jruoho * walk routine that can be called from multiple places to
601 1.1 jruoho * provide multiple services; the callback function(s) can be
602 1.1 jruoho * tailored to each task, whether it is a print function,
603 1.1 jruoho * a compare function, etc.
604 1.1 jruoho *
605 1.1 jruoho ******************************************************************************/
606 1.1 jruoho
607 1.1 jruoho ACPI_STATUS
608 1.1 jruoho AcpiWalkNamespace (
609 1.1 jruoho ACPI_OBJECT_TYPE Type,
610 1.1 jruoho ACPI_HANDLE StartObject,
611 1.1 jruoho UINT32 MaxDepth,
612 1.4 christos ACPI_WALK_CALLBACK DescendingCallback,
613 1.4 christos ACPI_WALK_CALLBACK AscendingCallback,
614 1.1 jruoho void *Context,
615 1.1 jruoho void **ReturnValue)
616 1.1 jruoho {
617 1.1 jruoho ACPI_STATUS Status;
618 1.1 jruoho
619 1.1 jruoho
620 1.1 jruoho ACPI_FUNCTION_TRACE (AcpiWalkNamespace);
621 1.1 jruoho
622 1.1 jruoho
623 1.1 jruoho /* Parameter validation */
624 1.1 jruoho
625 1.1 jruoho if ((Type > ACPI_TYPE_LOCAL_MAX) ||
626 1.1 jruoho (!MaxDepth) ||
627 1.4 christos (!DescendingCallback && !AscendingCallback))
628 1.1 jruoho {
629 1.1 jruoho return_ACPI_STATUS (AE_BAD_PARAMETER);
630 1.1 jruoho }
631 1.1 jruoho
632 1.1 jruoho /*
633 1.1 jruoho * Need to acquire the namespace reader lock to prevent interference
634 1.1 jruoho * with any concurrent table unloads (which causes the deletion of
635 1.1 jruoho * namespace objects). We cannot allow the deletion of a namespace node
636 1.1 jruoho * while the user function is using it. The exception to this are the
637 1.1 jruoho * nodes created and deleted during control method execution -- these
638 1.1 jruoho * nodes are marked as temporary nodes and are ignored by the namespace
639 1.1 jruoho * walk. Thus, control methods can be executed while holding the
640 1.1 jruoho * namespace deletion lock (and the user function can execute control
641 1.1 jruoho * methods.)
642 1.1 jruoho */
643 1.1 jruoho Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock);
644 1.1 jruoho if (ACPI_FAILURE (Status))
645 1.1 jruoho {
646 1.4 christos return_ACPI_STATUS (Status);
647 1.1 jruoho }
648 1.1 jruoho
649 1.1 jruoho /*
650 1.1 jruoho * Lock the namespace around the walk. The namespace will be
651 1.1 jruoho * unlocked/locked around each call to the user function - since the user
652 1.1 jruoho * function must be allowed to make ACPICA calls itself (for example, it
653 1.1 jruoho * will typically execute control methods during device enumeration.)
654 1.1 jruoho */
655 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
656 1.1 jruoho if (ACPI_FAILURE (Status))
657 1.1 jruoho {
658 1.1 jruoho goto UnlockAndExit;
659 1.1 jruoho }
660 1.1 jruoho
661 1.4 christos /* Now we can validate the starting node */
662 1.4 christos
663 1.4 christos if (!AcpiNsValidateHandle (StartObject))
664 1.4 christos {
665 1.4 christos Status = AE_BAD_PARAMETER;
666 1.4 christos goto UnlockAndExit2;
667 1.4 christos }
668 1.4 christos
669 1.1 jruoho Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth,
670 1.5.2.3 skrll ACPI_NS_WALK_UNLOCK, DescendingCallback,
671 1.5.2.3 skrll AscendingCallback, Context, ReturnValue);
672 1.1 jruoho
673 1.4 christos UnlockAndExit2:
674 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
675 1.1 jruoho
676 1.1 jruoho UnlockAndExit:
677 1.1 jruoho (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock);
678 1.1 jruoho return_ACPI_STATUS (Status);
679 1.1 jruoho }
680 1.1 jruoho
681 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiWalkNamespace)
682 1.1 jruoho
683 1.1 jruoho
684 1.1 jruoho /*******************************************************************************
685 1.1 jruoho *
686 1.1 jruoho * FUNCTION: AcpiNsGetDeviceCallback
687 1.1 jruoho *
688 1.1 jruoho * PARAMETERS: Callback from AcpiGetDevice
689 1.1 jruoho *
690 1.1 jruoho * RETURN: Status
691 1.1 jruoho *
692 1.1 jruoho * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
693 1.1 jruoho * present devices, or if they specified a HID, it filters based
694 1.1 jruoho * on that.
695 1.1 jruoho *
696 1.1 jruoho ******************************************************************************/
697 1.1 jruoho
698 1.1 jruoho static ACPI_STATUS
699 1.1 jruoho AcpiNsGetDeviceCallback (
700 1.1 jruoho ACPI_HANDLE ObjHandle,
701 1.1 jruoho UINT32 NestingLevel,
702 1.1 jruoho void *Context,
703 1.1 jruoho void **ReturnValue)
704 1.1 jruoho {
705 1.1 jruoho ACPI_GET_DEVICES_INFO *Info = Context;
706 1.1 jruoho ACPI_STATUS Status;
707 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
708 1.1 jruoho UINT32 Flags;
709 1.4 christos ACPI_PNP_DEVICE_ID *Hid;
710 1.4 christos ACPI_PNP_DEVICE_ID_LIST *Cid;
711 1.1 jruoho UINT32 i;
712 1.1 jruoho BOOLEAN Found;
713 1.1 jruoho int NoMatch;
714 1.1 jruoho
715 1.1 jruoho
716 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
717 1.1 jruoho if (ACPI_FAILURE (Status))
718 1.1 jruoho {
719 1.1 jruoho return (Status);
720 1.1 jruoho }
721 1.1 jruoho
722 1.1 jruoho Node = AcpiNsValidateHandle (ObjHandle);
723 1.1 jruoho Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
724 1.1 jruoho if (ACPI_FAILURE (Status))
725 1.1 jruoho {
726 1.1 jruoho return (Status);
727 1.1 jruoho }
728 1.1 jruoho
729 1.1 jruoho if (!Node)
730 1.1 jruoho {
731 1.1 jruoho return (AE_BAD_PARAMETER);
732 1.1 jruoho }
733 1.1 jruoho
734 1.1 jruoho /*
735 1.1 jruoho * First, filter based on the device HID and CID.
736 1.1 jruoho *
737 1.1 jruoho * 01/2010: For this case where a specific HID is requested, we don't
738 1.1 jruoho * want to run _STA until we have an actual HID match. Thus, we will
739 1.1 jruoho * not unnecessarily execute _STA on devices for which the caller
740 1.1 jruoho * doesn't care about. Previously, _STA was executed unconditionally
741 1.1 jruoho * on all devices found here.
742 1.1 jruoho *
743 1.1 jruoho * A side-effect of this change is that now we will continue to search
744 1.1 jruoho * for a matching HID even under device trees where the parent device
745 1.1 jruoho * would have returned a _STA that indicates it is not present or
746 1.1 jruoho * not functioning (thus aborting the search on that branch).
747 1.1 jruoho */
748 1.1 jruoho if (Info->Hid != NULL)
749 1.1 jruoho {
750 1.1 jruoho Status = AcpiUtExecute_HID (Node, &Hid);
751 1.1 jruoho if (Status == AE_NOT_FOUND)
752 1.1 jruoho {
753 1.1 jruoho return (AE_OK);
754 1.1 jruoho }
755 1.1 jruoho else if (ACPI_FAILURE (Status))
756 1.1 jruoho {
757 1.1 jruoho return (AE_CTRL_DEPTH);
758 1.1 jruoho }
759 1.1 jruoho
760 1.5.2.2 skrll NoMatch = strcmp (Hid->String, Info->Hid);
761 1.1 jruoho ACPI_FREE (Hid);
762 1.1 jruoho
763 1.1 jruoho if (NoMatch)
764 1.1 jruoho {
765 1.1 jruoho /*
766 1.1 jruoho * HID does not match, attempt match within the
767 1.1 jruoho * list of Compatible IDs (CIDs)
768 1.1 jruoho */
769 1.1 jruoho Status = AcpiUtExecute_CID (Node, &Cid);
770 1.1 jruoho if (Status == AE_NOT_FOUND)
771 1.1 jruoho {
772 1.1 jruoho return (AE_OK);
773 1.1 jruoho }
774 1.1 jruoho else if (ACPI_FAILURE (Status))
775 1.1 jruoho {
776 1.1 jruoho return (AE_CTRL_DEPTH);
777 1.1 jruoho }
778 1.1 jruoho
779 1.1 jruoho /* Walk the CID list */
780 1.1 jruoho
781 1.1 jruoho Found = FALSE;
782 1.1 jruoho for (i = 0; i < Cid->Count; i++)
783 1.1 jruoho {
784 1.5.2.2 skrll if (strcmp (Cid->Ids[i].String, Info->Hid) == 0)
785 1.1 jruoho {
786 1.1 jruoho /* Found a matching CID */
787 1.1 jruoho
788 1.1 jruoho Found = TRUE;
789 1.1 jruoho break;
790 1.1 jruoho }
791 1.1 jruoho }
792 1.1 jruoho
793 1.1 jruoho ACPI_FREE (Cid);
794 1.1 jruoho if (!Found)
795 1.1 jruoho {
796 1.1 jruoho return (AE_OK);
797 1.1 jruoho }
798 1.1 jruoho }
799 1.1 jruoho }
800 1.1 jruoho
801 1.1 jruoho /* Run _STA to determine if device is present */
802 1.1 jruoho
803 1.1 jruoho Status = AcpiUtExecute_STA (Node, &Flags);
804 1.1 jruoho if (ACPI_FAILURE (Status))
805 1.1 jruoho {
806 1.1 jruoho return (AE_CTRL_DEPTH);
807 1.1 jruoho }
808 1.1 jruoho
809 1.1 jruoho if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&
810 1.1 jruoho !(Flags & ACPI_STA_DEVICE_FUNCTIONING))
811 1.1 jruoho {
812 1.1 jruoho /*
813 1.1 jruoho * Don't examine the children of the device only when the
814 1.1 jruoho * device is neither present nor functional. See ACPI spec,
815 1.1 jruoho * description of _STA for more information.
816 1.1 jruoho */
817 1.1 jruoho return (AE_CTRL_DEPTH);
818 1.1 jruoho }
819 1.1 jruoho
820 1.1 jruoho /* We have a valid device, invoke the user function */
821 1.1 jruoho
822 1.5.2.3 skrll Status = Info->UserFunction (ObjHandle, NestingLevel,
823 1.5.2.3 skrll Info->Context, ReturnValue);
824 1.1 jruoho return (Status);
825 1.1 jruoho }
826 1.1 jruoho
827 1.1 jruoho
828 1.1 jruoho /*******************************************************************************
829 1.1 jruoho *
830 1.1 jruoho * FUNCTION: AcpiGetDevices
831 1.1 jruoho *
832 1.1 jruoho * PARAMETERS: HID - HID to search for. Can be NULL.
833 1.1 jruoho * UserFunction - Called when a matching object is found
834 1.1 jruoho * Context - Passed to user function
835 1.1 jruoho * ReturnValue - Location where return value of
836 1.1 jruoho * UserFunction is put if terminated early
837 1.1 jruoho *
838 1.1 jruoho * RETURNS Return value from the UserFunction if terminated early.
839 1.1 jruoho * Otherwise, returns NULL.
840 1.1 jruoho *
841 1.1 jruoho * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
842 1.1 jruoho * starting (and ending) at the object specified by StartHandle.
843 1.1 jruoho * The UserFunction is called whenever an object of type
844 1.4 christos * Device is found. If the user function returns
845 1.1 jruoho * a non-zero value, the search is terminated immediately and this
846 1.1 jruoho * value is returned to the caller.
847 1.1 jruoho *
848 1.1 jruoho * This is a wrapper for WalkNamespace, but the callback performs
849 1.1 jruoho * additional filtering. Please see AcpiNsGetDeviceCallback.
850 1.1 jruoho *
851 1.1 jruoho ******************************************************************************/
852 1.1 jruoho
853 1.1 jruoho ACPI_STATUS
854 1.1 jruoho AcpiGetDevices (
855 1.1 jruoho char *HID,
856 1.1 jruoho ACPI_WALK_CALLBACK UserFunction,
857 1.1 jruoho void *Context,
858 1.1 jruoho void **ReturnValue)
859 1.1 jruoho {
860 1.1 jruoho ACPI_STATUS Status;
861 1.1 jruoho ACPI_GET_DEVICES_INFO Info;
862 1.1 jruoho
863 1.1 jruoho
864 1.1 jruoho ACPI_FUNCTION_TRACE (AcpiGetDevices);
865 1.1 jruoho
866 1.1 jruoho
867 1.1 jruoho /* Parameter validation */
868 1.1 jruoho
869 1.1 jruoho if (!UserFunction)
870 1.1 jruoho {
871 1.1 jruoho return_ACPI_STATUS (AE_BAD_PARAMETER);
872 1.1 jruoho }
873 1.1 jruoho
874 1.1 jruoho /*
875 1.1 jruoho * We're going to call their callback from OUR callback, so we need
876 1.1 jruoho * to know what it is, and their context parameter.
877 1.1 jruoho */
878 1.5.2.3 skrll Info.Hid = HID;
879 1.5.2.3 skrll Info.Context = Context;
880 1.1 jruoho Info.UserFunction = UserFunction;
881 1.1 jruoho
882 1.1 jruoho /*
883 1.1 jruoho * Lock the namespace around the walk.
884 1.1 jruoho * The namespace will be unlocked/locked around each call
885 1.1 jruoho * to the user function - since this function
886 1.1 jruoho * must be allowed to make Acpi calls itself.
887 1.1 jruoho */
888 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
889 1.1 jruoho if (ACPI_FAILURE (Status))
890 1.1 jruoho {
891 1.1 jruoho return_ACPI_STATUS (Status);
892 1.1 jruoho }
893 1.1 jruoho
894 1.1 jruoho Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
895 1.5.2.3 skrll ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
896 1.5.2.3 skrll AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
897 1.1 jruoho
898 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
899 1.1 jruoho return_ACPI_STATUS (Status);
900 1.1 jruoho }
901 1.1 jruoho
902 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiGetDevices)
903 1.1 jruoho
904 1.1 jruoho
905 1.1 jruoho /*******************************************************************************
906 1.1 jruoho *
907 1.1 jruoho * FUNCTION: AcpiAttachData
908 1.1 jruoho *
909 1.1 jruoho * PARAMETERS: ObjHandle - Namespace node
910 1.1 jruoho * Handler - Handler for this attachment
911 1.1 jruoho * Data - Pointer to data to be attached
912 1.1 jruoho *
913 1.1 jruoho * RETURN: Status
914 1.1 jruoho *
915 1.1 jruoho * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
916 1.1 jruoho *
917 1.1 jruoho ******************************************************************************/
918 1.1 jruoho
919 1.1 jruoho ACPI_STATUS
920 1.1 jruoho AcpiAttachData (
921 1.1 jruoho ACPI_HANDLE ObjHandle,
922 1.1 jruoho ACPI_OBJECT_HANDLER Handler,
923 1.1 jruoho void *Data)
924 1.1 jruoho {
925 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
926 1.1 jruoho ACPI_STATUS Status;
927 1.1 jruoho
928 1.1 jruoho
929 1.1 jruoho /* Parameter validation */
930 1.1 jruoho
931 1.1 jruoho if (!ObjHandle ||
932 1.1 jruoho !Handler ||
933 1.1 jruoho !Data)
934 1.1 jruoho {
935 1.1 jruoho return (AE_BAD_PARAMETER);
936 1.1 jruoho }
937 1.1 jruoho
938 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
939 1.1 jruoho if (ACPI_FAILURE (Status))
940 1.1 jruoho {
941 1.1 jruoho return (Status);
942 1.1 jruoho }
943 1.1 jruoho
944 1.1 jruoho /* Convert and validate the handle */
945 1.1 jruoho
946 1.1 jruoho Node = AcpiNsValidateHandle (ObjHandle);
947 1.1 jruoho if (!Node)
948 1.1 jruoho {
949 1.1 jruoho Status = AE_BAD_PARAMETER;
950 1.1 jruoho goto UnlockAndExit;
951 1.1 jruoho }
952 1.1 jruoho
953 1.1 jruoho Status = AcpiNsAttachData (Node, Handler, Data);
954 1.1 jruoho
955 1.1 jruoho UnlockAndExit:
956 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
957 1.1 jruoho return (Status);
958 1.1 jruoho }
959 1.1 jruoho
960 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiAttachData)
961 1.1 jruoho
962 1.1 jruoho
963 1.1 jruoho /*******************************************************************************
964 1.1 jruoho *
965 1.1 jruoho * FUNCTION: AcpiDetachData
966 1.1 jruoho *
967 1.1 jruoho * PARAMETERS: ObjHandle - Namespace node handle
968 1.1 jruoho * Handler - Handler used in call to AcpiAttachData
969 1.1 jruoho *
970 1.1 jruoho * RETURN: Status
971 1.1 jruoho *
972 1.1 jruoho * DESCRIPTION: Remove data that was previously attached to a node.
973 1.1 jruoho *
974 1.1 jruoho ******************************************************************************/
975 1.1 jruoho
976 1.1 jruoho ACPI_STATUS
977 1.1 jruoho AcpiDetachData (
978 1.1 jruoho ACPI_HANDLE ObjHandle,
979 1.1 jruoho ACPI_OBJECT_HANDLER Handler)
980 1.1 jruoho {
981 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
982 1.1 jruoho ACPI_STATUS Status;
983 1.1 jruoho
984 1.1 jruoho
985 1.1 jruoho /* Parameter validation */
986 1.1 jruoho
987 1.1 jruoho if (!ObjHandle ||
988 1.1 jruoho !Handler)
989 1.1 jruoho {
990 1.1 jruoho return (AE_BAD_PARAMETER);
991 1.1 jruoho }
992 1.1 jruoho
993 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
994 1.1 jruoho if (ACPI_FAILURE (Status))
995 1.1 jruoho {
996 1.1 jruoho return (Status);
997 1.1 jruoho }
998 1.1 jruoho
999 1.1 jruoho /* Convert and validate the handle */
1000 1.1 jruoho
1001 1.1 jruoho Node = AcpiNsValidateHandle (ObjHandle);
1002 1.1 jruoho if (!Node)
1003 1.1 jruoho {
1004 1.1 jruoho Status = AE_BAD_PARAMETER;
1005 1.1 jruoho goto UnlockAndExit;
1006 1.1 jruoho }
1007 1.1 jruoho
1008 1.1 jruoho Status = AcpiNsDetachData (Node, Handler);
1009 1.1 jruoho
1010 1.1 jruoho UnlockAndExit:
1011 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1012 1.1 jruoho return (Status);
1013 1.1 jruoho }
1014 1.1 jruoho
1015 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiDetachData)
1016 1.1 jruoho
1017 1.1 jruoho
1018 1.1 jruoho /*******************************************************************************
1019 1.1 jruoho *
1020 1.1 jruoho * FUNCTION: AcpiGetData
1021 1.1 jruoho *
1022 1.1 jruoho * PARAMETERS: ObjHandle - Namespace node
1023 1.1 jruoho * Handler - Handler used in call to AttachData
1024 1.1 jruoho * Data - Where the data is returned
1025 1.1 jruoho *
1026 1.1 jruoho * RETURN: Status
1027 1.1 jruoho *
1028 1.1 jruoho * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
1029 1.1 jruoho *
1030 1.1 jruoho ******************************************************************************/
1031 1.1 jruoho
1032 1.1 jruoho ACPI_STATUS
1033 1.1 jruoho AcpiGetData (
1034 1.1 jruoho ACPI_HANDLE ObjHandle,
1035 1.1 jruoho ACPI_OBJECT_HANDLER Handler,
1036 1.1 jruoho void **Data)
1037 1.1 jruoho {
1038 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
1039 1.1 jruoho ACPI_STATUS Status;
1040 1.1 jruoho
1041 1.1 jruoho
1042 1.1 jruoho /* Parameter validation */
1043 1.1 jruoho
1044 1.1 jruoho if (!ObjHandle ||
1045 1.1 jruoho !Handler ||
1046 1.1 jruoho !Data)
1047 1.1 jruoho {
1048 1.1 jruoho return (AE_BAD_PARAMETER);
1049 1.1 jruoho }
1050 1.1 jruoho
1051 1.1 jruoho Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
1052 1.1 jruoho if (ACPI_FAILURE (Status))
1053 1.1 jruoho {
1054 1.1 jruoho return (Status);
1055 1.1 jruoho }
1056 1.1 jruoho
1057 1.1 jruoho /* Convert and validate the handle */
1058 1.1 jruoho
1059 1.1 jruoho Node = AcpiNsValidateHandle (ObjHandle);
1060 1.1 jruoho if (!Node)
1061 1.1 jruoho {
1062 1.1 jruoho Status = AE_BAD_PARAMETER;
1063 1.1 jruoho goto UnlockAndExit;
1064 1.1 jruoho }
1065 1.1 jruoho
1066 1.1 jruoho Status = AcpiNsGetAttachedData (Node, Handler, Data);
1067 1.1 jruoho
1068 1.1 jruoho UnlockAndExit:
1069 1.1 jruoho (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1070 1.1 jruoho return (Status);
1071 1.1 jruoho }
1072 1.1 jruoho
1073 1.1 jruoho ACPI_EXPORT_SYMBOL (AcpiGetData)
1074