dbfileio.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. #include <stdio.h>
  48. #ifdef ACPI_APPLICATION
  49. #include "acapps.h"
  50. #endif
  51. #define _COMPONENT ACPI_CA_DEBUGGER
  52. ACPI_MODULE_NAME("dbfileio")
  53. #ifdef ACPI_DEBUGGER
  54. /*******************************************************************************
  55. *
  56. * FUNCTION: acpi_db_close_debug_file
  57. *
  58. * PARAMETERS: None
  59. *
  60. * RETURN: None
  61. *
  62. * DESCRIPTION: If open, close the current debug output file
  63. *
  64. ******************************************************************************/
  65. void acpi_db_close_debug_file(void)
  66. {
  67. #ifdef ACPI_APPLICATION
  68. if (acpi_gbl_debug_file) {
  69. fclose(acpi_gbl_debug_file);
  70. acpi_gbl_debug_file = NULL;
  71. acpi_gbl_db_output_to_file = FALSE;
  72. acpi_os_printf("Debug output file %s closed\n",
  73. acpi_gbl_db_debug_filename);
  74. }
  75. #endif
  76. }
  77. /*******************************************************************************
  78. *
  79. * FUNCTION: acpi_db_open_debug_file
  80. *
  81. * PARAMETERS: name - Filename to open
  82. *
  83. * RETURN: None
  84. *
  85. * DESCRIPTION: Open a file where debug output will be directed.
  86. *
  87. ******************************************************************************/
  88. void acpi_db_open_debug_file(char *name)
  89. {
  90. #ifdef ACPI_APPLICATION
  91. acpi_db_close_debug_file();
  92. acpi_gbl_debug_file = fopen(name, "w+");
  93. if (!acpi_gbl_debug_file) {
  94. acpi_os_printf("Could not open debug file %s\n", name);
  95. return;
  96. }
  97. acpi_os_printf("Debug output file %s opened\n", name);
  98. strncpy(acpi_gbl_db_debug_filename, name,
  99. sizeof(acpi_gbl_db_debug_filename));
  100. acpi_gbl_db_output_to_file = TRUE;
  101. #endif
  102. }
  103. #endif
  104. /*******************************************************************************
  105. *
  106. * FUNCTION: acpi_db_load_tables
  107. *
  108. * PARAMETERS: list_head - List of ACPI tables to load
  109. *
  110. * RETURN: Status
  111. *
  112. * DESCRIPTION: Load ACPI tables from a previously constructed table list.
  113. *
  114. ******************************************************************************/
  115. acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
  116. {
  117. acpi_status status;
  118. struct acpi_new_table_desc *table_list_head;
  119. struct acpi_table_header *table;
  120. /* Load all ACPI tables in the list */
  121. table_list_head = list_head;
  122. while (table_list_head) {
  123. table = table_list_head->table;
  124. status = acpi_load_table(table);
  125. if (ACPI_FAILURE(status)) {
  126. if (status == AE_ALREADY_EXISTS) {
  127. acpi_os_printf
  128. ("Table %4.4s is already installed\n",
  129. table->signature);
  130. } else {
  131. acpi_os_printf("Could not install table, %s\n",
  132. acpi_format_exception(status));
  133. }
  134. return (status);
  135. }
  136. fprintf(stderr,
  137. "Acpi table [%4.4s] successfully installed and loaded\n",
  138. table->signature);
  139. table_list_head = table_list_head->next;
  140. }
  141. return (AE_OK);
  142. }