Deleted Added
full compact
1/******************************************************************************
2 *
3 * Module Name: dswexec - Dispatcher method execution callbacks;
4 * dispatch to interpreter.
5 * $Revision: 1.120 $
5 * $Revision: 1.134 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 97 unchanged lines hidden (view full) ---

119
120#include <contrib/dev/acpica/acpi.h>
121#include <contrib/dev/acpica/acparser.h>
122#include <contrib/dev/acpica/amlcode.h>
123#include <contrib/dev/acpica/acdispat.h>
124#include <contrib/dev/acpica/acinterp.h>
125#include <contrib/dev/acpica/acnamesp.h>
126#include <contrib/dev/acpica/acdebug.h>
127#include <contrib/dev/acpica/acdisasm.h>
127
128
129#define _COMPONENT ACPI_DISPATCHER
130 ACPI_MODULE_NAME ("dswexec")
131
132/*
133 * Dispatch table for opcode classes
134 */
136static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = {
137 AcpiExOpcode_0A_0T_1R,
138 AcpiExOpcode_1A_0T_0R,
139 AcpiExOpcode_1A_0T_1R,
140 AcpiExOpcode_1A_1T_0R,
141 AcpiExOpcode_1A_1T_1R,
142 AcpiExOpcode_2A_0T_0R,
143 AcpiExOpcode_2A_0T_1R,
144 AcpiExOpcode_2A_1T_1R,
145 AcpiExOpcode_2A_2T_1R,
146 AcpiExOpcode_3A_0T_0R,
147 AcpiExOpcode_3A_1T_1R,
148 AcpiExOpcode_6A_0T_1R};
135static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] =
136{
137 AcpiExOpcode_0A_0T_1R,
138 AcpiExOpcode_1A_0T_0R,
139 AcpiExOpcode_1A_0T_1R,
140 AcpiExOpcode_1A_1T_0R,
141 AcpiExOpcode_1A_1T_1R,
142 AcpiExOpcode_2A_0T_0R,
143 AcpiExOpcode_2A_0T_1R,
144 AcpiExOpcode_2A_1T_1R,
145 AcpiExOpcode_2A_2T_1R,
146 AcpiExOpcode_3A_0T_0R,
147 AcpiExOpcode_3A_1T_1R,
148 AcpiExOpcode_6A_0T_1R
149};
150
151
152/*****************************************************************************
153 *
154 * FUNCTION: AcpiDsGetPredicateValue
155 *
156 * PARAMETERS: WalkState - Current state of the parse tree walk
157 * ResultObj - if non-zero, pop result from result stack

--- 9 unchanged lines hidden (view full) ---

167 ACPI_WALK_STATE *WalkState,
168 ACPI_OPERAND_OBJECT *ResultObj)
169{
170 ACPI_STATUS Status = AE_OK;
171 ACPI_OPERAND_OBJECT *ObjDesc;
172 ACPI_OPERAND_OBJECT *LocalObjDesc = NULL;
173
174
174 ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState);
175 ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState);
176
177
178 WalkState->ControlState->Common.State = 0;
179
180 if (ResultObj)
181 {
182 Status = AcpiDsResultPop (&ObjDesc, WalkState);
183 if (ACPI_FAILURE (Status))
184 {
184 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
185 "Could not get result from predicate evaluation, %s\n",
186 AcpiFormatException (Status)));
185 ACPI_EXCEPTION ((AE_INFO, Status,
186 "Could not get result from predicate evaluation"));
187
188 return_ACPI_STATUS (Status);
189 }
190 }
191 else
192 {
193 Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
194 if (ACPI_FAILURE (Status))

--- 7 unchanged lines hidden (view full) ---

202 return_ACPI_STATUS (Status);
203 }
204
205 ObjDesc = WalkState->Operands [0];
206 }
207
208 if (!ObjDesc)
209 {
210 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
211 "No predicate ObjDesc=%p State=%p\n",
210 ACPI_ERROR ((AE_INFO,
211 "No predicate ObjDesc=%p State=%p",
212 ObjDesc, WalkState));
213
214 return_ACPI_STATUS (AE_AML_NO_OPERAND);
215 }
216
217 /*
218 * Result of predicate evaluation must be an Integer
219 * object. Implicitly convert the argument if necessary.
220 */
221 Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16);
222 if (ACPI_FAILURE (Status))
223 {
224 goto Cleanup;
225 }
226
227 if (ACPI_GET_OBJECT_TYPE (LocalObjDesc) != ACPI_TYPE_INTEGER)
228 {
229 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
230 "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X\n",
229 ACPI_ERROR ((AE_INFO,
230 "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X",
231 ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc)));
232
233 Status = AE_AML_OPERAND_TYPE;
234 goto Cleanup;
235 }
236
237 /* Truncate the predicate to 32-bits if necessary */
238

--- 62 unchanged lines hidden (view full) ---

301 ACPI_WALK_STATE *WalkState,
302 ACPI_PARSE_OBJECT **OutOp)
303{
304 ACPI_PARSE_OBJECT *Op;
305 ACPI_STATUS Status = AE_OK;
306 UINT32 OpcodeClass;
307
308
309 ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState);
309 ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState);
310
311
312 Op = WalkState->Op;
313 if (!Op)
314 {
315 Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
316 if (ACPI_FAILURE (Status))
317 {
318 return_ACPI_STATUS (Status);
318 goto ErrorExit;
319 }
320
321 Op = *OutOp;
322 WalkState->Op = Op;
323 WalkState->Opcode = Op->Common.AmlOpcode;
324 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
325
326 if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
327 {
328 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
329 "(%s) Popping scope for Op %p\n",
330 AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
331
332 Status = AcpiDsScopeStackPop (WalkState);
333 if (ACPI_FAILURE (Status))
334 {
335 return_ACPI_STATUS (Status);
335 goto ErrorExit;
336 }
337 }
338 }
339
340 if (Op == WalkState->Origin)
341 {
342 if (OutOp)
343 {

--- 34 unchanged lines hidden (view full) ---

378
379 /*
380 * Handle the opcode based upon the opcode type
381 */
382 switch (OpcodeClass)
383 {
384 case AML_CLASS_CONTROL:
385
386 Status = AcpiDsResultStackPush (WalkState);
387 if (ACPI_FAILURE (Status))
388 {
389 return_ACPI_STATUS (Status);
390 }
391
386 Status = AcpiDsExecBeginControlOp (WalkState, Op);
387 break;
388
389
390 case AML_CLASS_NAMED_OBJECT:
391
398 if (WalkState->WalkType == ACPI_WALK_METHOD)
392 if (WalkState->WalkType & ACPI_WALK_METHOD)
393 {
394 /*
395 * Found a named object declaration during method execution;
396 * we must enter this object into the namespace. The created
397 * object is temporary and will be deleted upon completion of
398 * the execution of this method.
399 */
400 Status = AcpiDsLoad2BeginOp (WalkState, NULL);
401 }
402
409 if (Op->Common.AmlOpcode == AML_REGION_OP)
410 {
411 Status = AcpiDsResultStackPush (WalkState);
412 }
403 break;
404
405
406 case AML_CLASS_EXECUTE:
407 case AML_CLASS_CREATE:
408
419 /*
420 * Most operators with arguments.
421 * Start a new result/operand state
422 */
423 Status = AcpiDsResultStackPush (WalkState);
409 break;
410
411
412 default:
413 break;
414 }
415
416 /* Nothing to do here during method execution */
417
418 return_ACPI_STATUS (Status);
419
420
421ErrorExit:
422 Status = AcpiDsMethodError (Status, WalkState);
423 return_ACPI_STATUS (Status);
424}
425
426
427/*****************************************************************************
428 *
429 * FUNCTION: AcpiDsExecEndOp
430 *
431 * PARAMETERS: WalkState - Current state of the parse tree walk

--- 13 unchanged lines hidden (view full) ---

445 ACPI_PARSE_OBJECT *Op;
446 ACPI_STATUS Status = AE_OK;
447 UINT32 OpType;
448 UINT32 OpClass;
449 ACPI_PARSE_OBJECT *NextOp;
450 ACPI_PARSE_OBJECT *FirstArg;
451
452
463 ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState);
453 ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState);
454
455
456 Op = WalkState->Op;
457 OpType = WalkState->OpInfo->Type;
458 OpClass = WalkState->OpInfo->Class;
459
460 if (OpClass == AML_CLASS_UNKNOWN)
461 {
472 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode));
462 ACPI_ERROR ((AE_INFO, "Unknown opcode %X", Op->Common.AmlOpcode));
463 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
464 }
465
466 FirstArg = Op->Common.Value.Arg;
467
468 /* Init the walk state */
469
470 WalkState->NumOperands = 0;
471 WalkState->OperandIndex = 0;
472 WalkState->ReturnDesc = NULL;
473 WalkState->ResultObj = NULL;
474
475 /* Call debugger for single step support (DEBUG build only) */
476
477 ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
478 ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
479
480 /* Decode the Opcode Class */
481
482 switch (OpClass)
483 {
493 case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
484 case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */
485
486 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
487 {
488 Status = AcpiDsEvaluateNamePath (WalkState);
489 if (ACPI_FAILURE (Status))
490 {
491 goto Cleanup;
492 }
493 }
494 break;
495
496
497 case AML_CLASS_EXECUTE: /* most operators with arguments */
497 case AML_CLASS_EXECUTE: /* Most operators with arguments */
498
499 /* Build resolved operand stack */
500
501 Status = AcpiDsCreateOperands (WalkState, FirstArg);
502 if (ACPI_FAILURE (Status))
503 {
504 goto Cleanup;
505 }
506
507 /* Done with this result state (Now that operand stack is built) */
508
509 Status = AcpiDsResultStackPop (WalkState);
510 if (ACPI_FAILURE (Status))
511 {
512 goto Cleanup;
513 }
514
507 /*
508 * All opcodes require operand resolution, with the only exceptions
509 * being the ObjectType and SizeOf operators.
510 */
511 if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE))
512 {
513 /* Resolve all operands */
514

--- 31 unchanged lines hidden (view full) ---

546 WalkState->Operands[1]->Reference.Opcode) &&
547 (WalkState->Operands[0]->Reference.Offset ==
548 WalkState->Operands[1]->Reference.Offset))
549 {
550 Status = AE_OK;
551 }
552 else
553 {
562 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
563 "[%s]: Could not resolve operands, %s\n",
564 AcpiPsGetOpcodeName (WalkState->Opcode),
565 AcpiFormatException (Status)));
554 ACPI_EXCEPTION ((AE_INFO, Status,
555 "While resolving operands for [%s]",
556 AcpiPsGetOpcodeName (WalkState->Opcode)));
557 }
558 }
559
560 /* Always delete the argument objects and clear the operand stack */
561
562 AcpiDsClearOperands (WalkState);
563
564 /*
565 * If a result object was returned from above, push it on the
566 * current result stack
567 */
568 if (ACPI_SUCCESS (Status) &&
569 WalkState->ResultObj)
570 {
571 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
572 }
582
573 break;
574
575
576 default:
577
578 switch (OpType)
579 {
580 case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
581
582 /* 1 Operand, 0 ExternalResult, 0 InternalResult */
583
584 Status = AcpiDsExecEndControlOp (WalkState, Op);
585
596 /* Make sure to properly pop the result stack */
597
598 if (ACPI_SUCCESS (Status))
599 {
600 Status = AcpiDsResultStackPop (WalkState);
601 }
602 else if (Status == AE_CTRL_PENDING)
603 {
604 Status = AcpiDsResultStackPop (WalkState);
605 if (ACPI_SUCCESS (Status))
606 {
607 Status = AE_CTRL_PENDING;
608 }
609 }
586 break;
587
588
589 case AML_TYPE_METHOD_CALL:
590
591 /*
592 * If the method is referenced from within a package
593 * declaration, it is not a invocation of the method, just
594 * a reference to it.
595 */
596 if ((Op->Asl.Parent) &&
597 ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
598 (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)))
599 {
600 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
601 "Method Reference in a Package, Op=%p\n", Op));
602
603 Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node->Object;
604 AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object);
605 return_ACPI_STATUS (AE_OK);
606 }
607
608 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op));
609
610 /*

--- 93 unchanged lines hidden (view full) ---

704 break;
705
706 default:
707
708 Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
709 break;
710 }
711
735 /* Done with result state (Now that operand stack is built) */
736
737 Status = AcpiDsResultStackPop (WalkState);
738 if (ACPI_FAILURE (Status))
739 {
740 goto Cleanup;
741 }
742
712 /*
713 * If a result object was returned from above, push it on the
714 * current result stack
715 */
716 if (WalkState->ResultObj)
717 {
718 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
719 }

--- 16 unchanged lines hidden (view full) ---

736 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
737 "Executing OpRegion Address/Length Op=%p\n", Op));
738
739 Status = AcpiDsEvalRegionOperands (WalkState, Op);
740 if (ACPI_FAILURE (Status))
741 {
742 break;
743 }
775
776 Status = AcpiDsResultStackPop (WalkState);
744 }
778
745 break;
746
747
748 case AML_TYPE_UNDEFINED:
749
784 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
785 "Undefined opcode type Op=%p\n", Op));
750 ACPI_ERROR ((AE_INFO,
751 "Undefined opcode type Op=%p", Op));
752 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
753
754
755 case AML_TYPE_BOGUS:
756
757 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
758 "Internal opcode=%X type Op=%p\n",
759 WalkState->Opcode, Op));
760 break;
761
762
763 default:
764
799 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
800 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
765 ACPI_ERROR ((AE_INFO,
766 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p",
767 OpClass, OpType, Op->Common.AmlOpcode, Op));
768
769 Status = AE_NOT_IMPLEMENTED;
770 break;
771 }
772 }
773
774 /*
775 * ACPI 2.0 support for 64-bit integers: Truncate numeric
776 * result value if we are executing from a 32-bit ACPI table
777 */
778 AcpiExTruncateFor32bitTable (WalkState->ResultObj);
779
780 /*
781 * Check if we just completed the evaluation of a
782 * conditional predicate
783 */
818
784 if ((ACPI_SUCCESS (Status)) &&
785 (WalkState->ControlState) &&
786 (WalkState->ControlState->Common.State ==
787 ACPI_CONTROL_PREDICATE_EXECUTING) &&
788 (WalkState->ControlState->Control.PredicateOp == Op))
789 {
790 Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
791 WalkState->ResultObj = NULL;
792 }
793
794
795Cleanup:
796
832 /* Invoke exception handler on error */
833
834 if (ACPI_FAILURE (Status) &&
835 AcpiGbl_ExceptionHandler &&
836 !(Status & AE_CODE_CONTROL))
837 {
838 AcpiExExitInterpreter ();
839 Status = AcpiGbl_ExceptionHandler (Status,
840 WalkState->MethodNode->Name.Integer, WalkState->Opcode,
841 WalkState->AmlOffset, NULL);
842 (void) AcpiExEnterInterpreter ();
843 }
844
797 if (WalkState->ResultObj)
798 {
799 /* Break to debugger to display result */
800
801 ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj,
802 WalkState));
803
804 /*

--- 7 unchanged lines hidden (view full) ---

812#ifdef _UNDER_DEVELOPMENT
813
814 if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
815 {
816 AcpiDbMethodEnd (WalkState);
817 }
818#endif
819
868 /* Always clear the object stack */
820 /* Invoke exception handler on error */
821
870 WalkState->NumOperands = 0;
871
872#ifdef ACPI_DISASSEMBLER
873
874 /* On error, display method locals/args */
875
822 if (ACPI_FAILURE (Status))
823 {
878 AcpiDmDumpMethodInfo (Status, WalkState, Op);
824 Status = AcpiDsMethodError (Status, WalkState);
825 }
880#endif
826
827 /* Always clear the object stack */
828
829 WalkState->NumOperands = 0;
830 return_ACPI_STATUS (Status);
831}
832
833