diff options
| author | Dana Myers <Dana.Myers@Sun.COM> | 2008-10-15 19:26:19 -0400 |
|---|---|---|
| committer | Dana Myers <Dana.Myers@Sun.COM> | 2008-10-15 19:26:19 -0400 |
| commit | db2bae3047e71d795bde12e3baa621f4b6cc8930 (patch) | |
| tree | 6f7ced35318bced4805171292ec76a5229f3e78a /usr/src/uts/intel/io/acpica/debugger/dbexec.c | |
| parent | 25351652d920ae27c5a56c199da581033ce763f6 (diff) | |
| download | illumos-joyent-db2bae3047e71d795bde12e3baa621f4b6cc8930.tar.gz | |
6464695 acpica: update to Intel ACPI CA 20080829
6747548 acpica: must check size of buffers returned from AcpiEvaluateObject()
--HG--
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsfield.c => usr/src/uts/intel/io/acpica/dispatcher/dsfield.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsinit.c => usr/src/uts/intel/io/acpica/dispatcher/dsinit.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsmethod.c => usr/src/uts/intel/io/acpica/dispatcher/dsmethod.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsmthdat.c => usr/src/uts/intel/io/acpica/dispatcher/dsmthdat.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsobject.c => usr/src/uts/intel/io/acpica/dispatcher/dsobject.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsopcode.c => usr/src/uts/intel/io/acpica/dispatcher/dsopcode.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dsutils.c => usr/src/uts/intel/io/acpica/dispatcher/dsutils.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dswexec.c => usr/src/uts/intel/io/acpica/dispatcher/dswexec.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dswload.c => usr/src/uts/intel/io/acpica/dispatcher/dswload.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dswscope.c => usr/src/uts/intel/io/acpica/dispatcher/dswscope.c
rename : usr/src/uts/intel/io/acpica/interpreter/dispatcher/dswstate.c => usr/src/uts/intel/io/acpica/dispatcher/dswstate.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exconfig.c => usr/src/uts/intel/io/acpica/executer/exconfig.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exconvrt.c => usr/src/uts/intel/io/acpica/executer/exconvrt.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/excreate.c => usr/src/uts/intel/io/acpica/executer/excreate.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exdump.c => usr/src/uts/intel/io/acpica/executer/exdump.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exfield.c => usr/src/uts/intel/io/acpica/executer/exfield.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exfldio.c => usr/src/uts/intel/io/acpica/executer/exfldio.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exmisc.c => usr/src/uts/intel/io/acpica/executer/exmisc.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exmutex.c => usr/src/uts/intel/io/acpica/executer/exmutex.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exnames.c => usr/src/uts/intel/io/acpica/executer/exnames.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exoparg1.c => usr/src/uts/intel/io/acpica/executer/exoparg1.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exoparg2.c => usr/src/uts/intel/io/acpica/executer/exoparg2.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exoparg3.c => usr/src/uts/intel/io/acpica/executer/exoparg3.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exoparg6.c => usr/src/uts/intel/io/acpica/executer/exoparg6.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exprep.c => usr/src/uts/intel/io/acpica/executer/exprep.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exregion.c => usr/src/uts/intel/io/acpica/executer/exregion.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exresnte.c => usr/src/uts/intel/io/acpica/executer/exresnte.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exresolv.c => usr/src/uts/intel/io/acpica/executer/exresolv.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exresop.c => usr/src/uts/intel/io/acpica/executer/exresop.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exstore.c => usr/src/uts/intel/io/acpica/executer/exstore.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exstoren.c => usr/src/uts/intel/io/acpica/executer/exstoren.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exstorob.c => usr/src/uts/intel/io/acpica/executer/exstorob.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exsystem.c => usr/src/uts/intel/io/acpica/executer/exsystem.c
rename : usr/src/uts/intel/io/acpica/interpreter/executer/exutils.c => usr/src/uts/intel/io/acpica/executer/exutils.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psargs.c => usr/src/uts/intel/io/acpica/parser/psargs.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psloop.c => usr/src/uts/intel/io/acpica/parser/psloop.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psopcode.c => usr/src/uts/intel/io/acpica/parser/psopcode.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psparse.c => usr/src/uts/intel/io/acpica/parser/psparse.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psscope.c => usr/src/uts/intel/io/acpica/parser/psscope.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/pstree.c => usr/src/uts/intel/io/acpica/parser/pstree.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psutils.c => usr/src/uts/intel/io/acpica/parser/psutils.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/pswalk.c => usr/src/uts/intel/io/acpica/parser/pswalk.c
rename : usr/src/uts/intel/io/acpica/interpreter/parser/psxface.c => usr/src/uts/intel/io/acpica/parser/psxface.c
Diffstat (limited to 'usr/src/uts/intel/io/acpica/debugger/dbexec.c')
| -rw-r--r-- | usr/src/uts/intel/io/acpica/debugger/dbexec.c | 211 |
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 */ |
