utinit.c 4.5 KB

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