evsci.c 6.0 KB

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