1 /******************************************************************************
3 * Module Name: dtcompiler.h - header for data table compiler
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, 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__
53 #define ASL_FIELD_CACHE_SIZE 512
54 #define ASL_SUBTABLE_CACHE_SIZE 128
59 #ifdef _DECLARE_DT_GLOBALS
61 #define DT_INIT_GLOBAL(a,b) (a)=(b)
63 #define DT_EXTERN extern
64 #define DT_INIT_GLOBAL(a,b) (a)
68 /* Types for individual fields (one per input line) */
70 #define DT_FIELD_TYPE_STRING 0
71 #define DT_FIELD_TYPE_INTEGER 1
72 #define DT_FIELD_TYPE_BUFFER 2
73 #define DT_FIELD_TYPE_PCI_PATH 3
74 #define DT_FIELD_TYPE_FLAG 4
75 #define DT_FIELD_TYPE_FLAGS_INTEGER 5
76 #define DT_FIELD_TYPE_INLINE_SUBTABLE 6
77 #define DT_FIELD_TYPE_UUID 7
78 #define DT_FIELD_TYPE_UNICODE 8
79 #define DT_FIELD_TYPE_DEVICE_PATH 9
80 #define DT_FIELD_TYPE_LABEL 10
84 * Structure used for each individual field within an ACPI table
86 typedef struct dt_field
88 char *Name; /* Field name (from name : value) */
89 char *Value; /* Field value (from name : value) */
90 UINT32 StringLength;/* Length of Value */
91 struct dt_field *Next; /* Next field */
92 struct dt_field *NextLabel; /* If field is a label, next label */
93 UINT32 Line; /* Line number for this field */
94 UINT32 ByteOffset; /* Offset in source file for field */
95 UINT32 NameColumn; /* Start column for field name */
96 UINT32 Column; /* Start column for field value */
97 UINT32 TableOffset; /* Binary offset within ACPI table */
102 /* Flags for above */
104 #define DT_FIELD_NOT_ALLOCATED 1
108 * Structure used for individual subtables within an ACPI table
110 typedef struct dt_subtable
112 struct dt_subtable *Parent;
113 struct dt_subtable *Child;
114 struct dt_subtable *Peer;
115 struct dt_subtable *StackTop;
120 UINT32 SizeOfLengthField;
131 /* List of all field names and values from the input source */
133 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldList, NULL);
135 /* List of all compiled tables and subtables */
137 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_RootTable, NULL);
139 /* Stack for subtables */
141 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL);
143 /* List for defined labels */
145 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL);
147 /* Current offset within the binary output table */
149 DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0);
153 DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_SubtableCount, 0);
154 DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_SubtableCacheList, NULL);
155 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheNext, NULL);
156 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheLast, NULL);
158 DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_FieldCount, 0);
159 DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_FieldCacheList, NULL);
160 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheNext, NULL);
161 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheLast, NULL);
164 /* dtcompiler - main module */
169 ACPI_DMTABLE_INFO *Info,
170 DT_SUBTABLE **RetSubtable,
174 /* dtio - binary and text input/output */
186 DT_SUBTABLE *RootTable);
197 DtWriteFieldToListing (
203 DtWriteTableToListing (
207 /* dtsubtable - compile subtables */
213 DT_SUBTABLE **RetSubtable);
216 DtGetSubtableLength (
218 ACPI_DMTABLE_INFO *Info);
221 DtSetSubtableLength (
222 DT_SUBTABLE *Subtable);
226 DT_SUBTABLE *Subtable);
238 DT_SUBTABLE *ParentTable,
239 DT_SUBTABLE *Subtable);
243 DT_SUBTABLE *ParentTable,
244 DT_SUBTABLE *ChildTable);
247 DtGetParentSubtable (
248 DT_SUBTABLE *Subtable);
251 /* dtexpress - Integer expressions and labels */
254 DtResolveIntegerExpression (
256 UINT64 *ReturnValue);
270 DT_FIELD *FieldList);
273 /* dtfield - Compile individual fields within a table */
301 ACPI_DMTABLE_INFO *Info);
304 /* dtparser - lex/yacc files */
307 DtEvaluateExpression (
323 /* dtutils - Miscellaneous utilities */
326 void (*DT_WALK_CALLBACK) (
327 DT_SUBTABLE *Subtable,
333 DT_SUBTABLE *StartTable,
334 DT_WALK_CALLBACK UserFunction,
342 DT_FIELD *FieldObject,
349 DT_FIELD *FieldObject,
355 DT_FIELD *FieldObject,
361 UINT64 *ReturnInteger);
369 ACPI_DMTABLE_INFO *Info);
378 ACPI_DMTABLE_INFO *Info);
382 UINT8 *ChecksumPointer);
389 UtSubtableCacheCalloc (
401 /* dttable - individual table compilation */
405 DT_FIELD **PFieldList);
409 DT_FIELD **PFieldList);
497 DT_FIELD **PFieldList);
532 DtGetGenericTableInfo (
535 /* ACPI Table templates */
537 extern const unsigned char TemplateAsf[];
538 extern const unsigned char TemplateBoot[];
539 extern const unsigned char TemplateBert[];
540 extern const unsigned char TemplateBgrt[];
541 extern const unsigned char TemplateCpep[];
542 extern const unsigned char TemplateCsrt[];
543 extern const unsigned char TemplateDbg2[];
544 extern const unsigned char TemplateDbgp[];
545 extern const unsigned char TemplateDmar[];
546 extern const unsigned char TemplateEcdt[];
547 extern const unsigned char TemplateEinj[];
548 extern const unsigned char TemplateErst[];
549 extern const unsigned char TemplateFadt[];
550 extern const unsigned char TemplateFpdt[];
551 extern const unsigned char TemplateGtdt[];
552 extern const unsigned char TemplateHest[];
553 extern const unsigned char TemplateHpet[];
554 extern const unsigned char TemplateIvrs[];
555 extern const unsigned char TemplateLpit[];
556 extern const unsigned char TemplateMadt[];
557 extern const unsigned char TemplateMcfg[];
558 extern const unsigned char TemplateMchi[];
559 extern const unsigned char TemplateMpst[];
560 extern const unsigned char TemplateMsct[];
561 extern const unsigned char TemplateMsdm[];
562 extern const unsigned char TemplateMtmr[];
563 extern const unsigned char TemplatePcct[];
564 extern const unsigned char TemplatePmtt[];
565 extern const unsigned char TemplateRsdt[];
566 extern const unsigned char TemplateS3pt[];
567 extern const unsigned char TemplateSbst[];
568 extern const unsigned char TemplateSlic[];
569 extern const unsigned char TemplateSlit[];
570 extern const unsigned char TemplateSpcr[];
571 extern const unsigned char TemplateSpmi[];
572 extern const unsigned char TemplateSrat[];
573 extern const unsigned char TemplateTcpa[];
574 extern const unsigned char TemplateTpm2[];
575 extern const unsigned char TemplateUefi[];
576 extern const unsigned char TemplateVrtc[];
577 extern const unsigned char TemplateWaet[];
578 extern const unsigned char TemplateWdat[];
579 extern const unsigned char TemplateWddt[];
580 extern const unsigned char TemplateWdrt[];
581 extern const unsigned char TemplateXsdt[];