1 /******************************************************************************
3 * Module Name: dtcompiler.h - header for data table compiler
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, 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.
44 #define __DTCOMPILER_H__
50 #include <contrib/dev/acpica/include/acdisasm.h>
55 #ifdef _DECLARE_DT_GLOBALS
57 #define DT_INIT_GLOBAL(a,b) (a)=(b)
59 #define DT_EXTERN extern
60 #define DT_INIT_GLOBAL(a,b) (a)
64 /* Types for individual fields (one per input line) */
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
80 * Structure used for each individual field within an ACPI table
82 typedef struct dt_field
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 */
99 #define DT_FIELD_NOT_ALLOCATED 1
103 * Structure used for individual subtables within an ACPI table
105 typedef struct dt_subtable
107 struct dt_subtable *Parent;
108 struct dt_subtable *Child;
109 struct dt_subtable *Peer;
110 struct dt_subtable *StackTop;
115 UINT32 SizeOfLengthField;
125 /* List of all field names and values from the input source */
127 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldList, NULL);
129 /* List of all compiled tables and subtables */
131 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_RootTable, NULL);
133 /* Stack for subtables */
135 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL);
137 /* List for defined labels */
139 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL);
141 /* Current offset within the binary output table */
143 DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0);
146 /* dtcompiler - main module */
151 ACPI_DMTABLE_INFO *Info,
152 DT_SUBTABLE **RetSubtable,
156 /* dtio - binary and text input/output */
164 DT_SUBTABLE *RootTable);
167 DtWriteFieldToListing (
173 DtWriteTableToListing (
177 /* dtsubtable - compile subtables */
183 DT_SUBTABLE **RetSubtable);
186 DtGetSubtableLength (
188 ACPI_DMTABLE_INFO *Info);
191 DtSetSubtableLength (
192 DT_SUBTABLE *Subtable);
196 DT_SUBTABLE *Subtable);
208 DT_SUBTABLE *ParentTable,
209 DT_SUBTABLE *Subtable);
213 DT_SUBTABLE *ParentTable,
214 DT_SUBTABLE *ChildTable);
217 DtGetParentSubtable (
218 DT_SUBTABLE *Subtable);
221 /* dtexpress - Integer expressions and labels */
224 DtResolveIntegerExpression (
226 UINT64 *ReturnValue);
240 DT_FIELD *FieldList);
243 /* dtfield - Compile individual fields within a table */
271 ACPI_DMTABLE_INFO *Info);
274 /* dtparser - lex/yacc files */
277 DtEvaluateExpression (
293 /* dtutils - Miscellaneous utilities */
296 void (*DT_WALK_CALLBACK) (
297 DT_SUBTABLE *Subtable,
303 DT_SUBTABLE *StartTable,
304 DT_WALK_CALLBACK UserFunction,
312 DT_FIELD *FieldObject,
319 DT_FIELD *FieldObject,
325 DT_FIELD *FieldObject,
331 UINT64 *ReturnInteger);
343 ACPI_DMTABLE_INFO *Info);
352 ACPI_DMTABLE_INFO *Info);
356 UINT8 *ChecksumPointer);
367 /* dttable - individual table compilation */
371 DT_FIELD **PFieldList);
375 DT_FIELD **PFieldList);
454 DtGetGenericTableInfo (
457 /* ACPI Table templates */
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[];