Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/utilities/utids.c
          +++ new/usr/src/common/acpica/components/utilities/utids.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: utids - support for device IDs - HID, UID, CID
   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 ↓ 47 lines elided ↑ open up ↑
  66   66   *              Integer or a String. A string is always returned. An EISAID
  67   67   *              is converted to a string.
  68   68   *
  69   69   *              NOTE: Internal function, no parameter validation
  70   70   *
  71   71   ******************************************************************************/
  72   72  
  73   73  ACPI_STATUS
  74   74  AcpiUtExecute_HID (
  75   75      ACPI_NAMESPACE_NODE     *DeviceNode,
  76      -    ACPI_DEVICE_ID          **ReturnId)
       76 +    ACPI_PNP_DEVICE_ID      **ReturnId)
  77   77  {
  78   78      ACPI_OPERAND_OBJECT     *ObjDesc;
  79      -    ACPI_DEVICE_ID          *Hid;
       79 +    ACPI_PNP_DEVICE_ID      *Hid;
  80   80      UINT32                  Length;
  81   81      ACPI_STATUS             Status;
  82   82  
  83   83  
  84   84      ACPI_FUNCTION_TRACE (UtExecute_HID);
  85   85  
  86   86  
  87   87      Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
  88   88                  ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
  89   89      if (ACPI_FAILURE (Status))
↓ open down ↓ 7 lines elided ↑ open up ↑
  97   97      {
  98   98          Length = ACPI_EISAID_STRING_SIZE;
  99   99      }
 100  100      else
 101  101      {
 102  102          Length = ObjDesc->String.Length + 1;
 103  103      }
 104  104  
 105  105      /* Allocate a buffer for the HID */
 106  106  
 107      -    Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
      107 +    Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
 108  108      if (!Hid)
 109  109      {
 110  110          Status = AE_NO_MEMORY;
 111  111          goto Cleanup;
 112  112      }
 113  113  
 114      -    /* Area for the string starts after DEVICE_ID struct */
      114 +    /* Area for the string starts after PNP_DEVICE_ID struct */
 115  115  
 116      -    Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID));
      116 +    Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_PNP_DEVICE_ID));
 117  117  
 118  118      /* Convert EISAID to a string or simply copy existing string */
 119  119  
 120  120      if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
 121  121      {
 122  122          AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value);
 123  123      }
 124  124      else
 125  125      {
 126  126          ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer);
↓ open down ↓ 7 lines elided ↑ open up ↑
 134  134  
 135  135      /* On exit, we must delete the return object */
 136  136  
 137  137      AcpiUtRemoveReference (ObjDesc);
 138  138      return_ACPI_STATUS (Status);
 139  139  }
 140  140  
 141  141  
 142  142  /*******************************************************************************
 143  143   *
      144 + * FUNCTION:    AcpiUtExecute_SUB
      145 + *
      146 + * PARAMETERS:  DeviceNode          - Node for the device
      147 + *              ReturnId            - Where the _SUB is returned
      148 + *
      149 + * RETURN:      Status
      150 + *
      151 + * DESCRIPTION: Executes the _SUB control method that returns the subsystem
      152 + *              ID of the device. The _SUB value is always a string containing
      153 + *              either a valid PNP or ACPI ID.
      154 + *
      155 + *              NOTE: Internal function, no parameter validation
      156 + *
      157 + ******************************************************************************/
      158 +
      159 +ACPI_STATUS
      160 +AcpiUtExecute_SUB (
      161 +    ACPI_NAMESPACE_NODE     *DeviceNode,
      162 +    ACPI_PNP_DEVICE_ID      **ReturnId)
      163 +{
      164 +    ACPI_OPERAND_OBJECT     *ObjDesc;
      165 +    ACPI_PNP_DEVICE_ID      *Sub;
      166 +    UINT32                  Length;
      167 +    ACPI_STATUS             Status;
      168 +
      169 +
      170 +    ACPI_FUNCTION_TRACE (UtExecute_SUB);
      171 +
      172 +
      173 +    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__SUB,
      174 +                ACPI_BTYPE_STRING, &ObjDesc);
      175 +    if (ACPI_FAILURE (Status))
      176 +    {
      177 +        return_ACPI_STATUS (Status);
      178 +    }
      179 +
      180 +    /* Get the size of the String to be returned, includes null terminator */
      181 +
      182 +    Length = ObjDesc->String.Length + 1;
      183 +
      184 +    /* Allocate a buffer for the SUB */
      185 +
      186 +    Sub = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
      187 +    if (!Sub)
      188 +    {
      189 +        Status = AE_NO_MEMORY;
      190 +        goto Cleanup;
      191 +    }
      192 +
      193 +    /* Area for the string starts after PNP_DEVICE_ID struct */
      194 +
      195 +    Sub->String = ACPI_ADD_PTR (char, Sub, sizeof (ACPI_PNP_DEVICE_ID));
      196 +
      197 +    /* Simply copy existing string */
      198 +
      199 +    ACPI_STRCPY (Sub->String, ObjDesc->String.Pointer);
      200 +    Sub->Length = Length;
      201 +    *ReturnId = Sub;
      202 +
      203 +
      204 +Cleanup:
      205 +
      206 +    /* On exit, we must delete the return object */
      207 +
      208 +    AcpiUtRemoveReference (ObjDesc);
      209 +    return_ACPI_STATUS (Status);
      210 +}
      211 +
      212 +
      213 +/*******************************************************************************
      214 + *
 144  215   * FUNCTION:    AcpiUtExecute_UID
 145  216   *
 146  217   * PARAMETERS:  DeviceNode          - Node for the device
 147  218   *              ReturnId            - Where the string UID is returned
 148  219   *
 149  220   * RETURN:      Status
 150  221   *
 151  222   * DESCRIPTION: Executes the _UID control method that returns the unique
 152  223   *              ID of the device. The UID is either a 64-bit Integer (NOT an
 153  224   *              EISAID) or a string. Always returns a string. A 64-bit integer
 154  225   *              is converted to a decimal string.
 155  226   *
 156  227   *              NOTE: Internal function, no parameter validation
 157  228   *
 158  229   ******************************************************************************/
 159  230  
 160  231  ACPI_STATUS
 161  232  AcpiUtExecute_UID (
 162  233      ACPI_NAMESPACE_NODE     *DeviceNode,
 163      -    ACPI_DEVICE_ID          **ReturnId)
      234 +    ACPI_PNP_DEVICE_ID      **ReturnId)
 164  235  {
 165  236      ACPI_OPERAND_OBJECT     *ObjDesc;
 166      -    ACPI_DEVICE_ID          *Uid;
      237 +    ACPI_PNP_DEVICE_ID      *Uid;
 167  238      UINT32                  Length;
 168  239      ACPI_STATUS             Status;
 169  240  
 170  241  
 171  242      ACPI_FUNCTION_TRACE (UtExecute_UID);
 172  243  
 173  244  
 174  245      Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
 175  246                  ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
 176  247      if (ACPI_FAILURE (Status))
↓ open down ↓ 7 lines elided ↑ open up ↑
 184  255      {
 185  256          Length = ACPI_MAX64_DECIMAL_DIGITS + 1;
 186  257      }
 187  258      else
 188  259      {
 189  260          Length = ObjDesc->String.Length + 1;
 190  261      }
 191  262  
 192  263      /* Allocate a buffer for the UID */
 193  264  
 194      -    Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
      265 +    Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
 195  266      if (!Uid)
 196  267      {
 197  268          Status = AE_NO_MEMORY;
 198  269          goto Cleanup;
 199  270      }
 200  271  
 201      -    /* Area for the string starts after DEVICE_ID struct */
      272 +    /* Area for the string starts after PNP_DEVICE_ID struct */
 202  273  
 203      -    Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID));
      274 +    Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_PNP_DEVICE_ID));
 204  275  
 205  276      /* Convert an Integer to string, or just copy an existing string */
 206  277  
 207  278      if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
 208  279      {
 209  280          AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value);
 210  281      }
 211  282      else
 212  283      {
 213  284          ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer);
↓ open down ↓ 31 lines elided ↑ open up ↑
 245  316   * 1) Integer (32 bit compressed EISA ID) or
 246  317   * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
 247  318   *
 248  319   * The Integer CIDs are converted to string format by this function.
 249  320   *
 250  321   ******************************************************************************/
 251  322  
 252  323  ACPI_STATUS
 253  324  AcpiUtExecute_CID (
 254  325      ACPI_NAMESPACE_NODE     *DeviceNode,
 255      -    ACPI_DEVICE_ID_LIST     **ReturnCidList)
      326 +    ACPI_PNP_DEVICE_ID_LIST **ReturnCidList)
 256  327  {
 257  328      ACPI_OPERAND_OBJECT     **CidObjects;
 258  329      ACPI_OPERAND_OBJECT     *ObjDesc;
 259      -    ACPI_DEVICE_ID_LIST     *CidList;
      330 +    ACPI_PNP_DEVICE_ID_LIST *CidList;
 260  331      char                    *NextIdString;
 261  332      UINT32                  StringAreaSize;
 262  333      UINT32                  Length;
 263  334      UINT32                  CidListSize;
 264  335      ACPI_STATUS             Status;
 265  336      UINT32                  Count;
 266  337      UINT32                  i;
 267  338  
 268  339  
 269  340      ACPI_FUNCTION_TRACE (UtExecute_CID);
↓ open down ↓ 27 lines elided ↑ open up ↑
 297  368      }
 298  369  
 299  370      StringAreaSize = 0;
 300  371      for (i = 0; i < Count; i++)
 301  372      {
 302  373          /* String lengths include null terminator */
 303  374  
 304  375          switch (CidObjects[i]->Common.Type)
 305  376          {
 306  377          case ACPI_TYPE_INTEGER:
      378 +
 307  379              StringAreaSize += ACPI_EISAID_STRING_SIZE;
 308  380              break;
 309  381  
 310  382          case ACPI_TYPE_STRING:
      383 +
 311  384              StringAreaSize += CidObjects[i]->String.Length + 1;
 312  385              break;
 313  386  
 314  387          default:
      388 +
 315  389              Status = AE_TYPE;
 316  390              goto Cleanup;
 317  391          }
 318  392      }
 319  393  
 320  394      /*
 321  395       * Now that we know the length of the CIDs, allocate return buffer:
 322  396       * 1) Size of the base structure +
 323      -     * 2) Size of the CID DEVICE_ID array +
      397 +     * 2) Size of the CID PNP_DEVICE_ID array +
 324  398       * 3) Size of the actual CID strings
 325  399       */
 326      -    CidListSize = sizeof (ACPI_DEVICE_ID_LIST) +
 327      -        ((Count - 1) * sizeof (ACPI_DEVICE_ID)) +
      400 +    CidListSize = sizeof (ACPI_PNP_DEVICE_ID_LIST) +
      401 +        ((Count - 1) * sizeof (ACPI_PNP_DEVICE_ID)) +
 328  402          StringAreaSize;
 329  403  
 330  404      CidList = ACPI_ALLOCATE_ZEROED (CidListSize);
 331  405      if (!CidList)
 332  406      {
 333  407          Status = AE_NO_MEMORY;
 334  408          goto Cleanup;
 335  409      }
 336  410  
 337      -    /* Area for CID strings starts after the CID DEVICE_ID array */
      411 +    /* Area for CID strings starts after the CID PNP_DEVICE_ID array */
 338  412  
 339  413      NextIdString = ACPI_CAST_PTR (char, CidList->Ids) +
 340      -        ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID));
      414 +        ((ACPI_SIZE) Count * sizeof (ACPI_PNP_DEVICE_ID));
 341  415  
 342  416      /* Copy/convert the CIDs to the return buffer */
 343  417  
 344  418      for (i = 0; i < Count; i++)
 345  419      {
 346  420          if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER)
 347  421          {
 348  422              /* Convert the Integer (EISAID) CID to a string */
 349  423  
 350  424              AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value);
↓ open down ↓ 19 lines elided ↑ open up ↑
 370  444      *ReturnCidList = CidList;
 371  445  
 372  446  
 373  447  Cleanup:
 374  448  
 375  449      /* On exit, we must delete the _CID return object */
 376  450  
 377  451      AcpiUtRemoveReference (ObjDesc);
 378  452      return_ACPI_STATUS (Status);
 379  453  }
 380      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX