ReactOS 0.4.15-dev-7953-g1f49173
exoparg2.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "acinterp.h"
#include "acevents.h"
#include "amlcode.h"
Include dependency graph for exoparg2.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

ACPI_STATUS AcpiExOpcode_2A_0T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_2T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_1T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_0T_1R (ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 52 of file exoparg2.c.

Function Documentation

◆ AcpiExOpcode_2A_0T_0R()

ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE WalkState)

Naming convention for AML interpreter execution routines.

The routines that begin execution of AML opcodes are named with a common convention based upon the number of arguments, the number of target operands, and whether or not a value is returned:

 AcpiExOpcode_xA_yT_zR

Where:

xA - ARGUMENTS: The number of arguments (input operands) that are required for this opcode type (1 through 6 args). yT - TARGETS: The number of targets (output operands) that are required for this opcode type (0, 1, or 2 targets). zR - RETURN VALUE: Indicates whether this opcode type returns a value as the function return (0 or 1).

The AcpiExOpcode* functions are called via the Dispatcher component with fully resolved operands. !

Definition at line 95 of file exoparg2.c.

97{
98 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
102
103
104 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
105 AcpiPsGetOpcodeName (WalkState->Opcode));
106
107
108 /* Examine the opcode */
109
110 switch (WalkState->Opcode)
111 {
112 case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
113
114 /* The first operand is a namespace node */
115
116 Node = (ACPI_NAMESPACE_NODE *) Operand[0];
117
118 /* Second value is the notify value */
119
120 Value = (UINT32) Operand[1]->Integer.Value;
121
122 /* Are notifies allowed on this object? */
123
125 {
127 "Unexpected notify object type [%s]",
128 AcpiUtGetTypeName (Node->Type)));
129
131 break;
132 }
133
134 /*
135 * Dispatch the notify to the appropriate handler
136 * NOTE: the request is queued for execution after this method
137 * completes. The notify handlers are NOT invoked synchronously
138 * from this thread -- because handlers may in turn run other
139 * control methods.
140 */
142 break;
143
144 default:
145
146 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
147 WalkState->Opcode));
149 }
150
152}
unsigned int UINT32
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define AE_OK
Definition: acexcep.h:97
#define ACPI_FUNCTION_TRACE_STR(a, b)
Definition: acoutput.h:483
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
UINT32 ACPI_STATUS
Definition: actypes.h:460
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
#define AML_NOTIFY_OP
Definition: amlcode.h:110
union node Node
Definition: types.h:1255
ACPI_STATUS AcpiEvQueueNotifyRequest(ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue)
Definition: evmisc.c:111
BOOLEAN AcpiEvIsNotifyObject(ACPI_NAMESPACE_NODE *Node)
Definition: evmisc.c:75
Status
Definition: gdiplustypes.h:25
if(dx< 0)
Definition: linetemp.h:194
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105
UINT16 Opcode
Definition: acstruct.h:78
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ AcpiExOpcode_2A_0T_1R()

ACPI_STATUS AcpiExOpcode_2A_0T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 540 of file exoparg2.c.

542{
543 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
544 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
546 BOOLEAN LogicalResult = FALSE;
547
548
549 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
550 AcpiPsGetOpcodeName (WalkState->Opcode));
551
552
553 /* Create the internal return object */
554
556 if (!ReturnDesc)
557 {
559 goto Cleanup;
560 }
561
562 /* Execute the Opcode */
563
564 if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
565 {
566 /* LogicalOp (Operand0, Operand1) */
567
569 Operand[0]->Integer.Value, Operand[1]->Integer.Value,
570 &LogicalResult);
571 goto StoreLogicalResult;
572 }
573 else if (WalkState->OpInfo->Flags & AML_LOGICAL)
574 {
575 /* LogicalOp (Operand0, Operand1) */
576
577 Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
578 Operand[1], &LogicalResult);
579 goto StoreLogicalResult;
580 }
581
582 switch (WalkState->Opcode)
583 {
584 case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
585
586 Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
587 if (Status == AE_TIME)
588 {
589 LogicalResult = TRUE; /* TRUE = Acquire timed out */
590 Status = AE_OK;
591 }
592 break;
593
594
595 case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
596
597 Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
598 if (Status == AE_TIME)
599 {
600 LogicalResult = TRUE; /* TRUE, Wait timed out */
601 Status = AE_OK;
602 }
603 break;
604
605 default:
606
607 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
608 WalkState->Opcode));
609
611 goto Cleanup;
612 }
613
614
615StoreLogicalResult:
616 /*
617 * Set return value to according to LogicalResult. logical TRUE (all ones)
618 * Default is FALSE (zero)
619 */
620 if (LogicalResult)
621 {
622 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
623 }
624
625Cleanup:
626
627 /* Delete return object on error */
628
629 if (ACPI_FAILURE (Status))
630 {
631 AcpiUtRemoveReference (ReturnDesc);
632 }
633
634 /* Save return object on success */
635
636 else
637 {
638 WalkState->ResultObj = ReturnDesc;
639 }
640
642}
unsigned char BOOLEAN
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_TIME
Definition: acexcep.h:125
#define ACPI_UINT64_MAX
Definition: actypes.h:67
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
#define AML_WAIT_OP
Definition: amlcode.h:170
#define AML_ACQUIRE_OP
Definition: amlcode.h:168
#define AML_LOGICAL
Definition: amlcode.h:317
#define AML_LOGICAL_NUMERIC
Definition: amlcode.h:318
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR Cleanup[]
Definition: register.c:80
ACPI_STATUS AcpiExDoLogicalOp(UINT16 Opcode, ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, BOOLEAN *LogicalResult)
Definition: exmisc.c:335
ACPI_STATUS AcpiExDoLogicalNumericOp(UINT16 Opcode, UINT64 Integer0, UINT64 Integer1, BOOLEAN *LogicalResult)
Definition: exmisc.c:262
ACPI_STATUS AcpiExAcquireMutex(ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: exmutex.c:248
ACPI_STATUS AcpiExSystemWaitEvent(ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exsystem.c:299
UINT16 Flags
Definition: aclocal.h:873
union acpi_operand_object * ResultObj
Definition: acstruct.h:121
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520

◆ AcpiExOpcode_2A_1T_1R()

ACPI_STATUS AcpiExOpcode_2A_1T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 279 of file exoparg2.c.

281{
282 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
283 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
286 ACPI_SIZE Length = 0;
287
288
289 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
290 AcpiPsGetOpcodeName (WalkState->Opcode));
291
292
293 /* Execute the opcode */
294
295 if (WalkState->OpInfo->Flags & AML_MATH)
296 {
297 /* All simple math opcodes (add, etc.) */
298
300 if (!ReturnDesc)
301 {
303 goto Cleanup;
304 }
305
306 ReturnDesc->Integer.Value = AcpiExDoMathOp (
307 WalkState->Opcode,
308 Operand[0]->Integer.Value,
309 Operand[1]->Integer.Value);
310 goto StoreResultToTarget;
311 }
312
313 switch (WalkState->Opcode)
314 {
315 case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
316
318 if (!ReturnDesc)
319 {
321 goto Cleanup;
322 }
323
324 /* ReturnDesc will contain the remainder */
325
327 Operand[0]->Integer.Value,
328 Operand[1]->Integer.Value,
329 NULL,
330 &ReturnDesc->Integer.Value);
331 break;
332
333 case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
334
336 Operand[0], Operand[1], &ReturnDesc, WalkState);
337 break;
338
339 case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
340 /*
341 * Input object is guaranteed to be a buffer at this point (it may have
342 * been converted.) Copy the raw buffer data to a new object of
343 * type String.
344 */
345
346 /*
347 * Get the length of the new string. It is the smallest of:
348 * 1) Length of the input buffer
349 * 2) Max length as specified in the ToString operator
350 * 3) Length of input buffer up to a zero byte (null terminator)
351 *
352 * NOTE: A length of zero is ok, and will create a zero-length, null
353 * terminated string.
354 */
355 while ((Length < Operand[0]->Buffer.Length) && /* Length of input buffer */
356 (Length < Operand[1]->Integer.Value) && /* Length operand */
357 (Operand[0]->Buffer.Pointer[Length])) /* Null terminator */
358 {
359 Length++;
360 }
361
362 /* Allocate a new string object */
363
364 ReturnDesc = AcpiUtCreateStringObject (Length);
365 if (!ReturnDesc)
366 {
368 goto Cleanup;
369 }
370
371 /*
372 * Copy the raw buffer data with no transform.
373 * (NULL terminated already)
374 */
375 memcpy (ReturnDesc->String.Pointer,
376 Operand[0]->Buffer.Pointer, Length);
377 break;
378
380
381 /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
382
384 Operand[0], Operand[1], &ReturnDesc, WalkState);
385 break;
386
387 case AML_INDEX_OP: /* Index (Source Index Result) */
388
389 /* Create the internal return object */
390
392 if (!ReturnDesc)
393 {
395 goto Cleanup;
396 }
397
398 /* Initialize the Index reference object */
399
400 Index = Operand[1]->Integer.Value;
401 ReturnDesc->Reference.Value = (UINT32) Index;
402 ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
403
404 /*
405 * At this point, the Source operand is a String, Buffer, or Package.
406 * Verify that the index is within range.
407 */
408 switch ((Operand[0])->Common.Type)
409 {
410 case ACPI_TYPE_STRING:
411
412 if (Index >= Operand[0]->String.Length)
413 {
414 Length = Operand[0]->String.Length;
416 }
417
419 ReturnDesc->Reference.IndexPointer =
420 &(Operand[0]->Buffer.Pointer [Index]);
421 break;
422
423 case ACPI_TYPE_BUFFER:
424
425 if (Index >= Operand[0]->Buffer.Length)
426 {
427 Length = Operand[0]->Buffer.Length;
429 }
430
432 ReturnDesc->Reference.IndexPointer =
433 &(Operand[0]->Buffer.Pointer [Index]);
434 break;
435
437
438 if (Index >= Operand[0]->Package.Count)
439 {
440 Length = Operand[0]->Package.Count;
442 }
443
445 ReturnDesc->Reference.Where =
446 &Operand[0]->Package.Elements [Index];
447 break;
448
449 default:
450
452 "Invalid object type: %X", (Operand[0])->Common.Type));
454 goto Cleanup;
455 }
456
457 /* Failure means that the Index was beyond the end of the object */
458
459 if (ACPI_FAILURE (Status))
460 {
462 "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
464 goto Cleanup;
465 }
466
467 /*
468 * Save the target object and add a reference to it for the life
469 * of the index
470 */
471 ReturnDesc->Reference.Object = Operand[0];
472 AcpiUtAddReference (Operand[0]);
473
474 /* Store the reference to the Target */
475
476 Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
477
478 /* Return the reference */
479
480 WalkState->ResultObj = ReturnDesc;
481 goto Cleanup;
482
483 default:
484
485 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
486 WalkState->Opcode));
488 break;
489 }
490
491
492StoreResultToTarget:
493
494 if (ACPI_SUCCESS (Status))
495 {
496 /*
497 * Store the result of the operation (which is now in ReturnDesc) into
498 * the Target descriptor.
499 */
500 Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
501 if (ACPI_FAILURE (Status))
502 {
503 goto Cleanup;
504 }
505
506 if (!WalkState->ResultObj)
507 {
508 WalkState->ResultObj = ReturnDesc;
509 }
510 }
511
512
513Cleanup:
514
515 /* Delete return object on error */
516
517 if (ACPI_FAILURE (Status))
518 {
519 AcpiUtRemoveReference (ReturnDesc);
520 WalkState->ResultObj = NULL;
521 }
522
524}
unsigned long long UINT64
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
#define AE_AML_BUFFER_LIMIT
Definition: acexcep.h:189
#define AE_AML_STRING_LIMIT
Definition: acexcep.h:196
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
@ ACPI_REFCLASS_INDEX
Definition: acobject.h:462
#define ACPI_BIOS_EXCEPTION(plist)
Definition: acoutput.h:242
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:701
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
ACPI_OPERAND_OBJECT * AcpiUtCreateStringObject(ACPI_SIZE StringSize)
Definition: utobject.c:320
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752
ACPI_STATUS AcpiUtDivide(UINT64 InDividend, UINT64 InDivisor, UINT64 *OutQuotient, UINT64 *OutRemainder)
Definition: utmath.c:402
#define AML_MOD_OP
Definition: amlcode.h:109
#define AML_CONCATENATE_TEMPLATE_OP
Definition: amlcode.h:108
#define AML_MATH
Definition: amlcode.h:319
#define AML_CONCATENATE_OP
Definition: amlcode.h:91
#define AML_INDEX_OP
Definition: amlcode.h:112
#define AML_TO_STRING_OP
Definition: amlcode.h:130
Definition: bufpool.h:45
ACPI_STATUS AcpiExConcatTemplate(ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
Definition: exconcat.c:388
ACPI_STATUS AcpiExDoConcatenate(ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
Definition: exconcat.c:85
UINT64 AcpiExDoMathOp(UINT16 Opcode, UINT64 Integer0, UINT64 Integer1)
Definition: exmisc.c:167
ACPI_STATUS AcpiExStore(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState)
Definition: exstore.c:91
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
union acpi_operand_object ** Elements
Definition: acobject.h:161
union acpi_operand_object ** Where
Definition: acobject.h:448
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
ACPI_OBJECT_STRING String
Definition: acobject.h:521
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

◆ AcpiExOpcode_2A_2T_1R()

ACPI_STATUS AcpiExOpcode_2A_2T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 169 of file exoparg2.c.

171{
172 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
173 ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL;
174 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
176
177
178 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
179 AcpiPsGetOpcodeName (WalkState->Opcode));
180
181
182 /* Execute the opcode */
183
184 switch (WalkState->Opcode)
185 {
186 case AML_DIVIDE_OP:
187
188 /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
189
191 if (!ReturnDesc1)
192 {
194 goto Cleanup;
195 }
196
198 if (!ReturnDesc2)
199 {
201 goto Cleanup;
202 }
203
204 /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
205
207 Operand[0]->Integer.Value,
208 Operand[1]->Integer.Value,
209 &ReturnDesc1->Integer.Value,
210 &ReturnDesc2->Integer.Value);
211 if (ACPI_FAILURE (Status))
212 {
213 goto Cleanup;
214 }
215 break;
216
217 default:
218
219 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
220 WalkState->Opcode));
221
223 goto Cleanup;
224 }
225
226 /* Store the results to the target reference operands */
227
228 Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
229 if (ACPI_FAILURE (Status))
230 {
231 goto Cleanup;
232 }
233
234 Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
235 if (ACPI_FAILURE (Status))
236 {
237 goto Cleanup;
238 }
239
240Cleanup:
241 /*
242 * Since the remainder is not returned indirectly, remove a reference to
243 * it. Only the quotient is returned indirectly.
244 */
245 AcpiUtRemoveReference (ReturnDesc2);
246
247 if (ACPI_FAILURE (Status))
248 {
249 /* Delete the return object */
250
251 AcpiUtRemoveReference (ReturnDesc1);
252 }
253
254 /* Save return object (the remainder) on success */
255
256 else
257 {
258 WalkState->ResultObj = ReturnDesc1;
259 }
260
262}
#define AML_DIVIDE_OP
Definition: amlcode.h:96