// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.01/*******************************************************************************2*3* Module Name: dbfileio - Debugger file I/O commands. These can't usually4* be used when running the debugger in Ring 0 (Kernel mode)5*6******************************************************************************/78#include <acpi/acpi.h>9#include "accommon.h"10#include "acdebug.h"11#include "actables.h"1213#define _COMPONENT ACPI_CA_DEBUGGER14ACPI_MODULE_NAME("dbfileio")1516#ifdef ACPI_APPLICATION17#include "acapps.h"18#ifdef ACPI_DEBUGGER19/*******************************************************************************20*21* FUNCTION: acpi_db_close_debug_file22*23* PARAMETERS: None24*25* RETURN: None26*27* DESCRIPTION: If open, close the current debug output file28*29******************************************************************************/30void acpi_db_close_debug_file(void)31{3233if (acpi_gbl_debug_file) {34fclose(acpi_gbl_debug_file);35acpi_gbl_debug_file = NULL;36acpi_gbl_db_output_to_file = FALSE;37acpi_os_printf("Debug output file %s closed\n",38acpi_gbl_db_debug_filename);39}40}4142/*******************************************************************************43*44* FUNCTION: acpi_db_open_debug_file45*46* PARAMETERS: name - Filename to open47*48* RETURN: None49*50* DESCRIPTION: Open a file where debug output will be directed.51*52******************************************************************************/5354void acpi_db_open_debug_file(char *name)55{5657acpi_db_close_debug_file();58acpi_gbl_debug_file = fopen(name, "w+");59if (!acpi_gbl_debug_file) {60acpi_os_printf("Could not open debug file %s\n", name);61return;62}6364acpi_os_printf("Debug output file %s opened\n", name);65acpi_ut_safe_strncpy(acpi_gbl_db_debug_filename, name,66sizeof(acpi_gbl_db_debug_filename));67acpi_gbl_db_output_to_file = TRUE;68}69#endif7071/*******************************************************************************72*73* FUNCTION: acpi_db_load_tables74*75* PARAMETERS: list_head - List of ACPI tables to load76*77* RETURN: Status78*79* DESCRIPTION: Load ACPI tables from a previously constructed table list.80*81******************************************************************************/8283acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)84{85acpi_status status;86struct acpi_new_table_desc *table_list_head;87struct acpi_table_header *table;8889/* Load all ACPI tables in the list */9091table_list_head = list_head;92while (table_list_head) {93table = table_list_head->table;9495status = acpi_load_table(table, NULL);96if (ACPI_FAILURE(status)) {97if (status == AE_ALREADY_EXISTS) {98acpi_os_printf99("Table %4.4s is already installed\n",100table->signature);101} else {102acpi_os_printf("Could not install table, %s\n",103acpi_format_exception(status));104}105106return (status);107}108109acpi_os_printf110("Acpi table [%4.4s] successfully installed and loaded\n",111table->signature);112113table_list_head = table_list_head->next;114}115116return (AE_OK);117}118#endif119120121