ReactOS 0.4.15-dev-8119-g4fb2fdb
nsxfeval.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
#include "acinterp.h"
Include dependency graph for nsxfeval.c:

Go to the source code of this file.

Macros

#define EXPORT_ACPI_INTERFACES
 
#define _COMPONENT   ACPI_NAMESPACE
 

Functions

static void AcpiNsResolveReferences (ACPI_EVALUATE_INFO *Info)
 
ACPI_STATUS AcpiEvaluateObjectTyped (ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer, ACPI_OBJECT_TYPE ReturnType)
 
ACPI_STATUS AcpiEvaluateObject (ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
 
ACPI_STATUS AcpiWalkNamespace (ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
 
static ACPI_STATUS AcpiNsGetDeviceCallback (ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue)
 
ACPI_STATUS AcpiGetDevices (char *HID, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue)
 
ACPI_STATUS AcpiAttachData (ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void *Data)
 
ACPI_STATUS AcpiDetachData (ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler)
 
ACPI_STATUS AcpiGetData (ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 53 of file nsxfeval.c.

◆ EXPORT_ACPI_INTERFACES

#define EXPORT_ACPI_INTERFACES

Definition at line 45 of file nsxfeval.c.

Function Documentation

◆ AcpiAttachData()

ACPI_STATUS AcpiAttachData ( ACPI_HANDLE  ObjHandle,
ACPI_OBJECT_HANDLER  Handler,
void Data 
)

Definition at line 952 of file nsxfeval.c.

956{
959
960
961 /* Parameter validation */
962
963 if (!ObjHandle ||
964 !Handler ||
965 !Data)
966 {
967 return (AE_BAD_PARAMETER);
968 }
969
971 if (ACPI_FAILURE (Status))
972 {
973 return (Status);
974 }
975
976 /* Convert and validate the handle */
977
978 Node = AcpiNsValidateHandle (ObjHandle);
979 if (!Node)
980 {
982 goto UnlockAndExit;
983 }
984
986
987UnlockAndExit:
989 return (Status);
990}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
ACPI_NAMESPACE_NODE * AcpiNsValidateHandle(ACPI_HANDLE Handle)
Definition: nsutils.c:655
ACPI_STATUS AcpiNsAttachData(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void *Data)
Definition: nsobject.c:379
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
union node Node
Definition: types.h:1255
Status
Definition: gdiplustypes.h:25
Definition: dlist.c:348

Referenced by acpi_bus_add().

◆ AcpiDetachData()

ACPI_STATUS AcpiDetachData ( ACPI_HANDLE  ObjHandle,
ACPI_OBJECT_HANDLER  Handler 
)

Definition at line 1009 of file nsxfeval.c.

1012{
1015
1016
1017 /* Parameter validation */
1018
1019 if (!ObjHandle ||
1020 !Handler)
1021 {
1022 return (AE_BAD_PARAMETER);
1023 }
1024
1026 if (ACPI_FAILURE (Status))
1027 {
1028 return (Status);
1029 }
1030
1031 /* Convert and validate the handle */
1032
1033 Node = AcpiNsValidateHandle (ObjHandle);
1034 if (!Node)
1035 {
1037 goto UnlockAndExit;
1038 }
1039
1041
1042UnlockAndExit:
1044 return (Status);
1045}
ACPI_STATUS AcpiNsDetachData(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler)
Definition: nsobject.c:446

◆ AcpiEvaluateObject()

ACPI_STATUS AcpiEvaluateObject ( ACPI_HANDLE  Handle,
ACPI_STRING  Pathname,
ACPI_OBJECT_LIST ExternalParams,
ACPI_BUFFER ReturnBuffer 
)

Definition at line 217 of file nsxfeval.c.

222{
225 ACPI_SIZE BufferSpaceNeeded;
226 UINT32 i;
227
228
230
231
232 /* Allocate and initialize the evaluation information block */
233
235 if (!Info)
236 {
238 }
239
240 /* Convert and validate the device handle */
241
242 Info->PrefixNode = AcpiNsValidateHandle (Handle);
243 if (!Info->PrefixNode)
244 {
246 goto Cleanup;
247 }
248
249 /*
250 * Get the actual namespace node for the target object.
251 * Handles these cases:
252 *
253 * 1) Null node, valid pathname from root (absolute path)
254 * 2) Node and valid pathname (path relative to Node)
255 * 3) Node, Null pathname
256 */
257 if ((Pathname) &&
259 {
260 /* The path is fully qualified, just evaluate by name */
261
262 Info->PrefixNode = NULL;
263 }
264 else if (!Handle)
265 {
266 /*
267 * A handle is optional iff a fully qualified pathname is specified.
268 * Since we've already handled fully qualified names above, this is
269 * an error.
270 */
271 if (!Pathname)
272 {
274 "Both Handle and Pathname are NULL"));
275 }
276 else
277 {
279 "Null Handle with relative pathname [%s]", Pathname));
280 }
281
283 goto Cleanup;
284 }
285
286 Info->RelativePathname = Pathname;
287
288 /*
289 * Convert all external objects passed as arguments to the
290 * internal version(s).
291 */
292 if (ExternalParams && ExternalParams->Count)
293 {
294 Info->ParamCount = (UINT16) ExternalParams->Count;
295
296 /* Warn on impossible argument count */
297
298 if (Info->ParamCount > ACPI_METHOD_NUM_ARGS)
299 {
301 "Excess arguments (%u) - using only %u",
302 Info->ParamCount, ACPI_METHOD_NUM_ARGS));
303
304 Info->ParamCount = ACPI_METHOD_NUM_ARGS;
305 }
306
307 /*
308 * Allocate a new parameter block for the internal objects
309 * Add 1 to count to allow for null terminated internal list
310 */
311 Info->Parameters = ACPI_ALLOCATE_ZEROED (
312 ((ACPI_SIZE) Info->ParamCount + 1) * sizeof (void *));
313 if (!Info->Parameters)
314 {
316 goto Cleanup;
317 }
318
319 /* Convert each external object in the list to an internal object */
320
321 for (i = 0; i < Info->ParamCount; i++)
322 {
324 &ExternalParams->Pointer[i], &Info->Parameters[i]);
325 if (ACPI_FAILURE (Status))
326 {
327 goto Cleanup;
328 }
329 }
330
331 Info->Parameters[Info->ParamCount] = NULL;
332 }
333
334
335#ifdef _FUTURE_FEATURE
336
337 /*
338 * Begin incoming argument count analysis. Check for too few args
339 * and too many args.
340 */
341 switch (AcpiNsGetType (Info->Node))
342 {
343 case ACPI_TYPE_METHOD:
344
345 /* Check incoming argument count against the method definition */
346
347 if (Info->ObjDesc->Method.ParamCount > Info->ParamCount)
348 {
350 "Insufficient arguments (%u) - %u are required",
351 Info->ParamCount,
352 Info->ObjDesc->Method.ParamCount));
353
355 goto Cleanup;
356 }
357
358 else if (Info->ObjDesc->Method.ParamCount < Info->ParamCount)
359 {
361 "Excess arguments (%u) - only %u are required",
362 Info->ParamCount,
363 Info->ObjDesc->Method.ParamCount));
364
365 /* Just pass the required number of arguments */
366
367 Info->ParamCount = Info->ObjDesc->Method.ParamCount;
368 }
369
370 /*
371 * Any incoming external objects to be passed as arguments to the
372 * method must be converted to internal objects
373 */
374 if (Info->ParamCount)
375 {
376 /*
377 * Allocate a new parameter block for the internal objects
378 * Add 1 to count to allow for null terminated internal list
379 */
380 Info->Parameters = ACPI_ALLOCATE_ZEROED (
381 ((ACPI_SIZE) Info->ParamCount + 1) * sizeof (void *));
382 if (!Info->Parameters)
383 {
385 goto Cleanup;
386 }
387
388 /* Convert each external object in the list to an internal object */
389
390 for (i = 0; i < Info->ParamCount; i++)
391 {
393 &ExternalParams->Pointer[i], &Info->Parameters[i]);
394 if (ACPI_FAILURE (Status))
395 {
396 goto Cleanup;
397 }
398 }
399
400 Info->Parameters[Info->ParamCount] = NULL;
401 }
402 break;
403
404 default:
405
406 /* Warn if arguments passed to an object that is not a method */
407
408 if (Info->ParamCount)
409 {
411 "%u arguments were passed to a non-method ACPI object",
412 Info->ParamCount));
413 }
414 break;
415 }
416
417#endif
418
419
420 /* Now we can evaluate the object */
421
423
424 /*
425 * If we are expecting a return value, and all went well above,
426 * copy the return value to an external object.
427 */
428 if (!ReturnBuffer)
429 {
430 goto CleanupReturnObject;
431 }
432
433 if (!Info->ReturnObject)
434 {
435 ReturnBuffer->Length = 0;
436 goto Cleanup;
437 }
438
439 if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
441 {
442 /*
443 * If we received a NS Node as a return object, this means that
444 * the object we are evaluating has nothing interesting to
445 * return (such as a mutex, etc.) We return an error because
446 * these types are essentially unsupported by this interface.
447 * We don't check up front because this makes it easier to add
448 * support for various types at a later date if necessary.
449 */
450 Status = AE_TYPE;
451 Info->ReturnObject = NULL; /* No need to delete a NS Node */
452 ReturnBuffer->Length = 0;
453 }
454
455 if (ACPI_FAILURE (Status))
456 {
457 goto CleanupReturnObject;
458 }
459
460 /* Dereference Index and RefOf references */
461
463
464 /* Get the size of the returned object */
465
466 Status = AcpiUtGetObjectSize (Info->ReturnObject,
467 &BufferSpaceNeeded);
468 if (ACPI_SUCCESS (Status))
469 {
470 /* Validate/Allocate/Clear caller buffer */
471
472 Status = AcpiUtInitializeBuffer (ReturnBuffer,
473 BufferSpaceNeeded);
474 if (ACPI_FAILURE (Status))
475 {
476 /*
477 * Caller's buffer is too small or a new one can't
478 * be allocated
479 */
481 "Needed buffer size %X, %s\n",
482 (UINT32) BufferSpaceNeeded,
484 }
485 else
486 {
487 /* We have enough space for the object, build it */
488
490 Info->ReturnObject, ReturnBuffer);
491 }
492 }
493
494CleanupReturnObject:
495
496 if (Info->ReturnObject)
497 {
498 /*
499 * Delete the internal return object. NOTE: Interpreter must be
500 * locked to avoid race condition.
501 */
503
504 /* Remove one reference on the return object (should delete it) */
505
506 AcpiUtRemoveReference (Info->ReturnObject);
508 }
509
510
511Cleanup:
512
513 /* Free the input parameter list (if we created one) */
514
515 if (Info->Parameters)
516 {
517 /* Free the allocated parameter block */
518
520 }
521
522 ACPI_FREE (Info);
524}
unsigned short UINT16
unsigned int UINT32
#define AE_MISSING_ARGUMENTS
Definition: acexcep.h:158
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_TYPE
Definition: acexcep.h:116
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_IS_ROOT_PREFIX(c)
Definition: acmacros.h:401
#define ACPI_WARN_PREDEFINED(plist)
Definition: acmacros.h:464
ACPI_OBJECT_TYPE AcpiNsGetType(ACPI_NAMESPACE_NODE *Node)
Definition: nsutils.c:120
#define ACPI_WARN_ALWAYS
Definition: acnamesp.h:87
ACPI_STATUS AcpiNsEvaluate(ACPI_EVALUATE_INFO *Info)
Definition: nseval.c:82
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:577
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DB_INFO
Definition: acoutput.h:153
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING Pathname
Definition: acpixf.h:704
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
ACPI_STATUS AcpiUtInitializeBuffer(ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength)
Definition: utalloc.c:336
ACPI_STATUS AcpiUtCopyIobjectToEobject(ACPI_OPERAND_OBJECT *Obj, ACPI_BUFFER *RetBuffer)
Definition: utcopy.c:414
void AcpiUtDeleteInternalObjectList(ACPI_OPERAND_OBJECT **ObjList)
Definition: utdelete.c:384
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
ACPI_STATUS AcpiUtCopyEobjectToIobject(ACPI_OBJECT *Obj, ACPI_OPERAND_OBJECT **InternalObj)
Definition: utcopy.c:670
ACPI_STATUS AcpiUtGetObjectSize(ACPI_OPERAND_OBJECT *Obj, ACPI_SIZE *ObjLength)
Definition: utobject.c:762
#define NULL
Definition: types.h:112
static const WCHAR Cleanup[]
Definition: register.c:80
#define ACPI_METHOD_NUM_ARGS
Definition: acconfig.h:166
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
ULONG Handle
Definition: gdb_input.c:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
if(dx< 0)
Definition: linetemp.h:194
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
static void AcpiNsResolveReferences(ACPI_EVALUATE_INFO *Info)
Definition: nsxfeval.c:551
ACPI_SIZE Length
Definition: actypes.h:1053
ACPI_OBJECT * Pointer
Definition: actypes.h:1029
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by acpi_bus_set_power(), acpi_device_sleep_wake(), acpi_evaluate_integer(), acpi_evaluate_reference(), acpi_power_add(), acpi_power_off_device(), acpi_power_on(), AcpiEnterSleepStatePrep(), AcpiEvaluateObject(), AcpiEvaluateObjectTyped(), AcpiEvExecuteOrphanRegMethod(), AcpiHwExecuteSleepMethod(), and EvalEvaluateObject().

◆ AcpiEvaluateObjectTyped()

ACPI_STATUS AcpiEvaluateObjectTyped ( ACPI_HANDLE  Handle,
ACPI_STRING  Pathname,
ACPI_OBJECT_LIST ExternalParams,
ACPI_BUFFER ReturnBuffer,
ACPI_OBJECT_TYPE  ReturnType 
)

Definition at line 85 of file nsxfeval.c.

91{
93 BOOLEAN FreeBufferOnError = FALSE;
95 char *FullPathname;
96
97
99
100
101 /* Return buffer must be valid */
102
103 if (!ReturnBuffer)
104 {
106 }
107
108 if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER)
109 {
110 FreeBufferOnError = TRUE;
111 }
112
113 /* Get a handle here, in order to build an error message if needed */
114
116 if (Pathname)
117 {
119 if (ACPI_FAILURE (Status))
120 {
122 }
123 }
124
126 if (!FullPathname)
127 {
129 }
130
131 /* Evaluate the object */
132
133 Status = AcpiEvaluateObject (TargetHandle, NULL, ExternalParams,
134 ReturnBuffer);
135 if (ACPI_FAILURE (Status))
136 {
137 goto Exit;
138 }
139
140 /* Type ANY means "don't care about return value type" */
141
142 if (ReturnType == ACPI_TYPE_ANY)
143 {
144 goto Exit;
145 }
146
147 if (ReturnBuffer->Length == 0)
148 {
149 /* Error because caller specifically asked for a return value */
150
151 ACPI_ERROR ((AE_INFO, "%s did not return any object",
152 FullPathname));
154 goto Exit;
155 }
156
157 /* Examine the object type returned from EvaluateObject */
158
159 if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType)
160 {
161 goto Exit;
162 }
163
164 /* Return object type does not match requested type */
165
167 "Incorrect return type from %s - received [%s], requested [%s]",
168 FullPathname,
169 AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type),
170 AcpiUtGetTypeName (ReturnType)));
171
172 if (FreeBufferOnError)
173 {
174 /*
175 * Free a buffer created via ACPI_ALLOCATE_BUFFER.
176 * Note: We use AcpiOsFree here because AcpiOsAllocate was used
177 * to allocate the buffer. This purposefully bypasses the
178 * (optionally enabled) allocation tracking mechanism since we
179 * only want to track internal allocations.
180 */
181 AcpiOsFree (ReturnBuffer->Pointer);
182 ReturnBuffer->Pointer = NULL;
183 }
184
185 ReturnBuffer->Length = 0;
186 Status = AE_TYPE;
187
188Exit:
189 ACPI_FREE (FullPathname);
191}
unsigned char BOOLEAN
#define AE_NULL_OBJECT
Definition: acexcep.h:117
char * AcpiNsGetExternalPathname(ACPI_NAMESPACE_NODE *Node)
Definition: nsnames.c:70
void AcpiOsFree(void *Memory)
Definition: osl.c:167
#define ACPI_ALLOCATE_BUFFER
Definition: actypes.h:1046
#define ACPI_TYPE_ANY
Definition: actypes.h:687
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ HANDLE _In_opt_ HANDLE _Out_opt_ PHANDLE TargetHandle
Definition: obfuncs.h:431
ACPI_STATUS AcpiEvaluateObjectTyped(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer, ACPI_OBJECT_TYPE ReturnType)
Definition: nsxfeval.c:85
ACPI_STATUS AcpiGetHandle(ACPI_HANDLE Parent, ACPI_STRING Pathname, ACPI_HANDLE *RetHandle)
Definition: nsxfname.c:85
static void Exit(void)
Definition: sock.c:1330
void * Pointer
Definition: actypes.h:1054

Referenced by AcpiEvaluateObjectTyped().

◆ AcpiGetData()

ACPI_STATUS AcpiGetData ( ACPI_HANDLE  ObjHandle,
ACPI_OBJECT_HANDLER  Handler,
void **  Data 
)

Definition at line 1065 of file nsxfeval.c.

1069{
1072
1073
1074 /* Parameter validation */
1075
1076 if (!ObjHandle ||
1077 !Handler ||
1078 !Data)
1079 {
1080 return (AE_BAD_PARAMETER);
1081 }
1082
1084 if (ACPI_FAILURE (Status))
1085 {
1086 return (Status);
1087 }
1088
1089 /* Convert and validate the handle */
1090
1091 Node = AcpiNsValidateHandle (ObjHandle);
1092 if (!Node)
1093 {
1095 goto UnlockAndExit;
1096 }
1097
1099
1100UnlockAndExit:
1102 return (Status);
1103}
ACPI_STATUS AcpiNsGetAttachedData(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void **Data)
Definition: nsobject.c:498

Referenced by acpi_bus_get_device(), and acpi_bus_get_private_data().

◆ AcpiGetDevices()

ACPI_STATUS AcpiGetDevices ( char HID,
ACPI_WALK_CALLBACK  UserFunction,
void Context,
void **  ReturnValue 
)

Definition at line 886 of file nsxfeval.c.

891{
894
895
897
898
899 /* Parameter validation */
900
901 if (!UserFunction)
902 {
904 }
905
906 /*
907 * We're going to call their callback from OUR callback, so we need
908 * to know what it is, and their context parameter.
909 */
910 Info.Hid = HID;
911 Info.Context = Context;
912 Info.UserFunction = UserFunction;
913
914 /*
915 * Lock the namespace around the walk.
916 * The namespace will be unlocked/locked around each call
917 * to the user function - since this function
918 * must be allowed to make Acpi calls itself.
919 */
921 if (ACPI_FAILURE (Status))
922 {
924 }
925
929
932}
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define ACPI_NS_WALK_UNLOCK
Definition: acnamesp.h:77
ACPI_STATUS AcpiNsWalkNamespace(ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, UINT32 Flags, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
Definition: nswalk.c:190
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK UserFunction
Definition: acpixf.h:1078
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
#define ACPI_UINT32_MAX
Definition: actypes.h:66
#define ACPI_ROOT_OBJECT
Definition: actypes.h:500
ACPI_STATUS AcpiGetDevices(char *HID, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue)
Definition: nsxfeval.c:886
static ACPI_STATUS AcpiNsGetDeviceCallback(ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue)
Definition: nsxfeval.c:731

Referenced by AcpiGetDevices().

◆ AcpiNsGetDeviceCallback()

static ACPI_STATUS AcpiNsGetDeviceCallback ( ACPI_HANDLE  ObjHandle,
UINT32  NestingLevel,
void Context,
void **  ReturnValue 
)
static

Definition at line 731 of file nsxfeval.c.

736{
743 UINT32 i;
745 int NoMatch;
746
747
749 if (ACPI_FAILURE (Status))
750 {
751 return (Status);
752 }
753
754 Node = AcpiNsValidateHandle (ObjHandle);
756 if (ACPI_FAILURE (Status))
757 {
758 return (Status);
759 }
760
761 if (!Node)
762 {
763 return (AE_BAD_PARAMETER);
764 }
765
766 /*
767 * First, filter based on the device HID and CID.
768 *
769 * 01/2010: For this case where a specific HID is requested, we don't
770 * want to run _STA until we have an actual HID match. Thus, we will
771 * not unnecessarily execute _STA on devices for which the caller
772 * doesn't care about. Previously, _STA was executed unconditionally
773 * on all devices found here.
774 *
775 * A side-effect of this change is that now we will continue to search
776 * for a matching HID even under device trees where the parent device
777 * would have returned a _STA that indicates it is not present or
778 * not functioning (thus aborting the search on that branch).
779 */
780 if (Info->Hid != NULL)
781 {
782 Status = AcpiUtExecute_HID (Node, &Hid);
783 if (Status == AE_NOT_FOUND)
784 {
785 return (AE_OK);
786 }
787 else if (ACPI_FAILURE (Status))
788 {
789 return (AE_CTRL_DEPTH);
790 }
791
792 NoMatch = strcmp (Hid->String, Info->Hid);
793 ACPI_FREE (Hid);
794
795 if (NoMatch)
796 {
797 /*
798 * HID does not match, attempt match within the
799 * list of Compatible IDs (CIDs)
800 */
801 Status = AcpiUtExecute_CID (Node, &Cid);
802 if (Status == AE_NOT_FOUND)
803 {
804 return (AE_OK);
805 }
806 else if (ACPI_FAILURE (Status))
807 {
808 return (AE_CTRL_DEPTH);
809 }
810
811 /* Walk the CID list */
812
813 Found = FALSE;
814 for (i = 0; i < Cid->Count; i++)
815 {
816 if (strcmp (Cid->Ids[i].String, Info->Hid) == 0)
817 {
818 /* Found a matching CID */
819
820 Found = TRUE;
821 break;
822 }
823 }
824
825 ACPI_FREE (Cid);
826 if (!Found)
827 {
828 return (AE_OK);
829 }
830 }
831 }
832
833 /* Run _STA to determine if device is present */
834
836 if (ACPI_FAILURE (Status))
837 {
838 return (AE_CTRL_DEPTH);
839 }
840
843 {
844 /*
845 * Don't examine the children of the device only when the
846 * device is neither present nor functional. See ACPI spec,
847 * description of _STA for more information.
848 */
849 return (AE_CTRL_DEPTH);
850 }
851
852 /* We have a valid device, invoke the user function */
853
854 Status = Info->UserFunction (ObjHandle, NestingLevel,
855 Info->Context, ReturnValue);
856 return (Status);
857}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define AE_CTRL_DEPTH
Definition: acexcep.h:229
#define AE_OK
Definition: acexcep.h:97
#define ACPI_STA_DEVICE_PRESENT
Definition: actypes.h:1339
#define ACPI_STA_DEVICE_FUNCTIONING
Definition: actypes.h:1342
ACPI_STATUS AcpiUtExecute_CID(ACPI_NAMESPACE_NODE *DeviceNode, ACPI_PNP_DEVICE_ID_LIST **ReturnCidList)
Definition: utids.c:253
ACPI_STATUS AcpiUtExecute_HID(ACPI_NAMESPACE_NODE *DeviceNode, ACPI_PNP_DEVICE_ID **ReturnId)
Definition: utids.c:72
ACPI_STATUS AcpiUtExecute_STA(ACPI_NAMESPACE_NODE *DeviceNode, UINT32 *StatusFlags)
Definition: uteval.c:269
return Found
Definition: dirsup.c:1270
ACPI_PNP_DEVICE_ID Ids[]
Definition: actypes.h:1297
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by AcpiGetDevices().

◆ AcpiNsResolveReferences()

static void AcpiNsResolveReferences ( ACPI_EVALUATE_INFO Info)
static

Definition at line 551 of file nsxfeval.c.

553{
554 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
556
557
558 /* We are interested in reference objects only */
559
560 if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
561 {
562 return;
563 }
564
565 /*
566 * Two types of references are supported - those created by Index and
567 * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
568 * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
569 * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
570 * an ACPI_OBJECT.
571 */
572 switch (Info->ReturnObject->Reference.Class)
573 {
575
576 ObjDesc = *(Info->ReturnObject->Reference.Where);
577 break;
578
580
581 Node = Info->ReturnObject->Reference.Object;
582 if (Node)
583 {
584 ObjDesc = Node->Object;
585 }
586 break;
587
588 default:
589
590 return;
591 }
592
593 /* Replace the existing reference object */
594
595 if (ObjDesc)
596 {
597 AcpiUtAddReference (ObjDesc);
598 AcpiUtRemoveReference (Info->ReturnObject);
599 Info->ReturnObject = ObjDesc;
600 }
601
602 return;
603}
@ ACPI_REFCLASS_INDEX
Definition: acobject.h:462
@ ACPI_REFCLASS_REFOF
Definition: acobject.h:461
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752

Referenced by AcpiEvaluateObject().

◆ AcpiWalkNamespace()

ACPI_STATUS AcpiWalkNamespace ( ACPI_OBJECT_TYPE  Type,
ACPI_HANDLE  StartObject,
UINT32  MaxDepth,
ACPI_WALK_CALLBACK  DescendingCallback,
ACPI_WALK_CALLBACK  AscendingCallback,
void Context,
void **  ReturnValue 
)

Definition at line 640 of file nsxfeval.c.

648{
650
651
653
654
655 /* Parameter validation */
656
657 if ((Type > ACPI_TYPE_LOCAL_MAX) ||
658 (!MaxDepth) ||
660 {
662 }
663
664 /*
665 * Need to acquire the namespace reader lock to prevent interference
666 * with any concurrent table unloads (which causes the deletion of
667 * namespace objects). We cannot allow the deletion of a namespace node
668 * while the user function is using it. The exception to this are the
669 * nodes created and deleted during control method execution -- these
670 * nodes are marked as temporary nodes and are ignored by the namespace
671 * walk. Thus, control methods can be executed while holding the
672 * namespace deletion lock (and the user function can execute control
673 * methods.)
674 */
675 Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock);
676 if (ACPI_FAILURE (Status))
677 {
679 }
680
681 /*
682 * Lock the namespace around the walk. The namespace will be
683 * unlocked/locked around each call to the user function - since the user
684 * function must be allowed to make ACPICA calls itself (for example, it
685 * will typically execute control methods during device enumeration.)
686 */
688 if (ACPI_FAILURE (Status))
689 {
690 goto UnlockAndExit;
691 }
692
693 /* Now we can validate the starting node */
694
696 {
698 goto UnlockAndExit2;
699 }
700
704
705UnlockAndExit2:
707
708UnlockAndExit:
709 (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock);
711}
Type
Definition: Type.h:7
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK DescendingCallback
Definition: acpixf.h:641
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE StartObject
Definition: acpixf.h:639
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK AscendingCallback
Definition: acpixf.h:642
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 MaxDepth
Definition: acpixf.h:640
#define ACPI_TYPE_LOCAL_MAX
Definition: actypes.h:738
ACPI_STATUS AcpiUtAcquireReadLock(ACPI_RW_LOCK *Lock)
Definition: utlock.c:117
ACPI_STATUS AcpiUtReleaseReadLock(ACPI_RW_LOCK *Lock)
Definition: utlock.c:143
ACPI_STATUS AcpiWalkNamespace(ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
Definition: nsxfeval.c:640

Referenced by AcpiNsInitializeObjects(), and AcpiWalkNamespace().