dbcmds.c revision 26f3cdf03f1adcc98f6d3d99843ee71e9229a8c0
/*******************************************************************************
*
* Module Name: dbcmds - Miscellaneous debug commands and output routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2011, 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 "acpi.h"
#include "accommon.h"
#include "acevents.h"
#include "acdebug.h"
#include "acresrc.h"
#include "actables.h"
#ifdef ACPI_DEBUGGER
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME ("dbcmds")
/* Local prototypes */
static void
static ACPI_STATUS
char *Name);
/*******************************************************************************
*
* FUNCTION: AcpiDbConvertToNode
*
* PARAMETERS: InString - String to convert
*
* RETURN: Pointer to a NS node
*
* DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
* alpha strings.
*
******************************************************************************/
char *InString)
{
{
/* Numeric argument, convert */
{
AcpiOsPrintf ("Address %p is invalid in this address space\n",
Node);
return (NULL);
}
/* Make sure pointer is valid NS node */
{
AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
return (NULL);
}
}
else
{
/* Alpha argument */
/* The parameter is a name string that must be resolved to a
* Named obj
*/
if (!Node)
{
}
}
return (Node);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSleep
*
* PARAMETERS: ObjectArg - Desired sleep state (0-5)
*
* RETURN: Status
*
*
******************************************************************************/
char *ObjectArg)
{
AcpiOsPrintf ("**** Prepare to sleep ****\n");
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiOsPrintf ("**** Going to sleep ****\n");
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiOsPrintf ("**** returning from sleep ****\n");
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayLocks
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display information about internal mutexes.
*
******************************************************************************/
void
void)
{
UINT32 i;
for (i = 0; i < ACPI_MAX_MUTEX; i++)
{
? "Locked" : "Unlocked");
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayTableInfo
*
* PARAMETERS: TableArg - String with name of table to be displayed
*
* RETURN: None
*
* DESCRIPTION: Display information about loaded tables. Current
* implementation displays all loaded tables.
*
******************************************************************************/
void
char *TableArg)
{
UINT32 i;
/* Walk the entire root table list */
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
{
AcpiOsPrintf ("%u ", i);
/* Make sure that the table is mapped */
if (ACPI_FAILURE (Status))
{
return;
}
/* Dump the table header */
{
}
else
{
/* If the pointer is null, the table has been unloaded */
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbUnloadAcpiTable
*
* PARAMETERS: TableArg - Name of the table to be unloaded
* InstanceArg - Which instance of the table to unload (if
* there are multiple tables of the same type)
*
* RETURN: Nonde
*
* DESCRIPTION: Unload an ACPI table.
* Instance is not implemented
*
******************************************************************************/
void
char *TableArg,
char *InstanceArg)
{
/* TBD: Need to reimplement for new data structures */
#if 0
UINT32 i;
/* Search all tables for the target type */
for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
{
{
/* Found the table, unload it */
Status = AcpiUnloadTable (i);
if (ACPI_SUCCESS (Status))
{
}
else
{
AcpiOsPrintf ("%s, while unloading [%s]\n",
}
return;
}
}
#endif
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSendNotify
*
* PARAMETERS: Name - Name of ACPI object to send the notify to
* Value - Value of the notify to send.
*
* RETURN: None
*
* DESCRIPTION: Send an ACPI notification. The value specified is sent to the
* named object as an ACPI notify.
*
******************************************************************************/
void
char *Name,
{
/* Translate name to an Named object */
if (!Node)
{
return;
}
/* Decode Named object type */
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_THERMAL:
/* Send the notify */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not queue notify\n");
}
break;
default:
AcpiOsPrintf ("Named object is not a device or a thermal object\n");
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayInterfaces
*
* PARAMETERS: ActionArg - Null, "install", or "remove"
*
* RETURN: None
*
* DESCRIPTION: Display or modify the global _OSI interface list
*
******************************************************************************/
void
char *ActionArg,
char *InterfaceNameArg)
{
char *SubString;
/* If no arguments, just display current interface list */
if (!ActionArg)
{
(void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
while (NextInterface)
{
{
}
}
return;
}
/* If ActionArg exists, so must InterfaceNameArg */
if (!InterfaceNameArg)
{
AcpiOsPrintf ("Missing Interface Name argument\n");
return;
}
/* Uppercase the action for match below */
/* Install - install an interface */
if (SubString)
{
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("%s, while installing \"%s\"\n",
}
return;
}
/* Remove - remove an interface */
if (SubString)
{
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("%s, while removing \"%s\"\n",
}
return;
}
/* Invalid ActionArg */
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiDmCompareAmlResources
*
* PARAMETERS: Aml1Buffer - Contains first resource list
* Aml1BufferLength - Length of first resource list
* Aml2Buffer - Contains second resource list
* Aml2BufferLength - Length of second resource list
*
* RETURN: None
*
* DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
* order to isolate a miscompare to an individual resource)
*
******************************************************************************/
static void
{
ACPI_RSDESC_SIZE Offset = 0;
/* Compare overall buffer sizes (may be different due to size rounding) */
if (Aml1BufferLength != Aml2BufferLength)
{
"**** Buffer length mismatch in converted AML: original %X new %X ****\n",
}
Aml1 = Aml1Buffer;
Aml2 = Aml2Buffer;
/* Walk the descriptor lists, comparing each descriptor */
{
/* Get the lengths of each descriptor */
/* Check for descriptor length match */
if (Aml1Length != Aml2Length)
{
"**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
}
/* Check for descriptor byte match */
{
"**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
}
/* Exit on EndTag descriptor */
{
return;
}
/* Point to next descriptor in each buffer */
Count++;
Offset += Aml1Length;
Aml1 += Aml1Length;
Aml2 += Aml2Length;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmTestResourceConversion
*
* PARAMETERS: Node - Parent device node
* Name - resource method name (_CRS)
*
* RETURN: Status
*
* DESCRIPTION: Compare the original AML with a conversion of the AML to
* internal resource list, then back to AML.
*
******************************************************************************/
static ACPI_STATUS
char *Name)
{
AcpiOsPrintf ("Resource Conversion Comparison:\n");
/* Get the original _CRS AML resource template */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not obtain %s: %s\n",
return (Status);
}
/* Get the AML resource template, converted to internal resource structs */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
goto Exit1;
}
/* Convert internal resource list to external AML resource template */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
goto Exit2;
}
/* Compare original AML to the newly created AML resource list */
/* Cleanup and exit */
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayResources
*
* PARAMETERS: ObjectArg - String with hex value of the object
*
* RETURN: None
*
* DESCRIPTION: Display the resource objects associated with a device.
*
******************************************************************************/
void
char *ObjectArg)
{
/* Convert string to object pointer */
if (!Node)
{
return;
}
/* Prepare for a return object of arbitrary size */
/* _PRT */
AcpiOsPrintf ("Evaluating _PRT\n");
/* Check if _PRT exists */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not obtain _PRT: %s\n",
goto GetCrs;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
goto GetCrs;
}
/* _CRS */
AcpiOsPrintf ("Evaluating _CRS\n");
/* Check if _CRS exists */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not obtain _CRS: %s\n",
goto GetPrs;
}
/* Get the _CRS resource list */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
goto GetPrs;
}
/* Dump the _CRS resource list */
/*
* Perform comparison of original AML to newly created AML. This tests both
* the AML->Resource conversion and the Resource->Aml conversion.
*/
/* Execute _SRS with the resource list */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
goto GetPrs;
}
/* _PRS */
AcpiOsPrintf ("Evaluating _PRS\n");
/* Check if _PRS exists */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not obtain _PRS: %s\n",
goto Cleanup;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
goto Cleanup;
}
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiDbGenerateGpe
*
* PARAMETERS: GpeArg - Raw GPE number, ascii string
* BlockArg - GPE block number, ascii string
* 0 or 1 for FADT GPE blocks
*
* RETURN: None
*
* DESCRIPTION: Generate a GPE
*
******************************************************************************/
void
char *GpeArg,
char *BlockArg)
{
if (!GpeEventInfo)
{
AcpiOsPrintf ("Invalid GPE\n");
return;
}
}
#endif /* ACPI_DEBUGGER */