utdebug.c revision 82367
1/****************************************************************************** 2 * 3 * Module Name: utdebug - Debug print routines 4 * $Revision: 76 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __UTDEBUG_C__ 118 119#include "acpi.h" 120 121#define _COMPONENT ACPI_UTILITIES 122 MODULE_NAME ("utdebug") 123 124 125UINT32 PrevThreadId = 0xFFFFFFFF; 126 127/***************************************************************************** 128 * 129 * FUNCTION: Get/Set debug level 130 * 131 * DESCRIPTION: Get or set value of the debug flag 132 * 133 * These are used to allow user's to get/set the debug level 134 * 135 ****************************************************************************/ 136 137 138UINT32 139GetDebugLevel (void) 140{ 141 142 return (AcpiDbgLevel); 143} 144 145void 146SetDebugLevel ( 147 UINT32 NewDebugLevel) 148{ 149 150 AcpiDbgLevel = NewDebugLevel; 151} 152 153 154/***************************************************************************** 155 * 156 * FUNCTION: AcpiUtDebugPrint 157 * 158 * PARAMETERS: DebugLevel - Requested debug print level 159 * ProcName - Caller's procedure name 160 * ModuleName - Caller's module name (for error output) 161 * LineNumber - Caller's line number (for error output) 162 * ComponentId - Caller's component ID (for error output) 163 * 164 * Format - Printf format field 165 * ... - Optional printf arguments 166 * 167 * RETURN: None 168 * 169 * DESCRIPTION: Print error message with prefix consisting of the module name, 170 * line number, and component ID. 171 * 172 ****************************************************************************/ 173 174void 175AcpiUtDebugPrint ( 176 UINT32 RequestedDebugLevel, 177 UINT32 ComponentId, 178 NATIVE_CHAR *ProcName, 179 NATIVE_CHAR *ModuleName, 180 UINT32 LineNumber, 181 char *Format, 182 ...) 183{ 184 UINT32 ThreadId; 185 va_list args; 186 187 188 if (!(RequestedDebugLevel & AcpiDbgLevel) || 189 !(ComponentId & AcpiDbgLayer)) 190 { 191 return; 192 } 193 194 195 ThreadId = AcpiOsGetThreadId (); 196 197 if (ThreadId != PrevThreadId) 198 { 199 if (ACPI_LV_THREADS & AcpiDbgLevel) 200 { 201 AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n", 202 PrevThreadId, ThreadId); 203 } 204 205 PrevThreadId = ThreadId; 206 } 207 208 if (ACPI_LV_THREADS & AcpiDbgLevel) 209 { 210 AcpiOsPrintf ("%8s-%04d[%04X][%02d] %s: ", ModuleName, LineNumber, ThreadId, AcpiGbl_NestingLevel, ProcName); 211 } 212 else 213 { 214 AcpiOsPrintf ("%8s-%04d[%02d] %s: ", ModuleName, LineNumber, AcpiGbl_NestingLevel, ProcName); 215 } 216 217 218 219 va_start (args, Format); 220 AcpiOsVprintf (Format, args); 221} 222 223 224/***************************************************************************** 225 * 226 * FUNCTION: AcpiUtDebugPrintRaw 227 * 228 * PARAMETERS: DebugLevel - Requested debug print level 229 * ProcName - Caller's procedure name 230 * ModuleName - Caller's module name (for error output) 231 * LineNumber - Caller's line number (for error output) 232 * ComponentId - Caller's component ID (for error output) 233 * 234 * Format - Printf format field 235 * ... - Optional printf arguments 236 * 237 * RETURN: None 238 * 239 * DESCRIPTION: Print message with no headers. Has same interface as 240 * DebugPrint so that the same macros can be used. 241 * 242 ****************************************************************************/ 243 244void 245AcpiUtDebugPrintRaw ( 246 UINT32 RequestedDebugLevel, 247 UINT32 ComponentId, 248 NATIVE_CHAR *ProcName, 249 NATIVE_CHAR *ModuleName, 250 UINT32 LineNumber, 251 char *Format, 252 ...) 253{ 254 va_list args; 255 256 257 258 if (!(RequestedDebugLevel & AcpiDbgLevel) || 259 !(ComponentId & AcpiDbgLayer)) 260 { 261 return; 262 } 263 264 va_start (args, Format); 265 266 AcpiOsVprintf (Format, args); 267} 268 269 270/***************************************************************************** 271 * 272 * FUNCTION: FunctionTrace 273 * 274 * PARAMETERS: ModuleName - Caller's module name (for error output) 275 * LineNumber - Caller's line number (for error output) 276 * ComponentId - Caller's component ID (for error output) 277 * FunctionName - Name of Caller's function 278 * 279 * RETURN: None 280 * 281 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 282 * set in DebugLevel 283 * 284 ****************************************************************************/ 285 286void 287FunctionTrace ( 288 NATIVE_CHAR *ModuleName, 289 UINT32 LineNumber, 290 UINT32 ComponentId, 291 NATIVE_CHAR *FunctionName) 292{ 293 294 AcpiGbl_NestingLevel++; 295 296 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 297 ModuleName, LineNumber, "----Entered Function----\n"); 298} 299 300 301/***************************************************************************** 302 * 303 * FUNCTION: FunctionTracePtr 304 * 305 * PARAMETERS: ModuleName - Caller's module name (for error output) 306 * LineNumber - Caller's line number (for error output) 307 * ComponentId - Caller's component ID (for error output) 308 * FunctionName - Name of Caller's function 309 * Pointer - Pointer to display 310 * 311 * RETURN: None 312 * 313 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 314 * set in DebugLevel 315 * 316 ****************************************************************************/ 317 318void 319FunctionTracePtr ( 320 NATIVE_CHAR *ModuleName, 321 UINT32 LineNumber, 322 UINT32 ComponentId, 323 NATIVE_CHAR *FunctionName, 324 void *Pointer) 325{ 326 AcpiGbl_NestingLevel++; 327 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 328 ModuleName, LineNumber, "----Entered Function---- %p\n", Pointer); 329} 330 331 332 333/***************************************************************************** 334 * 335 * FUNCTION: FunctionTraceStr 336 * 337 * PARAMETERS: ModuleName - Caller's module name (for error output) 338 * LineNumber - Caller's line number (for error output) 339 * ComponentId - Caller's component ID (for error output) 340 * FunctionName - Name of Caller's function 341 * String - Additional string to display 342 * 343 * RETURN: None 344 * 345 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 346 * set in DebugLevel 347 * 348 ****************************************************************************/ 349 350void 351FunctionTraceStr ( 352 NATIVE_CHAR *ModuleName, 353 UINT32 LineNumber, 354 UINT32 ComponentId, 355 NATIVE_CHAR *FunctionName, 356 NATIVE_CHAR *String) 357{ 358 359 AcpiGbl_NestingLevel++; 360 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 361 ModuleName, LineNumber, "----Entered Function---- %s\n", String); 362} 363 364 365/***************************************************************************** 366 * 367 * FUNCTION: FunctionTraceU32 368 * 369 * PARAMETERS: ModuleName - Caller's module name (for error output) 370 * LineNumber - Caller's line number (for error output) 371 * ComponentId - Caller's component ID (for error output) 372 * FunctionName - Name of Caller's function 373 * Integer - Integer to display 374 * 375 * RETURN: None 376 * 377 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 378 * set in DebugLevel 379 * 380 ****************************************************************************/ 381 382void 383FunctionTraceU32 ( 384 NATIVE_CHAR *ModuleName, 385 UINT32 LineNumber, 386 UINT32 ComponentId, 387 NATIVE_CHAR *FunctionName, 388 UINT32 Integer) 389{ 390 391 AcpiGbl_NestingLevel++; 392 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 393 ModuleName, LineNumber, "----Entered Function---- %08X\n", Integer); 394} 395 396 397/***************************************************************************** 398 * 399 * FUNCTION: FunctionExit 400 * 401 * PARAMETERS: ModuleName - Caller's module name (for error output) 402 * LineNumber - Caller's line number (for error output) 403 * ComponentId - Caller's component ID (for error output) 404 * FunctionName - Name of Caller's function 405 * 406 * RETURN: None 407 * 408 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 409 * set in DebugLevel 410 * 411 ****************************************************************************/ 412 413void 414FunctionExit ( 415 NATIVE_CHAR *ModuleName, 416 UINT32 LineNumber, 417 UINT32 ComponentId, 418 NATIVE_CHAR *FunctionName) 419{ 420 421 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 422 ModuleName, LineNumber, "----Exiting Function----\n"); 423 424 AcpiGbl_NestingLevel--; 425} 426 427 428/***************************************************************************** 429 * 430 * FUNCTION: FunctionStatusExit 431 * 432 * PARAMETERS: ModuleName - Caller's module name (for error output) 433 * LineNumber - Caller's line number (for error output) 434 * ComponentId - Caller's component ID (for error output) 435 * FunctionName - Name of Caller's function 436 * Status - Exit status code 437 * 438 * RETURN: None 439 * 440 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 441 * set in DebugLevel. Prints exit status also. 442 * 443 ****************************************************************************/ 444 445void 446FunctionStatusExit ( 447 NATIVE_CHAR *ModuleName, 448 UINT32 LineNumber, 449 UINT32 ComponentId, 450 NATIVE_CHAR *FunctionName, 451 ACPI_STATUS Status) 452{ 453 454 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 455 ModuleName, LineNumber, "----Exiting Function---- %s\n", 456 AcpiFormatException (Status)); 457 458 AcpiGbl_NestingLevel--; 459} 460 461 462/***************************************************************************** 463 * 464 * FUNCTION: FunctionValueExit 465 * 466 * PARAMETERS: ModuleName - Caller's module name (for error output) 467 * LineNumber - Caller's line number (for error output) 468 * ComponentId - Caller's component ID (for error output) 469 * FunctionName - Name of Caller's function 470 * Value - Value to be printed with exit msg 471 * 472 * RETURN: None 473 * 474 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 475 * set in DebugLevel. Prints exit value also. 476 * 477 ****************************************************************************/ 478 479void 480FunctionValueExit ( 481 NATIVE_CHAR *ModuleName, 482 UINT32 LineNumber, 483 UINT32 ComponentId, 484 NATIVE_CHAR *FunctionName, 485 ACPI_INTEGER Value) 486{ 487 488 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 489 ModuleName, LineNumber, "----Exiting Function---- %08X\n", 490 Value); 491 492 AcpiGbl_NestingLevel--; 493} 494 495 496/***************************************************************************** 497 * 498 * FUNCTION: FunctionPtrExit 499 * 500 * PARAMETERS: ModuleName - Caller's module name (for error output) 501 * LineNumber - Caller's line number (for error output) 502 * ComponentId - Caller's component ID (for error output) 503 * FunctionName - Name of Caller's function 504 * Value - Value to be printed with exit msg 505 * 506 * RETURN: None 507 * 508 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 509 * set in DebugLevel. Prints exit value also. 510 * 511 ****************************************************************************/ 512 513void 514FunctionPtrExit ( 515 NATIVE_CHAR *ModuleName, 516 UINT32 LineNumber, 517 UINT32 ComponentId, 518 NATIVE_CHAR *FunctionName, 519 UINT8 *Ptr) 520{ 521 522 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, ComponentId, FunctionName, 523 ModuleName, LineNumber, "----Exiting Function----, %p\n", 524 Ptr); 525 526 AcpiGbl_NestingLevel--; 527} 528 529 530/***************************************************************************** 531 * 532 * FUNCTION: AcpiUtDumpBuffer 533 * 534 * PARAMETERS: Buffer - Buffer to dump 535 * Count - Amount to dump, in bytes 536 * ComponentID - Caller's component ID 537 * 538 * RETURN: None 539 * 540 * DESCRIPTION: Generic dump buffer in both hex and ascii. 541 * 542 ****************************************************************************/ 543 544void 545AcpiUtDumpBuffer ( 546 UINT8 *Buffer, 547 UINT32 Count, 548 UINT32 Display, 549 UINT32 ComponentId) 550{ 551 UINT32 i = 0; 552 UINT32 j; 553 UINT32 Temp32; 554 UINT8 BufChar; 555 556 557 /* Only dump the buffer if tracing is enabled */ 558 559 if (!((ACPI_LV_TABLES & AcpiDbgLevel) && 560 (ComponentId & AcpiDbgLayer))) 561 { 562 return; 563 } 564 565 566 /* 567 * Nasty little dump buffer routine! 568 */ 569 while (i < Count) 570 { 571 /* Print current offset */ 572 573 AcpiOsPrintf ("%05X ", i); 574 575 576 /* Print 16 hex chars */ 577 578 for (j = 0; j < 16;) 579 { 580 if (i + j >= Count) 581 { 582 AcpiOsPrintf ("\n"); 583 return; 584 } 585 586 /* Make sure that the INT8 doesn't get sign-extended! */ 587 588 switch (Display) 589 { 590 /* Default is BYTE display */ 591 592 default: 593 594 AcpiOsPrintf ("%02X ", 595 *((UINT8 *) &Buffer[i + j])); 596 j += 1; 597 break; 598 599 600 case DB_WORD_DISPLAY: 601 602 MOVE_UNALIGNED16_TO_32 (&Temp32, 603 &Buffer[i + j]); 604 AcpiOsPrintf ("%04X ", Temp32); 605 j += 2; 606 break; 607 608 609 case DB_DWORD_DISPLAY: 610 611 MOVE_UNALIGNED32_TO_32 (&Temp32, 612 &Buffer[i + j]); 613 AcpiOsPrintf ("%08X ", Temp32); 614 j += 4; 615 break; 616 617 618 case DB_QWORD_DISPLAY: 619 620 MOVE_UNALIGNED32_TO_32 (&Temp32, 621 &Buffer[i + j]); 622 AcpiOsPrintf ("%08X", Temp32); 623 624 MOVE_UNALIGNED32_TO_32 (&Temp32, 625 &Buffer[i + j + 4]); 626 AcpiOsPrintf ("%08X ", Temp32); 627 j += 8; 628 break; 629 } 630 } 631 632 633 /* 634 * Print the ASCII equivalent characters 635 * But watch out for the bad unprintable ones... 636 */ 637 638 for (j = 0; j < 16; j++) 639 { 640 if (i + j >= Count) 641 { 642 AcpiOsPrintf ("\n"); 643 return; 644 } 645 646 BufChar = Buffer[i + j]; 647 if ((BufChar > 0x1F && BufChar < 0x2E) || 648 (BufChar > 0x2F && BufChar < 0x61) || 649 (BufChar > 0x60 && BufChar < 0x7F)) 650 { 651 AcpiOsPrintf ("%c", BufChar); 652 } 653 else 654 { 655 AcpiOsPrintf ("."); 656 } 657 } 658 659 /* Done with that line. */ 660 661 AcpiOsPrintf ("\n"); 662 i += 16; 663 } 664 665 return; 666} 667 668 669