Print this page
    
acpica-unix2-20130823
PANKOVs restructure
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/intel/io/acpica/executer/exoparg3.c
          +++ new/usr/src/common/acpica/components/executer/exoparg3.c
   1      -
   2    1  /******************************************************************************
   3    2   *
   4    3   * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
   5    4   *
   6    5   *****************************************************************************/
   7    6  
   8    7  /*
   9      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, Intel Corp.
  10    9   * All rights reserved.
  11   10   *
  12   11   * Redistribution and use in source and binary forms, with or without
  13   12   * modification, are permitted provided that the following conditions
  14   13   * are met:
  15   14   * 1. Redistributions of source code must retain the above copyright
  16   15   *    notice, this list of conditions, and the following disclaimer,
  17   16   *    without modification.
  18   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19   18   *    substantially similar to the "NO WARRANTY" disclaimer below
  20   19   *    ("Disclaimer") and any redistribution must be conditioned upon
  21   20   *    including a substantially similar Disclaimer requirement for further
  22   21   *    binary redistribution.
  23   22   * 3. Neither the names of the above-listed copyright holders nor the names
  24   23   *    of any contributors may be used to endorse or promote products derived
  25   24   *    from this software without specific prior written permission.
  26   25   *
  27   26   * Alternatively, this software may be distributed under the terms of the
  28   27   * GNU General Public License ("GPL") version 2 as published by the Free
  29   28   * Software Foundation.
  30   29   *
  31   30   * NO WARRANTY
  32   31   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33   32   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34   33   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  35   34   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  36   35   * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37   36   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38   37   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39   38   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40   39   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  41   40   * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  42   41   * POSSIBILITY OF SUCH DAMAGES.
  43   42   */
  44   43  
  45   44  #define __EXOPARG3_C__
  46   45  
  47   46  #include "acpi.h"
  48   47  #include "accommon.h"
  49   48  #include "acinterp.h"
  50   49  #include "acparser.h"
  51   50  #include "amlcode.h"
  52   51  
  53   52  
  54   53  #define _COMPONENT          ACPI_EXECUTER
  55   54          ACPI_MODULE_NAME    ("exoparg3")
  56   55  
  57   56  
  58   57  /*!
  59   58   * Naming convention for AML interpreter execution routines.
  60   59   *
  61   60   * The routines that begin execution of AML opcodes are named with a common
  62   61   * convention based upon the number of arguments, the number of target operands,
  63   62   * and whether or not a value is returned:
  64   63   *
  65   64   *      AcpiExOpcode_xA_yT_zR
  66   65   *
  67   66   * Where:
  68   67   *
  69   68   * xA - ARGUMENTS:    The number of arguments (input operands) that are
  70   69   *                    required for this opcode type (1 through 6 args).
  71   70   * yT - TARGETS:      The number of targets (output operands) that are required
  72   71   *                    for this opcode type (0, 1, or 2 targets).
  73   72   * zR - RETURN VALUE: Indicates whether this opcode type returns a value
  74   73   *                    as the function return (0 or 1).
  75   74   *
  76   75   * The AcpiExOpcode* functions are called via the Dispatcher component with
  77   76   * fully resolved operands.
  78   77  !*/
  79   78  
  80   79  
  81   80  /*******************************************************************************
  82   81   *
  83   82   * FUNCTION:    AcpiExOpcode_3A_0T_0R
  84   83   *
  85   84   * PARAMETERS:  WalkState           - Current walk state
  86   85   *
  87   86   * RETURN:      Status
  88   87   *
  89   88   * DESCRIPTION: Execute Triadic operator (3 operands)
  90   89   *
  91   90   ******************************************************************************/
  92   91  
  93   92  ACPI_STATUS
  94   93  AcpiExOpcode_3A_0T_0R (
  95   94      ACPI_WALK_STATE         *WalkState)
  96   95  {
  97   96      ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
  98   97      ACPI_SIGNAL_FATAL_INFO  *Fatal;
  99   98      ACPI_STATUS             Status = AE_OK;
 100   99  
 101  100  
 102  101      ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
 103  102          AcpiPsGetOpcodeName (WalkState->Opcode));
 104  103  
 105  104  
 106  105      switch (WalkState->Opcode)
 107  106      {
 108  107      case AML_FATAL_OP:          /* Fatal (FatalType  FatalCode  FatalArg) */
 109  108  
 110  109          ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 111  110              "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
 112  111              (UINT32) Operand[0]->Integer.Value,
 113  112              (UINT32) Operand[1]->Integer.Value,
 114  113              (UINT32) Operand[2]->Integer.Value));
 115  114  
 116  115          Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO));
 117  116          if (Fatal)
 118  117          {
 119  118              Fatal->Type     = (UINT32) Operand[0]->Integer.Value;
 120  119              Fatal->Code     = (UINT32) Operand[1]->Integer.Value;
 121  120              Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
 122  121          }
  
    | ↓ open down ↓ | 103 lines elided | ↑ open up ↑ | 
 123  122  
 124  123          /* Always signal the OS! */
 125  124  
 126  125          Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal);
 127  126  
 128  127          /* Might return while OS is shutting down, just continue */
 129  128  
 130  129          ACPI_FREE (Fatal);
 131  130          break;
 132  131  
 133      -
 134  132      default:
 135  133  
 136  134          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 137  135              WalkState->Opcode));
 138  136          Status = AE_AML_BAD_OPCODE;
 139  137          goto Cleanup;
 140  138      }
 141  139  
 142  140  
 143  141  Cleanup:
 144  142  
 145  143      return_ACPI_STATUS (Status);
 146  144  }
 147  145  
 148  146  
 149  147  /*******************************************************************************
 150  148   *
 151  149   * FUNCTION:    AcpiExOpcode_3A_1T_1R
 152  150   *
 153  151   * PARAMETERS:  WalkState           - Current walk state
 154  152   *
 155  153   * RETURN:      Status
 156  154   *
 157  155   * DESCRIPTION: Execute Triadic operator (3 operands)
 158  156   *
 159  157   ******************************************************************************/
 160  158  
 161  159  ACPI_STATUS
 162  160  AcpiExOpcode_3A_1T_1R (
 163  161      ACPI_WALK_STATE         *WalkState)
 164  162  {
 165  163      ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 166  164      ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
 167  165      char                    *Buffer = NULL;
 168  166      ACPI_STATUS             Status = AE_OK;
 169  167      UINT64                  Index;
  
    | ↓ open down ↓ | 26 lines elided | ↑ open up ↑ | 
 170  168      ACPI_SIZE               Length;
 171  169  
 172  170  
 173  171      ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
 174  172          AcpiPsGetOpcodeName (WalkState->Opcode));
 175  173  
 176  174  
 177  175      switch (WalkState->Opcode)
 178  176      {
 179  177      case AML_MID_OP:    /* Mid (Source[0], Index[1], Length[2], Result[3]) */
 180      -
 181  178          /*
 182      -         * Create the return object.  The Source operand is guaranteed to be
      179 +         * Create the return object. The Source operand is guaranteed to be
 183  180           * either a String or a Buffer, so just use its type.
 184  181           */
 185  182          ReturnDesc = AcpiUtCreateInternalObject (
 186  183                          (Operand[0])->Common.Type);
 187  184          if (!ReturnDesc)
 188  185          {
 189  186              Status = AE_NO_MEMORY;
 190  187              goto Cleanup;
 191  188          }
 192  189  
 193  190          /* Get the Integer values from the objects */
 194  191  
 195  192          Index = Operand[1]->Integer.Value;
 196  193          Length = (ACPI_SIZE) Operand[2]->Integer.Value;
 197  194  
 198  195          /*
 199  196           * If the index is beyond the length of the String/Buffer, or if the
 200  197           * requested length is zero, return a zero-length String/Buffer
 201  198           */
 202  199          if (Index >= Operand[0]->String.Length)
 203  200          {
 204  201              Length = 0;
 205  202          }
 206  203  
 207  204          /* Truncate request if larger than the actual String/Buffer */
 208  205  
 209  206          else if ((Index + Length) > Operand[0]->String.Length)
 210  207          {
 211  208              Length = (ACPI_SIZE) Operand[0]->String.Length -
 212  209                          (ACPI_SIZE) Index;
 213  210          }
 214  211  
 215  212          /* Strings always have a sub-pointer, not so for buffers */
 216  213  
 217  214          switch ((Operand[0])->Common.Type)
 218  215          {
 219  216          case ACPI_TYPE_STRING:
 220  217  
 221  218              /* Always allocate a new buffer for the String */
 222  219  
 223  220              Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
 224  221              if (!Buffer)
 225  222              {
 226  223                  Status = AE_NO_MEMORY;
 227  224                  goto Cleanup;
 228  225              }
 229  226              break;
 230  227  
 231  228          case ACPI_TYPE_BUFFER:
 232  229  
 233  230              /* If the requested length is zero, don't allocate a buffer */
 234  231  
 235  232              if (Length > 0)
 236  233              {
 237  234                  /* Allocate a new buffer for the Buffer */
 238  235  
 239  236                  Buffer = ACPI_ALLOCATE_ZEROED (Length);
 240  237                  if (!Buffer)
 241  238                  {
 242  239                      Status = AE_NO_MEMORY;
 243  240                      goto Cleanup;
 244  241                  }
 245  242              }
 246  243              break;
 247  244  
 248  245          default:                        /* Should not happen */
 249  246  
 250  247              Status = AE_AML_OPERAND_TYPE;
 251  248              goto Cleanup;
 252  249          }
 253  250  
 254  251          if (Buffer)
 255  252          {
 256  253              /* We have a buffer, copy the portion requested */
 257  254  
 258  255              ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index,
 259  256                           Length);
 260  257          }
 261  258  
  
    | ↓ open down ↓ | 69 lines elided | ↑ open up ↑ | 
 262  259          /* Set the length of the new String/Buffer */
 263  260  
 264  261          ReturnDesc->String.Pointer = Buffer;
 265  262          ReturnDesc->String.Length = (UINT32) Length;
 266  263  
 267  264          /* Mark buffer initialized */
 268  265  
 269  266          ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
 270  267          break;
 271  268  
 272      -
 273  269      default:
 274  270  
 275  271          ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 276  272              WalkState->Opcode));
 277  273          Status = AE_AML_BAD_OPCODE;
 278  274          goto Cleanup;
 279  275      }
 280  276  
 281  277      /* Store the result in the target */
 282  278  
 283  279      Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
 284  280  
 285  281  Cleanup:
 286  282  
 287  283      /* Delete return object on error */
 288  284  
 289  285      if (ACPI_FAILURE (Status) || WalkState->ResultObj)
 290  286      {
 291  287          AcpiUtRemoveReference (ReturnDesc);
 292  288          WalkState->ResultObj = NULL;
  
    | ↓ open down ↓ | 10 lines elided | ↑ open up ↑ | 
 293  289      }
 294  290  
 295  291      /* Set the return object and exit */
 296  292  
 297  293      else
 298  294      {
 299  295          WalkState->ResultObj = ReturnDesc;
 300  296      }
 301  297      return_ACPI_STATUS (Status);
 302  298  }
 303      -
 304      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX