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