1 /****************************************************************************** 2 * 3 * Module Name: aslerror - Error handling and statistics 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include <contrib/dev/acpica/compiler/aslcompiler.h> 153 154 #define _COMPONENT ACPI_COMPILER 155 ACPI_MODULE_NAME ("aslerror") 156 157 /* Local prototypes */ 158 159 static void 160 AeAddToErrorLog ( 161 ASL_ERROR_MSG *Enode); 162 163 static BOOLEAN 164 AslIsExceptionExpected ( 165 char *Filename, 166 UINT32 LineNumber, 167 UINT8 Level, 168 UINT16 MessageId); 169 170 static BOOLEAN 171 AslIsExceptionDisabled ( 172 UINT8 Level, 173 UINT16 MessageId); 174 175 static void 176 AslInitEnode ( 177 ASL_ERROR_MSG **Enode, 178 UINT8 Level, 179 UINT16 MessageId, 180 UINT32 LineNumber, 181 UINT32 LogicalLineNumber, 182 UINT32 LogicalByteOffset, 183 UINT32 Column, 184 char *Filename, 185 char *Message, 186 char *SourceLine, 187 ASL_ERROR_MSG *SubError); 188 189 static void 190 AslLogNewError ( 191 UINT8 Level, 192 UINT16 MessageId, 193 UINT32 LineNumber, 194 UINT32 LogicalLineNumber, 195 UINT32 LogicalByteOffset, 196 UINT32 Column, 197 char *Filename, 198 char *Message, 199 char *SourceLine, 200 ASL_ERROR_MSG *SubError); 201 202 static void 203 AePrintSubError ( 204 FILE *OutputFile, 205 ASL_ERROR_MSG *Enode); 206 207 static UINT8 208 GetModifiedLevel ( 209 UINT8 Level, 210 UINT16 MessageId); 211 212 213 /******************************************************************************* 214 * 215 * FUNCTION: AslAbort 216 * 217 * PARAMETERS: None 218 * 219 * RETURN: None 220 * 221 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious 222 * I/O errors. 223 * 224 ******************************************************************************/ 225 226 void 227 AslAbort ( 228 void) 229 { 230 231 AePrintErrorLog (ASL_FILE_STDERR); 232 if (AslGbl_DebugFlag) 233 { 234 /* Print error summary to stdout also */ 235 236 AePrintErrorLog (ASL_FILE_STDOUT); 237 } 238 239 exit (1); 240 } 241 242 243 /******************************************************************************* 244 * 245 * FUNCTION: AeClearErrorLog 246 * 247 * PARAMETERS: None 248 * 249 * RETURN: None 250 * 251 * DESCRIPTION: Empty the error list 252 * 253 ******************************************************************************/ 254 255 void 256 AeClearErrorLog ( 257 void) 258 { 259 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog; 260 ASL_ERROR_MSG *Next; 261 262 263 /* Walk the error node list */ 264 265 while (Enode) 266 { 267 Next = Enode->Next; 268 ACPI_FREE (Enode); 269 Enode = Next; 270 } 271 272 AslGbl_ErrorLog = NULL; 273 } 274 275 276 /******************************************************************************* 277 * 278 * FUNCTION: AeAddToErrorLog 279 * 280 * PARAMETERS: Enode - An error node to add to the log 281 * 282 * RETURN: None 283 * 284 * DESCRIPTION: Add a new error node to the error log. The error log is 285 * ordered by the "logical" line number (cumulative line number 286 * including all include files.) 287 * 288 ******************************************************************************/ 289 290 static void 291 AeAddToErrorLog ( 292 ASL_ERROR_MSG *Enode) 293 { 294 ASL_ERROR_MSG *Next; 295 ASL_ERROR_MSG *Prev; 296 297 298 /* If Gbl_ErrorLog is null, this is the first error node */ 299 300 if (!AslGbl_ErrorLog) 301 { 302 AslGbl_ErrorLog = Enode; 303 return; 304 } 305 306 /* 307 * Walk error list until we find a line number greater than ours. 308 * List is sorted according to line number. 309 */ 310 Prev = NULL; 311 Next = AslGbl_ErrorLog; 312 313 while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber)) 314 { 315 Prev = Next; 316 Next = Next->Next; 317 } 318 319 /* Found our place in the list */ 320 321 Enode->Next = Next; 322 323 if (Prev) 324 { 325 Prev->Next = Enode; 326 } 327 else 328 { 329 AslGbl_ErrorLog = Enode; 330 } 331 } 332 333 334 /******************************************************************************* 335 * 336 * FUNCTION: AeDecodeErrorMessageId 337 * 338 * PARAMETERS: OutputFile - Output file 339 * Enode - Error node to print 340 * PrematureEOF - True = PrematureEOF has been reached 341 * Total - Total length of line 342 * 343 * RETURN: None 344 * 345 * DESCRIPTION: Print the source line of an error. 346 * 347 ******************************************************************************/ 348 349 static void 350 AeDecodeErrorMessageId ( 351 FILE *OutputFile, 352 ASL_ERROR_MSG *Enode, 353 BOOLEAN PrematureEOF, 354 UINT32 Total) 355 { 356 UINT32 MsgLength; 357 const char *MainMessage; 358 char *ExtraMessage; 359 UINT32 SourceColumn; 360 UINT32 ErrorColumn; 361 362 363 fprintf (OutputFile, "%s %4.4d -", 364 AeDecodeExceptionLevel (Enode->Level), 365 AeBuildFullExceptionCode (Enode->Level, Enode->MessageId)); 366 367 MainMessage = AeDecodeMessageId (Enode->MessageId); 368 ExtraMessage = Enode->Message; 369 370 /* If a NULL line number, just print the decoded message */ 371 372 if (!Enode->LineNumber) 373 { 374 fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); 375 return; 376 } 377 378 MsgLength = strlen (MainMessage); 379 if (MsgLength == 0) 380 { 381 /* Use the secondary/extra message as main message */ 382 383 MainMessage = Enode->Message; 384 if (!MainMessage) 385 { 386 MainMessage = ""; 387 } 388 389 MsgLength = strlen (MainMessage); 390 ExtraMessage = NULL; 391 } 392 393 if (AslGbl_VerboseErrors && !PrematureEOF) 394 { 395 if (Total >= 256) 396 { 397 fprintf (OutputFile, " %s", 398 MainMessage); 399 } 400 else 401 { 402 SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; 403 ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; 404 405 if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) 406 { 407 fprintf (OutputFile, "%*s%s", 408 (int) ((SourceColumn - 1) - ErrorColumn), 409 MainMessage, " ^ "); 410 } 411 else 412 { 413 fprintf (OutputFile, "%*s %s", 414 (int) ((SourceColumn - ErrorColumn) + 1), "^", 415 MainMessage); 416 } 417 } 418 } 419 else 420 { 421 fprintf (OutputFile, " %s", MainMessage); 422 } 423 424 /* Print the extra info message if present */ 425 426 if (ExtraMessage) 427 { 428 fprintf (OutputFile, " (%s)", ExtraMessage); 429 } 430 431 if (PrematureEOF) 432 { 433 fprintf (OutputFile, " and premature End-Of-File"); 434 } 435 436 fprintf (OutputFile, "\n"); 437 if (AslGbl_VerboseErrors && !Enode->SubError) 438 { 439 fprintf (OutputFile, "\n"); 440 } 441 } 442 443 444 /******************************************************************************* 445 * 446 * FUNCTION: AePrintErrorSourceLine 447 * 448 * PARAMETERS: OutputFile - Output file 449 * Enode - Error node to print 450 * PrematureEOF - True = PrematureEOF has been reached 451 * Total - Number of characters printed so far 452 * 453 * 454 * RETURN: Status 455 * 456 * DESCRIPTION: Print the source line of an error. 457 * 458 ******************************************************************************/ 459 460 static ACPI_STATUS 461 AePrintErrorSourceLine ( 462 FILE *OutputFile, 463 ASL_ERROR_MSG *Enode, 464 BOOLEAN *PrematureEOF, 465 UINT32 *Total) 466 { 467 UINT8 SourceByte; 468 int Actual; 469 size_t RActual; 470 FILE *SourceFile = NULL; 471 long FileSize; 472 473 474 if (!Enode->SourceLine) 475 { 476 /* 477 * Use the merged header/source file if present, otherwise 478 * use input file 479 */ 480 SourceFile = FlGetFileHandle (ASL_FILE_SOURCE_OUTPUT, 481 ASL_FILE_SOURCE_OUTPUT, Enode->SourceFilename); 482 if (!SourceFile) 483 { 484 SourceFile = FlGetFileHandle (ASL_FILE_INPUT, 485 ASL_FILE_INPUT, Enode->Filename); 486 } 487 488 if (SourceFile) 489 { 490 /* Determine if the error occurred at source file EOF */ 491 492 fseek (SourceFile, 0, SEEK_END); 493 FileSize = ftell (SourceFile); 494 495 if ((long) Enode->LogicalByteOffset >= FileSize) 496 { 497 *PrematureEOF = TRUE; 498 } 499 } 500 else 501 { 502 fprintf (OutputFile, 503 "[*** iASL: Source File Does not exist ***]\n"); 504 return AE_IO_ERROR; 505 } 506 } 507 508 /* Print filename and line number if present and valid */ 509 510 if (AslGbl_VerboseErrors) 511 { 512 fprintf (OutputFile, "%-8s", Enode->Filename); 513 514 if (Enode->SourceLine && Enode->LineNumber) 515 { 516 fprintf (OutputFile, " %6u: %s", 517 Enode->LineNumber, Enode->SourceLine); 518 } 519 else if (Enode->LineNumber) 520 { 521 fprintf (OutputFile, " %6u: ", Enode->LineNumber); 522 523 /* 524 * If not at EOF, get the corresponding source code line 525 * and display it. Don't attempt this if we have a 526 * premature EOF condition. 527 */ 528 if (*PrematureEOF) 529 { 530 fprintf (OutputFile, "\n"); 531 return AE_OK; 532 } 533 534 /* 535 * Seek to the offset in the combined source file, 536 * read the source line, and write it to the output. 537 */ 538 Actual = fseek (SourceFile, 539 (long) Enode->LogicalByteOffset, (int) SEEK_SET); 540 if (Actual) 541 { 542 fprintf (OutputFile, 543 "[*** iASL: Seek error on source code temp file %s ***]", 544 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); 545 546 fprintf (OutputFile, "\n"); 547 return AE_OK; 548 } 549 RActual = fread (&SourceByte, 1, 1, SourceFile); 550 if (RActual != 1) 551 { 552 fprintf (OutputFile, 553 "[*** iASL: Read error on source code temp file %s ***]", 554 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); 555 return AE_IO_ERROR; 556 } 557 558 /* Read/write the source line, up to the maximum line length */ 559 560 while (RActual && SourceByte && (SourceByte != '\n')) 561 { 562 if (*Total < 256) 563 { 564 /* After the max line length, we will just read the line, no write */ 565 566 if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) 567 { 568 printf ("[*** iASL: Write error on output file ***]\n"); 569 return AE_IO_ERROR; 570 } 571 } 572 else if (*Total == 256) 573 { 574 fprintf (OutputFile, 575 "\n[*** iASL: Very long input line, message below refers to column %u ***]", 576 Enode->Column); 577 } 578 579 RActual = fread (&SourceByte, 1, 1, SourceFile); 580 if (RActual != 1) 581 { 582 fprintf (OutputFile, 583 "[*** iASL: Read error on source code temp file %s ***]", 584 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); 585 586 return AE_IO_ERROR; 587 } 588 *Total += 1; 589 } 590 591 fprintf (OutputFile, "\n"); 592 } 593 } 594 else 595 { 596 /* 597 * Less verbose version of the error message, enabled via the 598 * -vi switch. The format is compatible with MS Visual Studio. 599 */ 600 fprintf (OutputFile, "%s", Enode->Filename); 601 602 if (Enode->LineNumber) 603 { 604 fprintf (OutputFile, "(%u) : ", 605 Enode->LineNumber); 606 } 607 } 608 609 return AE_OK; 610 } 611 612 /******************************************************************************* 613 * 614 * FUNCTION: AePrintException 615 * 616 * PARAMETERS: FileId - ID of output file 617 * Enode - Error node to print 618 * Header - Additional text before each message 619 * 620 * RETURN: None 621 * 622 * DESCRIPTION: Print the contents of an error node. 623 * 624 * NOTE: We don't use the FlxxxFile I/O functions here because on error 625 * they abort the compiler and call this function! Since we 626 * are reporting errors here, we ignore most output errors and 627 * just try to get out as much as we can. 628 * 629 ******************************************************************************/ 630 631 void 632 AePrintException ( 633 UINT32 FileId, 634 ASL_ERROR_MSG *Enode, 635 char *Header) 636 { 637 FILE *OutputFile; 638 BOOLEAN PrematureEOF = FALSE; 639 UINT32 Total = 0; 640 ACPI_STATUS Status; 641 ASL_ERROR_MSG *Child = Enode->SubError; 642 643 644 if (AslGbl_NoErrors) 645 { 646 return; 647 } 648 649 /* 650 * Only listing files have a header, and remarks/optimizations 651 * are always output 652 */ 653 if (!Header) 654 { 655 /* Ignore remarks if requested */ 656 657 switch (Enode->Level) 658 { 659 case ASL_WARNING: 660 case ASL_WARNING2: 661 case ASL_WARNING3: 662 663 if (!AslGbl_DisplayWarnings) 664 { 665 return; 666 } 667 break; 668 669 case ASL_REMARK: 670 671 if (!AslGbl_DisplayRemarks) 672 { 673 return; 674 } 675 break; 676 677 case ASL_OPTIMIZATION: 678 679 if (!AslGbl_DisplayOptimizations) 680 { 681 return; 682 } 683 break; 684 685 default: 686 687 break; 688 } 689 } 690 691 /* Get the various required file handles */ 692 693 OutputFile = AslGbl_Files[FileId].Handle; 694 695 if (Header) 696 { 697 fprintf (OutputFile, "%s", Header); 698 } 699 700 if (!Enode->Filename) 701 { 702 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total); 703 return; 704 } 705 706 Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total); 707 if (ACPI_FAILURE (Status)) 708 { 709 return; 710 } 711 712 /* If a NULL message ID, just print the raw message */ 713 714 if (Enode->MessageId == 0) 715 { 716 fprintf (OutputFile, "%s\n", Enode->Message); 717 return; 718 } 719 720 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total); 721 722 while (Child) 723 { 724 fprintf (OutputFile, "\n"); 725 AePrintSubError (OutputFile, Child); 726 Child = Child->SubError; 727 } 728 } 729 730 731 /******************************************************************************* 732 * 733 * FUNCTION: AePrintSubError 734 * 735 * PARAMETERS: OutputFile - Output file 736 * Enode - Error node to print 737 * 738 * RETURN: None 739 * 740 * DESCRIPTION: Print the contents of an error node. This function is tailored 741 * to print error nodes that are SubErrors within ASL_ERROR_MSG 742 * 743 ******************************************************************************/ 744 745 static void 746 AePrintSubError ( 747 FILE *OutputFile, 748 ASL_ERROR_MSG *Enode) 749 { 750 UINT32 Total = 0; 751 BOOLEAN PrematureEOF = FALSE; 752 const char *MainMessage; 753 754 755 MainMessage = AeDecodeMessageId (Enode->MessageId); 756 757 fprintf (OutputFile, " %s", MainMessage); 758 759 if (Enode->Message) 760 { 761 fprintf (OutputFile, "(%s)", Enode->Message); 762 } 763 764 fprintf (OutputFile, "\n "); 765 (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total); 766 fprintf (OutputFile, "\n"); 767 } 768 769 770 /******************************************************************************* 771 * 772 * FUNCTION: AePrintErrorLog 773 * 774 * PARAMETERS: FileId - Where to output the error log 775 * 776 * RETURN: None 777 * 778 * DESCRIPTION: Print the entire contents of the error log 779 * 780 ******************************************************************************/ 781 782 void 783 AePrintErrorLog ( 784 UINT32 FileId) 785 { 786 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog; 787 788 789 /* Walk the error node list */ 790 791 while (Enode) 792 { 793 AePrintException (FileId, Enode, NULL); 794 Enode = Enode->Next; 795 } 796 } 797 798 799 /******************************************************************************* 800 * 801 * FUNCTION: AslInitEnode 802 * 803 * PARAMETERS: InputEnode - Input Error node to initialize 804 * Level - Seriousness (Warning/error, etc.) 805 * MessageId - Index into global message buffer 806 * CurrentLineNumber - Actual file line number 807 * LogicalLineNumber - Cumulative line number 808 * LogicalByteOffset - Byte offset in source file 809 * Column - Column in current line 810 * Filename - Source filename 811 * ExtraMessage - Additional error message 812 * SourceLine - Line of error source code 813 * SubError - SubError of this InputEnode 814 * 815 * RETURN: None 816 * 817 * DESCRIPTION: Initialize an Error node 818 * 819 ******************************************************************************/ 820 821 static void AslInitEnode ( 822 ASL_ERROR_MSG **InputEnode, 823 UINT8 Level, 824 UINT16 MessageId, 825 UINT32 LineNumber, 826 UINT32 LogicalLineNumber, 827 UINT32 LogicalByteOffset, 828 UINT32 Column, 829 char *Filename, 830 char *ExtraMessage, 831 char *SourceLine, 832 ASL_ERROR_MSG *SubError) 833 { 834 ASL_ERROR_MSG *Enode; 835 ASL_GLOBAL_FILE_NODE *FileNode; 836 837 838 *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG)); 839 Enode = *InputEnode; 840 Enode->Level = Level; 841 Enode->MessageId = MessageId; 842 Enode->LineNumber = LineNumber; 843 Enode->LogicalLineNumber = LogicalLineNumber; 844 Enode->LogicalByteOffset = LogicalByteOffset; 845 Enode->Column = Column; 846 Enode->SubError = SubError; 847 Enode->Message = NULL; 848 Enode->SourceLine = NULL; 849 Enode->Filename = NULL; 850 851 if (ExtraMessage) 852 { 853 /* Allocate a buffer for the message and a new error node */ 854 855 Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1); 856 857 /* Keep a copy of the extra message */ 858 859 strcpy (Enode->Message, ExtraMessage); 860 } 861 862 if (SourceLine) 863 { 864 Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1); 865 strcpy (Enode->SourceLine, SourceLine); 866 } 867 868 869 if (Filename) 870 { 871 Enode->Filename = Filename; 872 Enode->FilenameLength = strlen (Filename); 873 if (Enode->FilenameLength < 6) 874 { 875 Enode->FilenameLength = 6; 876 } 877 878 /* 879 * Attempt to get the file node of the filename listed in the parse 880 * node. If the name doesn't exist in the global file node, it is 881 * because the file is included by #include or ASL include. In this 882 * case, get the current file node. The source output of the current 883 * file will contain the contents of the file listed in the parse node. 884 */ 885 FileNode = FlGetFileNode (ASL_FILE_INPUT, Filename); 886 if (!FileNode) 887 { 888 FileNode = FlGetCurrentFileNode (); 889 } 890 891 Enode->SourceFilename = 892 FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename; 893 } 894 } 895 896 897 /******************************************************************************* 898 * 899 * FUNCTION: AslCommonError2 900 * 901 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 902 * MessageId - Index into global message buffer 903 * LineNumber - Actual file line number 904 * Column - Column in current line 905 * SourceLine - Actual source code line 906 * Filename - Source filename 907 * ExtraMessage - Additional error message 908 * 909 * RETURN: None 910 * 911 * DESCRIPTION: Create a new error node and add it to the error log 912 * 913 ******************************************************************************/ 914 915 void 916 AslCommonError2 ( 917 UINT8 Level, 918 UINT16 MessageId, 919 UINT32 LineNumber, 920 UINT32 Column, 921 char *SourceLine, 922 char *Filename, 923 char *ExtraMessage) 924 { 925 AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column, 926 Filename, ExtraMessage, SourceLine, NULL); 927 } 928 929 930 /******************************************************************************* 931 * 932 * FUNCTION: AslCommonError 933 * 934 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 935 * MessageId - Index into global message buffer 936 * CurrentLineNumber - Actual file line number 937 * LogicalLineNumber - Cumulative line number 938 * LogicalByteOffset - Byte offset in source file 939 * Column - Column in current line 940 * Filename - Source filename 941 * ExtraMessage - Additional error message 942 * 943 * RETURN: None 944 * 945 * DESCRIPTION: Create a new error node and add it to the error log 946 * 947 ******************************************************************************/ 948 949 void 950 AslCommonError ( 951 UINT8 Level, 952 UINT16 MessageId, 953 UINT32 CurrentLineNumber, 954 UINT32 LogicalLineNumber, 955 UINT32 LogicalByteOffset, 956 UINT32 Column, 957 char *Filename, 958 char *ExtraMessage) 959 { 960 /* Check if user wants to ignore this exception */ 961 962 if (AslIsExceptionIgnored (Filename, LogicalLineNumber, Level, MessageId)) 963 { 964 return; 965 } 966 967 AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber, 968 LogicalByteOffset, Column, Filename, ExtraMessage, 969 NULL, NULL); 970 } 971 972 973 /******************************************************************************* 974 * 975 * FUNCTION: AslLogNewError 976 * 977 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 978 * MessageId - Index into global message buffer 979 * CurrentLineNumber - Actual file line number 980 * LogicalLineNumber - Cumulative line number 981 * LogicalByteOffset - Byte offset in source file 982 * Column - Column in current line 983 * Filename - Source filename 984 * Message - Additional error message 985 * SourceLine - Actual line of source code 986 * SubError - Sub-error associated with this error 987 * 988 * RETURN: None 989 * 990 * DESCRIPTION: Create a new error node and add it to the error log 991 * 992 ******************************************************************************/ 993 static void 994 AslLogNewError ( 995 UINT8 Level, 996 UINT16 MessageId, 997 UINT32 LineNumber, 998 UINT32 LogicalLineNumber, 999 UINT32 LogicalByteOffset, 1000 UINT32 Column, 1001 char *Filename, 1002 char *Message, 1003 char *SourceLine, 1004 ASL_ERROR_MSG *SubError) 1005 { 1006 ASL_ERROR_MSG *Enode = NULL; 1007 UINT8 ModifiedLevel = GetModifiedLevel (Level, MessageId); 1008 1009 1010 AslInitEnode (&Enode, ModifiedLevel, MessageId, LineNumber, 1011 LogicalLineNumber, LogicalByteOffset, Column, Filename, Message, 1012 SourceLine, SubError); 1013 1014 /* Add the new node to the error node list */ 1015 1016 AeAddToErrorLog (Enode); 1017 1018 if (AslGbl_DebugFlag) 1019 { 1020 /* stderr is a file, send error to it immediately */ 1021 1022 AePrintException (ASL_FILE_STDERR, Enode, NULL); 1023 } 1024 1025 AslGbl_ExceptionCount[ModifiedLevel]++; 1026 if (!AslGbl_IgnoreErrors && AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) 1027 { 1028 printf ("\nMaximum error count (%u) exceeded (aslerror.c)\n", ASL_MAX_ERROR_COUNT); 1029 1030 AslGbl_SourceLine = 0; 1031 AslGbl_NextError = AslGbl_ErrorLog; 1032 CmCleanupAndExit (); 1033 exit(1); 1034 } 1035 1036 AslGbl_ExceptionCount[ASL_ERROR] = 0; 1037 return; 1038 } 1039 1040 1041 /******************************************************************************* 1042 * 1043 * FUNCTION: GetModifiedLevel 1044 * 1045 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1046 * MessageId - Index into global message buffer 1047 * 1048 * RETURN: UINT8 - Modified level 1049 * 1050 * DESCRIPTION: Get the modified level of exception codes that are reported as 1051 * errors from the -ww option. 1052 * 1053 ******************************************************************************/ 1054 1055 static UINT8 1056 GetModifiedLevel ( 1057 UINT8 Level, 1058 UINT16 MessageId) 1059 { 1060 UINT32 i; 1061 UINT16 ExceptionCode; 1062 1063 1064 ExceptionCode = AeBuildFullExceptionCode (Level, MessageId); 1065 1066 for (i = 0; i < AslGbl_ElevatedMessagesIndex; i++) 1067 { 1068 if (ExceptionCode == AslGbl_ElevatedMessages[i]) 1069 { 1070 return (ASL_ERROR); 1071 } 1072 } 1073 1074 return (Level); 1075 } 1076 1077 1078 /******************************************************************************* 1079 * 1080 * FUNCTION: AslIsExceptionIgnored 1081 * 1082 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1083 * MessageId - Index into global message buffer 1084 * 1085 * RETURN: BOOLEAN 1086 * 1087 * DESCRIPTION: Check if a particular exception is ignored. In this case it 1088 * means that the exception is (expected or disabled. 1089 * 1090 ******************************************************************************/ 1091 1092 BOOLEAN 1093 AslIsExceptionIgnored ( 1094 char *Filename, 1095 UINT32 LineNumber, 1096 UINT8 Level, 1097 UINT16 MessageId) 1098 { 1099 BOOLEAN ExceptionIgnored; 1100 1101 1102 /* Note: this allows exception to be disabled and expected */ 1103 1104 ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId); 1105 ExceptionIgnored |= 1106 AslIsExceptionExpected (Filename, LineNumber, Level, MessageId); 1107 1108 return (AslGbl_AllExceptionsDisabled || ExceptionIgnored); 1109 } 1110 1111 1112 /******************************************************************************* 1113 * 1114 * FUNCTION: AslCheckExpectedException 1115 * 1116 * PARAMETERS: none 1117 * 1118 * RETURN: none 1119 * 1120 * DESCRIPTION: Check the global expected messages table and raise an error 1121 * for each message that has not been received. 1122 * 1123 ******************************************************************************/ 1124 1125 void 1126 AslCheckExpectedExceptions ( 1127 void) 1128 { 1129 UINT32 i; 1130 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList; 1131 ASL_LOCATION_NODE *LocationNode; 1132 1133 1134 for (i = 0; i < AslGbl_ExpectedMessagesIndex; ++i) 1135 { 1136 if (!AslGbl_ExpectedMessages[i].MessageReceived) 1137 { 1138 AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL, 1139 AslGbl_ExpectedMessages[i].MessageIdStr); 1140 } 1141 } 1142 1143 while (Current) 1144 { 1145 LocationNode = Current->LocationList; 1146 1147 while (LocationNode) 1148 { 1149 if (!LocationNode->MessageReceived) 1150 { 1151 AslCommonError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, 1152 LocationNode->LineNumber, LocationNode->LineNumber, 1153 LocationNode->LogicalByteOffset, LocationNode->Column, 1154 LocationNode->Filename, Current->MessageIdStr); 1155 } 1156 1157 LocationNode = LocationNode->Next; 1158 } 1159 1160 Current = Current->Next; 1161 } 1162 } 1163 1164 1165 /******************************************************************************* 1166 * 1167 * FUNCTION: AslLogExpectedException 1168 * 1169 * PARAMETERS: MessageIdString - ID of excepted exception during compile 1170 * 1171 * RETURN: Status 1172 * 1173 * DESCRIPTION: Enter a message ID into the global expected messages table 1174 * If these messages are not raised during the compilation, throw 1175 * an error. 1176 * 1177 ******************************************************************************/ 1178 1179 ACPI_STATUS 1180 AslLogExpectedException ( 1181 char *MessageIdString) 1182 { 1183 UINT32 MessageId; 1184 1185 1186 /* Convert argument to an integer and validate it */ 1187 1188 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); 1189 1190 if (MessageId > 6999) 1191 { 1192 printf ("\"%s\" is not a valid warning/remark/error ID\n", 1193 MessageIdString); 1194 return (AE_BAD_PARAMETER); 1195 } 1196 1197 /* Insert value into the global expected message array */ 1198 1199 if (AslGbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES) 1200 { 1201 printf ("Too many messages have been registered as expected (max %d)\n", 1202 ASL_MAX_DISABLED_MESSAGES); 1203 return (AE_LIMIT); 1204 } 1205 1206 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageId = MessageId; 1207 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString; 1208 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageReceived = FALSE; 1209 AslGbl_ExpectedMessagesIndex++; 1210 return (AE_OK); 1211 } 1212 1213 1214 /******************************************************************************* 1215 * 1216 * FUNCTION: AslLogExpectedExceptionByLine 1217 * 1218 * PARAMETERS: MessageIdString - ID of excepted exception during compile 1219 * 1220 * RETURN: Status 1221 * 1222 * DESCRIPTION: Enter a message ID into the global expected messages table 1223 * based on file and line number. If these messages are not raised 1224 * during the compilation, throw an error. 1225 * 1226 ******************************************************************************/ 1227 1228 void 1229 AslLogExpectedExceptionByLine ( 1230 char *MessageIdString) 1231 { 1232 ASL_LOCATION_NODE *NewErrorLocationNode; 1233 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList; 1234 UINT32 MessageId; 1235 1236 1237 NewErrorLocationNode = UtLocalCalloc (sizeof (ASL_LOCATION_NODE)); 1238 1239 NewErrorLocationNode->LineNumber = AslGbl_CurrentLineNumber; 1240 NewErrorLocationNode->Filename = AslGbl_Files[ASL_FILE_INPUT].Filename; 1241 NewErrorLocationNode->LogicalByteOffset = AslGbl_CurrentLineOffset; 1242 NewErrorLocationNode->Column = AslGbl_CurrentColumn; 1243 1244 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); 1245 1246 /* search the existing list for a matching message ID */ 1247 1248 while (Current && Current->MessageId != MessageId ) 1249 { 1250 Current = Current->Next; 1251 } 1252 if (!Current) 1253 { 1254 /* ID was not found, create a new node for this message ID */ 1255 1256 Current = UtLocalCalloc (sizeof (ASL_EXPECTED_MSG_NODE)); 1257 1258 Current->Next = AslGbl_ExpectedErrorCodeList; 1259 Current->MessageIdStr = MessageIdString; 1260 Current->MessageId = MessageId; 1261 AslGbl_ExpectedErrorCodeList = Current; 1262 } 1263 1264 NewErrorLocationNode->Next = Current->LocationList; 1265 Current->LocationList = NewErrorLocationNode; 1266 } 1267 1268 1269 /******************************************************************************* 1270 * 1271 * FUNCTION: AslDisableException 1272 * 1273 * PARAMETERS: MessageIdString - ID to be disabled 1274 * 1275 * RETURN: Status 1276 * 1277 * DESCRIPTION: Enter a message ID into the global disabled messages table 1278 * 1279 ******************************************************************************/ 1280 1281 ACPI_STATUS 1282 AslDisableException ( 1283 char *MessageIdString) 1284 { 1285 UINT32 MessageId; 1286 1287 1288 /* Convert argument to an integer and validate it */ 1289 1290 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); 1291 1292 if ((MessageId < 2000) || (MessageId > 6999)) 1293 { 1294 printf ("\"%s\" is not a valid warning/remark/error ID\n", 1295 MessageIdString); 1296 return (AE_BAD_PARAMETER); 1297 } 1298 1299 /* Insert value into the global disabled message array */ 1300 1301 if (AslGbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES) 1302 { 1303 printf ("Too many messages have been disabled (max %d)\n", 1304 ASL_MAX_DISABLED_MESSAGES); 1305 return (AE_LIMIT); 1306 } 1307 1308 AslGbl_DisabledMessages[AslGbl_DisabledMessagesIndex] = MessageId; 1309 AslGbl_DisabledMessagesIndex++; 1310 return (AE_OK); 1311 } 1312 1313 1314 /******************************************************************************* 1315 * 1316 * FUNCTION: AslElevateException 1317 * 1318 * PARAMETERS: MessageIdString - ID of excepted exception during compile 1319 * 1320 * RETURN: Status 1321 * 1322 * DESCRIPTION: Enter a message ID into the global elevated exceptions table. 1323 * These messages will be considered as compilation errors. 1324 * 1325 ******************************************************************************/ 1326 1327 ACPI_STATUS 1328 AslElevateException ( 1329 char *MessageIdString) 1330 { 1331 UINT32 MessageId; 1332 1333 1334 /* Convert argument to an integer and validate it */ 1335 1336 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); 1337 1338 if (MessageId > 6999) 1339 { 1340 printf ("\"%s\" is not a valid warning/remark/error ID\n", 1341 MessageIdString); 1342 return (AE_BAD_PARAMETER); 1343 } 1344 1345 /* Insert value into the global expected message array */ 1346 1347 if (AslGbl_ElevatedMessagesIndex >= ASL_MAX_ELEVATED_MESSAGES) 1348 { 1349 printf ("Too many messages have been registered as elevated (max %d)\n", 1350 ASL_MAX_DISABLED_MESSAGES); 1351 return (AE_LIMIT); 1352 } 1353 1354 AslGbl_ElevatedMessages[AslGbl_ElevatedMessagesIndex] = MessageId; 1355 AslGbl_ElevatedMessagesIndex++; 1356 return (AE_OK); 1357 } 1358 1359 1360 /******************************************************************************* 1361 * 1362 * FUNCTION: AslIsExceptionDisabled 1363 * 1364 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1365 * MessageId - Index into global message buffer 1366 * 1367 * RETURN: TRUE if exception/message should be ignored 1368 * 1369 * DESCRIPTION: Check if the user has specified options such that this 1370 * exception should be ignored 1371 * 1372 ******************************************************************************/ 1373 1374 static BOOLEAN 1375 AslIsExceptionExpected ( 1376 char *Filename, 1377 UINT32 LineNumber, 1378 UINT8 Level, 1379 UINT16 MessageId) 1380 { 1381 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList; 1382 ASL_LOCATION_NODE *CurrentErrorLocation; 1383 UINT32 EncodedMessageId; 1384 UINT32 i; 1385 1386 1387 /* Mark this exception as received */ 1388 1389 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId); 1390 for (i = 0; i < AslGbl_ExpectedMessagesIndex; i++) 1391 { 1392 /* Simple implementation via fixed array */ 1393 1394 if (EncodedMessageId == AslGbl_ExpectedMessages[i].MessageId) 1395 { 1396 return (AslGbl_ExpectedMessages[i].MessageReceived = TRUE); 1397 } 1398 } 1399 1400 while (Current && Current->MessageId != EncodedMessageId) 1401 { 1402 Current = Current->Next; 1403 } 1404 if (!Current) 1405 { 1406 return (FALSE); 1407 } 1408 1409 CurrentErrorLocation = Current->LocationList; 1410 1411 while (CurrentErrorLocation) 1412 { 1413 if (!strcmp (CurrentErrorLocation->Filename, Filename) && 1414 CurrentErrorLocation->LineNumber == LineNumber) 1415 { 1416 return (CurrentErrorLocation->MessageReceived = TRUE); 1417 } 1418 1419 CurrentErrorLocation = CurrentErrorLocation->Next; 1420 } 1421 1422 return (FALSE); 1423 } 1424 1425 1426 /******************************************************************************* 1427 * 1428 * FUNCTION: AslIsExceptionDisabled 1429 * 1430 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1431 * MessageId - Index into global message buffer 1432 * 1433 * RETURN: TRUE if exception/message should be ignored 1434 * 1435 * DESCRIPTION: Check if the user has specified options such that this 1436 * exception should be ignored 1437 * 1438 ******************************************************************************/ 1439 1440 static BOOLEAN 1441 AslIsExceptionDisabled ( 1442 UINT8 Level, 1443 UINT16 MessageId) 1444 { 1445 UINT32 EncodedMessageId; 1446 UINT32 i; 1447 1448 1449 switch (Level) 1450 { 1451 case ASL_WARNING2: 1452 case ASL_WARNING3: 1453 1454 /* Check for global disable via -w1/-w2/-w3 options */ 1455 1456 if (Level > AslGbl_WarningLevel) 1457 { 1458 return (TRUE); 1459 } 1460 ACPI_FALLTHROUGH; 1461 1462 case ASL_WARNING: 1463 case ASL_REMARK: 1464 case ASL_ERROR: 1465 /* 1466 * Ignore this error/warning/remark if it has been disabled by 1467 * the user (-vw option) 1468 */ 1469 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId); 1470 for (i = 0; i < AslGbl_DisabledMessagesIndex; i++) 1471 { 1472 /* Simple implementation via fixed array */ 1473 1474 if (EncodedMessageId == AslGbl_DisabledMessages[i]) 1475 { 1476 return (TRUE); 1477 } 1478 } 1479 break; 1480 1481 default: 1482 break; 1483 } 1484 1485 return (FALSE); 1486 } 1487 1488 1489 /******************************************************************************* 1490 * 1491 * FUNCTION: AslDualParseOpError 1492 * 1493 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1494 * MainMsgId - Index into global message buffer 1495 * MainOp - Parse node where error happened 1496 * MainMsg - Message pertaining to the MainOp 1497 * SubMsgId - Index into global message buffer 1498 * SubOp - Additional parse node for better message 1499 * SubMsg - Message pertaining to SubOp 1500 * 1501 * 1502 * RETURN: None 1503 * 1504 * DESCRIPTION: Main error reporting routine for the ASL compiler for error 1505 * messages that point to multiple parse objects. 1506 * 1507 ******************************************************************************/ 1508 1509 void 1510 AslDualParseOpError ( 1511 UINT8 Level, 1512 UINT16 MainMsgId, 1513 ACPI_PARSE_OBJECT *MainOp, 1514 char *MainMsg, 1515 UINT16 SubMsgId, 1516 ACPI_PARSE_OBJECT *SubOp, 1517 char *SubMsg) 1518 { 1519 ASL_ERROR_MSG *SubEnode = NULL; 1520 1521 1522 /* Check if user wants to ignore this exception */ 1523 1524 if (!MainOp || AslIsExceptionIgnored (MainOp->Asl.Filename, 1525 MainOp->Asl.LogicalLineNumber, Level, MainMsgId)) 1526 { 1527 return; 1528 } 1529 1530 if (SubOp) 1531 { 1532 AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber, 1533 SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset, 1534 SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg, 1535 NULL, NULL); 1536 } 1537 1538 AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber, 1539 MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset, 1540 MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg, 1541 NULL, SubEnode); 1542 } 1543 1544 1545 /******************************************************************************* 1546 * 1547 * FUNCTION: AslError 1548 * 1549 * PARAMETERS: Level - Seriousness (Warning/error, etc.) 1550 * MessageId - Index into global message buffer 1551 * Op - Parse node where error happened 1552 * ExtraMessage - Additional error message 1553 * 1554 * RETURN: None 1555 * 1556 * DESCRIPTION: Main error reporting routine for the ASL compiler (all code 1557 * except the parser.) 1558 * 1559 ******************************************************************************/ 1560 1561 void 1562 AslError ( 1563 UINT8 Level, 1564 UINT16 MessageId, 1565 ACPI_PARSE_OBJECT *Op, 1566 char *ExtraMessage) 1567 { 1568 if (Op) 1569 { 1570 AslCommonError (Level, MessageId, Op->Asl.LineNumber, 1571 Op->Asl.LogicalLineNumber, 1572 Op->Asl.LogicalByteOffset, 1573 Op->Asl.Column, 1574 Op->Asl.Filename, ExtraMessage); 1575 } 1576 else 1577 { 1578 AslCommonError (Level, MessageId, 0, 1579 0, 0, 0, NULL, ExtraMessage); 1580 } 1581 } 1582 1583 1584 /******************************************************************************* 1585 * 1586 * FUNCTION: AslCoreSubsystemError 1587 * 1588 * PARAMETERS: Op - Parse node where error happened 1589 * Status - The ACPICA Exception 1590 * ExtraMessage - Additional error message 1591 * Abort - TRUE -> Abort compilation 1592 * 1593 * RETURN: None 1594 * 1595 * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA 1596 * core subsystem. 1597 * 1598 ******************************************************************************/ 1599 1600 void 1601 AslCoreSubsystemError ( 1602 ACPI_PARSE_OBJECT *Op, 1603 ACPI_STATUS Status, 1604 char *ExtraMessage, 1605 BOOLEAN Abort) 1606 { 1607 1608 sprintf (AslGbl_MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage); 1609 1610 if (Op) 1611 { 1612 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 1613 Op->Asl.LineNumber, 1614 Op->Asl.LogicalLineNumber, 1615 Op->Asl.LogicalByteOffset, 1616 Op->Asl.Column, 1617 Op->Asl.Filename, AslGbl_MsgBuffer); 1618 } 1619 else 1620 { 1621 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 1622 0, 0, 0, 0, NULL, AslGbl_MsgBuffer); 1623 } 1624 1625 if (Abort) 1626 { 1627 AslAbort (); 1628 } 1629 } 1630 1631 1632 /******************************************************************************* 1633 * 1634 * FUNCTION: AslCompilererror 1635 * 1636 * PARAMETERS: CompilerMessage - Error message from the parser 1637 * 1638 * RETURN: Status (0 for now) 1639 * 1640 * DESCRIPTION: Report an error situation discovered in a production 1641 * NOTE: don't change the name of this function, it is called 1642 * from the auto-generated parser. 1643 * 1644 ******************************************************************************/ 1645 1646 int 1647 AslCompilererror ( 1648 const char *CompilerMessage) 1649 { 1650 1651 AslGbl_SyntaxError++; 1652 1653 AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, AslGbl_CurrentLineNumber, 1654 AslGbl_LogicalLineNumber, AslGbl_CurrentLineOffset, 1655 AslGbl_CurrentColumn, AslGbl_Files[ASL_FILE_INPUT].Filename, 1656 ACPI_CAST_PTR (char, CompilerMessage)); 1657 1658 return (0); 1659 } 1660