1 /*******************************************************************************
3 * Module Name: evsci - System Control Interrupt configuration and
4 * legacy to ACPI mode state transition functions
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
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.
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.
45 #include <contrib/dev/acpica/include/acpi.h>
46 #include <contrib/dev/acpica/include/accommon.h>
47 #include <contrib/dev/acpica/include/acevents.h>
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evsci")
53 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
55 /* Local prototypes */
57 static UINT32 ACPI_SYSTEM_XFACE
58 AcpiEvSciXruptHandler (
62 /*******************************************************************************
64 * FUNCTION: AcpiEvSciDispatch
68 * RETURN: Status code indicates whether interrupt was handled.
70 * DESCRIPTION: Dispatch the SCI to all host-installed SCI handlers.
72 ******************************************************************************/
78 ACPI_SCI_HANDLER_INFO *SciHandler;
80 UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
83 ACPI_FUNCTION_NAME (EvSciDispatch);
86 /* Are there any host-installed SCI handlers? */
88 if (!AcpiGbl_SciHandlerList)
93 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
95 /* Invoke all host-installed SCI handlers */
97 SciHandler = AcpiGbl_SciHandlerList;
100 /* Invoke the installed handler (at interrupt level) */
102 IntStatus |= SciHandler->Address (
103 SciHandler->Context);
105 SciHandler = SciHandler->Next;
108 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
113 /*******************************************************************************
115 * FUNCTION: AcpiEvSciXruptHandler
117 * PARAMETERS: Context - Calling Context
119 * RETURN: Status code indicates whether interrupt was handled.
121 * DESCRIPTION: Interrupt handler that will figure out what function or
122 * control method to call to deal with a SCI.
124 ******************************************************************************/
126 static UINT32 ACPI_SYSTEM_XFACE
127 AcpiEvSciXruptHandler (
130 ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
131 UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
134 ACPI_FUNCTION_TRACE (EvSciXruptHandler);
138 * We are guaranteed by the ACPICA initialization/shutdown code that
139 * if this interrupt handler is installed, ACPI is enabled.
144 * Check for and dispatch any Fixed Events that have occurred
146 InterruptHandled |= AcpiEvFixedEventDetect ();
149 * General Purpose Events:
150 * Check for and dispatch any GPEs that have occurred
152 InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
154 /* Invoke all host-installed SCI handlers */
156 InterruptHandled |= AcpiEvSciDispatch ();
159 return_UINT32 (InterruptHandled);
163 /*******************************************************************************
165 * FUNCTION: AcpiEvGpeXruptHandler
167 * PARAMETERS: Context - Calling Context
169 * RETURN: Status code indicates whether interrupt was handled.
171 * DESCRIPTION: Handler for GPE Block Device interrupts
173 ******************************************************************************/
175 UINT32 ACPI_SYSTEM_XFACE
176 AcpiEvGpeXruptHandler (
179 ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
180 UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
183 ACPI_FUNCTION_TRACE (EvGpeXruptHandler);
187 * We are guaranteed by the ACPICA initialization/shutdown code that
188 * if this interrupt handler is installed, ACPI is enabled.
191 /* GPEs: Check for and dispatch any GPEs that have occurred */
193 InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
194 return_UINT32 (InterruptHandled);
198 /******************************************************************************
200 * FUNCTION: AcpiEvInstallSciHandler
206 * DESCRIPTION: Installs SCI handler.
208 ******************************************************************************/
211 AcpiEvInstallSciHandler (
214 UINT32 Status = AE_OK;
217 ACPI_FUNCTION_TRACE (EvInstallSciHandler);
220 Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
221 AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead);
222 return_ACPI_STATUS (Status);
226 /******************************************************************************
228 * FUNCTION: AcpiEvRemoveAllSciHandlers
232 * RETURN: AE_OK if handler uninstalled, AE_ERROR if handler was not
233 * installed to begin with
235 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
236 * taken. Remove all host-installed SCI handlers.
238 * Note: It doesn't seem important to disable all events or set the event
239 * enable registers to their original values. The OS should disable
240 * the SCI interrupt level when the handler is removed, so no more
241 * events will come in.
243 ******************************************************************************/
246 AcpiEvRemoveAllSciHandlers (
249 ACPI_SCI_HANDLER_INFO *SciHandler;
250 ACPI_CPU_FLAGS Flags;
254 ACPI_FUNCTION_TRACE (EvRemoveAllSciHandlers);
257 /* Just let the OS remove the handler and disable the level */
259 Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
260 AcpiEvSciXruptHandler);
262 if (!AcpiGbl_SciHandlerList)
267 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
269 /* Free all host-installed SCI handlers */
271 while (AcpiGbl_SciHandlerList)
273 SciHandler = AcpiGbl_SciHandlerList;
274 AcpiGbl_SciHandlerList = SciHandler->Next;
275 ACPI_FREE (SciHandler);
278 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
279 return_ACPI_STATUS (Status);
282 #endif /* !ACPI_REDUCED_HARDWARE */