evsci.c revision 1.1.1.2 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.2 jruoho * Copyright (C) 2000 - 2011, 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 jruoho /* Local prototypes */
54 1.1 jruoho
55 1.1 jruoho static UINT32 ACPI_SYSTEM_XFACE
56 1.1 jruoho AcpiEvSciXruptHandler (
57 1.1 jruoho void *Context);
58 1.1 jruoho
59 1.1 jruoho
60 1.1 jruoho /*******************************************************************************
61 1.1 jruoho *
62 1.1 jruoho * FUNCTION: AcpiEvSciXruptHandler
63 1.1 jruoho *
64 1.1 jruoho * PARAMETERS: Context - Calling Context
65 1.1 jruoho *
66 1.1 jruoho * RETURN: Status code indicates whether interrupt was handled.
67 1.1 jruoho *
68 1.1 jruoho * DESCRIPTION: Interrupt handler that will figure out what function or
69 1.1 jruoho * control method to call to deal with a SCI.
70 1.1 jruoho *
71 1.1 jruoho ******************************************************************************/
72 1.1 jruoho
73 1.1 jruoho static UINT32 ACPI_SYSTEM_XFACE
74 1.1 jruoho AcpiEvSciXruptHandler (
75 1.1 jruoho void *Context)
76 1.1 jruoho {
77 1.1 jruoho ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
78 1.1 jruoho UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
79 1.1 jruoho
80 1.1 jruoho
81 1.1 jruoho ACPI_FUNCTION_TRACE (EvSciXruptHandler);
82 1.1 jruoho
83 1.1 jruoho
84 1.1 jruoho /*
85 1.1 jruoho * We are guaranteed by the ACPI CA initialization/shutdown code that
86 1.1 jruoho * if this interrupt handler is installed, ACPI is enabled.
87 1.1 jruoho */
88 1.1 jruoho
89 1.1 jruoho /*
90 1.1 jruoho * Fixed Events:
91 1.1 jruoho * Check for and dispatch any Fixed Events that have occurred
92 1.1 jruoho */
93 1.1 jruoho InterruptHandled |= AcpiEvFixedEventDetect ();
94 1.1 jruoho
95 1.1 jruoho /*
96 1.1 jruoho * General Purpose Events:
97 1.1 jruoho * Check for and dispatch any GPEs that have occurred
98 1.1 jruoho */
99 1.1 jruoho InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
100 1.1 jruoho
101 1.1 jruoho AcpiSciCount++;
102 1.1 jruoho return_UINT32 (InterruptHandled);
103 1.1 jruoho }
104 1.1 jruoho
105 1.1 jruoho
106 1.1 jruoho /*******************************************************************************
107 1.1 jruoho *
108 1.1 jruoho * FUNCTION: AcpiEvGpeXruptHandler
109 1.1 jruoho *
110 1.1 jruoho * PARAMETERS: Context - Calling Context
111 1.1 jruoho *
112 1.1 jruoho * RETURN: Status code indicates whether interrupt was handled.
113 1.1 jruoho *
114 1.1 jruoho * DESCRIPTION: Handler for GPE Block Device interrupts
115 1.1 jruoho *
116 1.1 jruoho ******************************************************************************/
117 1.1 jruoho
118 1.1 jruoho UINT32 ACPI_SYSTEM_XFACE
119 1.1 jruoho AcpiEvGpeXruptHandler (
120 1.1 jruoho void *Context)
121 1.1 jruoho {
122 1.1 jruoho ACPI_GPE_XRUPT_INFO *GpeXruptList = Context;
123 1.1 jruoho UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
124 1.1 jruoho
125 1.1 jruoho
126 1.1 jruoho ACPI_FUNCTION_TRACE (EvGpeXruptHandler);
127 1.1 jruoho
128 1.1 jruoho
129 1.1 jruoho /*
130 1.1 jruoho * We are guaranteed by the ACPI CA initialization/shutdown code that
131 1.1 jruoho * if this interrupt handler is installed, ACPI is enabled.
132 1.1 jruoho */
133 1.1 jruoho
134 1.1 jruoho /* GPEs: Check for and dispatch any GPEs that have occurred */
135 1.1 jruoho
136 1.1 jruoho InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
137 1.1 jruoho
138 1.1 jruoho return_UINT32 (InterruptHandled);
139 1.1 jruoho }
140 1.1 jruoho
141 1.1 jruoho
142 1.1 jruoho /******************************************************************************
143 1.1 jruoho *
144 1.1 jruoho * FUNCTION: AcpiEvInstallSciHandler
145 1.1 jruoho *
146 1.1 jruoho * PARAMETERS: none
147 1.1 jruoho *
148 1.1 jruoho * RETURN: Status
149 1.1 jruoho *
150 1.1 jruoho * DESCRIPTION: Installs SCI handler.
151 1.1 jruoho *
152 1.1 jruoho ******************************************************************************/
153 1.1 jruoho
154 1.1 jruoho UINT32
155 1.1 jruoho AcpiEvInstallSciHandler (
156 1.1 jruoho void)
157 1.1 jruoho {
158 1.1 jruoho UINT32 Status = AE_OK;
159 1.1 jruoho
160 1.1 jruoho
161 1.1 jruoho ACPI_FUNCTION_TRACE (EvInstallSciHandler);
162 1.1 jruoho
163 1.1 jruoho
164 1.1 jruoho Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
165 1.1 jruoho AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead);
166 1.1 jruoho return_ACPI_STATUS (Status);
167 1.1 jruoho }
168 1.1 jruoho
169 1.1 jruoho
170 1.1 jruoho /******************************************************************************
171 1.1 jruoho *
172 1.1 jruoho * FUNCTION: AcpiEvRemoveSciHandler
173 1.1 jruoho *
174 1.1 jruoho * PARAMETERS: none
175 1.1 jruoho *
176 1.1 jruoho * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
177 1.1 jruoho * installed to begin with
178 1.1 jruoho *
179 1.1 jruoho * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
180 1.1 jruoho * taken.
181 1.1 jruoho *
182 1.1 jruoho * Note: It doesn't seem important to disable all events or set the event
183 1.1 jruoho * enable registers to their original values. The OS should disable
184 1.1 jruoho * the SCI interrupt level when the handler is removed, so no more
185 1.1 jruoho * events will come in.
186 1.1 jruoho *
187 1.1 jruoho ******************************************************************************/
188 1.1 jruoho
189 1.1 jruoho ACPI_STATUS
190 1.1 jruoho AcpiEvRemoveSciHandler (
191 1.1 jruoho void)
192 1.1 jruoho {
193 1.1 jruoho ACPI_STATUS Status;
194 1.1 jruoho
195 1.1 jruoho
196 1.1 jruoho ACPI_FUNCTION_TRACE (EvRemoveSciHandler);
197 1.1 jruoho
198 1.1 jruoho
199 1.1 jruoho /* Just let the OS remove the handler and disable the level */
200 1.1 jruoho
201 1.1 jruoho Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt,
202 1.1 jruoho AcpiEvSciXruptHandler);
203 1.1 jruoho
204 1.1 jruoho return_ACPI_STATUS (Status);
205 1.1 jruoho }
206 1.1 jruoho
207 1.1 jruoho
208