2 /******************************************************************************
4 * Module Name: asllisting - Listing file generation
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #include "aslcompiler.h"
119 #include "aslcompiler.y.h"
121 #include "acparser.h"
122 #include "acnamesp.h"
124 #define _COMPONENT ACPI_COMPILER
125 ACPI_MODULE_NAME ("aslisting")
127 /* Local prototypes */
136 LsDumpAsciiInComment (
143 ACPI_PARSE_OBJECT
*Op
,
155 static ASL_LISTING_NODE
*
165 LsFlushListingBuffer (
169 LsWriteListingHexBytes (
175 LsWriteOneSourceLine (
179 LsFinishSourceListing (
185 UINT32 ToLogicalLineNumber
,
189 LsWriteNodeToListing (
190 ACPI_PARSE_OBJECT
*Op
,
203 ACPI_PARSE_OBJECT
*Op
,
208 /*******************************************************************************
210 * FUNCTION: LsTreeWriteWalk
212 * PARAMETERS: ASL_WALK_CALLBACK
217 * DESCRIPTION: Dump entire parse tree, for compiler debug only
219 ******************************************************************************/
223 ACPI_PARSE_OBJECT
*Op
,
230 DbgPrint (ASL_TREE_OUTPUT
,
231 "%5.5d [%2d]", Op
->Asl
.LogicalLineNumber
, Level
);
232 UtPrintFormattedName (Op
->Asl
.ParseOpcode
, Level
);
235 DbgPrint (ASL_TREE_OUTPUT
, "\n");
250 DbgPrint (ASL_TREE_OUTPUT
, "\nOriginal parse tree from parser:\n\n");
251 TrWalkParseTree (RootNode
, ASL_WALK_VISIT_DOWNWARD
,
252 LsTreeWriteWalk
, NULL
, NULL
);
256 /*******************************************************************************
258 * FUNCTION: LsDumpAscii
260 * PARAMETERS: FileId - ID of current listing file
261 * Count - Number of bytes to convert
262 * Buffer - Buffer of bytes to convert
266 * DESCRIPTION: Convert hex bytes to ascii
268 ******************************************************************************/
280 FlPrintFile (FileId
, " \"");
281 for (i
= 0; i
< Count
; i
++)
284 if (isprint (BufChar
))
286 FlPrintFile (FileId
, "%c", BufChar
);
290 /* Not a printable character, just put out a dot */
292 FlPrintFile (FileId
, ".");
295 FlPrintFile (FileId
, "\"");
299 /*******************************************************************************
301 * FUNCTION: LsDumpAsciiInComment
303 * PARAMETERS: FileId - ID of current listing file
304 * Count - Number of bytes to convert
305 * Buffer - Buffer of bytes to convert
309 * DESCRIPTION: Convert hex bytes to ascii
311 ******************************************************************************/
314 LsDumpAsciiInComment (
324 FlPrintFile (FileId
, " \"");
325 for (i
= 0; i
< Count
; i
++)
330 if (isprint (BufChar
))
332 /* Handle embedded C comment sequences */
334 if (((LastChar
== '*') && (BufChar
== '/')) ||
335 ((LastChar
== '/') && (BufChar
== '*')))
337 /* Insert a space to break the sequence */
339 FlPrintFile (FileId
, ".", BufChar
);
342 FlPrintFile (FileId
, "%c", BufChar
);
346 /* Not a printable character, just put out a dot */
348 FlPrintFile (FileId
, ".");
351 FlPrintFile (FileId
, "\"");
355 /*******************************************************************************
357 * FUNCTION: LsAmlListingWalk
359 * PARAMETERS: ASL_WALK_CALLBACK
363 * DESCRIPTION: Process one node during a listing file generation.
365 ******************************************************************************/
369 ACPI_PARSE_OBJECT
*Op
,
375 UINT32 FileId
= (UINT32
) ACPI_TO_INTEGER (Context
);
378 LsWriteNodeToListing (Op
, FileId
);
380 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DATA
)
382 /* Buffer is a resource template, don't dump the data all at once */
387 /* Write the hex bytes to the listing file(s) (if requested) */
389 for (i
= 0; i
< Op
->Asl
.FinalAmlLength
; i
++)
391 if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
, 1)))
393 FlFileError (ASL_FILE_AML_OUTPUT
, ASL_MSG_READ
);
396 LsWriteListingHexBytes (&FileByte
, 1, FileId
);
403 /*******************************************************************************
405 * FUNCTION: LsGenerateListing
407 * PARAMETERS: FileId - ID of listing file
411 * DESCRIPTION: Generate a listing file. This can be one of the several types
412 * of "listings" supported.
414 ******************************************************************************/
421 /* Start at the beginning of both the source and AML files */
423 FlSeekFile (ASL_FILE_SOURCE_OUTPUT
, 0);
424 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
426 Gbl_CurrentHexColumn
= 0;
427 LsPushNode (Gbl_Files
[ASL_FILE_INPUT
].Filename
);
429 /* Process all parse nodes */
431 TrWalkParseTree (RootNode
, ASL_WALK_VISIT_DOWNWARD
, LsAmlListingWalk
,
432 NULL
, (void *) ACPI_TO_POINTER (FileId
));
434 /* Final processing */
436 LsFinishSourceListing (FileId
);
440 /*******************************************************************************
442 * FUNCTION: LsDoListings
448 * DESCRIPTION: Generate all requested listing files.
450 ******************************************************************************/
457 if (Gbl_C_OutputFlag
)
459 LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT
);
464 LsGenerateListing (ASL_FILE_LISTING_OUTPUT
);
467 if (Gbl_AsmOutputFlag
)
469 LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT
);
472 if (Gbl_C_IncludeOutputFlag
)
474 LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT
);
477 if (Gbl_AsmIncludeOutputFlag
)
479 LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT
);
484 /*******************************************************************************
486 * FUNCTION: LsPushNode
488 * PARAMETERS: Filename - Pointer to the include filename
492 * DESCRIPTION: Push a listing node on the listing/include file stack. This
493 * stack enables tracking of include files (infinitely nested)
494 * and resumption of the listing of the parent file when the
495 * include file is finished.
497 ******************************************************************************/
503 ASL_LISTING_NODE
*Lnode
;
506 /* Create a new node */
508 Lnode
= UtLocalCalloc (sizeof (ASL_LISTING_NODE
));
512 Lnode
->Filename
= Filename
;
513 Lnode
->LineNumber
= 0;
517 Lnode
->Next
= Gbl_ListingNode
;
518 Gbl_ListingNode
= Lnode
;
522 /*******************************************************************************
524 * FUNCTION: LsPopNode
528 * RETURN: List head after current head is popped off
530 * DESCRIPTION: Pop the current head of the list, free it, and return the
531 * next node on the stack (the new current node).
533 ******************************************************************************/
535 static ASL_LISTING_NODE
*
539 ASL_LISTING_NODE
*Lnode
;
542 /* Just grab the node at the head of the list */
544 Lnode
= Gbl_ListingNode
;
548 AslError (ASL_ERROR
, ASL_MSG_COMPILER_INTERNAL
, NULL
,
549 "Could not pop empty listing stack");
550 return Gbl_ListingNode
;
553 Gbl_ListingNode
= Lnode
->Next
;
556 /* New "Current" node is the new head */
558 return (Gbl_ListingNode
);
562 /*******************************************************************************
564 * FUNCTION: LsCheckException
566 * PARAMETERS: LineNumber - Current logical (cumulative) line #
567 * FileId - ID of output listing file
571 * DESCRIPTION: Check if there is an exception for this line, and if there is,
572 * put it in the listing immediately. Handles multiple errors
573 * per line. Gbl_NextError points to the next error in the
574 * sorted (by line #) list of compile errors/warnings.
576 ******************************************************************************/
584 if ((!Gbl_NextError
) ||
585 (LineNumber
< Gbl_NextError
->LogicalLineNumber
))
590 /* Handle multiple errors per line */
592 if (FileId
== ASL_FILE_LISTING_OUTPUT
)
594 while (Gbl_NextError
&&
595 (LineNumber
>= Gbl_NextError
->LogicalLineNumber
))
597 AePrintException (FileId
, Gbl_NextError
, "\n[****iasl****]\n");
599 Gbl_NextError
= Gbl_NextError
->Next
;
602 FlPrintFile (FileId
, "\n");
607 /*******************************************************************************
609 * FUNCTION: LsFlushListingBuffer
611 * PARAMETERS: FileId - ID of the listing file
615 * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
616 * buffer. Usually called at the termination of a single line
617 * of source code or when the buffer is full.
619 ******************************************************************************/
622 LsFlushListingBuffer (
628 if (Gbl_CurrentHexColumn
== 0)
633 /* Write the hex bytes */
637 case ASL_FILE_LISTING_OUTPUT
:
639 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
641 FlPrintFile (FileId
, "%2.2X ", Gbl_AmlBuffer
[i
]);
644 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 3); i
++)
646 FlWriteFile (FileId
, ".", 1);
649 /* Write the ASCII character associated with each of the bytes */
651 LsDumpAscii (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
655 case ASL_FILE_ASM_SOURCE_OUTPUT
:
657 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
661 FlPrintFile (FileId
, ",");
663 FlPrintFile (FileId
, "0%2.2Xh", Gbl_AmlBuffer
[i
]);
666 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 5); i
++)
668 FlWriteFile (FileId
, " ", 1);
671 FlPrintFile (FileId
, " ;%8.8X",
672 Gbl_CurrentAmlOffset
- HEX_LISTING_LINE_SIZE
);
674 /* Write the ASCII character associated with each of the bytes */
676 LsDumpAscii (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
680 case ASL_FILE_C_SOURCE_OUTPUT
:
682 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
684 FlPrintFile (FileId
, "0x%2.2X,", Gbl_AmlBuffer
[i
]);
687 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 5); i
++)
689 FlWriteFile (FileId
, " ", 1);
692 FlPrintFile (FileId
, " /* %8.8X",
693 Gbl_CurrentAmlOffset
- HEX_LISTING_LINE_SIZE
);
695 /* Write the ASCII character associated with each of the bytes */
697 LsDumpAsciiInComment (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
698 FlPrintFile (FileId
, " */");
702 /* No other types supported */
706 FlPrintFile (FileId
, "\n");
708 Gbl_CurrentHexColumn
= 0;
709 Gbl_HexBytesWereWritten
= TRUE
;
713 /*******************************************************************************
715 * FUNCTION: LsWriteListingHexBytes
717 * PARAMETERS: Buffer - AML code buffer
718 * Length - Number of AML bytes to write
719 * FileId - ID of current listing file.
723 * DESCRIPTION: Write the contents of the AML buffer to the listing file via
724 * the listing buffer. The listing buffer is flushed every 16
727 ******************************************************************************/
730 LsWriteListingHexBytes (
738 /* Transfer all requested bytes */
740 for (i
= 0; i
< Length
; i
++)
742 /* Print line header when buffer is empty */
744 if (Gbl_CurrentHexColumn
== 0)
746 if (Gbl_HasIncludeFiles
)
748 FlPrintFile (FileId
, "%*s", 10, " ");
753 case ASL_FILE_LISTING_OUTPUT
:
755 FlPrintFile (FileId
, "%8.8X....", Gbl_CurrentAmlOffset
);
758 case ASL_FILE_ASM_SOURCE_OUTPUT
:
760 FlPrintFile (FileId
, " db ");
763 case ASL_FILE_C_SOURCE_OUTPUT
:
765 FlPrintFile (FileId
, " ");
769 /* No other types supported */
774 /* Transfer AML byte and update counts */
776 Gbl_AmlBuffer
[Gbl_CurrentHexColumn
] = Buffer
[i
];
778 Gbl_CurrentHexColumn
++;
779 Gbl_CurrentAmlOffset
++;
781 /* Flush buffer when it is full */
783 if (Gbl_CurrentHexColumn
>= HEX_LISTING_LINE_SIZE
)
785 LsFlushListingBuffer (FileId
);
791 /*******************************************************************************
793 * FUNCTION: LsWriteOneSourceLine
795 * PARAMETERS: FileID - ID of current listing file
797 * RETURN: FALSE on EOF (input source file), TRUE otherwise
799 * DESCRIPTION: Read one line from the input source file and echo it to the
800 * listing file, prefixed with the line number, and if the source
801 * file contains include files, prefixed with the current filename
803 ******************************************************************************/
806 LsWriteOneSourceLine (
813 Gbl_ListingNode
->LineNumber
++;
815 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
817 FlPrintFile (FileId
, " *");
819 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
821 FlPrintFile (FileId
, "; ");
824 if (Gbl_HasIncludeFiles
)
827 * This file contains "include" statements, print the current
828 * filename and line number within the current file
830 FlPrintFile (FileId
, "%12s %5d....",
831 Gbl_ListingNode
->Filename
, Gbl_ListingNode
->LineNumber
);
835 /* No include files, just print the line number */
837 FlPrintFile (FileId
, "%8d....", Gbl_SourceLine
);
840 /* Read one line (up to a newline or EOF) */
842 while (FlReadFile (ASL_FILE_SOURCE_OUTPUT
, &FileByte
, 1) == AE_OK
)
844 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
852 FlWriteFile (FileId
, &FileByte
, 1);
853 if (FileByte
== '\n')
856 * Check if an error occurred on this source line during the compile.
857 * If so, we print the error message after the source line.
859 LsCheckException (Gbl_SourceLine
, FileId
);
864 /* EOF on the input file was reached */
870 /*******************************************************************************
872 * FUNCTION: LsFinishSourceListing
874 * PARAMETERS: FileId - ID of current listing file.
878 * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
879 * listing buffer, and flush out any remaining lines in the
882 ******************************************************************************/
885 LsFinishSourceListing (
889 if ((FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
) ||
890 (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
))
895 LsFlushListingBuffer (FileId
);
896 Gbl_CurrentAmlOffset
= 0;
898 /* Flush any remaining text in the source file */
900 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
902 FlPrintFile (FileId
, " /*\n");
905 while (LsWriteOneSourceLine (FileId
))
908 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
910 FlPrintFile (FileId
, "\n */\n };\n");
913 FlPrintFile (FileId
, "\n");
915 if (FileId
== ASL_FILE_LISTING_OUTPUT
)
917 /* Print a summary of the compile exceptions */
919 FlPrintFile (FileId
, "\n\nSummary of errors and warnings\n\n");
920 AePrintErrorLog (FileId
);
921 FlPrintFile (FileId
, "\n\n");
922 UtDisplaySummary (FileId
);
923 FlPrintFile (FileId
, "\n\n");
928 /*******************************************************************************
930 * FUNCTION: LsWriteSourceLines
932 * PARAMETERS: ToLineNumber -
933 * ToLogicalLineNumber - Write up to this source line number
934 * FileId - ID of current listing file
938 * DESCRIPTION: Read then write source lines to the listing file until we have
939 * reached the specified logical (cumulative) line number. This
940 * automatically echos out comment blocks and other non-AML
941 * generating text until we get to the actual AML-generating line
942 * of ASL code specified by the logical line number.
944 ******************************************************************************/
949 UINT32 ToLogicalLineNumber
,
953 if ((FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
) ||
954 (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
))
959 Gbl_CurrentLine
= ToLogicalLineNumber
;
961 /* Flush any hex bytes remaining from the last opcode */
963 LsFlushListingBuffer (FileId
);
965 /* Read lines and write them as long as we are not caught up */
967 if (Gbl_SourceLine
< Gbl_CurrentLine
)
970 * If we just completed writing some AML hex bytes, output a linefeed
971 * to add some whitespace for readability.
973 if (Gbl_HexBytesWereWritten
)
975 FlPrintFile (FileId
, "\n");
976 Gbl_HexBytesWereWritten
= FALSE
;
979 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
981 FlPrintFile (FileId
, " /*\n");
984 /* Write one line at a time until we have reached the target line # */
986 while ((Gbl_SourceLine
< Gbl_CurrentLine
) &&
987 LsWriteOneSourceLine (FileId
))
990 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
992 FlPrintFile (FileId
, " */");
994 FlPrintFile (FileId
, "\n");
999 /*******************************************************************************
1001 * FUNCTION: LsWriteNodeToListing
1003 * PARAMETERS: Op - Parse node to write to the listing file.
1004 * FileId - ID of current listing file
1008 * DESCRIPTION: Write "a node" to the listing file. This means to
1009 * 1) Write out all of the source text associated with the node
1010 * 2) Write out all of the AML bytes associated with the node
1011 * 3) Write any compiler exceptions associated with the node
1013 ******************************************************************************/
1016 LsWriteNodeToListing (
1017 ACPI_PARSE_OBJECT
*Op
,
1020 const ACPI_OPCODE_INFO
*OpInfo
;
1027 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Asl
.AmlOpcode
);
1028 OpClass
= OpInfo
->Class
;
1030 /* TBD: clean this up with a single flag that says:
1031 * I start a named output block
1033 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1035 switch (Op
->Asl
.ParseOpcode
)
1037 case PARSEOP_DEFINITIONBLOCK
:
1038 case PARSEOP_METHODCALL
:
1039 case PARSEOP_INCLUDE
:
1040 case PARSEOP_INCLUDE_END
:
1041 case PARSEOP_DEFAULT_ARG
:
1048 case AML_CLASS_NAMED_OBJECT
:
1049 switch (Op
->Asl
.AmlOpcode
)
1056 if (Op
->Asl
.ExternalName
)
1058 LsFlushListingBuffer (FileId
);
1059 FlPrintFile (FileId
, " };\n");
1066 /* Don't care about other objects */
1073 /* These cases do not have a corresponding AML opcode */
1075 switch (Op
->Asl
.ParseOpcode
)
1077 case PARSEOP_DEFINITIONBLOCK
:
1079 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
, FileId
);
1081 /* Use the table Signature and TableId to build a unique name */
1083 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
1085 FlPrintFile (FileId
,
1086 "%s_%s_Header \\\n",
1087 Gbl_TableSignature
, Gbl_TableId
);
1089 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1091 FlPrintFile (FileId
,
1092 " unsigned char %s_%s_Header [] =\n {\n",
1093 Gbl_TableSignature
, Gbl_TableId
);
1095 if (FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
)
1097 FlPrintFile (FileId
,
1098 "extrn %s_%s_Header : byte\n",
1099 Gbl_TableSignature
, Gbl_TableId
);
1101 if (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
)
1103 FlPrintFile (FileId
,
1104 "extern unsigned char %s_%s_Header [];\n",
1105 Gbl_TableSignature
, Gbl_TableId
);
1110 case PARSEOP_METHODCALL
:
1112 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1117 case PARSEOP_INCLUDE
:
1119 /* Flush everything up to and including the include source line */
1121 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1124 /* Create a new listing node and push it */
1126 LsPushNode (Op
->Asl
.Child
->Asl
.Value
.String
);
1130 case PARSEOP_INCLUDE_END
:
1132 /* Flush out the rest of the include file */
1134 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1137 /* Pop off this listing node and go back to the parent file */
1139 (void) LsPopNode ();
1143 case PARSEOP_DEFAULT_ARG
:
1145 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
)
1147 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.EndLogicalLine
,
1154 /* All other opcodes have an AML opcode */
1159 * Otherwise, we look at the AML opcode because we can
1160 * switch on the opcode type, getting an entire class
1165 case AML_CLASS_ARGUMENT
: /* argument type only */
1166 case AML_CLASS_INTERNAL
:
1171 case AML_CLASS_NAMED_OBJECT
:
1173 switch (Op
->Asl
.AmlOpcode
)
1176 case AML_INDEX_FIELD_OP
:
1177 case AML_BANK_FIELD_OP
:
1180 * For fields, we want to dump all the AML after the
1183 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
,
1189 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
)
1191 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1197 * For fields, we want to dump all the AML after the
1200 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
,
1206 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1211 switch (Op
->Asl
.AmlOpcode
)
1216 /* These opcodes do not declare a new object, ignore them */
1222 /* All other named object opcodes come here */
1226 case ASL_FILE_ASM_SOURCE_OUTPUT
:
1227 case ASL_FILE_C_SOURCE_OUTPUT
:
1228 case ASL_FILE_ASM_INCLUDE_OUTPUT
:
1229 case ASL_FILE_C_INCLUDE_OUTPUT
:
1232 * For named objects, we will create a valid symbol so that the
1233 * AML code can be referenced from C or ASM
1235 if (Op
->Asl
.ExternalName
)
1237 /* Get the full pathname associated with this node */
1239 Pathname
= AcpiNsGetExternalPathname (Op
->Asl
.Node
);
1240 Length
= strlen (Pathname
);
1243 /* Convert all dots in the path to underscores */
1245 for (i
= 0; i
< Length
; i
++)
1247 if (Pathname
[i
] == '.')
1253 /* Create the appropriate symbol in the output file */
1255 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
1257 FlPrintFile (FileId
,
1259 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1261 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1263 FlPrintFile (FileId
,
1264 " unsigned char %s_%s_%s [] =\n {\n",
1265 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1267 if (FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
)
1269 FlPrintFile (FileId
,
1270 "extrn %s_%s_%s : byte\n",
1271 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1273 if (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
)
1275 FlPrintFile (FileId
,
1276 "extern unsigned char %s_%s_%s [];\n",
1277 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1280 ACPI_FREE (Pathname
);
1285 /* Nothing to do for listing file */
1291 case AML_CLASS_EXECUTE
:
1292 case AML_CLASS_CREATE
:
1295 if ((Op
->Asl
.ParseOpcode
== PARSEOP_BUFFER
) &&
1296 (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
))
1301 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1305 case AML_CLASS_UNKNOWN
:
1311 /*******************************************************************************
1313 * FUNCTION: LsDoHexOutput
1319 * DESCRIPTION: Create the hex output file.
1321 ******************************************************************************/
1328 switch (Gbl_HexOutputFlag
)
1335 case HEX_OUTPUT_ASM
:
1337 LsDoHexOutputAsm ();
1341 /* No other output types supported */
1347 /*******************************************************************************
1349 * FUNCTION: LsDoHexOutputC
1355 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1356 * output file, but formatted into hex/ascii bytes suitable for
1357 * inclusion into a C source file.
1359 ******************************************************************************/
1366 UINT8 FileByte
[HEX_TABLE_LINE_SIZE
];
1371 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " * C source code output\n *\n */\n");
1372 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "unsigned char AmlCode[] =\n{\n");
1374 /* Start at the beginning of the AML file */
1376 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
1378 /* Process all AML bytes in the AML file */
1381 while (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
[j
], 1) == AE_OK
)
1385 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " ");
1388 /* Convert each AML byte to hex */
1390 UtConvertByteToHex (FileByte
[j
], Buffer
);
1391 FlWriteFile (ASL_FILE_HEX_OUTPUT
, Buffer
, 4);
1392 FlPrintFile (ASL_FILE_HEX_OUTPUT
, ",");
1394 /* An occasional linefeed improves readability */
1399 if (j
>= HEX_TABLE_LINE_SIZE
)
1401 /* End of line, emit the ascii dump of the entire line */
1403 FlPrintFile (ASL_FILE_HEX_OUTPUT
,
1404 " /* %8.8X", Offset
- HEX_TABLE_LINE_SIZE
);
1406 /* Write the ASCII character associated with each of the bytes */
1408 LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT
,
1409 HEX_TABLE_LINE_SIZE
, FileByte
);
1410 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " */\n");
1412 /* Start new line */
1418 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n};\n");
1419 FlCloseFile (ASL_FILE_HEX_OUTPUT
);
1423 /*******************************************************************************
1425 * FUNCTION: LsDoHexOutputAsm
1431 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1432 * output file, but formatted into hex/ascii bytes suitable for
1433 * inclusion into a ASM source file.
1435 ******************************************************************************/
1442 UINT8 FileByte
[HEX_TABLE_LINE_SIZE
];
1445 BOOLEAN DoComma
= FALSE
;
1448 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "; Assembly code source output\n;\n");
1450 /* Start at the beginning of the AML file */
1452 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
1454 /* Process all AML bytes in the AML file */
1457 while (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
[j
], 1) == AE_OK
)
1461 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " db ");
1465 FlPrintFile (ASL_FILE_HEX_OUTPUT
, ",");
1469 /* Convert each AML byte to hex */
1471 UtConvertByteToAsmHex (FileByte
[j
], Buffer
);
1472 FlWriteFile (ASL_FILE_HEX_OUTPUT
, Buffer
, 4);
1474 /* An occasional linefeed improves readability */
1478 if (j
>= HEX_TABLE_LINE_SIZE
)
1480 FlPrintFile (ASL_FILE_HEX_OUTPUT
,
1481 " ;%8.8X", Offset
- HEX_TABLE_LINE_SIZE
);
1483 /* Write the ASCII character associated with each of the bytes */
1485 LsDumpAscii (ASL_FILE_HEX_OUTPUT
, HEX_TABLE_LINE_SIZE
, FileByte
);
1486 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n");
1495 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n");
1496 FlCloseFile (ASL_FILE_HEX_OUTPUT
);