2 /******************************************************************************
4 * Module Name: asllisting - Listing file generation
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2006, 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")
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: LsTreeWriteWalk
207 * PARAMETERS: ASL_WALK_CALLBACK
212 * DESCRIPTION: Dump entire parse tree, for compiler debug only
214 ******************************************************************************/
218 ACPI_PARSE_OBJECT
*Op
,
225 DbgPrint (ASL_TREE_OUTPUT
,
226 "%5.5d [%2d]", Op
->Asl
.LogicalLineNumber
, Level
);
227 UtPrintFormattedName (Op
->Asl
.ParseOpcode
, Level
);
230 DbgPrint (ASL_TREE_OUTPUT
, "\n");
245 DbgPrint (ASL_TREE_OUTPUT
, "\nOriginal parse tree from parser:\n\n");
246 TrWalkParseTree (RootNode
, ASL_WALK_VISIT_DOWNWARD
,
247 LsTreeWriteWalk
, NULL
, NULL
);
251 /*******************************************************************************
253 * FUNCTION: LsDumpAscii
255 * PARAMETERS: FileId - ID of current listing file
256 * Count - Number of bytes to convert
257 * Buffer - Buffer of bytes to convert
261 * DESCRIPTION: Convert hex bytes to ascii
263 ******************************************************************************/
275 FlPrintFile (FileId
, " \"");
276 for (i
= 0; i
< Count
; i
++)
279 if (isprint (BufChar
))
281 FlPrintFile (FileId
, "%c", BufChar
);
285 /* Not a printable character, just put out a dot */
287 FlPrintFile (FileId
, ".");
290 FlPrintFile (FileId
, "\"");
294 /*******************************************************************************
296 * FUNCTION: LsDumpAsciiInComment
298 * PARAMETERS: FileId - ID of current listing file
299 * Count - Number of bytes to convert
300 * Buffer - Buffer of bytes to convert
304 * DESCRIPTION: Convert hex bytes to ascii
306 ******************************************************************************/
309 LsDumpAsciiInComment (
319 FlPrintFile (FileId
, " \"");
320 for (i
= 0; i
< Count
; i
++)
325 if (isprint (BufChar
))
327 /* Handle embedded C comment sequences */
329 if (((LastChar
== '*') && (BufChar
== '/')) ||
330 ((LastChar
== '/') && (BufChar
== '*')))
332 /* Insert a space to break the sequence */
334 FlPrintFile (FileId
, ".", BufChar
);
337 FlPrintFile (FileId
, "%c", BufChar
);
341 /* Not a printable character, just put out a dot */
343 FlPrintFile (FileId
, ".");
346 FlPrintFile (FileId
, "\"");
350 /*******************************************************************************
352 * FUNCTION: LsAmlListingWalk
354 * PARAMETERS: ASL_WALK_CALLBACK
358 * DESCRIPTION: Process one node during a listing file generation.
360 ******************************************************************************/
364 ACPI_PARSE_OBJECT
*Op
,
370 UINT32 FileId
= (UINT32
) ACPI_TO_INTEGER (Context
);
373 LsWriteNodeToListing (Op
, FileId
);
375 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DATA
)
377 /* Buffer is a resource template, don't dump the data all at once */
382 /* Write the hex bytes to the listing file(s) (if requested) */
384 for (i
= 0; i
< Op
->Asl
.FinalAmlLength
; i
++)
386 if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
, 1)))
388 FlFileError (ASL_FILE_AML_OUTPUT
, ASL_MSG_READ
);
391 LsWriteListingHexBytes (&FileByte
, 1, FileId
);
398 /*******************************************************************************
400 * FUNCTION: LsGenerateListing
402 * PARAMETERS: FileId - ID of listing file
406 * DESCRIPTION: Generate a listing file. This can be one of the several types
407 * of "listings" supported.
409 ******************************************************************************/
416 /* Start at the beginning of both the source and AML files */
418 FlSeekFile (ASL_FILE_SOURCE_OUTPUT
, 0);
419 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
421 Gbl_CurrentHexColumn
= 0;
422 LsPushNode (Gbl_Files
[ASL_FILE_INPUT
].Filename
);
424 /* Process all parse nodes */
426 TrWalkParseTree (RootNode
, ASL_WALK_VISIT_DOWNWARD
, LsAmlListingWalk
,
427 NULL
, (void *) ACPI_TO_POINTER (FileId
));
429 /* Final processing */
431 LsFinishSourceListing (FileId
);
435 /*******************************************************************************
437 * FUNCTION: LsDoListings
443 * DESCRIPTION: Generate all requested listing files.
445 ******************************************************************************/
452 if (Gbl_C_OutputFlag
)
454 LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT
);
459 LsGenerateListing (ASL_FILE_LISTING_OUTPUT
);
462 if (Gbl_AsmOutputFlag
)
464 LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT
);
467 if (Gbl_C_IncludeOutputFlag
)
469 LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT
);
472 if (Gbl_AsmIncludeOutputFlag
)
474 LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT
);
479 /*******************************************************************************
481 * FUNCTION: LsPushNode
483 * PARAMETERS: Filename - Pointer to the include filename
487 * DESCRIPTION: Push a listing node on the listing/include file stack. This
488 * stack enables tracking of include files (infinitely nested)
489 * and resumption of the listing of the parent file when the
490 * include file is finished.
492 ******************************************************************************/
498 ASL_LISTING_NODE
*Lnode
;
501 /* Create a new node */
503 Lnode
= UtLocalCalloc (sizeof (ASL_LISTING_NODE
));
507 Lnode
->Filename
= Filename
;
508 Lnode
->LineNumber
= 0;
512 Lnode
->Next
= Gbl_ListingNode
;
513 Gbl_ListingNode
= Lnode
;
517 /*******************************************************************************
519 * FUNCTION: LsPopNode
523 * RETURN: List head after current head is popped off
525 * DESCRIPTION: Pop the current head of the list, free it, and return the
526 * next node on the stack (the new current node).
528 ******************************************************************************/
530 static ASL_LISTING_NODE
*
534 ASL_LISTING_NODE
*Lnode
;
537 /* Just grab the node at the head of the list */
539 Lnode
= Gbl_ListingNode
;
543 AslError (ASL_ERROR
, ASL_MSG_COMPILER_INTERNAL
, NULL
,
544 "Could not pop empty listing stack");
545 return Gbl_ListingNode
;
548 Gbl_ListingNode
= Lnode
->Next
;
551 /* New "Current" node is the new head */
553 return (Gbl_ListingNode
);
557 /*******************************************************************************
559 * FUNCTION: LsCheckException
561 * PARAMETERS: LineNumber - Current logical (cumulative) line #
562 * FileId - ID of output listing file
566 * DESCRIPTION: Check if there is an exception for this line, and if there is,
567 * put it in the listing immediately. Handles multiple errors
568 * per line. Gbl_NextError points to the next error in the
569 * sorted (by line #) list of compile errors/warnings.
571 ******************************************************************************/
579 if ((!Gbl_NextError
) ||
580 (LineNumber
< Gbl_NextError
->LogicalLineNumber
))
585 /* Handle multiple errors per line */
587 if (FileId
== ASL_FILE_LISTING_OUTPUT
)
589 while (Gbl_NextError
&&
590 (LineNumber
>= Gbl_NextError
->LogicalLineNumber
))
592 AePrintException (FileId
, Gbl_NextError
, "\n[****iasl****]\n");
594 Gbl_NextError
= Gbl_NextError
->Next
;
597 FlPrintFile (FileId
, "\n");
602 /*******************************************************************************
604 * FUNCTION: LsFlushListingBuffer
606 * PARAMETERS: FileId - ID of the listing file
610 * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
611 * buffer. Usually called at the termination of a single line
612 * of source code or when the buffer is full.
614 ******************************************************************************/
617 LsFlushListingBuffer (
623 if (Gbl_CurrentHexColumn
== 0)
628 /* Write the hex bytes */
632 case ASL_FILE_LISTING_OUTPUT
:
634 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
636 FlPrintFile (FileId
, "%2.2X ", Gbl_AmlBuffer
[i
]);
639 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 3); i
++)
641 FlWriteFile (FileId
, ".", 1);
644 /* Write the ASCII character associated with each of the bytes */
646 LsDumpAscii (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
650 case ASL_FILE_ASM_SOURCE_OUTPUT
:
652 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
656 FlPrintFile (FileId
, ",");
658 FlPrintFile (FileId
, "0%2.2Xh", Gbl_AmlBuffer
[i
]);
661 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 5); i
++)
663 FlWriteFile (FileId
, " ", 1);
666 FlPrintFile (FileId
, " ;%8.8X",
667 Gbl_CurrentAmlOffset
- HEX_LISTING_LINE_SIZE
);
669 /* Write the ASCII character associated with each of the bytes */
671 LsDumpAscii (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
675 case ASL_FILE_C_SOURCE_OUTPUT
:
677 for (i
= 0; i
< Gbl_CurrentHexColumn
; i
++)
679 FlPrintFile (FileId
, "0x%2.2X,", Gbl_AmlBuffer
[i
]);
682 for (i
= 0; i
< ((HEX_LISTING_LINE_SIZE
- Gbl_CurrentHexColumn
) * 5); i
++)
684 FlWriteFile (FileId
, " ", 1);
687 FlPrintFile (FileId
, " /* %8.8X",
688 Gbl_CurrentAmlOffset
- HEX_LISTING_LINE_SIZE
);
690 /* Write the ASCII character associated with each of the bytes */
692 LsDumpAsciiInComment (FileId
, Gbl_CurrentHexColumn
, Gbl_AmlBuffer
);
693 FlPrintFile (FileId
, " */");
697 /* No other types supported */
701 FlPrintFile (FileId
, "\n");
703 Gbl_CurrentHexColumn
= 0;
704 Gbl_HexBytesWereWritten
= TRUE
;
708 /*******************************************************************************
710 * FUNCTION: LsWriteListingHexBytes
712 * PARAMETERS: Buffer - AML code buffer
713 * Length - Number of AML bytes to write
714 * FileId - ID of current listing file.
718 * DESCRIPTION: Write the contents of the AML buffer to the listing file via
719 * the listing buffer. The listing buffer is flushed every 16
722 ******************************************************************************/
725 LsWriteListingHexBytes (
733 /* Transfer all requested bytes */
735 for (i
= 0; i
< Length
; i
++)
737 /* Print line header when buffer is empty */
739 if (Gbl_CurrentHexColumn
== 0)
741 if (Gbl_HasIncludeFiles
)
743 FlPrintFile (FileId
, "%*s", 10, " ");
748 case ASL_FILE_LISTING_OUTPUT
:
750 FlPrintFile (FileId
, "%8.8X....", Gbl_CurrentAmlOffset
);
753 case ASL_FILE_ASM_SOURCE_OUTPUT
:
755 FlPrintFile (FileId
, " db ");
758 case ASL_FILE_C_SOURCE_OUTPUT
:
760 FlPrintFile (FileId
, " ");
764 /* No other types supported */
769 /* Transfer AML byte and update counts */
771 Gbl_AmlBuffer
[Gbl_CurrentHexColumn
] = Buffer
[i
];
773 Gbl_CurrentHexColumn
++;
774 Gbl_CurrentAmlOffset
++;
776 /* Flush buffer when it is full */
778 if (Gbl_CurrentHexColumn
>= HEX_LISTING_LINE_SIZE
)
780 LsFlushListingBuffer (FileId
);
786 /*******************************************************************************
788 * FUNCTION: LsWriteOneSourceLine
790 * PARAMETERS: FileID - ID of current listing file
792 * RETURN: FALSE on EOF (input source file), TRUE otherwise
794 * DESCRIPTION: Read one line from the input source file and echo it to the
795 * listing file, prefixed with the line number, and if the source
796 * file contains include files, prefixed with the current filename
798 ******************************************************************************/
801 LsWriteOneSourceLine (
808 Gbl_ListingNode
->LineNumber
++;
810 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
812 FlPrintFile (FileId
, " *");
814 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
816 FlPrintFile (FileId
, "; ");
819 if (Gbl_HasIncludeFiles
)
822 * This file contains "include" statements, print the current
823 * filename and line number within the current file
825 FlPrintFile (FileId
, "%12s %5d....",
826 Gbl_ListingNode
->Filename
, Gbl_ListingNode
->LineNumber
);
830 /* No include files, just print the line number */
832 FlPrintFile (FileId
, "%8d....", Gbl_SourceLine
);
835 /* Read one line (up to a newline or EOF) */
837 while (FlReadFile (ASL_FILE_SOURCE_OUTPUT
, &FileByte
, 1) == AE_OK
)
839 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
847 FlWriteFile (FileId
, &FileByte
, 1);
848 if (FileByte
== '\n')
851 * Check if an error occurred on this source line during the compile.
852 * If so, we print the error message after the source line.
854 LsCheckException (Gbl_SourceLine
, FileId
);
859 /* EOF on the input file was reached */
865 /*******************************************************************************
867 * FUNCTION: LsFinishSourceListing
869 * PARAMETERS: FileId - ID of current listing file.
873 * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
874 * listing buffer, and flush out any remaining lines in the
877 ******************************************************************************/
880 LsFinishSourceListing (
884 if ((FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
) ||
885 (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
))
890 LsFlushListingBuffer (FileId
);
891 Gbl_CurrentAmlOffset
= 0;
893 /* Flush any remaining text in the source file */
895 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
897 FlPrintFile (FileId
, " /*\n");
900 while (LsWriteOneSourceLine (FileId
))
903 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
905 FlPrintFile (FileId
, "\n */\n };\n");
908 FlPrintFile (FileId
, "\n");
910 if (FileId
== ASL_FILE_LISTING_OUTPUT
)
912 /* Print a summary of the compile exceptions */
914 FlPrintFile (FileId
, "\n\nSummary of errors and warnings\n\n");
915 AePrintErrorLog (FileId
);
916 FlPrintFile (FileId
, "\n\n");
917 UtDisplaySummary (FileId
);
918 FlPrintFile (FileId
, "\n\n");
923 /*******************************************************************************
925 * FUNCTION: LsWriteSourceLines
927 * PARAMETERS: ToLineNumber -
928 * ToLogicalLineNumber - Write up to this source line number
929 * FileId - ID of current listing file
933 * DESCRIPTION: Read then write source lines to the listing file until we have
934 * reached the specified logical (cumulative) line number. This
935 * automatically echos out comment blocks and other non-AML
936 * generating text until we get to the actual AML-generating line
937 * of ASL code specified by the logical line number.
939 ******************************************************************************/
944 UINT32 ToLogicalLineNumber
,
948 if ((FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
) ||
949 (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
))
954 Gbl_CurrentLine
= ToLogicalLineNumber
;
956 /* Flush any hex bytes remaining from the last opcode */
958 LsFlushListingBuffer (FileId
);
960 /* Read lines and write them as long as we are not caught up */
962 if (Gbl_SourceLine
< Gbl_CurrentLine
)
965 * If we just completed writing some AML hex bytes, output a linefeed
966 * to add some whitespace for readability.
968 if (Gbl_HexBytesWereWritten
)
970 FlPrintFile (FileId
, "\n");
971 Gbl_HexBytesWereWritten
= FALSE
;
974 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
976 FlPrintFile (FileId
, " /*\n");
979 /* Write one line at a time until we have reached the target line # */
981 while ((Gbl_SourceLine
< Gbl_CurrentLine
) &&
982 LsWriteOneSourceLine (FileId
))
985 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
987 FlPrintFile (FileId
, " */");
989 FlPrintFile (FileId
, "\n");
994 /*******************************************************************************
996 * FUNCTION: LsWriteNodeToListing
998 * PARAMETERS: Op - Parse node to write to the listing file.
999 * FileId - ID of current listing file
1003 * DESCRIPTION: Write "a node" to the listing file. This means to
1004 * 1) Write out all of the source text associated with the node
1005 * 2) Write out all of the AML bytes associated with the node
1006 * 3) Write any compiler exceptions associated with the node
1008 ******************************************************************************/
1011 LsWriteNodeToListing (
1012 ACPI_PARSE_OBJECT
*Op
,
1015 const ACPI_OPCODE_INFO
*OpInfo
;
1022 OpInfo
= AcpiPsGetOpcodeInfo (Op
->Asl
.AmlOpcode
);
1023 OpClass
= OpInfo
->Class
;
1025 /* TBD: clean this up with a single flag that says:
1026 * I start a named output block
1028 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1030 switch (Op
->Asl
.ParseOpcode
)
1032 case PARSEOP_DEFINITIONBLOCK
:
1033 case PARSEOP_METHODCALL
:
1034 case PARSEOP_INCLUDE
:
1035 case PARSEOP_INCLUDE_END
:
1036 case PARSEOP_DEFAULT_ARG
:
1043 case AML_CLASS_NAMED_OBJECT
:
1044 switch (Op
->Asl
.AmlOpcode
)
1051 if (Op
->Asl
.ExternalName
)
1053 LsFlushListingBuffer (FileId
);
1054 FlPrintFile (FileId
, " };\n");
1061 /* Don't care about other objects */
1068 /* These cases do not have a corresponding AML opcode */
1070 switch (Op
->Asl
.ParseOpcode
)
1072 case PARSEOP_DEFINITIONBLOCK
:
1074 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
, FileId
);
1076 /* Use the table Signature and TableId to build a unique name */
1078 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
1080 FlPrintFile (FileId
,
1081 "%s_%s_Header \\\n",
1082 Gbl_TableSignature
, Gbl_TableId
);
1084 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1086 FlPrintFile (FileId
,
1087 " unsigned char %s_%s_Header [] =\n {\n",
1088 Gbl_TableSignature
, Gbl_TableId
);
1090 if (FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
)
1092 FlPrintFile (FileId
,
1093 "extrn %s_%s_Header : byte\n",
1094 Gbl_TableSignature
, Gbl_TableId
);
1096 if (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
)
1098 FlPrintFile (FileId
,
1099 "extern unsigned char %s_%s_Header [];\n",
1100 Gbl_TableSignature
, Gbl_TableId
);
1105 case PARSEOP_METHODCALL
:
1107 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1112 case PARSEOP_INCLUDE
:
1114 /* Flush everything up to and including the include source line */
1116 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1119 /* Create a new listing node and push it */
1121 LsPushNode (Op
->Asl
.Child
->Asl
.Value
.String
);
1125 case PARSEOP_INCLUDE_END
:
1127 /* Flush out the rest of the include file */
1129 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1132 /* Pop off this listing node and go back to the parent file */
1134 (void) LsPopNode ();
1138 case PARSEOP_DEFAULT_ARG
:
1140 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
)
1142 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.EndLogicalLine
,
1149 /* All other opcodes have an AML opcode */
1154 * Otherwise, we look at the AML opcode because we can
1155 * switch on the opcode type, getting an entire class
1160 case AML_CLASS_ARGUMENT
: /* argument type only */
1161 case AML_CLASS_INTERNAL
:
1166 case AML_CLASS_NAMED_OBJECT
:
1168 switch (Op
->Asl
.AmlOpcode
)
1171 case AML_INDEX_FIELD_OP
:
1172 case AML_BANK_FIELD_OP
:
1175 * For fields, we want to dump all the AML after the
1178 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
,
1184 if (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
)
1186 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1192 * For fields, we want to dump all the AML after the
1195 LsWriteSourceLines (Op
->Asl
.EndLine
, Op
->Asl
.EndLogicalLine
,
1201 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1206 switch (Op
->Asl
.AmlOpcode
)
1211 /* These opcodes do not declare a new object, ignore them */
1217 /* All other named object opcodes come here */
1221 case ASL_FILE_ASM_SOURCE_OUTPUT
:
1222 case ASL_FILE_C_SOURCE_OUTPUT
:
1223 case ASL_FILE_ASM_INCLUDE_OUTPUT
:
1224 case ASL_FILE_C_INCLUDE_OUTPUT
:
1227 * For named objects, we will create a valid symbol so that the
1228 * AML code can be referenced from C or ASM
1230 if (Op
->Asl
.ExternalName
)
1232 /* Get the full pathname associated with this node */
1234 Pathname
= AcpiNsGetExternalPathname (Op
->Asl
.Node
);
1235 Length
= strlen (Pathname
);
1238 /* Convert all dots in the path to underscores */
1240 for (i
= 0; i
< Length
; i
++)
1242 if (Pathname
[i
] == '.')
1248 /* Create the appropriate symbol in the output file */
1250 if (FileId
== ASL_FILE_ASM_SOURCE_OUTPUT
)
1252 FlPrintFile (FileId
,
1254 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1256 if (FileId
== ASL_FILE_C_SOURCE_OUTPUT
)
1258 FlPrintFile (FileId
,
1259 " unsigned char %s_%s_%s [] =\n {\n",
1260 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1262 if (FileId
== ASL_FILE_ASM_INCLUDE_OUTPUT
)
1264 FlPrintFile (FileId
,
1265 "extrn %s_%s_%s : byte\n",
1266 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1268 if (FileId
== ASL_FILE_C_INCLUDE_OUTPUT
)
1270 FlPrintFile (FileId
,
1271 "extern unsigned char %s_%s_%s [];\n",
1272 Gbl_TableSignature
, Gbl_TableId
, &Pathname
[1]);
1275 ACPI_FREE (Pathname
);
1280 /* Nothing to do for listing file */
1286 case AML_CLASS_EXECUTE
:
1287 case AML_CLASS_CREATE
:
1290 if ((Op
->Asl
.ParseOpcode
== PARSEOP_BUFFER
) &&
1291 (Op
->Asl
.CompileFlags
& NODE_IS_RESOURCE_DESC
))
1296 LsWriteSourceLines (Op
->Asl
.LineNumber
, Op
->Asl
.LogicalLineNumber
,
1300 case AML_CLASS_UNKNOWN
:
1306 /*******************************************************************************
1308 * FUNCTION: LsDoHexOutput
1314 * DESCRIPTION: Create the hex output file.
1316 ******************************************************************************/
1323 switch (Gbl_HexOutputFlag
)
1330 case HEX_OUTPUT_ASM
:
1332 LsDoHexOutputAsm ();
1336 /* No other output types supported */
1342 /*******************************************************************************
1344 * FUNCTION: LsDoHexOutputC
1350 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1351 * output file, but formatted into hex/ascii bytes suitable for
1352 * inclusion into a C source file.
1354 ******************************************************************************/
1361 UINT8 FileByte
[HEX_TABLE_LINE_SIZE
];
1366 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " * C source code output\n *\n */\n");
1367 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "unsigned char AmlCode[] =\n{\n");
1369 /* Start at the beginning of the AML file */
1371 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
1373 /* Process all AML bytes in the AML file */
1376 while (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
[j
], 1) == AE_OK
)
1380 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " ");
1383 /* Convert each AML byte to hex */
1385 UtConvertByteToHex (FileByte
[j
], Buffer
);
1386 FlWriteFile (ASL_FILE_HEX_OUTPUT
, Buffer
, 4);
1387 FlPrintFile (ASL_FILE_HEX_OUTPUT
, ",");
1389 /* An occasional linefeed improves readability */
1394 if (j
>= HEX_TABLE_LINE_SIZE
)
1396 /* End of line, emit the ascii dump of the entire line */
1398 FlPrintFile (ASL_FILE_HEX_OUTPUT
,
1399 " /* %8.8X", Offset
- HEX_TABLE_LINE_SIZE
);
1401 /* Write the ASCII character associated with each of the bytes */
1403 LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT
,
1404 HEX_TABLE_LINE_SIZE
, FileByte
);
1405 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " */\n");
1407 /* Start new line */
1413 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n};\n");
1414 FlCloseFile (ASL_FILE_HEX_OUTPUT
);
1418 /*******************************************************************************
1420 * FUNCTION: LsDoHexOutputAsm
1426 * DESCRIPTION: Create the hex output file. This is the same data as the AML
1427 * output file, but formatted into hex/ascii bytes suitable for
1428 * inclusion into a ASM source file.
1430 ******************************************************************************/
1437 UINT8 FileByte
[HEX_TABLE_LINE_SIZE
];
1440 BOOLEAN DoComma
= FALSE
;
1443 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "; Assembly code source output\n;\n");
1445 /* Start at the beginning of the AML file */
1447 FlSeekFile (ASL_FILE_AML_OUTPUT
, 0);
1449 /* Process all AML bytes in the AML file */
1452 while (FlReadFile (ASL_FILE_AML_OUTPUT
, &FileByte
[j
], 1) == AE_OK
)
1456 FlPrintFile (ASL_FILE_HEX_OUTPUT
, " db ");
1460 FlPrintFile (ASL_FILE_HEX_OUTPUT
, ",");
1464 /* Convert each AML byte to hex */
1466 UtConvertByteToAsmHex (FileByte
[j
], Buffer
);
1467 FlWriteFile (ASL_FILE_HEX_OUTPUT
, Buffer
, 4);
1469 /* An occasional linefeed improves readability */
1473 if (j
>= HEX_TABLE_LINE_SIZE
)
1475 FlPrintFile (ASL_FILE_HEX_OUTPUT
,
1476 " ;%8.8X", Offset
- HEX_TABLE_LINE_SIZE
);
1478 /* Write the ASCII character associated with each of the bytes */
1480 LsDumpAscii (ASL_FILE_HEX_OUTPUT
, HEX_TABLE_LINE_SIZE
, FileByte
);
1481 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n");
1490 FlPrintFile (ASL_FILE_HEX_OUTPUT
, "\n");
1491 FlCloseFile (ASL_FILE_HEX_OUTPUT
);