2 /******************************************************************************
4 * Module Name: asllisting - Listing file generation
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2005, 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 <contrib/dev/acpica/compiler/aslcompiler.h>
120 #include "aslcompiler.y.h"
121 #include <contrib/dev/acpica/amlcode.h>
122 #include <contrib/dev/acpica/acparser.h>
123 #include <contrib/dev/acpica/acnamesp.h>
125 #define _COMPONENT ACPI_COMPILER
126 ACPI_MODULE_NAME ("aslisting")
128 /* Local prototypes */
137 LsDumpAsciiInComment (
144 ACPI_PARSE_OBJECT *Op,
156 static ASL_LISTING_NODE *
166 LsFlushListingBuffer (
170 LsWriteListingHexBytes (
176 LsWriteOneSourceLine (
180 LsFinishSourceListing (
186 UINT32 ToLogicalLineNumber,
190 LsWriteNodeToListing (
191 ACPI_PARSE_OBJECT *Op,
203 /*******************************************************************************
205 * FUNCTION: LsDumpAscii
207 * PARAMETERS: FileId - ID of current listing file
208 * Count - Number of bytes to convert
209 * Buffer - Buffer of bytes to convert
213 * DESCRIPTION: Convert hex bytes to ascii
215 ******************************************************************************/
227 FlPrintFile (FileId, " \"");
228 for (i = 0; i < Count; i++)
231 if (isprint (BufChar))
233 FlPrintFile (FileId, "%c", BufChar);
237 /* Not a printable character, just put out a dot */
239 FlPrintFile (FileId, ".");
242 FlPrintFile (FileId, "\"");
246 /*******************************************************************************
248 * FUNCTION: LsDumpAsciiInComment
250 * PARAMETERS: FileId - ID of current listing file
251 * Count - Number of bytes to convert
252 * Buffer - Buffer of bytes to convert
256 * DESCRIPTION: Convert hex bytes to ascii
258 ******************************************************************************/
261 LsDumpAsciiInComment (
271 FlPrintFile (FileId, " \"");
272 for (i = 0; i < Count; i++)
277 if (isprint (BufChar))
279 /* Handle embedded C comment sequences */
281 if (((LastChar == '*') && (BufChar == '/')) ||
282 ((LastChar == '/') && (BufChar == '*')))
284 /* Insert a space to break the sequence */
286 FlPrintFile (FileId, ".", BufChar);
289 FlPrintFile (FileId, "%c", BufChar);
293 /* Not a printable character, just put out a dot */
295 FlPrintFile (FileId, ".");
298 FlPrintFile (FileId, "\"");
302 /*******************************************************************************
304 * FUNCTION: LsAmlListingWalk
306 * PARAMETERS: ASL_WALK_CALLBACK
310 * DESCRIPTION: Process one node during a listing file generation.
312 ******************************************************************************/
316 ACPI_PARSE_OBJECT *Op,
322 UINT32 FileId = (UINT32) Context;
325 LsWriteNodeToListing (Op, FileId);
327 /* Write the hex bytes to the listing file(s) (if requested) */
329 for (i = 0; i < Op->Asl.FinalAmlLength; i++)
331 if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
333 FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
336 LsWriteListingHexBytes (&FileByte, 1, FileId);
343 /*******************************************************************************
345 * FUNCTION: LsGenerateListing
347 * PARAMETERS: FileId - ID of listing file
351 * DESCRIPTION: Generate a listing file. This can be one of the several types
352 * of "listings" supported.
354 ******************************************************************************/
361 /* Start at the beginning of both the source and AML files */
363 FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
364 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
366 Gbl_CurrentHexColumn = 0;
367 LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
369 /* Process all parse nodes */
371 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
372 NULL, (void *) ACPI_TO_POINTER (FileId));
374 /* Final processing */
376 LsFinishSourceListing (FileId);
380 /*******************************************************************************
382 * FUNCTION: LsDoListings
388 * DESCRIPTION: Generate all requested listing files.
390 ******************************************************************************/
397 if (Gbl_C_OutputFlag)
399 LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
404 LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
407 if (Gbl_AsmOutputFlag)
409 LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
412 if (Gbl_C_IncludeOutputFlag)
414 LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
417 if (Gbl_AsmIncludeOutputFlag)
419 LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
424 /*******************************************************************************
426 * FUNCTION: LsPushNode
428 * PARAMETERS: Filename - Pointer to the include filename
432 * DESCRIPTION: Push a listing node on the listing/include file stack. This
433 * stack enables tracking of include files (infinitely nested)
434 * and resumption of the listing of the parent file when the
435 * include file is finished.
437 ******************************************************************************/
443 ASL_LISTING_NODE *Lnode;
446 /* Create a new node */
448 Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
452 Lnode->Filename = Filename;
453 Lnode->LineNumber = 0;
457 Lnode->Next = Gbl_ListingNode;
458 Gbl_ListingNode = Lnode;
462 /*******************************************************************************
464 * FUNCTION: LsPopNode
468 * RETURN: List head after current head is popped off
470 * DESCRIPTION: Pop the current head of the list, free it, and return the
471 * next node on the stack (the new current node).
473 ******************************************************************************/
475 static ASL_LISTING_NODE *
479 ASL_LISTING_NODE *Lnode;
482 /* Just grab the node at the head of the list */
484 Lnode = Gbl_ListingNode;
488 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
489 "Could not pop empty listing stack");
490 return Gbl_ListingNode;
493 Gbl_ListingNode = Lnode->Next;
494 ACPI_MEM_FREE (Lnode);
496 /* New "Current" node is the new head */
498 return (Gbl_ListingNode);
502 /*******************************************************************************
504 * FUNCTION: LsCheckException
506 * PARAMETERS: LineNumber - Current logical (cumulative) line #
507 * FileId - ID of output listing file
511 * DESCRIPTION: Check if there is an exception for this line, and if there is,
512 * put it in the listing immediately. Handles multiple errors
513 * per line. Gbl_NextError points to the next error in the
514 * sorted (by line #) list of compile errors/warnings.
516 ******************************************************************************/
524 if ((!Gbl_NextError) ||
525 (LineNumber < Gbl_NextError->LogicalLineNumber ))
530 /* Handle multiple errors per line */
532 if (FileId == ASL_FILE_LISTING_OUTPUT)
534 while (Gbl_NextError &&
535 (LineNumber >= Gbl_NextError->LogicalLineNumber))
537 AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n");
539 Gbl_NextError = Gbl_NextError->Next;
542 FlPrintFile (FileId, "\n");
547 /*******************************************************************************
549 * FUNCTION: LsFlushListingBuffer
551 * PARAMETERS: FileId - ID of the listing file
555 * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
556 * buffer. Usually called at the termination of a single line
557 * of source code or when the buffer is full.
559 ******************************************************************************/
562 LsFlushListingBuffer (
568 if (Gbl_CurrentHexColumn == 0)
573 /* Write the hex bytes */
577 case ASL_FILE_LISTING_OUTPUT:
579 for (i = 0; i < Gbl_CurrentHexColumn; i++)
581 FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]);
584 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++)
586 FlWriteFile (FileId, ".", 1);
589 /* Write the ASCII character associated with each of the bytes */
591 LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
595 case ASL_FILE_ASM_SOURCE_OUTPUT:
597 for (i = 0; i < Gbl_CurrentHexColumn; i++)
601 FlPrintFile (FileId, ",");
603 FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]);
606 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
608 FlWriteFile (FileId, " ", 1);
611 FlPrintFile (FileId, " ;%8.8X",
612 Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
614 /* Write the ASCII character associated with each of the bytes */
616 LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
620 case ASL_FILE_C_SOURCE_OUTPUT:
622 for (i = 0; i < Gbl_CurrentHexColumn; i++)
624 FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]);
627 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
629 FlWriteFile (FileId, " ", 1);
632 FlPrintFile (FileId, " /* %8.8X",
633 Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
635 /* Write the ASCII character associated with each of the bytes */
637 LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
638 FlPrintFile (FileId, " */");
642 /* No other types supported */
646 FlPrintFile (FileId, "\n");
648 Gbl_CurrentHexColumn = 0;
649 Gbl_HexBytesWereWritten = TRUE;
653 /*******************************************************************************
655 * FUNCTION: LsWriteListingHexBytes
657 * PARAMETERS: Buffer - AML code buffer
658 * Length - Number of AML bytes to write
659 * FileId - ID of current listing file.
663 * DESCRIPTION: Write the contents of the AML buffer to the listing file via
664 * the listing buffer. The listing buffer is flushed every 16
667 ******************************************************************************/
670 LsWriteListingHexBytes (
678 /* Transfer all requested bytes */
680 for (i = 0; i < Length; i++)
682 /* Print line header when buffer is empty */
684 if (Gbl_CurrentHexColumn == 0)
686 if (Gbl_HasIncludeFiles)
688 FlPrintFile (FileId, "%*s", 10, " ");
693 case ASL_FILE_LISTING_OUTPUT:
695 FlPrintFile (FileId, "%8.8X....", Gbl_CurrentAmlOffset);
698 case ASL_FILE_ASM_SOURCE_OUTPUT:
700 FlPrintFile (FileId, " db ");
703 case ASL_FILE_C_SOURCE_OUTPUT:
705 FlPrintFile (FileId, " ");
709 /* No other types supported */
714 /* Transfer AML byte and update counts */
716 Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i];
718 Gbl_CurrentHexColumn++;
719 Gbl_CurrentAmlOffset++;
721 /* Flush buffer when it is full */
723 if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
725 LsFlushListingBuffer (FileId);
731 /*******************************************************************************
733 * FUNCTION: LsWriteOneSourceLine
735 * PARAMETERS: FileID - ID of current listing file
737 * RETURN: FALSE on EOF (input source file), TRUE otherwise
739 * DESCRIPTION: Read one line from the input source file and echo it to the
740 * listing file, prefixed with the line number, and if the source
741 * file contains include files, prefixed with the current filename
743 ******************************************************************************/
746 LsWriteOneSourceLine (
753 Gbl_ListingNode->LineNumber++;
755 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
757 FlPrintFile (FileId, " *");
759 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
761 FlPrintFile (FileId, "; ");
764 if (Gbl_HasIncludeFiles)
767 * This file contains "include" statements, print the current
768 * filename and line number within the current file
770 FlPrintFile (FileId, "%12s %5d....",
771 Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber);
775 /* No include files, just print the line number */
777 FlPrintFile (FileId, "%8d....", Gbl_SourceLine);
780 /* Read one line (up to a newline or EOF) */
782 while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK)
784 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
792 FlWriteFile (FileId, &FileByte, 1);
793 if (FileByte == '\n')
796 * Check if an error occurred on this source line during the compile.
797 * If so, we print the error message after the source line.
799 LsCheckException (Gbl_SourceLine, FileId);
804 /* EOF on the input file was reached */
810 /*******************************************************************************
812 * FUNCTION: LsFinishSourceListing
814 * PARAMETERS: FileId - ID of current listing file.
818 * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
819 * listing buffer, and flush out any remaining lines in the
822 ******************************************************************************/
825 LsFinishSourceListing (
829 if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
830 (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
835 LsFlushListingBuffer (FileId);
836 Gbl_CurrentAmlOffset = 0;
838 /* Flush any remaining text in the source file */
840 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
842 FlPrintFile (FileId, " /*\n");
845 while (LsWriteOneSourceLine (FileId))
848 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
850 FlPrintFile (FileId, "\n */\n };\n");
853 FlPrintFile (FileId, "\n");
855 if (FileId == ASL_FILE_LISTING_OUTPUT)
857 /* Print a summary of the compile exceptions */
859 FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
860 AePrintErrorLog (FileId);
861 FlPrintFile (FileId, "\n\n");
862 UtDisplaySummary (FileId);
863 FlPrintFile (FileId, "\n\n");
868 /*******************************************************************************
870 * FUNCTION: LsWriteSourceLines
872 * PARAMETERS: ToLineNumber -
873 * ToLogicalLineNumber - Write up to this source line number
874 * FileId - ID of current listing file
878 * DESCRIPTION: Read then write source lines to the listing file until we have
879 * reached the specified logical (cumulative) line number. This
880 * automatically echos out comment blocks and other non-AML
881 * generating text until we get to the actual AML-generating line
882 * of ASL code specified by the logical line number.
884 ******************************************************************************/
889 UINT32 ToLogicalLineNumber,
893 if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
894 (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
899 Gbl_CurrentLine = ToLogicalLineNumber;
901 /* Flush any hex bytes remaining from the last opcode */
903 LsFlushListingBuffer (FileId);
905 /* Read lines and write them as long as we are not caught up */
907 if (Gbl_SourceLine < Gbl_CurrentLine)
910 * If we just completed writing some AML hex bytes, output a linefeed
911 * to add some whitespace for readability.
913 if (Gbl_HexBytesWereWritten)
915 FlPrintFile (FileId, "\n");
916 Gbl_HexBytesWereWritten = FALSE;
919 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
921 FlPrintFile (FileId, " /*\n");
924 /* Write one line at a time until we have reached the target line # */
926 while ((Gbl_SourceLine < Gbl_CurrentLine) &&
927 LsWriteOneSourceLine (FileId))
930 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
932 FlPrintFile (FileId, " */");
934 FlPrintFile (FileId, "\n");
939 /*******************************************************************************
941 * FUNCTION: LsWriteNodeToListing
943 * PARAMETERS: Op - Parse node to write to the listing file.
944 * FileId - ID of current listing file
948 * DESCRIPTION: Write "a node" to the listing file. This means to
949 * 1) Write out all of the source text associated with the node
950 * 2) Write out all of the AML bytes associated with the node
951 * 3) Write any compiler exceptions associated with the node
953 ******************************************************************************/
956 LsWriteNodeToListing (
957 ACPI_PARSE_OBJECT *Op,
960 const ACPI_OPCODE_INFO *OpInfo;
967 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
968 OpClass = OpInfo->Class;
970 /* TBD: clean this up with a single flag that says:
971 * I start a named output block
973 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
975 switch (Op->Asl.ParseOpcode)
977 case PARSEOP_DEFINITIONBLOCK:
978 case PARSEOP_METHODCALL:
979 case PARSEOP_INCLUDE:
980 case PARSEOP_INCLUDE_END:
981 case PARSEOP_DEFAULT_ARG:
988 case AML_CLASS_NAMED_OBJECT:
989 switch (Op->Asl.AmlOpcode)
996 if (Op->Asl.ExternalName)
998 LsFlushListingBuffer (FileId);
999 FlPrintFile (FileId, " };\n");
1006 /* Don't care about other objects */
1013 /* These cases do not have a corresponding AML opcode */
1015 switch (Op->Asl.ParseOpcode)
1017 case PARSEOP_DEFINITIONBLOCK:
1019 LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
1021 /* Use the table Signature and TableId to build a unique name */
1023 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
1025 FlPrintFile (FileId,
1026 "%s_%s_Header \\\n",
1027 Gbl_TableSignature, Gbl_TableId);
1029 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
1031 FlPrintFile (FileId,
1032 " unsigned char %s_%s_Header [] =\n {\n",
1033 Gbl_TableSignature, Gbl_TableId);
1035 if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
1037 FlPrintFile (FileId,
1038 "extrn %s_%s_Header : byte\n",
1039 Gbl_TableSignature, Gbl_TableId);
1041 if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
1043 FlPrintFile (FileId,
1044 "extern unsigned char %s_%s_Header [];\n",
1045 Gbl_TableSignature, Gbl_TableId);
1050 case PARSEOP_METHODCALL:
1052 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1057 case PARSEOP_INCLUDE:
1059 /* Flush everything up to and including the include source line */
1061 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1064 /* Create a new listing node and push it */
1066 LsPushNode (Op->Asl.Child->Asl.Value.String);
1070 case PARSEOP_INCLUDE_END:
1072 /* Flush out the rest of the include file */
1074 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1077 /* Pop off this listing node and go back to the parent file */
1079 (void) LsPopNode ();
1083 case PARSEOP_DEFAULT_ARG:
1088 /* All other opcodes have an AML opcode */
1093 * Otherwise, we look at the AML opcode because we can
1094 * switch on the opcode type, getting an entire class
1099 case AML_CLASS_ARGUMENT: /* argument type only */
1100 case AML_CLASS_INTERNAL:
1105 case AML_CLASS_NAMED_OBJECT:
1107 switch (Op->Asl.AmlOpcode)
1110 case AML_INDEX_FIELD_OP:
1111 case AML_BANK_FIELD_OP:
1115 * For fields, we want to dump all the AML after the
1118 LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
1123 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1128 switch (Op->Asl.AmlOpcode)
1133 /* These opcodes do not declare a new object, ignore them */
1139 /* All other named object opcodes come here */
1143 case ASL_FILE_ASM_SOURCE_OUTPUT:
1144 case ASL_FILE_C_SOURCE_OUTPUT:
1145 case ASL_FILE_ASM_INCLUDE_OUTPUT:
1146 case ASL_FILE_C_INCLUDE_OUTPUT:
1149 * For named objects, we will create a valid symbol so that the
1150 * AML code can be referenced from C or ASM
1152 if (Op->Asl.ExternalName)
1154 /* Get the full pathname associated with this node */
1156 Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
1157 Length = strlen (Pathname);
1160 /* Convert all dots in the path to underscores */
1162 for (i = 0; i < Length; i++)
1164 if (Pathname[i] == '.')
1170 /* Create the appropriate symbol in the output file */
1172 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
1174 FlPrintFile (FileId,
1176 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1178 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
1180 FlPrintFile (FileId,
1181 " unsigned char %s_%s_%s [] =\n {\n",
1182 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1184 if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
1186 FlPrintFile (FileId,
1187 "extrn %s_%s_%s : byte\n",
1188 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1190 if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
1192 FlPrintFile (FileId,
1193 "extern unsigned char %s_%s_%s [];\n",
1194 Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1197 ACPI_MEM_FREE (Pathname);
1202 /* Nothing to do for listing file */
1208 case AML_CLASS_EXECUTE:
1209 case AML_CLASS_CREATE:
1212 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1216 case AML_CLASS_UNKNOWN:
1222 /*******************************************************************************
1224 * FUNCTION: LsDoHexOutput
1230 * DESCRIPTION: Create the hex output file.
1232 ******************************************************************************/
1239 switch (Gbl_HexOutputFlag)
1246 case HEX_OUTPUT_ASM:
1248 LsDoHexOutputAsm ();
1252 /* No other output types supported */
1258 /*******************************************************************************
1260 * FUNCTION: LsDoHexOutputC
1266 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1267 * output file, but formatted into hex/ascii bytes suitable for
1268 * inclusion into a C source file.
1270 ******************************************************************************/
1277 UINT8 FileByte[HEX_TABLE_LINE_SIZE];
1282 FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n");
1283 FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n");
1285 /* Start at the beginning of the AML file */
1287 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
1289 /* Process all AML bytes in the AML file */
1292 while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
1296 FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
1299 /* Convert each AML byte to hex */
1301 UtConvertByteToHex (FileByte[j], Buffer);
1302 FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
1303 FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
1305 /* An occasional linefeed improves readability */
1310 if (j >= HEX_TABLE_LINE_SIZE)
1312 /* End of line, emit the ascii dump of the entire line */
1314 FlPrintFile (ASL_FILE_HEX_OUTPUT,
1315 " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE);
1317 /* Write the ASCII character associated with each of the bytes */
1319 LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT,
1320 HEX_TABLE_LINE_SIZE, FileByte);
1321 FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n");
1323 /* Start new line */
1329 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n");
1330 FlCloseFile (ASL_FILE_HEX_OUTPUT);
1334 /*******************************************************************************
1336 * FUNCTION: LsDoHexOutputAsm
1342 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1343 * output file, but formatted into hex/ascii bytes suitable for
1344 * inclusion into a ASM source file.
1346 ******************************************************************************/
1353 UINT8 FileByte[HEX_TABLE_LINE_SIZE];
1356 BOOLEAN DoComma = FALSE;
1359 FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n");
1361 /* Start at the beginning of the AML file */
1363 FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
1365 /* Process all AML bytes in the AML file */
1368 while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
1372 FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
1376 FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
1380 /* Convert each AML byte to hex */
1382 UtConvertByteToAsmHex (FileByte[j], Buffer);
1383 FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
1385 /* An occasional linefeed improves readability */
1389 if (j >= HEX_TABLE_LINE_SIZE)
1391 FlPrintFile (ASL_FILE_HEX_OUTPUT,
1392 " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE);
1394 /* Write the ASCII character associated with each of the bytes */
1396 LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
1397 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
1406 FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
1407 FlCloseFile (ASL_FILE_HEX_OUTPUT);