]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/compiler/asltypes.h
Import ACPICA 20170224.
[FreeBSD/FreeBSD.git] / source / compiler / asltypes.h
1 /******************************************************************************
2  *
3  * Module Name: asltypes.h - compiler data types and struct definitions
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2017, 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 __ASLTYPES_H
45 #define __ASLTYPES_H
46
47
48 /*******************************************************************************
49  *
50  * Structure definitions
51  *
52  ******************************************************************************/
53
54
55 /* Op flags for the ACPI_PARSE_OBJECT */
56
57 #define NODE_VISITED                0x00000001
58 #define NODE_AML_PACKAGE            0x00000002
59 #define NODE_IS_TARGET              0x00000004
60 #define NODE_IS_RESOURCE_DESC       0x00000008
61 #define NODE_IS_RESOURCE_FIELD      0x00000010
62 #define NODE_HAS_NO_EXIT            0x00000020
63 #define NODE_IF_HAS_NO_EXIT         0x00000040
64 #define NODE_NAME_INTERNALIZED      0x00000080
65 #define NODE_METHOD_NO_RETVAL       0x00000100
66 #define NODE_METHOD_SOME_NO_RETVAL  0x00000200
67 #define NODE_RESULT_NOT_USED        0x00000400
68 #define NODE_METHOD_TYPED           0x00000800
69 #define NODE_COULD_NOT_REDUCE       0x00001000
70 #define NODE_COMPILE_TIME_CONST     0x00002000
71 #define NODE_IS_TERM_ARG            0x00004000
72 #define NODE_WAS_ONES_OP            0x00008000
73 #define NODE_IS_NAME_DECLARATION    0x00010000
74 #define NODE_COMPILER_EMITTED       0x00020000
75 #define NODE_IS_DUPLICATE           0x00040000
76 #define NODE_IS_RESOURCE_DATA       0x00080000
77 #define NODE_IS_NULL_RETURN         0x00100000
78
79 /* Keeps information about individual control methods */
80
81 typedef struct asl_method_info
82 {
83     ACPI_PARSE_OBJECT       *Op;
84     ACPI_PARSE_OBJECT       *CurrentOp;
85     struct asl_method_info  *Next;
86     UINT32                  ValidArgTypes[ACPI_METHOD_NUM_ARGS];
87     UINT32                  ValidReturnTypes;
88     UINT32                  NumReturnNoValue;
89     UINT32                  NumReturnWithValue;
90     UINT8                   NumArguments;
91     UINT8                   LocalInitialized[ACPI_METHOD_NUM_LOCALS];
92     UINT8                   ArgInitialized[ACPI_METHOD_NUM_ARGS];
93     UINT8                   HasBeenTyped;
94     UINT8                   ShouldBeSerialized;
95
96 } ASL_METHOD_INFO;
97
98
99 /* Parse tree walk info for control method analysis */
100
101 typedef struct asl_analysis_walk_info
102 {
103     ASL_METHOD_INFO         *MethodStack;
104
105 } ASL_ANALYSIS_WALK_INFO;
106
107
108 /* An entry in the ParseOpcode to AmlOpcode mapping table */
109
110 typedef struct asl_mapping_entry
111 {
112     UINT32                      Value;
113     UINT32                      AcpiBtype;   /* Object type or return type */
114     UINT16                      AmlOpcode;
115     UINT8                       Flags;
116
117 } ASL_MAPPING_ENTRY;
118
119
120 /* Parse tree walk info structure */
121
122 typedef struct asl_walk_info
123 {
124     ACPI_PARSE_OBJECT           **NodePtr;
125     UINT32                      *LevelPtr;
126
127 } ASL_WALK_INFO;
128
129
130 /* File info */
131
132 typedef struct asl_file_info
133 {
134     FILE                        *Handle;
135     char                        *Filename;
136     const char                  *ShortDescription;
137     const char                  *Description;
138
139 } ASL_FILE_INFO;
140
141 typedef struct asl_file_status
142 {
143     UINT32                  Line;
144     UINT32                  Offset;
145
146 } ASL_FILE_STATUS;
147
148
149 /*
150  * File types. Note: Any changes to this table must also be reflected
151  * in the Gbl_Files array.
152  *
153  * Corresponding filename suffixes are in comments
154  *
155  * NOTE: Don't move the first 4 file types
156  *
157  * .xxx file extension: this is used as a temporary .aml file for
158  * the ASL/ASL+ converter and is deleted after conversion. This file
159  * should never be used in the interpreter.
160  */
161 typedef enum
162 {
163     ASL_FILE_STDOUT             = 0,
164     ASL_FILE_STDERR,
165     ASL_FILE_INPUT,             /* .asl */
166     ASL_FILE_AML_OUTPUT,        /* .aml */
167     ASL_FILE_SOURCE_OUTPUT,     /* .src */
168     ASL_FILE_PREPROCESSOR,      /* .pre */
169     ASL_FILE_PREPROCESSOR_USER, /* .i   */
170     ASL_FILE_LISTING_OUTPUT,    /* .lst */
171     ASL_FILE_HEX_OUTPUT,        /* .hex */
172     ASL_FILE_NAMESPACE_OUTPUT,  /* .nsp */
173     ASL_FILE_DEBUG_OUTPUT,      /* .txt */
174     ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */
175     ASL_FILE_C_SOURCE_OUTPUT,   /* .c   */
176     ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */
177     ASL_FILE_C_INCLUDE_OUTPUT,  /* .h   */
178     ASL_FILE_C_OFFSET_OUTPUT,   /* .offset.h */
179     ASL_FILE_MAP_OUTPUT,        /* .map */
180     ASL_FILE_XREF_OUTPUT,       /* .xrf */
181     ASL_FILE_CONV_DEBUG_OUTPUT, /* .cdb */
182     ASL_FILE_CONV_OUTPUT        /* .xxx */
183
184 } ASL_FILE_TYPES;
185
186
187 #define ASL_MAX_FILE_TYPE       18
188 #define ASL_NUM_FILES           (ASL_MAX_FILE_TYPE + 1)
189
190 /* Name suffixes used to create filenames for output files */
191
192 #define FILE_SUFFIX_ASL_CODE        "asl"
193 #define FILE_SUFFIX_AML_CODE        "aml"
194 #define FILE_SUFFIX_SOURCE          "src"
195 #define FILE_SUFFIX_PREPROCESSOR    "pre"
196 #define FILE_SUFFIX_PREPROC_USER    "i"
197 #define FILE_SUFFIX_LISTING         "lst"
198 #define FILE_SUFFIX_HEX_DUMP        "hex"
199 #define FILE_SUFFIX_NAMESPACE       "nsp"
200 #define FILE_SUFFIX_DEBUG           "txt"
201 #define FILE_SUFFIX_ASM_SOURCE      "asm"
202 #define FILE_SUFFIX_C_SOURCE        "c"
203 #define FILE_SUFFIX_ASM_INCLUDE     "inc"
204 #define FILE_SUFFIX_C_INCLUDE       "h"
205 #define FILE_SUFFIX_C_OFFSET        "offset.h"
206 #define FILE_SUFFIX_MAP             "map"
207 #define FILE_SUFFIX_XREF            "xrf"
208 #define FILE_SUFFIX_CONVERT_AML     "xxx"
209 #define FILE_SUFFIX_CONVERT_DEBUG   "cdb"
210
211
212 /* Cache block structure for ParseOps and Strings */
213
214 typedef struct asl_cache_info
215 {
216     void                            *Next;
217     char                            Buffer[1];
218
219 } ASL_CACHE_INFO;
220
221
222 typedef struct asl_include_dir
223 {
224     char                        *Dir;
225     struct asl_include_dir      *Next;
226
227 } ASL_INCLUDE_DIR;
228
229
230 /* An entry in the exception list, one for each error/warning */
231
232 typedef struct asl_error_msg
233 {
234     UINT32                      LineNumber;
235     UINT32                      LogicalLineNumber;
236     UINT32                      LogicalByteOffset;
237     UINT32                      Column;
238     char                        *Message;
239     struct asl_error_msg        *Next;
240     char                        *Filename;
241     char                        *SourceLine;
242     UINT32                      FilenameLength;
243     UINT16                      MessageId;
244     UINT8                       Level;
245
246 } ASL_ERROR_MSG;
247
248
249 /* An entry in the listing file stack (for include files) */
250
251 typedef struct asl_listing_node
252 {
253     char                        *Filename;
254     UINT32                      LineNumber;
255     struct asl_listing_node     *Next;
256
257 } ASL_LISTING_NODE;
258
259
260 /* Callback interface for a parse tree walk */
261
262 /*
263  * TBD - another copy of this is in adisasm.h, fix
264  */
265 #ifndef ASL_WALK_CALLBACK_DEFINED
266 typedef
267 ACPI_STATUS (*ASL_WALK_CALLBACK) (
268     ACPI_PARSE_OBJECT           *Op,
269     UINT32                      Level,
270     void                        *Context);
271 #define ASL_WALK_CALLBACK_DEFINED
272 #endif
273
274
275 typedef struct asl_event_info
276 {
277     UINT64                      StartTime;
278     UINT64                      EndTime;
279     char                        *EventName;
280     BOOLEAN                     Valid;
281
282 } ASL_EVENT_INFO;
283
284
285 /* Hardware mapping file structures */
286
287 typedef struct acpi_gpio_info
288 {
289     struct acpi_gpio_info   *Next;
290     ACPI_PARSE_OBJECT       *Op;
291     char                    *DeviceName;
292     ACPI_NAMESPACE_NODE     *TargetNode;
293     UINT32                  References;
294     UINT32                  PinCount;
295     UINT32                  PinIndex;
296     UINT16                  PinNumber;
297     UINT8                   Type;
298     UINT8                   Direction;
299     UINT8                   Polarity;
300
301 } ACPI_GPIO_INFO;
302
303 typedef struct acpi_serial_info
304 {
305     struct acpi_serial_info *Next;
306     ACPI_PARSE_OBJECT       *Op;
307     char                    *DeviceName;
308     ACPI_NAMESPACE_NODE     *TargetNode;
309     AML_RESOURCE            *Resource;
310     UINT32                  Speed;
311     UINT16                  Address;
312
313 } ACPI_SERIAL_INFO;
314
315 typedef struct asl_method_local
316 {
317     ACPI_PARSE_OBJECT       *Op;
318     UINT8                   Flags;
319
320 } ASL_METHOD_LOCAL;
321
322 /* Values for Flags field above */
323
324 #define ASL_LOCAL_INITIALIZED   (1)
325 #define ASL_LOCAL_REFERENCED    (1<<1)
326 #define ASL_ARG_IS_LOCAL        (1<<2)
327 #define ASL_ARG_INITIALIZED     (1<<3)
328 #define ASL_ARG_REFERENCED      (1<<4)
329
330 /* Info used to track method counts for cross reference output file */
331
332 typedef struct asl_xref_info
333 {
334     UINT32                  ThisMethodInvocations;
335     UINT32                  TotalPredefinedMethods;
336     UINT32                  TotalUserMethods;
337     UINT32                  TotalUnreferenceUserMethods;
338     UINT32                  ThisObjectReferences;
339     UINT32                  TotalObjects;
340     UINT32                  TotalUnreferencedObjects;
341     ACPI_PARSE_OBJECT       *MethodOp;
342     ACPI_PARSE_OBJECT       *CurrentMethodOp;
343
344 } ASL_XREF_INFO;
345
346
347 typedef struct yy_buffer_state *YY_BUFFER_STATE;
348 typedef struct asl_file_node
349 {
350     FILE                    *File;
351     UINT32                  CurrentLineNumber;
352     YY_BUFFER_STATE         State;
353     char                    *Filename;
354     struct asl_file_node    *Next;
355
356 } ASL_FILE_NODE;
357
358 #endif  /* __ASLTYPES_H */