1a159c266SJung-uk Kim /******************************************************************************* 2a159c266SJung-uk Kim * 3a159c266SJung-uk Kim * Module Name: dbmethod - Debug commands for control methods 4a159c266SJung-uk Kim * 5a159c266SJung-uk Kim ******************************************************************************/ 6a159c266SJung-uk Kim 7a159c266SJung-uk Kim /* 8efcc2a30SJung-uk Kim * Copyright (C) 2000 - 2013, Intel Corp. 9a159c266SJung-uk Kim * All rights reserved. 10a159c266SJung-uk Kim * 11a159c266SJung-uk Kim * Redistribution and use in source and binary forms, with or without 12a159c266SJung-uk Kim * modification, are permitted provided that the following conditions 13a159c266SJung-uk Kim * are met: 14a159c266SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 15a159c266SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 16a159c266SJung-uk Kim * without modification. 17a159c266SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18a159c266SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 19a159c266SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 20a159c266SJung-uk Kim * including a substantially similar Disclaimer requirement for further 21a159c266SJung-uk Kim * binary redistribution. 22a159c266SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 23a159c266SJung-uk Kim * of any contributors may be used to endorse or promote products derived 24a159c266SJung-uk Kim * from this software without specific prior written permission. 25a159c266SJung-uk Kim * 26a159c266SJung-uk Kim * Alternatively, this software may be distributed under the terms of the 27a159c266SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 28a159c266SJung-uk Kim * Software Foundation. 29a159c266SJung-uk Kim * 30a159c266SJung-uk Kim * NO WARRANTY 31a159c266SJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32a159c266SJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33a159c266SJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34a159c266SJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35a159c266SJung-uk Kim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36a159c266SJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37a159c266SJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38a159c266SJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39a159c266SJung-uk Kim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40a159c266SJung-uk Kim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41a159c266SJung-uk Kim * POSSIBILITY OF SUCH DAMAGES. 42a159c266SJung-uk Kim */ 43a159c266SJung-uk Kim 44a159c266SJung-uk Kim 45a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h> 46a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h> 47a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h> 48a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 49a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdebug.h> 50a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 51a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 52a159c266SJung-uk Kim 53a159c266SJung-uk Kim 54a159c266SJung-uk Kim #ifdef ACPI_DEBUGGER 55a159c266SJung-uk Kim 56a159c266SJung-uk Kim #define _COMPONENT ACPI_CA_DEBUGGER 57a159c266SJung-uk Kim ACPI_MODULE_NAME ("dbmethod") 58a159c266SJung-uk Kim 59a159c266SJung-uk Kim 60a159c266SJung-uk Kim /* Local prototypes */ 61a159c266SJung-uk Kim 62a159c266SJung-uk Kim static ACPI_STATUS 63a159c266SJung-uk Kim AcpiDbWalkForExecute ( 64a159c266SJung-uk Kim ACPI_HANDLE ObjHandle, 65a159c266SJung-uk Kim UINT32 NestingLevel, 66a159c266SJung-uk Kim void *Context, 67a159c266SJung-uk Kim void **ReturnValue); 68a159c266SJung-uk Kim 69a159c266SJung-uk Kim 70a159c266SJung-uk Kim /******************************************************************************* 71a159c266SJung-uk Kim * 72a159c266SJung-uk Kim * FUNCTION: AcpiDbSetMethodBreakpoint 73a159c266SJung-uk Kim * 74a159c266SJung-uk Kim * PARAMETERS: Location - AML offset of breakpoint 75a159c266SJung-uk Kim * WalkState - Current walk info 76a159c266SJung-uk Kim * Op - Current Op (from parse walk) 77a159c266SJung-uk Kim * 78a159c266SJung-uk Kim * RETURN: None 79a159c266SJung-uk Kim * 80a159c266SJung-uk Kim * DESCRIPTION: Set a breakpoint in a control method at the specified 81a159c266SJung-uk Kim * AML offset 82a159c266SJung-uk Kim * 83a159c266SJung-uk Kim ******************************************************************************/ 84a159c266SJung-uk Kim 85a159c266SJung-uk Kim void 86a159c266SJung-uk Kim AcpiDbSetMethodBreakpoint ( 87a159c266SJung-uk Kim char *Location, 88a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 89a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op) 90a159c266SJung-uk Kim { 91a159c266SJung-uk Kim UINT32 Address; 92a159c266SJung-uk Kim 93a159c266SJung-uk Kim 94a159c266SJung-uk Kim if (!Op) 95a159c266SJung-uk Kim { 96a159c266SJung-uk Kim AcpiOsPrintf ("There is no method currently executing\n"); 97a159c266SJung-uk Kim return; 98a159c266SJung-uk Kim } 99a159c266SJung-uk Kim 100a159c266SJung-uk Kim /* Get and verify the breakpoint address */ 101a159c266SJung-uk Kim 102a159c266SJung-uk Kim Address = ACPI_STRTOUL (Location, NULL, 16); 103a159c266SJung-uk Kim if (Address <= Op->Common.AmlOffset) 104a159c266SJung-uk Kim { 105a159c266SJung-uk Kim AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", 106a159c266SJung-uk Kim Address, Op->Common.AmlOffset); 107a159c266SJung-uk Kim } 108a159c266SJung-uk Kim 109a159c266SJung-uk Kim /* Save breakpoint in current walk */ 110a159c266SJung-uk Kim 111a159c266SJung-uk Kim WalkState->UserBreakpoint = Address; 112a159c266SJung-uk Kim AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); 113a159c266SJung-uk Kim } 114a159c266SJung-uk Kim 115a159c266SJung-uk Kim 116a159c266SJung-uk Kim /******************************************************************************* 117a159c266SJung-uk Kim * 118a159c266SJung-uk Kim * FUNCTION: AcpiDbSetMethodCallBreakpoint 119a159c266SJung-uk Kim * 120a159c266SJung-uk Kim * PARAMETERS: Op - Current Op (from parse walk) 121a159c266SJung-uk Kim * 122a159c266SJung-uk Kim * RETURN: None 123a159c266SJung-uk Kim * 124a159c266SJung-uk Kim * DESCRIPTION: Set a breakpoint in a control method at the specified 125a159c266SJung-uk Kim * AML offset 126a159c266SJung-uk Kim * 127a159c266SJung-uk Kim ******************************************************************************/ 128a159c266SJung-uk Kim 129a159c266SJung-uk Kim void 130a159c266SJung-uk Kim AcpiDbSetMethodCallBreakpoint ( 131a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op) 132a159c266SJung-uk Kim { 133a159c266SJung-uk Kim 134a159c266SJung-uk Kim 135a159c266SJung-uk Kim if (!Op) 136a159c266SJung-uk Kim { 137a159c266SJung-uk Kim AcpiOsPrintf ("There is no method currently executing\n"); 138a159c266SJung-uk Kim return; 139a159c266SJung-uk Kim } 140a159c266SJung-uk Kim 141a159c266SJung-uk Kim AcpiGbl_StepToNextCall = TRUE; 142a159c266SJung-uk Kim } 143a159c266SJung-uk Kim 144a159c266SJung-uk Kim 145a159c266SJung-uk Kim /******************************************************************************* 146a159c266SJung-uk Kim * 147a159c266SJung-uk Kim * FUNCTION: AcpiDbSetMethodData 148a159c266SJung-uk Kim * 149a159c266SJung-uk Kim * PARAMETERS: TypeArg - L for local, A for argument 150a159c266SJung-uk Kim * IndexArg - which one 151a159c266SJung-uk Kim * ValueArg - Value to set. 152a159c266SJung-uk Kim * 153a159c266SJung-uk Kim * RETURN: None 154a159c266SJung-uk Kim * 155a159c266SJung-uk Kim * DESCRIPTION: Set a local or argument for the running control method. 156a159c266SJung-uk Kim * NOTE: only object supported is Number. 157a159c266SJung-uk Kim * 158a159c266SJung-uk Kim ******************************************************************************/ 159a159c266SJung-uk Kim 160a159c266SJung-uk Kim void 161a159c266SJung-uk Kim AcpiDbSetMethodData ( 162a159c266SJung-uk Kim char *TypeArg, 163a159c266SJung-uk Kim char *IndexArg, 164a159c266SJung-uk Kim char *ValueArg) 165a159c266SJung-uk Kim { 166a159c266SJung-uk Kim char Type; 167a159c266SJung-uk Kim UINT32 Index; 168a159c266SJung-uk Kim UINT32 Value; 169a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState; 170a159c266SJung-uk Kim ACPI_OPERAND_OBJECT *ObjDesc; 171a159c266SJung-uk Kim ACPI_STATUS Status; 172a159c266SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 173a159c266SJung-uk Kim 174a159c266SJung-uk Kim 175a159c266SJung-uk Kim /* Validate TypeArg */ 176a159c266SJung-uk Kim 177a159c266SJung-uk Kim AcpiUtStrupr (TypeArg); 178a159c266SJung-uk Kim Type = TypeArg[0]; 179a159c266SJung-uk Kim if ((Type != 'L') && 180a159c266SJung-uk Kim (Type != 'A') && 181a159c266SJung-uk Kim (Type != 'N')) 182a159c266SJung-uk Kim { 183a159c266SJung-uk Kim AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 184a159c266SJung-uk Kim return; 185a159c266SJung-uk Kim } 186a159c266SJung-uk Kim 187a159c266SJung-uk Kim Value = ACPI_STRTOUL (ValueArg, NULL, 16); 188a159c266SJung-uk Kim 189a159c266SJung-uk Kim if (Type == 'N') 190a159c266SJung-uk Kim { 191a159c266SJung-uk Kim Node = AcpiDbConvertToNode (IndexArg); 192a159c266SJung-uk Kim if (Node->Type != ACPI_TYPE_INTEGER) 193a159c266SJung-uk Kim { 194a159c266SJung-uk Kim AcpiOsPrintf ("Can only set Integer nodes\n"); 195a159c266SJung-uk Kim return; 196a159c266SJung-uk Kim } 197a159c266SJung-uk Kim ObjDesc = Node->Object; 198a159c266SJung-uk Kim ObjDesc->Integer.Value = Value; 199a159c266SJung-uk Kim return; 200a159c266SJung-uk Kim } 201a159c266SJung-uk Kim 202a159c266SJung-uk Kim /* Get the index and value */ 203a159c266SJung-uk Kim 204a159c266SJung-uk Kim Index = ACPI_STRTOUL (IndexArg, NULL, 16); 205a159c266SJung-uk Kim 206a159c266SJung-uk Kim WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 207a159c266SJung-uk Kim if (!WalkState) 208a159c266SJung-uk Kim { 209a159c266SJung-uk Kim AcpiOsPrintf ("There is no method currently executing\n"); 210a159c266SJung-uk Kim return; 211a159c266SJung-uk Kim } 212a159c266SJung-uk Kim 213a159c266SJung-uk Kim /* Create and initialize the new object */ 214a159c266SJung-uk Kim 215a159c266SJung-uk Kim ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value); 216a159c266SJung-uk Kim if (!ObjDesc) 217a159c266SJung-uk Kim { 218a159c266SJung-uk Kim AcpiOsPrintf ("Could not create an internal object\n"); 219a159c266SJung-uk Kim return; 220a159c266SJung-uk Kim } 221a159c266SJung-uk Kim 222a159c266SJung-uk Kim /* Store the new object into the target */ 223a159c266SJung-uk Kim 224a159c266SJung-uk Kim switch (Type) 225a159c266SJung-uk Kim { 226a159c266SJung-uk Kim case 'A': 227a159c266SJung-uk Kim 228a159c266SJung-uk Kim /* Set a method argument */ 229a159c266SJung-uk Kim 230a159c266SJung-uk Kim if (Index > ACPI_METHOD_MAX_ARG) 231a159c266SJung-uk Kim { 232a159c266SJung-uk Kim AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); 233a159c266SJung-uk Kim goto Cleanup; 234a159c266SJung-uk Kim } 235a159c266SJung-uk Kim 236a159c266SJung-uk Kim Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, 237a159c266SJung-uk Kim WalkState); 238a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 239a159c266SJung-uk Kim { 240a159c266SJung-uk Kim goto Cleanup; 241a159c266SJung-uk Kim } 242a159c266SJung-uk Kim 243a159c266SJung-uk Kim ObjDesc = WalkState->Arguments[Index].Object; 244a159c266SJung-uk Kim 245a159c266SJung-uk Kim AcpiOsPrintf ("Arg%u: ", Index); 246a159c266SJung-uk Kim AcpiDmDisplayInternalObject (ObjDesc, WalkState); 247a159c266SJung-uk Kim break; 248a159c266SJung-uk Kim 249a159c266SJung-uk Kim case 'L': 250a159c266SJung-uk Kim 251a159c266SJung-uk Kim /* Set a method local */ 252a159c266SJung-uk Kim 253a159c266SJung-uk Kim if (Index > ACPI_METHOD_MAX_LOCAL) 254a159c266SJung-uk Kim { 255a159c266SJung-uk Kim AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); 256a159c266SJung-uk Kim goto Cleanup; 257a159c266SJung-uk Kim } 258a159c266SJung-uk Kim 259a159c266SJung-uk Kim Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, 260a159c266SJung-uk Kim WalkState); 261a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 262a159c266SJung-uk Kim { 263a159c266SJung-uk Kim goto Cleanup; 264a159c266SJung-uk Kim } 265a159c266SJung-uk Kim 266a159c266SJung-uk Kim ObjDesc = WalkState->LocalVariables[Index].Object; 267a159c266SJung-uk Kim 268a159c266SJung-uk Kim AcpiOsPrintf ("Local%u: ", Index); 269a159c266SJung-uk Kim AcpiDmDisplayInternalObject (ObjDesc, WalkState); 270a159c266SJung-uk Kim break; 271a159c266SJung-uk Kim 272a159c266SJung-uk Kim default: 273a159c266SJung-uk Kim break; 274a159c266SJung-uk Kim } 275a159c266SJung-uk Kim 276a159c266SJung-uk Kim Cleanup: 277a159c266SJung-uk Kim AcpiUtRemoveReference (ObjDesc); 278a159c266SJung-uk Kim } 279a159c266SJung-uk Kim 280a159c266SJung-uk Kim 281a159c266SJung-uk Kim /******************************************************************************* 282a159c266SJung-uk Kim * 283a159c266SJung-uk Kim * FUNCTION: AcpiDbDisassembleAml 284a159c266SJung-uk Kim * 285a159c266SJung-uk Kim * PARAMETERS: Statements - Number of statements to disassemble 286a159c266SJung-uk Kim * Op - Current Op (from parse walk) 287a159c266SJung-uk Kim * 288a159c266SJung-uk Kim * RETURN: None 289a159c266SJung-uk Kim * 290a159c266SJung-uk Kim * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 291a159c266SJung-uk Kim * of statements specified. 292a159c266SJung-uk Kim * 293a159c266SJung-uk Kim ******************************************************************************/ 294a159c266SJung-uk Kim 295a159c266SJung-uk Kim void 296a159c266SJung-uk Kim AcpiDbDisassembleAml ( 297a159c266SJung-uk Kim char *Statements, 298a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op) 299a159c266SJung-uk Kim { 300a159c266SJung-uk Kim UINT32 NumStatements = 8; 301a159c266SJung-uk Kim 302a159c266SJung-uk Kim 303a159c266SJung-uk Kim if (!Op) 304a159c266SJung-uk Kim { 305a159c266SJung-uk Kim AcpiOsPrintf ("There is no method currently executing\n"); 306a159c266SJung-uk Kim return; 307a159c266SJung-uk Kim } 308a159c266SJung-uk Kim 309a159c266SJung-uk Kim if (Statements) 310a159c266SJung-uk Kim { 311a159c266SJung-uk Kim NumStatements = ACPI_STRTOUL (Statements, NULL, 0); 312a159c266SJung-uk Kim } 313a159c266SJung-uk Kim 314a159c266SJung-uk Kim #ifdef ACPI_DISASSEMBLER 315a159c266SJung-uk Kim AcpiDmDisassemble (NULL, Op, NumStatements); 316a159c266SJung-uk Kim #endif 317a159c266SJung-uk Kim } 318a159c266SJung-uk Kim 319a159c266SJung-uk Kim 320a159c266SJung-uk Kim /******************************************************************************* 321a159c266SJung-uk Kim * 322a159c266SJung-uk Kim * FUNCTION: AcpiDbDisassembleMethod 323a159c266SJung-uk Kim * 324a159c266SJung-uk Kim * PARAMETERS: Name - Name of control method 325a159c266SJung-uk Kim * 326a159c266SJung-uk Kim * RETURN: None 327a159c266SJung-uk Kim * 328a159c266SJung-uk Kim * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 329a159c266SJung-uk Kim * of statements specified. 330a159c266SJung-uk Kim * 331a159c266SJung-uk Kim ******************************************************************************/ 332a159c266SJung-uk Kim 333a159c266SJung-uk Kim ACPI_STATUS 334a159c266SJung-uk Kim AcpiDbDisassembleMethod ( 335a159c266SJung-uk Kim char *Name) 336a159c266SJung-uk Kim { 337a159c266SJung-uk Kim ACPI_STATUS Status; 338a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op; 339a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState; 340a159c266SJung-uk Kim ACPI_OPERAND_OBJECT *ObjDesc; 341a159c266SJung-uk Kim ACPI_NAMESPACE_NODE *Method; 342a159c266SJung-uk Kim 343a159c266SJung-uk Kim 344a159c266SJung-uk Kim Method = AcpiDbConvertToNode (Name); 345a159c266SJung-uk Kim if (!Method) 346a159c266SJung-uk Kim { 347a159c266SJung-uk Kim return (AE_BAD_PARAMETER); 348a159c266SJung-uk Kim } 349a159c266SJung-uk Kim 350ed17e06eSJung-uk Kim if (Method->Type != ACPI_TYPE_METHOD) 351ed17e06eSJung-uk Kim { 352ed17e06eSJung-uk Kim ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method", 353ed17e06eSJung-uk Kim Name, AcpiUtGetTypeName (Method->Type))); 354ed17e06eSJung-uk Kim return (AE_BAD_PARAMETER); 355ed17e06eSJung-uk Kim } 356ed17e06eSJung-uk Kim 357a159c266SJung-uk Kim ObjDesc = Method->Object; 358a159c266SJung-uk Kim 359a159c266SJung-uk Kim Op = AcpiPsCreateScopeOp (); 360a159c266SJung-uk Kim if (!Op) 361a159c266SJung-uk Kim { 362a159c266SJung-uk Kim return (AE_NO_MEMORY); 363a159c266SJung-uk Kim } 364a159c266SJung-uk Kim 365a159c266SJung-uk Kim /* Create and initialize a new walk state */ 366a159c266SJung-uk Kim 367a159c266SJung-uk Kim WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); 368a159c266SJung-uk Kim if (!WalkState) 369a159c266SJung-uk Kim { 370a159c266SJung-uk Kim return (AE_NO_MEMORY); 371a159c266SJung-uk Kim } 372a159c266SJung-uk Kim 373a159c266SJung-uk Kim Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, 374a159c266SJung-uk Kim ObjDesc->Method.AmlStart, 375a159c266SJung-uk Kim ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); 376a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 377a159c266SJung-uk Kim { 378a159c266SJung-uk Kim return (Status); 379a159c266SJung-uk Kim } 380a159c266SJung-uk Kim 381ed17e06eSJung-uk Kim Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); 382ed17e06eSJung-uk Kim WalkState->OwnerId = ObjDesc->Method.OwnerId; 383ed17e06eSJung-uk Kim 384ed17e06eSJung-uk Kim /* Push start scope on scope stack and make it current */ 385ed17e06eSJung-uk Kim 386ed17e06eSJung-uk Kim Status = AcpiDsScopeStackPush (Method, 387ed17e06eSJung-uk Kim Method->Type, WalkState); 388ed17e06eSJung-uk Kim if (ACPI_FAILURE (Status)) 389ed17e06eSJung-uk Kim { 390ed17e06eSJung-uk Kim return (Status); 391ed17e06eSJung-uk Kim } 392ed17e06eSJung-uk Kim 393ed17e06eSJung-uk Kim /* Parse the entire method AML including deferred operators */ 394a159c266SJung-uk Kim 395a159c266SJung-uk Kim WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; 396a159c266SJung-uk Kim WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; 397a159c266SJung-uk Kim 398ed17e06eSJung-uk Kim Status = AcpiPsParseAml (WalkState); 399efcc2a30SJung-uk Kim (void) AcpiDmParseDeferredOps (Op); 400ed17e06eSJung-uk Kim 401ed17e06eSJung-uk Kim /* Now we can disassemble the method */ 402ed17e06eSJung-uk Kim 403ed17e06eSJung-uk Kim AcpiGbl_DbOpt_verbose = FALSE; 404a159c266SJung-uk Kim #ifdef ACPI_DISASSEMBLER 405a159c266SJung-uk Kim AcpiDmDisassemble (NULL, Op, 0); 406a159c266SJung-uk Kim #endif 407ed17e06eSJung-uk Kim AcpiGbl_DbOpt_verbose = TRUE; 408ed17e06eSJung-uk Kim 409a159c266SJung-uk Kim AcpiPsDeleteParseTree (Op); 410ed17e06eSJung-uk Kim 411ed17e06eSJung-uk Kim /* Method cleanup */ 412ed17e06eSJung-uk Kim 413ed17e06eSJung-uk Kim AcpiNsDeleteNamespaceSubtree (Method); 414ed17e06eSJung-uk Kim AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId); 415ed17e06eSJung-uk Kim AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId); 416a159c266SJung-uk Kim return (AE_OK); 417a159c266SJung-uk Kim } 418a159c266SJung-uk Kim 419a159c266SJung-uk Kim 420a159c266SJung-uk Kim /******************************************************************************* 421a159c266SJung-uk Kim * 422a159c266SJung-uk Kim * FUNCTION: AcpiDbWalkForExecute 423a159c266SJung-uk Kim * 424a159c266SJung-uk Kim * PARAMETERS: Callback from WalkNamespace 425a159c266SJung-uk Kim * 426a159c266SJung-uk Kim * RETURN: Status 427a159c266SJung-uk Kim * 428a159c266SJung-uk Kim * DESCRIPTION: Batch execution module. Currently only executes predefined 429a159c266SJung-uk Kim * ACPI names. 430a159c266SJung-uk Kim * 431a159c266SJung-uk Kim ******************************************************************************/ 432a159c266SJung-uk Kim 433a159c266SJung-uk Kim static ACPI_STATUS 434a159c266SJung-uk Kim AcpiDbWalkForExecute ( 435a159c266SJung-uk Kim ACPI_HANDLE ObjHandle, 436a159c266SJung-uk Kim UINT32 NestingLevel, 437a159c266SJung-uk Kim void *Context, 438a159c266SJung-uk Kim void **ReturnValue) 439a159c266SJung-uk Kim { 440a159c266SJung-uk Kim ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 441042ff955SJung-uk Kim ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context; 442a159c266SJung-uk Kim ACPI_BUFFER ReturnObj; 443a159c266SJung-uk Kim ACPI_STATUS Status; 444a159c266SJung-uk Kim char *Pathname; 445a159c266SJung-uk Kim UINT32 i; 446a159c266SJung-uk Kim ACPI_DEVICE_INFO *ObjInfo; 447a159c266SJung-uk Kim ACPI_OBJECT_LIST ParamObjects; 448a159c266SJung-uk Kim ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; 449a159c266SJung-uk Kim const ACPI_PREDEFINED_INFO *Predefined; 450a159c266SJung-uk Kim 451a159c266SJung-uk Kim 452*9c7c683cSJung-uk Kim Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); 453a159c266SJung-uk Kim if (!Predefined) 454a159c266SJung-uk Kim { 455a159c266SJung-uk Kim return (AE_OK); 456a159c266SJung-uk Kim } 457a159c266SJung-uk Kim 458a159c266SJung-uk Kim if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 459a159c266SJung-uk Kim { 460a159c266SJung-uk Kim return (AE_OK); 461a159c266SJung-uk Kim } 462a159c266SJung-uk Kim 463a159c266SJung-uk Kim Pathname = AcpiNsGetExternalPathname (Node); 464a159c266SJung-uk Kim if (!Pathname) 465a159c266SJung-uk Kim { 466a159c266SJung-uk Kim return (AE_OK); 467a159c266SJung-uk Kim } 468a159c266SJung-uk Kim 469a159c266SJung-uk Kim /* Get the object info for number of method parameters */ 470a159c266SJung-uk Kim 471a159c266SJung-uk Kim Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); 472a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 473a159c266SJung-uk Kim { 474a159c266SJung-uk Kim return (Status); 475a159c266SJung-uk Kim } 476a159c266SJung-uk Kim 477a159c266SJung-uk Kim ParamObjects.Pointer = NULL; 478a159c266SJung-uk Kim ParamObjects.Count = 0; 479a159c266SJung-uk Kim 480a159c266SJung-uk Kim if (ObjInfo->Type == ACPI_TYPE_METHOD) 481a159c266SJung-uk Kim { 482a159c266SJung-uk Kim /* Setup default parameters */ 483a159c266SJung-uk Kim 484a159c266SJung-uk Kim for (i = 0; i < ObjInfo->ParamCount; i++) 485a159c266SJung-uk Kim { 486a159c266SJung-uk Kim Params[i].Type = ACPI_TYPE_INTEGER; 487a159c266SJung-uk Kim Params[i].Integer.Value = 1; 488a159c266SJung-uk Kim } 489a159c266SJung-uk Kim 490a159c266SJung-uk Kim ParamObjects.Pointer = Params; 491a159c266SJung-uk Kim ParamObjects.Count = ObjInfo->ParamCount; 492a159c266SJung-uk Kim } 493a159c266SJung-uk Kim 494a159c266SJung-uk Kim ACPI_FREE (ObjInfo); 495a159c266SJung-uk Kim ReturnObj.Pointer = NULL; 496a159c266SJung-uk Kim ReturnObj.Length = ACPI_ALLOCATE_BUFFER; 497a159c266SJung-uk Kim 498a159c266SJung-uk Kim /* Do the actual method execution */ 499a159c266SJung-uk Kim 500a159c266SJung-uk Kim AcpiGbl_MethodExecuting = TRUE; 501a159c266SJung-uk Kim 502a159c266SJung-uk Kim Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); 503a159c266SJung-uk Kim 504a159c266SJung-uk Kim AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); 505a159c266SJung-uk Kim AcpiGbl_MethodExecuting = FALSE; 506a159c266SJung-uk Kim ACPI_FREE (Pathname); 507a159c266SJung-uk Kim 508a159c266SJung-uk Kim /* Ignore status from method execution */ 509a159c266SJung-uk Kim 510a159c266SJung-uk Kim Status = AE_OK; 511a159c266SJung-uk Kim 512a159c266SJung-uk Kim /* Update count, check if we have executed enough methods */ 513a159c266SJung-uk Kim 514a159c266SJung-uk Kim Info->Count++; 515a159c266SJung-uk Kim if (Info->Count >= Info->MaxCount) 516a159c266SJung-uk Kim { 517a159c266SJung-uk Kim Status = AE_CTRL_TERMINATE; 518a159c266SJung-uk Kim } 519a159c266SJung-uk Kim 520a159c266SJung-uk Kim return (Status); 521a159c266SJung-uk Kim } 522a159c266SJung-uk Kim 523a159c266SJung-uk Kim 524a159c266SJung-uk Kim /******************************************************************************* 525a159c266SJung-uk Kim * 526a159c266SJung-uk Kim * FUNCTION: AcpiDbBatchExecute 527a159c266SJung-uk Kim * 528a159c266SJung-uk Kim * PARAMETERS: CountArg - Max number of methods to execute 529a159c266SJung-uk Kim * 530a159c266SJung-uk Kim * RETURN: None 531a159c266SJung-uk Kim * 532a159c266SJung-uk Kim * DESCRIPTION: Namespace batch execution. Execute predefined names in the 533a159c266SJung-uk Kim * namespace, up to the max count, if specified. 534a159c266SJung-uk Kim * 535a159c266SJung-uk Kim ******************************************************************************/ 536a159c266SJung-uk Kim 537a159c266SJung-uk Kim void 538a159c266SJung-uk Kim AcpiDbBatchExecute ( 539a159c266SJung-uk Kim char *CountArg) 540a159c266SJung-uk Kim { 541042ff955SJung-uk Kim ACPI_DB_EXECUTE_WALK Info; 542a159c266SJung-uk Kim 543a159c266SJung-uk Kim 544a159c266SJung-uk Kim Info.Count = 0; 545a159c266SJung-uk Kim Info.MaxCount = ACPI_UINT32_MAX; 546a159c266SJung-uk Kim 547a159c266SJung-uk Kim if (CountArg) 548a159c266SJung-uk Kim { 549a159c266SJung-uk Kim Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0); 550a159c266SJung-uk Kim } 551a159c266SJung-uk Kim 552a159c266SJung-uk Kim 553a159c266SJung-uk Kim /* Search all nodes in namespace */ 554a159c266SJung-uk Kim 555a159c266SJung-uk Kim (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 556a159c266SJung-uk Kim AcpiDbWalkForExecute, NULL, (void *) &Info, NULL); 557a159c266SJung-uk Kim 558042ff955SJung-uk Kim AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count); 559a159c266SJung-uk Kim } 560a159c266SJung-uk Kim 561a159c266SJung-uk Kim #endif /* ACPI_DEBUGGER */ 562