ReactOS 0.4.15-dev-7924-g5949c20
dsmthdat.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "acinterp.h"
Include dependency graph for dsmthdat.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_DISPATCHER
 

Functions

static void AcpiDsMethodDataDeleteValue (UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState)
 
static ACPI_STATUS AcpiDsMethodDataSetValue (UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState)
 
void AcpiDsMethodDataInit (ACPI_WALK_STATE *WalkState)
 
void AcpiDsMethodDataDeleteAll (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsMethodDataInitArgs (ACPI_OPERAND_OBJECT **Params, UINT32 MaxParamCount, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsMethodDataGetNode (UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node)
 
ACPI_STATUS AcpiDsMethodDataGetValue (UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc)
 
ACPI_STATUS AcpiDsStoreObjectToLocal (UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_DISPATCHER

Definition at line 51 of file dsmthdat.c.

Function Documentation

◆ AcpiDsMethodDataDeleteAll()

void AcpiDsMethodDataDeleteAll ( ACPI_WALK_STATE WalkState)

Definition at line 153 of file dsmthdat.c.

155{
157
158
159 ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
160
161
162 /* Detach the locals */
163
165 {
166 if (WalkState->LocalVariables[Index].Object)
167 {
168 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
169 Index, WalkState->LocalVariables[Index].Object));
170
171 /* Detach object (if present) and remove a reference */
172
174 }
175 }
176
177 /* Detach the arguments */
178
179 for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
180 {
181 if (WalkState->Arguments[Index].Object)
182 {
183 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
184 Index, WalkState->Arguments[Index].Object));
185
186 /* Detach object (if present) and remove a reference */
187
188 AcpiNsDetachObject (&WalkState->Arguments[Index]);
189 }
190 }
191
193}
unsigned int UINT32
void AcpiNsDetachObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:220
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define return_VOID
Definition: acoutput.h:495
#define ACPI_METHOD_NUM_LOCALS
Definition: acconfig.h:163
#define ACPI_METHOD_NUM_ARGS
Definition: acconfig.h:166
struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]
Definition: acstruct.h:104
struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]
Definition: acstruct.h:103
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiDsTerminateControlMethod().

◆ AcpiDsMethodDataDeleteValue()

static void AcpiDsMethodDataDeleteValue ( UINT8  Type,
UINT32  Index,
ACPI_WALK_STATE WalkState 
)
static

Definition at line 519 of file dsmthdat.c.

523{
527
528
529 ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
530
531
532 /* Get the namespace node for the arg/local */
533
534 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
535 if (ACPI_FAILURE (Status))
536 {
538 }
539
540 /* Get the associated object */
541
543
544 /*
545 * Undefine the Arg or Local by setting its descriptor
546 * pointer to NULL. Locals/Args can contain both
547 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
548 */
549 Node->Object = NULL;
550
551 if ((Object) &&
553 {
554 /*
555 * There is a valid object.
556 * Decrement the reference count by one to balance the
557 * increment when the object was stored.
558 */
560 }
561
563}
Type
Definition: Type.h:7
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:576
UINT32 ACPI_STATUS
Definition: actypes.h:460
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
#define NULL
Definition: types.h:112
union node Node
Definition: types.h:1255
ACPI_STATUS AcpiDsMethodDataGetNode(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node)
Definition: dsmthdat.c:275
Status
Definition: gdiplustypes.h:25
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Referenced by AcpiDsStoreObjectToLocal().

◆ AcpiDsMethodDataGetNode()

ACPI_STATUS AcpiDsMethodDataGetNode ( UINT8  Type,
UINT32  Index,
ACPI_WALK_STATE WalkState,
ACPI_NAMESPACE_NODE **  Node 
)

Definition at line 275 of file dsmthdat.c.

280{
281 ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
282
283
284 /*
285 * Method Locals and Arguments are supported
286 */
287 switch (Type)
288 {
290
292 {
294 "Local index %u is invalid (max %u)",
297 }
298
299 /* Return a pointer to the pseudo-node */
300
301 *Node = &WalkState->LocalVariables[Index];
302 break;
303
305
307 {
309 "Arg index %u is invalid (max %u)",
312 }
313
314 /* Return a pointer to the pseudo-node */
315
316 *Node = &WalkState->Arguments[Index];
317 break;
318
319 default:
320
321 ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
323 }
324
326}
#define AE_TYPE
Definition: acexcep.h:116
#define AE_AML_INVALID_INDEX
Definition: acexcep.h:203
#define AE_OK
Definition: acexcep.h:97
@ ACPI_REFCLASS_ARG
Definition: acobject.h:460
@ ACPI_REFCLASS_LOCAL
Definition: acobject.h:459
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_METHOD_MAX_LOCAL
Definition: acconfig.h:164
#define ACPI_METHOD_MAX_ARG
Definition: acconfig.h:167

Referenced by AcpiDsInitObjectFromOp(), AcpiDsMethodDataDeleteValue(), AcpiDsMethodDataGetValue(), AcpiDsMethodDataSetValue(), AcpiDsStoreObjectToLocal(), and AcpiExResolveMultiple().

◆ AcpiDsMethodDataGetValue()

ACPI_STATUS AcpiDsMethodDataGetValue ( UINT8  Type,
UINT32  Index,
ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT **  DestDesc 
)

Definition at line 406 of file dsmthdat.c.

411{
415
416
417 ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
418
419
420 /* Validate the object descriptor */
421
422 if (!DestDesc)
423 {
424 ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
426 }
427
428 /* Get the namespace node for the arg/local */
429
430 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
431 if (ACPI_FAILURE (Status))
432 {
434 }
435
436 /* Get the object from the node */
437
438 Object = Node->Object;
439
440 /* Examine the returned object, it must be valid. */
441
442 if (!Object)
443 {
444 /*
445 * Index points to uninitialized object.
446 * This means that either 1) The expected argument was
447 * not passed to the method, or 2) A local variable
448 * was referenced by the method (via the ASL)
449 * before it was initialized. Either case is an error.
450 */
451
452 /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
453
454 if (AcpiGbl_EnableInterpreterSlack)
455 {
457 if (!Object)
458 {
460 }
461
462 Node->Object = Object;
463 }
464
465 /* Otherwise, return the error */
466
467 else switch (Type)
468 {
470
472 "Uninitialized Arg[%u] at node %p",
473 Index, Node));
474
476
478 /*
479 * No error message for this case, will be trapped again later to
480 * detect and ignore cases of Store(LocalX,LocalX)
481 */
483
484 default:
485
486 ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
488 }
489 }
490
491 /*
492 * The Index points to an initialized and valid object.
493 * Return an additional reference to the object
494 */
495 *DestDesc = Object;
497
499}
unsigned long long UINT64
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_AML_UNINITIALIZED_LOCAL
Definition: acexcep.h:184
#define AE_AML_UNINITIALIZED_ARG
Definition: acexcep.h:185
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752

Referenced by AcpiExOpcode_1A_0T_1R(), AcpiExResolveMultiple(), and AcpiExResolveObjectToValue().

◆ AcpiDsMethodDataInit()

void AcpiDsMethodDataInit ( ACPI_WALK_STATE WalkState)

Definition at line 100 of file dsmthdat.c.

102{
103 UINT32 i;
104
105
106 ACPI_FUNCTION_TRACE (DsMethodDataInit);
107
108
109 /* Init the method arguments */
110
111 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
112 {
113 ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name,
115
116 WalkState->Arguments[i].Name.Integer |= (i << 24);
117 WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
118 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
119 WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
120 }
121
122 /* Init the method locals */
123
124 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
125 {
126 ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name,
128
129 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
130 WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
131 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
132 WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
133 }
134
136}
#define NAMEOF_ARG_NTE
Definition: acdispat.h:49
#define NAMEOF_LOCAL_NTE
Definition: acdispat.h:48
#define ANOBJ_METHOD_ARG
Definition: aclocal.h:217
#define ANOBJ_METHOD_LOCAL
Definition: aclocal.h:218
#define ACPI_MOVE_32_TO_32(d, s)
Definition: acmacros.h:148
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:577
#define ACPI_TYPE_ANY
Definition: actypes.h:687
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

Referenced by AcpiDsCreateWalkState().

◆ AcpiDsMethodDataInitArgs()

ACPI_STATUS AcpiDsMethodDataInitArgs ( ACPI_OPERAND_OBJECT **  Params,
UINT32  MaxParamCount,
ACPI_WALK_STATE WalkState 
)

Definition at line 213 of file dsmthdat.c.

217{
219 UINT32 Index = 0;
220
221
222 ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
223
224
225 if (!Params)
226 {
228 "No parameter list passed to method\n"));
230 }
231
232 /* Copy passed parameters into the new method stack frame */
233
234 while ((Index < ACPI_METHOD_NUM_ARGS) &&
235 (Index < MaxParamCount) &&
236 Params[Index])
237 {
238 /*
239 * A valid parameter.
240 * Store the argument in the method/walk descriptor.
241 * Do not copy the arg in order to implement call by reference
242 */
244 ACPI_REFCLASS_ARG, Index, Params[Index], WalkState);
245 if (ACPI_FAILURE (Status))
246 {
248 }
249
250 Index++;
251 }
252
253 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
255}
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
static ACPI_STATUS AcpiDsMethodDataSetValue(UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:347
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

Referenced by AcpiDsInitAmlWalk().

◆ AcpiDsMethodDataSetValue()

static ACPI_STATUS AcpiDsMethodDataSetValue ( UINT8  Type,
UINT32  Index,
ACPI_OPERAND_OBJECT Object,
ACPI_WALK_STATE WalkState 
)
static

Definition at line 347 of file dsmthdat.c.

352{
355
356
357 ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
358
359
361 "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
362 Type, Object->Common.ReferenceCount,
363 AcpiUtGetTypeName (Object->Common.Type)));
364
365 /* Get the namespace node for the arg/local */
366
367 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
368 if (ACPI_FAILURE (Status))
369 {
371 }
372
373 /*
374 * Increment ref count so object can't be deleted while installed.
375 * NOTE: We do not copy the object in order to preserve the call by
376 * reference semantics of ACPI Control Method invocation.
377 * (See ACPI Specification 2.0C)
378 */
380
381 /* Install the object */
382
383 Node->Object = Object;
385}
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250

Referenced by AcpiDsMethodDataInitArgs(), and AcpiDsStoreObjectToLocal().

◆ AcpiDsStoreObjectToLocal()

ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT8  Type,
UINT32  Index,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 585 of file dsmthdat.c.

590{
593 ACPI_OPERAND_OBJECT *CurrentObjDesc;
594 ACPI_OPERAND_OBJECT *NewObjDesc;
595
596
597 ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
598 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
599 Type, Index, ObjDesc));
600
601 /* Parameter validation */
602
603 if (!ObjDesc)
604 {
606 }
607
608 /* Get the namespace node for the arg/local */
609
610 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
611 if (ACPI_FAILURE (Status))
612 {
614 }
615
616 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
617 if (CurrentObjDesc == ObjDesc)
618 {
619 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
620 ObjDesc));
622 }
623
624 /*
625 * If the reference count on the object is more than one, we must
626 * take a copy of the object before we store. A reference count
627 * of exactly 1 means that the object was just created during the
628 * evaluation of an expression, and we can safely use it since it
629 * is not used anywhere else.
630 */
631 NewObjDesc = ObjDesc;
632 if (ObjDesc->Common.ReferenceCount > 1)
633 {
635 ObjDesc, &NewObjDesc, WalkState);
636 if (ACPI_FAILURE (Status))
637 {
639 }
640 }
641
642 /*
643 * If there is an object already in this slot, we either
644 * have to delete it, or if this is an argument and there
645 * is an object reference stored there, we have to do
646 * an indirect store!
647 */
648 if (CurrentObjDesc)
649 {
650 /*
651 * Check for an indirect store if an argument
652 * contains an object reference (stored as an Node).
653 * We don't allow this automatic dereferencing for
654 * locals, since a store to a local should overwrite
655 * anything there, including an object reference.
656 *
657 * If both Arg0 and Local0 contain RefOf (Local4):
658 *
659 * Store (1, Arg0) - Causes indirect store to local4
660 * Store (1, Local0) - Stores 1 in local0, overwriting
661 * the reference to local4
662 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
663 *
664 * Weird, but true.
665 */
666 if (Type == ACPI_REFCLASS_ARG)
667 {
668 /*
669 * If we have a valid reference object that came from RefOf(),
670 * do the indirect store
671 */
672 if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) ==
674 (CurrentObjDesc->Common.Type ==
676 (CurrentObjDesc->Reference.Class ==
678 {
680 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
681 NewObjDesc, CurrentObjDesc));
682
683 /*
684 * Store this object to the Node (perform the indirect store)
685 * NOTE: No implicit conversion is performed, as per the ACPI
686 * specification rules on storing to Locals/Args.
687 */
688 Status = AcpiExStoreObjectToNode (NewObjDesc,
689 CurrentObjDesc->Reference.Object, WalkState,
691
692 /* Remove local reference if we copied the object above */
693
694 if (NewObjDesc != ObjDesc)
695 {
696 AcpiUtRemoveReference (NewObjDesc);
697 }
698
700 }
701 }
702
703 /* Delete the existing object before storing the new one */
704
706 }
707
708 /*
709 * Install the Obj descriptor (*NewObjDesc) into
710 * the descriptor for the Arg or Local.
711 * (increments the object reference count by one)
712 */
713 Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
714
715 /* Remove local reference if we copied the object above */
716
717 if (NewObjDesc != ObjDesc)
718 {
719 AcpiUtRemoveReference (NewObjDesc);
720 }
721
723}
@ ACPI_REFCLASS_REFOF
Definition: acobject.h:461
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_NO_IMPLICIT_CONVERSION
Definition: acutils.h:146
ACPI_STATUS AcpiUtCopyIobjectToIobject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, ACPI_WALK_STATE *WalkState)
Definition: utcopy.c:1037
static void AcpiDsMethodDataDeleteValue(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:519
ACPI_STATUS AcpiExStoreObjectToNode(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, ACPI_WALK_STATE *WalkState, UINT8 ImplicitConversion)
Definition: exstore.c:412
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519

Referenced by AcpiExStore().