diff options
author | msmith <msmith@FreeBSD.org> | 2000-10-28 05:01:06 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2000-10-28 05:01:06 +0000 |
commit | 25edde61bd32b25aa0283f4b7559433476ba0b87 (patch) | |
tree | 77ac9efbc80cb4cf8b914eca22875260a54fbd16 /sys/contrib/dev/acpica/Subsystem/Debugger | |
parent | 9c3bb2995c1791e8dc3d7bde3d579458ab51305b (diff) | |
parent | 748be155016b7e29202235815e27acc5ff5e9e87 (diff) | |
download | FreeBSD-src-25edde61bd32b25aa0283f4b7559433476ba0b87.zip FreeBSD-src-25edde61bd32b25aa0283f4b7559433476ba0b87.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r67754,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Debugger')
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c | 997 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c | 822 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c | 904 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c | 482 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c | 472 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c | 301 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c | 981 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c | 548 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c | 465 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c | 432 |
10 files changed, 6404 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c new file mode 100644 index 0000000..bd357df --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c @@ -0,0 +1,997 @@ +/******************************************************************************* + * + * Module Name: dbcmds - debug commands and output routines + * $Revision: 41 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbcmds") + + +/* + * Arguments for the Objects command + * These object types map directly to the ACPI_TYPES + */ + +ARGUMENT_INFO AcpiDbObjectTypes [] = +{ + {"ANY"}, + {"NUMBERS"}, + {"STRINGS"}, + {"BUFFERS"}, + {"PACKAGES"}, + {"FIELDS"}, + {"DEVICES"}, + {"EVENTS"}, + {"METHODS"}, + {"MUTEXES"}, + {"REGIONS"}, + {"POWERRESOURCES"}, + {"PROCESSORS"}, + {"THERMALZONES"}, + {"BUFFERFIELDS"}, + {"DDBHANDLES"}, + {NULL} /* Must be null terminated */ +}; + + +/******************************************************************************* + * + * 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. + * + ******************************************************************************/ + +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", &Node->Name); + } + + /* Check for match against the object attached to the node */ + + if (Node->Object == ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name); + } + + /* Check first child for a match */ + /* TBD: [Investigate] probably now obsolete with new datastructure */ + + if (Node->Child == (void *) ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name); + } + + 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 ( + NATIVE_CHAR *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Convert string to object pointer */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); + + /* Search all nodes in namespace */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForReferences, (void *) ObjDesc, NULL); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *TableArg) +{ + UINT32 i; + + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (AcpiGbl_AcpiTables[i].Pointer) + { + AcpiOsPrintf ("%s at 0x%p length 0x%X\n", AcpiGbl_AcpiTableData[i].Name, + AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length); + } + } +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *TableArg, + NATIVE_CHAR *InstanceArg) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Search all tables for the target type */ + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[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", AcpiCmFormatException (Status), TableArg); + } + + return; + } + } + + AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_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 = STRTOUL (Location, NULL, 16); + if (Address <= Op->AmlOffset) + { + AcpiOsPrintf ("Breakpoint 0x%X is beyond current address 0x%X\n", Address, Op->AmlOffset); + } + + /* Save breakpoint in current walk */ + + WalkState->MethodBreakpoint = Address; + AcpiOsPrintf ("Breakpoint set at AML offset 0x%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 ( + NATIVE_CHAR *Statements, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 NumStatements = 8; + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + if (Statements) + { + NumStatements = STRTOUL (Statements, NULL, 0); + } + + + AcpiDbDisplayOp (NULL, Op, NumStatements); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *StartArg, + NATIVE_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) + { + /* Check if numeric argument, must be a Node */ + + if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) + { + SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16); + if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); + return; + } + + if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); + return; + } + } + + /* Alpha argument */ + + else + { + /* The parameter is a name string that must be resolved to a Named obj*/ + + SubtreeEntry = AcpiDbLocalNsLookup (StartArg); + if (!SubtreeEntry) + { + SubtreeEntry = AcpiGbl_RootNode; + } + } + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); + AcpiDbSetOutputDestination (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 ( + NATIVE_CHAR *OwnerArg, + NATIVE_CHAR *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + UINT16 OwnerId; + + + OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0); + + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace by owner 0x%X:\n", OwnerId); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, OwnerId, SubtreeEntry); + AcpiDbSetOutputDestination (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 ( + NATIVE_CHAR *Name, + UINT32 Value) +{ + ACPI_NAMESPACE_NODE *Node; + + + /* Translate name to an Named object */ + + Node = AcpiDbLocalNsLookup (Name); + if (!Node) + { + return; + } + + /* Decode Named object type */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + /* Send the notify */ + + AcpiEvNotifyDispatch (Node, Value); + 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 ( + NATIVE_CHAR *TypeArg, + NATIVE_CHAR *IndexArg, + NATIVE_CHAR *ValueArg) +{ + NATIVE_CHAR Type; + UINT32 Index; + UINT32 Value; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Validate TypeArg */ + + STRUPR (TypeArg); + Type = TypeArg[0]; + if ((Type != 'L') && + (Type != 'A')) + { + AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); + return; + } + + /* Get the index and value */ + + Index = STRTOUL (IndexArg, NULL, 16); + Value = STRTOUL (ValueArg, NULL, 16); + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + + /* Create and initialize the new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + AcpiOsPrintf ("Could not create an internal object\n"); + return; + } + + ObjDesc->Number.Value = Value; + + + /* Store the new object into the target */ + + switch (Type) + { + case 'A': + + /* Set a method argument */ + + if (Index > MTH_NUM_ARGS) + { + AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Index, ObjDesc, WalkState); + ObjDesc = WalkState->Arguments[Index].Object; + + AcpiOsPrintf ("Arg%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + case 'L': + + /* Set a method local */ + + if (Index > MTH_NUM_LOCALS) + { + AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, Index, ObjDesc, WalkState); + ObjDesc = WalkState->LocalVariables[Index].Object; + + AcpiOsPrintf ("Local%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForSpecificObjects + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT32 BufSize; + NATIVE_CHAR buffer[64]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + /* Get and display the full pathname to this object */ + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, buffer); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + AcpiOsPrintf ("%32s", buffer); + + + /* Display short information about the object */ + + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf (" #Args %d Concurrency %d", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); + break; + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf (" Value 0x%X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); + break; + + case ACPI_TYPE_REGION: + AcpiOsPrintf (" SpaceId %d Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length); + break; + + case ACPI_TYPE_PACKAGE: + AcpiOsPrintf (" #Elements %d", ObjDesc->Package.Count); + break; + + case ACPI_TYPE_BUFFER: + AcpiOsPrintf (" Length %d", ObjDesc->Buffer.Length); + break; + } + } + + AcpiOsPrintf ("\n"); + 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 ( + NATIVE_CHAR *ObjTypeArg, + NATIVE_CHAR *DisplayCountArg) +{ + UINT32 DisplayCount; + OBJECT_TYPE_INTERNAL Type; + + + /* Get the object type */ + + STRUPR (ObjTypeArg); + Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); + if (Type == ACPI_TYPE_NOT_FOUND) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + + /* Get the display depth */ + + if (DisplayCountArg) + { + DisplayCount = STRTOUL (DisplayCountArg, NULL, 0); + } + + else + { + DisplayCount = ACPI_UINT32_MAX; + } + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiCmGetTypeName (Type)); + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); + + AcpiDbSetOutputDestination (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. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context; + UINT32 i; + UINT32 BufSize; + NATIVE_CHAR Buffer[96]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + + /* Check for a name match */ + + for (i = 0; i < 4; i++) + { + /* Wildcard support */ + + if ((RequestedName[i] != '?') && + (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i])) + { + /* No match, just exit */ + + return (AE_OK); + } + } + + + /* Get the full pathname to this object */ + + BufSize = sizeof (Buffer); + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + } + + else + { + AcpiOsPrintf ("%32s (0x%p) - %s\n", Buffer, ObjHandle, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); + } + + 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 ( + NATIVE_CHAR *NameArg) +{ + + if (STRLEN (NameArg) > 4) + { + AcpiOsPrintf ("Name must be no longer than 4 characters\n"); + return (AE_OK); + } + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkAndMatchName, NameArg, NULL); + + AcpiDbSetOutputDestination (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 ( + NATIVE_CHAR *Name) +{ + + if (!Name || Name[0] == 0) + { + AcpiOsPrintf ("Current scope: %s\n", ScopeBuf); + return; + } + + AcpiDbPrepNamestring (Name); + + /* TBD: [Future] Validate scope here */ + + if (Name[0] == '\\') + { + STRCPY (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + else + { + STRCAT (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + AcpiOsPrintf ("New scope: %s\n", ScopeBuf); +} + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c new file mode 100644 index 0000000..4a7b32d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c @@ -0,0 +1,822 @@ +/******************************************************************************* + * + * Module Name: dbdisasm - parser op tree display routines + * $Revision: 33 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisasm") + + +#define MAX_SHOW_ENTRY 128 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define DB_NO_OP_INFO " [%2.2d] " +#define DB_FULL_OP_INFO "%5.5X #%4.4X [%2.2d] " + + +NATIVE_CHAR *INDENT_STRING = "...."; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBlockType + * + * PARAMETERS: Op - Object to be examined + * + * RETURN: Status + * + * DESCRIPTION: Type of block for this op (parens or braces) + * + ******************************************************************************/ + +UINT32 +AcpiDbBlockType ( + ACPI_PARSE_OBJECT *Op) +{ + + switch (Op->Opcode) + { + case AML_METHOD_OP: + return (BLOCK_BRACE); + break; + + default: + break; + } + + return (BLOCK_PAREN); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDisplayObjectPathname + * + * PARAMETERS: Op - Object whose pathname is to be obtained + * + * RETURN: Status + * + * DESCRIPTION: Diplay the pathname associated with a named object. Two + * versions. One searches the parse tree (for parser-only + * applications suchas AcpiDump), and the other searches the + * ACPI namespace (the parse tree is probably deleted) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *TargetOp; + + + /* Search parent tree up to the root if necessary */ + + TargetOp = AcpiPsFind (Op, Op->Value.Name, 0, 0); + if (!TargetOp) + { + /* + * Didn't find the name in the parse tree. This may be + * a problem, or it may simply be one of the predefined names + * (such as _OS_). Rather than worry about looking up all + * the predefined names, just display the name as given + */ + + AcpiOsPrintf (" **** Path not found in parse tree"); + } + + else + { + /* The target was found, print the name and complete path */ + + AcpiOsPrintf (" (Path "); + AcpiDbDisplayPath (TargetOp); + AcpiOsPrintf (")"); + } + + return (AE_OK); +} + +#else + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + NATIVE_CHAR Buffer[MAX_SHOW_ENTRY]; + UINT32 BufferSize = MAX_SHOW_ENTRY; + + + AcpiOsPrintf (" (Path "); + + /* Just get the Node out of the Op object */ + + Node = Op->Node; + if (!Node) + { + /* + * No Named obj, so we can't get the pathname since the object + * is not in the namespace. This can happen during single + * stepping where a dynamic named object is *about* to be created. + */ + return (AE_OK); + } + + /* Convert NamedDesc/handle to a full pathname */ + + Status = AcpiNsHandleToPathname (Node, &BufferSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("****Could not get pathname****)"); + return (Status); + } + + AcpiOsPrintf ("%s)", Buffer); + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOp + * + * PARAMETERS: Origin - Starting object + * NumOpcodes - Max number of opcodes to be displayed + * + * RETURN: None + * + * DESCRIPTION: Display parser object and its children + * + ******************************************************************************/ + +void +AcpiDbDisplayOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes) +{ + ACPI_PARSE_OBJECT *Op = Origin; + ACPI_PARSE_OBJECT *arg; + ACPI_PARSE_OBJECT *depth; + UINT32 DepthCount = 0; + UINT32 LastDepth = 0; + UINT32 i; + UINT32 j; + + + if (Op) + { + while (Op) + { + /* indentation */ + + DepthCount = 0; + if (!opt_verbose) + { + DepthCount++; + } + + /* Determine the nesting depth of this argument */ + + for (depth = Op->Parent; depth; depth = depth->Parent) + { + arg = AcpiPsGetArg (depth, 0); + while (arg && arg != Origin) + { + arg = arg->Next; + } + + if (arg) + { + break; + } + + DepthCount++; + } + + + /* Open a new block if we are nested further than last time */ + + if (DepthCount > LastDepth) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth)); + for (i = 0; i < LastDepth; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf ("(\n"); + else + AcpiOsPrintf ("{\n"); + } + + /* Close a block if we are nested less than last time */ + + else if (DepthCount < LastDepth) + { + for (j = 0; j < (LastDepth - DepthCount); j++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - j)); + for (i = 0; i < (LastDepth - j - 1); i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf (")\n"); + else + AcpiOsPrintf ("}\n"); + } + } + + /* In verbose mode, print the AML offset, opcode and depth count */ + + VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) Op->AmlOffset, Op->Opcode, DepthCount)); + + + /* Indent the output according to the depth count */ + + for (i = 0; i < DepthCount; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + + /* Now print the opcode */ + + AcpiDbDisplayOpcode (WalkState, Op); + + /* Resolve a name reference */ + + if ((Op->Opcode == AML_NAMEPATH_OP && Op->Value.Name) && + (Op->Parent) && + (opt_verbose)) + { + AcpiPsDisplayObjectPathname (Op); + } + + AcpiOsPrintf ("\n"); + + /* Get the next node in the tree */ + + Op = AcpiPsGetDepthNext (Origin, Op); + LastDepth = DepthCount; + + NumOpcodes--; + if (!NumOpcodes) + { + Op = NULL; + } + } + + /* Close the last block(s) */ + + DepthCount = LastDepth -1; + for (i = 0; i < LastDepth; i++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - i)); + for (j = 0; j < DepthCount; j++) + { + AcpiOsPrintf (INDENT_STRING); + } + AcpiOsPrintf ("}\n"); + DepthCount--; + } + + } + + else + { + AcpiDbDisplayOpcode (WalkState, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayNamestring + * + * PARAMETERS: Name - ACPI Name string to store + * + * RETURN: None + * + * DESCRIPTION: Display namestring. Handles prefix characters + * + ******************************************************************************/ + +void +AcpiDbDisplayNamestring ( + NATIVE_CHAR *Name) +{ + UINT32 SegCount; + BOOLEAN DoDot = FALSE; + + + if (!Name) + { + AcpiOsPrintf ("<NULL NAME PTR>"); + return; + } + + if (AcpiPsIsPrefixChar (GET8 (Name))) + { + /* append prefix character */ + + AcpiOsPrintf ("%1c", GET8 (Name)); + Name++; + } + + switch (GET8 (Name)) + { + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Name++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = (UINT32) GET8 (Name + 1); + Name += 2; + break; + + default: + SegCount = 1; + break; + } + + while (SegCount--) + { + /* append Name segment */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + AcpiOsPrintf ("%4.4s", Name); + DoDot = TRUE; + + Name += 4; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayPath + * + * PARAMETERS: Op - Named Op whose path is to be constructed + * + * RETURN: None + * + * DESCRIPTION: Walk backwards from current scope and display the name + * of each previous level of scope up to the root scope + * (like "pwd" does with file systems) + * + ******************************************************************************/ + +void +AcpiDbDisplayPath ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Search; + UINT32 Name; + BOOLEAN DoDot = FALSE; + ACPI_PARSE_OBJECT *NamePath; + + + /* We are only interested in named objects */ + + if (!AcpiPsIsNodeOp (Op->Opcode)) + { + return; + } + + + if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + /* Field creation - check for a fully qualified namepath */ + + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String) && + (NamePath->Value.String[0] == '\\')) + { + AcpiDbDisplayNamestring (NamePath->Value.String); + return; + } + } + + Prev = NULL; /* Start with Root Node */ + + while (Prev != Op) + { + /* Search upwards in the tree to find scope with "prev" as its parent */ + + Search = Op; + for (; ;) + { + if (Search->Parent == Prev) + { + break; + } + + /* Go up one level */ + + Search = Search->Parent; + } + + if (Prev && !AcpiPsIsFieldOp (Search->Opcode)) + { + /* below root scope, append scope name */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + if (AcpiPsIsCreateFieldOp (Search->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String)) + { + AcpiOsPrintf ("%4.4s", NamePath->Value.String); + } + } + + else + { + Name = AcpiPsGetName (Search); + AcpiOsPrintf ("%4.4s", &Name); + } + + DoDot = TRUE; + } + + Prev = Search; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOpcode + * + * PARAMETERS: Op - Op that is to be printed + * + * RETURN: Status + * + * DESCRIPTION: Store printed op in a Buffer and return its length + * (or -1 if out of space) + * + * NOTE: Terse mode prints out ASL-like code. Verbose mode adds more info. + * + ******************************************************************************/ + +void +AcpiDbDisplayOpcode ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + UINT32 i; + ACPI_OPCODE_INFO *Opc = NULL; + UINT32 Name; + + + if (!Op) + { + AcpiOsPrintf ("<NULL OP PTR>"); + } + + + /* op and arguments */ + + switch (Op->Opcode) + { + + case AML_BYTE_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT8) 0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + break; + + + case AML_WORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT16) 0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + else + { + AcpiOsPrintf ("0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + break; + + + case AML_DWORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT32) 0x%8.8X", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%8.8X", Op->Value.Integer); + } + + break; + + + case AML_STRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + } + + break; + + + case AML_STATICSTRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("\"<NULL STATIC STRING PTR>\""); + } + + break; + + + case AML_NAMEPATH_OP: + + AcpiDbDisplayNamestring (Op->Value.Name); + break; + + + case AML_NAMEDFIELD_OP: + + AcpiOsPrintf ("NamedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_RESERVEDFIELD_OP: + + AcpiOsPrintf ("ReservedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_ACCESSFIELD_OP: + + AcpiOsPrintf ("AccessField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_BYTELIST_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("ByteList (Length 0x%8.8X) ", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer); + + ByteCount = Op->Value.Integer; + ByteData = ((ACPI_PARSE2_OBJECT *) Op)->Data; + + for (i = 0; i < ByteCount; i++) + { + AcpiOsPrintf (", 0x%2.2X", ByteData[i]); + } + } + + break; + + + default: + + /* Just get the opcode name and print it */ + + Opc = AcpiPsGetOpcodeInfo (Op->Opcode); + DEBUG_ONLY_MEMBERS ((AcpiOsPrintf ("%s", Opc->Name))); + + +#ifndef PARSER_ONLY + if ((Op->Opcode == AML_RETURN_VALUE_OP) && + (WalkState->NumResults)) + { + AcpiDbDecodeInternalObject (WalkState->Results [WalkState->NumResults-1]); + } +#endif + + break; + } + + + if (!Opc) + { + /* If there is another element in the list, add a comma */ + + if (Op->Next) + { + AcpiOsPrintf (","); + } + } + + + /* + * If this is a named opcode, print the associated name value + */ + + if (Op && AcpiPsIsNamedOp (Op->Opcode)) + { + Name = AcpiPsGetName (Op); + AcpiOsPrintf (" %4.4s", &Name); + + if (opt_verbose) + { + AcpiOsPrintf (" (Path \\"); + AcpiDbDisplayPath (Op); + AcpiOsPrintf (")"); + } + } +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c new file mode 100644 index 0000000..1128e57 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c @@ -0,0 +1,904 @@ +/******************************************************************************* + * + * Module Name: dbdisply - debug display commands + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisply") + + +/****************************************************************************** + * + * FUNCTION: AcpiDbGetPointer + * + * PARAMETERS: Target - Pointer to string to be converted + * + * RETURN: Converted pointer + * + * DESCRIPTION: Convert an ascii pointer value to a real value + * + *****************************************************************************/ + +void * +AcpiDbGetPointer ( + void *Target) +{ + void *ObjPtr; + + +#ifdef _IA16 +#include <stdio.h> + + /* Have to handle 16-bit pointers of the form segment:offset */ + + if (!sscanf (Target, "%p", &ObjPtr)) + { + AcpiOsPrintf ("Invalid pointer: %s\n", Target); + return (NULL); + } + +#else + + /* Simple flat pointer */ + + ObjPtr = (void *) STRTOUL (Target, NULL, 16); + +#endif + + return (ObjPtr); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpParserDescriptor + * + * PARAMETERS: Op - A parser Op descriptor + * + * RETURN: None + * + * DESCRIPTION: Display a formatted parser object + * + ******************************************************************************/ + +void +AcpiDbDumpParserDescriptor ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_OPCODE_INFO *Info; + + + Info = AcpiPsGetOpcodeInfo (Op->Opcode); + + AcpiOsPrintf ("Parser Op Descriptor:\n"); + AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Opcode); + + DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name)); + + AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Value); + AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Parent); + AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->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 ( + NATIVE_CHAR *Target, + NATIVE_CHAR *OutputType) +{ + void *ObjPtr; + ACPI_NAMESPACE_NODE *Node; + UINT32 Display = DB_BYTE_DISPLAY; + NATIVE_CHAR Buffer[80]; + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + UINT32 Size; + + + if (!Target) + { + return; + } + + /* Decode the output type */ + + if (OutputType) + { + STRUPR (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 */ + + if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_NAMED)) + { + /* This is a Node */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); + return; + } + + Node = ObjPtr; + goto DumpNte; + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_INTERNAL)) + { + /* This is an ACPI OBJECT */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); + return; + } + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (ObjPtr, 1); + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_PARSER)) + { + /* This is an Parser Op object */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); + return; + } + + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); + AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); + } + + else + { + Size = 16; + if (AcpiOsReadable (ObjPtr, 64)) + { + Size = 64; + } + + /* Just dump some memory */ + + AcpiCmDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); + } + + return; + } + + + /* The parameter is a name string that must be resolved to a Named obj */ + + Node = AcpiDbLocalNsLookup (Target); + if (!Node) + { + return; + } + + +DumpNte: + /* Now dump the Named obj */ + + Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + return; + } + + AcpiOsPrintf ("Object Pathname: %s\n", RetBuf.Pointer); + if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Invalid Named object at address %p\n", Node); + return; + } + + AcpiCmDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); + AcpiAmlDumpNode (Node, 1); + + if (Node->Object) + { + AcpiOsPrintf ("\nAttached Object (0x%p):\n", Node->Object); + if (!AcpiOsReadable (Node->Object, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", Node->Object); + return; + } + + AcpiCmDumpBuffer (Node->Object, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (Node->Object, 1); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object. Numbers and Strings. + * + ******************************************************************************/ + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + if (!ObjDesc) + { + return; + } + + AcpiOsPrintf (" %9.9s ", AcpiCmGetTypeName (ObjDesc->Common.Type)); + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("0x%.8X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf ("\"%.16s\"...", ObjDesc->String.Pointer); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object + * + ******************************************************************************/ + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + UINT8 Type; + + + AcpiOsPrintf ("%p ", ObjDesc); + + if (!ObjDesc) + { + AcpiOsPrintf ("<NullObj>\n"); + return; + } + + + /* Decode the object type */ + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_PARSER)) + { + AcpiOsPrintf ("<Parser> "); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf ("<Node> Name %4.4s Type %s", &((ACPI_NAMESPACE_NODE *)ObjDesc)->Name, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjDesc)->Type)); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + AcpiOsPrintf ("<Obj> "); + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_MAX) + { + AcpiOsPrintf (" Type %x [Invalid Type]", Type); + return; + } + + /* Decode the ACPI object type */ + + switch (ObjDesc->Common.Type) + { + case INTERNAL_TYPE_REFERENCE: + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 0); + break; + + case AML_ONES_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", ACPI_UINT32_MAX); + break; + + case AML_ONE_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 1); + break; + + case AML_LOCAL_OP: + AcpiOsPrintf ("[Local%d]", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_ARG_OP: + AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_DEBUG_OP: + AcpiOsPrintf ("[Debug] "); + break; + + case AML_INDEX_OP: + AcpiOsPrintf ("[Index] "); + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); + break; + + default: + break; + + } + break; + + default: + AcpiOsPrintf (" "); + AcpiDbDecodeInternalObject (ObjDesc); + break; + } + } + + else + { + AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> "); + } + + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * 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; + ACPI_OPCODE_INFO *OpInfo; + UINT32 NumOps = 0; + UINT32 NumOperands = 0; + UINT32 NumOperators = 0; + UINT32 NumRemainingOps = 0; + UINT32 NumRemainingOperands = 0; + UINT32 NumRemainingOperators = 0; + UINT32 NumArgs; + UINT32 Concurrency; + BOOLEAN CountRemaining = FALSE; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", &Node->Name); + AcpiOsPrintf ("%d arguments, max concurrency = %d\n", NumArgs, Concurrency); + + + RootOp = StartOp; + while (RootOp->Parent) + { + RootOp = RootOp->Parent; + } + + Op = RootOp; + + while (Op) + { + if (Op == StartOp) + { + CountRemaining = TRUE; + } + + NumOps++; + if (CountRemaining) + { + NumRemainingOps++; + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Bad opcode or ASCII character */ + + continue; + } + + + /* Decode the opcode */ + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + if (CountRemaining) + { + NumRemainingOperands++; + } + + NumOperands++; + break; + + default: + if (CountRemaining) + { + NumRemainingOperators++; + } + + NumOperators++; + break; + } + + + Op = AcpiPsGetDepthNext (StartOp, Op); + } + + AcpiOsPrintf ("Method contains: %d AML Opcodes - %d Operators, %d Operands\n", + NumOps, NumOperators, NumOperands); + + AcpiOsPrintf ("Remaining to execute: %d AML Opcodes - %d Operators, %d Operands\n", + NumRemainingOps, NumRemainingOperators, NumRemainingOperands); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayLocals + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all locals for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayLocals (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + + AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", &Node->Name); + + for (i = 0; i < MTH_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + AcpiOsPrintf ("Local%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayArguments + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all arguments for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayArguments (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 NumArgs; + UINT32 Concurrency; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Method [%4.4s] has %d arguments, max concurrency = %d\n", &Node->Name, NumArgs, Concurrency); + + for (i = 0; i < NumArgs; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + AcpiOsPrintf ("Arg%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, 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 NumResults; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + NumResults = WalkState->NumResults - WalkState->CurrentResult; + + AcpiOsPrintf ("Method [%4.4s] has %d stacked result objects\n", &Node->Name, NumResults); + + for (i = WalkState->CurrentResult; i < WalkState->NumResults; i++) + { + ObjDesc = WalkState->Results[i]; + AcpiOsPrintf ("Result%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayCallingTree + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display current calling tree of nested control methods + * + ******************************************************************************/ + +void +AcpiDbDisplayCallingTree (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf ("Current Control Method Call Tree\n"); + + for (i = 0; WalkState; i++) + { + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf (" [%4.4s]\n", &Node->Name); + + WalkState = WalkState->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResultObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Display the result of an AML opcode + * + ******************************************************************************/ + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + + /* TBD: [Future] We don't always want to display the result. + * For now, only display if single stepping + * however, this output is very useful in other contexts also + */ + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("ResultObj: "); + AcpiDbDisplayInternalObject (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: "); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); +} + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c new file mode 100644 index 0000000..af1d884 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c @@ -0,0 +1,482 @@ +/******************************************************************************* + * + * Module Name: dbexec - debugger control method execution + * $Revision: 16 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbexec") + + +typedef struct dbmethodinfo +{ + ACPI_HANDLE ThreadGate; + NATIVE_CHAR *Name; + NATIVE_CHAR **Args; + UINT32 Flags; + UINT32 NumLoops; + NATIVE_CHAR Pathname[128]; + +} DB_METHOD_INFO; + + +DB_METHOD_INFO Info; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteMethod + * + * PARAMETERS: Info - Valid info segment + * ReturnObj - Where to put return object + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbExecuteMethod ( + DB_METHOD_INFO *Info, + ACPI_BUFFER *ReturnObj) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[MTH_NUM_ARGS]; + UINT32 i; + + + if (OutputToFile && !AcpiDbgLevel) + { + AcpiOsPrintf ("Warning: debug output is not enabled!\n"); + } + + /* Are there arguments to the method? */ + + if (Info->Args && Info->Args[0]) + { + for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++) + { + Params[i].Type = ACPI_TYPE_NUMBER; + Params[i].Number.Value = STRTOUL (Info->Args[i], NULL, 16); + } + + ParamObjects.Pointer = Params; + ParamObjects.Count = i; + } + + else + { + /* Setup default parameters */ + + Params[0].Type = ACPI_TYPE_NUMBER; + Params[0].Number.Value = 0x01020304; + + Params[1].Type = ACPI_TYPE_STRING; + Params[1].String.Length = 12; + Params[1].String.Pointer = "AML Debugger"; + + ParamObjects.Pointer = Params; + ParamObjects.Count = 2; + } + + /* Prepare for a return object of arbitrary size */ + + ReturnObj->Pointer = Buffer; + ReturnObj->Length = BUFFER_SIZE; + + + /* Do the actual method execution */ + + Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); + + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_MethodExecuting = FALSE; + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteSetup + * + * PARAMETERS: Info - Valid method info + * + * RETURN: Status + * + * DESCRIPTION: Setup info segment prior to method execution + * + ******************************************************************************/ + +void +AcpiDbExecuteSetup ( + DB_METHOD_INFO *Info) +{ + + /* Catenate the current scope to the supplied name */ + + Info->Pathname[0] = 0; + if ((Info->Name[0] != '\\') && + (Info->Name[0] != '/')) + { + STRCAT (Info->Pathname, ScopeBuf); + } + + STRCAT (Info->Pathname, Info->Name); + AcpiDbPrepNamestring (Info->Pathname); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Executing %s\n", Info->Pathname); + + if (Info->Flags & EX_SINGLE_STEP) + { + AcpiGbl_CmSingleStep = TRUE; + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + } + + else + { + /* No single step, allow redirection to a file */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecute + * + * PARAMETERS: Name - Name of method to execute + * Args - Parameters to the method + * Flags - single step/no single step + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. Name is relative to the current + * scope. + * + ******************************************************************************/ + +void +AcpiDbExecute ( + NATIVE_CHAR *Name, + NATIVE_CHAR **Args, + UINT32 Flags) +{ + ACPI_STATUS Status; + UINT32 PreviousAllocations; + UINT32 PreviousSize; + UINT32 Allocations; + UINT32 Size; + ACPI_BUFFER ReturnObj; + + + /* Memory allocation tracking */ + + PreviousAllocations = AcpiGbl_CurrentAllocCount; + PreviousSize = AcpiGbl_CurrentAllocSize; + + + Info.Name = Name; + Info.Args = Args; + Info.Flags = Flags; + + AcpiDbExecuteSetup (&Info); + Status = AcpiDbExecuteMethod (&Info, &ReturnObj); + + + /* Memory allocation tracking */ + + Allocations = AcpiGbl_CurrentAllocCount - PreviousAllocations; + Size = AcpiGbl_CurrentAllocSize - PreviousSize; + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + + if (Allocations > 0) + { + AcpiOsPrintf ("Outstanding: %ld allocations of total size %ld after execution\n", + Allocations, Size); + } + + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Execution of %s failed with status %s\n", Info.Pathname, AcpiCmFormatException (Status)); + } + + else + { + /* Display a return object, if any */ + + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info.Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + + AcpiDbSetOutputDestination (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. + * + ******************************************************************************/ + +void +AcpiDbMethodThread ( + void *Context) +{ + ACPI_STATUS Status; + DB_METHOD_INFO *Info = Context; + UINT32 i; + ACPI_BUFFER ReturnObj; + + + for (i = 0; i < Info->NumLoops; i++) + { + Status = AcpiDbExecuteMethod (Info, &ReturnObj); + if (ACPI_SUCCESS (Status)) + { + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info->Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + } + + + /* Signal our completion */ + + AcpiOsSignalSemaphore (Info->ThreadGate, 1); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *NumThreadsArg, + NATIVE_CHAR *NumLoopsArg, + NATIVE_CHAR *MethodNameArg) +{ + ACPI_STATUS Status; + UINT32 NumThreads; + UINT32 NumLoops; + UINT32 i; + ACPI_HANDLE ThreadGate; + + + /* Get the arguments */ + + NumThreads = STRTOUL (NumThreadsArg, NULL, 0); + NumLoops = STRTOUL (NumLoopsArg, NULL, 0); + + if (!NumThreads || !NumLoops) + { + AcpiOsPrintf ("Bad argument: Threads %d, Loops %d\n", NumThreads, NumLoops); + return; + } + + + /* Create the synchronization semaphore */ + + Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiCmFormatException (Status)); + return; + } + + /* Setup the context to be passed to each thread */ + + Info.Name = MethodNameArg; + Info.Args = NULL; + Info.Flags = 0; + Info.NumLoops = NumLoops; + Info.ThreadGate = ThreadGate; + + AcpiDbExecuteSetup (&Info); + + + /* Create the threads */ + + AcpiOsPrintf ("Creating %d threads to execute %d times each\n", NumThreads, NumLoops); + + for (i = 0; i < (NumThreads); i++) + { + AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &Info); + } + + + /* Wait for all threads to complete */ + + i = NumThreads; + while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ + { + Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER); + i--; + } + + /* Cleanup and exit */ + + AcpiOsDeleteSemaphore (ThreadGate); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("All threads (%d) have completed\n", NumThreads); + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c new file mode 100644 index 0000000..c7fe4fe --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c @@ -0,0 +1,472 @@ +/******************************************************************************* + * + * Module Name: dbfileio - Debugger file I/O commands. These can't usually + * be used when running the debugger in Ring 0 (Kernel mode) + * $Revision: 30 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acdebug.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbfileio") + + +ACPI_PARSE_OBJECT *root; + +#ifdef ACPI_APPLICATION +#include <stdio.h> +FILE *DebugFile = NULL; +#endif + + +/* + * NOTE: this is here for lack of a better place. It is used in all + * flavors of the debugger, need LCD file + */ + +/******************************************************************************* + * + * 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 + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDbMatchArgument ( + NATIVE_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 (STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) + { + return ((OBJECT_TYPE_INTERNAL) i); + } + } + + /* Argument not recognized */ + + return (ACPI_TYPE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCloseDebugFile + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: If open, close the current debug output file + * + ******************************************************************************/ + +void +AcpiDbCloseDebugFile ( + void) +{ + +#ifdef ACPI_APPLICATION + + if (DebugFile) + { + fclose (DebugFile); + DebugFile = NULL; + OutputToFile = FALSE; + AcpiOsPrintf ("Debug output file %s closed\n", DebugFilename); + } +#endif + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbOpenDebugFile + * + * PARAMETERS: Name - Filename to open + * + * RETURN: Status + * + * DESCRIPTION: Open a file where debug output will be directed. + * + ******************************************************************************/ + +void +AcpiDbOpenDebugFile ( + NATIVE_CHAR *Name) +{ + +#ifdef ACPI_APPLICATION + + AcpiDbCloseDebugFile (); + DebugFile = fopen (Name, "w+"); + if (DebugFile) + { + AcpiOsPrintf ("Debug output file %s opened\n", Name); + STRCPY (DebugFilename, Name); + OutputToFile = TRUE; + } + +#endif +} + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadTable + * + * PARAMETERS: fp - File that contains table + * TablePtr - Return value, buffer with table + * TableLenght - Return value, length of table + * + * RETURN: Status + * + * DESCRIPTION: Load the DSDT from the file pointer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadTable( + FILE *fp, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength) +{ + ACPI_TABLE_HEADER TableHeader; + UINT8 *AmlPtr; + UINT32 AmlLength; + UINT32 Actual; + + + /* Read the table header */ + + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (TableHeader)) + { + AcpiOsPrintf ("Couldn't read the table header\n"); + return (AE_BAD_SIGNATURE); + } + + /* Get and validate the table length */ + + *TableLength = TableHeader.Length; + if (!*TableLength) + { + AcpiOsPrintf ("Found a table length of zero!\n"); + return (AE_ERROR); + } + + /* Allocate a buffer for the table */ + + *TablePtr = (ACPI_TABLE_HEADER *) malloc ((size_t) *TableLength); + if (!*TablePtr) + { + AcpiOsPrintf ("Could not allocate memory for the table (size=0x%X)\n", TableHeader.Length); + return (AE_NO_MEMORY); + } + + + AmlPtr = (UINT8 *) *TablePtr + sizeof (TableHeader); + AmlLength = *TableLength - sizeof (TableHeader); + + /* Copy the header to the buffer */ + + MEMCPY (*TablePtr, &TableHeader, sizeof (TableHeader)); + + /* Get the rest of the table */ + + Actual = fread (AmlPtr, 1, (size_t) AmlLength, fp); + if (Actual == AmlLength) + { + return (AE_OK); + } + + if (Actual > 0) + { + AcpiOsPrintf ("Warning - reading table, asked for %d got %d\n", AmlLength, Actual); + return (AE_OK); + } + + + AcpiOsPrintf ("Error - could not read the table file\n"); + free (*TablePtr); + *TablePtr = NULL; + *TableLength = 0; + + return (AE_ERROR); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AeLocalLoadTable + * + * PARAMETERS: TablePtr - 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. + * + * If the call fails an appropriate status will be returned. + * + ******************************************************************************/ + +ACPI_STATUS +AeLocalLoadTable ( + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("AeLocalLoadTable"); + + if (!TablePtr) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Install the new table into the local data structures */ + + TableInfo.Pointer = TablePtr; + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* Free table allocated by AcpiTbGetTable */ + + AcpiTbDeleteSingleTable (&TableInfo); + return_ACPI_STATUS (Status); + } + + +#ifndef PARSER_ONLY + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + /* Uninstall table and free the buffer */ + + AcpiTbUninstallTable (TableInfo.InstalledDesc); + return_ACPI_STATUS (Status); + } +#endif + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadAcpiTable + * + * PARAMETERS: Filname - File where table is located + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a file + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + NATIVE_CHAR *Filename) +{ +#ifdef ACPI_APPLICATION + FILE *fp; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TablePtr; + UINT32 TableLength; + + + /* Open the file */ + + fp = fopen (Filename, "rb"); + if (!fp) + { + AcpiOsPrintf ("Could not open file %s\n", Filename); + return (AE_ERROR); + } + + + /* Get the entire file */ + + AcpiOsPrintf ("Loading Acpi table from file %s\n", Filename); + Status = AcpiDbLoadTable (fp, &TablePtr, &TableLength); + fclose(fp); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Couldn't get table from the file\n"); + return (Status); + } + + + /* Attempt to recognize and install the table */ + Status = AeLocalLoadTable (TablePtr); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_EXIST) + { + AcpiOsPrintf ("Table %4.4s is already installed\n", + &TablePtr->Signature); + } + else + { + AcpiOsPrintf ("Could not install table, %s\n", + AcpiCmFormatException (Status)); + } + free (TablePtr); + return (Status); + } + + AcpiOsPrintf ("%4.4s at %p successfully installed and loaded\n", + &TablePtr->Signature, TablePtr); + + AcpiGbl_AcpiHardwarePresent = FALSE; + +#endif /* ACPI_APPLICATION */ + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c new file mode 100644 index 0000000..bcc18a8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c @@ -0,0 +1,301 @@ +/****************************************************************************** + * + * Module Name: dbhistry - debugger HISTORY command + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbhistry") + + +#define HI_NO_HISTORY 0 +#define HI_RECORD_HISTORY 1 +#define HISTORY_SIZE 20 + + +typedef struct HistoryInfo +{ + NATIVE_CHAR Command[80]; + UINT32 CmdNum; + +} HISTORY_INFO; + + +HISTORY_INFO HistoryBuffer[HISTORY_SIZE]; +UINT16 LoHistory = 0; +UINT16 NumHistory = 0; +UINT16 NextHistoryIndex = 0; +UINT32 NextCmdNum = 1; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbAddToHistory + * + * PARAMETERS: CommandLine - Command to add + * + * RETURN: None + * + * DESCRIPTION: Add a command line to the history buffer. + * + ******************************************************************************/ + +void +AcpiDbAddToHistory ( + NATIVE_CHAR *CommandLine) +{ + + + /* Put command into the next available slot */ + + STRCPY (HistoryBuffer[NextHistoryIndex].Command, CommandLine); + HistoryBuffer[NextHistoryIndex].CmdNum = NextCmdNum; + + /* Adjust indexes */ + + if ((NumHistory == HISTORY_SIZE) && + (NextHistoryIndex == LoHistory)) + { + LoHistory++; + if (LoHistory >= HISTORY_SIZE) + { + LoHistory = 0; + } + } + + NextHistoryIndex++; + if (NextHistoryIndex >= HISTORY_SIZE) + { + NextHistoryIndex = 0; + } + + + NextCmdNum++; + if (NumHistory < HISTORY_SIZE) + { + NumHistory++; + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHistory + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display the contents of the history buffer + * + ******************************************************************************/ + +void +AcpiDbDisplayHistory (void) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + + + HistoryIndex = LoHistory; + + /* Dump entire history buffer */ + + for (i = 0; i < NumHistory; i++) + { + AcpiOsPrintf ("%ld %s\n", HistoryBuffer[HistoryIndex].CmdNum, 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: None + * + * DESCRIPTION: Get a command from the history buffer + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetFromHistory ( + NATIVE_CHAR *CommandNumArg) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + UINT32 CmdNum; + + + if (CommandNumArg == NULL) + { + CmdNum = NextCmdNum - 1; + } + + else + { + CmdNum = STRTOUL (CommandNumArg, NULL, 0); + } + + + /* Search history buffer */ + + HistoryIndex = LoHistory; + for (i = 0; i < NumHistory; i++) + { + if (HistoryBuffer[HistoryIndex].CmdNum == CmdNum) + { + /* Found the commnad, return it */ + + return (HistoryBuffer[HistoryIndex].Command); + } + + + HistoryIndex++; + if (HistoryIndex >= HISTORY_SIZE) + { + HistoryIndex = 0; + } + } + + AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); + return (NULL); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c new file mode 100644 index 0000000..d81e1ad --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c @@ -0,0 +1,981 @@ +/******************************************************************************* + * + * Module Name: dbinput - user front-end to the AML debugger + * $Revision: 51 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "actables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbinput") + + +/* + * Globals that are specific to the debugger + */ + +NATIVE_CHAR LineBuf[80]; +NATIVE_CHAR ParsedBuf[80]; +NATIVE_CHAR ScopeBuf[40]; +NATIVE_CHAR DebugFilename[40]; +NATIVE_CHAR *Args[DB_MAX_ARGS]; +NATIVE_CHAR *Buffer; +NATIVE_CHAR *Filename = NULL; +BOOLEAN OutputToFile = FALSE; + + +UINT32 AcpiGbl_DbDebugLevel = 0x0FFFFFFF; +UINT32 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | TRACE_TABLES; +UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; + + +BOOLEAN opt_tables = FALSE; +BOOLEAN opt_disasm = FALSE; +BOOLEAN opt_stats = FALSE; +BOOLEAN opt_parse_jit = FALSE; +BOOLEAN opt_verbose = TRUE; + + +/* + * Top-level debugger commands. + * + * This list of commands must match the string table below it + */ + +enum AcpiAmlDebuggerCommands +{ + CMD_NOT_FOUND = 0, + CMD_NULL, + CMD_ALLOCATIONS, + CMD_ARGS, + CMD_ARGUMENTS, + CMD_BREAKPOINT, + CMD_CALL, + CMD_CLOSE, + CMD_DEBUG, + CMD_DUMP, + CMD_ENABLEACPI, + CMD_EVENT, + CMD_EXECUTE, + CMD_EXIT, + CMD_FIND, + CMD_GO, + CMD_HELP, + CMD_HELP2, + CMD_HISTORY, + CMD_HISTORY_EXE, + CMD_HISTORY_LAST, + CMD_INFORMATION, + CMD_INTO, + CMD_LEVEL, + CMD_LIST, + CMD_LOAD, + CMD_LOCALS, + CMD_METHODS, + CMD_NAMESPACE, + CMD_NOTIFY, + CMD_OBJECT, + CMD_OPEN, + CMD_OWNER, + CMD_PREFIX, + CMD_QUIT, + CMD_REFERENCES, + CMD_RESULTS, + CMD_SET, + CMD_STATS, + CMD_STOP, + CMD_TABLES, + CMD_TERMINATE, + CMD_THREADS, + CMD_TREE, + CMD_UNLOAD +}; + +#define CMD_FIRST_VALID 2 + + +COMMAND_INFO Commands[] = +{ + {"<NOT FOUND>", 0}, + {"<NULL>", 0}, + {"ALLOCATIONS", 0}, + {"ARGS", 0}, + {"ARGUMENTS", 0}, + {"BREAKPOINT", 1}, + {"CALL", 0}, + {"CLOSE", 0}, + {"DEBUG", 1}, + {"DUMP", 1}, + {"ENABLEACPI", 0}, + {"EVENT", 1}, + {"EXECUTE", 1}, + {"EXIT", 0}, + {"FIND", 1}, + {"GO", 0}, + {"HELP", 0}, + {"?", 0}, + {"HISTORY", 0}, + {"!", 1}, + {"!!", 0}, + {"INFORMATION", 0}, + {"INTO", 0}, + {"LEVEL", 0}, + {"LIST", 0}, + {"LOAD", 1}, + {"LOCALS", 0}, + {"METHODS", 0}, + {"NAMESPACE", 0}, + {"NOTIFY", 2}, + {"OBJECT", 1}, + {"OPEN", 1}, + {"OWNER", 1}, + {"PREFIX", 0}, + {"QUIT", 0}, + {"REFERENCES", 1}, + {"RESULTS", 0}, + {"SET", 3}, + {"STATS", 0}, + {"STOP", 0}, + {"TABLES", 0}, + {"TERMINATE", 0}, + {"THREADS", 3}, + {"TREE", 0}, + {"UNLOAD", 0}, + {NULL, 0} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHelp + * + * PARAMETERS: HelpType - Subcommand (optional) + * + * RETURN: None + * + * DESCRIPTION: Print a usage message. + * + ******************************************************************************/ + +void +AcpiDbDisplayHelp ( + NATIVE_CHAR *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 (" [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 ("Quit or Exit Exit this command\n"); + AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); + AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); + AcpiOsPrintf ("Unload Unload an ACPI table\n"); + AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); + AcpiOsPrintf ("!! Execute last command again\n"); + return; + + case 'N': + AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n"); + AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); + AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n"); + AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Method Display list of loaded control methods\n"); + AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n"); + AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n"); + AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n"); + AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); + AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); + AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); + AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); + AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\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 ("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 AcpiAml 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 ("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: %x\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 + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetNextToken ( + NATIVE_CHAR *String, + NATIVE_CHAR **Next) +{ + NATIVE_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: None + * + * DESCRIPTION: Get the next command line from the user. Gets entire line + * up to the next newline + * + ******************************************************************************/ + +UINT32 +AcpiDbGetLine ( + NATIVE_CHAR *InputBuffer) +{ + UINT32 i; + UINT32 Count; + NATIVE_CHAR *Next; + NATIVE_CHAR *This; + + + STRCPY (ParsedBuf, InputBuffer); + STRUPR (ParsedBuf); + + This = ParsedBuf; + for (i = 0; i < DB_MAX_ARGS; i++) + { + Args[i] = AcpiDbGetNextToken (This, &Next); + if (!Args[i]) + { + break; + } + + This = Next; + } + + + /* Uppercase the actual command */ + + if (Args[0]) + { + STRUPR (Args[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 + * + ******************************************************************************/ + +UINT32 +AcpiDbMatchCommand ( + NATIVE_CHAR *UserCommand) +{ + UINT32 i; + + + if (!UserCommand || UserCommand[0] == 0) + { + return (CMD_NULL); + } + + for (i = CMD_FIRST_VALID; Commands[i].Name; i++) + { + if (STRSTR (Commands[i].Name, UserCommand) == Commands[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. Called from two places: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCommandDispatch ( + NATIVE_CHAR *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 Temp; + UINT32 CommandIndex; + UINT32 ParamCount; + NATIVE_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 (Args[0]); + Temp = 0; + + /* Verify that we have the minimum number of params */ + + if (ParamCount < Commands[CommandIndex].MinArgs) + { + AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", + ParamCount, Commands[CommandIndex].Name, Commands[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: + AcpiCmDumpCurrentAllocations ((UINT32) -1, NULL); + break; + + case CMD_ARGS: + case CMD_ARGUMENTS: + AcpiDbDisplayArguments (); + break; + + case CMD_BREAKPOINT: + AcpiDbSetMethodBreakpoint (Args[1], WalkState, Op); + break; + + case CMD_CALL: + AcpiDbSetMethodCallBreakpoint (Op); + Status = AE_OK; + break; + + case CMD_CLOSE: + AcpiDbCloseDebugFile (); + break; + + case CMD_DEBUG: + AcpiDbExecute (Args[1], &Args[2], EX_SINGLE_STEP); + break; + + case CMD_DUMP: + AcpiDbDecodeAndDisplayObject (Args[1], Args[2]); + break; + + case CMD_ENABLEACPI: + Status = AcpiEnable(); + if (ACPI_FAILURE(Status)) + { + AcpiOsPrintf("AcpiEnable failed (0x%x)\n", Status); + return (Status); + } + break; + + case CMD_EVENT: + AcpiOsPrintf ("Event command not implemented\n"); + break; + + case CMD_EXECUTE: + AcpiDbExecute (Args[1], &Args[2], EX_NO_SINGLE_STEP); + break; + + case CMD_FIND: + AcpiDbFindNameInNamespace (Args[1]); + break; + + case CMD_GO: + AcpiGbl_CmSingleStep = FALSE; + return (AE_OK); + + case CMD_HELP: + case CMD_HELP2: + AcpiDbDisplayHelp (Args[1]); + break; + + case CMD_HISTORY: + AcpiDbDisplayHistory (); + break; + + case CMD_HISTORY_EXE: + CommandLine = AcpiDbGetFromHistory (Args[1]); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + break; + + case CMD_HISTORY_LAST: + CommandLine = AcpiDbGetFromHistory (NULL); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + + case CMD_INFORMATION: + AcpiDbDisplayMethodInfo (Op); + break; + + case CMD_INTO: + if (Op) + { + AcpiGbl_CmSingleStep = TRUE; + +/* TBD: Must get current walk state */ + /* AcpiGbl_MethodBreakpoint = 0; */ + 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 = STRTOUL (Args[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 = STRTOUL (Args[1], NULL, 16); + AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); + } + break; + + case CMD_LIST: + AcpiDbDisassembleAml (Args[1], Op); + break; + + case CMD_LOAD: + Status = AcpiDbLoadAcpiTable (Args[1]); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case CMD_LOCALS: + AcpiDbDisplayLocals (); + break; + + case CMD_METHODS: + AcpiDbDisplayObjects ("METHOD", Args[1]); + break; + + case CMD_NAMESPACE: + AcpiDbDumpNamespace (Args[1], Args[2]); + break; + + case CMD_NOTIFY: + Temp = STRTOUL (Args[2], NULL, 0); + AcpiDbSendNotify (Args[1], Temp); + break; + + case CMD_OBJECT: + AcpiDbDisplayObjects (Args[1], Args[2]); + break; + + case CMD_OPEN: + AcpiDbOpenDebugFile (Args[1]); + break; + + case CMD_OWNER: + AcpiDbDumpNamespaceByOwner (Args[1], Args[2]); + break; + + case CMD_PREFIX: + AcpiDbSetScope (Args[1]); + break; + + case CMD_REFERENCES: + AcpiDbFindReferences (Args[1]); + break; + + case CMD_RESULTS: + AcpiDbDisplayResults (); + break; + + case CMD_SET: + AcpiDbSetMethodData (Args[1], Args[2], Args[3]); + break; + + case CMD_STATS: + AcpiDbDisplayStatistics (Args[1]); + break; + + case CMD_STOP: + return (AE_AML_ERROR); + break; + + case CMD_TABLES: + AcpiDbDisplayTableInfo (Args[1]); + break; + + case CMD_TERMINATE: + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiCmSubsystemShutdown (); + + /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ + + /* AcpiInitialize (NULL); */ + break; + + case CMD_THREADS: + AcpiDbCreateExecutionThreads (Args[1], Args[2], Args[3]); + break; + + case CMD_TREE: + AcpiDbDisplayCallingTree (); + break; + + case CMD_UNLOAD: + AcpiDbUnloadAcpiTable (Args[1], Args[2]); + break; + + case CMD_EXIT: + case CMD_QUIT: + if (Op) + { + return (AE_AML_ERROR); + } + + if (!OutputToFile) + { + AcpiDbgLevel = DEBUG_DEFAULT; + } + + /* Shutdown */ + + /* AcpiCmSubsystemShutdown (); */ + AcpiDbCloseDebugFile (); + + AcpiGbl_DbTerminateThreads = TRUE; + + return (AE_CTRL_TERMINATE); + + case CMD_NOT_FOUND: + AcpiOsPrintf ("Unknown Command\n"); + return (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 +AcpiDbExecuteThread ( + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + + while (Status != AE_CTRL_TERMINATE) + { + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiDbCommandDispatch (LineBuf, NULL, NULL); + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleThread + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbSingleThread ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + Status = AcpiDbCommandDispatch (LineBuf, 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 ( + NATIVE_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 (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + + + /* 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. + */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } + + 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 + */ + AcpiTerminate (); + + return (Status); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c new file mode 100644 index 0000000..afb8b44 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c @@ -0,0 +1,548 @@ +/******************************************************************************* + * + * Module Name: dbstats - Generation and display of ACPI table statistics + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 <acdebug.h> +#include <amlcode.h> +#include <acparser.h> +#include <acnamesp.h> + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbstats") + +/* + * Statistics subcommands + */ +ARGUMENT_INFO AcpiDbStatTypes [] = +{ + {"ALLOCATIONS"}, + {"OBJECTS"}, + {"MEMORY"}, + {"MISC"}, + {"TABLES"}, + {"SIZES"}, + {NULL} /* Must be null terminated */ +}; + +#define CMD_ALLOCATIONS 0 +#define CMD_OBJECTS 1 +#define CMD_MEMORY 2 +#define CMD_MISC 3 +#define CMD_TABLES 4 +#define CMD_SIZES 5 + + +/* + * Statistic globals + */ +UINT16 AcpiGbl_ObjTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_NodeTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_ObjTypeCountMisc; +UINT16 AcpiGbl_NodeTypeCountMisc; +UINT32 NumNodes; +UINT32 NumObjects; + + +UINT32 SizeOfParseTree; +UINT32 SizeOfMethodTrees; +UINT32 SizeOfNodeEntries; +UINT32 SizeOfAcpiObjects; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbEnumerateObject + * + * PARAMETERS: ObjDesc - Object to be counted + * + * RETURN: None + * + * DESCRIPTION: Add this object to the global counts, by object type. + * Recursively handles subobjects and packages. + * + * [TBD] Restructure - remove recursion. + * + ******************************************************************************/ + +void +AcpiDbEnumerateObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 Type; + UINT32 i; + + + if (!ObjDesc) + { + return; + } + + + /* Enumerate this object first */ + + NumObjects++; + + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_NODE_MAX) + { + AcpiGbl_ObjTypeCountMisc++; + } + else + { + AcpiGbl_ObjTypeCount [Type]++; + } + + /* Count the sub-objects */ + + switch (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.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Device.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Device.AddrHandler); + break; + + case ACPI_TYPE_REGION: + AcpiDbEnumerateObject (ObjDesc->Region.AddrHandler); + break; + + case ACPI_TYPE_POWER: + AcpiDbEnumerateObject (ObjDesc->PowerResource.SysHandler); + AcpiDbEnumerateObject (ObjDesc->PowerResource.DrvHandler); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiDbEnumerateObject (ObjDesc->Processor.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.AddrHandler); + break; + + case ACPI_TYPE_THERMAL: + AcpiDbEnumerateObject (ObjDesc->ThermalZone.SysHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.AddrHandler); + break; + } +} + + +#ifndef PARSER_ONLY + +/******************************************************************************* + * + * FUNCTION: AcpiDbClassifyOneObject + * + * PARAMETERS: Callback for WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and + * the parent namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbClassifyOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + + + NumNodes++; + + Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjHandle)->Object; + + AcpiDbEnumerateObject (ObjDesc); + + Type = Node->Type; + if (Type > INTERNAL_TYPE_INVALID) + { + AcpiGbl_NodeTypeCountMisc++; + } + + else + { + AcpiGbl_NodeTypeCount [Type]++; + } + + return AE_OK; + + + /* 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); + + */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCountNamespaceObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Count and classify the entire namespace, including all + * namespace nodes and attached objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCountNamespaceObjects ( + void) +{ + UINT32 i; + + + NumNodes = 0; + NumObjects = 0; + + AcpiGbl_ObjTypeCountMisc = 0; + for (i = 0; i < INTERNAL_TYPE_INVALID; i++) + { + AcpiGbl_ObjTypeCount [i] = 0; + AcpiGbl_NodeTypeCount [i] = 0; + } + + AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, AcpiDbClassifyOneObject, NULL, NULL); + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayStatistics + * + * PARAMETERS: TypeArg - Subcommand + * + * RETURN: Status + * + * DESCRIPTION: Display various statistics + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayStatistics ( + NATIVE_CHAR *TypeArg) +{ + UINT32 i; + UINT32 Type; + + + if (!AcpiGbl_DSDT) + { + AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n"); + } + + if (!TypeArg) + { + AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); + return (AE_OK); + } + + STRUPR (TypeArg); + Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); + if (Type == (UINT32) -1) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + +#ifndef PARSER_ONLY + + AcpiDbCountNamespaceObjects (); +#endif + + + switch (Type) + { +#ifndef PARSER_ONLY + case CMD_ALLOCATIONS: + AcpiCmDumpAllocationInfo (); + break; +#endif + + case CMD_TABLES: + + AcpiOsPrintf ("ACPI Table Information:\n\n"); + if (AcpiGbl_DSDT) + { + AcpiOsPrintf ("DSDT Length:................% 7ld (0x%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); + } + break; + + case CMD_OBJECTS: + + 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 < INTERNAL_TYPE_NODE_MAX; i++) + { + AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiCmGetTypeName (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:", + NumNodes, NumObjects); + + +/* + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ASL/AML Grammar Usage:\n\n"); + AcpiOsPrintf ("Elements Inside Methods:....% 7ld\n", NumMethodElements); + AcpiOsPrintf ("Elements Outside Methods:...% 7ld\n", NumGrammarElements - NumMethodElements); + AcpiOsPrintf ("Total Grammar Elements:.....% 7ld\n", NumGrammarElements); +*/ + break; + + case CMD_MEMORY: + + AcpiOsPrintf ("\nDynamic Memory Estimates:\n\n"); + AcpiOsPrintf ("Parse Tree without Methods:.% 7ld\n", SizeOfParseTree); + AcpiOsPrintf ("Control Method Parse Trees:.% 7ld (If parsed simultaneously)\n", SizeOfMethodTrees); + AcpiOsPrintf ("Namespace Nodes:............% 7ld (%d nodes)\n", sizeof (ACPI_NAMESPACE_NODE) * NumNodes, NumNodes); + AcpiOsPrintf ("Named Internal Objects......% 7ld\n", SizeOfAcpiObjects); + AcpiOsPrintf ("State Cache size............% 7ld\n", AcpiGbl_GenericStateCacheDepth * sizeof (ACPI_GENERIC_STATE)); + AcpiOsPrintf ("Parse Cache size............% 7ld\n", AcpiGbl_ParseCacheDepth * sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Object Cache size...........% 7ld\n", AcpiGbl_ObjectCacheDepth * sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("WalkState Cache size........% 7ld\n", AcpiGbl_WalkStateCacheDepth * sizeof (ACPI_WALK_STATE)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("Cache Statistics:\n\n"); + AcpiOsPrintf ("State Cache requests........% 7ld\n", AcpiGbl_StateCacheRequests); + AcpiOsPrintf ("State Cache hits............% 7ld\n", AcpiGbl_StateCacheHits); + AcpiOsPrintf ("State Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_GenericStateCacheDepth, + MAX_STATE_CACHE_DEPTH - AcpiGbl_GenericStateCacheDepth); + AcpiOsPrintf ("Parse Cache requests........% 7ld\n", AcpiGbl_ParseCacheRequests); + AcpiOsPrintf ("Parse Cache hits............% 7ld\n", AcpiGbl_ParseCacheHits); + AcpiOsPrintf ("Parse Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_ParseCacheDepth, + MAX_PARSE_CACHE_DEPTH - AcpiGbl_ParseCacheDepth); + AcpiOsPrintf ("Ext Parse Cache requests....% 7ld\n", AcpiGbl_ExtParseCacheRequests); + AcpiOsPrintf ("Ext Parse Cache hits........% 7ld\n", AcpiGbl_ExtParseCacheHits); + AcpiOsPrintf ("Ext Parse Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_ExtParseCacheDepth, + MAX_EXTPARSE_CACHE_DEPTH - AcpiGbl_ExtParseCacheDepth); + AcpiOsPrintf ("Object Cache requests.......% 7ld\n", AcpiGbl_ObjectCacheRequests); + AcpiOsPrintf ("Object Cache hits...........% 7ld\n", AcpiGbl_ObjectCacheHits); + AcpiOsPrintf ("Object Cache depth..........% 7ld (%d remaining entries)\n", AcpiGbl_ObjectCacheDepth, + MAX_OBJECT_CACHE_DEPTH - AcpiGbl_ObjectCacheDepth); + AcpiOsPrintf ("WalkState Cache requests....% 7ld\n", AcpiGbl_WalkStateCacheRequests); + AcpiOsPrintf ("WalkState Cache hits........% 7ld\n", AcpiGbl_WalkStateCacheHits); + AcpiOsPrintf ("WalkState Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_WalkStateCacheDepth, + MAX_WALK_CACHE_DEPTH - AcpiGbl_WalkStateCacheDepth); + break; + + case CMD_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 < NUM_MTX; i++) + { + AcpiOsPrintf ("%-20s: % 7ld\n", AcpiCmGetMutexName (i), AcpiGbl_AcpiMutexInfo[i].UseCount); + } + break; + + + case CMD_SIZES: + + AcpiOsPrintf ("\nInternal object sizes:\n\n"); + + AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); + AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_NUMBER)); + 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 ("FieldUnit %3d\n", sizeof (ACPI_OBJECT_FIELD_UNIT)); + 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 ("Field %3d\n", sizeof (ACPI_OBJECT_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 ("NotifyHandler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); + AcpiOsPrintf ("AddrHandler %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); + AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Parse2Object %3d\n", sizeof (ACPI_PARSE2_OBJECT)); + AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE)); + + break; + + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c new file mode 100644 index 0000000..a520221 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c @@ -0,0 +1,465 @@ +/******************************************************************************* + * + * Module Name: dbutils - AML debugger utilities + * $Revision: 32 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "acdispat.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetOutputDestination + * + * PARAMETERS: OutputFlags - Current flags word + * + * RETURN: None + * + * DESCRIPTION: Set the current destination for debugger output. Alos sets + * the debug output level accordingly. + * + ******************************************************************************/ + +void +AcpiDbSetOutputDestination ( + UINT32 OutputFlags) +{ + + AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; + + if (OutputFlags & DB_REDIRECTABLE_OUTPUT) + { + if (OutputToFile) + { + AcpiDbgLevel = AcpiGbl_DbDebugLevel; + } + } + else + { + AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpBuffer + * + * PARAMETERS: Address - Pointer to the buffer + * + * RETURN: None + * + * DESCRIPTION: Print a portion of a buffer + * + ******************************************************************************/ + +void +AcpiDbDumpBuffer ( + UINT32 Address) +{ + + AcpiOsPrintf ("\nLocation 0x%X:\n", Address); + + AcpiDbgLevel |= TRACE_TABLES; + AcpiCmDumpBuffer ((UINT8 *) Address, 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpObject + * + * PARAMETERS: ObjDesc - External ACPI object to dump + * Level - Nesting level. + * + * RETURN: None + * + * DESCRIPTION: Dump the contents of an ACPI external object + * + ******************************************************************************/ + +void +AcpiDbDumpObject ( + 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 ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("[Number] Value: %ld (0x%lX)\n", ObjDesc->Number.Value, ObjDesc->Number.Value); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("[String] Value: "); + for (i = 0; i < ObjDesc->String.Length; i++) + { + AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); + } + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("[Buffer] Value: "); + AcpiCmDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements: \n", ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1); + } + break; + + + case INTERNAL_TYPE_REFERENCE: + AcpiOsPrintf ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiOsPrintf ("[Processor]\n"); + break; + + case ACPI_TYPE_POWER: + AcpiOsPrintf ("[Power Resource]\n"); + break; + + default: + + AcpiOsPrintf ("[Unknown Type] 0x%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 ( + NATIVE_CHAR *Name) +{ + + + if (!Name) + { + return; + } + + STRUPR (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: 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_PARSE2_OBJECT *Method; + ACPI_PARSE_OBJECT *SearchOp; + ACPI_PARSE_OBJECT *StartOp; + ACPI_STATUS Status = AE_OK; + UINT32 BaseAmlOffset; + + + AcpiOsPrintf ("Pass two parse ....\n"); + + while (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + Method = (ACPI_PARSE2_OBJECT *) Op; + Status = AcpiPsParseAml (Op, Method->Data, Method->Length, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + + BaseAmlOffset = (Method->Value.Arg)->AmlOffset + 1; + StartOp = (Method->Value.Arg)->Next; + SearchOp = StartOp; + + while (SearchOp) + { + SearchOp->AmlOffset += BaseAmlOffset; + SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); + } + + } + + if (Op->Opcode == 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)) + { + return (Status); + } + + Op = AcpiPsGetDepthNext (Root, Op); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLocalNsLookup + * + * PARAMETERS: Name - Name to lookup + * + * RETURN: Pointer to a namespace node + * + * DESCRIPTION: Lookup a name in the ACPI namespace + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + NATIVE_CHAR *Name) +{ + NATIVE_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 */ + + /* TBD: [Investigate] what scope do we use? */ + /* Use the root scope for the start of the search */ + + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not locate name: %s %s\n", Name, AcpiCmFormatException (Status)); + } + + + AcpiCmFree (InternalPath); + + return (Node); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c new file mode 100644 index 0000000..19cfafb --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c @@ -0,0 +1,432 @@ +/******************************************************************************* + * + * Module Name: dbxface - AML Debugger external interfaces + * $Revision: 31 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, 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 "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleStep + * + * PARAMETERS: WalkState - Current walk + * Op - Current executing op + * OpType - Type 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, + UINT8 OpType) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_STATUS Status = AE_OK; + UINT32 OriginalDebugLevel; + ACPI_PARSE_OBJECT *DisplayOp; + + + /* Is there a breakpoint set? */ + + if (WalkState->MethodBreakpoint) + { + /* Check if the breakpoint has been reached or passed */ + + if (WalkState->MethodBreakpoint <= Op->AmlOffset) + { + /* Hit the breakpoint, resume single step, reset breakpoint */ + + AcpiOsPrintf ("***Break*** at AML offset 0x%X\n", Op->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->Opcode == AML_NAMEDFIELD_OP) + { + return (AE_OK); + } + + switch (OpType) + { + case OPTYPE_UNDEFINED: + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + return (AE_OK); + break; + + case OPTYPE_NAMED_OBJECT: + switch (Op->Opcode) + { + case AML_NAMEPATH_OP: + return (AE_OK); + break; + } + } + + + /* + * Under certain debug conditions, display this opcode and its operands + */ + + if ((OutputToFile) || + (AcpiGbl_CmSingleStep) || + (AcpiDbgLevel & TRACE_PARSE)) + { + if ((OutputToFile) || + (AcpiDbgLevel & TRACE_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 &= ~(TRACE_PARSE | TRACE_FUNCTIONS); + Next = Op->Next; + Op->Next = NULL; + + + DisplayOp = Op; + if (Op->Parent) + { + if ((Op->Parent->Opcode == AML_IF_OP) || + (Op->Parent->Opcode == AML_WHILE_OP)) + { + DisplayOp = Op->Parent; + } + } + + /* Now we can display it */ + + AcpiDbDisplayOp (WalkState, DisplayOp, ACPI_UINT32_MAX); + + if ((Op->Opcode == AML_IF_OP) || + (Op->Opcode == AML_WHILE_OP)) + { + if (WalkState->ControlState->Common.Value) + { + AcpiOsPrintf ("Predicate was TRUE, executed block\n"); + } + else + { + AcpiOsPrintf ("Predicate is FALSE, skipping block\n"); + } + } + + else if (Op->Opcode == AML_ELSE_OP) + { + /* TBD */ + } + + + /* Restore everything */ + + Op->Next = Next; + 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->Opcode != AML_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->Opcode == AML_METHODCALL_OP) + { + AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */ + + /* Set the breakpoint on the call, it will stop execution as soon as we return */ + + /* TBD: [Future] don't kill the user breakpoint! */ + + WalkState->MethodBreakpoint = /* Op->AmlOffset + */ 1; /* Must be non-zero! */ + } + + + /* TBD: [Investigate] what are the namespace locking issues here */ + + /* AcpiCmReleaseMutex (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 */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + } + + else + { + /* Single threaded, we must get a command line ourselves */ + + /* Force output to console until a command is entered */ + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + } + + Status = AcpiDbCommandDispatch (LineBuf, WalkState, Op); + } + + /* AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); */ + + + /* User commands complete, continue execution of the interrupted method */ + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Init and start debugger + * + ******************************************************************************/ + +int +AcpiDbInitialize (void) +{ + + + /* Init globals */ + + Buffer = AcpiOsAllocate (BUFFER_SIZE); + + /* Initial scope is the root */ + + ScopeBuf [0] = '\\'; + ScopeBuf [1] = 0; + + + /* + * 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 */ + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + + /* Create the debug execution thread to execute commands */ + + AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL); + } + + if (!opt_verbose) + { + INDENT_STRING = " "; + opt_disasm = TRUE; + opt_stats = FALSE; + } + + + return (0); +} + + +#endif /* ENABLE_DEBUGGER */ |