/drivers/devman/acpica/debugger/dbcmds.c |
---|
0,0 → 1,2129 |
/******************************************************************************* |
* |
* Module Name: dbcmds - debug commands and output routines |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdispat.h" |
#include "acnamesp.h" |
#include "acevents.h" |
#include "acdebug.h" |
#include "acresrc.h" |
#include "acdisasm.h" |
#include "actables.h" |
#include "acparser.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbcmds") |
/* Local prototypes */ |
static ACPI_STATUS |
AcpiDbIntegrityWalk ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
static ACPI_STATUS |
AcpiDbWalkAndMatchName ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
static ACPI_STATUS |
AcpiDbWalkForReferences ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
static ACPI_STATUS |
AcpiDbWalkForSpecificObjects ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
static ACPI_NAMESPACE_NODE * |
AcpiDbConvertToNode ( |
char *InString); |
static void |
AcpiDmCompareAmlResources ( |
UINT8 *Aml1Buffer, |
ACPI_RSDESC_SIZE Aml1BufferLength, |
UINT8 *Aml2Buffer, |
ACPI_RSDESC_SIZE Aml2BufferLength); |
static ACPI_STATUS |
AcpiDmTestResourceConversion ( |
ACPI_NAMESPACE_NODE *Node, |
char *Name); |
/* |
* Arguments for the Objects command |
* These object types map directly to the ACPI_TYPES |
*/ |
static ARGUMENT_INFO AcpiDbObjectTypes [] = |
{ |
{"ANY"}, |
{"INTEGERS"}, |
{"STRINGS"}, |
{"BUFFERS"}, |
{"PACKAGES"}, |
{"FIELDS"}, |
{"DEVICES"}, |
{"EVENTS"}, |
{"METHODS"}, |
{"MUTEXES"}, |
{"REGIONS"}, |
{"POWERRESOURCES"}, |
{"PROCESSORS"}, |
{"THERMALZONES"}, |
{"BUFFERFIELDS"}, |
{"DDBHANDLES"}, |
{"DEBUG"}, |
{"REGIONFIELDS"}, |
{"BANKFIELDS"}, |
{"INDEXFIELDS"}, |
{"REFERENCES"}, |
{"ALIAS"}, |
{NULL} /* Must be null terminated */ |
}; |
/******************************************************************************* |
* |
* 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. |
* |
******************************************************************************/ |
static ACPI_NAMESPACE_NODE * |
AcpiDbConvertToNode ( |
char *InString) |
{ |
ACPI_NAMESPACE_NODE *Node; |
if ((*InString >= 0x30) && (*InString <= 0x39)) |
{ |
/* Numeric argument, convert */ |
Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16)); |
if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) |
{ |
AcpiOsPrintf ("Address %p is invalid in this address space\n", |
Node); |
return (NULL); |
} |
/* Make sure pointer is valid NS node */ |
if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) |
{ |
AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", |
Node, AcpiUtGetDescriptorName (Node)); |
return (NULL); |
} |
} |
else |
{ |
/* Alpha argument */ |
/* The parameter is a name string that must be resolved to a |
* Named obj |
*/ |
Node = AcpiDbLocalNsLookup (InString); |
if (!Node) |
{ |
Node = AcpiGbl_RootNode; |
} |
} |
return (Node); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSleep |
* |
* PARAMETERS: ObjectArg - Desired sleep state (0-5) |
* |
* RETURN: Status |
* |
* DESCRIPTION: Simulate a sleep/wake sequence |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbSleep ( |
char *ObjectArg) |
{ |
ACPI_STATUS Status; |
UINT8 SleepState; |
SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); |
AcpiOsPrintf ("**** Prepare to sleep ****\n"); |
Status = AcpiEnterSleepStatePrep (SleepState); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
AcpiOsPrintf ("**** Going to sleep ****\n"); |
Status = AcpiEnterSleepState (SleepState); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
AcpiOsPrintf ("**** returning from sleep ****\n"); |
Status = AcpiLeaveSleepState (SleepState); |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbWalkForReferences |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Check if this namespace object refers to the target object |
* that is passed in as the context value. |
* |
* Note: Currently doesn't check subobjects within the Node's object |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbWalkForReferences ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
/* Check for match against the namespace node itself */ |
if (Node == (void *) ObjDesc) |
{ |
AcpiOsPrintf ("Object is a Node [%4.4s]\n", |
AcpiUtGetNodeName (Node)); |
} |
/* Check for match against the object attached to the node */ |
if (AcpiNsGetAttachedObject (Node) == ObjDesc) |
{ |
AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", |
Node, AcpiUtGetNodeName (Node)); |
} |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbFindReferences |
* |
* PARAMETERS: ObjectArg - String with hex value of the object |
* |
* RETURN: None |
* |
* DESCRIPTION: Search namespace for all references to the input object |
* |
******************************************************************************/ |
void |
AcpiDbFindReferences ( |
char *ObjectArg) |
{ |
ACPI_OPERAND_OBJECT *ObjDesc; |
/* Convert string to object pointer */ |
ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); |
/* Search all nodes in namespace */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbWalkForPredefinedNames |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Detect and display predefined ACPI names (names that start with |
* an underscore) |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbWalkForPredefinedNames ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
UINT32 *Count = (UINT32 *) Context; |
const ACPI_PREDEFINED_INFO *Predefined; |
const ACPI_PREDEFINED_INFO *Package = NULL; |
char *Pathname; |
Predefined = AcpiNsCheckForPredefinedName (Node); |
if (!Predefined) |
{ |
return (AE_OK); |
} |
Pathname = AcpiNsGetExternalPathname (Node); |
if (!Pathname) |
{ |
return (AE_OK); |
} |
/* If method returns a package, the info is in the next table entry */ |
if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE) |
{ |
Package = Predefined + 1; |
} |
AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname, |
Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes); |
if (Package) |
{ |
AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X", |
Package->RetInfo.Type, Package->RetInfo.ObjectType1, |
Package->RetInfo.Count1); |
} |
AcpiOsPrintf("\n"); |
AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined); |
ACPI_FREE (Pathname); |
(*Count)++; |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCheckPredefinedNames |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Validate all predefined names in the namespace |
* |
******************************************************************************/ |
void |
AcpiDbCheckPredefinedNames ( |
void) |
{ |
UINT32 Count = 0; |
/* Search all nodes in namespace */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL); |
AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbWalkForExecute |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Batch execution module. Currently only executes predefined |
* ACPI names. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbWalkForExecute ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context; |
ACPI_BUFFER ReturnObj; |
ACPI_STATUS Status; |
char *Pathname; |
UINT32 i; |
ACPI_DEVICE_INFO *ObjInfo; |
ACPI_OBJECT_LIST ParamObjects; |
ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; |
const ACPI_PREDEFINED_INFO *Predefined; |
Predefined = AcpiNsCheckForPredefinedName (Node); |
if (!Predefined) |
{ |
return (AE_OK); |
} |
if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) |
{ |
return (AE_OK); |
} |
Pathname = AcpiNsGetExternalPathname (Node); |
if (!Pathname) |
{ |
return (AE_OK); |
} |
/* Get the object info for number of method parameters */ |
Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
ParamObjects.Pointer = NULL; |
ParamObjects.Count = 0; |
if (ObjInfo->Type == ACPI_TYPE_METHOD) |
{ |
/* Setup default parameters */ |
for (i = 0; i < ObjInfo->ParamCount; i++) |
{ |
Params[i].Type = ACPI_TYPE_INTEGER; |
Params[i].Integer.Value = 1; |
} |
ParamObjects.Pointer = Params; |
ParamObjects.Count = ObjInfo->ParamCount; |
} |
ACPI_FREE (ObjInfo); |
ReturnObj.Pointer = NULL; |
ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
/* Do the actual method execution */ |
AcpiGbl_MethodExecuting = TRUE; |
Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); |
AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); |
AcpiGbl_MethodExecuting = FALSE; |
ACPI_FREE (Pathname); |
/* Ignore status from method execution */ |
Status = AE_OK; |
/* Update count, check if we have executed enough methods */ |
Info->Count++; |
if (Info->Count >= Info->MaxCount) |
{ |
Status = AE_CTRL_TERMINATE; |
} |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbBatchExecute |
* |
* PARAMETERS: CountArg - Max number of methods to execute |
* |
* RETURN: None |
* |
* DESCRIPTION: Namespace batch execution. Execute predefined names in the |
* namespace, up to the max count, if specified. |
* |
******************************************************************************/ |
void |
AcpiDbBatchExecute ( |
char *CountArg) |
{ |
ACPI_EXECUTE_WALK Info; |
Info.Count = 0; |
Info.MaxCount = ACPI_UINT32_MAX; |
if (CountArg) |
{ |
Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0); |
} |
/* Search all nodes in namespace */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbWalkForExecute, NULL, (void *) &Info, NULL); |
AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayLocks |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display information about internal mutexes. |
* |
******************************************************************************/ |
void |
AcpiDbDisplayLocks ( |
void) |
{ |
UINT32 i; |
for (i = 0; i < ACPI_MAX_MUTEX; i++) |
{ |
AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), |
AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED |
? "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 |
AcpiDbDisplayTableInfo ( |
char *TableArg) |
{ |
UINT32 i; |
ACPI_TABLE_DESC *TableDesc; |
ACPI_STATUS Status; |
/* Walk the entire root table list */ |
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) |
{ |
TableDesc = &AcpiGbl_RootTableList.Tables[i]; |
AcpiOsPrintf ("%u ", i); |
/* Make sure that the table is mapped */ |
Status = AcpiTbVerifyTable (TableDesc); |
if (ACPI_FAILURE (Status)) |
{ |
return; |
} |
/* Dump the table header */ |
if (TableDesc->Pointer) |
{ |
AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); |
} |
else |
{ |
/* If the pointer is null, the table has been unloaded */ |
ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", |
TableDesc->Signature.Ascii)); |
} |
} |
} |
/******************************************************************************* |
* |
* 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 |
AcpiDbUnloadAcpiTable ( |
char *TableArg, |
char *InstanceArg) |
{ |
/* TBD: Need to reimplement for new data structures */ |
#if 0 |
UINT32 i; |
ACPI_STATUS Status; |
/* Search all tables for the target type */ |
for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) |
{ |
if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, |
AcpiGbl_TableData[i].SigLength)) |
{ |
/* Found the table, unload it */ |
Status = AcpiUnloadTable (i); |
if (ACPI_SUCCESS (Status)) |
{ |
AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); |
} |
else |
{ |
AcpiOsPrintf ("%s, while unloading [%s]\n", |
AcpiFormatException (Status), TableArg); |
} |
return; |
} |
} |
AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); |
#endif |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSetMethodBreakpoint |
* |
* PARAMETERS: Location - AML offset of breakpoint |
* WalkState - Current walk info |
* Op - Current Op (from parse walk) |
* |
* RETURN: None |
* |
* DESCRIPTION: Set a breakpoint in a control method at the specified |
* AML offset |
* |
******************************************************************************/ |
void |
AcpiDbSetMethodBreakpoint ( |
char *Location, |
ACPI_WALK_STATE *WalkState, |
ACPI_PARSE_OBJECT *Op) |
{ |
UINT32 Address; |
if (!Op) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
/* Get and verify the breakpoint address */ |
Address = ACPI_STRTOUL (Location, NULL, 16); |
if (Address <= Op->Common.AmlOffset) |
{ |
AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", |
Address, Op->Common.AmlOffset); |
} |
/* Save breakpoint in current walk */ |
WalkState->UserBreakpoint = Address; |
AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSetMethodCallBreakpoint |
* |
* PARAMETERS: Op - Current Op (from parse walk) |
* |
* RETURN: None |
* |
* DESCRIPTION: Set a breakpoint in a control method at the specified |
* AML offset |
* |
******************************************************************************/ |
void |
AcpiDbSetMethodCallBreakpoint ( |
ACPI_PARSE_OBJECT *Op) |
{ |
if (!Op) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
AcpiGbl_StepToNextCall = TRUE; |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisassembleAml |
* |
* PARAMETERS: Statements - Number of statements to disassemble |
* Op - Current Op (from parse walk) |
* |
* RETURN: None |
* |
* DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number |
* of statements specified. |
* |
******************************************************************************/ |
void |
AcpiDbDisassembleAml ( |
char *Statements, |
ACPI_PARSE_OBJECT *Op) |
{ |
UINT32 NumStatements = 8; |
if (!Op) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
if (Statements) |
{ |
NumStatements = ACPI_STRTOUL (Statements, NULL, 0); |
} |
AcpiDmDisassemble (NULL, Op, NumStatements); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisassembleMethod |
* |
* PARAMETERS: Name - Name of control method |
* |
* RETURN: None |
* |
* DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number |
* of statements specified. |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbDisassembleMethod ( |
char *Name) |
{ |
ACPI_STATUS Status; |
ACPI_PARSE_OBJECT *Op; |
ACPI_WALK_STATE *WalkState; |
ACPI_OPERAND_OBJECT *ObjDesc; |
ACPI_NAMESPACE_NODE *Method; |
Method = AcpiDbConvertToNode (Name); |
if (!Method) |
{ |
return (AE_BAD_PARAMETER); |
} |
ObjDesc = Method->Object; |
Op = AcpiPsCreateScopeOp (); |
if (!Op) |
{ |
return (AE_NO_MEMORY); |
} |
/* Create and initialize a new walk state */ |
WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); |
if (!WalkState) |
{ |
return (AE_NO_MEMORY); |
} |
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, |
ObjDesc->Method.AmlStart, |
ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
/* Parse the AML */ |
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; |
WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; |
Status = AcpiPsParseAml (WalkState); |
AcpiDmDisassemble (NULL, Op, 0); |
AcpiPsDeleteParseTree (Op); |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDumpNamespace |
* |
* PARAMETERS: StartArg - Node to begin namespace dump |
* DepthArg - Maximum tree depth to be dumped |
* |
* RETURN: None |
* |
* DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed |
* with type and other information. |
* |
******************************************************************************/ |
void |
AcpiDbDumpNamespace ( |
char *StartArg, |
char *DepthArg) |
{ |
ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; |
UINT32 MaxDepth = ACPI_UINT32_MAX; |
/* No argument given, just start at the root and dump entire namespace */ |
if (StartArg) |
{ |
SubtreeEntry = AcpiDbConvertToNode (StartArg); |
if (!SubtreeEntry) |
{ |
return; |
} |
/* Now we can check for the depth argument */ |
if (DepthArg) |
{ |
MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); |
} |
} |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", |
((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); |
/* Display the subtree */ |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, |
ACPI_OWNER_ID_MAX, SubtreeEntry); |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDumpNamespaceByOwner |
* |
* PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed |
* DepthArg - Maximum tree depth to be dumped |
* |
* RETURN: None |
* |
* DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. |
* |
******************************************************************************/ |
void |
AcpiDbDumpNamespaceByOwner ( |
char *OwnerArg, |
char *DepthArg) |
{ |
ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; |
UINT32 MaxDepth = ACPI_UINT32_MAX; |
ACPI_OWNER_ID OwnerId; |
OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); |
/* Now we can check for the depth argument */ |
if (DepthArg) |
{ |
MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); |
} |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); |
/* Display the subtree */ |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, |
SubtreeEntry); |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
} |
/******************************************************************************* |
* |
* 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 |
AcpiDbSendNotify ( |
char *Name, |
UINT32 Value) |
{ |
ACPI_NAMESPACE_NODE *Node; |
ACPI_STATUS Status; |
/* Translate name to an Named object */ |
Node = AcpiDbConvertToNode (Name); |
if (!Node) |
{ |
return; |
} |
/* Decode Named object type */ |
switch (Node->Type) |
{ |
case ACPI_TYPE_DEVICE: |
case ACPI_TYPE_THERMAL: |
/* Send the notify */ |
Status = AcpiEvQueueNotifyRequest (Node, Value); |
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: AcpiDbSetMethodData |
* |
* PARAMETERS: TypeArg - L for local, A for argument |
* IndexArg - which one |
* ValueArg - Value to set. |
* |
* RETURN: None |
* |
* DESCRIPTION: Set a local or argument for the running control method. |
* NOTE: only object supported is Number. |
* |
******************************************************************************/ |
void |
AcpiDbSetMethodData ( |
char *TypeArg, |
char *IndexArg, |
char *ValueArg) |
{ |
char Type; |
UINT32 Index; |
UINT32 Value; |
ACPI_WALK_STATE *WalkState; |
ACPI_OPERAND_OBJECT *ObjDesc; |
ACPI_STATUS Status; |
ACPI_NAMESPACE_NODE *Node; |
/* Validate TypeArg */ |
AcpiUtStrupr (TypeArg); |
Type = TypeArg[0]; |
if ((Type != 'L') && |
(Type != 'A') && |
(Type != 'N')) |
{ |
AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); |
return; |
} |
Value = ACPI_STRTOUL (ValueArg, NULL, 16); |
if (Type == 'N') |
{ |
Node = AcpiDbConvertToNode (IndexArg); |
if (Node->Type != ACPI_TYPE_INTEGER) |
{ |
AcpiOsPrintf ("Can only set Integer nodes\n"); |
return; |
} |
ObjDesc = Node->Object; |
ObjDesc->Integer.Value = Value; |
return; |
} |
/* Get the index and value */ |
Index = ACPI_STRTOUL (IndexArg, NULL, 16); |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
/* Create and initialize the new object */ |
ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value); |
if (!ObjDesc) |
{ |
AcpiOsPrintf ("Could not create an internal object\n"); |
return; |
} |
/* Store the new object into the target */ |
switch (Type) |
{ |
case 'A': |
/* Set a method argument */ |
if (Index > ACPI_METHOD_MAX_ARG) |
{ |
AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); |
goto Cleanup; |
} |
Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, |
WalkState); |
if (ACPI_FAILURE (Status)) |
{ |
goto Cleanup; |
} |
ObjDesc = WalkState->Arguments[Index].Object; |
AcpiOsPrintf ("Arg%u: ", Index); |
AcpiDmDisplayInternalObject (ObjDesc, WalkState); |
break; |
case 'L': |
/* Set a method local */ |
if (Index > ACPI_METHOD_MAX_LOCAL) |
{ |
AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); |
goto Cleanup; |
} |
Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, |
WalkState); |
if (ACPI_FAILURE (Status)) |
{ |
goto Cleanup; |
} |
ObjDesc = WalkState->LocalVariables[Index].Object; |
AcpiOsPrintf ("Local%u: ", Index); |
AcpiDmDisplayInternalObject (ObjDesc, WalkState); |
break; |
default: |
break; |
} |
Cleanup: |
AcpiUtRemoveReference (ObjDesc); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbWalkForSpecificObjects |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Display short info about objects in the namespace |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbWalkForSpecificObjects ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; |
ACPI_BUFFER Buffer; |
ACPI_STATUS Status; |
Info->Count++; |
/* Get and display the full pathname to this object */ |
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); |
return (AE_OK); |
} |
AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); |
ACPI_FREE (Buffer.Pointer); |
/* Dump short info about the object */ |
(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayObjects |
* |
* PARAMETERS: ObjTypeArg - Type of object to display |
* DisplayCountArg - Max depth to display |
* |
* RETURN: None |
* |
* DESCRIPTION: Display objects in the namespace of the requested type |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbDisplayObjects ( |
char *ObjTypeArg, |
char *DisplayCountArg) |
{ |
ACPI_WALK_INFO Info; |
ACPI_OBJECT_TYPE Type; |
/* Get the object type */ |
Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); |
if (Type == ACPI_TYPE_NOT_FOUND) |
{ |
AcpiOsPrintf ("Invalid or unsupported argument\n"); |
return (AE_OK); |
} |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
AcpiOsPrintf ( |
"Objects of type [%s] defined in the current ACPI Namespace:\n", |
AcpiUtGetTypeName (Type)); |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
Info.Count = 0; |
Info.OwnerId = ACPI_OWNER_ID_MAX; |
Info.DebugLevel = ACPI_UINT32_MAX; |
Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; |
/* Walk the namespace from the root */ |
(void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); |
AcpiOsPrintf ( |
"\nFound %u objects of type [%s] in the current ACPI Namespace\n", |
Info.Count, AcpiUtGetTypeName (Type)); |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbWalkAndMatchName |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Find a particular name/names within the namespace. Wildcards |
* are supported -- '?' matches any character. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbWalkAndMatchName ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_STATUS Status; |
char *RequestedName = (char *) Context; |
UINT32 i; |
ACPI_BUFFER Buffer; |
ACPI_WALK_INFO Info; |
/* Check for a name match */ |
for (i = 0; i < 4; i++) |
{ |
/* Wildcard support */ |
if ((RequestedName[i] != '?') && |
(RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) |
{ |
/* No match, just exit */ |
return (AE_OK); |
} |
} |
/* Get the full pathname to this object */ |
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); |
} |
else |
{ |
Info.OwnerId = ACPI_OWNER_ID_MAX; |
Info.DebugLevel = ACPI_UINT32_MAX; |
Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; |
AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); |
(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); |
ACPI_FREE (Buffer.Pointer); |
} |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbFindNameInNamespace |
* |
* PARAMETERS: NameArg - The 4-character ACPI name to find. |
* wildcards are supported. |
* |
* RETURN: None |
* |
* DESCRIPTION: Search the namespace for a given name (with wildcards) |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbFindNameInNamespace ( |
char *NameArg) |
{ |
char AcpiName[5] = "____"; |
char *AcpiNamePtr = AcpiName; |
if (ACPI_STRLEN (NameArg) > 4) |
{ |
AcpiOsPrintf ("Name must be no longer than 4 characters\n"); |
return (AE_OK); |
} |
/* Pad out name with underscores as necessary to create a 4-char name */ |
AcpiUtStrupr (NameArg); |
while (*NameArg) |
{ |
*AcpiNamePtr = *NameArg; |
AcpiNamePtr++; |
NameArg++; |
} |
/* Walk the namespace from the root */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSetScope |
* |
* PARAMETERS: Name - New scope path |
* |
* RETURN: Status |
* |
* DESCRIPTION: Set the "current scope" as maintained by this utility. |
* The scope is used as a prefix to ACPI paths. |
* |
******************************************************************************/ |
void |
AcpiDbSetScope ( |
char *Name) |
{ |
ACPI_STATUS Status; |
ACPI_NAMESPACE_NODE *Node; |
if (!Name || Name[0] == 0) |
{ |
AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); |
return; |
} |
AcpiDbPrepNamestring (Name); |
if (Name[0] == '\\') |
{ |
/* Validate new scope from the root */ |
Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, |
&Node); |
if (ACPI_FAILURE (Status)) |
{ |
goto ErrorExit; |
} |
ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); |
ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); |
} |
else |
{ |
/* Validate new scope relative to old scope */ |
Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, |
&Node); |
if (ACPI_FAILURE (Status)) |
{ |
goto ErrorExit; |
} |
ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); |
ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); |
} |
AcpiGbl_DbScopeNode = Node; |
AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); |
return; |
ErrorExit: |
AcpiOsPrintf ("Could not attach scope: %s, %s\n", |
Name, AcpiFormatException (Status)); |
} |
/******************************************************************************* |
* |
* 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 |
AcpiDmCompareAmlResources ( |
UINT8 *Aml1Buffer, |
ACPI_RSDESC_SIZE Aml1BufferLength, |
UINT8 *Aml2Buffer, |
ACPI_RSDESC_SIZE Aml2BufferLength) |
{ |
UINT8 *Aml1; |
UINT8 *Aml2; |
ACPI_RSDESC_SIZE Aml1Length; |
ACPI_RSDESC_SIZE Aml2Length; |
ACPI_RSDESC_SIZE Offset = 0; |
UINT8 ResourceType; |
UINT32 Count = 0; |
/* Compare overall buffer sizes (may be different due to size rounding) */ |
if (Aml1BufferLength != Aml2BufferLength) |
{ |
AcpiOsPrintf ( |
"**** Buffer length mismatch in converted AML: original %X new %X ****\n", |
Aml1BufferLength, Aml2BufferLength); |
} |
Aml1 = Aml1Buffer; |
Aml2 = Aml2Buffer; |
/* Walk the descriptor lists, comparing each descriptor */ |
while (Aml1 < (Aml1Buffer + Aml1BufferLength)) |
{ |
/* Get the lengths of each descriptor */ |
Aml1Length = AcpiUtGetDescriptorLength (Aml1); |
Aml2Length = AcpiUtGetDescriptorLength (Aml2); |
ResourceType = AcpiUtGetResourceType (Aml1); |
/* Check for descriptor length match */ |
if (Aml1Length != Aml2Length) |
{ |
AcpiOsPrintf ( |
"**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n", |
Count, ResourceType, Offset, Aml1Length, Aml2Length); |
} |
/* Check for descriptor byte match */ |
else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) |
{ |
AcpiOsPrintf ( |
"**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", |
Count, ResourceType, Offset); |
} |
/* Exit on EndTag descriptor */ |
if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) |
{ |
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 |
AcpiDmTestResourceConversion ( |
ACPI_NAMESPACE_NODE *Node, |
char *Name) |
{ |
ACPI_STATUS Status; |
ACPI_BUFFER ReturnObj; |
ACPI_BUFFER ResourceObj; |
ACPI_BUFFER NewAml; |
ACPI_OBJECT *OriginalAml; |
AcpiOsPrintf ("Resource Conversion Comparison:\n"); |
NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
/* Get the original _CRS AML resource template */ |
Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not obtain %s: %s\n", |
Name, AcpiFormatException (Status)); |
return (Status); |
} |
/* Get the AML resource template, converted to internal resource structs */ |
Status = AcpiGetCurrentResources (Node, &ResourceObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", |
AcpiFormatException (Status)); |
goto Exit1; |
} |
/* Convert internal resource list to external AML resource template */ |
Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", |
AcpiFormatException (Status)); |
goto Exit2; |
} |
/* Compare original AML to the newly created AML resource list */ |
OriginalAml = ReturnObj.Pointer; |
AcpiDmCompareAmlResources ( |
OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, |
NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length); |
/* Cleanup and exit */ |
ACPI_FREE (NewAml.Pointer); |
Exit2: |
ACPI_FREE (ResourceObj.Pointer); |
Exit1: |
ACPI_FREE (ReturnObj.Pointer); |
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 |
AcpiDbDisplayResources ( |
char *ObjectArg) |
{ |
ACPI_NAMESPACE_NODE *Node; |
ACPI_STATUS Status; |
ACPI_BUFFER ReturnObj; |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
AcpiDbgLevel |= ACPI_LV_RESOURCES; |
/* Convert string to object pointer */ |
Node = AcpiDbConvertToNode (ObjectArg); |
if (!Node) |
{ |
return; |
} |
/* Prepare for a return object of arbitrary size */ |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
/* _PRT */ |
AcpiOsPrintf ("Evaluating _PRT\n"); |
/* Check if _PRT exists */ |
Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not obtain _PRT: %s\n", |
AcpiFormatException (Status)); |
goto GetCrs; |
} |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", |
AcpiFormatException (Status)); |
goto GetCrs; |
} |
AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); |
/* _CRS */ |
GetCrs: |
AcpiOsPrintf ("Evaluating _CRS\n"); |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
/* Check if _CRS exists */ |
Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not obtain _CRS: %s\n", |
AcpiFormatException (Status)); |
goto GetPrs; |
} |
/* Get the _CRS resource list */ |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
Status = AcpiGetCurrentResources (Node, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", |
AcpiFormatException (Status)); |
goto GetPrs; |
} |
/* Dump the _CRS resource list */ |
AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, |
ReturnObj.Pointer)); |
/* |
* Perform comparison of original AML to newly created AML. This tests both |
* the AML->Resource conversion and the Resource->Aml conversion. |
*/ |
Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); |
/* Execute _SRS with the resource list */ |
Status = AcpiSetCurrentResources (Node, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", |
AcpiFormatException (Status)); |
goto GetPrs; |
} |
/* _PRS */ |
GetPrs: |
AcpiOsPrintf ("Evaluating _PRS\n"); |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
/* Check if _PRS exists */ |
Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not obtain _PRS: %s\n", |
AcpiFormatException (Status)); |
goto Cleanup; |
} |
ReturnObj.Pointer = AcpiGbl_DbBuffer; |
ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
Status = AcpiGetPossibleResources (Node, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", |
AcpiFormatException (Status)); |
goto Cleanup; |
} |
AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); |
Cleanup: |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
return; |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbIntegrityWalk |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Examine one NS node for valid values. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbIntegrityWalk ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
ACPI_OPERAND_OBJECT *Object; |
BOOLEAN Alias = TRUE; |
Info->Nodes++; |
/* Verify the NS node, and dereference aliases */ |
while (Alias) |
{ |
if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) |
{ |
AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n", |
Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node), |
ACPI_DESC_TYPE_NAMED); |
return (AE_OK); |
} |
if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) || |
(Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) |
{ |
Node = (ACPI_NAMESPACE_NODE *) Node->Object; |
} |
else |
{ |
Alias = FALSE; |
} |
} |
if (Node->Type > ACPI_TYPE_LOCAL_MAX) |
{ |
AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", |
Node, Node->Type); |
return (AE_OK); |
} |
if (!AcpiUtValidAcpiName (Node->Name.Integer)) |
{ |
AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); |
return (AE_OK); |
} |
Object = AcpiNsGetAttachedObject (Node); |
if (Object) |
{ |
Info->Objects++; |
if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) |
{ |
AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", |
Object, AcpiUtGetDescriptorName (Object)); |
} |
} |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCheckIntegrity |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Check entire namespace for data structure integrity |
* |
******************************************************************************/ |
void |
AcpiDbCheckIntegrity ( |
void) |
{ |
ACPI_INTEGRITY_INFO Info = {0,0}; |
/* Search all nodes in namespace */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); |
AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", |
Info.Nodes, Info.Objects); |
} |
/******************************************************************************* |
* |
* 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 |
AcpiDbGenerateGpe ( |
char *GpeArg, |
char *BlockArg) |
{ |
UINT32 BlockNumber; |
UINT32 GpeNumber; |
ACPI_GPE_EVENT_INFO *GpeEventInfo; |
GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); |
BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); |
GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), |
GpeNumber); |
if (!GpeEventInfo) |
{ |
AcpiOsPrintf ("Invalid GPE\n"); |
return; |
} |
(void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbBusWalk |
* |
* PARAMETERS: Callback from WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Display info about device objects that have a corresponding |
* _PRT method. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbBusWalk ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
ACPI_STATUS Status; |
ACPI_BUFFER Buffer; |
ACPI_NAMESPACE_NODE *TempNode; |
ACPI_DEVICE_INFO *Info; |
UINT32 i; |
if ((Node->Type != ACPI_TYPE_DEVICE) && |
(Node->Type != ACPI_TYPE_PROCESSOR)) |
{ |
return (AE_OK); |
} |
/* Exit if there is no _PRT under this device */ |
Status = AcpiGetHandle (Node, METHOD_NAME__PRT, |
ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); |
if (ACPI_FAILURE (Status)) |
{ |
return (AE_OK); |
} |
/* Get the full path to this device object */ |
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); |
return (AE_OK); |
} |
Status = AcpiGetObjectInfo (ObjHandle, &Info); |
if (ACPI_FAILURE (Status)) |
{ |
return (AE_OK); |
} |
/* Display the full path */ |
AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); |
ACPI_FREE (Buffer.Pointer); |
if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) |
{ |
AcpiOsPrintf (" - Is PCI Root Bridge"); |
} |
AcpiOsPrintf ("\n"); |
/* _PRT info */ |
AcpiOsPrintf ("_PRT: %p\n", TempNode); |
/* Dump _ADR, _HID, _UID, _CID */ |
if (Info->Valid & ACPI_VALID_ADR) |
{ |
AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); |
} |
else |
{ |
AcpiOsPrintf ("_ADR: <Not Present>\n"); |
} |
if (Info->Valid & ACPI_VALID_HID) |
{ |
AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); |
} |
else |
{ |
AcpiOsPrintf ("_HID: <Not Present>\n"); |
} |
if (Info->Valid & ACPI_VALID_UID) |
{ |
AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); |
} |
else |
{ |
AcpiOsPrintf ("_UID: <Not Present>\n"); |
} |
if (Info->Valid & ACPI_VALID_CID) |
{ |
for (i = 0; i < Info->CompatibleIdList.Count; i++) |
{ |
AcpiOsPrintf ("_CID: %s\n", |
Info->CompatibleIdList.Ids[i].String); |
} |
} |
else |
{ |
AcpiOsPrintf ("_CID: <Not Present>\n"); |
} |
ACPI_FREE (Info); |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetBusInfo |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display info about system busses. |
* |
******************************************************************************/ |
void |
AcpiDbGetBusInfo ( |
void) |
{ |
/* Search all nodes in namespace */ |
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
AcpiDbBusWalk, NULL, NULL, NULL); |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbdisply.c |
---|
0,0 → 1,960 |
/******************************************************************************* |
* |
* Module Name: dbdisply - debug display commands |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "amlcode.h" |
#include "acdispat.h" |
#include "acnamesp.h" |
#include "acparser.h" |
#include "acinterp.h" |
#include "acdebug.h" |
#include "acdisasm.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbdisply") |
/* Local prototypes */ |
static void |
AcpiDbDumpParserDescriptor ( |
ACPI_PARSE_OBJECT *Op); |
static void * |
AcpiDbGetPointer ( |
void *Target); |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetPointer |
* |
* PARAMETERS: Target - Pointer to string to be converted |
* |
* RETURN: Converted pointer |
* |
* DESCRIPTION: Convert an ascii pointer value to a real value |
* |
******************************************************************************/ |
static void * |
AcpiDbGetPointer ( |
void *Target) |
{ |
void *ObjPtr; |
ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16)); |
return (ObjPtr); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDumpParserDescriptor |
* |
* PARAMETERS: Op - A parser Op descriptor |
* |
* RETURN: None |
* |
* DESCRIPTION: Display a formatted parser object |
* |
******************************************************************************/ |
static void |
AcpiDbDumpParserDescriptor ( |
ACPI_PARSE_OBJECT *Op) |
{ |
const ACPI_OPCODE_INFO *Info; |
Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); |
AcpiOsPrintf ("Parser Op Descriptor:\n"); |
AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); |
ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", |
Info->Name)); |
AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); |
AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); |
AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDecodeAndDisplayObject |
* |
* PARAMETERS: Target - String with object to be displayed. Names |
* and hex pointers are supported. |
* OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) |
* |
* RETURN: None |
* |
* DESCRIPTION: Display a formatted ACPI object |
* |
******************************************************************************/ |
void |
AcpiDbDecodeAndDisplayObject ( |
char *Target, |
char *OutputType) |
{ |
void *ObjPtr; |
ACPI_NAMESPACE_NODE *Node; |
ACPI_OPERAND_OBJECT *ObjDesc; |
UINT32 Display = DB_BYTE_DISPLAY; |
char Buffer[80]; |
ACPI_BUFFER RetBuf; |
ACPI_STATUS Status; |
UINT32 Size; |
if (!Target) |
{ |
return; |
} |
/* Decode the output type */ |
if (OutputType) |
{ |
AcpiUtStrupr (OutputType); |
if (OutputType[0] == 'W') |
{ |
Display = DB_WORD_DISPLAY; |
} |
else if (OutputType[0] == 'D') |
{ |
Display = DB_DWORD_DISPLAY; |
} |
else if (OutputType[0] == 'Q') |
{ |
Display = DB_QWORD_DISPLAY; |
} |
} |
RetBuf.Length = sizeof (Buffer); |
RetBuf.Pointer = Buffer; |
/* Differentiate between a number and a name */ |
if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) |
{ |
ObjPtr = AcpiDbGetPointer (Target); |
if (!AcpiOsReadable (ObjPtr, 16)) |
{ |
AcpiOsPrintf ("Address %p is invalid in this address space\n", |
ObjPtr); |
return; |
} |
/* Decode the object type */ |
switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)) |
{ |
case ACPI_DESC_TYPE_NAMED: |
/* This is a namespace Node */ |
if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) |
{ |
AcpiOsPrintf ( |
"Cannot read entire Named object at address %p\n", ObjPtr); |
return; |
} |
Node = ObjPtr; |
goto DumpNode; |
case ACPI_DESC_TYPE_OPERAND: |
/* This is a ACPI OPERAND OBJECT */ |
if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) |
{ |
AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", |
ObjPtr); |
return; |
} |
AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, |
ACPI_UINT32_MAX); |
AcpiExDumpObjectDescriptor (ObjPtr, 1); |
break; |
case ACPI_DESC_TYPE_PARSER: |
/* This is a Parser Op object */ |
if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) |
{ |
AcpiOsPrintf ( |
"Cannot read entire Parser object at address %p\n", ObjPtr); |
return; |
} |
AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, |
ACPI_UINT32_MAX); |
AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); |
break; |
default: |
/* Is not a recognizeable object */ |
Size = 16; |
if (AcpiOsReadable (ObjPtr, 64)) |
{ |
Size = 64; |
} |
/* Just dump some memory */ |
AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); |
break; |
} |
return; |
} |
/* The parameter is a name string that must be resolved to a Named obj */ |
Node = AcpiDbLocalNsLookup (Target); |
if (!Node) |
{ |
return; |
} |
DumpNode: |
/* Now dump the NS node */ |
Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not convert name to pathname\n"); |
} |
else |
{ |
AcpiOsPrintf ("Object (%p) Pathname: %s\n", |
Node, (char *) RetBuf.Pointer); |
} |
if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) |
{ |
AcpiOsPrintf ("Invalid Named object at address %p\n", Node); |
return; |
} |
AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), |
Display, ACPI_UINT32_MAX); |
AcpiExDumpNamespaceNode (Node, 1); |
ObjDesc = AcpiNsGetAttachedObject (Node); |
if (ObjDesc) |
{ |
AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); |
if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) |
{ |
AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", |
ObjDesc); |
return; |
} |
AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), |
Display, ACPI_UINT32_MAX); |
AcpiExDumpObjectDescriptor (ObjDesc, 1); |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayMethodInfo |
* |
* PARAMETERS: StartOp - Root of the control method parse tree |
* |
* RETURN: None |
* |
* DESCRIPTION: Display information about the current method |
* |
******************************************************************************/ |
void |
AcpiDbDisplayMethodInfo ( |
ACPI_PARSE_OBJECT *StartOp) |
{ |
ACPI_WALK_STATE *WalkState; |
ACPI_OPERAND_OBJECT *ObjDesc; |
ACPI_NAMESPACE_NODE *Node; |
ACPI_PARSE_OBJECT *RootOp; |
ACPI_PARSE_OBJECT *Op; |
const ACPI_OPCODE_INFO *OpInfo; |
UINT32 NumOps = 0; |
UINT32 NumOperands = 0; |
UINT32 NumOperators = 0; |
UINT32 NumRemainingOps = 0; |
UINT32 NumRemainingOperands = 0; |
UINT32 NumRemainingOperators = 0; |
BOOLEAN CountRemaining = FALSE; |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
ObjDesc = WalkState->MethodDesc; |
Node = WalkState->MethodNode; |
AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", |
AcpiUtGetNodeName (Node)); |
AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", |
(UINT32) ObjDesc->Method.ParamCount, |
(UINT32) ObjDesc->Method.SyncLevel); |
RootOp = StartOp; |
while (RootOp->Common.Parent) |
{ |
RootOp = RootOp->Common.Parent; |
} |
Op = RootOp; |
while (Op) |
{ |
if (Op == StartOp) |
{ |
CountRemaining = TRUE; |
} |
NumOps++; |
if (CountRemaining) |
{ |
NumRemainingOps++; |
} |
/* Decode the opcode */ |
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); |
switch (OpInfo->Class) |
{ |
case AML_CLASS_ARGUMENT: |
if (CountRemaining) |
{ |
NumRemainingOperands++; |
} |
NumOperands++; |
break; |
case AML_CLASS_UNKNOWN: |
/* Bad opcode or ASCII character */ |
continue; |
default: |
if (CountRemaining) |
{ |
NumRemainingOperators++; |
} |
NumOperators++; |
break; |
} |
Op = AcpiPsGetDepthNext (StartOp, Op); |
} |
AcpiOsPrintf ( |
"Method contains: %X AML Opcodes - %X Operators, %X Operands\n", |
NumOps, NumOperators, NumOperands); |
AcpiOsPrintf ( |
"Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", |
NumRemainingOps, NumRemainingOperators, NumRemainingOperands); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayLocals |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display all locals for the currently running control method |
* |
******************************************************************************/ |
void |
AcpiDbDisplayLocals ( |
void) |
{ |
ACPI_WALK_STATE *WalkState; |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
AcpiDmDisplayLocals (WalkState); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayArguments |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display all arguments for the currently running control method |
* |
******************************************************************************/ |
void |
AcpiDbDisplayArguments ( |
void) |
{ |
ACPI_WALK_STATE *WalkState; |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
AcpiDmDisplayArguments (WalkState); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayResults |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display current contents of a method result stack |
* |
******************************************************************************/ |
void |
AcpiDbDisplayResults ( |
void) |
{ |
UINT32 i; |
ACPI_WALK_STATE *WalkState; |
ACPI_OPERAND_OBJECT *ObjDesc; |
UINT32 ResultCount = 0; |
ACPI_NAMESPACE_NODE *Node; |
ACPI_GENERIC_STATE *Frame; |
UINT32 Index; /* Index onto current frame */ |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
ObjDesc = WalkState->MethodDesc; |
Node = WalkState->MethodNode; |
if (WalkState->Results) |
{ |
ResultCount = WalkState->ResultCount; |
} |
AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", |
AcpiUtGetNodeName (Node), ResultCount); |
/* From the top element of result stack */ |
Frame = WalkState->Results; |
Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; |
for (i = 0; i < ResultCount; i++) |
{ |
ObjDesc = Frame->Results.ObjDesc[Index]; |
AcpiOsPrintf ("Result%u: ", i); |
AcpiDmDisplayInternalObject (ObjDesc, WalkState); |
if (Index == 0) |
{ |
Frame = Frame->Results.Next; |
Index = ACPI_RESULTS_FRAME_OBJ_NUM; |
} |
Index--; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayCallingTree |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display current calling tree of nested control methods |
* |
******************************************************************************/ |
void |
AcpiDbDisplayCallingTree ( |
void) |
{ |
ACPI_WALK_STATE *WalkState; |
ACPI_NAMESPACE_NODE *Node; |
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); |
if (!WalkState) |
{ |
AcpiOsPrintf ("There is no method currently executing\n"); |
return; |
} |
Node = WalkState->MethodNode; |
AcpiOsPrintf ("Current Control Method Call Tree\n"); |
while (WalkState) |
{ |
Node = WalkState->MethodNode; |
AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); |
WalkState = WalkState->Next; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayObjectType |
* |
* PARAMETERS: ObjectArg - User entered NS node handle |
* |
* RETURN: None |
* |
* DESCRIPTION: Display type of an arbitrary NS node |
* |
******************************************************************************/ |
void |
AcpiDbDisplayObjectType ( |
char *ObjectArg) |
{ |
ACPI_HANDLE Handle; |
ACPI_DEVICE_INFO *Info; |
ACPI_STATUS Status; |
UINT32 i; |
Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); |
Status = AcpiGetObjectInfo (Handle, &Info); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not get object info, %s\n", |
AcpiFormatException (Status)); |
return; |
} |
AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", |
ACPI_FORMAT_UINT64 (Info->Address), |
Info->CurrentStatus, Info->Flags); |
AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", |
Info->HighestDstates[0], Info->HighestDstates[1], |
Info->HighestDstates[2], Info->HighestDstates[3]); |
AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", |
Info->LowestDstates[0], Info->LowestDstates[1], |
Info->LowestDstates[2], Info->LowestDstates[3], |
Info->LowestDstates[4]); |
if (Info->Valid & ACPI_VALID_HID) |
{ |
AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); |
} |
if (Info->Valid & ACPI_VALID_UID) |
{ |
AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); |
} |
if (Info->Valid & ACPI_VALID_CID) |
{ |
for (i = 0; i < Info->CompatibleIdList.Count; i++) |
{ |
AcpiOsPrintf ("CID %u: %s\n", i, |
Info->CompatibleIdList.Ids[i].String); |
} |
} |
ACPI_FREE (Info); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayResultObject |
* |
* PARAMETERS: ObjDesc - Object to be displayed |
* WalkState - Current walk state |
* |
* RETURN: None |
* |
* DESCRIPTION: Display the result of an AML opcode |
* |
* Note: Curently only displays the result object if we are single stepping. |
* However, this output may be useful in other contexts and could be enabled |
* to do so if needed. |
* |
******************************************************************************/ |
void |
AcpiDbDisplayResultObject ( |
ACPI_OPERAND_OBJECT *ObjDesc, |
ACPI_WALK_STATE *WalkState) |
{ |
/* Only display if single stepping */ |
if (!AcpiGbl_CmSingleStep) |
{ |
return; |
} |
AcpiOsPrintf ("ResultObj: "); |
AcpiDmDisplayInternalObject (ObjDesc, WalkState); |
AcpiOsPrintf ("\n"); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayArgumentObject |
* |
* PARAMETERS: ObjDesc - Object to be displayed |
* WalkState - Current walk state |
* |
* RETURN: None |
* |
* DESCRIPTION: Display the result of an AML opcode |
* |
******************************************************************************/ |
void |
AcpiDbDisplayArgumentObject ( |
ACPI_OPERAND_OBJECT *ObjDesc, |
ACPI_WALK_STATE *WalkState) |
{ |
if (!AcpiGbl_CmSingleStep) |
{ |
return; |
} |
AcpiOsPrintf ("ArgObj: "); |
AcpiDmDisplayInternalObject (ObjDesc, WalkState); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayGpes |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display the current GPE structures |
* |
******************************************************************************/ |
void |
AcpiDbDisplayGpes ( |
void) |
{ |
ACPI_GPE_BLOCK_INFO *GpeBlock; |
ACPI_GPE_XRUPT_INFO *GpeXruptInfo; |
ACPI_GPE_EVENT_INFO *GpeEventInfo; |
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; |
char *GpeType; |
UINT32 GpeIndex; |
UINT32 Block = 0; |
UINT32 i; |
UINT32 j; |
char Buffer[80]; |
ACPI_BUFFER RetBuf; |
ACPI_STATUS Status; |
RetBuf.Length = sizeof (Buffer); |
RetBuf.Pointer = Buffer; |
Block = 0; |
/* Walk the GPE lists */ |
GpeXruptInfo = AcpiGbl_GpeXruptListHead; |
while (GpeXruptInfo) |
{ |
GpeBlock = GpeXruptInfo->GpeBlockListHead; |
while (GpeBlock) |
{ |
Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not convert name to pathname\n"); |
} |
if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) |
{ |
GpeType = "FADT-defined GPE block"; |
} |
else |
{ |
GpeType = "GPE Block Device"; |
} |
AcpiOsPrintf ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", |
Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); |
AcpiOsPrintf (" Registers: %u (%u GPEs)\n", |
GpeBlock->RegisterCount, GpeBlock->GpeCount); |
AcpiOsPrintf (" GPE range: 0x%X to 0x%X on interrupt %u\n", |
GpeBlock->BlockBaseNumber, |
GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), |
GpeXruptInfo->InterruptNumber); |
AcpiOsPrintf ( |
" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", |
GpeBlock->RegisterInfo, |
ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), |
ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); |
AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); |
/* Examine each GPE Register within the block */ |
for (i = 0; i < GpeBlock->RegisterCount; i++) |
{ |
GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; |
AcpiOsPrintf ( |
" Reg %u: (GPE %.2X-%.2X) RunEnable %2.2X WakeEnable %2.2X" |
" Status %8.8X%8.8X Enable %8.8X%8.8X\n", |
i, GpeRegisterInfo->BaseGpeNumber, |
GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), |
GpeRegisterInfo->EnableForRun, |
GpeRegisterInfo->EnableForWake, |
ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), |
ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); |
/* Now look at the individual GPEs in this byte register */ |
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) |
{ |
GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; |
GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; |
if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) |
{ |
/* This GPE is not used (no method or handler), ignore it */ |
continue; |
} |
AcpiOsPrintf ( |
" GPE %.2X: %p RunRefs %2.2X WakeRefs %2.2X Flags %2.2X (", |
GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo, |
GpeEventInfo->RuntimeCount, GpeEventInfo->WakeupCount, |
GpeEventInfo->Flags); |
/* Decode the flags byte */ |
if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) |
{ |
AcpiOsPrintf ("Level, "); |
} |
else |
{ |
AcpiOsPrintf ("Edge, "); |
} |
if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) |
{ |
AcpiOsPrintf ("CanWake, "); |
} |
else |
{ |
AcpiOsPrintf ("RunOnly, "); |
} |
switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) |
{ |
case ACPI_GPE_DISPATCH_NOT_USED: |
AcpiOsPrintf ("NotUsed"); |
break; |
case ACPI_GPE_DISPATCH_HANDLER: |
AcpiOsPrintf ("Handler"); |
break; |
case ACPI_GPE_DISPATCH_METHOD: |
AcpiOsPrintf ("Method"); |
break; |
default: |
AcpiOsPrintf ("UNKNOWN: %X", |
GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK); |
break; |
} |
AcpiOsPrintf (")\n"); |
} |
} |
Block++; |
GpeBlock = GpeBlock->Next; |
} |
GpeXruptInfo = GpeXruptInfo->Next; |
} |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbexec.c |
---|
0,0 → 1,793 |
/******************************************************************************* |
* |
* Module Name: dbexec - debugger control method execution |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdebug.h" |
#include "acnamesp.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbexec") |
static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; |
/* Local prototypes */ |
static ACPI_STATUS |
AcpiDbExecuteMethod ( |
ACPI_DB_METHOD_INFO *Info, |
ACPI_BUFFER *ReturnObj); |
static void |
AcpiDbExecuteSetup ( |
ACPI_DB_METHOD_INFO *Info); |
static UINT32 |
AcpiDbGetOutstandingAllocations ( |
void); |
static void ACPI_SYSTEM_XFACE |
AcpiDbMethodThread ( |
void *Context); |
static ACPI_STATUS |
AcpiDbExecutionWalk ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbExecuteMethod |
* |
* PARAMETERS: Info - Valid info segment |
* ReturnObj - Where to put return object |
* |
* RETURN: Status |
* |
* DESCRIPTION: Execute a control method. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbExecuteMethod ( |
ACPI_DB_METHOD_INFO *Info, |
ACPI_BUFFER *ReturnObj) |
{ |
ACPI_STATUS Status; |
ACPI_OBJECT_LIST ParamObjects; |
ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; |
ACPI_HANDLE Handle; |
UINT32 i; |
ACPI_DEVICE_INFO *ObjInfo; |
if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) |
{ |
AcpiOsPrintf ("Warning: debug output is not enabled!\n"); |
} |
/* Get the NS node, determines existence also */ |
Status = AcpiGetHandle (NULL, Info->Pathname, &Handle); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
/* Get the object info for number of method parameters */ |
Status = AcpiGetObjectInfo (Handle, &ObjInfo); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
ParamObjects.Pointer = NULL; |
ParamObjects.Count = 0; |
if (ObjInfo->Type == ACPI_TYPE_METHOD) |
{ |
/* Are there arguments to the method? */ |
if (Info->Args && Info->Args[0]) |
{ |
for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++) |
{ |
Params[i].Type = ACPI_TYPE_INTEGER; |
Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); |
} |
ParamObjects.Pointer = Params; |
ParamObjects.Count = i; |
} |
else |
{ |
/* Setup default parameters */ |
for (i = 0; i < ObjInfo->ParamCount; i++) |
{ |
switch (i) |
{ |
case 0: |
Params[0].Type = ACPI_TYPE_INTEGER; |
Params[0].Integer.Value = 0x01020304; |
break; |
case 1: |
Params[1].Type = ACPI_TYPE_STRING; |
Params[1].String.Length = 12; |
Params[1].String.Pointer = "AML Debugger"; |
break; |
default: |
Params[i].Type = ACPI_TYPE_INTEGER; |
Params[i].Integer.Value = i * (UINT64) 0x1000; |
break; |
} |
} |
ParamObjects.Pointer = Params; |
ParamObjects.Count = ObjInfo->ParamCount; |
} |
} |
ACPI_FREE (ObjInfo); |
/* Prepare for a return object of arbitrary size */ |
ReturnObj->Pointer = AcpiGbl_DbBuffer; |
ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; |
/* Do the actual method execution */ |
AcpiGbl_MethodExecuting = TRUE; |
Status = AcpiEvaluateObject (NULL, |
Info->Pathname, &ParamObjects, ReturnObj); |
AcpiGbl_CmSingleStep = FALSE; |
AcpiGbl_MethodExecuting = FALSE; |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbExecuteSetup |
* |
* PARAMETERS: Info - Valid method info |
* |
* RETURN: None |
* |
* DESCRIPTION: Setup info segment prior to method execution |
* |
******************************************************************************/ |
static void |
AcpiDbExecuteSetup ( |
ACPI_DB_METHOD_INFO *Info) |
{ |
/* Catenate the current scope to the supplied name */ |
Info->Pathname[0] = 0; |
if ((Info->Name[0] != '\\') && |
(Info->Name[0] != '/')) |
{ |
ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); |
} |
ACPI_STRCAT (Info->Pathname, Info->Name); |
AcpiDbPrepNamestring (Info->Pathname); |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
AcpiOsPrintf ("Executing %s\n", Info->Pathname); |
if (Info->Flags & EX_SINGLE_STEP) |
{ |
AcpiGbl_CmSingleStep = TRUE; |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
} |
else |
{ |
/* No single step, allow redirection to a file */ |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
} |
} |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
UINT32 |
AcpiDbGetCacheInfo ( |
ACPI_MEMORY_LIST *Cache) |
{ |
return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth); |
} |
#endif |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetOutstandingAllocations |
* |
* PARAMETERS: None |
* |
* RETURN: Current global allocation count minus cache entries |
* |
* DESCRIPTION: Determine the current number of "outstanding" allocations -- |
* those allocations that have not been freed and also are not |
* in one of the various object caches. |
* |
******************************************************************************/ |
static UINT32 |
AcpiDbGetOutstandingAllocations ( |
void) |
{ |
UINT32 Outstanding = 0; |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache); |
Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache); |
Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache); |
Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache); |
#endif |
return (Outstanding); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbExecutionWalk |
* |
* PARAMETERS: WALK_CALLBACK |
* |
* RETURN: Status |
* |
* DESCRIPTION: Execute a control method. Name is relative to the current |
* scope. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbExecutionWalk ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_OPERAND_OBJECT *ObjDesc; |
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
ACPI_BUFFER ReturnObj; |
ACPI_STATUS Status; |
ObjDesc = AcpiNsGetAttachedObject (Node); |
if (ObjDesc->Method.ParamCount) |
{ |
return (AE_OK); |
} |
ReturnObj.Pointer = NULL; |
ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
AcpiNsPrintNodePathname (Node, "Execute"); |
/* Do the actual method execution */ |
AcpiOsPrintf ("\n"); |
AcpiGbl_MethodExecuting = TRUE; |
Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); |
AcpiOsPrintf ("[%4.4s] returned %s\n", AcpiUtGetNodeName (Node), |
AcpiFormatException (Status)); |
AcpiGbl_MethodExecuting = FALSE; |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbExecute |
* |
* PARAMETERS: Name - Name of method to execute |
* Args - Parameters to the method |
* Flags - single step/no single step |
* |
* RETURN: None |
* |
* DESCRIPTION: Execute a control method. Name is relative to the current |
* scope. |
* |
******************************************************************************/ |
void |
AcpiDbExecute ( |
char *Name, |
char **Args, |
UINT32 Flags) |
{ |
ACPI_STATUS Status; |
ACPI_BUFFER ReturnObj; |
char *NameString; |
#ifdef ACPI_DEBUG_OUTPUT |
UINT32 PreviousAllocations; |
UINT32 Allocations; |
/* Memory allocation tracking */ |
PreviousAllocations = AcpiDbGetOutstandingAllocations (); |
#endif |
if (*Name == '*') |
{ |
(void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, |
ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); |
return; |
} |
else |
{ |
NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); |
if (!NameString) |
{ |
return; |
} |
ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
ACPI_STRCPY (NameString, Name); |
AcpiUtStrupr (NameString); |
AcpiGbl_DbMethodInfo.Name = NameString; |
AcpiGbl_DbMethodInfo.Args = Args; |
AcpiGbl_DbMethodInfo.Flags = Flags; |
ReturnObj.Pointer = NULL; |
ReturnObj.Length = ACPI_ALLOCATE_BUFFER; |
AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); |
ACPI_FREE (NameString); |
} |
/* |
* Allow any handlers in separate threads to complete. |
* (Such as Notify handlers invoked from AML executed above). |
*/ |
AcpiOsSleep ((UINT64) 10); |
#ifdef ACPI_DEBUG_OUTPUT |
/* Memory allocation tracking */ |
Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations; |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
if (Allocations > 0) |
{ |
AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", |
Allocations); |
} |
#endif |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Execution of %s failed with status %s\n", |
AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); |
} |
else |
{ |
/* Display a return object, if any */ |
if (ReturnObj.Length) |
{ |
AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, |
(UINT32) ReturnObj.Length); |
AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
} |
else |
{ |
AcpiOsPrintf ("No return object from execution of %s\n", |
AcpiGbl_DbMethodInfo.Pathname); |
} |
} |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbMethodThread |
* |
* PARAMETERS: Context - Execution info segment |
* |
* RETURN: None |
* |
* DESCRIPTION: Debugger execute thread. Waits for a command line, then |
* simply dispatches it. |
* |
******************************************************************************/ |
static void ACPI_SYSTEM_XFACE |
AcpiDbMethodThread ( |
void *Context) |
{ |
ACPI_STATUS Status; |
ACPI_DB_METHOD_INFO *Info = Context; |
ACPI_DB_METHOD_INFO LocalInfo; |
UINT32 i; |
UINT8 Allow; |
ACPI_BUFFER ReturnObj; |
/* |
* AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments. |
* Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads |
* concurrently. |
* |
* Note: The arguments we are passing are used by the ASL test suite |
* (aslts). Do not change them without updating the tests. |
*/ |
(void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER); |
if (Info->InitArgs) |
{ |
AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); |
AcpiDbUInt32ToHexString (ACPI_TO_INTEGER (AcpiOsGetThreadId ()), |
Info->IdOfThreadStr); |
} |
if (Info->Threads && (Info->NumCreated < Info->NumThreads)) |
{ |
Info->Threads[Info->NumCreated++] = |
ACPI_TO_INTEGER (AcpiOsGetThreadId()); |
} |
LocalInfo = *Info; |
LocalInfo.Args = LocalInfo.Arguments; |
LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr; |
LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr; |
LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr; |
LocalInfo.Arguments[3] = NULL; |
(void) AcpiOsSignalSemaphore (Info->InfoGate, 1); |
for (i = 0; i < Info->NumLoops; i++) |
{ |
Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("%s During execution of %s at iteration %X\n", |
AcpiFormatException (Status), Info->Pathname, i); |
if (Status == AE_ABORT_METHOD) |
{ |
break; |
} |
} |
#if 0 |
if ((i % 100) == 0) |
{ |
AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); |
} |
if (ReturnObj.Length) |
{ |
AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", |
Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); |
AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); |
} |
#endif |
} |
/* Signal our completion */ |
Allow = 0; |
(void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); |
Info->NumCompleted++; |
if (Info->NumCompleted == Info->NumThreads) |
{ |
/* Do signal for main thread once only */ |
Allow = 1; |
} |
(void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1); |
if (Allow) |
{ |
Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", |
AcpiFormatException (Status)); |
} |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCreateExecutionThreads |
* |
* PARAMETERS: NumThreadsArg - Number of threads to create |
* NumLoopsArg - Loop count for the thread(s) |
* MethodNameArg - Control method to execute |
* |
* RETURN: None |
* |
* DESCRIPTION: Create threads to execute method(s) |
* |
******************************************************************************/ |
void |
AcpiDbCreateExecutionThreads ( |
char *NumThreadsArg, |
char *NumLoopsArg, |
char *MethodNameArg) |
{ |
ACPI_STATUS Status; |
UINT32 NumThreads; |
UINT32 NumLoops; |
UINT32 i; |
UINT32 Size; |
ACPI_MUTEX MainThreadGate; |
ACPI_MUTEX ThreadCompleteGate; |
ACPI_MUTEX InfoGate; |
/* Get the arguments */ |
NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); |
NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); |
if (!NumThreads || !NumLoops) |
{ |
AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", |
NumThreads, NumLoops); |
return; |
} |
/* |
* Create the semaphore for synchronization of |
* the created threads with the main thread. |
*/ |
Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", |
AcpiFormatException (Status)); |
return; |
} |
/* |
* Create the semaphore for synchronization |
* between the created threads. |
*/ |
Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", |
AcpiFormatException (Status)); |
(void) AcpiOsDeleteSemaphore (MainThreadGate); |
return; |
} |
Status = AcpiOsCreateSemaphore (1, 1, &InfoGate); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n", |
AcpiFormatException (Status)); |
(void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
(void) AcpiOsDeleteSemaphore (MainThreadGate); |
return; |
} |
ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); |
/* Array to store IDs of threads */ |
AcpiGbl_DbMethodInfo.NumThreads = NumThreads; |
Size = 4 * AcpiGbl_DbMethodInfo.NumThreads; |
AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size); |
if (AcpiGbl_DbMethodInfo.Threads == NULL) |
{ |
AcpiOsPrintf ("No memory for thread IDs array\n"); |
(void) AcpiOsDeleteSemaphore (MainThreadGate); |
(void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
(void) AcpiOsDeleteSemaphore (InfoGate); |
return; |
} |
ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); |
/* Setup the context to be passed to each thread */ |
AcpiGbl_DbMethodInfo.Name = MethodNameArg; |
AcpiGbl_DbMethodInfo.Flags = 0; |
AcpiGbl_DbMethodInfo.NumLoops = NumLoops; |
AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate; |
AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate; |
AcpiGbl_DbMethodInfo.InfoGate = InfoGate; |
/* Init arguments to be passed to method */ |
AcpiGbl_DbMethodInfo.InitArgs = 1; |
AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments; |
AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr; |
AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr; |
AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr; |
AcpiGbl_DbMethodInfo.Arguments[3] = NULL; |
AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); |
AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); |
/* Create the threads */ |
AcpiOsPrintf ("Creating %X threads to execute %X times each\n", |
NumThreads, NumLoops); |
for (i = 0; i < (NumThreads); i++) |
{ |
Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, |
&AcpiGbl_DbMethodInfo); |
if (ACPI_FAILURE (Status)) |
{ |
break; |
} |
} |
/* Wait for all threads to complete */ |
(void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER); |
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); |
AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
/* Cleanup and exit */ |
(void) AcpiOsDeleteSemaphore (MainThreadGate); |
(void) AcpiOsDeleteSemaphore (ThreadCompleteGate); |
(void) AcpiOsDeleteSemaphore (InfoGate); |
AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); |
AcpiGbl_DbMethodInfo.Threads = NULL; |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbfileio.c |
---|
0,0 → 1,649 |
/******************************************************************************* |
* |
* Module Name: dbfileio - Debugger file I/O commands. These can't usually |
* be used when running the debugger in Ring 0 (Kernel mode) |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdebug.h" |
#ifdef ACPI_APPLICATION |
#include "actables.h" |
#endif |
#if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbfileio") |
/* |
* NOTE: this is here for lack of a better place. It is used in all |
* flavors of the debugger, need LCD file |
*/ |
#ifdef ACPI_APPLICATION |
#include <stdio.h> |
FILE *AcpiGbl_DebugFile = NULL; |
#endif |
#ifdef ACPI_DEBUGGER |
/* Local prototypes */ |
#ifdef ACPI_APPLICATION |
static ACPI_STATUS |
AcpiDbCheckTextModeCorruption ( |
UINT8 *Table, |
UINT32 TableLength, |
UINT32 FileLength); |
#endif |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCloseDebugFile |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: If open, close the current debug output file |
* |
******************************************************************************/ |
void |
AcpiDbCloseDebugFile ( |
void) |
{ |
#ifdef ACPI_APPLICATION |
if (AcpiGbl_DebugFile) |
{ |
fclose (AcpiGbl_DebugFile); |
AcpiGbl_DebugFile = NULL; |
AcpiGbl_DbOutputToFile = FALSE; |
AcpiOsPrintf ("Debug output file %s closed\n", AcpiGbl_DbDebugFilename); |
} |
#endif |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbOpenDebugFile |
* |
* PARAMETERS: Name - Filename to open |
* |
* RETURN: None |
* |
* DESCRIPTION: Open a file where debug output will be directed. |
* |
******************************************************************************/ |
void |
AcpiDbOpenDebugFile ( |
char *Name) |
{ |
#ifdef ACPI_APPLICATION |
AcpiDbCloseDebugFile (); |
AcpiGbl_DebugFile = fopen (Name, "w+"); |
if (AcpiGbl_DebugFile) |
{ |
AcpiOsPrintf ("Debug output file %s opened\n", Name); |
ACPI_STRCPY (AcpiGbl_DbDebugFilename, Name); |
AcpiGbl_DbOutputToFile = TRUE; |
} |
else |
{ |
AcpiOsPrintf ("Could not open debug file %s\n", Name); |
} |
#endif |
} |
#endif |
#ifdef ACPI_APPLICATION |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCheckTextModeCorruption |
* |
* PARAMETERS: Table - Table buffer |
* TableLength - Length of table from the table header |
* FileLength - Length of the file that contains the table |
* |
* RETURN: Status |
* |
* DESCRIPTION: Check table for text mode file corruption where all linefeed |
* characters (LF) have been replaced by carriage return linefeed |
* pairs (CR/LF). |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbCheckTextModeCorruption ( |
UINT8 *Table, |
UINT32 TableLength, |
UINT32 FileLength) |
{ |
UINT32 i; |
UINT32 Pairs = 0; |
if (TableLength != FileLength) |
{ |
ACPI_WARNING ((AE_INFO, |
"File length (0x%X) is not the same as the table length (0x%X)", |
FileLength, TableLength)); |
} |
/* Scan entire table to determine if each LF has been prefixed with a CR */ |
for (i = 1; i < FileLength; i++) |
{ |
if (Table[i] == 0x0A) |
{ |
if (Table[i - 1] != 0x0D) |
{ |
/* The LF does not have a preceding CR, table not corrupted */ |
return (AE_OK); |
} |
else |
{ |
/* Found a CR/LF pair */ |
Pairs++; |
} |
i++; |
} |
} |
if (!Pairs) |
{ |
return (AE_OK); |
} |
/* |
* Entire table scanned, each CR is part of a CR/LF pair -- |
* meaning that the table was treated as a text file somewhere. |
* |
* NOTE: We can't "fix" the table, because any existing CR/LF pairs in the |
* original table are left untouched by the text conversion process -- |
* meaning that we cannot simply replace CR/LF pairs with LFs. |
*/ |
AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); |
AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); |
AcpiOsPrintf ("Table cannot be repaired!\n"); |
return (AE_BAD_VALUE); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbReadTable |
* |
* PARAMETERS: fp - File that contains table |
* Table - Return value, buffer with table |
* TableLength - Return value, length of table |
* |
* RETURN: Status |
* |
* DESCRIPTION: Load the DSDT from the file pointer |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbReadTable ( |
FILE *fp, |
ACPI_TABLE_HEADER **Table, |
UINT32 *TableLength) |
{ |
ACPI_TABLE_HEADER TableHeader; |
UINT32 Actual; |
ACPI_STATUS Status; |
UINT32 FileSize; |
BOOLEAN StandardHeader = TRUE; |
/* Get the file size */ |
fseek (fp, 0, SEEK_END); |
FileSize = (UINT32) ftell (fp); |
fseek (fp, 0, SEEK_SET); |
if (FileSize < 4) |
{ |
return (AE_BAD_HEADER); |
} |
/* Read the signature */ |
if (fread (&TableHeader, 1, 4, fp) != 4) |
{ |
AcpiOsPrintf ("Could not read the table signature\n"); |
return (AE_BAD_HEADER); |
} |
fseek (fp, 0, SEEK_SET); |
/* The RSDT and FACS tables do not have standard ACPI headers */ |
if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") || |
ACPI_COMPARE_NAME (TableHeader.Signature, "FACS")) |
{ |
*TableLength = FileSize; |
StandardHeader = FALSE; |
} |
else |
{ |
/* Read the table header */ |
if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != |
sizeof (ACPI_TABLE_HEADER)) |
{ |
AcpiOsPrintf ("Could not read the table header\n"); |
return (AE_BAD_HEADER); |
} |
#if 0 |
/* Validate the table header/length */ |
Status = AcpiTbValidateTableHeader (&TableHeader); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Table header is invalid!\n"); |
return (Status); |
} |
#endif |
/* File size must be at least as long as the Header-specified length */ |
if (TableHeader.Length > FileSize) |
{ |
AcpiOsPrintf ( |
"TableHeader length [0x%X] greater than the input file size [0x%X]\n", |
TableHeader.Length, FileSize); |
return (AE_BAD_HEADER); |
} |
#ifdef ACPI_OBSOLETE_CODE |
/* We only support a limited number of table types */ |
if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) && |
ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) && |
ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4)) |
{ |
AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", |
(char *) TableHeader.Signature); |
ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); |
return (AE_ERROR); |
} |
#endif |
*TableLength = TableHeader.Length; |
} |
/* Allocate a buffer for the table */ |
*Table = AcpiOsAllocate ((size_t) FileSize); |
if (!*Table) |
{ |
AcpiOsPrintf ( |
"Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", |
TableHeader.Signature, *TableLength); |
return (AE_NO_MEMORY); |
} |
/* Get the rest of the table */ |
fseek (fp, 0, SEEK_SET); |
Actual = fread (*Table, 1, (size_t) FileSize, fp); |
if (Actual == FileSize) |
{ |
if (StandardHeader) |
{ |
/* Now validate the checksum */ |
Status = AcpiTbVerifyChecksum ((void *) *Table, |
ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); |
if (Status == AE_BAD_CHECKSUM) |
{ |
Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, |
FileSize, (*Table)->Length); |
return (Status); |
} |
} |
return (AE_OK); |
} |
if (Actual > 0) |
{ |
AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", |
FileSize, Actual); |
return (AE_OK); |
} |
AcpiOsPrintf ("Error - could not read the table file\n"); |
AcpiOsFree (*Table); |
*Table = NULL; |
*TableLength = 0; |
return (AE_ERROR); |
} |
/******************************************************************************* |
* |
* FUNCTION: AeLocalLoadTable |
* |
* PARAMETERS: Table - pointer to a buffer containing the entire |
* table to be loaded |
* |
* RETURN: Status |
* |
* DESCRIPTION: This function is called to load a table from the caller's |
* buffer. The buffer must contain an entire ACPI Table including |
* a valid header. The header fields will be verified, and if it |
* is determined that the table is invalid, the call will fail. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AeLocalLoadTable ( |
ACPI_TABLE_HEADER *Table) |
{ |
ACPI_STATUS Status = AE_OK; |
/* ACPI_TABLE_DESC TableInfo; */ |
ACPI_FUNCTION_TRACE (AeLocalLoadTable); |
#if 0 |
if (!Table) |
{ |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
} |
TableInfo.Pointer = Table; |
Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL); |
if (ACPI_FAILURE (Status)) |
{ |
return_ACPI_STATUS (Status); |
} |
/* Install the new table into the local data structures */ |
Status = AcpiTbInstallTable (&TableInfo); |
if (ACPI_FAILURE (Status)) |
{ |
if (Status == AE_ALREADY_EXISTS) |
{ |
/* Table already exists, no error */ |
Status = AE_OK; |
} |
/* Free table allocated by AcpiTbGetTable */ |
AcpiTbDeleteSingleTable (&TableInfo); |
return_ACPI_STATUS (Status); |
} |
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) |
Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); |
if (ACPI_FAILURE (Status)) |
{ |
/* Uninstall table and free the buffer */ |
AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT); |
return_ACPI_STATUS (Status); |
} |
#endif |
#endif |
return_ACPI_STATUS (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbReadTableFromFile |
* |
* PARAMETERS: Filename - File where table is located |
* Table - Where a pointer to the table is returned |
* |
* RETURN: Status |
* |
* DESCRIPTION: Get an ACPI table from a file |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbReadTableFromFile ( |
char *Filename, |
ACPI_TABLE_HEADER **Table) |
{ |
FILE *fp; |
UINT32 TableLength; |
ACPI_STATUS Status; |
/* Open the file */ |
fp = fopen (Filename, "rb"); |
if (!fp) |
{ |
AcpiOsPrintf ("Could not open input file %s\n", Filename); |
return (AE_ERROR); |
} |
/* Get the entire file */ |
fprintf (stderr, "Loading Acpi table from file %s\n", Filename); |
Status = AcpiDbReadTable (fp, Table, &TableLength); |
fclose(fp); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not get table from the file\n"); |
return (Status); |
} |
return (AE_OK); |
} |
#endif |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetTableFromFile |
* |
* PARAMETERS: Filename - File where table is located |
* ReturnTable - Where a pointer to the table is returned |
* |
* RETURN: Status |
* |
* DESCRIPTION: Load an ACPI table from a file |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbGetTableFromFile ( |
char *Filename, |
ACPI_TABLE_HEADER **ReturnTable) |
{ |
#ifdef ACPI_APPLICATION |
ACPI_STATUS Status; |
ACPI_TABLE_HEADER *Table; |
BOOLEAN IsAmlTable = TRUE; |
Status = AcpiDbReadTableFromFile (Filename, &Table); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
#ifdef ACPI_DATA_TABLE_DISASSEMBLY |
IsAmlTable = AcpiUtIsAmlTable (Table); |
#endif |
if (IsAmlTable) |
{ |
/* Attempt to recognize and install the table */ |
Status = AeLocalLoadTable (Table); |
if (ACPI_FAILURE (Status)) |
{ |
if (Status == AE_ALREADY_EXISTS) |
{ |
AcpiOsPrintf ("Table %4.4s is already installed\n", |
Table->Signature); |
} |
else |
{ |
AcpiOsPrintf ("Could not install table, %s\n", |
AcpiFormatException (Status)); |
} |
return (Status); |
} |
fprintf (stderr, |
"Acpi table [%4.4s] successfully installed and loaded\n", |
Table->Signature); |
} |
AcpiGbl_AcpiHardwarePresent = FALSE; |
if (ReturnTable) |
{ |
*ReturnTable = Table; |
} |
#endif /* ACPI_APPLICATION */ |
return (AE_OK); |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbhistry.c |
---|
0,0 → 1,292 |
/****************************************************************************** |
* |
* Module Name: dbhistry - debugger HISTORY command |
* |
*****************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdebug.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbhistry") |
#define HI_NO_HISTORY 0 |
#define HI_RECORD_HISTORY 1 |
#define HISTORY_SIZE 20 |
typedef struct HistoryInfo |
{ |
char Command[80]; |
UINT32 CmdNum; |
} HISTORY_INFO; |
static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; |
static UINT16 AcpiGbl_LoHistory = 0; |
static UINT16 AcpiGbl_NumHistory = 0; |
static UINT16 AcpiGbl_NextHistoryIndex = 0; |
static UINT32 AcpiGbl_NextCmdNum = 1; |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbAddToHistory |
* |
* PARAMETERS: CommandLine - Command to add |
* |
* RETURN: None |
* |
* DESCRIPTION: Add a command line to the history buffer. |
* |
******************************************************************************/ |
void |
AcpiDbAddToHistory ( |
char *CommandLine) |
{ |
/* Put command into the next available slot */ |
ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, |
CommandLine); |
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum; |
/* Adjust indexes */ |
if ((AcpiGbl_NumHistory == HISTORY_SIZE) && |
(AcpiGbl_NextHistoryIndex == AcpiGbl_LoHistory)) |
{ |
AcpiGbl_LoHistory++; |
if (AcpiGbl_LoHistory >= HISTORY_SIZE) |
{ |
AcpiGbl_LoHistory = 0; |
} |
} |
AcpiGbl_NextHistoryIndex++; |
if (AcpiGbl_NextHistoryIndex >= HISTORY_SIZE) |
{ |
AcpiGbl_NextHistoryIndex = 0; |
} |
AcpiGbl_NextCmdNum++; |
if (AcpiGbl_NumHistory < HISTORY_SIZE) |
{ |
AcpiGbl_NumHistory++; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayHistory |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Display the contents of the history buffer |
* |
******************************************************************************/ |
void |
AcpiDbDisplayHistory ( |
void) |
{ |
UINT32 i; |
UINT16 HistoryIndex; |
HistoryIndex = AcpiGbl_LoHistory; |
/* Dump entire history buffer */ |
for (i = 0; i < AcpiGbl_NumHistory; i++) |
{ |
AcpiOsPrintf ("%ld %s\n", AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum, |
AcpiGbl_HistoryBuffer[HistoryIndex].Command); |
HistoryIndex++; |
if (HistoryIndex >= HISTORY_SIZE) |
{ |
HistoryIndex = 0; |
} |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetFromHistory |
* |
* PARAMETERS: CommandNumArg - String containing the number of the |
* command to be retrieved |
* |
* RETURN: Pointer to the retrieved command. Null on error. |
* |
* DESCRIPTION: Get a command from the history buffer |
* |
******************************************************************************/ |
char * |
AcpiDbGetFromHistory ( |
char *CommandNumArg) |
{ |
UINT32 i; |
UINT16 HistoryIndex; |
UINT32 CmdNum; |
if (CommandNumArg == NULL) |
{ |
CmdNum = AcpiGbl_NextCmdNum - 1; |
} |
else |
{ |
CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); |
} |
/* Search history buffer */ |
HistoryIndex = AcpiGbl_LoHistory; |
for (i = 0; i < AcpiGbl_NumHistory; i++) |
{ |
if (AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum == CmdNum) |
{ |
/* Found the commnad, return it */ |
return (AcpiGbl_HistoryBuffer[HistoryIndex].Command); |
} |
HistoryIndex++; |
if (HistoryIndex >= HISTORY_SIZE) |
{ |
HistoryIndex = 0; |
} |
} |
AcpiOsPrintf ("Invalid history number: %u\n", HistoryIndex); |
return (NULL); |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbinput.c |
---|
0,0 → 1,1085 |
/******************************************************************************* |
* |
* Module Name: dbinput - user front-end to the AML debugger |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdebug.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbinput") |
/* Local prototypes */ |
static char * |
AcpiDbGetNextToken ( |
char *String, |
char **Next); |
static UINT32 |
AcpiDbGetLine ( |
char *InputBuffer); |
static UINT32 |
AcpiDbMatchCommand ( |
char *UserCommand); |
static void |
AcpiDbSingleThread ( |
void); |
static void |
AcpiDbDisplayHelp ( |
char *HelpType); |
/* |
* Top-level debugger commands. |
* |
* This list of commands must match the string table below it |
*/ |
enum AcpiExDebuggerCommands |
{ |
CMD_NOT_FOUND = 0, |
CMD_NULL, |
CMD_ALLOCATIONS, |
CMD_ARGS, |
CMD_ARGUMENTS, |
CMD_BATCH, |
CMD_BREAKPOINT, |
CMD_BUSINFO, |
CMD_CALL, |
CMD_CLOSE, |
CMD_DEBUG, |
CMD_DISASSEMBLE, |
CMD_DUMP, |
CMD_ENABLEACPI, |
CMD_EVENT, |
CMD_EXECUTE, |
CMD_EXIT, |
CMD_FIND, |
CMD_GO, |
CMD_GPE, |
CMD_GPES, |
CMD_HELP, |
CMD_HELP2, |
CMD_HISTORY, |
CMD_HISTORY_EXE, |
CMD_HISTORY_LAST, |
CMD_INFORMATION, |
CMD_INTEGRITY, |
CMD_INTO, |
CMD_LEVEL, |
CMD_LIST, |
CMD_LOAD, |
CMD_LOCALS, |
CMD_LOCKS, |
CMD_METHODS, |
CMD_NAMESPACE, |
CMD_NOTIFY, |
CMD_OBJECT, |
CMD_OPEN, |
CMD_OWNER, |
CMD_PREDEFINED, |
CMD_PREFIX, |
CMD_QUIT, |
CMD_REFERENCES, |
CMD_RESOURCES, |
CMD_RESULTS, |
CMD_SET, |
CMD_SLEEP, |
CMD_STATS, |
CMD_STOP, |
CMD_TABLES, |
CMD_TERMINATE, |
CMD_THREADS, |
CMD_TRACE, |
CMD_TREE, |
CMD_TYPE, |
CMD_UNLOAD |
}; |
#define CMD_FIRST_VALID 2 |
/* Second parameter is the required argument count */ |
static const COMMAND_INFO AcpiGbl_DbCommands[] = |
{ |
{"<NOT FOUND>", 0}, |
{"<NULL>", 0}, |
{"ALLOCATIONS", 0}, |
{"ARGS", 0}, |
{"ARGUMENTS", 0}, |
{"BATCH", 0}, |
{"BREAKPOINT", 1}, |
{"BUSINFO", 0}, |
{"CALL", 0}, |
{"CLOSE", 0}, |
{"DEBUG", 1}, |
{"DISASSEMBLE", 1}, |
{"DUMP", 1}, |
{"ENABLEACPI", 0}, |
{"EVENT", 1}, |
{"EXECUTE", 1}, |
{"EXIT", 0}, |
{"FIND", 1}, |
{"GO", 0}, |
{"GPE", 2}, |
{"GPES", 0}, |
{"HELP", 0}, |
{"?", 0}, |
{"HISTORY", 0}, |
{"!", 1}, |
{"!!", 0}, |
{"INFORMATION", 0}, |
{"INTEGRITY", 0}, |
{"INTO", 0}, |
{"LEVEL", 0}, |
{"LIST", 0}, |
{"LOAD", 1}, |
{"LOCALS", 0}, |
{"LOCKS", 0}, |
{"METHODS", 0}, |
{"NAMESPACE", 0}, |
{"NOTIFY", 2}, |
{"OBJECT", 1}, |
{"OPEN", 1}, |
{"OWNER", 1}, |
{"PREDEFINED", 0}, |
{"PREFIX", 0}, |
{"QUIT", 0}, |
{"REFERENCES", 1}, |
{"RESOURCES", 1}, |
{"RESULTS", 0}, |
{"SET", 3}, |
{"SLEEP", 1}, |
{"STATS", 0}, |
{"STOP", 0}, |
{"TABLES", 0}, |
{"TERMINATE", 0}, |
{"THREADS", 3}, |
{"TRACE", 1}, |
{"TREE", 0}, |
{"TYPE", 1}, |
{"UNLOAD", 1}, |
{NULL, 0} |
}; |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayHelp |
* |
* PARAMETERS: HelpType - Subcommand (optional) |
* |
* RETURN: None |
* |
* DESCRIPTION: Print a usage message. |
* |
******************************************************************************/ |
static void |
AcpiDbDisplayHelp ( |
char *HelpType) |
{ |
AcpiUtStrupr (HelpType); |
/* No parameter, just give the overview */ |
if (!HelpType) |
{ |
AcpiOsPrintf ("ACPI CA Debugger Commands\n\n"); |
AcpiOsPrintf ("The following classes of commands are available. Help is available for\n"); |
AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n"); |
AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); |
AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); |
AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); |
AcpiOsPrintf (" [STATISTICS] Statistical Information\n"); |
AcpiOsPrintf (" [FILE] File I/O Commands\n"); |
return; |
} |
/* |
* Parameter is the command class |
* |
* The idea here is to keep each class of commands smaller than a screenful |
*/ |
switch (HelpType[0]) |
{ |
case 'G': |
AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n"); |
AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); |
AcpiOsPrintf ("Dump <Address>|<Namepath>\n"); |
AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); |
AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n"); |
AcpiOsPrintf ("Help This help screen\n"); |
AcpiOsPrintf ("History Display command history buffer\n"); |
AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n"); |
AcpiOsPrintf ("Locks Current status of internal mutexes\n"); |
AcpiOsPrintf ("Quit or Exit Exit this command\n"); |
AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); |
AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); |
AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); |
AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n"); |
AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); |
AcpiOsPrintf ("!! Execute last command again\n"); |
return; |
case 'S': |
AcpiOsPrintf ("\nStats Subcommands\n\n"); |
AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); |
AcpiOsPrintf ("Memory Dump internal memory lists\n"); |
AcpiOsPrintf ("Misc Namespace search and mutex stats\n"); |
AcpiOsPrintf ("Objects Summary of namespace objects\n"); |
AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n"); |
AcpiOsPrintf ("Stack Display CPU stack usage\n"); |
AcpiOsPrintf ("Tables Info about current ACPI table(s)\n"); |
return; |
case 'N': |
AcpiOsPrintf ("\nNamespace Access Commands\n\n"); |
AcpiOsPrintf ("Businfo Display system bus info\n"); |
AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n"); |
AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); |
AcpiOsPrintf ("Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n"); |
AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); |
AcpiOsPrintf ("Gpes Display info on all GPEs\n"); |
AcpiOsPrintf ("Integrity Validate namespace integrity\n"); |
AcpiOsPrintf ("Methods Display list of loaded control methods\n"); |
AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); |
AcpiOsPrintf ("Notify <Object> <Value> Send a notification on Object\n"); |
AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n"); |
AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); |
AcpiOsPrintf ("Predefined Check all predefined names\n"); |
AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); |
AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); |
AcpiOsPrintf ("Resources <Device> Get and display Device resources\n"); |
AcpiOsPrintf ("Set N <NamedObject> <Value> Set value for named integer\n"); |
AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n"); |
AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); |
AcpiOsPrintf ("Type <Object> Display object type\n"); |
return; |
case 'M': |
AcpiOsPrintf ("\nControl Method Execution Commands\n\n"); |
AcpiOsPrintf ("Arguments (or Args) Display method arguments\n"); |
AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n"); |
AcpiOsPrintf ("Call Run to next control method invocation\n"); |
AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n"); |
AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n"); |
AcpiOsPrintf ("Go Allow method to run to completion\n"); |
AcpiOsPrintf ("Information Display info about the current method\n"); |
AcpiOsPrintf ("Into Step into (not over) a method call\n"); |
AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n"); |
AcpiOsPrintf ("Locals Display method local variables\n"); |
AcpiOsPrintf ("Results Display method result stack\n"); |
AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); |
AcpiOsPrintf ("Stop Terminate control method\n"); |
AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); |
AcpiOsPrintf ("Trace <method name> Trace method execution\n"); |
AcpiOsPrintf ("Tree Display control method calling tree\n"); |
AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n"); |
return; |
case 'F': |
AcpiOsPrintf ("\nFile I/O Commands\n\n"); |
AcpiOsPrintf ("Close Close debug output file\n"); |
AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n"); |
AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n"); |
return; |
default: |
AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType); |
return; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetNextToken |
* |
* PARAMETERS: String - Command buffer |
* Next - Return value, end of next token |
* |
* RETURN: Pointer to the start of the next token. |
* |
* DESCRIPTION: Command line parsing. Get the next token on the command line |
* |
******************************************************************************/ |
static char * |
AcpiDbGetNextToken ( |
char *String, |
char **Next) |
{ |
char *Start; |
/* At end of buffer? */ |
if (!String || !(*String)) |
{ |
return (NULL); |
} |
/* Get rid of any spaces at the beginning */ |
if (*String == ' ') |
{ |
while (*String && (*String == ' ')) |
{ |
String++; |
} |
if (!(*String)) |
{ |
return (NULL); |
} |
} |
Start = String; |
/* Find end of token */ |
while (*String && (*String != ' ')) |
{ |
String++; |
} |
if (!(*String)) |
{ |
*Next = NULL; |
} |
else |
{ |
*String = 0; |
*Next = String + 1; |
} |
return (Start); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbGetLine |
* |
* PARAMETERS: InputBuffer - Command line buffer |
* |
* RETURN: Count of arguments to the command |
* |
* DESCRIPTION: Get the next command line from the user. Gets entire line |
* up to the next newline |
* |
******************************************************************************/ |
static UINT32 |
AcpiDbGetLine ( |
char *InputBuffer) |
{ |
UINT32 i; |
UINT32 Count; |
char *Next; |
char *This; |
ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); |
This = AcpiGbl_DbParsedBuf; |
for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) |
{ |
AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next); |
if (!AcpiGbl_DbArgs[i]) |
{ |
break; |
} |
This = Next; |
} |
/* Uppercase the actual command */ |
if (AcpiGbl_DbArgs[0]) |
{ |
AcpiUtStrupr (AcpiGbl_DbArgs[0]); |
} |
Count = i; |
if (Count) |
{ |
Count--; /* Number of args only */ |
} |
return (Count); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbMatchCommand |
* |
* PARAMETERS: UserCommand - User command line |
* |
* RETURN: Index into command array, -1 if not found |
* |
* DESCRIPTION: Search command array for a command match |
* |
******************************************************************************/ |
static UINT32 |
AcpiDbMatchCommand ( |
char *UserCommand) |
{ |
UINT32 i; |
if (!UserCommand || UserCommand[0] == 0) |
{ |
return (CMD_NULL); |
} |
for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) |
{ |
if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == |
AcpiGbl_DbCommands[i].Name) |
{ |
return (i); |
} |
} |
/* Command not recognized */ |
return (CMD_NOT_FOUND); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCommandDispatch |
* |
* PARAMETERS: InputBuffer - Command line buffer |
* WalkState - Current walk |
* Op - Current (executing) parse op |
* |
* RETURN: Status |
* |
* DESCRIPTION: Command dispatcher. |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbCommandDispatch ( |
char *InputBuffer, |
ACPI_WALK_STATE *WalkState, |
ACPI_PARSE_OBJECT *Op) |
{ |
UINT32 Temp; |
UINT32 CommandIndex; |
UINT32 ParamCount; |
char *CommandLine; |
ACPI_STATUS Status = AE_CTRL_TRUE; |
/* If AcpiTerminate has been called, terminate this thread */ |
if (AcpiGbl_DbTerminateThreads) |
{ |
return (AE_CTRL_TERMINATE); |
} |
ParamCount = AcpiDbGetLine (InputBuffer); |
CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); |
Temp = 0; |
/* Verify that we have the minimum number of params */ |
if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) |
{ |
AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n", |
ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, |
AcpiGbl_DbCommands[CommandIndex].MinArgs); |
return (AE_CTRL_TRUE); |
} |
/* Decode and dispatch the command */ |
switch (CommandIndex) |
{ |
case CMD_NULL: |
if (Op) |
{ |
return (AE_OK); |
} |
break; |
case CMD_ALLOCATIONS: |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
AcpiUtDumpAllocations ((UINT32) -1, NULL); |
#endif |
break; |
case CMD_ARGS: |
case CMD_ARGUMENTS: |
AcpiDbDisplayArguments (); |
break; |
case CMD_BATCH: |
AcpiDbBatchExecute (AcpiGbl_DbArgs[1]); |
break; |
case CMD_BREAKPOINT: |
AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); |
break; |
case CMD_BUSINFO: |
AcpiDbGetBusInfo (); |
break; |
case CMD_CALL: |
AcpiDbSetMethodCallBreakpoint (Op); |
Status = AE_OK; |
break; |
case CMD_CLOSE: |
AcpiDbCloseDebugFile (); |
break; |
case CMD_DEBUG: |
AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP); |
break; |
case CMD_DISASSEMBLE: |
(void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); |
break; |
case CMD_DUMP: |
AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_ENABLEACPI: |
Status = AcpiEnable(); |
if (ACPI_FAILURE(Status)) |
{ |
AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); |
return (Status); |
} |
break; |
case CMD_EVENT: |
AcpiOsPrintf ("Event command not implemented\n"); |
break; |
case CMD_EXECUTE: |
AcpiDbExecute (AcpiGbl_DbArgs[1], |
&AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); |
break; |
case CMD_FIND: |
Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); |
break; |
case CMD_GO: |
AcpiGbl_CmSingleStep = FALSE; |
return (AE_OK); |
case CMD_GPE: |
AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_GPES: |
AcpiDbDisplayGpes (); |
break; |
case CMD_HELP: |
case CMD_HELP2: |
AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]); |
break; |
case CMD_HISTORY: |
AcpiDbDisplayHistory (); |
break; |
case CMD_HISTORY_EXE: |
CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]); |
if (!CommandLine) |
{ |
return (AE_CTRL_TRUE); |
} |
Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); |
return (Status); |
case CMD_HISTORY_LAST: |
CommandLine = AcpiDbGetFromHistory (NULL); |
if (!CommandLine) |
{ |
return (AE_CTRL_TRUE); |
} |
Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); |
return (Status); |
case CMD_INFORMATION: |
AcpiDbDisplayMethodInfo (Op); |
break; |
case CMD_INTEGRITY: |
AcpiDbCheckIntegrity (); |
break; |
case CMD_INTO: |
if (Op) |
{ |
AcpiGbl_CmSingleStep = TRUE; |
return (AE_OK); |
} |
break; |
case CMD_LEVEL: |
if (ParamCount == 0) |
{ |
AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", |
AcpiGbl_DbDebugLevel); |
AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", |
AcpiGbl_DbConsoleDebugLevel); |
} |
else if (ParamCount == 2) |
{ |
Temp = AcpiGbl_DbConsoleDebugLevel; |
AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], |
NULL, 16); |
AcpiOsPrintf ( |
"Debug Level for console output was %8.8lX, now %8.8lX\n", |
Temp, AcpiGbl_DbConsoleDebugLevel); |
} |
else |
{ |
Temp = AcpiGbl_DbDebugLevel; |
AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); |
AcpiOsPrintf ( |
"Debug Level for file output was %8.8lX, now %8.8lX\n", |
Temp, AcpiGbl_DbDebugLevel); |
} |
break; |
case CMD_LIST: |
AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); |
break; |
case CMD_LOAD: |
Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL); |
break; |
case CMD_LOCKS: |
AcpiDbDisplayLocks (); |
break; |
case CMD_LOCALS: |
AcpiDbDisplayLocals (); |
break; |
case CMD_METHODS: |
Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); |
break; |
case CMD_NAMESPACE: |
AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_NOTIFY: |
Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); |
AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); |
break; |
case CMD_OBJECT: |
AcpiUtStrupr (AcpiGbl_DbArgs[1]); |
Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_OPEN: |
AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); |
break; |
case CMD_OWNER: |
AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_PREDEFINED: |
AcpiDbCheckPredefinedNames (); |
break; |
case CMD_PREFIX: |
AcpiDbSetScope (AcpiGbl_DbArgs[1]); |
break; |
case CMD_REFERENCES: |
AcpiDbFindReferences (AcpiGbl_DbArgs[1]); |
break; |
case CMD_RESOURCES: |
AcpiDbDisplayResources (AcpiGbl_DbArgs[1]); |
break; |
case CMD_RESULTS: |
AcpiDbDisplayResults (); |
break; |
case CMD_SET: |
AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], |
AcpiGbl_DbArgs[3]); |
break; |
case CMD_SLEEP: |
Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); |
break; |
case CMD_STATS: |
Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); |
break; |
case CMD_STOP: |
return (AE_NOT_IMPLEMENTED); |
case CMD_TABLES: |
AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]); |
break; |
case CMD_TERMINATE: |
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
AcpiUtSubsystemShutdown (); |
/* |
* TBD: [Restructure] Need some way to re-initialize without |
* re-creating the semaphores! |
*/ |
/* AcpiInitialize (NULL); */ |
break; |
case CMD_THREADS: |
AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], |
AcpiGbl_DbArgs[3]); |
break; |
case CMD_TRACE: |
(void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); |
break; |
case CMD_TREE: |
AcpiDbDisplayCallingTree (); |
break; |
case CMD_TYPE: |
AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); |
break; |
case CMD_UNLOAD: |
AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); |
break; |
case CMD_EXIT: |
case CMD_QUIT: |
if (Op) |
{ |
AcpiOsPrintf ("Method execution terminated\n"); |
return (AE_CTRL_TERMINATE); |
} |
if (!AcpiGbl_DbOutputToFile) |
{ |
AcpiDbgLevel = ACPI_DEBUG_DEFAULT; |
} |
AcpiDbCloseDebugFile (); |
AcpiGbl_DbTerminateThreads = TRUE; |
return (AE_CTRL_TERMINATE); |
case CMD_NOT_FOUND: |
default: |
AcpiOsPrintf ("Unknown Command\n"); |
return (AE_CTRL_TRUE); |
} |
if (ACPI_SUCCESS (Status)) |
{ |
Status = AE_CTRL_TRUE; |
} |
/* Add all commands that come here to the history buffer */ |
AcpiDbAddToHistory (InputBuffer); |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbExecuteThread |
* |
* PARAMETERS: Context - Not used |
* |
* RETURN: None |
* |
* DESCRIPTION: Debugger execute thread. Waits for a command line, then |
* simply dispatches it. |
* |
******************************************************************************/ |
void ACPI_SYSTEM_XFACE |
AcpiDbExecuteThread ( |
void *Context) |
{ |
ACPI_STATUS Status = AE_OK; |
ACPI_STATUS MStatus; |
while (Status != AE_CTRL_TERMINATE) |
{ |
AcpiGbl_MethodExecuting = FALSE; |
AcpiGbl_StepToNextCall = FALSE; |
MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); |
if (ACPI_FAILURE (MStatus)) |
{ |
return; |
} |
Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); |
MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); |
if (ACPI_FAILURE (MStatus)) |
{ |
return; |
} |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSingleThread |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Debugger execute thread. Waits for a command line, then |
* simply dispatches it. |
* |
******************************************************************************/ |
static void |
AcpiDbSingleThread ( |
void) |
{ |
AcpiGbl_MethodExecuting = FALSE; |
AcpiGbl_StepToNextCall = FALSE; |
(void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbUserCommands |
* |
* PARAMETERS: Prompt - User prompt (depends on mode) |
* Op - Current executing parse op |
* |
* RETURN: None |
* |
* DESCRIPTION: Command line execution for the AML debugger. Commands are |
* matched and dispatched here. |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbUserCommands ( |
char Prompt, |
ACPI_PARSE_OBJECT *Op) |
{ |
ACPI_STATUS Status = AE_OK; |
/* TBD: [Restructure] Need a separate command line buffer for step mode */ |
while (!AcpiGbl_DbTerminateThreads) |
{ |
/* Force output to console until a command is entered */ |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
/* Different prompt if method is executing */ |
if (!AcpiGbl_MethodExecuting) |
{ |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); |
} |
else |
{ |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); |
} |
/* Get the user input line */ |
(void) AcpiOsGetLine (AcpiGbl_DbLineBuf); |
/* Check for single or multithreaded debug */ |
if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) |
{ |
/* |
* Signal the debug thread that we have a command to execute, |
* and wait for the command to complete. |
*/ |
Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
} |
else |
{ |
/* Just call to the command line interpreter */ |
AcpiDbSingleThread (); |
} |
} |
/* |
* Only this thread (the original thread) should actually terminate the |
* subsystem, because all the semaphores are deleted during termination |
*/ |
Status = AcpiTerminate (); |
return (Status); |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbstats.c |
---|
0,0 → 1,621 |
/******************************************************************************* |
* |
* Module Name: dbstats - Generation and display of ACPI table statistics |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acdebug.h" |
#include "acnamesp.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbstats") |
/* Local prototypes */ |
static void |
AcpiDbCountNamespaceObjects ( |
void); |
static void |
AcpiDbEnumerateObject ( |
ACPI_OPERAND_OBJECT *ObjDesc); |
static ACPI_STATUS |
AcpiDbClassifyOneObject ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue); |
#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE |
static void |
AcpiDbListInfo ( |
ACPI_MEMORY_LIST *List); |
#endif |
/* |
* Statistics subcommands |
*/ |
static ARGUMENT_INFO AcpiDbStatTypes [] = |
{ |
{"ALLOCATIONS"}, |
{"OBJECTS"}, |
{"MEMORY"}, |
{"MISC"}, |
{"TABLES"}, |
{"SIZES"}, |
{"STACK"}, |
{NULL} /* Must be null terminated */ |
}; |
#define CMD_STAT_ALLOCATIONS 0 |
#define CMD_STAT_OBJECTS 1 |
#define CMD_STAT_MEMORY 2 |
#define CMD_STAT_MISC 3 |
#define CMD_STAT_TABLES 4 |
#define CMD_STAT_SIZES 5 |
#define CMD_STAT_STACK 6 |
#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbListInfo |
* |
* PARAMETERS: List - Memory list/cache to be displayed |
* |
* RETURN: None |
* |
* DESCRIPTION: Display information about the input memory list or cache. |
* |
******************************************************************************/ |
static void |
AcpiDbListInfo ( |
ACPI_MEMORY_LIST *List) |
{ |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
UINT32 Outstanding; |
#endif |
AcpiOsPrintf ("\n%s\n", List->ListName); |
/* MaxDepth > 0 indicates a cache object */ |
if (List->MaxDepth > 0) |
{ |
AcpiOsPrintf ( |
" Cache: [Depth MaxD Avail Size] %8.2X %8.2X %8.2X %8.2X\n", |
List->CurrentDepth, |
List->MaxDepth, |
List->MaxDepth - List->CurrentDepth, |
(List->CurrentDepth * List->ObjectSize)); |
} |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
if (List->MaxDepth > 0) |
{ |
AcpiOsPrintf ( |
" Cache: [Requests Hits Misses ObjSize] %8.2X %8.2X %8.2X %8.2X\n", |
List->Requests, |
List->Hits, |
List->Requests - List->Hits, |
List->ObjectSize); |
} |
Outstanding = AcpiDbGetCacheInfo (List); |
if (List->ObjectSize) |
{ |
AcpiOsPrintf ( |
" Mem: [Alloc Free Max CurSize Outstanding] %8.2X %8.2X %8.2X %8.2X %8.2X\n", |
List->TotalAllocated, |
List->TotalFreed, |
List->MaxOccupied, |
Outstanding * List->ObjectSize, |
Outstanding); |
} |
else |
{ |
AcpiOsPrintf ( |
" Mem: [Alloc Free Max CurSize Outstanding Total] %8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", |
List->TotalAllocated, |
List->TotalFreed, |
List->MaxOccupied, |
List->CurrentTotalSize, |
Outstanding, |
List->TotalSize); |
} |
#endif |
} |
#endif |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbEnumerateObject |
* |
* PARAMETERS: ObjDesc - Object to be counted |
* |
* RETURN: None |
* |
* DESCRIPTION: Add this object to the global counts, by object type. |
* Limited recursion handles subobjects and packages, and this |
* is probably acceptable within the AML debugger only. |
* |
******************************************************************************/ |
static void |
AcpiDbEnumerateObject ( |
ACPI_OPERAND_OBJECT *ObjDesc) |
{ |
UINT32 i; |
if (!ObjDesc) |
{ |
return; |
} |
/* Enumerate this object first */ |
AcpiGbl_NumObjects++; |
if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) |
{ |
AcpiGbl_ObjTypeCountMisc++; |
} |
else |
{ |
AcpiGbl_ObjTypeCount [ObjDesc->Common.Type]++; |
} |
/* Count the sub-objects */ |
switch (ObjDesc->Common.Type) |
{ |
case ACPI_TYPE_PACKAGE: |
for (i = 0; i < ObjDesc->Package.Count; i++) |
{ |
AcpiDbEnumerateObject (ObjDesc->Package.Elements[i]); |
} |
break; |
case ACPI_TYPE_DEVICE: |
AcpiDbEnumerateObject (ObjDesc->Device.SystemNotify); |
AcpiDbEnumerateObject (ObjDesc->Device.DeviceNotify); |
AcpiDbEnumerateObject (ObjDesc->Device.Handler); |
break; |
case ACPI_TYPE_BUFFER_FIELD: |
if (AcpiNsGetSecondaryObject (ObjDesc)) |
{ |
AcpiGbl_ObjTypeCount [ACPI_TYPE_BUFFER_FIELD]++; |
} |
break; |
case ACPI_TYPE_REGION: |
AcpiGbl_ObjTypeCount [ACPI_TYPE_LOCAL_REGION_FIELD ]++; |
AcpiDbEnumerateObject (ObjDesc->Region.Handler); |
break; |
case ACPI_TYPE_POWER: |
AcpiDbEnumerateObject (ObjDesc->PowerResource.SystemNotify); |
AcpiDbEnumerateObject (ObjDesc->PowerResource.DeviceNotify); |
break; |
case ACPI_TYPE_PROCESSOR: |
AcpiDbEnumerateObject (ObjDesc->Processor.SystemNotify); |
AcpiDbEnumerateObject (ObjDesc->Processor.DeviceNotify); |
AcpiDbEnumerateObject (ObjDesc->Processor.Handler); |
break; |
case ACPI_TYPE_THERMAL: |
AcpiDbEnumerateObject (ObjDesc->ThermalZone.SystemNotify); |
AcpiDbEnumerateObject (ObjDesc->ThermalZone.DeviceNotify); |
AcpiDbEnumerateObject (ObjDesc->ThermalZone.Handler); |
break; |
default: |
break; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbClassifyOneObject |
* |
* PARAMETERS: Callback for WalkNamespace |
* |
* RETURN: Status |
* |
* DESCRIPTION: Enumerate both the object descriptor (including subobjects) and |
* the parent namespace node. |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbClassifyOneObject ( |
ACPI_HANDLE ObjHandle, |
UINT32 NestingLevel, |
void *Context, |
void **ReturnValue) |
{ |
ACPI_NAMESPACE_NODE *Node; |
ACPI_OPERAND_OBJECT *ObjDesc; |
UINT32 Type; |
AcpiGbl_NumNodes++; |
Node = (ACPI_NAMESPACE_NODE *) ObjHandle; |
ObjDesc = AcpiNsGetAttachedObject (Node); |
AcpiDbEnumerateObject (ObjDesc); |
Type = Node->Type; |
if (Type > ACPI_TYPE_NS_NODE_MAX) |
{ |
AcpiGbl_NodeTypeCountMisc++; |
} |
else |
{ |
AcpiGbl_NodeTypeCount [Type]++; |
} |
return AE_OK; |
#ifdef ACPI_FUTURE_IMPLEMENTATION |
/* TBD: These need to be counted during the initial parsing phase */ |
if (AcpiPsIsNamedOp (Op->Opcode)) |
{ |
NumNodes++; |
} |
if (IsMethod) |
{ |
NumMethodElements++; |
} |
NumGrammarElements++; |
Op = AcpiPsGetDepthNext (Root, Op); |
SizeOfParseTree = (NumGrammarElements - NumMethodElements) * |
(UINT32) sizeof (ACPI_PARSE_OBJECT); |
SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); |
SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); |
SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); |
#endif |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbCountNamespaceObjects |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Count and classify the entire namespace, including all |
* namespace nodes and attached objects. |
* |
******************************************************************************/ |
static void |
AcpiDbCountNamespaceObjects ( |
void) |
{ |
UINT32 i; |
AcpiGbl_NumNodes = 0; |
AcpiGbl_NumObjects = 0; |
AcpiGbl_ObjTypeCountMisc = 0; |
for (i = 0; i < (ACPI_TYPE_NS_NODE_MAX -1); i++) |
{ |
AcpiGbl_ObjTypeCount [i] = 0; |
AcpiGbl_NodeTypeCount [i] = 0; |
} |
(void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, |
ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDisplayStatistics |
* |
* PARAMETERS: TypeArg - Subcommand |
* |
* RETURN: Status |
* |
* DESCRIPTION: Display various statistics |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbDisplayStatistics ( |
char *TypeArg) |
{ |
UINT32 i; |
UINT32 Temp; |
if (!TypeArg) |
{ |
AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); |
return (AE_OK); |
} |
AcpiUtStrupr (TypeArg); |
Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); |
if (Temp == (UINT32) -1) |
{ |
AcpiOsPrintf ("Invalid or unsupported argument\n"); |
return (AE_OK); |
} |
switch (Temp) |
{ |
case CMD_STAT_ALLOCATIONS: |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
AcpiUtDumpAllocationInfo (); |
#endif |
break; |
case CMD_STAT_TABLES: |
AcpiOsPrintf ("ACPI Table Information (not implemented):\n\n"); |
break; |
case CMD_STAT_OBJECTS: |
AcpiDbCountNamespaceObjects (); |
AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); |
AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", |
"ACPI_TYPE", "NODES", "OBJECTS"); |
for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) |
{ |
AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i), |
AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]); |
} |
AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown", |
AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc); |
AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "TOTALS:", |
AcpiGbl_NumNodes, AcpiGbl_NumObjects); |
break; |
case CMD_STAT_MEMORY: |
#ifdef ACPI_DBG_TRACK_ALLOCATIONS |
AcpiOsPrintf ("\n----Object Statistics (all in hex)---------\n"); |
AcpiDbListInfo (AcpiGbl_GlobalList); |
AcpiDbListInfo (AcpiGbl_NsNodeList); |
#endif |
#ifdef ACPI_USE_LOCAL_CACHE |
AcpiOsPrintf ("\n----Cache Statistics (all in hex)---------\n"); |
AcpiDbListInfo (AcpiGbl_OperandCache); |
AcpiDbListInfo (AcpiGbl_PsNodeCache); |
AcpiDbListInfo (AcpiGbl_PsNodeExtCache); |
AcpiDbListInfo (AcpiGbl_StateCache); |
#endif |
break; |
case CMD_STAT_MISC: |
AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n"); |
AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", |
AcpiGbl_PsFindCount); |
AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", |
AcpiGbl_NsLookupCount); |
AcpiOsPrintf ("\n"); |
AcpiOsPrintf ("Mutex usage:\n\n"); |
for (i = 0; i < ACPI_NUM_MUTEX; i++) |
{ |
AcpiOsPrintf ("%-28s: % 7ld\n", |
AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); |
} |
break; |
case CMD_STAT_SIZES: |
AcpiOsPrintf ("\nInternal object sizes:\n\n"); |
AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); |
AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER)); |
AcpiOsPrintf ("String %3d\n", sizeof (ACPI_OBJECT_STRING)); |
AcpiOsPrintf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER)); |
AcpiOsPrintf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE)); |
AcpiOsPrintf ("BufferField %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD)); |
AcpiOsPrintf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE)); |
AcpiOsPrintf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT)); |
AcpiOsPrintf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD)); |
AcpiOsPrintf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX)); |
AcpiOsPrintf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION)); |
AcpiOsPrintf ("PowerResource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE)); |
AcpiOsPrintf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR)); |
AcpiOsPrintf ("ThermalZone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE)); |
AcpiOsPrintf ("RegionField %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD)); |
AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD)); |
AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD)); |
AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE)); |
AcpiOsPrintf ("Notify %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); |
AcpiOsPrintf ("AddressSpace %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); |
AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); |
AcpiOsPrintf ("Data %3d\n", sizeof (ACPI_OBJECT_DATA)); |
AcpiOsPrintf ("\n"); |
AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJ_COMMON)); |
AcpiOsPrintf ("ParseObjectNamed %3d\n", sizeof (ACPI_PARSE_OBJ_NAMED)); |
AcpiOsPrintf ("ParseObjectAsl %3d\n", sizeof (ACPI_PARSE_OBJ_ASL)); |
AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT)); |
AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE)); |
AcpiOsPrintf ("AcpiObject %3d\n", sizeof (ACPI_OBJECT)); |
break; |
case CMD_STAT_STACK: |
#if defined(ACPI_DEBUG_OUTPUT) |
Temp = (UINT32) ACPI_PTR_DIFF (AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); |
AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n"); |
AcpiOsPrintf ("Entry Stack Pointer %p\n", AcpiGbl_EntryStackPointer); |
AcpiOsPrintf ("Lowest Stack Pointer %p\n", AcpiGbl_LowestStackPointer); |
AcpiOsPrintf ("Stack Use %X (%u)\n", Temp, Temp); |
AcpiOsPrintf ("Deepest Procedure Nesting %u\n", AcpiGbl_DeepestNesting); |
#endif |
break; |
default: |
break; |
} |
AcpiOsPrintf ("\n"); |
return (AE_OK); |
} |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbutils.c |
---|
0,0 → 1,599 |
/******************************************************************************* |
* |
* Module Name: dbutils - AML debugger utilities |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "acnamesp.h" |
#include "acdebug.h" |
#include "acdisasm.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbutils") |
/* Local prototypes */ |
#ifdef ACPI_OBSOLETE_FUNCTIONS |
ACPI_STATUS |
AcpiDbSecondPassParse ( |
ACPI_PARSE_OBJECT *Root); |
void |
AcpiDbDumpBuffer ( |
UINT32 Address); |
#endif |
static char *Converter = "0123456789ABCDEF"; |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbMatchArgument |
* |
* PARAMETERS: UserArgument - User command line |
* Arguments - Array of commands to match against |
* |
* RETURN: Index into command array or ACPI_TYPE_NOT_FOUND if not found |
* |
* DESCRIPTION: Search command array for a command match |
* |
******************************************************************************/ |
ACPI_OBJECT_TYPE |
AcpiDbMatchArgument ( |
char *UserArgument, |
ARGUMENT_INFO *Arguments) |
{ |
UINT32 i; |
if (!UserArgument || UserArgument[0] == 0) |
{ |
return (ACPI_TYPE_NOT_FOUND); |
} |
for (i = 0; Arguments[i].Name; i++) |
{ |
if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) |
{ |
return (i); |
} |
} |
/* Argument not recognized */ |
return (ACPI_TYPE_NOT_FOUND); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSetOutputDestination |
* |
* PARAMETERS: OutputFlags - Current flags word |
* |
* RETURN: None |
* |
* DESCRIPTION: Set the current destination for debugger output. Also sets |
* the debug output level accordingly. |
* |
******************************************************************************/ |
void |
AcpiDbSetOutputDestination ( |
UINT32 OutputFlags) |
{ |
AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; |
if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile) |
{ |
AcpiDbgLevel = AcpiGbl_DbDebugLevel; |
} |
else |
{ |
AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDumpExternalObject |
* |
* PARAMETERS: ObjDesc - External ACPI object to dump |
* Level - Nesting level. |
* |
* RETURN: None |
* |
* DESCRIPTION: Dump the contents of an ACPI external object |
* |
******************************************************************************/ |
void |
AcpiDbDumpExternalObject ( |
ACPI_OBJECT *ObjDesc, |
UINT32 Level) |
{ |
UINT32 i; |
if (!ObjDesc) |
{ |
AcpiOsPrintf ("[Null Object]\n"); |
return; |
} |
for (i = 0; i < Level; i++) |
{ |
AcpiOsPrintf (" "); |
} |
switch (ObjDesc->Type) |
{ |
case ACPI_TYPE_ANY: |
AcpiOsPrintf ("[Null Object] (Type=0)\n"); |
break; |
case ACPI_TYPE_INTEGER: |
AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", |
ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); |
break; |
case ACPI_TYPE_STRING: |
AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length); |
for (i = 0; i < ObjDesc->String.Length; i++) |
{ |
AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); |
} |
AcpiOsPrintf ("\n"); |
break; |
case ACPI_TYPE_BUFFER: |
AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); |
if (ObjDesc->Buffer.Length) |
{ |
if (ObjDesc->Buffer.Length > 16) |
{ |
AcpiOsPrintf ("\n"); |
} |
AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), |
ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); |
} |
else |
{ |
AcpiOsPrintf ("\n"); |
} |
break; |
case ACPI_TYPE_PACKAGE: |
AcpiOsPrintf ("[Package] Contains %u Elements:\n", |
ObjDesc->Package.Count); |
for (i = 0; i < ObjDesc->Package.Count; i++) |
{ |
AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1); |
} |
break; |
case ACPI_TYPE_LOCAL_REFERENCE: |
AcpiOsPrintf ("[Object Reference] = "); |
AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); |
break; |
case ACPI_TYPE_PROCESSOR: |
AcpiOsPrintf ("[Processor]\n"); |
break; |
case ACPI_TYPE_POWER: |
AcpiOsPrintf ("[Power Resource]\n"); |
break; |
default: |
AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type); |
break; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbPrepNamestring |
* |
* PARAMETERS: Name - String to prepare |
* |
* RETURN: None |
* |
* DESCRIPTION: Translate all forward slashes and dots to backslashes. |
* |
******************************************************************************/ |
void |
AcpiDbPrepNamestring ( |
char *Name) |
{ |
if (!Name) |
{ |
return; |
} |
AcpiUtStrupr (Name); |
/* Convert a leading forward slash to a backslash */ |
if (*Name == '/') |
{ |
*Name = '\\'; |
} |
/* Ignore a leading backslash, this is the root prefix */ |
if (*Name == '\\') |
{ |
Name++; |
} |
/* Convert all slash path separators to dots */ |
while (*Name) |
{ |
if ((*Name == '/') || |
(*Name == '\\')) |
{ |
*Name = '.'; |
} |
Name++; |
} |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbLocalNsLookup |
* |
* PARAMETERS: Name - Name to lookup |
* |
* RETURN: Pointer to a namespace node, null on failure |
* |
* DESCRIPTION: Lookup a name in the ACPI namespace |
* |
* Note: Currently begins search from the root. Could be enhanced to use |
* the current prefix (scope) node as the search beginning point. |
* |
******************************************************************************/ |
ACPI_NAMESPACE_NODE * |
AcpiDbLocalNsLookup ( |
char *Name) |
{ |
char *InternalPath; |
ACPI_STATUS Status; |
ACPI_NAMESPACE_NODE *Node = NULL; |
AcpiDbPrepNamestring (Name); |
/* Build an internal namestring */ |
Status = AcpiNsInternalizeName (Name, &InternalPath); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Invalid namestring: %s\n", Name); |
return (NULL); |
} |
/* |
* Lookup the name. |
* (Uses root node as the search starting point) |
*/ |
Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, |
ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not locate name: %s, %s\n", |
Name, AcpiFormatException (Status)); |
} |
ACPI_FREE (InternalPath); |
return (Node); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbUInt32ToHexString |
* |
* PARAMETERS: Value - The value to be converted to string |
* Buffer - Buffer for result (not less than 11 bytes) |
* |
* RETURN: None |
* |
* DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image |
* |
* NOTE: It is the caller's responsibility to ensure that the length of buffer |
* is sufficient. |
* |
******************************************************************************/ |
void |
AcpiDbUInt32ToHexString ( |
UINT32 Value, |
char *Buffer) |
{ |
UINT8 i; |
if (Value == 0) |
{ |
ACPI_STRCPY (Buffer, "0"); |
return; |
} |
ACPI_STRCPY (Buffer, "0x"); |
Buffer[10] = '\0'; |
for (i = 9; i > 1; i--) |
{ |
Buffer[i] = Converter [Value & 0x0F]; |
Value = Value >> 4; |
} |
} |
#ifdef ACPI_OBSOLETE_FUNCTIONS |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSecondPassParse |
* |
* PARAMETERS: Root - Root of the parse tree |
* |
* RETURN: Status |
* |
* DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until |
* second pass to parse the control methods |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbSecondPassParse ( |
ACPI_PARSE_OBJECT *Root) |
{ |
ACPI_PARSE_OBJECT *Op = Root; |
ACPI_PARSE_OBJECT *Method; |
ACPI_PARSE_OBJECT *SearchOp; |
ACPI_PARSE_OBJECT *StartOp; |
ACPI_STATUS Status = AE_OK; |
UINT32 BaseAmlOffset; |
ACPI_WALK_STATE *WalkState; |
ACPI_FUNCTION_ENTRY (); |
AcpiOsPrintf ("Pass two parse ....\n"); |
while (Op) |
{ |
if (Op->Common.AmlOpcode == AML_METHOD_OP) |
{ |
Method = Op; |
/* Create a new walk state for the parse */ |
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); |
if (!WalkState) |
{ |
return (AE_NO_MEMORY); |
} |
/* Init the Walk State */ |
WalkState->ParserState.Aml = |
WalkState->ParserState.AmlStart = Method->Named.Data; |
WalkState->ParserState.AmlEnd = |
WalkState->ParserState.PkgEnd = Method->Named.Data + |
Method->Named.Length; |
WalkState->ParserState.StartScope = Op; |
WalkState->DescendingCallback = AcpiDsLoad1BeginOp; |
WalkState->AscendingCallback = AcpiDsLoad1EndOp; |
/* Perform the AML parse */ |
Status = AcpiPsParseAml (WalkState); |
BaseAmlOffset = (Method->Common.Value.Arg)->Common.AmlOffset + 1; |
StartOp = (Method->Common.Value.Arg)->Common.Next; |
SearchOp = StartOp; |
while (SearchOp) |
{ |
SearchOp->Common.AmlOffset += BaseAmlOffset; |
SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); |
} |
} |
if (Op->Common.AmlOpcode == AML_REGION_OP) |
{ |
/* TBD: [Investigate] this isn't quite the right thing to do! */ |
/* |
* |
* Method = (ACPI_DEFERRED_OP *) Op; |
* Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength); |
*/ |
} |
if (ACPI_FAILURE (Status)) |
{ |
break; |
} |
Op = AcpiPsGetDepthNext (Root, Op); |
} |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbDumpBuffer |
* |
* PARAMETERS: Address - Pointer to the buffer |
* |
* RETURN: None |
* |
* DESCRIPTION: Print a portion of a buffer |
* |
******************************************************************************/ |
void |
AcpiDbDumpBuffer ( |
UINT32 Address) |
{ |
AcpiOsPrintf ("\nLocation %X:\n", Address); |
AcpiDbgLevel |= ACPI_LV_TABLES; |
AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, |
ACPI_UINT32_MAX); |
} |
#endif |
#endif /* ACPI_DEBUGGER */ |
/drivers/devman/acpica/debugger/dbxface.c |
---|
0,0 → 1,602 |
/******************************************************************************* |
* |
* Module Name: dbxface - AML Debugger external interfaces |
* |
******************************************************************************/ |
/****************************************************************************** |
* |
* 1. Copyright Notice |
* |
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
* All rights reserved. |
* |
* 2. License |
* |
* 2.1. This is your license from Intel Corp. under its intellectual property |
* rights. You may have additional license terms from the party that provided |
* you this software, covering your right to use that party's intellectual |
* property rights. |
* |
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
* copy of the source code appearing in this file ("Covered Code") an |
* irrevocable, perpetual, worldwide license under Intel's copyrights in the |
* base code distributed originally by Intel ("Original Intel Code") to copy, |
* make derivatives, distribute, use and display any portion of the Covered |
* Code in any form, with the right to sublicense such rights; and |
* |
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
* license (with the right to sublicense), under only those claims of Intel |
* patents that are infringed by the Original Intel Code, to make, use, sell, |
* offer to sell, and import the Covered Code and derivative works thereof |
* solely to the minimum extent necessary to exercise the above copyright |
* license, and in no event shall the patent license extend to any additions |
* to or modifications of the Original Intel Code. No other license or right |
* is granted directly or by implication, estoppel or otherwise; |
* |
* The above copyright and patent license is granted only if the following |
* conditions are met: |
* |
* 3. Conditions |
* |
* 3.1. Redistribution of Source with Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification with rights to further distribute source must include |
* the above Copyright Notice, the above License, this list of Conditions, |
* and the following Disclaimer and Export Compliance provision. In addition, |
* Licensee must cause all Covered Code to which Licensee contributes to |
* contain a file documenting the changes Licensee made to create that Covered |
* Code and the date of any change. Licensee must include in that file the |
* documentation of any changes made by any predecessor Licensee. Licensee |
* must include a prominent statement that the modification is derived, |
* directly or indirectly, from Original Intel Code. |
* |
* 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
* Redistribution of source code of any substantial portion of the Covered |
* Code or modification without rights to further distribute source must |
* include the following Disclaimer and Export Compliance provision in the |
* documentation and/or other materials provided with distribution. In |
* addition, Licensee may not authorize further sublicense of source of any |
* portion of the Covered Code, and must include terms to the effect that the |
* license from Licensee to its licensee is limited to the intellectual |
* property embodied in the software Licensee provides to its licensee, and |
* not to intellectual property embodied in modifications its licensee may |
* make. |
* |
* 3.3. Redistribution of Executable. Redistribution in executable form of any |
* substantial portion of the Covered Code or modification must reproduce the |
* above Copyright Notice, and the following Disclaimer and Export Compliance |
* provision in the documentation and/or other materials provided with the |
* distribution. |
* |
* 3.4. Intel retains all right, title, and interest in and to the Original |
* Intel Code. |
* |
* 3.5. Neither the name Intel nor any other trademark owned or controlled by |
* Intel shall be used in advertising or otherwise to promote the sale, use or |
* other dealings in products derived from or relating to the Covered Code |
* without prior written authorization from Intel. |
* |
* 4. Disclaimer and Export Compliance |
* |
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
* PARTICULAR PURPOSE. |
* |
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
* LIMITED REMEDY. |
* |
* 4.3. Licensee shall not export, either directly or indirectly, any of this |
* software or system incorporating such software without first obtaining any |
* required license or other approval from the U. S. Department of Commerce or |
* any other agency or department of the United States Government. In the |
* event Licensee exports any such software from the United States or |
* re-exports any such software from a foreign destination, Licensee shall |
* ensure that the distribution and export/re-export of the software is in |
* compliance with all laws, regulations, orders, or other restrictions of the |
* U.S. Export Administration Regulations. Licensee agrees that neither it nor |
* any of its subsidiaries will export/re-export any technical data, process, |
* software, or service, directly or indirectly, to any country for which the |
* United States government or any agency thereof requires an export license, |
* other governmental approval, or letter of assurance, without first obtaining |
* such license, approval or letter. |
* |
*****************************************************************************/ |
#include "acpi.h" |
#include "accommon.h" |
#include "amlcode.h" |
#include "acdebug.h" |
#include "acdisasm.h" |
#ifdef ACPI_DEBUGGER |
#define _COMPONENT ACPI_CA_DEBUGGER |
ACPI_MODULE_NAME ("dbxface") |
/* Local prototypes */ |
static ACPI_STATUS |
AcpiDbStartCommand ( |
ACPI_WALK_STATE *WalkState, |
ACPI_PARSE_OBJECT *Op); |
#ifdef ACPI_OBSOLETE_FUNCTIONS |
void |
AcpiDbMethodEnd ( |
ACPI_WALK_STATE *WalkState); |
#endif |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbStartCommand |
* |
* PARAMETERS: WalkState - Current walk |
* Op - Current executing Op, from AML interpreter |
* |
* RETURN: Status |
* |
* DESCRIPTION: Enter debugger command loop |
* |
******************************************************************************/ |
static ACPI_STATUS |
AcpiDbStartCommand ( |
ACPI_WALK_STATE *WalkState, |
ACPI_PARSE_OBJECT *Op) |
{ |
ACPI_STATUS Status; |
/* TBD: [Investigate] are there namespace locking issues here? */ |
/* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */ |
/* Go into the command loop and await next user command */ |
AcpiGbl_MethodExecuting = TRUE; |
Status = AE_CTRL_TRUE; |
while (Status == AE_CTRL_TRUE) |
{ |
if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) |
{ |
/* Handshake with the front-end that gets user command lines */ |
Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); |
if (ACPI_FAILURE (Status)) |
{ |
return (Status); |
} |
} |
else |
{ |
/* Single threaded, we must get a command line ourselves */ |
/* Force output to console until a command is entered */ |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
/* Different prompt if method is executing */ |
if (!AcpiGbl_MethodExecuting) |
{ |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); |
} |
else |
{ |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); |
} |
/* Get the user input line */ |
(void) AcpiOsGetLine (AcpiGbl_DbLineBuf); |
} |
Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op); |
} |
/* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */ |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbSingleStep |
* |
* PARAMETERS: WalkState - Current walk |
* Op - Current executing op (from aml interpreter) |
* OpcodeClass - Class of the current AML Opcode |
* |
* RETURN: Status |
* |
* DESCRIPTION: Called just before execution of an AML opcode. |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbSingleStep ( |
ACPI_WALK_STATE *WalkState, |
ACPI_PARSE_OBJECT *Op, |
UINT32 OpcodeClass) |
{ |
ACPI_PARSE_OBJECT *Next; |
ACPI_STATUS Status = AE_OK; |
UINT32 OriginalDebugLevel; |
ACPI_PARSE_OBJECT *DisplayOp; |
ACPI_PARSE_OBJECT *ParentOp; |
ACPI_FUNCTION_ENTRY (); |
/* Check the abort flag */ |
if (AcpiGbl_AbortMethod) |
{ |
AcpiGbl_AbortMethod = FALSE; |
return (AE_ABORT_METHOD); |
} |
/* Check for single-step breakpoint */ |
if (WalkState->MethodBreakpoint && |
(WalkState->MethodBreakpoint <= Op->Common.AmlOffset)) |
{ |
/* Check if the breakpoint has been reached or passed */ |
/* Hit the breakpoint, resume single step, reset breakpoint */ |
AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset); |
AcpiGbl_CmSingleStep = TRUE; |
AcpiGbl_StepToNextCall = FALSE; |
WalkState->MethodBreakpoint = 0; |
} |
/* Check for user breakpoint (Must be on exact Aml offset) */ |
else if (WalkState->UserBreakpoint && |
(WalkState->UserBreakpoint == Op->Common.AmlOffset)) |
{ |
AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", |
Op->Common.AmlOffset); |
AcpiGbl_CmSingleStep = TRUE; |
AcpiGbl_StepToNextCall = FALSE; |
WalkState->MethodBreakpoint = 0; |
} |
/* |
* Check if this is an opcode that we are interested in -- |
* namely, opcodes that have arguments |
*/ |
if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) |
{ |
return (AE_OK); |
} |
switch (OpcodeClass) |
{ |
case AML_CLASS_UNKNOWN: |
case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */ |
return (AE_OK); |
default: |
/* All other opcodes -- continue */ |
break; |
} |
/* |
* Under certain debug conditions, display this opcode and its operands |
*/ |
if ((AcpiGbl_DbOutputToFile) || |
(AcpiGbl_CmSingleStep) || |
(AcpiDbgLevel & ACPI_LV_PARSE)) |
{ |
if ((AcpiGbl_DbOutputToFile) || |
(AcpiDbgLevel & ACPI_LV_PARSE)) |
{ |
AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n"); |
} |
/* |
* Display this op (and only this op - zero out the NEXT field |
* temporarily, and disable parser trace output for the duration of |
* the display because we don't want the extraneous debug output) |
*/ |
OriginalDebugLevel = AcpiDbgLevel; |
AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS); |
Next = Op->Common.Next; |
Op->Common.Next = NULL; |
DisplayOp = Op; |
ParentOp = Op->Common.Parent; |
if (ParentOp) |
{ |
if ((WalkState->ControlState) && |
(WalkState->ControlState->Common.State == |
ACPI_CONTROL_PREDICATE_EXECUTING)) |
{ |
/* |
* We are executing the predicate of an IF or WHILE statement |
* Search upwards for the containing IF or WHILE so that the |
* entire predicate can be displayed. |
*/ |
while (ParentOp) |
{ |
if ((ParentOp->Common.AmlOpcode == AML_IF_OP) || |
(ParentOp->Common.AmlOpcode == AML_WHILE_OP)) |
{ |
DisplayOp = ParentOp; |
break; |
} |
ParentOp = ParentOp->Common.Parent; |
} |
} |
else |
{ |
while (ParentOp) |
{ |
if ((ParentOp->Common.AmlOpcode == AML_IF_OP) || |
(ParentOp->Common.AmlOpcode == AML_ELSE_OP) || |
(ParentOp->Common.AmlOpcode == AML_SCOPE_OP) || |
(ParentOp->Common.AmlOpcode == AML_METHOD_OP) || |
(ParentOp->Common.AmlOpcode == AML_WHILE_OP)) |
{ |
break; |
} |
DisplayOp = ParentOp; |
ParentOp = ParentOp->Common.Parent; |
} |
} |
} |
/* Now we can display it */ |
AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX); |
if ((Op->Common.AmlOpcode == AML_IF_OP) || |
(Op->Common.AmlOpcode == AML_WHILE_OP)) |
{ |
if (WalkState->ControlState->Common.Value) |
{ |
AcpiOsPrintf ("Predicate = [True], IF block was executed\n"); |
} |
else |
{ |
AcpiOsPrintf ("Predicate = [False], Skipping IF block\n"); |
} |
} |
else if (Op->Common.AmlOpcode == AML_ELSE_OP) |
{ |
AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n"); |
} |
/* Restore everything */ |
Op->Common.Next = Next; |
AcpiOsPrintf ("\n"); |
if ((AcpiGbl_DbOutputToFile) || |
(AcpiDbgLevel & ACPI_LV_PARSE)) |
{ |
AcpiOsPrintf ("\n"); |
} |
AcpiDbgLevel = OriginalDebugLevel; |
} |
/* If we are not single stepping, just continue executing the method */ |
if (!AcpiGbl_CmSingleStep) |
{ |
return (AE_OK); |
} |
/* |
* If we are executing a step-to-call command, |
* Check if this is a method call. |
*/ |
if (AcpiGbl_StepToNextCall) |
{ |
if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP) |
{ |
/* Not a method call, just keep executing */ |
return (AE_OK); |
} |
/* Found a method call, stop executing */ |
AcpiGbl_StepToNextCall = FALSE; |
} |
/* |
* If the next opcode is a method call, we will "step over" it |
* by default. |
*/ |
if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP) |
{ |
/* Force no more single stepping while executing called method */ |
AcpiGbl_CmSingleStep = FALSE; |
/* |
* Set the breakpoint on/before the call, it will stop execution |
* as soon as we return |
*/ |
WalkState->MethodBreakpoint = 1; /* Must be non-zero! */ |
} |
Status = AcpiDbStartCommand (WalkState, Op); |
/* User commands complete, continue execution of the interrupted method */ |
return (Status); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbInitialize |
* |
* PARAMETERS: None |
* |
* RETURN: Status |
* |
* DESCRIPTION: Init and start debugger |
* |
******************************************************************************/ |
ACPI_STATUS |
AcpiDbInitialize ( |
void) |
{ |
ACPI_STATUS Status; |
/* Init globals */ |
AcpiGbl_DbBuffer = NULL; |
AcpiGbl_DbFilename = NULL; |
AcpiGbl_DbOutputToFile = FALSE; |
AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2; |
AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; |
AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; |
AcpiGbl_DbOpt_tables = FALSE; |
AcpiGbl_DbOpt_disasm = FALSE; |
AcpiGbl_DbOpt_stats = FALSE; |
AcpiGbl_DbOpt_verbose = TRUE; |
AcpiGbl_DbOpt_ini_methods = TRUE; |
AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); |
if (!AcpiGbl_DbBuffer) |
{ |
return (AE_NO_MEMORY); |
} |
ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); |
/* Initial scope is the root */ |
AcpiGbl_DbScopeBuf [0] = '\\'; |
AcpiGbl_DbScopeBuf [1] = 0; |
AcpiGbl_DbScopeNode = AcpiGbl_RootNode; |
/* |
* If configured for multi-thread support, the debug executor runs in |
* a separate thread so that the front end can be in another address |
* space, environment, or even another machine. |
*/ |
if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) |
{ |
/* These were created with one unit, grab it */ |
Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not get debugger mutex\n"); |
return (Status); |
} |
Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not get debugger mutex\n"); |
return (Status); |
} |
/* Create the debug execution thread to execute commands */ |
Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL); |
if (ACPI_FAILURE (Status)) |
{ |
AcpiOsPrintf ("Could not start debugger thread\n"); |
return (Status); |
} |
} |
if (!AcpiGbl_DbOpt_verbose) |
{ |
AcpiGbl_DbOpt_disasm = TRUE; |
AcpiGbl_DbOpt_stats = FALSE; |
} |
return (AE_OK); |
} |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbTerminate |
* |
* PARAMETERS: None |
* |
* RETURN: None |
* |
* DESCRIPTION: Stop debugger |
* |
******************************************************************************/ |
void |
AcpiDbTerminate ( |
void) |
{ |
if (AcpiGbl_DbBuffer) |
{ |
AcpiOsFree (AcpiGbl_DbBuffer); |
} |
} |
#ifdef ACPI_OBSOLETE_FUNCTIONS |
/******************************************************************************* |
* |
* FUNCTION: AcpiDbMethodEnd |
* |
* PARAMETERS: WalkState - Current walk |
* |
* RETURN: Status |
* |
* DESCRIPTION: Called at method termination |
* |
******************************************************************************/ |
void |
AcpiDbMethodEnd ( |
ACPI_WALK_STATE *WalkState) |
{ |
if (!AcpiGbl_CmSingleStep) |
{ |
return; |
} |
AcpiOsPrintf ("<Method Terminating>\n"); |
AcpiDbStartCommand (WalkState, NULL); |
} |
#endif |
#endif /* ACPI_DEBUGGER */ |