ReactOS 0.4.15-dev-7934-g1dc8d80
acdispat.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NAMEOF_LOCAL_NTE   "__L0"
 
#define NAMEOF_ARG_NTE   "__A0"
 

Functions

ACPI_STATUS AcpiDsGetBufferFieldArguments (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsGetBankFieldArguments (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsGetRegionArguments (ACPI_OPERAND_OBJECT *RgnDesc)
 
ACPI_STATUS AcpiDsGetBufferArguments (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsGetPackageArguments (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsExecBeginControlOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsExecEndControlOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsEvalBufferFieldOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsEvalRegionOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsEvalTableRegionOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsEvalDataObjectOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsEvalBankFieldOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsInitializeRegion (ACPI_HANDLE ObjHandle)
 
ACPI_STATUS AcpiDsGetPredicateValue (ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ResultObj)
 
ACPI_STATUS AcpiDsExecBeginOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
 
ACPI_STATUS AcpiDsExecEndOp (ACPI_WALK_STATE *State)
 
ACPI_STATUS AcpiDsCreateField (ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsCreateBankField (ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsCreateIndexField (ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsCreateBufferField (ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsInitFieldObjects (ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsInitCallbacks (ACPI_WALK_STATE *WalkState, UINT32 PassNumber)
 
ACPI_STATUS AcpiDsLoad1BeginOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
 
ACPI_STATUS AcpiDsLoad1EndOp (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsLoad2BeginOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
 
ACPI_STATUS AcpiDsLoad2EndOp (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsStoreObjectToLocal (UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *SrcDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsMethodDataGetEntry (UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT ***Node)
 
void AcpiDsMethodDataDeleteAll (ACPI_WALK_STATE *WalkState)
 
BOOLEAN AcpiDsIsMethodValue (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsMethodDataGetValue (UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc)
 
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)
 
void AcpiDsMethodDataInit (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsAutoSerializeMethod (ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiDsCallControlMethod (ACPI_THREAD_STATE *Thread, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsRestartControlMethod (ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ReturnDesc)
 
void AcpiDsTerminateControlMethod (ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsBeginMethodExecution (ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsMethodError (ACPI_STATUS Status, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsInitializeObjects (UINT32 TableIndex, ACPI_NAMESPACE_NODE *StartNode)
 
ACPI_STATUS AcpiDsBuildInternalObject (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr)
 
ACPI_STATUS AcpiDsBuildInternalBufferObj (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr)
 
ACPI_STATUS AcpiDsBuildInternalPackageObj (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *op, UINT32 PackageLength, ACPI_OPERAND_OBJECT **ObjDesc)
 
ACPI_STATUS AcpiDsInitObjectFromOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT16 Opcode, ACPI_OPERAND_OBJECT **ObjDesc)
 
ACPI_STATUS AcpiDsCreateNode (ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsInitPackageElement (UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
 
void AcpiDsClearImplicitReturn (ACPI_WALK_STATE *WalkState)
 
BOOLEAN AcpiDsDoImplicitReturn (ACPI_OPERAND_OBJECT *ReturnDesc, ACPI_WALK_STATE *WalkState, BOOLEAN AddReference)
 
BOOLEAN AcpiDsIsResultUsed (ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
 
void AcpiDsDeleteResultIfNotUsed (ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ResultObj, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsCreateOperand (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg, UINT32 ArgsRemaining)
 
ACPI_STATUS AcpiDsCreateOperands (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *FirstArg)
 
ACPI_STATUS AcpiDsResolveOperands (ACPI_WALK_STATE *WalkState)
 
void AcpiDsClearOperands (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsEvaluateNamePath (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsScopeStackPush (ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsScopeStackPop (ACPI_WALK_STATE *WalkState)
 
void AcpiDsScopeStackClear (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsObjStackPush (void *Object, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsObjStackPop (UINT32 PopCount, ACPI_WALK_STATE *WalkState)
 
ACPI_WALK_STATEAcpiDsCreateWalkState (ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MthDesc, ACPI_THREAD_STATE *Thread)
 
ACPI_STATUS AcpiDsInitAmlWalk (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_EVALUATE_INFO *Info, UINT8 PassNumber)
 
void AcpiDsObjStackPopAndDelete (UINT32 PopCount, ACPI_WALK_STATE *WalkState)
 
void AcpiDsDeleteWalkState (ACPI_WALK_STATE *WalkState)
 
ACPI_WALK_STATEAcpiDsPopWalkState (ACPI_THREAD_STATE *Thread)
 
void AcpiDsPushWalkState (ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread)
 
ACPI_STATUS AcpiDsResultStackClear (ACPI_WALK_STATE *WalkState)
 
ACPI_WALK_STATEAcpiDsGetCurrentWalkState (ACPI_THREAD_STATE *Thread)
 
ACPI_STATUS AcpiDsResultPop (ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiDsResultPush (ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState)
 
void AcpiDsDumpMethodStack (ACPI_STATUS Status, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 

Macro Definition Documentation

◆ NAMEOF_ARG_NTE

#define NAMEOF_ARG_NTE   "__A0"

Definition at line 49 of file acdispat.h.

◆ NAMEOF_LOCAL_NTE

#define NAMEOF_LOCAL_NTE   "__L0"

Definition at line 48 of file acdispat.h.

Function Documentation

◆ AcpiDsAutoSerializeMethod()

ACPI_STATUS AcpiDsAutoSerializeMethod ( ACPI_NAMESPACE_NODE Node,
ACPI_OPERAND_OBJECT ObjDesc 
)

Definition at line 94 of file dsmethod.c.

97{
100 ACPI_WALK_STATE *WalkState;
101
102
103 ACPI_FUNCTION_TRACE_PTR (DsAutoSerializeMethod, Node);
104
105
107 "Method auto-serialization parse [%4.4s] %p\n",
109
110 /* Create/Init a root op for the method parse tree */
111
113 if (!Op)
114 {
116 }
117
118 AcpiPsSetName (Op, Node->Name.Integer);
119 Op->Common.Node = Node;
120
121 /* Create and initialize a new walk state */
122
123 WalkState = AcpiDsCreateWalkState (Node->OwnerId, NULL, NULL, NULL);
124 if (!WalkState)
125 {
126 AcpiPsFreeOp (Op);
128 }
129
130 Status = AcpiDsInitAmlWalk (WalkState, Op, Node,
131 ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, 0);
132 if (ACPI_FAILURE (Status))
133 {
134 AcpiDsDeleteWalkState (WalkState);
135 AcpiPsFreeOp (Op);
137 }
138
140
141 /* Parse the method, scan for creation of named objects */
142
143 Status = AcpiPsParseAml (WalkState);
144
147}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_PARSE
Definition: acoutput.h:162
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
void AcpiPsSetName(ACPI_PARSE_OBJECT *op, UINT32 name)
Definition: psutils.c:281
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
void AcpiPsFreeOp(ACPI_PARSE_OBJECT *Op)
Definition: psutils.c:212
ACPI_STATUS AcpiPsParseAml(ACPI_WALK_STATE *WalkState)
Definition: psparse.c:453
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
UINT32 ACPI_STATUS
Definition: actypes.h:460
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
#define AML_METHOD_OP
Definition: amlcode.h:64
#define NULL
Definition: types.h:112
union node Node
Definition: types.h:1255
static ACPI_STATUS AcpiDsDetectNamedOpcodes(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
Definition: dsmethod.c:166
ACPI_WALK_STATE * AcpiDsCreateWalkState(ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MethodDesc, ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:600
ACPI_STATUS AcpiDsInitAmlWalk(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_EVALUATE_INFO *Info, UINT8 PassNumber)
Definition: dswstate.c:662
void AcpiDsDeleteWalkState(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:780
Status
Definition: gdiplustypes.h:25
UINT8 * AmlStart
Definition: acobject.h:221
ACPI_PARSE_DOWNWARDS DescendingCallback
Definition: acstruct.h:128
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
Definition: dlist.c:348

Referenced by AcpiDsInitOneObject().

◆ AcpiDsBeginMethodExecution()

ACPI_STATUS AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE MethodNode,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 352 of file dsmethod.c.

356{
358
359
360 ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
361
362
363 if (!MethodNode)
364 {
366 }
367
368 AcpiExStartTraceMethod (MethodNode, ObjDesc, WalkState);
369
370 /* Prevent wraparound of thread count */
371
372 if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX)
373 {
375 "Method reached maximum reentrancy limit (255)"));
377 }
378
379 /*
380 * If this method is serialized, we need to acquire the method mutex.
381 */
383 {
384 /*
385 * Create a mutex for the method if it is defined to be Serialized
386 * and a mutex has not already been created. We defer the mutex creation
387 * until a method is actually executed, to minimize the object count
388 */
389 if (!ObjDesc->Method.Mutex)
390 {
392 if (ACPI_FAILURE (Status))
393 {
395 }
396 }
397
398 /*
399 * The CurrentSyncLevel (per-thread) must be less than or equal to
400 * the sync level of the method. This mechanism provides some
401 * deadlock prevention.
402 *
403 * If the method was auto-serialized, we just ignore the sync level
404 * mechanism, because auto-serialization of methods can interfere
405 * with ASL code that actually uses sync levels.
406 *
407 * Top-level method invocation has no walk state at this point
408 */
409 if (WalkState &&
411 (WalkState->Thread->CurrentSyncLevel >
412 ObjDesc->Method.Mutex->Mutex.SyncLevel))
413 {
415 "Cannot acquire Mutex for method [%4.4s]"
416 ", current SyncLevel is too large (%u)",
417 AcpiUtGetNodeName (MethodNode),
418 WalkState->Thread->CurrentSyncLevel));
419
421 }
422
423 /*
424 * Obtain the method mutex if necessary. Do not acquire mutex for a
425 * recursive call.
426 */
427 if (!WalkState ||
428 !ObjDesc->Method.Mutex->Mutex.ThreadId ||
429 (WalkState->Thread->ThreadId !=
430 ObjDesc->Method.Mutex->Mutex.ThreadId))
431 {
432 /*
433 * Acquire the method mutex. This releases the interpreter if we
434 * block (and reacquires it before it returns)
435 */
438 if (ACPI_FAILURE (Status))
439 {
441 }
442
443 /* Update the mutex and walk info and save the original SyncLevel */
444
445 if (WalkState)
446 {
448 WalkState->Thread->CurrentSyncLevel;
449
450 ObjDesc->Method.Mutex->Mutex.ThreadId =
451 WalkState->Thread->ThreadId;
452
453 /*
454 * Update the current SyncLevel only if this is not an auto-
455 * serialized method. In the auto case, we have to ignore
456 * the sync level for the method mutex (created for the
457 * auto-serialization) because we have no idea of what the
458 * sync level should be. Therefore, just ignore it.
459 */
460 if (!(ObjDesc->Method.InfoFlags &
462 {
463 WalkState->Thread->CurrentSyncLevel =
464 ObjDesc->Method.SyncLevel;
465 }
466 }
467 else
468 {
470 ObjDesc->Method.Mutex->Mutex.SyncLevel;
471
472 ObjDesc->Method.Mutex->Mutex.ThreadId =
474 }
475 }
476
477 /* Always increase acquisition depth */
478
480 }
481
482 /*
483 * Allocate an Owner ID for this method, only if this is the first thread
484 * to begin concurrent execution. We only need one OwnerId, even if the
485 * method is invoked recursively.
486 */
487 if (!ObjDesc->Method.OwnerId)
488 {
490 if (ACPI_FAILURE (Status))
491 {
492 goto Cleanup;
493 }
494 }
495
496 /*
497 * Increment the method parse tree thread count since it has been
498 * reentered one more time (even if it is the same thread)
499 */
500 ObjDesc->Method.ThreadCount++;
501 AcpiMethodCount++;
503
504
505Cleanup:
506 /* On error, must release the method mutex (if present) */
507
508 if (ObjDesc->Method.Mutex)
509 {
511 }
513}
#define AE_NULL_ENTRY
Definition: acexcep.h:118
#define AE_AML_MUTEX_ORDER
Definition: acexcep.h:200
#define AE_AML_METHOD_LIMIT
Definition: acexcep.h:198
#define AE_OK
Definition: acexcep.h:97
#define ACPI_METHOD_IGNORE_SYNC_LEVEL
Definition: acobject.h:240
#define ACPI_METHOD_SERIALIZED
Definition: acobject.h:238
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
ACPI_THREAD_ID AcpiOsGetThreadId(void)
Definition: osl.c:217
#define AcpiOsReleaseMutex(Handle)
Definition: actypes.h:277
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
#define ACPI_UINT8_MAX
Definition: actypes.h:64
ACPI_STATUS AcpiUtAllocateOwnerId(ACPI_OWNER_ID *OwnerId)
Definition: utownerid.c:68
static const WCHAR Cleanup[]
Definition: register.c:80
static ACPI_STATUS AcpiDsCreateMethodMutex(ACPI_OPERAND_OBJECT *MethodDesc)
Definition: dsmethod.c:301
ACPI_STATUS AcpiExSystemWaitMutex(ACPI_MUTEX Mutex, UINT16 Timeout)
Definition: exsystem.c:120
void AcpiExStartTraceMethod(ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: extrace.c:224
ACPI_OWNER_ID OwnerId
Definition: acobject.h:229
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:216
union acpi_operand_object * Mutex
Definition: acobject.h:219
ACPI_OBJECT_COMMON_HEADER UINT8 SyncLevel
Definition: acobject.h:186
UINT16 AcquisitionDepth
Definition: acobject.h:187
ACPI_THREAD_ID ThreadId
Definition: acobject.h:189
ACPI_MUTEX OsMutex
Definition: acobject.h:188
UINT8 OriginalSyncLevel
Definition: acobject.h:194
ACPI_STATE_COMMON UINT8 CurrentSyncLevel
Definition: aclocal.h:764
ACPI_THREAD_ID ThreadId
Definition: aclocal.h:767
ACPI_THREAD_STATE * Thread
Definition: acstruct.h:127
ACPI_OBJECT_MUTEX Mutex
Definition: acobject.h:526

Referenced by AcpiDsCallControlMethod(), and AcpiPsExecuteMethod().

◆ AcpiDsBuildInternalBufferObj()

ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
UINT32  BufferLength,
ACPI_OPERAND_OBJECT **  ObjDescPtr 
)

Definition at line 188 of file dsobject.c.

193{
195 ACPI_OPERAND_OBJECT *ObjDesc;
196 ACPI_PARSE_OBJECT *ByteList;
197 UINT32 ByteListLength = 0;
198
199
200 ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
201
202
203 /*
204 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
205 * The buffer object already exists (from the NS node), otherwise it must
206 * be created.
207 */
208 ObjDesc = *ObjDescPtr;
209 if (!ObjDesc)
210 {
211 /* Create a new buffer object */
212
214 *ObjDescPtr = ObjDesc;
215 if (!ObjDesc)
216 {
218 }
219 }
220
221 /*
222 * Second arg is the buffer data (optional) ByteList can be either
223 * individual bytes or a string initializer. In either case, a
224 * ByteList appears in the AML.
225 */
226 Arg = Op->Common.Value.Arg; /* skip first arg */
227
228 ByteList = Arg->Named.Next;
229 if (ByteList)
230 {
231 if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
232 {
234 "Expecting bytelist, found AML opcode 0x%X in op %p",
235 ByteList->Common.AmlOpcode, ByteList));
236
237 AcpiUtRemoveReference (ObjDesc);
238 return (AE_TYPE);
239 }
240
241 ByteListLength = (UINT32) ByteList->Common.Value.Integer;
242 }
243
244 /*
245 * The buffer length (number of bytes) will be the larger of:
246 * 1) The specified buffer length and
247 * 2) The length of the initializer byte list
248 */
249 ObjDesc->Buffer.Length = BufferLength;
250 if (ByteListLength > BufferLength)
251 {
252 ObjDesc->Buffer.Length = ByteListLength;
253 }
254
255 /* Allocate the buffer */
256
257 if (ObjDesc->Buffer.Length == 0)
258 {
259 ObjDesc->Buffer.Pointer = NULL;
261 "Buffer defined with zero length in AML, creating\n"));
262 }
263 else
264 {
265 ObjDesc->Buffer.Pointer =
266 ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length);
267 if (!ObjDesc->Buffer.Pointer)
268 {
269 AcpiUtDeleteObjectDesc (ObjDesc);
271 }
272
273 /* Initialize buffer from the ByteList (if present) */
274
275 if (ByteList)
276 {
277 memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
278 ByteListLength);
279 }
280 }
281
282 ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
283 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
285}
unsigned int UINT32
#define AE_TYPE
Definition: acexcep.h:116
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
void AcpiUtDeleteObjectDesc(ACPI_OPERAND_OBJECT *Object)
Definition: utobject.c:473
#define AML_INT_BYTELIST_OP
Definition: amlcode.h:209
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by AcpiDsEvalDataObjectOperands().

◆ AcpiDsBuildInternalObject()

ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_OPERAND_OBJECT **  ObjDescPtr 
)

Definition at line 72 of file dsobject.c.

76{
77 ACPI_OPERAND_OBJECT *ObjDesc;
79
80
81 ACPI_FUNCTION_TRACE (DsBuildInternalObject);
82
83
84 *ObjDescPtr = NULL;
85 if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
86 {
87 /*
88 * This is a named object reference. If this name was
89 * previously looked up in the namespace, it was stored in
90 * this op. Otherwise, go ahead and look it up now
91 */
92 if (!Op->Common.Node)
93 {
94 /* Check if we are resolving a named reference within a package */
95
96 if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
97 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
98 {
99 /*
100 * We won't resolve package elements here, we will do this
101 * after all ACPI tables are loaded into the namespace. This
102 * behavior supports both forward references to named objects
103 * and external references to objects in other tables.
104 */
105 goto CreateNewObject;
106 }
107 else
108 {
109 Status = AcpiNsLookup (WalkState->ScopeInfo,
110 Op->Common.Value.String,
114 ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
115 if (ACPI_FAILURE (Status))
116 {
118 Op->Common.Value.String, Status);
120 }
121 }
122 }
123 }
124
125CreateNewObject:
126
127 /* Create and init a new internal ACPI object */
128
130 (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
131 if (!ObjDesc)
132 {
134 }
135
137 WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
138 if (ACPI_FAILURE (Status))
139 {
140 AcpiUtRemoveReference (ObjDesc);
142 }
143
144 /*
145 * Handling for unresolved package reference elements.
146 * These are elements that are namepaths.
147 */
148 if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
149 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
150 {
151 ObjDesc->Reference.Resolved = TRUE;
152
153 if ((Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
154 !ObjDesc->Reference.Node)
155 {
156 /*
157 * Name was unresolved above.
158 * Get the prefix node for later lookup
159 */
160 ObjDesc->Reference.Node = WalkState->ScopeInfo->Scope.Node;
161 ObjDesc->Reference.Aml = Op->Common.Aml;
162 ObjDesc->Reference.Resolved = FALSE;
163 }
164 }
165
166 *ObjDescPtr = ObjDesc;
168}
@ ACPI_IMODE_EXECUTE
Definition: aclocal.h:169
#define ACPI_ERROR_NAMESPACE(s, p, e)
Definition: acmacros.h:462
ACPI_STATUS AcpiNsLookup(ACPI_GENERIC_STATE *ScopeInfo, char *Name, ACPI_OBJECT_TYPE Type, ACPI_INTERPRETER_MODE InterpreterMode, UINT32 Flags, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **RetNode)
Definition: nsaccess.c:328
#define ACPI_NS_DONT_OPEN_SCOPE
Definition: acnamesp.h:64
#define ACPI_NS_SEARCH_PARENT
Definition: acnamesp.h:63
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define ACPI_CAST_INDIRECT_PTR(t, p)
Definition: actypes.h:545
#define ACPI_TYPE_ANY
Definition: actypes.h:687
#define AML_VARIABLE_PACKAGE_OP
Definition: amlcode.h:63
#define AML_PACKAGE_OP
Definition: amlcode.h:62
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ACPI_STATUS AcpiDsInitObjectFromOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc)
Definition: dsobject.c:373
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:447
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540

Referenced by AcpiDsBuildInternalPackageObj(), and AcpiDsCreateNode().

◆ AcpiDsBuildInternalPackageObj()

ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT op,
UINT32  PackageLength,
ACPI_OPERAND_OBJECT **  ObjDesc 
)

Definition at line 94 of file dspkginit.c.

99{
102 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
104 BOOLEAN ModuleLevelCode = FALSE;
105 UINT16 ReferenceCount;
107 UINT32 i;
108
109
110 ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj);
111
112
113 /* Check if we are executing module level code */
114
115 if (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)
116 {
117 ModuleLevelCode = TRUE;
118 }
119
120 /* Find the parent of a possibly nested package */
121
122 Parent = Op->Common.Parent;
123 while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
124 (Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
125 {
126 Parent = Parent->Common.Parent;
127 }
128
129 /*
130 * If we are evaluating a Named package object of the form:
131 * Name (xxxx, Package)
132 * the package object already exists, otherwise it must be created.
133 */
134 ObjDesc = *ObjDescPtr;
135 if (!ObjDesc)
136 {
138 *ObjDescPtr = ObjDesc;
139 if (!ObjDesc)
140 {
142 }
143
144 ObjDesc->Package.Node = Parent->Common.Node;
145 }
146
147 if (ObjDesc->Package.Flags & AOPOBJ_DATA_VALID) /* Just in case */
148 {
150 }
151
152 /*
153 * Allocate the element array (array of pointers to the individual
154 * objects) if necessary. the count is based on the NumElements
155 * parameter. Add an extra pointer slot so that the list is always
156 * null terminated.
157 */
158 if (!ObjDesc->Package.Elements)
159 {
161 ((ACPI_SIZE) ElementCount + 1) * sizeof (void *));
162
163 if (!ObjDesc->Package.Elements)
164 {
165 AcpiUtDeleteObjectDesc (ObjDesc);
167 }
168
169 ObjDesc->Package.Count = ElementCount;
170 }
171
172 /* First arg is element count. Second arg begins the initializer list */
173
174 Arg = Op->Common.Value.Arg;
175 Arg = Arg->Common.Next;
176
177 /*
178 * If we are executing module-level code, we will defer the
179 * full resolution of the package elements in order to support
180 * forward references from the elements. This provides
181 * compatibility with other ACPI implementations.
182 */
183 if (ModuleLevelCode)
184 {
185 ObjDesc->Package.AmlStart = WalkState->Aml;
186 ObjDesc->Package.AmlLength = 0;
187
189 "%s: Deferring resolution of Package elements\n",
191 }
192
193 /*
194 * Initialize the elements of the package, up to the NumElements count.
195 * Package is automatically padded with uninitialized (NULL) elements
196 * if NumElements is greater than the package list length. Likewise,
197 * Package is truncated if NumElements is less than the list length.
198 */
199 for (i = 0; Arg && (i < ElementCount); i++)
200 {
201 if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
202 {
203 if (!Arg->Common.Node)
204 {
205 /*
206 * This is the case where an expression has returned a value.
207 * The use of expressions (TermArgs) within individual
208 * package elements is not supported by the AML interpreter,
209 * even though the ASL grammar supports it. Example:
210 *
211 * Name (INT1, 0x1234)
212 *
213 * Name (PKG3, Package () {
214 * Add (INT1, 0xAAAA0000)
215 * })
216 *
217 * 1) No known AML interpreter supports this type of construct
218 * 2) This fixes a fault if the construct is encountered
219 */
221 "Expressions within package elements are not supported"));
222
223 /* Cleanup the return object, it is not needed */
224
227 }
228
229 if (Arg->Common.Node->Type == ACPI_TYPE_METHOD)
230 {
231 /*
232 * A method reference "looks" to the parser to be a method
233 * invocation, so we special case it here
234 */
235 Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
237 WalkState, Arg, &ObjDesc->Package.Elements[i]);
238 }
239 else
240 {
241 /* This package element is already built, just get it */
242
243 ObjDesc->Package.Elements[i] =
245 }
246 }
247 else
248 {
250 WalkState, Arg, &ObjDesc->Package.Elements[i]);
251 if (Status == AE_NOT_FOUND)
252 {
253 ACPI_ERROR ((AE_INFO, "%-48s", "****DS namepath not found"));
254 }
255
256 if (!ModuleLevelCode)
257 {
258 /*
259 * Initialize this package element. This function handles the
260 * resolution of named references within the package.
261 * Forward references from module-level code are deferred
262 * until all ACPI tables are loaded.
263 */
265 NULL, &ObjDesc->Package.Elements[i]);
266 }
267 }
268
269 if (*ObjDescPtr)
270 {
271 /* Existing package, get existing reference count */
272
273 ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount;
274 if (ReferenceCount > 1)
275 {
276 /* Make new element ref count match original ref count */
277 /* TBD: Probably need an AcpiUtAddReferences function */
278
279 for (Index = 0; Index < ((UINT32) ReferenceCount - 1); Index++)
280 {
281 AcpiUtAddReference ((ObjDesc->Package.Elements[i]));
282 }
283 }
284 }
285
286 Arg = Arg->Common.Next;
287 }
288
289 /* Check for match between NumElements and actual length of PackageList */
290
291 if (Arg)
292 {
293 /*
294 * NumElements was exhausted, but there are remaining elements in
295 * the PackageList. Truncate the package to NumElements.
296 *
297 * Note: technically, this is an error, from ACPI spec: "It is an
298 * error for NumElements to be less than the number of elements in
299 * the PackageList". However, we just print a message and no
300 * exception is returned. This provides compatibility with other
301 * ACPI implementations. Some firmware implementations will alter
302 * the NumElements on the fly, possibly creating this type of
303 * ill-formed package object.
304 */
305 while (Arg)
306 {
307 /*
308 * We must delete any package elements that were created earlier
309 * and are not going to be used because of the package truncation.
310 */
311 if (Arg->Common.Node)
312 {
315 Arg->Common.Node = NULL;
316 }
317
318 /* Find out how many elements there really are */
319
320 i++;
321 Arg = Arg->Common.Next;
322 }
323
324 ACPI_INFO ((
325 "Actual Package length (%u) is larger than "
326 "NumElements field (%u), truncated",
327 i, ElementCount));
328 }
329 else if (i < ElementCount)
330 {
331 /*
332 * Arg list (elements) was exhausted, but we did not reach
333 * NumElements count.
334 *
335 * Note: this is not an error, the package is padded out
336 * with NULLs as per the ACPI specification.
337 */
339 "%s: Package List length (%u) smaller than NumElements "
340 "count (%u), padded with null elements\n",
341 ACPI_GET_FUNCTION_NAME, i, ElementCount));
342 }
343
344 /* Module-level packages will be resolved later */
345
346 if (!ModuleLevelCode)
347 {
348 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
349 }
350
351 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
353}
unsigned short UINT16
unsigned char BOOLEAN
#define AE_SUPPORT
Definition: acexcep.h:123
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define ACPI_GET_FUNCTION_NAME
Definition: acgcc.h:67
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_INFO(plist)
Definition: acoutput.h:237
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
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 ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752
#define AML_INT_RETURN_VALUE_OP
Definition: amlcode.h:211
ACPI_STATUS AcpiDsBuildInternalObject(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr)
Definition: dsobject.c:72
ACPI_STATUS AcpiDsInitPackageElement(UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
Definition: dspkginit.c:369
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
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:160
union acpi_operand_object ** Elements
Definition: acobject.h:161
ACPI_STATE_COMMON union acpi_operand_object * ObjDesc[ACPI_RESULTS_FRAME_OBJ_NUM]
Definition: aclocal.h:779
UINT8 * Aml
Definition: acstruct.h:91
ACPI_GENERIC_STATE * Results
Definition: acstruct.h:122
UINT32 ParseFlags
Definition: acstruct.h:95
ACPI_RESULT_VALUES Results
Definition: aclocal.h:829
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiDsEvalDataObjectOperands().

◆ AcpiDsCallControlMethod()

ACPI_STATUS AcpiDsCallControlMethod ( ACPI_THREAD_STATE Thread,
ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 531 of file dsmethod.c.

535{
537 ACPI_NAMESPACE_NODE *MethodNode;
538 ACPI_WALK_STATE *NextWalkState = NULL;
539 ACPI_OPERAND_OBJECT *ObjDesc;
541 UINT32 i;
542
543
544 ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
545
547 "Calling method %p, currentstate=%p\n",
548 ThisWalkState->PrevOp, ThisWalkState));
549
550 /*
551 * Get the namespace entry for the control method we are about to call
552 */
553 MethodNode = ThisWalkState->MethodCallNode;
554 if (!MethodNode)
555 {
557 }
558
559 ObjDesc = AcpiNsGetAttachedObject (MethodNode);
560 if (!ObjDesc)
561 {
563 }
564
565 /* Init for new method, possibly wait on method mutex */
566
568 MethodNode, ObjDesc, ThisWalkState);
569 if (ACPI_FAILURE (Status))
570 {
572 }
573
574 /* Begin method parse/execution. Create a new walk state */
575
576 NextWalkState = AcpiDsCreateWalkState (
577 ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread);
578 if (!NextWalkState)
579 {
581 goto Cleanup;
582 }
583
584 /*
585 * The resolved arguments were put on the previous walk state's operand
586 * stack. Operands on the previous walk state stack always
587 * start at index 0. Also, null terminate the list of arguments
588 */
589 ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
590
591 /*
592 * Allocate and initialize the evaluation information block
593 * TBD: this is somewhat inefficient, should change interface to
594 * DsInitAmlWalk. For now, keeps this struct off the CPU stack
595 */
597 if (!Info)
598 {
600 goto Cleanup;
601 }
602
603 Info->Parameters = &ThisWalkState->Operands[0];
604
605 Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
606 ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
608
609 ACPI_FREE (Info);
610 if (ACPI_FAILURE (Status))
611 {
612 goto Cleanup;
613 }
614
615 NextWalkState->MethodNestingDepth = ThisWalkState->MethodNestingDepth + 1;
616
617 /*
618 * Delete the operands on the previous walkstate operand stack
619 * (they were copied to new objects)
620 */
621 for (i = 0; i < ObjDesc->Method.ParamCount; i++)
622 {
623 AcpiUtRemoveReference (ThisWalkState->Operands [i]);
624 ThisWalkState->Operands [i] = NULL;
625 }
626
627 /* Clear the operand stack */
628
629 ThisWalkState->NumOperands = 0;
630
632 "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
633 MethodNode->Name.Ascii, NextWalkState));
634
635 ThisWalkState->MethodPathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
636 ThisWalkState->MethodIsNested = TRUE;
637
638 /* Optional object evaluation log */
639
641 "%-26s: %*s%s\n", " Nested method call",
642 NextWalkState->MethodNestingDepth * 3, " ",
643 &ThisWalkState->MethodPathname[1]));
644
645 /* Invoke an internal method if necessary */
646
648 {
649 Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState);
650 if (Status == AE_OK)
651 {
653 }
654 }
655
657
658
659Cleanup:
660
661 /* On error, we must terminate the method properly */
662
663 AcpiDsTerminateControlMethod (ObjDesc, NextWalkState);
664 AcpiDsDeleteWalkState (NextWalkState);
665
667}
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define AE_NULL_OBJECT
Definition: acexcep.h:117
char * AcpiNsGetNormalizedPathname(ACPI_NAMESPACE_NODE *Node, BOOLEAN NoTrailing)
Definition: nsnames.c:367
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define ACPI_METHOD_INTERNAL_ONLY
Definition: acobject.h:237
#define ACPI_DB_DISPATCH
Definition: acoutput.h:163
#define ACPI_DB_EVALUATION
Definition: acoutput.h:181
#define ACPI_FREE(a)
Definition: actypes.h:386
void AcpiDsTerminateControlMethod(ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:779
ACPI_STATUS AcpiDsBeginMethodExecution(ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:352
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ACPI_NAME_UNION Name
Definition: aclocal.h:191
union acpi_object_method::@610 Dispatch
ACPI_INTERNAL_METHOD Implementation
Definition: acobject.h:224
UINT16 MethodNestingDepth
Definition: acstruct.h:100
char Ascii[4]
Definition: actbl.h:394
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by AcpiPsParseAml().

◆ AcpiDsClearImplicitReturn()

void AcpiDsClearImplicitReturn ( ACPI_WALK_STATE WalkState)

Definition at line 73 of file dsutils.c.

75{
76 ACPI_FUNCTION_NAME (DsClearImplicitReturn);
77
78
79 /*
80 * Slack must be enabled for this feature
81 */
82 if (!AcpiGbl_EnableInterpreterSlack)
83 {
84 return;
85 }
86
87 if (WalkState->ImplicitReturnObj)
88 {
89 /*
90 * Delete any "stale" implicit return. However, in
91 * complex statements, the implicit return value can be
92 * bubbled up several levels.
93 */
95 "Removing reference on stale implicit return obj %p\n",
96 WalkState->ImplicitReturnObj));
97
99 WalkState->ImplicitReturnObj = NULL;
100 }
101}
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
union acpi_operand_object * ImplicitReturnObj
Definition: acstruct.h:112

Referenced by AcpiDsDoImplicitReturn(), AcpiDsExecEndControlOp(), AcpiDsMethodError(), and AcpiPsParseAml().

◆ AcpiDsClearOperands()

void AcpiDsClearOperands ( ACPI_WALK_STATE WalkState)

Definition at line 453 of file dsutils.c.

455{
456 UINT32 i;
457
458
459 ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState);
460
461
462 /* Remove a reference on each operand on the stack */
463
464 for (i = 0; i < WalkState->NumOperands; i++)
465 {
466 /*
467 * Remove a reference to all operands, including both
468 * "Arguments" and "Targets".
469 */
470 AcpiUtRemoveReference (WalkState->Operands[i]);
471 WalkState->Operands[i] = NULL;
472 }
473
474 WalkState->NumOperands = 0;
476}
#define return_VOID
Definition: acoutput.h:495
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105
UINT8 NumOperands
Definition: acstruct.h:80

Referenced by AcpiDsExecEndOp().

◆ AcpiDsCreateBankField()

ACPI_STATUS AcpiDsCreateBankField ( ACPI_PARSE_OBJECT Op,
ACPI_NAMESPACE_NODE RegionNode,
ACPI_WALK_STATE WalkState 
)

Definition at line 748 of file dsfield.c.

752{
756
757
758 ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
759
760
761 /* First arg is the name of the parent OpRegion (must already exist) */
762
763 Arg = Op->Common.Value.Arg;
764 if (!RegionNode)
765 {
766 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
768 ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
769#ifdef ACPI_ASL_COMPILER
770 Status = AcpiDsCreateExternalRegion (Status, Arg,
771 Arg->Common.Value.Name, WalkState, &RegionNode);
772#endif
773 if (ACPI_FAILURE (Status))
774 {
776 Arg->Common.Value.Name, Status);
778 }
779 }
780
781 /* Second arg is the Bank Register (Field) (must already exist) */
782
783 Arg = Arg->Common.Next;
784 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
786 ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
787 if (ACPI_FAILURE (Status))
788 {
790 Arg->Common.Value.String, Status);
792 }
793
794 /*
795 * Third arg is the BankValue
796 * This arg is a TermArg, not a constant
797 * It will be evaluated later, by AcpiDsEvalBankFieldOperands
798 */
799 Arg = Arg->Common.Next;
800
801 /* Fourth arg is the field flags */
802
803 Arg = Arg->Common.Next;
804 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
805
806 /* Each remaining arg is a Named Field */
807
809 Info.RegionNode = RegionNode;
810
811 /*
812 * Use Info.DataRegisterNode to store BankField Op
813 * It's safe because DataRegisterNode will never be used when create
814 * bank field \we store AmlStart and AmlLength in the BankField Op for
815 * late evaluation. Used in AcpiExPrepFieldValue(Info)
816 *
817 * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like
818 * "void *ParentOp"?
819 */
820 Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
821
822 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
824}
unsigned char UINT8
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:717
#define ACPI_TYPE_REGION
Definition: actypes.h:697
static ACPI_STATUS AcpiDsGetFieldNames(ACPI_CREATE_FIELD_INFO *Info, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg)
Definition: dsfield.c:324

Referenced by AcpiDsLoad2EndOp().

◆ AcpiDsCreateBufferField()

ACPI_STATUS AcpiDsCreateBufferField ( ACPI_PARSE_OBJECT Op,
ACPI_WALK_STATE WalkState 
)

Definition at line 165 of file dsfield.c.

168{
172 ACPI_OPERAND_OBJECT *ObjDesc;
173 ACPI_OPERAND_OBJECT *SecondDesc = NULL;
175
176
177 ACPI_FUNCTION_TRACE (DsCreateBufferField);
178
179
180 /*
181 * Get the NameString argument (name of the new BufferField)
182 */
183 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
184 {
185 /* For CreateField, name is the 4th argument */
186
187 Arg = AcpiPsGetArg (Op, 3);
188 }
189 else
190 {
191 /* For all other CreateXXXField operators, name is the 3rd argument */
192
193 Arg = AcpiPsGetArg (Op, 2);
194 }
195
196 if (!Arg)
197 {
199 }
200
201 if (WalkState->DeferredNode)
202 {
203 Node = WalkState->DeferredNode;
204 }
205 else
206 {
207 /* Execute flag should always be set when this function is entered */
208
209 if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
210 {
212 "Parse execute mode is not set"));
214 }
215
216 /* Creating new namespace node, should not already exist */
217
220
221 /*
222 * Mark node temporary if we are executing a normal control
223 * method. (Don't mark if this is a module-level code method)
224 */
225 if (WalkState->MethodNode &&
226 !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
227 {
229 }
230
231 /* Enter the NameString into the namespace */
232
233 Status = AcpiNsLookup (WalkState->ScopeInfo,
234 Arg->Common.Value.String, ACPI_TYPE_ANY,
235 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
236 if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) &&
238 {
239 Status = AE_OK;
240 }
241 else if (ACPI_FAILURE (Status))
242 {
244 Arg->Common.Value.String, Status);
246 }
247 }
248
249 /*
250 * We could put the returned object (Node) on the object stack for later,
251 * but for now, we will put it in the "op" object that the parser uses,
252 * so we can get it again at the end of this scope.
253 */
254 Op->Common.Node = Node;
255
256 /*
257 * If there is no object attached to the node, this node was just created
258 * and we need to create the field object. Otherwise, this was a lookup
259 * of an existing node and we don't want to create the field object again.
260 */
261 ObjDesc = AcpiNsGetAttachedObject (Node);
262 if (ObjDesc)
263 {
265 }
266
267 /*
268 * The Field definition is not fully parsed at this time.
269 * (We must save the address of the AML for the buffer and index operands)
270 */
271
272 /* Create the buffer field object */
273
275 if (!ObjDesc)
276 {
278 goto Cleanup;
279 }
280
281 /*
282 * Remember location in AML stream of the field unit opcode and operands
283 * -- since the buffer and index operands must be evaluated.
284 */
285 SecondDesc = ObjDesc->Common.NextObject;
286 SecondDesc->Extra.AmlStart = Op->Named.Data;
287 SecondDesc->Extra.AmlLength = Op->Named.Length;
288 ObjDesc->BufferField.Node = Node;
289
290 /* Attach constructed field descriptors to parent node */
291
293 if (ACPI_FAILURE (Status))
294 {
295 goto Cleanup;
296 }
297
298
299Cleanup:
300
301 /* Remove local reference to the object */
302
303 AcpiUtRemoveReference (ObjDesc);
305}
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
@ ACPI_IMODE_LOAD_PASS1
Definition: aclocal.h:167
#define ACPI_NS_TEMPORARY
Definition: acnamesp.h:69
#define ACPI_NS_NO_UPSEARCH
Definition: acnamesp.h:62
#define ACPI_NS_ERROR_IF_FOUND
Definition: acnamesp.h:66
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
#define ACPI_PARSE_EXECUTE
Definition: acparser.h:61
ACPI_PARSE_OBJECT * AcpiPsGetArg(ACPI_PARSE_OBJECT *op, UINT32 argn)
Definition: pstree.c:76
#define ACPI_PARSE_DISASSEMBLE
Definition: acparser.h:65
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:701
#define AML_CREATE_FIELD_OP
Definition: amlcode.h:163
UINT32 AmlLength
Definition: acobject.h:485
UINT8 * AmlStart
Definition: acobject.h:484
struct acpi_namespace_node * MethodNode
Definition: acstruct.h:116
struct acpi_namespace_node * DeferredNode
Definition: acstruct.h:111
ACPI_OBJECT_BUFFER_FIELD BufferField
Definition: acobject.h:535
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:541
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsCreateField()

ACPI_STATUS AcpiDsCreateField ( ACPI_PARSE_OBJECT Op,
ACPI_NAMESPACE_NODE RegionNode,
ACPI_WALK_STATE WalkState 
)

Definition at line 534 of file dsfield.c.

538{
542
543
544 ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
545
546
547 /* First arg is the name of the parent OpRegion (must already exist) */
548
549 Arg = Op->Common.Value.Arg;
550
551 if (!RegionNode)
552 {
553 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
555 ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
556#ifdef ACPI_ASL_COMPILER
557 Status = AcpiDsCreateExternalRegion (Status, Arg,
558 Arg->Common.Value.Name, WalkState, &RegionNode);
559#endif
560 if (ACPI_FAILURE (Status))
561 {
563 Arg->Common.Value.Name, Status);
565 }
566 }
567
568 memset (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
569
570 /* Second arg is the field flags */
571
572 Arg = Arg->Common.Next;
573 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
574 Info.Attribute = 0;
575
576 /* Each remaining arg is a Named Field */
577
579 Info.RegionNode = RegionNode;
580
581 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
582 if (ACPI_FAILURE (Status))
583 {
585 }
586
587 if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)
588 {
589 RegionNode->Object->Field.InternalPccBuffer =
590 ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length);
591 if (!RegionNode->Object->Field.InternalPccBuffer)
592 {
594 }
595 }
596
598}
#define ACPI_ADR_SPACE_PLATFORM_COMM
Definition: actypes.h:871
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:716
#define memset(x, y, z)
Definition: compat.h:39
union acpi_operand_object * Object
Definition: aclocal.h:187
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:534

Referenced by AcpiDsLoad2EndOp().

◆ AcpiDsCreateIndexField()

ACPI_STATUS AcpiDsCreateIndexField ( ACPI_PARSE_OBJECT Op,
ACPI_NAMESPACE_NODE RegionNode,
ACPI_WALK_STATE WalkState 
)

Definition at line 842 of file dsfield.c.

846{
850
851
852 ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op);
853
854
855 /* First arg is the name of the Index register (must already exist) */
856
857 Arg = Op->Common.Value.Arg;
858 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
860 ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
861 if (ACPI_FAILURE (Status))
862 {
864 Arg->Common.Value.String, Status);
866 }
867
868 /* Second arg is the data register (must already exist) */
869
870 Arg = Arg->Common.Next;
871 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
873 ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
874 if (ACPI_FAILURE (Status))
875 {
877 Arg->Common.Value.String, Status);
879 }
880
881 /* Next arg is the field flags */
882
883 Arg = Arg->Common.Next;
884 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
885
886 /* Each remaining arg is a Named Field */
887
889 Info.RegionNode = RegionNode;
890
891 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
893}
#define ACPI_TYPE_LOCAL_INDEX_FIELD
Definition: actypes.h:718

Referenced by AcpiDsLoad2EndOp().

◆ AcpiDsCreateNode()

ACPI_STATUS AcpiDsCreateNode ( ACPI_WALK_STATE WalkState,
ACPI_NAMESPACE_NODE Node,
ACPI_PARSE_OBJECT Op 
)

Definition at line 302 of file dsobject.c.

306{
308 ACPI_OPERAND_OBJECT *ObjDesc;
309
310
311 ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
312
313
314 /*
315 * Because of the execution pass through the non-control-method
316 * parts of the table, we can arrive here twice. Only init
317 * the named object node the first time through
318 */
320 {
322 }
323
324 if (!Op->Common.Value.Arg)
325 {
326 /* No arguments, there is nothing to do */
327
329 }
330
331 /* Build an internal object for the argument(s) */
332
334 WalkState, Op->Common.Value.Arg, &ObjDesc);
335 if (ACPI_FAILURE (Status))
336 {
338 }
339
340 /* Re-type the object according to its argument */
341
342 Node->Type = ObjDesc->Common.Type;
343
344 /* Attach obj to node */
345
346 Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
347
348 /* Remove local reference to the object */
349
350 AcpiUtRemoveReference (ObjDesc);
352}

Referenced by AcpiDsExecEndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsCreateOperand()

ACPI_STATUS AcpiDsCreateOperand ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Arg,
UINT32  ArgsRemaining 
)

Definition at line 497 of file dsutils.c.

501{
503 char *NameString;
504 UINT32 NameLength;
505 ACPI_OPERAND_OBJECT *ObjDesc;
506 ACPI_PARSE_OBJECT *ParentOp;
508 ACPI_INTERPRETER_MODE InterpreterMode;
509 const ACPI_OPCODE_INFO *OpInfo;
510
511
512 ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg);
513
514
515 /* A valid name must be looked up in the namespace */
516
517 if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
518 (Arg->Common.Value.String) &&
519 !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
520 {
521 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg));
522
523 /* Get the entire name string from the AML stream */
524
526 Arg->Common.Value.Buffer, &NameString, &NameLength);
527
528 if (ACPI_FAILURE (Status))
529 {
531 }
532
533 /* All prefixes have been handled, and the name is in NameString */
534
535 /*
536 * Special handling for BufferField declarations. This is a deferred
537 * opcode that unfortunately defines the field name as the last
538 * parameter instead of the first. We get here when we are performing
539 * the deferred execution, so the actual name of the field is already
540 * in the namespace. We don't want to attempt to look it up again
541 * because we may be executing in a different scope than where the
542 * actual opcode exists.
543 */
544 if ((WalkState->DeferredNode) &&
545 (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) &&
546 (ArgIndex == (UINT32)
547 ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2)))
548 {
549 ObjDesc = ACPI_CAST_PTR (
551 Status = AE_OK;
552 }
553 else /* All other opcodes */
554 {
555 /*
556 * Differentiate between a namespace "create" operation
557 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
558 * IMODE_EXECUTE) in order to support the creation of
559 * namespace objects during the execution of control methods.
560 */
561 ParentOp = Arg->Common.Parent;
562 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
563
564 if ((OpInfo->Flags & AML_NSNODE) &&
565 (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
566 (ParentOp->Common.AmlOpcode != AML_REGION_OP) &&
567 (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
568 {
569 /* Enter name into namespace if not found */
570
571 InterpreterMode = ACPI_IMODE_LOAD_PASS2;
572 }
573 else
574 {
575 /* Return a failure if name not found */
576
577 InterpreterMode = ACPI_IMODE_EXECUTE;
578 }
579
580 Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
581 ACPI_TYPE_ANY, InterpreterMode,
584 /*
585 * The only case where we pass through (ignore) a NOT_FOUND
586 * error is for the CondRefOf opcode.
587 */
588 if (Status == AE_NOT_FOUND)
589 {
590 if (ParentOp->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
591 {
592 /*
593 * For the Conditional Reference op, it's OK if
594 * the name is not found; We just need a way to
595 * indicate this to the interpreter, set the
596 * object to the root
597 */
598 ObjDesc = ACPI_CAST_PTR (
599 ACPI_OPERAND_OBJECT, AcpiGbl_RootNode);
600 Status = AE_OK;
601 }
602 else if (ParentOp->Common.AmlOpcode == AML_EXTERNAL_OP)
603 {
604 /*
605 * This opcode should never appear here. It is used only
606 * by AML disassemblers and is surrounded by an If(0)
607 * by the ASL compiler.
608 *
609 * Therefore, if we see it here, it is a serious error.
610 */
612 }
613 else
614 {
615 /*
616 * We just plain didn't find it -- which is a
617 * very serious error at this point
618 */
620 }
621 }
622
623 if (ACPI_FAILURE (Status))
624 {
626 NameString, Status);
627 }
628 }
629
630 /* Free the namestring created above */
631
632 ACPI_FREE (NameString);
633
634 /* Check status from the lookup */
635
636 if (ACPI_FAILURE (Status))
637 {
639 }
640
641 /* Put the resulting object onto the current object stack */
642
643 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
644 if (ACPI_FAILURE (Status))
645 {
647 }
648
649 AcpiDbDisplayArgumentObject (ObjDesc, WalkState);
650 }
651 else
652 {
653 /* Check for null name case */
654
655 if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
656 !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
657 {
658 /*
659 * If the name is null, this means that this is an
660 * optional result parameter that was not specified
661 * in the original ASL. Create a Zero Constant for a
662 * placeholder. (Store to a constant is a Noop.)
663 */
664 Opcode = AML_ZERO_OP; /* Has no arguments! */
665
667 "Null namepath: Arg=%p\n", Arg));
668 }
669 else
670 {
671 Opcode = Arg->Common.AmlOpcode;
672 }
673
674 /* Get the object type of the argument */
675
676 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
677 if (OpInfo->ObjectType == ACPI_TYPE_INVALID)
678 {
680 }
681
682 if ((OpInfo->Flags & AML_HAS_RETVAL) ||
683 (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
684 {
685 /*
686 * Use value that was already previously returned
687 * by the evaluation of this argument
688 */
689 Status = AcpiDsResultPop (&ObjDesc, WalkState);
690 if (ACPI_FAILURE (Status))
691 {
692 /*
693 * Only error is underflow, and this indicates
694 * a missing or null operand!
695 */
697 "Missing or null operand"));
699 }
700 }
701 else
702 {
703 /* Create an ACPI_INTERNAL_OBJECT for the argument */
704
705 ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType);
706 if (!ObjDesc)
707 {
709 }
710
711 /* Initialize the new object */
712
714 WalkState, Arg, Opcode, &ObjDesc);
715 if (ACPI_FAILURE (Status))
716 {
717 AcpiUtDeleteObjectDesc (ObjDesc);
719 }
720 }
721
722 /* Put the operand object on the object stack */
723
724 Status = AcpiDsObjStackPush (ObjDesc, WalkState);
725 if (ACPI_FAILURE (Status))
726 {
728 }
729
730 AcpiDbDisplayArgumentObject (ObjDesc, WalkState);
731 }
732
734}
#define AE_NOT_IMPLEMENTED
Definition: acexcep.h:122
#define AE_AML_NAME_NOT_FOUND
Definition: acexcep.h:193
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
#define ACPI_PARSEOP_IN_STACK
Definition: aclocal.h:1121
ACPI_INTERPRETER_MODE
Definition: aclocal.h:166
@ ACPI_IMODE_LOAD_PASS2
Definition: aclocal.h:168
#define ACPI_TYPE_INVALID
Definition: actypes.h:742
#define AML_REGION_OP
Definition: amlcode.h:180
#define AML_NSNODE
Definition: amlcode.h:324
#define AML_HAS_RETVAL
Definition: amlcode.h:327
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define AML_INT_METHODCALL_OP
Definition: amlcode.h:210
#define AML_CONDITIONAL_REF_OF_OP
Definition: amlcode.h:162
#define AML_ZERO_OP
Definition: amlcode.h:51
ACPI_STATUS AcpiDsResultPop(ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:78
ACPI_STATUS AcpiDsObjStackPush(void *Object, ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:342
ACPI_STATUS AcpiExGetNameString(ACPI_OBJECT_TYPE DataType, UINT8 *InAmlAddress, char **OutNameString, UINT32 *OutNameLength)
Definition: exnames.c:278
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:331
UINT16 Flags
Definition: aclocal.h:873
UINT8 ObjectType
Definition: aclocal.h:874
UINT16 Opcode
Definition: acstruct.h:78

Referenced by AcpiDsCreateOperands(), AcpiDsEvalBankFieldOperands(), AcpiDsEvalDataObjectOperands(), AcpiDsEvaluateNamePath(), and AcpiDsGetPredicateValue().

◆ AcpiDsCreateOperands()

ACPI_STATUS AcpiDsCreateOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT FirstArg 
)

Definition at line 753 of file dsutils.c.

756{
760 UINT32 ArgCount = 0;
761 UINT32 Index = WalkState->NumOperands;
762 UINT32 i;
763
764
765 ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg);
766
767
768 /* Get all arguments in the list */
769
770 Arg = FirstArg;
771 while (Arg)
772 {
774 {
776 }
777
778 Arguments[Index] = Arg;
779 WalkState->Operands [Index] = NULL;
780
781 /* Move on to next argument, if any */
782
783 Arg = Arg->Common.Next;
784 ArgCount++;
785 Index++;
786 }
787
789 "NumOperands %d, ArgCount %d, Index %d\n",
790 WalkState->NumOperands, ArgCount, Index));
791
792 /* Create the interpreter arguments, in reverse order */
793
794 Index--;
795 for (i = 0; i < ArgCount; i++)
796 {
797 Arg = Arguments[Index];
798 WalkState->OperandIndex = (UINT8) Index;
799
800 Status = AcpiDsCreateOperand (WalkState, Arg, Index);
801 if (ACPI_FAILURE (Status))
802 {
803 goto Cleanup;
804 }
805
807 "Created Arg #%u (%p) %u args total\n",
808 Index, Arg, ArgCount));
809 Index--;
810 }
811
813
814
815Cleanup:
816 /*
817 * We must undo everything done above; meaning that we must
818 * pop everything off of the operand stack and delete those
819 * objects
820 */
821 AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
822
823 ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index));
825}
#define AE_BAD_DATA
Definition: acexcep.h:154
#define ACPI_OBJ_NUM_OPERANDS
Definition: acconfig.h:172
ACPI_STATUS AcpiDsCreateOperand(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg, UINT32 ArgIndex)
Definition: dsutils.c:497
void AcpiDsObjStackPopAndDelete(UINT32 PopCount, ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:441
UINT8 OperandIndex
Definition: acstruct.h:81

Referenced by AcpiDsEvalBufferFieldOperands(), AcpiDsEvalRegionOperands(), AcpiDsEvalTableRegionOperands(), AcpiDsExecEndControlOp(), AcpiDsExecEndOp(), AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsCreateWalkState()

ACPI_WALK_STATE * AcpiDsCreateWalkState ( ACPI_OWNER_ID  OwnerId,
ACPI_PARSE_OBJECT Origin,
ACPI_OPERAND_OBJECT MthDesc,
ACPI_THREAD_STATE Thread 
)

Definition at line 600 of file dswstate.c.

605{
606 ACPI_WALK_STATE *WalkState;
607
608
609 ACPI_FUNCTION_TRACE (DsCreateWalkState);
610
611
612 WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE));
613 if (!WalkState)
614 {
616 }
617
619 WalkState->MethodDesc = MethodDesc;
620 WalkState->OwnerId = OwnerId;
621 WalkState->Origin = Origin;
622 WalkState->Thread = Thread;
623
624 WalkState->ParserState.StartOp = Origin;
625
626 /* Init the method args/local */
627
628#ifndef ACPI_CONSTANT_EVAL_ONLY
629 AcpiDsMethodDataInit (WalkState);
630#endif
631
632 /* Put the new state at the head of the walk list */
633
634 if (Thread)
635 {
636 AcpiDsPushWalkState (WalkState, Thread);
637 }
638
639 return_PTR (WalkState);
640}
#define ACPI_DESC_TYPE_WALK
Definition: acobject.h:574
#define return_PTR(s)
Definition: acoutput.h:497
void AcpiDsMethodDataInit(ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:100
void AcpiDsPushWalkState(ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:526
_Must_inspect_result_ _In_opt_ PVOID OwnerId
Definition: fsrtlfuncs.h:907
union acpi_parse_object * StartOp
Definition: aclocal.h:1106
union acpi_operand_object * MethodDesc
Definition: acstruct.h:115
ACPI_PARSE_OBJECT * Origin
Definition: acstruct.h:120
UINT8 DescriptorType
Definition: acstruct.h:76
ACPI_OWNER_ID OwnerId
Definition: acstruct.h:82
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsCallControlMethod(), AcpiDsExecuteArguments(), AcpiNsOneCompleteParse(), AcpiPsExecuteMethod(), and AcpiPsExecuteTable().

◆ AcpiDsDeleteResultIfNotUsed()

void AcpiDsDeleteResultIfNotUsed ( ACPI_PARSE_OBJECT Op,
ACPI_OPERAND_OBJECT ResultObj,
ACPI_WALK_STATE WalkState 
)

Definition at line 359 of file dsutils.c.

363{
364 ACPI_OPERAND_OBJECT *ObjDesc;
366
367
368 ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj);
369
370
371 if (!Op)
372 {
373 ACPI_ERROR ((AE_INFO, "Null Op"));
375 }
376
377 if (!ResultObj)
378 {
380 }
381
382 if (!AcpiDsIsResultUsed (Op, WalkState))
383 {
384 /* Must pop the result stack (ObjDesc should be equal to ResultObj) */
385
386 Status = AcpiDsResultPop (&ObjDesc, WalkState);
387 if (ACPI_SUCCESS (Status))
388 {
389 AcpiUtRemoveReference (ResultObj);
390 }
391 }
392
394}
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
BOOLEAN AcpiDsIsResultUsed(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:187

Referenced by AcpiDsExecEndOp().

◆ AcpiDsDeleteWalkState()

void AcpiDsDeleteWalkState ( ACPI_WALK_STATE WalkState)

Definition at line 780 of file dswstate.c.

782{
784
785
786 ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState);
787
788
789 if (!WalkState)
790 {
792 }
793
794 if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK)
795 {
796 ACPI_ERROR ((AE_INFO, "%p is not a valid walk state",
797 WalkState));
799 }
800
801 /* There should not be any open scopes */
802
803 if (WalkState->ParserState.Scope)
804 {
805 ACPI_ERROR ((AE_INFO, "%p walk still has a scope list",
806 WalkState));
807 AcpiPsCleanupScope (&WalkState->ParserState);
808 }
809
810 /* Always must free any linked control states */
811
812 while (WalkState->ControlState)
813 {
814 State = WalkState->ControlState;
815 WalkState->ControlState = State->Common.Next;
816
818 }
819
820 /* Always must free any linked parse states */
821
822 while (WalkState->ScopeInfo)
823 {
824 State = WalkState->ScopeInfo;
825 WalkState->ScopeInfo = State->Common.Next;
826
828 }
829
830 /* Always must free any stacked result states */
831
832 while (WalkState->Results)
833 {
834 State = WalkState->Results;
835 WalkState->Results = State->Common.Next;
836
838 }
839
840 ACPI_FREE (WalkState);
842}
void AcpiPsCleanupScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:277
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
union acpi_generic_state * Scope
Definition: aclocal.h:1108
ACPI_GENERIC_STATE * ControlState
Definition: acstruct.h:110

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsCallControlMethod(), AcpiDsExecuteArguments(), AcpiNsOneCompleteParse(), AcpiPsExecuteMethod(), AcpiPsExecuteTable(), and AcpiPsParseAml().

◆ AcpiDsDoImplicitReturn()

BOOLEAN AcpiDsDoImplicitReturn ( ACPI_OPERAND_OBJECT ReturnDesc,
ACPI_WALK_STATE WalkState,
BOOLEAN  AddReference 
)

Definition at line 123 of file dsutils.c.

127{
128 ACPI_FUNCTION_NAME (DsDoImplicitReturn);
129
130
131 /*
132 * Slack must be enabled for this feature, and we must
133 * have a valid return object
134 */
135 if ((!AcpiGbl_EnableInterpreterSlack) ||
136 (!ReturnDesc))
137 {
138 return (FALSE);
139 }
140
142 "Result %p will be implicitly returned; Prev=%p\n",
143 ReturnDesc,
144 WalkState->ImplicitReturnObj));
145
146 /*
147 * Delete any "stale" implicit return value first. However, in
148 * complex statements, the implicit return value can be
149 * bubbled up several levels, so we don't clear the value if it
150 * is the same as the ReturnDesc.
151 */
152 if (WalkState->ImplicitReturnObj)
153 {
154 if (WalkState->ImplicitReturnObj == ReturnDesc)
155 {
156 return (TRUE);
157 }
158 AcpiDsClearImplicitReturn (WalkState);
159 }
160
161 /* Save the implicit return value, add a reference if requested */
162
163 WalkState->ImplicitReturnObj = ReturnDesc;
164 if (AddReference)
165 {
166 AcpiUtAddReference (ReturnDesc);
167 }
168
169 return (TRUE);
170}
void AcpiDsClearImplicitReturn(ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:73

Referenced by AcpiDsGetPredicateValue(), AcpiDsIsResultUsed(), and AcpiDsRestartControlMethod().

◆ AcpiDsDumpMethodStack()

void AcpiDsDumpMethodStack ( ACPI_STATUS  Status,
ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 249 of file dsdebug.c.

253{
254 return;
255}

Referenced by AcpiDsMethodError().

◆ AcpiDsEvalBankFieldOperands()

ACPI_STATUS AcpiDsEvalBankFieldOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 755 of file dsopcode.c.

758{
760 ACPI_OPERAND_OBJECT *ObjDesc;
761 ACPI_OPERAND_OBJECT *OperandDesc;
763 ACPI_PARSE_OBJECT *NextOp;
765
766
767 ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);
768
769
770 /*
771 * This is where we evaluate the BankValue field of the
772 * BankField declaration
773 */
774
775 /* NextOp points to the op that holds the Region */
776
777 NextOp = Op->Common.Value.Arg;
778
779 /* NextOp points to the op that holds the Bank Register */
780
781 NextOp = NextOp->Common.Next;
782
783 /* NextOp points to the op that holds the Bank Value */
784
785 NextOp = NextOp->Common.Next;
786
787 /*
788 * Set proper index into operand stack for AcpiDsObjStackPush
789 * invoked inside AcpiDsCreateOperand.
790 *
791 * We use WalkState->Operands[0] to store the evaluated BankValue
792 */
793 WalkState->OperandIndex = 0;
794
795 Status = AcpiDsCreateOperand (WalkState, NextOp, 0);
796 if (ACPI_FAILURE (Status))
797 {
799 }
800
801 Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);
802 if (ACPI_FAILURE (Status))
803 {
805 }
806
808 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);
809 /*
810 * Get the BankValue operand and save it
811 * (at Top of stack)
812 */
813 OperandDesc = WalkState->Operands[0];
814
815 /* Arg points to the start Bank Field */
816
817 Arg = AcpiPsGetArg (Op, 4);
818 while (Arg)
819 {
820 /* Ignore OFFSET and ACCESSAS terms here */
821
822 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
823 {
824 Node = Arg->Common.Node;
825
826 ObjDesc = AcpiNsGetAttachedObject (Node);
827 if (!ObjDesc)
828 {
830 }
831
832 ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;
833 }
834
835 /* Move to next field in the list */
836
837 Arg = Arg->Common.Next;
838 }
839
840 AcpiUtRemoveReference (OperandDesc);
842}
#define AE_NOT_EXIST
Definition: acexcep.h:114
#define ACPI_WALK_OPERANDS
Definition: acinterp.h:48
#define ACPI_DUMP_OPERANDS(a, b, c)
Definition: acoutput.h:486
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
#define AML_INT_NAMEDFIELD_OP
Definition: amlcode.h:206
ACPI_STATUS AcpiExResolveToValue(ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
Definition: exresolv.c:79
ACPI_OBJECT_BANK_FIELD BankField
Definition: acobject.h:536
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520

Referenced by AcpiDsExecEndOp().

◆ AcpiDsEvalBufferFieldOperands()

ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 321 of file dsopcode.c.

324{
326 ACPI_OPERAND_OBJECT *ObjDesc;
328 ACPI_PARSE_OBJECT *NextOp;
329
330
331 ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op);
332
333
334 /*
335 * This is where we evaluate the address and length fields of the
336 * CreateXxxField declaration
337 */
338 Node = Op->Common.Node;
339
340 /* NextOp points to the op that holds the Buffer */
341
342 NextOp = Op->Common.Value.Arg;
343
344 /* Evaluate/create the address and length operands */
345
346 Status = AcpiDsCreateOperands (WalkState, NextOp);
347 if (ACPI_FAILURE (Status))
348 {
350 }
351
352 ObjDesc = AcpiNsGetAttachedObject (Node);
353 if (!ObjDesc)
354 {
356 }
357
358 /* Resolve the operands */
359
361 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
362 if (ACPI_FAILURE (Status))
363 {
364 ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",
365 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
366
368 }
369
370 /* Initialize the Buffer Field */
371
372 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
373 {
374 /* NOTE: Slightly different operands for this opcode */
375
376 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
377 WalkState->Operands[0], WalkState->Operands[1],
378 WalkState->Operands[2], WalkState->Operands[3]);
379 }
380 else
381 {
382 /* All other, CreateXxxField opcodes */
383
384 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
385 WalkState->Operands[0], WalkState->Operands[1],
386 NULL, WalkState->Operands[2]);
387 }
388
390}
static ACPI_STATUS AcpiDsInitBufferField(UINT16 AmlOpcode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *BufferDesc, ACPI_OPERAND_OBJECT *OffsetDesc, ACPI_OPERAND_OBJECT *LengthDesc, ACPI_OPERAND_OBJECT *ResultDesc)
Definition: dsopcode.c:116
ACPI_STATUS AcpiDsCreateOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *FirstArg)
Definition: dsutils.c:753
ACPI_STATUS AcpiExResolveOperands(UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
Definition: exresop.c:145

Referenced by AcpiDsExecEndOp().

◆ AcpiDsEvalDataObjectOperands()

ACPI_STATUS AcpiDsEvalDataObjectOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_OPERAND_OBJECT ObjDesc 
)

Definition at line 637 of file dsopcode.c.

641{
643 ACPI_OPERAND_OBJECT *ArgDesc;
645
646
647 ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands);
648
649
650 /* The first operand (for all of these data objects) is the length */
651
652 /*
653 * Set proper index into operand stack for AcpiDsObjStackPush
654 * invoked inside AcpiDsCreateOperand.
655 */
656 WalkState->OperandIndex = WalkState->NumOperands;
657
658 /* Ignore if child is not valid */
659
660 if (!Op->Common.Value.Arg)
661 {
663 "Missing child while evaluating opcode %4.4X, Op %p",
664 Op->Common.AmlOpcode, Op));
666 }
667
668 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
669 if (ACPI_FAILURE (Status))
670 {
672 }
673
674 Status = AcpiExResolveOperands (WalkState->Opcode,
675 &(WalkState->Operands [WalkState->NumOperands -1]),
676 WalkState);
677 if (ACPI_FAILURE (Status))
678 {
680 }
681
682 /* Extract length operand */
683
684 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
685 Length = (UINT32) ArgDesc->Integer.Value;
686
687 /* Cleanup for length operand */
688
689 Status = AcpiDsObjStackPop (1, WalkState);
690 if (ACPI_FAILURE (Status))
691 {
693 }
694
695 AcpiUtRemoveReference (ArgDesc);
696
697 /*
698 * Create the actual data object
699 */
700 switch (Op->Common.AmlOpcode)
701 {
702 case AML_BUFFER_OP:
703
705 WalkState, Op, Length, &ObjDesc);
706 break;
707
708 case AML_PACKAGE_OP:
710
712 WalkState, Op, Length, &ObjDesc);
713 break;
714
715 default:
716
718 }
719
720 if (ACPI_SUCCESS (Status))
721 {
722 /*
723 * Return the object in the WalkState, unless the parent is a package -
724 * in this case, the return object will be stored in the parse tree
725 * for the package.
726 */
727 if ((!Op->Common.Parent) ||
728 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
729 (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&
730 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
731 {
732 WalkState->ResultObj = ObjDesc;
733 }
734 }
735
737}
#define AML_NAME_OP
Definition: amlcode.h:54
#define AML_BUFFER_OP
Definition: amlcode.h:61
ACPI_STATUS AcpiDsBuildInternalBufferObj(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr)
Definition: dsobject.c:188
ACPI_STATUS AcpiDsBuildInternalPackageObj(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 ElementCount, ACPI_OPERAND_OBJECT **ObjDescPtr)
Definition: dspkginit.c:94
ACPI_STATUS AcpiDsObjStackPop(UINT32 PopCount, ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:391
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
union acpi_operand_object * ResultObj
Definition: acstruct.h:121

Referenced by AcpiDsExecEndOp().

◆ AcpiDsEvalRegionOperands()

ACPI_STATUS AcpiDsEvalRegionOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 408 of file dsopcode.c.

411{
413 ACPI_OPERAND_OBJECT *ObjDesc;
414 ACPI_OPERAND_OBJECT *OperandDesc;
416 ACPI_PARSE_OBJECT *NextOp;
418
419
420 ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op);
421
422
423 /*
424 * This is where we evaluate the address and length fields of the
425 * OpRegion declaration
426 */
427 Node = Op->Common.Node;
428
429 /* NextOp points to the op that holds the SpaceID */
430
431 NextOp = Op->Common.Value.Arg;
432 SpaceId = (ACPI_ADR_SPACE_TYPE) NextOp->Common.Value.Integer;
433
434 /* NextOp points to address op */
435
436 NextOp = NextOp->Common.Next;
437
438 /* Evaluate/create the address and length operands */
439
440 Status = AcpiDsCreateOperands (WalkState, NextOp);
441 if (ACPI_FAILURE (Status))
442 {
444 }
445
446 /* Resolve the length and address operands to numbers */
447
449 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
450 if (ACPI_FAILURE (Status))
451 {
453 }
454
455 ObjDesc = AcpiNsGetAttachedObject (Node);
456 if (!ObjDesc)
457 {
459 }
460
461 /*
462 * Get the length operand and save it
463 * (at Top of stack)
464 */
465 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
466
467 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
468 AcpiUtRemoveReference (OperandDesc);
469
470 /* A zero-length operation region is unusable. Just warn */
471
473 {
475 "Operation Region [%4.4s] has zero length (SpaceId %X)",
476 Node->Name.Ascii, SpaceId));
477 }
478
479 /*
480 * Get the address and save it
481 * (at top of stack - 1)
482 */
483 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
484
485 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS)
486 OperandDesc->Integer.Value;
487 AcpiUtRemoveReference (OperandDesc);
488
489 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
490 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
491 ObjDesc->Region.Length));
492
494 ObjDesc->Region.Address, ObjDesc->Region.Length, Node);
495
496 /* Now the address and length are valid for this opregion */
497
498 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
500}
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
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 ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE SpaceId
Definition: acpixf.h:832
UINT8 ACPI_ADR_SPACE_TYPE
Definition: actypes.h:859
#define ACPI_NUM_PREDEFINED_REGIONS
Definition: actypes.h:874
ACPI_STATUS AcpiUtAddAddressRange(ACPI_ADR_SPACE_TYPE SpaceId, ACPI_PHYSICAL_ADDRESS Address, UINT32 Length, ACPI_NAMESPACE_NODE *RegionNode)
Definition: utaddress.c:78
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
ACPI_PHYSICAL_ADDRESS Address
Definition: acobject.h:206
ACPI_OBJECT_REGION Region
Definition: acobject.h:527

Referenced by AcpiDsExecEndOp().

◆ AcpiDsEvalTableRegionOperands()

ACPI_STATUS AcpiDsEvalTableRegionOperands ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 519 of file dsopcode.c.

522{
524 ACPI_OPERAND_OBJECT *ObjDesc;
525 ACPI_OPERAND_OBJECT **Operand;
527 ACPI_PARSE_OBJECT *NextOp;
529 UINT32 TableIndex;
530
531
532 ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);
533
534
535 /*
536 * This is where we evaluate the Signature string, OemId string,
537 * and OemTableId string of the Data Table Region declaration
538 */
539 Node = Op->Common.Node;
540
541 /* NextOp points to Signature string op */
542
543 NextOp = Op->Common.Value.Arg;
544
545 /*
546 * Evaluate/create the Signature string, OemId string,
547 * and OemTableId string operands
548 */
549 Status = AcpiDsCreateOperands (WalkState, NextOp);
550 if (ACPI_FAILURE (Status))
551 {
553 }
554
555 Operand = &WalkState->Operands[0];
556
557 /*
558 * Resolve the Signature string, OemId string,
559 * and OemTableId string operands
560 */
562 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
563 if (ACPI_FAILURE (Status))
564 {
565 goto Cleanup;
566 }
567
568 /* Find the ACPI table */
569
571 Operand[0]->String.Pointer,
572 Operand[1]->String.Pointer,
573 Operand[2]->String.Pointer, &TableIndex);
574 if (ACPI_FAILURE (Status))
575 {
576 if (Status == AE_NOT_FOUND)
577 {
579 "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",
580 Operand[0]->String.Pointer,
581 Operand[1]->String.Pointer,
582 Operand[2]->String.Pointer));
583 }
584 goto Cleanup;
585 }
586
587 Status = AcpiGetTableByIndex (TableIndex, &Table);
588 if (ACPI_FAILURE (Status))
589 {
590 goto Cleanup;
591 }
592
593 ObjDesc = AcpiNsGetAttachedObject (Node);
594 if (!ObjDesc)
595 {
597 goto Cleanup;
598 }
599
601 ObjDesc->Region.Length = Table->Length;
602 ObjDesc->Region.Pointer = Table;
603
604 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
605 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
606 ObjDesc->Region.Length));
607
608 /* Now the address and length are valid for this opregion */
609
610 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
611
612Cleanup:
613 AcpiUtRemoveReference (Operand[0]);
614 AcpiUtRemoveReference (Operand[1]);
615 AcpiUtRemoveReference (Operand[2]);
616
618}
ACPI_STATUS AcpiTbFindTable(char *Signature, char *OemId, char *OemTableId, UINT32 *TableIndex)
Definition: tbfind.c:70
#define ACPI_PTR_TO_PHYSADDR(i)
Definition: actypes.h:559
ASMGENDATA Table[]
Definition: genincdata.c:61
ACPI_STATUS AcpiGetTableByIndex(UINT32 TableIndex, ACPI_TABLE_HEADER **OutTable)
Definition: tbxface.c:491
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by AcpiDsExecEndOp().

◆ AcpiDsEvaluateNamePath()

ACPI_STATUS AcpiDsEvaluateNamePath ( ACPI_WALK_STATE WalkState)

Definition at line 845 of file dsutils.c.

847{
849 ACPI_PARSE_OBJECT *Op = WalkState->Op;
850 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
851 ACPI_OPERAND_OBJECT *NewObjDesc;
852 UINT8 Type;
853
854
855 ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState);
856
857
858 if (!Op->Common.Parent)
859 {
860 /* This happens after certain exception processing */
861
862 goto Exit;
863 }
864
865 if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
866 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
867 (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP))
868 {
869 /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */
870
871 goto Exit;
872 }
873
874 Status = AcpiDsCreateOperand (WalkState, Op, 0);
875 if (ACPI_FAILURE (Status))
876 {
877 goto Exit;
878 }
879
880 if (Op->Common.Flags & ACPI_PARSEOP_TARGET)
881 {
882 NewObjDesc = *Operand;
883 goto PushResult;
884 }
885
886 Type = (*Operand)->Common.Type;
887
888 Status = AcpiExResolveToValue (Operand, WalkState);
889 if (ACPI_FAILURE (Status))
890 {
891 goto Exit;
892 }
893
894 if (Type == ACPI_TYPE_INTEGER)
895 {
896 /* It was incremented by AcpiExResolveToValue */
897
898 AcpiUtRemoveReference (*Operand);
899
901 *Operand, &NewObjDesc, WalkState);
902 if (ACPI_FAILURE (Status))
903 {
904 goto Exit;
905 }
906 }
907 else
908 {
909 /*
910 * The object either was anew created or is
911 * a Namespace node - don't decrement it.
912 */
913 NewObjDesc = *Operand;
914 }
915
916 /* Cleanup for name-path operand */
917
918 Status = AcpiDsObjStackPop (1, WalkState);
919 if (ACPI_FAILURE (Status))
920 {
921 WalkState->ResultObj = NewObjDesc;
922 goto Exit;
923 }
924
925PushResult:
926
927 WalkState->ResultObj = NewObjDesc;
928
929 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
930 if (ACPI_SUCCESS (Status))
931 {
932 /* Force to take it from stack */
933
934 Op->Common.Flags |= ACPI_PARSEOP_IN_STACK;
935 }
936
937Exit:
938
940}
Type
Definition: Type.h:7
#define ACPI_PARSEOP_TARGET
Definition: aclocal.h:1122
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
ACPI_STATUS AcpiUtCopyIobjectToIobject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, ACPI_WALK_STATE *WalkState)
Definition: utcopy.c:1037
#define AML_REF_OF_OP
Definition: amlcode.h:89
ACPI_STATUS AcpiDsResultPush(ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:160
static void Exit(void)
Definition: sock.c:1330
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118

Referenced by AcpiDsExecEndOp().

◆ AcpiDsExecBeginControlOp()

ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 71 of file dscontrol.c.

74{
76 ACPI_GENERIC_STATE *ControlState;
77
78
79 ACPI_FUNCTION_NAME (DsExecBeginControlOp);
80
81
82 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
83 Op, Op->Common.AmlOpcode, WalkState));
84
85 switch (Op->Common.AmlOpcode)
86 {
87 case AML_WHILE_OP:
88 /*
89 * If this is an additional iteration of a while loop, continue.
90 * There is no need to allocate a new control state.
91 */
92 if (WalkState->ControlState)
93 {
94 if (WalkState->ControlState->Control.AmlPredicateStart ==
95 (WalkState->ParserState.Aml - 1))
96 {
97 /* Reset the state to start-of-loop */
98
99 WalkState->ControlState->Common.State =
101 break;
102 }
103 }
104
106
107 case AML_IF_OP:
108 /*
109 * IF/WHILE: Create a new control state to manage these
110 * constructs. We need to manage these as a stack, in order
111 * to handle nesting.
112 */
113 ControlState = AcpiUtCreateControlState ();
114 if (!ControlState)
115 {
117 break;
118 }
119 /*
120 * Save a pointer to the predicate for multiple executions
121 * of a loop
122 */
123 ControlState->Control.AmlPredicateStart =
124 WalkState->ParserState.Aml - 1;
125 ControlState->Control.PackageEnd =
126 WalkState->ParserState.PkgEnd;
127 ControlState->Control.Opcode =
128 Op->Common.AmlOpcode;
129 ControlState->Control.LoopTimeout = AcpiOsGetTimer () +
130 ((UINT64) AcpiGbl_MaxLoopIterations * ACPI_100NSEC_PER_SEC);
131
132 /* Push the control state on this walk's control stack */
133
134 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
135 break;
136
137 case AML_ELSE_OP:
138
139 /* Predicate is in the state object */
140 /* If predicate is true, the IF was executed, ignore ELSE part */
141
142 if (WalkState->LastPredicate)
143 {
145 }
146
147 break;
148
149 case AML_RETURN_OP:
150
151 break;
152
153 default:
154
155 break;
156 }
157
158 return (Status);
159}
unsigned long long UINT64
#define AE_CTRL_TRUE
Definition: acexcep.h:227
#define ACPI_CONTROL_CONDITIONAL_EXECUTING
Definition: aclocal.h:670
UINT64 AcpiOsGetTimer(void)
Definition: osl.c:884
#define ACPI_100NSEC_PER_SEC
Definition: actypes.h:475
#define ACPI_FALLTHROUGH
Definition: actypes.h:1466
ACPI_GENERIC_STATE * AcpiUtCreateControlState(void)
Definition: utstate.c:300
void AcpiUtPushGenericState(ACPI_GENERIC_STATE **ListHead, ACPI_GENERIC_STATE *State)
Definition: utstate.c:65
#define AML_RETURN_OP
Definition: amlcode.h:138
#define AML_IF_OP
Definition: amlcode.h:134
#define AML_ELSE_OP
Definition: amlcode.h:135
#define AML_WHILE_OP
Definition: amlcode.h:136
UINT64 LoopTimeout
Definition: aclocal.h:729
UINT8 * AmlPredicateStart
Definition: aclocal.h:727
UINT8 * PackageEnd
Definition: aclocal.h:728
ACPI_STATE_COMMON UINT16 Opcode
Definition: aclocal.h:725
UINT8 * PkgEnd
Definition: aclocal.h:1105
BOOLEAN LastPredicate
Definition: acstruct.h:83
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
ACPI_CONTROL_STATE Control
Definition: aclocal.h:823

Referenced by AcpiDsExecBeginOp().

◆ AcpiDsExecBeginOp()

ACPI_STATUS AcpiDsExecBeginOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT **  OutOp 
)

Definition at line 234 of file dswexec.c.

237{
240 UINT32 OpcodeClass;
241
242
243 ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState);
244
245
246 Op = WalkState->Op;
247 if (!Op)
248 {
249 Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
250 if (ACPI_FAILURE (Status))
251 {
252 goto ErrorExit;
253 }
254
255 Op = *OutOp;
256 WalkState->Op = Op;
257 WalkState->Opcode = Op->Common.AmlOpcode;
258 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
259
260 if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
261 {
263 "(%s) Popping scope for Op %p\n",
264 AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
265
266 Status = AcpiDsScopeStackPop (WalkState);
267 if (ACPI_FAILURE (Status))
268 {
269 goto ErrorExit;
270 }
271 }
272 }
273
274 if (Op == WalkState->Origin)
275 {
276 if (OutOp)
277 {
278 *OutOp = Op;
279 }
280
282 }
283
284 /*
285 * If the previous opcode was a conditional, this opcode
286 * must be the beginning of the associated predicate.
287 * Save this knowledge in the current scope descriptor
288 */
289 if ((WalkState->ControlState) &&
290 (WalkState->ControlState->Common.State ==
292 {
294 "Exec predicate Op=%p State=%p\n",
295 Op, WalkState));
296
297 WalkState->ControlState->Common.State =
299
300 /* Save start of predicate */
301
302 WalkState->ControlState->Control.PredicateOp = Op;
303 }
304
305
306 OpcodeClass = WalkState->OpInfo->Class;
307
308 /* We want to send namepaths to the load code */
309
310 if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
311 {
312 OpcodeClass = AML_CLASS_NAMED_OBJECT;
313 }
314
315 /*
316 * Handle the opcode based upon the opcode type
317 */
318 switch (OpcodeClass)
319 {
321
322 Status = AcpiDsExecBeginControlOp (WalkState, Op);
323 break;
324
326
327 if (WalkState->WalkType & ACPI_WALK_METHOD)
328 {
329 /*
330 * Found a named object declaration during method execution;
331 * we must enter this object into the namespace. The created
332 * object is temporary and will be deleted upon completion of
333 * the execution of this method.
334 *
335 * Note 10/2010: Except for the Scope() op. This opcode does
336 * not actually create a new object, it refers to an existing
337 * object. However, for Scope(), we want to indeed open a
338 * new scope.
339 */
340 if (Op->Common.AmlOpcode != AML_SCOPE_OP)
341 {
342 Status = AcpiDsLoad2BeginOp (WalkState, NULL);
343 }
344 else
345 {
347 Op->Named.Node, Op->Named.Node->Type, WalkState);
348 if (ACPI_FAILURE (Status))
349 {
351 }
352 }
353 }
354 break;
355
357 case AML_CLASS_CREATE:
358
359 break;
360
361 default:
362
363 break;
364 }
365
366 /* Nothing to do here during method execution */
367
369
370
372 Status = AcpiDsMethodError (Status, WalkState);
374}
#define ACPI_CONTROL_PREDICATE_EXECUTING
Definition: aclocal.h:671
UINT32 AcpiNsOpensScope(ACPI_OBJECT_TYPE Type)
Definition: nsutils.c:736
#define ACPI_WALK_METHOD
Definition: acstruct.h:69
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
#define AML_CLASS_NAMED_OBJECT
Definition: amlcode.h:403
#define AML_CLASS_EXECUTE
Definition: amlcode.h:400
#define AML_CLASS_CREATE
Definition: amlcode.h:401
#define AML_CLASS_CONTROL
Definition: amlcode.h:404
#define AML_SCOPE_OP
Definition: amlcode.h:60
ACPI_STATUS AcpiDsExecBeginControlOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dscontrol.c:71
ACPI_STATUS AcpiDsMethodError(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:223
ACPI_STATUS AcpiDsLoad2BeginOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
Definition: dswload2.c:74
ACPI_STATUS AcpiDsScopeStackPush(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:107
ACPI_STATUS AcpiDsScopeStackPop(ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:192
union acpi_parse_object * PredicateOp
Definition: aclocal.h:726
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
UINT8 WalkType
Definition: acstruct.h:77
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647

Referenced by AcpiDsInitCallbacks(), and AcpiDsLoad2BeginOp().

◆ AcpiDsExecEndControlOp()

ACPI_STATUS AcpiDsExecEndControlOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 177 of file dscontrol.c.

180{
182 ACPI_GENERIC_STATE *ControlState;
183
184
185 ACPI_FUNCTION_NAME (DsExecEndControlOp);
186
187
188 switch (Op->Common.AmlOpcode)
189 {
190 case AML_IF_OP:
191
192 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
193
194 /*
195 * Save the result of the predicate in case there is an
196 * ELSE to come
197 */
198 WalkState->LastPredicate =
199 (BOOLEAN) WalkState->ControlState->Common.Value;
200
201 /*
202 * Pop the control state that was created at the start
203 * of the IF and free it
204 */
205 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
206 AcpiUtDeleteGenericState (ControlState);
207 break;
208
209 case AML_ELSE_OP:
210
211 break;
212
213 case AML_WHILE_OP:
214
215 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
216
217 ControlState = WalkState->ControlState;
218 if (ControlState->Common.Value)
219 {
220 /* Predicate was true, the body of the loop was just executed */
221
222 /*
223 * This infinite loop detection mechanism allows the interpreter
224 * to escape possibly infinite loops. This can occur in poorly
225 * written AML when the hardware does not respond within a while
226 * loop and the loop does not implement a timeout.
227 */
229 ControlState->Control.LoopTimeout))
230 {
232 break;
233 }
234
235 /*
236 * Go back and evaluate the predicate and maybe execute the loop
237 * another time
238 */
240 WalkState->AmlLastWhile =
241 ControlState->Control.AmlPredicateStart;
242 break;
243 }
244
245 /* Predicate was false, terminate this while loop */
246
248 "[WHILE_OP] termination! Op=%p\n",Op));
249
250 /* Pop this control state and free it */
251
252 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
253 AcpiUtDeleteGenericState (ControlState);
254 break;
255
256 case AML_RETURN_OP:
257
259 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
260
261 /*
262 * One optional operand -- the return value
263 * It can be either an immediate operand or a result that
264 * has been bubbled up the tree
265 */
266 if (Op->Common.Value.Arg)
267 {
268 /* Since we have a real Return(), delete any implicit return */
269
270 AcpiDsClearImplicitReturn (WalkState);
271
272 /* Return statement has an immediate operand */
273
274 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
275 if (ACPI_FAILURE (Status))
276 {
277 return (Status);
278 }
279
280 /*
281 * If value being returned is a Reference (such as
282 * an arg or local), resolve it now because it may
283 * cease to exist at the end of the method.
284 */
286 &WalkState->Operands [0], WalkState);
287 if (ACPI_FAILURE (Status))
288 {
289 return (Status);
290 }
291
292 /*
293 * Get the return value and save as the last result
294 * value. This is the only place where WalkState->ReturnDesc
295 * is set to anything other than zero!
296 */
297 WalkState->ReturnDesc = WalkState->Operands[0];
298 }
299 else if (WalkState->ResultCount)
300 {
301 /* Since we have a real Return(), delete any implicit return */
302
303 AcpiDsClearImplicitReturn (WalkState);
304
305 /*
306 * The return value has come from a previous calculation.
307 *
308 * If value being returned is a Reference (such as
309 * an arg or local), resolve it now because it may
310 * cease to exist at the end of the method.
311 *
312 * Allow references created by the Index operator to return
313 * unchanged.
314 */
315 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) ==
317 ((WalkState->Results->Results.ObjDesc [0])->Common.Type ==
319 ((WalkState->Results->Results.ObjDesc [0])->Reference.Class !=
321 {
323 &WalkState->Results->Results.ObjDesc [0], WalkState);
324 if (ACPI_FAILURE (Status))
325 {
326 return (Status);
327 }
328 }
329
330 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
331 }
332 else
333 {
334 /* No return operand */
335
336 if (WalkState->NumOperands)
337 {
338 AcpiUtRemoveReference (WalkState->Operands [0]);
339 }
340
341 WalkState->Operands[0] = NULL;
342 WalkState->NumOperands = 0;
343 WalkState->ReturnDesc = NULL;
344 }
345
346
348 "Completed RETURN_OP State=%p, RetVal=%p\n",
349 WalkState, WalkState->ReturnDesc));
350
351 /* End the control method execution right now */
352
354 break;
355
356 case AML_NOOP_OP:
357
358 /* Just do nothing! */
359
360 break;
361
363
364 AcpiDbSignalBreakPoint (WalkState);
365
366 /* Call to the OSL in case OS wants a piece of the action */
367
369 "Executed AML Breakpoint opcode");
370 break;
371
372 case AML_BREAK_OP:
373 case AML_CONTINUE_OP: /* ACPI 2.0 */
374
375 /* Pop and delete control states until we find a while */
376
377 while (WalkState->ControlState &&
378 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
379 {
380 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
381 AcpiUtDeleteGenericState (ControlState);
382 }
383
384 /* No while found? */
385
386 if (!WalkState->ControlState)
387 {
388 return (AE_AML_NO_WHILE);
389 }
390
391 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
392
393 WalkState->AmlLastWhile =
394 WalkState->ControlState->Control.PackageEnd;
395
396 /* Return status depending on opcode */
397
398 if (Op->Common.AmlOpcode == AML_BREAK_OP)
399 {
401 }
402 else
403 {
405 }
406 break;
407
408 default:
409
410 ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
411 Op->Common.AmlOpcode, Op));
412
414 break;
415 }
416
417 return (Status);
418}
#define AE_CTRL_CONTINUE
Definition: acexcep.h:233
#define AE_AML_LOOP_TIMEOUT
Definition: acexcep.h:212
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define AE_CTRL_BREAK
Definition: acexcep.h:232
#define AE_AML_NO_WHILE
Definition: acexcep.h:205
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:576
@ ACPI_REFCLASS_INDEX
Definition: acobject.h:462
#define ACPI_SIGNAL_BREAKPOINT
Definition: acpiosxf.h:74
ACPI_STATUS AcpiOsSignal(UINT32 Function, void *Info)
Definition: osl.c:904
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TIME_AFTER(a, b)
Definition: actypes.h:481
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
#define AML_BREAK_OP
Definition: amlcode.h:139
#define AML_BREAKPOINT_OP
Definition: amlcode.h:141
#define AML_NOOP_OP
Definition: amlcode.h:137
#define AML_CONTINUE_OP
Definition: amlcode.h:133
#define BOOLEAN
Definition: pedump.c:73
union acpi_operand_object * ReturnDesc
Definition: acstruct.h:123
UINT8 * AmlLastWhile
Definition: acstruct.h:108
UINT8 ResultCount
Definition: acstruct.h:90

Referenced by AcpiDsExecEndOp().

◆ AcpiDsExecEndOp()

ACPI_STATUS AcpiDsExecEndOp ( ACPI_WALK_STATE State)

Definition at line 392 of file dswexec.c.

394{
399 ACPI_PARSE_OBJECT *NextOp;
400 ACPI_PARSE_OBJECT *FirstArg;
401#ifdef ACPI_EXEC_APP
402 char *Namepath;
403 ACPI_OPERAND_OBJECT *ObjDesc;
404#endif
405
406 ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState);
407
408
409 Op = WalkState->Op;
410 OpType = WalkState->OpInfo->Type;
411 OpClass = WalkState->OpInfo->Class;
412
414 {
415 ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode));
417 }
418
419 FirstArg = Op->Common.Value.Arg;
420
421 /* Init the walk state */
422
423 WalkState->NumOperands = 0;
424 WalkState->OperandIndex = 0;
425 WalkState->ReturnDesc = NULL;
426 WalkState->ResultObj = NULL;
427
428 /* Call debugger for single step support (DEBUG build only) */
429
430 Status = AcpiDbSingleStep (WalkState, Op, OpClass);
431 if (ACPI_FAILURE (Status))
432 {
434 }
435
436 /* Decode the Opcode Class */
437
438 switch (OpClass)
439 {
440 case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */
441
442 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
443 {
444 Status = AcpiDsEvaluateNamePath (WalkState);
445 if (ACPI_FAILURE (Status))
446 {
447 goto Cleanup;
448 }
449 }
450 break;
451
452 case AML_CLASS_EXECUTE: /* Most operators with arguments */
453
454 /* Build resolved operand stack */
455
456 Status = AcpiDsCreateOperands (WalkState, FirstArg);
457 if (ACPI_FAILURE (Status))
458 {
459 goto Cleanup;
460 }
461
462 /*
463 * All opcodes require operand resolution, with the only exceptions
464 * being the ObjectType and SizeOf operators.
465 */
466 if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE))
467 {
468 /* Resolve all operands */
469
470 Status = AcpiExResolveOperands (WalkState->Opcode,
471 &(WalkState->Operands [WalkState->NumOperands -1]),
472 WalkState);
473 }
474
475 if (ACPI_SUCCESS (Status))
476 {
477 /*
478 * Dispatch the request to the appropriate interpreter handler
479 * routine. There is one routine per opcode "type" based upon the
480 * number of opcode arguments and return type.
481 */
482 Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState);
483 }
484 else
485 {
486 /*
487 * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
488 * Local is uninitialized.
489 */
491 (WalkState->Opcode == AML_STORE_OP) &&
492 (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
493 (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
494 (WalkState->Operands[0]->Reference.Class ==
495 WalkState->Operands[1]->Reference.Class) &&
496 (WalkState->Operands[0]->Reference.Value ==
497 WalkState->Operands[1]->Reference.Value))
498 {
499 Status = AE_OK;
500 }
501 else
502 {
504 "While resolving operands for [%s]",
505 AcpiPsGetOpcodeName (WalkState->Opcode)));
506 }
507 }
508
509 /* Always delete the argument objects and clear the operand stack */
510
511 AcpiDsClearOperands (WalkState);
512
513 /*
514 * If a result object was returned from above, push it on the
515 * current result stack
516 */
517 if (ACPI_SUCCESS (Status) &&
518 WalkState->ResultObj)
519 {
520 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
521 }
522 break;
523
524 default:
525
526 switch (OpType)
527 {
528 case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
529
530 /* 1 Operand, 0 ExternalResult, 0 InternalResult */
531
532 Status = AcpiDsExecEndControlOp (WalkState, Op);
533
534 break;
535
537 /*
538 * If the method is referenced from within a package
539 * declaration, it is not a invocation of the method, just
540 * a reference to it.
541 */
542 if ((Op->Asl.Parent) &&
543 ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
544 (Op->Asl.Parent->Asl.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
545 {
547 "Method Reference in a Package, Op=%p\n", Op));
548
549 Op->Common.Node = (ACPI_NAMESPACE_NODE *)
550 Op->Asl.Value.Arg->Asl.Node;
551 AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object);
553 }
554
556 "Method invocation, Op=%p\n", Op));
557
558 /*
559 * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
560 * the method Node pointer
561 */
562 /* NextOp points to the op that holds the method name */
563
564 NextOp = FirstArg;
565
566 /* NextOp points to first argument op */
567
568 NextOp = NextOp->Common.Next;
569
570 /*
571 * Get the method's arguments and put them on the operand stack
572 */
573 Status = AcpiDsCreateOperands (WalkState, NextOp);
574 if (ACPI_FAILURE (Status))
575 {
576 break;
577 }
578
579 /*
580 * Since the operands will be passed to another control method,
581 * we must resolve all local references here (Local variables,
582 * arguments to *this* method, etc.)
583 */
584 Status = AcpiDsResolveOperands (WalkState);
585 if (ACPI_FAILURE (Status))
586 {
587 /* On error, clear all resolved operands */
588
589 AcpiDsClearOperands (WalkState);
590 break;
591 }
592
593 /*
594 * Tell the walk loop to preempt this running method and
595 * execute the new method
596 */
598
599 /*
600 * Return now; we don't want to disturb anything,
601 * especially the operand count!
602 */
604
606
608 "Executing CreateField Buffer/Index Op=%p\n", Op));
609
610 Status = AcpiDsLoad2EndOp (WalkState);
611 if (ACPI_FAILURE (Status))
612 {
613 break;
614 }
615
616 Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
617 if (ACPI_FAILURE (Status))
618 {
619 break;
620 }
621
622#ifdef ACPI_EXEC_APP
623 /*
624 * AcpiExec support for namespace initialization file (initialize
625 * BufferFields in this code.)
626 */
627 Namepath = AcpiNsGetExternalPathname (Op->Common.Node);
628 Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
629 if (ACPI_SUCCESS (Status))
630 {
631 Status = AcpiExWriteDataToField (ObjDesc, Op->Common.Node->Object, NULL);
632 if (ACPI_FAILURE (Status))
633 {
634 ACPI_EXCEPTION ((AE_INFO, Status, "While writing to buffer field"));
635 }
636 }
637 ACPI_FREE (Namepath);
638 Status = AE_OK;
639#endif
640 break;
641
642
644
646 "Executing CreateObject (Buffer/Package) Op=%p Child=%p ParentOpcode=%4.4X\n",
647 Op, Op->Named.Value.Arg, Op->Common.Parent->Common.AmlOpcode));
648
649 switch (Op->Common.Parent->Common.AmlOpcode)
650 {
651 case AML_NAME_OP:
652 /*
653 * Put the Node on the object stack (Contains the ACPI Name
654 * of this object)
655 */
656 WalkState->Operands[0] = (void *)
657 Op->Common.Parent->Common.Node;
658 WalkState->NumOperands = 1;
659
660 Status = AcpiDsCreateNode (WalkState,
661 Op->Common.Parent->Common.Node, Op->Common.Parent);
662 if (ACPI_FAILURE (Status))
663 {
664 break;
665 }
666
668
670
671 Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
672 AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
673 break;
674
675 default:
676
677 Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
678 break;
679 }
680
681 /*
682 * If a result object was returned from above, push it on the
683 * current result stack
684 */
685 if (WalkState->ResultObj)
686 {
687 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
688 }
689 break;
690
695
696 Status = AcpiDsLoad2EndOp (WalkState);
697 if (ACPI_FAILURE (Status))
698 {
699 break;
700 }
701
702 if (Op->Common.AmlOpcode == AML_REGION_OP)
703 {
705 "Executing OpRegion Address/Length Op=%p\n", Op));
706
707 Status = AcpiDsEvalRegionOperands (WalkState, Op);
708 if (ACPI_FAILURE (Status))
709 {
710 break;
711 }
712 }
713 else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
714 {
716 "Executing DataTableRegion Strings Op=%p\n", Op));
717
718 Status = AcpiDsEvalTableRegionOperands (WalkState, Op);
719 if (ACPI_FAILURE (Status))
720 {
721 break;
722 }
723 }
724 else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
725 {
727 "Executing BankField Op=%p\n", Op));
728
729 Status = AcpiDsEvalBankFieldOperands (WalkState, Op);
730 if (ACPI_FAILURE (Status))
731 {
732 break;
733 }
734 }
735 break;
736
738
740 "Undefined opcode type Op=%p", Op));
742
743 case AML_TYPE_BOGUS:
744
746 "Internal opcode=%X type Op=%p\n",
747 WalkState->Opcode, Op));
748 break;
749
750 default:
751
753 "Unimplemented opcode, class=0x%X "
754 "type=0x%X Opcode=0x%X Op=%p",
755 OpClass, OpType, Op->Common.AmlOpcode, Op));
756
758 break;
759 }
760 }
761
762 /*
763 * ACPI 2.0 support for 64-bit integers: Truncate numeric
764 * result value if we are executing from a 32-bit ACPI table
765 */
766 (void) AcpiExTruncateFor32bitTable (WalkState->ResultObj);
767
768 /*
769 * Check if we just completed the evaluation of a
770 * conditional predicate
771 */
772 if ((ACPI_SUCCESS (Status)) &&
773 (WalkState->ControlState) &&
774 (WalkState->ControlState->Common.State ==
776 (WalkState->ControlState->Control.PredicateOp == Op))
777 {
778 Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
779 WalkState->ResultObj = NULL;
780 }
781
782
783Cleanup:
784
785 if (WalkState->ResultObj)
786 {
787 /* Break to debugger to display result */
788
789 AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState);
790
791 /*
792 * Delete the result op if and only if:
793 * Parent will not use the result -- such as any
794 * non-nested type2 op in a method (parent will be method)
795 */
796 AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
797 }
798
799#ifdef _UNDER_DEVELOPMENT
800
801 if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
802 {
803 AcpiDbMethodEnd (WalkState);
804 }
805#endif
806
807 /* Invoke exception handler on error */
808
809 if (ACPI_FAILURE (Status))
810 {
811 Status = AcpiDsMethodError (Status, WalkState);
812 }
813
814 /* Always clear the object stack */
815
816 WalkState->NumOperands = 0;
818}
#define AE_CTRL_TRANSFER
Definition: acexcep.h:231
#define AE_AML_UNINITIALIZED_LOCAL
Definition: acexcep.h:184
char * AcpiNsGetExternalPathname(ACPI_NAMESPACE_NODE *Node)
Definition: nsnames.c:70
#define AML_CLASS_ARGUMENT
Definition: amlcode.h:402
#define AML_TYPE_NAMED_NO_OBJ
Definition: amlcode.h:382
#define AML_TYPE_UNDEFINED
Definition: amlcode.h:387
#define AML_TYPE_CREATE_FIELD
Definition: amlcode.h:379
#define AML_BANK_FIELD_OP
Definition: amlcode.h:187
#define AML_INT_EVAL_SUBTREE_OP
Definition: amlcode.h:212
#define AML_TYPE_NAMED_SIMPLE
Definition: amlcode.h:384
#define AML_STORE_OP
Definition: amlcode.h:88
#define AML_TYPE_METHOD_CALL
Definition: amlcode.h:375
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define AML_TYPE_NAMED_FIELD
Definition: amlcode.h:383
#define AML_TYPE_BOGUS
Definition: amlcode.h:388
#define AML_TYPE_CREATE_OBJECT
Definition: amlcode.h:380
#define AML_TYPE_CONTROL
Definition: amlcode.h:381
#define AML_NO_OPERAND_RESOLVE
Definition: amlcode.h:331
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
#define AML_TYPE_NAMED_COMPLEX
Definition: amlcode.h:385
ACPI_STATUS AcpiDsExecEndControlOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dscontrol.c:177
ACPI_STATUS AcpiDsCreateNode(ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op)
Definition: dsobject.c:302
ACPI_STATUS AcpiDsEvalTableRegionOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsopcode.c:519
ACPI_STATUS AcpiDsEvalBufferFieldOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsopcode.c:321
ACPI_STATUS AcpiDsEvalBankFieldOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsopcode.c:755
ACPI_STATUS AcpiDsEvalRegionOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsopcode.c:408
ACPI_STATUS AcpiDsEvalDataObjectOperands(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsopcode.c:637
void AcpiDsDeleteResultIfNotUsed(ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ResultObj, ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:359
void AcpiDsClearOperands(ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:453
ACPI_STATUS AcpiDsResolveOperands(ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:412
ACPI_STATUS AcpiDsEvaluateNamePath(ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:845
ACPI_STATUS AcpiDsGetPredicateValue(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ResultObj)
Definition: dswexec.c:94
static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch[]
Definition: dswexec.c:63
ACPI_STATUS AcpiDsLoad2EndOp(ACPI_WALK_STATE *WalkState)
Definition: dswload2.c:418
ACPI_STATUS AcpiExWriteDataToField(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
Definition: exfield.c:317
BOOLEAN AcpiExTruncateFor32bitTable(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exutils.c:177
OpClass
Definition: simd.h:241
OpType
Definition: simd.h:223
ACPI_PARSE_OBJ_ASL Asl
Definition: aclocal.h:1080

Referenced by AcpiDsInitCallbacks().

◆ AcpiDsGetBankFieldArguments()

ACPI_STATUS AcpiDsGetBankFieldArguments ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 245 of file dsargs.c.

247{
248 ACPI_OPERAND_OBJECT *ExtraDesc;
251
252
253 ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc);
254
255
256 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
257 {
259 }
260
261 /* Get the AML pointer (method object) and BankField node */
262
263 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
264 Node = ObjDesc->BankField.Node;
265
266 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
268
269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
271
272 /* Execute the AML code for the TermArg arguments */
273
275 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
277}
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346
#define ACPI_DEBUG_EXEC(a)
Definition: acoutput.h:477
static ACPI_STATUS AcpiDsExecuteArguments(ACPI_NAMESPACE_NODE *Node, ACPI_NAMESPACE_NODE *ScopeNode, UINT32 AmlLength, UINT8 *AmlStart)
Definition: dsargs.c:81

Referenced by AcpiNsInitOneObject().

◆ AcpiDsGetBufferArguments()

ACPI_STATUS AcpiDsGetBufferArguments ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 294 of file dsargs.c.

296{
299
300
301 ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc);
302
303
304 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
305 {
307 }
308
309 /* Get the Buffer node */
310
311 Node = ObjDesc->Buffer.Node;
312 if (!Node)
313 {
315 "No pointer back to namespace node in buffer object %p",
316 ObjDesc));
318 }
319
320 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
321
322 /* Execute the AML code for the TermArg arguments */
323
325 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
327}
UINT8 * AmlStart
Definition: acobject.h:151
ACPI_OBJECT_COMMON_HEADER UINT32 AmlLength
Definition: acobject.h:150
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:152

Referenced by AcpiExOpcode_1A_0T_1R(), AcpiExPrepFieldValue(), AcpiExResolveNodeToValue(), and AcpiExResolveObjectToValue().

◆ AcpiDsGetBufferFieldArguments()

ACPI_STATUS AcpiDsGetBufferFieldArguments ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 196 of file dsargs.c.

198{
199 ACPI_OPERAND_OBJECT *ExtraDesc;
202
203
204 ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc);
205
206
207 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
208 {
210 }
211
212 /* Get the AML pointer (method object) and BufferField node */
213
214 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
215 Node = ObjDesc->BufferField.Node;
216
217 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
219
220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
222
223 /* Execute the AML code for the TermArg arguments */
224
226 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
228}

Referenced by AcpiExFieldDatumIo(), AcpiExReadDataFromField(), and AcpiExWriteDataToField().

◆ AcpiDsGetCurrentWalkState()

ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE Thread)

Definition at line 494 of file dswstate.c.

496{
497 ACPI_FUNCTION_NAME (DsGetCurrentWalkState);
498
499
500 if (!Thread)
501 {
502 return (NULL);
503 }
504
505 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n",
506 Thread->WalkStateList));
507
508 return (Thread->WalkStateList);
509}

Referenced by AcpiPsParseAml().

◆ AcpiDsGetPackageArguments()

ACPI_STATUS AcpiDsGetPackageArguments ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 344 of file dsargs.c.

346{
349
350
351 ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc);
352
353
354 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
355 {
357 }
358
359 /* Get the Package node */
360
361 Node = ObjDesc->Package.Node;
362 if (!Node)
363 {
365 "No pointer back to namespace node in package %p", ObjDesc));
367 }
368
369 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Argument Init, AML Ptr: %p\n",
370 ObjDesc->Package.AmlStart));
371
372 /* Execute the AML code for the TermArg arguments */
373
375 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
376
378}

Referenced by AcpiExOpcode_1A_0T_1R(), AcpiExResolveNodeToValue(), AcpiExResolveObjectToValue(), and AcpiNsInitOnePackage().

◆ AcpiDsGetPredicateValue()

ACPI_STATUS AcpiDsGetPredicateValue ( ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT ResultObj 
)

Definition at line 94 of file dswexec.c.

97{
99 ACPI_OPERAND_OBJECT *ObjDesc;
100 ACPI_OPERAND_OBJECT *LocalObjDesc = NULL;
101
102
103 ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState);
104
105
106 WalkState->ControlState->Common.State = 0;
107
108 if (ResultObj)
109 {
110 Status = AcpiDsResultPop (&ObjDesc, WalkState);
111 if (ACPI_FAILURE (Status))
112 {
114 "Could not get result from predicate evaluation"));
115
117 }
118 }
119 else
120 {
121 Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
122 if (ACPI_FAILURE (Status))
123 {
125 }
126
127 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
128 if (ACPI_FAILURE (Status))
129 {
131 }
132
133 ObjDesc = WalkState->Operands [0];
134 }
135
136 if (!ObjDesc)
137 {
139 "No predicate ObjDesc=%p State=%p",
140 ObjDesc, WalkState));
141
143 }
144
145 /*
146 * Result of predicate evaluation must be an Integer
147 * object. Implicitly convert the argument if necessary.
148 */
149 Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc,
151 if (ACPI_FAILURE (Status))
152 {
153 goto Cleanup;
154 }
155
156 if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER)
157 {
159 "Bad predicate (not an integer) ObjDesc=%p State=%p Type=0x%X",
160 ObjDesc, WalkState, ObjDesc->Common.Type));
161
163 goto Cleanup;
164 }
165
166 /* Truncate the predicate to 32-bits if necessary */
167
168 (void) AcpiExTruncateFor32bitTable (LocalObjDesc);
169
170 /*
171 * Save the result of the predicate evaluation on
172 * the control stack
173 */
174 if (LocalObjDesc->Integer.Value)
175 {
176 WalkState->ControlState->Common.Value = TRUE;
177 }
178 else
179 {
180 /*
181 * Predicate is FALSE, we will just toss the
182 * rest of the package
183 */
184 WalkState->ControlState->Common.Value = FALSE;
186 }
187
188 /* Predicate can be used for an implicit return value */
189
190 (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE);
191
192
193Cleanup:
194
196 "Completed a predicate eval=%X Op=%p\n",
197 WalkState->ControlState->Common.Value, WalkState->Op));
198
199 /* Break to debugger to display result */
200
201 AcpiDbDisplayResultObject (LocalObjDesc, WalkState);
202
203 /*
204 * Delete the predicate result object (we know that
205 * we don't need it anymore)
206 */
207 if (LocalObjDesc != ObjDesc)
208 {
209 AcpiUtRemoveReference (LocalObjDesc);
210 }
211 AcpiUtRemoveReference (ObjDesc);
212
213 WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
215}
#define AE_CTRL_FALSE
Definition: acexcep.h:228
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_CONTROL_NORMAL
Definition: aclocal.h:669
#define ACPI_IMPLICIT_CONVERSION
Definition: acutils.h:145
BOOLEAN AcpiDsDoImplicitReturn(ACPI_OPERAND_OBJECT *ReturnDesc, ACPI_WALK_STATE *WalkState, BOOLEAN AddReference)
Definition: dsutils.c:123
ACPI_STATUS AcpiExConvertToInteger(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 ImplicitConversion)
Definition: exconvrt.c:79

Referenced by AcpiDsExecEndOp(), and AcpiPsParseLoop().

◆ AcpiDsGetRegionArguments()

ACPI_STATUS AcpiDsGetRegionArguments ( ACPI_OPERAND_OBJECT RgnDesc)

Definition at line 395 of file dsargs.c.

397{
400 ACPI_OPERAND_OBJECT *ExtraDesc;
401
402
403 ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc);
404
405
406 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
407 {
409 }
410
411 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
412 if (!ExtraDesc)
413 {
415 }
416
417 /* Get the Region node */
418
419 Node = ObjDesc->Region.Node;
420
421 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
423
425 "[%4.4s] OpRegion Arg Init at AML %p\n",
426 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
427
428 /* Execute the argument AML */
429
431 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
432 if (ACPI_FAILURE (Status))
433 {
435 }
436
437 Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId,
438 ObjDesc->Region.Address, ObjDesc->Region.Length, Node);
440}
ACPI_NAMESPACE_NODE * ScopeNode
Definition: acobject.h:482

Referenced by AcpiExLoadOp(), and AcpiExSetupRegion().

◆ AcpiDsInitAmlWalk()

ACPI_STATUS AcpiDsInitAmlWalk ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_NAMESPACE_NODE MethodNode,
UINT8 AmlStart,
UINT32  AmlLength,
ACPI_EVALUATE_INFO Info,
UINT8  PassNumber 
)

Definition at line 662 of file dswstate.c.

670{
672 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
673 ACPI_PARSE_OBJECT *ExtraOp;
674
675
676 ACPI_FUNCTION_TRACE (DsInitAmlWalk);
677
678
679 WalkState->ParserState.Aml =
680 WalkState->ParserState.AmlStart = AmlStart;
681 WalkState->ParserState.AmlEnd =
682 WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
683
684 /* The NextOp of the NextWalk will be the beginning of the method */
685
686 WalkState->NextOp = NULL;
687 WalkState->PassNumber = PassNumber;
688
689 if (Info)
690 {
691 WalkState->Params = Info->Parameters;
692 WalkState->CallerReturnDesc = &Info->ReturnObject;
693 }
694
695 Status = AcpiPsInitScope (&WalkState->ParserState, Op);
696 if (ACPI_FAILURE (Status))
697 {
699 }
700
701 if (MethodNode)
702 {
703 WalkState->ParserState.StartNode = MethodNode;
704 WalkState->WalkType = ACPI_WALK_METHOD;
705 WalkState->MethodNode = MethodNode;
706 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode);
707
708 /* Push start scope on scope stack and make it current */
709
711 MethodNode, ACPI_TYPE_METHOD, WalkState);
712 if (ACPI_FAILURE (Status))
713 {
715 }
716
717 /* Init the method arguments */
718
720 ACPI_METHOD_NUM_ARGS, WalkState);
721 if (ACPI_FAILURE (Status))
722 {
724 }
725 }
726 else
727 {
728 /*
729 * Setup the current scope.
730 * Find a Named Op that has a namespace node associated with it.
731 * search upwards from this Op. Current scope is the first
732 * Op with a namespace node.
733 */
734 ExtraOp = ParserState->StartOp;
735 while (ExtraOp && !ExtraOp->Common.Node)
736 {
737 ExtraOp = ExtraOp->Common.Parent;
738 }
739
740 if (!ExtraOp)
741 {
742 ParserState->StartNode = NULL;
743 }
744 else
745 {
746 ParserState->StartNode = ExtraOp->Common.Node;
747 }
748
749 if (ParserState->StartNode)
750 {
751 /* Push start scope on scope stack and make it current */
752
753 Status = AcpiDsScopeStackPush (ParserState->StartNode,
754 ParserState->StartNode->Type, WalkState);
755 if (ACPI_FAILURE (Status))
756 {
758 }
759 }
760 }
761
762 Status = AcpiDsInitCallbacks (WalkState, PassNumber);
764}
ACPI_STATUS AcpiPsInitScope(ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Root)
Definition: psscope.c:112
#define ACPI_METHOD_NUM_ARGS
Definition: acconfig.h:166
ACPI_STATUS AcpiDsMethodDataInitArgs(ACPI_OPERAND_OBJECT **Params, UINT32 MaxParamCount, ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:213
ACPI_STATUS AcpiDsInitCallbacks(ACPI_WALK_STATE *WalkState, UINT32 PassNumber)
Definition: dswload.c:73
UINT8 * AmlEnd
Definition: aclocal.h:1103
struct acpi_namespace_node * StartNode
Definition: aclocal.h:1107
UINT8 * AmlStart
Definition: aclocal.h:1101
ACPI_PARSE_OBJECT * NextOp
Definition: acstruct.h:126
union acpi_operand_object ** Params
Definition: acstruct.h:106
UINT8 PassNumber
Definition: acstruct.h:87
union acpi_operand_object ** CallerReturnDesc
Definition: acstruct.h:109

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsCallControlMethod(), AcpiDsExecuteArguments(), AcpiNsOneCompleteParse(), AcpiPsExecuteMethod(), and AcpiPsExecuteTable().

◆ AcpiDsInitCallbacks()

ACPI_STATUS AcpiDsInitCallbacks ( ACPI_WALK_STATE WalkState,
UINT32  PassNumber 
)

Definition at line 73 of file dswload.c.

76{
77
78 switch (PassNumber)
79 {
80 case 0:
81
82 /* Parse only - caller will setup callbacks */
83
87 WalkState->DescendingCallback = NULL;
88 WalkState->AscendingCallback = NULL;
89 break;
90
91 case 1:
92
93 /* Load pass 1 */
94
99 break;
100
101 case 2:
102
103 /* Load pass 2 */
104
105 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 |
109 break;
110
111 case 3:
112
113 /* Execution pass */
114
115 WalkState->ParseFlags |= ACPI_PARSE_EXECUTE |
119 break;
120
121 default:
122
123 return (AE_BAD_PARAMETER);
124 }
125
126 return (AE_OK);
127}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_PARSE_LOAD_PASS1
Definition: acparser.h:59
#define ACPI_PARSE_DELETE_TREE
Definition: acparser.h:55
ACPI_STATUS AcpiDsExecEndOp(ACPI_WALK_STATE *WalkState)
Definition: dswexec.c:392
ACPI_STATUS AcpiDsExecBeginOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
Definition: dswexec.c:234
ACPI_STATUS AcpiDsLoad1EndOp(ACPI_WALK_STATE *WalkState)
Definition: dswload.c:443
ACPI_STATUS AcpiDsLoad1BeginOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp)
Definition: dswload.c:144
ACPI_PARSE_UPWARDS AscendingCallback
Definition: acstruct.h:129

Referenced by AcpiDsInitAmlWalk().

◆ AcpiDsInitFieldObjects()

ACPI_STATUS AcpiDsInitFieldObjects ( ACPI_PARSE_OBJECT Op,
ACPI_WALK_STATE WalkState 
)

Definition at line 617 of file dsfield.c.

620{
622 ACPI_PARSE_OBJECT *Arg = NULL;
624 UINT8 Type = 0;
626
627
628 ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
629
630
631 /* Execute flag should always be set when this function is entered */
632
633 if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
634 {
635 if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
636 {
637 /* BankField Op is deferred, just return OK */
638
640 }
641
643 "Parse deferred mode is not set"));
645 }
646
647 /*
648 * Get the FieldList argument for this opcode. This is the start of the
649 * list of field elements.
650 */
651 switch (WalkState->Opcode)
652 {
653 case AML_FIELD_OP:
654
655 Arg = AcpiPsGetArg (Op, 2);
657 break;
658
660
661 Arg = AcpiPsGetArg (Op, 4);
663 break;
664
666
667 Arg = AcpiPsGetArg (Op, 3);
669 break;
670
671 default:
672
674 }
675
676 /* Creating new namespace node(s), should not already exist */
677
680
681 /*
682 * Mark node(s) temporary if we are executing a normal control
683 * method. (Don't mark if this is a module-level code method)
684 */
685 if (WalkState->MethodNode &&
686 !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
687 {
689 }
690
691#ifdef ACPI_EXEC_APP
693#endif
694 /*
695 * Walk the list of entries in the FieldList
696 * Note: FieldList can be of zero length. In this case, Arg will be NULL.
697 */
698 while (Arg)
699 {
700 /*
701 * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
702 * in the field names in order to enter them into the namespace.
703 */
704 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
705 {
706 Status = AcpiNsLookup (WalkState->ScopeInfo,
707 (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
708 Flags, WalkState, &Node);
709 if (ACPI_FAILURE (Status))
710 {
712 (char *) &Arg->Named.Name, Status);
714 {
716 }
717
718 /* Name already exists, just ignore this error */
719 }
720
721 Arg->Common.Node = Node;
722 }
723
724 /* Get the next field element in the list */
725
726 Arg = Arg->Common.Next;
727 }
728
730}
#define ACPI_NS_OVERRIDE_IF_FOUND
Definition: acnamesp.h:70
#define ACPI_PARSE_DEFERRED_OP
Definition: acparser.h:64
#define AML_INDEX_FIELD_OP
Definition: amlcode.h:186
#define AML_FIELD_OP
Definition: amlcode.h:181

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsInitializeObjects()

ACPI_STATUS AcpiDsInitializeObjects ( UINT32  TableIndex,
ACPI_NAMESPACE_NODE StartNode 
)

Definition at line 204 of file dsinit.c.

207{
212
213
214 ACPI_FUNCTION_TRACE (DsInitializeObjects);
215
216
217 Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
218 if (ACPI_FAILURE (Status))
219 {
221 }
222
224 "**** Starting initialization of namespace objects ****\n"));
225
226 /* Set all init info to zero */
227
228 memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
229
230 Info.OwnerId = OwnerId;
231 Info.TableIndex = TableIndex;
232
233 /* Walk entire namespace from the supplied root */
234
235 /*
236 * We don't use AcpiWalkNamespace since we do not want to acquire
237 * the namespace reader lock.
238 */
241 if (ACPI_FAILURE (Status))
242 {
243 ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
244 }
245
246 Status = AcpiGetTableByIndex (TableIndex, &Table);
247 if (ACPI_FAILURE (Status))
248 {
250 }
251
252 /* DSDT is always the first AML table */
253
254 if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT))
255 {
257 "\nACPI table initialization:\n"));
258 }
259
260 /* Summary of objects initialized */
261
263 "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, "
264 "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n",
265 Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount,
266 Info.DeviceCount,Info.OpRegionCount, Info.MethodCount,
267 Info.SerialMethodCount, Info.NonSerialMethodCount,
268 Info.SerializedMethodCount));
269
270 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n",
271 Info.MethodCount, Info.OpRegionCount));
272
274}
#define ACPI_NS_WALK_NO_UNLOCK
Definition: acnamesp.h:76
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
#define ACPI_DB_INIT
Definition: acoutput.h:151
ACPI_STATUS AcpiTbGetOwnerId(UINT32 TableIndex, ACPI_OWNER_ID *OwnerId)
Definition: tbdata.c:993
#define ACPI_SIG_DSDT
Definition: actbl.h:67
#define ACPI_COMPARE_NAMESEG(a, b)
Definition: actypes.h:564
#define ACPI_UINT32_MAX
Definition: actypes.h:66
UINT16 ACPI_OWNER_ID
Definition: actypes.h:486
static ACPI_STATUS AcpiDsInitOneObject(ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue)
Definition: dsinit.c:86

Referenced by AcpiNsLoadTable().

◆ AcpiDsInitializeRegion()

ACPI_STATUS AcpiDsInitializeRegion ( ACPI_HANDLE  ObjHandle)

Definition at line 82 of file dsopcode.c.

84{
85 ACPI_OPERAND_OBJECT *ObjDesc;
87
88
89 ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
90
91 /* Namespace is NOT locked */
92
94 return (Status);
95}
ACPI_STATUS AcpiEvInitializeRegion(ACPI_OPERAND_OBJECT *RegionObj)
Definition: evrgnini.c:629

Referenced by AcpiDsInitOneObject().

◆ AcpiDsInitObjectFromOp()

ACPI_STATUS AcpiDsInitObjectFromOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
UINT16  Opcode,
ACPI_OPERAND_OBJECT **  ObjDesc 
)

Definition at line 373 of file dsobject.c.

378{
379 const ACPI_OPCODE_INFO *OpInfo;
380 ACPI_OPERAND_OBJECT *ObjDesc;
382
383
384 ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
385
386
387 ObjDesc = *RetObjDesc;
388 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
389 if (OpInfo->Class == AML_CLASS_UNKNOWN)
390 {
391 /* Unknown opcode */
392
394 }
395
396 /* Perform per-object initialization */
397
398 switch (ObjDesc->Common.Type)
399 {
400 case ACPI_TYPE_BUFFER:
401 /*
402 * Defer evaluation of Buffer TermArg operand
403 */
404 ObjDesc->Buffer.Node = ACPI_CAST_PTR (
405 ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
406 ObjDesc->Buffer.AmlStart = Op->Named.Data;
407 ObjDesc->Buffer.AmlLength = Op->Named.Length;
408 break;
409
411 /*
412 * Defer evaluation of Package TermArg operand and all
413 * package elements. (01/2017): We defer the element
414 * resolution to allow forward references from the package
415 * in order to provide compatibility with other ACPI
416 * implementations.
417 */
418 ObjDesc->Package.Node = ACPI_CAST_PTR (
419 ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
420
421 if (!Op->Named.Data)
422 {
424 }
425
426 ObjDesc->Package.AmlStart = Op->Named.Data;
427 ObjDesc->Package.AmlLength = Op->Named.Length;
428 break;
429
431
432 switch (OpInfo->Type)
433 {
435 /*
436 * Resolve AML Constants here - AND ONLY HERE!
437 * All constants are integers.
438 * We mark the integer with a flag that indicates that it started
439 * life as a constant -- so that stores to constants will perform
440 * as expected (noop). ZeroOp is used as a placeholder for optional
441 * target operands.
442 */
443 ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
444
445 switch (Opcode)
446 {
447 case AML_ZERO_OP:
448
449 ObjDesc->Integer.Value = 0;
450 break;
451
452 case AML_ONE_OP:
453
454 ObjDesc->Integer.Value = 1;
455 break;
456
457 case AML_ONES_OP:
458
459 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
460
461 /* Truncate value if we are executing from a 32-bit ACPI table */
462
464 break;
465
466 case AML_REVISION_OP:
467
468 ObjDesc->Integer.Value = ACPI_CA_VERSION;
469 break;
470
471 default:
472
474 "Unknown constant opcode 0x%X", Opcode));
476 break;
477 }
478 break;
479
480 case AML_TYPE_LITERAL:
481
482 ObjDesc->Integer.Value = Op->Common.Value.Integer;
483
484 if (AcpiExTruncateFor32bitTable (ObjDesc))
485 {
486 /* Warn if we found a 64-bit constant in a 32-bit table */
487
489 "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
490 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
491 (UINT32) ObjDesc->Integer.Value));
492 }
493 break;
494
495 default:
496
497 ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
498 OpInfo->Type));
500 break;
501 }
502 break;
503
504 case ACPI_TYPE_STRING:
505
506 ObjDesc->String.Pointer = Op->Common.Value.String;
507 ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
508
509 /*
510 * The string is contained in the ACPI table, don't ever try
511 * to delete it
512 */
513 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
514 break;
515
516 case ACPI_TYPE_METHOD:
517 break;
518
520
521 switch (OpInfo->Type)
522 {
524
525 /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
526
529
531 ObjDesc->Reference.Value, WalkState,
533 &ObjDesc->Reference.Object));
534 break;
535
537
538 /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
539
542
544 ObjDesc->Reference.Value, WalkState,
546 &ObjDesc->Reference.Object));
547 break;
548
549 default: /* Object name or Debug object */
550
551 switch (Op->Common.AmlOpcode)
552 {
554
555 /* Node was saved in Op */
556
557 ObjDesc->Reference.Node = Op->Common.Node;
559 if (Op->Common.Node)
560 {
561 ObjDesc->Reference.Object = Op->Common.Node->Object;
562 }
563 break;
564
565 case AML_DEBUG_OP:
566
568 break;
569
570 default:
571
573 "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
575 }
576 break;
577 }
578 break;
579
580 default:
581
582 ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
583 ObjDesc->Common.Type));
584
586 break;
587 }
588
590}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
@ ACPI_REFCLASS_NAME
Definition: acobject.h:464
@ ACPI_REFCLASS_ARG
Definition: acobject.h:460
@ ACPI_REFCLASS_LOCAL
Definition: acobject.h:459
@ ACPI_REFCLASS_DEBUG
Definition: acobject.h:465
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
#define AOPOBJ_AML_CONSTANT
Definition: acobject.h:94
#define ACPI_CA_VERSION
Definition: acpixf.h:49
#define ACPI_UINT64_MAX
Definition: actypes.h:67
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define AML_FIRST_ARG_OP
Definition: amlcode.h:80
#define AML_ONES_OP
Definition: amlcode.h:142
#define AML_FIRST_LOCAL_OP
Definition: amlcode.h:71
#define AML_TYPE_METHOD_ARGUMENT
Definition: amlcode.h:369
#define AML_DEBUG_OP
Definition: amlcode.h:177
#define AML_TYPE_LITERAL
Definition: amlcode.h:367
#define AML_ONE_OP
Definition: amlcode.h:52
#define AML_TYPE_LOCAL_VARIABLE
Definition: amlcode.h:370
#define AML_TYPE_CONSTANT
Definition: amlcode.h:368
#define AML_REVISION_OP
Definition: amlcode.h:176
ACPI_STATUS AcpiDsMethodDataGetNode(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node)
Definition: dsmthdat.c:275
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_STRING String
Definition: acobject.h:521

Referenced by AcpiDsBuildInternalObject(), and AcpiDsCreateOperand().

◆ AcpiDsInitPackageElement()

ACPI_STATUS AcpiDsInitPackageElement ( UINT8  ObjectType,
ACPI_OPERAND_OBJECT SourceObject,
ACPI_GENERIC_STATE State,
void Context 
)

Definition at line 369 of file dspkginit.c.

374{
375 ACPI_OPERAND_OBJECT **ElementPtr;
376
377
378 ACPI_FUNCTION_TRACE (DsInitPackageElement);
379
380
381 if (!SourceObject)
382 {
384 }
385
386 /*
387 * The following code is a bit of a hack to workaround a (current)
388 * limitation of the ACPI_PKG_CALLBACK interface. We need a pointer
389 * to the location within the element array because a new object
390 * may be created and stored there.
391 */
392 if (Context)
393 {
394 /* A direct call was made to this function */
395
396 ElementPtr = (ACPI_OPERAND_OBJECT **) Context;
397 }
398 else
399 {
400 /* Call came from AcpiUtWalkPackageTree */
401
402 ElementPtr = State->Pkg.ThisTargetObj;
403 }
404
405 /* We are only interested in reference objects/elements */
406
407 if (SourceObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
408 {
409 /* Attempt to resolve the (named) reference to a namespace node */
410
411 AcpiDsResolvePackageElement (ElementPtr);
412 }
413 else if (SourceObject->Common.Type == ACPI_TYPE_PACKAGE)
414 {
415 SourceObject->Package.Flags |= AOPOBJ_DATA_VALID;
416 }
417
419}
static void AcpiDsResolvePackageElement(ACPI_OPERAND_OBJECT **Element)
Definition: dspkginit.c:436

Referenced by AcpiDsBuildInternalPackageObj(), and AcpiNsInitOnePackage().

◆ AcpiDsIsMethodValue()

BOOLEAN AcpiDsIsMethodValue ( ACPI_OPERAND_OBJECT ObjDesc)

◆ AcpiDsIsResultUsed()

BOOLEAN AcpiDsIsResultUsed ( ACPI_PARSE_OBJECT Op,
ACPI_WALK_STATE WalkState 
)

Definition at line 187 of file dsutils.c.

190{
191 const ACPI_OPCODE_INFO *ParentInfo;
192
193 ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op);
194
195
196 /* Must have both an Op and a Result Object */
197
198 if (!Op)
199 {
200 ACPI_ERROR ((AE_INFO, "Null Op"));
202 }
203
204 /*
205 * We know that this operator is not a
206 * Return() operator (would not come here.) The following code is the
207 * optional support for a so-called "implicit return". Some AML code
208 * assumes that the last value of the method is "implicitly" returned
209 * to the caller. Just save the last result as the return value.
210 * NOTE: this is optional because the ASL language does not actually
211 * support this behavior.
212 */
213 (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE);
214
215 /*
216 * Now determine if the parent will use the result
217 *
218 * If there is no parent, or the parent is a ScopeOp, we are executing
219 * at the method level. An executing method typically has no parent,
220 * since each method is parsed separately. A method invoked externally
221 * via ExecuteControlMethod has a ScopeOp as the parent.
222 */
223 if ((!Op->Common.Parent) ||
224 (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
225 {
226 /* No parent, the return value cannot possibly be used */
227
229 "At Method level, result of [%s] not used\n",
230 AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
232 }
233
234 /* Get info on the parent. The RootOp is AML_SCOPE */
235
236 ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
237 if (ParentInfo->Class == AML_CLASS_UNKNOWN)
238 {
240 "Unknown parent opcode Op=%p", Op));
242 }
243
244 /*
245 * Decide what to do with the result based on the parent. If
246 * the parent opcode will not use the result, delete the object.
247 * Otherwise leave it as is, it will be deleted when it is used
248 * as an operand later.
249 */
250 switch (ParentInfo->Class)
251 {
253
254 switch (Op->Common.Parent->Common.AmlOpcode)
255 {
256 case AML_RETURN_OP:
257
258 /* Never delete the return value associated with a return opcode */
259
260 goto ResultUsed;
261
262 case AML_IF_OP:
263 case AML_WHILE_OP:
264 /*
265 * If we are executing the predicate AND this is the predicate op,
266 * we will use the return value
267 */
268 if ((WalkState->ControlState->Common.State ==
270 (WalkState->ControlState->Control.PredicateOp == Op))
271 {
272 goto ResultUsed;
273 }
274 break;
275
276 default:
277
278 /* Ignore other control opcodes */
279
280 break;
281 }
282
283 /* The general control opcode returns no result */
284
285 goto ResultNotUsed;
286
287 case AML_CLASS_CREATE:
288 /*
289 * These opcodes allow TermArg(s) as operands and therefore
290 * the operands can be method calls. The result is used.
291 */
292 goto ResultUsed;
293
295
296 if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
297 (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
298 (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
299 (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
300 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
301 (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
302 (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
303 {
304 /*
305 * These opcodes allow TermArg(s) as operands and therefore
306 * the operands can be method calls. The result is used.
307 */
308 goto ResultUsed;
309 }
310
311 goto ResultNotUsed;
312
313 default:
314 /*
315 * In all other cases. the parent will actually use the return
316 * object, so keep it.
317 */
318 goto ResultUsed;
319 }
320
321
322ResultUsed:
324 "Result of [%s] used by Parent [%s] Op=%p\n",
325 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
326 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
327
329
330
331ResultNotUsed:
333 "Result of [%s] not used by Parent [%s] Op=%p\n",
334 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
335 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
336
338}
#define return_UINT8(s)
Definition: acoutput.h:500

Referenced by AcpiDsDeleteResultIfNotUsed(), and AcpiPsNextParseState().

◆ AcpiDsLoad1BeginOp()

ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT **  OutOp 
)

Definition at line 144 of file dswload.c.

147{
152 char *Path;
154
155
156 ACPI_FUNCTION_TRACE_PTR (DsLoad1BeginOp, WalkState->Op);
157
158
159 Op = WalkState->Op;
160 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
161
162 /* We are only interested in opcodes that have an associated name */
163
164 if (Op)
165 {
166 if (!(WalkState->OpInfo->Flags & AML_NAMED))
167 {
168 *OutOp = Op;
170 }
171
172 /* Check if this object has already been installed in the namespace */
173
174 if (Op->Common.Node)
175 {
176 *OutOp = Op;
178 }
179 }
180
182
183 /* Map the raw opcode into an internal object type */
184
185 ObjectType = WalkState->OpInfo->ObjectType;
186
188 "State=%p Op=%p [%s]\n", WalkState, Op,
190
191 switch (WalkState->Opcode)
192 {
193 case AML_SCOPE_OP:
194 /*
195 * The target name of the Scope() operator must exist at this point so
196 * that we can actually open the scope to enter new names underneath it.
197 * Allow search-to-root for single namesegs.
198 */
201#ifdef ACPI_ASL_COMPILER
202 if (Status == AE_NOT_FOUND)
203 {
204 /*
205 * Table disassembly:
206 * Target of Scope() not found. Generate an External for it, and
207 * insert the name into the namespace.
208 */
212 WalkState, &Node);
213 }
214#endif
215 if (ACPI_FAILURE (Status))
216 {
219 }
220
221 /*
222 * Check to make sure that the target is
223 * one of the opcodes that actually opens a scope
224 */
225 switch (Node->Type)
226 {
227 case ACPI_TYPE_ANY:
228 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
229 case ACPI_TYPE_DEVICE:
230 case ACPI_TYPE_POWER:
233
234 /* These are acceptable types */
235 break;
236
238 case ACPI_TYPE_STRING:
239 case ACPI_TYPE_BUFFER:
240 /*
241 * These types we will allow, but we will change the type.
242 * This enables some existing code of the form:
243 *
244 * Name (DEB, 0)
245 * Scope (DEB) { ... }
246 *
247 * Note: silently change the type here. On the second pass,
248 * we will report a warning
249 */
251 "Type override - [%4.4s] had invalid type (%s) "
252 "for Scope operator, changed to type ANY\n",
254
255 Node->Type = ACPI_TYPE_ANY;
256 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
257 break;
258
259 case ACPI_TYPE_METHOD:
260 /*
261 * Allow scope change to root during execution of module-level
262 * code. Root is typed METHOD during this time.
263 */
264 if ((Node == AcpiGbl_RootNode) &&
265 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
266 {
267 break;
268 }
269
271
272 default:
273
274 /* All other types are an error */
275
277 "Invalid type (%s) for target of "
278 "Scope operator [%4.4s] (Cannot override)",
280
282 }
283 break;
284
285 default:
286 /*
287 * For all other named opcodes, we will enter the name into
288 * the namespace.
289 *
290 * Setup the search flags.
291 * Since we are entering a name into the namespace, we do not want to
292 * enable the search-to-root upsearch.
293 *
294 * There are only two conditions where it is acceptable that the name
295 * already exists:
296 * 1) the Scope() operator can reopen a scoping object that was
297 * previously defined (Scope, Method, Device, etc.)
298 * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
299 * BufferField, or Package), the name of the object is already
300 * in the namespace.
301 */
302 if (WalkState->DeferredNode)
303 {
304 /* This name is already in the namespace, get the node */
305
306 Node = WalkState->DeferredNode;
307 Status = AE_OK;
308 break;
309 }
310
311 /*
312 * If we are executing a method, do not create any namespace objects
313 * during the load phase, only during execution.
314 */
315 if (WalkState->MethodNode)
316 {
317 Node = NULL;
318 Status = AE_OK;
319 break;
320 }
321
323 if ((WalkState->Opcode != AML_SCOPE_OP) &&
324 (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
325 {
326 if (WalkState->NamespaceOverride)
327 {
329 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
331 }
332 else
333 {
335 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
337 }
338 }
339 else
340 {
342 "[%s] Both Find or Create allowed\n",
344 }
345
346 /*
347 * Enter the named type into the internal namespace. We enter the name
348 * as we go downward in the parse tree. Any necessary subobjects that
349 * involve arguments to the opcode must be created as we go back up the
350 * parse tree later.
351 */
353 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
354 if (ACPI_FAILURE (Status))
355 {
357 {
358 /* The name already exists in this scope */
359
360 if (Node->Flags & ANOBJ_IS_EXTERNAL)
361 {
362 /*
363 * Allow one create on an object or segment that was
364 * previously declared External
365 */
366 Node->Flags &= ~ANOBJ_IS_EXTERNAL;
367 Node->Type = (UINT8) ObjectType;
368
369 /* Just retyped a node, probably will need to open a scope */
370
372 {
374 Node, ObjectType, WalkState);
375 if (ACPI_FAILURE (Status))
376 {
378 }
379 }
380
381 Status = AE_OK;
382 }
383 }
384
385 if (ACPI_FAILURE (Status))
386 {
389 }
390 }
391 break;
392 }
393
394 /* Common exit */
395
396 if (!Op)
397 {
398 /* Create a new op */
399
400 Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
401 if (!Op)
402 {
404 }
405 }
406
407 /* Initialize the op */
408
409#ifdef ACPI_CONSTANT_EVAL_ONLY
410 Op->Named.Path = Path;
411#endif
412
413 if (Node)
414 {
415 /*
416 * Put the Node in the "op" object that the parser uses, so we
417 * can get it again quickly when this scope is closed
418 */
419 Op->Common.Node = Node;
420 Op->Named.Name = Node->Name.Integer;
421 }
422
424 *OutOp = Op;
426}
PRTL_UNICODE_STRING_BUFFER Path
void AcpiDmAddOpToExternalList(ACPI_PARSE_OBJECT *Op, char *Path, UINT8 Type, UINT32 Value, UINT16 Flags)
#define ANOBJ_IS_EXTERNAL
Definition: aclocal.h:224
char * AcpiPsGetNextNamestring(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:172
void AcpiPsAppendArg(ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
Definition: pstree.c:138
ACPI_PARSE_OBJECT * AcpiPsGetParentScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:65
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:699
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
#define ACPI_TYPE_POWER
Definition: actypes.h:698
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
#define ACPI_TYPE_LOCAL_SCOPE
Definition: actypes.h:726
#define ACPI_TYPE_THERMAL
Definition: actypes.h:700
#define AML_NAMED
Definition: amlcode.h:323
ObjectType
Definition: metafile.c:81
ACPI_PARSE_COMMON char * Path
Definition: aclocal.h:1032
BOOLEAN NamespaceOverride
Definition: acstruct.h:88

Referenced by AcpiDsInitCallbacks().

◆ AcpiDsLoad1EndOp()

ACPI_STATUS AcpiDsLoad1EndOp ( ACPI_WALK_STATE WalkState)

Definition at line 443 of file dswload.c.

445{
449#ifdef ACPI_ASL_COMPILER
450 UINT8 ParamCount;
451#endif
452
453
454 ACPI_FUNCTION_TRACE (DsLoad1EndOp);
455
456
457 Op = WalkState->Op;
458 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
459
460 /*
461 * Disassembler: handle create field operators here.
462 *
463 * CreateBufferField is a deferred op that is typically processed in load
464 * pass 2. However, disassembly of control method contents walk the parse
465 * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed
466 * in a later walk. This is a problem when there is a control method that
467 * has the same name as the AML_CREATE object. In this case, any use of the
468 * name segment will be detected as a method call rather than a reference
469 * to a buffer field.
470 *
471 * This earlier creation during disassembly solves this issue by inserting
472 * the named object in the ACPI namespace so that references to this name
473 * would be a name string rather than a method call.
474 */
475 if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) &&
476 (WalkState->OpInfo->Flags & AML_CREATE))
477 {
478 Status = AcpiDsCreateBufferField (Op, WalkState);
480 }
481
482 /* We are only interested in opcodes that have an associated name */
483
484 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
485 {
487 }
488
489 /* Get the object type to determine if we should pop the scope */
490
491 ObjectType = WalkState->OpInfo->ObjectType;
492
493 if (WalkState->OpInfo->Flags & AML_FIELD)
494 {
495 /*
496 * If we are executing a method, do not create any namespace objects
497 * during the load phase, only during execution.
498 */
499 if (!WalkState->MethodNode)
500 {
501 if (WalkState->Opcode == AML_FIELD_OP ||
502 WalkState->Opcode == AML_BANK_FIELD_OP ||
503 WalkState->Opcode == AML_INDEX_FIELD_OP)
504 {
505 Status = AcpiDsInitFieldObjects (Op, WalkState);
506 }
507 }
509 }
510
511 /*
512 * If we are executing a method, do not create any namespace objects
513 * during the load phase, only during execution.
514 */
515 if (!WalkState->MethodNode)
516 {
517 if (Op->Common.AmlOpcode == AML_REGION_OP)
518 {
521 ((Op->Common.Value.Arg)->Common.Value.Integer),
522 WalkState);
523 if (ACPI_FAILURE (Status))
524 {
526 }
527 }
528 else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
529 {
531 ACPI_ADR_SPACE_DATA_TABLE, WalkState);
532 if (ACPI_FAILURE (Status))
533 {
535 }
536 }
537 }
538
539 if (Op->Common.AmlOpcode == AML_NAME_OP)
540 {
541 /* For Name opcode, get the object type from the argument */
542
543 if (Op->Common.Value.Arg)
544 {
546 (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
547
548 /* Set node type if we have a namespace node */
549
550 if (Op->Common.Node)
551 {
552 Op->Common.Node->Type = (UINT8) ObjectType;
553 }
554 }
555 }
556
557#ifdef ACPI_ASL_COMPILER
558 /*
559 * For external opcode, get the object type from the argument and
560 * get the parameter count from the argument's next.
561 */
562 if (AcpiGbl_DisasmFlag &&
563 Op->Common.Node &&
564 Op->Common.AmlOpcode == AML_EXTERNAL_OP)
565 {
566 /*
567 * Note, if this external is not a method
568 * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0
569 * Therefore, ParamCount will be 0.
570 */
571 ParamCount = (UINT8) Op->Common.Value.Arg->Common.Next->Common.Value.Integer;
572 ObjectType = (UINT8) Op->Common.Value.Arg->Common.Value.Integer;
573 Op->Common.Node->Flags |= ANOBJ_IS_EXTERNAL;
574 Op->Common.Node->Type = (UINT8) ObjectType;
575
577 &Op->Common.Node, ParamCount);
578
579 /*
580 * Add the external to the external list because we may be
581 * emitting code based off of the items within the external list.
582 */
583 AcpiDmAddOpToExternalList (Op, Op->Named.Path, (UINT8)ObjectType, ParamCount,
585 }
586#endif
587
588 /*
589 * If we are executing a method, do not create any namespace objects
590 * during the load phase, only during execution.
591 */
592 if (!WalkState->MethodNode)
593 {
594 if (Op->Common.AmlOpcode == AML_METHOD_OP)
595 {
596 /*
597 * MethodOp PkgLength NameString MethodFlags TermList
598 *
599 * Note: We must create the method node/object pair as soon as we
600 * see the method declaration. This allows later pass1 parsing
601 * of invocations of the method (need to know the number of
602 * arguments.)
603 */
605 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
606 WalkState, Op, Op->Named.Node));
607
608 if (!AcpiNsGetAttachedObject (Op->Named.Node))
609 {
610 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
611 WalkState->NumOperands = 1;
612
614 WalkState, Op->Common.Value.Arg);
615 if (ACPI_SUCCESS (Status))
616 {
618 Op->Named.Length, WalkState);
619 }
620
621 WalkState->Operands[0] = NULL;
622 WalkState->NumOperands = 0;
623
624 if (ACPI_FAILURE (Status))
625 {
627 }
628 }
629 }
630 }
631
632 /* Pop the scope stack (only if loading a table) */
633
634 if (!WalkState->MethodNode &&
635 Op->Common.AmlOpcode != AML_EXTERNAL_OP &&
637 {
638 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
640
641 Status = AcpiDsScopeStackPop (WalkState);
642 }
643
645}
void AcpiDmCreateSubobjectForExternal(UINT8 Type, ACPI_NAMESPACE_NODE **Node, UINT32 Value)
#define ACPI_EXT_RESOLVED_REFERENCE
Definition: aclocal.h:1379
#define ACPI_EXT_ORIGIN_FROM_OPCODE
Definition: aclocal.h:1383
#define ACPI_ADR_SPACE_DATA_TABLE
Definition: actypes.h:884
#define AML_FIELD
Definition: amlcode.h:321
#define AML_CREATE
Definition: amlcode.h:320
ACPI_STATUS AcpiDsCreateBufferField(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: dsfield.c:165
ACPI_STATUS AcpiDsInitFieldObjects(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: dsfield.c:617
ACPI_STATUS AcpiExCreateRegion(UINT8 *AmlStart, UINT32 AmlLength, UINT8 SpaceId, ACPI_WALK_STATE *WalkState)
Definition: excreate.c:268
ACPI_STATUS AcpiExCreateMethod(UINT8 *AmlStart, UINT32 AmlLength, ACPI_WALK_STATE *WalkState)
Definition: excreate.c:484

Referenced by AcpiDsInitCallbacks().

◆ AcpiDsLoad2BeginOp()

ACPI_STATUS AcpiDsLoad2BeginOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT **  OutOp 
)

Definition at line 74 of file dswload2.c.

77{
82 char *BufferPtr;
84
85
86 ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
87
88
89 Op = WalkState->Op;
90 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
91
92 if (Op)
93 {
94 if ((WalkState->ControlState) &&
95 (WalkState->ControlState->Common.State ==
97 {
98 /* We are executing a while loop outside of a method */
99
100 Status = AcpiDsExecBeginOp (WalkState, OutOp);
102 }
103
104 /* We only care about Namespace opcodes here */
105
106 if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
107 (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
108 (!(WalkState->OpInfo->Flags & AML_NAMED)))
109 {
111 }
112
113 /* Get the name we are going to enter or lookup in the namespace */
114
115 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
116 {
117 /* For Namepath op, get the path string */
118
119 BufferPtr = Op->Common.Value.String;
120 if (!BufferPtr)
121 {
122 /* No name, just exit */
123
125 }
126 }
127 else
128 {
129 /* Get name from the op */
130
131 BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
132 }
133 }
134 else
135 {
136 /* Get the namestring from the raw AML */
137
138 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
139 }
140
141 /* Map the opcode into an internal object type */
142
143 ObjectType = WalkState->OpInfo->ObjectType;
144
146 "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
147
148 switch (WalkState->Opcode)
149 {
150 case AML_FIELD_OP:
153
154 Node = NULL;
155 Status = AE_OK;
156 break;
157
159 /*
160 * The NamePath is an object reference to an existing object.
161 * Don't enter the name into the namespace, but look it up
162 * for use later.
163 */
164 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
166 WalkState, &(Node));
167 break;
168
169 case AML_SCOPE_OP:
170
171 /* Special case for Scope(\‍) -> refers to the Root node */
172
173 if (Op && (Op->Named.Node == AcpiGbl_RootNode))
174 {
175 Node = Op->Named.Node;
176
178 if (ACPI_FAILURE (Status))
179 {
181 }
182 }
183 else
184 {
185 /*
186 * The Path is an object reference to an existing object.
187 * Don't enter the name into the namespace, but look it up
188 * for use later.
189 */
190 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
192 WalkState, &(Node));
193 if (ACPI_FAILURE (Status))
194 {
195#ifdef ACPI_ASL_COMPILER
196 if (Status == AE_NOT_FOUND)
197 {
198 Status = AE_OK;
199 }
200 else
201 {
203 BufferPtr, Status);
204 }
205#else
207 BufferPtr, Status);
208#endif
210 }
211 }
212
213 /*
214 * We must check to make sure that the target is
215 * one of the opcodes that actually opens a scope
216 */
217 switch (Node->Type)
218 {
219 case ACPI_TYPE_ANY:
220 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
221 case ACPI_TYPE_DEVICE:
222 case ACPI_TYPE_POWER:
225
226 /* These are acceptable types */
227 break;
228
230 case ACPI_TYPE_STRING:
231 case ACPI_TYPE_BUFFER:
232
233 /*
234 * These types we will allow, but we will change the type.
235 * This enables some existing code of the form:
236 *
237 * Name (DEB, 0)
238 * Scope (DEB) { ... }
239 */
241 "Type override - [%4.4s] had invalid type (%s) "
242 "for Scope operator, changed to type ANY",
244
245 Node->Type = ACPI_TYPE_ANY;
246 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
247 break;
248
249 case ACPI_TYPE_METHOD:
250
251 /*
252 * Allow scope change to root during execution of module-level
253 * code. Root is typed METHOD during this time.
254 */
255 if ((Node == AcpiGbl_RootNode) &&
256 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
257 {
258 break;
259 }
260
262
263 default:
264
265 /* All other types are an error */
266
268 "Invalid type (%s) for target of "
269 "Scope operator [%4.4s] (Cannot override)",
271
273 }
274 break;
275
276 default:
277
278 /* All other opcodes */
279
280 if (Op && Op->Common.Node)
281 {
282 /* This op/node was previously entered into the namespace */
283
284 Node = Op->Common.Node;
285
287 {
289 if (ACPI_FAILURE (Status))
290 {
292 }
293 }
294
296 }
297
298 /*
299 * Enter the named type into the internal namespace. We enter the name
300 * as we go downward in the parse tree. Any necessary subobjects that
301 * involve arguments to the opcode must be created as we go back up the
302 * parse tree later.
303 *
304 * Note: Name may already exist if we are executing a deferred opcode.
305 */
306 if (WalkState->DeferredNode)
307 {
308 /* This name is already in the namespace, get the node */
309
310 Node = WalkState->DeferredNode;
311 Status = AE_OK;
312 break;
313 }
314
316 if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
317 {
318 /* Execution mode, node cannot already exist, node is temporary */
319
321
322 if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
323 {
325 }
326 }
327
328#ifdef ACPI_ASL_COMPILER
329
330 /*
331 * Do not open a scope for AML_EXTERNAL_OP
332 * AcpiNsLookup can open a new scope based on the object type
333 * of this op. AML_EXTERNAL_OP is a declaration rather than a
334 * definition. In the case that this external is a method object,
335 * AcpiNsLookup will open a new scope. However, an AML_EXTERNAL_OP
336 * associated with the ACPI_TYPE_METHOD is a declaration, rather than
337 * a definition. Flags is set to avoid opening a scope for any
338 * AML_EXTERNAL_OP.
339 */
340 if (WalkState->Opcode == AML_EXTERNAL_OP)
341 {
343 }
344#endif
345
346 /*
347 * For name creation opcodes, the full namepath prefix must
348 * exist, except for the final (new) nameseg.
349 */
350 if (WalkState->OpInfo->Flags & AML_NAMED)
351 {
353 }
354
355 /* Add new entry or lookup existing entry */
356
357 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
358 ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
359
361 {
363 "***New Node [%4.4s] %p is temporary\n",
365 }
366 break;
367 }
368
369 if (ACPI_FAILURE (Status))
370 {
372 BufferPtr, Status);
374 }
375
376 if (!Op)
377 {
378 /* Create a new op */
379
380 Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
381 if (!Op)
382 {
384 }
385
386 /* Initialize the new op */
387
388 if (Node)
389 {
390 Op->Named.Name = Node->Name.Integer;
391 }
392 *OutOp = Op;
393 }
394
395 /*
396 * Put the Node in the "op" object that the parser uses, so we
397 * can get it again quickly when this scope is closed
398 */
399 Op->Common.Node = Node;
401}
#define ACPI_NS_PREFIX_MUST_EXIST
Definition: acnamesp.h:72
#define AML_NSOPCODE
Definition: amlcode.h:325

Referenced by AcpiDsExecBeginOp(), and AcpiDsInitCallbacks().

◆ AcpiDsLoad2EndOp()

ACPI_STATUS AcpiDsLoad2EndOp ( ACPI_WALK_STATE WalkState)

Definition at line 418 of file dswload2.c.

420{
426 ACPI_NAMESPACE_NODE *NewNode;
427 UINT32 i;
428 UINT8 RegionSpace;
429#ifdef ACPI_EXEC_APP
430 ACPI_OPERAND_OBJECT *ObjDesc;
431 char *Namepath;
432#endif
433
434
435 ACPI_FUNCTION_TRACE (DsLoad2EndOp);
436
437 Op = WalkState->Op;
438 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
439 WalkState->OpInfo->Name, Op, WalkState));
440
441 /* Check if opcode had an associated namespace object */
442
443 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
444 {
446 }
447
448 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
449 {
451 "Ending scope Op=%p State=%p\n", Op, WalkState));
452 }
453
454 ObjectType = WalkState->OpInfo->ObjectType;
455
456 /*
457 * Get the Node/name from the earlier lookup
458 * (It was saved in the *op structure)
459 */
460 Node = Op->Common.Node;
461
462 /*
463 * Put the Node on the object stack (Contains the ACPI Name of
464 * this object)
465 */
466 WalkState->Operands[0] = (void *) Node;
467 WalkState->NumOperands = 1;
468
469 /* Pop the scope stack */
470
472 (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
473 {
474 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
476
477 Status = AcpiDsScopeStackPop (WalkState);
478 if (ACPI_FAILURE (Status))
479 {
480 goto Cleanup;
481 }
482 }
483
484 /*
485 * Named operations are as follows:
486 *
487 * AML_ALIAS
488 * AML_BANKFIELD
489 * AML_CREATEBITFIELD
490 * AML_CREATEBYTEFIELD
491 * AML_CREATEDWORDFIELD
492 * AML_CREATEFIELD
493 * AML_CREATEQWORDFIELD
494 * AML_CREATEWORDFIELD
495 * AML_DATA_REGION
496 * AML_DEVICE
497 * AML_EVENT
498 * AML_FIELD
499 * AML_INDEXFIELD
500 * AML_METHOD
501 * AML_METHODCALL
502 * AML_MUTEX
503 * AML_NAME
504 * AML_NAMEDFIELD
505 * AML_OPREGION
506 * AML_POWERRES
507 * AML_PROCESSOR
508 * AML_SCOPE
509 * AML_THERMALZONE
510 */
511
513 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
514 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
515
516 /* Decode the opcode */
517
518 Arg = Op->Common.Value.Arg;
519
520 switch (WalkState->OpInfo->Type)
521 {
522
524 /*
525 * Create the field object, but the field buffer and index must
526 * be evaluated later during the execution phase
527 */
528 Status = AcpiDsCreateBufferField (Op, WalkState);
530 {
531 ACPI_EXCEPTION ((AE_INFO, Status, "CreateBufferField failure"));
532 goto Cleanup;
533 }
534 break;
535
537 /*
538 * If we are executing a method, initialize the field
539 */
540 if (WalkState->MethodNode)
541 {
542 Status = AcpiDsInitFieldObjects (Op, WalkState);
543 }
544
545 switch (Op->Common.AmlOpcode)
546 {
548
550 Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);
551 break;
552
554
555 Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
556 break;
557
558 case AML_FIELD_OP:
559
560 Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
561 break;
562
563 default:
564
565 /* All NAMED_FIELD opcodes must be handled above */
566 break;
567 }
568 break;
569
571
572 Status = AcpiDsCreateOperands (WalkState, Arg);
573 if (ACPI_FAILURE (Status))
574 {
575 goto Cleanup;
576 }
577
578 switch (Op->Common.AmlOpcode)
579 {
580 case AML_PROCESSOR_OP:
581
582 Status = AcpiExCreateProcessor (WalkState);
583 break;
584
586
587 Status = AcpiExCreatePowerResource (WalkState);
588 break;
589
590 case AML_MUTEX_OP:
591
592 Status = AcpiExCreateMutex (WalkState);
593 break;
594
595 case AML_EVENT_OP:
596
597 Status = AcpiExCreateEvent (WalkState);
598 break;
599
600 case AML_ALIAS_OP:
601
602 Status = AcpiExCreateAlias (WalkState);
603 break;
604
605 default:
606
607 /* Unknown opcode */
608
609 Status = AE_OK;
610 goto Cleanup;
611 }
612
613 /* Delete operands */
614
615 for (i = 1; i < WalkState->NumOperands; i++)
616 {
617 AcpiUtRemoveReference (WalkState->Operands[i]);
618 WalkState->Operands[i] = NULL;
619 }
620
621 break;
622
624
625 switch (Op->Common.AmlOpcode)
626 {
627 case AML_REGION_OP:
629
630 if (Op->Common.AmlOpcode == AML_REGION_OP)
631 {
632 RegionSpace = (ACPI_ADR_SPACE_TYPE)
633 ((Op->Common.Value.Arg)->Common.Value.Integer);
634 }
635 else
636 {
637 RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
638 }
639
640 /*
641 * The OpRegion is not fully parsed at this time. The only valid
642 * argument is the SpaceId. (We must save the address of the
643 * AML of the address and length operands)
644 *
645 * If we have a valid region, initialize it. The namespace is
646 * unlocked at this point.
647 *
648 * Need to unlock interpreter if it is locked (if we are running
649 * a control method), in order to allow _REG methods to be run
650 * during AcpiEvInitializeRegion.
651 */
652 if (WalkState->MethodNode)
653 {
654 /*
655 * Executing a method: initialize the region and unlock
656 * the interpreter
657 */
659 Op->Named.Length, RegionSpace, WalkState);
660 if (ACPI_FAILURE (Status))
661 {
663 }
664 }
665
668 break;
669
670 case AML_NAME_OP:
671
672 Status = AcpiDsCreateNode (WalkState, Node, Op);
673 if (ACPI_FAILURE (Status))
674 {
675 goto Cleanup;
676 }
677
678#ifdef ACPI_EXEC_APP
679 /*
680 * AcpiExec support for namespace initialization file (initialize
681 * Name opcodes in this code.)
682 */
683 Namepath = AcpiNsGetExternalPathname (Node);
684 Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
685 if (ACPI_SUCCESS (Status))
686 {
687 /* Detach any existing object, attach new object */
688
689 if (Node->Object)
690 {
692 }
693 AcpiNsAttachObject (Node, ObjDesc, ObjDesc->Common.Type);
694 }
695 ACPI_FREE (Namepath);
696 Status = AE_OK;
697#endif
698 break;
699
700 case AML_METHOD_OP:
701 /*
702 * MethodOp PkgLength NameString MethodFlags TermList
703 *
704 * Note: We must create the method node/object pair as soon as we
705 * see the method declaration. This allows later pass1 parsing
706 * of invocations of the method (need to know the number of
707 * arguments.)
708 */
710 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
711 WalkState, Op, Op->Named.Node));
712
713 if (!AcpiNsGetAttachedObject (Op->Named.Node))
714 {
715 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
716 WalkState->NumOperands = 1;
717
719 WalkState, Op->Common.Value.Arg);
720 if (ACPI_SUCCESS (Status))
721 {
723 Op->Named.Data, Op->Named.Length, WalkState);
724 }
725
726 WalkState->Operands[0] = NULL;
727 WalkState->NumOperands = 0;
728
729 if (ACPI_FAILURE (Status))
730 {
732 }
733 }
734 break;
735
736
737 default:
738
739 /* All NAMED_COMPLEX opcodes must be handled above */
740 break;
741 }
742 break;
743
745
746 /* case AML_INT_NAMEPATH_OP: */
747 break;
748
750
752 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
753 WalkState, Op, Node));
754
755 /*
756 * Lookup the method name and save the Node
757 */
758 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
761 WalkState, &(NewNode));
762 if (ACPI_SUCCESS (Status))
763 {
764 /*
765 * Make sure that what we found is indeed a method
766 * We didn't search for a method on purpose, to see if the name
767 * would resolve
768 */
769 if (NewNode->Type != ACPI_TYPE_METHOD)
770 {
772 }
773
774 /* We could put the returned object (Node) on the object stack for
775 * later, but for now, we will put it in the "op" object that the
776 * parser uses, so we can get it again at the end of this scope
777 */
778 Op->Common.Node = NewNode;
779 }
780 else
781 {
783 Arg->Common.Value.String, Status);
784 }
785 break;
786
787
788 default:
789
790 break;
791 }
792
793Cleanup:
794
795 /* Remove the Node pushed at the very beginning */
796
797 WalkState->Operands[0] = NULL;
798 WalkState->NumOperands = 0;
800}
void AcpiNsDetachObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:220
#define AML_PROCESSOR_OP
Definition: amlcode.h:183
#define AML_CLASS_METHOD_CALL
Definition: amlcode.h:409
#define AML_MUTEX_OP
Definition: amlcode.h:158
#define AML_EVENT_OP
Definition: amlcode.h:159
#define AML_POWER_RESOURCE_OP
Definition: amlcode.h:184
#define AML_NSOBJECT
Definition: amlcode.h:326
#define AML_CLASS_INTERNAL
Definition: amlcode.h:407
#define AML_ALIAS_OP
Definition: amlcode.h:53
ACPI_STATUS AcpiDsCreateField(ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
Definition: dsfield.c:534
ACPI_STATUS AcpiDsCreateBankField(ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
Definition: dsfield.c:748
ACPI_STATUS AcpiDsCreateIndexField(ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState)
Definition: dsfield.c:842
ACPI_STATUS AcpiExCreateAlias(ACPI_WALK_STATE *WalkState)
Definition: excreate.c:68
ACPI_STATUS AcpiExCreateMutex(ACPI_WALK_STATE *WalkState)
Definition: excreate.c:206
ACPI_STATUS AcpiExCreateEvent(ACPI_WALK_STATE *WalkState)
Definition: excreate.c:147
ACPI_STATUS AcpiExCreateProcessor(ACPI_WALK_STATE *WalkState)
Definition: excreate.c:381
ACPI_STATUS AcpiExCreatePowerResource(ACPI_WALK_STATE *WalkState)
Definition: excreate.c:433

Referenced by AcpiDsExecEndOp(), and AcpiDsInitCallbacks().

◆ 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}
#define ACPI_METHOD_NUM_LOCALS
Definition: acconfig.h:163
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

Referenced by AcpiDsTerminateControlMethod().

◆ AcpiDsMethodDataGetEntry()

ACPI_STATUS AcpiDsMethodDataGetEntry ( UINT16  Opcode,
UINT32  Index,
ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT ***  Node 
)

◆ 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_AML_INVALID_INDEX
Definition: acexcep.h:203
#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}
#define AE_AML_UNINITIALIZED_ARG
Definition: acexcep.h:185
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

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

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}
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().

◆ AcpiDsMethodError()

ACPI_STATUS AcpiDsMethodError ( ACPI_STATUS  Status,
ACPI_WALK_STATE WalkState 
)

Definition at line 223 of file dsmethod.c.

226{
227 UINT32 AmlOffset;
228 ACPI_NAME Name = 0;
229
230
232
233
234 /* Ignore AE_OK and control exception codes */
235
236 if (ACPI_SUCCESS (Status) ||
238 {
239 return (Status);
240 }
241
242 /* Invoke the global exception handler */
243
244 if (AcpiGbl_ExceptionHandler)
245 {
246 /* Exit the interpreter, allow handler to execute methods */
247
249
250 /*
251 * Handler can map the exception code to anything it wants, including
252 * AE_OK, in which case the executing method will not be aborted.
253 */
254 AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
255 WalkState->ParserState.AmlStart);
256
257 if (WalkState->MethodNode)
258 {
259 Name = WalkState->MethodNode->Name.Integer;
260 }
261 else if (WalkState->DeferredNode)
262 {
263 Name = WalkState->DeferredNode->Name.Integer;
264 }
265
266 Status = AcpiGbl_ExceptionHandler (Status, Name,
267 WalkState->Opcode, AmlOffset, NULL);
269 }
270
271 AcpiDsClearImplicitReturn (WalkState);
272
273 if (ACPI_FAILURE (Status))
274 {
275 AcpiDsDumpMethodStack (Status, WalkState, WalkState->Op);
276
277 /* Display method locals/args if debugger is present */
278
279#ifdef ACPI_DEBUGGER
280 AcpiDbDumpMethodInfo (Status, WalkState);
281#endif
282 }
283
284 return (Status);
285}
void AcpiDbDumpMethodInfo(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState)
#define AE_CODE_CONTROL
Definition: acexcep.h:57
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_PTR_DIFF(a, b)
Definition: actypes.h:548
UINT32 ACPI_NAME
Definition: actypes.h:461
void AcpiDsDumpMethodStack(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsdebug.c:249
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91

Referenced by AcpiDsExecBeginOp(), AcpiDsExecEndOp(), AcpiPsGetNextNamepath(), and AcpiPsParseAml().

◆ AcpiDsObjStackPop()

ACPI_STATUS AcpiDsObjStackPop ( UINT32  PopCount,
ACPI_WALK_STATE WalkState 
)

Definition at line 391 of file dswstate.c.

394{
395 UINT32 i;
396
397
398 ACPI_FUNCTION_NAME (DsObjStackPop);
399
400
401 for (i = 0; i < PopCount; i++)
402 {
403 /* Check for stack underflow */
404
405 if (WalkState->NumOperands == 0)
406 {
408 "Object stack underflow! Count=%X State=%p #Ops=%u",
409 PopCount, WalkState, WalkState->NumOperands));
410 return (AE_STACK_UNDERFLOW);
411 }
412
413 /* Just set the stack entry to null */
414
415 WalkState->NumOperands--;
416 WalkState->Operands [WalkState->NumOperands] = NULL;
417 }
418
419 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%u\n",
420 PopCount, WalkState, WalkState->NumOperands));
421
422 return (AE_OK);
423}
#define AE_STACK_UNDERFLOW
Definition: acexcep.h:121

Referenced by AcpiDsEvalDataObjectOperands(), and AcpiDsEvaluateNamePath().

◆ AcpiDsObjStackPopAndDelete()

void AcpiDsObjStackPopAndDelete ( UINT32  PopCount,
ACPI_WALK_STATE WalkState 
)

Definition at line 441 of file dswstate.c.

444{
445 INT32 i;
446 ACPI_OPERAND_OBJECT *ObjDesc;
447
448
449 ACPI_FUNCTION_NAME (DsObjStackPopAndDelete);
450
451
452 if (PopCount == 0)
453 {
454 return;
455 }
456
457 for (i = (INT32) PopCount - 1; i >= 0; i--)
458 {
459 if (WalkState->NumOperands == 0)
460 {
461 return;
462 }
463
464 /* Pop the stack and delete an object if present in this stack entry */
465
466 WalkState->NumOperands--;
467 ObjDesc = WalkState->Operands [i];
468 if (ObjDesc)
469 {
470 AcpiUtRemoveReference (WalkState->Operands [i]);
471 WalkState->Operands [i] = NULL;
472 }
473 }
474
475 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
476 PopCount, WalkState, WalkState->NumOperands));
477}
signed int INT32

Referenced by AcpiDsCreateOperands().

◆ AcpiDsObjStackPush()

ACPI_STATUS AcpiDsObjStackPush ( void Object,
ACPI_WALK_STATE WalkState 
)

Definition at line 342 of file dswstate.c.

345{
346 ACPI_FUNCTION_NAME (DsObjStackPush);
347
348
349 /* Check for stack overflow */
350
351 if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS)
352 {
354 "Object stack overflow! Obj=%p State=%p #Ops=%u",
355 Object, WalkState, WalkState->NumOperands));
356 return (AE_STACK_OVERFLOW);
357 }
358
359 /* Put the object onto the stack */
360
361 WalkState->Operands [WalkState->OperandIndex] = Object;
362 WalkState->NumOperands++;
363
364 /* For the usual order of filling the operand stack */
365
366 WalkState->OperandIndex++;
367
368 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
370 WalkState, WalkState->NumOperands));
371
372 return (AE_OK);
373}
#define AE_STACK_OVERFLOW
Definition: acexcep.h:120
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264

Referenced by AcpiDsCreateOperand().

◆ AcpiDsPopWalkState()

ACPI_WALK_STATE * AcpiDsPopWalkState ( ACPI_THREAD_STATE Thread)

Definition at line 555 of file dswstate.c.

557{
558 ACPI_WALK_STATE *WalkState;
559
560
561 ACPI_FUNCTION_TRACE (DsPopWalkState);
562
563
564 WalkState = Thread->WalkStateList;
565
566 if (WalkState)
567 {
568 /* Next walk state becomes the current walk state */
569
570 Thread->WalkStateList = WalkState->Next;
571
572 /*
573 * Don't clear the NEXT field, this serves as an indicator
574 * that there is a parent WALK STATE
575 * Do Not: WalkState->Next = NULL;
576 */
577 }
578
579 return_PTR (WalkState);
580}
struct acpi_walk_state * Next
Definition: acstruct.h:75

Referenced by AcpiPsParseAml().

◆ AcpiDsPushWalkState()

void AcpiDsPushWalkState ( ACPI_WALK_STATE WalkState,
ACPI_THREAD_STATE Thread 
)

Definition at line 526 of file dswstate.c.

529{
530 ACPI_FUNCTION_TRACE (DsPushWalkState);
531
532
533 WalkState->Next = Thread->WalkStateList;
534 Thread->WalkStateList = WalkState;
535
537}

Referenced by AcpiDsCreateWalkState(), and AcpiPsParseAml().

◆ AcpiDsResolveOperands()

ACPI_STATUS AcpiDsResolveOperands ( ACPI_WALK_STATE WalkState)

Definition at line 412 of file dsutils.c.

414{
415 UINT32 i;
417
418
419 ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState);
420
421
422 /*
423 * Attempt to resolve each of the valid operands
424 * Method arguments are passed by reference, not by value. This means
425 * that the actual objects are passed, not copies of the objects.
426 */
427 for (i = 0; i < WalkState->NumOperands; i++)
428 {
429 Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
430 if (ACPI_FAILURE (Status))
431 {
432 break;
433 }
434 }
435
437}

Referenced by AcpiDsExecEndOp().

◆ AcpiDsRestartControlMethod()

ACPI_STATUS AcpiDsRestartControlMethod ( ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT ReturnDesc 
)

Definition at line 685 of file dsmethod.c.

688{
690 int SameAsImplicitReturn;
691
692
693 ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState);
694
695
697 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
698 AcpiUtGetNodeName (WalkState->MethodNode),
699 WalkState->MethodCallOp, ReturnDesc));
700
702 " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
703 WalkState->ReturnUsed,
704 WalkState->Results, WalkState));
705
706 /* Did the called method return a value? */
707
708 if (ReturnDesc)
709 {
710 /* Is the implicit return object the same as the return desc? */
711
712 SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc);
713
714 /* Are we actually going to use the return value? */
715
716 if (WalkState->ReturnUsed)
717 {
718 /* Save the return value from the previous method */
719
720 Status = AcpiDsResultPush (ReturnDesc, WalkState);
721 if (ACPI_FAILURE (Status))
722 {
723 AcpiUtRemoveReference (ReturnDesc);
725 }
726
727 /*
728 * Save as THIS method's return value in case it is returned
729 * immediately to yet another method
730 */
731 WalkState->ReturnDesc = ReturnDesc;
732 }
733
734 /*
735 * The following code is the optional support for the so-called
736 * "implicit return". Some AML code assumes that the last value of the
737 * method is "implicitly" returned to the caller, in the absence of an
738 * explicit return value.
739 *
740 * Just save the last result of the method as the return value.
741 *
742 * NOTE: this is optional because the ASL language does not actually
743 * support this behavior.
744 */
745 else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) ||
746 SameAsImplicitReturn)
747 {
748 /*
749 * Delete the return value if it will not be used by the
750 * calling method or remove one reference if the explicit return
751 * is the same as the implicit return value.
752 */
753 AcpiUtRemoveReference (ReturnDesc);
754 }
755 }
756
758}
ACPI_PARSE_OBJECT * MethodCallOp
Definition: acstruct.h:114
UINT8 ReturnUsed
Definition: acstruct.h:85

Referenced by AcpiPsParseAml().

◆ AcpiDsResultPop()

ACPI_STATUS AcpiDsResultPop ( ACPI_OPERAND_OBJECT **  Object,
ACPI_WALK_STATE WalkState 
)

Definition at line 78 of file dswstate.c.

81{
85
86
87 ACPI_FUNCTION_NAME (DsResultPop);
88
89
90 State = WalkState->Results;
91
92 /* Incorrect state of result stack */
93
94 if (State && !WalkState->ResultCount)
95 {
96 ACPI_ERROR ((AE_INFO, "No results on result stack"));
97 return (AE_AML_INTERNAL);
98 }
99
100 if (!State && WalkState->ResultCount)
101 {
102 ACPI_ERROR ((AE_INFO, "No result state for result stack"));
103 return (AE_AML_INTERNAL);
104 }
105
106 /* Empty result stack */
107
108 if (!State)
109 {
110 ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState));
111 return (AE_AML_NO_RETURN_VALUE);
112 }
113
114 /* Return object of the top element and clean that top element result stack */
115
116 WalkState->ResultCount--;
118
119 *Object = State->Results.ObjDesc [Index];
120 if (!*Object)
121 {
122 ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p",
123 WalkState));
124 return (AE_AML_NO_RETURN_VALUE);
125 }
126
127 State->Results.ObjDesc [Index] = NULL;
128 if (Index == 0)
129 {
130 Status = AcpiDsResultStackPop (WalkState);
131 if (ACPI_FAILURE (Status))
132 {
133 return (Status);
134 }
135 }
136
138 "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object,
140 Index, WalkState, WalkState->ResultCount));
141
142 return (AE_OK);
143}
#define AE_AML_NO_RETURN_VALUE
Definition: acexcep.h:197
#define ACPI_RESULTS_FRAME_OBJ_NUM
Definition: acconfig.h:177
static ACPI_STATUS AcpiDsResultStackPop(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:289
if(dx< 0)
Definition: linetemp.h:194

Referenced by AcpiDsCreateOperand(), AcpiDsDeleteResultIfNotUsed(), and AcpiDsGetPredicateValue().

◆ AcpiDsResultPush()

ACPI_STATUS AcpiDsResultPush ( ACPI_OPERAND_OBJECT Object,
ACPI_WALK_STATE WalkState 
)

Definition at line 160 of file dswstate.c.

163{
167
168
169 ACPI_FUNCTION_NAME (DsResultPush);
170
171
172 if (WalkState->ResultCount > WalkState->ResultSize)
173 {
174 ACPI_ERROR ((AE_INFO, "Result stack is full"));
175 return (AE_AML_INTERNAL);
176 }
177 else if (WalkState->ResultCount == WalkState->ResultSize)
178 {
179 /* Extend the result stack */
180
181 Status = AcpiDsResultStackPush (WalkState);
182 if (ACPI_FAILURE (Status))
183 {
184 ACPI_ERROR ((AE_INFO, "Failed to extend the result stack"));
185 return (Status);
186 }
187 }
188
189 if (!(WalkState->ResultCount < WalkState->ResultSize))
190 {
191 ACPI_ERROR ((AE_INFO, "No free elements in result stack"));
192 return (AE_AML_INTERNAL);
193 }
194
195 State = WalkState->Results;
196 if (!State)
197 {
198 ACPI_ERROR ((AE_INFO, "No result stack frame during push"));
199 return (AE_AML_INTERNAL);
200 }
201
202 if (!Object)
203 {
205 "Null Object! Obj=%p State=%p Num=%u",
206 Object, WalkState, WalkState->ResultCount));
207 return (AE_BAD_PARAMETER);
208 }
209
210 /* Assign the address of object to the top free element of result stack */
211
213 State->Results.ObjDesc [Index] = Object;
214 WalkState->ResultCount++;
215
216 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
218 WalkState, WalkState->ResultCount, WalkState->CurrentResult));
219
220 return (AE_OK);
221}
static ACPI_STATUS AcpiDsResultStackPush(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:237
UINT8 CurrentResult
Definition: acstruct.h:84
UINT8 ResultSize
Definition: acstruct.h:89

Referenced by AcpiDsEvaluateNamePath(), AcpiDsExecEndOp(), and AcpiDsRestartControlMethod().

◆ AcpiDsResultStackClear()

ACPI_STATUS AcpiDsResultStackClear ( ACPI_WALK_STATE WalkState)

◆ AcpiDsScopeStackClear()

void AcpiDsScopeStackClear ( ACPI_WALK_STATE WalkState)

Definition at line 67 of file dswscope.c.

69{
70 ACPI_GENERIC_STATE *ScopeInfo;
71
72 ACPI_FUNCTION_NAME (DsScopeStackClear);
73
74
75 while (WalkState->ScopeInfo)
76 {
77 /* Pop a scope off the stack */
78
79 ScopeInfo = WalkState->ScopeInfo;
80 WalkState->ScopeInfo = ScopeInfo->Scope.Next;
81
83 "Popped object type (%s)\n",
84 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
85
86 AcpiUtDeleteGenericState (ScopeInfo);
87 }
88}

Referenced by AcpiPsExecuteMethod(), and AcpiPsParseAml().

◆ AcpiDsScopeStackPop()

ACPI_STATUS AcpiDsScopeStackPop ( ACPI_WALK_STATE WalkState)

Definition at line 192 of file dswscope.c.

194{
195 ACPI_GENERIC_STATE *ScopeInfo;
196 ACPI_GENERIC_STATE *NewScopeInfo;
197
198
199 ACPI_FUNCTION_TRACE (DsScopeStackPop);
200
201
202 /*
203 * Pop scope info object off the stack.
204 */
205 ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo);
206 if (!ScopeInfo)
207 {
209 }
210
211 WalkState->ScopeDepth--;
212
214 "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
215 (UINT32) WalkState->ScopeDepth,
216 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
217 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
218
219 NewScopeInfo = WalkState->ScopeInfo;
220 if (NewScopeInfo)
221 {
222 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "[%4.4s] (%s)\n",
223 AcpiUtGetNodeName (NewScopeInfo->Scope.Node),
224 AcpiUtGetTypeName (NewScopeInfo->Common.Value)));
225 }
226 else
227 {
229 }
230
231 AcpiUtDeleteGenericState (ScopeInfo);
233}
#define ACPI_NAMESPACE_ROOT
Definition: acnames.h:94
UINT8 ScopeDepth
Definition: acstruct.h:86

Referenced by AcpiDsExecBeginOp(), AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsScopeStackPush()

ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE Node,
ACPI_OBJECT_TYPE  Type,
ACPI_WALK_STATE WalkState 
)

Definition at line 107 of file dswscope.c.

111{
112 ACPI_GENERIC_STATE *ScopeInfo;
113 ACPI_GENERIC_STATE *OldScopeInfo;
114
115
116 ACPI_FUNCTION_TRACE (DsScopeStackPush);
117
118
119 if (!Node)
120 {
121 /* Invalid scope */
122
123 ACPI_ERROR ((AE_INFO, "Null scope parameter"));
125 }
126
127 /* Make sure object type is valid */
128
130 {
132 "Invalid object type: 0x%X", Type));
133 }
134
135 /* Allocate a new scope object */
136
137 ScopeInfo = AcpiUtCreateGenericState ();
138 if (!ScopeInfo)
139 {
141 }
142
143 /* Init new scope object */
144
145 ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE;
146 ScopeInfo->Scope.Node = Node;
147 ScopeInfo->Common.Value = (UINT16) Type;
148
149 WalkState->ScopeDepth++;
150
152 "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth));
153
154 OldScopeInfo = WalkState->ScopeInfo;
155 if (OldScopeInfo)
156 {
158 "[%4.4s] (%s)",
159 AcpiUtGetNodeName (OldScopeInfo->Scope.Node),
160 AcpiUtGetTypeName (OldScopeInfo->Common.Value)));
161 }
162 else
163 {
165 }
166
168 ", New scope -> [%4.4s] (%s)\n",
169 AcpiUtGetNodeName (ScopeInfo->Scope.Node),
170 AcpiUtGetTypeName (ScopeInfo->Common.Value)));
171
172 /* Push new scope object onto stack */
173
174 AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo);
176}
#define ACPI_DESC_TYPE_STATE_WSCOPE
Definition: acobject.h:570
ACPI_GENERIC_STATE * AcpiUtCreateGenericState(void)
Definition: utstate.c:130
BOOLEAN AcpiUtValidObjectType(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:681

Referenced by AcpiDsExecBeginOp(), AcpiDsInitAmlWalk(), AcpiDsLoad1BeginOp(), AcpiDsLoad2BeginOp(), AcpiNsLookup(), AcpiNsOneCompleteParse(), and AcpiPsExecuteTable().

◆ AcpiDsStoreObjectToLocal()

ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT8  Type,
UINT32  Index,
ACPI_OPERAND_OBJECT SrcDesc,
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_NO_IMPLICIT_CONVERSION
Definition: acutils.h:146
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

Referenced by AcpiExStore().

◆ AcpiDsTerminateControlMethod()

void AcpiDsTerminateControlMethod ( ACPI_OPERAND_OBJECT MethodDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 779 of file dsmethod.c.

782{
783
784 ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);
785
786
787 /* MethodDesc is required, WalkState is optional */
788
789 if (!MethodDesc)
790 {
792 }
793
794 if (WalkState)
795 {
796 /* Delete all arguments and locals */
797
798 AcpiDsMethodDataDeleteAll (WalkState);
799
800 /*
801 * Delete any namespace objects created anywhere within the
802 * namespace by the execution of this method. Unless:
803 * 1) This method is a module-level executable code method, in which
804 * case we want make the objects permanent.
805 * 2) There are other threads executing the method, in which case we
806 * will wait until the last thread has completed.
807 */
808 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) &&
809 (MethodDesc->Method.ThreadCount == 1))
810 {
811 /* Delete any direct children of (created by) this method */
812
816
817 /*
818 * Delete any objects that were created by this method
819 * elsewhere in the namespace (if any were created).
820 * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
821 * deletion such that we don't have to perform an entire
822 * namespace walk for every control method execution.
823 */
825 {
829 MethodDesc->Method.InfoFlags &=
830 ~ACPI_METHOD_MODIFIED_NAMESPACE;
831 }
832 }
833
834 /*
835 * If method is serialized, release the mutex and restore the
836 * current sync level for this thread
837 */
838 if (MethodDesc->Method.Mutex)
839 {
840 /* Acquisition Depth handles recursive calls */
841
842 MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--;
843 if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth)
844 {
845 WalkState->Thread->CurrentSyncLevel =
846 MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel;
847
849 MethodDesc->Method.Mutex->Mutex.OsMutex);
850 MethodDesc->Method.Mutex->Mutex.ThreadId = 0;
851 }
852 }
853 }
854
855 /* Decrement the thread count on the method */
856
857 if (MethodDesc->Method.ThreadCount)
858 {
859 MethodDesc->Method.ThreadCount--;
860 }
861 else
862 {
864 "Invalid zero thread count in method"));
865 }
866
867 /* Are there any other threads currently executing this method? */
868
869 if (MethodDesc->Method.ThreadCount)
870 {
871 /*
872 * Additional threads. Do not release the OwnerId in this case,
873 * we immediately reuse it for the next thread executing this method
874 */
876 "*** Completed execution of one thread, %u threads remaining\n",
877 MethodDesc->Method.ThreadCount));
878 }
879 else
880 {
881 /* This is the only executing thread for this method */
882
883 /*
884 * Support to dynamically change a method from NotSerialized to
885 * Serialized if it appears that the method is incorrectly written and
886 * does not support multiple thread execution. The best example of this
887 * is if such a method creates namespace objects and blocks. A second
888 * thread will fail with an AE_ALREADY_EXISTS exception.
889 *
890 * This code is here because we must wait until the last thread exits
891 * before marking the method as serialized.
892 */
894 {
895 if (WalkState)
896 {
897 ACPI_INFO ((
898 "Marking method %4.4s as Serialized "
899 "because of AE_ALREADY_EXISTS error",
900 WalkState->MethodNode->Name.Ascii));
901 }
902
903 /*
904 * Method tried to create an object twice and was marked as
905 * "pending serialized". The probable cause is that the method
906 * cannot handle reentrancy.
907 *
908 * The method was created as NotSerialized, but it tried to create
909 * a named object and then blocked, causing the second thread
910 * entrance to begin and then fail. Workaround this problem by
911 * marking the method permanently as Serialized when the last
912 * thread exits here.
913 */
914 MethodDesc->Method.InfoFlags &=
915 ~ACPI_METHOD_SERIALIZED_PENDING;
916
917 MethodDesc->Method.InfoFlags |=
919 MethodDesc->Method.SyncLevel = 0;
920 }
921
922 /* No more threads, we can free the OwnerId */
923
924 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL))
925 {
926 AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId);
927 }
928 }
929
931 MethodDesc, WalkState);
932
934}
void AcpiNsDeleteNamespaceSubtree(ACPI_NAMESPACE_NODE *ParentHandle)
Definition: nsalloc.c:399
void AcpiNsDeleteNamespaceByOwner(ACPI_OWNER_ID OwnerId)
Definition: nsalloc.c:497
#define ACPI_METHOD_MODIFIED_NAMESPACE
Definition: acobject.h:241
#define ACPI_METHOD_MODULE_LEVEL
Definition: acobject.h:236
#define ACPI_METHOD_SERIALIZED_PENDING
Definition: acobject.h:239
void AcpiUtReleaseOwnerId(ACPI_OWNER_ID *OwnerId)
Definition: utownerid.c:190
void AcpiDsMethodDataDeleteAll(ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:153
void AcpiExStopTraceMethod(ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: extrace.c:290
union acpi_operand_object * Node
Definition: acobject.h:220

Referenced by AcpiDsCallControlMethod(), AcpiPsExecuteMethod(), and AcpiPsParseAml().