Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure
   1 /*******************************************************************************
   2  *
   3  * Module Name: dbxface - AML Debugger external interfaces
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 215         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
 216             Op->Common.AmlOffset);
 217         AcpiGbl_CmSingleStep = TRUE;
 218         AcpiGbl_StepToNextCall = FALSE;
 219         WalkState->MethodBreakpoint = 0;
 220     }
 221 
 222     /*
 223      * Check if this is an opcode that we are interested in --
 224      * namely, opcodes that have arguments
 225      */
 226     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
 227     {
 228         return (AE_OK);
 229     }
 230 
 231     switch (OpcodeClass)
 232     {
 233     case AML_CLASS_UNKNOWN:
 234     case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */

 235         return (AE_OK);
 236 
 237     default:

 238         /* All other opcodes -- continue */
 239         break;
 240     }
 241 
 242     /*
 243      * Under certain debug conditions, display this opcode and its operands
 244      */
 245     if ((AcpiGbl_DbOutputToFile)            ||
 246         (AcpiGbl_CmSingleStep)              ||
 247         (AcpiDbgLevel & ACPI_LV_PARSE))
 248     {
 249         if ((AcpiGbl_DbOutputToFile)        ||
 250             (AcpiDbgLevel & ACPI_LV_PARSE))
 251         {
 252             AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
 253         }
 254 
 255         /*
 256          * Display this op (and only this op - zero out the NEXT field
 257          * temporarily, and disable parser trace output for the duration of


 391 
 392 /*******************************************************************************
 393  *
 394  * FUNCTION:    AcpiDbInitialize
 395  *
 396  * PARAMETERS:  None
 397  *
 398  * RETURN:      Status
 399  *
 400  * DESCRIPTION: Init and start debugger
 401  *
 402  ******************************************************************************/
 403 
 404 ACPI_STATUS
 405 AcpiDbInitialize (
 406     void)
 407 {
 408     ACPI_STATUS             Status;
 409 
 410 



 411     /* Init globals */
 412 
 413     AcpiGbl_DbBuffer            = NULL;
 414     AcpiGbl_DbFilename          = NULL;
 415     AcpiGbl_DbOutputToFile      = FALSE;
 416 
 417     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
 418     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
 419     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
 420 
 421     AcpiGbl_DbOpt_tables        = FALSE;
 422     AcpiGbl_DbOpt_disasm        = FALSE;
 423     AcpiGbl_DbOpt_stats         = FALSE;
 424     AcpiGbl_DbOpt_verbose       = TRUE;
 425     AcpiGbl_DbOpt_ini_methods   = TRUE;
 426 
 427     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
 428     if (!AcpiGbl_DbBuffer)
 429     {
 430         return (AE_NO_MEMORY);
 431     }
 432     ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
 433 
 434     /* Initial scope is the root */
 435 
 436     AcpiGbl_DbScopeBuf [0] = '\\';
 437     AcpiGbl_DbScopeBuf [1] =  0;
 438     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
 439 
 440     /*
 441      * If configured for multi-thread support, the debug executor runs in
 442      * a separate thread so that the front end can be in another address
 443      * space, environment, or even another machine.
 444      */
 445     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
 446     {
 447         /* These were created with one unit, grab it */
 448 
 449         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
 450         if (ACPI_FAILURE (Status))
 451         {
 452             AcpiOsPrintf ("Could not get debugger mutex\n");
 453             return (Status);
 454         }
 455 
 456         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
 457         if (ACPI_FAILURE (Status))
 458         {
 459             AcpiOsPrintf ("Could not get debugger mutex\n");
 460             return (Status);
 461         }
 462 
 463         /* Create the debug execution thread to execute commands */
 464 
 465         Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL);
 466         if (ACPI_FAILURE (Status))
 467         {
 468             AcpiOsPrintf ("Could not start debugger thread\n");
 469             return (Status);
 470         }
 471     }
 472 
 473     if (!AcpiGbl_DbOpt_verbose)
 474     {
 475         AcpiGbl_DbOpt_disasm = TRUE;
 476         AcpiGbl_DbOpt_stats = FALSE;
 477     }
 478 
 479     return (AE_OK);
 480 }
 481 
 482 
 483 /*******************************************************************************
 484  *
 485  * FUNCTION:    AcpiDbTerminate
 486  *
 487  * PARAMETERS:  None
 488  *
 489  * RETURN:      None
 490  *
 491  * DESCRIPTION: Stop debugger
 492  *
 493  ******************************************************************************/
 494 
 495 void
 496 AcpiDbTerminate (
 497     void)
 498 {
 499 
 500     if (AcpiGbl_DbBuffer)
 501     {
 502         AcpiOsFree (AcpiGbl_DbBuffer);

 503     }




 504 }
 505 
 506 
 507 #ifdef ACPI_OBSOLETE_FUNCTIONS
 508 /*******************************************************************************
 509  *
 510  * FUNCTION:    AcpiDbMethodEnd
 511  *
 512  * PARAMETERS:  WalkState       - Current walk
 513  *
 514  * RETURN:      Status
 515  *
 516  * DESCRIPTION: Called at method termination
 517  *
 518  ******************************************************************************/
 519 
 520 void
 521 AcpiDbMethodEnd (
 522     ACPI_WALK_STATE         *WalkState)
 523 {
   1 /*******************************************************************************
   2  *
   3  * Module Name: dbxface - AML Debugger external interfaces
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 215         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
 216             Op->Common.AmlOffset);
 217         AcpiGbl_CmSingleStep = TRUE;
 218         AcpiGbl_StepToNextCall = FALSE;
 219         WalkState->MethodBreakpoint = 0;
 220     }
 221 
 222     /*
 223      * Check if this is an opcode that we are interested in --
 224      * namely, opcodes that have arguments
 225      */
 226     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
 227     {
 228         return (AE_OK);
 229     }
 230 
 231     switch (OpcodeClass)
 232     {
 233     case AML_CLASS_UNKNOWN:
 234     case AML_CLASS_ARGUMENT:    /* constants, literals, etc. do nothing */
 235 
 236         return (AE_OK);
 237 
 238     default:
 239 
 240         /* All other opcodes -- continue */
 241         break;
 242     }
 243 
 244     /*
 245      * Under certain debug conditions, display this opcode and its operands
 246      */
 247     if ((AcpiGbl_DbOutputToFile)            ||
 248         (AcpiGbl_CmSingleStep)              ||
 249         (AcpiDbgLevel & ACPI_LV_PARSE))
 250     {
 251         if ((AcpiGbl_DbOutputToFile)        ||
 252             (AcpiDbgLevel & ACPI_LV_PARSE))
 253         {
 254             AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
 255         }
 256 
 257         /*
 258          * Display this op (and only this op - zero out the NEXT field
 259          * temporarily, and disable parser trace output for the duration of


 393 
 394 /*******************************************************************************
 395  *
 396  * FUNCTION:    AcpiDbInitialize
 397  *
 398  * PARAMETERS:  None
 399  *
 400  * RETURN:      Status
 401  *
 402  * DESCRIPTION: Init and start debugger
 403  *
 404  ******************************************************************************/
 405 
 406 ACPI_STATUS
 407 AcpiDbInitialize (
 408     void)
 409 {
 410     ACPI_STATUS             Status;
 411 
 412 
 413     ACPI_FUNCTION_TRACE (DbInitialize);
 414 
 415 
 416     /* Init globals */
 417 
 418     AcpiGbl_DbBuffer            = NULL;
 419     AcpiGbl_DbFilename          = NULL;
 420     AcpiGbl_DbOutputToFile      = FALSE;
 421 
 422     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
 423     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
 424     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
 425 
 426     AcpiGbl_DbOpt_tables        = FALSE;
 427     AcpiGbl_DbOpt_disasm        = FALSE;
 428     AcpiGbl_DbOpt_stats         = FALSE;
 429     AcpiGbl_DbOpt_verbose       = TRUE;
 430     AcpiGbl_DbOpt_ini_methods   = TRUE;
 431 
 432     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
 433     if (!AcpiGbl_DbBuffer)
 434     {
 435         return_ACPI_STATUS (AE_NO_MEMORY);
 436     }
 437     ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
 438 
 439     /* Initial scope is the root */
 440 
 441     AcpiGbl_DbScopeBuf [0] = AML_ROOT_PREFIX;
 442     AcpiGbl_DbScopeBuf [1] =  0;
 443     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
 444 
 445     /*
 446      * If configured for multi-thread support, the debug executor runs in
 447      * a separate thread so that the front end can be in another address
 448      * space, environment, or even another machine.
 449      */
 450     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
 451     {
 452         /* These were created with one unit, grab it */
 453 
 454         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
 455         if (ACPI_FAILURE (Status))
 456         {
 457             AcpiOsPrintf ("Could not get debugger mutex\n");
 458             return_ACPI_STATUS (Status);
 459         }
 460 
 461         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
 462         if (ACPI_FAILURE (Status))
 463         {
 464             AcpiOsPrintf ("Could not get debugger mutex\n");
 465             return_ACPI_STATUS (Status);
 466         }
 467 
 468         /* Create the debug execution thread to execute commands */
 469 
 470         Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL);
 471         if (ACPI_FAILURE (Status))
 472         {
 473             ACPI_EXCEPTION ((AE_INFO, Status, "Could not start debugger thread"));
 474             return_ACPI_STATUS (Status);
 475         }
 476     }
 477 
 478     if (!AcpiGbl_DbOpt_verbose)
 479     {
 480         AcpiGbl_DbOpt_disasm = TRUE;
 481         AcpiGbl_DbOpt_stats = FALSE;
 482     }
 483 
 484     return_ACPI_STATUS (AE_OK);
 485 }
 486 
 487 
 488 /*******************************************************************************
 489  *
 490  * FUNCTION:    AcpiDbTerminate
 491  *
 492  * PARAMETERS:  None
 493  *
 494  * RETURN:      None
 495  *
 496  * DESCRIPTION: Stop debugger
 497  *
 498  ******************************************************************************/
 499 
 500 void
 501 AcpiDbTerminate (
 502     void)
 503 {
 504 
 505     if (AcpiGbl_DbBuffer)
 506     {
 507         AcpiOsFree (AcpiGbl_DbBuffer);
 508         AcpiGbl_DbBuffer = NULL;
 509     }
 510 
 511     /* Ensure that debug output is now disabled */
 512 
 513     AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT;
 514 }
 515 
 516 
 517 #ifdef ACPI_OBSOLETE_FUNCTIONS
 518 /*******************************************************************************
 519  *
 520  * FUNCTION:    AcpiDbMethodEnd
 521  *
 522  * PARAMETERS:  WalkState       - Current walk
 523  *
 524  * RETURN:      Status
 525  *
 526  * DESCRIPTION: Called at method termination
 527  *
 528  ******************************************************************************/
 529 
 530 void
 531 AcpiDbMethodEnd (
 532     ACPI_WALK_STATE         *WalkState)
 533 {