2 /******************************************************************************
4 * Module Name: aslcompiler.h - common include file
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 #ifndef __ASLCOMPILER_H
120 #define __ASLCOMPILER_H
123 /* Microsoft-specific */
125 #if (defined WIN32 || defined WIN64)
127 /* warn : used #pragma pack */
128 #pragma warning(disable:4103)
130 /* warn : named type definition in parentheses */
131 #pragma warning(disable:4115)
143 #include "amlresrc.h"
145 #include "asltypes.h"
146 #include "aslglobal.h"
150 * Compiler versions and names
153 #define CompilerCreatorRevision ACPI_CA_VERSION
155 #define IntelAcpiCA "Intel ACPI Component Architecture"
156 #define CompilerId "ASL Optimizing Compiler / AML Disassembler"
157 #define CompilerCopyright "Copyright (C) 2000 - 2005 Intel Corporation"
158 #define CompilerCompliance "ACPI 3.0"
159 #define CompilerName "iasl"
160 #define CompilerCreatorId "INTL"
163 /* Configuration constants */
165 #define ASL_MAX_ERROR_COUNT 200
166 #define ASL_NODE_CACHE_SIZE 1024
167 #define ASL_STRING_CACHE_SIZE 32768
169 #define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS
170 #define ASL_YYTNAME_START 3
176 #define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (ASL_RESOURCE_DESC, m)
177 #define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a))
178 #define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b)))
179 #define ASL_GET_CHILD_NODE(a) (a)->Asl.Child
180 #define ASL_GET_PEER_NODE(a) (a)->Asl.Next
181 #define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c}
184 #define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */
187 /* Internal AML opcodes */
189 #define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */
190 #define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */
191 #define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */
192 #define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */
193 #define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */
194 #define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */
195 #define AML_PACKAGE_LENGTH (UINT16) 0xAA10
196 #define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE
197 #define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD
200 /* filename suffixes for output files */
202 #define FILE_SUFFIX_AML_CODE "aml"
203 #define FILE_SUFFIX_LISTING "lst"
204 #define FILE_SUFFIX_HEX_DUMP "hex"
205 #define FILE_SUFFIX_DEBUG "txt"
206 #define FILE_SUFFIX_SOURCE "src"
207 #define FILE_SUFFIX_NAMESPACE "nsp"
208 #define FILE_SUFFIX_ASM_SOURCE "asm"
209 #define FILE_SUFFIX_C_SOURCE "c"
210 #define FILE_SUFFIX_DISASSEMBLY "dsl"
211 #define FILE_SUFFIX_ASM_INCLUDE "inc"
212 #define FILE_SUFFIX_C_INCLUDE "h"
217 #define ASL_EXTERNAL_METHOD 255
218 #define ASL_ABORT TRUE
219 #define ASL_NO_ABORT FALSE
222 /*******************************************************************************
224 * Compiler prototypes
226 ******************************************************************************/
252 ResetCurrentLineBuffer (
260 AslPopInputFileStack (
264 AslPushInputFileStack (
275 AslCompilerFileHeader (
279 AslDoSourceOutputFile (
282 #define ASL_DEBUG_OUTPUT 0
283 #define ASL_PARSE_OUTPUT 1
284 #define ASL_TREE_OUTPUT 2
302 CmDoOutputFiles (void);
305 CmCleanupAndExit (void);
314 ACPI_PARSE_OBJECT
*Op
,
318 AslCoreSubsystemError (
319 ACPI_PARSE_OBJECT
*Op
,
328 UINT32 CurrentLineNumber
,
329 UINT32 LogicalLineNumber
,
330 UINT32 LogicalByteOffset
,
338 ASL_ERROR_MSG
*Enode
,
346 AeLocalGetRootPointer (
348 ACPI_PHYSICAL_ADDRESS
*RsdpPhysicalAddress
);
354 LsWriteListingHexBytes (
360 LsWriteNodeToListing (
361 ACPI_PARSE_OBJECT
*Op
,
365 LsWriteNodeToAsmListing (
366 ACPI_PARSE_OBJECT
*Op
);
370 ACPI_PARSE_OBJECT
*Op
,
374 LsFinishSourceListing (
378 LsFlushListingBuffer (
403 * aslopcodes - generate AML opcodes
408 ACPI_PARSE_OBJECT
*Op
,
414 ACPI_PARSE_OBJECT
*Op
,
419 OpcGenerateAmlOpcode (
420 ACPI_PARSE_OBJECT
*Op
);
423 OpcSetOptimalIntegerSize (
424 ACPI_PARSE_OBJECT
*Op
);
428 ACPI_PARSE_OBJECT
*Op
);
431 * asloperands - generate AML operands for the AML opcodes
435 OpnGenerateAmlOperands (
436 ACPI_PARSE_OBJECT
*Op
);
440 ACPI_PARSE_OBJECT
*Op
);
444 ACPI_PARSE_OBJECT
*Op
);
448 ACPI_PARSE_OBJECT
*Op
);
451 OpnDoDefinitionBlock (
452 ACPI_PARSE_OBJECT
*Op
);
456 ACPI_PARSE_OBJECT
*FieldOp
,
457 ACPI_PARSE_OBJECT
*Op
);
461 ACPI_PARSE_OBJECT
*Op
);
465 ACPI_PARSE_OBJECT
*Op
);
469 ACPI_PARSE_OBJECT
*Op
);
473 ACPI_PARSE_OBJECT
*Op
);
477 ACPI_PARSE_OBJECT
*Op
);
480 * aslopt - optmization
484 OptOptimizeNamePath (
485 ACPI_PARSE_OBJECT
*Op
,
487 ACPI_WALK_STATE
*WalkState
,
489 ACPI_NAMESPACE_NODE
*TargetNode
);
493 * aslresource - resource template generation
497 RsDoResourceTemplate (
498 ACPI_PARSE_OBJECT
*Op
);
502 CgGenerateAmlOutput (void);
512 CgGenerateAmlLengths (
513 ACPI_PARSE_OBJECT
*Op
);
517 char *InputFilename
);
523 LnPackageLengthWalk (
524 ACPI_PARSE_OBJECT
*Op
,
530 ACPI_PARSE_OBJECT
*Op
,
537 ACPI_PARSE_OBJECT
*Op
,
551 ACPI_PARSE_OBJECT
*Op
);
558 AslMapNamedOpcodeToDataType (
562 * asltransform - parse tree transformations
567 ACPI_PARSE_OBJECT
*Op
,
574 ACPI_PARSE_OBJECT
*Op
);
578 ACPI_PARSE_OBJECT
*Op
);
581 TrDoDefinitionBlock (
582 ACPI_PARSE_OBJECT
*Op
);
585 * asltree - parse tree support
590 ACPI_PARSE_OBJECT
*Op
,
592 ASL_WALK_CALLBACK DescendingCallback
,
593 ASL_WALK_CALLBACK AscendingCallback
,
601 /* Values for "Visitation" parameter above */
603 #define ASL_WALK_VISIT_DOWNWARD 0x01
604 #define ASL_WALK_VISIT_UPWARD 0x02
605 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
615 ACPI_PARSE_OBJECT
*Op
);
628 TrCreateValuedLeafNode (
634 ACPI_PARSE_OBJECT
*Op
,
640 ACPI_PARSE_OBJECT
*Op
);
647 ACPI_PARSE_OBJECT
*Op1
,
648 ACPI_PARSE_OBJECT
*Op2
);
652 ACPI_PARSE_OBJECT
*Op1
,
653 ACPI_PARSE_OBJECT
*Op2
);
657 ACPI_PARSE_OBJECT
*Op
,
667 ACPI_PARSE_OBJECT
*Op
);
672 AnOtherSemanticAnalysisWalkBegin (
673 ACPI_PARSE_OBJECT
*Op
,
678 AnOtherSemanticAnalysisWalkEnd (
679 ACPI_PARSE_OBJECT
*Op
,
684 AnOperandTypecheckWalkBegin (
685 ACPI_PARSE_OBJECT
*Op
,
690 AnOperandTypecheckWalkEnd (
691 ACPI_PARSE_OBJECT
*Op
,
696 AnMethodAnalysisWalkBegin (
697 ACPI_PARSE_OBJECT
*Op
,
702 AnMethodAnalysisWalkEnd (
703 ACPI_PARSE_OBJECT
*Op
,
708 AnMethodTypingWalkBegin (
709 ACPI_PARSE_OBJECT
*Op
,
714 AnMethodTypingWalkEnd (
715 ACPI_PARSE_OBJECT
*Op
,
721 * aslfiles - File I/O support
734 ACPI_PARSE_OBJECT
*Op
);
776 ACPI_PARSE_OBJECT
*Op
);
779 FlParseInputPathname (
780 char *InputFilename
);
784 char *InputFilename
);
787 FlOpenAmlOutputFile (
788 char *InputFilename
);
791 FlOpenMiscOutputFiles (
792 char *InputFilename
);
795 MpDisplayReservedNames (
803 ACPI_PARSE_OBJECT
*RootOp
);
808 ACPI_PARSE_OBJECT
*Op
,
814 ACPI_PARSE_OBJECT
*Op
,
822 LkCrossReferenceNamespace (void);
825 LkNamespaceLocateBegin (
826 ACPI_PARSE_OBJECT
*Op
,
831 LkNamespaceLocateEnd (
832 ACPI_PARSE_OBJECT
*Op
,
841 LsCompareOneNamespaceObject (
842 ACPI_HANDLE ObjHandle
,
851 UtDisplayConstantOpcodes (
868 UtPrintFormattedName (
886 UtConvertByteToAsmHex (
896 ACPI_PARSE_OBJECT
*Op
);
900 ACPI_PARSE_OBJECT
*Op
,
910 char **ConvertedName
);
913 UtAttachNamepathToOwner (
914 ACPI_PARSE_OBJECT
*Op
,
915 ACPI_PARSE_OBJECT
*NameNode
);
918 UtCheckIntegerRange (
919 ACPI_PARSE_OBJECT
*Op
,
927 ACPI_INTEGER
*RetInteger
);
937 LnAdjustLengthToRoot (
938 ACPI_PARSE_OBJECT
*Op
,
942 #define NEXT_RESOURCE_DESC(a,b) (ASL_RESOURCE_DESC *) (((char *) (a)) + sizeof(b))
944 #define DEFAULT_RESOURCE_DESC_SIZE (sizeof (ASL_RESOURCE_DESC) + sizeof (ASL_END_TAG_DESC))
952 RsAllocateResourceNode (
957 ACPI_PARSE_OBJECT
*Op
,
964 ACPI_PARSE_OBJECT
*Op
,
971 ACPI_PARSE_OBJECT
*Op
,
976 RsCompleteNodeAndGetNext (
977 ACPI_PARSE_OBJECT
*Op
);
980 RsDoOneResourceDescriptor (
981 ACPI_PARSE_OBJECT
*DescriptorTypeOp
,
982 UINT32 CurrentByteOffset
,
985 #define ACPI_RSTATE_NORMAL 0
986 #define ACPI_RSTATE_START_DEPENDENT 1
987 #define ACPI_RSTATE_DEPENDENT_LIST 2
990 RsLinkDescriptorChain (
991 ASL_RESOURCE_NODE
**PreviousRnode
,
992 ASL_RESOURCE_NODE
*Rnode
);
1001 ACPI_PARSE_OBJECT
*Op
,
1002 UINT32 CurrentByteOffset
);
1005 RsDoEndDependentDescriptor (
1006 ACPI_PARSE_OBJECT
*Op
,
1007 UINT32 CurrentByteOffset
);
1010 RsDoFixedIoDescriptor (
1011 ACPI_PARSE_OBJECT
*Op
,
1012 UINT32 CurrentByteOffset
);
1015 RsDoInterruptDescriptor (
1016 ACPI_PARSE_OBJECT
*Op
,
1017 UINT32 CurrentByteOffset
);
1021 ACPI_PARSE_OBJECT
*Op
,
1022 UINT32 CurrentByteOffset
);
1026 ACPI_PARSE_OBJECT
*Op
,
1027 UINT32 CurrentByteOffset
);
1030 RsDoIrqNoFlagsDescriptor (
1031 ACPI_PARSE_OBJECT
*Op
,
1032 UINT32 CurrentByteOffset
);
1035 RsDoMemory24Descriptor (
1036 ACPI_PARSE_OBJECT
*Op
,
1037 UINT32 CurrentByteOffset
);
1040 RsDoMemory32Descriptor (
1041 ACPI_PARSE_OBJECT
*Op
,
1042 UINT32 CurrentByteOffset
);
1045 RsDoMemory32FixedDescriptor (
1046 ACPI_PARSE_OBJECT
*Op
,
1047 UINT32 CurrentByteOffset
);
1050 RsDoStartDependentDescriptor (
1051 ACPI_PARSE_OBJECT
*Op
,
1052 UINT32 CurrentByteOffset
);
1055 RsDoStartDependentNoPriDescriptor (
1056 ACPI_PARSE_OBJECT
*Op
,
1057 UINT32 CurrentByteOffset
);
1060 RsDoVendorSmallDescriptor (
1061 ACPI_PARSE_OBJECT
*Op
,
1062 UINT32 CurrentByteOffset
);
1070 RsGetStringDataLength (
1071 ACPI_PARSE_OBJECT
*InitializerOp
);
1074 RsDoDwordIoDescriptor (
1075 ACPI_PARSE_OBJECT
*Op
,
1076 UINT32 CurrentByteOffset
);
1079 RsDoDwordMemoryDescriptor (
1080 ACPI_PARSE_OBJECT
*Op
,
1081 UINT32 CurrentByteOffset
);
1084 RsDoDwordSpaceDescriptor (
1085 ACPI_PARSE_OBJECT
*Op
,
1086 UINT32 CurrentByteOffset
);
1089 RsDoExtendedIoDescriptor (
1090 ACPI_PARSE_OBJECT
*Op
,
1091 UINT32 CurrentByteOffset
);
1094 RsDoExtendedMemoryDescriptor (
1095 ACPI_PARSE_OBJECT
*Op
,
1096 UINT32 CurrentByteOffset
);
1099 RsDoExtendedSpaceDescriptor (
1100 ACPI_PARSE_OBJECT
*Op
,
1101 UINT32 CurrentByteOffset
);
1104 RsDoQwordIoDescriptor (
1105 ACPI_PARSE_OBJECT
*Op
,
1106 UINT32 CurrentByteOffset
);
1109 RsDoQwordMemoryDescriptor (
1110 ACPI_PARSE_OBJECT
*Op
,
1111 UINT32 CurrentByteOffset
);
1114 RsDoQwordSpaceDescriptor (
1115 ACPI_PARSE_OBJECT
*Op
,
1116 UINT32 CurrentByteOffset
);
1119 RsDoWordIoDescriptor (
1120 ACPI_PARSE_OBJECT
*Op
,
1121 UINT32 CurrentByteOffset
);
1124 RsDoWordSpaceDescriptor (
1125 ACPI_PARSE_OBJECT
*Op
,
1126 UINT32 CurrentByteOffset
);
1129 RsDoWordBusNumberDescriptor (
1130 ACPI_PARSE_OBJECT
*Op
,
1131 UINT32 CurrentByteOffset
);
1134 RsDoVendorLargeDescriptor (
1135 ACPI_PARSE_OBJECT
*Op
,
1136 UINT32 CurrentByteOffset
);
1139 RsDoGeneralRegisterDescriptor (
1140 ACPI_PARSE_OBJECT
*Op
,
1141 UINT32 CurrentByteOffset
);
1144 #endif /* __ASLCOMPILER_H */