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