Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/executer/exoparg2.c
          +++ new/usr/src/common/acpica/components/executer/exoparg2.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2014, Intel Corp.
   9    9   * All rights reserved.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions, and the following disclaimer,
  16   16   *    without modification.
  17   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 111 lines elided ↑ open up ↑
 130  130                  "Unexpected notify object type [%s]",
 131  131                  AcpiUtGetTypeName (Node->Type)));
 132  132  
 133  133              Status = AE_AML_OPERAND_TYPE;
 134  134              break;
 135  135          }
 136  136  
 137  137          /*
 138  138           * Dispatch the notify to the appropriate handler
 139  139           * NOTE: the request is queued for execution after this method
 140      -         * completes.  The notify handlers are NOT invoked synchronously
      140 +         * completes. The notify handlers are NOT invoked synchronously
 141  141           * from this thread -- because handlers may in turn run other
 142  142           * control methods.
 143  143           */
 144  144          Status = AcpiEvQueueNotifyRequest (Node, Value);
 145  145          break;
 146  146  
 147      -
 148  147      default:
 149  148  
 150  149          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 151  150              WalkState->Opcode));
 152  151          Status = AE_AML_BAD_OPCODE;
 153  152      }
 154  153  
 155  154      return_ACPI_STATUS (Status);
 156  155  }
 157  156  
↓ open down ↓ 52 lines elided ↑ open up ↑
 210  209          Status = AcpiUtDivide (Operand[0]->Integer.Value,
 211  210                                 Operand[1]->Integer.Value,
 212  211                                 &ReturnDesc1->Integer.Value,
 213  212                                 &ReturnDesc2->Integer.Value);
 214  213          if (ACPI_FAILURE (Status))
 215  214          {
 216  215              goto Cleanup;
 217  216          }
 218  217          break;
 219  218  
 220      -
 221  219      default:
 222  220  
 223  221          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 224  222              WalkState->Opcode));
 225  223          Status = AE_AML_BAD_OPCODE;
 226  224          goto Cleanup;
 227  225      }
 228  226  
 229  227      /* Store the results to the target reference operands */
 230  228  
↓ open down ↓ 48 lines elided ↑ open up ↑
 279  277   ******************************************************************************/
 280  278  
 281  279  ACPI_STATUS
 282  280  AcpiExOpcode_2A_1T_1R (
 283  281      ACPI_WALK_STATE         *WalkState)
 284  282  {
 285  283      ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 286  284      ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
 287  285      UINT64                  Index;
 288  286      ACPI_STATUS             Status = AE_OK;
 289      -    ACPI_SIZE               Length;
      287 +    ACPI_SIZE               Length = 0;
 290  288  
 291  289  
 292  290      ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
 293  291          AcpiPsGetOpcodeName (WalkState->Opcode));
 294  292  
 295  293  
 296  294      /* Execute the opcode */
 297  295  
 298  296      if (WalkState->OpInfo->Flags & AML_MATH)
 299  297      {
↓ open down ↓ 24 lines elided ↑ open up ↑
 324  322          }
 325  323  
 326  324          /* ReturnDesc will contain the remainder */
 327  325  
 328  326          Status = AcpiUtDivide (Operand[0]->Integer.Value,
 329  327                                 Operand[1]->Integer.Value,
 330  328                                 NULL,
 331  329                                 &ReturnDesc->Integer.Value);
 332  330          break;
 333  331  
 334      -
 335  332      case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
 336  333  
 337  334          Status = AcpiExDoConcatenate (Operand[0], Operand[1],
 338  335                      &ReturnDesc, WalkState);
 339  336          break;
 340  337  
 341      -
 342  338      case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
 343      -
 344  339          /*
 345  340           * Input object is guaranteed to be a buffer at this point (it may have
 346  341           * been converted.)  Copy the raw buffer data to a new object of
 347  342           * type String.
 348  343           */
 349  344  
 350  345          /*
 351  346           * Get the length of the new string. It is the smallest of:
 352  347           * 1) Length of the input buffer
 353  348           * 2) Max length as specified in the ToString operator
 354  349           * 3) Length of input buffer up to a zero byte (null terminator)
 355  350           *
 356  351           * NOTE: A length of zero is ok, and will create a zero-length, null
 357  352           *       terminated string.
 358  353           */
 359      -        Length = 0;
 360  354          while ((Length < Operand[0]->Buffer.Length) &&
 361  355                 (Length < Operand[1]->Integer.Value) &&
 362  356                 (Operand[0]->Buffer.Pointer[Length]))
 363  357          {
 364  358              Length++;
 365  359          }
 366  360  
 367  361          /* Allocate a new string object */
 368  362  
 369  363          ReturnDesc = AcpiUtCreateStringObject (Length);
↓ open down ↓ 4 lines elided ↑ open up ↑
 374  368          }
 375  369  
 376  370          /*
 377  371           * Copy the raw buffer data with no transform.
 378  372           * (NULL terminated already)
 379  373           */
 380  374          ACPI_MEMCPY (ReturnDesc->String.Pointer,
 381  375              Operand[0]->Buffer.Pointer, Length);
 382  376          break;
 383  377  
 384      -
 385  378      case AML_CONCAT_RES_OP:
 386  379  
 387  380          /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
 388  381  
 389  382          Status = AcpiExConcatTemplate (Operand[0], Operand[1],
 390  383                      &ReturnDesc, WalkState);
 391  384          break;
 392  385  
 393      -
 394  386      case AML_INDEX_OP:              /* Index (Source Index Result) */
 395  387  
 396  388          /* Create the internal return object */
 397  389  
 398  390          ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
 399  391          if (!ReturnDesc)
 400  392          {
 401  393              Status = AE_NO_MEMORY;
 402  394              goto Cleanup;
 403  395          }
↓ open down ↓ 7 lines elided ↑ open up ↑
 411  403          /*
 412  404           * At this point, the Source operand is a String, Buffer, or Package.
 413  405           * Verify that the index is within range.
 414  406           */
 415  407          switch ((Operand[0])->Common.Type)
 416  408          {
 417  409          case ACPI_TYPE_STRING:
 418  410  
 419  411              if (Index >= Operand[0]->String.Length)
 420  412              {
      413 +                Length = Operand[0]->String.Length;
 421  414                  Status = AE_AML_STRING_LIMIT;
 422  415              }
 423  416  
 424  417              ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
 425  418              break;
 426  419  
 427  420          case ACPI_TYPE_BUFFER:
 428  421  
 429  422              if (Index >= Operand[0]->Buffer.Length)
 430  423              {
      424 +                Length = Operand[0]->Buffer.Length;
 431  425                  Status = AE_AML_BUFFER_LIMIT;
 432  426              }
 433  427  
 434  428              ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
 435  429              break;
 436  430  
 437  431          case ACPI_TYPE_PACKAGE:
 438  432  
 439  433              if (Index >= Operand[0]->Package.Count)
 440  434              {
      435 +                Length = Operand[0]->Package.Count;
 441  436                  Status = AE_AML_PACKAGE_LIMIT;
 442  437              }
 443  438  
 444  439              ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
 445  440              ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];
 446  441              break;
 447  442  
 448  443          default:
 449  444  
 450  445              Status = AE_AML_INTERNAL;
 451  446              goto Cleanup;
 452  447          }
 453  448  
 454  449          /* Failure means that the Index was beyond the end of the object */
 455  450  
 456  451          if (ACPI_FAILURE (Status))
 457  452          {
 458  453              ACPI_EXCEPTION ((AE_INFO, Status,
 459      -                "Index (0x%8.8X%8.8X) is beyond end of object",
 460      -                ACPI_FORMAT_UINT64 (Index)));
      454 +                "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
      455 +                ACPI_FORMAT_UINT64 (Index), (UINT32) Length));
 461  456              goto Cleanup;
 462  457          }
 463  458  
 464  459          /*
 465  460           * Save the target object and add a reference to it for the life
 466  461           * of the index
 467  462           */
 468  463          ReturnDesc->Reference.Object = Operand[0];
 469  464          AcpiUtAddReference (Operand[0]);
 470  465  
 471  466          /* Store the reference to the Target */
 472  467  
 473  468          Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
 474  469  
 475  470          /* Return the reference */
 476  471  
 477  472          WalkState->ResultObj = ReturnDesc;
 478  473          goto Cleanup;
 479  474  
 480      -
 481  475      default:
 482  476  
 483  477          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 484  478              WalkState->Opcode));
 485  479          Status = AE_AML_BAD_OPCODE;
 486  480          break;
 487  481      }
 488  482  
 489  483  
 490  484  StoreResultToTarget:
↓ open down ↓ 102 lines elided ↑ open up ↑
 593  587      case AML_WAIT_OP:               /* Wait (EventObject, Timeout) */
 594  588  
 595  589          Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
 596  590          if (Status == AE_TIME)
 597  591          {
 598  592              LogicalResult = TRUE;       /* TRUE, Wait timed out */
 599  593              Status = AE_OK;
 600  594          }
 601  595          break;
 602  596  
 603      -
 604  597      default:
 605  598  
 606  599          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 607  600              WalkState->Opcode));
 608  601          Status = AE_AML_BAD_OPCODE;
 609  602          goto Cleanup;
 610  603      }
 611  604  
 612  605  
 613  606  StoreLogicalResult:
↓ open down ↓ 17 lines elided ↑ open up ↑
 631  624  
 632  625      /* Save return object on success */
 633  626  
 634  627      else
 635  628      {
 636  629          WalkState->ResultObj = ReturnDesc;
 637  630      }
 638  631  
 639  632      return_ACPI_STATUS (Status);
 640  633  }
 641      -
 642      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX