evsci.c 6.1 KB

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