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 8217365Sjkim/* 9306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 1070243Smsmith * All rights reserved. 1167754Smsmith * 12217365Sjkim * Redistribution and use in source and binary forms, with or without 13217365Sjkim * modification, are permitted provided that the following conditions 14217365Sjkim * are met: 15217365Sjkim * 1. Redistributions of source code must retain the above copyright 16217365Sjkim * notice, this list of conditions, and the following disclaimer, 17217365Sjkim * without modification. 18217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 20217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 21217365Sjkim * including a substantially similar Disclaimer requirement for further 22217365Sjkim * binary redistribution. 23217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 24217365Sjkim * of any contributors may be used to endorse or promote products derived 25217365Sjkim * from this software without specific prior written permission. 2667754Smsmith * 27217365Sjkim * Alternatively, this software may be distributed under the terms of the 28217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 29217365Sjkim * Software Foundation. 3067754Smsmith * 31217365Sjkim * NO WARRANTY 32217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 43217365Sjkim */ 4467754Smsmith 45193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 46193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 47193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 48193341Sjkim#include <contrib/dev/acpica/include/actables.h> 49306536Sjkim#include <stdio.h> 50306536Sjkim#ifdef ACPI_APPLICATION 51306536Sjkim#include <contrib/dev/acpica/include/acapps.h> 52306536Sjkim#endif 5367754Smsmith 54102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 5591116Smsmith ACPI_MODULE_NAME ("dbfileio") 5667754Smsmith 57306536Sjkim 58102550Siwasaki#ifdef ACPI_DEBUGGER 5967754Smsmith/******************************************************************************* 6067754Smsmith * 6167754Smsmith * FUNCTION: AcpiDbCloseDebugFile 6267754Smsmith * 6367754Smsmith * PARAMETERS: None 6467754Smsmith * 65151937Sjkim * RETURN: None 6667754Smsmith * 6767754Smsmith * DESCRIPTION: If open, close the current debug output file 6867754Smsmith * 6967754Smsmith ******************************************************************************/ 7067754Smsmith 7167754Smsmithvoid 7267754SmsmithAcpiDbCloseDebugFile ( 7367754Smsmith void) 7467754Smsmith{ 7567754Smsmith 7667754Smsmith#ifdef ACPI_APPLICATION 7767754Smsmith 7883174Smsmith if (AcpiGbl_DebugFile) 7967754Smsmith { 8083174Smsmith fclose (AcpiGbl_DebugFile); 8183174Smsmith AcpiGbl_DebugFile = NULL; 8283174Smsmith AcpiGbl_DbOutputToFile = FALSE; 83306536Sjkim AcpiOsPrintf ("Debug output file %s closed\n", 84306536Sjkim AcpiGbl_DbDebugFilename); 8567754Smsmith } 8667754Smsmith#endif 8767754Smsmith} 8867754Smsmith 8967754Smsmith 9067754Smsmith/******************************************************************************* 9167754Smsmith * 9267754Smsmith * FUNCTION: AcpiDbOpenDebugFile 9367754Smsmith * 9467754Smsmith * PARAMETERS: Name - Filename to open 9567754Smsmith * 96151937Sjkim * RETURN: None 9767754Smsmith * 9867754Smsmith * DESCRIPTION: Open a file where debug output will be directed. 9967754Smsmith * 10067754Smsmith ******************************************************************************/ 10167754Smsmith 10267754Smsmithvoid 10367754SmsmithAcpiDbOpenDebugFile ( 104114237Snjl char *Name) 10567754Smsmith{ 10667754Smsmith 10767754Smsmith#ifdef ACPI_APPLICATION 10867754Smsmith 10967754Smsmith AcpiDbCloseDebugFile (); 11083174Smsmith AcpiGbl_DebugFile = fopen (Name, "w+"); 111243347Sjkim if (!AcpiGbl_DebugFile) 11267754Smsmith { 11373561Smsmith AcpiOsPrintf ("Could not open debug file %s\n", Name); 114243347Sjkim return; 11573561Smsmith } 11667754Smsmith 117243347Sjkim AcpiOsPrintf ("Debug output file %s opened\n", Name); 118306536Sjkim strncpy (AcpiGbl_DbDebugFilename, Name, 119254745Sjkim sizeof (AcpiGbl_DbDebugFilename)); 120243347Sjkim AcpiGbl_DbOutputToFile = TRUE; 121243347Sjkim 12267754Smsmith#endif 12367754Smsmith} 124100966Siwasaki#endif 12567754Smsmith 12667754Smsmith 127117521Snjl/******************************************************************************* 128117521Snjl * 129306536Sjkim * FUNCTION: AcpiDbLoadTables 13067754Smsmith * 131306536Sjkim * PARAMETERS: ListHead - List of ACPI tables to load 13267754Smsmith * 13367754Smsmith * RETURN: Status 13467754Smsmith * 135306536Sjkim * DESCRIPTION: Load ACPI tables from a previously constructed table list. 13667754Smsmith * 13767754Smsmith ******************************************************************************/ 13867754Smsmith 13999146SiwasakiACPI_STATUS 140306536SjkimAcpiDbLoadTables ( 141306536Sjkim ACPI_NEW_TABLE_DESC *ListHead) 14299146Siwasaki{ 14399146Siwasaki ACPI_STATUS Status; 144306536Sjkim ACPI_NEW_TABLE_DESC *TableListHead; 145114237Snjl ACPI_TABLE_HEADER *Table; 14699146Siwasaki 14799146Siwasaki 148306536Sjkim /* Load all ACPI tables in the list */ 14999146Siwasaki 150306536Sjkim TableListHead = ListHead; 151306536Sjkim while (TableListHead) 152284460Sjkim { 153306536Sjkim Table = TableListHead->Table; 15499146Siwasaki 155306536Sjkim Status = AcpiLoadTable (Table); 156167802Sjkim if (ACPI_FAILURE (Status)) 15767754Smsmith { 158167802Sjkim if (Status == AE_ALREADY_EXISTS) 159167802Sjkim { 160167802Sjkim AcpiOsPrintf ("Table %4.4s is already installed\n", 161167802Sjkim Table->Signature); 162167802Sjkim } 163167802Sjkim else 164167802Sjkim { 165167802Sjkim AcpiOsPrintf ("Could not install table, %s\n", 166167802Sjkim AcpiFormatException (Status)); 167167802Sjkim } 168167802Sjkim 169167802Sjkim return (Status); 17067754Smsmith } 17180062Smsmith 172167802Sjkim fprintf (stderr, 173167802Sjkim "Acpi table [%4.4s] successfully installed and loaded\n", 174167802Sjkim Table->Signature); 17567754Smsmith 176306536Sjkim TableListHead = TableListHead->Next; 177114237Snjl } 17867754Smsmith 17967754Smsmith return (AE_OK); 18067754Smsmith} 181