utinit.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /******************************************************************************
  2. *
  3. * Module Name: utinit - Common ACPI subsystem initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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. #define _COMPONENT ACPI_UTILITIES
  46. ACPI_MODULE_NAME ("utinit")
  47. /*******************************************************************************
  48. *
  49. * FUNCTION: acpi_ut_fadt_register_error
  50. *
  51. * PARAMETERS: *register_name - Pointer to string identifying register
  52. * Value - Actual register contents value
  53. * acpi_test_spec_section - TDS section containing assertion
  54. * acpi_assertion - Assertion number being tested
  55. *
  56. * RETURN: AE_BAD_VALUE
  57. *
  58. * DESCRIPTION: Display failure message and link failure to TDS assertion
  59. *
  60. ******************************************************************************/
  61. static void
  62. acpi_ut_fadt_register_error (
  63. char *register_name,
  64. u32 value,
  65. acpi_size offset)
  66. {
  67. ACPI_REPORT_WARNING (
  68. ("Invalid FADT value %s=%X at offset %X FADT=%p\n",
  69. register_name, value, (u32) offset, acpi_gbl_FADT));
  70. }
  71. /******************************************************************************
  72. *
  73. * FUNCTION: acpi_ut_validate_fadt
  74. *
  75. * PARAMETERS: None
  76. *
  77. * RETURN: Status
  78. *
  79. * DESCRIPTION: Validate various ACPI registers in the FADT
  80. *
  81. ******************************************************************************/
  82. acpi_status
  83. acpi_ut_validate_fadt (
  84. void)
  85. {
  86. /*
  87. * Verify Fixed ACPI Description Table fields,
  88. * but don't abort on any problems, just display error
  89. */
  90. if (acpi_gbl_FADT->pm1_evt_len < 4) {
  91. acpi_ut_fadt_register_error ("PM1_EVT_LEN",
  92. (u32) acpi_gbl_FADT->pm1_evt_len,
  93. ACPI_FADT_OFFSET (pm1_evt_len));
  94. }
  95. if (!acpi_gbl_FADT->pm1_cnt_len) {
  96. acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0,
  97. ACPI_FADT_OFFSET (pm1_cnt_len));
  98. }
  99. if (!acpi_gbl_FADT->xpm1a_evt_blk.address) {
  100. acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0,
  101. ACPI_FADT_OFFSET (xpm1a_evt_blk.address));
  102. }
  103. if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) {
  104. acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0,
  105. ACPI_FADT_OFFSET (xpm1a_cnt_blk.address));
  106. }
  107. if (!acpi_gbl_FADT->xpm_tmr_blk.address) {
  108. acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0,
  109. ACPI_FADT_OFFSET (xpm_tmr_blk.address));
  110. }
  111. if ((acpi_gbl_FADT->xpm2_cnt_blk.address &&
  112. !acpi_gbl_FADT->pm2_cnt_len)) {
  113. acpi_ut_fadt_register_error ("PM2_CNT_LEN",
  114. (u32) acpi_gbl_FADT->pm2_cnt_len,
  115. ACPI_FADT_OFFSET (pm2_cnt_len));
  116. }
  117. if (acpi_gbl_FADT->pm_tm_len < 4) {
  118. acpi_ut_fadt_register_error ("PM_TM_LEN",
  119. (u32) acpi_gbl_FADT->pm_tm_len,
  120. ACPI_FADT_OFFSET (pm_tm_len));
  121. }
  122. /* Length of GPE blocks must be a multiple of 2 */
  123. if (acpi_gbl_FADT->xgpe0_blk.address &&
  124. (acpi_gbl_FADT->gpe0_blk_len & 1)) {
  125. acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN",
  126. (u32) acpi_gbl_FADT->gpe0_blk_len,
  127. ACPI_FADT_OFFSET (gpe0_blk_len));
  128. }
  129. if (acpi_gbl_FADT->xgpe1_blk.address &&
  130. (acpi_gbl_FADT->gpe1_blk_len & 1)) {
  131. acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN",
  132. (u32) acpi_gbl_FADT->gpe1_blk_len,
  133. ACPI_FADT_OFFSET (gpe1_blk_len));
  134. }
  135. return (AE_OK);
  136. }
  137. /******************************************************************************
  138. *
  139. * FUNCTION: acpi_ut_terminate
  140. *
  141. * PARAMETERS: none
  142. *
  143. * RETURN: none
  144. *
  145. * DESCRIPTION: free global memory
  146. *
  147. ******************************************************************************/
  148. void
  149. acpi_ut_terminate (void)
  150. {
  151. struct acpi_gpe_block_info *gpe_block;
  152. struct acpi_gpe_block_info *next_gpe_block;
  153. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  154. struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
  155. ACPI_FUNCTION_TRACE ("ut_terminate");
  156. /* Free global tables, etc. */
  157. /* Free global GPE blocks and related info structures */
  158. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  159. while (gpe_xrupt_info) {
  160. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  161. while (gpe_block) {
  162. next_gpe_block = gpe_block->next;
  163. ACPI_MEM_FREE (gpe_block->event_info);
  164. ACPI_MEM_FREE (gpe_block->register_info);
  165. ACPI_MEM_FREE (gpe_block);
  166. gpe_block = next_gpe_block;
  167. }
  168. next_gpe_xrupt_info = gpe_xrupt_info->next;
  169. ACPI_MEM_FREE (gpe_xrupt_info);
  170. gpe_xrupt_info = next_gpe_xrupt_info;
  171. }
  172. return_VOID;
  173. }
  174. /*******************************************************************************
  175. *
  176. * FUNCTION: acpi_ut_subsystem_shutdown
  177. *
  178. * PARAMETERS: none
  179. *
  180. * RETURN: none
  181. *
  182. * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
  183. * objects here -- because the AML debugger may be still running.
  184. *
  185. ******************************************************************************/
  186. void
  187. acpi_ut_subsystem_shutdown (void)
  188. {
  189. ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown");
  190. /* Just exit if subsystem is already shutdown */
  191. if (acpi_gbl_shutdown) {
  192. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n"));
  193. return_VOID;
  194. }
  195. /* Subsystem appears active, go ahead and shut it down */
  196. acpi_gbl_shutdown = TRUE;
  197. ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
  198. /* Close the acpi_event Handling */
  199. acpi_ev_terminate ();
  200. /* Close the Namespace */
  201. acpi_ns_terminate ();
  202. /* Close the globals */
  203. acpi_ut_terminate ();
  204. /* Purge the local caches */
  205. (void) acpi_purge_cached_objects ();
  206. /* Debug only - display leftover memory allocation, if any */
  207. #ifdef ACPI_DBG_TRACK_ALLOCATIONS
  208. acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL);
  209. #endif
  210. return_VOID;
  211. }