Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: dbfileio - Debugger file I/O commands. These can't usually |
| 4 | * be used when running the debugger in Ring 0 (Kernel mode) |
| 5 | * |
| 6 | ******************************************************************************/ |
| 7 | |
| 8 | /* |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2016, Intel Corp. |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
| 45 | #include <acpi/acpi.h> |
| 46 | #include "accommon.h" |
| 47 | #include "acdebug.h" |
| 48 | #include "actables.h" |
| 49 | |
| 50 | #define _COMPONENT ACPI_CA_DEBUGGER |
| 51 | ACPI_MODULE_NAME("dbfileio") |
| 52 | |
Lv Zheng | e8f2c16 | 2016-08-04 16:44:04 +0800 | [diff] [blame] | 53 | #ifdef ACPI_APPLICATION |
| 54 | #include "acapps.h" |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 55 | #ifdef ACPI_DEBUGGER |
| 56 | /******************************************************************************* |
| 57 | * |
| 58 | * FUNCTION: acpi_db_close_debug_file |
| 59 | * |
| 60 | * PARAMETERS: None |
| 61 | * |
| 62 | * RETURN: None |
| 63 | * |
| 64 | * DESCRIPTION: If open, close the current debug output file |
| 65 | * |
| 66 | ******************************************************************************/ |
| 67 | void acpi_db_close_debug_file(void) |
| 68 | { |
| 69 | |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 70 | if (acpi_gbl_debug_file) { |
| 71 | fclose(acpi_gbl_debug_file); |
| 72 | acpi_gbl_debug_file = NULL; |
| 73 | acpi_gbl_db_output_to_file = FALSE; |
| 74 | acpi_os_printf("Debug output file %s closed\n", |
| 75 | acpi_gbl_db_debug_filename); |
| 76 | } |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /******************************************************************************* |
| 80 | * |
| 81 | * FUNCTION: acpi_db_open_debug_file |
| 82 | * |
| 83 | * PARAMETERS: name - Filename to open |
| 84 | * |
| 85 | * RETURN: None |
| 86 | * |
| 87 | * DESCRIPTION: Open a file where debug output will be directed. |
| 88 | * |
| 89 | ******************************************************************************/ |
| 90 | |
| 91 | void acpi_db_open_debug_file(char *name) |
| 92 | { |
| 93 | |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 94 | acpi_db_close_debug_file(); |
| 95 | acpi_gbl_debug_file = fopen(name, "w+"); |
| 96 | if (!acpi_gbl_debug_file) { |
| 97 | acpi_os_printf("Could not open debug file %s\n", name); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | acpi_os_printf("Debug output file %s opened\n", name); |
| 102 | strncpy(acpi_gbl_db_debug_filename, name, |
| 103 | sizeof(acpi_gbl_db_debug_filename)); |
| 104 | acpi_gbl_db_output_to_file = TRUE; |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 105 | } |
| 106 | #endif |
| 107 | |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 108 | /******************************************************************************* |
| 109 | * |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 110 | * FUNCTION: acpi_db_load_tables |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 111 | * |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 112 | * PARAMETERS: list_head - List of ACPI tables to load |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 113 | * |
| 114 | * RETURN: Status |
| 115 | * |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 116 | * DESCRIPTION: Load ACPI tables from a previously constructed table list. |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 117 | * |
| 118 | ******************************************************************************/ |
| 119 | |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 120 | 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] | 121 | { |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 122 | acpi_status status; |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 123 | struct acpi_new_table_desc *table_list_head; |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 124 | struct acpi_table_header *table; |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 125 | |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 126 | /* Load all ACPI tables in the list */ |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 127 | |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 128 | table_list_head = list_head; |
| 129 | while (table_list_head) { |
| 130 | table = table_list_head->table; |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 131 | |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 132 | status = acpi_load_table(table); |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 133 | if (ACPI_FAILURE(status)) { |
| 134 | if (status == AE_ALREADY_EXISTS) { |
| 135 | acpi_os_printf |
| 136 | ("Table %4.4s is already installed\n", |
| 137 | table->signature); |
| 138 | } else { |
| 139 | acpi_os_printf("Could not install table, %s\n", |
| 140 | acpi_format_exception(status)); |
| 141 | } |
| 142 | |
| 143 | return (status); |
| 144 | } |
| 145 | |
Lv Zheng | e8f2c16 | 2016-08-04 16:44:04 +0800 | [diff] [blame] | 146 | acpi_os_printf |
| 147 | ("Acpi table [%4.4s] successfully installed and loaded\n", |
| 148 | table->signature); |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 149 | |
| 150 | table_list_head = table_list_head->next; |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 151 | } |
| 152 | |
Lv Zheng | 9957510 | 2015-10-19 10:25:20 +0800 | [diff] [blame] | 153 | return (AE_OK); |
| 154 | } |
Lv Zheng | e8f2c16 | 2016-08-04 16:44:04 +0800 | [diff] [blame] | 155 | #endif |