1 /******************************************************************************
3 * Module Name: dtcompiler.h - header for data table compiler
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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
;
121 UINT32 SizeOfLengthField
;
132 /* List of all field names and values from the input source */
134 DT_EXTERN DT_FIELD
DT_INIT_GLOBAL (*Gbl_FieldList
, NULL
);
136 /* List of all compiled tables and subtables */
138 DT_EXTERN DT_SUBTABLE
DT_INIT_GLOBAL (*Gbl_RootTable
, NULL
);
140 /* Stack for subtables */
142 DT_EXTERN DT_SUBTABLE
DT_INIT_GLOBAL (*Gbl_SubtableStack
, NULL
);
144 /* List for defined labels */
146 DT_EXTERN DT_FIELD
DT_INIT_GLOBAL (*Gbl_LabelList
, NULL
);
148 /* Current offset within the binary output table */
150 DT_EXTERN UINT32
DT_INIT_GLOBAL (Gbl_CurrentTableOffset
, 0);
154 DT_EXTERN UINT32
DT_INIT_GLOBAL (Gbl_SubtableCount
, 0);
155 DT_EXTERN ASL_CACHE_INFO
DT_INIT_GLOBAL (*Gbl_SubtableCacheList
, NULL
);
156 DT_EXTERN DT_SUBTABLE
DT_INIT_GLOBAL (*Gbl_SubtableCacheNext
, NULL
);
157 DT_EXTERN DT_SUBTABLE
DT_INIT_GLOBAL (*Gbl_SubtableCacheLast
, NULL
);
159 DT_EXTERN UINT32
DT_INIT_GLOBAL (Gbl_FieldCount
, 0);
160 DT_EXTERN ASL_CACHE_INFO
DT_INIT_GLOBAL (*Gbl_FieldCacheList
, NULL
);
161 DT_EXTERN DT_FIELD
DT_INIT_GLOBAL (*Gbl_FieldCacheNext
, NULL
);
162 DT_EXTERN DT_FIELD
DT_INIT_GLOBAL (*Gbl_FieldCacheLast
, NULL
);
165 /* dtcompiler - main module */
170 ACPI_DMTABLE_INFO
*Info
,
171 DT_SUBTABLE
**RetSubtable
,
175 DtCompileTwoSubtables (
177 ACPI_DMTABLE_INFO
*TableInfo1
,
178 ACPI_DMTABLE_INFO
*TableInfo2
);
183 DT_SUBTABLE
**RetSubtable
);
186 /* dtio - binary and text input/output */
193 /* Flags for DtGetNextLine */
195 #define DT_ALLOW_MULTILINE_QUOTES 0x01
204 DT_SUBTABLE
*RootTable
);
215 DtWriteFieldToListing (
221 DtWriteTableToListing (
225 /* dtsubtable - compile subtables */
231 DT_SUBTABLE
**RetSubtable
);
234 DtGetSubtableLength (
236 ACPI_DMTABLE_INFO
*Info
);
239 DtSetSubtableLength (
240 DT_SUBTABLE
*Subtable
);
244 DT_SUBTABLE
*Subtable
);
256 DT_SUBTABLE
*ParentTable
,
257 DT_SUBTABLE
*Subtable
);
261 DT_SUBTABLE
*ParentTable
,
262 DT_SUBTABLE
*ChildTable
);
265 DtGetParentSubtable (
266 DT_SUBTABLE
*Subtable
);
269 /* dtexpress - Integer expressions and labels */
272 DtResolveIntegerExpression (
274 UINT64
*ReturnValue
);
288 DT_FIELD
*FieldList
);
291 /* dtfield - Compile individual fields within a table */
319 ACPI_DMTABLE_INFO
*Info
);
322 /* dtparser - lex/yacc files */
325 DtEvaluateExpression (
341 /* dtutils - Miscellaneous utilities */
344 void (*DT_WALK_CALLBACK
) (
345 DT_SUBTABLE
*Subtable
,
351 DT_SUBTABLE
*StartTable
,
352 DT_WALK_CALLBACK UserFunction
,
360 DT_FIELD
*FieldObject
,
367 DT_FIELD
*FieldObject
,
373 DT_FIELD
*FieldObject
,
382 ACPI_DMTABLE_INFO
*Info
);
391 ACPI_DMTABLE_INFO
*Info
);
395 UINT8
*ChecksumPointer
);
402 UtSubtableCacheCalloc (
414 /* dttable - individual table compilation */
418 DT_FIELD
**PFieldList
);
422 DT_FIELD
**PFieldList
);
522 DT_FIELD
**PFieldList
);
568 UINT32
*PFieldLength
);
571 DtGetGenericTableInfo (
574 /* ACPI Table templates */
576 extern const unsigned char TemplateAsf
[];
577 extern const unsigned char TemplateBoot
[];
578 extern const unsigned char TemplateBert
[];
579 extern const unsigned char TemplateBgrt
[];
580 extern const unsigned char TemplateCpep
[];
581 extern const unsigned char TemplateCsrt
[];
582 extern const unsigned char TemplateDbg2
[];
583 extern const unsigned char TemplateDbgp
[];
584 extern const unsigned char TemplateDmar
[];
585 extern const unsigned char TemplateDrtm
[];
586 extern const unsigned char TemplateEcdt
[];
587 extern const unsigned char TemplateEinj
[];
588 extern const unsigned char TemplateErst
[];
589 extern const unsigned char TemplateFadt
[];
590 extern const unsigned char TemplateFpdt
[];
591 extern const unsigned char TemplateGtdt
[];
592 extern const unsigned char TemplateHest
[];
593 extern const unsigned char TemplateHpet
[];
594 extern const unsigned char TemplateIort
[];
595 extern const unsigned char TemplateIvrs
[];
596 extern const unsigned char TemplateLpit
[];
597 extern const unsigned char TemplateMadt
[];
598 extern const unsigned char TemplateMcfg
[];
599 extern const unsigned char TemplateMchi
[];
600 extern const unsigned char TemplateMpst
[];
601 extern const unsigned char TemplateMsct
[];
602 extern const unsigned char TemplateMsdm
[];
603 extern const unsigned char TemplateMtmr
[];
604 extern const unsigned char TemplateNfit
[];
605 extern const unsigned char TemplatePcct
[];
606 extern const unsigned char TemplatePmtt
[];
607 extern const unsigned char TemplateRasf
[];
608 extern const unsigned char TemplateRsdt
[];
609 extern const unsigned char TemplateS3pt
[];
610 extern const unsigned char TemplateSbst
[];
611 extern const unsigned char TemplateSlic
[];
612 extern const unsigned char TemplateSlit
[];
613 extern const unsigned char TemplateSpcr
[];
614 extern const unsigned char TemplateSpmi
[];
615 extern const unsigned char TemplateSrat
[];
616 extern const unsigned char TemplateStao
[];
617 extern const unsigned char TemplateTcpa
[];
618 extern const unsigned char TemplateTpm2
[];
619 extern const unsigned char TemplateUefi
[];
620 extern const unsigned char TemplateVrtc
[];
621 extern const unsigned char TemplateWaet
[];
622 extern const unsigned char TemplateWdat
[];
623 extern const unsigned char TemplateWddt
[];
624 extern const unsigned char TemplateWdrt
[];
625 extern const unsigned char TemplateWpbt
[];
626 extern const unsigned char TemplateXenv
[];
627 extern const unsigned char TemplateXsdt
[];