dbexec.c revision 100966
167754Smsmith/*******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: dbexec - debugger control method execution
467754Smsmith *              $Revision: 42 $
567754Smsmith *
667754Smsmith ******************************************************************************/
7217365Sjkim
8245582Sjkim/******************************************************************************
970243Smsmith *
1067754Smsmith * 1. Copyright Notice
11217365Sjkim *
12217365Sjkim * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13217365Sjkim * All rights reserved.
14217365Sjkim *
15217365Sjkim * 2. License
16217365Sjkim *
17217365Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property
18217365Sjkim * rights.  You may have additional license terms from the party that provided
19217365Sjkim * you this software, covering your right to use that party's intellectual
20217365Sjkim * property rights.
21217365Sjkim *
22217365Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23217365Sjkim * copy of the source code appearing in this file ("Covered Code") an
24217365Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
26217365Sjkim * make derivatives, distribute, use and display any portion of the Covered
27217365Sjkim * Code in any form, with the right to sublicense such rights; and
28217365Sjkim *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30217365Sjkim * license (with the right to sublicense), under only those claims of Intel
31217365Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell,
32217365Sjkim * offer to sell, and import the Covered Code and derivative works thereof
33217365Sjkim * solely to the minimum extent necessary to exercise the above copyright
34217365Sjkim * license, and in no event shall the patent license extend to any additions
35217365Sjkim * to or modifications of the Original Intel Code.  No other license or right
36217365Sjkim * is granted directly or by implication, estoppel or otherwise;
37217365Sjkim *
38217365Sjkim * The above copyright and patent license is granted only if the following
39217365Sjkim * conditions are met:
40217365Sjkim *
41217365Sjkim * 3. Conditions
42217365Sjkim *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial portion of the Covered
45193341Sjkim * Code or modification with rights to further distribute source must include
46193341Sjkim * the above Copyright Notice, the above License, this list of Conditions,
47193341Sjkim * and the following Disclaimer and Export Compliance provision.  In addition,
48193341Sjkim * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
50102550Siwasaki * 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
52102550Siwasaki * must include a prominent statement that the modification is derived,
5391116Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56222544Sjkim * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
58151937Sjkim * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
60151937Sjkim * addition, Licensee may not authorize further sublicense of source of any
61151937Sjkim * portion of the Covered Code, and must include terms to the effect that the
62151937Sjkim * license from Licensee to its licensee is limited to the intellectual
63151937Sjkim * property embodied in the software Licensee provides to its licensee, and
64151937Sjkim * not to intellectual property embodied in modifications its licensee may
65151937Sjkim * make.
66151937Sjkim *
67151937Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any
68151937Sjkim * substantial portion of the Covered Code or modification must reproduce the
69151937Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance
70151937Sjkim * provision in the documentation and/or other materials provided with the
71151937Sjkim * distribution.
72151937Sjkim *
73151937Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original
74151937Sjkim * Intel Code.
75151937Sjkim *
76151937Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77151937Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or
78151937Sjkim * other dealings in products derived from or relating to the Covered Code
79151937Sjkim * without prior written authorization from Intel.
80151937Sjkim *
81151937Sjkim * 4. Disclaimer and Export Compliance
82151937Sjkim *
83151937Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84151937Sjkim * 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
87222544Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88222544Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89222544Sjkim * PARTICULAR PURPOSE.
90222544Sjkim *
91222544Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92222544Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93222544Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94222544Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95222544Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96222544Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97222544Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98222544Sjkim * LIMITED REMEDY.
99245582Sjkim *
100222544Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this
101222544Sjkim * software or system incorporating such software without first obtaining any
102222544Sjkim * required license or other approval from the U. S. Department of Commerce or
103222544Sjkim * any other agency or department of the United States Government.  In the
104222544Sjkim * event Licensee exports any such software from the United States or
105222544Sjkim * re-exports any such software from a foreign destination, Licensee shall
106222544Sjkim * ensure that the distribution and export/re-export of the software is in
107222544Sjkim * compliance with all laws, regulations, orders, or other restrictions of the
108222544Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109222544Sjkim * any of its subsidiaries will export/re-export any technical data, process,
110222544Sjkim * software, or service, directly or indirectly, to any country for which the
111222544Sjkim * United States government or any agency thereof requires an export license,
112250838Sjkim * other governmental approval, or letter of assurance, without first obtaining
113222544Sjkim * such license, approval or letter.
114222544Sjkim *
115222544Sjkim *****************************************************************************/
116222544Sjkim
117222544Sjkim
118222544Sjkim#include "acpi.h"
119222544Sjkim#include "acdebug.h"
120222544Sjkim
121222544Sjkim#ifdef ENABLE_DEBUGGER
122222544Sjkim
123222544Sjkim#define _COMPONENT          ACPI_DEBUGGER
124222544Sjkim        ACPI_MODULE_NAME    ("dbexec")
125222544Sjkim
126222544Sjkim
127222544Sjkimstatic ACPI_DB_METHOD_INFO  AcpiGbl_DbMethodInfo;
128222544Sjkim
129250838Sjkim
130222544Sjkim/*******************************************************************************
131222544Sjkim *
132222544Sjkim * FUNCTION:    AcpiDbExecuteMethod
133222544Sjkim *
134222544Sjkim * PARAMETERS:  Info            - Valid info segment
135222544Sjkim *              ReturnObj       - Where to put return object
136222544Sjkim *
137222544Sjkim * RETURN:      Status
13867754Smsmith *
13967754Smsmith * DESCRIPTION: Execute a control method.
14067754Smsmith *
14167754Smsmith ******************************************************************************/
14267754Smsmith
14367754SmsmithACPI_STATUS
14467754SmsmithAcpiDbExecuteMethod (
14567754Smsmith    ACPI_DB_METHOD_INFO     *Info,
14667754Smsmith    ACPI_BUFFER             *ReturnObj)
14767754Smsmith{
14867754Smsmith    ACPI_STATUS             Status;
149151937Sjkim    ACPI_OBJECT_LIST        ParamObjects;
15067754Smsmith    ACPI_OBJECT             Params[MTH_NUM_ARGS];
15191116Smsmith    UINT32                  i;
15267754Smsmith
15367754Smsmith
15467754Smsmith    if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel)
15567754Smsmith    {
156249663Sjkim        AcpiOsPrintf ("Warning: debug output is not enabled!\n");
15767754Smsmith    }
15867754Smsmith
15967754Smsmith    /* Are there arguments to the method? */
160216471Sjkim
161216471Sjkim    if (Info->Args && Info->Args[0])
162216471Sjkim    {
16383174Smsmith        for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++)
16467754Smsmith        {
16567754Smsmith            Params[i].Type              = ACPI_TYPE_INTEGER;
16667754Smsmith            Params[i].Integer.Value     = ACPI_STRTOUL (Info->Args[i], NULL, 16);
16767754Smsmith        }
168249663Sjkim
169249663Sjkim        ParamObjects.Pointer        = Params;
170193267Sjkim        ParamObjects.Count          = i;
171249663Sjkim    }
172193267Sjkim    else
173249663Sjkim    {
17467754Smsmith        /* Setup default parameters */
175249663Sjkim
17667754Smsmith        Params[0].Type              = ACPI_TYPE_INTEGER;
177249663Sjkim        Params[0].Integer.Value     = 0x01020304;
178193267Sjkim
179249663Sjkim        Params[1].Type              = ACPI_TYPE_STRING;
180222544Sjkim        Params[1].String.Length     = 12;
181249663Sjkim        Params[1].String.Pointer    = "AML Debugger";
182249663Sjkim
183249663Sjkim        ParamObjects.Pointer        = Params;
184193267Sjkim        ParamObjects.Count          = 2;
185249663Sjkim    }
186249663Sjkim
187249663Sjkim    /* Prepare for a return object of arbitrary size */
188193267Sjkim
189222544Sjkim    ReturnObj->Pointer           = AcpiGbl_DbBuffer;
19067754Smsmith    ReturnObj->Length            = ACPI_DEBUG_BUFFER_SIZE;
191249663Sjkim
192222544Sjkim    /* Do the actual method execution */
19367754Smsmith
19467754Smsmith    Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj);
19567754Smsmith
19667754Smsmith    AcpiGbl_CmSingleStep = FALSE;
197151937Sjkim    AcpiGbl_MethodExecuting = FALSE;
198151937Sjkim
19967754Smsmith    return (Status);
20067754Smsmith}
20167754Smsmith
202114237Snjl
203249663Sjkim/*******************************************************************************
204249663Sjkim *
20567754Smsmith * FUNCTION:    AcpiDbExecuteSetup
20667754Smsmith *
20767754Smsmith * PARAMETERS:  Info            - Valid method info
20867754Smsmith *
209216471Sjkim * RETURN:      Status
210216471Sjkim *
211216471Sjkim * DESCRIPTION: Setup info segment prior to method execution
212222544Sjkim *
213216471Sjkim ******************************************************************************/
214216471Sjkim
215216471Sjkimvoid
216216471SjkimAcpiDbExecuteSetup (
217222544Sjkim    ACPI_DB_METHOD_INFO     *Info)
218216471Sjkim{
219216471Sjkim
220216471Sjkim    /* Catenate the current scope to the supplied name */
221216471Sjkim
222222544Sjkim    Info->Pathname[0] = 0;
223249663Sjkim    if ((Info->Name[0] != '\\') &&
224216471Sjkim        (Info->Name[0] != '/'))
22567754Smsmith    {
22667754Smsmith        ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf);
22767754Smsmith    }
22867754Smsmith
22967754Smsmith    ACPI_STRCAT (Info->Pathname, Info->Name);
23067754Smsmith    AcpiDbPrepNamestring (Info->Pathname);
23167754Smsmith
23267754Smsmith    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
23367754Smsmith    AcpiOsPrintf ("Executing %s\n", Info->Pathname);
234151937Sjkim
23567754Smsmith    if (Info->Flags & EX_SINGLE_STEP)
23667754Smsmith    {
23767754Smsmith        AcpiGbl_CmSingleStep = TRUE;
23867754Smsmith        AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
23967754Smsmith    }
240151937Sjkim
24167754Smsmith    else
24299679Siwasaki    {
24367754Smsmith        /* No single step, allow redirection to a file */
24467754Smsmith
24567754Smsmith        AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
24667754Smsmith    }
24767754Smsmith}
24867754Smsmith
24967754Smsmith
25067754Smsmith/*******************************************************************************
25191116Smsmith *
25267754Smsmith * FUNCTION:    AcpiDbGetOutstandingAllocations
25367754Smsmith *
25491116Smsmith * PARAMETERS:  None
25567754Smsmith *
25667754Smsmith * RETURN:      Current global allocation count minus cache entries
25791116Smsmith *
258240716Sjkim * DESCRIPTION: Determine the current number of "outstanding" allocations --
25967754Smsmith *              those allocations that have not been freed and also are not
26067754Smsmith *              in one of the various object caches.
26167754Smsmith *
26267754Smsmith ******************************************************************************/
26391116Smsmith
26467754SmsmithUINT32
26567754SmsmithAcpiDbGetOutstandingAllocations (
26667754Smsmith    void)
26767754Smsmith{
26867754Smsmith    UINT32                  Outstanding = 0;
26967754Smsmith
27091116Smsmith#ifdef ACPI_DBG_TRACK_ALLOCATIONS
27167754Smsmith    UINT32                  i;
27267754Smsmith
27367754Smsmith
27467754Smsmith    for (i = ACPI_MEM_LIST_FIRST_CACHE_LIST; i < ACPI_NUM_MEM_LISTS; i++)
275151937Sjkim    {
276167802Sjkim        Outstanding += (AcpiGbl_MemoryLists[i].TotalAllocated -
277151937Sjkim                        AcpiGbl_MemoryLists[i].TotalFreed -
278151937Sjkim                        AcpiGbl_MemoryLists[i].CacheDepth);
279151937Sjkim    }
280151937Sjkim#endif
281151937Sjkim
282151937Sjkim    return (Outstanding);
283151937Sjkim}
284151937Sjkim
28567754Smsmith
28667754Smsmith/*******************************************************************************
28782367Smsmith *
28882367Smsmith * FUNCTION:    AcpiDbExecute
28982367Smsmith *
29082367Smsmith * PARAMETERS:  Name                - Name of method to execute
29182367Smsmith *              Args                - Parameters to the method
29282367Smsmith *              Flags               - single step/no single step
29382367Smsmith *
29482367Smsmith * RETURN:      Status
29582367Smsmith *
29682367Smsmith * DESCRIPTION: Execute a control method.  Name is relative to the current
29782367Smsmith *              scope.
29882367Smsmith *
299151937Sjkim ******************************************************************************/
30099679Siwasaki
30199679Siwasakivoid
30282367SmsmithAcpiDbExecute (
30382367Smsmith    NATIVE_CHAR             *Name,
30482367Smsmith    NATIVE_CHAR             **Args,
30582367Smsmith    UINT32                  Flags)
30682367Smsmith{
307151937Sjkim    ACPI_STATUS             Status;
308151937Sjkim    ACPI_BUFFER             ReturnObj;
309151937Sjkim
310151937Sjkim
31182367Smsmith#ifdef ACPI_DEBUG
31282367Smsmith    UINT32                  PreviousAllocations;
31382367Smsmith    UINT32                  Allocations;
31482367Smsmith
31582367Smsmith
31682367Smsmith    /* Memory allocation tracking */
31782367Smsmith
31882367Smsmith    PreviousAllocations = AcpiDbGetOutstandingAllocations ();
319114237Snjl#endif
320114237Snjl
321114237Snjl    AcpiGbl_DbMethodInfo.Name = Name;
322114237Snjl    AcpiGbl_DbMethodInfo.Args = Args;
323114237Snjl    AcpiGbl_DbMethodInfo.Flags = Flags;
324114237Snjl
325241973Sjkim    ReturnObj.Pointer = NULL;
326114237Snjl    ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
327114237Snjl
328114237Snjl    AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
329114237Snjl    Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj);
330151937Sjkim
331114237Snjl    /*
332114237Snjl     * Allow any handlers in separate threads to complete.
333114237Snjl     * (Such as Notify handlers invoked from AML executed above).
334114237Snjl     */
335114237Snjl    AcpiOsSleep (0, 10);
336114237Snjl
337114237Snjl
338114237Snjl#ifdef ACPI_DEBUG
339114237Snjl
340114237Snjl    /* Memory allocation tracking */
341114237Snjl
342114237Snjl    Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations;
343114237Snjl
344114237Snjl    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
345114237Snjl
346114237Snjl    if (Allocations > 0)
347114237Snjl    {
348114237Snjl        AcpiOsPrintf ("Outstanding: %ld allocations after execution\n",
349114237Snjl                        Allocations);
350114237Snjl    }
351114237Snjl#endif
352240716Sjkim
353114237Snjl    if (ACPI_FAILURE (Status))
354114237Snjl    {
355114237Snjl        AcpiOsPrintf ("Execution of %s failed with status %s\n",
356114237Snjl            AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status));
357114237Snjl    }
358114237Snjl
359114237Snjl    else
360114237Snjl    {
361240716Sjkim        /* Display a return object, if any */
362123315Snjl
363114237Snjl        if (ReturnObj.Length)
364114237Snjl        {
365114237Snjl            AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
366114237Snjl                AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, ReturnObj.Length);
367114237Snjl            AcpiDbDumpObject (ReturnObj.Pointer, 1);
368114237Snjl        }
369114237Snjl        else
370114237Snjl        {
37167754Smsmith            AcpiOsPrintf ("No return object from execution of %s\n",
37267754Smsmith                AcpiGbl_DbMethodInfo.Pathname);
37367754Smsmith        }
37467754Smsmith    }
37567754Smsmith
37667754Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
377151937Sjkim}
37867754Smsmith
379241973Sjkim
38067754Smsmith/*******************************************************************************
38167754Smsmith *
38267754Smsmith * FUNCTION:    AcpiDbMethodThread
38367754Smsmith *
38467754Smsmith * PARAMETERS:  Context             - Execution info segment
38567754Smsmith *
386114237Snjl * RETURN:      None
387114237Snjl *
388222544Sjkim * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
38967754Smsmith *              simply dispatches it.
39067754Smsmith *
39167754Smsmith ******************************************************************************/
39269450Smsmith
393167802Sjkimvoid ACPI_SYSTEM_XFACE
39469450SmsmithAcpiDbMethodThread (
39569450Smsmith    void                    *Context)
396102550Siwasaki{
39767754Smsmith    ACPI_STATUS             Status;
39867754Smsmith    ACPI_DB_METHOD_INFO     *Info = Context;
39967754Smsmith    UINT32                  i;
40067754Smsmith    ACPI_BUFFER             ReturnObj;
40167754Smsmith
40267754Smsmith
40382367Smsmith    for (i = 0; i < Info->NumLoops; i++)
40469450Smsmith    {
40567754Smsmith        Status = AcpiDbExecuteMethod (Info, &ReturnObj);
406114237Snjl        if (ACPI_SUCCESS (Status))
407114237Snjl        {
408151937Sjkim            if (ReturnObj.Length)
409199337Sjkim            {
410114237Snjl                AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
411114237Snjl                    Info->Pathname, ReturnObj.Pointer, ReturnObj.Length);
412114237Snjl                AcpiDbDumpObject (ReturnObj.Pointer, 1);
413114237Snjl            }
414167802Sjkim        }
415167802Sjkim    }
416167802Sjkim
417167802Sjkim    /* Signal our completion */
418167802Sjkim
419167802Sjkim    Status = AcpiOsSignalSemaphore (Info->ThreadGate, 1);
420167802Sjkim    if (ACPI_FAILURE (Status))
421167802Sjkim    {
422167802Sjkim        AcpiOsPrintf ("Could not signal debugger semaphore\n");
423167802Sjkim    }
424167802Sjkim}
425114237Snjl
426222544Sjkim
427114237Snjl/*******************************************************************************
42867754Smsmith *
429114237Snjl * FUNCTION:    AcpiDbCreateExecutionThreads
430114237Snjl *
431100966Siwasaki * PARAMETERS:  NumThreadsArg           - Number of threads to create
432114237Snjl *              NumLoopsArg             - Loop count for the thread(s)
433239340Sjkim *              MethodNameArg           - Control method to execute
434239340Sjkim *
435239340Sjkim * RETURN:      None
436239340Sjkim *
437239340Sjkim * DESCRIPTION: Create threads to execute method(s)
438245582Sjkim *
439239340Sjkim ******************************************************************************/
440245582Sjkim
441239340Sjkimvoid
442167802SjkimAcpiDbCreateExecutionThreads (
443114237Snjl    NATIVE_CHAR             *NumThreadsArg,
44467754Smsmith    NATIVE_CHAR             *NumLoopsArg,
44582367Smsmith    NATIVE_CHAR             *MethodNameArg)
44682367Smsmith{
44782367Smsmith    ACPI_STATUS             Status;
44882367Smsmith    UINT32                  NumThreads;
449202771Sjkim    UINT32                  NumLoops;
45067754Smsmith    UINT32                  i;
451102550Siwasaki    ACPI_HANDLE             ThreadGate;
45269450Smsmith
45367754Smsmith
45467754Smsmith    /* Get the arguments */
45582367Smsmith
45667754Smsmith    NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0);
45791116Smsmith    NumLoops   = ACPI_STRTOUL (NumLoopsArg, NULL, 0);
45867754Smsmith
45967754Smsmith    if (!NumThreads || !NumLoops)
46067754Smsmith    {
461240716Sjkim        AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops);
462240716Sjkim        return;
46367754Smsmith    }
46469450Smsmith
46567754Smsmith    /* Create the synchronization semaphore */
46667754Smsmith
46767754Smsmith    Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate);
468240716Sjkim    if (ACPI_FAILURE (Status))
46983174Smsmith    {
47067754Smsmith        AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status));
47167754Smsmith        return;
47267754Smsmith    }
47367754Smsmith
47467754Smsmith    /* Setup the context to be passed to each thread */
47567754Smsmith
47667754Smsmith    AcpiGbl_DbMethodInfo.Name = MethodNameArg;
477240716Sjkim    AcpiGbl_DbMethodInfo.Args = NULL;
478240716Sjkim    AcpiGbl_DbMethodInfo.Flags = 0;
479114237Snjl    AcpiGbl_DbMethodInfo.NumLoops = NumLoops;
480104470Siwasaki    AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate;
481151937Sjkim
482239340Sjkim    AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
483239340Sjkim
484239340Sjkim    /* Create the threads */
485239340Sjkim
486239340Sjkim    AcpiOsPrintf ("Creating %X threads to execute %X times each\n", NumThreads, NumLoops);
487239340Sjkim
488239340Sjkim    for (i = 0; i < (NumThreads); i++)
489239340Sjkim    {
49067754Smsmith        Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo);
491100966Siwasaki        if (ACPI_FAILURE (Status))
492100966Siwasaki        {
493240716Sjkim            break;
494100966Siwasaki        }
495100966Siwasaki    }
49667754Smsmith
49767754Smsmith    /* Wait for all threads to complete */
49891116Smsmith
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
50867754Smsmith    (void) AcpiOsDeleteSemaphore (ThreadGate);
50967754Smsmith
510241973Sjkim    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
51167754Smsmith    AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads);
51267754Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
51367754Smsmith}
51467754Smsmith
515151937Sjkim
51667754Smsmith#endif /* ENABLE_DEBUGGER */
51767754Smsmith
51867754Smsmith
51967754Smsmith