dbfileio.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*******************************************************************************
  2. *
  3. * Module Name: dbfileio - Debugger file I/O commands. These can't usually
  4. * be used when running the debugger in Ring 0 (Kernel mode)
  5. *
  6. ******************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2016, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #include <acpi/acpi.h>
  44. #include "accommon.h"
  45. #include "acdebug.h"
  46. #include "actables.h"
  47. #define _COMPONENT ACPI_CA_DEBUGGER
  48. ACPI_MODULE_NAME("dbfileio")
  49. #ifdef ACPI_APPLICATION
  50. #include "acapps.h"
  51. #ifdef ACPI_DEBUGGER
  52. /*******************************************************************************
  53. *
  54. * FUNCTION: acpi_db_close_debug_file
  55. *
  56. * PARAMETERS: None
  57. *
  58. * RETURN: None
  59. *
  60. * DESCRIPTION: If open, close the current debug output file
  61. *
  62. ******************************************************************************/
  63. void acpi_db_close_debug_file(void)
  64. {
  65. if (acpi_gbl_debug_file) {
  66. fclose(acpi_gbl_debug_file);
  67. acpi_gbl_debug_file = NULL;
  68. acpi_gbl_db_output_to_file = FALSE;
  69. acpi_os_printf("Debug output file %s closed\n",
  70. acpi_gbl_db_debug_filename);
  71. }
  72. }
  73. /*******************************************************************************
  74. *
  75. * FUNCTION: acpi_db_open_debug_file
  76. *
  77. * PARAMETERS: name - Filename to open
  78. *
  79. * RETURN: None
  80. *
  81. * DESCRIPTION: Open a file where debug output will be directed.
  82. *
  83. ******************************************************************************/
  84. void acpi_db_open_debug_file(char *name)
  85. {
  86. acpi_db_close_debug_file();
  87. acpi_gbl_debug_file = fopen(name, "w+");
  88. if (!acpi_gbl_debug_file) {
  89. acpi_os_printf("Could not open debug file %s\n", name);
  90. return;
  91. }
  92. acpi_os_printf("Debug output file %s opened\n", name);
  93. strncpy(acpi_gbl_db_debug_filename, name,
  94. sizeof(acpi_gbl_db_debug_filename));
  95. acpi_gbl_db_output_to_file = TRUE;
  96. }
  97. #endif
  98. /*******************************************************************************
  99. *
  100. * FUNCTION: acpi_db_load_tables
  101. *
  102. * PARAMETERS: list_head - List of ACPI tables to load
  103. *
  104. * RETURN: Status
  105. *
  106. * DESCRIPTION: Load ACPI tables from a previously constructed table list.
  107. *
  108. ******************************************************************************/
  109. acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
  110. {
  111. acpi_status status;
  112. struct acpi_new_table_desc *table_list_head;
  113. struct acpi_table_header *table;
  114. /* Load all ACPI tables in the list */
  115. table_list_head = list_head;
  116. while (table_list_head) {
  117. table = table_list_head->table;
  118. status = acpi_load_table(table);
  119. if (ACPI_FAILURE(status)) {
  120. if (status == AE_ALREADY_EXISTS) {
  121. acpi_os_printf
  122. ("Table %4.4s is already installed\n",
  123. table->signature);
  124. } else {
  125. acpi_os_printf("Could not install table, %s\n",
  126. acpi_format_exception(status));
  127. }
  128. return (status);
  129. }
  130. acpi_os_printf
  131. ("Acpi table [%4.4s] successfully installed and loaded\n",
  132. table->signature);
  133. table_list_head = table_list_head->next;
  134. }
  135. return (AE_OK);
  136. }
  137. #endif