2 /******************************************************************************
4 * Module Name: asllisting - Listing file generation
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
119 #include "aslcompiler.h"
120 #include "aslcompiler.y.h"
122 #include "acparser.h"
123 #include "acnamesp.h"
125 #define _COMPONENT ACPI_COMPILER
126 ACPI_MODULE_NAME ("aslisting")
129 /*******************************************************************************
131 * FUNCTION: LsDumpAscii
133 * PARAMETERS: FileId - ID of current listing file
134 * Count - Number of bytes to convert
135 * Buffer - Buffer of bytes to convert
139 * DESCRIPTION: Convert hex bytes to ascii
141 ******************************************************************************/
153 FlPrintFile (FileId, " \"");
154 for (i = 0; i < Count; i++)
157 if (isprint (BufChar))
159 FlPrintFile (FileId, "%c", BufChar);
163 /* Not a printable character, just put out a dot */
165 FlPrintFile (FileId, ".");
168 FlPrintFile (FileId, "\"");
172 /*******************************************************************************
174 * FUNCTION: LsDumpAsciiInComment
176 * PARAMETERS: FileId - ID of current listing file
177 * Count - Number of bytes to convert
178 * Buffer - Buffer of bytes to convert
182 * DESCRIPTION: Convert hex bytes to ascii
184 ******************************************************************************/
187 LsDumpAsciiInComment (
197 FlPrintFile (FileId, " \"");
198 for (i = 0; i < Count; i++)
203 if (isprint (BufChar))
205 /* Handle embedded C comment sequences */
207 if (((LastChar == '*') && (BufChar == '/')) ||
208 ((LastChar == '/') && (BufChar == '*')))
210 /* Insert a space to break the sequence */
212 FlPrintFile (FileId, ".", BufChar);
215 FlPrintFile (FileId, "%c", BufChar);
219 /* Not a printable character, just put out a dot */
221 FlPrintFile (FileId, ".");
224 FlPrintFile (FileId, "\"");
228 /*******************************************************************************
230 * FUNCTION: LsAmlListingWalk
232 * PARAMETERS: ASL_WALK_CALLBACK
236 * DESCRIPTION: Process one node during a listing file generation.
238 ******************************************************************************/
242 ACPI_PARSE_OBJECT *Op,
248 UINT32 FileId = (UINT32) Context;
251 LsWriteNodeToListing (Op, FileId);
253 /* Write the hex bytes to the listing file(s) (if requested) */
255 for (i = 0; i < Op->Asl.FinalAmlLength; i++)
257 if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
259 FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
262 LsWriteListingHexBytes (&FileByte, 1, FileId);
269 /*******************************************************************************
271 * FUNCTION: LsGenerateListing
273 * PARAMETERS: FileId - ID of listing file
277 * DESCRIPTION: Generate a listing file. This can be one of the several types
278 * of "listings" supported.
280 ******************************************************************************/
287 /* Start at the beginning of both the source and AML files */
289 FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
290 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
292 Gbl_CurrentHexColumn = 0;
293 LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
295 /* Process all parse nodes */
297 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
298 NULL, (void *) ACPI_TO_POINTER (FileId));
300 /* Final processing */
302 LsFinishSourceListing (FileId);
306 /*******************************************************************************
308 * FUNCTION: LsDoListings
314 * DESCRIPTION: Generate all requested listing files.
316 ******************************************************************************/
322 if (Gbl_C_OutputFlag)
324 LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
329 LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
332 if (Gbl_AsmOutputFlag)
334 LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
337 if (Gbl_C_IncludeOutputFlag)
339 LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
342 if (Gbl_AsmIncludeOutputFlag)
344 LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
349 /*******************************************************************************
351 * FUNCTION: LsPushNode
353 * PARAMETERS: Filename - Pointer to the include filename
357 * DESCRIPTION: Push a listing node on the listing/include file stack. This
358 * stack enables tracking of include files (infinitely nested)
359 * and resumption of the listing of the parent file when the
360 * include file is finished.
362 ******************************************************************************/
368 ASL_LISTING_NODE *Lnode;
371 /* Create a new node */
373 Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
377 Lnode->Filename = Filename;
378 Lnode->LineNumber = 0;
382 Lnode->Next = Gbl_ListingNode;
383 Gbl_ListingNode = Lnode;
387 /*******************************************************************************
389 * FUNCTION: LsPopNode
393 * RETURN: List head after current head is popped off
395 * DESCRIPTION: Pop the current head of the list, free it, and return the
396 * next node on the stack (the new current node).
398 ******************************************************************************/
403 ASL_LISTING_NODE *Lnode;
406 /* Just grab the node at the head of the list */
408 Lnode = Gbl_ListingNode;
412 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, "Could not pop empty listing stack");
413 return Gbl_ListingNode;
416 Gbl_ListingNode = Lnode->Next;
417 ACPI_MEM_FREE (Lnode);
419 /* New "Current" node is the new head */
421 return (Gbl_ListingNode);
425 /*******************************************************************************
427 * FUNCTION: LsCheckException
429 * PARAMETERS: LineNumber - Current logical (cumulative) line #
430 * FileId - ID of output listing file
434 * DESCRIPTION: Check if there is an exception for this line, and if there is,
435 * put it in the listing immediately. Handles multiple errors
436 * per line. Gbl_NextError points to the next error in the
437 * sorted (by line #) list of compile errors/warnings.
439 ******************************************************************************/
447 if ((!Gbl_NextError) ||
448 (LineNumber < Gbl_NextError->LogicalLineNumber ))
453 /* Handle multiple errors per line */
455 if (FileId == ASL_FILE_LISTING_OUTPUT)
457 while (Gbl_NextError &&
458 (LineNumber >= Gbl_NextError->LogicalLineNumber))
460 AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n");
462 Gbl_NextError = Gbl_NextError->Next;
465 FlPrintFile (FileId, "\n");
470 /*******************************************************************************
472 * FUNCTION: LsFlushListingBuffer
474 * PARAMETERS: FileId - ID of the listing file
478 * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
479 * buffer. Usually called at the termination of a single line
480 * of source code or when the buffer is full.
482 ******************************************************************************/
485 LsFlushListingBuffer (
491 if (Gbl_CurrentHexColumn == 0)
496 /* Write the hex bytes */
500 case ASL_FILE_LISTING_OUTPUT:
502 for (i = 0; i < Gbl_CurrentHexColumn; i++)
504 FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]);
507 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++)
509 FlWriteFile (FileId, ".", 1);
512 /* Write the ASCII character associated with each of the bytes */
514 LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
518 case ASL_FILE_ASM_SOURCE_OUTPUT:
520 for (i = 0; i < Gbl_CurrentHexColumn; i++)
524 FlPrintFile (FileId, ",");
526 FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]);
529 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
531 FlWriteFile (FileId, " ", 1);
534 FlPrintFile (FileId, " ;%8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
536 /* Write the ASCII character associated with each of the bytes */
538 LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
542 case ASL_FILE_C_SOURCE_OUTPUT:
544 for (i = 0; i < Gbl_CurrentHexColumn; i++)
546 FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]);
549 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
551 FlWriteFile (FileId, " ", 1);
554 FlPrintFile (FileId, " /* %8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
556 /* Write the ASCII character associated with each of the bytes */
558 LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
559 FlPrintFile (FileId, " */");
563 /* No other types supported */
567 FlPrintFile (FileId, "\n");
569 Gbl_CurrentHexColumn = 0;
570 Gbl_HexBytesWereWritten = TRUE;
574 /*******************************************************************************
576 * FUNCTION: LsWriteListingHexBytes
578 * PARAMETERS: Buffer - AML code buffer
579 * Length - Number of AML bytes to write
580 * FileId - ID of current listing file.
584 * DESCRIPTION: Write the contents of the AML buffer to the listing file via
585 * the listing buffer. The listing buffer is flushed every 16
588 ******************************************************************************/
591 LsWriteListingHexBytes (
599 /* Transfer all requested bytes */
601 for (i = 0; i < Length; i++)
603 /* Print line header when buffer is empty */
605 if (Gbl_CurrentHexColumn == 0)
607 if (Gbl_HasIncludeFiles)
609 FlPrintFile (FileId, "%*s", 10, " ");
614 case ASL_FILE_LISTING_OUTPUT:
616 FlPrintFile (FileId, "%8.8X....", Gbl_CurrentAmlOffset);
619 case ASL_FILE_ASM_SOURCE_OUTPUT:
621 FlPrintFile (FileId, " db ");
624 case ASL_FILE_C_SOURCE_OUTPUT:
626 FlPrintFile (FileId, " ");
630 /* No other types supported */
635 /* Transfer AML byte and update counts */
637 Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i];
639 Gbl_CurrentHexColumn++;
640 Gbl_CurrentAmlOffset++;
642 /* Flush buffer when it is full */
644 if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
646 LsFlushListingBuffer (FileId);
652 /*******************************************************************************
654 * FUNCTION: LsWriteOneSourceLine
656 * PARAMETERS: FileID - ID of current listing file
658 * RETURN: FALSE on EOF (input source file), TRUE otherwise
660 * DESCRIPTION: Read one line from the input source file and echo it to the
661 * listing file, prefixed with the line number, and if the source
662 * file contains include files, prefixed with the current filename
664 ******************************************************************************/
667 LsWriteOneSourceLine (
674 Gbl_ListingNode->LineNumber++;
676 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
678 FlPrintFile (FileId, " *");
680 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
682 FlPrintFile (FileId, "; ");
685 if (Gbl_HasIncludeFiles)
688 * This file contains "include" statements, print the current
689 * filename and line number within the current file
691 FlPrintFile (FileId, "%12s %5d....",
692 Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber);
696 /* No include files, just print the line number */
698 FlPrintFile (FileId, "%8d....", Gbl_SourceLine);
701 /* Read one line (up to a newline or EOF) */
703 while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK)
705 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
713 FlWriteFile (FileId, &FileByte, 1);
714 if (FileByte == '\n')
717 * Check if an error occurred on this source line during the compile.
718 * If so, we print the error message after the source line.
720 LsCheckException (Gbl_SourceLine, FileId);
725 /* EOF on the input file was reached */
731 /*******************************************************************************
733 * FUNCTION: LsFinishSourceListing
735 * PARAMETERS: FileId - ID of current listing file.
739 * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
740 * listing buffer, and flush out any remaining lines in the
743 ******************************************************************************/
746 LsFinishSourceListing (
750 if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
751 (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
756 LsFlushListingBuffer (FileId);
757 Gbl_CurrentAmlOffset = 0;
759 /* Flush any remaining text in the source file */
761 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
763 FlPrintFile (FileId, " /*\n");
766 while (LsWriteOneSourceLine (FileId))
769 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
771 FlPrintFile (FileId, "\n */\n };\n");
774 FlPrintFile (FileId, "\n");
776 if (FileId == ASL_FILE_LISTING_OUTPUT)
778 /* Print a summary of the compile exceptions */
780 FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
781 AePrintErrorLog (FileId);
782 FlPrintFile (FileId, "\n\n");
783 UtDisplaySummary (FileId);
784 FlPrintFile (FileId, "\n\n");
789 /*******************************************************************************
791 * FUNCTION: LsWriteSourceLines
793 * PARAMETERS: ToLineNumber -
794 * ToLogicalLineNumber - Write up to this source line number
795 * FileId - ID of current listing file
799 * DESCRIPTION: Read then write source lines to the listing file until we have
800 * reached the specified logical (cumulative) line number. This
801 * automatically echos out comment blocks and other non-AML
802 * generating text until we get to the actual AML-generating line
803 * of ASL code specified by the logical line number.
805 ******************************************************************************/
810 UINT32 ToLogicalLineNumber,
814 if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
815 (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
820 Gbl_CurrentLine = ToLogicalLineNumber;
822 /* Flush any hex bytes remaining from the last opcode */
824 LsFlushListingBuffer (FileId);
827 * Read lines and write them as long as we are not caught up
829 if (Gbl_SourceLine < Gbl_CurrentLine)
832 * If we just completed writing some AML hex bytes, output a linefeed
833 * to add some whitespace for readability.
835 if (Gbl_HexBytesWereWritten)
837 FlPrintFile (FileId, "\n");
838 Gbl_HexBytesWereWritten = FALSE;
841 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
843 FlPrintFile (FileId, " /*\n");
847 * Write one line at a time until we have reached the target line #
849 while ((Gbl_SourceLine < Gbl_CurrentLine) &&
850 LsWriteOneSourceLine (FileId))
853 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
855 FlPrintFile (FileId, " */");
857 FlPrintFile (FileId, "\n");
862 /*******************************************************************************
864 * FUNCTION: LsWriteNodeToListing
866 * PARAMETERS: Op - Parse node to write to the listing file.
867 * FileId - ID of current listing file
871 * DESCRIPTION: Write "a node" to the listing file. This means to
872 * 1) Write out all of the source text associated with the node
873 * 2) Write out all of the AML bytes associated with the node
874 * 3) Write any compiler exceptions associated with the node
876 ******************************************************************************/
879 LsWriteNodeToListing (
880 ACPI_PARSE_OBJECT *Op,
883 const ACPI_OPCODE_INFO *OpInfo;
890 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
891 OpClass = OpInfo->Class;
893 /* TBD: clean this up with a single flag that says: I start a named output block */
895 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
897 switch (Op->Asl.ParseOpcode)
899 case PARSEOP_DEFINITIONBLOCK:
900 case PARSEOP_METHODCALL:
901 case PARSEOP_INCLUDE:
902 case PARSEOP_INCLUDE_END:
903 case PARSEOP_DEFAULT_ARG:
910 case AML_CLASS_NAMED_OBJECT:
911 switch (Op->Asl.AmlOpcode)
918 if (Op->Asl.ExternalName)
920 LsFlushListingBuffer (FileId);
921 FlPrintFile (FileId, " };\n");
928 /* Don't care about other objects */
936 /* These cases do not have a corresponding AML opcode */
938 switch (Op->Asl.ParseOpcode)
940 case PARSEOP_DEFINITIONBLOCK:
942 LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
944 /* Use the table Signature and TableId to build a unique name */
946 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
948 FlPrintFile (FileId, "%s_%s_Header \\\n",
949 Gbl_TableSignature, Gbl_TableId);
951 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
953 FlPrintFile (FileId, " unsigned char %s_%s_Header [] = \n {\n",
954 Gbl_TableSignature, Gbl_TableId);
956 if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
958 FlPrintFile (FileId, "extrn %s_%s_Header : byte\n",
959 Gbl_TableSignature, Gbl_TableId);
961 if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
963 FlPrintFile (FileId, "extern unsigned char %s_%s_Header [];\n",
964 Gbl_TableSignature, Gbl_TableId);
969 case PARSEOP_METHODCALL:
971 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
975 case PARSEOP_INCLUDE:
978 * Flush everything up to and including the include source line
980 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
983 * Create a new listing node and push it
985 LsPushNode (Op->Asl.Child->Asl.Value.String);
989 case PARSEOP_INCLUDE_END:
992 * Flush out the rest of the include file
994 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
997 * Pop off this listing node and go back to the parent file
1003 case PARSEOP_DEFAULT_ARG:
1008 /* All other opcodes have an AML opcode */
1013 * Otherwise, we look at the AML opcode because we can
1014 * switch on the opcode type, getting an entire class
1019 case AML_CLASS_ARGUMENT: /* argument type only */
1020 case AML_CLASS_INTERNAL:
1025 case AML_CLASS_NAMED_OBJECT:
1027 switch (Op->Asl.AmlOpcode)
1030 case AML_INDEX_FIELD_OP:
1031 case AML_BANK_FIELD_OP:
1034 /* For fields, we want to dump all the AML after the entire definition */
1036 LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
1040 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
1044 switch (Op->Asl.AmlOpcode)
1049 /* These opcodes do not declare a new object, ignore them */
1055 /* All other named object opcodes come here */
1059 case ASL_FILE_ASM_SOURCE_OUTPUT:
1060 case ASL_FILE_C_SOURCE_OUTPUT:
1061 case ASL_FILE_ASM_INCLUDE_OUTPUT:
1062 case ASL_FILE_C_INCLUDE_OUTPUT:
1065 * For named objects, we will create a valid symbol so that the
1066 * AML code can be referenced from C or ASM
1068 if (Op->Asl.ExternalName)
1070 /* Get the full pathname associated with this node */
1072 Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
1073 Length = strlen (Pathname);
1076 /* Convert all dots in the path to underscores */
1078 for (i = 0; i < Length; i++)
1080 if (Pathname[i] == '.')
1086 /* Create the appropriate symbol in the output file */
1088 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
1090 FlPrintFile (FileId, "%s_%s_%s \\\n",
1091 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1093 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
1095 FlPrintFile (FileId, " unsigned char %s_%s_%s [] = \n {\n",
1096 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1098 if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
1100 FlPrintFile (FileId, "extrn %s_%s_%s : byte\n",
1101 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1103 if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
1105 FlPrintFile (FileId, "extern unsigned char %s_%s_%s [];\n",
1106 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1109 ACPI_MEM_FREE (Pathname);
1114 /* Nothing to do for listing file */
1120 case AML_CLASS_EXECUTE:
1121 case AML_CLASS_CREATE:
1124 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId);
1127 case AML_CLASS_UNKNOWN:
1133 /*******************************************************************************
1135 * FUNCTION: LsDoHexOutput
1141 * DESCRIPTION: Create the hex output file.
1143 ******************************************************************************/
1146 LsDoHexOutput (void)
1149 switch (Gbl_HexOutputFlag)
1156 case HEX_OUTPUT_ASM:
1158 LsDoHexOutputAsm ();
1162 /* No other output types supported */
1168 /*******************************************************************************
1170 * FUNCTION: LsDoHexOutputC
1176 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1177 * output file, but formatted into hex/ascii bytes suitable for
1178 * inclusion into a C source file.
1180 ******************************************************************************/
1183 LsDoHexOutputC (void)
1186 UINT8 FileByte[HEX_TABLE_LINE_SIZE];
1191 FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n");
1192 FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] = \n{\n");
1194 /* Start at the beginning of the AML file */
1196 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
1198 /* Process all AML bytes in the AML file */
1201 while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
1205 FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
1209 * Convert each AML byte to hex
1211 UtConvertByteToHex (FileByte[j], Buffer);
1212 FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
1213 FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
1215 /* An occasional linefeed improves readability */
1220 if (j >= HEX_TABLE_LINE_SIZE)
1222 /* End of line, emit the ascii dump of the entire line */
1224 FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE);
1226 /* Write the ASCII character associated with each of the bytes */
1228 LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
1229 FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n");
1231 /* Start new line */
1238 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n");
1239 FlCloseFile (ASL_FILE_HEX_OUTPUT);
1243 /*******************************************************************************
1245 * FUNCTION: LsDoHexOutputAsm
1251 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1252 * output file, but formatted into hex/ascii bytes suitable for
1253 * inclusion into a ASM source file.
1255 ******************************************************************************/
1262 UINT8 FileByte[HEX_TABLE_LINE_SIZE];
1265 BOOLEAN DoComma = FALSE;
1268 FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n");
1270 /* Start at the beginning of the AML file */
1272 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
1274 /* Process all AML bytes in the AML file */
1277 while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
1281 FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
1285 FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
1290 * Convert each AML byte to hex
1292 UtConvertByteToAsmHex (FileByte[j], Buffer);
1293 FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
1295 /* An occasional linefeed improves readability */
1299 if (j >= HEX_TABLE_LINE_SIZE)
1301 FlPrintFile (ASL_FILE_HEX_OUTPUT, " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE);
1303 /* Write the ASCII character associated with each of the bytes */
1305 LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
1306 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
1315 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
1316 FlCloseFile (ASL_FILE_HEX_OUTPUT);