Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20131218
acpica-unix2-20130823
PANKOVs restructure
   1 /*******************************************************************************
   2  *
   3  * Module Name: dsutils - Dispatcher utilities
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 247     /*
 248      * Decide what to do with the result based on the parent.  If
 249      * the parent opcode will not use the result, delete the object.
 250      * Otherwise leave it as is, it will be deleted when it is used
 251      * as an operand later.
 252      */
 253     switch (ParentInfo->Class)
 254     {
 255     case AML_CLASS_CONTROL:
 256 
 257         switch (Op->Common.Parent->Common.AmlOpcode)
 258         {
 259         case AML_RETURN_OP:
 260 
 261             /* Never delete the return value associated with a return opcode */
 262 
 263             goto ResultUsed;
 264 
 265         case AML_IF_OP:
 266         case AML_WHILE_OP:
 267 
 268             /*
 269              * If we are executing the predicate AND this is the predicate op,
 270              * we will use the return value
 271              */
 272             if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
 273                 (WalkState->ControlState->Control.PredicateOp == Op))
 274             {
 275                 goto ResultUsed;
 276             }
 277             break;
 278 
 279         default:

 280             /* Ignore other control opcodes */

 281             break;
 282         }
 283 
 284         /* The general control opcode returns no result */
 285 
 286         goto ResultNotUsed;
 287 
 288 
 289     case AML_CLASS_CREATE:
 290 
 291         /*
 292          * These opcodes allow TermArg(s) as operands and therefore
 293          * the operands can be method calls.  The result is used.
 294          */
 295         goto ResultUsed;
 296 
 297 
 298     case AML_CLASS_NAMED_OBJECT:
 299 
 300         if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
 301             (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
 302             (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
 303             (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)  ||
 304             (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
 305             (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
 306             (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
 307         {
 308             /*
 309              * These opcodes allow TermArg(s) as operands and therefore
 310              * the operands can be method calls.  The result is used.
 311              */
 312             goto ResultUsed;
 313         }
 314 
 315         goto ResultNotUsed;
 316 
 317 
 318     default:
 319 
 320         /*
 321          * In all other cases. the parent will actually use the return
 322          * object, so keep it.
 323          */
 324         goto ResultUsed;
 325     }
 326 
 327 
 328 ResultUsed:
 329     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 330         "Result of [%s] used by Parent [%s] Op=%p\n",
 331         AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
 332         AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
 333 
 334     return_UINT8 (TRUE);
 335 
 336 
 337 ResultNotUsed:
 338     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 339         "Result of [%s] not used by Parent [%s] Op=%p\n",


 766     /* Get all arguments in the list */
 767 
 768     Arg = FirstArg;
 769     while (Arg)
 770     {
 771         if (Index >= ACPI_OBJ_NUM_OPERANDS)
 772         {
 773             return_ACPI_STATUS (AE_BAD_DATA);
 774         }
 775 
 776         Arguments[Index] = Arg;
 777         WalkState->Operands [Index] = NULL;
 778 
 779         /* Move on to next argument, if any */
 780 
 781         Arg = Arg->Common.Next;
 782         ArgCount++;
 783         Index++;
 784     }
 785 
 786     Index--;


 787 
 788     /* It is the appropriate order to get objects from the Result stack */
 789 

 790     for (i = 0; i < ArgCount; i++)
 791     {
 792         Arg = Arguments[Index];
 793 
 794         /* Force the filling of the operand stack in inverse order */
 795 
 796         WalkState->OperandIndex = (UINT8) Index;
 797 
 798         Status = AcpiDsCreateOperand (WalkState, Arg, Index);
 799         if (ACPI_FAILURE (Status))
 800         {
 801             goto Cleanup;
 802         }
 803 



 804         Index--;
 805 
 806         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n",
 807             Index, Arg, FirstArg));
 808     }
 809 
 810     return_ACPI_STATUS (Status);
 811 
 812 
 813 Cleanup:
 814     /*
 815      * We must undo everything done above; meaning that we must
 816      * pop everything off of the operand stack and delete those
 817      * objects
 818      */
 819     AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
 820 
 821     ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index));
 822     return_ACPI_STATUS (Status);
 823 }
 824 
 825 
 826 /*****************************************************************************
 827  *


   1 /*******************************************************************************
   2  *
   3  * Module Name: dsutils - Dispatcher utilities
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 247     /*
 248      * Decide what to do with the result based on the parent. If
 249      * the parent opcode will not use the result, delete the object.
 250      * Otherwise leave it as is, it will be deleted when it is used
 251      * as an operand later.
 252      */
 253     switch (ParentInfo->Class)
 254     {
 255     case AML_CLASS_CONTROL:
 256 
 257         switch (Op->Common.Parent->Common.AmlOpcode)
 258         {
 259         case AML_RETURN_OP:
 260 
 261             /* Never delete the return value associated with a return opcode */
 262 
 263             goto ResultUsed;
 264 
 265         case AML_IF_OP:
 266         case AML_WHILE_OP:

 267             /*
 268              * If we are executing the predicate AND this is the predicate op,
 269              * we will use the return value
 270              */
 271             if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
 272                 (WalkState->ControlState->Control.PredicateOp == Op))
 273             {
 274                 goto ResultUsed;
 275             }
 276             break;
 277 
 278         default:
 279 
 280             /* Ignore other control opcodes */
 281 
 282             break;
 283         }
 284 
 285         /* The general control opcode returns no result */
 286 
 287         goto ResultNotUsed;
 288 

 289     case AML_CLASS_CREATE:

 290         /*
 291          * These opcodes allow TermArg(s) as operands and therefore
 292          * the operands can be method calls. The result is used.
 293          */
 294         goto ResultUsed;
 295 

 296     case AML_CLASS_NAMED_OBJECT:
 297 
 298         if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
 299             (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
 300             (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
 301             (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)  ||
 302             (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
 303             (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
 304             (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
 305         {
 306             /*
 307              * These opcodes allow TermArg(s) as operands and therefore
 308              * the operands can be method calls. The result is used.
 309              */
 310             goto ResultUsed;
 311         }
 312 
 313         goto ResultNotUsed;
 314 

 315     default:

 316         /*
 317          * In all other cases. the parent will actually use the return
 318          * object, so keep it.
 319          */
 320         goto ResultUsed;
 321     }
 322 
 323 
 324 ResultUsed:
 325     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 326         "Result of [%s] used by Parent [%s] Op=%p\n",
 327         AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
 328         AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
 329 
 330     return_UINT8 (TRUE);
 331 
 332 
 333 ResultNotUsed:
 334     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 335         "Result of [%s] not used by Parent [%s] Op=%p\n",


 762     /* Get all arguments in the list */
 763 
 764     Arg = FirstArg;
 765     while (Arg)
 766     {
 767         if (Index >= ACPI_OBJ_NUM_OPERANDS)
 768         {
 769             return_ACPI_STATUS (AE_BAD_DATA);
 770         }
 771 
 772         Arguments[Index] = Arg;
 773         WalkState->Operands [Index] = NULL;
 774 
 775         /* Move on to next argument, if any */
 776 
 777         Arg = Arg->Common.Next;
 778         ArgCount++;
 779         Index++;
 780     }
 781 
 782     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 783         "NumOperands %d, ArgCount %d, Index %d\n",
 784         WalkState->NumOperands, ArgCount, Index));
 785 
 786     /* Create the interpreter arguments, in reverse order */
 787 
 788     Index--;
 789     for (i = 0; i < ArgCount; i++)
 790     {
 791         Arg = Arguments[Index];



 792         WalkState->OperandIndex = (UINT8) Index;
 793 
 794         Status = AcpiDsCreateOperand (WalkState, Arg, Index);
 795         if (ACPI_FAILURE (Status))
 796         {
 797             goto Cleanup;
 798         }
 799 
 800         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 801             "Created Arg #%u (%p) %u args total\n",
 802             Index, Arg, ArgCount));
 803         Index--;



 804     }
 805 
 806     return_ACPI_STATUS (Status);
 807 
 808 
 809 Cleanup:
 810     /*
 811      * We must undo everything done above; meaning that we must
 812      * pop everything off of the operand stack and delete those
 813      * objects
 814      */
 815     AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
 816 
 817     ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index));
 818     return_ACPI_STATUS (Status);
 819 }
 820 
 821 
 822 /*****************************************************************************
 823  *