1*433d6423SLionel Sambuc /****************************************************************************** 2*433d6423SLionel Sambuc * 3*433d6423SLionel Sambuc * Module Name: dsmethod - Parser/Interpreter interface - control method parsing 4*433d6423SLionel Sambuc * 5*433d6423SLionel Sambuc *****************************************************************************/ 6*433d6423SLionel Sambuc 7*433d6423SLionel Sambuc /****************************************************************************** 8*433d6423SLionel Sambuc * 9*433d6423SLionel Sambuc * 1. Copyright Notice 10*433d6423SLionel Sambuc * 11*433d6423SLionel Sambuc * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 12*433d6423SLionel Sambuc * All rights reserved. 13*433d6423SLionel Sambuc * 14*433d6423SLionel Sambuc * 2. License 15*433d6423SLionel Sambuc * 16*433d6423SLionel Sambuc * 2.1. This is your license from Intel Corp. under its intellectual property 17*433d6423SLionel Sambuc * rights. You may have additional license terms from the party that provided 18*433d6423SLionel Sambuc * you this software, covering your right to use that party's intellectual 19*433d6423SLionel Sambuc * property rights. 20*433d6423SLionel Sambuc * 21*433d6423SLionel Sambuc * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*433d6423SLionel Sambuc * copy of the source code appearing in this file ("Covered Code") an 23*433d6423SLionel Sambuc * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*433d6423SLionel Sambuc * base code distributed originally by Intel ("Original Intel Code") to copy, 25*433d6423SLionel Sambuc * make derivatives, distribute, use and display any portion of the Covered 26*433d6423SLionel Sambuc * Code in any form, with the right to sublicense such rights; and 27*433d6423SLionel Sambuc * 28*433d6423SLionel Sambuc * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*433d6423SLionel Sambuc * license (with the right to sublicense), under only those claims of Intel 30*433d6423SLionel Sambuc * patents that are infringed by the Original Intel Code, to make, use, sell, 31*433d6423SLionel Sambuc * offer to sell, and import the Covered Code and derivative works thereof 32*433d6423SLionel Sambuc * solely to the minimum extent necessary to exercise the above copyright 33*433d6423SLionel Sambuc * license, and in no event shall the patent license extend to any additions 34*433d6423SLionel Sambuc * to or modifications of the Original Intel Code. No other license or right 35*433d6423SLionel Sambuc * is granted directly or by implication, estoppel or otherwise; 36*433d6423SLionel Sambuc * 37*433d6423SLionel Sambuc * The above copyright and patent license is granted only if the following 38*433d6423SLionel Sambuc * conditions are met: 39*433d6423SLionel Sambuc * 40*433d6423SLionel Sambuc * 3. Conditions 41*433d6423SLionel Sambuc * 42*433d6423SLionel Sambuc * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 44*433d6423SLionel Sambuc * Code or modification with rights to further distribute source must include 45*433d6423SLionel Sambuc * the above Copyright Notice, the above License, this list of Conditions, 46*433d6423SLionel Sambuc * and the following Disclaimer and Export Compliance provision. In addition, 47*433d6423SLionel Sambuc * Licensee must cause all Covered Code to which Licensee contributes to 48*433d6423SLionel Sambuc * contain a file documenting the changes Licensee made to create that Covered 49*433d6423SLionel Sambuc * Code and the date of any change. Licensee must include in that file the 50*433d6423SLionel Sambuc * documentation of any changes made by any predecessor Licensee. Licensee 51*433d6423SLionel Sambuc * must include a prominent statement that the modification is derived, 52*433d6423SLionel Sambuc * directly or indirectly, from Original Intel Code. 53*433d6423SLionel Sambuc * 54*433d6423SLionel Sambuc * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 56*433d6423SLionel Sambuc * Code or modification without rights to further distribute source must 57*433d6423SLionel Sambuc * include the following Disclaimer and Export Compliance provision in the 58*433d6423SLionel Sambuc * documentation and/or other materials provided with distribution. In 59*433d6423SLionel Sambuc * addition, Licensee may not authorize further sublicense of source of any 60*433d6423SLionel Sambuc * portion of the Covered Code, and must include terms to the effect that the 61*433d6423SLionel Sambuc * license from Licensee to its licensee is limited to the intellectual 62*433d6423SLionel Sambuc * property embodied in the software Licensee provides to its licensee, and 63*433d6423SLionel Sambuc * not to intellectual property embodied in modifications its licensee may 64*433d6423SLionel Sambuc * make. 65*433d6423SLionel Sambuc * 66*433d6423SLionel Sambuc * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*433d6423SLionel Sambuc * substantial portion of the Covered Code or modification must reproduce the 68*433d6423SLionel Sambuc * above Copyright Notice, and the following Disclaimer and Export Compliance 69*433d6423SLionel Sambuc * provision in the documentation and/or other materials provided with the 70*433d6423SLionel Sambuc * distribution. 71*433d6423SLionel Sambuc * 72*433d6423SLionel Sambuc * 3.4. Intel retains all right, title, and interest in and to the Original 73*433d6423SLionel Sambuc * Intel Code. 74*433d6423SLionel Sambuc * 75*433d6423SLionel Sambuc * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*433d6423SLionel Sambuc * Intel shall be used in advertising or otherwise to promote the sale, use or 77*433d6423SLionel Sambuc * other dealings in products derived from or relating to the Covered Code 78*433d6423SLionel Sambuc * without prior written authorization from Intel. 79*433d6423SLionel Sambuc * 80*433d6423SLionel Sambuc * 4. Disclaimer and Export Compliance 81*433d6423SLionel Sambuc * 82*433d6423SLionel Sambuc * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*433d6423SLionel Sambuc * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*433d6423SLionel Sambuc * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*433d6423SLionel Sambuc * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*433d6423SLionel Sambuc * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*433d6423SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*433d6423SLionel Sambuc * PARTICULAR PURPOSE. 89*433d6423SLionel Sambuc * 90*433d6423SLionel Sambuc * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*433d6423SLionel Sambuc * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*433d6423SLionel Sambuc * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*433d6423SLionel Sambuc * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*433d6423SLionel Sambuc * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*433d6423SLionel Sambuc * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*433d6423SLionel Sambuc * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*433d6423SLionel Sambuc * LIMITED REMEDY. 98*433d6423SLionel Sambuc * 99*433d6423SLionel Sambuc * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*433d6423SLionel Sambuc * software or system incorporating such software without first obtaining any 101*433d6423SLionel Sambuc * required license or other approval from the U. S. Department of Commerce or 102*433d6423SLionel Sambuc * any other agency or department of the United States Government. In the 103*433d6423SLionel Sambuc * event Licensee exports any such software from the United States or 104*433d6423SLionel Sambuc * re-exports any such software from a foreign destination, Licensee shall 105*433d6423SLionel Sambuc * ensure that the distribution and export/re-export of the software is in 106*433d6423SLionel Sambuc * compliance with all laws, regulations, orders, or other restrictions of the 107*433d6423SLionel Sambuc * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*433d6423SLionel Sambuc * any of its subsidiaries will export/re-export any technical data, process, 109*433d6423SLionel Sambuc * software, or service, directly or indirectly, to any country for which the 110*433d6423SLionel Sambuc * United States government or any agency thereof requires an export license, 111*433d6423SLionel Sambuc * other governmental approval, or letter of assurance, without first obtaining 112*433d6423SLionel Sambuc * such license, approval or letter. 113*433d6423SLionel Sambuc * 114*433d6423SLionel Sambuc *****************************************************************************/ 115*433d6423SLionel Sambuc 116*433d6423SLionel Sambuc #define __DSMETHOD_C__ 117*433d6423SLionel Sambuc 118*433d6423SLionel Sambuc #include "acpi.h" 119*433d6423SLionel Sambuc #include "accommon.h" 120*433d6423SLionel Sambuc #include "amlcode.h" 121*433d6423SLionel Sambuc #include "acdispat.h" 122*433d6423SLionel Sambuc #include "acinterp.h" 123*433d6423SLionel Sambuc #include "acnamesp.h" 124*433d6423SLionel Sambuc #include "acdisasm.h" 125*433d6423SLionel Sambuc 126*433d6423SLionel Sambuc 127*433d6423SLionel Sambuc #define _COMPONENT ACPI_DISPATCHER 128*433d6423SLionel Sambuc ACPI_MODULE_NAME ("dsmethod") 129*433d6423SLionel Sambuc 130*433d6423SLionel Sambuc /* Local prototypes */ 131*433d6423SLionel Sambuc 132*433d6423SLionel Sambuc static ACPI_STATUS 133*433d6423SLionel Sambuc AcpiDsCreateMethodMutex ( 134*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *MethodDesc); 135*433d6423SLionel Sambuc 136*433d6423SLionel Sambuc 137*433d6423SLionel Sambuc /******************************************************************************* 138*433d6423SLionel Sambuc * 139*433d6423SLionel Sambuc * FUNCTION: AcpiDsMethodError 140*433d6423SLionel Sambuc * 141*433d6423SLionel Sambuc * PARAMETERS: Status - Execution status 142*433d6423SLionel Sambuc * WalkState - Current state 143*433d6423SLionel Sambuc * 144*433d6423SLionel Sambuc * RETURN: Status 145*433d6423SLionel Sambuc * 146*433d6423SLionel Sambuc * DESCRIPTION: Called on method error. Invoke the global exception handler if 147*433d6423SLionel Sambuc * present, dump the method data if the disassembler is configured 148*433d6423SLionel Sambuc * 149*433d6423SLionel Sambuc * Note: Allows the exception handler to change the status code 150*433d6423SLionel Sambuc * 151*433d6423SLionel Sambuc ******************************************************************************/ 152*433d6423SLionel Sambuc 153*433d6423SLionel Sambuc ACPI_STATUS 154*433d6423SLionel Sambuc AcpiDsMethodError ( 155*433d6423SLionel Sambuc ACPI_STATUS Status, 156*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 157*433d6423SLionel Sambuc { 158*433d6423SLionel Sambuc ACPI_FUNCTION_ENTRY (); 159*433d6423SLionel Sambuc 160*433d6423SLionel Sambuc 161*433d6423SLionel Sambuc /* Ignore AE_OK and control exception codes */ 162*433d6423SLionel Sambuc 163*433d6423SLionel Sambuc if (ACPI_SUCCESS (Status) || 164*433d6423SLionel Sambuc (Status & AE_CODE_CONTROL)) 165*433d6423SLionel Sambuc { 166*433d6423SLionel Sambuc return (Status); 167*433d6423SLionel Sambuc } 168*433d6423SLionel Sambuc 169*433d6423SLionel Sambuc /* Invoke the global exception handler */ 170*433d6423SLionel Sambuc 171*433d6423SLionel Sambuc if (AcpiGbl_ExceptionHandler) 172*433d6423SLionel Sambuc { 173*433d6423SLionel Sambuc /* Exit the interpreter, allow handler to execute methods */ 174*433d6423SLionel Sambuc 175*433d6423SLionel Sambuc AcpiExExitInterpreter (); 176*433d6423SLionel Sambuc 177*433d6423SLionel Sambuc /* 178*433d6423SLionel Sambuc * Handler can map the exception code to anything it wants, including 179*433d6423SLionel Sambuc * AE_OK, in which case the executing method will not be aborted. 180*433d6423SLionel Sambuc */ 181*433d6423SLionel Sambuc Status = AcpiGbl_ExceptionHandler (Status, 182*433d6423SLionel Sambuc WalkState->MethodNode ? 183*433d6423SLionel Sambuc WalkState->MethodNode->Name.Integer : 0, 184*433d6423SLionel Sambuc WalkState->Opcode, WalkState->AmlOffset, NULL); 185*433d6423SLionel Sambuc AcpiExEnterInterpreter (); 186*433d6423SLionel Sambuc } 187*433d6423SLionel Sambuc 188*433d6423SLionel Sambuc AcpiDsClearImplicitReturn (WalkState); 189*433d6423SLionel Sambuc 190*433d6423SLionel Sambuc #ifdef ACPI_DISASSEMBLER 191*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 192*433d6423SLionel Sambuc { 193*433d6423SLionel Sambuc /* Display method locals/args if disassembler is present */ 194*433d6423SLionel Sambuc 195*433d6423SLionel Sambuc AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op); 196*433d6423SLionel Sambuc } 197*433d6423SLionel Sambuc #endif 198*433d6423SLionel Sambuc 199*433d6423SLionel Sambuc return (Status); 200*433d6423SLionel Sambuc } 201*433d6423SLionel Sambuc 202*433d6423SLionel Sambuc 203*433d6423SLionel Sambuc /******************************************************************************* 204*433d6423SLionel Sambuc * 205*433d6423SLionel Sambuc * FUNCTION: AcpiDsCreateMethodMutex 206*433d6423SLionel Sambuc * 207*433d6423SLionel Sambuc * PARAMETERS: ObjDesc - The method object 208*433d6423SLionel Sambuc * 209*433d6423SLionel Sambuc * RETURN: Status 210*433d6423SLionel Sambuc * 211*433d6423SLionel Sambuc * DESCRIPTION: Create a mutex object for a serialized control method 212*433d6423SLionel Sambuc * 213*433d6423SLionel Sambuc ******************************************************************************/ 214*433d6423SLionel Sambuc 215*433d6423SLionel Sambuc static ACPI_STATUS 216*433d6423SLionel Sambuc AcpiDsCreateMethodMutex ( 217*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *MethodDesc) 218*433d6423SLionel Sambuc { 219*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *MutexDesc; 220*433d6423SLionel Sambuc ACPI_STATUS Status; 221*433d6423SLionel Sambuc 222*433d6423SLionel Sambuc 223*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (DsCreateMethodMutex); 224*433d6423SLionel Sambuc 225*433d6423SLionel Sambuc 226*433d6423SLionel Sambuc /* Create the new mutex object */ 227*433d6423SLionel Sambuc 228*433d6423SLionel Sambuc MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 229*433d6423SLionel Sambuc if (!MutexDesc) 230*433d6423SLionel Sambuc { 231*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY); 232*433d6423SLionel Sambuc } 233*433d6423SLionel Sambuc 234*433d6423SLionel Sambuc /* Create the actual OS Mutex */ 235*433d6423SLionel Sambuc 236*433d6423SLionel Sambuc Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex); 237*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 238*433d6423SLionel Sambuc { 239*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 240*433d6423SLionel Sambuc } 241*433d6423SLionel Sambuc 242*433d6423SLionel Sambuc MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel; 243*433d6423SLionel Sambuc MethodDesc->Method.Mutex = MutexDesc; 244*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 245*433d6423SLionel Sambuc } 246*433d6423SLionel Sambuc 247*433d6423SLionel Sambuc 248*433d6423SLionel Sambuc /******************************************************************************* 249*433d6423SLionel Sambuc * 250*433d6423SLionel Sambuc * FUNCTION: AcpiDsBeginMethodExecution 251*433d6423SLionel Sambuc * 252*433d6423SLionel Sambuc * PARAMETERS: MethodNode - Node of the method 253*433d6423SLionel Sambuc * ObjDesc - The method object 254*433d6423SLionel Sambuc * WalkState - current state, NULL if not yet executing 255*433d6423SLionel Sambuc * a method. 256*433d6423SLionel Sambuc * 257*433d6423SLionel Sambuc * RETURN: Status 258*433d6423SLionel Sambuc * 259*433d6423SLionel Sambuc * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, 260*433d6423SLionel Sambuc * increments the thread count, and waits at the method semaphore 261*433d6423SLionel Sambuc * for clearance to execute. 262*433d6423SLionel Sambuc * 263*433d6423SLionel Sambuc ******************************************************************************/ 264*433d6423SLionel Sambuc 265*433d6423SLionel Sambuc ACPI_STATUS 266*433d6423SLionel Sambuc AcpiDsBeginMethodExecution ( 267*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *MethodNode, 268*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc, 269*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 270*433d6423SLionel Sambuc { 271*433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK; 272*433d6423SLionel Sambuc 273*433d6423SLionel Sambuc 274*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode); 275*433d6423SLionel Sambuc 276*433d6423SLionel Sambuc 277*433d6423SLionel Sambuc if (!MethodNode) 278*433d6423SLionel Sambuc { 279*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NULL_ENTRY); 280*433d6423SLionel Sambuc } 281*433d6423SLionel Sambuc 282*433d6423SLionel Sambuc /* Prevent wraparound of thread count */ 283*433d6423SLionel Sambuc 284*433d6423SLionel Sambuc if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) 285*433d6423SLionel Sambuc { 286*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 287*433d6423SLionel Sambuc "Method reached maximum reentrancy limit (255)")); 288*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_METHOD_LIMIT); 289*433d6423SLionel Sambuc } 290*433d6423SLionel Sambuc 291*433d6423SLionel Sambuc /* 292*433d6423SLionel Sambuc * If this method is serialized, we need to acquire the method mutex. 293*433d6423SLionel Sambuc */ 294*433d6423SLionel Sambuc if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) 295*433d6423SLionel Sambuc { 296*433d6423SLionel Sambuc /* 297*433d6423SLionel Sambuc * Create a mutex for the method if it is defined to be Serialized 298*433d6423SLionel Sambuc * and a mutex has not already been created. We defer the mutex creation 299*433d6423SLionel Sambuc * until a method is actually executed, to minimize the object count 300*433d6423SLionel Sambuc */ 301*433d6423SLionel Sambuc if (!ObjDesc->Method.Mutex) 302*433d6423SLionel Sambuc { 303*433d6423SLionel Sambuc Status = AcpiDsCreateMethodMutex (ObjDesc); 304*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 305*433d6423SLionel Sambuc { 306*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 307*433d6423SLionel Sambuc } 308*433d6423SLionel Sambuc } 309*433d6423SLionel Sambuc 310*433d6423SLionel Sambuc /* 311*433d6423SLionel Sambuc * The CurrentSyncLevel (per-thread) must be less than or equal to 312*433d6423SLionel Sambuc * the sync level of the method. This mechanism provides some 313*433d6423SLionel Sambuc * deadlock prevention 314*433d6423SLionel Sambuc * 315*433d6423SLionel Sambuc * Top-level method invocation has no walk state at this point 316*433d6423SLionel Sambuc */ 317*433d6423SLionel Sambuc if (WalkState && 318*433d6423SLionel Sambuc (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) 319*433d6423SLionel Sambuc { 320*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 321*433d6423SLionel Sambuc "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)", 322*433d6423SLionel Sambuc AcpiUtGetNodeName (MethodNode), 323*433d6423SLionel Sambuc WalkState->Thread->CurrentSyncLevel)); 324*433d6423SLionel Sambuc 325*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 326*433d6423SLionel Sambuc } 327*433d6423SLionel Sambuc 328*433d6423SLionel Sambuc /* 329*433d6423SLionel Sambuc * Obtain the method mutex if necessary. Do not acquire mutex for a 330*433d6423SLionel Sambuc * recursive call. 331*433d6423SLionel Sambuc */ 332*433d6423SLionel Sambuc if (!WalkState || 333*433d6423SLionel Sambuc !ObjDesc->Method.Mutex->Mutex.ThreadId || 334*433d6423SLionel Sambuc (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) 335*433d6423SLionel Sambuc { 336*433d6423SLionel Sambuc /* 337*433d6423SLionel Sambuc * Acquire the method mutex. This releases the interpreter if we 338*433d6423SLionel Sambuc * block (and reacquires it before it returns) 339*433d6423SLionel Sambuc */ 340*433d6423SLionel Sambuc Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, 341*433d6423SLionel Sambuc ACPI_WAIT_FOREVER); 342*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 343*433d6423SLionel Sambuc { 344*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 345*433d6423SLionel Sambuc } 346*433d6423SLionel Sambuc 347*433d6423SLionel Sambuc /* Update the mutex and walk info and save the original SyncLevel */ 348*433d6423SLionel Sambuc 349*433d6423SLionel Sambuc if (WalkState) 350*433d6423SLionel Sambuc { 351*433d6423SLionel Sambuc ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = 352*433d6423SLionel Sambuc WalkState->Thread->CurrentSyncLevel; 353*433d6423SLionel Sambuc 354*433d6423SLionel Sambuc ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; 355*433d6423SLionel Sambuc WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; 356*433d6423SLionel Sambuc } 357*433d6423SLionel Sambuc else 358*433d6423SLionel Sambuc { 359*433d6423SLionel Sambuc ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = 360*433d6423SLionel Sambuc ObjDesc->Method.Mutex->Mutex.SyncLevel; 361*433d6423SLionel Sambuc } 362*433d6423SLionel Sambuc } 363*433d6423SLionel Sambuc 364*433d6423SLionel Sambuc /* Always increase acquisition depth */ 365*433d6423SLionel Sambuc 366*433d6423SLionel Sambuc ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++; 367*433d6423SLionel Sambuc } 368*433d6423SLionel Sambuc 369*433d6423SLionel Sambuc /* 370*433d6423SLionel Sambuc * Allocate an Owner ID for this method, only if this is the first thread 371*433d6423SLionel Sambuc * to begin concurrent execution. We only need one OwnerId, even if the 372*433d6423SLionel Sambuc * method is invoked recursively. 373*433d6423SLionel Sambuc */ 374*433d6423SLionel Sambuc if (!ObjDesc->Method.OwnerId) 375*433d6423SLionel Sambuc { 376*433d6423SLionel Sambuc Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); 377*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 378*433d6423SLionel Sambuc { 379*433d6423SLionel Sambuc goto Cleanup; 380*433d6423SLionel Sambuc } 381*433d6423SLionel Sambuc } 382*433d6423SLionel Sambuc 383*433d6423SLionel Sambuc /* 384*433d6423SLionel Sambuc * Increment the method parse tree thread count since it has been 385*433d6423SLionel Sambuc * reentered one more time (even if it is the same thread) 386*433d6423SLionel Sambuc */ 387*433d6423SLionel Sambuc ObjDesc->Method.ThreadCount++; 388*433d6423SLionel Sambuc AcpiMethodCount++; 389*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 390*433d6423SLionel Sambuc 391*433d6423SLionel Sambuc 392*433d6423SLionel Sambuc Cleanup: 393*433d6423SLionel Sambuc /* On error, must release the method mutex (if present) */ 394*433d6423SLionel Sambuc 395*433d6423SLionel Sambuc if (ObjDesc->Method.Mutex) 396*433d6423SLionel Sambuc { 397*433d6423SLionel Sambuc AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex); 398*433d6423SLionel Sambuc } 399*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 400*433d6423SLionel Sambuc } 401*433d6423SLionel Sambuc 402*433d6423SLionel Sambuc 403*433d6423SLionel Sambuc /******************************************************************************* 404*433d6423SLionel Sambuc * 405*433d6423SLionel Sambuc * FUNCTION: AcpiDsCallControlMethod 406*433d6423SLionel Sambuc * 407*433d6423SLionel Sambuc * PARAMETERS: Thread - Info for this thread 408*433d6423SLionel Sambuc * ThisWalkState - Current walk state 409*433d6423SLionel Sambuc * Op - Current Op to be walked 410*433d6423SLionel Sambuc * 411*433d6423SLionel Sambuc * RETURN: Status 412*433d6423SLionel Sambuc * 413*433d6423SLionel Sambuc * DESCRIPTION: Transfer execution to a called control method 414*433d6423SLionel Sambuc * 415*433d6423SLionel Sambuc ******************************************************************************/ 416*433d6423SLionel Sambuc 417*433d6423SLionel Sambuc ACPI_STATUS 418*433d6423SLionel Sambuc AcpiDsCallControlMethod ( 419*433d6423SLionel Sambuc ACPI_THREAD_STATE *Thread, 420*433d6423SLionel Sambuc ACPI_WALK_STATE *ThisWalkState, 421*433d6423SLionel Sambuc ACPI_PARSE_OBJECT *Op) 422*433d6423SLionel Sambuc { 423*433d6423SLionel Sambuc ACPI_STATUS Status; 424*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *MethodNode; 425*433d6423SLionel Sambuc ACPI_WALK_STATE *NextWalkState = NULL; 426*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc; 427*433d6423SLionel Sambuc ACPI_EVALUATE_INFO *Info; 428*433d6423SLionel Sambuc UINT32 i; 429*433d6423SLionel Sambuc 430*433d6423SLionel Sambuc 431*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); 432*433d6423SLionel Sambuc 433*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", 434*433d6423SLionel Sambuc ThisWalkState->PrevOp, ThisWalkState)); 435*433d6423SLionel Sambuc 436*433d6423SLionel Sambuc /* 437*433d6423SLionel Sambuc * Get the namespace entry for the control method we are about to call 438*433d6423SLionel Sambuc */ 439*433d6423SLionel Sambuc MethodNode = ThisWalkState->MethodCallNode; 440*433d6423SLionel Sambuc if (!MethodNode) 441*433d6423SLionel Sambuc { 442*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NULL_ENTRY); 443*433d6423SLionel Sambuc } 444*433d6423SLionel Sambuc 445*433d6423SLionel Sambuc ObjDesc = AcpiNsGetAttachedObject (MethodNode); 446*433d6423SLionel Sambuc if (!ObjDesc) 447*433d6423SLionel Sambuc { 448*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NULL_OBJECT); 449*433d6423SLionel Sambuc } 450*433d6423SLionel Sambuc 451*433d6423SLionel Sambuc /* Init for new method, possibly wait on method mutex */ 452*433d6423SLionel Sambuc 453*433d6423SLionel Sambuc Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, 454*433d6423SLionel Sambuc ThisWalkState); 455*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 456*433d6423SLionel Sambuc { 457*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 458*433d6423SLionel Sambuc } 459*433d6423SLionel Sambuc 460*433d6423SLionel Sambuc /* Begin method parse/execution. Create a new walk state */ 461*433d6423SLionel Sambuc 462*433d6423SLionel Sambuc NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, 463*433d6423SLionel Sambuc NULL, ObjDesc, Thread); 464*433d6423SLionel Sambuc if (!NextWalkState) 465*433d6423SLionel Sambuc { 466*433d6423SLionel Sambuc Status = AE_NO_MEMORY; 467*433d6423SLionel Sambuc goto Cleanup; 468*433d6423SLionel Sambuc } 469*433d6423SLionel Sambuc 470*433d6423SLionel Sambuc /* 471*433d6423SLionel Sambuc * The resolved arguments were put on the previous walk state's operand 472*433d6423SLionel Sambuc * stack. Operands on the previous walk state stack always 473*433d6423SLionel Sambuc * start at index 0. Also, null terminate the list of arguments 474*433d6423SLionel Sambuc */ 475*433d6423SLionel Sambuc ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; 476*433d6423SLionel Sambuc 477*433d6423SLionel Sambuc /* 478*433d6423SLionel Sambuc * Allocate and initialize the evaluation information block 479*433d6423SLionel Sambuc * TBD: this is somewhat inefficient, should change interface to 480*433d6423SLionel Sambuc * DsInitAmlWalk. For now, keeps this struct off the CPU stack 481*433d6423SLionel Sambuc */ 482*433d6423SLionel Sambuc Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 483*433d6423SLionel Sambuc if (!Info) 484*433d6423SLionel Sambuc { 485*433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY); 486*433d6423SLionel Sambuc } 487*433d6423SLionel Sambuc 488*433d6423SLionel Sambuc Info->Parameters = &ThisWalkState->Operands[0]; 489*433d6423SLionel Sambuc 490*433d6423SLionel Sambuc Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, 491*433d6423SLionel Sambuc ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, 492*433d6423SLionel Sambuc Info, ACPI_IMODE_EXECUTE); 493*433d6423SLionel Sambuc 494*433d6423SLionel Sambuc ACPI_FREE (Info); 495*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 496*433d6423SLionel Sambuc { 497*433d6423SLionel Sambuc goto Cleanup; 498*433d6423SLionel Sambuc } 499*433d6423SLionel Sambuc 500*433d6423SLionel Sambuc /* 501*433d6423SLionel Sambuc * Delete the operands on the previous walkstate operand stack 502*433d6423SLionel Sambuc * (they were copied to new objects) 503*433d6423SLionel Sambuc */ 504*433d6423SLionel Sambuc for (i = 0; i < ObjDesc->Method.ParamCount; i++) 505*433d6423SLionel Sambuc { 506*433d6423SLionel Sambuc AcpiUtRemoveReference (ThisWalkState->Operands [i]); 507*433d6423SLionel Sambuc ThisWalkState->Operands [i] = NULL; 508*433d6423SLionel Sambuc } 509*433d6423SLionel Sambuc 510*433d6423SLionel Sambuc /* Clear the operand stack */ 511*433d6423SLionel Sambuc 512*433d6423SLionel Sambuc ThisWalkState->NumOperands = 0; 513*433d6423SLionel Sambuc 514*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 515*433d6423SLionel Sambuc "**** Begin nested execution of [%4.4s] **** WalkState=%p\n", 516*433d6423SLionel Sambuc MethodNode->Name.Ascii, NextWalkState)); 517*433d6423SLionel Sambuc 518*433d6423SLionel Sambuc /* Invoke an internal method if necessary */ 519*433d6423SLionel Sambuc 520*433d6423SLionel Sambuc if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) 521*433d6423SLionel Sambuc { 522*433d6423SLionel Sambuc Status = ObjDesc->Method.Extra.Implementation (NextWalkState); 523*433d6423SLionel Sambuc if (Status == AE_OK) 524*433d6423SLionel Sambuc { 525*433d6423SLionel Sambuc Status = AE_CTRL_TERMINATE; 526*433d6423SLionel Sambuc } 527*433d6423SLionel Sambuc } 528*433d6423SLionel Sambuc 529*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 530*433d6423SLionel Sambuc 531*433d6423SLionel Sambuc 532*433d6423SLionel Sambuc Cleanup: 533*433d6423SLionel Sambuc 534*433d6423SLionel Sambuc /* On error, we must terminate the method properly */ 535*433d6423SLionel Sambuc 536*433d6423SLionel Sambuc AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); 537*433d6423SLionel Sambuc if (NextWalkState) 538*433d6423SLionel Sambuc { 539*433d6423SLionel Sambuc AcpiDsDeleteWalkState (NextWalkState); 540*433d6423SLionel Sambuc } 541*433d6423SLionel Sambuc 542*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 543*433d6423SLionel Sambuc } 544*433d6423SLionel Sambuc 545*433d6423SLionel Sambuc 546*433d6423SLionel Sambuc /******************************************************************************* 547*433d6423SLionel Sambuc * 548*433d6423SLionel Sambuc * FUNCTION: AcpiDsRestartControlMethod 549*433d6423SLionel Sambuc * 550*433d6423SLionel Sambuc * PARAMETERS: WalkState - State for preempted method (caller) 551*433d6423SLionel Sambuc * ReturnDesc - Return value from the called method 552*433d6423SLionel Sambuc * 553*433d6423SLionel Sambuc * RETURN: Status 554*433d6423SLionel Sambuc * 555*433d6423SLionel Sambuc * DESCRIPTION: Restart a method that was preempted by another (nested) method 556*433d6423SLionel Sambuc * invocation. Handle the return value (if any) from the callee. 557*433d6423SLionel Sambuc * 558*433d6423SLionel Sambuc ******************************************************************************/ 559*433d6423SLionel Sambuc 560*433d6423SLionel Sambuc ACPI_STATUS 561*433d6423SLionel Sambuc AcpiDsRestartControlMethod ( 562*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 563*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ReturnDesc) 564*433d6423SLionel Sambuc { 565*433d6423SLionel Sambuc ACPI_STATUS Status; 566*433d6423SLionel Sambuc int SameAsImplicitReturn; 567*433d6423SLionel Sambuc 568*433d6423SLionel Sambuc 569*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState); 570*433d6423SLionel Sambuc 571*433d6423SLionel Sambuc 572*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 573*433d6423SLionel Sambuc "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", 574*433d6423SLionel Sambuc AcpiUtGetNodeName (WalkState->MethodNode), 575*433d6423SLionel Sambuc WalkState->MethodCallOp, ReturnDesc)); 576*433d6423SLionel Sambuc 577*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 578*433d6423SLionel Sambuc " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", 579*433d6423SLionel Sambuc WalkState->ReturnUsed, 580*433d6423SLionel Sambuc WalkState->Results, WalkState)); 581*433d6423SLionel Sambuc 582*433d6423SLionel Sambuc /* Did the called method return a value? */ 583*433d6423SLionel Sambuc 584*433d6423SLionel Sambuc if (ReturnDesc) 585*433d6423SLionel Sambuc { 586*433d6423SLionel Sambuc /* Is the implicit return object the same as the return desc? */ 587*433d6423SLionel Sambuc 588*433d6423SLionel Sambuc SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc); 589*433d6423SLionel Sambuc 590*433d6423SLionel Sambuc /* Are we actually going to use the return value? */ 591*433d6423SLionel Sambuc 592*433d6423SLionel Sambuc if (WalkState->ReturnUsed) 593*433d6423SLionel Sambuc { 594*433d6423SLionel Sambuc /* Save the return value from the previous method */ 595*433d6423SLionel Sambuc 596*433d6423SLionel Sambuc Status = AcpiDsResultPush (ReturnDesc, WalkState); 597*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 598*433d6423SLionel Sambuc { 599*433d6423SLionel Sambuc AcpiUtRemoveReference (ReturnDesc); 600*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 601*433d6423SLionel Sambuc } 602*433d6423SLionel Sambuc 603*433d6423SLionel Sambuc /* 604*433d6423SLionel Sambuc * Save as THIS method's return value in case it is returned 605*433d6423SLionel Sambuc * immediately to yet another method 606*433d6423SLionel Sambuc */ 607*433d6423SLionel Sambuc WalkState->ReturnDesc = ReturnDesc; 608*433d6423SLionel Sambuc } 609*433d6423SLionel Sambuc 610*433d6423SLionel Sambuc /* 611*433d6423SLionel Sambuc * The following code is the optional support for the so-called 612*433d6423SLionel Sambuc * "implicit return". Some AML code assumes that the last value of the 613*433d6423SLionel Sambuc * method is "implicitly" returned to the caller, in the absence of an 614*433d6423SLionel Sambuc * explicit return value. 615*433d6423SLionel Sambuc * 616*433d6423SLionel Sambuc * Just save the last result of the method as the return value. 617*433d6423SLionel Sambuc * 618*433d6423SLionel Sambuc * NOTE: this is optional because the ASL language does not actually 619*433d6423SLionel Sambuc * support this behavior. 620*433d6423SLionel Sambuc */ 621*433d6423SLionel Sambuc else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) || 622*433d6423SLionel Sambuc SameAsImplicitReturn) 623*433d6423SLionel Sambuc { 624*433d6423SLionel Sambuc /* 625*433d6423SLionel Sambuc * Delete the return value if it will not be used by the 626*433d6423SLionel Sambuc * calling method or remove one reference if the explicit return 627*433d6423SLionel Sambuc * is the same as the implicit return value. 628*433d6423SLionel Sambuc */ 629*433d6423SLionel Sambuc AcpiUtRemoveReference (ReturnDesc); 630*433d6423SLionel Sambuc } 631*433d6423SLionel Sambuc } 632*433d6423SLionel Sambuc 633*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 634*433d6423SLionel Sambuc } 635*433d6423SLionel Sambuc 636*433d6423SLionel Sambuc 637*433d6423SLionel Sambuc /******************************************************************************* 638*433d6423SLionel Sambuc * 639*433d6423SLionel Sambuc * FUNCTION: AcpiDsTerminateControlMethod 640*433d6423SLionel Sambuc * 641*433d6423SLionel Sambuc * PARAMETERS: MethodDesc - Method object 642*433d6423SLionel Sambuc * WalkState - State associated with the method 643*433d6423SLionel Sambuc * 644*433d6423SLionel Sambuc * RETURN: None 645*433d6423SLionel Sambuc * 646*433d6423SLionel Sambuc * DESCRIPTION: Terminate a control method. Delete everything that the method 647*433d6423SLionel Sambuc * created, delete all locals and arguments, and delete the parse 648*433d6423SLionel Sambuc * tree if requested. 649*433d6423SLionel Sambuc * 650*433d6423SLionel Sambuc * MUTEX: Interpreter is locked 651*433d6423SLionel Sambuc * 652*433d6423SLionel Sambuc ******************************************************************************/ 653*433d6423SLionel Sambuc 654*433d6423SLionel Sambuc void 655*433d6423SLionel Sambuc AcpiDsTerminateControlMethod ( 656*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *MethodDesc, 657*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 658*433d6423SLionel Sambuc { 659*433d6423SLionel Sambuc 660*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); 661*433d6423SLionel Sambuc 662*433d6423SLionel Sambuc 663*433d6423SLionel Sambuc /* MethodDesc is required, WalkState is optional */ 664*433d6423SLionel Sambuc 665*433d6423SLionel Sambuc if (!MethodDesc) 666*433d6423SLionel Sambuc { 667*433d6423SLionel Sambuc return_VOID; 668*433d6423SLionel Sambuc } 669*433d6423SLionel Sambuc 670*433d6423SLionel Sambuc if (WalkState) 671*433d6423SLionel Sambuc { 672*433d6423SLionel Sambuc /* Delete all arguments and locals */ 673*433d6423SLionel Sambuc 674*433d6423SLionel Sambuc AcpiDsMethodDataDeleteAll (WalkState); 675*433d6423SLionel Sambuc 676*433d6423SLionel Sambuc /* 677*433d6423SLionel Sambuc * If method is serialized, release the mutex and restore the 678*433d6423SLionel Sambuc * current sync level for this thread 679*433d6423SLionel Sambuc */ 680*433d6423SLionel Sambuc if (MethodDesc->Method.Mutex) 681*433d6423SLionel Sambuc { 682*433d6423SLionel Sambuc /* Acquisition Depth handles recursive calls */ 683*433d6423SLionel Sambuc 684*433d6423SLionel Sambuc MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; 685*433d6423SLionel Sambuc if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) 686*433d6423SLionel Sambuc { 687*433d6423SLionel Sambuc WalkState->Thread->CurrentSyncLevel = 688*433d6423SLionel Sambuc MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; 689*433d6423SLionel Sambuc 690*433d6423SLionel Sambuc AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); 691*433d6423SLionel Sambuc MethodDesc->Method.Mutex->Mutex.ThreadId = 0; 692*433d6423SLionel Sambuc } 693*433d6423SLionel Sambuc } 694*433d6423SLionel Sambuc 695*433d6423SLionel Sambuc /* 696*433d6423SLionel Sambuc * Delete any namespace objects created anywhere within the 697*433d6423SLionel Sambuc * namespace by the execution of this method. Unless this method 698*433d6423SLionel Sambuc * is a module-level executable code method, in which case we 699*433d6423SLionel Sambuc * want make the objects permanent. 700*433d6423SLionel Sambuc */ 701*433d6423SLionel Sambuc if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) 702*433d6423SLionel Sambuc { 703*433d6423SLionel Sambuc /* Delete any direct children of (created by) this method */ 704*433d6423SLionel Sambuc 705*433d6423SLionel Sambuc AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode); 706*433d6423SLionel Sambuc 707*433d6423SLionel Sambuc /* 708*433d6423SLionel Sambuc * Delete any objects that were created by this method 709*433d6423SLionel Sambuc * elsewhere in the namespace (if any were created). 710*433d6423SLionel Sambuc */ 711*433d6423SLionel Sambuc if (MethodDesc->Method.Flags & AOPOBJ_MODIFIED_NAMESPACE) 712*433d6423SLionel Sambuc { 713*433d6423SLionel Sambuc AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); 714*433d6423SLionel Sambuc } 715*433d6423SLionel Sambuc } 716*433d6423SLionel Sambuc } 717*433d6423SLionel Sambuc 718*433d6423SLionel Sambuc /* Decrement the thread count on the method */ 719*433d6423SLionel Sambuc 720*433d6423SLionel Sambuc if (MethodDesc->Method.ThreadCount) 721*433d6423SLionel Sambuc { 722*433d6423SLionel Sambuc MethodDesc->Method.ThreadCount--; 723*433d6423SLionel Sambuc } 724*433d6423SLionel Sambuc else 725*433d6423SLionel Sambuc { 726*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 727*433d6423SLionel Sambuc "Invalid zero thread count in method")); 728*433d6423SLionel Sambuc } 729*433d6423SLionel Sambuc 730*433d6423SLionel Sambuc /* Are there any other threads currently executing this method? */ 731*433d6423SLionel Sambuc 732*433d6423SLionel Sambuc if (MethodDesc->Method.ThreadCount) 733*433d6423SLionel Sambuc { 734*433d6423SLionel Sambuc /* 735*433d6423SLionel Sambuc * Additional threads. Do not release the OwnerId in this case, 736*433d6423SLionel Sambuc * we immediately reuse it for the next thread executing this method 737*433d6423SLionel Sambuc */ 738*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 739*433d6423SLionel Sambuc "*** Completed execution of one thread, %u threads remaining\n", 740*433d6423SLionel Sambuc MethodDesc->Method.ThreadCount)); 741*433d6423SLionel Sambuc } 742*433d6423SLionel Sambuc else 743*433d6423SLionel Sambuc { 744*433d6423SLionel Sambuc /* This is the only executing thread for this method */ 745*433d6423SLionel Sambuc 746*433d6423SLionel Sambuc /* 747*433d6423SLionel Sambuc * Support to dynamically change a method from NotSerialized to 748*433d6423SLionel Sambuc * Serialized if it appears that the method is incorrectly written and 749*433d6423SLionel Sambuc * does not support multiple thread execution. The best example of this 750*433d6423SLionel Sambuc * is if such a method creates namespace objects and blocks. A second 751*433d6423SLionel Sambuc * thread will fail with an AE_ALREADY_EXISTS exception 752*433d6423SLionel Sambuc * 753*433d6423SLionel Sambuc * This code is here because we must wait until the last thread exits 754*433d6423SLionel Sambuc * before creating the synchronization semaphore. 755*433d6423SLionel Sambuc */ 756*433d6423SLionel Sambuc if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && 757*433d6423SLionel Sambuc (!MethodDesc->Method.Mutex)) 758*433d6423SLionel Sambuc { 759*433d6423SLionel Sambuc (void) AcpiDsCreateMethodMutex (MethodDesc); 760*433d6423SLionel Sambuc } 761*433d6423SLionel Sambuc 762*433d6423SLionel Sambuc /* No more threads, we can free the OwnerId */ 763*433d6423SLionel Sambuc 764*433d6423SLionel Sambuc if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) 765*433d6423SLionel Sambuc { 766*433d6423SLionel Sambuc AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); 767*433d6423SLionel Sambuc } 768*433d6423SLionel Sambuc } 769*433d6423SLionel Sambuc 770*433d6423SLionel Sambuc return_VOID; 771*433d6423SLionel Sambuc } 772*433d6423SLionel Sambuc 773*433d6423SLionel Sambuc 774