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 ACPI_MODULE_NAME ("utdebug") 123 124 125#ifdef ACPI_DEBUG_OUTPUT 126 127static UINT32 AcpiGbl_PrevThreadId = 0xFFFFFFFF; 128static char *AcpiGbl_FnEntryStr = "----Entry"; 129static char *AcpiGbl_FnExitStr = "----Exit-"; 130 131 132/***************************************************************************** 133 * 134 * FUNCTION: AcpiUtInitStackPtrTrace 135 * 136 * PARAMETERS: None 137 * 138 * RETURN: None 139 * 140 * DESCRIPTION: Save the current stack pointer 141 * 142 ****************************************************************************/ 143 144void 145AcpiUtInitStackPtrTrace ( 146 void) 147{ 148 UINT32 CurrentSp; 149 150 151 AcpiGbl_EntryStackPointer = ACPI_PTR_DIFF (&CurrentSp, NULL); 152} 153 154 155/***************************************************************************** 156 * 157 * FUNCTION: AcpiUtTrackStackPtr 158 * 159 * PARAMETERS: None 160 * 161 * RETURN: None 162 * 163 * DESCRIPTION: Save the current stack pointer 164 * 165 ****************************************************************************/ 166 167void 168AcpiUtTrackStackPtr ( 169 void) 170{ 171 ACPI_SIZE CurrentSp; 172 173 174 CurrentSp = ACPI_PTR_DIFF (&CurrentSp, NULL); 175 176 if (CurrentSp < AcpiGbl_LowestStackPointer) 177 { 178 AcpiGbl_LowestStackPointer = CurrentSp; 179 } 180 181 if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) 182 { 183 AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel; 184 } 185} 186 187 188/***************************************************************************** 189 * 190 * FUNCTION: AcpiUtDebugPrint 191 * 192 * PARAMETERS: DebugLevel - Requested debug print level 193 * ProcName - Caller's procedure name 194 * ModuleName - Caller's module name (for error output) 195 * LineNumber - Caller's line number (for error output) 196 * ComponentId - Caller's component ID (for error output) 197 * 198 * Format - Printf format field 199 * ... - Optional printf arguments 200 * 201 * RETURN: None 202 * 203 * DESCRIPTION: Print error message with prefix consisting of the module name, 204 * line number, and component ID. 205 * 206 ****************************************************************************/ 207 208void ACPI_INTERNAL_VAR_XFACE 209AcpiUtDebugPrint ( 210 UINT32 RequestedDebugLevel, 211 UINT32 LineNumber, 212 ACPI_DEBUG_PRINT_INFO *DbgInfo, 213 char *Format, 214 ...) 215{ 216 UINT32 ThreadId; 217 va_list args; 218 219 220 /* 221 * Stay silent if the debug level or component ID is disabled 222 */ 223 if (!(RequestedDebugLevel & AcpiDbgLevel) || 224 !(DbgInfo->ComponentId & AcpiDbgLayer)) 225 { 226 return; 227 } 228 229 /* 230 * Thread tracking and context switch notification 231 */ 232 ThreadId = AcpiOsGetThreadId (); 233 234 if (ThreadId != AcpiGbl_PrevThreadId) 235 { 236 if (ACPI_LV_THREADS & AcpiDbgLevel) 237 { 238 AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n", 239 AcpiGbl_PrevThreadId, ThreadId); 240 } 241 242 AcpiGbl_PrevThreadId = ThreadId; 243 } 244 245 /* 246 * Display the module name, current line number, thread ID (if requested), 247 * current procedure nesting level, and the current procedure name 248 */ 249 AcpiOsPrintf ("%8s-%04ld ", DbgInfo->ModuleName, LineNumber); 250 251 if (ACPI_LV_THREADS & AcpiDbgLevel) 252 { 253 AcpiOsPrintf ("[%04lX] ", ThreadId); 254 } 255 256 AcpiOsPrintf ("[%02ld] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName); 257 258 va_start (args, Format); 259 AcpiOsVprintf (Format, args); 260} 261 262 263/***************************************************************************** 264 * 265 * FUNCTION: AcpiUtDebugPrintRaw 266 * 267 * PARAMETERS: RequestedDebugLevel - Requested debug print level 268 * LineNumber - Caller's line number 269 * DbgInfo - Contains: 270 * ProcName - Caller's procedure name 271 * ModuleName - Caller's module name 272 * ComponentId - Caller's component ID 273 * Format - Printf format field 274 * ... - Optional printf arguments 275 * 276 * RETURN: None 277 * 278 * DESCRIPTION: Print message with no headers. Has same interface as 279 * DebugPrint so that the same macros can be used. 280 * 281 ****************************************************************************/ 282 283void ACPI_INTERNAL_VAR_XFACE 284AcpiUtDebugPrintRaw ( 285 UINT32 RequestedDebugLevel, 286 UINT32 LineNumber, 287 ACPI_DEBUG_PRINT_INFO *DbgInfo, 288 char *Format, 289 ...) 290{ 291 va_list args; 292 293 294 if (!(RequestedDebugLevel & AcpiDbgLevel) || 295 !(DbgInfo->ComponentId & AcpiDbgLayer)) 296 { 297 return; 298 } 299 300 va_start (args, Format); 301 AcpiOsVprintf (Format, args); 302} 303 304 305/***************************************************************************** 306 * 307 * FUNCTION: AcpiUtTrace 308 * 309 * PARAMETERS: LineNumber - Caller's line number 310 * DbgInfo - Contains: 311 * ProcName - Caller's procedure name 312 * ModuleName - Caller's module name 313 * ComponentId - Caller's component ID 314 * 315 * RETURN: None 316 * 317 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 318 * set in DebugLevel 319 * 320 ****************************************************************************/ 321 322void 323AcpiUtTrace ( 324 UINT32 LineNumber, 325 ACPI_DEBUG_PRINT_INFO *DbgInfo) 326{ 327 328 AcpiGbl_NestingLevel++; 329 AcpiUtTrackStackPtr (); 330 331 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 332 "%s\n", AcpiGbl_FnEntryStr); 333} 334 335 336/***************************************************************************** 337 * 338 * FUNCTION: AcpiUtTracePtr 339 * 340 * PARAMETERS: LineNumber - Caller's line number 341 * DbgInfo - Contains: 342 * ProcName - Caller's procedure name 343 * ModuleName - Caller's module name 344 * ComponentId - Caller's component ID 345 * Pointer - Pointer to display 346 * 347 * RETURN: None 348 * 349 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 350 * set in DebugLevel 351 * 352 ****************************************************************************/ 353 354void 355AcpiUtTracePtr ( 356 UINT32 LineNumber, 357 ACPI_DEBUG_PRINT_INFO *DbgInfo, 358 void *Pointer) 359{ 360 AcpiGbl_NestingLevel++; 361 AcpiUtTrackStackPtr (); 362 363 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 364 "%s %p\n", AcpiGbl_FnEntryStr, Pointer); 365} 366 367 368/***************************************************************************** 369 * 370 * FUNCTION: AcpiUtTraceStr 371 * 372 * PARAMETERS: LineNumber - Caller's line number 373 * DbgInfo - Contains: 374 * ProcName - Caller's procedure name 375 * ModuleName - Caller's module name 376 * ComponentId - Caller's component ID 377 * String - Additional string to display 378 * 379 * RETURN: None 380 * 381 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 382 * set in DebugLevel 383 * 384 ****************************************************************************/ 385 386void 387AcpiUtTraceStr ( 388 UINT32 LineNumber, 389 ACPI_DEBUG_PRINT_INFO *DbgInfo, 390 char *String) 391{ 392 393 AcpiGbl_NestingLevel++; 394 AcpiUtTrackStackPtr (); 395 396 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 397 "%s %s\n", AcpiGbl_FnEntryStr, String); 398} 399 400 401/***************************************************************************** 402 * 403 * FUNCTION: AcpiUtTraceU32 404 * 405 * PARAMETERS: LineNumber - Caller's line number 406 * DbgInfo - Contains: 407 * ProcName - Caller's procedure name 408 * ModuleName - Caller's module name 409 * ComponentId - Caller's component ID 410 * Integer - Integer to display 411 * 412 * RETURN: None 413 * 414 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 415 * set in DebugLevel 416 * 417 ****************************************************************************/ 418 419void 420AcpiUtTraceU32 ( 421 UINT32 LineNumber, 422 ACPI_DEBUG_PRINT_INFO *DbgInfo, 423 UINT32 Integer) 424{ 425 426 AcpiGbl_NestingLevel++; 427 AcpiUtTrackStackPtr (); 428 429 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 430 "%s %08X\n", AcpiGbl_FnEntryStr, Integer); 431} 432 433 434/***************************************************************************** 435 * 436 * FUNCTION: AcpiUtExit 437 * 438 * PARAMETERS: LineNumber - Caller's line number 439 * DbgInfo - Contains: 440 * ProcName - Caller's procedure name 441 * ModuleName - Caller's module name 442 * ComponentId - Caller's component ID 443 * 444 * RETURN: None 445 * 446 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 447 * set in DebugLevel 448 * 449 ****************************************************************************/ 450 451void 452AcpiUtExit ( 453 UINT32 LineNumber, 454 ACPI_DEBUG_PRINT_INFO *DbgInfo) 455{ 456 457 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 458 "%s\n", AcpiGbl_FnExitStr); 459 460 AcpiGbl_NestingLevel--; 461} 462 463 464/***************************************************************************** 465 * 466 * FUNCTION: AcpiUtStatusExit 467 * 468 * PARAMETERS: LineNumber - Caller's line number 469 * DbgInfo - Contains: 470 * ProcName - Caller's procedure name 471 * ModuleName - Caller's module name 472 * ComponentId - Caller's component ID 473 * Status - Exit status code 474 * 475 * RETURN: None 476 * 477 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 478 * set in DebugLevel. Prints exit status also. 479 * 480 ****************************************************************************/ 481 482void 483AcpiUtStatusExit ( 484 UINT32 LineNumber, 485 ACPI_DEBUG_PRINT_INFO *DbgInfo, 486 ACPI_STATUS Status) 487{ 488 489 if (ACPI_SUCCESS (Status)) 490 { 491 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 492 "%s %s\n", AcpiGbl_FnExitStr, 493 AcpiFormatException (Status)); 494 } 495 else 496 { 497 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 498 "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, 499 AcpiFormatException (Status)); 500 } 501 502 AcpiGbl_NestingLevel--; 503} 504 505 506/***************************************************************************** 507 * 508 * FUNCTION: AcpiUtValueExit 509 * 510 * PARAMETERS: LineNumber - Caller's line number 511 * DbgInfo - Contains: 512 * ProcName - Caller's procedure name 513 * ModuleName - Caller's module name 514 * ComponentId - Caller's component ID 515 * Value - Value to be printed with exit msg 516 * 517 * RETURN: None 518 * 519 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 520 * set in DebugLevel. Prints exit value also. 521 * 522 ****************************************************************************/ 523 524void 525AcpiUtValueExit ( 526 UINT32 LineNumber, 527 ACPI_DEBUG_PRINT_INFO *DbgInfo, 528 ACPI_INTEGER Value) 529{ 530 531 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 532 "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, 533 ACPI_FORMAT_UINT64 (Value)); 534 535 AcpiGbl_NestingLevel--; 536} 537 538 539/***************************************************************************** 540 * 541 * FUNCTION: AcpiUtPtrExit 542 * 543 * PARAMETERS: LineNumber - Caller's line number 544 * DbgInfo - Contains: 545 * ProcName - Caller's procedure name 546 * ModuleName - Caller's module name 547 * ComponentId - Caller's component ID 548 * Value - Value to be printed with exit msg 549 * 550 * RETURN: None 551 * 552 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 553 * set in DebugLevel. Prints exit value also. 554 * 555 ****************************************************************************/ 556 557void 558AcpiUtPtrExit ( 559 UINT32 LineNumber, 560 ACPI_DEBUG_PRINT_INFO *DbgInfo, 561 UINT8 *Ptr) 562{ 563 564 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 565 "%s %p\n", AcpiGbl_FnExitStr, Ptr); 566 567 AcpiGbl_NestingLevel--; 568} 569 570#endif 571 572 573/***************************************************************************** 574 * 575 * FUNCTION: AcpiUtDumpBuffer 576 * 577 * PARAMETERS: Buffer - Buffer to dump 578 * Count - Amount to dump, in bytes 579 * Display - BYTE, WORD, DWORD, or QWORD display 580 * ComponentID - Caller's component ID 581 * 582 * RETURN: None 583 * 584 * DESCRIPTION: Generic dump buffer in both hex and ascii. 585 * 586 ****************************************************************************/ 587 588void 589AcpiUtDumpBuffer ( 590 UINT8 *Buffer, 591 UINT32 Count, 592 UINT32 Display, 593 UINT32 ComponentId) 594{ 595 ACPI_NATIVE_UINT i = 0; 596 ACPI_NATIVE_UINT j; 597 UINT32 Temp32; 598 UINT8 BufChar; 599 600 601 /* Only dump the buffer if tracing is enabled */ 602 603 if (!((ACPI_LV_TABLES & AcpiDbgLevel) && 604 (ComponentId & AcpiDbgLayer))) 605 { 606 return; 607 } 608 609 if ((Count < 4) || (Count & 0x01)) 610 { 611 Display = DB_BYTE_DISPLAY; 612 } 613 614 AcpiOsPrintf ("\nOffset Value\n"); 615 616 /* 617 * Nasty little dump buffer routine! 618 */ 619 while (i < Count) 620 { 621 /* Print current offset */ 622 623 AcpiOsPrintf ("%05X ", (UINT32) i); 624 625 /* Print 16 hex chars */ 626 627 for (j = 0; j < 16;) 628 { 629 if (i + j >= Count) 630 { 631 AcpiOsPrintf ("\n"); 632 return; 633 } 634 635 /* Make sure that the INT8 doesn't get sign-extended! */ 636 637 switch (Display) 638 { 639 /* Default is BYTE display */ 640 641 default: 642 643 AcpiOsPrintf ("%02X ", 644 *((UINT8 *) &Buffer[i + j])); 645 j += 1; 646 break; 647 648 649 case DB_WORD_DISPLAY: 650 651 ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[i + j]); 652 AcpiOsPrintf ("%04X ", Temp32); 653 j += 2; 654 break; 655 656 657 case DB_DWORD_DISPLAY: 658 659 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); 660 AcpiOsPrintf ("%08X ", Temp32); 661 j += 4; 662 break; 663 664 665 case DB_QWORD_DISPLAY: 666 667 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); 668 AcpiOsPrintf ("%08X", Temp32); 669 670 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j + 4]); 671 AcpiOsPrintf ("%08X ", Temp32); 672 j += 8; 673 break; 674 } 675 } 676 677 /* 678 * Print the ASCII equivalent characters 679 * But watch out for the bad unprintable ones... 680 */ 681 for (j = 0; j < 16; j++) 682 { 683 if (i + j >= Count) 684 { 685 AcpiOsPrintf ("\n"); 686 return; 687 } 688 689 BufChar = Buffer[i + j]; 690 if ((BufChar > 0x1F && BufChar < 0x2E) || 691 (BufChar > 0x2F && BufChar < 0x61) || 692 (BufChar > 0x60 && BufChar < 0x7F)) 693 { 694 AcpiOsPrintf ("%c", BufChar); 695 } 696 else 697 { 698 AcpiOsPrintf ("."); 699 } 700 } 701 702 /* Done with that line. */ 703 704 AcpiOsPrintf ("\n"); 705 i += 16; 706 } 707 708 return; 709} 710
| 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 ACPI_MODULE_NAME ("utdebug") 123 124 125#ifdef ACPI_DEBUG_OUTPUT 126 127static UINT32 AcpiGbl_PrevThreadId = 0xFFFFFFFF; 128static char *AcpiGbl_FnEntryStr = "----Entry"; 129static char *AcpiGbl_FnExitStr = "----Exit-"; 130 131 132/***************************************************************************** 133 * 134 * FUNCTION: AcpiUtInitStackPtrTrace 135 * 136 * PARAMETERS: None 137 * 138 * RETURN: None 139 * 140 * DESCRIPTION: Save the current stack pointer 141 * 142 ****************************************************************************/ 143 144void 145AcpiUtInitStackPtrTrace ( 146 void) 147{ 148 UINT32 CurrentSp; 149 150 151 AcpiGbl_EntryStackPointer = ACPI_PTR_DIFF (&CurrentSp, NULL); 152} 153 154 155/***************************************************************************** 156 * 157 * FUNCTION: AcpiUtTrackStackPtr 158 * 159 * PARAMETERS: None 160 * 161 * RETURN: None 162 * 163 * DESCRIPTION: Save the current stack pointer 164 * 165 ****************************************************************************/ 166 167void 168AcpiUtTrackStackPtr ( 169 void) 170{ 171 ACPI_SIZE CurrentSp; 172 173 174 CurrentSp = ACPI_PTR_DIFF (&CurrentSp, NULL); 175 176 if (CurrentSp < AcpiGbl_LowestStackPointer) 177 { 178 AcpiGbl_LowestStackPointer = CurrentSp; 179 } 180 181 if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) 182 { 183 AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel; 184 } 185} 186 187 188/***************************************************************************** 189 * 190 * FUNCTION: AcpiUtDebugPrint 191 * 192 * PARAMETERS: DebugLevel - Requested debug print level 193 * ProcName - Caller's procedure name 194 * ModuleName - Caller's module name (for error output) 195 * LineNumber - Caller's line number (for error output) 196 * ComponentId - Caller's component ID (for error output) 197 * 198 * Format - Printf format field 199 * ... - Optional printf arguments 200 * 201 * RETURN: None 202 * 203 * DESCRIPTION: Print error message with prefix consisting of the module name, 204 * line number, and component ID. 205 * 206 ****************************************************************************/ 207 208void ACPI_INTERNAL_VAR_XFACE 209AcpiUtDebugPrint ( 210 UINT32 RequestedDebugLevel, 211 UINT32 LineNumber, 212 ACPI_DEBUG_PRINT_INFO *DbgInfo, 213 char *Format, 214 ...) 215{ 216 UINT32 ThreadId; 217 va_list args; 218 219 220 /* 221 * Stay silent if the debug level or component ID is disabled 222 */ 223 if (!(RequestedDebugLevel & AcpiDbgLevel) || 224 !(DbgInfo->ComponentId & AcpiDbgLayer)) 225 { 226 return; 227 } 228 229 /* 230 * Thread tracking and context switch notification 231 */ 232 ThreadId = AcpiOsGetThreadId (); 233 234 if (ThreadId != AcpiGbl_PrevThreadId) 235 { 236 if (ACPI_LV_THREADS & AcpiDbgLevel) 237 { 238 AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n", 239 AcpiGbl_PrevThreadId, ThreadId); 240 } 241 242 AcpiGbl_PrevThreadId = ThreadId; 243 } 244 245 /* 246 * Display the module name, current line number, thread ID (if requested), 247 * current procedure nesting level, and the current procedure name 248 */ 249 AcpiOsPrintf ("%8s-%04ld ", DbgInfo->ModuleName, LineNumber); 250 251 if (ACPI_LV_THREADS & AcpiDbgLevel) 252 { 253 AcpiOsPrintf ("[%04lX] ", ThreadId); 254 } 255 256 AcpiOsPrintf ("[%02ld] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName); 257 258 va_start (args, Format); 259 AcpiOsVprintf (Format, args); 260} 261 262 263/***************************************************************************** 264 * 265 * FUNCTION: AcpiUtDebugPrintRaw 266 * 267 * PARAMETERS: RequestedDebugLevel - Requested debug print level 268 * LineNumber - Caller's line number 269 * DbgInfo - Contains: 270 * ProcName - Caller's procedure name 271 * ModuleName - Caller's module name 272 * ComponentId - Caller's component ID 273 * Format - Printf format field 274 * ... - Optional printf arguments 275 * 276 * RETURN: None 277 * 278 * DESCRIPTION: Print message with no headers. Has same interface as 279 * DebugPrint so that the same macros can be used. 280 * 281 ****************************************************************************/ 282 283void ACPI_INTERNAL_VAR_XFACE 284AcpiUtDebugPrintRaw ( 285 UINT32 RequestedDebugLevel, 286 UINT32 LineNumber, 287 ACPI_DEBUG_PRINT_INFO *DbgInfo, 288 char *Format, 289 ...) 290{ 291 va_list args; 292 293 294 if (!(RequestedDebugLevel & AcpiDbgLevel) || 295 !(DbgInfo->ComponentId & AcpiDbgLayer)) 296 { 297 return; 298 } 299 300 va_start (args, Format); 301 AcpiOsVprintf (Format, args); 302} 303 304 305/***************************************************************************** 306 * 307 * FUNCTION: AcpiUtTrace 308 * 309 * PARAMETERS: LineNumber - Caller's line number 310 * DbgInfo - Contains: 311 * ProcName - Caller's procedure name 312 * ModuleName - Caller's module name 313 * ComponentId - Caller's component ID 314 * 315 * RETURN: None 316 * 317 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 318 * set in DebugLevel 319 * 320 ****************************************************************************/ 321 322void 323AcpiUtTrace ( 324 UINT32 LineNumber, 325 ACPI_DEBUG_PRINT_INFO *DbgInfo) 326{ 327 328 AcpiGbl_NestingLevel++; 329 AcpiUtTrackStackPtr (); 330 331 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 332 "%s\n", AcpiGbl_FnEntryStr); 333} 334 335 336/***************************************************************************** 337 * 338 * FUNCTION: AcpiUtTracePtr 339 * 340 * PARAMETERS: LineNumber - Caller's line number 341 * DbgInfo - Contains: 342 * ProcName - Caller's procedure name 343 * ModuleName - Caller's module name 344 * ComponentId - Caller's component ID 345 * Pointer - Pointer to display 346 * 347 * RETURN: None 348 * 349 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 350 * set in DebugLevel 351 * 352 ****************************************************************************/ 353 354void 355AcpiUtTracePtr ( 356 UINT32 LineNumber, 357 ACPI_DEBUG_PRINT_INFO *DbgInfo, 358 void *Pointer) 359{ 360 AcpiGbl_NestingLevel++; 361 AcpiUtTrackStackPtr (); 362 363 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 364 "%s %p\n", AcpiGbl_FnEntryStr, Pointer); 365} 366 367 368/***************************************************************************** 369 * 370 * FUNCTION: AcpiUtTraceStr 371 * 372 * PARAMETERS: LineNumber - Caller's line number 373 * DbgInfo - Contains: 374 * ProcName - Caller's procedure name 375 * ModuleName - Caller's module name 376 * ComponentId - Caller's component ID 377 * String - Additional string to display 378 * 379 * RETURN: None 380 * 381 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 382 * set in DebugLevel 383 * 384 ****************************************************************************/ 385 386void 387AcpiUtTraceStr ( 388 UINT32 LineNumber, 389 ACPI_DEBUG_PRINT_INFO *DbgInfo, 390 char *String) 391{ 392 393 AcpiGbl_NestingLevel++; 394 AcpiUtTrackStackPtr (); 395 396 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 397 "%s %s\n", AcpiGbl_FnEntryStr, String); 398} 399 400 401/***************************************************************************** 402 * 403 * FUNCTION: AcpiUtTraceU32 404 * 405 * PARAMETERS: LineNumber - Caller's line number 406 * DbgInfo - Contains: 407 * ProcName - Caller's procedure name 408 * ModuleName - Caller's module name 409 * ComponentId - Caller's component ID 410 * Integer - Integer to display 411 * 412 * RETURN: None 413 * 414 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 415 * set in DebugLevel 416 * 417 ****************************************************************************/ 418 419void 420AcpiUtTraceU32 ( 421 UINT32 LineNumber, 422 ACPI_DEBUG_PRINT_INFO *DbgInfo, 423 UINT32 Integer) 424{ 425 426 AcpiGbl_NestingLevel++; 427 AcpiUtTrackStackPtr (); 428 429 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 430 "%s %08X\n", AcpiGbl_FnEntryStr, Integer); 431} 432 433 434/***************************************************************************** 435 * 436 * FUNCTION: AcpiUtExit 437 * 438 * PARAMETERS: LineNumber - Caller's line number 439 * DbgInfo - Contains: 440 * ProcName - Caller's procedure name 441 * ModuleName - Caller's module name 442 * ComponentId - Caller's component ID 443 * 444 * RETURN: None 445 * 446 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 447 * set in DebugLevel 448 * 449 ****************************************************************************/ 450 451void 452AcpiUtExit ( 453 UINT32 LineNumber, 454 ACPI_DEBUG_PRINT_INFO *DbgInfo) 455{ 456 457 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 458 "%s\n", AcpiGbl_FnExitStr); 459 460 AcpiGbl_NestingLevel--; 461} 462 463 464/***************************************************************************** 465 * 466 * FUNCTION: AcpiUtStatusExit 467 * 468 * PARAMETERS: LineNumber - Caller's line number 469 * DbgInfo - Contains: 470 * ProcName - Caller's procedure name 471 * ModuleName - Caller's module name 472 * ComponentId - Caller's component ID 473 * Status - Exit status code 474 * 475 * RETURN: None 476 * 477 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 478 * set in DebugLevel. Prints exit status also. 479 * 480 ****************************************************************************/ 481 482void 483AcpiUtStatusExit ( 484 UINT32 LineNumber, 485 ACPI_DEBUG_PRINT_INFO *DbgInfo, 486 ACPI_STATUS Status) 487{ 488 489 if (ACPI_SUCCESS (Status)) 490 { 491 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 492 "%s %s\n", AcpiGbl_FnExitStr, 493 AcpiFormatException (Status)); 494 } 495 else 496 { 497 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 498 "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, 499 AcpiFormatException (Status)); 500 } 501 502 AcpiGbl_NestingLevel--; 503} 504 505 506/***************************************************************************** 507 * 508 * FUNCTION: AcpiUtValueExit 509 * 510 * PARAMETERS: LineNumber - Caller's line number 511 * DbgInfo - Contains: 512 * ProcName - Caller's procedure name 513 * ModuleName - Caller's module name 514 * ComponentId - Caller's component ID 515 * Value - Value to be printed with exit msg 516 * 517 * RETURN: None 518 * 519 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 520 * set in DebugLevel. Prints exit value also. 521 * 522 ****************************************************************************/ 523 524void 525AcpiUtValueExit ( 526 UINT32 LineNumber, 527 ACPI_DEBUG_PRINT_INFO *DbgInfo, 528 ACPI_INTEGER Value) 529{ 530 531 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 532 "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, 533 ACPI_FORMAT_UINT64 (Value)); 534 535 AcpiGbl_NestingLevel--; 536} 537 538 539/***************************************************************************** 540 * 541 * FUNCTION: AcpiUtPtrExit 542 * 543 * PARAMETERS: LineNumber - Caller's line number 544 * DbgInfo - Contains: 545 * ProcName - Caller's procedure name 546 * ModuleName - Caller's module name 547 * ComponentId - Caller's component ID 548 * Value - Value to be printed with exit msg 549 * 550 * RETURN: None 551 * 552 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 553 * set in DebugLevel. Prints exit value also. 554 * 555 ****************************************************************************/ 556 557void 558AcpiUtPtrExit ( 559 UINT32 LineNumber, 560 ACPI_DEBUG_PRINT_INFO *DbgInfo, 561 UINT8 *Ptr) 562{ 563 564 AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, 565 "%s %p\n", AcpiGbl_FnExitStr, Ptr); 566 567 AcpiGbl_NestingLevel--; 568} 569 570#endif 571 572 573/***************************************************************************** 574 * 575 * FUNCTION: AcpiUtDumpBuffer 576 * 577 * PARAMETERS: Buffer - Buffer to dump 578 * Count - Amount to dump, in bytes 579 * Display - BYTE, WORD, DWORD, or QWORD display 580 * ComponentID - Caller's component ID 581 * 582 * RETURN: None 583 * 584 * DESCRIPTION: Generic dump buffer in both hex and ascii. 585 * 586 ****************************************************************************/ 587 588void 589AcpiUtDumpBuffer ( 590 UINT8 *Buffer, 591 UINT32 Count, 592 UINT32 Display, 593 UINT32 ComponentId) 594{ 595 ACPI_NATIVE_UINT i = 0; 596 ACPI_NATIVE_UINT j; 597 UINT32 Temp32; 598 UINT8 BufChar; 599 600 601 /* Only dump the buffer if tracing is enabled */ 602 603 if (!((ACPI_LV_TABLES & AcpiDbgLevel) && 604 (ComponentId & AcpiDbgLayer))) 605 { 606 return; 607 } 608 609 if ((Count < 4) || (Count & 0x01)) 610 { 611 Display = DB_BYTE_DISPLAY; 612 } 613 614 AcpiOsPrintf ("\nOffset Value\n"); 615 616 /* 617 * Nasty little dump buffer routine! 618 */ 619 while (i < Count) 620 { 621 /* Print current offset */ 622 623 AcpiOsPrintf ("%05X ", (UINT32) i); 624 625 /* Print 16 hex chars */ 626 627 for (j = 0; j < 16;) 628 { 629 if (i + j >= Count) 630 { 631 AcpiOsPrintf ("\n"); 632 return; 633 } 634 635 /* Make sure that the INT8 doesn't get sign-extended! */ 636 637 switch (Display) 638 { 639 /* Default is BYTE display */ 640 641 default: 642 643 AcpiOsPrintf ("%02X ", 644 *((UINT8 *) &Buffer[i + j])); 645 j += 1; 646 break; 647 648 649 case DB_WORD_DISPLAY: 650 651 ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[i + j]); 652 AcpiOsPrintf ("%04X ", Temp32); 653 j += 2; 654 break; 655 656 657 case DB_DWORD_DISPLAY: 658 659 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); 660 AcpiOsPrintf ("%08X ", Temp32); 661 j += 4; 662 break; 663 664 665 case DB_QWORD_DISPLAY: 666 667 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); 668 AcpiOsPrintf ("%08X", Temp32); 669 670 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j + 4]); 671 AcpiOsPrintf ("%08X ", Temp32); 672 j += 8; 673 break; 674 } 675 } 676 677 /* 678 * Print the ASCII equivalent characters 679 * But watch out for the bad unprintable ones... 680 */ 681 for (j = 0; j < 16; j++) 682 { 683 if (i + j >= Count) 684 { 685 AcpiOsPrintf ("\n"); 686 return; 687 } 688 689 BufChar = Buffer[i + j]; 690 if ((BufChar > 0x1F && BufChar < 0x2E) || 691 (BufChar > 0x2F && BufChar < 0x61) || 692 (BufChar > 0x60 && BufChar < 0x7F)) 693 { 694 AcpiOsPrintf ("%c", BufChar); 695 } 696 else 697 { 698 AcpiOsPrintf ("."); 699 } 700 } 701 702 /* Done with that line. */ 703 704 AcpiOsPrintf ("\n"); 705 i += 16; 706 } 707 708 return; 709} 710
|