ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

evxfgpe.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
00004  *
00005  *****************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 
00117 #define __EVXFGPE_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acevents.h"
00122 #include "acnamesp.h"
00123 
00124 #define _COMPONENT          ACPI_EVENTS
00125         ACPI_MODULE_NAME    ("evxfgpe")
00126 
00127 
00128 /*******************************************************************************
00129  *
00130  * FUNCTION:    AcpiUpdateAllGpes
00131  *
00132  * PARAMETERS:  None
00133  *
00134  * RETURN:      Status
00135  *
00136  * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
00137  *              associated _Lxx or _Exx methods and are not pointed to by any
00138  *              device _PRW methods (this indicates that these GPEs are
00139  *              generally intended for system or device wakeup. Such GPEs
00140  *              have to be enabled directly when the devices whose _PRW
00141  *              methods point to them are set up for wakeup signaling.)
00142  *
00143  * NOTE: Should be called after any GPEs are added to the system. Primarily,
00144  * after the system _PRW methods have been run, but also after a GPE Block
00145  * Device has been added or if any new GPE methods have been added via a
00146  * dynamic table load.
00147  *
00148  ******************************************************************************/
00149 
00150 ACPI_STATUS
00151 AcpiUpdateAllGpes (
00152     void)
00153 {
00154     ACPI_STATUS             Status;
00155 
00156 
00157     ACPI_FUNCTION_TRACE (AcpiUpdateGpes);
00158 
00159 
00160     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
00161     if (ACPI_FAILURE (Status))
00162     {
00163         return_ACPI_STATUS (Status);
00164     }
00165 
00166     if (AcpiGbl_AllGpesInitialized)
00167     {
00168         goto UnlockAndExit;
00169     }
00170 
00171     Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL);
00172     if (ACPI_SUCCESS (Status))
00173     {
00174         AcpiGbl_AllGpesInitialized = TRUE;
00175     }
00176 
00177 UnlockAndExit:
00178     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
00179     return_ACPI_STATUS (Status);
00180 }
00181 
00182 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes)
00183 
00184 
00185 /*******************************************************************************
00186  *
00187  * FUNCTION:    AcpiEnableGpe
00188  *
00189  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00190  *              GpeNumber           - GPE level within the GPE block
00191  *
00192  * RETURN:      Status
00193  *
00194  * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
00195  *              hardware-enabled.
00196  *
00197  ******************************************************************************/
00198 
00199 ACPI_STATUS
00200 AcpiEnableGpe (
00201     ACPI_HANDLE             GpeDevice,
00202     UINT32                  GpeNumber)
00203 {
00204     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00205     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00206     ACPI_CPU_FLAGS          Flags;
00207 
00208 
00209     ACPI_FUNCTION_TRACE (AcpiEnableGpe);
00210 
00211 
00212     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00213 
00214     /* Ensure that we have a valid GPE number */
00215 
00216     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00217     if (GpeEventInfo)
00218     {
00219         Status = AcpiEvAddGpeReference (GpeEventInfo);
00220     }
00221 
00222     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00223     return_ACPI_STATUS (Status);
00224 }
00225 
00226 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
00227 
00228 
00229 /*******************************************************************************
00230  *
00231  * FUNCTION:    AcpiDisableGpe
00232  *
00233  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00234  *              GpeNumber           - GPE level within the GPE block
00235  *
00236  * RETURN:      Status
00237  *
00238  * DESCRIPTION: Remove a reference to a GPE. When the last reference is
00239  *              removed, only then is the GPE disabled (for runtime GPEs), or
00240  *              the GPE mask bit disabled (for wake GPEs)
00241  *
00242  ******************************************************************************/
00243 
00244 ACPI_STATUS
00245 AcpiDisableGpe (
00246     ACPI_HANDLE             GpeDevice,
00247     UINT32                  GpeNumber)
00248 {
00249     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00250     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00251     ACPI_CPU_FLAGS          Flags;
00252 
00253 
00254     ACPI_FUNCTION_TRACE (AcpiDisableGpe);
00255 
00256 
00257     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00258 
00259     /* Ensure that we have a valid GPE number */
00260 
00261     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00262     if (GpeEventInfo)
00263     {
00264         Status = AcpiEvRemoveGpeReference (GpeEventInfo);
00265     }
00266 
00267     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00268     return_ACPI_STATUS (Status);
00269 }
00270 
00271 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
00272 
00273 
00274 /*******************************************************************************
00275  *
00276  * FUNCTION:    AcpiSetGpe
00277  *
00278  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00279  *              GpeNumber           - GPE level within the GPE block
00280  *              Action              - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
00281  *
00282  * RETURN:      Status
00283  *
00284  * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
00285  *              the reference count mechanism used in the AcpiEnableGpe and
00286  *              AcpiDisableGpe interfaces -- and should be used with care.
00287  *
00288  * Note: Typically used to disable a runtime GPE for short period of time,
00289  * then re-enable it, without disturbing the existing reference counts. This
00290  * is useful, for example, in the Embedded Controller (EC) driver.
00291  *
00292  ******************************************************************************/
00293 
00294 ACPI_STATUS
00295 AcpiSetGpe (
00296     ACPI_HANDLE             GpeDevice,
00297     UINT32                  GpeNumber,
00298     UINT8                   Action)
00299 {
00300     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00301     ACPI_STATUS             Status;
00302     ACPI_CPU_FLAGS          Flags;
00303 
00304 
00305     ACPI_FUNCTION_TRACE (AcpiSetGpe);
00306 
00307 
00308     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00309 
00310     /* Ensure that we have a valid GPE number */
00311 
00312     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00313     if (!GpeEventInfo)
00314     {
00315         Status = AE_BAD_PARAMETER;
00316         goto UnlockAndExit;
00317     }
00318 
00319     /* Perform the action */
00320 
00321     switch (Action)
00322     {
00323     case ACPI_GPE_ENABLE:
00324         Status = AcpiEvEnableGpe (GpeEventInfo);
00325         break;
00326 
00327     case ACPI_GPE_DISABLE:
00328         Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
00329         break;
00330 
00331     default:
00332         Status = AE_BAD_PARAMETER;
00333         break;
00334     }
00335 
00336 UnlockAndExit:
00337     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00338     return_ACPI_STATUS (Status);
00339 }
00340 
00341 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
00342 
00343 
00344 /*******************************************************************************
00345  *
00346  * FUNCTION:    AcpiSetupGpeForWake
00347  *
00348  * PARAMETERS:  WakeDevice          - Device associated with the GPE (via _PRW)
00349  *              GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00350  *              GpeNumber           - GPE level within the GPE block
00351  *
00352  * RETURN:      Status
00353  *
00354  * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
00355  *              interface is intended to be used as the host executes the
00356  *              _PRW methods (Power Resources for Wake) in the system tables.
00357  *              Each _PRW appears under a Device Object (The WakeDevice), and
00358  *              contains the info for the wake GPE associated with the
00359  *              WakeDevice.
00360  *
00361  ******************************************************************************/
00362 
00363 ACPI_STATUS
00364 AcpiSetupGpeForWake (
00365     ACPI_HANDLE             WakeDevice,
00366     ACPI_HANDLE             GpeDevice,
00367     UINT32                  GpeNumber)
00368 {
00369     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00370     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00371     ACPI_NAMESPACE_NODE     *DeviceNode;
00372     ACPI_CPU_FLAGS          Flags;
00373 
00374 
00375     ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
00376 
00377 
00378     /* Parameter Validation */
00379 
00380     if (!WakeDevice)
00381     {
00382         /*
00383          * By forcing WakeDevice to be valid, we automatically enable the
00384          * implicit notify feature on all hosts.
00385          */
00386         return_ACPI_STATUS (AE_BAD_PARAMETER);
00387     }
00388 
00389     /* Handle root object case */
00390 
00391     if (WakeDevice == ACPI_ROOT_OBJECT)
00392     {
00393         DeviceNode = AcpiGbl_RootNode;
00394     }
00395     else
00396     {
00397         DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
00398     }
00399 
00400     /* Validate WakeDevice is of type Device */
00401 
00402     if (DeviceNode->Type != ACPI_TYPE_DEVICE)
00403     {
00404         return_ACPI_STATUS (AE_BAD_PARAMETER);
00405     }
00406 
00407     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00408 
00409     /* Ensure that we have a valid GPE number */
00410 
00411     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00412     if (GpeEventInfo)
00413     {
00414         /*
00415          * If there is no method or handler for this GPE, then the
00416          * WakeDevice will be notified whenever this GPE fires (aka
00417          * "implicit notify") Note: The GPE is assumed to be
00418          * level-triggered (for windows compatibility).
00419          */
00420         if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
00421                 ACPI_GPE_DISPATCH_NONE)
00422         {
00423             GpeEventInfo->Flags =
00424                 (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
00425             GpeEventInfo->Dispatch.DeviceNode = DeviceNode;
00426         }
00427 
00428         GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
00429         Status = AE_OK;
00430     }
00431 
00432     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00433     return_ACPI_STATUS (Status);
00434 }
00435 
00436 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
00437 
00438 
00439 /*******************************************************************************
00440  *
00441  * FUNCTION:    AcpiSetGpeWakeMask
00442  *
00443  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00444  *              GpeNumber           - GPE level within the GPE block
00445  *              Action              - Enable or Disable
00446  *
00447  * RETURN:      Status
00448  *
00449  * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
00450  *              already be marked as a WAKE GPE.
00451  *
00452  ******************************************************************************/
00453 
00454 ACPI_STATUS
00455 AcpiSetGpeWakeMask (
00456     ACPI_HANDLE             GpeDevice,
00457     UINT32                  GpeNumber,
00458     UINT8                   Action)
00459 {
00460     ACPI_STATUS             Status = AE_OK;
00461     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00462     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
00463     ACPI_CPU_FLAGS          Flags;
00464     UINT32                  RegisterBit;
00465 
00466 
00467     ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask);
00468 
00469 
00470     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00471 
00472     /*
00473      * Ensure that we have a valid GPE number and that this GPE is in
00474      * fact a wake GPE
00475      */
00476     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00477     if (!GpeEventInfo)
00478     {
00479         Status = AE_BAD_PARAMETER;
00480         goto UnlockAndExit;
00481     }
00482 
00483     if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
00484     {
00485         Status = AE_TYPE;
00486         goto UnlockAndExit;
00487     }
00488 
00489     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
00490     if (!GpeRegisterInfo)
00491     {
00492         Status = AE_NOT_EXIST;
00493         goto UnlockAndExit;
00494     }
00495 
00496     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
00497 
00498     /* Perform the action */
00499 
00500     switch (Action)
00501     {
00502     case ACPI_GPE_ENABLE:
00503         ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
00504         break;
00505 
00506     case ACPI_GPE_DISABLE:
00507         ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
00508         break;
00509 
00510     default:
00511         ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
00512         Status = AE_BAD_PARAMETER;
00513         break;
00514     }
00515 
00516 UnlockAndExit:
00517     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00518     return_ACPI_STATUS (Status);
00519 }
00520 
00521 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask)
00522 
00523 
00524 /*******************************************************************************
00525  *
00526  * FUNCTION:    AcpiClearGpe
00527  *
00528  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00529  *              GpeNumber           - GPE level within the GPE block
00530  *
00531  * RETURN:      Status
00532  *
00533  * DESCRIPTION: Clear an ACPI event (general purpose)
00534  *
00535  ******************************************************************************/
00536 
00537 ACPI_STATUS
00538 AcpiClearGpe (
00539     ACPI_HANDLE             GpeDevice,
00540     UINT32                  GpeNumber)
00541 {
00542     ACPI_STATUS             Status = AE_OK;
00543     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00544     ACPI_CPU_FLAGS          Flags;
00545 
00546 
00547     ACPI_FUNCTION_TRACE (AcpiClearGpe);
00548 
00549 
00550     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00551 
00552     /* Ensure that we have a valid GPE number */
00553 
00554     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00555     if (!GpeEventInfo)
00556     {
00557         Status = AE_BAD_PARAMETER;
00558         goto UnlockAndExit;
00559     }
00560 
00561     Status = AcpiHwClearGpe (GpeEventInfo);
00562 
00563 UnlockAndExit:
00564     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00565     return_ACPI_STATUS (Status);
00566 }
00567 
00568 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
00569 
00570 
00571 /*******************************************************************************
00572  *
00573  * FUNCTION:    AcpiGetGpeStatus
00574  *
00575  * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
00576  *              GpeNumber           - GPE level within the GPE block
00577  *              EventStatus         - Where the current status of the event
00578  *                                    will be returned
00579  *
00580  * RETURN:      Status
00581  *
00582  * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
00583  *
00584  ******************************************************************************/
00585 
00586 ACPI_STATUS
00587 AcpiGetGpeStatus (
00588     ACPI_HANDLE             GpeDevice,
00589     UINT32                  GpeNumber,
00590     ACPI_EVENT_STATUS       *EventStatus)
00591 {
00592     ACPI_STATUS             Status = AE_OK;
00593     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00594     ACPI_CPU_FLAGS          Flags;
00595 
00596 
00597     ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
00598 
00599 
00600     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00601 
00602     /* Ensure that we have a valid GPE number */
00603 
00604     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00605     if (!GpeEventInfo)
00606     {
00607         Status = AE_BAD_PARAMETER;
00608         goto UnlockAndExit;
00609     }
00610 
00611     /* Obtain status on the requested GPE number */
00612 
00613     Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
00614 
00615 UnlockAndExit:
00616     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00617     return_ACPI_STATUS (Status);
00618 }
00619 
00620 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
00621 
00622 
00623 /*******************************************************************************
00624  *
00625  * FUNCTION:    AcpiFinishGpe
00626  *
00627  * PARAMETERS:  GpeDevice           - Namespace node for the GPE Block
00628  *                                    (NULL for FADT defined GPEs)
00629  *              GpeNumber           - GPE level within the GPE block
00630  *
00631  * RETURN:      Status
00632  *
00633  * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
00634  *              processing. Intended for use by asynchronous host-installed
00635  *              GPE handlers. The GPE is only reenabled if the EnableForRun bit
00636  *              is set in the GPE info.
00637  *
00638  ******************************************************************************/
00639 
00640 ACPI_STATUS
00641 AcpiFinishGpe (
00642     ACPI_HANDLE             GpeDevice,
00643     UINT32                  GpeNumber)
00644 {
00645     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
00646     ACPI_STATUS             Status;
00647     ACPI_CPU_FLAGS          Flags;
00648 
00649 
00650     ACPI_FUNCTION_TRACE (AcpiFinishGpe);
00651 
00652 
00653     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
00654 
00655     /* Ensure that we have a valid GPE number */
00656 
00657     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
00658     if (!GpeEventInfo)
00659     {
00660         Status = AE_BAD_PARAMETER;
00661         goto UnlockAndExit;
00662     }
00663 
00664     Status = AcpiEvFinishGpe (GpeEventInfo);
00665 
00666 UnlockAndExit:
00667     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
00668     return_ACPI_STATUS (Status);
00669 }
00670 
00671 ACPI_EXPORT_SYMBOL (AcpiFinishGpe)
00672 
00673 
00674 /******************************************************************************
00675  *
00676  * FUNCTION:    AcpiDisableAllGpes
00677  *
00678  * PARAMETERS:  None
00679  *
00680  * RETURN:      Status
00681  *
00682  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
00683  *
00684  ******************************************************************************/
00685 
00686 ACPI_STATUS
00687 AcpiDisableAllGpes (
00688     void)
00689 {
00690     ACPI_STATUS             Status;
00691 
00692 
00693     ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
00694 
00695 
00696     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
00697     if (ACPI_FAILURE (Status))
00698     {
00699         return_ACPI_STATUS (Status);
00700     }
00701 
00702     Status = AcpiHwDisableAllGpes ();
00703     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
00704 
00705     return_ACPI_STATUS (Status);
00706 }
00707 
00708 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes)
00709 
00710 
00711 /******************************************************************************
00712  *
00713  * FUNCTION:    AcpiEnableAllRuntimeGpes
00714  *
00715  * PARAMETERS:  None
00716  *
00717  * RETURN:      Status
00718  *
00719  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
00720  *
00721  ******************************************************************************/
00722 
00723 ACPI_STATUS
00724 AcpiEnableAllRuntimeGpes (
00725     void)
00726 {
00727     ACPI_STATUS             Status;
00728 
00729 
00730     ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
00731 
00732 
00733     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
00734     if (ACPI_FAILURE (Status))
00735     {
00736         return_ACPI_STATUS (Status);
00737     }
00738 
00739     Status = AcpiHwEnableAllRuntimeGpes ();
00740     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
00741 
00742     return_ACPI_STATUS (Status);
00743 }
00744 
00745 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes)
00746 
00747 
00748 /*******************************************************************************
00749  *
00750  * FUNCTION:    AcpiInstallGpeBlock
00751  *
00752  * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
00753  *              GpeBlockAddress     - Address and SpaceID
00754  *              RegisterCount       - Number of GPE register pairs in the block
00755  *              InterruptNumber     - H/W interrupt for the block
00756  *
00757  * RETURN:      Status
00758  *
00759  * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
00760  *              enabled here.
00761  *
00762  ******************************************************************************/
00763 
00764 ACPI_STATUS
00765 AcpiInstallGpeBlock (
00766     ACPI_HANDLE             GpeDevice,
00767     ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
00768     UINT32                  RegisterCount,
00769     UINT32                  InterruptNumber)
00770 {
00771     ACPI_STATUS             Status;
00772     ACPI_OPERAND_OBJECT     *ObjDesc;
00773     ACPI_NAMESPACE_NODE     *Node;
00774     ACPI_GPE_BLOCK_INFO     *GpeBlock;
00775 
00776 
00777     ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
00778 
00779 
00780     if ((!GpeDevice)       ||
00781         (!GpeBlockAddress) ||
00782         (!RegisterCount))
00783     {
00784         return_ACPI_STATUS (AE_BAD_PARAMETER);
00785     }
00786 
00787     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00788     if (ACPI_FAILURE (Status))
00789     {
00790         return (Status);
00791     }
00792 
00793     Node = AcpiNsValidateHandle (GpeDevice);
00794     if (!Node)
00795     {
00796         Status = AE_BAD_PARAMETER;
00797         goto UnlockAndExit;
00798     }
00799 
00800     /*
00801      * For user-installed GPE Block Devices, the GpeBlockBaseNumber
00802      * is always zero
00803      */
00804     Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
00805                 0, InterruptNumber, &GpeBlock);
00806     if (ACPI_FAILURE (Status))
00807     {
00808         goto UnlockAndExit;
00809     }
00810 
00811     /* Install block in the DeviceObject attached to the node */
00812 
00813     ObjDesc = AcpiNsGetAttachedObject (Node);
00814     if (!ObjDesc)
00815     {
00816         /*
00817          * No object, create a new one (Device nodes do not always have
00818          * an attached object)
00819          */
00820         ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
00821         if (!ObjDesc)
00822         {
00823             Status = AE_NO_MEMORY;
00824             goto UnlockAndExit;
00825         }
00826 
00827         Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
00828 
00829         /* Remove local reference to the object */
00830 
00831         AcpiUtRemoveReference (ObjDesc);
00832         if (ACPI_FAILURE (Status))
00833         {
00834             goto UnlockAndExit;
00835         }
00836     }
00837 
00838     /* Now install the GPE block in the DeviceObject */
00839 
00840     ObjDesc->Device.GpeBlock = GpeBlock;
00841 
00842 
00843 UnlockAndExit:
00844     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00845     return_ACPI_STATUS (Status);
00846 }
00847 
00848 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
00849 
00850 
00851 /*******************************************************************************
00852  *
00853  * FUNCTION:    AcpiRemoveGpeBlock
00854  *
00855  * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
00856  *
00857  * RETURN:      Status
00858  *
00859  * DESCRIPTION: Remove a previously installed block of GPE registers
00860  *
00861  ******************************************************************************/
00862 
00863 ACPI_STATUS
00864 AcpiRemoveGpeBlock (
00865     ACPI_HANDLE             GpeDevice)
00866 {
00867     ACPI_OPERAND_OBJECT     *ObjDesc;
00868     ACPI_STATUS             Status;
00869     ACPI_NAMESPACE_NODE     *Node;
00870 
00871 
00872     ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
00873 
00874 
00875     if (!GpeDevice)
00876     {
00877         return_ACPI_STATUS (AE_BAD_PARAMETER);
00878     }
00879 
00880     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00881     if (ACPI_FAILURE (Status))
00882     {
00883         return (Status);
00884     }
00885 
00886     Node = AcpiNsValidateHandle (GpeDevice);
00887     if (!Node)
00888     {
00889         Status = AE_BAD_PARAMETER;
00890         goto UnlockAndExit;
00891     }
00892 
00893     /* Get the DeviceObject attached to the node */
00894 
00895     ObjDesc = AcpiNsGetAttachedObject (Node);
00896     if (!ObjDesc ||
00897         !ObjDesc->Device.GpeBlock)
00898     {
00899         return_ACPI_STATUS (AE_NULL_OBJECT);
00900     }
00901 
00902     /* Delete the GPE block (but not the DeviceObject) */
00903 
00904     Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
00905     if (ACPI_SUCCESS (Status))
00906     {
00907         ObjDesc->Device.GpeBlock = NULL;
00908     }
00909 
00910 UnlockAndExit:
00911     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00912     return_ACPI_STATUS (Status);
00913 }
00914 
00915 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
00916 
00917 
00918 /*******************************************************************************
00919  *
00920  * FUNCTION:    AcpiGetGpeDevice
00921  *
00922  * PARAMETERS:  Index               - System GPE index (0-CurrentGpeCount)
00923  *              GpeDevice           - Where the parent GPE Device is returned
00924  *
00925  * RETURN:      Status
00926  *
00927  * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
00928  *              gpe device indicates that the gpe number is contained in one of
00929  *              the FADT-defined gpe blocks. Otherwise, the GPE block device.
00930  *
00931  ******************************************************************************/
00932 
00933 ACPI_STATUS
00934 AcpiGetGpeDevice (
00935     UINT32                  Index,
00936     ACPI_HANDLE             *GpeDevice)
00937 {
00938     ACPI_GPE_DEVICE_INFO    Info;
00939     ACPI_STATUS             Status;
00940 
00941 
00942     ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
00943 
00944 
00945     if (!GpeDevice)
00946     {
00947         return_ACPI_STATUS (AE_BAD_PARAMETER);
00948     }
00949 
00950     if (Index >= AcpiCurrentGpeCount)
00951     {
00952         return_ACPI_STATUS (AE_NOT_EXIST);
00953     }
00954 
00955     /* Setup and walk the GPE list */
00956 
00957     Info.Index = Index;
00958     Info.Status = AE_NOT_EXIST;
00959     Info.GpeDevice = NULL;
00960     Info.NextBlockBaseIndex = 0;
00961 
00962     Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
00963     if (ACPI_FAILURE (Status))
00964     {
00965         return_ACPI_STATUS (Status);
00966     }
00967 
00968     *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
00969     return_ACPI_STATUS (Info.Status);
00970 }
00971 
00972 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)

Generated on Sat May 26 2012 04:25:46 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.