167754Smsmith/******************************************************************************* 267754Smsmith * 3193267Sjkim * Module Name: dbfileio - Debugger file I/O commands. These can't usually 467754Smsmith * be used when running the debugger in Ring 0 (Kernel mode) 567754Smsmith * 667754Smsmith ******************************************************************************/ 767754Smsmith 8316303Sjkim/****************************************************************************** 9316303Sjkim * 10316303Sjkim * 1. Copyright Notice 11316303Sjkim * 12316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 15316303Sjkim * 2. License 16316303Sjkim * 17316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 18316303Sjkim * rights. You may have additional license terms from the party that provided 19316303Sjkim * you this software, covering your right to use that party's intellectual 20316303Sjkim * property rights. 21316303Sjkim * 22316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 24316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 26316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 27316303Sjkim * Code in any form, with the right to sublicense such rights; and 28316303Sjkim * 29316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30316303Sjkim * license (with the right to sublicense), under only those claims of Intel 31316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 32316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 33316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 34316303Sjkim * license, and in no event shall the patent license extend to any additions 35316303Sjkim * to or modifications of the Original Intel Code. No other license or right 36316303Sjkim * is granted directly or by implication, estoppel or otherwise; 37316303Sjkim * 38316303Sjkim * The above copyright and patent license is granted only if the following 39316303Sjkim * conditions are met: 40316303Sjkim * 41316303Sjkim * 3. Conditions 42316303Sjkim * 43316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44316303Sjkim * Redistribution of source code of any substantial portion of the Covered 45316303Sjkim * Code or modification with rights to further distribute source must include 46316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 47316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 48316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 49316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 50316303Sjkim * Code and the date of any change. Licensee must include in that file the 51316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 52316303Sjkim * must include a prominent statement that the modification is derived, 53316303Sjkim * directly or indirectly, from Original Intel Code. 54316303Sjkim * 55316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56316303Sjkim * Redistribution of source code of any substantial portion of the Covered 57316303Sjkim * Code or modification without rights to further distribute source must 58316303Sjkim * include the following Disclaimer and Export Compliance provision in the 59316303Sjkim * documentation and/or other materials provided with distribution. In 60316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 61316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 62316303Sjkim * license from Licensee to its licensee is limited to the intellectual 63316303Sjkim * property embodied in the software Licensee provides to its licensee, and 64316303Sjkim * not to intellectual property embodied in modifications its licensee may 65316303Sjkim * make. 66316303Sjkim * 67316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 68316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 69316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 70316303Sjkim * provision in the documentation and/or other materials provided with the 71316303Sjkim * distribution. 72316303Sjkim * 73316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 74316303Sjkim * Intel Code. 75316303Sjkim * 76316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 78316303Sjkim * other dealings in products derived from or relating to the Covered Code 79316303Sjkim * without prior written authorization from Intel. 80316303Sjkim * 81316303Sjkim * 4. Disclaimer and Export Compliance 82316303Sjkim * 83316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89316303Sjkim * PARTICULAR PURPOSE. 90316303Sjkim * 91316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98316303Sjkim * LIMITED REMEDY. 99316303Sjkim * 100316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 101316303Sjkim * software or system incorporating such software without first obtaining any 102316303Sjkim * required license or other approval from the U. S. Department of Commerce or 103316303Sjkim * any other agency or department of the United States Government. In the 104316303Sjkim * event Licensee exports any such software from the United States or 105316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 106316303Sjkim * ensure that the distribution and export/re-export of the software is in 107316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 108316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 110316303Sjkim * software, or service, directly or indirectly, to any country for which the 111316303Sjkim * United States government or any agency thereof requires an export license, 112316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 113316303Sjkim * such license, approval or letter. 114316303Sjkim * 115316303Sjkim ***************************************************************************** 116316303Sjkim * 117316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 118316303Sjkim * following license: 119316303Sjkim * 120217365Sjkim * Redistribution and use in source and binary forms, with or without 121217365Sjkim * modification, are permitted provided that the following conditions 122217365Sjkim * are met: 123217365Sjkim * 1. Redistributions of source code must retain the above copyright 124217365Sjkim * notice, this list of conditions, and the following disclaimer, 125217365Sjkim * without modification. 126217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 127217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 128217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 129217365Sjkim * including a substantially similar Disclaimer requirement for further 130217365Sjkim * binary redistribution. 131217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 132217365Sjkim * of any contributors may be used to endorse or promote products derived 133217365Sjkim * from this software without specific prior written permission. 13467754Smsmith * 135316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 136316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 137316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 138316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 139316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 140316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 141316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 142316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 143316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 144316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 145316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 146316303Sjkim * 147316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 148217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 149217365Sjkim * Software Foundation. 15067754Smsmith * 151316303Sjkim *****************************************************************************/ 15267754Smsmith 153193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 154193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 155193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 156193341Sjkim#include <contrib/dev/acpica/include/actables.h> 15767754Smsmith 158102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 15991116Smsmith ACPI_MODULE_NAME ("dbfileio") 16067754Smsmith 161287168Sjkim 162316303Sjkim#ifdef ACPI_APPLICATION 163316303Sjkim#include <contrib/dev/acpica/include/acapps.h> 164316303Sjkim 165316303Sjkim 166102550Siwasaki#ifdef ACPI_DEBUGGER 16767754Smsmith/******************************************************************************* 16867754Smsmith * 16967754Smsmith * FUNCTION: AcpiDbCloseDebugFile 17067754Smsmith * 17167754Smsmith * PARAMETERS: None 17267754Smsmith * 173151937Sjkim * RETURN: None 17467754Smsmith * 17567754Smsmith * DESCRIPTION: If open, close the current debug output file 17667754Smsmith * 17767754Smsmith ******************************************************************************/ 17867754Smsmith 17967754Smsmithvoid 18067754SmsmithAcpiDbCloseDebugFile ( 18167754Smsmith void) 18267754Smsmith{ 18367754Smsmith 18483174Smsmith if (AcpiGbl_DebugFile) 18567754Smsmith { 18683174Smsmith fclose (AcpiGbl_DebugFile); 18783174Smsmith AcpiGbl_DebugFile = NULL; 18883174Smsmith AcpiGbl_DbOutputToFile = FALSE; 189287168Sjkim AcpiOsPrintf ("Debug output file %s closed\n", 190287168Sjkim AcpiGbl_DbDebugFilename); 19167754Smsmith } 19267754Smsmith} 19367754Smsmith 19467754Smsmith 19567754Smsmith/******************************************************************************* 19667754Smsmith * 19767754Smsmith * FUNCTION: AcpiDbOpenDebugFile 19867754Smsmith * 19967754Smsmith * PARAMETERS: Name - Filename to open 20067754Smsmith * 201151937Sjkim * RETURN: None 20267754Smsmith * 20367754Smsmith * DESCRIPTION: Open a file where debug output will be directed. 20467754Smsmith * 20567754Smsmith ******************************************************************************/ 20667754Smsmith 20767754Smsmithvoid 20867754SmsmithAcpiDbOpenDebugFile ( 209114237Snjl char *Name) 21067754Smsmith{ 21167754Smsmith 21267754Smsmith AcpiDbCloseDebugFile (); 21383174Smsmith AcpiGbl_DebugFile = fopen (Name, "w+"); 214243347Sjkim if (!AcpiGbl_DebugFile) 21567754Smsmith { 21673561Smsmith AcpiOsPrintf ("Could not open debug file %s\n", Name); 217243347Sjkim return; 21873561Smsmith } 21967754Smsmith 220243347Sjkim AcpiOsPrintf ("Debug output file %s opened\n", Name); 221327557Sjkim AcpiUtSafeStrncpy (AcpiGbl_DbDebugFilename, Name, 222254745Sjkim sizeof (AcpiGbl_DbDebugFilename)); 223243347Sjkim AcpiGbl_DbOutputToFile = TRUE; 22467754Smsmith} 225100966Siwasaki#endif 22667754Smsmith 22767754Smsmith 228117521Snjl/******************************************************************************* 229117521Snjl * 230298714Sjkim * FUNCTION: AcpiDbLoadTables 23167754Smsmith * 232298714Sjkim * PARAMETERS: ListHead - List of ACPI tables to load 23367754Smsmith * 23467754Smsmith * RETURN: Status 23567754Smsmith * 236298714Sjkim * DESCRIPTION: Load ACPI tables from a previously constructed table list. 23767754Smsmith * 23867754Smsmith ******************************************************************************/ 23967754Smsmith 24099146SiwasakiACPI_STATUS 241298714SjkimAcpiDbLoadTables ( 242298714Sjkim ACPI_NEW_TABLE_DESC *ListHead) 24399146Siwasaki{ 24499146Siwasaki ACPI_STATUS Status; 245298714Sjkim ACPI_NEW_TABLE_DESC *TableListHead; 246114237Snjl ACPI_TABLE_HEADER *Table; 24799146Siwasaki 24899146Siwasaki 249298714Sjkim /* Load all ACPI tables in the list */ 25099146Siwasaki 251298714Sjkim TableListHead = ListHead; 252298714Sjkim while (TableListHead) 253283092Sjkim { 254298714Sjkim Table = TableListHead->Table; 25599146Siwasaki 256298714Sjkim Status = AcpiLoadTable (Table); 257167802Sjkim if (ACPI_FAILURE (Status)) 25867754Smsmith { 259167802Sjkim if (Status == AE_ALREADY_EXISTS) 260167802Sjkim { 261167802Sjkim AcpiOsPrintf ("Table %4.4s is already installed\n", 262167802Sjkim Table->Signature); 263167802Sjkim } 264167802Sjkim else 265167802Sjkim { 266167802Sjkim AcpiOsPrintf ("Could not install table, %s\n", 267167802Sjkim AcpiFormatException (Status)); 268167802Sjkim } 269167802Sjkim 270167802Sjkim return (Status); 27167754Smsmith } 27280062Smsmith 273316303Sjkim AcpiOsPrintf ("Acpi table [%4.4s] successfully installed and loaded\n", 274167802Sjkim Table->Signature); 27567754Smsmith 276298714Sjkim TableListHead = TableListHead->Next; 277114237Snjl } 27867754Smsmith 27967754Smsmith return (AE_OK); 28067754Smsmith} 281316303Sjkim#endif 282