dbfileio.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: dbfileio - Debugger file I/O commands. These can't usually
  5. * be used when running the debugger in Ring 0 (Kernel mode)
  6. *
  7. ******************************************************************************/
  8. #include <acpi/acpi.h>
  9. #include "accommon.h"
  10. #include "acdebug.h"
  11. #include "actables.h"
  12. #define _COMPONENT ACPI_CA_DEBUGGER
  13. ACPI_MODULE_NAME("dbfileio")
  14. #ifdef ACPI_APPLICATION
  15. #include "acapps.h"
  16. #ifdef ACPI_DEBUGGER
  17. /*******************************************************************************
  18. *
  19. * FUNCTION: acpi_db_close_debug_file
  20. *
  21. * PARAMETERS: None
  22. *
  23. * RETURN: None
  24. *
  25. * DESCRIPTION: If open, close the current debug output file
  26. *
  27. ******************************************************************************/
  28. void acpi_db_close_debug_file(void)
  29. {
  30. if (acpi_gbl_debug_file) {
  31. fclose(acpi_gbl_debug_file);
  32. acpi_gbl_debug_file = NULL;
  33. acpi_gbl_db_output_to_file = FALSE;
  34. acpi_os_printf("Debug output file %s closed\n",
  35. acpi_gbl_db_debug_filename);
  36. }
  37. }
  38. /*******************************************************************************
  39. *
  40. * FUNCTION: acpi_db_open_debug_file
  41. *
  42. * PARAMETERS: name - Filename to open
  43. *
  44. * RETURN: None
  45. *
  46. * DESCRIPTION: Open a file where debug output will be directed.
  47. *
  48. ******************************************************************************/
  49. void acpi_db_open_debug_file(char *name)
  50. {
  51. acpi_db_close_debug_file();
  52. acpi_gbl_debug_file = fopen(name, "w+");
  53. if (!acpi_gbl_debug_file) {
  54. acpi_os_printf("Could not open debug file %s\n", name);
  55. return;
  56. }
  57. acpi_os_printf("Debug output file %s opened\n", name);
  58. acpi_ut_safe_strncpy(acpi_gbl_db_debug_filename, name,
  59. sizeof(acpi_gbl_db_debug_filename));
  60. acpi_gbl_db_output_to_file = TRUE;
  61. }
  62. #endif
  63. /*******************************************************************************
  64. *
  65. * FUNCTION: acpi_db_load_tables
  66. *
  67. * PARAMETERS: list_head - List of ACPI tables to load
  68. *
  69. * RETURN: Status
  70. *
  71. * DESCRIPTION: Load ACPI tables from a previously constructed table list.
  72. *
  73. ******************************************************************************/
  74. acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
  75. {
  76. acpi_status status;
  77. struct acpi_new_table_desc *table_list_head;
  78. struct acpi_table_header *table;
  79. /* Load all ACPI tables in the list */
  80. table_list_head = list_head;
  81. while (table_list_head) {
  82. table = table_list_head->table;
  83. status = acpi_load_table(table, NULL);
  84. if (ACPI_FAILURE(status)) {
  85. if (status == AE_ALREADY_EXISTS) {
  86. acpi_os_printf
  87. ("Table %4.4s is already installed\n",
  88. table->signature);
  89. } else {
  90. acpi_os_printf("Could not install table, %s\n",
  91. acpi_format_exception(status));
  92. }
  93. return (status);
  94. }
  95. acpi_os_printf
  96. ("Acpi table [%4.4s] successfully installed and loaded\n",
  97. table->signature);
  98. table_list_head = table_list_head->next;
  99. }
  100. return (AE_OK);
  101. }
  102. #endif