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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/namespace/nsxfname.c
          +++ new/usr/src/common/acpica/components/namespace/nsxfname.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: nsxfname - Public interfaces to the ACPI subsystem
   4    4   *                         ACPI Namespace oriented interfaces
   5    5   *
   6    6   *****************************************************************************/
   7    7  
   8    8  /*
   9      - * Copyright (C) 2000 - 2011, Intel Corp.
        9 + * Copyright (C) 2000 - 2014, Intel Corp.
  10   10   * All rights reserved.
  11   11   *
  12   12   * Redistribution and use in source and binary forms, with or without
  13   13   * modification, are permitted provided that the following conditions
  14   14   * are met:
  15   15   * 1. Redistributions of source code must retain the above copyright
  16   16   *    notice, this list of conditions, and the following disclaimer,
  17   17   *    without modification.
  18   18   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19   19   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 16 lines elided ↑ open up ↑
  36   36   * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37   37   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38   38   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39   39   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40   40   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  41   41   * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  42   42   * POSSIBILITY OF SUCH DAMAGES.
  43   43   */
  44   44  
  45   45  #define __NSXFNAME_C__
       46 +#define EXPORT_ACPI_INTERFACES
  46   47  
  47   48  #include "acpi.h"
  48   49  #include "accommon.h"
  49   50  #include "acnamesp.h"
  50   51  #include "acparser.h"
  51   52  #include "amlcode.h"
  52   53  
  53   54  
  54   55  #define _COMPONENT          ACPI_NAMESPACE
  55   56          ACPI_MODULE_NAME    ("nsxfname")
  56   57  
  57   58  /* Local prototypes */
  58   59  
  59   60  static char *
  60   61  AcpiNsCopyDeviceId (
  61      -    ACPI_DEVICE_ID          *Dest,
  62      -    ACPI_DEVICE_ID          *Source,
       62 +    ACPI_PNP_DEVICE_ID      *Dest,
       63 +    ACPI_PNP_DEVICE_ID      *Source,
  63   64      char                    *StringArea);
  64   65  
  65   66  
  66   67  /******************************************************************************
  67   68   *
  68   69   * FUNCTION:    AcpiGetHandle
  69   70   *
  70   71   * PARAMETERS:  Parent          - Object to search under (search scope).
  71   72   *              Pathname        - Pointer to an asciiz string containing the
  72   73   *                                name
  73   74   *              RetHandle       - Where the return handle is returned
  74   75   *
  75   76   * RETURN:      Status
  76   77   *
  77   78   * DESCRIPTION: This routine will search for a caller specified name in the
  78      - *              name space.  The caller can restrict the search region by
  79      - *              specifying a non NULL parent.  The parent value is itself a
       79 + *              name space. The caller can restrict the search region by
       80 + *              specifying a non NULL parent. The parent value is itself a
  80   81   *              namespace handle.
  81   82   *
  82   83   ******************************************************************************/
  83   84  
  84   85  ACPI_STATUS
  85   86  AcpiGetHandle (
  86   87      ACPI_HANDLE             Parent,
  87   88      ACPI_STRING             Pathname,
  88   89      ACPI_HANDLE             *RetHandle)
  89   90  {
↓ open down ↓ 23 lines elided ↑ open up ↑
 113  114          }
 114  115      }
 115  116  
 116  117      /*
 117  118       * Valid cases are:
 118  119       * 1) Fully qualified pathname
 119  120       * 2) Parent + Relative pathname
 120  121       *
 121  122       * Error for <null Parent + relative path>
 122  123       */
 123      -    if (AcpiNsValidRootPrefix (Pathname[0]))
      124 +    if (ACPI_IS_ROOT_PREFIX (Pathname[0]))
 124  125      {
 125  126          /* Pathname is fully qualified (starts with '\') */
 126  127  
 127  128          /* Special case for root-only, since we can't search for it */
 128  129  
 129  130          if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH))
 130  131          {
 131  132              *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode);
 132  133              return (AE_OK);
 133  134          }
↓ open down ↓ 23 lines elided ↑ open up ↑
 157  158   *
 158  159   * FUNCTION:    AcpiGetName
 159  160   *
 160  161   * PARAMETERS:  Handle          - Handle to be converted to a pathname
 161  162   *              NameType        - Full pathname or single segment
 162  163   *              Buffer          - Buffer for returned path
 163  164   *
 164  165   * RETURN:      Pointer to a string containing the fully qualified Name.
 165  166   *
 166  167   * DESCRIPTION: This routine returns the fully qualified name associated with
 167      - *              the Handle parameter.  This and the AcpiPathnameToHandle are
      168 + *              the Handle parameter. This and the AcpiPathnameToHandle are
 168  169   *              complementary functions.
 169  170   *
 170  171   ******************************************************************************/
 171  172  
 172  173  ACPI_STATUS
 173  174  AcpiGetName (
 174  175      ACPI_HANDLE             Handle,
 175  176      UINT32                  NameType,
 176  177      ACPI_BUFFER             *Buffer)
 177  178  {
 178  179      ACPI_STATUS             Status;
 179  180      ACPI_NAMESPACE_NODE     *Node;
      181 +    char                    *NodeName;
 180  182  
 181  183  
 182  184      /* Parameter validation */
 183  185  
 184  186      if (NameType > ACPI_NAME_TYPE_MAX)
 185  187      {
 186  188          return (AE_BAD_PARAMETER);
 187  189      }
 188  190  
 189  191      Status = AcpiUtValidateBuffer (Buffer);
↓ open down ↓ 30 lines elided ↑ open up ↑
 220  222      /* Validate/Allocate/Clear caller buffer */
 221  223  
 222  224      Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH);
 223  225      if (ACPI_FAILURE (Status))
 224  226      {
 225  227          goto UnlockAndExit;
 226  228      }
 227  229  
 228  230      /* Just copy the ACPI name from the Node and zero terminate it */
 229  231  
 230      -    ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node),
 231      -                ACPI_NAME_SIZE);
      232 +    NodeName = AcpiUtGetNodeName (Node);
      233 +    ACPI_MOVE_NAME (Buffer->Pointer, NodeName);
 232  234      ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
 233  235      Status = AE_OK;
 234  236  
 235  237  
 236  238  UnlockAndExit:
 237  239  
 238  240      (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
 239  241      return (Status);
 240  242  }
 241  243  
 242  244  ACPI_EXPORT_SYMBOL (AcpiGetName)
 243  245  
 244  246  
 245  247  /******************************************************************************
 246  248   *
 247  249   * FUNCTION:    AcpiNsCopyDeviceId
 248  250   *
 249      - * PARAMETERS:  Dest                - Pointer to the destination DEVICE_ID
 250      - *              Source              - Pointer to the source DEVICE_ID
      251 + * PARAMETERS:  Dest                - Pointer to the destination PNP_DEVICE_ID
      252 + *              Source              - Pointer to the source PNP_DEVICE_ID
 251  253   *              StringArea          - Pointer to where to copy the dest string
 252  254   *
 253  255   * RETURN:      Pointer to the next string area
 254  256   *
 255      - * DESCRIPTION: Copy a single DEVICE_ID, including the string data.
      257 + * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data.
 256  258   *
 257  259   ******************************************************************************/
 258  260  
 259  261  static char *
 260  262  AcpiNsCopyDeviceId (
 261      -    ACPI_DEVICE_ID          *Dest,
 262      -    ACPI_DEVICE_ID          *Source,
      263 +    ACPI_PNP_DEVICE_ID      *Dest,
      264 +    ACPI_PNP_DEVICE_ID      *Source,
 263  265      char                    *StringArea)
 264  266  {
 265      -    /* Create the destination DEVICE_ID */
 266  267  
      268 +    /* Create the destination PNP_DEVICE_ID */
      269 +
 267  270      Dest->String = StringArea;
 268  271      Dest->Length = Source->Length;
 269  272  
 270  273      /* Copy actual string and return a pointer to the next string area */
 271  274  
 272  275      ACPI_MEMCPY (StringArea, Source->String, Source->Length);
 273  276      return (StringArea + Source->Length);
 274  277  }
 275  278  
 276  279  
↓ open down ↓ 3 lines elided ↑ open up ↑
 280  283   *
 281  284   * PARAMETERS:  Handle              - Object Handle
 282  285   *              ReturnBuffer        - Where the info is returned
 283  286   *
 284  287   * RETURN:      Status
 285  288   *
 286  289   * DESCRIPTION: Returns information about an object as gleaned from the
 287  290   *              namespace node and possibly by running several standard
 288  291   *              control methods (Such as in the case of a device.)
 289  292   *
 290      - * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
 291      - * _ADR, _SxW, and _SxD methods.
      293 + * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB,
      294 + * _STA, _ADR, _SxW, and _SxD methods.
 292  295   *
 293  296   * Note: Allocates the return buffer, must be freed by the caller.
 294  297   *
 295  298   ******************************************************************************/
 296  299  
 297  300  ACPI_STATUS
 298  301  AcpiGetObjectInfo (
 299  302      ACPI_HANDLE             Handle,
 300  303      ACPI_DEVICE_INFO        **ReturnBuffer)
 301  304  {
 302  305      ACPI_NAMESPACE_NODE     *Node;
 303  306      ACPI_DEVICE_INFO        *Info;
 304      -    ACPI_DEVICE_ID_LIST     *CidList = NULL;
 305      -    ACPI_DEVICE_ID          *Hid = NULL;
 306      -    ACPI_DEVICE_ID          *Uid = NULL;
      307 +    ACPI_PNP_DEVICE_ID_LIST *CidList = NULL;
      308 +    ACPI_PNP_DEVICE_ID      *Hid = NULL;
      309 +    ACPI_PNP_DEVICE_ID      *Uid = NULL;
      310 +    ACPI_PNP_DEVICE_ID      *Sub = NULL;
 307  311      char                    *NextIdString;
 308  312      ACPI_OBJECT_TYPE        Type;
 309  313      ACPI_NAME               Name;
 310  314      UINT8                   ParamCount= 0;
 311  315      UINT8                   Valid = 0;
 312  316      UINT32                  InfoSize;
 313  317      UINT32                  i;
 314  318      ACPI_STATUS             Status;
 315  319  
 316  320  
 317  321      /* Parameter validation */
 318  322  
 319  323      if (!Handle || !ReturnBuffer)
 320  324      {
 321  325          return (AE_BAD_PARAMETER);
 322  326      }
 323  327  
 324  328      Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
 325  329      if (ACPI_FAILURE (Status))
 326  330      {
 327      -        goto Cleanup;
      331 +        return (Status);
 328  332      }
 329  333  
 330  334      Node = AcpiNsValidateHandle (Handle);
 331  335      if (!Node)
 332  336      {
 333  337          (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
 334  338          return (AE_BAD_PARAMETER);
 335  339      }
 336  340  
 337  341      /* Get the namespace node data while the namespace is locked */
↓ open down ↓ 11 lines elided ↑ open up ↑
 349  353      if (ACPI_FAILURE (Status))
 350  354      {
 351  355          return (Status);
 352  356      }
 353  357  
 354  358      if ((Type == ACPI_TYPE_DEVICE) ||
 355  359          (Type == ACPI_TYPE_PROCESSOR))
 356  360      {
 357  361          /*
 358  362           * Get extra info for ACPI Device/Processor objects only:
 359      -         * Run the Device _HID, _UID, and _CID methods.
      363 +         * Run the Device _HID, _UID, _SUB, and _CID methods.
 360  364           *
 361  365           * Note: none of these methods are required, so they may or may
 362  366           * not be present for this device. The Info->Valid bitfield is used
 363  367           * to indicate which methods were found and run successfully.
 364  368           */
 365  369  
 366  370          /* Execute the Device._HID method */
 367  371  
 368  372          Status = AcpiUtExecute_HID (Node, &Hid);
 369  373          if (ACPI_SUCCESS (Status))
↓ open down ↓ 4 lines elided ↑ open up ↑
 374  378  
 375  379          /* Execute the Device._UID method */
 376  380  
 377  381          Status = AcpiUtExecute_UID (Node, &Uid);
 378  382          if (ACPI_SUCCESS (Status))
 379  383          {
 380  384              InfoSize += Uid->Length;
 381  385              Valid |= ACPI_VALID_UID;
 382  386          }
 383  387  
      388 +        /* Execute the Device._SUB method */
      389 +
      390 +        Status = AcpiUtExecute_SUB (Node, &Sub);
      391 +        if (ACPI_SUCCESS (Status))
      392 +        {
      393 +            InfoSize += Sub->Length;
      394 +            Valid |= ACPI_VALID_SUB;
      395 +        }
      396 +
 384  397          /* Execute the Device._CID method */
 385  398  
 386  399          Status = AcpiUtExecute_CID (Node, &CidList);
 387  400          if (ACPI_SUCCESS (Status))
 388  401          {
 389  402              /* Add size of CID strings and CID pointer array */
 390  403  
 391      -            InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST));
      404 +            InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST));
 392  405              Valid |= ACPI_VALID_CID;
 393  406          }
 394  407      }
 395  408  
 396  409      /*
 397  410       * Now that we have the variable-length data, we can allocate the
 398  411       * return buffer
 399  412       */
 400  413      Info = ACPI_ALLOCATE_ZEROED (InfoSize);
 401  414      if (!Info)
↓ open down ↓ 4 lines elided ↑ open up ↑
 406  419  
 407  420      /* Get the fixed-length data */
 408  421  
 409  422      if ((Type == ACPI_TYPE_DEVICE) ||
 410  423          (Type == ACPI_TYPE_PROCESSOR))
 411  424      {
 412  425          /*
 413  426           * Get extra info for ACPI Device/Processor objects only:
 414  427           * Run the _STA, _ADR and, SxW, and _SxD methods.
 415  428           *
 416      -         * Note: none of these methods are required, so they may or may
      429 +         * Notes: none of these methods are required, so they may or may
 417  430           * not be present for this device. The Info->Valid bitfield is used
 418  431           * to indicate which methods were found and run successfully.
      432 +         *
      433 +         * For _STA, if the method does not exist, then (as per the ACPI
      434 +         * specification), the returned CurrentStatus flags will indicate
      435 +         * that the device is present/functional/enabled. Otherwise, the
      436 +         * CurrentStatus flags reflect the value returned from _STA.
 419  437           */
 420  438  
 421  439          /* Execute the Device._STA method */
 422  440  
 423  441          Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus);
 424  442          if (ACPI_SUCCESS (Status))
 425  443          {
 426  444              Valid |= ACPI_VALID_STA;
 427  445          }
 428  446  
↓ open down ↓ 27 lines elided ↑ open up ↑
 456  474          }
 457  475      }
 458  476  
 459  477      /*
 460  478       * Create a pointer to the string area of the return buffer.
 461  479       * Point to the end of the base ACPI_DEVICE_INFO structure.
 462  480       */
 463  481      NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids);
 464  482      if (CidList)
 465  483      {
 466      -        /* Point past the CID DEVICE_ID array */
      484 +        /* Point past the CID PNP_DEVICE_ID array */
 467  485  
 468      -        NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID));
      486 +        NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_PNP_DEVICE_ID));
 469  487      }
 470  488  
 471  489      /*
 472      -     * Copy the HID, UID, and CIDs to the return buffer. The variable-length
 473      -     * strings are copied to the reserved area at the end of the buffer.
      490 +     * Copy the HID, UID, SUB, and CIDs to the return buffer.
      491 +     * The variable-length strings are copied to the reserved area
      492 +     * at the end of the buffer.
 474  493       *
 475  494       * For HID and CID, check if the ID is a PCI Root Bridge.
 476  495       */
 477  496      if (Hid)
 478  497      {
 479  498          NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId,
 480  499              Hid, NextIdString);
 481  500  
 482  501          if (AcpiUtIsPciRootBridge (Hid->String))
 483  502          {
 484  503              Info->Flags |= ACPI_PCI_ROOT_BRIDGE;
 485  504          }
 486  505      }
 487  506  
 488  507      if (Uid)
 489  508      {
 490  509          NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId,
 491  510              Uid, NextIdString);
 492  511      }
 493  512  
      513 +    if (Sub)
      514 +    {
      515 +        NextIdString = AcpiNsCopyDeviceId (&Info->SubsystemId,
      516 +            Sub, NextIdString);
      517 +    }
      518 +
 494  519      if (CidList)
 495  520      {
 496  521          Info->CompatibleIdList.Count = CidList->Count;
 497  522          Info->CompatibleIdList.ListSize = CidList->ListSize;
 498  523  
 499  524          /* Copy each CID */
 500  525  
 501  526          for (i = 0; i < CidList->Count; i++)
 502  527          {
 503  528              NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i],
↓ open down ↓ 20 lines elided ↑ open up ↑
 524  549  
 525  550  Cleanup:
 526  551      if (Hid)
 527  552      {
 528  553          ACPI_FREE (Hid);
 529  554      }
 530  555      if (Uid)
 531  556      {
 532  557          ACPI_FREE (Uid);
 533  558      }
      559 +    if (Sub)
      560 +    {
      561 +        ACPI_FREE (Sub);
      562 +    }
 534  563      if (CidList)
 535  564      {
 536  565          ACPI_FREE (CidList);
 537  566      }
 538  567      return (Status);
 539  568  }
 540  569  
 541  570  ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo)
 542  571  
 543  572  
↓ open down ↓ 159 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX