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 /* 9 * Copyright (C) 2000 - 2016, Intel Corp. 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.h" 46 #include "accommon.h" 47 #include "acdebug.h" 48 #include "actables.h" 49 #ifndef _KERNEL 50 #include <stdio.h> 51 #endif 52 #ifdef ACPI_APPLICATION 53 #include "acapps.h" 54 #endif 55 56 #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) 57 58 #define _COMPONENT ACPI_CA_DEBUGGER 59 ACPI_MODULE_NAME ("dbfileio") 60 61 #ifdef ACPI_DEBUGGER 62 63 /******************************************************************************* 64 * 65 * FUNCTION: AcpiDbCloseDebugFile 66 * 67 * PARAMETERS: None 68 * 69 * RETURN: None 70 * 71 * DESCRIPTION: If open, close the current debug output file 72 * 73 ******************************************************************************/ 74 75 void 76 AcpiDbCloseDebugFile ( 77 void) 78 { 79 80 #ifdef ACPI_APPLICATION 81 82 if (AcpiGbl_DebugFile) 83 { 84 fclose (AcpiGbl_DebugFile); 85 AcpiGbl_DebugFile = NULL; 86 AcpiGbl_DbOutputToFile = FALSE; 87 AcpiOsPrintf ("Debug output file %s closed\n", 88 AcpiGbl_DbDebugFilename); 89 } 90 #endif 91 } 92 93 94 /******************************************************************************* 95 * 96 * FUNCTION: AcpiDbOpenDebugFile 97 * 98 * PARAMETERS: Name - Filename to open 99 * 100 * RETURN: None 101 * 102 * DESCRIPTION: Open a file where debug output will be directed. 103 * 104 ******************************************************************************/ 105 106 void 107 AcpiDbOpenDebugFile ( 108 char *Name) 109 { 110 111 #ifdef ACPI_APPLICATION 112 113 AcpiDbCloseDebugFile (); 114 AcpiGbl_DebugFile = fopen (Name, "w+"); 115 if (!AcpiGbl_DebugFile) 116 { 117 AcpiOsPrintf ("Could not open debug file %s\n", Name); 118 return; 119 } 120 121 AcpiOsPrintf ("Debug output file %s opened\n", Name); 122 strncpy (AcpiGbl_DbDebugFilename, Name, 123 sizeof (AcpiGbl_DbDebugFilename)); 124 AcpiGbl_DbOutputToFile = TRUE; 125 126 #endif 127 } 128 #endif 129 130 131 /******************************************************************************* 132 * 133 * FUNCTION: AcpiDbLoadTables 134 * 135 * PARAMETERS: ListHead - List of ACPI tables to load 136 * 137 * RETURN: Status 138 * 139 * DESCRIPTION: Load ACPI tables from a previously constructed table list. 140 * 141 ******************************************************************************/ 142 143 ACPI_STATUS 144 AcpiDbLoadTables ( 145 ACPI_NEW_TABLE_DESC *ListHead) 146 { 147 #ifdef ACPI_APPLICATION 148 ACPI_STATUS Status; 149 ACPI_NEW_TABLE_DESC *TableListHead; 150 ACPI_TABLE_HEADER *Table; 151 152 153 /* Load all ACPI tables in the list */ 154 155 TableListHead = ListHead; 156 while (TableListHead) 157 { 158 Table = TableListHead->Table; 159 160 Status = AcpiLoadTable (Table); 161 if (ACPI_FAILURE (Status)) 162 { 163 if (Status == AE_ALREADY_EXISTS) 164 { 165 AcpiOsPrintf ("Table %4.4s is already installed\n", 166 Table->Signature); 167 } 168 else 169 { 170 AcpiOsPrintf ("Could not install table, %s\n", 171 AcpiFormatException (Status)); 172 } 173 174 return (Status); 175 } 176 177 fprintf (stderr, 178 "Acpi table [%4.4s] successfully installed and loaded\n", 179 Table->Signature); 180 181 TableListHead = TableListHead->Next; 182 } 183 184 185 #endif /* ACPI_APPLICATION */ 186 return (AE_OK); 187 } 188 189 #endif /* ACPI_DEBUGGER */ 190