summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/io/acpica/debugger/dbexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/intel/io/acpica/debugger/dbexec.c')
-rw-r--r--usr/src/uts/intel/io/acpica/debugger/dbexec.c211
1 files changed, 161 insertions, 50 deletions
diff --git a/usr/src/uts/intel/io/acpica/debugger/dbexec.c b/usr/src/uts/intel/io/acpica/debugger/dbexec.c
index 4547f0e5b4..b1add758b6 100644
--- a/usr/src/uts/intel/io/acpica/debugger/dbexec.c
+++ b/usr/src/uts/intel/io/acpica/debugger/dbexec.c
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: dbexec - debugger control method execution
- * $Revision: 1.77 $
+ * $Revision: 1.83 $
*
******************************************************************************/
@@ -9,7 +9,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -153,12 +153,6 @@ AcpiDbExecutionWalk (
void *Context,
void **ReturnValue);
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-static UINT32
-AcpiDbGetCacheInfo (
- ACPI_MEMORY_LIST *Cache);
-#endif
-
/*******************************************************************************
*
@@ -181,7 +175,10 @@ AcpiDbExecuteMethod (
ACPI_STATUS Status;
ACPI_OBJECT_LIST ParamObjects;
ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
+ ACPI_HANDLE Handle;
+ ACPI_BUFFER Buffer;
UINT32 i;
+ ACPI_DEVICE_INFO *ObjInfo;
if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel)
@@ -189,34 +186,78 @@ AcpiDbExecuteMethod (
AcpiOsPrintf ("Warning: debug output is not enabled!\n");
}
- /* Are there arguments to the method? */
+ /* Get the NS node, determines existence also */
- if (Info->Args && Info->Args[0])
+ Status = AcpiGetHandle (NULL, Info->Pathname, &Handle);
+ if (ACPI_FAILURE (Status))
{
- for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++)
- {
- Params[i].Type = ACPI_TYPE_INTEGER;
- Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16);
- }
+ return (Status);
+ }
+
+ /* Get the object info for number of method parameters */
- ParamObjects.Pointer = Params;
- ParamObjects.Count = i;
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiGetObjectInfo (Handle, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
}
- else
+
+ ParamObjects.Pointer = NULL;
+ ParamObjects.Count = 0;
+
+ ObjInfo = Buffer.Pointer;
+ if (ObjInfo->Type == ACPI_TYPE_METHOD)
{
- /* Setup default parameters */
+ /* Are there arguments to the method? */
- Params[0].Type = ACPI_TYPE_INTEGER;
- Params[0].Integer.Value = 0x01020304;
+ if (Info->Args && Info->Args[0])
+ {
+ for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++)
+ {
+ Params[i].Type = ACPI_TYPE_INTEGER;
+ Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16);
+ }
- Params[1].Type = ACPI_TYPE_STRING;
- Params[1].String.Length = 12;
- Params[1].String.Pointer = "AML Debugger";
+ ParamObjects.Pointer = Params;
+ ParamObjects.Count = i;
+ }
+ else
+ {
+ /* Setup default parameters */
+
+ for (i = 0; i < ObjInfo->ParamCount; i++)
+ {
+ switch (i)
+ {
+ case 0:
+
+ Params[0].Type = ACPI_TYPE_INTEGER;
+ Params[0].Integer.Value = 0x01020304;
+ break;
+
+ case 1:
- ParamObjects.Pointer = Params;
- ParamObjects.Count = 2;
+ Params[1].Type = ACPI_TYPE_STRING;
+ Params[1].String.Length = 12;
+ Params[1].String.Pointer = "AML Debugger";
+ break;
+
+ default:
+
+ Params[i].Type = ACPI_TYPE_INTEGER;
+ Params[i].Integer.Value = i * (ACPI_INTEGER) 0x1000;
+ break;
+ }
+ }
+
+ ParamObjects.Pointer = Params;
+ ParamObjects.Count = ObjInfo->ParamCount;
+ }
}
+ ACPI_FREE (Buffer.Pointer);
+
/* Prepare for a return object of arbitrary size */
ReturnObj->Pointer = AcpiGbl_DbBuffer;
@@ -283,7 +324,7 @@ AcpiDbExecuteSetup (
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-static UINT32
+UINT32
AcpiDbGetCacheInfo (
ACPI_MEMORY_LIST *Cache)
{
@@ -426,6 +467,8 @@ AcpiDbExecute (
return;
}
+ ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+
ACPI_STRCPY (NameString, Name);
AcpiUtStrupr (NameString);
AcpiGbl_DbMethodInfo.Name = NameString;
@@ -509,9 +552,21 @@ AcpiDbMethodThread (
ACPI_STATUS Status;
ACPI_DB_METHOD_INFO *Info = Context;
UINT32 i;
+ UINT8 Allow;
ACPI_BUFFER ReturnObj;
+ if (Info->InitArgs)
+ {
+ AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr);
+ AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr);
+ }
+
+ if (Info->Threads && (Info->NumCreated < Info->NumThreads))
+ {
+ Info->Threads[Info->NumCreated++] = (UINT32) AcpiOsGetThreadId();
+ }
+
for (i = 0; i < Info->NumLoops; i++)
{
Status = AcpiDbExecuteMethod (Info, &ReturnObj);
@@ -525,12 +580,12 @@ AcpiDbMethodThread (
}
}
+#if 0
if ((i % 100) == 0)
{
- AcpiOsPrintf ("%d executions\n", i);
+ AcpiOsPrintf ("%d executions, Thread 0x%x\n", i, AcpiOsGetThreadId ());
}
-#if 0
if (ReturnObj.Length)
{
AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
@@ -542,11 +597,26 @@ AcpiDbMethodThread (
/* Signal our completion */
- Status = AcpiOsSignalSemaphore (Info->ThreadGate, 1);
- if (ACPI_FAILURE (Status))
+ Allow = 0;
+ (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER);
+ Info->NumCompleted++;
+
+ if (Info->NumCompleted == Info->NumThreads)
{
- AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n",
- AcpiFormatException (Status));
+ /* Do signal for main thread once only */
+ Allow = 1;
+ }
+
+ (void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1);
+
+ if (Allow)
+ {
+ Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n",
+ AcpiFormatException (Status));
+ }
}
}
@@ -575,8 +645,9 @@ AcpiDbCreateExecutionThreads (
UINT32 NumThreads;
UINT32 NumLoops;
UINT32 i;
- ACPI_MUTEX ThreadGate;
-
+ UINT32 Size;
+ ACPI_MUTEX MainThreadGate;
+ ACPI_MUTEX ThreadCompleteGate;
/* Get the arguments */
@@ -590,23 +661,64 @@ AcpiDbCreateExecutionThreads (
return;
}
- /* Create the synchronization semaphore */
+ /*
+ * Create the semaphore for synchronization of
+ * the created threads with the main thread.
+ */
+ Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n",
+ AcpiFormatException (Status));
+ return;
+ }
- Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate);
+ /*
+ * Create the semaphore for synchronization
+ * between the created threads.
+ */
+ Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate);
if (ACPI_FAILURE (Status))
{
- AcpiOsPrintf ("Could not create semaphore, %s\n",
+ AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n",
AcpiFormatException (Status));
+ (void) AcpiOsDeleteSemaphore (MainThreadGate);
+ return;
+ }
+
+ ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+
+ /* Array to store IDs of threads */
+
+ AcpiGbl_DbMethodInfo.NumThreads = NumThreads;
+ Size = 4 * AcpiGbl_DbMethodInfo.NumThreads;
+ AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size);
+ if (AcpiGbl_DbMethodInfo.Threads == NULL)
+ {
+ AcpiOsPrintf ("No memory for thread IDs array\n");
+ (void) AcpiOsDeleteSemaphore (MainThreadGate);
+ (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
return;
}
+ ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size);
/* Setup the context to be passed to each thread */
AcpiGbl_DbMethodInfo.Name = MethodNameArg;
- AcpiGbl_DbMethodInfo.Args = NULL;
AcpiGbl_DbMethodInfo.Flags = 0;
AcpiGbl_DbMethodInfo.NumLoops = NumLoops;
- AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate;
+ AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate;
+ AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate;
+
+ /* Init arguments to be passed to method */
+
+ AcpiGbl_DbMethodInfo.InitArgs = 1;
+ AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments;
+ AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr;
+ AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr;
+ AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr;
+ AcpiGbl_DbMethodInfo.Arguments[3] = NULL;
+ AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr);
AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
@@ -627,20 +739,19 @@ AcpiDbCreateExecutionThreads (
/* Wait for all threads to complete */
- i = NumThreads;
- while (i) /* Brain damage for host OSs that only support wait of 1 unit */
- {
- Status = AcpiOsWaitSemaphore (ThreadGate, 1, ACPI_WAIT_FOREVER);
- i--;
- }
-
- /* Cleanup and exit */
-
- (void) AcpiOsDeleteSemaphore (ThreadGate);
+ (void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER);
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads);
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+ /* Cleanup and exit */
+
+ (void) AcpiOsDeleteSemaphore (MainThreadGate);
+ (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
+
+ AcpiOsFree (AcpiGbl_DbMethodInfo.Threads);
+ AcpiGbl_DbMethodInfo.Threads = NULL;
}
#endif /* ACPI_DEBUGGER */