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/events/evxfgpe.c
          +++ new/usr/src/common/acpica/components/events/evxfgpe.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2014, 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 __EVXFGPE_C__
       46 +#define EXPORT_ACPI_INTERFACES
  46   47  
  47   48  #include "acpi.h"
  48   49  #include "accommon.h"
  49   50  #include "acevents.h"
  50   51  #include "acnamesp.h"
  51   52  
  52   53  #define _COMPONENT          ACPI_EVENTS
  53   54          ACPI_MODULE_NAME    ("evxfgpe")
  54   55  
  55   56  
       57 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
  56   58  /*******************************************************************************
  57   59   *
  58   60   * FUNCTION:    AcpiUpdateAllGpes
  59   61   *
  60   62   * PARAMETERS:  None
  61   63   *
  62   64   * RETURN:      Status
  63   65   *
  64   66   * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
  65   67   *              associated _Lxx or _Exx methods and are not pointed to by any
↓ open down ↓ 9 lines elided ↑ open up ↑
  75   77   *
  76   78   ******************************************************************************/
  77   79  
  78   80  ACPI_STATUS
  79   81  AcpiUpdateAllGpes (
  80   82      void)
  81   83  {
  82   84      ACPI_STATUS             Status;
  83   85  
  84   86  
  85      -    ACPI_FUNCTION_TRACE (AcpiUpdateGpes);
       87 +    ACPI_FUNCTION_TRACE (AcpiUpdateAllGpes);
  86   88  
  87   89  
  88   90      Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
  89   91      if (ACPI_FAILURE (Status))
  90   92      {
  91   93          return_ACPI_STATUS (Status);
  92   94      }
  93   95  
  94   96      if (AcpiGbl_AllGpesInitialized)
  95   97      {
↓ open down ↓ 146 lines elided ↑ open up ↑
 242  244      {
 243  245          Status = AE_BAD_PARAMETER;
 244  246          goto UnlockAndExit;
 245  247      }
 246  248  
 247  249      /* Perform the action */
 248  250  
 249  251      switch (Action)
 250  252      {
 251  253      case ACPI_GPE_ENABLE:
      254 +
 252  255          Status = AcpiEvEnableGpe (GpeEventInfo);
 253  256          break;
 254  257  
 255  258      case ACPI_GPE_DISABLE:
      259 +
 256  260          Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
 257  261          break;
 258  262  
 259  263      default:
      264 +
 260  265          Status = AE_BAD_PARAMETER;
 261  266          break;
 262  267      }
 263  268  
 264  269  UnlockAndExit:
 265  270      AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
 266  271      return_ACPI_STATUS (Status);
 267  272  }
 268  273  
 269  274  ACPI_EXPORT_SYMBOL (AcpiSetGpe)
↓ open down ↓ 17 lines elided ↑ open up ↑
 287  292   *              WakeDevice.
 288  293   *
 289  294   ******************************************************************************/
 290  295  
 291  296  ACPI_STATUS
 292  297  AcpiSetupGpeForWake (
 293  298      ACPI_HANDLE             WakeDevice,
 294  299      ACPI_HANDLE             GpeDevice,
 295  300      UINT32                  GpeNumber)
 296  301  {
 297      -    ACPI_STATUS             Status = AE_BAD_PARAMETER;
      302 +    ACPI_STATUS             Status;
 298  303      ACPI_GPE_EVENT_INFO     *GpeEventInfo;
 299  304      ACPI_NAMESPACE_NODE     *DeviceNode;
      305 +    ACPI_GPE_NOTIFY_INFO    *Notify;
      306 +    ACPI_GPE_NOTIFY_INFO    *NewNotify;
 300  307      ACPI_CPU_FLAGS          Flags;
 301  308  
 302  309  
 303  310      ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
 304  311  
 305  312  
 306  313      /* Parameter Validation */
 307  314  
 308  315      if (!WakeDevice)
 309  316      {
↓ open down ↓ 15 lines elided ↑ open up ↑
 325  332          DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
 326  333      }
 327  334  
 328  335      /* Validate WakeDevice is of type Device */
 329  336  
 330  337      if (DeviceNode->Type != ACPI_TYPE_DEVICE)
 331  338      {
 332  339          return_ACPI_STATUS (AE_BAD_PARAMETER);
 333  340      }
 334  341  
      342 +    /*
      343 +     * Allocate a new notify object up front, in case it is needed.
      344 +     * Memory allocation while holding a spinlock is a big no-no
      345 +     * on some hosts.
      346 +     */
      347 +    NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
      348 +    if (!NewNotify)
      349 +    {
      350 +        return_ACPI_STATUS (AE_NO_MEMORY);
      351 +    }
      352 +
 335  353      Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
 336  354  
 337  355      /* Ensure that we have a valid GPE number */
 338  356  
 339  357      GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
 340      -    if (GpeEventInfo)
      358 +    if (!GpeEventInfo)
 341  359      {
      360 +        Status = AE_BAD_PARAMETER;
      361 +        goto UnlockAndExit;
      362 +    }
      363 +
      364 +    /*
      365 +     * If there is no method or handler for this GPE, then the
      366 +     * WakeDevice will be notified whenever this GPE fires. This is
      367 +     * known as an "implicit notify". Note: The GPE is assumed to be
      368 +     * level-triggered (for windows compatibility).
      369 +     */
      370 +    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
      371 +            ACPI_GPE_DISPATCH_NONE)
      372 +    {
 342  373          /*
 343      -         * If there is no method or handler for this GPE, then the
 344      -         * WakeDevice will be notified whenever this GPE fires (aka
 345      -         * "implicit notify") Note: The GPE is assumed to be
 346      -         * level-triggered (for windows compatibility).
      374 +         * This is the first device for implicit notify on this GPE.
      375 +         * Just set the flags here, and enter the NOTIFY block below.
 347  376           */
 348      -        if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
 349      -                ACPI_GPE_DISPATCH_NONE)
      377 +        GpeEventInfo->Flags =
      378 +            (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
      379 +    }
      380 +
      381 +    /*
      382 +     * If we already have an implicit notify on this GPE, add
      383 +     * this device to the notify list.
      384 +     */
      385 +    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
      386 +            ACPI_GPE_DISPATCH_NOTIFY)
      387 +    {
      388 +        /* Ensure that the device is not already in the list */
      389 +
      390 +        Notify = GpeEventInfo->Dispatch.NotifyList;
      391 +        while (Notify)
 350  392          {
 351      -            GpeEventInfo->Flags =
 352      -                (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
 353      -            GpeEventInfo->Dispatch.DeviceNode = DeviceNode;
      393 +            if (Notify->DeviceNode == DeviceNode)
      394 +            {
      395 +                Status = AE_ALREADY_EXISTS;
      396 +                goto UnlockAndExit;
      397 +            }
      398 +            Notify = Notify->Next;
 354  399          }
 355  400  
 356      -        GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
 357      -        Status = AE_OK;
      401 +        /* Add this device to the notify list for this GPE */
      402 +
      403 +        NewNotify->DeviceNode = DeviceNode;
      404 +        NewNotify->Next = GpeEventInfo->Dispatch.NotifyList;
      405 +        GpeEventInfo->Dispatch.NotifyList = NewNotify;
      406 +        NewNotify = NULL;
 358  407      }
 359  408  
      409 +    /* Mark the GPE as a possible wake event */
      410 +
      411 +    GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
      412 +    Status = AE_OK;
      413 +
      414 +
      415 +UnlockAndExit:
 360  416      AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
      417 +
      418 +    /* Delete the notify object if it was not used above */
      419 +
      420 +    if (NewNotify)
      421 +    {
      422 +        ACPI_FREE (NewNotify);
      423 +    }
 361  424      return_ACPI_STATUS (Status);
 362  425  }
 363  426  
 364  427  ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
 365  428  
 366  429  
 367  430  /*******************************************************************************
 368  431   *
 369  432   * FUNCTION:    AcpiSetGpeWakeMask
 370  433   *
↓ open down ↓ 43 lines elided ↑ open up ↑
 414  477          goto UnlockAndExit;
 415  478      }
 416  479  
 417  480      GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 418  481      if (!GpeRegisterInfo)
 419  482      {
 420  483          Status = AE_NOT_EXIST;
 421  484          goto UnlockAndExit;
 422  485      }
 423  486  
 424      -    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
      487 +    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
 425  488  
 426  489      /* Perform the action */
 427  490  
 428  491      switch (Action)
 429  492      {
 430  493      case ACPI_GPE_ENABLE:
      494 +
 431  495          ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
 432  496          break;
 433  497  
 434  498      case ACPI_GPE_DISABLE:
      499 +
 435  500          ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
 436  501          break;
 437  502  
 438  503      default:
      504 +
 439  505          ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
 440  506          Status = AE_BAD_PARAMETER;
 441  507          break;
 442  508      }
 443  509  
 444  510  UnlockAndExit:
 445  511      AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
 446  512      return_ACPI_STATUS (Status);
 447  513  }
 448  514  
↓ open down ↓ 259 lines elided ↑ open up ↑
 708  774      if ((!GpeDevice)       ||
 709  775          (!GpeBlockAddress) ||
 710  776          (!RegisterCount))
 711  777      {
 712  778          return_ACPI_STATUS (AE_BAD_PARAMETER);
 713  779      }
 714  780  
 715  781      Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
 716  782      if (ACPI_FAILURE (Status))
 717  783      {
 718      -        return (Status);
      784 +        return_ACPI_STATUS (Status);
 719  785      }
 720  786  
 721  787      Node = AcpiNsValidateHandle (GpeDevice);
 722  788      if (!Node)
 723  789      {
 724  790          Status = AE_BAD_PARAMETER;
 725  791          goto UnlockAndExit;
 726  792      }
 727  793  
      794 +    /* Validate the parent device */
      795 +
      796 +    if (Node->Type != ACPI_TYPE_DEVICE)
      797 +    {
      798 +        Status = AE_TYPE;
      799 +        goto UnlockAndExit;
      800 +    }
      801 +
      802 +    if (Node->Object)
      803 +    {
      804 +        Status = AE_ALREADY_EXISTS;
      805 +        goto UnlockAndExit;
      806 +    }
      807 +
 728  808      /*
 729  809       * For user-installed GPE Block Devices, the GpeBlockBaseNumber
 730  810       * is always zero
 731  811       */
 732  812      Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
 733  813                  0, InterruptNumber, &GpeBlock);
 734  814      if (ACPI_FAILURE (Status))
 735  815      {
 736  816          goto UnlockAndExit;
 737  817      }
↓ open down ↓ 63 lines elided ↑ open up ↑
 801  881  
 802  882  
 803  883      if (!GpeDevice)
 804  884      {
 805  885          return_ACPI_STATUS (AE_BAD_PARAMETER);
 806  886      }
 807  887  
 808  888      Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
 809  889      if (ACPI_FAILURE (Status))
 810  890      {
 811      -        return (Status);
      891 +        return_ACPI_STATUS (Status);
 812  892      }
 813  893  
 814  894      Node = AcpiNsValidateHandle (GpeDevice);
 815  895      if (!Node)
 816  896      {
 817  897          Status = AE_BAD_PARAMETER;
 818  898          goto UnlockAndExit;
 819  899      }
 820  900  
      901 +    /* Validate the parent device */
      902 +
      903 +    if (Node->Type != ACPI_TYPE_DEVICE)
      904 +    {
      905 +        Status = AE_TYPE;
      906 +        goto UnlockAndExit;
      907 +    }
      908 +
 821  909      /* Get the DeviceObject attached to the node */
 822  910  
 823  911      ObjDesc = AcpiNsGetAttachedObject (Node);
 824  912      if (!ObjDesc ||
 825  913          !ObjDesc->Device.GpeBlock)
 826  914      {
 827  915          return_ACPI_STATUS (AE_NULL_OBJECT);
 828  916      }
 829  917  
 830  918      /* Delete the GPE block (but not the DeviceObject) */
↓ open down ↓ 60 lines elided ↑ open up ↑
 891  979      if (ACPI_FAILURE (Status))
 892  980      {
 893  981          return_ACPI_STATUS (Status);
 894  982      }
 895  983  
 896  984      *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
 897  985      return_ACPI_STATUS (Info.Status);
 898  986  }
 899  987  
 900  988  ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
      989 +
      990 +#endif /* !ACPI_REDUCED_HARDWARE */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX