dbexec.c revision 102550
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dbexec - debugger control method execution 4102550Siwasaki * $Revision: 44 $ 567754Smsmith * 667754Smsmith ******************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 1291116Smsmith * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith 11867754Smsmith#include "acpi.h" 11967754Smsmith#include "acdebug.h" 12067754Smsmith 121102550Siwasaki#ifdef ACPI_DEBUGGER 12267754Smsmith 123102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 12491116Smsmith ACPI_MODULE_NAME ("dbexec") 12567754Smsmith 12667754Smsmith 12799679Siwasakistatic ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; 12867754Smsmith 12967754Smsmith 13067754Smsmith/******************************************************************************* 13167754Smsmith * 13267754Smsmith * FUNCTION: AcpiDbExecuteMethod 13367754Smsmith * 13467754Smsmith * PARAMETERS: Info - Valid info segment 13567754Smsmith * ReturnObj - Where to put return object 13667754Smsmith * 13767754Smsmith * RETURN: Status 13867754Smsmith * 13967754Smsmith * DESCRIPTION: Execute a control method. 14067754Smsmith * 14167754Smsmith ******************************************************************************/ 14267754Smsmith 14367754SmsmithACPI_STATUS 14467754SmsmithAcpiDbExecuteMethod ( 14591116Smsmith ACPI_DB_METHOD_INFO *Info, 14667754Smsmith ACPI_BUFFER *ReturnObj) 14767754Smsmith{ 14867754Smsmith ACPI_STATUS Status; 14967754Smsmith ACPI_OBJECT_LIST ParamObjects; 15067754Smsmith ACPI_OBJECT Params[MTH_NUM_ARGS]; 15167754Smsmith UINT32 i; 15267754Smsmith 15367754Smsmith 15483174Smsmith if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) 15567754Smsmith { 15667754Smsmith AcpiOsPrintf ("Warning: debug output is not enabled!\n"); 15767754Smsmith } 15867754Smsmith 15967754Smsmith /* Are there arguments to the method? */ 16067754Smsmith 16167754Smsmith if (Info->Args && Info->Args[0]) 16267754Smsmith { 16367754Smsmith for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++) 16467754Smsmith { 16571867Smsmith Params[i].Type = ACPI_TYPE_INTEGER; 16691116Smsmith Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); 16767754Smsmith } 16867754Smsmith 16967754Smsmith ParamObjects.Pointer = Params; 17067754Smsmith ParamObjects.Count = i; 17167754Smsmith } 17267754Smsmith else 17367754Smsmith { 17467754Smsmith /* Setup default parameters */ 17567754Smsmith 17671867Smsmith Params[0].Type = ACPI_TYPE_INTEGER; 17771867Smsmith Params[0].Integer.Value = 0x01020304; 17867754Smsmith 17967754Smsmith Params[1].Type = ACPI_TYPE_STRING; 18067754Smsmith Params[1].String.Length = 12; 18167754Smsmith Params[1].String.Pointer = "AML Debugger"; 18267754Smsmith 18367754Smsmith ParamObjects.Pointer = Params; 18467754Smsmith ParamObjects.Count = 2; 18567754Smsmith } 18667754Smsmith 18767754Smsmith /* Prepare for a return object of arbitrary size */ 18867754Smsmith 18983174Smsmith ReturnObj->Pointer = AcpiGbl_DbBuffer; 19083174Smsmith ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; 19167754Smsmith 19267754Smsmith /* Do the actual method execution */ 19367754Smsmith 19467754Smsmith Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); 19567754Smsmith 19667754Smsmith AcpiGbl_CmSingleStep = FALSE; 19767754Smsmith AcpiGbl_MethodExecuting = FALSE; 19867754Smsmith 19967754Smsmith return (Status); 20067754Smsmith} 20167754Smsmith 20267754Smsmith 20367754Smsmith/******************************************************************************* 20467754Smsmith * 20567754Smsmith * FUNCTION: AcpiDbExecuteSetup 20667754Smsmith * 20767754Smsmith * PARAMETERS: Info - Valid method info 20867754Smsmith * 20967754Smsmith * RETURN: Status 21067754Smsmith * 21167754Smsmith * DESCRIPTION: Setup info segment prior to method execution 21267754Smsmith * 21367754Smsmith ******************************************************************************/ 21467754Smsmith 21567754Smsmithvoid 21667754SmsmithAcpiDbExecuteSetup ( 21799679Siwasaki ACPI_DB_METHOD_INFO *Info) 21867754Smsmith{ 21967754Smsmith 22067754Smsmith /* Catenate the current scope to the supplied name */ 22167754Smsmith 22267754Smsmith Info->Pathname[0] = 0; 22367754Smsmith if ((Info->Name[0] != '\\') && 22467754Smsmith (Info->Name[0] != '/')) 22567754Smsmith { 22691116Smsmith ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); 22767754Smsmith } 22867754Smsmith 22991116Smsmith ACPI_STRCAT (Info->Pathname, Info->Name); 23067754Smsmith AcpiDbPrepNamestring (Info->Pathname); 23167754Smsmith 23291116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 23367754Smsmith AcpiOsPrintf ("Executing %s\n", Info->Pathname); 23467754Smsmith 23567754Smsmith if (Info->Flags & EX_SINGLE_STEP) 23667754Smsmith { 23767754Smsmith AcpiGbl_CmSingleStep = TRUE; 23891116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 23967754Smsmith } 24067754Smsmith 24167754Smsmith else 24267754Smsmith { 24367754Smsmith /* No single step, allow redirection to a file */ 24467754Smsmith 24591116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 24667754Smsmith } 24767754Smsmith} 24867754Smsmith 24967754Smsmith 25067754Smsmith/******************************************************************************* 25167754Smsmith * 25282367Smsmith * FUNCTION: AcpiDbGetOutstandingAllocations 25382367Smsmith * 25482367Smsmith * PARAMETERS: None 25582367Smsmith * 25682367Smsmith * RETURN: Current global allocation count minus cache entries 25782367Smsmith * 25882367Smsmith * DESCRIPTION: Determine the current number of "outstanding" allocations -- 25982367Smsmith * those allocations that have not been freed and also are not 26082367Smsmith * in one of the various object caches. 26182367Smsmith * 26282367Smsmith ******************************************************************************/ 26382367Smsmith 26482367SmsmithUINT32 26599679SiwasakiAcpiDbGetOutstandingAllocations ( 26699679Siwasaki void) 26782367Smsmith{ 26882367Smsmith UINT32 Outstanding = 0; 26982367Smsmith 27082367Smsmith#ifdef ACPI_DBG_TRACK_ALLOCATIONS 27191116Smsmith UINT32 i; 27282367Smsmith 27391116Smsmith 27482367Smsmith for (i = ACPI_MEM_LIST_FIRST_CACHE_LIST; i < ACPI_NUM_MEM_LISTS; i++) 27582367Smsmith { 27683174Smsmith Outstanding += (AcpiGbl_MemoryLists[i].TotalAllocated - 27783174Smsmith AcpiGbl_MemoryLists[i].TotalFreed - 27882367Smsmith AcpiGbl_MemoryLists[i].CacheDepth); 27982367Smsmith } 28082367Smsmith#endif 28182367Smsmith 28282367Smsmith return (Outstanding); 28382367Smsmith} 28482367Smsmith 28582367Smsmith 28682367Smsmith/******************************************************************************* 28782367Smsmith * 28867754Smsmith * FUNCTION: AcpiDbExecute 28967754Smsmith * 29067754Smsmith * PARAMETERS: Name - Name of method to execute 29167754Smsmith * Args - Parameters to the method 29267754Smsmith * Flags - single step/no single step 29367754Smsmith * 29467754Smsmith * RETURN: Status 29567754Smsmith * 29667754Smsmith * DESCRIPTION: Execute a control method. Name is relative to the current 29767754Smsmith * scope. 29867754Smsmith * 29967754Smsmith ******************************************************************************/ 30067754Smsmith 30167754Smsmithvoid 30267754SmsmithAcpiDbExecute ( 30367754Smsmith NATIVE_CHAR *Name, 30467754Smsmith NATIVE_CHAR **Args, 30567754Smsmith UINT32 Flags) 30667754Smsmith{ 30767754Smsmith ACPI_STATUS Status; 30869450Smsmith ACPI_BUFFER ReturnObj; 30969450Smsmith 31069450Smsmith 311102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT 31267754Smsmith UINT32 PreviousAllocations; 31367754Smsmith UINT32 Allocations; 31467754Smsmith 31567754Smsmith 31667754Smsmith /* Memory allocation tracking */ 31767754Smsmith 31882367Smsmith PreviousAllocations = AcpiDbGetOutstandingAllocations (); 31969450Smsmith#endif 32067754Smsmith 32183174Smsmith AcpiGbl_DbMethodInfo.Name = Name; 32283174Smsmith AcpiGbl_DbMethodInfo.Args = Args; 32383174Smsmith AcpiGbl_DbMethodInfo.Flags = Flags; 32467754Smsmith 325100966Siwasaki ReturnObj.Pointer = NULL; 326100966Siwasaki ReturnObj.Length = ACPI_ALLOCATE_BUFFER; 327100966Siwasaki 32883174Smsmith AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); 32983174Smsmith Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); 33067754Smsmith 33182367Smsmith /* 33282367Smsmith * Allow any handlers in separate threads to complete. 33382367Smsmith * (Such as Notify handlers invoked from AML executed above). 33482367Smsmith */ 33582367Smsmith AcpiOsSleep (0, 10); 33667754Smsmith 33782367Smsmith 338102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT 33969450Smsmith 34067754Smsmith /* Memory allocation tracking */ 34167754Smsmith 34282367Smsmith Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations; 34367754Smsmith 34491116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 34567754Smsmith 34667754Smsmith if (Allocations > 0) 34767754Smsmith { 34882367Smsmith AcpiOsPrintf ("Outstanding: %ld allocations after execution\n", 34982367Smsmith Allocations); 35067754Smsmith } 35169450Smsmith#endif 35267754Smsmith 35367754Smsmith if (ACPI_FAILURE (Status)) 35467754Smsmith { 35583174Smsmith AcpiOsPrintf ("Execution of %s failed with status %s\n", 35683174Smsmith AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); 35767754Smsmith } 35867754Smsmith 35967754Smsmith else 36067754Smsmith { 36167754Smsmith /* Display a return object, if any */ 36267754Smsmith 36367754Smsmith if (ReturnObj.Length) 36467754Smsmith { 36577424Smsmith AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", 36683174Smsmith AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, ReturnObj.Length); 36767754Smsmith AcpiDbDumpObject (ReturnObj.Pointer, 1); 36867754Smsmith } 369100966Siwasaki else 370100966Siwasaki { 371102550Siwasaki AcpiOsPrintf ("No return object from execution of %s\n", 372100966Siwasaki AcpiGbl_DbMethodInfo.Pathname); 373100966Siwasaki } 37467754Smsmith } 37567754Smsmith 37691116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 37767754Smsmith} 37867754Smsmith 37967754Smsmith 38067754Smsmith/******************************************************************************* 38167754Smsmith * 38267754Smsmith * FUNCTION: AcpiDbMethodThread 38367754Smsmith * 38467754Smsmith * PARAMETERS: Context - Execution info segment 38567754Smsmith * 38667754Smsmith * RETURN: None 38767754Smsmith * 38867754Smsmith * DESCRIPTION: Debugger execute thread. Waits for a command line, then 38967754Smsmith * simply dispatches it. 39067754Smsmith * 39167754Smsmith ******************************************************************************/ 39267754Smsmith 39392388Smsmithvoid ACPI_SYSTEM_XFACE 39467754SmsmithAcpiDbMethodThread ( 39567754Smsmith void *Context) 39667754Smsmith{ 39767754Smsmith ACPI_STATUS Status; 39891116Smsmith ACPI_DB_METHOD_INFO *Info = Context; 39967754Smsmith UINT32 i; 40067754Smsmith ACPI_BUFFER ReturnObj; 40167754Smsmith 40267754Smsmith 40367754Smsmith for (i = 0; i < Info->NumLoops; i++) 40467754Smsmith { 40567754Smsmith Status = AcpiDbExecuteMethod (Info, &ReturnObj); 40667754Smsmith if (ACPI_SUCCESS (Status)) 40767754Smsmith { 40867754Smsmith if (ReturnObj.Length) 40967754Smsmith { 41077424Smsmith AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", 41177424Smsmith Info->Pathname, ReturnObj.Pointer, ReturnObj.Length); 41267754Smsmith AcpiDbDumpObject (ReturnObj.Pointer, 1); 41367754Smsmith } 41467754Smsmith } 41567754Smsmith } 41667754Smsmith 41767754Smsmith /* Signal our completion */ 41867754Smsmith 41999679Siwasaki Status = AcpiOsSignalSemaphore (Info->ThreadGate, 1); 42099679Siwasaki if (ACPI_FAILURE (Status)) 42199679Siwasaki { 42299679Siwasaki AcpiOsPrintf ("Could not signal debugger semaphore\n"); 42399679Siwasaki } 42467754Smsmith} 42567754Smsmith 42667754Smsmith 42767754Smsmith/******************************************************************************* 42867754Smsmith * 42967754Smsmith * FUNCTION: AcpiDbCreateExecutionThreads 43067754Smsmith * 43167754Smsmith * PARAMETERS: NumThreadsArg - Number of threads to create 43267754Smsmith * NumLoopsArg - Loop count for the thread(s) 43367754Smsmith * MethodNameArg - Control method to execute 43467754Smsmith * 43567754Smsmith * RETURN: None 43667754Smsmith * 43767754Smsmith * DESCRIPTION: Create threads to execute method(s) 43867754Smsmith * 43967754Smsmith ******************************************************************************/ 44067754Smsmith 44167754Smsmithvoid 44267754SmsmithAcpiDbCreateExecutionThreads ( 44367754Smsmith NATIVE_CHAR *NumThreadsArg, 44467754Smsmith NATIVE_CHAR *NumLoopsArg, 44567754Smsmith NATIVE_CHAR *MethodNameArg) 44667754Smsmith{ 44767754Smsmith ACPI_STATUS Status; 44867754Smsmith UINT32 NumThreads; 44967754Smsmith UINT32 NumLoops; 45067754Smsmith UINT32 i; 45167754Smsmith ACPI_HANDLE ThreadGate; 45267754Smsmith 45367754Smsmith 45467754Smsmith /* Get the arguments */ 45567754Smsmith 45691116Smsmith NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); 45791116Smsmith NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); 45867754Smsmith 45967754Smsmith if (!NumThreads || !NumLoops) 46067754Smsmith { 46169746Smsmith AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops); 46267754Smsmith return; 46367754Smsmith } 46467754Smsmith 46567754Smsmith /* Create the synchronization semaphore */ 46667754Smsmith 46767754Smsmith Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); 46867754Smsmith if (ACPI_FAILURE (Status)) 46967754Smsmith { 47080062Smsmith AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status)); 47167754Smsmith return; 47267754Smsmith } 47367754Smsmith 47467754Smsmith /* Setup the context to be passed to each thread */ 47567754Smsmith 47683174Smsmith AcpiGbl_DbMethodInfo.Name = MethodNameArg; 47783174Smsmith AcpiGbl_DbMethodInfo.Args = NULL; 47883174Smsmith AcpiGbl_DbMethodInfo.Flags = 0; 47983174Smsmith AcpiGbl_DbMethodInfo.NumLoops = NumLoops; 48083174Smsmith AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate; 48167754Smsmith 48283174Smsmith AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); 48367754Smsmith 48467754Smsmith /* Create the threads */ 48567754Smsmith 48669746Smsmith AcpiOsPrintf ("Creating %X threads to execute %X times each\n", NumThreads, NumLoops); 48767754Smsmith 48867754Smsmith for (i = 0; i < (NumThreads); i++) 48967754Smsmith { 49099679Siwasaki Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); 49199679Siwasaki if (ACPI_FAILURE (Status)) 49299679Siwasaki { 49399679Siwasaki break; 49499679Siwasaki } 49567754Smsmith } 49667754Smsmith 49767754Smsmith /* Wait for all threads to complete */ 49867754Smsmith 49967754Smsmith i = NumThreads; 50067754Smsmith while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ 50167754Smsmith { 50267754Smsmith Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER); 50367754Smsmith i--; 50467754Smsmith } 50567754Smsmith 50667754Smsmith /* Cleanup and exit */ 50767754Smsmith 50899679Siwasaki (void) AcpiOsDeleteSemaphore (ThreadGate); 50967754Smsmith 51091116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 51169746Smsmith AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); 51291116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 51367754Smsmith} 51467754Smsmith 51567754Smsmith 516102550Siwasaki#endif /* ACPI_DEBUGGER */ 51767754Smsmith 51867754Smsmith 519