Sync ACPICA with Intel's version 20160831.
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / dtcompiler.h
blobaf7beadb88800708d1282787943fc2038cc4fdc4
1 /******************************************************************************
3 * Module Name: dtcompiler.h - header for data table compiler
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #define __DTCOMPILER_H__
46 #ifndef _DTCOMPILER
47 #define _DTCOMPILER
49 #include <stdio.h>
50 #include "acdisasm.h"
53 #define ASL_FIELD_CACHE_SIZE 512
54 #define ASL_SUBTABLE_CACHE_SIZE 128
57 #undef DT_EXTERN
59 #ifdef _DECLARE_DT_GLOBALS
60 #define DT_EXTERN
61 #define DT_INIT_GLOBAL(a,b) (a)=(b)
62 #else
63 #define DT_EXTERN extern
64 #define DT_INIT_GLOBAL(a,b) (a)
65 #endif
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 */
98 UINT8 Flags;
100 } DT_FIELD;
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;
116 UINT8 *Buffer;
117 UINT8 *LengthField;
118 char *Name;
119 UINT32 Length;
120 UINT32 TotalLength;
121 UINT32 SizeOfLengthField;
122 UINT16 Depth;
123 UINT8 Flags;
125 } DT_SUBTABLE;
129 * Globals
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);
152 /* Local caches */
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 */
167 ACPI_STATUS
168 DtCompileTable (
169 DT_FIELD **Field,
170 ACPI_DMTABLE_INFO *Info,
171 DT_SUBTABLE **RetSubtable,
172 BOOLEAN Required);
174 ACPI_STATUS
175 DtCompileTwoSubtables (
176 void **List,
177 ACPI_DMTABLE_INFO *TableInfo1,
178 ACPI_DMTABLE_INFO *TableInfo2);
180 ACPI_STATUS
181 DtCompilePadding (
182 UINT32 Length,
183 DT_SUBTABLE **RetSubtable);
186 /* dtio - binary and text input/output */
188 UINT32
189 DtGetNextLine (
190 FILE *Handle,
191 UINT32 Flags);
193 /* Flags for DtGetNextLine */
195 #define DT_ALLOW_MULTILINE_QUOTES 0x01
198 DT_FIELD *
199 DtScanFile (
200 FILE *Handle);
202 void
203 DtOutputBinary (
204 DT_SUBTABLE *RootTable);
206 void
207 DtDumpSubtableList (
208 void);
210 void
211 DtDumpFieldList (
212 DT_FIELD *Field);
214 void
215 DtWriteFieldToListing (
216 UINT8 *Buffer,
217 DT_FIELD *Field,
218 UINT32 Length);
220 void
221 DtWriteTableToListing (
222 void);
225 /* dtsubtable - compile subtables */
227 void
228 DtCreateSubtable (
229 UINT8 *Buffer,
230 UINT32 Length,
231 DT_SUBTABLE **RetSubtable);
233 UINT32
234 DtGetSubtableLength (
235 DT_FIELD *Field,
236 ACPI_DMTABLE_INFO *Info);
238 void
239 DtSetSubtableLength (
240 DT_SUBTABLE *Subtable);
242 void
243 DtPushSubtable (
244 DT_SUBTABLE *Subtable);
246 void
247 DtPopSubtable (
248 void);
250 DT_SUBTABLE *
251 DtPeekSubtable (
252 void);
254 void
255 DtInsertSubtable (
256 DT_SUBTABLE *ParentTable,
257 DT_SUBTABLE *Subtable);
259 DT_SUBTABLE *
260 DtGetNextSubtable (
261 DT_SUBTABLE *ParentTable,
262 DT_SUBTABLE *ChildTable);
264 DT_SUBTABLE *
265 DtGetParentSubtable (
266 DT_SUBTABLE *Subtable);
269 /* dtexpress - Integer expressions and labels */
271 ACPI_STATUS
272 DtResolveIntegerExpression (
273 DT_FIELD *Field,
274 UINT64 *ReturnValue);
276 UINT64
277 DtDoOperator (
278 UINT64 LeftValue,
279 UINT32 Operator,
280 UINT64 RightValue);
282 UINT64
283 DtResolveLabel (
284 char *LabelString);
286 void
287 DtDetectAllLabels (
288 DT_FIELD *FieldList);
291 /* dtfield - Compile individual fields within a table */
293 void
294 DtCompileOneField (
295 UINT8 *Buffer,
296 DT_FIELD *Field,
297 UINT32 ByteLength,
298 UINT8 Type,
299 UINT8 Flags);
301 void
302 DtCompileInteger (
303 UINT8 *Buffer,
304 DT_FIELD *Field,
305 UINT32 ByteLength,
306 UINT8 Flags);
308 UINT32
309 DtCompileBuffer (
310 UINT8 *Buffer,
311 char *Value,
312 DT_FIELD *Field,
313 UINT32 ByteLength);
315 void
316 DtCompileFlag (
317 UINT8 *Buffer,
318 DT_FIELD *Field,
319 ACPI_DMTABLE_INFO *Info);
322 /* dtparser - lex/yacc files */
324 UINT64
325 DtEvaluateExpression (
326 char *ExprString);
329 DtInitLexer (
330 char *String);
332 void
333 DtTerminateLexer (
334 void);
336 char *
337 DtGetOpName (
338 UINT32 ParseOpcode);
341 /* dtutils - Miscellaneous utilities */
343 typedef
344 void (*DT_WALK_CALLBACK) (
345 DT_SUBTABLE *Subtable,
346 void *Context,
347 void *ReturnValue);
349 void
350 DtWalkTableTree (
351 DT_SUBTABLE *StartTable,
352 DT_WALK_CALLBACK UserFunction,
353 void *Context,
354 void *ReturnValue);
356 void
357 DtError (
358 UINT8 Level,
359 UINT16 MessageId,
360 DT_FIELD *FieldObject,
361 char *ExtraMessage);
363 void
364 DtNameError (
365 UINT8 Level,
366 UINT16 MessageId,
367 DT_FIELD *FieldObject,
368 char *ExtraMessage);
370 void
371 DtFatal (
372 UINT16 MessageId,
373 DT_FIELD *FieldObject,
374 char *ExtraMessage);
376 char*
377 DtGetFieldValue (
378 DT_FIELD *Field);
380 UINT8
381 DtGetFieldType (
382 ACPI_DMTABLE_INFO *Info);
384 UINT32
385 DtGetBufferLength (
386 char *Buffer);
388 UINT32
389 DtGetFieldLength (
390 DT_FIELD *Field,
391 ACPI_DMTABLE_INFO *Info);
393 void
394 DtSetTableChecksum (
395 UINT8 *ChecksumPointer);
397 void
398 DtSetTableLength(
399 void);
401 DT_SUBTABLE *
402 UtSubtableCacheCalloc (
403 void);
405 DT_FIELD *
406 UtFieldCacheCalloc (
407 void);
409 void
410 DtDeleteCaches (
411 void);
414 /* dttable - individual table compilation */
416 ACPI_STATUS
417 DtCompileFacs (
418 DT_FIELD **PFieldList);
420 ACPI_STATUS
421 DtCompileRsdp (
422 DT_FIELD **PFieldList);
424 ACPI_STATUS
425 DtCompileAsf (
426 void **PFieldList);
428 ACPI_STATUS
429 DtCompileCpep (
430 void **PFieldList);
432 ACPI_STATUS
433 DtCompileCsrt (
434 void **PFieldList);
436 ACPI_STATUS
437 DtCompileDbg2 (
438 void **PFieldList);
440 ACPI_STATUS
441 DtCompileDmar (
442 void **PFieldList);
444 ACPI_STATUS
445 DtCompileDrtm (
446 void **PFieldList);
448 ACPI_STATUS
449 DtCompileEinj (
450 void **PFieldList);
452 ACPI_STATUS
453 DtCompileErst (
454 void **PFieldList);
456 ACPI_STATUS
457 DtCompileFadt (
458 void **PFieldList);
460 ACPI_STATUS
461 DtCompileFpdt (
462 void **PFieldList);
464 ACPI_STATUS
465 DtCompileGtdt (
466 void **PFieldList);
468 ACPI_STATUS
469 DtCompileHest (
470 void **PFieldList);
472 ACPI_STATUS
473 DtCompileIort (
474 void **PFieldList);
476 ACPI_STATUS
477 DtCompileIvrs (
478 void **PFieldList);
480 ACPI_STATUS
481 DtCompileLpit (
482 void **PFieldList);
484 ACPI_STATUS
485 DtCompileMadt (
486 void **PFieldList);
488 ACPI_STATUS
489 DtCompileMcfg (
490 void **PFieldList);
492 ACPI_STATUS
493 DtCompileMpst (
494 void **PFieldList);
496 ACPI_STATUS
497 DtCompileMsct (
498 void **PFieldList);
500 ACPI_STATUS
501 DtCompileMtmr (
502 void **PFieldList);
504 ACPI_STATUS
505 DtCompileNfit (
506 void **PFieldList);
508 ACPI_STATUS
509 DtCompilePmtt (
510 void **PFieldList);
512 ACPI_STATUS
513 DtCompilePcct (
514 void **PFieldList);
516 ACPI_STATUS
517 DtCompileRsdt (
518 void **PFieldList);
520 ACPI_STATUS
521 DtCompileS3pt (
522 DT_FIELD **PFieldList);
524 ACPI_STATUS
525 DtCompileSlic (
526 void **PFieldList);
528 ACPI_STATUS
529 DtCompileSlit (
530 void **PFieldList);
532 ACPI_STATUS
533 DtCompileSrat (
534 void **PFieldList);
536 ACPI_STATUS
537 DtCompileStao (
538 void **PFieldList);
540 ACPI_STATUS
541 DtCompileTcpa (
542 void **PFieldList);
544 ACPI_STATUS
545 DtCompileUefi (
546 void **PFieldList);
548 ACPI_STATUS
549 DtCompileVrtc (
550 void **PFieldList);
552 ACPI_STATUS
553 DtCompileWdat (
554 void **PFieldList);
556 ACPI_STATUS
557 DtCompileWpbt (
558 void **PFieldList);
560 ACPI_STATUS
561 DtCompileXsdt (
562 void **PFieldList);
564 ACPI_STATUS
565 DtCompileGeneric (
566 void **PFieldList,
567 char *TermFieldName,
568 UINT32 *PFieldLength);
570 ACPI_DMTABLE_INFO *
571 DtGetGenericTableInfo (
572 char *Name);
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[];
629 #endif