13446Smrj /*******************************************************************************
23446Smrj *
33446Smrj * Module Name: evsci - System Control Interrupt configuration and
43446Smrj * legacy to ACPI mode state transition functions
53446Smrj *
63446Smrj ******************************************************************************/
73446Smrj
83446Smrj /******************************************************************************
93446Smrj *
103446Smrj * 1. Copyright Notice
113446Smrj *
12*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
133446Smrj * All rights reserved.
143446Smrj *
153446Smrj * 2. License
163446Smrj *
173446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj * rights. You may have additional license terms from the party that provided
193446Smrj * you this software, covering your right to use that party's intellectual
203446Smrj * property rights.
213446Smrj *
223446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj * copy of the source code appearing in this file ("Covered Code") an
243446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj * make derivatives, distribute, use and display any portion of the Covered
273446Smrj * Code in any form, with the right to sublicense such rights; and
283446Smrj *
293446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj * license (with the right to sublicense), under only those claims of Intel
313446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj * solely to the minimum extent necessary to exercise the above copyright
343446Smrj * license, and in no event shall the patent license extend to any additions
353446Smrj * to or modifications of the Original Intel Code. No other license or right
363446Smrj * is granted directly or by implication, estoppel or otherwise;
373446Smrj *
383446Smrj * The above copyright and patent license is granted only if the following
393446Smrj * conditions are met:
403446Smrj *
413446Smrj * 3. Conditions
423446Smrj *
433446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj * Redistribution of source code of any substantial portion of the Covered
453446Smrj * Code or modification with rights to further distribute source must include
463446Smrj * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
483446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj * contain a file documenting the changes Licensee made to create that Covered
503446Smrj * Code and the date of any change. Licensee must include in that file the
513446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
523446Smrj * must include a prominent statement that the modification is derived,
533446Smrj * directly or indirectly, from Original Intel Code.
543446Smrj *
553446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj * Redistribution of source code of any substantial portion of the Covered
573446Smrj * Code or modification without rights to further distribute source must
583446Smrj * include the following Disclaimer and Export Compliance provision in the
593446Smrj * documentation and/or other materials provided with distribution. In
603446Smrj * addition, Licensee may not authorize further sublicense of source of any
613446Smrj * portion of the Covered Code, and must include terms to the effect that the
623446Smrj * license from Licensee to its licensee is limited to the intellectual
633446Smrj * property embodied in the software Licensee provides to its licensee, and
643446Smrj * not to intellectual property embodied in modifications its licensee may
653446Smrj
663446Smrj * make.
673446Smrj *
683446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
693446Smrj * substantial portion of the Covered Code or modification must reproduce the
703446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
713446Smrj * provision in the documentation and/or other materials provided with the
723446Smrj * distribution.
733446Smrj *
743446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
753446Smrj * Intel Code.
763446Smrj *
773446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
783446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
793446Smrj * other dealings in products derived from or relating to the Covered Code
803446Smrj * without prior written authorization from Intel.
813446Smrj *
823446Smrj * 4. Disclaimer and Export Compliance
833446Smrj *
843446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
853446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
863446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
873446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
883446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
893446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
903446Smrj * PARTICULAR PURPOSE.
913446Smrj *
923446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
933446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
943446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
953446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
963446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
973446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
983446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
993446Smrj * LIMITED REMEDY.
1003446Smrj *
1013446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1023446Smrj * software or system incorporating such software without first obtaining any
1033446Smrj * required license or other approval from the U. S. Department of Commerce or
1043446Smrj * any other agency or department of the United States Government. In the
1053446Smrj * event Licensee exports any such software from the United States or
1063446Smrj * re-exports any such software from a foreign destination, Licensee shall
1073446Smrj * ensure that the distribution and export/re-export of the software is in
1083446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1093446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1103446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1113446Smrj * software, or service, directly or indirectly, to any country for which the
1123446Smrj * United States government or any agency thereof requires an export license,
1133446Smrj * other governmental approval, or letter of assurance, without first obtaining
1143446Smrj * such license, approval or letter.
1153446Smrj *
1163446Smrj *****************************************************************************/
1173446Smrj
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acevents.h"
1213446Smrj
1223446Smrj
1233446Smrj #define _COMPONENT ACPI_EVENTS
1243446Smrj ACPI_MODULE_NAME ("evsci")
1253446Smrj
1263446Smrj /* Local prototypes */
1273446Smrj
1283446Smrj static UINT32 ACPI_SYSTEM_XFACE
1293446Smrj AcpiEvSciXruptHandler (
1303446Smrj void *Context);
1313446Smrj
1323446Smrj
1333446Smrj /*******************************************************************************
1343446Smrj *
1353446Smrj * FUNCTION: AcpiEvSciXruptHandler
1363446Smrj *
1373446Smrj * PARAMETERS: Context - Calling Context
1383446Smrj *
1393446Smrj * RETURN: Status code indicates whether interrupt was handled.
1403446Smrj *
1413446Smrj * DESCRIPTION: Interrupt handler that will figure out what function or
1423446Smrj * control method to call to deal with a SCI.
1433446Smrj *
1443446Smrj ******************************************************************************/
1453446Smrj
1463446Smrj static UINT32 ACPI_SYSTEM_XFACE
AcpiEvSciXruptHandler(void * Context)1473446Smrj AcpiEvSciXruptHandler (
1483446Smrj void *Context)
1493446Smrj {
1503446Smrj ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
1513446Smrj UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
1523446Smrj
1533446Smrj
1543446Smrj ACPI_FUNCTION_TRACE (EvSciXruptHandler);
1553446Smrj
1563446Smrj
1573446Smrj /*
1583446Smrj * We are guaranteed by the ACPI CA initialization/shutdown code that
1593446Smrj * if this interrupt handler is installed, ACPI is enabled.
1603446Smrj */
1613446Smrj
1623446Smrj /*
1633446Smrj * Fixed Events:
1643446Smrj * Check for and dispatch any Fixed Events that have occurred
1653446Smrj */
1663446Smrj InterruptHandled |= AcpiEvFixedEventDetect ();
1673446Smrj
1683446Smrj /*
1693446Smrj * General Purpose Events:
1703446Smrj * Check for and dispatch any GPEs that have occurred
1713446Smrj */
1723446Smrj InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
1733446Smrj
1747851SDana.Myers@Sun.COM AcpiSciCount++;
1753446Smrj return_UINT32 (InterruptHandled);
1763446Smrj }
1773446Smrj
1783446Smrj
1793446Smrj /*******************************************************************************
1803446Smrj *
1813446Smrj * FUNCTION: AcpiEvGpeXruptHandler
1823446Smrj *
1833446Smrj * PARAMETERS: Context - Calling Context
1843446Smrj *
1853446Smrj * RETURN: Status code indicates whether interrupt was handled.
1863446Smrj *
1873446Smrj * DESCRIPTION: Handler for GPE Block Device interrupts
1883446Smrj *
1893446Smrj ******************************************************************************/
1903446Smrj
1913446Smrj UINT32 ACPI_SYSTEM_XFACE
AcpiEvGpeXruptHandler(void * Context)1923446Smrj AcpiEvGpeXruptHandler (
1933446Smrj void *Context)
1943446Smrj {
1953446Smrj ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
1963446Smrj UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
1973446Smrj
1983446Smrj
1993446Smrj ACPI_FUNCTION_TRACE (EvGpeXruptHandler);
2003446Smrj
2013446Smrj
2023446Smrj /*
2033446Smrj * We are guaranteed by the ACPI CA initialization/shutdown code that
2043446Smrj * if this interrupt handler is installed, ACPI is enabled.
2053446Smrj */
2063446Smrj
207*9980SDana.Myers@Sun.COM /* GPEs: Check for and dispatch any GPEs that have occurred */
208*9980SDana.Myers@Sun.COM
2093446Smrj InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
2103446Smrj
2113446Smrj return_UINT32 (InterruptHandled);
2123446Smrj }
2133446Smrj
2143446Smrj
2153446Smrj /******************************************************************************
2163446Smrj *
2173446Smrj * FUNCTION: AcpiEvInstallSciHandler
2183446Smrj *
2193446Smrj * PARAMETERS: none
2203446Smrj *
2213446Smrj * RETURN: Status
2223446Smrj *
2233446Smrj * DESCRIPTION: Installs SCI handler.
2243446Smrj *
2253446Smrj ******************************************************************************/
2263446Smrj
2273446Smrj UINT32
AcpiEvInstallSciHandler(void)2283446Smrj AcpiEvInstallSciHandler (
2293446Smrj void)
2303446Smrj {
2313446Smrj UINT32 Status = AE_OK;
2323446Smrj
2333446Smrj
2343446Smrj ACPI_FUNCTION_TRACE (EvInstallSciHandler);
2353446Smrj
2363446Smrj
2377851SDana.Myers@Sun.COM Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
2387851SDana.Myers@Sun.COM AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead);
2393446Smrj return_ACPI_STATUS (Status);
2403446Smrj }
2413446Smrj
2423446Smrj
2433446Smrj /******************************************************************************
2443446Smrj *
2453446Smrj * FUNCTION: AcpiEvRemoveSciHandler
2463446Smrj *
2473446Smrj * PARAMETERS: none
2483446Smrj *
2493446Smrj * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
2503446Smrj * installed to begin with
2513446Smrj *
252*9980SDana.Myers@Sun.COM * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
2533446Smrj * taken.
2543446Smrj *
2553446Smrj * Note: It doesn't seem important to disable all events or set the event
256*9980SDana.Myers@Sun.COM * enable registers to their original values. The OS should disable
2573446Smrj * the SCI interrupt level when the handler is removed, so no more
2583446Smrj * events will come in.
2593446Smrj *
2603446Smrj ******************************************************************************/
2613446Smrj
2623446Smrj ACPI_STATUS
AcpiEvRemoveSciHandler(void)2633446Smrj AcpiEvRemoveSciHandler (
2643446Smrj void)
2653446Smrj {
2663446Smrj ACPI_STATUS Status;
2673446Smrj
2683446Smrj
2693446Smrj ACPI_FUNCTION_TRACE (EvRemoveSciHandler);
2703446Smrj
2713446Smrj
2723446Smrj /* Just let the OS remove the handler and disable the level */
2733446Smrj
2747851SDana.Myers@Sun.COM Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
2757851SDana.Myers@Sun.COM AcpiEvSciXruptHandler);
2763446Smrj
2773446Smrj return_ACPI_STATUS (Status);
2783446Smrj }
2793446Smrj
2803446Smrj
281