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