summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2016-11-03 01:17:13 +0800
committerLv Zheng <lv.zheng@intel.com>2016-11-03 01:17:13 +0800
commite76eb8b36ace880e4d475880db1128a206e57b6f (patch)
tree83b5b9a652d3dc85eaca7785891d71054f94e11c
parentf0071e71698ac492bc9abb46d671d3bea2d3ffbc (diff)
downloadacpica-e76eb8b36ace880e4d475880db1128a206e57b6f.tar.gz
Debugger: Convert some mechanisms to OSPM specific
The following mechanisms are OSPM specific: 1. Redirect output destination to console: no file redirection will be needed by an in-kernel debugger, there is even no file can be accessed when the debugger is running in the kernel mode. 2. Output command prompts: programs other than acpiexec can have different prompt characters and the prompt characters may be implemented as a special character sequence to form a char device IO protocol. 3. Command ready/complete handshake: OSPM debugger may wait more conditions to implement OSPM specific semantics (for example, FIFO full/empty conditions for O_NONBLOCK or IO open/close conditions). Leaving such OSPM specific stuffs in the ACPICA debugger core blocks Linux debugger IO driver implementation. Several new OSL APIs are provided by this patch: 1. AcpiOsInitializeDebugger: initialize debugger. 2. AcpiOsTerminateDebugger: reversal of AcpiOsInitializeDebugger. 3. AcpiOsWaitCommandReady: putting debugger task into wait state when a command is not ready. OSPMs can terminate command loop by returning AE_CTRL_TERMINATE from this API. Normally, wait_event() or WaitForMultipleObject() may be used to implement this API. 4. AcpiOsNotifyCommandComplete: putting user task into running state when a command has been completed. OSPMs can terminate command loop by returning AE_CTRL_TERMINATE from this API. Normally, wake_up() or SetEvent() may be used to implement this API. This patch also converts current command signaling implementation into a generic debugger layer (osgendbg.c) to be used by the existing OSPMs or acpiexec, in return, Linux can have chance to implement its own command handshake mechanism. This patch also implements acpiexec batch mode in a multi-threading mode comaptible style as a demo (this can be confirmed by configuring acpiexec into DEBUGGER_MULTI_THREADED mode where the batch mode is still working). Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rwxr-xr-xgenerate/msvc/AcpiExec.dsp4
-rwxr-xr-xgenerate/msvc9/AcpiExec.vcproj4
-rw-r--r--generate/unix/acpiexec/Makefile1
-rw-r--r--source/components/debugger/dbinput.c111
-rw-r--r--source/components/debugger/dbxface.c70
-rw-r--r--source/components/utilities/utmutex.c19
-rw-r--r--source/include/acdebug.h3
-rw-r--r--source/include/acglobal.h5
-rw-r--r--source/include/acpiosxf.h26
-rw-r--r--source/include/acpixf.h13
-rw-r--r--source/include/platform/aclinux.h2
-rw-r--r--source/include/platform/aclinuxex.h14
-rw-r--r--source/os_specific/service_layers/osgendbg.c438
-rw-r--r--source/tools/acpiexec/aemain.c65
14 files changed, 544 insertions, 231 deletions
diff --git a/generate/msvc/AcpiExec.dsp b/generate/msvc/AcpiExec.dsp
index 95f1b97e5..856652303 100755
--- a/generate/msvc/AcpiExec.dsp
+++ b/generate/msvc/AcpiExec.dsp
@@ -614,6 +614,10 @@ SOURCE=..\..\source\common\getopt.c
# End Source File
# Begin Source File
+SOURCE=..\..\source\os_specific\service_layers\osgendbg.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\source\os_specific\service_layers\oswindir.c
# End Source File
# Begin Source File
diff --git a/generate/msvc9/AcpiExec.vcproj b/generate/msvc9/AcpiExec.vcproj
index bc2f6e919..245286cf4 100755
--- a/generate/msvc9/AcpiExec.vcproj
+++ b/generate/msvc9/AcpiExec.vcproj
@@ -735,6 +735,10 @@
>
</File>
<File
+ RelativePath="..\..\source\os_specific\service_layers\osgendbg.c"
+ >
+ </File>
+ <File
RelativePath="..\..\source\os_specific\service_layers\oswindir.c"
>
</File>
diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile
index 62850ac27..3191850ad 100644
--- a/generate/unix/acpiexec/Makefile
+++ b/generate/unix/acpiexec/Makefile
@@ -163,6 +163,7 @@ OBJECTS = \
$(OBJDIR)/nsxfeval.o\
$(OBJDIR)/nsxfname.o\
$(OBJDIR)/nsxfobj.o\
+ $(OBJDIR)/osgendbg.o\
$(OBJDIR)/osunixxf.o\
$(OBJDIR)/psargs.o\
$(OBJDIR)/psloop.o\
diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c
index f41ad81fd..6bcb84be5 100644
--- a/source/components/debugger/dbinput.c
+++ b/source/components/debugger/dbinput.c
@@ -136,10 +136,6 @@ AcpiDbMatchCommand (
char *UserCommand);
static void
-AcpiDbSingleThread (
- void);
-
-static void
AcpiDbDisplayCommandInfo (
const char *Command,
BOOLEAN DisplayAll);
@@ -1303,61 +1299,17 @@ void ACPI_SYSTEM_XFACE
AcpiDbExecuteThread (
void *Context)
{
- ACPI_STATUS Status = AE_OK;
- ACPI_STATUS MStatus;
-
-
- while (Status != AE_CTRL_TERMINATE && !AcpiGbl_DbTerminateLoop)
- {
- AcpiGbl_MethodExecuting = FALSE;
- AcpiGbl_StepToNextCall = FALSE;
- MStatus = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
- ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (MStatus))
- {
- return;
- }
-
- Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
-
- AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
- }
+ (void) AcpiDbUserCommands ();
AcpiGbl_DbThreadsTerminated = TRUE;
}
/*******************************************************************************
*
- * FUNCTION: AcpiDbSingleThread
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Debugger execute thread. Waits for a command line, then
- * simply dispatches it.
- *
- ******************************************************************************/
-
-static void
-AcpiDbSingleThread (
- void)
-{
-
- AcpiGbl_MethodExecuting = FALSE;
- AcpiGbl_StepToNextCall = FALSE;
-
- (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: AcpiDbUserCommands
*
- * PARAMETERS: Prompt - User prompt (depends on mode)
- * Op - Current executing parse op
+ * PARAMETERS: None
*
* RETURN: None
*
@@ -1368,8 +1320,7 @@ AcpiDbSingleThread (
ACPI_STATUS
AcpiDbUserCommands (
- char Prompt,
- ACPI_PARSE_OBJECT *Op)
+ void)
{
ACPI_STATUS Status = AE_OK;
@@ -1380,55 +1331,33 @@ AcpiDbUserCommands (
while (!AcpiGbl_DbTerminateLoop)
{
- /* Force output to console until a command is entered */
-
- AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
-
- /* Different prompt if method is executing */
+ /* Wait the readiness of the command */
- if (!AcpiGbl_MethodExecuting)
- {
- AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
- }
- else
+ Status = AcpiOsWaitCommandReady ();
+ if (ACPI_FAILURE (Status))
{
- AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+ break;
}
- /* Get the user input line */
+ /* Just call to the command line interpreter */
- Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
- ACPI_DB_LINE_BUFFER_SIZE, NULL);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
- return (Status);
- }
+ AcpiGbl_MethodExecuting = FALSE;
+ AcpiGbl_StepToNextCall = FALSE;
- /* Check for single or multithreaded debug */
+ (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
- if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
- {
- /*
- * Signal the debug thread that we have a command to execute,
- * and wait for the command to complete.
- */
- AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
-
- Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
- ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- else
- {
- /* Just call to the command line interpreter */
+ /* Notify the completion of the command */
- AcpiDbSingleThread ();
+ Status = AcpiOsNotifyCommandComplete ();
+ if (ACPI_FAILURE (Status))
+ {
+ break;
}
}
+ if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
+ }
return (Status);
}
diff --git a/source/components/debugger/dbxface.c b/source/components/debugger/dbxface.c
index fe803bc9a..6a1c231f9 100644
--- a/source/components/debugger/dbxface.c
+++ b/source/components/debugger/dbxface.c
@@ -167,50 +167,23 @@ AcpiDbStartCommand (
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 */
+ /* Notify the completion of the command */
- AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
-
- Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
- ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- else
+ Status = AcpiOsNotifyCommandComplete ();
+ if (ACPI_FAILURE (Status))
{
- /* Single threaded, we must get a command line ourselves */
-
- /* Force output to console until a command is entered */
-
- AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
-
- /* Different prompt if method is executing */
-
- if (!AcpiGbl_MethodExecuting)
- {
- AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
- }
- else
- {
- AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
- }
+ goto ErrorExit;
+ }
- /* Get the user input line */
+ /* Wait the readiness of the command */
- Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
- ACPI_DB_LINE_BUFFER_SIZE, NULL);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "While parsing command line"));
- return (Status);
- }
+ Status = AcpiOsWaitCommandReady ();
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
}
Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
@@ -218,6 +191,12 @@ AcpiDbStartCommand (
/* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
+ErrorExit:
+ if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While parsing/handling command line"));
+ }
return (Status);
}
@@ -565,16 +544,7 @@ AcpiInitializeDebugger (
{
/* These were created with one unit, grab it */
- Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
- ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsPrintf ("Could not get debugger mutex\n");
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
- ACPI_WAIT_FOREVER);
+ Status = AcpiOsInitializeDebugger ();
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not get debugger mutex\n");
@@ -628,14 +598,14 @@ AcpiTerminateDebugger (
if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
{
- AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
-
/* Wait the AML Debugger threads */
while (!AcpiGbl_DbThreadsTerminated)
{
AcpiOsSleep (100);
}
+
+ AcpiOsTerminateDebugger ();
}
if (AcpiGbl_DbBuffer)
diff --git a/source/components/utilities/utmutex.c b/source/components/utilities/utmutex.c
index d80a57c8d..aaf366065 100644
--- a/source/components/utilities/utmutex.c
+++ b/source/components/utilities/utmutex.c
@@ -201,19 +201,6 @@ AcpiUtMutexInitialize (
return_ACPI_STATUS (Status);
}
-#ifdef ACPI_DEBUGGER
-
- /* Debugger Support */
-
- Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete);
-#endif
-
return_ACPI_STATUS (Status);
}
@@ -259,12 +246,6 @@ AcpiUtMutexTerminate (
/* Delete the reader/writer lock */
AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
-
-#ifdef ACPI_DEBUGGER
- AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
- AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
-#endif
-
return_VOID;
}
diff --git a/source/include/acdebug.h b/source/include/acdebug.h
index c7cfc54f3..ac44660ec 100644
--- a/source/include/acdebug.h
+++ b/source/include/acdebug.h
@@ -493,8 +493,7 @@ AcpiDbExecuteThread (
ACPI_STATUS
AcpiDbUserCommands (
- char Prompt,
- ACPI_PARSE_OBJECT *Op);
+ void);
char *
AcpiDbGetNextToken (
diff --git a/source/include/acglobal.h b/source/include/acglobal.h
index eb48d408d..d9817411c 100644
--- a/source/include/acglobal.h
+++ b/source/include/acglobal.h
@@ -403,7 +403,6 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList);
#ifdef ACPI_DEBUGGER
ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE);
-ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE);
ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID);
ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods);
@@ -422,7 +421,6 @@ ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARG
/* These buffers should all be the same size */
-ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]);
ACPI_GLOBAL (char, AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]);
ACPI_GLOBAL (char, AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]);
ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]);
@@ -437,9 +435,6 @@ ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc);
ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes);
ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects);
-ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandReady);
-ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandComplete);
-
#endif /* ACPI_DEBUGGER */
#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER)
diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h
index 60d61f119..c71fecc1e 100644
--- a/source/include/acpiosxf.h
+++ b/source/include/acpiosxf.h
@@ -554,7 +554,7 @@ AcpiOsRedirectOutput (
/*
- * Debug input
+ * Debug IO
*/
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine
ACPI_STATUS
@@ -564,6 +564,30 @@ AcpiOsGetLine (
UINT32 *BytesRead);
#endif
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger
+ACPI_STATUS
+AcpiOsInitializeDebugger (
+ void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger
+void
+AcpiOsTerminateDebugger (
+ void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitCommandReady
+ACPI_STATUS
+AcpiOsWaitCommandReady (
+ void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsNotifyCommandComplete
+ACPI_STATUS
+AcpiOsNotifyCommandComplete (
+ void);
+#endif
+
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint
void
AcpiOsTracePoint (
diff --git a/source/include/acpixf.h b/source/include/acpixf.h
index 8efd75978..a80827237 100644
--- a/source/include/acpixf.h
+++ b/source/include/acpixf.h
@@ -365,6 +365,15 @@ ACPI_INIT_GLOBAL (UINT32, AcpiDbgLayer, ACPI_COMPONENT_DEFAULT);
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisplayDebugTimer, FALSE);
/*
+ * Debugger command handshake globals. Host OSes need to access these
+ * variables to implement their own command handshake mechanism.
+ */
+#ifdef ACPI_DEBUGGER
+ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE);
+ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]);
+#endif
+
+/*
* Other miscellaneous globals
*/
ACPI_GLOBAL (ACPI_TABLE_FADT, AcpiGbl_FADT);
@@ -1334,6 +1343,10 @@ AcpiTerminateDebugger (
void);
void
+AcpiRunDebugger (
+ char *BatchBuffer);
+
+void
AcpiSetDebuggerThreadId (
ACPI_THREAD_ID ThreadId);
diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h
index 6f7c5775e..8d0b56fcb 100644
--- a/source/include/platform/aclinux.h
+++ b/source/include/platform/aclinux.h
@@ -225,6 +225,8 @@
*/
#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable
#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable
+#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger
+#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger
/*
* OSL interfaces used by utilities
diff --git a/source/include/platform/aclinuxex.h b/source/include/platform/aclinuxex.h
index 7f24989c9..c39672d43 100644
--- a/source/include/platform/aclinuxex.h
+++ b/source/include/platform/aclinuxex.h
@@ -216,6 +216,20 @@ AcpiOsReadable (
return TRUE;
}
+static inline ACPI_STATUS
+AcpiOsInitializeDebugger (
+ void)
+{
+ return AE_OK;
+}
+
+static inline void
+AcpiOsTerminateDebugger (
+ void)
+{
+ return;
+}
+
/*
* OSL interfaces added by Linux
diff --git a/source/os_specific/service_layers/osgendbg.c b/source/os_specific/service_layers/osgendbg.c
new file mode 100644
index 000000000..10791d871
--- /dev/null
+++ b/source/os_specific/service_layers/osgendbg.c
@@ -0,0 +1,438 @@
+/******************************************************************************
+ *
+ * Module Name: osgendbg - Generic debugger command singalling
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acdebug.h"
+
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("osgendbg")
+
+
+/* Local prototypes */
+
+static void
+AcpiDbRunRemoteDebugger (
+ char *BatchBuffer);
+
+
+static ACPI_MUTEX AcpiGbl_DbCommandReady;
+static ACPI_MUTEX AcpiGbl_DbCommandComplete;
+static BOOLEAN AcpiGbl_DbCommandSignalsInitialized = FALSE;
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiDbRunRemoteDebugger
+ *
+ * PARAMETERS: BatchBuffer - Buffer containing commands running in
+ * the batch mode
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Run multi-threading debugger remotely
+ *
+ *****************************************************************************/
+
+static void
+AcpiDbRunRemoteDebugger (
+ char *BatchBuffer)
+{
+ ACPI_STATUS Status;
+ char *Ptr = BatchBuffer;
+ char *Cmd = Ptr;
+
+
+ while (!AcpiGbl_DbTerminateLoop)
+ {
+ if (BatchBuffer)
+ {
+ if (*Ptr)
+ {
+ while (*Ptr)
+ {
+ if (*Ptr == ',')
+ {
+ /* Convert commas to spaces */
+ *Ptr = ' ';
+ }
+ else if (*Ptr == ';')
+ {
+ *Ptr = '\0';
+ continue;
+ }
+
+ Ptr++;
+ }
+
+ strcpy (AcpiGbl_DbLineBuf, Cmd);
+ Ptr++;
+ Cmd = Ptr;
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ /* Force output to console until a command is entered */
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+ /* Different prompt if method is executing */
+
+ if (!AcpiGbl_MethodExecuting)
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+ }
+ else
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+ }
+
+ /* Get the user input line */
+
+ Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+ ACPI_DB_LINE_BUFFER_SIZE, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+
+ /*
+ * Signal the debug thread that we have a command to execute,
+ * and wait for the command to complete.
+ */
+ AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
+
+ Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
+ ACPI_WAIT_FOREVER);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWaitCommandReady
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Negotiate with the debugger foreground thread (the user
+ * thread) to wait the readiness of a command.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWaitCommandReady (
+ void)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
+ {
+ Status = AE_TIME;
+
+ while (Status == AE_TIME)
+ {
+ if (AcpiGbl_DbTerminateLoop)
+ {
+ Status = AE_CTRL_TERMINATE;
+ }
+ else
+ {
+ Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, 1000);
+ }
+ }
+ }
+ else
+ {
+ /* Force output to console until a command is entered */
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+ /* Different prompt if method is executing */
+
+ if (!AcpiGbl_MethodExecuting)
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+ }
+ else
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+ }
+
+ /* Get the user input line */
+
+ Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+ ACPI_DB_LINE_BUFFER_SIZE, NULL);
+ }
+
+ if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While parsing/handling command line"));
+ }
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsNotifyCommandComplete
+ *
+ * PARAMETERS: void
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Negotiate with the debugger foreground thread (the user
+ * thread) to notify the completion of a command.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsNotifyCommandComplete (
+ void)
+{
+
+ if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
+ {
+ AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
+ }
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsInitializeDebugger
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize OSPM specific part of the debugger
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsInitializeDebugger (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ /* Create command signals */
+
+ Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorReady;
+ }
+
+ /* Initialize the states of the command signals */
+
+ Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
+ ACPI_WAIT_FOREVER);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorComplete;
+ }
+ Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
+ ACPI_WAIT_FOREVER);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorComplete;
+ }
+
+ AcpiGbl_DbCommandSignalsInitialized = TRUE;
+ return (Status);
+
+ErrorComplete:
+ AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
+ErrorReady:
+ AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsTerminateDebugger
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Terminate signals used by the multi-threading debugger
+ *
+ *****************************************************************************/
+
+void
+AcpiOsTerminateDebugger (
+ void)
+{
+
+ if (AcpiGbl_DbCommandSignalsInitialized)
+ {
+ AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
+ AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
+ }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiRunDebugger
+ *
+ * PARAMETERS: BatchBuffer - Buffer containing commands running in
+ * the batch mode
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Run a local/remote debugger
+ *
+ *****************************************************************************/
+
+void
+AcpiRunDebugger (
+ char *BatchBuffer)
+{
+ /* Check for single or multithreaded debug */
+
+ if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
+ {
+ AcpiDbRunRemoteDebugger (BatchBuffer);
+ }
+ else
+ {
+ AcpiDbUserCommands ();
+ }
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRunDebugger)
diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c
index 2b3f81020..6ed8f3be8 100644
--- a/source/tools/acpiexec/aemain.c
+++ b/source/tools/acpiexec/aemain.c
@@ -138,10 +138,6 @@ AeDoOptions (
int argc,
char **argv);
-static void
-AcpiDbRunBatchMode (
- void);
-
#define AE_BUFFER_SIZE 1024
#define ASL_MAX_FILES 256
@@ -735,12 +731,12 @@ EnterDebugger:
default:
case AE_MODE_COMMAND_LOOP:
- AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL);
+ AcpiRunDebugger (NULL);
break;
case AE_MODE_BATCH_MULTIPLE:
- AcpiDbRunBatchMode ();
+ AcpiRunDebugger (BatchBuffer);
break;
case AE_MODE_BATCH_SINGLE:
@@ -751,12 +747,7 @@ EnterDebugger:
/* Shut down the debugger and ACPICA */
-#if 0
-
- /* Temporarily removed */
AcpiTerminateDebugger ();
- (void) AcpiTerminate ();
-#endif
NormalExit:
ExitCode = 0;
@@ -765,55 +756,3 @@ ErrorExit:
(void) AcpiOsTerminate ();
return (ExitCode);
}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiDbRunBatchMode
- *
- * PARAMETERS: BatchCommandLine - A semicolon separated list of commands
- * to be executed.
- * Use only commas to separate elements of
- * particular command.
- * RETURN: None
- *
- * DESCRIPTION: For each command of list separated by ';' prepare the command
- * buffer and pass it to AcpiDbCommandDispatch.
- *
- *****************************************************************************/
-
-static void
-AcpiDbRunBatchMode (
- void)
-{
- char *Ptr = BatchBuffer;
- char *Cmd = Ptr;
- UINT8 Run = 0;
-
-
- AcpiGbl_MethodExecuting = FALSE;
- AcpiGbl_StepToNextCall = FALSE;
-
- while (*Ptr)
- {
- if (*Ptr == ',')
- {
- /* Convert commas to spaces */
- *Ptr = ' ';
- }
- else if (*Ptr == ';')
- {
- *Ptr = '\0';
- Run = 1;
- }
-
- Ptr++;
-
- if (Run || (*Ptr == '\0'))
- {
- (void) AcpiDbCommandDispatch (Cmd, NULL, NULL);
- Run = 0;
- Cmd = Ptr;
- }
- }
-}