]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/dev/acpica/compiler/dtcompiler.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / dev / acpica / compiler / dtcompiler.h
1 /******************************************************************************
2  *
3  * Module Name: dtcompiler.h - header for data table compiler
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2011, 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 #define __DTCOMPILER_H__
45
46 #ifndef _DTCOMPILER
47 #define _DTCOMPILER
48
49 #include <stdio.h>
50 #include <contrib/dev/acpica/include/acdisasm.h>
51
52
53 #undef DT_EXTERN
54
55 #ifdef _DECLARE_DT_GLOBALS
56 #define DT_EXTERN
57 #define DT_INIT_GLOBAL(a,b)         (a)=(b)
58 #else
59 #define DT_EXTERN                   extern
60 #define DT_INIT_GLOBAL(a,b)         (a)
61 #endif
62
63
64 /* Types for individual fields (one per input line) */
65
66 #define DT_FIELD_TYPE_STRING            0
67 #define DT_FIELD_TYPE_INTEGER           1
68 #define DT_FIELD_TYPE_BUFFER            2
69 #define DT_FIELD_TYPE_PCI_PATH          3
70 #define DT_FIELD_TYPE_FLAG              4
71 #define DT_FIELD_TYPE_FLAGS_INTEGER     5
72 #define DT_FIELD_TYPE_INLINE_SUBTABLE   6
73 #define DT_FIELD_TYPE_UUID              7
74 #define DT_FIELD_TYPE_UNICODE           8
75 #define DT_FIELD_TYPE_DEVICE_PATH       9
76 #define DT_FIELD_TYPE_LABEL             10
77
78
79 /*
80  * Structure used for each individual field within an ACPI table
81  */
82 typedef struct dt_field
83 {
84     char                    *Name;      /* Field name (from name : value) */
85     char                    *Value;     /* Field value (from name : value) */
86     struct dt_field         *Next;      /* Next field */
87     struct dt_field         *NextLabel; /* If field is a label, next label */
88     UINT32                  Line;       /* Line number for this field */
89     UINT32                  ByteOffset; /* Offset in source file for field */
90     UINT32                  NameColumn; /* Start column for field name */
91     UINT32                  Column;     /* Start column for field value */
92     UINT32                  TableOffset;/* Binary offset within ACPI table */
93     UINT8                   Flags;
94
95 } DT_FIELD;
96
97 /* Flags for above */
98
99 #define DT_FIELD_NOT_ALLOCATED      1
100
101
102 /*
103  * Structure used for individual subtables within an ACPI table
104  */
105 typedef struct dt_subtable
106 {
107     struct dt_subtable      *Parent;
108     struct dt_subtable      *Child;
109     struct dt_subtable      *Peer;
110     struct dt_subtable      *StackTop;
111     UINT8                   *Buffer;
112     UINT8                   *LengthField;
113     UINT32                  Length;
114     UINT32                  TotalLength;
115     UINT32                  SizeOfLengthField;
116     UINT8                   Flags;
117
118 } DT_SUBTABLE;
119
120
121 /*
122  * Globals
123  */
124
125 /* List of all field names and values from the input source */
126
127 DT_EXTERN DT_FIELD          DT_INIT_GLOBAL (*Gbl_FieldList, NULL);
128
129 /* List of all compiled tables and subtables */
130
131 DT_EXTERN DT_SUBTABLE       DT_INIT_GLOBAL (*Gbl_RootTable, NULL);
132
133 /* Stack for subtables */
134
135 DT_EXTERN DT_SUBTABLE       DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL);
136
137 /* List for defined labels */
138
139 DT_EXTERN DT_FIELD          DT_INIT_GLOBAL (*Gbl_LabelList, NULL);
140
141 /* Current offset within the binary output table */
142
143 DT_EXTERN UINT32            DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0);
144
145
146 /* dtcompiler - main module */
147
148 ACPI_STATUS
149 DtCompileTable (
150     DT_FIELD                **Field,
151     ACPI_DMTABLE_INFO       *Info,
152     DT_SUBTABLE             **RetSubtable,
153     BOOLEAN                 Required);
154
155
156 /* dtio - binary and text input/output */
157
158 DT_FIELD *
159 DtScanFile (
160     FILE                    *Handle);
161
162 void
163 DtOutputBinary (
164     DT_SUBTABLE             *RootTable);
165
166 void
167 DtWriteFieldToListing (
168     UINT8                   *Buffer,
169     DT_FIELD                *Field,
170     UINT32                  Length);
171
172 void
173 DtWriteTableToListing (
174     void);
175
176
177 /* dtsubtable - compile subtables */
178
179 void
180 DtCreateSubtable (
181     UINT8                   *Buffer,
182     UINT32                  Length,
183     DT_SUBTABLE             **RetSubtable);
184
185 UINT32
186 DtGetSubtableLength (
187     DT_FIELD                *Field,
188     ACPI_DMTABLE_INFO       *Info);
189
190 void
191 DtSetSubtableLength (
192     DT_SUBTABLE             *Subtable);
193
194 void
195 DtPushSubtable (
196     DT_SUBTABLE             *Subtable);
197
198 void
199 DtPopSubtable (
200     void);
201
202 DT_SUBTABLE *
203 DtPeekSubtable (
204     void);
205
206 void
207 DtInsertSubtable (
208     DT_SUBTABLE             *ParentTable,
209     DT_SUBTABLE             *Subtable);
210
211 DT_SUBTABLE *
212 DtGetNextSubtable (
213     DT_SUBTABLE             *ParentTable,
214     DT_SUBTABLE             *ChildTable);
215
216 DT_SUBTABLE *
217 DtGetParentSubtable (
218     DT_SUBTABLE             *Subtable);
219
220
221 /* dtexpress - Integer expressions and labels */
222
223 ACPI_STATUS
224 DtResolveIntegerExpression (
225     DT_FIELD                *Field,
226     UINT64                  *ReturnValue);
227
228 UINT64
229 DtDoOperator (
230     UINT64                  LeftValue,
231     UINT32                  Operator,
232     UINT64                  RightValue);
233
234 UINT64
235 DtResolveLabel (
236     char                    *LabelString);
237
238 void
239 DtDetectAllLabels (
240     DT_FIELD                *FieldList);
241
242
243 /* dtfield - Compile individual fields within a table */
244
245 void
246 DtCompileOneField (
247     UINT8                   *Buffer,
248     DT_FIELD                *Field,
249     UINT32                  ByteLength,
250     UINT8                   Type,
251     UINT8                   Flags);
252
253 void
254 DtCompileInteger (
255     UINT8                   *Buffer,
256     DT_FIELD                *Field,
257     UINT32                  ByteLength,
258     UINT8                   Flags);
259
260 UINT32
261 DtCompileBuffer (
262     UINT8                   *Buffer,
263     char                    *Value,
264     DT_FIELD                *Field,
265     UINT32                  ByteLength);
266
267 void
268 DtCompileFlag (
269     UINT8                   *Buffer,
270     DT_FIELD                *Field,
271     ACPI_DMTABLE_INFO       *Info);
272
273
274 /* dtparser - lex/yacc files */
275
276 UINT64
277 DtEvaluateExpression (
278     char                    *ExprString);
279
280 int
281 DtInitLexer (
282     char                    *String);
283
284 void
285 DtTerminateLexer (
286     void);
287
288 char *
289 DtGetOpName (
290     UINT32                  ParseOpcode);
291
292
293 /* dtutils - Miscellaneous utilities */
294
295 typedef
296 void (*DT_WALK_CALLBACK) (
297     DT_SUBTABLE             *Subtable,
298     void                    *Context,
299     void                    *ReturnValue);
300
301 void
302 DtWalkTableTree (
303     DT_SUBTABLE             *StartTable,
304     DT_WALK_CALLBACK        UserFunction,
305     void                    *Context,
306     void                    *ReturnValue);
307
308 void
309 DtError (
310     UINT8                   Level,
311     UINT8                   MessageId,
312     DT_FIELD                *FieldObject,
313     char                    *ExtraMessage);
314
315 void
316 DtNameError (
317     UINT8                   Level,
318     UINT8                   MessageId,
319     DT_FIELD                *FieldObject,
320     char                    *ExtraMessage);
321
322 void
323 DtFatal (
324     UINT8                   MessageId,
325     DT_FIELD                *FieldObject,
326     char                    *ExtraMessage);
327
328 ACPI_STATUS
329 DtStrtoul64 (
330     char                    *String,
331     UINT64                  *ReturnInteger);
332
333 UINT32
334 DtGetFileSize (
335     FILE                    *Handle);
336
337 char*
338 DtGetFieldValue (
339     DT_FIELD                *Field);
340
341 UINT8
342 DtGetFieldType (
343     ACPI_DMTABLE_INFO       *Info);
344
345 UINT32
346 DtGetBufferLength (
347     char                    *Buffer);
348
349 UINT32
350 DtGetFieldLength (
351     DT_FIELD                *Field,
352     ACPI_DMTABLE_INFO       *Info);
353
354 void
355 DtSetTableChecksum (
356     UINT8                   *ChecksumPointer);
357
358 void
359 DtSetTableLength(
360     void);
361
362 void
363 DtFreeFieldList (
364     void);
365
366
367 /* dttable - individual table compilation */
368
369 ACPI_STATUS
370 DtCompileFacs (
371     DT_FIELD                **PFieldList);
372
373 ACPI_STATUS
374 DtCompileRsdp (
375     DT_FIELD                **PFieldList);
376
377 ACPI_STATUS
378 DtCompileAsf (
379     void                    **PFieldList);
380
381 ACPI_STATUS
382 DtCompileCpep (
383     void                    **PFieldList);
384
385 ACPI_STATUS
386 DtCompileDmar (
387     void                    **PFieldList);
388
389 ACPI_STATUS
390 DtCompileEinj (
391     void                    **PFieldList);
392
393 ACPI_STATUS
394 DtCompileErst (
395     void                    **PFieldList);
396
397 ACPI_STATUS
398 DtCompileFadt (
399     void                    **PFieldList);
400
401 ACPI_STATUS
402 DtCompileHest (
403     void                    **PFieldList);
404
405 ACPI_STATUS
406 DtCompileIvrs (
407     void                    **PFieldList);
408
409 ACPI_STATUS
410 DtCompileMadt (
411     void                    **PFieldList);
412
413 ACPI_STATUS
414 DtCompileMcfg (
415     void                    **PFieldList);
416
417 ACPI_STATUS
418 DtCompileMsct (
419     void                    **PFieldList);
420
421 ACPI_STATUS
422 DtCompileRsdt (
423     void                    **PFieldList);
424
425 ACPI_STATUS
426 DtCompileSlic (
427     void                    **PFieldList);
428
429 ACPI_STATUS
430 DtCompileSlit (
431     void                    **PFieldList);
432
433 ACPI_STATUS
434 DtCompileSrat (
435     void                    **PFieldList);
436
437 ACPI_STATUS
438 DtCompileUefi (
439     void                    **PFieldList);
440
441 ACPI_STATUS
442 DtCompileWdat (
443     void                    **PFieldList);
444
445 ACPI_STATUS
446 DtCompileXsdt (
447     void                    **PFieldList);
448
449 ACPI_STATUS
450 DtCompileGeneric (
451     void                    **PFieldList);
452
453 ACPI_DMTABLE_INFO *
454 DtGetGenericTableInfo (
455     char                    *Name);
456
457 /* ACPI Table templates */
458
459 extern const unsigned char  TemplateAsf[];
460 extern const unsigned char  TemplateBoot[];
461 extern const unsigned char  TemplateBert[];
462 extern const unsigned char  TemplateCpep[];
463 extern const unsigned char  TemplateDbgp[];
464 extern const unsigned char  TemplateDmar[];
465 extern const unsigned char  TemplateEcdt[];
466 extern const unsigned char  TemplateEinj[];
467 extern const unsigned char  TemplateErst[];
468 extern const unsigned char  TemplateFadt[];
469 extern const unsigned char  TemplateHest[];
470 extern const unsigned char  TemplateHpet[];
471 extern const unsigned char  TemplateIvrs[];
472 extern const unsigned char  TemplateMadt[];
473 extern const unsigned char  TemplateMcfg[];
474 extern const unsigned char  TemplateMchi[];
475 extern const unsigned char  TemplateMsct[];
476 extern const unsigned char  TemplateRsdt[];
477 extern const unsigned char  TemplateSbst[];
478 extern const unsigned char  TemplateSlic[];
479 extern const unsigned char  TemplateSlit[];
480 extern const unsigned char  TemplateSpcr[];
481 extern const unsigned char  TemplateSpmi[];
482 extern const unsigned char  TemplateSrat[];
483 extern const unsigned char  TemplateTcpa[];
484 extern const unsigned char  TemplateUefi[];
485 extern const unsigned char  TemplateWaet[];
486 extern const unsigned char  TemplateWdat[];
487 extern const unsigned char  TemplateWddt[];
488 extern const unsigned char  TemplateWdrt[];
489 extern const unsigned char  TemplateXsdt[];
490
491 #endif