evsci.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*******************************************************************************
  2. *
  3. * Module Name: evsci - System Control Interrupt configuration and
  4. * legacy to ACPI mode state transition functions
  5. *
  6. ******************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2005, R. Byron Moore
  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. #include <acpi/acpi.h>
  44. #include <acpi/acevents.h>
  45. #define _COMPONENT ACPI_EVENTS
  46. ACPI_MODULE_NAME ("evsci")
  47. /* Local prototypes */
  48. static u32 ACPI_SYSTEM_XFACE
  49. acpi_ev_sci_xrupt_handler (
  50. void *context);
  51. /*******************************************************************************
  52. *
  53. * FUNCTION: acpi_ev_sci_xrupt_handler
  54. *
  55. * PARAMETERS: Context - Calling Context
  56. *
  57. * RETURN: Status code indicates whether interrupt was handled.
  58. *
  59. * DESCRIPTION: Interrupt handler that will figure out what function or
  60. * control method to call to deal with a SCI.
  61. *
  62. ******************************************************************************/
  63. static u32 ACPI_SYSTEM_XFACE
  64. acpi_ev_sci_xrupt_handler (
  65. void *context)
  66. {
  67. struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
  68. u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
  69. ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
  70. /*
  71. * We are guaranteed by the ACPI CA initialization/shutdown code that
  72. * if this interrupt handler is installed, ACPI is enabled.
  73. */
  74. /*
  75. * Fixed Events:
  76. * Check for and dispatch any Fixed Events that have occurred
  77. */
  78. interrupt_handled |= acpi_ev_fixed_event_detect ();
  79. /*
  80. * General Purpose Events:
  81. * Check for and dispatch any GPEs that have occurred
  82. */
  83. interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
  84. return_VALUE (interrupt_handled);
  85. }
  86. /*******************************************************************************
  87. *
  88. * FUNCTION: acpi_ev_gpe_xrupt_handler
  89. *
  90. * PARAMETERS: Context - Calling Context
  91. *
  92. * RETURN: Status code indicates whether interrupt was handled.
  93. *
  94. * DESCRIPTION: Handler for GPE Block Device interrupts
  95. *
  96. ******************************************************************************/
  97. u32 ACPI_SYSTEM_XFACE
  98. acpi_ev_gpe_xrupt_handler (
  99. void *context)
  100. {
  101. struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
  102. u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
  103. ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
  104. /*
  105. * We are guaranteed by the ACPI CA initialization/shutdown code that
  106. * if this interrupt handler is installed, ACPI is enabled.
  107. */
  108. /*
  109. * GPEs:
  110. * Check for and dispatch any GPEs that have occurred
  111. */
  112. interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
  113. return_VALUE (interrupt_handled);
  114. }
  115. /******************************************************************************
  116. *
  117. * FUNCTION: acpi_ev_install_sci_handler
  118. *
  119. * PARAMETERS: none
  120. *
  121. * RETURN: Status
  122. *
  123. * DESCRIPTION: Installs SCI handler.
  124. *
  125. ******************************************************************************/
  126. u32
  127. acpi_ev_install_sci_handler (
  128. void)
  129. {
  130. u32 status = AE_OK;
  131. ACPI_FUNCTION_TRACE ("ev_install_sci_handler");
  132. status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
  133. acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head);
  134. return_ACPI_STATUS (status);
  135. }
  136. /******************************************************************************
  137. *
  138. * FUNCTION: acpi_ev_remove_sci_handler
  139. *
  140. * PARAMETERS: none
  141. *
  142. * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
  143. * installed to begin with
  144. *
  145. * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
  146. * taken.
  147. *
  148. * Note: It doesn't seem important to disable all events or set the event
  149. * enable registers to their original values. The OS should disable
  150. * the SCI interrupt level when the handler is removed, so no more
  151. * events will come in.
  152. *
  153. ******************************************************************************/
  154. acpi_status
  155. acpi_ev_remove_sci_handler (
  156. void)
  157. {
  158. acpi_status status;
  159. ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
  160. /* Just let the OS remove the handler and disable the level */
  161. status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
  162. acpi_ev_sci_xrupt_handler);
  163. return_ACPI_STATUS (status);
  164. }