1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: evsci - System Control Interrupt configuration and
5 * legacy to ACPI mode state transition functions
7 ******************************************************************************/
13 #define _COMPONENT ACPI_EVENTS
14 ACPI_MODULE_NAME("evsci")
15 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
16 /* Local prototypes */
17 static u32 ACPI_SYSTEM_XFACE
acpi_ev_sci_xrupt_handler(void *context
);
19 /*******************************************************************************
21 * FUNCTION: acpi_ev_sci_dispatch
25 * RETURN: Status code indicates whether interrupt was handled.
27 * DESCRIPTION: Dispatch the SCI to all host-installed SCI handlers.
29 ******************************************************************************/
31 u32
acpi_ev_sci_dispatch(void)
33 struct acpi_sci_handler_info
*sci_handler
;
35 u32 int_status
= ACPI_INTERRUPT_NOT_HANDLED
;
37 ACPI_FUNCTION_NAME(ev_sci_dispatch
);
39 /* Are there any host-installed SCI handlers? */
41 if (!acpi_gbl_sci_handler_list
) {
45 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
47 /* Invoke all host-installed SCI handlers */
49 sci_handler
= acpi_gbl_sci_handler_list
;
52 /* Invoke the installed handler (at interrupt level) */
54 int_status
|= sci_handler
->address(sci_handler
->context
);
56 sci_handler
= sci_handler
->next
;
59 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
63 /*******************************************************************************
65 * FUNCTION: acpi_ev_sci_xrupt_handler
67 * PARAMETERS: context - Calling Context
69 * RETURN: Status code indicates whether interrupt was handled.
71 * DESCRIPTION: Interrupt handler that will figure out what function or
72 * control method to call to deal with a SCI.
74 ******************************************************************************/
76 static u32 ACPI_SYSTEM_XFACE
acpi_ev_sci_xrupt_handler(void *context
)
78 struct acpi_gpe_xrupt_info
*gpe_xrupt_list
= context
;
79 u32 interrupt_handled
= ACPI_INTERRUPT_NOT_HANDLED
;
81 ACPI_FUNCTION_TRACE(ev_sci_xrupt_handler
);
84 * We are guaranteed by the ACPICA initialization/shutdown code that
85 * if this interrupt handler is installed, ACPI is enabled.
90 * Check for and dispatch any Fixed Events that have occurred
92 interrupt_handled
|= acpi_ev_fixed_event_detect();
95 * General Purpose Events:
96 * Check for and dispatch any GPEs that have occurred
98 interrupt_handled
|= acpi_ev_gpe_detect(gpe_xrupt_list
);
100 /* Invoke all host-installed SCI handlers */
102 interrupt_handled
|= acpi_ev_sci_dispatch();
105 return_UINT32(interrupt_handled
);
108 /*******************************************************************************
110 * FUNCTION: acpi_ev_gpe_xrupt_handler
112 * PARAMETERS: context - Calling Context
114 * RETURN: Status code indicates whether interrupt was handled.
116 * DESCRIPTION: Handler for GPE Block Device interrupts
118 ******************************************************************************/
120 u32 ACPI_SYSTEM_XFACE
acpi_ev_gpe_xrupt_handler(void *context
)
122 struct acpi_gpe_xrupt_info
*gpe_xrupt_list
= context
;
123 u32 interrupt_handled
= ACPI_INTERRUPT_NOT_HANDLED
;
125 ACPI_FUNCTION_TRACE(ev_gpe_xrupt_handler
);
128 * We are guaranteed by the ACPICA initialization/shutdown code that
129 * if this interrupt handler is installed, ACPI is enabled.
132 /* GPEs: Check for and dispatch any GPEs that have occurred */
134 interrupt_handled
|= acpi_ev_gpe_detect(gpe_xrupt_list
);
135 return_UINT32(interrupt_handled
);
138 /******************************************************************************
140 * FUNCTION: acpi_ev_install_sci_handler
146 * DESCRIPTION: Installs SCI handler.
148 ******************************************************************************/
150 u32
acpi_ev_install_sci_handler(void)
154 ACPI_FUNCTION_TRACE(ev_install_sci_handler
);
157 acpi_os_install_interrupt_handler((u32
) acpi_gbl_FADT
.sci_interrupt
,
158 acpi_ev_sci_xrupt_handler
,
159 acpi_gbl_gpe_xrupt_list_head
);
160 return_ACPI_STATUS(status
);
163 /******************************************************************************
165 * FUNCTION: acpi_ev_remove_all_sci_handlers
169 * RETURN: AE_OK if handler uninstalled, AE_ERROR if handler was not
170 * installed to begin with
172 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
173 * taken. Remove all host-installed SCI handlers.
175 * Note: It doesn't seem important to disable all events or set the event
176 * enable registers to their original values. The OS should disable
177 * the SCI interrupt level when the handler is removed, so no more
178 * events will come in.
180 ******************************************************************************/
182 acpi_status
acpi_ev_remove_all_sci_handlers(void)
184 struct acpi_sci_handler_info
*sci_handler
;
185 acpi_cpu_flags flags
;
188 ACPI_FUNCTION_TRACE(ev_remove_all_sci_handlers
);
190 /* Just let the OS remove the handler and disable the level */
193 acpi_os_remove_interrupt_handler((u32
) acpi_gbl_FADT
.sci_interrupt
,
194 acpi_ev_sci_xrupt_handler
);
196 if (!acpi_gbl_sci_handler_list
) {
200 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
202 /* Free all host-installed SCI handlers */
204 while (acpi_gbl_sci_handler_list
) {
205 sci_handler
= acpi_gbl_sci_handler_list
;
206 acpi_gbl_sci_handler_list
= sci_handler
->next
;
207 ACPI_FREE(sci_handler
);
210 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
211 return_ACPI_STATUS(status
);
214 #endif /* !ACPI_REDUCED_HARDWARE */