1a159c266SJung-uk Kim /******************************************************************************* 2a159c266SJung-uk Kim * 3a159c266SJung-uk Kim * Module Name: dbxface - AML Debugger external interfaces 4a159c266SJung-uk Kim * 5a159c266SJung-uk Kim ******************************************************************************/ 6a159c266SJung-uk Kim 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 11*804fe266SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 12a159c266SJung-uk Kim * All rights reserved. 13a159c266SJung-uk Kim * 140d84335fSJung-uk Kim * 2. License 150d84335fSJung-uk Kim * 160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 190d84335fSJung-uk Kim * property rights. 200d84335fSJung-uk Kim * 210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 270d84335fSJung-uk Kim * 280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 360d84335fSJung-uk Kim * 370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 380d84335fSJung-uk Kim * conditions are met: 390d84335fSJung-uk Kim * 400d84335fSJung-uk Kim * 3. Conditions 410d84335fSJung-uk Kim * 420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 530d84335fSJung-uk Kim * 540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 640d84335fSJung-uk Kim * make. 650d84335fSJung-uk Kim * 660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 700d84335fSJung-uk Kim * distribution. 710d84335fSJung-uk Kim * 720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 730d84335fSJung-uk Kim * Intel Code. 740d84335fSJung-uk Kim * 750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 780d84335fSJung-uk Kim * without prior written authorization from Intel. 790d84335fSJung-uk Kim * 800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 810d84335fSJung-uk Kim * 820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 880d84335fSJung-uk Kim * PARTICULAR PURPOSE. 890d84335fSJung-uk Kim * 900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 970d84335fSJung-uk Kim * LIMITED REMEDY. 980d84335fSJung-uk Kim * 990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 1120d84335fSJung-uk Kim * such license, approval or letter. 1130d84335fSJung-uk Kim * 1140d84335fSJung-uk Kim ***************************************************************************** 1150d84335fSJung-uk Kim * 1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1170d84335fSJung-uk Kim * following license: 1180d84335fSJung-uk Kim * 119a159c266SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120a159c266SJung-uk Kim * modification, are permitted provided that the following conditions 121a159c266SJung-uk Kim * are met: 122a159c266SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123a159c266SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124a159c266SJung-uk Kim * without modification. 125a159c266SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126a159c266SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127a159c266SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128a159c266SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129a159c266SJung-uk Kim * binary redistribution. 130a159c266SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131a159c266SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132a159c266SJung-uk Kim * from this software without specific prior written permission. 133a159c266SJung-uk Kim * 1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1450d84335fSJung-uk Kim * 1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 147a159c266SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148a159c266SJung-uk Kim * Software Foundation. 149a159c266SJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 151a159c266SJung-uk Kim 152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h> 153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h> 154a159c266SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h> 155a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdebug.h> 1560d84335fSJung-uk Kim #include <contrib/dev/acpica/include/acinterp.h> 15751f42badSJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 158a159c266SJung-uk Kim 159a159c266SJung-uk Kim 160a159c266SJung-uk Kim #define _COMPONENT ACPI_CA_DEBUGGER 161a159c266SJung-uk Kim ACPI_MODULE_NAME ("dbxface") 162a159c266SJung-uk Kim 163a159c266SJung-uk Kim 164a159c266SJung-uk Kim /* Local prototypes */ 165a159c266SJung-uk Kim 166a159c266SJung-uk Kim static ACPI_STATUS 167a159c266SJung-uk Kim AcpiDbStartCommand ( 168a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 169a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op); 170a159c266SJung-uk Kim 171a159c266SJung-uk Kim #ifdef ACPI_OBSOLETE_FUNCTIONS 172a159c266SJung-uk Kim void 173a159c266SJung-uk Kim AcpiDbMethodEnd ( 174a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState); 175a159c266SJung-uk Kim #endif 176a159c266SJung-uk Kim 1774a38ee6dSJung-uk Kim #ifdef ACPI_DISASSEMBLER 1784a38ee6dSJung-uk Kim static ACPI_PARSE_OBJECT * 1794a38ee6dSJung-uk Kim AcpiDbGetDisplayOp ( 1804a38ee6dSJung-uk Kim ACPI_WALK_STATE *WalkState, 1814a38ee6dSJung-uk Kim ACPI_PARSE_OBJECT *Op); 1824a38ee6dSJung-uk Kim #endif 183a159c266SJung-uk Kim 184a159c266SJung-uk Kim /******************************************************************************* 185a159c266SJung-uk Kim * 186a159c266SJung-uk Kim * FUNCTION: AcpiDbStartCommand 187a159c266SJung-uk Kim * 188a159c266SJung-uk Kim * PARAMETERS: WalkState - Current walk 189a159c266SJung-uk Kim * Op - Current executing Op, from AML interpreter 190a159c266SJung-uk Kim * 191a159c266SJung-uk Kim * RETURN: Status 192a159c266SJung-uk Kim * 193a159c266SJung-uk Kim * DESCRIPTION: Enter debugger command loop 194a159c266SJung-uk Kim * 195a159c266SJung-uk Kim ******************************************************************************/ 196a159c266SJung-uk Kim 197a159c266SJung-uk Kim static ACPI_STATUS 198a159c266SJung-uk Kim AcpiDbStartCommand ( 199a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 200a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op) 201a159c266SJung-uk Kim { 202a159c266SJung-uk Kim ACPI_STATUS Status; 203a159c266SJung-uk Kim 204a159c266SJung-uk Kim 205a159c266SJung-uk Kim /* TBD: [Investigate] are there namespace locking issues here? */ 206a159c266SJung-uk Kim 207a159c266SJung-uk Kim /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */ 208a159c266SJung-uk Kim 209a159c266SJung-uk Kim /* Go into the command loop and await next user command */ 210a159c266SJung-uk Kim 211a159c266SJung-uk Kim 212a159c266SJung-uk Kim AcpiGbl_MethodExecuting = TRUE; 213a159c266SJung-uk Kim Status = AE_CTRL_TRUE; 21428482948SJung-uk Kim 215a159c266SJung-uk Kim while (Status == AE_CTRL_TRUE) 216a159c266SJung-uk Kim { 21728482948SJung-uk Kim /* Notify the completion of the command */ 218a159c266SJung-uk Kim 21928482948SJung-uk Kim Status = AcpiOsNotifyCommandComplete (); 220a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 221a159c266SJung-uk Kim { 22228482948SJung-uk Kim goto ErrorExit; 223a159c266SJung-uk Kim } 224a159c266SJung-uk Kim 22528482948SJung-uk Kim /* Wait the readiness of the command */ 226a159c266SJung-uk Kim 22728482948SJung-uk Kim Status = AcpiOsWaitCommandReady (); 228a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 229a159c266SJung-uk Kim { 23028482948SJung-uk Kim goto ErrorExit; 231a159c266SJung-uk Kim } 232a159c266SJung-uk Kim 233a159c266SJung-uk Kim Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op); 234a159c266SJung-uk Kim } 235a159c266SJung-uk Kim 236a159c266SJung-uk Kim /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */ 237a159c266SJung-uk Kim 23828482948SJung-uk Kim ErrorExit: 23928482948SJung-uk Kim if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) 24028482948SJung-uk Kim { 24128482948SJung-uk Kim ACPI_EXCEPTION ((AE_INFO, Status, 24228482948SJung-uk Kim "While parsing/handling command line")); 24328482948SJung-uk Kim } 244a159c266SJung-uk Kim return (Status); 245a159c266SJung-uk Kim } 246a159c266SJung-uk Kim 247a159c266SJung-uk Kim 248a159c266SJung-uk Kim /******************************************************************************* 249a159c266SJung-uk Kim * 250f8146b88SJung-uk Kim * FUNCTION: AcpiDbSignalBreakPoint 251f8146b88SJung-uk Kim * 252f8146b88SJung-uk Kim * PARAMETERS: WalkState - Current walk 253f8146b88SJung-uk Kim * 254f8146b88SJung-uk Kim * RETURN: Status 255f8146b88SJung-uk Kim * 2560d84335fSJung-uk Kim * DESCRIPTION: Called for AML_BREAKPOINT_OP 257f8146b88SJung-uk Kim * 258f8146b88SJung-uk Kim ******************************************************************************/ 259f8146b88SJung-uk Kim 260f8146b88SJung-uk Kim void 261f8146b88SJung-uk Kim AcpiDbSignalBreakPoint ( 262f8146b88SJung-uk Kim ACPI_WALK_STATE *WalkState) 263f8146b88SJung-uk Kim { 264f8146b88SJung-uk Kim 265f8146b88SJung-uk Kim #ifndef ACPI_APPLICATION 266f8146b88SJung-uk Kim if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) 267f8146b88SJung-uk Kim { 268f8146b88SJung-uk Kim return; 269f8146b88SJung-uk Kim } 270f8146b88SJung-uk Kim #endif 271f8146b88SJung-uk Kim 272f8146b88SJung-uk Kim /* 273f8146b88SJung-uk Kim * Set the single-step flag. This will cause the debugger (if present) 274f8146b88SJung-uk Kim * to break to the console within the AML debugger at the start of the 275f8146b88SJung-uk Kim * next AML instruction. 276f8146b88SJung-uk Kim */ 277f8146b88SJung-uk Kim AcpiGbl_CmSingleStep = TRUE; 278f8146b88SJung-uk Kim AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"); 279f8146b88SJung-uk Kim } 280f8146b88SJung-uk Kim 281f8146b88SJung-uk Kim 2824a38ee6dSJung-uk Kim #ifdef ACPI_DISASSEMBLER 2834a38ee6dSJung-uk Kim /******************************************************************************* 2844a38ee6dSJung-uk Kim * 2854a38ee6dSJung-uk Kim * FUNCTION: AcpiDbGetDisplayOp 2864a38ee6dSJung-uk Kim * 2874a38ee6dSJung-uk Kim * PARAMETERS: WalkState - Current walk 2884a38ee6dSJung-uk Kim * Op - Current executing op (from aml interpreter) 2894a38ee6dSJung-uk Kim * 2904a38ee6dSJung-uk Kim * RETURN: Opcode to display 2914a38ee6dSJung-uk Kim * 2924a38ee6dSJung-uk Kim * DESCRIPTION: Find the opcode to display during single stepping 2934a38ee6dSJung-uk Kim * 2944a38ee6dSJung-uk Kim ******************************************************************************/ 2954a38ee6dSJung-uk Kim 2964a38ee6dSJung-uk Kim static ACPI_PARSE_OBJECT * 2974a38ee6dSJung-uk Kim AcpiDbGetDisplayOp ( 2984a38ee6dSJung-uk Kim ACPI_WALK_STATE *WalkState, 2994a38ee6dSJung-uk Kim ACPI_PARSE_OBJECT *Op) 3004a38ee6dSJung-uk Kim { 3014a38ee6dSJung-uk Kim ACPI_PARSE_OBJECT *DisplayOp; 3024a38ee6dSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp; 3034a38ee6dSJung-uk Kim 3044a38ee6dSJung-uk Kim DisplayOp = Op; 3054a38ee6dSJung-uk Kim ParentOp = Op->Common.Parent; 3064a38ee6dSJung-uk Kim if (ParentOp) 3074a38ee6dSJung-uk Kim { 3084a38ee6dSJung-uk Kim if ((WalkState->ControlState) && 3094a38ee6dSJung-uk Kim (WalkState->ControlState->Common.State == 3104a38ee6dSJung-uk Kim ACPI_CONTROL_PREDICATE_EXECUTING)) 3114a38ee6dSJung-uk Kim { 3124a38ee6dSJung-uk Kim /* 3134a38ee6dSJung-uk Kim * We are executing the predicate of an IF or WHILE statement 3144a38ee6dSJung-uk Kim * Search upwards for the containing IF or WHILE so that the 3154a38ee6dSJung-uk Kim * entire predicate can be displayed. 3164a38ee6dSJung-uk Kim */ 3174a38ee6dSJung-uk Kim while (ParentOp) 3184a38ee6dSJung-uk Kim { 3194a38ee6dSJung-uk Kim if ((ParentOp->Common.AmlOpcode == AML_IF_OP) || 3204a38ee6dSJung-uk Kim (ParentOp->Common.AmlOpcode == AML_WHILE_OP)) 3214a38ee6dSJung-uk Kim { 3224a38ee6dSJung-uk Kim DisplayOp = ParentOp; 3234a38ee6dSJung-uk Kim break; 3244a38ee6dSJung-uk Kim } 3254a38ee6dSJung-uk Kim ParentOp = ParentOp->Common.Parent; 3264a38ee6dSJung-uk Kim } 3274a38ee6dSJung-uk Kim } 3284a38ee6dSJung-uk Kim else 3294a38ee6dSJung-uk Kim { 3304a38ee6dSJung-uk Kim while (ParentOp) 3314a38ee6dSJung-uk Kim { 3324a38ee6dSJung-uk Kim if ((ParentOp->Common.AmlOpcode == AML_IF_OP) || 3334a38ee6dSJung-uk Kim (ParentOp->Common.AmlOpcode == AML_ELSE_OP) || 3344a38ee6dSJung-uk Kim (ParentOp->Common.AmlOpcode == AML_SCOPE_OP) || 3354a38ee6dSJung-uk Kim (ParentOp->Common.AmlOpcode == AML_METHOD_OP) || 3364a38ee6dSJung-uk Kim (ParentOp->Common.AmlOpcode == AML_WHILE_OP)) 3374a38ee6dSJung-uk Kim { 3384a38ee6dSJung-uk Kim break; 3394a38ee6dSJung-uk Kim } 3404a38ee6dSJung-uk Kim DisplayOp = ParentOp; 3414a38ee6dSJung-uk Kim ParentOp = ParentOp->Common.Parent; 3424a38ee6dSJung-uk Kim } 3434a38ee6dSJung-uk Kim } 3444a38ee6dSJung-uk Kim } 3454a38ee6dSJung-uk Kim return DisplayOp; 3464a38ee6dSJung-uk Kim } 3474a38ee6dSJung-uk Kim #endif 3484a38ee6dSJung-uk Kim 3494a38ee6dSJung-uk Kim 350f8146b88SJung-uk Kim /******************************************************************************* 351f8146b88SJung-uk Kim * 352a159c266SJung-uk Kim * FUNCTION: AcpiDbSingleStep 353a159c266SJung-uk Kim * 354a159c266SJung-uk Kim * PARAMETERS: WalkState - Current walk 355a159c266SJung-uk Kim * Op - Current executing op (from aml interpreter) 356a159c266SJung-uk Kim * OpcodeClass - Class of the current AML Opcode 357a159c266SJung-uk Kim * 358a159c266SJung-uk Kim * RETURN: Status 359a159c266SJung-uk Kim * 360a159c266SJung-uk Kim * DESCRIPTION: Called just before execution of an AML opcode. 361a159c266SJung-uk Kim * 362a159c266SJung-uk Kim ******************************************************************************/ 363a159c266SJung-uk Kim 364a159c266SJung-uk Kim ACPI_STATUS 365a159c266SJung-uk Kim AcpiDbSingleStep ( 366a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 367a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op, 368a159c266SJung-uk Kim UINT32 OpcodeClass) 369a159c266SJung-uk Kim { 370a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Next; 371a159c266SJung-uk Kim ACPI_STATUS Status = AE_OK; 372a159c266SJung-uk Kim UINT32 OriginalDebugLevel; 373fe0f0bbbSJung-uk Kim UINT32 AmlOffset; 374a159c266SJung-uk Kim 375a159c266SJung-uk Kim 376a159c266SJung-uk Kim ACPI_FUNCTION_ENTRY (); 377a159c266SJung-uk Kim 378a159c266SJung-uk Kim 379f8146b88SJung-uk Kim #ifndef ACPI_APPLICATION 380f8146b88SJung-uk Kim if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) 381f8146b88SJung-uk Kim { 382f8146b88SJung-uk Kim return (AE_OK); 383f8146b88SJung-uk Kim } 384f8146b88SJung-uk Kim #endif 385f8146b88SJung-uk Kim 386a159c266SJung-uk Kim /* Check the abort flag */ 387a159c266SJung-uk Kim 388a159c266SJung-uk Kim if (AcpiGbl_AbortMethod) 389a159c266SJung-uk Kim { 390a159c266SJung-uk Kim AcpiGbl_AbortMethod = FALSE; 391a159c266SJung-uk Kim return (AE_ABORT_METHOD); 392a159c266SJung-uk Kim } 393a159c266SJung-uk Kim 394fe0f0bbbSJung-uk Kim AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, 395fe0f0bbbSJung-uk Kim WalkState->ParserState.AmlStart); 396fe0f0bbbSJung-uk Kim 397a159c266SJung-uk Kim /* Check for single-step breakpoint */ 398a159c266SJung-uk Kim 399a159c266SJung-uk Kim if (WalkState->MethodBreakpoint && 400fe0f0bbbSJung-uk Kim (WalkState->MethodBreakpoint <= AmlOffset)) 401a159c266SJung-uk Kim { 402a159c266SJung-uk Kim /* Check if the breakpoint has been reached or passed */ 403a159c266SJung-uk Kim /* Hit the breakpoint, resume single step, reset breakpoint */ 404a159c266SJung-uk Kim 405fe0f0bbbSJung-uk Kim AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset); 406a159c266SJung-uk Kim AcpiGbl_CmSingleStep = TRUE; 407a159c266SJung-uk Kim AcpiGbl_StepToNextCall = FALSE; 408a159c266SJung-uk Kim WalkState->MethodBreakpoint = 0; 409a159c266SJung-uk Kim } 410a159c266SJung-uk Kim 411a159c266SJung-uk Kim /* Check for user breakpoint (Must be on exact Aml offset) */ 412a159c266SJung-uk Kim 413a159c266SJung-uk Kim else if (WalkState->UserBreakpoint && 414fe0f0bbbSJung-uk Kim (WalkState->UserBreakpoint == AmlOffset)) 415a159c266SJung-uk Kim { 416a159c266SJung-uk Kim AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", 417fe0f0bbbSJung-uk Kim AmlOffset); 418a159c266SJung-uk Kim AcpiGbl_CmSingleStep = TRUE; 419a159c266SJung-uk Kim AcpiGbl_StepToNextCall = FALSE; 420a159c266SJung-uk Kim WalkState->MethodBreakpoint = 0; 421a159c266SJung-uk Kim } 422a159c266SJung-uk Kim 423a159c266SJung-uk Kim /* 424a159c266SJung-uk Kim * Check if this is an opcode that we are interested in -- 425a159c266SJung-uk Kim * namely, opcodes that have arguments 426a159c266SJung-uk Kim */ 427a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 428a159c266SJung-uk Kim { 429a159c266SJung-uk Kim return (AE_OK); 430a159c266SJung-uk Kim } 431a159c266SJung-uk Kim 432a159c266SJung-uk Kim switch (OpcodeClass) 433a159c266SJung-uk Kim { 434a159c266SJung-uk Kim case AML_CLASS_UNKNOWN: 435a159c266SJung-uk Kim case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */ 436a9d8d09cSJung-uk Kim 437a159c266SJung-uk Kim return (AE_OK); 438a159c266SJung-uk Kim 439a159c266SJung-uk Kim default: 440a9d8d09cSJung-uk Kim 441a159c266SJung-uk Kim /* All other opcodes -- continue */ 442a159c266SJung-uk Kim break; 443a159c266SJung-uk Kim } 444a159c266SJung-uk Kim 445a159c266SJung-uk Kim /* 446a159c266SJung-uk Kim * Under certain debug conditions, display this opcode and its operands 447a159c266SJung-uk Kim */ 448a159c266SJung-uk Kim if ((AcpiGbl_DbOutputToFile) || 449a159c266SJung-uk Kim (AcpiGbl_CmSingleStep) || 450a159c266SJung-uk Kim (AcpiDbgLevel & ACPI_LV_PARSE)) 451a159c266SJung-uk Kim { 452a159c266SJung-uk Kim if ((AcpiGbl_DbOutputToFile) || 453a159c266SJung-uk Kim (AcpiDbgLevel & ACPI_LV_PARSE)) 454a159c266SJung-uk Kim { 455af051161SJung-uk Kim AcpiOsPrintf ("\nAML Debug: Next AML Opcode to execute:\n"); 456a159c266SJung-uk Kim } 457a159c266SJung-uk Kim 458a159c266SJung-uk Kim /* 459a159c266SJung-uk Kim * Display this op (and only this op - zero out the NEXT field 460a159c266SJung-uk Kim * temporarily, and disable parser trace output for the duration of 461a159c266SJung-uk Kim * the display because we don't want the extraneous debug output) 462a159c266SJung-uk Kim */ 463a159c266SJung-uk Kim OriginalDebugLevel = AcpiDbgLevel; 464a159c266SJung-uk Kim AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS); 465a159c266SJung-uk Kim Next = Op->Common.Next; 466a159c266SJung-uk Kim Op->Common.Next = NULL; 467a159c266SJung-uk Kim 46851f42badSJung-uk Kim /* Now we can disassemble and display it */ 469a159c266SJung-uk Kim 470a159c266SJung-uk Kim #ifdef ACPI_DISASSEMBLER 4714a38ee6dSJung-uk Kim AcpiDmDisassemble (WalkState, AcpiDbGetDisplayOp (WalkState, Op), 4724a38ee6dSJung-uk Kim ACPI_UINT32_MAX); 47351f42badSJung-uk Kim #else 47451f42badSJung-uk Kim /* 47551f42badSJung-uk Kim * The AML Disassembler is not configured - at least we can 47651f42badSJung-uk Kim * display the opcode value and name 47751f42badSJung-uk Kim */ 47851f42badSJung-uk Kim AcpiOsPrintf ("AML Opcode: %4.4X %s\n", Op->Common.AmlOpcode, 47951f42badSJung-uk Kim AcpiPsGetOpcodeName (Op->Common.AmlOpcode)); 480a159c266SJung-uk Kim #endif 481a159c266SJung-uk Kim 482a159c266SJung-uk Kim if ((Op->Common.AmlOpcode == AML_IF_OP) || 483a159c266SJung-uk Kim (Op->Common.AmlOpcode == AML_WHILE_OP)) 484a159c266SJung-uk Kim { 485a159c266SJung-uk Kim if (WalkState->ControlState->Common.Value) 486a159c266SJung-uk Kim { 487a159c266SJung-uk Kim AcpiOsPrintf ("Predicate = [True], IF block was executed\n"); 488a159c266SJung-uk Kim } 489a159c266SJung-uk Kim else 490a159c266SJung-uk Kim { 491a159c266SJung-uk Kim AcpiOsPrintf ("Predicate = [False], Skipping IF block\n"); 492a159c266SJung-uk Kim } 493a159c266SJung-uk Kim } 494a159c266SJung-uk Kim else if (Op->Common.AmlOpcode == AML_ELSE_OP) 495a159c266SJung-uk Kim { 496a159c266SJung-uk Kim AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n"); 497a159c266SJung-uk Kim } 498a159c266SJung-uk Kim 499a159c266SJung-uk Kim /* Restore everything */ 500a159c266SJung-uk Kim 501a159c266SJung-uk Kim Op->Common.Next = Next; 502a159c266SJung-uk Kim AcpiOsPrintf ("\n"); 503a159c266SJung-uk Kim if ((AcpiGbl_DbOutputToFile) || 504a159c266SJung-uk Kim (AcpiDbgLevel & ACPI_LV_PARSE)) 505a159c266SJung-uk Kim { 506a159c266SJung-uk Kim AcpiOsPrintf ("\n"); 507a159c266SJung-uk Kim } 508a159c266SJung-uk Kim AcpiDbgLevel = OriginalDebugLevel; 509a159c266SJung-uk Kim } 510a159c266SJung-uk Kim 511a159c266SJung-uk Kim /* If we are not single stepping, just continue executing the method */ 512a159c266SJung-uk Kim 513a159c266SJung-uk Kim if (!AcpiGbl_CmSingleStep) 514a159c266SJung-uk Kim { 515a159c266SJung-uk Kim return (AE_OK); 516a159c266SJung-uk Kim } 517a159c266SJung-uk Kim 518a159c266SJung-uk Kim /* 519a159c266SJung-uk Kim * If we are executing a step-to-call command, 520a159c266SJung-uk Kim * Check if this is a method call. 521a159c266SJung-uk Kim */ 522a159c266SJung-uk Kim if (AcpiGbl_StepToNextCall) 523a159c266SJung-uk Kim { 524a159c266SJung-uk Kim if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP) 525a159c266SJung-uk Kim { 526a159c266SJung-uk Kim /* Not a method call, just keep executing */ 527a159c266SJung-uk Kim 528a159c266SJung-uk Kim return (AE_OK); 529a159c266SJung-uk Kim } 530a159c266SJung-uk Kim 531a159c266SJung-uk Kim /* Found a method call, stop executing */ 532a159c266SJung-uk Kim 533a159c266SJung-uk Kim AcpiGbl_StepToNextCall = FALSE; 534a159c266SJung-uk Kim } 535a159c266SJung-uk Kim 536a159c266SJung-uk Kim /* 537a159c266SJung-uk Kim * If the next opcode is a method call, we will "step over" it 538a159c266SJung-uk Kim * by default. 539a159c266SJung-uk Kim */ 540a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP) 541a159c266SJung-uk Kim { 542a159c266SJung-uk Kim /* Force no more single stepping while executing called method */ 543a159c266SJung-uk Kim 544a159c266SJung-uk Kim AcpiGbl_CmSingleStep = FALSE; 545a159c266SJung-uk Kim 546a159c266SJung-uk Kim /* 547a159c266SJung-uk Kim * Set the breakpoint on/before the call, it will stop execution 548a159c266SJung-uk Kim * as soon as we return 549a159c266SJung-uk Kim */ 550a159c266SJung-uk Kim WalkState->MethodBreakpoint = 1; /* Must be non-zero! */ 551a159c266SJung-uk Kim } 552a159c266SJung-uk Kim 553a159c266SJung-uk Kim 5540d84335fSJung-uk Kim AcpiExExitInterpreter (); 555a159c266SJung-uk Kim Status = AcpiDbStartCommand (WalkState, Op); 5560d84335fSJung-uk Kim AcpiExEnterInterpreter (); 557a159c266SJung-uk Kim 558a159c266SJung-uk Kim /* User commands complete, continue execution of the interrupted method */ 559a159c266SJung-uk Kim 560a159c266SJung-uk Kim return (Status); 561a159c266SJung-uk Kim } 562a159c266SJung-uk Kim 563a159c266SJung-uk Kim 564a159c266SJung-uk Kim /******************************************************************************* 565a159c266SJung-uk Kim * 56670e6ab8fSJung-uk Kim * FUNCTION: AcpiInitializeDebugger 567a159c266SJung-uk Kim * 568a159c266SJung-uk Kim * PARAMETERS: None 569a159c266SJung-uk Kim * 570a159c266SJung-uk Kim * RETURN: Status 571a159c266SJung-uk Kim * 572a159c266SJung-uk Kim * DESCRIPTION: Init and start debugger 573a159c266SJung-uk Kim * 574a159c266SJung-uk Kim ******************************************************************************/ 575a159c266SJung-uk Kim 576a159c266SJung-uk Kim ACPI_STATUS 57770e6ab8fSJung-uk Kim AcpiInitializeDebugger ( 578a159c266SJung-uk Kim void) 579a159c266SJung-uk Kim { 580a159c266SJung-uk Kim ACPI_STATUS Status; 581a159c266SJung-uk Kim 582a159c266SJung-uk Kim 58370e6ab8fSJung-uk Kim ACPI_FUNCTION_TRACE (AcpiInitializeDebugger); 584a9d8d09cSJung-uk Kim 585a9d8d09cSJung-uk Kim 586a159c266SJung-uk Kim /* Init globals */ 587a159c266SJung-uk Kim 588a159c266SJung-uk Kim AcpiGbl_DbBuffer = NULL; 589a159c266SJung-uk Kim AcpiGbl_DbFilename = NULL; 590a159c266SJung-uk Kim AcpiGbl_DbOutputToFile = FALSE; 591a159c266SJung-uk Kim 592a159c266SJung-uk Kim AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2; 593a159c266SJung-uk Kim AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; 594a159c266SJung-uk Kim AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 595a159c266SJung-uk Kim 5967cf3e94aSJung-uk Kim AcpiGbl_DbOpt_NoIniMethods = FALSE; 5973ee58df5SJung-uk Kim AcpiGbl_DbOpt_NoRegionSupport = FALSE; 598a159c266SJung-uk Kim 599a159c266SJung-uk Kim AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); 600a159c266SJung-uk Kim if (!AcpiGbl_DbBuffer) 601a159c266SJung-uk Kim { 602a9d8d09cSJung-uk Kim return_ACPI_STATUS (AE_NO_MEMORY); 603a159c266SJung-uk Kim } 6045ef50723SJung-uk Kim memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); 605a159c266SJung-uk Kim 606a159c266SJung-uk Kim /* Initial scope is the root */ 607a159c266SJung-uk Kim 608efcc2a30SJung-uk Kim AcpiGbl_DbScopeBuf [0] = AML_ROOT_PREFIX; 609a159c266SJung-uk Kim AcpiGbl_DbScopeBuf [1] = 0; 610a159c266SJung-uk Kim AcpiGbl_DbScopeNode = AcpiGbl_RootNode; 611a159c266SJung-uk Kim 612f8146b88SJung-uk Kim /* Initialize user commands loop */ 613f8146b88SJung-uk Kim 614f8146b88SJung-uk Kim AcpiGbl_DbTerminateLoop = FALSE; 615f8146b88SJung-uk Kim 616a159c266SJung-uk Kim /* 617a159c266SJung-uk Kim * If configured for multi-thread support, the debug executor runs in 618a159c266SJung-uk Kim * a separate thread so that the front end can be in another address 619a159c266SJung-uk Kim * space, environment, or even another machine. 620a159c266SJung-uk Kim */ 621a159c266SJung-uk Kim if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 622a159c266SJung-uk Kim { 623a159c266SJung-uk Kim /* These were created with one unit, grab it */ 624a159c266SJung-uk Kim 62528482948SJung-uk Kim Status = AcpiOsInitializeDebugger (); 626a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 627a159c266SJung-uk Kim { 628a159c266SJung-uk Kim AcpiOsPrintf ("Could not get debugger mutex\n"); 629a9d8d09cSJung-uk Kim return_ACPI_STATUS (Status); 630a159c266SJung-uk Kim } 631a159c266SJung-uk Kim 632a159c266SJung-uk Kim /* Create the debug execution thread to execute commands */ 633a159c266SJung-uk Kim 634f8146b88SJung-uk Kim AcpiGbl_DbThreadsTerminated = FALSE; 635f8146b88SJung-uk Kim Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD, 63670e6ab8fSJung-uk Kim AcpiDbExecuteThread, NULL); 637a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 638a159c266SJung-uk Kim { 63970e6ab8fSJung-uk Kim ACPI_EXCEPTION ((AE_INFO, Status, 64070e6ab8fSJung-uk Kim "Could not start debugger thread")); 641f8146b88SJung-uk Kim AcpiGbl_DbThreadsTerminated = TRUE; 642a9d8d09cSJung-uk Kim return_ACPI_STATUS (Status); 643a159c266SJung-uk Kim } 644a159c266SJung-uk Kim } 645f8146b88SJung-uk Kim else 646f8146b88SJung-uk Kim { 647f8146b88SJung-uk Kim AcpiGbl_DbThreadId = AcpiOsGetThreadId (); 648f8146b88SJung-uk Kim } 649a159c266SJung-uk Kim 650a9d8d09cSJung-uk Kim return_ACPI_STATUS (AE_OK); 651a159c266SJung-uk Kim } 652a159c266SJung-uk Kim 65370e6ab8fSJung-uk Kim ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger) 65470e6ab8fSJung-uk Kim 655a159c266SJung-uk Kim 656a159c266SJung-uk Kim /******************************************************************************* 657a159c266SJung-uk Kim * 65870e6ab8fSJung-uk Kim * FUNCTION: AcpiTerminateDebugger 659a159c266SJung-uk Kim * 660a159c266SJung-uk Kim * PARAMETERS: None 661a159c266SJung-uk Kim * 662a159c266SJung-uk Kim * RETURN: None 663a159c266SJung-uk Kim * 664a159c266SJung-uk Kim * DESCRIPTION: Stop debugger 665a159c266SJung-uk Kim * 666a159c266SJung-uk Kim ******************************************************************************/ 667a159c266SJung-uk Kim 668a159c266SJung-uk Kim void 66970e6ab8fSJung-uk Kim AcpiTerminateDebugger ( 670a159c266SJung-uk Kim void) 671a159c266SJung-uk Kim { 672a159c266SJung-uk Kim 673f8146b88SJung-uk Kim /* Terminate the AML Debugger */ 674f8146b88SJung-uk Kim 675f8146b88SJung-uk Kim AcpiGbl_DbTerminateLoop = TRUE; 676f8146b88SJung-uk Kim 677f8146b88SJung-uk Kim if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 678f8146b88SJung-uk Kim { 679f8146b88SJung-uk Kim /* Wait the AML Debugger threads */ 680f8146b88SJung-uk Kim 681f8146b88SJung-uk Kim while (!AcpiGbl_DbThreadsTerminated) 682f8146b88SJung-uk Kim { 683f8146b88SJung-uk Kim AcpiOsSleep (100); 684f8146b88SJung-uk Kim } 68528482948SJung-uk Kim 68628482948SJung-uk Kim AcpiOsTerminateDebugger (); 687f8146b88SJung-uk Kim } 688f8146b88SJung-uk Kim 689a159c266SJung-uk Kim if (AcpiGbl_DbBuffer) 690a159c266SJung-uk Kim { 691a159c266SJung-uk Kim AcpiOsFree (AcpiGbl_DbBuffer); 692a9d8d09cSJung-uk Kim AcpiGbl_DbBuffer = NULL; 693a159c266SJung-uk Kim } 694313a0c13SJung-uk Kim 695313a0c13SJung-uk Kim /* Ensure that debug output is now disabled */ 696313a0c13SJung-uk Kim 697313a0c13SJung-uk Kim AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; 698a159c266SJung-uk Kim } 699a159c266SJung-uk Kim 70070e6ab8fSJung-uk Kim ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger) 70170e6ab8fSJung-uk Kim 702a159c266SJung-uk Kim 703a159c266SJung-uk Kim /******************************************************************************* 704a159c266SJung-uk Kim * 705f8146b88SJung-uk Kim * FUNCTION: AcpiSetDebuggerThreadId 706a159c266SJung-uk Kim * 707f8146b88SJung-uk Kim * PARAMETERS: ThreadId - Debugger thread ID 708a159c266SJung-uk Kim * 709f8146b88SJung-uk Kim * RETURN: None 710a159c266SJung-uk Kim * 711f8146b88SJung-uk Kim * DESCRIPTION: Set debugger thread ID 712a159c266SJung-uk Kim * 713a159c266SJung-uk Kim ******************************************************************************/ 714a159c266SJung-uk Kim 715a159c266SJung-uk Kim void 716f8146b88SJung-uk Kim AcpiSetDebuggerThreadId ( 717f8146b88SJung-uk Kim ACPI_THREAD_ID ThreadId) 718a159c266SJung-uk Kim { 719f8146b88SJung-uk Kim AcpiGbl_DbThreadId = ThreadId; 720a159c266SJung-uk Kim } 721a159c266SJung-uk Kim 722f8146b88SJung-uk Kim ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId) 723