diff options
Diffstat (limited to 'sys/contrib/dev/acpica/components/debugger/dbxface.c')
-rw-r--r-- | sys/contrib/dev/acpica/components/debugger/dbxface.c | 158 |
1 files changed, 106 insertions, 52 deletions
diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c index d72ee5e..2bcd47c 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,11 +45,8 @@ #include <contrib/dev/acpica/include/accommon.h> #include <contrib/dev/acpica/include/amlcode.h> #include <contrib/dev/acpica/include/acdebug.h> -#include <contrib/dev/acpica/include/acdisasm.h> -#ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbxface") @@ -104,12 +101,10 @@ AcpiDbStartCommand ( { /* Handshake with the front-end that gets user command lines */ - Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); + + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { return (Status); @@ -140,7 +135,8 @@ AcpiDbStartCommand ( ACPI_DB_LINE_BUFFER_SIZE, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing command line")); return (Status); } } @@ -156,6 +152,40 @@ AcpiDbStartCommand ( /******************************************************************************* * + * FUNCTION: AcpiDbSignalBreakPoint + * + * PARAMETERS: WalkState - Current walk + * + * RETURN: Status + * + * DESCRIPTION: Called for AML_BREAK_POINT_OP + * + ******************************************************************************/ + +void +AcpiDbSignalBreakPoint ( + ACPI_WALK_STATE *WalkState) +{ + +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return; + } +#endif + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + AcpiGbl_CmSingleStep = TRUE; + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbSingleStep * * PARAMETERS: WalkState - Current walk @@ -179,11 +209,19 @@ AcpiDbSingleStep ( UINT32 OriginalDebugLevel; ACPI_PARSE_OBJECT *DisplayOp; ACPI_PARSE_OBJECT *ParentOp; + UINT32 AmlOffset; ACPI_FUNCTION_ENTRY (); +#ifndef ACPI_APPLICATION + if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ()) + { + return (AE_OK); + } +#endif + /* Check the abort flag */ if (AcpiGbl_AbortMethod) @@ -192,15 +230,18 @@ AcpiDbSingleStep ( return (AE_ABORT_METHOD); } + AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml, + WalkState->ParserState.AmlStart); + /* Check for single-step breakpoint */ if (WalkState->MethodBreakpoint && - (WalkState->MethodBreakpoint <= Op->Common.AmlOffset)) + (WalkState->MethodBreakpoint <= AmlOffset)) { /* Check if the breakpoint has been reached or passed */ /* Hit the breakpoint, resume single step, reset breakpoint */ - AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset); + AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -209,10 +250,10 @@ AcpiDbSingleStep ( /* Check for user breakpoint (Must be on exact Aml offset) */ else if (WalkState->UserBreakpoint && - (WalkState->UserBreakpoint == Op->Common.AmlOffset)) + (WalkState->UserBreakpoint == AmlOffset)) { AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", - Op->Common.AmlOffset); + AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -394,7 +435,7 @@ AcpiDbSingleStep ( /******************************************************************************* * - * FUNCTION: AcpiDbInitialize + * FUNCTION: AcpiInitializeDebugger * * PARAMETERS: None * @@ -405,13 +446,13 @@ AcpiDbSingleStep ( ******************************************************************************/ ACPI_STATUS -AcpiDbInitialize ( +AcpiInitializeDebugger ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (DbInitialize); + ACPI_FUNCTION_TRACE (AcpiInitializeDebugger); /* Init globals */ @@ -424,10 +465,6 @@ AcpiDbInitialize ( AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_DbOpt_Disasm = FALSE; -#ifdef ACPI_DISASSEMBLER - AcpiGbl_DbOpt_Verbose = TRUE; -#endif AcpiGbl_DbOpt_NoIniMethods = FALSE; AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); @@ -435,7 +472,7 @@ AcpiDbInitialize ( { return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); + memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE); /* Initial scope is the root */ @@ -443,6 +480,10 @@ AcpiDbInitialize ( AcpiGbl_DbScopeBuf [1] = 0; AcpiGbl_DbScopeNode = AcpiGbl_RootNode; + /* Initialize user commands loop */ + + AcpiGbl_DbTerminateLoop = FALSE; + /* * If configured for multi-thread support, the debug executor runs in * a separate thread so that the front end can be in another address @@ -452,14 +493,16 @@ AcpiDbInitialize ( { /* These were created with one unit, grab it */ - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); return_ACPI_STATUS (Status); } - Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); @@ -468,28 +511,31 @@ AcpiDbInitialize ( /* Create the debug execution thread to execute commands */ - Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL); + AcpiGbl_DbThreadsTerminated = FALSE; + Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD, + AcpiDbExecuteThread, NULL); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not start debugger thread")); + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not start debugger thread")); + AcpiGbl_DbThreadsTerminated = TRUE; return_ACPI_STATUS (Status); } } - -#ifdef ACPI_DISASSEMBLER - if (!AcpiGbl_DbOpt_Verbose) + else { - AcpiGbl_DbOpt_Disasm = TRUE; + AcpiGbl_DbThreadId = AcpiOsGetThreadId (); } -#endif return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger) + /******************************************************************************* * - * FUNCTION: AcpiDbTerminate + * FUNCTION: AcpiTerminateDebugger * * PARAMETERS: None * @@ -500,10 +546,26 @@ AcpiDbInitialize ( ******************************************************************************/ void -AcpiDbTerminate ( +AcpiTerminateDebugger ( void) { + /* Terminate the AML Debugger */ + + AcpiGbl_DbTerminateLoop = TRUE; + + if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) + { + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); + + /* Wait the AML Debugger threads */ + + while (!AcpiGbl_DbThreadsTerminated) + { + AcpiOsSleep (100); + } + } + if (AcpiGbl_DbBuffer) { AcpiOsFree (AcpiGbl_DbBuffer); @@ -515,34 +577,26 @@ AcpiDbTerminate ( AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; } +ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger) + -#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * - * FUNCTION: AcpiDbMethodEnd + * FUNCTION: AcpiSetDebuggerThreadId * - * PARAMETERS: WalkState - Current walk + * PARAMETERS: ThreadId - Debugger thread ID * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Called at method termination + * DESCRIPTION: Set debugger thread ID * ******************************************************************************/ void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState) +AcpiSetDebuggerThreadId ( + ACPI_THREAD_ID ThreadId) { - - if (!AcpiGbl_CmSingleStep) - { - return; - } - - AcpiOsPrintf ("<Method Terminating>\n"); - - AcpiDbStartCommand (WalkState, NULL); + AcpiGbl_DbThreadId = ThreadId; } -#endif -#endif /* ACPI_DEBUGGER */ +ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId) |