1 /******************************************************************************* 2 * 3 * Module Name: evsci - System Control Interrupt configuration and 4 * legacy to ACPI mode state transition functions 5 * 6 ******************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2011, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 #include "acpi.h" 46 #include "accommon.h" 47 #include "acevents.h" 48 49 50 #define _COMPONENT ACPI_EVENTS 51 ACPI_MODULE_NAME ("evsci") 52 53 /* Local prototypes */ 54 55 static UINT32 ACPI_SYSTEM_XFACE 56 AcpiEvSciXruptHandler ( 57 void *Context); 58 59 60 /******************************************************************************* 61 * 62 * FUNCTION: AcpiEvSciXruptHandler 63 * 64 * PARAMETERS: Context - Calling Context 65 * 66 * RETURN: Status code indicates whether interrupt was handled. 67 * 68 * DESCRIPTION: Interrupt handler that will figure out what function or 69 * control method to call to deal with a SCI. 70 * 71 ******************************************************************************/ 72 73 static UINT32 ACPI_SYSTEM_XFACE 74 AcpiEvSciXruptHandler ( 75 void *Context) 76 { 77 ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; 78 UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; 79 80 81 ACPI_FUNCTION_TRACE (EvSciXruptHandler); 82 83 84 /* 85 * We are guaranteed by the ACPI CA initialization/shutdown code that 86 * if this interrupt handler is installed, ACPI is enabled. 87 */ 88 89 /* 90 * Fixed Events: 91 * Check for and dispatch any Fixed Events that have occurred 92 */ 93 InterruptHandled |= AcpiEvFixedEventDetect (); 94 95 /* 96 * General Purpose Events: 97 * Check for and dispatch any GPEs that have occurred 98 */ 99 InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); 100 101 AcpiSciCount++; 102 return_UINT32 (InterruptHandled); 103 } 104 105 106 /******************************************************************************* 107 * 108 * FUNCTION: AcpiEvGpeXruptHandler 109 * 110 * PARAMETERS: Context - Calling Context 111 * 112 * RETURN: Status code indicates whether interrupt was handled. 113 * 114 * DESCRIPTION: Handler for GPE Block Device interrupts 115 * 116 ******************************************************************************/ 117 118 UINT32 ACPI_SYSTEM_XFACE 119 AcpiEvGpeXruptHandler ( 120 void *Context) 121 { 122 ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; 123 UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; 124 125 126 ACPI_FUNCTION_TRACE (EvGpeXruptHandler); 127 128 129 /* 130 * We are guaranteed by the ACPI CA initialization/shutdown code that 131 * if this interrupt handler is installed, ACPI is enabled. 132 */ 133 134 /* GPEs: Check for and dispatch any GPEs that have occurred */ 135 136 InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); 137 138 return_UINT32 (InterruptHandled); 139 } 140 141 142 /****************************************************************************** 143 * 144 * FUNCTION: AcpiEvInstallSciHandler 145 * 146 * PARAMETERS: none 147 * 148 * RETURN: Status 149 * 150 * DESCRIPTION: Installs SCI handler. 151 * 152 ******************************************************************************/ 153 154 UINT32 155 AcpiEvInstallSciHandler ( 156 void) 157 { 158 UINT32 Status = AE_OK; 159 160 161 ACPI_FUNCTION_TRACE (EvInstallSciHandler); 162 163 164 Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, 165 AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); 166 return_ACPI_STATUS (Status); 167 } 168 169 170 /****************************************************************************** 171 * 172 * FUNCTION: AcpiEvRemoveSciHandler 173 * 174 * PARAMETERS: none 175 * 176 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not 177 * installed to begin with 178 * 179 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be 180 * taken. 181 * 182 * Note: It doesn't seem important to disable all events or set the event 183 * enable registers to their original values. The OS should disable 184 * the SCI interrupt level when the handler is removed, so no more 185 * events will come in. 186 * 187 ******************************************************************************/ 188 189 ACPI_STATUS 190 AcpiEvRemoveSciHandler ( 191 void) 192 { 193 ACPI_STATUS Status; 194 195 196 ACPI_FUNCTION_TRACE (EvRemoveSciHandler); 197 198 199 /* Just let the OS remove the handler and disable the level */ 200 201 Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, 202 AcpiEvSciXruptHandler); 203 204 return_ACPI_STATUS (Status); 205 } 206 207