evsci.c 6.0 KB

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