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/exconvrt.c
          +++ new/usr/src/common/acpica/components/executer/exconvrt.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: exconvrt - Object conversion routines
   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 ↓ 88 lines elided ↑ open up ↑
 107  107      case ACPI_TYPE_BUFFER:
 108  108      case ACPI_TYPE_STRING:
 109  109  
 110  110          /* Note: Takes advantage of common buffer/string fields */
 111  111  
 112  112          Pointer = ObjDesc->Buffer.Pointer;
 113  113          Count   = ObjDesc->Buffer.Length;
 114  114          break;
 115  115  
 116  116      default:
      117 +
 117  118          return_ACPI_STATUS (AE_TYPE);
 118  119      }
 119  120  
 120  121      /*
 121  122       * Convert the buffer/string to an integer. Note that both buffers and
 122  123       * strings are treated as raw data - we don't convert ascii to hex for
 123  124       * strings.
 124  125       *
 125  126       * There are two terminating conditions for the loop:
 126  127       * 1) The size of an integer has been reached, or
 127  128       * 2) The end of the buffer or string has been reached
 128  129       */
 129  130      Result = 0;
 130  131  
 131  132      /* String conversion is different than Buffer conversion */
 132  133  
 133  134      switch (ObjDesc->Common.Type)
 134  135      {
 135  136      case ACPI_TYPE_STRING:
 136      -
 137  137          /*
 138  138           * Convert string to an integer - for most cases, the string must be
 139  139           * hexadecimal as per the ACPI specification. The only exception (as
 140  140           * of ACPI 3.0) is that the ToInteger() operator allows both decimal
 141  141           * and hexadecimal strings (hex prefixed with "0x").
 142  142           */
 143  143          Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result);
 144  144          if (ACPI_FAILURE (Status))
 145  145          {
 146  146              return_ACPI_STATUS (Status);
 147  147          }
 148  148          break;
 149  149  
 150      -
 151  150      case ACPI_TYPE_BUFFER:
 152  151  
 153  152          /* Check for zero-length buffer */
 154  153  
 155  154          if (!Count)
 156  155          {
 157  156              return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
 158  157          }
 159  158  
 160  159          /* Transfer no more than an integer's worth of data */
↓ open down ↓ 11 lines elided ↑ open up ↑
 172  171          {
 173  172              /*
 174  173               * Get next byte and shift it into the Result.
 175  174               * Little endian is used, meaning that the first byte of the buffer
 176  175               * is the LSB of the integer
 177  176               */
 178  177              Result |= (((UINT64) Pointer[i]) << (i * 8));
 179  178          }
 180  179          break;
 181  180  
 182      -
 183  181      default:
 184  182  
 185  183          /* No other types can get here */
      184 +
 186  185          break;
 187  186      }
 188  187  
 189  188      /* Create a new integer */
 190  189  
 191  190      ReturnDesc = AcpiUtCreateIntegerObject (Result);
 192  191      if (!ReturnDesc)
 193  192      {
 194  193          return_ACPI_STATUS (AE_NO_MEMORY);
 195  194      }
 196  195  
 197  196      ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
 198  197          ACPI_FORMAT_UINT64 (Result)));
 199  198  
 200  199      /* Save the Result */
 201  200  
 202      -    AcpiExTruncateFor32bitTable (ReturnDesc);
      201 +    (void) AcpiExTruncateFor32bitTable (ReturnDesc);
 203  202      *ResultDesc = ReturnDesc;
 204  203      return_ACPI_STATUS (AE_OK);
 205  204  }
 206  205  
 207  206  
 208  207  /*******************************************************************************
 209  208   *
 210  209   * FUNCTION:    AcpiExConvertToBuffer
 211  210   *
 212  211   * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
↓ open down ↓ 22 lines elided ↑ open up ↑
 235  234      {
 236  235      case ACPI_TYPE_BUFFER:
 237  236  
 238  237          /* No conversion necessary */
 239  238  
 240  239          *ResultDesc = ObjDesc;
 241  240          return_ACPI_STATUS (AE_OK);
 242  241  
 243  242  
 244  243      case ACPI_TYPE_INTEGER:
 245      -
 246  244          /*
 247  245           * Create a new Buffer object.
 248  246           * Need enough space for one integer
 249  247           */
 250  248          ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
 251  249          if (!ReturnDesc)
 252  250          {
 253  251              return_ACPI_STATUS (AE_NO_MEMORY);
 254  252          }
 255  253  
 256  254          /* Copy the integer to the buffer, LSB first */
 257  255  
 258  256          NewBuf = ReturnDesc->Buffer.Pointer;
 259  257          ACPI_MEMCPY (NewBuf,
 260  258                          &ObjDesc->Integer.Value,
 261  259                          AcpiGbl_IntegerByteWidth);
 262  260          break;
 263  261  
 264      -
 265  262      case ACPI_TYPE_STRING:
 266      -
 267  263          /*
 268  264           * Create a new Buffer object
 269  265           * Size will be the string length
 270  266           *
 271  267           * NOTE: Add one to the string length to include the null terminator.
 272  268           * The ACPI spec is unclear on this subject, but there is existing
 273  269           * ASL/AML code that depends on the null being transferred to the new
 274  270           * buffer.
 275  271           */
 276  272          ReturnDesc = AcpiUtCreateBufferObject (
↓ open down ↓ 3 lines elided ↑ open up ↑
 280  276              return_ACPI_STATUS (AE_NO_MEMORY);
 281  277          }
 282  278  
 283  279          /* Copy the string to the buffer */
 284  280  
 285  281          NewBuf = ReturnDesc->Buffer.Pointer;
 286  282          ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
 287  283              ObjDesc->String.Length);
 288  284          break;
 289  285  
 290      -
 291  286      default:
      287 +
 292  288          return_ACPI_STATUS (AE_TYPE);
 293  289      }
 294  290  
 295  291      /* Mark buffer initialized */
 296  292  
 297  293      ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
 298  294      *ResultDesc = ReturnDesc;
 299  295      return_ACPI_STATUS (AE_OK);
 300  296  }
 301  297  
↓ open down ↓ 35 lines elided ↑ open up ↑
 337  333  
 338  334      switch (Base)
 339  335      {
 340  336      case 10:
 341  337  
 342  338          /* Setup max length for the decimal number */
 343  339  
 344  340          switch (DataWidth)
 345  341          {
 346  342          case 1:
      343 +
 347  344              DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
 348  345              break;
 349  346  
 350  347          case 4:
      348 +
 351  349              DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
 352  350              break;
 353  351  
 354  352          case 8:
 355  353          default:
      354 +
 356  355              DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
 357  356              break;
 358  357          }
 359  358  
 360  359          SupressZeros = TRUE;     /* No leading zeros */
 361  360          Remainder = 0;
 362  361  
 363  362          for (i = DecimalLength; i > 0; i--)
 364  363          {
 365  364              /* Divide by nth factor of 10 */
↓ open down ↓ 88 lines elided ↑ open up ↑
 454  453  
 455  454      switch (ObjDesc->Common.Type)
 456  455      {
 457  456      case ACPI_TYPE_STRING:
 458  457  
 459  458          /* No conversion necessary */
 460  459  
 461  460          *ResultDesc = ObjDesc;
 462  461          return_ACPI_STATUS (AE_OK);
 463  462  
 464      -
 465  463      case ACPI_TYPE_INTEGER:
 466  464  
 467  465          switch (Type)
 468  466          {
 469  467          case ACPI_EXPLICIT_CONVERT_DECIMAL:
 470  468  
 471  469              /* Make room for maximum decimal number */
 472  470  
 473  471              StringLength = ACPI_MAX_DECIMAL_DIGITS;
 474  472              Base = 10;
↓ open down ↓ 23 lines elided ↑ open up ↑
 498  496  
 499  497          StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base,
 500  498                              NewBuf, AcpiGbl_IntegerByteWidth);
 501  499  
 502  500          /* Null terminate at the correct place */
 503  501  
 504  502          ReturnDesc->String.Length = StringLength;
 505  503          NewBuf [StringLength] = 0;
 506  504          break;
 507  505  
 508      -
 509  506      case ACPI_TYPE_BUFFER:
 510  507  
 511  508          /* Setup string length, base, and separator */
 512  509  
 513  510          switch (Type)
 514  511          {
 515  512          case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
 516  513              /*
 517  514               * From ACPI: "If Data is a buffer, it is converted to a string of
 518  515               * decimal values separated by commas."
↓ open down ↓ 78 lines elided ↑ open up ↑
 597  594           * (overwrites final comma/space from above)
 598  595           */
 599  596          if (ObjDesc->Buffer.Length)
 600  597          {
 601  598              NewBuf--;
 602  599          }
 603  600          *NewBuf = 0;
 604  601          break;
 605  602  
 606  603      default:
      604 +
 607  605          return_ACPI_STATUS (AE_TYPE);
 608  606      }
 609  607  
 610  608      *ResultDesc = ReturnDesc;
 611  609      return_ACPI_STATUS (AE_OK);
 612  610  }
 613  611  
 614  612  
 615  613  /*******************************************************************************
 616  614   *
↓ open down ↓ 39 lines elided ↑ open up ↑
 656  654  
 657  655          switch (DestinationType)
 658  656          {
 659  657          case ACPI_TYPE_LOCAL_REGION_FIELD:
 660  658              /*
 661  659               * Named field can always handle conversions
 662  660               */
 663  661              break;
 664  662  
 665  663          default:
      664 +
 666  665              /* No conversion allowed for these types */
 667  666  
 668  667              if (DestinationType != SourceDesc->Common.Type)
 669  668              {
 670  669                  ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 671  670                      "Explicit operator, will store (%s) over existing type (%s)\n",
 672  671                      AcpiUtGetObjectTypeName (SourceDesc),
 673  672                      AcpiUtGetTypeName (DestinationType)));
 674  673                  Status = AE_TYPE;
 675  674              }
 676  675          }
 677  676          break;
 678  677  
 679      -
 680  678      case ARGI_TARGETREF:
 681  679  
 682  680          switch (DestinationType)
 683  681          {
 684  682          case ACPI_TYPE_INTEGER:
 685  683          case ACPI_TYPE_BUFFER_FIELD:
 686  684          case ACPI_TYPE_LOCAL_BANK_FIELD:
 687  685          case ACPI_TYPE_LOCAL_INDEX_FIELD:
 688  686              /*
 689  687               * These types require an Integer operand. We can convert
 690  688               * a Buffer or a String to an Integer if necessary.
 691  689               */
 692  690              Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
 693  691                          16);
 694  692              break;
 695  693  
 696      -
 697  694          case ACPI_TYPE_STRING:
 698  695              /*
 699  696               * The operand must be a String. We can convert an
 700  697               * Integer or Buffer if necessary
 701  698               */
 702  699              Status = AcpiExConvertToString (SourceDesc, ResultDesc,
 703  700                          ACPI_IMPLICIT_CONVERT_HEX);
 704  701              break;
 705  702  
 706      -
 707  703          case ACPI_TYPE_BUFFER:
 708  704              /*
 709  705               * The operand must be a Buffer. We can convert an
 710  706               * Integer or String if necessary
 711  707               */
 712  708              Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
 713  709              break;
 714  710  
 715      -
 716  711          default:
      712 +
 717  713              ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X",
 718  714                  DestinationType));
 719  715              Status = AE_AML_INTERNAL;
 720  716              break;
 721  717          }
 722  718          break;
 723  719  
 724      -
 725  720      case ARGI_REFERENCE:
 726  721          /*
 727  722           * CreateXxxxField cases - we are storing the field object into the name
 728  723           */
 729  724          break;
 730  725  
 731      -
 732  726      default:
      727 +
 733  728          ACPI_ERROR ((AE_INFO,
 734  729              "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
 735  730              GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
 736  731              WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
 737  732          Status = AE_AML_INTERNAL;
 738  733      }
 739  734  
 740  735      /*
 741  736       * Source-to-Target conversion semantics:
 742  737       *
 743  738       * If conversion to the target type cannot be performed, then simply
 744  739       * overwrite the target with the new object and type.
 745  740       */
 746  741      if (Status == AE_TYPE)
 747  742      {
 748  743          Status = AE_OK;
 749  744      }
 750  745  
 751  746      return_ACPI_STATUS (Status);
 752  747  }
 753      -
 754      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX