dtio.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: dtio.c - File I/O support for data table compiler
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind *****************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind #define __DTIO_C__
45 1.1.1.2.4.2 rmind
46 1.1.1.2.4.2 rmind #include "aslcompiler.h"
47 1.1.1.2.4.2 rmind #include "dtcompiler.h"
48 1.1.1.2.4.2 rmind
49 1.1.1.2.4.2 rmind #define _COMPONENT DT_COMPILER
50 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("dtio")
51 1.1.1.2.4.2 rmind
52 1.1.1.2.4.2 rmind
53 1.1.1.2.4.2 rmind /* Local prototypes */
54 1.1.1.2.4.2 rmind
55 1.1.1.2.4.2 rmind static char *
56 1.1.1.2.4.2 rmind DtTrim (
57 1.1.1.2.4.2 rmind char *String);
58 1.1.1.2.4.2 rmind
59 1.1.1.2.4.2 rmind static void
60 1.1.1.2.4.2 rmind DtLinkField (
61 1.1.1.2.4.2 rmind DT_FIELD *Field);
62 1.1.1.2.4.2 rmind
63 1.1.1.2.4.2 rmind static ACPI_STATUS
64 1.1.1.2.4.2 rmind DtParseLine (
65 1.1.1.2.4.2 rmind char *LineBuffer,
66 1.1.1.2.4.2 rmind UINT32 Line,
67 1.1.1.2.4.2 rmind UINT32 Offset);
68 1.1.1.2.4.2 rmind
69 1.1.1.2.4.2 rmind UINT32
70 1.1.1.2.4.2 rmind DtGetNextLine (
71 1.1.1.2.4.2 rmind FILE *Handle);
72 1.1.1.2.4.2 rmind
73 1.1.1.2.4.2 rmind static void
74 1.1.1.2.4.2 rmind DtWriteBinary (
75 1.1.1.2.4.2 rmind DT_SUBTABLE *Subtable,
76 1.1.1.2.4.2 rmind void *Context,
77 1.1.1.2.4.2 rmind void *ReturnValue);
78 1.1.1.2.4.2 rmind
79 1.1.1.2.4.2 rmind static void
80 1.1.1.2.4.2 rmind DtDumpBuffer (
81 1.1.1.2.4.2 rmind UINT32 FileId,
82 1.1.1.2.4.2 rmind UINT8 *Buffer,
83 1.1.1.2.4.2 rmind UINT32 Offset,
84 1.1.1.2.4.2 rmind UINT32 Length);
85 1.1.1.2.4.2 rmind
86 1.1.1.2.4.2 rmind
87 1.1.1.2.4.2 rmind /* States for DtGetNextLine */
88 1.1.1.2.4.2 rmind
89 1.1.1.2.4.2 rmind #define DT_NORMAL_TEXT 0
90 1.1.1.2.4.2 rmind #define DT_START_QUOTED_STRING 1
91 1.1.1.2.4.2 rmind #define DT_START_COMMENT 2
92 1.1.1.2.4.2 rmind #define DT_SLASH_ASTERISK_COMMENT 3
93 1.1.1.2.4.2 rmind #define DT_SLASH_SLASH_COMMENT 4
94 1.1.1.2.4.2 rmind #define DT_END_COMMENT 5
95 1.1.1.2.4.2 rmind
96 1.1.1.2.4.2 rmind static UINT32 Gbl_NextLineOffset;
97 1.1.1.2.4.2 rmind
98 1.1.1.2.4.2 rmind
99 1.1.1.2.4.2 rmind /******************************************************************************
100 1.1.1.2.4.2 rmind *
101 1.1.1.2.4.2 rmind * FUNCTION: DtTrim
102 1.1.1.2.4.2 rmind *
103 1.1.1.2.4.2 rmind * PARAMETERS: String - Current source code line to trim
104 1.1.1.2.4.2 rmind *
105 1.1.1.2.4.2 rmind * RETURN: Trimmed line. Must be freed by caller.
106 1.1.1.2.4.2 rmind *
107 1.1.1.2.4.2 rmind * DESCRIPTION: Trim left and right spaces
108 1.1.1.2.4.2 rmind *
109 1.1.1.2.4.2 rmind *****************************************************************************/
110 1.1.1.2.4.2 rmind
111 1.1.1.2.4.2 rmind static char *
112 1.1.1.2.4.2 rmind DtTrim (
113 1.1.1.2.4.2 rmind char *String)
114 1.1.1.2.4.2 rmind {
115 1.1.1.2.4.2 rmind char *Start;
116 1.1.1.2.4.2 rmind char *End;
117 1.1.1.2.4.2 rmind char *ReturnString;
118 1.1.1.2.4.2 rmind ACPI_SIZE Length;
119 1.1.1.2.4.2 rmind
120 1.1.1.2.4.2 rmind
121 1.1.1.2.4.2 rmind /* Skip lines that start with a space */
122 1.1.1.2.4.2 rmind
123 1.1.1.2.4.2 rmind if (!ACPI_STRCMP (String, " "))
124 1.1.1.2.4.2 rmind {
125 1.1.1.2.4.2 rmind ReturnString = UtLocalCalloc (1);
126 1.1.1.2.4.2 rmind return (ReturnString);
127 1.1.1.2.4.2 rmind }
128 1.1.1.2.4.2 rmind
129 1.1.1.2.4.2 rmind /* Setup pointers to start and end of input string */
130 1.1.1.2.4.2 rmind
131 1.1.1.2.4.2 rmind Start = String;
132 1.1.1.2.4.2 rmind End = String + ACPI_STRLEN (String) - 1;
133 1.1.1.2.4.2 rmind
134 1.1.1.2.4.2 rmind /* Find first non-whitespace character */
135 1.1.1.2.4.2 rmind
136 1.1.1.2.4.2 rmind while ((Start <= End) && ((*Start == ' ') || (*Start == '\t')))
137 1.1.1.2.4.2 rmind {
138 1.1.1.2.4.2 rmind Start++;
139 1.1.1.2.4.2 rmind }
140 1.1.1.2.4.2 rmind
141 1.1.1.2.4.2 rmind /* Find last non-space character */
142 1.1.1.2.4.2 rmind
143 1.1.1.2.4.2 rmind while (End >= Start)
144 1.1.1.2.4.2 rmind {
145 1.1.1.2.4.2 rmind if (*End == '\r' || *End == '\n')
146 1.1.1.2.4.2 rmind {
147 1.1.1.2.4.2 rmind End--;
148 1.1.1.2.4.2 rmind continue;
149 1.1.1.2.4.2 rmind }
150 1.1.1.2.4.2 rmind
151 1.1.1.2.4.2 rmind if (*End != ' ')
152 1.1.1.2.4.2 rmind {
153 1.1.1.2.4.2 rmind break;
154 1.1.1.2.4.2 rmind }
155 1.1.1.2.4.2 rmind
156 1.1.1.2.4.2 rmind End--;
157 1.1.1.2.4.2 rmind }
158 1.1.1.2.4.2 rmind
159 1.1.1.2.4.2 rmind /* Remove any quotes around the string */
160 1.1.1.2.4.2 rmind
161 1.1.1.2.4.2 rmind if (*Start == '\"')
162 1.1.1.2.4.2 rmind {
163 1.1.1.2.4.2 rmind Start++;
164 1.1.1.2.4.2 rmind }
165 1.1.1.2.4.2 rmind if (*End == '\"')
166 1.1.1.2.4.2 rmind {
167 1.1.1.2.4.2 rmind End--;
168 1.1.1.2.4.2 rmind }
169 1.1.1.2.4.2 rmind
170 1.1.1.2.4.2 rmind /* Create the trimmed return string */
171 1.1.1.2.4.2 rmind
172 1.1.1.2.4.2 rmind Length = ACPI_PTR_DIFF (End, Start) + 1;
173 1.1.1.2.4.2 rmind ReturnString = UtLocalCalloc (Length + 1);
174 1.1.1.2.4.2 rmind if (ACPI_STRLEN (Start))
175 1.1.1.2.4.2 rmind {
176 1.1.1.2.4.2 rmind ACPI_STRNCPY (ReturnString, Start, Length);
177 1.1.1.2.4.2 rmind }
178 1.1.1.2.4.2 rmind
179 1.1.1.2.4.2 rmind ReturnString[Length] = 0;
180 1.1.1.2.4.2 rmind return (ReturnString);
181 1.1.1.2.4.2 rmind }
182 1.1.1.2.4.2 rmind
183 1.1.1.2.4.2 rmind
184 1.1.1.2.4.2 rmind /******************************************************************************
185 1.1.1.2.4.2 rmind *
186 1.1.1.2.4.2 rmind * FUNCTION: DtLinkField
187 1.1.1.2.4.2 rmind *
188 1.1.1.2.4.2 rmind * PARAMETERS: Field - New field object to link
189 1.1.1.2.4.2 rmind *
190 1.1.1.2.4.2 rmind * RETURN: None
191 1.1.1.2.4.2 rmind *
192 1.1.1.2.4.2 rmind * DESCRIPTION: Link one field name and value to the list
193 1.1.1.2.4.2 rmind *
194 1.1.1.2.4.2 rmind *****************************************************************************/
195 1.1.1.2.4.2 rmind
196 1.1.1.2.4.2 rmind static void
197 1.1.1.2.4.2 rmind DtLinkField (
198 1.1.1.2.4.2 rmind DT_FIELD *Field)
199 1.1.1.2.4.2 rmind {
200 1.1.1.2.4.2 rmind DT_FIELD *Prev;
201 1.1.1.2.4.2 rmind DT_FIELD *Next;
202 1.1.1.2.4.2 rmind
203 1.1.1.2.4.2 rmind
204 1.1.1.2.4.2 rmind Prev = Next = Gbl_FieldList;
205 1.1.1.2.4.2 rmind
206 1.1.1.2.4.2 rmind while (Next)
207 1.1.1.2.4.2 rmind {
208 1.1.1.2.4.2 rmind Prev = Next;
209 1.1.1.2.4.2 rmind Next = Next->Next;
210 1.1.1.2.4.2 rmind }
211 1.1.1.2.4.2 rmind
212 1.1.1.2.4.2 rmind if (Prev)
213 1.1.1.2.4.2 rmind {
214 1.1.1.2.4.2 rmind Prev->Next = Field;
215 1.1.1.2.4.2 rmind }
216 1.1.1.2.4.2 rmind else
217 1.1.1.2.4.2 rmind {
218 1.1.1.2.4.2 rmind Gbl_FieldList = Field;
219 1.1.1.2.4.2 rmind }
220 1.1.1.2.4.2 rmind }
221 1.1.1.2.4.2 rmind
222 1.1.1.2.4.2 rmind
223 1.1.1.2.4.2 rmind /******************************************************************************
224 1.1.1.2.4.2 rmind *
225 1.1.1.2.4.2 rmind * FUNCTION: DtParseLine
226 1.1.1.2.4.2 rmind *
227 1.1.1.2.4.2 rmind * PARAMETERS: LineBuffer - Current source code line
228 1.1.1.2.4.2 rmind * Line - Current line number in the source
229 1.1.1.2.4.2 rmind * Offset - Current byte offset of the line
230 1.1.1.2.4.2 rmind *
231 1.1.1.2.4.2 rmind * RETURN: Status
232 1.1.1.2.4.2 rmind *
233 1.1.1.2.4.2 rmind * DESCRIPTION: Parse one source line
234 1.1.1.2.4.2 rmind *
235 1.1.1.2.4.2 rmind *****************************************************************************/
236 1.1.1.2.4.2 rmind
237 1.1.1.2.4.2 rmind static ACPI_STATUS
238 1.1.1.2.4.2 rmind DtParseLine (
239 1.1.1.2.4.2 rmind char *LineBuffer,
240 1.1.1.2.4.2 rmind UINT32 Line,
241 1.1.1.2.4.2 rmind UINT32 Offset)
242 1.1.1.2.4.2 rmind {
243 1.1.1.2.4.2 rmind char *Start;
244 1.1.1.2.4.2 rmind char *End;
245 1.1.1.2.4.2 rmind char *TmpName;
246 1.1.1.2.4.2 rmind char *TmpValue;
247 1.1.1.2.4.2 rmind char *Name;
248 1.1.1.2.4.2 rmind char *Value;
249 1.1.1.2.4.2 rmind char *Colon;
250 1.1.1.2.4.2 rmind UINT32 Length;
251 1.1.1.2.4.2 rmind DT_FIELD *Field;
252 1.1.1.2.4.2 rmind UINT32 Column;
253 1.1.1.2.4.2 rmind UINT32 NameColumn;
254 1.1.1.2.4.2 rmind
255 1.1.1.2.4.2 rmind
256 1.1.1.2.4.2 rmind if (!LineBuffer)
257 1.1.1.2.4.2 rmind {
258 1.1.1.2.4.2 rmind return (AE_OK);
259 1.1.1.2.4.2 rmind }
260 1.1.1.2.4.2 rmind
261 1.1.1.2.4.2 rmind /* All lines after "Raw Table Data" are ingored */
262 1.1.1.2.4.2 rmind
263 1.1.1.2.4.2 rmind if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER))
264 1.1.1.2.4.2 rmind {
265 1.1.1.2.4.2 rmind return (AE_NOT_FOUND);
266 1.1.1.2.4.2 rmind }
267 1.1.1.2.4.2 rmind
268 1.1.1.2.4.2 rmind Colon = strchr (LineBuffer, ':');
269 1.1.1.2.4.2 rmind if (!Colon)
270 1.1.1.2.4.2 rmind {
271 1.1.1.2.4.2 rmind return (AE_OK);
272 1.1.1.2.4.2 rmind }
273 1.1.1.2.4.2 rmind
274 1.1.1.2.4.2 rmind Start = LineBuffer;
275 1.1.1.2.4.2 rmind End = Colon;
276 1.1.1.2.4.2 rmind
277 1.1.1.2.4.2 rmind while (Start < Colon)
278 1.1.1.2.4.2 rmind {
279 1.1.1.2.4.2 rmind if (*Start == ' ')
280 1.1.1.2.4.2 rmind {
281 1.1.1.2.4.2 rmind Start++;
282 1.1.1.2.4.2 rmind continue;
283 1.1.1.2.4.2 rmind }
284 1.1.1.2.4.2 rmind
285 1.1.1.2.4.2 rmind /* Found left bracket, go to the right bracket */
286 1.1.1.2.4.2 rmind
287 1.1.1.2.4.2 rmind if (*Start == '[')
288 1.1.1.2.4.2 rmind {
289 1.1.1.2.4.2 rmind while (Start < Colon && *Start != ']')
290 1.1.1.2.4.2 rmind {
291 1.1.1.2.4.2 rmind Start++;
292 1.1.1.2.4.2 rmind }
293 1.1.1.2.4.2 rmind
294 1.1.1.2.4.2 rmind if (Start == Colon)
295 1.1.1.2.4.2 rmind {
296 1.1.1.2.4.2 rmind break;
297 1.1.1.2.4.2 rmind }
298 1.1.1.2.4.2 rmind
299 1.1.1.2.4.2 rmind Start++;
300 1.1.1.2.4.2 rmind continue;
301 1.1.1.2.4.2 rmind }
302 1.1.1.2.4.2 rmind
303 1.1.1.2.4.2 rmind break;
304 1.1.1.2.4.2 rmind }
305 1.1.1.2.4.2 rmind
306 1.1.1.2.4.2 rmind /*
307 1.1.1.2.4.2 rmind * There are two column values. One for the field name,
308 1.1.1.2.4.2 rmind * and one for the field value.
309 1.1.1.2.4.2 rmind */
310 1.1.1.2.4.2 rmind Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3;
311 1.1.1.2.4.2 rmind NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1;
312 1.1.1.2.4.2 rmind
313 1.1.1.2.4.2 rmind Length = ACPI_PTR_DIFF (End, Start);
314 1.1.1.2.4.2 rmind
315 1.1.1.2.4.2 rmind TmpName = UtLocalCalloc (Length + 1);
316 1.1.1.2.4.2 rmind ACPI_STRNCPY (TmpName, Start, Length);
317 1.1.1.2.4.2 rmind Name = DtTrim (TmpName);
318 1.1.1.2.4.2 rmind ACPI_FREE (TmpName);
319 1.1.1.2.4.2 rmind
320 1.1.1.2.4.2 rmind Start = End = (Colon + 1);
321 1.1.1.2.4.2 rmind
322 1.1.1.2.4.2 rmind while (*End)
323 1.1.1.2.4.2 rmind {
324 1.1.1.2.4.2 rmind /* Found left quotation, go to the right quotation and break */
325 1.1.1.2.4.2 rmind
326 1.1.1.2.4.2 rmind if (*End == '"')
327 1.1.1.2.4.2 rmind {
328 1.1.1.2.4.2 rmind End++;
329 1.1.1.2.4.2 rmind while (*End && (*End != '"'))
330 1.1.1.2.4.2 rmind {
331 1.1.1.2.4.2 rmind End++;
332 1.1.1.2.4.2 rmind }
333 1.1.1.2.4.2 rmind
334 1.1.1.2.4.2 rmind End++;
335 1.1.1.2.4.2 rmind break;
336 1.1.1.2.4.2 rmind }
337 1.1.1.2.4.2 rmind
338 1.1.1.2.4.2 rmind /*
339 1.1.1.2.4.2 rmind * Special "comment" fields at line end, ignore them.
340 1.1.1.2.4.2 rmind * Note: normal slash-slash and slash-asterisk comments are
341 1.1.1.2.4.2 rmind * stripped already by the DtGetNextLine parser.
342 1.1.1.2.4.2 rmind *
343 1.1.1.2.4.2 rmind * TBD: Perhaps DtGetNextLine should parse the following type
344 1.1.1.2.4.2 rmind * of comments also.
345 1.1.1.2.4.2 rmind */
346 1.1.1.2.4.2 rmind if (*End == '(' ||
347 1.1.1.2.4.2 rmind *End == '<')
348 1.1.1.2.4.2 rmind {
349 1.1.1.2.4.2 rmind break;
350 1.1.1.2.4.2 rmind }
351 1.1.1.2.4.2 rmind
352 1.1.1.2.4.2 rmind End++;
353 1.1.1.2.4.2 rmind }
354 1.1.1.2.4.2 rmind
355 1.1.1.2.4.2 rmind Length = ACPI_PTR_DIFF (End, Start);
356 1.1.1.2.4.2 rmind TmpValue = UtLocalCalloc (Length + 1);
357 1.1.1.2.4.2 rmind ACPI_STRNCPY (TmpValue, Start, Length);
358 1.1.1.2.4.2 rmind Value = DtTrim (TmpValue);
359 1.1.1.2.4.2 rmind ACPI_FREE (TmpValue);
360 1.1.1.2.4.2 rmind
361 1.1.1.2.4.2 rmind if (Name && Value)
362 1.1.1.2.4.2 rmind {
363 1.1.1.2.4.2 rmind Field = UtLocalCalloc (sizeof (DT_FIELD));
364 1.1.1.2.4.2 rmind Field->Name = Name;
365 1.1.1.2.4.2 rmind Field->Value = Value;
366 1.1.1.2.4.2 rmind Field->Line = Line;
367 1.1.1.2.4.2 rmind Field->ByteOffset = Offset;
368 1.1.1.2.4.2 rmind Field->NameColumn = NameColumn;
369 1.1.1.2.4.2 rmind Field->Column = Column;
370 1.1.1.2.4.2 rmind
371 1.1.1.2.4.2 rmind DtLinkField (Field);
372 1.1.1.2.4.2 rmind }
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind return (AE_OK);
375 1.1.1.2.4.2 rmind }
376 1.1.1.2.4.2 rmind
377 1.1.1.2.4.2 rmind
378 1.1.1.2.4.2 rmind /******************************************************************************
379 1.1.1.2.4.2 rmind *
380 1.1.1.2.4.2 rmind * FUNCTION: DtGetNextLine
381 1.1.1.2.4.2 rmind *
382 1.1.1.2.4.2 rmind * PARAMETERS: Handle - Open file handle for the source file
383 1.1.1.2.4.2 rmind *
384 1.1.1.2.4.2 rmind * RETURN: Filled line buffer and offset of start-of-line (zero on EOF)
385 1.1.1.2.4.2 rmind *
386 1.1.1.2.4.2 rmind * DESCRIPTION: Get the next valid source line. Removes all comments.
387 1.1.1.2.4.2 rmind * Ignores empty lines.
388 1.1.1.2.4.2 rmind *
389 1.1.1.2.4.2 rmind * Handles both slash-asterisk and slash-slash comments.
390 1.1.1.2.4.2 rmind * Also, quoted strings, but no escapes within.
391 1.1.1.2.4.2 rmind *
392 1.1.1.2.4.2 rmind * Line is returned in Gbl_CurrentLineBuffer.
393 1.1.1.2.4.2 rmind * Line number in original file is returned in Gbl_CurrentLineNumber.
394 1.1.1.2.4.2 rmind *
395 1.1.1.2.4.2 rmind *****************************************************************************/
396 1.1.1.2.4.2 rmind
397 1.1.1.2.4.2 rmind UINT32
398 1.1.1.2.4.2 rmind DtGetNextLine (
399 1.1.1.2.4.2 rmind FILE *Handle)
400 1.1.1.2.4.2 rmind {
401 1.1.1.2.4.2 rmind UINT32 State = DT_NORMAL_TEXT;
402 1.1.1.2.4.2 rmind UINT32 CurrentLineOffset;
403 1.1.1.2.4.2 rmind UINT32 i;
404 1.1.1.2.4.2 rmind char c;
405 1.1.1.2.4.2 rmind
406 1.1.1.2.4.2 rmind
407 1.1.1.2.4.2 rmind for (i = 0; i < ASL_LINE_BUFFER_SIZE;)
408 1.1.1.2.4.2 rmind {
409 1.1.1.2.4.2 rmind c = (char) getc (Handle);
410 1.1.1.2.4.2 rmind if (c == EOF)
411 1.1.1.2.4.2 rmind {
412 1.1.1.2.4.2 rmind switch (State)
413 1.1.1.2.4.2 rmind {
414 1.1.1.2.4.2 rmind case DT_START_QUOTED_STRING:
415 1.1.1.2.4.2 rmind case DT_SLASH_ASTERISK_COMMENT:
416 1.1.1.2.4.2 rmind case DT_SLASH_SLASH_COMMENT:
417 1.1.1.2.4.2 rmind
418 1.1.1.2.4.2 rmind AcpiOsPrintf ("**** EOF within comment/string %u\n", State);
419 1.1.1.2.4.2 rmind break;
420 1.1.1.2.4.2 rmind
421 1.1.1.2.4.2 rmind default:
422 1.1.1.2.4.2 rmind break;
423 1.1.1.2.4.2 rmind }
424 1.1.1.2.4.2 rmind
425 1.1.1.2.4.2 rmind return (0);
426 1.1.1.2.4.2 rmind }
427 1.1.1.2.4.2 rmind
428 1.1.1.2.4.2 rmind switch (State)
429 1.1.1.2.4.2 rmind {
430 1.1.1.2.4.2 rmind case DT_NORMAL_TEXT:
431 1.1.1.2.4.2 rmind
432 1.1.1.2.4.2 rmind /* Normal text, insert char into line buffer */
433 1.1.1.2.4.2 rmind
434 1.1.1.2.4.2 rmind Gbl_CurrentLineBuffer[i] = c;
435 1.1.1.2.4.2 rmind switch (c)
436 1.1.1.2.4.2 rmind {
437 1.1.1.2.4.2 rmind case '/':
438 1.1.1.2.4.2 rmind State = DT_START_COMMENT;
439 1.1.1.2.4.2 rmind break;
440 1.1.1.2.4.2 rmind
441 1.1.1.2.4.2 rmind case '"':
442 1.1.1.2.4.2 rmind State = DT_START_QUOTED_STRING;
443 1.1.1.2.4.2 rmind i++;
444 1.1.1.2.4.2 rmind break;
445 1.1.1.2.4.2 rmind
446 1.1.1.2.4.2 rmind case '\n':
447 1.1.1.2.4.2 rmind CurrentLineOffset = Gbl_NextLineOffset;
448 1.1.1.2.4.2 rmind Gbl_NextLineOffset = (UINT32) ftell (Handle);
449 1.1.1.2.4.2 rmind Gbl_CurrentLineNumber++;
450 1.1.1.2.4.2 rmind
451 1.1.1.2.4.2 rmind /* Exit if line is complete. Ignore blank lines */
452 1.1.1.2.4.2 rmind
453 1.1.1.2.4.2 rmind if (i != 0)
454 1.1.1.2.4.2 rmind {
455 1.1.1.2.4.2 rmind Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate line */
456 1.1.1.2.4.2 rmind return (CurrentLineOffset);
457 1.1.1.2.4.2 rmind }
458 1.1.1.2.4.2 rmind break;
459 1.1.1.2.4.2 rmind
460 1.1.1.2.4.2 rmind default:
461 1.1.1.2.4.2 rmind i++;
462 1.1.1.2.4.2 rmind break;
463 1.1.1.2.4.2 rmind }
464 1.1.1.2.4.2 rmind break;
465 1.1.1.2.4.2 rmind
466 1.1.1.2.4.2 rmind case DT_START_QUOTED_STRING:
467 1.1.1.2.4.2 rmind
468 1.1.1.2.4.2 rmind /* Insert raw chars until end of quoted string */
469 1.1.1.2.4.2 rmind
470 1.1.1.2.4.2 rmind Gbl_CurrentLineBuffer[i] = c;
471 1.1.1.2.4.2 rmind i++;
472 1.1.1.2.4.2 rmind
473 1.1.1.2.4.2 rmind if (c == '"')
474 1.1.1.2.4.2 rmind {
475 1.1.1.2.4.2 rmind State = DT_NORMAL_TEXT;
476 1.1.1.2.4.2 rmind }
477 1.1.1.2.4.2 rmind break;
478 1.1.1.2.4.2 rmind
479 1.1.1.2.4.2 rmind case DT_START_COMMENT:
480 1.1.1.2.4.2 rmind
481 1.1.1.2.4.2 rmind /* Open comment if this character is an asterisk or slash */
482 1.1.1.2.4.2 rmind
483 1.1.1.2.4.2 rmind switch (c)
484 1.1.1.2.4.2 rmind {
485 1.1.1.2.4.2 rmind case '*':
486 1.1.1.2.4.2 rmind State = DT_SLASH_ASTERISK_COMMENT;
487 1.1.1.2.4.2 rmind break;
488 1.1.1.2.4.2 rmind
489 1.1.1.2.4.2 rmind case '/':
490 1.1.1.2.4.2 rmind State = DT_SLASH_SLASH_COMMENT;
491 1.1.1.2.4.2 rmind break;
492 1.1.1.2.4.2 rmind
493 1.1.1.2.4.2 rmind default: /* Not a comment */
494 1.1.1.2.4.2 rmind i++; /* Save the preceeding slash */
495 1.1.1.2.4.2 rmind Gbl_CurrentLineBuffer[i] = c;
496 1.1.1.2.4.2 rmind i++;
497 1.1.1.2.4.2 rmind State = DT_NORMAL_TEXT;
498 1.1.1.2.4.2 rmind break;
499 1.1.1.2.4.2 rmind }
500 1.1.1.2.4.2 rmind break;
501 1.1.1.2.4.2 rmind
502 1.1.1.2.4.2 rmind case DT_SLASH_ASTERISK_COMMENT:
503 1.1.1.2.4.2 rmind
504 1.1.1.2.4.2 rmind /* Ignore chars until an asterisk-slash is found */
505 1.1.1.2.4.2 rmind
506 1.1.1.2.4.2 rmind switch (c)
507 1.1.1.2.4.2 rmind {
508 1.1.1.2.4.2 rmind case '\n':
509 1.1.1.2.4.2 rmind Gbl_NextLineOffset = (UINT32) ftell (Handle);
510 1.1.1.2.4.2 rmind Gbl_CurrentLineNumber++;
511 1.1.1.2.4.2 rmind break;
512 1.1.1.2.4.2 rmind
513 1.1.1.2.4.2 rmind case '*':
514 1.1.1.2.4.2 rmind State = DT_END_COMMENT;
515 1.1.1.2.4.2 rmind break;
516 1.1.1.2.4.2 rmind
517 1.1.1.2.4.2 rmind default:
518 1.1.1.2.4.2 rmind break;
519 1.1.1.2.4.2 rmind }
520 1.1.1.2.4.2 rmind break;
521 1.1.1.2.4.2 rmind
522 1.1.1.2.4.2 rmind case DT_SLASH_SLASH_COMMENT:
523 1.1.1.2.4.2 rmind
524 1.1.1.2.4.2 rmind /* Ignore chars until end-of-line */
525 1.1.1.2.4.2 rmind
526 1.1.1.2.4.2 rmind if (c == '\n')
527 1.1.1.2.4.2 rmind {
528 1.1.1.2.4.2 rmind /* We will exit via the NORMAL_TEXT path */
529 1.1.1.2.4.2 rmind
530 1.1.1.2.4.2 rmind ungetc (c, Handle);
531 1.1.1.2.4.2 rmind State = DT_NORMAL_TEXT;
532 1.1.1.2.4.2 rmind }
533 1.1.1.2.4.2 rmind break;
534 1.1.1.2.4.2 rmind
535 1.1.1.2.4.2 rmind case DT_END_COMMENT:
536 1.1.1.2.4.2 rmind
537 1.1.1.2.4.2 rmind /* End comment if this char is a slash */
538 1.1.1.2.4.2 rmind
539 1.1.1.2.4.2 rmind switch (c)
540 1.1.1.2.4.2 rmind {
541 1.1.1.2.4.2 rmind case '/':
542 1.1.1.2.4.2 rmind State = DT_NORMAL_TEXT;
543 1.1.1.2.4.2 rmind break;
544 1.1.1.2.4.2 rmind
545 1.1.1.2.4.2 rmind case '\n':
546 1.1.1.2.4.2 rmind CurrentLineOffset = Gbl_NextLineOffset;
547 1.1.1.2.4.2 rmind Gbl_NextLineOffset = (UINT32) ftell (Handle);
548 1.1.1.2.4.2 rmind Gbl_CurrentLineNumber++;
549 1.1.1.2.4.2 rmind break;
550 1.1.1.2.4.2 rmind
551 1.1.1.2.4.2 rmind case '*':
552 1.1.1.2.4.2 rmind /* Consume all adjacent asterisks */
553 1.1.1.2.4.2 rmind break;
554 1.1.1.2.4.2 rmind
555 1.1.1.2.4.2 rmind default:
556 1.1.1.2.4.2 rmind State = DT_SLASH_ASTERISK_COMMENT;
557 1.1.1.2.4.2 rmind break;
558 1.1.1.2.4.2 rmind }
559 1.1.1.2.4.2 rmind break;
560 1.1.1.2.4.2 rmind
561 1.1.1.2.4.2 rmind default:
562 1.1.1.2.4.2 rmind DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state");
563 1.1.1.2.4.2 rmind return (0);
564 1.1.1.2.4.2 rmind }
565 1.1.1.2.4.2 rmind }
566 1.1.1.2.4.2 rmind
567 1.1.1.2.4.2 rmind printf ("ERROR - Input line is too long (max %u)\n", ASL_LINE_BUFFER_SIZE);
568 1.1.1.2.4.2 rmind return (0);
569 1.1.1.2.4.2 rmind }
570 1.1.1.2.4.2 rmind
571 1.1.1.2.4.2 rmind
572 1.1.1.2.4.2 rmind /******************************************************************************
573 1.1.1.2.4.2 rmind *
574 1.1.1.2.4.2 rmind * FUNCTION: DtScanFile
575 1.1.1.2.4.2 rmind *
576 1.1.1.2.4.2 rmind * PARAMETERS: Handle - Open file handle for the source file
577 1.1.1.2.4.2 rmind *
578 1.1.1.2.4.2 rmind * RETURN: Pointer to start of the constructed parse tree.
579 1.1.1.2.4.2 rmind *
580 1.1.1.2.4.2 rmind * DESCRIPTION: Scan source file, link all field names and values
581 1.1.1.2.4.2 rmind * to the global parse tree: Gbl_FieldList
582 1.1.1.2.4.2 rmind *
583 1.1.1.2.4.2 rmind *****************************************************************************/
584 1.1.1.2.4.2 rmind
585 1.1.1.2.4.2 rmind DT_FIELD *
586 1.1.1.2.4.2 rmind DtScanFile (
587 1.1.1.2.4.2 rmind FILE *Handle)
588 1.1.1.2.4.2 rmind {
589 1.1.1.2.4.2 rmind ACPI_STATUS Status;
590 1.1.1.2.4.2 rmind UINT32 Offset;
591 1.1.1.2.4.2 rmind
592 1.1.1.2.4.2 rmind
593 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (DtScanFile);
594 1.1.1.2.4.2 rmind
595 1.1.1.2.4.2 rmind
596 1.1.1.2.4.2 rmind /* Get the file size */
597 1.1.1.2.4.2 rmind
598 1.1.1.2.4.2 rmind Gbl_InputByteCount = DtGetFileSize (Handle);
599 1.1.1.2.4.2 rmind
600 1.1.1.2.4.2 rmind Gbl_CurrentLineNumber = 0;
601 1.1.1.2.4.2 rmind Gbl_CurrentLineOffset = 0;
602 1.1.1.2.4.2 rmind Gbl_NextLineOffset = 0;
603 1.1.1.2.4.2 rmind
604 1.1.1.2.4.2 rmind /* Scan line-by-line */
605 1.1.1.2.4.2 rmind
606 1.1.1.2.4.2 rmind while ((Offset = DtGetNextLine (Handle)))
607 1.1.1.2.4.2 rmind {
608 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
609 1.1.1.2.4.2 rmind Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
610 1.1.1.2.4.2 rmind
611 1.1.1.2.4.2 rmind Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset);
612 1.1.1.2.4.2 rmind if (Status == AE_NOT_FOUND)
613 1.1.1.2.4.2 rmind {
614 1.1.1.2.4.2 rmind break;
615 1.1.1.2.4.2 rmind }
616 1.1.1.2.4.2 rmind }
617 1.1.1.2.4.2 rmind
618 1.1.1.2.4.2 rmind return (Gbl_FieldList);
619 1.1.1.2.4.2 rmind }
620 1.1.1.2.4.2 rmind
621 1.1.1.2.4.2 rmind
622 1.1.1.2.4.2 rmind /*
623 1.1.1.2.4.2 rmind * Output functions
624 1.1.1.2.4.2 rmind */
625 1.1.1.2.4.2 rmind
626 1.1.1.2.4.2 rmind /******************************************************************************
627 1.1.1.2.4.2 rmind *
628 1.1.1.2.4.2 rmind * FUNCTION: DtWriteBinary
629 1.1.1.2.4.2 rmind *
630 1.1.1.2.4.2 rmind * PARAMETERS: DT_WALK_CALLBACK
631 1.1.1.2.4.2 rmind *
632 1.1.1.2.4.2 rmind * RETURN: Status
633 1.1.1.2.4.2 rmind *
634 1.1.1.2.4.2 rmind * DESCRIPTION: Write one subtable of a binary ACPI table
635 1.1.1.2.4.2 rmind *
636 1.1.1.2.4.2 rmind *****************************************************************************/
637 1.1.1.2.4.2 rmind
638 1.1.1.2.4.2 rmind static void
639 1.1.1.2.4.2 rmind DtWriteBinary (
640 1.1.1.2.4.2 rmind DT_SUBTABLE *Subtable,
641 1.1.1.2.4.2 rmind void *Context,
642 1.1.1.2.4.2 rmind void *ReturnValue)
643 1.1.1.2.4.2 rmind {
644 1.1.1.2.4.2 rmind
645 1.1.1.2.4.2 rmind FlWriteFile (ASL_FILE_AML_OUTPUT, Subtable->Buffer, Subtable->Length);
646 1.1.1.2.4.2 rmind }
647 1.1.1.2.4.2 rmind
648 1.1.1.2.4.2 rmind
649 1.1.1.2.4.2 rmind /******************************************************************************
650 1.1.1.2.4.2 rmind *
651 1.1.1.2.4.2 rmind * FUNCTION: DtOutputBinary
652 1.1.1.2.4.2 rmind *
653 1.1.1.2.4.2 rmind * PARAMETERS:
654 1.1.1.2.4.2 rmind *
655 1.1.1.2.4.2 rmind * RETURN: Status
656 1.1.1.2.4.2 rmind *
657 1.1.1.2.4.2 rmind * DESCRIPTION: Write entire binary ACPI table (result of compilation)
658 1.1.1.2.4.2 rmind *
659 1.1.1.2.4.2 rmind *****************************************************************************/
660 1.1.1.2.4.2 rmind
661 1.1.1.2.4.2 rmind void
662 1.1.1.2.4.2 rmind DtOutputBinary (
663 1.1.1.2.4.2 rmind DT_SUBTABLE *RootTable)
664 1.1.1.2.4.2 rmind {
665 1.1.1.2.4.2 rmind
666 1.1.1.2.4.2 rmind if (!RootTable)
667 1.1.1.2.4.2 rmind {
668 1.1.1.2.4.2 rmind return;
669 1.1.1.2.4.2 rmind }
670 1.1.1.2.4.2 rmind
671 1.1.1.2.4.2 rmind /* Walk the entire parse tree, emitting the binary data */
672 1.1.1.2.4.2 rmind
673 1.1.1.2.4.2 rmind DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL);
674 1.1.1.2.4.2 rmind Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
675 1.1.1.2.4.2 rmind }
676 1.1.1.2.4.2 rmind
677 1.1.1.2.4.2 rmind
678 1.1.1.2.4.2 rmind /*
679 1.1.1.2.4.2 rmind * Listing support
680 1.1.1.2.4.2 rmind */
681 1.1.1.2.4.2 rmind
682 1.1.1.2.4.2 rmind /******************************************************************************
683 1.1.1.2.4.2 rmind *
684 1.1.1.2.4.2 rmind * FUNCTION: DtDumpBuffer
685 1.1.1.2.4.2 rmind *
686 1.1.1.2.4.2 rmind * PARAMETERS: FileID - Where to write buffer data
687 1.1.1.2.4.2 rmind * Buffer - Buffer to dump
688 1.1.1.2.4.2 rmind * Offset - Offset in current table
689 1.1.1.2.4.2 rmind * Length - Buffer Length
690 1.1.1.2.4.2 rmind *
691 1.1.1.2.4.2 rmind * RETURN: None
692 1.1.1.2.4.2 rmind *
693 1.1.1.2.4.2 rmind * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately).
694 1.1.1.2.4.2 rmind *
695 1.1.1.2.4.2 rmind * TBD: merge dump buffer routines
696 1.1.1.2.4.2 rmind *
697 1.1.1.2.4.2 rmind *****************************************************************************/
698 1.1.1.2.4.2 rmind
699 1.1.1.2.4.2 rmind static void
700 1.1.1.2.4.2 rmind DtDumpBuffer (
701 1.1.1.2.4.2 rmind UINT32 FileId,
702 1.1.1.2.4.2 rmind UINT8 *Buffer,
703 1.1.1.2.4.2 rmind UINT32 Offset,
704 1.1.1.2.4.2 rmind UINT32 Length)
705 1.1.1.2.4.2 rmind {
706 1.1.1.2.4.2 rmind UINT32 i;
707 1.1.1.2.4.2 rmind UINT32 j;
708 1.1.1.2.4.2 rmind UINT8 BufChar;
709 1.1.1.2.4.2 rmind
710 1.1.1.2.4.2 rmind
711 1.1.1.2.4.2 rmind FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ",
712 1.1.1.2.4.2 rmind Offset, Offset, Length);
713 1.1.1.2.4.2 rmind
714 1.1.1.2.4.2 rmind i = 0;
715 1.1.1.2.4.2 rmind while (i < Length)
716 1.1.1.2.4.2 rmind {
717 1.1.1.2.4.2 rmind if (i >= 16)
718 1.1.1.2.4.2 rmind {
719 1.1.1.2.4.2 rmind FlPrintFile (FileId, "%23s", "");
720 1.1.1.2.4.2 rmind }
721 1.1.1.2.4.2 rmind
722 1.1.1.2.4.2 rmind /* Print 16 hex chars */
723 1.1.1.2.4.2 rmind
724 1.1.1.2.4.2 rmind for (j = 0; j < 16;)
725 1.1.1.2.4.2 rmind {
726 1.1.1.2.4.2 rmind if (i + j >= Length)
727 1.1.1.2.4.2 rmind {
728 1.1.1.2.4.2 rmind /* Dump fill spaces */
729 1.1.1.2.4.2 rmind
730 1.1.1.2.4.2 rmind FlPrintFile (FileId, " ");
731 1.1.1.2.4.2 rmind j++;
732 1.1.1.2.4.2 rmind continue;
733 1.1.1.2.4.2 rmind }
734 1.1.1.2.4.2 rmind
735 1.1.1.2.4.2 rmind FlPrintFile (FileId, "%02X ", Buffer[i+j]);
736 1.1.1.2.4.2 rmind j++;
737 1.1.1.2.4.2 rmind }
738 1.1.1.2.4.2 rmind
739 1.1.1.2.4.2 rmind FlPrintFile (FileId, " ");
740 1.1.1.2.4.2 rmind for (j = 0; j < 16; j++)
741 1.1.1.2.4.2 rmind {
742 1.1.1.2.4.2 rmind if (i + j >= Length)
743 1.1.1.2.4.2 rmind {
744 1.1.1.2.4.2 rmind FlPrintFile (FileId, "\n\n");
745 1.1.1.2.4.2 rmind return;
746 1.1.1.2.4.2 rmind }
747 1.1.1.2.4.2 rmind
748 1.1.1.2.4.2 rmind BufChar = Buffer[(ACPI_SIZE) i + j];
749 1.1.1.2.4.2 rmind if (ACPI_IS_PRINT (BufChar))
750 1.1.1.2.4.2 rmind {
751 1.1.1.2.4.2 rmind FlPrintFile (FileId, "%c", BufChar);
752 1.1.1.2.4.2 rmind }
753 1.1.1.2.4.2 rmind else
754 1.1.1.2.4.2 rmind {
755 1.1.1.2.4.2 rmind FlPrintFile (FileId, ".");
756 1.1.1.2.4.2 rmind }
757 1.1.1.2.4.2 rmind }
758 1.1.1.2.4.2 rmind
759 1.1.1.2.4.2 rmind /* Done with that line. */
760 1.1.1.2.4.2 rmind
761 1.1.1.2.4.2 rmind FlPrintFile (FileId, "\n");
762 1.1.1.2.4.2 rmind i += 16;
763 1.1.1.2.4.2 rmind }
764 1.1.1.2.4.2 rmind
765 1.1.1.2.4.2 rmind FlPrintFile (FileId, "\n\n");
766 1.1.1.2.4.2 rmind }
767 1.1.1.2.4.2 rmind
768 1.1.1.2.4.2 rmind
769 1.1.1.2.4.2 rmind /******************************************************************************
770 1.1.1.2.4.2 rmind *
771 1.1.1.2.4.2 rmind * FUNCTION: DtWriteFieldToListing
772 1.1.1.2.4.2 rmind *
773 1.1.1.2.4.2 rmind * PARAMETERS: Buffer - Contains the compiled data
774 1.1.1.2.4.2 rmind * Field - Field node for the input line
775 1.1.1.2.4.2 rmind * Length - Length of the output data
776 1.1.1.2.4.2 rmind *
777 1.1.1.2.4.2 rmind * RETURN: None
778 1.1.1.2.4.2 rmind *
779 1.1.1.2.4.2 rmind * DESCRIPTION: Write one field to the listing file (if listing is enabled).
780 1.1.1.2.4.2 rmind *
781 1.1.1.2.4.2 rmind *****************************************************************************/
782 1.1.1.2.4.2 rmind
783 1.1.1.2.4.2 rmind void
784 1.1.1.2.4.2 rmind DtWriteFieldToListing (
785 1.1.1.2.4.2 rmind UINT8 *Buffer,
786 1.1.1.2.4.2 rmind DT_FIELD *Field,
787 1.1.1.2.4.2 rmind UINT32 Length)
788 1.1.1.2.4.2 rmind {
789 1.1.1.2.4.2 rmind UINT8 FileByte;
790 1.1.1.2.4.2 rmind
791 1.1.1.2.4.2 rmind
792 1.1.1.2.4.2 rmind if (!Gbl_ListingFlag || !Field)
793 1.1.1.2.4.2 rmind {
794 1.1.1.2.4.2 rmind return;
795 1.1.1.2.4.2 rmind }
796 1.1.1.2.4.2 rmind
797 1.1.1.2.4.2 rmind /* Dump the original source line */
798 1.1.1.2.4.2 rmind
799 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input: ");
800 1.1.1.2.4.2 rmind FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset);
801 1.1.1.2.4.2 rmind
802 1.1.1.2.4.2 rmind while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK)
803 1.1.1.2.4.2 rmind {
804 1.1.1.2.4.2 rmind FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1);
805 1.1.1.2.4.2 rmind if (FileByte == '\n')
806 1.1.1.2.4.2 rmind {
807 1.1.1.2.4.2 rmind break;
808 1.1.1.2.4.2 rmind }
809 1.1.1.2.4.2 rmind }
810 1.1.1.2.4.2 rmind
811 1.1.1.2.4.2 rmind /* Dump the line as parsed and represented internally */
812 1.1.1.2.4.2 rmind
813 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n",
814 1.1.1.2.4.2 rmind Field->Column-4, Field->Name, Field->Value);
815 1.1.1.2.4.2 rmind
816 1.1.1.2.4.2 rmind /* Dump the hex data that will be output for this field */
817 1.1.1.2.4.2 rmind
818 1.1.1.2.4.2 rmind DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
819 1.1.1.2.4.2 rmind }
820 1.1.1.2.4.2 rmind
821 1.1.1.2.4.2 rmind
822 1.1.1.2.4.2 rmind /******************************************************************************
823 1.1.1.2.4.2 rmind *
824 1.1.1.2.4.2 rmind * FUNCTION: DtWriteTableToListing
825 1.1.1.2.4.2 rmind *
826 1.1.1.2.4.2 rmind * PARAMETERS: None
827 1.1.1.2.4.2 rmind *
828 1.1.1.2.4.2 rmind * RETURN: None
829 1.1.1.2.4.2 rmind *
830 1.1.1.2.4.2 rmind * DESCRIPTION: Write the entire compiled table to the listing file
831 1.1.1.2.4.2 rmind * in hex format
832 1.1.1.2.4.2 rmind *
833 1.1.1.2.4.2 rmind *****************************************************************************/
834 1.1.1.2.4.2 rmind
835 1.1.1.2.4.2 rmind void
836 1.1.1.2.4.2 rmind DtWriteTableToListing (
837 1.1.1.2.4.2 rmind void)
838 1.1.1.2.4.2 rmind {
839 1.1.1.2.4.2 rmind UINT8 *Buffer;
840 1.1.1.2.4.2 rmind
841 1.1.1.2.4.2 rmind
842 1.1.1.2.4.2 rmind if (!Gbl_ListingFlag)
843 1.1.1.2.4.2 rmind {
844 1.1.1.2.4.2 rmind return;
845 1.1.1.2.4.2 rmind }
846 1.1.1.2.4.2 rmind
847 1.1.1.2.4.2 rmind /* Read the entire table from the output file */
848 1.1.1.2.4.2 rmind
849 1.1.1.2.4.2 rmind Buffer = UtLocalCalloc (Gbl_TableLength);
850 1.1.1.2.4.2 rmind FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
851 1.1.1.2.4.2 rmind FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength);
852 1.1.1.2.4.2 rmind
853 1.1.1.2.4.2 rmind /* Dump the raw table data */
854 1.1.1.2.4.2 rmind
855 1.1.1.2.4.2 rmind AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle);
856 1.1.1.2.4.2 rmind
857 1.1.1.2.4.2 rmind AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
858 1.1.1.2.4.2 rmind ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength);
859 1.1.1.2.4.2 rmind AcpiUtDumpBuffer2 (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY);
860 1.1.1.2.4.2 rmind
861 1.1.1.2.4.2 rmind AcpiOsRedirectOutput (stdout);
862 1.1.1.2.4.2 rmind }
863