/******************************************************************************
*
* Module Name: apdump - Dump routines for ACPI tables (acpidump)
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpidump.h"
/* Local prototypes */
static int
/******************************************************************************
*
* FUNCTION: ApIsValidHeader
*
* PARAMETERS: Table - Pointer to table to be validated
*
* RETURN: TRUE if the header appears to be valid. FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI table header
*
******************************************************************************/
{
{
/* Make sure signature is all ASCII and a valid ACPI name */
{
AcpiLogError ("Table signature (0x%8.8X) is invalid\n",
return (FALSE);
}
/* Check for minimum table length */
{
AcpiLogError ("Table length (0x%8.8X) is invalid\n",
return (FALSE);
}
}
return (TRUE);
}
/******************************************************************************
*
* FUNCTION: ApIsValidChecksum
*
* PARAMETERS: Table - Pointer to table to be validated
*
* RETURN: TRUE if the checksum appears to be valid. FALSE otherwise.
*
* DESCRIPTION: Check for a valid ACPI table checksum.
*
******************************************************************************/
{
{
/*
* Checksum for RSDP.
* Note: Other checksums are computed during the table dump.
*/
}
else
{
}
if (ACPI_FAILURE (Status))
{
AcpiLogError ("%4.4s: Warning: wrong checksum in table\n",
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: ApGetTableLength
*
* PARAMETERS: Table - Pointer to the table
*
* RETURN: Table length
*
* DESCRIPTION: Obtain table length according to table signature.
*
******************************************************************************/
{
/* Check if table is valid */
if (!ApIsValidHeader (Table))
{
return (0);
}
{
return (AcpiTbGetRsdpLength (Rsdp));
}
/* Normal ACPI table */
}
/******************************************************************************
*
* FUNCTION: ApDumpTableBuffer
*
* PARAMETERS: Table - ACPI table to be dumped
* Instance - ACPI table instance no. to be dumped
* Address - Physical address of the table
*
* RETURN: None
*
* DESCRIPTION: Dump an ACPI table in standard ASCII hex format, with a
* header that is compatible with the AcpiXtract utility.
*
******************************************************************************/
static int
{
/* Print only the header if requested */
if (Gbl_SummaryMode)
{
return (0);
}
/* Dump to binary file if requested */
if (Gbl_BinaryMode)
{
}
/*
* Dump the table with header for use with acpixtract utility.
* Note: simplest to just always emit a 64-bit address. AcpiXtract
* utility can handle this.
*/
DB_BYTE_DISPLAY, 0);
return (0);
}
/******************************************************************************
*
* FUNCTION: ApDumpAllTables
*
* PARAMETERS: None
*
* RETURN: Status
*
* tables that we can possibly get).
*
******************************************************************************/
int
void)
{
int TableStatus;
UINT32 i;
/* Get and dump all available ACPI tables */
for (i = 0; i < AP_MAX_ACPI_FILES; i++)
{
if (ACPI_FAILURE (Status))
{
/* AE_LIMIT means that no more tables are available */
{
return (0);
}
else if (i == 0)
{
AcpiLogError ("Could not get ACPI tables, %s\n",
return (-1);
}
else
{
AcpiLogError ("Could not get ACPI table at index %u, %s\n",
i, AcpiFormatException (Status));
continue;
}
}
if (TableStatus)
{
break;
}
}
/* Something seriously bad happened if the loop terminates here */
return (-1);
}
/******************************************************************************
*
* FUNCTION: ApDumpTableByAddress
*
* PARAMETERS: AsciiAddress - Address for requested ACPI table
*
* RETURN: Status
*
* DESCRIPTION: Get an ACPI table via a physical address and dump it.
*
******************************************************************************/
int
char *AsciiAddress)
{
int TableStatus;
/* Convert argument to an integer physical address */
if (ACPI_FAILURE (Status))
{
AcpiLogError ("%s: Could not convert to a physical address\n",
return (-1);
}
if (ACPI_FAILURE (Status))
{
AcpiLogError ("Could not get table at 0x%8.8X%8.8X, %s\n",
return (-1);
}
return (TableStatus);
}
/******************************************************************************
*
* FUNCTION: ApDumpTableByName
*
* PARAMETERS: Signature - Requested ACPI table signature
*
* RETURN: Status
*
* DESCRIPTION: Get an ACPI table via a signature and dump it. Handles
* multiple tables with the same signature (SSDTs).
*
******************************************************************************/
int
char *Signature)
{
int TableStatus;
{
"Invalid table signature [%s]: must be exactly 4 characters\n",
return (-1);
}
/* Table signatures are expected to be uppercase */
/* To be friendly, handle tables whose signatures do not match the name */
{
}
{
}
/* Dump all instances of this signature (to handle multiple SSDTs) */
{
if (ACPI_FAILURE (Status))
{
/* AE_LIMIT means that no more tables are available */
{
return (0);
}
"Could not get ACPI table with signature [%s], %s\n",
return (-1);
}
if (TableStatus)
{
break;
}
}
/* Something seriously bad happened if the loop terminates here */
return (-1);
}
/******************************************************************************
*
* FUNCTION: ApDumpTableFromFile
*
* PARAMETERS: Pathname - File containing the binary ACPI table
*
* RETURN: Status
*
* DESCRIPTION: Dump an ACPI table from a binary file
*
******************************************************************************/
int
char *Pathname)
{
/* Get the entire ACPI table from the file */
if (!Table)
{
return (-1);
}
{
"No valid ACPI signature was found in input file %s\n",
Pathname);
}
/* File must be at least as long as the table length */
{
"Table length (0x%X) is too large for input file (0x%X) %s\n",
goto Exit;
}
if (Gbl_VerboseMode)
{
"Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
}
Exit:
return (TableStatus);
}