13446Smrj /*******************************************************************************
23446Smrj *
37851SDana.Myers@Sun.COM * Module Name: dbfileio - Debugger file I/O commands. These can't usually
43446Smrj * be used when running the debugger in Ring 0 (Kernel mode)
53446Smrj *
63446Smrj ******************************************************************************/
73446Smrj
83446Smrj /******************************************************************************
93446Smrj *
103446Smrj * 1. Copyright Notice
113446Smrj *
12*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
133446Smrj * All rights reserved.
143446Smrj *
153446Smrj * 2. License
163446Smrj *
173446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj * rights. You may have additional license terms from the party that provided
193446Smrj * you this software, covering your right to use that party's intellectual
203446Smrj * property rights.
213446Smrj *
223446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj * copy of the source code appearing in this file ("Covered Code") an
243446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj * make derivatives, distribute, use and display any portion of the Covered
273446Smrj * Code in any form, with the right to sublicense such rights; and
283446Smrj *
293446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj * license (with the right to sublicense), under only those claims of Intel
313446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj * solely to the minimum extent necessary to exercise the above copyright
343446Smrj * license, and in no event shall the patent license extend to any additions
353446Smrj * to or modifications of the Original Intel Code. No other license or right
363446Smrj * is granted directly or by implication, estoppel or otherwise;
373446Smrj *
383446Smrj * The above copyright and patent license is granted only if the following
393446Smrj * conditions are met:
403446Smrj *
413446Smrj * 3. Conditions
423446Smrj *
433446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj * Redistribution of source code of any substantial portion of the Covered
453446Smrj * Code or modification with rights to further distribute source must include
463446Smrj * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
483446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj * contain a file documenting the changes Licensee made to create that Covered
503446Smrj * Code and the date of any change. Licensee must include in that file the
513446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
523446Smrj * must include a prominent statement that the modification is derived,
533446Smrj * directly or indirectly, from Original Intel Code.
543446Smrj *
553446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj * Redistribution of source code of any substantial portion of the Covered
573446Smrj * Code or modification without rights to further distribute source must
583446Smrj * include the following Disclaimer and Export Compliance provision in the
593446Smrj * documentation and/or other materials provided with distribution. In
603446Smrj * addition, Licensee may not authorize further sublicense of source of any
613446Smrj * portion of the Covered Code, and must include terms to the effect that the
623446Smrj * license from Licensee to its licensee is limited to the intellectual
633446Smrj * property embodied in the software Licensee provides to its licensee, and
643446Smrj * not to intellectual property embodied in modifications its licensee may
653446Smrj * make.
663446Smrj *
673446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
683446Smrj * substantial portion of the Covered Code or modification must reproduce the
693446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
703446Smrj * provision in the documentation and/or other materials provided with the
713446Smrj * distribution.
723446Smrj *
733446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
743446Smrj * Intel Code.
753446Smrj *
763446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
773446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
783446Smrj * other dealings in products derived from or relating to the Covered Code
793446Smrj * without prior written authorization from Intel.
803446Smrj *
813446Smrj * 4. Disclaimer and Export Compliance
823446Smrj *
833446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
843446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
853446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
863446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
873446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
883446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
893446Smrj * PARTICULAR PURPOSE.
903446Smrj *
913446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
923446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
933446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
943446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
953446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
963446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
973446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
983446Smrj * LIMITED REMEDY.
993446Smrj *
1003446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1013446Smrj * software or system incorporating such software without first obtaining any
1023446Smrj * required license or other approval from the U. S. Department of Commerce or
1033446Smrj * any other agency or department of the United States Government. In the
1043446Smrj * event Licensee exports any such software from the United States or
1053446Smrj * re-exports any such software from a foreign destination, Licensee shall
1063446Smrj * ensure that the distribution and export/re-export of the software is in
1073446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1083446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1093446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1103446Smrj * software, or service, directly or indirectly, to any country for which the
1113446Smrj * United States government or any agency thereof requires an export license,
1123446Smrj * other governmental approval, or letter of assurance, without first obtaining
1133446Smrj * such license, approval or letter.
1143446Smrj *
1153446Smrj *****************************************************************************/
1163446Smrj
1173446Smrj
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acdebug.h"
1217851SDana.Myers@Sun.COM
1227851SDana.Myers@Sun.COM #ifdef ACPI_APPLICATION
1233446Smrj #include "actables.h"
1247851SDana.Myers@Sun.COM #endif
1253446Smrj
1263446Smrj #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER)
1273446Smrj
1283446Smrj #define _COMPONENT ACPI_CA_DEBUGGER
1293446Smrj ACPI_MODULE_NAME ("dbfileio")
1303446Smrj
1313446Smrj /*
1327851SDana.Myers@Sun.COM * NOTE: this is here for lack of a better place. It is used in all
1333446Smrj * flavors of the debugger, need LCD file
1343446Smrj */
1353446Smrj #ifdef ACPI_APPLICATION
1363446Smrj #include <stdio.h>
1373446Smrj FILE *AcpiGbl_DebugFile = NULL;
1383446Smrj #endif
1393446Smrj
1403446Smrj
1413446Smrj #ifdef ACPI_DEBUGGER
1423446Smrj
1433446Smrj /* Local prototypes */
1443446Smrj
1453446Smrj #ifdef ACPI_APPLICATION
1463446Smrj
1473446Smrj static ACPI_STATUS
1483446Smrj AcpiDbCheckTextModeCorruption (
1493446Smrj UINT8 *Table,
1503446Smrj UINT32 TableLength,
1513446Smrj UINT32 FileLength);
1523446Smrj
1533446Smrj static ACPI_STATUS
1543446Smrj AeLocalLoadTable (
1553446Smrj ACPI_TABLE_HEADER *TablePtr);
1563446Smrj #endif
1573446Smrj
1583446Smrj /*******************************************************************************
1593446Smrj *
1603446Smrj * FUNCTION: AcpiDbCloseDebugFile
1613446Smrj *
1623446Smrj * PARAMETERS: None
1633446Smrj *
1643446Smrj * RETURN: None
1653446Smrj *
1663446Smrj * DESCRIPTION: If open, close the current debug output file
1673446Smrj *
1683446Smrj ******************************************************************************/
1693446Smrj
1703446Smrj void
AcpiDbCloseDebugFile(void)1713446Smrj AcpiDbCloseDebugFile (
1723446Smrj void)
1733446Smrj {
1743446Smrj
1753446Smrj #ifdef ACPI_APPLICATION
1763446Smrj
1773446Smrj if (AcpiGbl_DebugFile)
1783446Smrj {
1793446Smrj fclose (AcpiGbl_DebugFile);
1803446Smrj AcpiGbl_DebugFile = NULL;
1813446Smrj AcpiGbl_DbOutputToFile = FALSE;
1823446Smrj AcpiOsPrintf ("Debug output file %s closed\n", AcpiGbl_DbDebugFilename);
1833446Smrj }
1843446Smrj #endif
1853446Smrj }
1863446Smrj
1873446Smrj
1883446Smrj /*******************************************************************************
1893446Smrj *
1903446Smrj * FUNCTION: AcpiDbOpenDebugFile
1913446Smrj *
1923446Smrj * PARAMETERS: Name - Filename to open
1933446Smrj *
1943446Smrj * RETURN: None
1953446Smrj *
1963446Smrj * DESCRIPTION: Open a file where debug output will be directed.
1973446Smrj *
1983446Smrj ******************************************************************************/
1993446Smrj
2003446Smrj void
AcpiDbOpenDebugFile(char * Name)2013446Smrj AcpiDbOpenDebugFile (
2023446Smrj char *Name)
2033446Smrj {
2043446Smrj
2053446Smrj #ifdef ACPI_APPLICATION
2063446Smrj
2073446Smrj AcpiDbCloseDebugFile ();
2083446Smrj AcpiGbl_DebugFile = fopen (Name, "w+");
2093446Smrj if (AcpiGbl_DebugFile)
2103446Smrj {
2113446Smrj AcpiOsPrintf ("Debug output file %s opened\n", Name);
2123446Smrj ACPI_STRCPY (AcpiGbl_DbDebugFilename, Name);
2133446Smrj AcpiGbl_DbOutputToFile = TRUE;
2143446Smrj }
2153446Smrj else
2163446Smrj {
2173446Smrj AcpiOsPrintf ("Could not open debug file %s\n", Name);
2183446Smrj }
2193446Smrj
2203446Smrj #endif
2213446Smrj }
2223446Smrj #endif
2233446Smrj
2243446Smrj
2253446Smrj #ifdef ACPI_APPLICATION
2263446Smrj /*******************************************************************************
2273446Smrj *
2283446Smrj * FUNCTION: AcpiDbCheckTextModeCorruption
2293446Smrj *
2303446Smrj * PARAMETERS: Table - Table buffer
2313446Smrj * TableLength - Length of table from the table header
2323446Smrj * FileLength - Length of the file that contains the table
2333446Smrj *
2343446Smrj * RETURN: Status
2353446Smrj *
2363446Smrj * DESCRIPTION: Check table for text mode file corruption where all linefeed
2373446Smrj * characters (LF) have been replaced by carriage return linefeed
2383446Smrj * pairs (CR/LF).
2393446Smrj *
2403446Smrj ******************************************************************************/
2413446Smrj
2423446Smrj static ACPI_STATUS
AcpiDbCheckTextModeCorruption(UINT8 * Table,UINT32 TableLength,UINT32 FileLength)2433446Smrj AcpiDbCheckTextModeCorruption (
2443446Smrj UINT8 *Table,
2453446Smrj UINT32 TableLength,
2463446Smrj UINT32 FileLength)
2473446Smrj {
2483446Smrj UINT32 i;
2493446Smrj UINT32 Pairs = 0;
2503446Smrj
2513446Smrj
2523446Smrj if (TableLength != FileLength)
2533446Smrj {
2543446Smrj ACPI_WARNING ((AE_INFO,
2553446Smrj "File length (0x%X) is not the same as the table length (0x%X)",
2563446Smrj FileLength, TableLength));
2573446Smrj }
2583446Smrj
2593446Smrj /* Scan entire table to determine if each LF has been prefixed with a CR */
2603446Smrj
2613446Smrj for (i = 1; i < FileLength; i++)
2623446Smrj {
2633446Smrj if (Table[i] == 0x0A)
2643446Smrj {
2653446Smrj if (Table[i - 1] != 0x0D)
2663446Smrj {
2677851SDana.Myers@Sun.COM /* The LF does not have a preceding CR, table not corrupted */
2683446Smrj
2693446Smrj return (AE_OK);
2703446Smrj }
2713446Smrj else
2723446Smrj {
2733446Smrj /* Found a CR/LF pair */
2743446Smrj
2753446Smrj Pairs++;
2763446Smrj }
2773446Smrj i++;
2783446Smrj }
2793446Smrj }
2803446Smrj
2813446Smrj if (!Pairs)
2823446Smrj {
2833446Smrj return (AE_OK);
2843446Smrj }
2853446Smrj
2863446Smrj /*
2873446Smrj * Entire table scanned, each CR is part of a CR/LF pair --
2883446Smrj * meaning that the table was treated as a text file somewhere.
2893446Smrj *
2903446Smrj * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
2913446Smrj * original table are left untouched by the text conversion process --
2923446Smrj * meaning that we cannot simply replace CR/LF pairs with LFs.
2933446Smrj */
2943446Smrj AcpiOsPrintf ("Table has been corrupted by text mode conversion\n");
2953446Smrj AcpiOsPrintf ("All LFs (%d) were changed to CR/LF pairs\n", Pairs);
2963446Smrj AcpiOsPrintf ("Table cannot be repaired!\n");
2973446Smrj return (AE_BAD_VALUE);
2983446Smrj }
2993446Smrj
3003446Smrj
3013446Smrj /*******************************************************************************
3023446Smrj *
3033446Smrj * FUNCTION: AcpiDbReadTable
3043446Smrj *
3053446Smrj * PARAMETERS: fp - File that contains table
3063446Smrj * Table - Return value, buffer with table
3073446Smrj * TableLength - Return value, length of table
3083446Smrj *
3093446Smrj * RETURN: Status
3103446Smrj *
3113446Smrj * DESCRIPTION: Load the DSDT from the file pointer
3123446Smrj *
3133446Smrj ******************************************************************************/
3143446Smrj
3153446Smrj static ACPI_STATUS
AcpiDbReadTable(FILE * fp,ACPI_TABLE_HEADER ** Table,UINT32 * TableLength)3163446Smrj AcpiDbReadTable (
3173446Smrj FILE *fp,
3183446Smrj ACPI_TABLE_HEADER **Table,
3193446Smrj UINT32 *TableLength)
3203446Smrj {
3213446Smrj ACPI_TABLE_HEADER TableHeader;
3223446Smrj UINT32 Actual;
3233446Smrj ACPI_STATUS Status;
3243446Smrj UINT32 FileSize;
3253446Smrj BOOLEAN StandardHeader = TRUE;
3263446Smrj
3273446Smrj
3283446Smrj /* Get the file size */
3293446Smrj
3303446Smrj fseek (fp, 0, SEEK_END);
3313446Smrj FileSize = (UINT32) ftell (fp);
3323446Smrj fseek (fp, 0, SEEK_SET);
3333446Smrj
3343446Smrj if (FileSize < 4)
3353446Smrj {
3363446Smrj return (AE_BAD_HEADER);
3373446Smrj }
3383446Smrj
3393446Smrj /* Read the signature */
3403446Smrj
3413446Smrj if (fread (&TableHeader, 1, 4, fp) != 4)
3423446Smrj {
3433446Smrj AcpiOsPrintf ("Could not read the table signature\n");
3443446Smrj return (AE_BAD_HEADER);
3453446Smrj }
3463446Smrj
3473446Smrj fseek (fp, 0, SEEK_SET);
3483446Smrj
3493446Smrj /* The RSDT and FACS tables do not have standard ACPI headers */
3503446Smrj
3513446Smrj if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") ||
3523446Smrj ACPI_COMPARE_NAME (TableHeader.Signature, "FACS"))
3533446Smrj {
3543446Smrj *TableLength = FileSize;
3553446Smrj StandardHeader = FALSE;
3563446Smrj }
3573446Smrj else
3583446Smrj {
3597851SDana.Myers@Sun.COM /* Read the table header */
3603446Smrj
3613446Smrj if (fread (&TableHeader, 1, sizeof (TableHeader), fp) !=
3623446Smrj sizeof (ACPI_TABLE_HEADER))
3633446Smrj {
3643446Smrj AcpiOsPrintf ("Could not read the table header\n");
3653446Smrj return (AE_BAD_HEADER);
3663446Smrj }
3673446Smrj
3687851SDana.Myers@Sun.COM #if 0
3693446Smrj /* Validate the table header/length */
3703446Smrj
3713446Smrj Status = AcpiTbValidateTableHeader (&TableHeader);
3723446Smrj if (ACPI_FAILURE (Status))
3733446Smrj {
3743446Smrj AcpiOsPrintf ("Table header is invalid!\n");
3753446Smrj return (Status);
3763446Smrj }
3777851SDana.Myers@Sun.COM #endif
3783446Smrj
3793446Smrj /* File size must be at least as long as the Header-specified length */
3803446Smrj
3813446Smrj if (TableHeader.Length > FileSize)
3823446Smrj {
3833446Smrj AcpiOsPrintf (
3843446Smrj "TableHeader length [0x%X] greater than the input file size [0x%X]\n",
3853446Smrj TableHeader.Length, FileSize);
3863446Smrj return (AE_BAD_HEADER);
3873446Smrj }
3883446Smrj
3893446Smrj #ifdef ACPI_OBSOLETE_CODE
3903446Smrj /* We only support a limited number of table types */
3913446Smrj
3923446Smrj if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) &&
3933446Smrj ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) &&
3943446Smrj ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4))
3953446Smrj {
3963446Smrj AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n",
3973446Smrj (char *) TableHeader.Signature);
3983446Smrj ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER));
3993446Smrj return (AE_ERROR);
4003446Smrj }
4013446Smrj #endif
4023446Smrj
4033446Smrj *TableLength = TableHeader.Length;
4043446Smrj }
4053446Smrj
4063446Smrj /* Allocate a buffer for the table */
4073446Smrj
4083446Smrj *Table = AcpiOsAllocate ((size_t) FileSize);
4093446Smrj if (!*Table)
4103446Smrj {
4113446Smrj AcpiOsPrintf (
4123446Smrj "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n",
4133446Smrj TableHeader.Signature, *TableLength);
4143446Smrj return (AE_NO_MEMORY);
4153446Smrj }
4163446Smrj
4173446Smrj /* Get the rest of the table */
4183446Smrj
4193446Smrj fseek (fp, 0, SEEK_SET);
4203446Smrj Actual = fread (*Table, 1, (size_t) FileSize, fp);
4213446Smrj if (Actual == FileSize)
4223446Smrj {
4233446Smrj if (StandardHeader)
4243446Smrj {
4253446Smrj /* Now validate the checksum */
4263446Smrj
4277851SDana.Myers@Sun.COM Status = AcpiTbChecksum ((void *) *Table,
4287851SDana.Myers@Sun.COM ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length);
4293446Smrj
4303446Smrj if (Status == AE_BAD_CHECKSUM)
4313446Smrj {
4323446Smrj Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table,
4333446Smrj FileSize, (*Table)->Length);
4343446Smrj return (Status);
4353446Smrj }
4363446Smrj }
4373446Smrj return (AE_OK);
4383446Smrj }
4393446Smrj
4403446Smrj if (Actual > 0)
4413446Smrj {
4423446Smrj AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n",
4433446Smrj FileSize, Actual);
4443446Smrj return (AE_OK);
4453446Smrj }
4463446Smrj
4473446Smrj AcpiOsPrintf ("Error - could not read the table file\n");
4483446Smrj AcpiOsFree (*Table);
4493446Smrj *Table = NULL;
4503446Smrj *TableLength = 0;
4513446Smrj
4523446Smrj return (AE_ERROR);
4533446Smrj }
4543446Smrj
4553446Smrj
4563446Smrj /*******************************************************************************
4573446Smrj *
4583446Smrj * FUNCTION: AeLocalLoadTable
4593446Smrj *
4603446Smrj * PARAMETERS: Table - pointer to a buffer containing the entire
4613446Smrj * table to be loaded
4623446Smrj *
4633446Smrj * RETURN: Status
4643446Smrj *
4653446Smrj * DESCRIPTION: This function is called to load a table from the caller's
4667851SDana.Myers@Sun.COM * buffer. The buffer must contain an entire ACPI Table including
4677851SDana.Myers@Sun.COM * a valid header. The header fields will be verified, and if it
4683446Smrj * is determined that the table is invalid, the call will fail.
4693446Smrj *
4703446Smrj ******************************************************************************/
4713446Smrj
4723446Smrj static ACPI_STATUS
AeLocalLoadTable(ACPI_TABLE_HEADER * Table)4733446Smrj AeLocalLoadTable (
4743446Smrj ACPI_TABLE_HEADER *Table)
4753446Smrj {
4767851SDana.Myers@Sun.COM ACPI_STATUS Status = AE_OK;
4777851SDana.Myers@Sun.COM /* ACPI_TABLE_DESC TableInfo; */
4783446Smrj
4793446Smrj
4803446Smrj ACPI_FUNCTION_TRACE (AeLocalLoadTable);
4817851SDana.Myers@Sun.COM #if 0
4823446Smrj
4833446Smrj
4843446Smrj if (!Table)
4853446Smrj {
4863446Smrj return_ACPI_STATUS (AE_BAD_PARAMETER);
4873446Smrj }
4883446Smrj
4893446Smrj TableInfo.Pointer = Table;
4903446Smrj Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL);
4913446Smrj if (ACPI_FAILURE (Status))
4923446Smrj {
4933446Smrj return_ACPI_STATUS (Status);
4943446Smrj }
4953446Smrj
4963446Smrj /* Install the new table into the local data structures */
4973446Smrj
4983446Smrj Status = AcpiTbInstallTable (&TableInfo);
4993446Smrj if (ACPI_FAILURE (Status))
5003446Smrj {
5013446Smrj if (Status == AE_ALREADY_EXISTS)
5023446Smrj {
5033446Smrj /* Table already exists, no error */
5043446Smrj
5053446Smrj Status = AE_OK;
5063446Smrj }
5073446Smrj
5083446Smrj /* Free table allocated by AcpiTbGetTable */
5093446Smrj
5103446Smrj AcpiTbDeleteSingleTable (&TableInfo);
5113446Smrj return_ACPI_STATUS (Status);
5123446Smrj }
5133446Smrj
5143446Smrj #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
5153446Smrj
5163446Smrj Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode);
5173446Smrj if (ACPI_FAILURE (Status))
5183446Smrj {
5193446Smrj /* Uninstall table and free the buffer */
5203446Smrj
5213446Smrj AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT);
5223446Smrj return_ACPI_STATUS (Status);
5233446Smrj }
5243446Smrj #endif
5257851SDana.Myers@Sun.COM #endif
5263446Smrj
5273446Smrj return_ACPI_STATUS (Status);
5283446Smrj }
5293446Smrj
5303446Smrj
5313446Smrj /*******************************************************************************
5323446Smrj *
5333446Smrj * FUNCTION: AcpiDbReadTableFromFile
5343446Smrj *
5353446Smrj * PARAMETERS: Filename - File where table is located
5363446Smrj * Table - Where a pointer to the table is returned
5373446Smrj *
5383446Smrj * RETURN: Status
5393446Smrj *
5403446Smrj * DESCRIPTION: Get an ACPI table from a file
5413446Smrj *
5423446Smrj ******************************************************************************/
5433446Smrj
5443446Smrj ACPI_STATUS
AcpiDbReadTableFromFile(char * Filename,ACPI_TABLE_HEADER ** Table)5453446Smrj AcpiDbReadTableFromFile (
5463446Smrj char *Filename,
5473446Smrj ACPI_TABLE_HEADER **Table)
5483446Smrj {
5493446Smrj FILE *fp;
5503446Smrj UINT32 TableLength;
5513446Smrj ACPI_STATUS Status;
5523446Smrj
5533446Smrj
5543446Smrj /* Open the file */
5553446Smrj
5563446Smrj fp = fopen (Filename, "rb");
5573446Smrj if (!fp)
5583446Smrj {
5593446Smrj AcpiOsPrintf ("Could not open input file %s\n", Filename);
5603446Smrj return (AE_ERROR);
5613446Smrj }
5623446Smrj
5633446Smrj /* Get the entire file */
5643446Smrj
5653446Smrj fprintf (stderr, "Loading Acpi table from file %s\n", Filename);
5663446Smrj Status = AcpiDbReadTable (fp, Table, &TableLength);
5673446Smrj fclose(fp);
5683446Smrj
5693446Smrj if (ACPI_FAILURE (Status))
5703446Smrj {
5713446Smrj AcpiOsPrintf ("Could not get table from the file\n");
5723446Smrj return (Status);
5733446Smrj }
5743446Smrj
5753446Smrj return (AE_OK);
5763446Smrj }
5773446Smrj #endif
5783446Smrj
5793446Smrj
5803446Smrj /*******************************************************************************
5813446Smrj *
5823446Smrj * FUNCTION: AcpiDbGetTableFromFile
5833446Smrj *
5843446Smrj * PARAMETERS: Filename - File where table is located
5853446Smrj * ReturnTable - Where a pointer to the table is returned
5863446Smrj *
5873446Smrj * RETURN: Status
5883446Smrj *
5893446Smrj * DESCRIPTION: Load an ACPI table from a file
5903446Smrj *
5913446Smrj ******************************************************************************/
5923446Smrj
5933446Smrj ACPI_STATUS
AcpiDbGetTableFromFile(char * Filename,ACPI_TABLE_HEADER ** ReturnTable)5943446Smrj AcpiDbGetTableFromFile (
5953446Smrj char *Filename,
5963446Smrj ACPI_TABLE_HEADER **ReturnTable)
5973446Smrj {
5983446Smrj #ifdef ACPI_APPLICATION
5993446Smrj ACPI_STATUS Status;
6003446Smrj ACPI_TABLE_HEADER *Table;
6013446Smrj BOOLEAN IsAmlTable = TRUE;
6023446Smrj
6033446Smrj
6043446Smrj Status = AcpiDbReadTableFromFile (Filename, &Table);
6053446Smrj if (ACPI_FAILURE (Status))
6063446Smrj {
6073446Smrj return (Status);
6083446Smrj }
6093446Smrj
6103446Smrj #ifdef ACPI_DATA_TABLE_DISASSEMBLY
6113446Smrj IsAmlTable = AcpiUtIsAmlTable (Table);
6123446Smrj #endif
6133446Smrj
6143446Smrj if (IsAmlTable)
6153446Smrj {
6163446Smrj /* Attempt to recognize and install the table */
6173446Smrj
6183446Smrj Status = AeLocalLoadTable (Table);
6193446Smrj if (ACPI_FAILURE (Status))
6203446Smrj {
6213446Smrj if (Status == AE_ALREADY_EXISTS)
6223446Smrj {
6233446Smrj AcpiOsPrintf ("Table %4.4s is already installed\n",
6243446Smrj Table->Signature);
6253446Smrj }
6263446Smrj else
6273446Smrj {
6283446Smrj AcpiOsPrintf ("Could not install table, %s\n",
6293446Smrj AcpiFormatException (Status));
6303446Smrj }
6313446Smrj
6323446Smrj return (Status);
6333446Smrj }
6343446Smrj
6353446Smrj fprintf (stderr,
6363446Smrj "Acpi table [%4.4s] successfully installed and loaded\n",
6373446Smrj Table->Signature);
6383446Smrj }
6393446Smrj
6403446Smrj AcpiGbl_AcpiHardwarePresent = FALSE;
6413446Smrj if (ReturnTable)
6423446Smrj {
6433446Smrj *ReturnTable = Table;
6443446Smrj }
6453446Smrj
6463446Smrj
6473446Smrj #endif /* ACPI_APPLICATION */
6483446Smrj return (AE_OK);
6493446Smrj }
6503446Smrj
6513446Smrj #endif /* ACPI_DEBUGGER */
6523446Smrj
653