ACPICA: Global event handler
[deliverable/linux.git] / drivers / acpi / acpica / evgpe.c
1 /******************************************************************************
2 *
3 * Module Name: evgpe - General Purpose Event handling and dispatch
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acevents.h"
47 #include "acnamesp.h"
48
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evgpe")
51
52 /* Local prototypes */
53 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
54
55 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context);
56
57 /*******************************************************************************
58 *
59 * FUNCTION: acpi_ev_update_gpe_enable_mask
60 *
61 * PARAMETERS: gpe_event_info - GPE to update
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Updates GPE register enable mask based upon whether there are
66 * runtime references to this GPE
67 *
68 ******************************************************************************/
69
70 acpi_status
71 acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
72 {
73 struct acpi_gpe_register_info *gpe_register_info;
74 u32 register_bit;
75
76 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_mask);
77
78 gpe_register_info = gpe_event_info->register_info;
79 if (!gpe_register_info) {
80 return_ACPI_STATUS(AE_NOT_EXIST);
81 }
82
83 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
84 gpe_register_info);
85
86 /* Clear the run bit up front */
87
88 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
89
90 /* Set the mask bit only if there are references to this GPE */
91
92 if (gpe_event_info->runtime_count) {
93 ACPI_SET_BIT(gpe_register_info->enable_for_run, (u8)register_bit);
94 }
95
96 return_ACPI_STATUS(AE_OK);
97 }
98
99 /*******************************************************************************
100 *
101 * FUNCTION: acpi_ev_enable_gpe
102 *
103 * PARAMETERS: gpe_event_info - GPE to enable
104 *
105 * RETURN: Status
106 *
107 * DESCRIPTION: Clear the given GPE from stale events and enable it.
108 *
109 ******************************************************************************/
110 acpi_status
111 acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
112 {
113 acpi_status status;
114
115 ACPI_FUNCTION_TRACE(ev_enable_gpe);
116
117 /*
118 * We will only allow a GPE to be enabled if it has either an associated
119 * method (_Lxx/_Exx) or a handler, or is using the implicit notify
120 * feature. Otherwise, the GPE will be immediately disabled by
121 * acpi_ev_gpe_dispatch the first time it fires.
122 */
123 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
124 ACPI_GPE_DISPATCH_NONE) {
125 return_ACPI_STATUS(AE_NO_HANDLER);
126 }
127
128 /* Clear the GPE (of stale events) */
129 status = acpi_hw_clear_gpe(gpe_event_info);
130 if (ACPI_FAILURE(status)) {
131 return_ACPI_STATUS(status);
132 }
133
134 /* Enable the requested GPE */
135 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
136
137 return_ACPI_STATUS(status);
138 }
139
140
141 /*******************************************************************************
142 *
143 * FUNCTION: acpi_ev_add_gpe_reference
144 *
145 * PARAMETERS: gpe_event_info - GPE to enable
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
150 * hardware-enabled.
151 *
152 ******************************************************************************/
153
154 acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
155 {
156 acpi_status status = AE_OK;
157
158 ACPI_FUNCTION_TRACE(ev_add_gpe_reference);
159
160 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) {
161 return_ACPI_STATUS(AE_LIMIT);
162 }
163
164 gpe_event_info->runtime_count++;
165 if (gpe_event_info->runtime_count == 1) {
166 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
167 if (ACPI_SUCCESS(status)) {
168 status = acpi_ev_enable_gpe(gpe_event_info);
169 }
170
171 if (ACPI_FAILURE(status)) {
172 gpe_event_info->runtime_count--;
173 }
174 }
175
176 return_ACPI_STATUS(status);
177 }
178
179 /*******************************************************************************
180 *
181 * FUNCTION: acpi_ev_remove_gpe_reference
182 *
183 * PARAMETERS: gpe_event_info - GPE to disable
184 *
185 * RETURN: Status
186 *
187 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
188 * removed, the GPE is hardware-disabled.
189 *
190 ******************************************************************************/
191
192 acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
193 {
194 acpi_status status = AE_OK;
195
196 ACPI_FUNCTION_TRACE(ev_remove_gpe_reference);
197
198 if (!gpe_event_info->runtime_count) {
199 return_ACPI_STATUS(AE_LIMIT);
200 }
201
202 gpe_event_info->runtime_count--;
203 if (!gpe_event_info->runtime_count) {
204 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
205 if (ACPI_SUCCESS(status)) {
206 status = acpi_hw_low_set_gpe(gpe_event_info,
207 ACPI_GPE_DISABLE);
208 }
209
210 if (ACPI_FAILURE(status)) {
211 gpe_event_info->runtime_count++;
212 }
213 }
214
215 return_ACPI_STATUS(status);
216 }
217
218 /*******************************************************************************
219 *
220 * FUNCTION: acpi_ev_low_get_gpe_info
221 *
222 * PARAMETERS: gpe_number - Raw GPE number
223 * gpe_block - A GPE info block
224 *
225 * RETURN: A GPE event_info struct. NULL if not a valid GPE (The gpe_number
226 * is not within the specified GPE block)
227 *
228 * DESCRIPTION: Returns the event_info struct associated with this GPE. This is
229 * the low-level implementation of ev_get_gpe_event_info.
230 *
231 ******************************************************************************/
232
233 struct acpi_gpe_event_info *acpi_ev_low_get_gpe_info(u32 gpe_number,
234 struct acpi_gpe_block_info
235 *gpe_block)
236 {
237 u32 gpe_index;
238
239 /*
240 * Validate that the gpe_number is within the specified gpe_block.
241 * (Two steps)
242 */
243 if (!gpe_block || (gpe_number < gpe_block->block_base_number)) {
244 return (NULL);
245 }
246
247 gpe_index = gpe_number - gpe_block->block_base_number;
248 if (gpe_index >= gpe_block->gpe_count) {
249 return (NULL);
250 }
251
252 return (&gpe_block->event_info[gpe_index]);
253 }
254
255
256 /*******************************************************************************
257 *
258 * FUNCTION: acpi_ev_get_gpe_event_info
259 *
260 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
261 * gpe_number - Raw GPE number
262 *
263 * RETURN: A GPE event_info struct. NULL if not a valid GPE
264 *
265 * DESCRIPTION: Returns the event_info struct associated with this GPE.
266 * Validates the gpe_block and the gpe_number
267 *
268 * Should be called only when the GPE lists are semaphore locked
269 * and not subject to change.
270 *
271 ******************************************************************************/
272
273 struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
274 u32 gpe_number)
275 {
276 union acpi_operand_object *obj_desc;
277 struct acpi_gpe_event_info *gpe_info;
278 u32 i;
279
280 ACPI_FUNCTION_ENTRY();
281
282 /* A NULL gpe_device means use the FADT-defined GPE block(s) */
283
284 if (!gpe_device) {
285
286 /* Examine GPE Block 0 and 1 (These blocks are permanent) */
287
288 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
289 gpe_info = acpi_ev_low_get_gpe_info(gpe_number,
290 acpi_gbl_gpe_fadt_blocks
291 [i]);
292 if (gpe_info) {
293 return (gpe_info);
294 }
295 }
296
297 /* The gpe_number was not in the range of either FADT GPE block */
298
299 return (NULL);
300 }
301
302 /* A Non-NULL gpe_device means this is a GPE Block Device */
303
304 obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *)
305 gpe_device);
306 if (!obj_desc || !obj_desc->device.gpe_block) {
307 return (NULL);
308 }
309
310 return (acpi_ev_low_get_gpe_info
311 (gpe_number, obj_desc->device.gpe_block));
312 }
313
314 /*******************************************************************************
315 *
316 * FUNCTION: acpi_ev_gpe_detect
317 *
318 * PARAMETERS: gpe_xrupt_list - Interrupt block for this interrupt.
319 * Can have multiple GPE blocks attached.
320 *
321 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
322 *
323 * DESCRIPTION: Detect if any GP events have occurred. This function is
324 * executed at interrupt level.
325 *
326 ******************************************************************************/
327
328 u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
329 {
330 acpi_status status;
331 struct acpi_gpe_block_info *gpe_block;
332 struct acpi_gpe_register_info *gpe_register_info;
333 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
334 u8 enabled_status_byte;
335 u32 status_reg;
336 u32 enable_reg;
337 acpi_cpu_flags flags;
338 u32 i;
339 u32 j;
340
341 ACPI_FUNCTION_NAME(ev_gpe_detect);
342
343 /* Check for the case where there are no GPEs */
344
345 if (!gpe_xrupt_list) {
346 return (int_status);
347 }
348
349 /*
350 * We need to obtain the GPE lock for both the data structs and registers
351 * Note: Not necessary to obtain the hardware lock, since the GPE
352 * registers are owned by the gpe_lock.
353 */
354 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
355
356 /* Examine all GPE blocks attached to this interrupt level */
357
358 gpe_block = gpe_xrupt_list->gpe_block_list_head;
359 while (gpe_block) {
360 /*
361 * Read all of the 8-bit GPE status and enable registers in this GPE
362 * block, saving all of them. Find all currently active GP events.
363 */
364 for (i = 0; i < gpe_block->register_count; i++) {
365
366 /* Get the next status/enable pair */
367
368 gpe_register_info = &gpe_block->register_info[i];
369
370 /* Read the Status Register */
371
372 status =
373 acpi_hw_read(&status_reg,
374 &gpe_register_info->status_address);
375 if (ACPI_FAILURE(status)) {
376 goto unlock_and_exit;
377 }
378
379 /* Read the Enable Register */
380
381 status =
382 acpi_hw_read(&enable_reg,
383 &gpe_register_info->enable_address);
384 if (ACPI_FAILURE(status)) {
385 goto unlock_and_exit;
386 }
387
388 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
389 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
390 gpe_register_info->base_gpe_number,
391 status_reg, enable_reg));
392
393 /* Check if there is anything active at all in this register */
394
395 enabled_status_byte = (u8) (status_reg & enable_reg);
396 if (!enabled_status_byte) {
397
398 /* No active GPEs in this register, move on */
399
400 continue;
401 }
402
403 /* Now look at the individual GPEs in this byte register */
404
405 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
406
407 /* Examine one GPE bit */
408
409 if (enabled_status_byte & (1 << j)) {
410 /*
411 * Found an active GPE. Dispatch the event to a handler
412 * or method.
413 */
414 int_status |=
415 acpi_ev_gpe_dispatch(gpe_block->
416 node,
417 &gpe_block->
418 event_info[((acpi_size) i * ACPI_GPE_REGISTER_WIDTH) + j], j + gpe_register_info->base_gpe_number);
419 }
420 }
421 }
422
423 gpe_block = gpe_block->next;
424 }
425
426 unlock_and_exit:
427
428 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
429 return (int_status);
430 }
431
432 /*******************************************************************************
433 *
434 * FUNCTION: acpi_ev_asynch_execute_gpe_method
435 *
436 * PARAMETERS: Context (gpe_event_info) - Info for this GPE
437 *
438 * RETURN: None
439 *
440 * DESCRIPTION: Perform the actual execution of a GPE control method. This
441 * function is called from an invocation of acpi_os_execute and
442 * therefore does NOT execute at interrupt level - so that
443 * the control method itself is not executed in the context of
444 * an interrupt handler.
445 *
446 ******************************************************************************/
447
448 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
449 {
450 struct acpi_gpe_event_info *gpe_event_info = context;
451 acpi_status status;
452 struct acpi_gpe_event_info *local_gpe_event_info;
453 struct acpi_evaluate_info *info;
454
455 ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method);
456
457 /* Allocate a local GPE block */
458
459 local_gpe_event_info =
460 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_event_info));
461 if (!local_gpe_event_info) {
462 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "while handling a GPE"));
463 return_VOID;
464 }
465
466 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
467 if (ACPI_FAILURE(status)) {
468 return_VOID;
469 }
470
471 /* Must revalidate the gpe_number/gpe_block */
472
473 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
474 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
475 return_VOID;
476 }
477
478 /*
479 * Take a snapshot of the GPE info for this level - we copy the info to
480 * prevent a race condition with remove_handler/remove_block.
481 */
482 ACPI_MEMCPY(local_gpe_event_info, gpe_event_info,
483 sizeof(struct acpi_gpe_event_info));
484
485 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
486 if (ACPI_FAILURE(status)) {
487 return_VOID;
488 }
489
490 /* Do the correct dispatch - normal method or implicit notify */
491
492 switch (local_gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) {
493 case ACPI_GPE_DISPATCH_NOTIFY:
494
495 /*
496 * Implicit notify.
497 * Dispatch a DEVICE_WAKE notify to the appropriate handler.
498 * NOTE: the request is queued for execution after this method
499 * completes. The notify handlers are NOT invoked synchronously
500 * from this thread -- because handlers may in turn run other
501 * control methods.
502 */
503 status =
504 acpi_ev_queue_notify_request(local_gpe_event_info->dispatch.
505 device_node,
506 ACPI_NOTIFY_DEVICE_WAKE);
507 break;
508
509 case ACPI_GPE_DISPATCH_METHOD:
510
511 /* Allocate the evaluation information block */
512
513 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
514 if (!info) {
515 status = AE_NO_MEMORY;
516 } else {
517 /*
518 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
519 * control method that corresponds to this GPE
520 */
521 info->prefix_node =
522 local_gpe_event_info->dispatch.method_node;
523 info->flags = ACPI_IGNORE_RETURN_VALUE;
524
525 status = acpi_ns_evaluate(info);
526 ACPI_FREE(info);
527 }
528
529 if (ACPI_FAILURE(status)) {
530 ACPI_EXCEPTION((AE_INFO, status,
531 "while evaluating GPE method [%4.4s]",
532 acpi_ut_get_node_name
533 (local_gpe_event_info->dispatch.
534 method_node)));
535 }
536
537 break;
538
539 default:
540 return_VOID; /* Should never happen */
541 }
542
543 /* Defer enabling of GPE until all notify handlers are done */
544
545 status = acpi_os_execute(OSL_NOTIFY_HANDLER,
546 acpi_ev_asynch_enable_gpe,
547 local_gpe_event_info);
548 if (ACPI_FAILURE(status)) {
549 ACPI_FREE(local_gpe_event_info);
550 }
551 return_VOID;
552 }
553
554
555 /*******************************************************************************
556 *
557 * FUNCTION: acpi_ev_asynch_enable_gpe
558 *
559 * PARAMETERS: Context (gpe_event_info) - Info for this GPE
560 * Callback from acpi_os_execute
561 *
562 * RETURN: None
563 *
564 * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to
565 * complete (i.e., finish execution of Notify)
566 *
567 ******************************************************************************/
568
569 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context)
570 {
571 struct acpi_gpe_event_info *gpe_event_info = context;
572
573 (void)acpi_ev_finish_gpe(gpe_event_info);
574
575 ACPI_FREE(gpe_event_info);
576 return;
577 }
578
579
580 /*******************************************************************************
581 *
582 * FUNCTION: acpi_ev_finish_gpe
583 *
584 * PARAMETERS: gpe_event_info - Info for this GPE
585 *
586 * RETURN: Status
587 *
588 * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution
589 * of a GPE method or a synchronous or asynchronous GPE handler.
590 *
591 ******************************************************************************/
592
593 acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info)
594 {
595 acpi_status status;
596
597 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
598 ACPI_GPE_LEVEL_TRIGGERED) {
599 /*
600 * GPE is level-triggered, we clear the GPE status bit after
601 * handling the event.
602 */
603 status = acpi_hw_clear_gpe(gpe_event_info);
604 if (ACPI_FAILURE(status)) {
605 return (status);
606 }
607 }
608
609 /*
610 * Enable this GPE, conditionally. This means that the GPE will
611 * only be physically enabled if the enable_for_run bit is set
612 * in the event_info.
613 */
614 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_CONDITIONAL_ENABLE);
615 return (AE_OK);
616 }
617
618
619 /*******************************************************************************
620 *
621 * FUNCTION: acpi_ev_gpe_dispatch
622 *
623 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
624 * gpe_event_info - Info for this GPE
625 * gpe_number - Number relative to the parent GPE block
626 *
627 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
628 *
629 * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
630 * or method (e.g. _Lxx/_Exx) handler.
631 *
632 * This function executes at interrupt level.
633 *
634 ******************************************************************************/
635
636 u32
637 acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
638 struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
639 {
640 acpi_status status;
641 u32 return_value;
642
643 ACPI_FUNCTION_TRACE(ev_gpe_dispatch);
644
645 /* Invoke global event handler if present */
646
647 acpi_gpe_count++;
648 if (acpi_gbl_global_event_handler) {
649 acpi_gbl_global_event_handler(ACPI_EVENT_TYPE_GPE, gpe_device,
650 gpe_number,
651 acpi_gbl_global_event_handler_context);
652 }
653
654 /*
655 * If edge-triggered, clear the GPE status bit now. Note that
656 * level-triggered events are cleared after the GPE is serviced.
657 */
658 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
659 ACPI_GPE_EDGE_TRIGGERED) {
660 status = acpi_hw_clear_gpe(gpe_event_info);
661 if (ACPI_FAILURE(status)) {
662 ACPI_EXCEPTION((AE_INFO, status,
663 "Unable to clear GPE[0x%2X]",
664 gpe_number));
665 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
666 }
667 }
668
669 /*
670 * Always disable the GPE so that it does not keep firing before
671 * any asynchronous activity completes (either from the execution
672 * of a GPE method or an asynchronous GPE handler.)
673 *
674 * If there is no handler or method to run, just disable the
675 * GPE and leave it disabled permanently to prevent further such
676 * pointless events from firing.
677 */
678 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
679 if (ACPI_FAILURE(status)) {
680 ACPI_EXCEPTION((AE_INFO, status,
681 "Unable to disable GPE%02X", gpe_number));
682 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
683 }
684
685 /*
686 * Dispatch the GPE to either an installed handler or the control
687 * method associated with this GPE (_Lxx or _Exx). If a handler
688 * exists, we invoke it and do not attempt to run the method.
689 * If there is neither a handler nor a method, leave the GPE
690 * disabled.
691 */
692 switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) {
693 case ACPI_GPE_DISPATCH_HANDLER:
694
695 /* Invoke the installed handler (at interrupt level) */
696
697 return_value =
698 gpe_event_info->dispatch.handler->address(gpe_device,
699 gpe_number,
700 gpe_event_info->
701 dispatch.handler->
702 context);
703
704 /* If requested, clear (if level-triggered) and reenable the GPE */
705
706 if (return_value & ACPI_REENABLE_GPE) {
707 (void)acpi_ev_finish_gpe(gpe_event_info);
708 }
709 break;
710
711 case ACPI_GPE_DISPATCH_METHOD:
712 case ACPI_GPE_DISPATCH_NOTIFY:
713
714 /*
715 * Execute the method associated with the GPE
716 * NOTE: Level-triggered GPEs are cleared after the method completes.
717 */
718 status = acpi_os_execute(OSL_GPE_HANDLER,
719 acpi_ev_asynch_execute_gpe_method,
720 gpe_event_info);
721 if (ACPI_FAILURE(status)) {
722 ACPI_EXCEPTION((AE_INFO, status,
723 "Unable to queue handler for GPE[0x%2X] - event disabled",
724 gpe_number));
725 }
726 break;
727
728 default:
729
730 /*
731 * No handler or method to run!
732 * 03/2010: This case should no longer be possible. We will not allow
733 * a GPE to be enabled if it has no handler or method.
734 */
735 ACPI_ERROR((AE_INFO,
736 "No handler or method for GPE[0x%2X], disabling event",
737 gpe_number));
738
739 break;
740 }
741
742 return_UINT32(ACPI_INTERRUPT_HANDLED);
743 }
This page took 0.067639 seconds and 6 git commands to generate.