utinit.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /******************************************************************************
  2. *
  3. * Module Name: utinit - Common ACPI subsystem initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2012, Intel Corp.
  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 "accommon.h"
  44. #include "acnamesp.h"
  45. #include "acevents.h"
  46. #include "actables.h"
  47. #define _COMPONENT ACPI_UTILITIES
  48. ACPI_MODULE_NAME("utinit")
  49. /* Local prototypes */
  50. static void acpi_ut_terminate(void);
  51. #if (!ACPI_REDUCED_HARDWARE)
  52. static void acpi_ut_free_gpe_lists(void);
  53. #else
  54. #define acpi_ut_free_gpe_lists()
  55. #endif /* !ACPI_REDUCED_HARDWARE */
  56. #if (!ACPI_REDUCED_HARDWARE)
  57. /******************************************************************************
  58. *
  59. * FUNCTION: acpi_ut_free_gpe_lists
  60. *
  61. * PARAMETERS: none
  62. *
  63. * RETURN: none
  64. *
  65. * DESCRIPTION: Free global GPE lists
  66. *
  67. ******************************************************************************/
  68. static void acpi_ut_free_gpe_lists(void)
  69. {
  70. struct acpi_gpe_block_info *gpe_block;
  71. struct acpi_gpe_block_info *next_gpe_block;
  72. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  73. struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
  74. /* Free global GPE blocks and related info structures */
  75. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  76. while (gpe_xrupt_info) {
  77. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  78. while (gpe_block) {
  79. next_gpe_block = gpe_block->next;
  80. ACPI_FREE(gpe_block->event_info);
  81. ACPI_FREE(gpe_block->register_info);
  82. ACPI_FREE(gpe_block);
  83. gpe_block = next_gpe_block;
  84. }
  85. next_gpe_xrupt_info = gpe_xrupt_info->next;
  86. ACPI_FREE(gpe_xrupt_info);
  87. gpe_xrupt_info = next_gpe_xrupt_info;
  88. }
  89. }
  90. #endif /* !ACPI_REDUCED_HARDWARE */
  91. /******************************************************************************
  92. *
  93. * FUNCTION: acpi_ut_terminate
  94. *
  95. * PARAMETERS: none
  96. *
  97. * RETURN: none
  98. *
  99. * DESCRIPTION: Free global memory
  100. *
  101. ******************************************************************************/
  102. static void acpi_ut_terminate(void)
  103. {
  104. ACPI_FUNCTION_TRACE(ut_terminate);
  105. acpi_ut_free_gpe_lists();
  106. acpi_ut_delete_address_lists();
  107. return_VOID;
  108. }
  109. /*******************************************************************************
  110. *
  111. * FUNCTION: acpi_ut_subsystem_shutdown
  112. *
  113. * PARAMETERS: None
  114. *
  115. * RETURN: None
  116. *
  117. * DESCRIPTION: Shutdown the various components. Do not delete the mutex
  118. * objects here, because the AML debugger may be still running.
  119. *
  120. ******************************************************************************/
  121. void acpi_ut_subsystem_shutdown(void)
  122. {
  123. ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
  124. #ifndef ACPI_ASL_COMPILER
  125. /* Close the acpi_event Handling */
  126. acpi_ev_terminate();
  127. /* Delete any dynamic _OSI interfaces */
  128. acpi_ut_interface_terminate();
  129. #endif
  130. /* Close the Namespace */
  131. acpi_ns_terminate();
  132. /* Delete the ACPI tables */
  133. acpi_tb_terminate();
  134. /* Close the globals */
  135. acpi_ut_terminate();
  136. /* Purge the local caches */
  137. (void)acpi_ut_delete_caches();
  138. return_VOID;
  139. }