Home | History | Annotate | Line # | Download | only in events
evsci.c revision 1.1.1.4
      1      1.1    jruoho /*******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: evsci - System Control Interrupt configuration and
      4      1.1    jruoho  *                      legacy to ACPI mode state transition functions
      5      1.1    jruoho  *
      6      1.1    jruoho  ******************************************************************************/
      7      1.1    jruoho 
      8  1.1.1.2    jruoho /*
      9  1.1.1.4  christos  * Copyright (C) 2000 - 2014, Intel Corp.
     10      1.1    jruoho  * All rights reserved.
     11      1.1    jruoho  *
     12  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     13  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     14  1.1.1.2    jruoho  * are met:
     15  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     16  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     17  1.1.1.2    jruoho  *    without modification.
     18  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     19  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     20  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     21  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     22  1.1.1.2    jruoho  *    binary redistribution.
     23  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     24  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     25  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     26  1.1.1.2    jruoho  *
     27  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     28  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     29  1.1.1.2    jruoho  * Software Foundation.
     30  1.1.1.2    jruoho  *
     31  1.1.1.2    jruoho  * NO WARRANTY
     32  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     33  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     34  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     35  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     36  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     40  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     41  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     42  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     43  1.1.1.2    jruoho  */
     44      1.1    jruoho 
     45      1.1    jruoho #include "acpi.h"
     46      1.1    jruoho #include "accommon.h"
     47      1.1    jruoho #include "acevents.h"
     48      1.1    jruoho 
     49      1.1    jruoho 
     50      1.1    jruoho #define _COMPONENT          ACPI_EVENTS
     51      1.1    jruoho         ACPI_MODULE_NAME    ("evsci")
     52      1.1    jruoho 
     53  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
     54  1.1.1.3  christos 
     55      1.1    jruoho /* Local prototypes */
     56      1.1    jruoho 
     57      1.1    jruoho static UINT32 ACPI_SYSTEM_XFACE
     58      1.1    jruoho AcpiEvSciXruptHandler (
     59      1.1    jruoho     void                    *Context);
     60      1.1    jruoho 
     61      1.1    jruoho 
     62      1.1    jruoho /*******************************************************************************
     63      1.1    jruoho  *
     64  1.1.1.3  christos  * FUNCTION:    AcpiEvSciDispatch
     65  1.1.1.3  christos  *
     66  1.1.1.3  christos  * PARAMETERS:  None
     67  1.1.1.3  christos  *
     68  1.1.1.3  christos  * RETURN:      Status code indicates whether interrupt was handled.
     69  1.1.1.3  christos  *
     70  1.1.1.3  christos  * DESCRIPTION: Dispatch the SCI to all host-installed SCI handlers.
     71  1.1.1.3  christos  *
     72  1.1.1.3  christos  ******************************************************************************/
     73  1.1.1.3  christos 
     74  1.1.1.3  christos UINT32
     75  1.1.1.3  christos AcpiEvSciDispatch (
     76  1.1.1.3  christos     void)
     77  1.1.1.3  christos {
     78  1.1.1.3  christos     ACPI_SCI_HANDLER_INFO   *SciHandler;
     79  1.1.1.3  christos     ACPI_CPU_FLAGS          Flags;
     80  1.1.1.3  christos     UINT32                  IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
     81  1.1.1.3  christos 
     82  1.1.1.3  christos 
     83  1.1.1.3  christos     ACPI_FUNCTION_NAME (EvSciDispatch);
     84  1.1.1.3  christos 
     85  1.1.1.3  christos 
     86  1.1.1.3  christos     /* Are there any host-installed SCI handlers? */
     87  1.1.1.3  christos 
     88  1.1.1.3  christos     if (!AcpiGbl_SciHandlerList)
     89  1.1.1.3  christos     {
     90  1.1.1.3  christos         return (IntStatus);
     91  1.1.1.3  christos     }
     92  1.1.1.3  christos 
     93  1.1.1.3  christos     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
     94  1.1.1.3  christos 
     95  1.1.1.3  christos     /* Invoke all host-installed SCI handlers */
     96  1.1.1.3  christos 
     97  1.1.1.3  christos     SciHandler = AcpiGbl_SciHandlerList;
     98  1.1.1.3  christos     while (SciHandler)
     99  1.1.1.3  christos     {
    100  1.1.1.3  christos         /* Invoke the installed handler (at interrupt level) */
    101  1.1.1.3  christos 
    102  1.1.1.3  christos         IntStatus |= SciHandler->Address (
    103  1.1.1.3  christos             SciHandler->Context);
    104  1.1.1.3  christos 
    105  1.1.1.3  christos         SciHandler = SciHandler->Next;
    106  1.1.1.3  christos     }
    107  1.1.1.3  christos 
    108  1.1.1.3  christos     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
    109  1.1.1.3  christos     return (IntStatus);
    110  1.1.1.3  christos }
    111  1.1.1.3  christos 
    112  1.1.1.3  christos 
    113  1.1.1.3  christos /*******************************************************************************
    114  1.1.1.3  christos  *
    115      1.1    jruoho  * FUNCTION:    AcpiEvSciXruptHandler
    116      1.1    jruoho  *
    117      1.1    jruoho  * PARAMETERS:  Context   - Calling Context
    118      1.1    jruoho  *
    119      1.1    jruoho  * RETURN:      Status code indicates whether interrupt was handled.
    120      1.1    jruoho  *
    121      1.1    jruoho  * DESCRIPTION: Interrupt handler that will figure out what function or
    122      1.1    jruoho  *              control method to call to deal with a SCI.
    123      1.1    jruoho  *
    124      1.1    jruoho  ******************************************************************************/
    125      1.1    jruoho 
    126      1.1    jruoho static UINT32 ACPI_SYSTEM_XFACE
    127      1.1    jruoho AcpiEvSciXruptHandler (
    128      1.1    jruoho     void                    *Context)
    129      1.1    jruoho {
    130      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptList = Context;
    131      1.1    jruoho     UINT32                  InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
    132      1.1    jruoho 
    133      1.1    jruoho 
    134      1.1    jruoho     ACPI_FUNCTION_TRACE (EvSciXruptHandler);
    135      1.1    jruoho 
    136      1.1    jruoho 
    137      1.1    jruoho     /*
    138  1.1.1.4  christos      * We are guaranteed by the ACPICA initialization/shutdown code that
    139      1.1    jruoho      * if this interrupt handler is installed, ACPI is enabled.
    140      1.1    jruoho      */
    141      1.1    jruoho 
    142      1.1    jruoho     /*
    143      1.1    jruoho      * Fixed Events:
    144      1.1    jruoho      * Check for and dispatch any Fixed Events that have occurred
    145      1.1    jruoho      */
    146      1.1    jruoho     InterruptHandled |= AcpiEvFixedEventDetect ();
    147      1.1    jruoho 
    148      1.1    jruoho     /*
    149      1.1    jruoho      * General Purpose Events:
    150      1.1    jruoho      * Check for and dispatch any GPEs that have occurred
    151      1.1    jruoho      */
    152      1.1    jruoho     InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
    153      1.1    jruoho 
    154  1.1.1.3  christos     /* Invoke all host-installed SCI handlers */
    155  1.1.1.3  christos 
    156  1.1.1.3  christos     InterruptHandled |= AcpiEvSciDispatch ();
    157  1.1.1.3  christos 
    158      1.1    jruoho     AcpiSciCount++;
    159      1.1    jruoho     return_UINT32 (InterruptHandled);
    160      1.1    jruoho }
    161      1.1    jruoho 
    162      1.1    jruoho 
    163      1.1    jruoho /*******************************************************************************
    164      1.1    jruoho  *
    165      1.1    jruoho  * FUNCTION:    AcpiEvGpeXruptHandler
    166      1.1    jruoho  *
    167      1.1    jruoho  * PARAMETERS:  Context   - Calling Context
    168      1.1    jruoho  *
    169      1.1    jruoho  * RETURN:      Status code indicates whether interrupt was handled.
    170      1.1    jruoho  *
    171      1.1    jruoho  * DESCRIPTION: Handler for GPE Block Device interrupts
    172      1.1    jruoho  *
    173      1.1    jruoho  ******************************************************************************/
    174      1.1    jruoho 
    175      1.1    jruoho UINT32 ACPI_SYSTEM_XFACE
    176      1.1    jruoho AcpiEvGpeXruptHandler (
    177      1.1    jruoho     void                    *Context)
    178      1.1    jruoho {
    179      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptList = Context;
    180      1.1    jruoho     UINT32                  InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
    181      1.1    jruoho 
    182      1.1    jruoho 
    183      1.1    jruoho     ACPI_FUNCTION_TRACE (EvGpeXruptHandler);
    184      1.1    jruoho 
    185      1.1    jruoho 
    186      1.1    jruoho     /*
    187  1.1.1.3  christos      * We are guaranteed by the ACPICA initialization/shutdown code that
    188      1.1    jruoho      * if this interrupt handler is installed, ACPI is enabled.
    189      1.1    jruoho      */
    190      1.1    jruoho 
    191      1.1    jruoho     /* GPEs: Check for and dispatch any GPEs that have occurred */
    192      1.1    jruoho 
    193      1.1    jruoho     InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
    194      1.1    jruoho     return_UINT32 (InterruptHandled);
    195      1.1    jruoho }
    196      1.1    jruoho 
    197      1.1    jruoho 
    198      1.1    jruoho /******************************************************************************
    199      1.1    jruoho  *
    200      1.1    jruoho  * FUNCTION:    AcpiEvInstallSciHandler
    201      1.1    jruoho  *
    202      1.1    jruoho  * PARAMETERS:  none
    203      1.1    jruoho  *
    204      1.1    jruoho  * RETURN:      Status
    205      1.1    jruoho  *
    206      1.1    jruoho  * DESCRIPTION: Installs SCI handler.
    207      1.1    jruoho  *
    208      1.1    jruoho  ******************************************************************************/
    209      1.1    jruoho 
    210      1.1    jruoho UINT32
    211      1.1    jruoho AcpiEvInstallSciHandler (
    212      1.1    jruoho     void)
    213      1.1    jruoho {
    214      1.1    jruoho     UINT32                  Status = AE_OK;
    215      1.1    jruoho 
    216      1.1    jruoho 
    217      1.1    jruoho     ACPI_FUNCTION_TRACE (EvInstallSciHandler);
    218      1.1    jruoho 
    219      1.1    jruoho 
    220      1.1    jruoho     Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
    221      1.1    jruoho                 AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead);
    222      1.1    jruoho     return_ACPI_STATUS (Status);
    223      1.1    jruoho }
    224      1.1    jruoho 
    225      1.1    jruoho 
    226      1.1    jruoho /******************************************************************************
    227      1.1    jruoho  *
    228  1.1.1.3  christos  * FUNCTION:    AcpiEvRemoveAllSciHandlers
    229      1.1    jruoho  *
    230      1.1    jruoho  * PARAMETERS:  none
    231      1.1    jruoho  *
    232  1.1.1.3  christos  * RETURN:      AE_OK if handler uninstalled, AE_ERROR if handler was not
    233      1.1    jruoho  *              installed to begin with
    234      1.1    jruoho  *
    235      1.1    jruoho  * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
    236  1.1.1.3  christos  *              taken. Remove all host-installed SCI handlers.
    237      1.1    jruoho  *
    238      1.1    jruoho  * Note:  It doesn't seem important to disable all events or set the event
    239      1.1    jruoho  *        enable registers to their original values. The OS should disable
    240      1.1    jruoho  *        the SCI interrupt level when the handler is removed, so no more
    241      1.1    jruoho  *        events will come in.
    242      1.1    jruoho  *
    243      1.1    jruoho  ******************************************************************************/
    244      1.1    jruoho 
    245      1.1    jruoho ACPI_STATUS
    246  1.1.1.3  christos AcpiEvRemoveAllSciHandlers (
    247      1.1    jruoho     void)
    248      1.1    jruoho {
    249  1.1.1.3  christos     ACPI_SCI_HANDLER_INFO   *SciHandler;
    250  1.1.1.3  christos     ACPI_CPU_FLAGS          Flags;
    251      1.1    jruoho     ACPI_STATUS             Status;
    252      1.1    jruoho 
    253      1.1    jruoho 
    254  1.1.1.3  christos     ACPI_FUNCTION_TRACE (EvRemoveAllSciHandlers);
    255      1.1    jruoho 
    256      1.1    jruoho 
    257      1.1    jruoho     /* Just let the OS remove the handler and disable the level */
    258      1.1    jruoho 
    259      1.1    jruoho     Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
    260      1.1    jruoho                 AcpiEvSciXruptHandler);
    261      1.1    jruoho 
    262  1.1.1.3  christos     if (!AcpiGbl_SciHandlerList)
    263  1.1.1.3  christos     {
    264  1.1.1.3  christos         return (Status);
    265  1.1.1.3  christos     }
    266  1.1.1.3  christos 
    267  1.1.1.3  christos     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
    268  1.1.1.3  christos 
    269  1.1.1.3  christos     /* Free all host-installed SCI handlers */
    270  1.1.1.3  christos 
    271  1.1.1.3  christos     while (AcpiGbl_SciHandlerList)
    272  1.1.1.3  christos     {
    273  1.1.1.3  christos         SciHandler = AcpiGbl_SciHandlerList;
    274  1.1.1.3  christos         AcpiGbl_SciHandlerList = SciHandler->Next;
    275  1.1.1.3  christos         ACPI_FREE (SciHandler);
    276  1.1.1.3  christos     }
    277  1.1.1.3  christos 
    278  1.1.1.3  christos     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
    279      1.1    jruoho     return_ACPI_STATUS (Status);
    280      1.1    jruoho }
    281      1.1    jruoho 
    282  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    283