utinit.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /******************************************************************************
  2. *
  3. * Module Name: utinit - Common ACPI subsystem initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, 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 <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_terminate(void);
  50. /******************************************************************************
  51. *
  52. * FUNCTION: acpi_ut_terminate
  53. *
  54. * PARAMETERS: none
  55. *
  56. * RETURN: none
  57. *
  58. * DESCRIPTION: Free global memory
  59. *
  60. ******************************************************************************/
  61. static void acpi_ut_terminate(void)
  62. {
  63. struct acpi_gpe_block_info *gpe_block;
  64. struct acpi_gpe_block_info *next_gpe_block;
  65. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  66. struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
  67. ACPI_FUNCTION_TRACE(ut_terminate);
  68. /* Free global GPE blocks and related info structures */
  69. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  70. while (gpe_xrupt_info) {
  71. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  72. while (gpe_block) {
  73. next_gpe_block = gpe_block->next;
  74. ACPI_FREE(gpe_block->event_info);
  75. ACPI_FREE(gpe_block->register_info);
  76. ACPI_FREE(gpe_block);
  77. gpe_block = next_gpe_block;
  78. }
  79. next_gpe_xrupt_info = gpe_xrupt_info->next;
  80. ACPI_FREE(gpe_xrupt_info);
  81. gpe_xrupt_info = next_gpe_xrupt_info;
  82. }
  83. return_VOID;
  84. }
  85. /*******************************************************************************
  86. *
  87. * FUNCTION: acpi_ut_subsystem_shutdown
  88. *
  89. * PARAMETERS: none
  90. *
  91. * RETURN: none
  92. *
  93. * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
  94. * objects here -- because the AML debugger may be still running.
  95. *
  96. ******************************************************************************/
  97. void acpi_ut_subsystem_shutdown(void)
  98. {
  99. ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
  100. /* Just exit if subsystem is already shutdown */
  101. if (acpi_gbl_shutdown) {
  102. ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
  103. return_VOID;
  104. }
  105. /* Subsystem appears active, go ahead and shut it down */
  106. acpi_gbl_shutdown = TRUE;
  107. acpi_gbl_startup_flags = 0;
  108. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
  109. #ifndef ACPI_ASL_COMPILER
  110. /* Close the acpi_event Handling */
  111. acpi_ev_terminate();
  112. #endif
  113. /* Close the Namespace */
  114. acpi_ns_terminate();
  115. /* Delete the ACPI tables */
  116. acpi_tb_terminate();
  117. /* Close the globals */
  118. acpi_ut_terminate();
  119. /* Purge the local caches */
  120. (void)acpi_ut_delete_caches();
  121. return_VOID;
  122. }