Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
0002 /*******************************************************************************
0003  *
0004  * Module Name: dbfileio - Debugger file I/O commands. These can't usually
0005  *              be used when running the debugger in Ring 0 (Kernel mode)
0006  *
0007  ******************************************************************************/
0008 
0009 #include <acpi/acpi.h>
0010 #include "accommon.h"
0011 #include "acdebug.h"
0012 #include "actables.h"
0013 
0014 #define _COMPONENT          ACPI_CA_DEBUGGER
0015 ACPI_MODULE_NAME("dbfileio")
0016 
0017 #ifdef ACPI_APPLICATION
0018 #include "acapps.h"
0019 #ifdef ACPI_DEBUGGER
0020 /*******************************************************************************
0021  *
0022  * FUNCTION:    acpi_db_close_debug_file
0023  *
0024  * PARAMETERS:  None
0025  *
0026  * RETURN:      None
0027  *
0028  * DESCRIPTION: If open, close the current debug output file
0029  *
0030  ******************************************************************************/
0031 void acpi_db_close_debug_file(void)
0032 {
0033 
0034     if (acpi_gbl_debug_file) {
0035         fclose(acpi_gbl_debug_file);
0036         acpi_gbl_debug_file = NULL;
0037         acpi_gbl_db_output_to_file = FALSE;
0038         acpi_os_printf("Debug output file %s closed\n",
0039                    acpi_gbl_db_debug_filename);
0040     }
0041 }
0042 
0043 /*******************************************************************************
0044  *
0045  * FUNCTION:    acpi_db_open_debug_file
0046  *
0047  * PARAMETERS:  name                - Filename to open
0048  *
0049  * RETURN:      None
0050  *
0051  * DESCRIPTION: Open a file where debug output will be directed.
0052  *
0053  ******************************************************************************/
0054 
0055 void acpi_db_open_debug_file(char *name)
0056 {
0057 
0058     acpi_db_close_debug_file();
0059     acpi_gbl_debug_file = fopen(name, "w+");
0060     if (!acpi_gbl_debug_file) {
0061         acpi_os_printf("Could not open debug file %s\n", name);
0062         return;
0063     }
0064 
0065     acpi_os_printf("Debug output file %s opened\n", name);
0066     acpi_ut_safe_strncpy(acpi_gbl_db_debug_filename, name,
0067                  sizeof(acpi_gbl_db_debug_filename));
0068     acpi_gbl_db_output_to_file = TRUE;
0069 }
0070 #endif
0071 
0072 /*******************************************************************************
0073  *
0074  * FUNCTION:    acpi_db_load_tables
0075  *
0076  * PARAMETERS:  list_head       - List of ACPI tables to load
0077  *
0078  * RETURN:      Status
0079  *
0080  * DESCRIPTION: Load ACPI tables from a previously constructed table list.
0081  *
0082  ******************************************************************************/
0083 
0084 acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
0085 {
0086     acpi_status status;
0087     struct acpi_new_table_desc *table_list_head;
0088     struct acpi_table_header *table;
0089 
0090     /* Load all ACPI tables in the list */
0091 
0092     table_list_head = list_head;
0093     while (table_list_head) {
0094         table = table_list_head->table;
0095 
0096         status = acpi_load_table(table, NULL);
0097         if (ACPI_FAILURE(status)) {
0098             if (status == AE_ALREADY_EXISTS) {
0099                 acpi_os_printf
0100                     ("Table %4.4s is already installed\n",
0101                      table->signature);
0102             } else {
0103                 acpi_os_printf("Could not install table, %s\n",
0104                            acpi_format_exception(status));
0105             }
0106 
0107             return (status);
0108         }
0109 
0110         acpi_os_printf
0111             ("Acpi table [%4.4s] successfully installed and loaded\n",
0112              table->signature);
0113 
0114         table_list_head = table_list_head->next;
0115     }
0116 
0117     return (AE_OK);
0118 }
0119 #endif