Fixed compatibility of output.
[AROS.git] / arch / all-pc / acpica / source / compiler / dtcompiler.h
blobf83ef7707d4a13518f59160187dcd708b45d87e3
1 /******************************************************************************
3 * Module Name: dtcompiler.h - header for data table compiler
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, 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 #undef DT_EXTERN
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
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 */
93 UINT8 Flags;
95 } DT_FIELD;
97 /* Flags for above */
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;
111 UINT8 *Buffer;
112 UINT8 *LengthField;
113 UINT32 Length;
114 UINT32 TotalLength;
115 UINT32 SizeOfLengthField;
116 UINT16 Depth;
117 UINT8 Flags;
119 } DT_SUBTABLE;
123 * Globals
126 /* List of all field names and values from the input source */
128 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldList, NULL);
130 /* List of all compiled tables and subtables */
132 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_RootTable, NULL);
134 /* Stack for subtables */
136 DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL);
138 /* List for defined labels */
140 DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL);
142 /* Current offset within the binary output table */
144 DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0);
147 /* dtcompiler - main module */
149 ACPI_STATUS
150 DtCompileTable (
151 DT_FIELD **Field,
152 ACPI_DMTABLE_INFO *Info,
153 DT_SUBTABLE **RetSubtable,
154 BOOLEAN Required);
157 /* dtio - binary and text input/output */
159 UINT32
160 DtGetNextLine (
161 FILE *Handle);
163 DT_FIELD *
164 DtScanFile (
165 FILE *Handle);
167 void
168 DtOutputBinary (
169 DT_SUBTABLE *RootTable);
171 void
172 DtDumpSubtableList (
173 void);
175 void
176 DtDumpFieldList (
177 DT_FIELD *Field);
179 void
180 DtWriteFieldToListing (
181 UINT8 *Buffer,
182 DT_FIELD *Field,
183 UINT32 Length);
185 void
186 DtWriteTableToListing (
187 void);
190 /* dtsubtable - compile subtables */
192 void
193 DtCreateSubtable (
194 UINT8 *Buffer,
195 UINT32 Length,
196 DT_SUBTABLE **RetSubtable);
198 UINT32
199 DtGetSubtableLength (
200 DT_FIELD *Field,
201 ACPI_DMTABLE_INFO *Info);
203 void
204 DtSetSubtableLength (
205 DT_SUBTABLE *Subtable);
207 void
208 DtPushSubtable (
209 DT_SUBTABLE *Subtable);
211 void
212 DtPopSubtable (
213 void);
215 DT_SUBTABLE *
216 DtPeekSubtable (
217 void);
219 void
220 DtInsertSubtable (
221 DT_SUBTABLE *ParentTable,
222 DT_SUBTABLE *Subtable);
224 DT_SUBTABLE *
225 DtGetNextSubtable (
226 DT_SUBTABLE *ParentTable,
227 DT_SUBTABLE *ChildTable);
229 DT_SUBTABLE *
230 DtGetParentSubtable (
231 DT_SUBTABLE *Subtable);
234 /* dtexpress - Integer expressions and labels */
236 ACPI_STATUS
237 DtResolveIntegerExpression (
238 DT_FIELD *Field,
239 UINT64 *ReturnValue);
241 UINT64
242 DtDoOperator (
243 UINT64 LeftValue,
244 UINT32 Operator,
245 UINT64 RightValue);
247 UINT64
248 DtResolveLabel (
249 char *LabelString);
251 void
252 DtDetectAllLabels (
253 DT_FIELD *FieldList);
256 /* dtfield - Compile individual fields within a table */
258 void
259 DtCompileOneField (
260 UINT8 *Buffer,
261 DT_FIELD *Field,
262 UINT32 ByteLength,
263 UINT8 Type,
264 UINT8 Flags);
266 void
267 DtCompileInteger (
268 UINT8 *Buffer,
269 DT_FIELD *Field,
270 UINT32 ByteLength,
271 UINT8 Flags);
273 UINT32
274 DtCompileBuffer (
275 UINT8 *Buffer,
276 char *Value,
277 DT_FIELD *Field,
278 UINT32 ByteLength);
280 void
281 DtCompileFlag (
282 UINT8 *Buffer,
283 DT_FIELD *Field,
284 ACPI_DMTABLE_INFO *Info);
287 /* dtparser - lex/yacc files */
289 UINT64
290 DtEvaluateExpression (
291 char *ExprString);
294 DtInitLexer (
295 char *String);
297 void
298 DtTerminateLexer (
299 void);
301 char *
302 DtGetOpName (
303 UINT32 ParseOpcode);
306 /* dtutils - Miscellaneous utilities */
308 typedef
309 void (*DT_WALK_CALLBACK) (
310 DT_SUBTABLE *Subtable,
311 void *Context,
312 void *ReturnValue);
314 void
315 DtWalkTableTree (
316 DT_SUBTABLE *StartTable,
317 DT_WALK_CALLBACK UserFunction,
318 void *Context,
319 void *ReturnValue);
321 void
322 DtError (
323 UINT8 Level,
324 UINT8 MessageId,
325 DT_FIELD *FieldObject,
326 char *ExtraMessage);
328 void
329 DtNameError (
330 UINT8 Level,
331 UINT8 MessageId,
332 DT_FIELD *FieldObject,
333 char *ExtraMessage);
335 void
336 DtFatal (
337 UINT8 MessageId,
338 DT_FIELD *FieldObject,
339 char *ExtraMessage);
341 ACPI_STATUS
342 DtStrtoul64 (
343 char *String,
344 UINT64 *ReturnInteger);
346 UINT32
347 DtGetFileSize (
348 FILE *Handle);
350 char*
351 DtGetFieldValue (
352 DT_FIELD *Field);
354 UINT8
355 DtGetFieldType (
356 ACPI_DMTABLE_INFO *Info);
358 UINT32
359 DtGetBufferLength (
360 char *Buffer);
362 UINT32
363 DtGetFieldLength (
364 DT_FIELD *Field,
365 ACPI_DMTABLE_INFO *Info);
367 void
368 DtSetTableChecksum (
369 UINT8 *ChecksumPointer);
371 void
372 DtSetTableLength(
373 void);
375 void
376 DtFreeFieldList (
377 void);
380 /* dttable - individual table compilation */
382 ACPI_STATUS
383 DtCompileFacs (
384 DT_FIELD **PFieldList);
386 ACPI_STATUS
387 DtCompileRsdp (
388 DT_FIELD **PFieldList);
390 ACPI_STATUS
391 DtCompileAsf (
392 void **PFieldList);
394 ACPI_STATUS
395 DtCompileCpep (
396 void **PFieldList);
398 ACPI_STATUS
399 DtCompileCsrt (
400 void **PFieldList);
402 ACPI_STATUS
403 DtCompileDmar (
404 void **PFieldList);
406 ACPI_STATUS
407 DtCompileEinj (
408 void **PFieldList);
410 ACPI_STATUS
411 DtCompileErst (
412 void **PFieldList);
414 ACPI_STATUS
415 DtCompileFadt (
416 void **PFieldList);
418 ACPI_STATUS
419 DtCompileFpdt (
420 void **PFieldList);
422 ACPI_STATUS
423 DtCompileHest (
424 void **PFieldList);
426 ACPI_STATUS
427 DtCompileIvrs (
428 void **PFieldList);
430 ACPI_STATUS
431 DtCompileMadt (
432 void **PFieldList);
434 ACPI_STATUS
435 DtCompileMcfg (
436 void **PFieldList);
438 ACPI_STATUS
439 DtCompileMpst (
440 void **PFieldList);
442 ACPI_STATUS
443 DtCompileMsct (
444 void **PFieldList);
446 ACPI_STATUS
447 DtCompileMtmr (
448 void **PFieldList);
450 ACPI_STATUS
451 DtCompilePmtt (
452 void **PFieldList);
454 ACPI_STATUS
455 DtCompileRsdt (
456 void **PFieldList);
458 ACPI_STATUS
459 DtCompileS3pt (
460 DT_FIELD **PFieldList);
462 ACPI_STATUS
463 DtCompileSlic (
464 void **PFieldList);
466 ACPI_STATUS
467 DtCompileSlit (
468 void **PFieldList);
470 ACPI_STATUS
471 DtCompileSrat (
472 void **PFieldList);
474 ACPI_STATUS
475 DtCompileUefi (
476 void **PFieldList);
478 ACPI_STATUS
479 DtCompileVrtc (
480 void **PFieldList);
482 ACPI_STATUS
483 DtCompileWdat (
484 void **PFieldList);
486 ACPI_STATUS
487 DtCompileXsdt (
488 void **PFieldList);
490 ACPI_STATUS
491 DtCompileGeneric (
492 void **PFieldList);
494 ACPI_DMTABLE_INFO *
495 DtGetGenericTableInfo (
496 char *Name);
498 /* ACPI Table templates */
500 extern const unsigned char TemplateAsf[];
501 extern const unsigned char TemplateBoot[];
502 extern const unsigned char TemplateBert[];
503 extern const unsigned char TemplateBgrt[];
504 extern const unsigned char TemplateCpep[];
505 extern const unsigned char TemplateCsrt[];
506 extern const unsigned char TemplateDbgp[];
507 extern const unsigned char TemplateDmar[];
508 extern const unsigned char TemplateEcdt[];
509 extern const unsigned char TemplateEinj[];
510 extern const unsigned char TemplateErst[];
511 extern const unsigned char TemplateFadt[];
512 extern const unsigned char TemplateFpdt[];
513 extern const unsigned char TemplateGtdt[];
514 extern const unsigned char TemplateHest[];
515 extern const unsigned char TemplateHpet[];
516 extern const unsigned char TemplateIvrs[];
517 extern const unsigned char TemplateMadt[];
518 extern const unsigned char TemplateMcfg[];
519 extern const unsigned char TemplateMchi[];
520 extern const unsigned char TemplateMpst[];
521 extern const unsigned char TemplateMsct[];
522 extern const unsigned char TemplateMtmr[];
523 extern const unsigned char TemplatePmtt[];
524 extern const unsigned char TemplateRsdt[];
525 extern const unsigned char TemplateS3pt[];
526 extern const unsigned char TemplateSbst[];
527 extern const unsigned char TemplateSlic[];
528 extern const unsigned char TemplateSlit[];
529 extern const unsigned char TemplateSpcr[];
530 extern const unsigned char TemplateSpmi[];
531 extern const unsigned char TemplateSrat[];
532 extern const unsigned char TemplateTcpa[];
533 extern const unsigned char TemplateTpm2[];
534 extern const unsigned char TemplateUefi[];
535 extern const unsigned char TemplateVrtc[];
536 extern const unsigned char TemplateWaet[];
537 extern const unsigned char TemplateWdat[];
538 extern const unsigned char TemplateWddt[];
539 extern const unsigned char TemplateWdrt[];
540 extern const unsigned char TemplateXsdt[];
542 #endif