1 /******************************************************************************
3 * Module Name: aslcompiler.h - common include file for iASL
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
45 #ifndef __ASLCOMPILER_H
46 #define __ASLCOMPILER_H
53 /* Microsoft-specific */
55 #if (defined WIN32 || defined WIN64)
57 /* warn : used #pragma pack */
58 #pragma warning(disable:4103)
60 /* warn : named type definition in parentheses */
61 #pragma warning(disable:4115)
71 /* Compiler headers */
73 #include "asldefine.h"
75 #include "aslmessages.h"
76 #include "aslglobal.h"
77 #include "preprocess.h"
80 /*******************************************************************************
84 ******************************************************************************/
87 * Main ASL parser - generated from flex/bison, lex/yacc, etc.
98 AslResetCurrentLineBuffer (
102 AslInsertLineBuffer (
106 AslPopInputFileStack (
110 AslPushInputFileStack (
115 * aslstartup - entered from main()
118 AslInitializeGlobals (
122 ACPI_STATUS (*ASL_PATHNAME_CALLBACK
) (
130 AslCheckForErrorExit (
135 * aslcompile - compile mainline
142 AslCompilerFileHeader (
158 FlCheckForAcpiTable (
165 BOOLEAN DisplayErrors
);
169 * aslwalks - semantic analysis and parse tree walks
172 AnOtherSemanticAnalysisWalkBegin (
173 ACPI_PARSE_OBJECT
*Op
,
178 AnOtherSemanticAnalysisWalkEnd (
179 ACPI_PARSE_OBJECT
*Op
,
184 AnOperandTypecheckWalkEnd (
185 ACPI_PARSE_OBJECT
*Op
,
190 AnMethodTypingWalkEnd (
191 ACPI_PARSE_OBJECT
*Op
,
197 * aslmethod - Control method analysis walk
200 MtMethodAnalysisWalkBegin (
201 ACPI_PARSE_OBJECT
*Op
,
206 MtMethodAnalysisWalkEnd (
207 ACPI_PARSE_OBJECT
*Op
,
213 * aslbtypes - bitfield data types
216 AnMapObjTypeToBtype (
217 ACPI_PARSE_OBJECT
*Op
);
220 AnMapArgTypeToBtype (
225 ACPI_PARSE_OBJECT
*Op
);
234 * aslanalyze - Support functions for parse tree walks
238 ACPI_PARSE_OBJECT
*Op
,
241 /* Values for Type argument above */
243 #define ASL_TYPE_HID 0
244 #define ASL_TYPE_CID 1
248 ACPI_PARSE_OBJECT
*Op
);
251 AnGetInternalMethodReturnType (
252 ACPI_PARSE_OBJECT
*Op
);
255 AnLastStatementIsReturn (
256 ACPI_PARSE_OBJECT
*Op
);
259 AnCheckMethodReturnValue (
260 ACPI_PARSE_OBJECT
*Op
,
261 const ACPI_OPCODE_INFO
*OpInfo
,
262 ACPI_PARSE_OBJECT
*ArgOp
,
263 UINT32 RequiredBtypes
,
264 UINT32 ThisNodeBtype
);
268 ACPI_PARSE_OBJECT
*Op
);
271 ApCheckForGpeNameConflict (
272 ACPI_PARSE_OBJECT
*Op
);
276 ACPI_PARSE_OBJECT
*Op
);
280 * aslerror - error handling/reporting
286 ACPI_PARSE_OBJECT
*Op
,
290 AslDisableException (
291 char *MessageIdString
);
294 AslIsExceptionDisabled (
299 AslCoreSubsystemError (
300 ACPI_PARSE_OBJECT
*Op
,
313 UINT32 CurrentLineNumber
,
314 UINT32 LogicalLineNumber
,
315 UINT32 LogicalByteOffset
,
333 ASL_ERROR_MSG
*Enode
,
344 ACPI_PHYSICAL_ADDRESS
345 AeLocalGetRootPointer (
350 * asllisting - generate all "listing" type files
357 LsWriteNodeToAsmListing (
358 ACPI_PARSE_OBJECT
*Op
);
362 ACPI_PARSE_OBJECT
*Op
,
371 * asllistsup - Listing file support utilities
380 LsDumpAsciiInComment (
391 LsFlushListingBuffer (
395 LsWriteListingHexBytes (
403 UINT32 ToLogicalLineNumber
,
407 LsWriteOneSourceLine (
420 * aslhex - generate all "hex" output files (C, ASM, ASL)
428 * aslfold - constant folding
432 ACPI_PARSE_OBJECT
*Op
,
438 * asloffset - generate C offset file for BIOS support
442 ACPI_PARSE_OBJECT
*Op
,
447 LsDoOffsetTableHeader (
451 LsDoOffsetTableFooter (
456 * aslopcodes - generate AML opcodes
460 ACPI_PARSE_OBJECT
*Op
,
465 OpcAmlOpcodeUpdateWalk (
466 ACPI_PARSE_OBJECT
*Op
,
471 OpcGenerateAmlOpcode (
472 ACPI_PARSE_OBJECT
*Op
);
475 OpcSetOptimalIntegerSize (
476 ACPI_PARSE_OBJECT
*Op
);
480 ACPI_PARSE_OBJECT
*Op
);
484 * asloperands - generate AML operands for the AML opcodes
488 ACPI_PARSE_OBJECT
*Op
,
492 OpnGenerateAmlOperands (
493 ACPI_PARSE_OBJECT
*Op
);
497 ACPI_PARSE_OBJECT
*Op
);
501 * aslopt - optmization
504 OptOptimizeNamePath (
505 ACPI_PARSE_OBJECT
*Op
,
507 ACPI_WALK_STATE
*WalkState
,
509 ACPI_NAMESPACE_NODE
*TargetNode
);
513 * aslcodegen - code generation
516 CgGenerateAmlOutput (
531 * asllength - calculate/adjust AML package lengths
534 LnPackageLengthWalk (
535 ACPI_PARSE_OBJECT
*Op
,
541 ACPI_PARSE_OBJECT
*Op
,
546 CgGenerateAmlLengths (
547 ACPI_PARSE_OBJECT
*Op
);
551 * aslmap - opcode mappings and reserved method names
554 AslMapNamedOpcodeToDataType (
559 * aslpredef - ACPI predefined names support
562 ApCheckForPredefinedMethod (
563 ACPI_PARSE_OBJECT
*Op
,
564 ASL_METHOD_INFO
*MethodInfo
);
567 ApCheckPredefinedReturnValue (
568 ACPI_PARSE_OBJECT
*Op
,
569 ASL_METHOD_INFO
*MethodInfo
);
572 ApCheckForPredefinedName (
573 ACPI_PARSE_OBJECT
*Op
,
577 ApCheckForPredefinedObject (
578 ACPI_PARSE_OBJECT
*Op
,
583 const char *PredefinedName
,
584 ACPI_PARSE_OBJECT
*Op
,
585 UINT32 ExpectedBtypes
,
586 UINT32 PackageIndex
);
589 ApDisplayReservedNames (
594 * aslprepkg - ACPI predefined names support for packages
598 ACPI_PARSE_OBJECT
*ParentOp
,
599 const ACPI_PREDEFINED_INFO
*Predefined
);
603 * asltransform - parse tree transformations
607 ACPI_PARSE_OBJECT
*Op
,
613 * asltree - parse tree support
617 ACPI_PARSE_OBJECT
*Op
,
619 ASL_WALK_CALLBACK DescendingCallback
,
620 ASL_WALK_CALLBACK AscendingCallback
,
623 /* Values for "Visitation" parameter above */
625 #define ASL_WALK_VISIT_DOWNWARD 0x01
626 #define ASL_WALK_VISIT_UPWARD 0x02
627 #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD)
636 ACPI_PARSE_OBJECT
*Op
);
641 ACPI_PARSE_OBJECT
*Op
);
654 TrCreateValuedLeafNode (
659 TrCreateConstantLeafNode (
664 ACPI_PARSE_OBJECT
*Op
,
670 ACPI_PARSE_OBJECT
*Op
);
678 ACPI_PARSE_OBJECT
*Op1
,
679 ACPI_PARSE_OBJECT
*Op2
);
683 ACPI_PARSE_OBJECT
*Op1
,
684 ACPI_PARSE_OBJECT
*Op2
);
688 ACPI_PARSE_OBJECT
*Op
,
693 ACPI_PARSE_OBJECT
*Op
,
703 * aslfiles - File I/O support
710 FlAddIncludeDirectory (
720 ACPI_PARSE_OBJECT
*Op
);
772 char *InputFilename
);
775 FlOpenAmlOutputFile (
776 char *InputFilename
);
779 FlOpenMiscOutputFiles (
780 char *InputFilename
);
784 * asload - load namespace in prep for cross reference
788 ACPI_PARSE_OBJECT
*RootOp
);
792 * asllookup - namespace lookup functions
795 LkFindUnreferencedObjects (
811 * aslnamesp - namespace output file generation
818 NsSetupNamespaceListing (
822 * asloptions - command line processing
830 * aslxref - namespace cross reference
833 XfCrossReferenceNamespace (
838 * aslutils - common compiler utilites
846 /* Type values for above */
848 #define ASL_DEBUG_OUTPUT 0
849 #define ASL_PARSE_OUTPUT 1
850 #define ASL_TREE_OUTPUT 2
853 UtDisplaySupportedTables (
857 UtDisplayConstantOpcodes (
873 UtPrintFormattedName (
891 UtConvertByteToAsmHex (
901 ACPI_PARSE_OBJECT
*Op
);
908 UtExpandLineBuffers (
914 char **ConvertedName
);
917 UtAttachNamepathToOwner (
918 ACPI_PARSE_OBJECT
*Op
,
919 ACPI_PARSE_OBJECT
*NameNode
);
922 UtCheckIntegerRange (
923 ACPI_PARSE_OBJECT
*Op
,
939 * asluuid - UUID support
946 AuConvertStringToUuid (
951 AuConvertUuidToString (
956 * aslresource - Resource template generation utilities
959 RsSmallAddressCheck (
965 ACPI_PARSE_OBJECT
*MinOp
,
966 ACPI_PARSE_OBJECT
*MaxOp
,
967 ACPI_PARSE_OBJECT
*LengthOp
,
968 ACPI_PARSE_OBJECT
*AlignOp
,
969 ACPI_PARSE_OBJECT
*Op
);
972 RsLargeAddressCheck (
978 ACPI_PARSE_OBJECT
*MinOp
,
979 ACPI_PARSE_OBJECT
*MaxOp
,
980 ACPI_PARSE_OBJECT
*LengthOp
,
981 ACPI_PARSE_OBJECT
*GranOp
,
982 ACPI_PARSE_OBJECT
*Op
);
985 RsGetStringDataLength (
986 ACPI_PARSE_OBJECT
*InitializerOp
);
989 RsAllocateResourceNode (
993 RsCreateResourceField (
994 ACPI_PARSE_OBJECT
*Op
,
1003 ACPI_PARSE_OBJECT
*Op
,
1010 ACPI_PARSE_OBJECT
*Op
,
1015 RsCompleteNodeAndGetNext (
1016 ACPI_PARSE_OBJECT
*Op
);
1019 RsCheckListForDuplicates (
1020 ACPI_PARSE_OBJECT
*Op
);
1023 RsDoOneResourceDescriptor (
1024 ACPI_PARSE_OBJECT
*DescriptorTypeOp
,
1025 UINT32 CurrentByteOffset
,
1028 /* Values for State above */
1030 #define ACPI_RSTATE_NORMAL 0
1031 #define ACPI_RSTATE_START_DEPENDENT 1
1032 #define ACPI_RSTATE_DEPENDENT_LIST 2
1035 RsLinkDescriptorChain (
1036 ASL_RESOURCE_NODE
**PreviousRnode
,
1037 ASL_RESOURCE_NODE
*Rnode
);
1040 RsDoResourceTemplate (
1041 ACPI_PARSE_OBJECT
*Op
);
1045 * aslrestype1 - Miscellaneous Small descriptors
1048 RsDoEndTagDescriptor (
1049 ACPI_PARSE_OBJECT
*Op
,
1050 UINT32 CurrentByteOffset
);
1053 RsDoEndDependentDescriptor (
1054 ACPI_PARSE_OBJECT
*Op
,
1055 UINT32 CurrentByteOffset
);
1058 RsDoMemory24Descriptor (
1059 ACPI_PARSE_OBJECT
*Op
,
1060 UINT32 CurrentByteOffset
);
1063 RsDoMemory32Descriptor (
1064 ACPI_PARSE_OBJECT
*Op
,
1065 UINT32 CurrentByteOffset
);
1068 RsDoMemory32FixedDescriptor (
1069 ACPI_PARSE_OBJECT
*Op
,
1070 UINT32 CurrentByteOffset
);
1073 RsDoStartDependentDescriptor (
1074 ACPI_PARSE_OBJECT
*Op
,
1075 UINT32 CurrentByteOffset
);
1078 RsDoStartDependentNoPriDescriptor (
1079 ACPI_PARSE_OBJECT
*Op
,
1080 UINT32 CurrentByteOffset
);
1083 RsDoVendorSmallDescriptor (
1084 ACPI_PARSE_OBJECT
*Op
,
1085 UINT32 CurrentByteOffset
);
1089 * aslrestype1i - I/O-related Small descriptors
1093 ACPI_PARSE_OBJECT
*Op
,
1094 UINT32 CurrentByteOffset
);
1097 RsDoFixedDmaDescriptor (
1098 ACPI_PARSE_OBJECT
*Op
,
1099 UINT32 CurrentByteOffset
);
1102 RsDoFixedIoDescriptor (
1103 ACPI_PARSE_OBJECT
*Op
,
1104 UINT32 CurrentByteOffset
);
1108 ACPI_PARSE_OBJECT
*Op
,
1109 UINT32 CurrentByteOffset
);
1113 ACPI_PARSE_OBJECT
*Op
,
1114 UINT32 CurrentByteOffset
);
1117 RsDoIrqNoFlagsDescriptor (
1118 ACPI_PARSE_OBJECT
*Op
,
1119 UINT32 CurrentByteOffset
);
1123 * aslrestype2 - Large resource descriptors
1126 RsDoInterruptDescriptor (
1127 ACPI_PARSE_OBJECT
*Op
,
1128 UINT32 CurrentByteOffset
);
1131 RsDoVendorLargeDescriptor (
1132 ACPI_PARSE_OBJECT
*Op
,
1133 UINT32 CurrentByteOffset
);
1136 RsDoGeneralRegisterDescriptor (
1137 ACPI_PARSE_OBJECT
*Op
,
1138 UINT32 CurrentByteOffset
);
1141 RsDoGpioIntDescriptor (
1142 ACPI_PARSE_OBJECT
*Op
,
1143 UINT32 CurrentByteOffset
);
1146 RsDoGpioIoDescriptor (
1147 ACPI_PARSE_OBJECT
*Op
,
1148 UINT32 CurrentByteOffset
);
1151 RsDoI2cSerialBusDescriptor (
1152 ACPI_PARSE_OBJECT
*Op
,
1153 UINT32 CurrentByteOffset
);
1156 RsDoSpiSerialBusDescriptor (
1157 ACPI_PARSE_OBJECT
*Op
,
1158 UINT32 CurrentByteOffset
);
1161 RsDoUartSerialBusDescriptor (
1162 ACPI_PARSE_OBJECT
*Op
,
1163 UINT32 CurrentByteOffset
);
1166 * aslrestype2d - DWord address descriptors
1169 RsDoDwordIoDescriptor (
1170 ACPI_PARSE_OBJECT
*Op
,
1171 UINT32 CurrentByteOffset
);
1174 RsDoDwordMemoryDescriptor (
1175 ACPI_PARSE_OBJECT
*Op
,
1176 UINT32 CurrentByteOffset
);
1179 RsDoDwordSpaceDescriptor (
1180 ACPI_PARSE_OBJECT
*Op
,
1181 UINT32 CurrentByteOffset
);
1185 * aslrestype2e - Extended address descriptors
1188 RsDoExtendedIoDescriptor (
1189 ACPI_PARSE_OBJECT
*Op
,
1190 UINT32 CurrentByteOffset
);
1193 RsDoExtendedMemoryDescriptor (
1194 ACPI_PARSE_OBJECT
*Op
,
1195 UINT32 CurrentByteOffset
);
1198 RsDoExtendedSpaceDescriptor (
1199 ACPI_PARSE_OBJECT
*Op
,
1200 UINT32 CurrentByteOffset
);
1204 * aslrestype2q - QWord address descriptors
1207 RsDoQwordIoDescriptor (
1208 ACPI_PARSE_OBJECT
*Op
,
1209 UINT32 CurrentByteOffset
);
1212 RsDoQwordMemoryDescriptor (
1213 ACPI_PARSE_OBJECT
*Op
,
1214 UINT32 CurrentByteOffset
);
1217 RsDoQwordSpaceDescriptor (
1218 ACPI_PARSE_OBJECT
*Op
,
1219 UINT32 CurrentByteOffset
);
1223 * aslrestype2w - Word address descriptors
1226 RsDoWordIoDescriptor (
1227 ACPI_PARSE_OBJECT
*Op
,
1228 UINT32 CurrentByteOffset
);
1231 RsDoWordSpaceDescriptor (
1232 ACPI_PARSE_OBJECT
*Op
,
1233 UINT32 CurrentByteOffset
);
1236 RsDoWordBusNumberDescriptor (
1237 ACPI_PARSE_OBJECT
*Op
,
1238 UINT32 CurrentByteOffset
);
1241 * Entry to data table compiler subsystem
1251 #endif /* __ASLCOMPILER_H */