xref: /freebsd/sys/contrib/dev/acpica/compiler/aslglobal.h (revision 63d1fd5970ec814904aa0f4580b10a0d302d08b2)
1 /******************************************************************************
2  *
3  * Module Name: aslglobal.h - Global variable definitions
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
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.
25  *
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.
29  *
30  * NO WARRANTY
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.
42  */
43 
44 #ifndef __ASLGLOBAL_H
45 #define __ASLGLOBAL_H
46 
47 
48 /*
49  * Global variables. Defined in aslmain.c only, externed in all other files
50  */
51 
52 #undef ASL_EXTERN
53 
54 #ifdef _DECLARE_GLOBALS
55 #define ASL_EXTERN
56 #define ASL_INIT_GLOBAL(a,b)        (a)=(b)
57 #else
58 #define ASL_EXTERN                  extern
59 #define ASL_INIT_GLOBAL(a,b)        (a)
60 #endif
61 
62 
63 #ifdef _DECLARE_GLOBALS
64 UINT32                              Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0};
65 
66 /* Table below must match ASL_FILE_TYPES in asltypes.h */
67 
68 ASL_FILE_INFO                       Gbl_Files [ASL_NUM_FILES] =
69 {
70     {NULL, NULL, "stdout:       ", "Standard Output"},
71     {NULL, NULL, "stderr:       ", "Standard Error"},
72     {NULL, NULL, "Table Input:  ", "Source Input"},
73     {NULL, NULL, "Binary Output:", "AML Output"},
74     {NULL, NULL, "Source Output:", "Source Output"},
75     {NULL, NULL, "Preprocessor: ", "Preprocessor Output"},
76     {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"},
77     {NULL, NULL, "Listing File: ", "Listing Output"},
78     {NULL, NULL, "Hex Dump:     ", "Hex Table Output"},
79     {NULL, NULL, "Namespace:    ", "Namespace Output"},
80     {NULL, NULL, "Debug File:   ", "Debug Output"},
81     {NULL, NULL, "ASM Source:   ", "Assembly Code Output"},
82     {NULL, NULL, "C Source:     ", "C Code Output"},
83     {NULL, NULL, "ASM Include:  ", "Assembly Header Output"},
84     {NULL, NULL, "C Include:    ", "C Header Output"},
85     {NULL, NULL, "Offset Table: ", "C Offset Table Output"},
86     {NULL, NULL, "Device Map:   ", "Device Map Output"},
87     {NULL, NULL, "Cross Ref:    ", "Cross-reference Output"}
88 };
89 
90 #else
91 extern UINT32                       Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
92 extern ASL_FILE_INFO                Gbl_Files [ASL_NUM_FILES];
93 #endif
94 
95 
96 /*
97  * Parser and other externals
98  */
99 extern int                          yydebug;
100 extern FILE                         *AslCompilerin;
101 extern int                          DtParserdebug;
102 extern int                          PrParserdebug;
103 extern const ASL_MAPPING_ENTRY      AslKeywordMapping[];
104 extern char                         *AslCompilertext;
105 
106 /*
107  * Older versions of Bison won't emit this external in the generated header.
108  * Newer versions do emit the external, so we don't need to do it.
109  */
110 #ifndef ASLCOMPILER_ASLCOMPILERPARSE_H
111 extern int                  AslCompilerdebug;
112 #endif
113 
114 
115 #define ASL_DEFAULT_LINE_BUFFER_SIZE    (1024 * 32) /* 32K */
116 #define ASL_MSG_BUFFER_SIZE             4096
117 #define ASL_MAX_DISABLED_MESSAGES       32
118 #define HEX_TABLE_LINE_SIZE             8
119 #define HEX_LISTING_LINE_SIZE           8
120 
121 
122 /* Source code buffers and pointers for error reporting */
123 
124 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NULL);
125 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL);
126 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE);
127 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
128 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
129 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
130 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
131 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0);
132 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_SyntaxError, 0);
133 
134 /* Exception reporting */
135 
136 ASL_EXTERN ASL_ERROR_MSG            ASL_INIT_GLOBAL (*Gbl_ErrorLog,NULL);
137 ASL_EXTERN ASL_ERROR_MSG            ASL_INIT_GLOBAL (*Gbl_NextError,NULL);
138 
139 /* Option flags */
140 
141 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoCompile, TRUE);
142 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoSignon, TRUE);
143 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessOnly, FALSE);
144 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessFlag, TRUE);
145 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisassembleAll, FALSE);
146 
147 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
148 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE);
149 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
150 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE);
151 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_KeepPreprocessorTempFile, FALSE);
152 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
153 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CrossReferenceOutput, FALSE);
154 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
155 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
156 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE);
157 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE);
158 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE);
159 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE);
160 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
161 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
162 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE);
163 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE);
164 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE);
165 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE);
166 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE);
167 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_WarningsAsErrors, FALSE);
168 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE);
169 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE);
170 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE);
171 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE);
172 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE);
173 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayWarnings, TRUE);
174 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE);
175 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING);
176 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE);
177 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_VerboseTemplates, FALSE);
178 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE);
179 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE);
180 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, FALSE);
181 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PruneParseTree, FALSE);
182 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoTypechecking, TRUE);
183 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_EnableReferenceTypechecking, FALSE);
184 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoExternals, TRUE);
185 
186 
187 #define HEX_OUTPUT_NONE             0
188 #define HEX_OUTPUT_C                1
189 #define HEX_OUTPUT_ASM              2
190 #define HEX_OUTPUT_ASL              3
191 
192 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE);
193 
194 
195 /* Files */
196 
197 ASL_EXTERN char                     *Gbl_DirectoryPath;
198 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
199 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
200 ASL_EXTERN ASL_INCLUDE_DIR          ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL);
201 ASL_EXTERN char                     *Gbl_CurrentInputFilename;
202 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL);
203 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_PreviousIncludeFilename, NULL);
204 
205 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
206 
207 
208 /* Statistics */
209 
210 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_InputByteCount, 0);
211 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_InputFieldCount, 0);
212 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_NsLookupCount, 0);
213 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalKeywords, 0);
214 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalNamedObjects, 0);
215 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalExecutableOpcodes, 0);
216 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalParseNodes, 0);
217 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalMethods, 0);
218 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalAllocations, 0);
219 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalAllocated, 0);
220 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalFolds, 0);
221 
222 
223 /* Local caches */
224 
225 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_ParseOpCount, 0);
226 ASL_EXTERN ASL_CACHE_INFO           ASL_INIT_GLOBAL (*Gbl_ParseOpCacheList, NULL);
227 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ParseOpCacheNext, NULL);
228 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ParseOpCacheLast, NULL);
229 
230 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_StringCount, 0);
231 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_StringSize, 0);
232 ASL_EXTERN ASL_CACHE_INFO           ASL_INIT_GLOBAL (*Gbl_StringCacheList, NULL);
233 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL);
234 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL);
235 
236 /* Map file */
237 
238 ASL_EXTERN ACPI_GPIO_INFO           ASL_INIT_GLOBAL (*Gbl_GpioList, NULL);
239 ASL_EXTERN ACPI_SERIAL_INFO         ASL_INIT_GLOBAL (*Gbl_SerialList, NULL);
240 
241 
242 /* Misc */
243 
244 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0);
245 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_TempCount, 0);
246 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ParseTreeRoot, NULL);
247 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ExternalsListHead, NULL);
248 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_TableLength, 0);
249 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_SourceLine, 0);
250 ASL_EXTERN ASL_LISTING_NODE         ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL);
251 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_FileType, 0);
252 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_Signature, NULL);
253 
254 ASL_EXTERN ACPI_PARSE_OBJECT        *Gbl_FirstLevelInsertionNode;
255 
256 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
257 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
258 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLine, 0);
259 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_DisabledMessagesIndex, 0);
260 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
261 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
262 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0);
263 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG");
264 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID");
265 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_PruneDepth, 0);
266 ASL_EXTERN UINT16                   ASL_INIT_GLOBAL (Gbl_PruneType, 0);
267 
268 
269 /* Static structures */
270 
271 ASL_EXTERN ASL_ANALYSIS_WALK_INFO   AnalysisWalkInfo;
272 ASL_EXTERN ACPI_TABLE_HEADER        TableHeader;
273 
274 /* Event timing */
275 
276 #define ASL_NUM_EVENTS              24
277 ASL_EXTERN ASL_EVENT_INFO           AslGbl_Events[ASL_NUM_EVENTS];
278 ASL_EXTERN UINT8                    AslGbl_NextEvent;
279 ASL_EXTERN UINT8                    AslGbl_NamespaceEvent;
280 
281 /* Scratch buffers */
282 
283 ASL_EXTERN UINT8                    Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
284 ASL_EXTERN char                     MsgBuffer[ASL_MSG_BUFFER_SIZE];
285 ASL_EXTERN char                     StringBuffer[ASL_MSG_BUFFER_SIZE];
286 ASL_EXTERN char                     StringBuffer2[ASL_MSG_BUFFER_SIZE];
287 ASL_EXTERN UINT32                   Gbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES];
288 
289 
290 #endif /* __ASLGLOBAL_H */
291