1 /******************************************************************************
3 * Module Name: aslcompiler.h - common include file for iASL
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #ifndef __ASLCOMPILER_H
45 #define __ASLCOMPILER_H
52 /* Microsoft-specific */
54 #if (defined WIN32 || defined WIN64)
56 /* warn : used #pragma pack */
57 #pragma warning(disable:4103)
59 /* warn : named type definition in parentheses */
60 #pragma warning(disable:4115)
69 /* Compiler headers */
71 #include "asldefine.h"
73 #include "aslmessages.h"
74 #include "aslglobal.h"
75 #include "preprocess.h"
78 /*******************************************************************************
82 ******************************************************************************/
85 * Main ASL parser - generated from flex/bison, lex/yacc, etc.
96 AslResetCurrentLineBuffer (
100 AslInsertLineBuffer (
104 AslPopInputFileStack (
108 AslPushInputFileStack (
118 * aslstartup - entered from main()
121 AslInitializeGlobals (
125 ACPI_STATUS (*ASL_PATHNAME_CALLBACK
) (
133 AslCheckForErrorExit (
138 * aslcompile - compile mainline
145 AslCompilerFileHeader (
166 * aslascii - ascii support
169 FlIsFileAsciiSource (
171 BOOLEAN DisplayErrors
);
175 * aslwalks - semantic analysis and parse tree walks
178 AnOtherSemanticAnalysisWalkBegin (
179 ACPI_PARSE_OBJECT
*Op
,
184 AnOtherSemanticAnalysisWalkEnd (
185 ACPI_PARSE_OBJECT
*Op
,
190 AnOperandTypecheckWalkEnd (
191 ACPI_PARSE_OBJECT
*Op
,
196 AnMethodTypingWalkEnd (
197 ACPI_PARSE_OBJECT
*Op
,
203 * aslmethod - Control method analysis walk
206 MtMethodAnalysisWalkBegin (
207 ACPI_PARSE_OBJECT
*Op
,
212 MtMethodAnalysisWalkEnd (
213 ACPI_PARSE_OBJECT
*Op
,
219 * aslbtypes - bitfield data types
222 AnMapObjTypeToBtype (
223 ACPI_PARSE_OBJECT
*Op
);
226 AnMapArgTypeToBtype (
231 ACPI_PARSE_OBJECT
*Op
);
240 * aslanalyze - Support functions for parse tree walks
244 ACPI_PARSE_OBJECT
*Op
,
247 /* Values for Type argument above */
249 #define ASL_TYPE_HID 0
250 #define ASL_TYPE_CID 1
254 ACPI_PARSE_OBJECT
*Op
);
257 AnGetInternalMethodReturnType (
258 ACPI_PARSE_OBJECT
*Op
);
261 AnLastStatementIsReturn (
262 ACPI_PARSE_OBJECT
*Op
);
265 AnCheckMethodReturnValue (
266 ACPI_PARSE_OBJECT
*Op
,
267 const ACPI_OPCODE_INFO
*OpInfo
,
268 ACPI_PARSE_OBJECT
*ArgOp
,
269 UINT32 RequiredBtypes
,
270 UINT32 ThisNodeBtype
);
274 ACPI_PARSE_OBJECT
*Op
);
277 ApCheckForGpeNameConflict (
278 ACPI_PARSE_OBJECT
*Op
);
282 ACPI_PARSE_OBJECT
*Op
);
287 ACPI_PARSE_OBJECT
*Op
);
290 ApFindNameInDeviceTree (
292 ACPI_PARSE_OBJECT
*Op
);
295 * aslerror - error handling/reporting
305 ACPI_PARSE_OBJECT
*Op
,
309 AslDisableException (
310 char *MessageIdString
);
313 AslIsExceptionDisabled (
318 AslCoreSubsystemError (
319 ACPI_PARSE_OBJECT
*Op
,
332 UINT32 CurrentLineNumber
,
333 UINT32 LogicalLineNumber
,
334 UINT32 LogicalByteOffset
,
352 ASL_ERROR_MSG
*Enode
,
365 * asllisting - generate all "listing" type files
372 LsWriteNodeToAsmListing (
373 ACPI_PARSE_OBJECT
*Op
);
377 ACPI_PARSE_OBJECT
*Op
,
386 * asllistsup - Listing file support utilities
395 LsDumpAsciiInComment (
406 LsFlushListingBuffer (
410 LsWriteListingHexBytes (
418 UINT32 ToLogicalLineNumber
,
422 LsWriteOneSourceLine (
435 * aslhex - generate all "hex" output files (C, ASM, ASL)
443 * aslfold - constant folding
447 ACPI_PARSE_OBJECT
*Op
,
453 * aslmessages - exception strings
460 AeDecodeExceptionLevel (
464 AeBuildFullExceptionCode (
469 * asloffset - generate C offset file for BIOS support
473 ACPI_PARSE_OBJECT
*Op
,
478 LsDoOffsetTableHeader (
482 LsDoOffsetTableFooter (
487 * aslopcodes - generate AML opcodes
491 ACPI_PARSE_OBJECT
*Op
,
496 OpcAmlOpcodeUpdateWalk (
497 ACPI_PARSE_OBJECT
*Op
,
502 OpcGenerateAmlOpcode (
503 ACPI_PARSE_OBJECT
*Op
);
506 OpcSetOptimalIntegerSize (
507 ACPI_PARSE_OBJECT
*Op
);
511 ACPI_PARSE_OBJECT
*Op
);
515 * asloperands - generate AML operands for the AML opcodes
519 ACPI_PARSE_OBJECT
*Op
,
523 OpnGenerateAmlOperands (
524 ACPI_PARSE_OBJECT
*Op
);
528 ACPI_PARSE_OBJECT
*Op
);
532 * aslopt - optmization
535 OptOptimizeNamePath (
536 ACPI_PARSE_OBJECT
*Op
,
538 ACPI_WALK_STATE
*WalkState
,
540 ACPI_NAMESPACE_NODE
*TargetNode
);
544 * aslpld - ToPLD macro support
548 ACPI_PARSE_OBJECT
*Op
);
552 * aslprintf - Printf/Fprintf macros
556 ACPI_PARSE_OBJECT
*Op
);
560 ACPI_PARSE_OBJECT
*Op
);
564 * aslprune - parse tree pruner
573 * aslcodegen - code generation
576 CgGenerateAmlOutput (
591 * asllength - calculate/adjust AML package lengths
594 LnPackageLengthWalk (
595 ACPI_PARSE_OBJECT
*Op
,
601 ACPI_PARSE_OBJECT
*Op
,
606 CgGenerateAmlLengths (
607 ACPI_PARSE_OBJECT
*Op
);
611 * aslmap - opcode mappings and reserved method names
614 AslMapNamedOpcodeToDataType (
619 * aslpredef - ACPI predefined names support
622 ApCheckForPredefinedMethod (
623 ACPI_PARSE_OBJECT
*Op
,
624 ASL_METHOD_INFO
*MethodInfo
);
627 ApCheckPredefinedReturnValue (
628 ACPI_PARSE_OBJECT
*Op
,
629 ASL_METHOD_INFO
*MethodInfo
);
632 ApCheckForPredefinedName (
633 ACPI_PARSE_OBJECT
*Op
,
637 ApCheckForPredefinedObject (
638 ACPI_PARSE_OBJECT
*Op
,
643 const char *PredefinedName
,
644 ACPI_PARSE_OBJECT
*Op
,
645 UINT32 ExpectedBtypes
,
646 UINT32 PackageIndex
);
649 ApDisplayReservedNames (
654 * aslprepkg - ACPI predefined names support for packages
658 ACPI_PARSE_OBJECT
*ParentOp
,
659 const ACPI_PREDEFINED_INFO
*Predefined
);
663 * asltransform - parse tree transformations
666 TrAmlTransformWalkBegin (
667 ACPI_PARSE_OBJECT
*Op
,
672 TrAmlTransformWalkEnd (
673 ACPI_PARSE_OBJECT
*Op
,
679 * asltree - parse tree support
683 ACPI_PARSE_OBJECT
*Op
,
685 ASL_WALK_CALLBACK DescendingCallback
,
686 ASL_WALK_CALLBACK AscendingCallback
,
690 * aslexternal - External opcode support
693 ExAmlExternalWalkBegin (
694 ACPI_PARSE_OBJECT
*Op
,
699 ExAmlExternalWalkEnd (
700 ACPI_PARSE_OBJECT
*Op
,
706 ACPI_PARSE_OBJECT
*Op
);
708 /* Values for "Visitation" parameter above */
710 #define ASL_WALK_VISIT_DOWNWARD 0x01
711 #define ASL_WALK_VISIT_UPWARD 0x02
712 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
717 ACPI_PARSE_OBJECT
*Op
,
718 ACPI_PARSE_OBJECT
*ParentOp
);
725 TrPrintNodeCompileFlags (
730 ACPI_PARSE_OBJECT
*Op
);
735 ACPI_PARSE_OBJECT
*Op
);
752 TrCreateAssignmentNode (
753 ACPI_PARSE_OBJECT
*Target
,
754 ACPI_PARSE_OBJECT
*Source
);
757 TrCreateTargetOperand (
758 ACPI_PARSE_OBJECT
*OriginalOp
,
759 ACPI_PARSE_OBJECT
*ParentOp
);
762 TrCreateValuedLeafNode (
767 TrCreateConstantLeafNode (
772 ACPI_PARSE_OBJECT
*Op
,
778 ACPI_PARSE_OBJECT
*Op
);
781 TrSetCurrentFilename (
782 ACPI_PARSE_OBJECT
*Op
);
790 ACPI_PARSE_OBJECT
*Op1
,
791 ACPI_PARSE_OBJECT
*Op2
);
795 ACPI_PARSE_OBJECT
*Op1
,
796 ACPI_PARSE_OBJECT
*Op2
);
800 ACPI_PARSE_OBJECT
*Op
,
805 ACPI_PARSE_OBJECT
*Op
,
815 * aslfiles - File I/O support
818 FlAddIncludeDirectory (
828 ACPI_PARSE_OBJECT
*Op
);
880 char *InputFilename
);
883 FlOpenAmlOutputFile (
884 char *InputFilename
);
887 FlOpenMiscOutputFiles (
888 char *InputFilename
);
891 * aslhwmap - hardware map summary
899 * asload - load namespace in prep for cross reference
903 ACPI_PARSE_OBJECT
*RootOp
);
907 * asllookup - namespace lookup functions
910 LkFindUnreferencedObjects (
914 * aslhelp - help screens
930 * aslnamesp - namespace output file generation
937 NsSetupNamespaceListing (
941 * asloptions - command line processing
949 * aslxref - namespace cross reference
952 XfCrossReferenceNamespace (
969 ACPI_PARSE_OBJECT
*Op
,
971 ASL_METHOD_INFO
*MethodInfo
);
975 * aslutils - common compiler utilites
983 /* Type values for above */
985 #define ASL_DEBUG_OUTPUT 0
986 #define ASL_PARSE_OUTPUT 1
987 #define ASL_TREE_OUTPUT 2
990 UtIsBigEndianMachine (
994 UtQueryForOverwrite (
999 ACPI_PARSE_OBJECT
*Op
,
1004 ACPI_PARSE_OBJECT
*Op
,
1006 UINT32 IntegerLength
);
1010 ACPI_PARSE_OBJECT
*Op
,
1014 UtDisplaySupportedTables (
1018 UtDisplayConstantOpcodes (
1038 UtConvertByteToHex (
1043 UtConvertByteToAsmHex (
1049 UINT32 ParseOpcode
);
1053 ACPI_PARSE_OBJECT
*Op
);
1056 UtStringCacheCalloc (
1060 UtExpandLineBuffers (
1070 char **ConvertedName
);
1073 UtAttachNamepathToOwner (
1074 ACPI_PARSE_OBJECT
*Op
,
1075 ACPI_PARSE_OBJECT
*NameNode
);
1078 UtCheckIntegerRange (
1079 ACPI_PARSE_OBJECT
*Op
,
1089 * asluuid - UUID support
1096 AuConvertUuidToString (
1101 * aslresource - Resource template generation utilities
1104 RsSmallAddressCheck (
1110 ACPI_PARSE_OBJECT
*MinOp
,
1111 ACPI_PARSE_OBJECT
*MaxOp
,
1112 ACPI_PARSE_OBJECT
*LengthOp
,
1113 ACPI_PARSE_OBJECT
*AlignOp
,
1114 ACPI_PARSE_OBJECT
*Op
);
1117 RsLargeAddressCheck (
1123 ACPI_PARSE_OBJECT
*MinOp
,
1124 ACPI_PARSE_OBJECT
*MaxOp
,
1125 ACPI_PARSE_OBJECT
*LengthOp
,
1126 ACPI_PARSE_OBJECT
*GranOp
,
1127 ACPI_PARSE_OBJECT
*Op
);
1130 RsGetStringDataLength (
1131 ACPI_PARSE_OBJECT
*InitializerOp
);
1134 RsAllocateResourceNode (
1138 RsCreateResourceField (
1139 ACPI_PARSE_OBJECT
*Op
,
1148 ACPI_PARSE_OBJECT
*Op
,
1155 ACPI_PARSE_OBJECT
*Op
,
1160 RsCompleteNodeAndGetNext (
1161 ACPI_PARSE_OBJECT
*Op
);
1164 RsCheckListForDuplicates (
1165 ACPI_PARSE_OBJECT
*Op
);
1168 RsDoOneResourceDescriptor (
1169 ASL_RESOURCE_INFO
*Info
,
1172 /* Values for State above */
1174 #define ACPI_RSTATE_NORMAL 0
1175 #define ACPI_RSTATE_START_DEPENDENT 1
1176 #define ACPI_RSTATE_DEPENDENT_LIST 2
1179 RsLinkDescriptorChain (
1180 ASL_RESOURCE_NODE
**PreviousRnode
,
1181 ASL_RESOURCE_NODE
*Rnode
);
1184 RsDoResourceTemplate (
1185 ACPI_PARSE_OBJECT
*Op
);
1189 * aslrestype1 - Miscellaneous Small descriptors
1192 RsDoEndTagDescriptor (
1193 ASL_RESOURCE_INFO
*Info
);
1196 RsDoEndDependentDescriptor (
1197 ASL_RESOURCE_INFO
*Info
);
1200 RsDoMemory24Descriptor (
1201 ASL_RESOURCE_INFO
*Info
);
1204 RsDoMemory32Descriptor (
1205 ASL_RESOURCE_INFO
*Info
);
1208 RsDoMemory32FixedDescriptor (
1209 ASL_RESOURCE_INFO
*Info
);
1212 RsDoStartDependentDescriptor (
1213 ASL_RESOURCE_INFO
*Info
);
1216 RsDoStartDependentNoPriDescriptor (
1217 ASL_RESOURCE_INFO
*Info
);
1220 RsDoVendorSmallDescriptor (
1221 ASL_RESOURCE_INFO
*Info
);
1225 * aslrestype1i - I/O-related Small descriptors
1229 ASL_RESOURCE_INFO
*Info
);
1232 RsDoFixedDmaDescriptor (
1233 ASL_RESOURCE_INFO
*Info
);
1236 RsDoFixedIoDescriptor (
1237 ASL_RESOURCE_INFO
*Info
);
1241 ASL_RESOURCE_INFO
*Info
);
1245 ASL_RESOURCE_INFO
*Info
);
1248 RsDoIrqNoFlagsDescriptor (
1249 ASL_RESOURCE_INFO
*Info
);
1253 * aslrestype2 - Large resource descriptors
1256 RsDoInterruptDescriptor (
1257 ASL_RESOURCE_INFO
*Info
);
1260 RsDoVendorLargeDescriptor (
1261 ASL_RESOURCE_INFO
*Info
);
1264 RsDoGeneralRegisterDescriptor (
1265 ASL_RESOURCE_INFO
*Info
);
1268 RsDoGpioIntDescriptor (
1269 ASL_RESOURCE_INFO
*Info
);
1272 RsDoGpioIoDescriptor (
1273 ASL_RESOURCE_INFO
*Info
);
1276 RsDoI2cSerialBusDescriptor (
1277 ASL_RESOURCE_INFO
*Info
);
1280 RsDoSpiSerialBusDescriptor (
1281 ASL_RESOURCE_INFO
*Info
);
1284 RsDoUartSerialBusDescriptor (
1285 ASL_RESOURCE_INFO
*Info
);
1288 * aslrestype2d - DWord address descriptors
1291 RsDoDwordIoDescriptor (
1292 ASL_RESOURCE_INFO
*Info
);
1295 RsDoDwordMemoryDescriptor (
1296 ASL_RESOURCE_INFO
*Info
);
1299 RsDoDwordSpaceDescriptor (
1300 ASL_RESOURCE_INFO
*Info
);
1304 * aslrestype2e - Extended address descriptors
1307 RsDoExtendedIoDescriptor (
1308 ASL_RESOURCE_INFO
*Info
);
1311 RsDoExtendedMemoryDescriptor (
1312 ASL_RESOURCE_INFO
*Info
);
1315 RsDoExtendedSpaceDescriptor (
1316 ASL_RESOURCE_INFO
*Info
);
1320 * aslrestype2q - QWord address descriptors
1323 RsDoQwordIoDescriptor (
1324 ASL_RESOURCE_INFO
*Info
);
1327 RsDoQwordMemoryDescriptor (
1328 ASL_RESOURCE_INFO
*Info
);
1331 RsDoQwordSpaceDescriptor (
1332 ASL_RESOURCE_INFO
*Info
);
1336 * aslrestype2w - Word address descriptors
1339 RsDoWordIoDescriptor (
1340 ASL_RESOURCE_INFO
*Info
);
1343 RsDoWordSpaceDescriptor (
1344 ASL_RESOURCE_INFO
*Info
);
1347 RsDoWordBusNumberDescriptor (
1348 ASL_RESOURCE_INFO
*Info
);
1352 * Entry to data table compiler subsystem
1362 #endif /* __ASLCOMPILER_H */