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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/resources/rsxface.c
          +++ new/usr/src/common/acpica/components/resources/rsxface.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: rsxface - Public interfaces to the resource manager
   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 ↓ 17 lines elided ↑ open up ↑
  36   36   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37   37   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38   38   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39   39   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40   40   * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41   41   * POSSIBILITY OF SUCH DAMAGES.
  42   42   */
  43   43  
  44   44  
  45   45  #define __RSXFACE_C__
       46 +#define EXPORT_ACPI_INTERFACES
  46   47  
  47   48  #include "acpi.h"
  48   49  #include "accommon.h"
  49   50  #include "acresrc.h"
  50   51  #include "acnamesp.h"
  51   52  
  52   53  #define _COMPONENT          ACPI_RESOURCES
  53   54          ACPI_MODULE_NAME    ("rsxface")
  54   55  
  55   56  /* Local macros for 16,32-bit to 64-bit conversion */
↓ open down ↓ 288 lines elided ↑ open up ↑
 344  345          return_ACPI_STATUS (Status);
 345  346      }
 346  347  
 347  348      Status = AcpiRsSetSrsMethodData (Node, InBuffer);
 348  349      return_ACPI_STATUS (Status);
 349  350  }
 350  351  
 351  352  ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
 352  353  
 353  354  
      355 +/*******************************************************************************
      356 + *
      357 + * FUNCTION:    AcpiGetEventResources
      358 + *
      359 + * PARAMETERS:  DeviceHandle    - Handle to the device object for the
      360 + *                                device we are getting resources
      361 + *              InBuffer        - Pointer to a buffer containing the
      362 + *                                resources to be set for the device
      363 + *
      364 + * RETURN:      Status
      365 + *
      366 + * DESCRIPTION: This function is called to get the event resources for a
      367 + *              specific device. The caller must first acquire a handle for
      368 + *              the desired device. The resource data is passed to the routine
      369 + *              the buffer pointed to by the InBuffer variable. Uses the
      370 + *              _AEI method.
      371 + *
      372 + ******************************************************************************/
      373 +
      374 +ACPI_STATUS
      375 +AcpiGetEventResources (
      376 +    ACPI_HANDLE             DeviceHandle,
      377 +    ACPI_BUFFER             *RetBuffer)
      378 +{
      379 +    ACPI_STATUS             Status;
      380 +    ACPI_NAMESPACE_NODE     *Node;
      381 +
      382 +
      383 +    ACPI_FUNCTION_TRACE (AcpiGetEventResources);
      384 +
      385 +
      386 +    /* Validate parameters then dispatch to internal routine */
      387 +
      388 +    Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
      389 +    if (ACPI_FAILURE (Status))
      390 +    {
      391 +        return_ACPI_STATUS (Status);
      392 +    }
      393 +
      394 +    Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
      395 +    return_ACPI_STATUS (Status);
      396 +}
      397 +
      398 +ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
      399 +
      400 +
 354  401  /******************************************************************************
 355  402   *
 356  403   * FUNCTION:    AcpiResourceToAddress64
 357  404   *
 358  405   * PARAMETERS:  Resource        - Pointer to a resource
 359  406   *              Out             - Pointer to the users's return buffer
 360  407   *                                (a struct acpi_resource_address64)
 361  408   *
 362  409   * RETURN:      Status
 363  410   *
↓ open down ↓ 35 lines elided ↑ open up ↑
 399  446          break;
 400  447  
 401  448      case ACPI_RESOURCE_TYPE_ADDRESS64:
 402  449  
 403  450          /* Simple copy for 64 bit source */
 404  451  
 405  452          ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
 406  453          break;
 407  454  
 408  455      default:
      456 +
 409  457          return (AE_BAD_PARAMETER);
 410  458      }
 411  459  
 412  460      return (AE_OK);
 413  461  }
 414  462  
 415  463  ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
 416  464  
 417  465  
 418  466  /*******************************************************************************
↓ open down ↓ 2 lines elided ↑ open up ↑
 421  469   *
 422  470   * PARAMETERS:  DeviceHandle    - Handle for the parent device object
 423  471   *              Name            - Method name for the parent resource
 424  472   *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
 425  473   *              Uuid            - Pointer to the UUID to be matched.
 426  474   *                                includes both subtype and 16-byte UUID
 427  475   *              RetBuffer       - Where the vendor resource is returned
 428  476   *
 429  477   * RETURN:      Status
 430  478   *
 431      - * DESCRIPTION: Walk a resource template for the specified evice to find a
      479 + * DESCRIPTION: Walk a resource template for the specified device to find a
 432  480   *              vendor-defined resource that matches the supplied UUID and
 433  481   *              UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
 434  482   *
 435  483   ******************************************************************************/
 436  484  
 437  485  ACPI_STATUS
 438  486  AcpiGetVendorResource (
 439  487      ACPI_HANDLE             DeviceHandle,
 440  488      char                    *Name,
 441  489      ACPI_VENDOR_UUID        *Uuid,
↓ open down ↓ 91 lines elided ↑ open up ↑
 533  581  
 534  582      /* Found the desired descriptor, terminate resource walk */
 535  583  
 536  584      Info->Status = AE_OK;
 537  585      return (AE_CTRL_TERMINATE);
 538  586  }
 539  587  
 540  588  
 541  589  /*******************************************************************************
 542  590   *
 543      - * FUNCTION:    AcpiWalkResources
      591 + * FUNCTION:    AcpiWalkResourceBuffer
 544  592   *
 545      - * PARAMETERS:  DeviceHandle    - Handle to the device object for the
 546      - *                                device we are querying
 547      - *              Name            - Method name of the resources we want
 548      - *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
      593 + * PARAMETERS:  Buffer          - Formatted buffer returned by one of the
      594 + *                                various Get*Resource functions
 549  595   *              UserFunction    - Called for each resource
 550  596   *              Context         - Passed to UserFunction
 551  597   *
 552  598   * RETURN:      Status
 553  599   *
 554      - * DESCRIPTION: Retrieves the current or possible resource list for the
 555      - *              specified device. The UserFunction is called once for
 556      - *              each resource in the list.
      600 + * DESCRIPTION: Walks the input resource template. The UserFunction is called
      601 + *              once for each resource in the list.
 557  602   *
 558  603   ******************************************************************************/
 559  604  
 560  605  ACPI_STATUS
 561      -AcpiWalkResources (
 562      -    ACPI_HANDLE                 DeviceHandle,
 563      -    char                        *Name,
      606 +AcpiWalkResourceBuffer (
      607 +    ACPI_BUFFER                 *Buffer,
 564  608      ACPI_WALK_RESOURCE_CALLBACK UserFunction,
 565  609      void                        *Context)
 566  610  {
 567      -    ACPI_STATUS                 Status;
 568      -    ACPI_BUFFER                 Buffer;
      611 +    ACPI_STATUS                 Status = AE_OK;
 569  612      ACPI_RESOURCE               *Resource;
 570  613      ACPI_RESOURCE               *ResourceEnd;
 571  614  
 572  615  
 573      -    ACPI_FUNCTION_TRACE (AcpiWalkResources);
      616 +    ACPI_FUNCTION_TRACE (AcpiWalkResourceBuffer);
 574  617  
 575  618  
 576  619      /* Parameter validation */
 577  620  
 578      -    if (!DeviceHandle || !UserFunction || !Name ||
 579      -        (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
 580      -         !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS)))
      621 +    if (!Buffer || !Buffer->Pointer || !UserFunction)
 581  622      {
 582  623          return_ACPI_STATUS (AE_BAD_PARAMETER);
 583  624      }
 584  625  
 585      -    /* Get the _CRS or _PRS resource list */
      626 +    /* Buffer contains the resource list and length */
 586  627  
 587      -    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
 588      -    Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
 589      -    if (ACPI_FAILURE (Status))
 590      -    {
 591      -        return_ACPI_STATUS (Status);
 592      -    }
      628 +    Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer->Pointer);
      629 +    ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer->Pointer, Buffer->Length);
 593  630  
 594      -    /* Buffer now contains the resource list */
 595      -
 596      -    Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
 597      -    ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
 598      -
 599  631      /* Walk the resource list until the EndTag is found (or buffer end) */
 600  632  
 601  633      while (Resource < ResourceEnd)
 602  634      {
 603      -        /* Sanity check the resource */
      635 +        /* Sanity check the resource type */
 604  636  
 605  637          if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
 606  638          {
 607  639              Status = AE_AML_INVALID_RESOURCE_TYPE;
 608  640              break;
 609  641          }
 610  642  
      643 +        /* Sanity check the length. It must not be zero, or we loop forever */
      644 +
      645 +        if (!Resource->Length)
      646 +        {
      647 +            return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
      648 +        }
      649 +
 611  650          /* Invoke the user function, abort on any error returned */
 612  651  
 613  652          Status = UserFunction (Resource, Context);
 614  653          if (ACPI_FAILURE (Status))
 615  654          {
 616  655              if (Status == AE_CTRL_TERMINATE)
 617  656              {
 618  657                  /* This is an OK termination by the user function */
 619  658  
 620  659                  Status = AE_OK;
↓ open down ↓ 3 lines elided ↑ open up ↑
 624  663  
 625  664          /* EndTag indicates end-of-list */
 626  665  
 627  666          if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
 628  667          {
 629  668              break;
 630  669          }
 631  670  
 632  671          /* Get the next resource descriptor */
 633  672  
 634      -        Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
      673 +        Resource = ACPI_NEXT_RESOURCE (Resource);
 635  674      }
 636  675  
      676 +    return_ACPI_STATUS (Status);
      677 +}
      678 +
      679 +ACPI_EXPORT_SYMBOL (AcpiWalkResourceBuffer)
      680 +
      681 +
      682 +/*******************************************************************************
      683 + *
      684 + * FUNCTION:    AcpiWalkResources
      685 + *
      686 + * PARAMETERS:  DeviceHandle    - Handle to the device object for the
      687 + *                                device we are querying
      688 + *              Name            - Method name of the resources we want.
      689 + *                                (METHOD_NAME__CRS, METHOD_NAME__PRS, or
      690 + *                                METHOD_NAME__AEI)
      691 + *              UserFunction    - Called for each resource
      692 + *              Context         - Passed to UserFunction
      693 + *
      694 + * RETURN:      Status
      695 + *
      696 + * DESCRIPTION: Retrieves the current or possible resource list for the
      697 + *              specified device. The UserFunction is called once for
      698 + *              each resource in the list.
      699 + *
      700 + ******************************************************************************/
      701 +
      702 +ACPI_STATUS
      703 +AcpiWalkResources (
      704 +    ACPI_HANDLE                 DeviceHandle,
      705 +    char                        *Name,
      706 +    ACPI_WALK_RESOURCE_CALLBACK UserFunction,
      707 +    void                        *Context)
      708 +{
      709 +    ACPI_STATUS                 Status;
      710 +    ACPI_BUFFER                 Buffer;
      711 +
      712 +
      713 +    ACPI_FUNCTION_TRACE (AcpiWalkResources);
      714 +
      715 +
      716 +    /* Parameter validation */
      717 +
      718 +    if (!DeviceHandle || !UserFunction || !Name ||
      719 +        (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
      720 +         !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS) &&
      721 +         !ACPI_COMPARE_NAME (Name, METHOD_NAME__AEI)))
      722 +    {
      723 +        return_ACPI_STATUS (AE_BAD_PARAMETER);
      724 +    }
      725 +
      726 +    /* Get the _CRS/_PRS/_AEI resource list */
      727 +
      728 +    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
      729 +    Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
      730 +    if (ACPI_FAILURE (Status))
      731 +    {
      732 +        return_ACPI_STATUS (Status);
      733 +    }
      734 +
      735 +    /* Walk the resource list and cleanup */
      736 +
      737 +    Status = AcpiWalkResourceBuffer (&Buffer, UserFunction, Context);
 637  738      ACPI_FREE (Buffer.Pointer);
 638  739      return_ACPI_STATUS (Status);
 639  740  }
 640  741  
 641  742  ACPI_EXPORT_SYMBOL (AcpiWalkResources)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX