dbcmds.c revision 199767f8919635c4928607450d9e0abb932109ce
/*******************************************************************************
*
* Module Name: dbcmds - Miscellaneous debug commands and output routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2015, 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.
*/
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME ("dbcmds")
/* Local prototypes */
static void
static ACPI_STATUS
char *Name);
static ACPI_STATUS
void *Context);
static ACPI_STATUS
void *Context,
void **ReturnValue);
static void
static char *AcpiDbTraceMethodName = NULL;
/*******************************************************************************
*
* 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
* alphanumeric strings.
*
******************************************************************************/
char *InString)
{
{
/* Numeric argument, convert */
{
AcpiOsPrintf ("Address %p is invalid",
Node);
return (NULL);
}
/* Make sure pointer is valid NS node */
{
AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
return (NULL);
}
}
else
{
/*
* Alpha argument: The parameter is a name string that must be
* resolved to a Namespace object.
*/
if (!Node)
{
"Could not find [%s] in namespace, defaulting to root node\n",
InString);
}
}
return (Node);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSleep
*
* PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
* invoke all possible sleep states.
*
* RETURN: Status
*
*
******************************************************************************/
char *ObjectArg)
{
UINT32 i;
/* Null input (no arguments) means to invoke all sleep states */
if (!ObjectArg)
{
AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
for (i = 0; i <= ACPI_S_STATES_MAX; i++)
{
AcpiDbDoOneSleepState ((UINT8) i);
}
}
/* Convert argument to binary and invoke the sleep state */
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDoOneSleepState
*
* PARAMETERS: SleepState - Desired sleep state (0-5)
*
* RETURN: None
*
*
******************************************************************************/
static void
{
/* Validate parameter */
if (SleepState > ACPI_S_STATES_MAX)
{
AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
return;
}
AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
/* Get the values for the sleep type registers (for display only) */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
return;
}
"Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
return;
SleepState));
}
/*******************************************************************************
*
* 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 - 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;
/* Header */
AcpiOsPrintf ("Idx ID Status Type "
"TableHeader (Sig, Address, Length, Misc)\n");
/* Walk the entire root table list */
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
{
/* Index and Table ID */
/* Decode the table flags */
{
AcpiOsPrintf ("NotLoaded ");
}
else
{
AcpiOsPrintf (" Loaded ");
}
{
AcpiOsPrintf ("External/virtual ");
break;
AcpiOsPrintf ("Internal/physical ");
break;
AcpiOsPrintf ("Internal/virtual ");
break;
default:
AcpiOsPrintf ("INVALID TYPE ");
break;
}
/* 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: ObjectName - Namespace pathname for an object that
* is owned by the table to be unloaded
*
* RETURN: None
*
* DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
* by the table.
*
******************************************************************************/
void
char *ObjectName)
{
/* Translate name to an Named object */
if (!Node)
{
return;
}
if (ACPI_SUCCESS (Status))
{
AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
ObjectName, Node);
}
else
{
AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSendNotify
*
* PARAMETERS: Name - Name of ACPI object where to send notify
* 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;
}
/* Dispatch the notify if legal */
if (AcpiEvIsNotifyObject (Node))
{
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not queue notify\n");
}
}
else
{
"Named object [%4.4s] Type %s, "
}
}
/*******************************************************************************
*
* 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)
{
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: AcpiDbDisplayTemplate
*
* PARAMETERS: BufferArg - Buffer name or address
*
* RETURN: None
*
* DESCRIPTION: Dump a buffer that contains a resource template
*
******************************************************************************/
void
char *BufferArg)
{
/* Translate BufferArg to an Named object */
{
return;
}
/* We must have a buffer object */
{
AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
return;
}
/* Attempt to convert the raw buffer to a resource list */
if (ACPI_FAILURE (Status))
{
"Could not convert Buffer to a resource list: %s, %s\n",
goto DumpBuffer;
}
/* Now we can dump the resource list */
AcpiOsPrintf ("\nRaw data buffer:\n");
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;
UINT32 i;
/* 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 Len1 %X, Len2 %X ****\n",
}
/* Check for descriptor byte match */
{
"**** Data mismatch in descriptor [%.2X] type %2.2X, "
"Offset %8.8X ****\n",
for (i = 0; i < Aml1Length; i++)
{
{
"Mismatch at byte offset %.2X: is %2.2X, "
"should be %2.2X\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: AcpiDbResourceCallback
*
* PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Simple callback to exercise AcpiWalkResources and
* AcpiWalkResourceBuffer.
*
******************************************************************************/
static ACPI_STATUS
void *Context)
{
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDeviceResources
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
*
******************************************************************************/
static ACPI_STATUS
void *Context,
void **ReturnValue)
{
char *ParentPath;
if (!ParentPath)
{
return (AE_NO_MEMORY);
}
/* Get handles to the resource methods for this device */
{
goto Cleanup; /* Nothing to do */
}
/* Prepare for a return object of arbitrary size */
/* _PRT */
if (PrtNode)
{
AcpiOsPrintf ("Evaluating _PRT\n");
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
goto GetCrs;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
goto GetCrs;
}
}
/* _CRS */
if (CrsNode)
{
AcpiOsPrintf ("Evaluating _CRS\n");
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
goto GetPrs;
}
/* This code exercises the AcpiWalkResources interface */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
goto GetPrs;
}
/* Get the _CRS resource list (test ALLOCATE buffer) */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
goto GetPrs;
}
/* This code exercises the AcpiWalkResourceBuffer interface */
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
goto EndCrs;
}
/* 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 */
AcpiOsPrintf ("Evaluating _SRS\n");
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
goto EndCrs;
}
}
/* _PRS */
if (PrsNode)
{
AcpiOsPrintf ("Evaluating _PRS\n");
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
goto GetAei;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
goto GetAei;
}
}
/* _AEI */
if (AeiNode)
{
AcpiOsPrintf ("Evaluating _AEI\n");
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
goto Cleanup;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
goto Cleanup;
}
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayResources
*
* PARAMETERS: ObjectArg - String object name or object pointer.
* NULL or "*" means "display resources for
* all devices"
*
* RETURN: None
*
* DESCRIPTION: Display the resource objects associated with a device.
*
******************************************************************************/
void
char *ObjectArg)
{
/* Asterisk means "display resources for all devices" */
{
}
else
{
/* Convert string to object pointer */
if (Node)
{
{
"%4.4s: Name is not a device object (%s)\n",
}
else
{
}
}
}
}
#if (!ACPI_REDUCED_HARDWARE)
/*******************************************************************************
*
* 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: Simulate firing of a GPE
*
******************************************************************************/
void
char *GpeArg,
char *BlockArg)
{
UINT32 BlockNumber = 0;
/*
* If no block arg, or block arg == 0 or 1, use the FADT-defined
* GPE blocks.
*/
if (BlockArg)
{
if (BlockNumber == 1)
{
BlockNumber = 0;
}
}
if (!GpeEventInfo)
{
AcpiOsPrintf ("Invalid GPE\n");
return;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbGenerateSci
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
*
******************************************************************************/
void
void)
{
}
#endif /* !ACPI_REDUCED_HARDWARE */
/*******************************************************************************
*
* FUNCTION: AcpiDbTrace
*
* DISABLE to disable tracer
* MethodArg - Method to trace
* OnceArg - Whether trace once
*
* RETURN: None
*
* DESCRIPTION: Control method tracing facility
*
******************************************************************************/
void
char *EnableArg,
char *MethodArg,
char *OnceArg)
{
UINT32 DebugLevel = 0;
UINT32 DebugLayer = 0;
if (EnableArg)
{
}
if (OnceArg)
{
}
if (MethodArg)
{
{
}
if (!AcpiDbTraceMethodName)
{
AcpiOsPrintf ("Failed to allocate method name (%s)\n",
return;
}
}
{
{
/* Inherit current console settings */
}
else
{
/* Restrict console output to trace points only */
}
{
}
{
}
}
(void) AcpiDebugTrace (AcpiDbTraceMethodName,
}