Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/executer/exfield.c
          +++ new/usr/src/common/acpica/components/executer/exfield.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, 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 ↓ 38 lines elided ↑ open up ↑
  57   57  /*******************************************************************************
  58   58   *
  59   59   * FUNCTION:    AcpiExReadDataFromField
  60   60   *
  61   61   * PARAMETERS:  WalkState           - Current execution state
  62   62   *              ObjDesc             - The named field
  63   63   *              RetBufferDesc       - Where the return data object is stored
  64   64   *
  65   65   * RETURN:      Status
  66   66   *
  67      - * DESCRIPTION: Read from a named field.  Returns either an Integer or a
       67 + * DESCRIPTION: Read from a named field. Returns either an Integer or a
  68   68   *              Buffer, depending on the size of the field.
  69   69   *
  70   70   ******************************************************************************/
  71   71  
  72   72  ACPI_STATUS
  73   73  AcpiExReadDataFromField (
  74   74      ACPI_WALK_STATE         *WalkState,
  75   75      ACPI_OPERAND_OBJECT     *ObjDesc,
  76   76      ACPI_OPERAND_OBJECT     **RetBufferDesc)
  77   77  {
↓ open down ↓ 28 lines elided ↑ open up ↑
 106  106          {
 107  107              Status = AcpiDsGetBufferFieldArguments (ObjDesc);
 108  108              if (ACPI_FAILURE (Status))
 109  109              {
 110  110                  return_ACPI_STATUS (Status);
 111  111              }
 112  112          }
 113  113      }
 114  114      else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
 115  115               (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
      116 +              ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
 116  117                ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
 117  118      {
 118  119          /*
 119      -         * This is an SMBus or IPMI read. We must create a buffer to hold
      120 +         * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
 120  121           * the data and then directly access the region handler.
 121  122           *
 122      -         * Note: Smbus protocol value is passed in upper 16-bits of Function
      123 +         * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
 123  124           */
 124  125          if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
 125  126          {
 126  127              Length = ACPI_SMBUS_BUFFER_SIZE;
 127  128              Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
 128  129          }
      130 +        else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
      131 +        {
      132 +            Length = ACPI_GSBUS_BUFFER_SIZE;
      133 +            Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
      134 +        }
 129  135          else /* IPMI */
 130  136          {
 131  137              Length = ACPI_IPMI_BUFFER_SIZE;
 132  138              Function = ACPI_READ;
 133  139          }
 134  140  
 135  141          BufferDesc = AcpiUtCreateBufferObject (Length);
 136  142          if (!BufferDesc)
 137  143          {
 138  144              return_ACPI_STATUS (AE_NO_MEMORY);
↓ open down ↓ 9 lines elided ↑ open up ↑
 148  154                      ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
 149  155                      Function);
 150  156          AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
 151  157          goto Exit;
 152  158      }
 153  159  
 154  160      /*
 155  161       * Allocate a buffer for the contents of the field.
 156  162       *
 157  163       * If the field is larger than the current integer width, create
 158      -     * a BUFFER to hold it.  Otherwise, use an INTEGER.  This allows
      164 +     * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
 159  165       * the use of arithmetic operators on the returned value if the
 160  166       * field size is equal or smaller than an Integer.
 161  167       *
 162  168       * Note: Field.length is in bits.
 163  169       */
 164  170      Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
 165  171      if (Length > AcpiGbl_IntegerByteWidth)
 166  172      {
 167  173          /* Field is too large for an Integer, create a Buffer instead */
 168  174  
↓ open down ↓ 98 lines elided ↑ open up ↑
 267  273          {
 268  274              Status = AcpiDsGetBufferFieldArguments (ObjDesc);
 269  275              if (ACPI_FAILURE (Status))
 270  276              {
 271  277                  return_ACPI_STATUS (Status);
 272  278              }
 273  279          }
 274  280      }
 275  281      else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
 276  282               (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
      283 +              ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
 277  284                ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
 278  285      {
 279  286          /*
 280      -         * This is an SMBus or IPMI write. We will bypass the entire field
      287 +         * This is an SMBus, GSBus or IPMI write. We will bypass the entire field
 281  288           * mechanism and handoff the buffer directly to the handler. For
 282  289           * these address spaces, the buffer is bi-directional; on a write,
 283  290           * return data is returned in the same buffer.
 284  291           *
 285  292           * Source must be a buffer of sufficient size:
 286      -         * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE.
      293 +         * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
 287  294           *
 288      -         * Note: SMBus protocol type is passed in upper 16-bits of Function
      295 +         * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function
 289  296           */
 290  297          if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
 291  298          {
 292  299              ACPI_ERROR ((AE_INFO,
 293      -                "SMBus or IPMI write requires Buffer, found type %s",
      300 +                "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s",
 294  301                  AcpiUtGetObjectTypeName (SourceDesc)));
 295  302  
 296  303              return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 297  304          }
 298  305  
 299  306          if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
 300  307          {
 301  308              Length = ACPI_SMBUS_BUFFER_SIZE;
 302  309              Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
 303  310          }
      311 +        else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
      312 +        {
      313 +            Length = ACPI_GSBUS_BUFFER_SIZE;
      314 +            Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
      315 +        }
 304  316          else /* IPMI */
 305  317          {
 306  318              Length = ACPI_IPMI_BUFFER_SIZE;
 307  319              Function = ACPI_WRITE;
 308  320          }
 309  321  
 310  322          if (SourceDesc->Buffer.Length < Length)
 311  323          {
 312  324              ACPI_ERROR ((AE_INFO,
 313      -                "SMBus or IPMI write requires Buffer of length %u, found length %u",
      325 +                "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u",
 314  326                  Length, SourceDesc->Buffer.Length));
 315  327  
 316  328              return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
 317  329          }
 318  330  
 319  331          /* Create the bi-directional buffer */
 320  332  
 321  333          BufferDesc = AcpiUtCreateBufferObject (Length);
 322  334          if (!BufferDesc)
 323  335          {
↓ open down ↓ 17 lines elided ↑ open up ↑
 341  353  
 342  354          *ResultDesc = BufferDesc;
 343  355          return_ACPI_STATUS (Status);
 344  356      }
 345  357  
 346  358      /* Get a pointer to the data to be written */
 347  359  
 348  360      switch (SourceDesc->Common.Type)
 349  361      {
 350  362      case ACPI_TYPE_INTEGER:
      363 +
 351  364          Buffer = &SourceDesc->Integer.Value;
 352  365          Length = sizeof (SourceDesc->Integer.Value);
 353  366          break;
 354  367  
 355  368      case ACPI_TYPE_BUFFER:
      369 +
 356  370          Buffer = SourceDesc->Buffer.Pointer;
 357  371          Length = SourceDesc->Buffer.Length;
 358  372          break;
 359  373  
 360  374      case ACPI_TYPE_STRING:
      375 +
 361  376          Buffer = SourceDesc->String.Pointer;
 362  377          Length = SourceDesc->String.Length;
 363  378          break;
 364  379  
 365  380      default:
      381 +
 366  382          return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 367  383      }
 368  384  
 369  385      ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
 370  386          "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
 371  387          SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
 372  388          SourceDesc->Common.Type, Buffer, Length));
 373  389  
 374  390      ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
 375  391          "FieldWrite [TO]:   Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
↓ open down ↓ 7 lines elided ↑ open up ↑
 383  399  
 384  400      AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
 385  401  
 386  402      /* Write to the field */
 387  403  
 388  404      Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
 389  405      AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
 390  406  
 391  407      return_ACPI_STATUS (Status);
 392  408  }
 393      -
 394      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX