1 /******************************************************************************
3 * Module Name: aslcompiler.h - common include file for iASL
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
116 #ifndef __ASLCOMPILER_H
117 #define __ASLCOMPILER_H
120 #include "accommon.h"
121 #include "amlresrc.h"
124 /* Microsoft-specific */
126 #if (defined WIN32 || defined WIN64)
128 /* warn : used #pragma pack */
129 #pragma warning(disable:4103)
131 /* warn : named type definition in parentheses */
132 #pragma warning(disable:4115)
142 /* Compiler headers */
144 #include "asldefine.h"
145 #include "asltypes.h"
146 #include "aslmessages.h"
147 #include "aslglobal.h"
148 #include "preprocess.h"
151 /*******************************************************************************
153 * Compiler prototypes
155 ******************************************************************************/
158 * Main ASL parser - generated from flex/bison, lex/yacc, etc.
169 AslResetCurrentLineBuffer (
173 AslInsertLineBuffer (
177 AslPopInputFileStack (
181 AslPushInputFileStack (
191 * aslstartup - entered from main()
194 AslInitializeGlobals (
198 ACPI_STATUS (*ASL_PATHNAME_CALLBACK) (
206 AslCheckForErrorExit (
211 * aslcompile - compile mainline
218 AslCompilerFileHeader (
239 * aslascii - ascii support
242 FlCheckForAcpiTable (
248 BOOLEAN DisplayErrors);
252 * aslwalks - semantic analysis and parse tree walks
255 AnOtherSemanticAnalysisWalkBegin (
256 ACPI_PARSE_OBJECT *Op,
261 AnOtherSemanticAnalysisWalkEnd (
262 ACPI_PARSE_OBJECT *Op,
267 AnOperandTypecheckWalkEnd (
268 ACPI_PARSE_OBJECT *Op,
273 AnMethodTypingWalkEnd (
274 ACPI_PARSE_OBJECT *Op,
280 * aslmethod - Control method analysis walk
283 MtMethodAnalysisWalkBegin (
284 ACPI_PARSE_OBJECT *Op,
289 MtMethodAnalysisWalkEnd (
290 ACPI_PARSE_OBJECT *Op,
296 * aslbtypes - bitfield data types
299 AnMapObjTypeToBtype (
300 ACPI_PARSE_OBJECT *Op);
303 AnMapArgTypeToBtype (
308 ACPI_PARSE_OBJECT *Op);
317 * aslanalyze - Support functions for parse tree walks
321 ACPI_PARSE_OBJECT *Op,
324 /* Values for Type argument above */
326 #define ASL_TYPE_HID 0
327 #define ASL_TYPE_CID 1
331 ACPI_PARSE_OBJECT *Op);
334 AnGetInternalMethodReturnType (
335 ACPI_PARSE_OBJECT *Op);
338 AnLastStatementIsReturn (
339 ACPI_PARSE_OBJECT *Op);
342 AnCheckMethodReturnValue (
343 ACPI_PARSE_OBJECT *Op,
344 const ACPI_OPCODE_INFO *OpInfo,
345 ACPI_PARSE_OBJECT *ArgOp,
346 UINT32 RequiredBtypes,
347 UINT32 ThisNodeBtype);
351 ACPI_PARSE_OBJECT *Op);
354 ApCheckForGpeNameConflict (
355 ACPI_PARSE_OBJECT *Op);
359 ACPI_PARSE_OBJECT *Op);
364 ACPI_PARSE_OBJECT *Op);
368 * aslerror - error handling/reporting
378 ACPI_PARSE_OBJECT *Op,
382 AslDisableException (
383 char *MessageIdString);
386 AslIsExceptionDisabled (
391 AslCoreSubsystemError (
392 ACPI_PARSE_OBJECT *Op,
405 UINT32 CurrentLineNumber,
406 UINT32 LogicalLineNumber,
407 UINT32 LogicalByteOffset,
425 ASL_ERROR_MSG *Enode,
438 * asllisting - generate all "listing" type files
445 LsWriteNodeToAsmListing (
446 ACPI_PARSE_OBJECT *Op);
450 ACPI_PARSE_OBJECT *Op,
459 * asllistsup - Listing file support utilities
468 LsDumpAsciiInComment (
479 LsFlushListingBuffer (
483 LsWriteListingHexBytes (
491 UINT32 ToLogicalLineNumber,
495 LsWriteOneSourceLine (
508 * aslhex - generate all "hex" output files (C, ASM, ASL)
516 * aslfold - constant folding
520 ACPI_PARSE_OBJECT *Op,
526 * aslmessages - exception strings
533 AeDecodeExceptionLevel (
537 AeBuildFullExceptionCode (
542 * asloffset - generate C offset file for BIOS support
546 ACPI_PARSE_OBJECT *Op,
551 LsDoOffsetTableHeader (
555 LsDoOffsetTableFooter (
560 * aslopcodes - generate AML opcodes
564 ACPI_PARSE_OBJECT *Op,
569 OpcAmlOpcodeUpdateWalk (
570 ACPI_PARSE_OBJECT *Op,
575 OpcGenerateAmlOpcode (
576 ACPI_PARSE_OBJECT *Op);
579 OpcSetOptimalIntegerSize (
580 ACPI_PARSE_OBJECT *Op);
584 ACPI_PARSE_OBJECT *Op);
588 * asloperands - generate AML operands for the AML opcodes
592 ACPI_PARSE_OBJECT *Op,
596 OpnGenerateAmlOperands (
597 ACPI_PARSE_OBJECT *Op);
601 ACPI_PARSE_OBJECT *Op);
605 * aslopt - optmization
608 OptOptimizeNamePath (
609 ACPI_PARSE_OBJECT *Op,
611 ACPI_WALK_STATE *WalkState,
613 ACPI_NAMESPACE_NODE *TargetNode);
617 * aslprintf - Printf/Fprintf macros
621 ACPI_PARSE_OBJECT *Op);
625 ACPI_PARSE_OBJECT *Op);
629 * aslprune - parse tree pruner
638 * aslcodegen - code generation
641 CgGenerateAmlOutput (
656 * asllength - calculate/adjust AML package lengths
659 LnPackageLengthWalk (
660 ACPI_PARSE_OBJECT *Op,
666 ACPI_PARSE_OBJECT *Op,
671 CgGenerateAmlLengths (
672 ACPI_PARSE_OBJECT *Op);
676 * aslmap - opcode mappings and reserved method names
679 AslMapNamedOpcodeToDataType (
684 * aslpredef - ACPI predefined names support
687 ApCheckForPredefinedMethod (
688 ACPI_PARSE_OBJECT *Op,
689 ASL_METHOD_INFO *MethodInfo);
692 ApCheckPredefinedReturnValue (
693 ACPI_PARSE_OBJECT *Op,
694 ASL_METHOD_INFO *MethodInfo);
697 ApCheckForPredefinedName (
698 ACPI_PARSE_OBJECT *Op,
702 ApCheckForPredefinedObject (
703 ACPI_PARSE_OBJECT *Op,
708 const char *PredefinedName,
709 ACPI_PARSE_OBJECT *Op,
710 UINT32 ExpectedBtypes,
711 UINT32 PackageIndex);
714 ApDisplayReservedNames (
719 * aslprepkg - ACPI predefined names support for packages
723 ACPI_PARSE_OBJECT *ParentOp,
724 const ACPI_PREDEFINED_INFO *Predefined);
728 * asltransform - parse tree transformations
732 ACPI_PARSE_OBJECT *Op,
738 * asltree - parse tree support
742 ACPI_PARSE_OBJECT *Op,
744 ASL_WALK_CALLBACK DescendingCallback,
745 ASL_WALK_CALLBACK AscendingCallback,
748 /* Values for "Visitation" parameter above */
750 #define ASL_WALK_VISIT_DOWNWARD 0x01
751 #define ASL_WALK_VISIT_UPWARD 0x02
752 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
760 TrPrintNodeCompileFlags (
765 ACPI_PARSE_OBJECT *Op);
770 ACPI_PARSE_OBJECT *Op);
787 TrCreateAssignmentNode (
788 ACPI_PARSE_OBJECT *Target,
789 ACPI_PARSE_OBJECT *Source);
792 TrCreateTargetOperand (
793 ACPI_PARSE_OBJECT *OriginalOp,
794 ACPI_PARSE_OBJECT *ParentOp);
797 TrCreateValuedLeafNode (
802 TrCreateConstantLeafNode (
807 ACPI_PARSE_OBJECT *Op,
813 ACPI_PARSE_OBJECT *Op);
821 ACPI_PARSE_OBJECT *Op1,
822 ACPI_PARSE_OBJECT *Op2);
826 ACPI_PARSE_OBJECT *Op1,
827 ACPI_PARSE_OBJECT *Op2);
831 ACPI_PARSE_OBJECT *Op,
836 ACPI_PARSE_OBJECT *Op,
846 * aslfiles - File I/O support
849 FlAddIncludeDirectory (
859 ACPI_PARSE_OBJECT *Op);
911 char *InputFilename);
914 FlOpenAmlOutputFile (
915 char *InputFilename);
918 FlOpenMiscOutputFiles (
919 char *InputFilename);
922 * aslhwmap - hardware map summary
930 * asload - load namespace in prep for cross reference
934 ACPI_PARSE_OBJECT *RootOp);
938 * asllookup - namespace lookup functions
941 LkFindUnreferencedObjects (
957 * aslnamesp - namespace output file generation
964 NsSetupNamespaceListing (
968 * asloptions - command line processing
976 * aslxref - namespace cross reference
979 XfCrossReferenceNamespace (
984 * aslutils - common compiler utilites
992 /* Type values for above */
994 #define ASL_DEBUG_OUTPUT 0
995 #define ASL_PARSE_OUTPUT 1
996 #define ASL_TREE_OUTPUT 2
999 UtDisplaySupportedTables (
1003 UtDisplayConstantOpcodes (
1019 UtPrintFormattedName (
1028 UtConvertByteToHex (
1033 UtConvertByteToAsmHex (
1039 UINT32 ParseOpcode);
1043 ACPI_PARSE_OBJECT *Op);
1046 UtStringCacheCalloc (
1050 UtExpandLineBuffers (
1060 char **ConvertedName);
1063 UtAttachNamepathToOwner (
1064 ACPI_PARSE_OBJECT *Op,
1065 ACPI_PARSE_OBJECT *NameNode);
1068 UtCheckIntegerRange (
1069 ACPI_PARSE_OBJECT *Op,
1081 UINT64 *RetInteger);
1085 * asluuid - UUID support
1092 AuConvertUuidToString (
1097 * aslresource - Resource template generation utilities
1100 RsSmallAddressCheck (
1106 ACPI_PARSE_OBJECT *MinOp,
1107 ACPI_PARSE_OBJECT *MaxOp,
1108 ACPI_PARSE_OBJECT *LengthOp,
1109 ACPI_PARSE_OBJECT *AlignOp,
1110 ACPI_PARSE_OBJECT *Op);
1113 RsLargeAddressCheck (
1119 ACPI_PARSE_OBJECT *MinOp,
1120 ACPI_PARSE_OBJECT *MaxOp,
1121 ACPI_PARSE_OBJECT *LengthOp,
1122 ACPI_PARSE_OBJECT *GranOp,
1123 ACPI_PARSE_OBJECT *Op);
1126 RsGetStringDataLength (
1127 ACPI_PARSE_OBJECT *InitializerOp);
1130 RsAllocateResourceNode (
1134 RsCreateResourceField (
1135 ACPI_PARSE_OBJECT *Op,
1144 ACPI_PARSE_OBJECT *Op,
1151 ACPI_PARSE_OBJECT *Op,
1156 RsCompleteNodeAndGetNext (
1157 ACPI_PARSE_OBJECT *Op);
1160 RsCheckListForDuplicates (
1161 ACPI_PARSE_OBJECT *Op);
1164 RsDoOneResourceDescriptor (
1165 ASL_RESOURCE_INFO *Info,
1168 /* Values for State above */
1170 #define ACPI_RSTATE_NORMAL 0
1171 #define ACPI_RSTATE_START_DEPENDENT 1
1172 #define ACPI_RSTATE_DEPENDENT_LIST 2
1175 RsLinkDescriptorChain (
1176 ASL_RESOURCE_NODE **PreviousRnode,
1177 ASL_RESOURCE_NODE *Rnode);
1180 RsDoResourceTemplate (
1181 ACPI_PARSE_OBJECT *Op);
1185 * aslrestype1 - Miscellaneous Small descriptors
1188 RsDoEndTagDescriptor (
1189 ASL_RESOURCE_INFO *Info);
1192 RsDoEndDependentDescriptor (
1193 ASL_RESOURCE_INFO *Info);
1196 RsDoMemory24Descriptor (
1197 ASL_RESOURCE_INFO *Info);
1200 RsDoMemory32Descriptor (
1201 ASL_RESOURCE_INFO *Info);
1204 RsDoMemory32FixedDescriptor (
1205 ASL_RESOURCE_INFO *Info);
1208 RsDoStartDependentDescriptor (
1209 ASL_RESOURCE_INFO *Info);
1212 RsDoStartDependentNoPriDescriptor (
1213 ASL_RESOURCE_INFO *Info);
1216 RsDoVendorSmallDescriptor (
1217 ASL_RESOURCE_INFO *Info);
1221 * aslrestype1i - I/O-related Small descriptors
1225 ASL_RESOURCE_INFO *Info);
1228 RsDoFixedDmaDescriptor (
1229 ASL_RESOURCE_INFO *Info);
1232 RsDoFixedIoDescriptor (
1233 ASL_RESOURCE_INFO *Info);
1237 ASL_RESOURCE_INFO *Info);
1241 ASL_RESOURCE_INFO *Info);
1244 RsDoIrqNoFlagsDescriptor (
1245 ASL_RESOURCE_INFO *Info);
1249 * aslrestype2 - Large resource descriptors
1252 RsDoInterruptDescriptor (
1253 ASL_RESOURCE_INFO *Info);
1256 RsDoVendorLargeDescriptor (
1257 ASL_RESOURCE_INFO *Info);
1260 RsDoGeneralRegisterDescriptor (
1261 ASL_RESOURCE_INFO *Info);
1264 RsDoGpioIntDescriptor (
1265 ASL_RESOURCE_INFO *Info);
1268 RsDoGpioIoDescriptor (
1269 ASL_RESOURCE_INFO *Info);
1272 RsDoI2cSerialBusDescriptor (
1273 ASL_RESOURCE_INFO *Info);
1276 RsDoSpiSerialBusDescriptor (
1277 ASL_RESOURCE_INFO *Info);
1280 RsDoUartSerialBusDescriptor (
1281 ASL_RESOURCE_INFO *Info);
1284 * aslrestype2d - DWord address descriptors
1287 RsDoDwordIoDescriptor (
1288 ASL_RESOURCE_INFO *Info);
1291 RsDoDwordMemoryDescriptor (
1292 ASL_RESOURCE_INFO *Info);
1295 RsDoDwordSpaceDescriptor (
1296 ASL_RESOURCE_INFO *Info);
1300 * aslrestype2e - Extended address descriptors
1303 RsDoExtendedIoDescriptor (
1304 ASL_RESOURCE_INFO *Info);
1307 RsDoExtendedMemoryDescriptor (
1308 ASL_RESOURCE_INFO *Info);
1311 RsDoExtendedSpaceDescriptor (
1312 ASL_RESOURCE_INFO *Info);
1316 * aslrestype2q - QWord address descriptors
1319 RsDoQwordIoDescriptor (
1320 ASL_RESOURCE_INFO *Info);
1323 RsDoQwordMemoryDescriptor (
1324 ASL_RESOURCE_INFO *Info);
1327 RsDoQwordSpaceDescriptor (
1328 ASL_RESOURCE_INFO *Info);
1332 * aslrestype2w - Word address descriptors
1335 RsDoWordIoDescriptor (
1336 ASL_RESOURCE_INFO *Info);
1339 RsDoWordSpaceDescriptor (
1340 ASL_RESOURCE_INFO *Info);
1343 RsDoWordBusNumberDescriptor (
1344 ASL_RESOURCE_INFO *Info);
1348 * Entry to data table compiler subsystem
1358 #endif /* __ASLCOMPILER_H */