utinit.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /******************************************************************************
  2. *
  3. * Module Name: utinit - Common ACPI subsystem initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/acnamesp.h>
  44. #include <acpi/acevents.h>
  45. #include <acpi/actables.h>
  46. #define _COMPONENT ACPI_UTILITIES
  47. ACPI_MODULE_NAME("utinit")
  48. /* Local prototypes */
  49. static void acpi_ut_fadt_register_error(char *register_name, u32 value);
  50. static void acpi_ut_terminate(void);
  51. /*******************************************************************************
  52. *
  53. * FUNCTION: acpi_ut_fadt_register_error
  54. *
  55. * PARAMETERS: register_name - Pointer to string identifying register
  56. * Value - Actual register contents value
  57. *
  58. * RETURN: None
  59. *
  60. * DESCRIPTION: Display failure message
  61. *
  62. ******************************************************************************/
  63. static void acpi_ut_fadt_register_error(char *register_name, u32 value)
  64. {
  65. ACPI_WARNING((AE_INFO, "Invalid FADT value %s = %X",
  66. register_name, value));
  67. }
  68. /******************************************************************************
  69. *
  70. * FUNCTION: acpi_ut_validate_fadt
  71. *
  72. * PARAMETERS: None
  73. *
  74. * RETURN: Status
  75. *
  76. * DESCRIPTION: Validate various ACPI registers in the FADT
  77. *
  78. ******************************************************************************/
  79. acpi_status acpi_ut_validate_fadt(void)
  80. {
  81. /*
  82. * Verify Fixed ACPI Description Table fields,
  83. * but don't abort on any problems, just display error
  84. */
  85. if (acpi_gbl_FADT.pm1_event_length < 4) {
  86. acpi_ut_fadt_register_error("Pm1EventLength",
  87. (u32) acpi_gbl_FADT.
  88. pm1_event_length);
  89. }
  90. if (acpi_gbl_FADT.pm_timer_length < 4) {
  91. acpi_ut_fadt_register_error("PmTimerLength",
  92. (u32) acpi_gbl_FADT.
  93. pm_timer_length);
  94. }
  95. if (!acpi_gbl_FADT.pm1_control_length) {
  96. acpi_ut_fadt_register_error("Pm1ControlLength", 0);
  97. }
  98. if (!acpi_gbl_FADT.xpm1a_event_block.address) {
  99. acpi_ut_fadt_register_error("XPm1aEventBlock.Address", 0);
  100. }
  101. if (!acpi_gbl_FADT.xpm1a_control_block.address) {
  102. acpi_ut_fadt_register_error("XPm1aControlBlock.Address", 0);
  103. }
  104. if (!acpi_gbl_FADT.xpm_timer_block.address) {
  105. acpi_ut_fadt_register_error("XPmTimerBlock.Address", 0);
  106. }
  107. if ((acpi_gbl_FADT.xpm2_control_block.address &&
  108. !acpi_gbl_FADT.pm2_control_length)) {
  109. acpi_ut_fadt_register_error("Pm2ControlLength",
  110. (u32) acpi_gbl_FADT.
  111. pm2_control_length);
  112. }
  113. /* Length of GPE blocks must be a multiple of 2 */
  114. if (acpi_gbl_FADT.xgpe0_block.address &&
  115. (acpi_gbl_FADT.gpe0_block_length & 1)) {
  116. acpi_ut_fadt_register_error("Gpe0BlockLength",
  117. (u32) acpi_gbl_FADT.
  118. gpe0_block_length);
  119. }
  120. if (acpi_gbl_FADT.xgpe1_block.address &&
  121. (acpi_gbl_FADT.gpe1_block_length & 1)) {
  122. acpi_ut_fadt_register_error("Gpe1BlockLength",
  123. (u32) acpi_gbl_FADT.
  124. gpe1_block_length);
  125. }
  126. return (AE_OK);
  127. }
  128. /******************************************************************************
  129. *
  130. * FUNCTION: acpi_ut_terminate
  131. *
  132. * PARAMETERS: none
  133. *
  134. * RETURN: none
  135. *
  136. * DESCRIPTION: Free global memory
  137. *
  138. ******************************************************************************/
  139. static void acpi_ut_terminate(void)
  140. {
  141. struct acpi_gpe_block_info *gpe_block;
  142. struct acpi_gpe_block_info *next_gpe_block;
  143. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  144. struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
  145. ACPI_FUNCTION_TRACE(ut_terminate);
  146. /* Free global GPE blocks and related info structures */
  147. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  148. while (gpe_xrupt_info) {
  149. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  150. while (gpe_block) {
  151. next_gpe_block = gpe_block->next;
  152. ACPI_FREE(gpe_block->event_info);
  153. ACPI_FREE(gpe_block->register_info);
  154. ACPI_FREE(gpe_block);
  155. gpe_block = next_gpe_block;
  156. }
  157. next_gpe_xrupt_info = gpe_xrupt_info->next;
  158. ACPI_FREE(gpe_xrupt_info);
  159. gpe_xrupt_info = next_gpe_xrupt_info;
  160. }
  161. return_VOID;
  162. }
  163. /*******************************************************************************
  164. *
  165. * FUNCTION: acpi_ut_subsystem_shutdown
  166. *
  167. * PARAMETERS: none
  168. *
  169. * RETURN: none
  170. *
  171. * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
  172. * objects here -- because the AML debugger may be still running.
  173. *
  174. ******************************************************************************/
  175. void acpi_ut_subsystem_shutdown(void)
  176. {
  177. ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
  178. /* Just exit if subsystem is already shutdown */
  179. if (acpi_gbl_shutdown) {
  180. ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
  181. return_VOID;
  182. }
  183. /* Subsystem appears active, go ahead and shut it down */
  184. acpi_gbl_shutdown = TRUE;
  185. acpi_gbl_startup_flags = 0;
  186. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
  187. /* Close the acpi_event Handling */
  188. acpi_ev_terminate();
  189. /* Close the Namespace */
  190. acpi_ns_terminate();
  191. /* Delete the ACPI tables */
  192. acpi_tb_terminate();
  193. /* Close the globals */
  194. acpi_ut_terminate();
  195. /* Purge the local caches */
  196. (void)acpi_ut_delete_caches();
  197. return_VOID;
  198. }