1 /******************************************************************************
3 * Module Name: dtio.c - File I/O support for data table compiler
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/compiler/aslcompiler.h>
153 #include <contrib/dev/acpica/compiler/dtcompiler.h>
154 #include <contrib/dev/acpica/include/acapps.h>
156 #define _COMPONENT DT_COMPILER
157 ACPI_MODULE_NAME ("dtio")
160 /* Local prototypes */
178 DT_SUBTABLE *Subtable,
191 DT_SUBTABLE *Subtable,
197 DT_SUBTABLE *Subtable,
202 /* States for DtGetNextLine */
204 #define DT_NORMAL_TEXT 0
205 #define DT_START_QUOTED_STRING 1
206 #define DT_START_COMMENT 2
207 #define DT_SLASH_ASTERISK_COMMENT 3
208 #define DT_SLASH_SLASH_COMMENT 4
209 #define DT_END_COMMENT 5
210 #define DT_MERGE_LINES 6
211 #define DT_ESCAPE_SEQUENCE 7
213 static UINT32 Gbl_NextLineOffset;
216 /******************************************************************************
220 * PARAMETERS: String - Current source code line to trim
222 * RETURN: Trimmed line. Must be freed by caller.
224 * DESCRIPTION: Trim left and right spaces
226 *****************************************************************************/
238 /* Skip lines that start with a space */
240 if (!strcmp (String, " "))
242 ReturnString = UtStringCacheCalloc (1);
243 return (ReturnString);
246 /* Setup pointers to start and end of input string */
249 End = String + strlen (String) - 1;
251 /* Find first non-whitespace character */
253 while ((Start <= End) && ((*Start == ' ') || (*Start == '\t')))
258 /* Find last non-space character */
262 if (*End == '\r' || *End == '\n')
276 /* Remove any quotes around the string */
287 /* Create the trimmed return string */
289 Length = ACPI_PTR_DIFF (End, Start) + 1;
290 ReturnString = UtStringCacheCalloc (Length + 1);
293 strncpy (ReturnString, Start, Length);
296 ReturnString[Length] = 0;
297 return (ReturnString);
301 /******************************************************************************
303 * FUNCTION: DtLinkField
305 * PARAMETERS: Field - New field object to link
309 * DESCRIPTION: Link one field name and value to the list
311 *****************************************************************************/
321 Prev = Next = Gbl_FieldList;
335 Gbl_FieldList = Field;
340 /******************************************************************************
342 * FUNCTION: DtParseLine
344 * PARAMETERS: LineBuffer - Current source code line
345 * Line - Current line number in the source
346 * Offset - Current byte offset of the line
350 * DESCRIPTION: Parse one source line
352 *****************************************************************************/
371 BOOLEAN IsNullString = FALSE;
379 /* All lines after "Raw Table Data" are ingored */
381 if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER))
383 return (AE_NOT_FOUND);
386 Colon = strchr (LineBuffer, ':');
395 while (Start < Colon)
399 /* Found left bracket, go to the right bracket */
401 while (Start < Colon && *Start != ']')
406 else if (*Start != ' ')
415 * There are two column values. One for the field name,
416 * and one for the field value.
418 Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3;
419 NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1;
421 Length = ACPI_PTR_DIFF (End, Start);
423 TmpName = UtLocalCalloc (Length + 1);
424 strncpy (TmpName, Start, Length);
425 Name = DtTrim (TmpName);
428 Start = End = (Colon + 1);
431 /* Found left quotation, go to the right quotation and break */
437 /* Check for an explicit null string */
443 while (*End && (*End != '"'))
453 * Special "comment" fields at line end, ignore them.
454 * Note: normal slash-slash and slash-asterisk comments are
455 * stripped already by the DtGetNextLine parser.
457 * TBD: Perhaps DtGetNextLine should parse the following type
469 Length = ACPI_PTR_DIFF (End, Start);
470 TmpValue = UtLocalCalloc (Length + 1);
472 strncpy (TmpValue, Start, Length);
473 Value = DtTrim (TmpValue);
474 ACPI_FREE (TmpValue);
476 /* Create a new field object only if we have a valid value field */
478 if ((Value && *Value) || IsNullString)
480 Field = UtFieldCacheCalloc ();
482 Field->Value = Value;
484 Field->ByteOffset = Offset;
485 Field->NameColumn = NameColumn;
486 Field->Column = Column;
487 Field->StringLength = Length;
491 /* Else -- Ignore this field, it has no valid data */
497 /******************************************************************************
499 * FUNCTION: DtGetNextLine
501 * PARAMETERS: Handle - Open file handle for the source file
503 * RETURN: Filled line buffer and offset of start-of-line (ASL_EOF on EOF)
505 * DESCRIPTION: Get the next valid source line. Removes all comments.
506 * Ignores empty lines.
508 * Handles both slash-asterisk and slash-slash comments.
509 * Also, quoted strings, but no escapes within.
511 * Line is returned in Gbl_CurrentLineBuffer.
512 * Line number in original file is returned in Gbl_CurrentLineNumber.
514 *****************************************************************************/
521 BOOLEAN LineNotAllBlanks = FALSE;
522 UINT32 State = DT_NORMAL_TEXT;
523 UINT32 CurrentLineOffset;
528 memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
532 * If line is too long, expand the line buffers. Also increases
533 * Gbl_LineBufferSize.
535 if (i >= Gbl_LineBufferSize)
537 UtExpandLineBuffers ();
545 case DT_START_QUOTED_STRING:
546 case DT_SLASH_ASTERISK_COMMENT:
548 AcpiOsPrintf ("**** EOF within comment/string %u\n", State);
556 /* Standalone EOF is OK */
564 * Received an EOF in the middle of a line. Terminate the
565 * line with a newline. The next call to this function will
566 * return a standalone EOF. Thus, the upper parsing software
567 * never has to deal with an EOF within a valid line (or
568 * the last line does not get tossed on the floor.)
571 State = DT_NORMAL_TEXT;
578 /* Normal text, insert char into line buffer */
580 Gbl_CurrentLineBuffer[i] = (char) c;
585 State = DT_START_COMMENT;
590 State = DT_START_QUOTED_STRING;
591 LineNotAllBlanks = TRUE;
597 * The continuation char MUST be last char on this line.
598 * Otherwise, it will be assumed to be a valid ASL char.
600 State = DT_MERGE_LINES;
605 CurrentLineOffset = Gbl_NextLineOffset;
606 Gbl_NextLineOffset = (UINT32) ftell (Handle);
607 Gbl_CurrentLineNumber++;
610 * Exit if line is complete. Ignore empty lines (only \n)
611 * or lines that contain nothing but blanks.
613 if ((i != 0) && LineNotAllBlanks)
615 if ((i + 1) >= Gbl_LineBufferSize)
617 UtExpandLineBuffers ();
620 Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */
621 return (CurrentLineOffset);
624 /* Toss this line and start a new one */
627 LineNotAllBlanks = FALSE;
634 LineNotAllBlanks = TRUE;
642 case DT_START_QUOTED_STRING:
644 /* Insert raw chars until end of quoted string */
646 Gbl_CurrentLineBuffer[i] = (char) c;
653 State = DT_NORMAL_TEXT;
658 State = DT_ESCAPE_SEQUENCE;
663 if (!(Flags & DT_ALLOW_MULTILINE_QUOTES))
666 "ERROR at line %u: Unterminated quoted string\n",
667 Gbl_CurrentLineNumber++);
668 State = DT_NORMAL_TEXT;
672 default: /* Get next character */
678 case DT_ESCAPE_SEQUENCE:
680 /* Just copy the escaped character. TBD: sufficient for table compiler? */
682 Gbl_CurrentLineBuffer[i] = (char) c;
684 State = DT_START_QUOTED_STRING;
687 case DT_START_COMMENT:
689 /* Open comment if this character is an asterisk or slash */
695 State = DT_SLASH_ASTERISK_COMMENT;
700 State = DT_SLASH_SLASH_COMMENT;
703 default: /* Not a comment */
705 i++; /* Save the preceding slash */
706 if (i >= Gbl_LineBufferSize)
708 UtExpandLineBuffers ();
711 Gbl_CurrentLineBuffer[i] = (char) c;
713 State = DT_NORMAL_TEXT;
718 case DT_SLASH_ASTERISK_COMMENT:
720 /* Ignore chars until an asterisk-slash is found */
726 Gbl_NextLineOffset = (UINT32) ftell (Handle);
727 Gbl_CurrentLineNumber++;
732 State = DT_END_COMMENT;
741 case DT_SLASH_SLASH_COMMENT:
743 /* Ignore chars until end-of-line */
747 /* We will exit via the NORMAL_TEXT path */
750 State = DT_NORMAL_TEXT;
756 /* End comment if this char is a slash */
762 State = DT_NORMAL_TEXT;
767 CurrentLineOffset = Gbl_NextLineOffset;
768 Gbl_NextLineOffset = (UINT32) ftell (Handle);
769 Gbl_CurrentLineNumber++;
774 /* Consume all adjacent asterisks */
779 State = DT_SLASH_ASTERISK_COMMENT;
789 * This is not a continuation backslash, it is a normal
790 * normal ASL backslash - for example: Scope(\_SB_)
792 i++; /* Keep the backslash that is already in the buffer */
795 State = DT_NORMAL_TEXT;
800 * This is a continuation line -- a backlash followed
801 * immediately by a newline. Insert a space between the
802 * lines (overwrite the backslash)
804 Gbl_CurrentLineBuffer[i] = ' ';
807 /* Ignore newline, this will merge the lines */
809 CurrentLineOffset = Gbl_NextLineOffset;
810 Gbl_NextLineOffset = (UINT32) ftell (Handle);
811 Gbl_CurrentLineNumber++;
812 State = DT_NORMAL_TEXT;
818 DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state");
825 /******************************************************************************
827 * FUNCTION: DtScanFile
829 * PARAMETERS: Handle - Open file handle for the source file
831 * RETURN: Pointer to start of the constructed parse tree.
833 * DESCRIPTION: Scan source file, link all field names and values
834 * to the global parse tree: Gbl_FieldList
836 *****************************************************************************/
846 ACPI_FUNCTION_NAME (DtScanFile);
849 /* Get the file size */
851 Gbl_InputByteCount = CmGetFileSize (Handle);
852 if (Gbl_InputByteCount == ACPI_UINT32_MAX)
857 Gbl_CurrentLineNumber = 0;
858 Gbl_CurrentLineOffset = 0;
859 Gbl_NextLineOffset = 0;
861 /* Scan line-by-line */
863 while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF)
865 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
866 Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
868 Status = DtParseLine (Gbl_CurrentLineBuffer,
869 Gbl_CurrentLineNumber, Offset);
870 if (Status == AE_NOT_FOUND)
876 /* Dump the parse tree if debug enabled */
878 DtDumpFieldList (Gbl_FieldList);
879 return (Gbl_FieldList);
887 /******************************************************************************
889 * FUNCTION: DtWriteBinary
891 * PARAMETERS: DT_WALK_CALLBACK
895 * DESCRIPTION: Write one subtable of a binary ACPI table
897 *****************************************************************************/
901 DT_SUBTABLE *Subtable,
906 FlWriteFile (ASL_FILE_AML_OUTPUT, Subtable->Buffer, Subtable->Length);
910 /******************************************************************************
912 * FUNCTION: DtOutputBinary
918 * DESCRIPTION: Write entire binary ACPI table (result of compilation)
920 *****************************************************************************/
924 DT_SUBTABLE *RootTable)
932 /* Walk the entire parse tree, emitting the binary data */
934 DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL);
936 Gbl_TableLength = CmGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
937 if (Gbl_TableLength == ACPI_UINT32_MAX)
948 /******************************************************************************
950 * FUNCTION: DtDumpBuffer
952 * PARAMETERS: FileID - Where to write buffer data
953 * Buffer - Buffer to dump
954 * Offset - Offset in current table
955 * Length - Buffer Length
959 * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately).
961 * TBD: merge dump buffer routines
963 *****************************************************************************/
977 FlPrintFile (FileId, "Output: [%3.3Xh %4.4d %3d] ",
978 Offset, Offset, Length);
985 FlPrintFile (FileId, "%24s", "");
988 /* Print 16 hex chars */
994 /* Dump fill spaces */
996 FlPrintFile (FileId, " ");
1001 FlPrintFile (FileId, "%02X ", Buffer[i+j]);
1005 FlPrintFile (FileId, " ");
1006 for (j = 0; j < 16; j++)
1008 if (i + j >= Length)
1010 FlPrintFile (FileId, "\n\n");
1014 BufChar = Buffer[(ACPI_SIZE) i + j];
1015 if (isprint (BufChar))
1017 FlPrintFile (FileId, "%c", BufChar);
1021 FlPrintFile (FileId, ".");
1025 /* Done with that line. */
1027 FlPrintFile (FileId, "\n");
1031 FlPrintFile (FileId, "\n\n");
1035 /******************************************************************************
1037 * FUNCTION: DtDumpFieldList
1039 * PARAMETERS: Field - Root field
1043 * DESCRIPTION: Dump the entire field list
1045 *****************************************************************************/
1052 if (!Gbl_DebugFlag || !Field)
1057 DbgPrint (ASL_DEBUG_OUTPUT, "\nField List:\n"
1058 "LineNo ByteOff NameCol Column TableOff "
1059 "Flags %32s : %s\n\n", "Name", "Value");
1063 DbgPrint (ASL_DEBUG_OUTPUT,
1064 "%.08X %.08X %.08X %.08X %.08X %2.2X %32s : %s\n",
1065 Field->Line, Field->ByteOffset, Field->NameColumn,
1066 Field->Column, Field->TableOffset, Field->Flags,
1067 Field->Name, Field->Value);
1069 Field = Field->Next;
1072 DbgPrint (ASL_DEBUG_OUTPUT, "\n\n");
1076 /******************************************************************************
1078 * FUNCTION: DtDumpSubtableInfo, DtDumpSubtableTree
1080 * PARAMETERS: DT_WALK_CALLBACK
1084 * DESCRIPTION: Info - dump a subtable tree entry with extra information.
1085 * Tree - dump a subtable tree formatted by depth indentation.
1087 *****************************************************************************/
1090 DtDumpSubtableInfo (
1091 DT_SUBTABLE *Subtable,
1096 DbgPrint (ASL_DEBUG_OUTPUT,
1097 "[%.04X] %24s %.08X %.08X %.08X %.08X %.08X %p %p %p\n",
1098 Subtable->Depth, Subtable->Name, Subtable->Length, Subtable->TotalLength,
1099 Subtable->SizeOfLengthField, Subtable->Flags, Subtable,
1100 Subtable->Parent, Subtable->Child, Subtable->Peer);
1104 DtDumpSubtableTree (
1105 DT_SUBTABLE *Subtable,
1110 DbgPrint (ASL_DEBUG_OUTPUT,
1111 "[%.04X] %24s %*s%08X (%.02X) - (%.02X)\n",
1112 Subtable->Depth, Subtable->Name, (4 * Subtable->Depth), " ",
1113 Subtable, Subtable->Length, Subtable->TotalLength);
1117 /******************************************************************************
1119 * FUNCTION: DtDumpSubtableList
1125 * DESCRIPTION: Dump the raw list of subtables with information, and also
1126 * dump the subtable list in formatted tree format. Assists with
1127 * the development of new table code.
1129 *****************************************************************************/
1132 DtDumpSubtableList (
1136 if (!Gbl_DebugFlag || !Gbl_RootTable)
1141 DbgPrint (ASL_DEBUG_OUTPUT,
1143 "Depth Name Length TotalLen LenSize Flags "
1144 "This Parent Child Peer\n\n");
1145 DtWalkTableTree (Gbl_RootTable, DtDumpSubtableInfo, NULL, NULL);
1147 DbgPrint (ASL_DEBUG_OUTPUT,
1148 "\nSubtable Tree: (Depth, Name, Subtable, Length, TotalLength)\n\n");
1149 DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL);
1151 DbgPrint (ASL_DEBUG_OUTPUT, "\n");
1155 /******************************************************************************
1157 * FUNCTION: DtWriteFieldToListing
1159 * PARAMETERS: Buffer - Contains the compiled data
1160 * Field - Field node for the input line
1161 * Length - Length of the output data
1165 * DESCRIPTION: Write one field to the listing file (if listing is enabled).
1167 *****************************************************************************/
1170 DtWriteFieldToListing (
1178 if (!Gbl_ListingFlag || !Field)
1183 /* Dump the original source line */
1185 FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input: ");
1186 FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset);
1188 while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK)
1190 FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1);
1191 if (FileByte == '\n')
1197 /* Dump the line as parsed and represented internally */
1199 FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %.64s",
1200 Field->Column-4, Field->Name, Field->Value);
1202 if (strlen (Field->Value) > 64)
1204 FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n",
1205 strlen (Field->Value));
1208 FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n");
1210 /* Dump the hex data that will be output for this field */
1212 DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
1216 /******************************************************************************
1218 * FUNCTION: DtWriteTableToListing
1224 * DESCRIPTION: Write the entire compiled table to the listing file
1227 *****************************************************************************/
1230 DtWriteTableToListing (
1236 if (!Gbl_ListingFlag)
1241 /* Read the entire table from the output file */
1243 Buffer = UtLocalCalloc (Gbl_TableLength);
1244 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
1245 FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength);
1247 /* Dump the raw table data */
1249 AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle);
1251 AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
1252 ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength);
1253 AcpiUtDumpBuffer (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY, 0);
1255 AcpiOsRedirectOutput (stdout);