xref: /freebsd/sys/contrib/dev/acpica/compiler/aslglobal.h (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1 /******************************************************************************
2  *
3  * Module Name: aslglobal.h - Global variable definitions
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2015, 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 };
88 
89 #else
90 extern UINT32                       Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
91 extern ASL_FILE_INFO                Gbl_Files [ASL_NUM_FILES];
92 #endif
93 
94 
95 /*
96  * Parser and other externals
97  */
98 extern int                          yydebug;
99 extern FILE                         *AslCompilerin;
100 extern int                          DtParserdebug;
101 extern int                          PrParserdebug;
102 extern const ASL_MAPPING_ENTRY      AslKeywordMapping[];
103 extern char                         *AslCompilertext;
104 
105 /*
106  * Older versions of Bison won't emit this external in the generated header.
107  * Newer versions do emit the external, so we don't need to do it.
108  */
109 #ifndef ASLCOMPILER_ASLCOMPILERPARSE_H
110 extern int                  AslCompilerdebug;
111 #endif
112 
113 
114 #define ASL_DEFAULT_LINE_BUFFER_SIZE    (1024 * 32) /* 32K */
115 #define ASL_MSG_BUFFER_SIZE             4096
116 #define ASL_MAX_DISABLED_MESSAGES       32
117 #define HEX_TABLE_LINE_SIZE             8
118 #define HEX_LISTING_LINE_SIZE           8
119 
120 
121 /* Source code buffers and pointers for error reporting */
122 
123 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NULL);
124 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL);
125 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE);
126 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
127 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
128 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
129 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
130 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0);
131 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_SyntaxError, 0);
132 
133 /* Exception reporting */
134 
135 ASL_EXTERN ASL_ERROR_MSG            ASL_INIT_GLOBAL (*Gbl_ErrorLog,NULL);
136 ASL_EXTERN ASL_ERROR_MSG            ASL_INIT_GLOBAL (*Gbl_NextError,NULL);
137 
138 /* Option flags */
139 
140 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoCompile, TRUE);
141 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoSignon, TRUE);
142 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessOnly, FALSE);
143 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessFlag, TRUE);
144 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisassembleAll, FALSE);
145 
146 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
147 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE);
148 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
149 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE);
150 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_KeepPreprocessorTempFile, FALSE);
151 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
152 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
153 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
154 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE);
155 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE);
156 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE);
157 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE);
158 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
159 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
160 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE);
161 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE);
162 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE);
163 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE);
164 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE);
165 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_WarningsAsErrors, FALSE);
166 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE);
167 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE);
168 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE);
169 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE);
170 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE);
171 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayWarnings, TRUE);
172 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE);
173 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING);
174 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE);
175 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_VerboseTemplates, FALSE);
176 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE);
177 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE);
178 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, FALSE);
179 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_PruneParseTree, FALSE);
180 
181 
182 #define HEX_OUTPUT_NONE             0
183 #define HEX_OUTPUT_C                1
184 #define HEX_OUTPUT_ASM              2
185 #define HEX_OUTPUT_ASL              3
186 
187 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE);
188 
189 
190 /* Files */
191 
192 ASL_EXTERN char                     *Gbl_DirectoryPath;
193 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
194 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
195 ASL_EXTERN ASL_INCLUDE_DIR          ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL);
196 ASL_EXTERN char                     *Gbl_CurrentInputFilename;
197 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL);
198 
199 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
200 
201 
202 /* Statistics */
203 
204 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_InputByteCount, 0);
205 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_InputFieldCount, 0);
206 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_NsLookupCount, 0);
207 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalKeywords, 0);
208 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalNamedObjects, 0);
209 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalExecutableOpcodes, 0);
210 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalParseNodes, 0);
211 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalMethods, 0);
212 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalAllocations, 0);
213 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalAllocated, 0);
214 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (TotalFolds, 0);
215 
216 
217 /* Local caches */
218 
219 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_ParseOpCount, 0);
220 ASL_EXTERN ASL_CACHE_INFO           ASL_INIT_GLOBAL (*Gbl_ParseOpCacheList, NULL);
221 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ParseOpCacheNext, NULL);
222 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*Gbl_ParseOpCacheLast, NULL);
223 
224 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_StringCount, 0);
225 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_StringSize, 0);
226 ASL_EXTERN ASL_CACHE_INFO           ASL_INIT_GLOBAL (*Gbl_StringCacheList, NULL);
227 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL);
228 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL);
229 
230 /* Map file */
231 
232 ASL_EXTERN ACPI_GPIO_INFO           ASL_INIT_GLOBAL (*Gbl_GpioList, NULL);
233 ASL_EXTERN ACPI_SERIAL_INFO         ASL_INIT_GLOBAL (*Gbl_SerialList, NULL);
234 
235 
236 /* Misc */
237 
238 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0);
239 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_TempCount, 0);
240 ASL_EXTERN ACPI_PARSE_OBJECT        ASL_INIT_GLOBAL (*RootNode, NULL);
241 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_TableLength, 0);
242 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_SourceLine, 0);
243 ASL_EXTERN ASL_LISTING_NODE         ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL);
244 ASL_EXTERN ACPI_PARSE_OBJECT        *Gbl_FirstLevelInsertionNode;
245 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_FileType, 0);
246 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_Signature, NULL);
247 ASL_EXTERN char                     *Gbl_TemplateSignature;
248 
249 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
250 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
251 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLine, 0);
252 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_DisabledMessagesIndex, 0);
253 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
254 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
255 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0);
256 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG");
257 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID");
258 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_PruneDepth, 0);
259 ASL_EXTERN UINT16                   ASL_INIT_GLOBAL (Gbl_PruneType, 0);
260 
261 
262 /* Static structures */
263 
264 ASL_EXTERN ASL_ANALYSIS_WALK_INFO   AnalysisWalkInfo;
265 ASL_EXTERN ACPI_TABLE_HEADER        TableHeader;
266 
267 /* Event timing */
268 
269 #define ASL_NUM_EVENTS              20
270 ASL_EXTERN ASL_EVENT_INFO           AslGbl_Events[ASL_NUM_EVENTS];
271 ASL_EXTERN UINT8                    AslGbl_NextEvent;
272 ASL_EXTERN UINT8                    AslGbl_NamespaceEvent;
273 
274 /* Scratch buffers */
275 
276 ASL_EXTERN UINT8                    Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
277 ASL_EXTERN char                     MsgBuffer[ASL_MSG_BUFFER_SIZE];
278 ASL_EXTERN char                     StringBuffer[ASL_MSG_BUFFER_SIZE];
279 ASL_EXTERN char                     StringBuffer2[ASL_MSG_BUFFER_SIZE];
280 ASL_EXTERN UINT32                   Gbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES];
281 
282 
283 #endif /* __ASLGLOBAL_H */
284