aslerror.c revision 1.9 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: aslerror - Error handling and statistics
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.2 christos /*
8 1.7 christos * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.2 christos * Redistribution and use in source and binary forms, with or without
12 1.2 christos * modification, are permitted provided that the following conditions
13 1.2 christos * are met:
14 1.2 christos * 1. Redistributions of source code must retain the above copyright
15 1.2 christos * notice, this list of conditions, and the following disclaimer,
16 1.2 christos * without modification.
17 1.2 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.2 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.2 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.2 christos * including a substantially similar Disclaimer requirement for further
21 1.2 christos * binary redistribution.
22 1.2 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.2 christos * of any contributors may be used to endorse or promote products derived
24 1.2 christos * from this software without specific prior written permission.
25 1.2 christos *
26 1.2 christos * Alternatively, this software may be distributed under the terms of the
27 1.2 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.2 christos * Software Foundation.
29 1.2 christos *
30 1.2 christos * NO WARRANTY
31 1.2 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.2 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.2 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.2 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.2 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.2 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.2 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.2 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.2 christos */
43 1.1 jruoho
44 1.1 jruoho #include "aslcompiler.h"
45 1.1 jruoho
46 1.1 jruoho #define _COMPONENT ACPI_COMPILER
47 1.1 jruoho ACPI_MODULE_NAME ("aslerror")
48 1.1 jruoho
49 1.1 jruoho /* Local prototypes */
50 1.1 jruoho
51 1.1 jruoho static void
52 1.1 jruoho AeAddToErrorLog (
53 1.1 jruoho ASL_ERROR_MSG *Enode);
54 1.1 jruoho
55 1.8 christos static BOOLEAN
56 1.8 christos AslIsExceptionExpected (
57 1.8 christos UINT8 Level,
58 1.8 christos UINT16 MessageId);
59 1.8 christos
60 1.8 christos static BOOLEAN
61 1.8 christos AslIsExceptionDisabled (
62 1.8 christos UINT8 Level,
63 1.8 christos UINT16 MessageId);
64 1.8 christos
65 1.9 christos static void AslInitEnode (
66 1.9 christos ASL_ERROR_MSG **Enode,
67 1.9 christos UINT8 Level,
68 1.9 christos UINT16 MessageId,
69 1.9 christos UINT32 LineNumber,
70 1.9 christos UINT32 LogicalLineNumber,
71 1.9 christos UINT32 LogicalByteOffset,
72 1.9 christos UINT32 Column,
73 1.9 christos char *Filename,
74 1.9 christos char *Message,
75 1.9 christos char *SourceLine,
76 1.9 christos ASL_ERROR_MSG *SubError);
77 1.9 christos
78 1.9 christos static void
79 1.9 christos AslLogNewError (
80 1.9 christos UINT8 Level,
81 1.9 christos UINT16 MessageId,
82 1.9 christos UINT32 LineNumber,
83 1.9 christos UINT32 LogicalLineNumber,
84 1.9 christos UINT32 LogicalByteOffset,
85 1.9 christos UINT32 Column,
86 1.9 christos char *Filename,
87 1.9 christos char *Message,
88 1.9 christos char *SourceLine,
89 1.9 christos ASL_ERROR_MSG *SubError);
90 1.9 christos
91 1.9 christos static void
92 1.9 christos AePrintSubError (
93 1.9 christos FILE *OutputFile,
94 1.9 christos ASL_ERROR_MSG *Enode);
95 1.9 christos
96 1.1 jruoho
97 1.2 christos /*******************************************************************************
98 1.2 christos *
99 1.3 christos * FUNCTION: AslAbort
100 1.3 christos *
101 1.3 christos * PARAMETERS: None
102 1.3 christos *
103 1.3 christos * RETURN: None
104 1.3 christos *
105 1.3 christos * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
106 1.3 christos * I/O errors.
107 1.3 christos *
108 1.3 christos ******************************************************************************/
109 1.3 christos
110 1.3 christos void
111 1.3 christos AslAbort (
112 1.3 christos void)
113 1.3 christos {
114 1.3 christos
115 1.3 christos AePrintErrorLog (ASL_FILE_STDERR);
116 1.3 christos if (Gbl_DebugFlag)
117 1.3 christos {
118 1.3 christos /* Print error summary to stdout also */
119 1.3 christos
120 1.3 christos AePrintErrorLog (ASL_FILE_STDOUT);
121 1.3 christos }
122 1.3 christos
123 1.3 christos exit (1);
124 1.3 christos }
125 1.3 christos
126 1.3 christos
127 1.3 christos /*******************************************************************************
128 1.3 christos *
129 1.2 christos * FUNCTION: AeClearErrorLog
130 1.2 christos *
131 1.2 christos * PARAMETERS: None
132 1.2 christos *
133 1.2 christos * RETURN: None
134 1.2 christos *
135 1.2 christos * DESCRIPTION: Empty the error list
136 1.2 christos *
137 1.2 christos ******************************************************************************/
138 1.2 christos
139 1.1 jruoho void
140 1.1 jruoho AeClearErrorLog (
141 1.1 jruoho void)
142 1.1 jruoho {
143 1.1 jruoho ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
144 1.1 jruoho ASL_ERROR_MSG *Next;
145 1.1 jruoho
146 1.9 christos
147 1.1 jruoho /* Walk the error node list */
148 1.1 jruoho
149 1.1 jruoho while (Enode)
150 1.1 jruoho {
151 1.1 jruoho Next = Enode->Next;
152 1.1 jruoho ACPI_FREE (Enode);
153 1.1 jruoho Enode = Next;
154 1.1 jruoho }
155 1.1 jruoho
156 1.1 jruoho Gbl_ErrorLog = NULL;
157 1.1 jruoho }
158 1.1 jruoho
159 1.1 jruoho
160 1.1 jruoho /*******************************************************************************
161 1.1 jruoho *
162 1.1 jruoho * FUNCTION: AeAddToErrorLog
163 1.1 jruoho *
164 1.1 jruoho * PARAMETERS: Enode - An error node to add to the log
165 1.1 jruoho *
166 1.1 jruoho * RETURN: None
167 1.1 jruoho *
168 1.2 christos * DESCRIPTION: Add a new error node to the error log. The error log is
169 1.1 jruoho * ordered by the "logical" line number (cumulative line number
170 1.1 jruoho * including all include files.)
171 1.1 jruoho *
172 1.1 jruoho ******************************************************************************/
173 1.1 jruoho
174 1.1 jruoho static void
175 1.1 jruoho AeAddToErrorLog (
176 1.1 jruoho ASL_ERROR_MSG *Enode)
177 1.1 jruoho {
178 1.1 jruoho ASL_ERROR_MSG *Next;
179 1.1 jruoho ASL_ERROR_MSG *Prev;
180 1.1 jruoho
181 1.1 jruoho
182 1.1 jruoho /* If Gbl_ErrorLog is null, this is the first error node */
183 1.1 jruoho
184 1.1 jruoho if (!Gbl_ErrorLog)
185 1.1 jruoho {
186 1.1 jruoho Gbl_ErrorLog = Enode;
187 1.1 jruoho return;
188 1.1 jruoho }
189 1.1 jruoho
190 1.1 jruoho /*
191 1.1 jruoho * Walk error list until we find a line number greater than ours.
192 1.1 jruoho * List is sorted according to line number.
193 1.1 jruoho */
194 1.1 jruoho Prev = NULL;
195 1.1 jruoho Next = Gbl_ErrorLog;
196 1.1 jruoho
197 1.9 christos while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
198 1.1 jruoho {
199 1.1 jruoho Prev = Next;
200 1.1 jruoho Next = Next->Next;
201 1.1 jruoho }
202 1.1 jruoho
203 1.1 jruoho /* Found our place in the list */
204 1.1 jruoho
205 1.1 jruoho Enode->Next = Next;
206 1.1 jruoho
207 1.1 jruoho if (Prev)
208 1.1 jruoho {
209 1.1 jruoho Prev->Next = Enode;
210 1.1 jruoho }
211 1.1 jruoho else
212 1.1 jruoho {
213 1.1 jruoho Gbl_ErrorLog = Enode;
214 1.1 jruoho }
215 1.1 jruoho }
216 1.1 jruoho
217 1.1 jruoho
218 1.1 jruoho /*******************************************************************************
219 1.1 jruoho *
220 1.9 christos * FUNCTION: AeDecodeErrorMessageId
221 1.1 jruoho *
222 1.9 christos * PARAMETERS: OutputFile - Output file
223 1.1 jruoho * Enode - Error node to print
224 1.9 christos * PrematureEOF - True = PrematureEOF has been reached
225 1.9 christos * Total - Total legth of line
226 1.1 jruoho *
227 1.1 jruoho * RETURN: None
228 1.1 jruoho *
229 1.9 christos * DESCRIPTION: Print the source line of an error.
230 1.1 jruoho *
231 1.1 jruoho ******************************************************************************/
232 1.1 jruoho
233 1.9 christos static void
234 1.9 christos AeDecodeErrorMessageId (
235 1.9 christos FILE *OutputFile,
236 1.1 jruoho ASL_ERROR_MSG *Enode,
237 1.9 christos BOOLEAN PrematureEOF,
238 1.9 christos UINT32 Total)
239 1.1 jruoho {
240 1.1 jruoho UINT32 MsgLength;
241 1.3 christos const char *MainMessage;
242 1.1 jruoho char *ExtraMessage;
243 1.1 jruoho UINT32 SourceColumn;
244 1.1 jruoho UINT32 ErrorColumn;
245 1.1 jruoho
246 1.1 jruoho
247 1.9 christos fprintf (OutputFile, "%s %4.4d -",
248 1.9 christos AeDecodeExceptionLevel (Enode->Level),
249 1.9 christos AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
250 1.9 christos
251 1.9 christos MainMessage = AeDecodeMessageId (Enode->MessageId);
252 1.9 christos ExtraMessage = Enode->Message;
253 1.9 christos
254 1.9 christos /* If a NULL line number, just print the decoded message */
255 1.9 christos
256 1.9 christos if (!Enode->LineNumber)
257 1.1 jruoho {
258 1.9 christos fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
259 1.1 jruoho return;
260 1.1 jruoho }
261 1.1 jruoho
262 1.9 christos MsgLength = strlen (MainMessage);
263 1.9 christos if (MsgLength == 0)
264 1.1 jruoho {
265 1.9 christos /* Use the secondary/extra message as main message */
266 1.9 christos
267 1.9 christos MainMessage = Enode->Message;
268 1.9 christos if (!MainMessage)
269 1.9 christos {
270 1.9 christos MainMessage = "";
271 1.9 christos }
272 1.9 christos
273 1.9 christos MsgLength = strlen (MainMessage);
274 1.9 christos ExtraMessage = NULL;
275 1.9 christos }
276 1.1 jruoho
277 1.9 christos if (Gbl_VerboseErrors && !PrematureEOF)
278 1.9 christos {
279 1.9 christos if (Total >= 256)
280 1.9 christos {
281 1.9 christos fprintf (OutputFile, " %s",
282 1.9 christos MainMessage);
283 1.9 christos }
284 1.9 christos else
285 1.1 jruoho {
286 1.9 christos SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
287 1.9 christos ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
288 1.2 christos
289 1.9 christos if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
290 1.2 christos {
291 1.9 christos fprintf (OutputFile, "%*s%s",
292 1.9 christos (int) ((SourceColumn - 1) - ErrorColumn),
293 1.9 christos MainMessage, " ^ ");
294 1.2 christos }
295 1.9 christos else
296 1.1 jruoho {
297 1.9 christos fprintf (OutputFile, "%*s %s",
298 1.9 christos (int) ((SourceColumn - ErrorColumn) + 1), "^",
299 1.9 christos MainMessage);
300 1.1 jruoho }
301 1.9 christos }
302 1.9 christos }
303 1.9 christos else
304 1.9 christos {
305 1.9 christos fprintf (OutputFile, " %s", MainMessage);
306 1.9 christos }
307 1.1 jruoho
308 1.9 christos /* Print the extra info message if present */
309 1.2 christos
310 1.9 christos if (ExtraMessage)
311 1.9 christos {
312 1.9 christos fprintf (OutputFile, " (%s)", ExtraMessage);
313 1.9 christos }
314 1.1 jruoho
315 1.9 christos if (PrematureEOF)
316 1.9 christos {
317 1.9 christos fprintf (OutputFile, " and premature End-Of-File");
318 1.9 christos }
319 1.2 christos
320 1.9 christos fprintf (OutputFile, "\n");
321 1.9 christos if (Gbl_VerboseErrors && !Enode->SubError)
322 1.9 christos {
323 1.9 christos fprintf (OutputFile, "\n");
324 1.1 jruoho }
325 1.9 christos }
326 1.9 christos
327 1.9 christos
328 1.9 christos /*******************************************************************************
329 1.9 christos *
330 1.9 christos * FUNCTION: AePrintErrorSourceLine
331 1.9 christos *
332 1.9 christos * PARAMETERS: OutputFile - Output file
333 1.9 christos * Enode - Error node to print
334 1.9 christos * PrematureEOF - True = PrematureEOF has been reached
335 1.9 christos * Total - amount of characters printed so far
336 1.9 christos *
337 1.9 christos *
338 1.9 christos * RETURN: Status
339 1.9 christos *
340 1.9 christos * DESCRIPTION: Print the source line of an error.
341 1.9 christos *
342 1.9 christos ******************************************************************************/
343 1.1 jruoho
344 1.9 christos static ACPI_STATUS
345 1.9 christos AePrintErrorSourceLine (
346 1.9 christos FILE *OutputFile,
347 1.9 christos ASL_ERROR_MSG *Enode,
348 1.9 christos BOOLEAN *PrematureEOF,
349 1.9 christos UINT32 *Total)
350 1.9 christos {
351 1.9 christos UINT8 SourceByte;
352 1.9 christos int Actual;
353 1.9 christos size_t RActual;
354 1.9 christos FILE *SourceFile = NULL;
355 1.9 christos long FileSize;
356 1.1 jruoho
357 1.2 christos
358 1.2 christos if (!Enode->SourceLine)
359 1.2 christos {
360 1.6 christos /*
361 1.6 christos * Use the merged header/source file if present, otherwise
362 1.6 christos * use input file
363 1.6 christos */
364 1.2 christos SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
365 1.2 christos if (!SourceFile)
366 1.2 christos {
367 1.2 christos SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
368 1.2 christos }
369 1.2 christos
370 1.2 christos if (SourceFile)
371 1.2 christos {
372 1.2 christos /* Determine if the error occurred at source file EOF */
373 1.2 christos
374 1.2 christos fseek (SourceFile, 0, SEEK_END);
375 1.2 christos FileSize = ftell (SourceFile);
376 1.2 christos
377 1.2 christos if ((long) Enode->LogicalByteOffset >= FileSize)
378 1.2 christos {
379 1.9 christos *PrematureEOF = TRUE;
380 1.2 christos }
381 1.2 christos }
382 1.9 christos else
383 1.9 christos {
384 1.9 christos fprintf (OutputFile,
385 1.9 christos "[*** iASL: Source File Does not exist ***]\n");
386 1.9 christos return AE_IO_ERROR;
387 1.9 christos }
388 1.1 jruoho }
389 1.1 jruoho
390 1.1 jruoho /* Print filename and line number if present and valid */
391 1.1 jruoho
392 1.9 christos if (Gbl_VerboseErrors)
393 1.1 jruoho {
394 1.9 christos fprintf (OutputFile, "%-8s", Enode->Filename);
395 1.9 christos
396 1.9 christos if (Enode->SourceLine && Enode->LineNumber)
397 1.9 christos {
398 1.9 christos fprintf (OutputFile, " %6u: %s",
399 1.9 christos Enode->LineNumber, Enode->SourceLine);
400 1.9 christos }
401 1.9 christos else if (Enode->LineNumber)
402 1.1 jruoho {
403 1.9 christos fprintf (OutputFile, " %6u: ", Enode->LineNumber);
404 1.9 christos
405 1.9 christos /*
406 1.9 christos * If not at EOF, get the corresponding source code line
407 1.9 christos * and display it. Don't attempt this if we have a
408 1.9 christos * premature EOF condition.
409 1.9 christos */
410 1.9 christos if (*PrematureEOF)
411 1.9 christos {
412 1.9 christos fprintf (OutputFile, "\n");
413 1.9 christos return AE_OK;
414 1.9 christos }
415 1.9 christos /*
416 1.9 christos * Seek to the offset in the combined source file,
417 1.9 christos * read the source line, and write it to the output.
418 1.9 christos */
419 1.9 christos Actual = fseek (SourceFile,
420 1.9 christos (long) Enode->LogicalByteOffset, (int) SEEK_SET);
421 1.9 christos if (Actual)
422 1.9 christos {
423 1.9 christos fprintf (OutputFile,
424 1.9 christos "[*** iASL: Seek error on source code temp file %s ***]",
425 1.9 christos Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
426 1.9 christos
427 1.9 christos fprintf (OutputFile, "\n");
428 1.9 christos return AE_OK;
429 1.9 christos }
430 1.9 christos RActual = fread (&SourceByte, 1, 1, SourceFile);
431 1.9 christos if (RActual != 1)
432 1.9 christos {
433 1.9 christos fprintf (OutputFile,
434 1.9 christos "[*** iASL: Read error on source code temp file %s ***]",
435 1.9 christos Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
436 1.9 christos return AE_IO_ERROR;
437 1.9 christos }
438 1.9 christos /* Read/write the source line, up to the maximum line length */
439 1.1 jruoho
440 1.9 christos while (RActual && SourceByte && (SourceByte != '\n'))
441 1.1 jruoho {
442 1.9 christos if (*Total < 256)
443 1.1 jruoho {
444 1.9 christos /* After the max line length, we will just read the line, no write */
445 1.9 christos
446 1.9 christos if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
447 1.9 christos {
448 1.9 christos printf ("[*** iASL: Write error on output file ***]\n");
449 1.9 christos return AE_IO_ERROR;
450 1.9 christos }
451 1.1 jruoho }
452 1.9 christos else if (*Total == 256)
453 1.1 jruoho {
454 1.9 christos fprintf (OutputFile,
455 1.9 christos "\n[*** iASL: Very long input line, message below refers to column %u ***]",
456 1.9 christos Enode->Column);
457 1.9 christos }
458 1.2 christos
459 1.9 christos RActual = fread (&SourceByte, 1, 1, SourceFile);
460 1.9 christos if (RActual != 1)
461 1.9 christos {
462 1.9 christos fprintf (OutputFile,
463 1.9 christos "[*** iASL: Read error on source code temp file %s ***]",
464 1.9 christos Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
465 1.1 jruoho
466 1.9 christos return AE_IO_ERROR;
467 1.1 jruoho }
468 1.9 christos *Total += 1;
469 1.1 jruoho }
470 1.1 jruoho
471 1.9 christos fprintf (OutputFile, "\n");
472 1.1 jruoho }
473 1.1 jruoho }
474 1.9 christos else
475 1.9 christos {
476 1.9 christos /*
477 1.9 christos * Less verbose version of the error message, enabled via the
478 1.9 christos * -vi switch. The format is compatible with MS Visual Studio.
479 1.9 christos */
480 1.9 christos fprintf (OutputFile, "%s", Enode->Filename);
481 1.1 jruoho
482 1.9 christos if (Enode->LineNumber)
483 1.9 christos {
484 1.9 christos fprintf (OutputFile, "(%u) : ",
485 1.9 christos Enode->LineNumber);
486 1.9 christos }
487 1.3 christos }
488 1.3 christos
489 1.9 christos return AE_OK;
490 1.9 christos }
491 1.3 christos
492 1.9 christos /*******************************************************************************
493 1.9 christos *
494 1.9 christos * FUNCTION: AePrintException
495 1.9 christos *
496 1.9 christos * PARAMETERS: FileId - ID of output file
497 1.9 christos * Enode - Error node to print
498 1.9 christos * Header - Additional text before each message
499 1.9 christos *
500 1.9 christos * RETURN: None
501 1.9 christos *
502 1.9 christos * DESCRIPTION: Print the contents of an error node.
503 1.9 christos *
504 1.9 christos * NOTE: We don't use the FlxxxFile I/O functions here because on error
505 1.9 christos * they abort the compiler and call this function! Since we
506 1.9 christos * are reporting errors here, we ignore most output errors and
507 1.9 christos * just try to get out as much as we can.
508 1.9 christos *
509 1.9 christos ******************************************************************************/
510 1.3 christos
511 1.9 christos void
512 1.9 christos AePrintException (
513 1.9 christos UINT32 FileId,
514 1.9 christos ASL_ERROR_MSG *Enode,
515 1.9 christos char *Header)
516 1.9 christos {
517 1.9 christos FILE *OutputFile;
518 1.9 christos BOOLEAN PrematureEOF = FALSE;
519 1.9 christos UINT32 Total = 0;
520 1.9 christos ACPI_STATUS Status;
521 1.9 christos ASL_ERROR_MSG *Child = Enode->SubError;
522 1.3 christos
523 1.3 christos
524 1.9 christos if (Gbl_NoErrors)
525 1.3 christos {
526 1.3 christos return;
527 1.1 jruoho }
528 1.3 christos
529 1.9 christos /*
530 1.9 christos * Only listing files have a header, and remarks/optimizations
531 1.9 christos * are always output
532 1.9 christos */
533 1.9 christos if (!Header)
534 1.1 jruoho {
535 1.9 christos /* Ignore remarks if requested */
536 1.1 jruoho
537 1.9 christos switch (Enode->Level)
538 1.2 christos {
539 1.9 christos case ASL_WARNING:
540 1.9 christos case ASL_WARNING2:
541 1.9 christos case ASL_WARNING3:
542 1.3 christos
543 1.9 christos if (!Gbl_DisplayWarnings)
544 1.9 christos {
545 1.9 christos return;
546 1.9 christos }
547 1.9 christos break;
548 1.3 christos
549 1.9 christos case ASL_REMARK:
550 1.2 christos
551 1.9 christos if (!Gbl_DisplayRemarks)
552 1.2 christos {
553 1.9 christos return;
554 1.1 jruoho }
555 1.9 christos break;
556 1.9 christos
557 1.9 christos case ASL_OPTIMIZATION:
558 1.9 christos
559 1.9 christos if (!Gbl_DisplayOptimizations)
560 1.1 jruoho {
561 1.9 christos return;
562 1.1 jruoho }
563 1.9 christos break;
564 1.9 christos
565 1.9 christos default:
566 1.9 christos
567 1.9 christos break;
568 1.3 christos }
569 1.3 christos }
570 1.9 christos
571 1.9 christos /* Get the various required file handles */
572 1.9 christos
573 1.9 christos OutputFile = Gbl_Files[FileId].Handle;
574 1.9 christos
575 1.9 christos if (Header)
576 1.3 christos {
577 1.9 christos fprintf (OutputFile, "%s", Header);
578 1.3 christos }
579 1.1 jruoho
580 1.9 christos if (!Enode->Filename)
581 1.9 christos {
582 1.9 christos AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
583 1.9 christos return;
584 1.9 christos }
585 1.1 jruoho
586 1.9 christos Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
587 1.9 christos if (ACPI_FAILURE (Status))
588 1.3 christos {
589 1.9 christos return;
590 1.3 christos }
591 1.1 jruoho
592 1.9 christos /* If a NULL message ID, just print the raw message */
593 1.9 christos
594 1.9 christos if (Enode->MessageId == 0)
595 1.3 christos {
596 1.9 christos fprintf (OutputFile, "%s\n", Enode->Message);
597 1.9 christos return;
598 1.3 christos }
599 1.2 christos
600 1.9 christos AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
601 1.9 christos
602 1.9 christos while (Child)
603 1.3 christos {
604 1.3 christos fprintf (OutputFile, "\n");
605 1.9 christos AePrintSubError (OutputFile, Child);
606 1.9 christos Child = Child->SubError;
607 1.1 jruoho }
608 1.1 jruoho }
609 1.1 jruoho
610 1.1 jruoho
611 1.1 jruoho /*******************************************************************************
612 1.1 jruoho *
613 1.9 christos * FUNCTION: AePrintSubError
614 1.9 christos *
615 1.9 christos * PARAMETERS: OutputFile - Output file
616 1.9 christos * Enode - Error node to print
617 1.9 christos *
618 1.9 christos * RETURN: None
619 1.9 christos *
620 1.9 christos * DESCRIPTION: Print the contents of an error nodes. This function is tailored
621 1.9 christos * to print error nodes that are SubErrors within ASL_ERROR_MSG
622 1.9 christos *
623 1.9 christos ******************************************************************************/
624 1.9 christos
625 1.9 christos static void
626 1.9 christos AePrintSubError (
627 1.9 christos FILE *OutputFile,
628 1.9 christos ASL_ERROR_MSG *Enode)
629 1.9 christos {
630 1.9 christos UINT32 Total = 0;
631 1.9 christos BOOLEAN PrematureEOF = FALSE;
632 1.9 christos const char *MainMessage;
633 1.9 christos
634 1.9 christos
635 1.9 christos MainMessage = AeDecodeMessageId (Enode->MessageId);
636 1.9 christos
637 1.9 christos fprintf (OutputFile, " %s%s", MainMessage, "\n ");
638 1.9 christos (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
639 1.9 christos fprintf (OutputFile, "\n");
640 1.9 christos }
641 1.9 christos
642 1.9 christos
643 1.9 christos /*******************************************************************************
644 1.9 christos *
645 1.1 jruoho * FUNCTION: AePrintErrorLog
646 1.1 jruoho *
647 1.1 jruoho * PARAMETERS: FileId - Where to output the error log
648 1.1 jruoho *
649 1.1 jruoho * RETURN: None
650 1.1 jruoho *
651 1.1 jruoho * DESCRIPTION: Print the entire contents of the error log
652 1.1 jruoho *
653 1.1 jruoho ******************************************************************************/
654 1.1 jruoho
655 1.1 jruoho void
656 1.1 jruoho AePrintErrorLog (
657 1.1 jruoho UINT32 FileId)
658 1.1 jruoho {
659 1.1 jruoho ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
660 1.1 jruoho
661 1.1 jruoho
662 1.1 jruoho /* Walk the error node list */
663 1.1 jruoho
664 1.1 jruoho while (Enode)
665 1.1 jruoho {
666 1.1 jruoho AePrintException (FileId, Enode, NULL);
667 1.1 jruoho Enode = Enode->Next;
668 1.1 jruoho }
669 1.1 jruoho }
670 1.1 jruoho
671 1.1 jruoho
672 1.1 jruoho /*******************************************************************************
673 1.1 jruoho *
674 1.9 christos * FUNCTION: AslInitEnode
675 1.2 christos *
676 1.9 christos * PARAMETERS: InputEnode - Input Error node to initialize
677 1.9 christos * Level - Seriousness (Warning/error, etc.)
678 1.2 christos * MessageId - Index into global message buffer
679 1.9 christos * CurrentLineNumber - Actual file line number
680 1.9 christos * LogicalLineNumber - Cumulative line number
681 1.9 christos * LogicalByteOffset - Byte offset in source file
682 1.2 christos * Column - Column in current line
683 1.2 christos * Filename - source filename
684 1.2 christos * ExtraMessage - additional error message
685 1.9 christos * SourceLine - Line of error source code
686 1.9 christos * SubError - SubError of this InputEnode
687 1.2 christos *
688 1.2 christos * RETURN: None
689 1.2 christos *
690 1.9 christos * DESCRIPTION: Initialize an Error node
691 1.2 christos *
692 1.2 christos ******************************************************************************/
693 1.2 christos
694 1.9 christos static void AslInitEnode (
695 1.9 christos ASL_ERROR_MSG **InputEnode,
696 1.2 christos UINT8 Level,
697 1.3 christos UINT16 MessageId,
698 1.2 christos UINT32 LineNumber,
699 1.9 christos UINT32 LogicalLineNumber,
700 1.9 christos UINT32 LogicalByteOffset,
701 1.2 christos UINT32 Column,
702 1.9 christos char *Filename,
703 1.9 christos char *ExtraMessage,
704 1.2 christos char *SourceLine,
705 1.9 christos ASL_ERROR_MSG *SubError)
706 1.2 christos {
707 1.2 christos ASL_ERROR_MSG *Enode;
708 1.2 christos
709 1.2 christos
710 1.9 christos *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
711 1.9 christos Enode = *InputEnode;
712 1.9 christos Enode->Level = Level;
713 1.9 christos Enode->MessageId = MessageId;
714 1.9 christos Enode->LineNumber = LineNumber;
715 1.9 christos Enode->LogicalLineNumber = LogicalLineNumber;
716 1.9 christos Enode->LogicalByteOffset = LogicalByteOffset;
717 1.9 christos Enode->Column = Column;
718 1.9 christos Enode->SubError = SubError;
719 1.9 christos Enode->Message = NULL;
720 1.9 christos Enode->SourceLine = NULL;
721 1.9 christos Enode->Filename = NULL;
722 1.2 christos
723 1.2 christos if (ExtraMessage)
724 1.2 christos {
725 1.2 christos /* Allocate a buffer for the message and a new error node */
726 1.2 christos
727 1.9 christos Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1);
728 1.2 christos
729 1.2 christos /* Keep a copy of the extra message */
730 1.2 christos
731 1.9 christos strcpy (Enode->Message, ExtraMessage);
732 1.2 christos }
733 1.2 christos
734 1.9 christos if (SourceLine)
735 1.9 christos {
736 1.9 christos Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1);
737 1.9 christos strcpy (Enode->SourceLine, SourceLine);
738 1.9 christos }
739 1.2 christos
740 1.2 christos
741 1.2 christos if (Filename)
742 1.2 christos {
743 1.3 christos Enode->Filename = Filename;
744 1.2 christos Enode->FilenameLength = strlen (Filename);
745 1.2 christos if (Enode->FilenameLength < 6)
746 1.2 christos {
747 1.2 christos Enode->FilenameLength = 6;
748 1.2 christos }
749 1.2 christos }
750 1.9 christos }
751 1.2 christos
752 1.2 christos
753 1.9 christos /*******************************************************************************
754 1.9 christos *
755 1.9 christos * FUNCTION: AslCommonError2
756 1.9 christos *
757 1.9 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
758 1.9 christos * MessageId - Index into global message buffer
759 1.9 christos * LineNumber - Actual file line number
760 1.9 christos * Column - Column in current line
761 1.9 christos * SourceLine - Actual source code line
762 1.9 christos * Filename - source filename
763 1.9 christos * ExtraMessage - additional error message
764 1.9 christos *
765 1.9 christos * RETURN: None
766 1.9 christos *
767 1.9 christos * DESCRIPTION: Create a new error node and add it to the error log
768 1.9 christos *
769 1.9 christos ******************************************************************************/
770 1.2 christos
771 1.9 christos void
772 1.9 christos AslCommonError2 (
773 1.9 christos UINT8 Level,
774 1.9 christos UINT16 MessageId,
775 1.9 christos UINT32 LineNumber,
776 1.9 christos UINT32 Column,
777 1.9 christos char *SourceLine,
778 1.9 christos char *Filename,
779 1.9 christos char *ExtraMessage)
780 1.9 christos {
781 1.9 christos AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column,
782 1.9 christos Filename, ExtraMessage, SourceLine, NULL);
783 1.2 christos }
784 1.2 christos
785 1.2 christos
786 1.2 christos /*******************************************************************************
787 1.2 christos *
788 1.1 jruoho * FUNCTION: AslCommonError
789 1.1 jruoho *
790 1.1 jruoho * PARAMETERS: Level - Seriousness (Warning/error, etc.)
791 1.1 jruoho * MessageId - Index into global message buffer
792 1.1 jruoho * CurrentLineNumber - Actual file line number
793 1.1 jruoho * LogicalLineNumber - Cumulative line number
794 1.1 jruoho * LogicalByteOffset - Byte offset in source file
795 1.1 jruoho * Column - Column in current line
796 1.1 jruoho * Filename - source filename
797 1.1 jruoho * ExtraMessage - additional error message
798 1.1 jruoho *
799 1.1 jruoho * RETURN: None
800 1.1 jruoho *
801 1.1 jruoho * DESCRIPTION: Create a new error node and add it to the error log
802 1.1 jruoho *
803 1.1 jruoho ******************************************************************************/
804 1.1 jruoho
805 1.1 jruoho void
806 1.1 jruoho AslCommonError (
807 1.1 jruoho UINT8 Level,
808 1.3 christos UINT16 MessageId,
809 1.1 jruoho UINT32 CurrentLineNumber,
810 1.1 jruoho UINT32 LogicalLineNumber,
811 1.1 jruoho UINT32 LogicalByteOffset,
812 1.1 jruoho UINT32 Column,
813 1.1 jruoho char *Filename,
814 1.1 jruoho char *ExtraMessage)
815 1.1 jruoho {
816 1.9 christos AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber,
817 1.9 christos LogicalByteOffset, Column, Filename, ExtraMessage,
818 1.9 christos NULL, NULL);
819 1.9 christos }
820 1.1 jruoho
821 1.1 jruoho
822 1.9 christos /*******************************************************************************
823 1.9 christos *
824 1.9 christos * FUNCTION: AslLogNewError
825 1.9 christos *
826 1.9 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
827 1.9 christos * MessageId - Index into global message buffer
828 1.9 christos * CurrentLineNumber - Actual file line number
829 1.9 christos * LogicalLineNumber - Cumulative line number
830 1.9 christos * LogicalByteOffset - Byte offset in source file
831 1.9 christos * Column - Column in current line
832 1.9 christos * Filename - source filename
833 1.9 christos * Message - additional error message
834 1.9 christos * SourceLine - Actual line of source code
835 1.9 christos * SubError - Sub-error associated with this error
836 1.9 christos *
837 1.9 christos * RETURN: None
838 1.9 christos *
839 1.9 christos * DESCRIPTION: Create a new error node and add it to the error log
840 1.9 christos *
841 1.9 christos ******************************************************************************/
842 1.9 christos static void
843 1.9 christos AslLogNewError (
844 1.9 christos UINT8 Level,
845 1.9 christos UINT16 MessageId,
846 1.9 christos UINT32 LineNumber,
847 1.9 christos UINT32 LogicalLineNumber,
848 1.9 christos UINT32 LogicalByteOffset,
849 1.9 christos UINT32 Column,
850 1.9 christos char *Filename,
851 1.9 christos char *Message,
852 1.9 christos char *SourceLine,
853 1.9 christos ASL_ERROR_MSG *SubError)
854 1.9 christos {
855 1.9 christos ASL_ERROR_MSG *Enode = NULL;
856 1.1 jruoho
857 1.1 jruoho
858 1.9 christos AslInitEnode (&Enode, Level, MessageId, LineNumber, LogicalLineNumber,
859 1.9 christos LogicalByteOffset, Column, Filename, Message, SourceLine,
860 1.9 christos SubError);
861 1.1 jruoho
862 1.1 jruoho /* Add the new node to the error node list */
863 1.1 jruoho
864 1.1 jruoho AeAddToErrorLog (Enode);
865 1.1 jruoho
866 1.1 jruoho if (Gbl_DebugFlag)
867 1.1 jruoho {
868 1.1 jruoho /* stderr is a file, send error to it immediately */
869 1.1 jruoho
870 1.1 jruoho AePrintException (ASL_FILE_STDERR, Enode, NULL);
871 1.1 jruoho }
872 1.1 jruoho
873 1.1 jruoho Gbl_ExceptionCount[Level]++;
874 1.1 jruoho if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
875 1.1 jruoho {
876 1.1 jruoho printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
877 1.1 jruoho
878 1.1 jruoho Gbl_SourceLine = 0;
879 1.1 jruoho Gbl_NextError = Gbl_ErrorLog;
880 1.1 jruoho CmCleanupAndExit ();
881 1.1 jruoho exit(1);
882 1.1 jruoho }
883 1.1 jruoho
884 1.1 jruoho return;
885 1.1 jruoho }
886 1.1 jruoho
887 1.8 christos /*******************************************************************************
888 1.8 christos *
889 1.8 christos * FUNCTION: AslIsExceptionIgnored
890 1.8 christos *
891 1.9 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
892 1.9 christos * MessageId - Index into global message buffer
893 1.8 christos *
894 1.8 christos * RETURN: BOOLEAN
895 1.8 christos *
896 1.8 christos * DESCRIPTION: Check if a particular exception is ignored. In this case it
897 1.8 christos * means that the exception is (expected or disabled.
898 1.8 christos *
899 1.8 christos ******************************************************************************/
900 1.8 christos
901 1.8 christos BOOLEAN
902 1.8 christos AslIsExceptionIgnored (
903 1.8 christos UINT8 Level,
904 1.8 christos UINT16 MessageId)
905 1.8 christos {
906 1.9 christos BOOLEAN ExceptionIgnored;
907 1.8 christos
908 1.8 christos
909 1.8 christos /* Note: this allows exception to be disabled and expected */
910 1.8 christos
911 1.8 christos ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId);
912 1.8 christos ExceptionIgnored |= AslIsExceptionExpected (Level, MessageId);
913 1.8 christos
914 1.8 christos return (Gbl_AllExceptionsDisabled || ExceptionIgnored);
915 1.8 christos }
916 1.8 christos
917 1.8 christos
918 1.8 christos /*******************************************************************************
919 1.8 christos *
920 1.8 christos * FUNCTION: AslCheckExpectException
921 1.8 christos *
922 1.8 christos * PARAMETERS: none
923 1.8 christos *
924 1.8 christos * RETURN: none
925 1.8 christos *
926 1.8 christos * DESCRIPTION: Check the global expected messages table and raise an error
927 1.8 christos * for each message that has not been received.
928 1.8 christos *
929 1.8 christos ******************************************************************************/
930 1.8 christos
931 1.8 christos void
932 1.8 christos AslCheckExpectedExceptions (
933 1.8 christos void)
934 1.8 christos {
935 1.9 christos UINT8 i;
936 1.9 christos
937 1.8 christos
938 1.8 christos for (i = 0; i < Gbl_ExpectedMessagesIndex; ++i)
939 1.8 christos {
940 1.8 christos if (!Gbl_ExpectedMessages[i].MessageReceived)
941 1.8 christos {
942 1.8 christos AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL,
943 1.8 christos Gbl_ExpectedMessages[i].MessageIdStr);
944 1.8 christos }
945 1.8 christos }
946 1.8 christos }
947 1.8 christos
948 1.8 christos
949 1.8 christos /*******************************************************************************
950 1.8 christos *
951 1.8 christos * FUNCTION: AslExpectException
952 1.8 christos *
953 1.8 christos * PARAMETERS: MessageIdString - ID of excepted exception during compile
954 1.8 christos *
955 1.8 christos * RETURN: Status
956 1.8 christos *
957 1.8 christos * DESCRIPTION: Enter a message ID into the global expected messages table
958 1.8 christos * If these messages are not raised during the compilation, throw
959 1.8 christos * an error.
960 1.8 christos *
961 1.8 christos ******************************************************************************/
962 1.8 christos
963 1.8 christos ACPI_STATUS
964 1.8 christos AslExpectException (
965 1.8 christos char *MessageIdString)
966 1.8 christos {
967 1.8 christos UINT32 MessageId;
968 1.8 christos
969 1.8 christos
970 1.8 christos /* Convert argument to an integer and validate it */
971 1.8 christos
972 1.8 christos MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
973 1.8 christos
974 1.8 christos if (MessageId > 6999)
975 1.8 christos {
976 1.8 christos printf ("\"%s\" is not a valid warning/remark/erro ID\n",
977 1.8 christos MessageIdString);
978 1.8 christos return (AE_BAD_PARAMETER);
979 1.8 christos }
980 1.8 christos
981 1.8 christos /* Insert value into the global expected message array */
982 1.8 christos
983 1.8 christos if (Gbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES)
984 1.8 christos {
985 1.8 christos printf ("Too many messages have been registered as expected (max %u)\n",
986 1.8 christos ASL_MAX_DISABLED_MESSAGES);
987 1.8 christos return (AE_LIMIT);
988 1.8 christos }
989 1.8 christos
990 1.8 christos Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageId = MessageId;
991 1.8 christos Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString;
992 1.8 christos Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageReceived = FALSE;
993 1.8 christos Gbl_ExpectedMessagesIndex++;
994 1.8 christos return (AE_OK);
995 1.8 christos }
996 1.8 christos
997 1.1 jruoho
998 1.1 jruoho /*******************************************************************************
999 1.1 jruoho *
1000 1.2 christos * FUNCTION: AslDisableException
1001 1.2 christos *
1002 1.2 christos * PARAMETERS: MessageIdString - ID to be disabled
1003 1.2 christos *
1004 1.2 christos * RETURN: Status
1005 1.2 christos *
1006 1.2 christos * DESCRIPTION: Enter a message ID into the global disabled messages table
1007 1.2 christos *
1008 1.2 christos ******************************************************************************/
1009 1.2 christos
1010 1.2 christos ACPI_STATUS
1011 1.2 christos AslDisableException (
1012 1.2 christos char *MessageIdString)
1013 1.2 christos {
1014 1.2 christos UINT32 MessageId;
1015 1.2 christos
1016 1.2 christos
1017 1.2 christos /* Convert argument to an integer and validate it */
1018 1.2 christos
1019 1.2 christos MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1020 1.2 christos
1021 1.8 christos if ((MessageId < 2000) || (MessageId > 6999))
1022 1.2 christos {
1023 1.8 christos printf ("\"%s\" is not a valid warning/remark/error ID\n",
1024 1.2 christos MessageIdString);
1025 1.2 christos return (AE_BAD_PARAMETER);
1026 1.2 christos }
1027 1.2 christos
1028 1.2 christos /* Insert value into the global disabled message array */
1029 1.2 christos
1030 1.2 christos if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
1031 1.2 christos {
1032 1.2 christos printf ("Too many messages have been disabled (max %u)\n",
1033 1.2 christos ASL_MAX_DISABLED_MESSAGES);
1034 1.2 christos return (AE_LIMIT);
1035 1.2 christos }
1036 1.2 christos
1037 1.2 christos Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId;
1038 1.2 christos Gbl_DisabledMessagesIndex++;
1039 1.2 christos return (AE_OK);
1040 1.2 christos }
1041 1.2 christos
1042 1.2 christos
1043 1.2 christos /*******************************************************************************
1044 1.2 christos *
1045 1.2 christos * FUNCTION: AslIsExceptionDisabled
1046 1.2 christos *
1047 1.9 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1048 1.9 christos * MessageId - Index into global message buffer
1049 1.2 christos *
1050 1.2 christos * RETURN: TRUE if exception/message should be ignored
1051 1.2 christos *
1052 1.2 christos * DESCRIPTION: Check if the user has specified options such that this
1053 1.2 christos * exception should be ignored
1054 1.2 christos *
1055 1.2 christos ******************************************************************************/
1056 1.2 christos
1057 1.8 christos static BOOLEAN
1058 1.8 christos AslIsExceptionExpected (
1059 1.8 christos UINT8 Level,
1060 1.8 christos UINT16 MessageId)
1061 1.8 christos {
1062 1.8 christos UINT32 EncodedMessageId;
1063 1.8 christos UINT32 i;
1064 1.8 christos
1065 1.8 christos
1066 1.9 christos /* Mark this exception as received */
1067 1.9 christos
1068 1.8 christos EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1069 1.8 christos for (i = 0; i < Gbl_ExpectedMessagesIndex; i++)
1070 1.8 christos {
1071 1.8 christos /* Simple implementation via fixed array */
1072 1.8 christos
1073 1.8 christos if (EncodedMessageId == Gbl_ExpectedMessages[i].MessageId)
1074 1.8 christos {
1075 1.8 christos return (Gbl_ExpectedMessages[i].MessageReceived = TRUE);
1076 1.8 christos }
1077 1.8 christos }
1078 1.8 christos
1079 1.8 christos return (FALSE);
1080 1.8 christos }
1081 1.8 christos
1082 1.8 christos
1083 1.8 christos /*******************************************************************************
1084 1.8 christos *
1085 1.8 christos * FUNCTION: AslIsExceptionDisabled
1086 1.8 christos *
1087 1.8 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1088 1.8 christos * MessageId - Index into global message buffer
1089 1.8 christos *
1090 1.8 christos * RETURN: TRUE if exception/message should be ignored
1091 1.8 christos *
1092 1.8 christos * DESCRIPTION: Check if the user has specified options such that this
1093 1.8 christos * exception should be ignored
1094 1.8 christos *
1095 1.8 christos ******************************************************************************/
1096 1.8 christos
1097 1.8 christos static BOOLEAN
1098 1.2 christos AslIsExceptionDisabled (
1099 1.2 christos UINT8 Level,
1100 1.3 christos UINT16 MessageId)
1101 1.2 christos {
1102 1.2 christos UINT32 EncodedMessageId;
1103 1.2 christos UINT32 i;
1104 1.2 christos
1105 1.2 christos
1106 1.2 christos switch (Level)
1107 1.2 christos {
1108 1.2 christos case ASL_WARNING2:
1109 1.2 christos case ASL_WARNING3:
1110 1.2 christos
1111 1.2 christos /* Check for global disable via -w1/-w2/-w3 options */
1112 1.2 christos
1113 1.2 christos if (Level > Gbl_WarningLevel)
1114 1.2 christos {
1115 1.2 christos return (TRUE);
1116 1.2 christos }
1117 1.2 christos /* Fall through */
1118 1.2 christos
1119 1.2 christos case ASL_WARNING:
1120 1.2 christos case ASL_REMARK:
1121 1.8 christos case ASL_ERROR:
1122 1.2 christos /*
1123 1.8 christos * Ignore this error/warning/remark if it has been disabled by
1124 1.2 christos * the user (-vw option)
1125 1.2 christos */
1126 1.3 christos EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1127 1.2 christos for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
1128 1.2 christos {
1129 1.2 christos /* Simple implementation via fixed array */
1130 1.2 christos
1131 1.2 christos if (EncodedMessageId == Gbl_DisabledMessages[i])
1132 1.2 christos {
1133 1.2 christos return (TRUE);
1134 1.2 christos }
1135 1.2 christos }
1136 1.2 christos break;
1137 1.2 christos
1138 1.2 christos default:
1139 1.2 christos break;
1140 1.2 christos }
1141 1.2 christos
1142 1.2 christos return (FALSE);
1143 1.2 christos }
1144 1.2 christos
1145 1.2 christos
1146 1.2 christos /*******************************************************************************
1147 1.2 christos *
1148 1.9 christos * FUNCTION: AslDualParseOpError
1149 1.9 christos *
1150 1.9 christos * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1151 1.9 christos * MainMsgId - Index into global message buffer
1152 1.9 christos * MainOp - Parse node where error happened
1153 1.9 christos * MainMsg - Message pertaining to the MainOp
1154 1.9 christos * SubMsgId - Index into global message buffer
1155 1.9 christos * SubOp - Additional parse node for better message
1156 1.9 christos * SubMsg - Message pertainint to SubOp
1157 1.9 christos *
1158 1.9 christos *
1159 1.9 christos * RETURN: None
1160 1.9 christos *
1161 1.9 christos * DESCRIPTION: Main error reporting routine for the ASL compiler for error
1162 1.9 christos * messages that point to multiple parse objects.
1163 1.9 christos *
1164 1.9 christos ******************************************************************************/
1165 1.9 christos
1166 1.9 christos void
1167 1.9 christos AslDualParseOpError (
1168 1.9 christos UINT8 Level,
1169 1.9 christos UINT16 MainMsgId,
1170 1.9 christos ACPI_PARSE_OBJECT *MainOp,
1171 1.9 christos char *MainMsg,
1172 1.9 christos UINT16 SubMsgId,
1173 1.9 christos ACPI_PARSE_OBJECT *SubOp,
1174 1.9 christos char *SubMsg)
1175 1.9 christos {
1176 1.9 christos ASL_ERROR_MSG *SubEnode = NULL;
1177 1.9 christos
1178 1.9 christos
1179 1.9 christos /* Check if user wants to ignore this exception */
1180 1.9 christos
1181 1.9 christos if (AslIsExceptionIgnored (Level, MainMsgId) || !MainOp)
1182 1.9 christos {
1183 1.9 christos return;
1184 1.9 christos }
1185 1.9 christos
1186 1.9 christos if (SubOp)
1187 1.9 christos {
1188 1.9 christos AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber,
1189 1.9 christos SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset,
1190 1.9 christos SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg,
1191 1.9 christos NULL, NULL);
1192 1.9 christos }
1193 1.9 christos
1194 1.9 christos AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber,
1195 1.9 christos MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset,
1196 1.9 christos MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg,
1197 1.9 christos NULL, SubEnode);
1198 1.9 christos }
1199 1.9 christos
1200 1.9 christos
1201 1.9 christos /*******************************************************************************
1202 1.9 christos *
1203 1.1 jruoho * FUNCTION: AslError
1204 1.1 jruoho *
1205 1.1 jruoho * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1206 1.1 jruoho * MessageId - Index into global message buffer
1207 1.1 jruoho * Op - Parse node where error happened
1208 1.1 jruoho * ExtraMessage - additional error message
1209 1.1 jruoho *
1210 1.1 jruoho * RETURN: None
1211 1.1 jruoho *
1212 1.1 jruoho * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
1213 1.1 jruoho * except the parser.)
1214 1.1 jruoho *
1215 1.1 jruoho ******************************************************************************/
1216 1.1 jruoho
1217 1.1 jruoho void
1218 1.1 jruoho AslError (
1219 1.1 jruoho UINT8 Level,
1220 1.3 christos UINT16 MessageId,
1221 1.1 jruoho ACPI_PARSE_OBJECT *Op,
1222 1.1 jruoho char *ExtraMessage)
1223 1.1 jruoho {
1224 1.1 jruoho if (Op)
1225 1.1 jruoho {
1226 1.1 jruoho AslCommonError (Level, MessageId, Op->Asl.LineNumber,
1227 1.2 christos Op->Asl.LogicalLineNumber,
1228 1.2 christos Op->Asl.LogicalByteOffset,
1229 1.2 christos Op->Asl.Column,
1230 1.2 christos Op->Asl.Filename, ExtraMessage);
1231 1.1 jruoho }
1232 1.1 jruoho else
1233 1.1 jruoho {
1234 1.1 jruoho AslCommonError (Level, MessageId, 0,
1235 1.2 christos 0, 0, 0, NULL, ExtraMessage);
1236 1.1 jruoho }
1237 1.1 jruoho }
1238 1.1 jruoho
1239 1.1 jruoho
1240 1.1 jruoho /*******************************************************************************
1241 1.1 jruoho *
1242 1.1 jruoho * FUNCTION: AslCoreSubsystemError
1243 1.1 jruoho *
1244 1.1 jruoho * PARAMETERS: Op - Parse node where error happened
1245 1.3 christos * Status - The ACPICA Exception
1246 1.1 jruoho * ExtraMessage - additional error message
1247 1.1 jruoho * Abort - TRUE -> Abort compilation
1248 1.1 jruoho *
1249 1.1 jruoho * RETURN: None
1250 1.1 jruoho *
1251 1.3 christos * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
1252 1.3 christos * core subsystem.
1253 1.1 jruoho *
1254 1.1 jruoho ******************************************************************************/
1255 1.1 jruoho
1256 1.1 jruoho void
1257 1.1 jruoho AslCoreSubsystemError (
1258 1.1 jruoho ACPI_PARSE_OBJECT *Op,
1259 1.1 jruoho ACPI_STATUS Status,
1260 1.1 jruoho char *ExtraMessage,
1261 1.1 jruoho BOOLEAN Abort)
1262 1.1 jruoho {
1263 1.1 jruoho
1264 1.2 christos snprintf (MsgBuffer, sizeof(MsgBuffer), "%s %s", AcpiFormatException (Status), ExtraMessage);
1265 1.1 jruoho
1266 1.1 jruoho if (Op)
1267 1.1 jruoho {
1268 1.6 christos AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1269 1.6 christos Op->Asl.LineNumber,
1270 1.6 christos Op->Asl.LogicalLineNumber,
1271 1.6 christos Op->Asl.LogicalByteOffset,
1272 1.6 christos Op->Asl.Column,
1273 1.6 christos Op->Asl.Filename, MsgBuffer);
1274 1.1 jruoho }
1275 1.1 jruoho else
1276 1.1 jruoho {
1277 1.6 christos AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1278 1.6 christos 0, 0, 0, 0, NULL, MsgBuffer);
1279 1.1 jruoho }
1280 1.1 jruoho
1281 1.1 jruoho if (Abort)
1282 1.1 jruoho {
1283 1.1 jruoho AslAbort ();
1284 1.1 jruoho }
1285 1.1 jruoho }
1286 1.1 jruoho
1287 1.1 jruoho
1288 1.1 jruoho /*******************************************************************************
1289 1.1 jruoho *
1290 1.1 jruoho * FUNCTION: AslCompilererror
1291 1.1 jruoho *
1292 1.1 jruoho * PARAMETERS: CompilerMessage - Error message from the parser
1293 1.1 jruoho *
1294 1.1 jruoho * RETURN: Status (0 for now)
1295 1.1 jruoho *
1296 1.1 jruoho * DESCRIPTION: Report an error situation discovered in a production
1297 1.1 jruoho * NOTE: don't change the name of this function, it is called
1298 1.1 jruoho * from the auto-generated parser.
1299 1.1 jruoho *
1300 1.1 jruoho ******************************************************************************/
1301 1.1 jruoho
1302 1.1 jruoho int
1303 1.1 jruoho AslCompilererror (
1304 1.2 christos const char *CompilerMessage)
1305 1.1 jruoho {
1306 1.1 jruoho
1307 1.4 christos Gbl_SyntaxError++;
1308 1.4 christos
1309 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
1310 1.2 christos Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
1311 1.2 christos Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
1312 1.2 christos ACPI_CAST_PTR (char, CompilerMessage));
1313 1.1 jruoho
1314 1.2 christos return (0);
1315 1.1 jruoho }
1316