1a88e22b7SJung-uk Kim /******************************************************************************
2a88e22b7SJung-uk Kim *
3a88e22b7SJung-uk Kim * Module Name: dtcompile.c - Front-end for data table compiler
4a88e22b7SJung-uk Kim *
5a88e22b7SJung-uk Kim *****************************************************************************/
6a88e22b7SJung-uk Kim
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim *
90d84335fSJung-uk Kim * 1. Copyright Notice
100d84335fSJung-uk Kim *
11*58308fadSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
12a88e22b7SJung-uk Kim * All rights reserved.
13a88e22b7SJung-uk Kim *
140d84335fSJung-uk Kim * 2. License
150d84335fSJung-uk Kim *
160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim * property rights.
200d84335fSJung-uk Kim *
210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim *
280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim *
370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim * conditions are met:
390d84335fSJung-uk Kim *
400d84335fSJung-uk Kim * 3. Conditions
410d84335fSJung-uk Kim *
420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim *
540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim * make.
650d84335fSJung-uk Kim *
660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim * distribution.
710d84335fSJung-uk Kim *
720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim * Intel Code.
740d84335fSJung-uk Kim *
750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim * without prior written authorization from Intel.
790d84335fSJung-uk Kim *
800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim *
820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim *
900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim * LIMITED REMEDY.
980d84335fSJung-uk Kim *
990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim * such license, approval or letter.
1130d84335fSJung-uk Kim *
1140d84335fSJung-uk Kim *****************************************************************************
1150d84335fSJung-uk Kim *
1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim * following license:
1180d84335fSJung-uk Kim *
119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without
120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions
121d244b227SJung-uk Kim * are met:
122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright
123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer,
124d244b227SJung-uk Kim * without modification.
125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below
127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon
128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further
129d244b227SJung-uk Kim * binary redistribution.
130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names
131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived
132d244b227SJung-uk Kim * from this software without specific prior written permission.
133a88e22b7SJung-uk Kim *
1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim *
1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the
147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free
148d244b227SJung-uk Kim * Software Foundation.
149a88e22b7SJung-uk Kim *
1500d84335fSJung-uk Kim *****************************************************************************/
151a88e22b7SJung-uk Kim
152a88e22b7SJung-uk Kim #define _DECLARE_DT_GLOBALS
153a88e22b7SJung-uk Kim
154a88e22b7SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
155a88e22b7SJung-uk Kim
156a88e22b7SJung-uk Kim #define _COMPONENT DT_COMPILER
157a88e22b7SJung-uk Kim ACPI_MODULE_NAME ("dtcompile")
158a88e22b7SJung-uk Kim
159a88e22b7SJung-uk Kim static char VersionString[9];
160a88e22b7SJung-uk Kim
161a88e22b7SJung-uk Kim
162a88e22b7SJung-uk Kim /* Local prototypes */
163a88e22b7SJung-uk Kim
164a009b7dcSJung-uk Kim void
165a88e22b7SJung-uk Kim DtInitialize (
166a88e22b7SJung-uk Kim void);
167a88e22b7SJung-uk Kim
168a88e22b7SJung-uk Kim static ACPI_STATUS
169a88e22b7SJung-uk Kim DtCompileDataTable (
170a88e22b7SJung-uk Kim DT_FIELD **Field);
171a88e22b7SJung-uk Kim
172a88e22b7SJung-uk Kim static void
173a88e22b7SJung-uk Kim DtInsertCompilerIds (
174a88e22b7SJung-uk Kim DT_FIELD *FieldList);
175a88e22b7SJung-uk Kim
176a88e22b7SJung-uk Kim
177a88e22b7SJung-uk Kim /******************************************************************************
178a88e22b7SJung-uk Kim *
179a88e22b7SJung-uk Kim * FUNCTION: DtDoCompile
180a88e22b7SJung-uk Kim *
181a88e22b7SJung-uk Kim * PARAMETERS: None
182a88e22b7SJung-uk Kim *
183a88e22b7SJung-uk Kim * RETURN: Status
184a88e22b7SJung-uk Kim *
185a88e22b7SJung-uk Kim * DESCRIPTION: Main entry point for the data table compiler.
186a88e22b7SJung-uk Kim *
1876f1f1a63SJung-uk Kim * Note: Assumes AslGbl_Files[ASL_FILE_INPUT] is initialized and the file is
188a88e22b7SJung-uk Kim * open at seek offset zero.
189a88e22b7SJung-uk Kim *
190a88e22b7SJung-uk Kim *****************************************************************************/
191a88e22b7SJung-uk Kim
192a88e22b7SJung-uk Kim ACPI_STATUS
DtDoCompile(void)193a88e22b7SJung-uk Kim DtDoCompile (
194a88e22b7SJung-uk Kim void)
195a88e22b7SJung-uk Kim {
196a88e22b7SJung-uk Kim ACPI_STATUS Status;
197a88e22b7SJung-uk Kim UINT8 Event;
198a88e22b7SJung-uk Kim DT_FIELD *FieldList;
199a009b7dcSJung-uk Kim ASL_GLOBAL_FILE_NODE *FileNode;
200a88e22b7SJung-uk Kim
201a88e22b7SJung-uk Kim
202a88e22b7SJung-uk Kim /* Initialize globals */
203a88e22b7SJung-uk Kim
204a009b7dcSJung-uk Kim DtInitialize ();
205a88e22b7SJung-uk Kim
2064c52cad2SJung-uk Kim /* Preprocessor */
2074c52cad2SJung-uk Kim
2086f1f1a63SJung-uk Kim if (AslGbl_PreprocessFlag)
2097cf3e94aSJung-uk Kim {
2107cf3e94aSJung-uk Kim /* Preprocessor */
2117cf3e94aSJung-uk Kim
2124c52cad2SJung-uk Kim Event = UtBeginEvent ("Preprocess input file");
2134c52cad2SJung-uk Kim PrDoPreprocess ();
2144c52cad2SJung-uk Kim UtEndEvent (Event);
2154c52cad2SJung-uk Kim
2166f1f1a63SJung-uk Kim if (AslGbl_PreprocessOnly)
2174c52cad2SJung-uk Kim {
2188ef1a331SJung-uk Kim return (AE_OK);
2194c52cad2SJung-uk Kim }
2207cf3e94aSJung-uk Kim }
2214c52cad2SJung-uk Kim
222a009b7dcSJung-uk Kim /* Compile the parse tree */
223a009b7dcSJung-uk Kim
224a009b7dcSJung-uk Kim if (AslGbl_DtLexBisonPrototype)
225a009b7dcSJung-uk Kim {
226a009b7dcSJung-uk Kim Event = UtBeginEvent ("Parse data table in prototype mode");
227a009b7dcSJung-uk Kim
228a009b7dcSJung-uk Kim DtCompilerInitLexer (AslGbl_Files[ASL_FILE_INPUT].Handle);
229a009b7dcSJung-uk Kim DtCompilerParserparse ();
230a009b7dcSJung-uk Kim FieldList = AslGbl_FieldList;
231a009b7dcSJung-uk Kim DtCompilerTerminateLexer ();
232a009b7dcSJung-uk Kim
233a009b7dcSJung-uk Kim UtEndEvent (Event);
234a009b7dcSJung-uk Kim }
235a009b7dcSJung-uk Kim else
236a009b7dcSJung-uk Kim {
237a88e22b7SJung-uk Kim /*
238a88e22b7SJung-uk Kim * Scan the input file (file is already open) and
239a88e22b7SJung-uk Kim * build the parse tree
240a88e22b7SJung-uk Kim */
241a88e22b7SJung-uk Kim Event = UtBeginEvent ("Scan and parse input file");
2426f1f1a63SJung-uk Kim FieldList = DtScanFile (AslGbl_Files[ASL_FILE_INPUT].Handle);
243a88e22b7SJung-uk Kim UtEndEvent (Event);
244a009b7dcSJung-uk Kim }
245a88e22b7SJung-uk Kim
246a88e22b7SJung-uk Kim /* Did the parse tree get successfully constructed? */
247a88e22b7SJung-uk Kim
248a88e22b7SJung-uk Kim if (!FieldList)
249a88e22b7SJung-uk Kim {
250a88e22b7SJung-uk Kim /* TBD: temporary error message. Msgs should come from function above */
251a88e22b7SJung-uk Kim
252a88e22b7SJung-uk Kim DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL,
253a88e22b7SJung-uk Kim "Input file does not appear to be an ASL or data table source file");
254a88e22b7SJung-uk Kim
25544b0f624SJung-uk Kim return (AE_ERROR);
256a88e22b7SJung-uk Kim }
257a88e22b7SJung-uk Kim
258a88e22b7SJung-uk Kim Event = UtBeginEvent ("Compile parse tree");
259a88e22b7SJung-uk Kim
260a88e22b7SJung-uk Kim Status = DtCompileDataTable (&FieldList);
261a88e22b7SJung-uk Kim UtEndEvent (Event);
262a88e22b7SJung-uk Kim
263a009b7dcSJung-uk Kim FileNode = FlGetCurrentFileNode ();
264f9a6772eSJung-uk Kim
265a009b7dcSJung-uk Kim FileNode->TotalLineCount = AslGbl_CurrentLineNumber;
266a009b7dcSJung-uk Kim FileNode->OriginalInputFileSize = AslGbl_InputByteCount;
267a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "Line count: %u input file size: %u\n",
268a009b7dcSJung-uk Kim FileNode->TotalLineCount, FileNode->OriginalInputFileSize);
269a009b7dcSJung-uk Kim
270a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
271a88e22b7SJung-uk Kim {
272a009b7dcSJung-uk Kim FileNode->ParserErrorDetected = TRUE;
273a009b7dcSJung-uk Kim
274a88e22b7SJung-uk Kim /* TBD: temporary error message. Msgs should come from function above */
275a88e22b7SJung-uk Kim
276a88e22b7SJung-uk Kim DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL,
277a88e22b7SJung-uk Kim "Could not compile input file");
278a88e22b7SJung-uk Kim
27944b0f624SJung-uk Kim return (Status);
280a88e22b7SJung-uk Kim }
281a88e22b7SJung-uk Kim
282a88e22b7SJung-uk Kim /* Create/open the binary output file */
283a88e22b7SJung-uk Kim
2846f1f1a63SJung-uk Kim AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename = NULL;
2856f1f1a63SJung-uk Kim Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix);
286a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
287a88e22b7SJung-uk Kim {
28844b0f624SJung-uk Kim return (Status);
289a88e22b7SJung-uk Kim }
290a88e22b7SJung-uk Kim
291a88e22b7SJung-uk Kim /* Write the binary, then the optional hex file */
292a88e22b7SJung-uk Kim
2936f1f1a63SJung-uk Kim DtOutputBinary (AslGbl_RootTable);
294efcc2a30SJung-uk Kim HxDoHexOutput ();
295d244b227SJung-uk Kim DtWriteTableToListing ();
296a88e22b7SJung-uk Kim
297a009b7dcSJung-uk Kim /* Save the compile time statistics to the current file node */
298a009b7dcSJung-uk Kim
299a009b7dcSJung-uk Kim FileNode->TotalFields = AslGbl_InputFieldCount;
300a009b7dcSJung-uk Kim FileNode->OutputByteLength = AslGbl_TableLength;
301a009b7dcSJung-uk Kim
302a88e22b7SJung-uk Kim return (Status);
303a88e22b7SJung-uk Kim }
304a88e22b7SJung-uk Kim
305a88e22b7SJung-uk Kim
306a88e22b7SJung-uk Kim /******************************************************************************
307a88e22b7SJung-uk Kim *
308a88e22b7SJung-uk Kim * FUNCTION: DtInitialize
309a88e22b7SJung-uk Kim *
310a88e22b7SJung-uk Kim * PARAMETERS: None
311a88e22b7SJung-uk Kim *
31242fecd12SJung-uk Kim * RETURN: Status
313a88e22b7SJung-uk Kim *
314a88e22b7SJung-uk Kim * DESCRIPTION: Initialize data table compiler globals. Enables multiple
315a88e22b7SJung-uk Kim * compiles per invocation.
316a88e22b7SJung-uk Kim *
317a88e22b7SJung-uk Kim *****************************************************************************/
318a88e22b7SJung-uk Kim
319a009b7dcSJung-uk Kim void
DtInitialize(void)320a88e22b7SJung-uk Kim DtInitialize (
321a88e22b7SJung-uk Kim void)
322a88e22b7SJung-uk Kim {
323a88e22b7SJung-uk Kim
32442fecd12SJung-uk Kim
3252f6a1a81SJung-uk Kim AcpiUtSetIntegerWidth (2); /* Set width to 64 bits */
3262f6a1a81SJung-uk Kim
3276f1f1a63SJung-uk Kim AslGbl_FieldList = NULL;
3286f1f1a63SJung-uk Kim AslGbl_RootTable = NULL;
3296f1f1a63SJung-uk Kim AslGbl_SubtableStack = NULL;
330a88e22b7SJung-uk Kim
331a88e22b7SJung-uk Kim sprintf (VersionString, "%X", (UINT32) ACPI_CA_VERSION);
332a009b7dcSJung-uk Kim return;
333a88e22b7SJung-uk Kim }
334a88e22b7SJung-uk Kim
335a88e22b7SJung-uk Kim
336a88e22b7SJung-uk Kim /******************************************************************************
337a88e22b7SJung-uk Kim *
338a88e22b7SJung-uk Kim * FUNCTION: DtInsertCompilerIds
339a88e22b7SJung-uk Kim *
340a88e22b7SJung-uk Kim * PARAMETERS: FieldList - Current field list pointer
341a88e22b7SJung-uk Kim *
342a88e22b7SJung-uk Kim * RETURN: None
343a88e22b7SJung-uk Kim *
344a88e22b7SJung-uk Kim * DESCRIPTION: Insert the IDs (Name, Version) of the current compiler into
345a88e22b7SJung-uk Kim * the original ACPI table header.
346a88e22b7SJung-uk Kim *
347a88e22b7SJung-uk Kim *****************************************************************************/
348a88e22b7SJung-uk Kim
349a88e22b7SJung-uk Kim static void
DtInsertCompilerIds(DT_FIELD * FieldList)350a88e22b7SJung-uk Kim DtInsertCompilerIds (
351a88e22b7SJung-uk Kim DT_FIELD *FieldList)
352a88e22b7SJung-uk Kim {
353a88e22b7SJung-uk Kim DT_FIELD *Next;
354a88e22b7SJung-uk Kim UINT32 i;
355a88e22b7SJung-uk Kim
356a88e22b7SJung-uk Kim
357a88e22b7SJung-uk Kim /*
358a88e22b7SJung-uk Kim * Don't insert current compiler ID if requested. Used for compiler
359a88e22b7SJung-uk Kim * debug/validation only.
360a88e22b7SJung-uk Kim */
3616f1f1a63SJung-uk Kim if (AslGbl_UseOriginalCompilerId)
362a88e22b7SJung-uk Kim {
363a88e22b7SJung-uk Kim return;
364a88e22b7SJung-uk Kim }
365a88e22b7SJung-uk Kim
366a88e22b7SJung-uk Kim /* Walk to the Compiler fields at the end of the header */
367a88e22b7SJung-uk Kim
368a88e22b7SJung-uk Kim Next = FieldList;
369a88e22b7SJung-uk Kim for (i = 0; i < 7; i++)
370a88e22b7SJung-uk Kim {
371a88e22b7SJung-uk Kim Next = Next->Next;
372a88e22b7SJung-uk Kim }
373a88e22b7SJung-uk Kim
3743c1812acSJung-uk Kim Next->Value = ASL_CREATOR_ID;
375a88e22b7SJung-uk Kim Next->Flags = DT_FIELD_NOT_ALLOCATED;
376a88e22b7SJung-uk Kim
377a88e22b7SJung-uk Kim Next = Next->Next;
378a88e22b7SJung-uk Kim Next->Value = VersionString;
379a88e22b7SJung-uk Kim Next->Flags = DT_FIELD_NOT_ALLOCATED;
380a88e22b7SJung-uk Kim }
381a88e22b7SJung-uk Kim
382a88e22b7SJung-uk Kim
383a88e22b7SJung-uk Kim /******************************************************************************
384a88e22b7SJung-uk Kim *
385a88e22b7SJung-uk Kim * FUNCTION: DtCompileDataTable
386a88e22b7SJung-uk Kim *
387a88e22b7SJung-uk Kim * PARAMETERS: FieldList - Current field list pointer
388a88e22b7SJung-uk Kim *
389a88e22b7SJung-uk Kim * RETURN: Status
390a88e22b7SJung-uk Kim *
391a88e22b7SJung-uk Kim * DESCRIPTION: Entry point to compile one data table
392a88e22b7SJung-uk Kim *
393a88e22b7SJung-uk Kim *****************************************************************************/
394a88e22b7SJung-uk Kim
395a88e22b7SJung-uk Kim static ACPI_STATUS
DtCompileDataTable(DT_FIELD ** FieldList)396a88e22b7SJung-uk Kim DtCompileDataTable (
397a88e22b7SJung-uk Kim DT_FIELD **FieldList)
398a88e22b7SJung-uk Kim {
399a371a5fdSJung-uk Kim const ACPI_DMTABLE_DATA *TableData;
400a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable;
401a88e22b7SJung-uk Kim char *Signature;
402a88e22b7SJung-uk Kim ACPI_TABLE_HEADER *AcpiTableHeader;
403a88e22b7SJung-uk Kim ACPI_STATUS Status;
404efcc2a30SJung-uk Kim DT_FIELD *RootField = *FieldList;
405a88e22b7SJung-uk Kim
406a88e22b7SJung-uk Kim
407a88e22b7SJung-uk Kim /* Verify that we at least have a table signature and save it */
408a88e22b7SJung-uk Kim
409d052a1ccSJung-uk Kim Signature = DtGetFieldValue (*FieldList);
410a88e22b7SJung-uk Kim if (!Signature)
411a88e22b7SJung-uk Kim {
4126f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Expected \"%s\"", "Signature");
413a88e22b7SJung-uk Kim DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
4146f1f1a63SJung-uk Kim *FieldList, AslGbl_MsgBuffer);
415a88e22b7SJung-uk Kim return (AE_ERROR);
416a88e22b7SJung-uk Kim }
417a88e22b7SJung-uk Kim
4186f1f1a63SJung-uk Kim AslGbl_Signature = UtLocalCacheCalloc (strlen (Signature) + 1);
4196f1f1a63SJung-uk Kim strcpy (AslGbl_Signature, Signature);
420a88e22b7SJung-uk Kim
421a88e22b7SJung-uk Kim /*
422a88e22b7SJung-uk Kim * Handle tables that don't use the common ACPI table header structure.
423a88e22b7SJung-uk Kim * Currently, these are the FACS and RSDP. Also check for an OEMx table,
424a88e22b7SJung-uk Kim * these tables have user-defined contents.
425a88e22b7SJung-uk Kim */
426278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_FACS))
427a88e22b7SJung-uk Kim {
428a88e22b7SJung-uk Kim Status = DtCompileFacs (FieldList);
429a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
430a88e22b7SJung-uk Kim {
431a88e22b7SJung-uk Kim return (Status);
432a88e22b7SJung-uk Kim }
433a88e22b7SJung-uk Kim
434a88e22b7SJung-uk Kim DtSetTableLength ();
435a88e22b7SJung-uk Kim return (Status);
436a88e22b7SJung-uk Kim }
43779c6d946SJung-uk Kim else if (ACPI_VALIDATE_RSDP_SIG (Signature))
438a88e22b7SJung-uk Kim {
439a88e22b7SJung-uk Kim Status = DtCompileRsdp (FieldList);
440a88e22b7SJung-uk Kim return (Status);
441a88e22b7SJung-uk Kim }
442278f0de6SJung-uk Kim else if (ACPI_COMPARE_NAMESEG (Signature, ACPI_SIG_S3PT))
4433f0275a0SJung-uk Kim {
4443f0275a0SJung-uk Kim Status = DtCompileS3pt (FieldList);
4453f0275a0SJung-uk Kim if (ACPI_FAILURE (Status))
4463f0275a0SJung-uk Kim {
4473f0275a0SJung-uk Kim return (Status);
4483f0275a0SJung-uk Kim }
4493f0275a0SJung-uk Kim
4503f0275a0SJung-uk Kim DtSetTableLength ();
4513f0275a0SJung-uk Kim return (Status);
4523f0275a0SJung-uk Kim }
453a88e22b7SJung-uk Kim
454a88e22b7SJung-uk Kim /*
4559a4bc520SJung-uk Kim * If the first field is named "CDAT Table Length" (not "Signature"),
4569a4bc520SJung-uk Kim * assume that we have a CDAT table (whose table header does not have
4579a4bc520SJung-uk Kim * a signature). Instead, the TableLength field is where the
4589a4bc520SJung-uk Kim * signature would (normally) be.
4599a4bc520SJung-uk Kim */
4609a4bc520SJung-uk Kim else if (!strcmp ((*FieldList)->Name, "CDAT Table Length"))
4619a4bc520SJung-uk Kim {
4629a4bc520SJung-uk Kim /* No longer true: (However, use this technique in the disassembler)
4639a4bc520SJung-uk Kim * We are assuming that there
4649a4bc520SJung-uk Kim * should be at least one non-ASCII byte in the 4-character
4659a4bc520SJung-uk Kim * Signature field, (At least the high-order byte should be zero).
4669a4bc520SJung-uk Kim */
4679a4bc520SJung-uk Kim Status = DtCompileTable (FieldList, AcpiDmTableInfoCdatTableHdr,
4689a4bc520SJung-uk Kim &AslGbl_RootTable);
4699a4bc520SJung-uk Kim if (ACPI_FAILURE (Status))
4709a4bc520SJung-uk Kim {
4719a4bc520SJung-uk Kim return (Status);
4729a4bc520SJung-uk Kim }
4739a4bc520SJung-uk Kim
4749a4bc520SJung-uk Kim /* Compile the CDAT */
4759a4bc520SJung-uk Kim
4769a4bc520SJung-uk Kim DtPushSubtable (AslGbl_RootTable);
4779a4bc520SJung-uk Kim Status = DtCompileCdat ((void **) FieldList);
4789a4bc520SJung-uk Kim if (ACPI_FAILURE (Status))
4799a4bc520SJung-uk Kim {
4809a4bc520SJung-uk Kim return (Status);
4819a4bc520SJung-uk Kim }
4829a4bc520SJung-uk Kim
4839a4bc520SJung-uk Kim /*
4849a4bc520SJung-uk Kim * Set the overall table length and the table checksum.
4859a4bc520SJung-uk Kim * The entire compiled table (including the CDAT table header with
4869a4bc520SJung-uk Kim * the table length and checksum) is in AslGbl_RootTable->Buffer.
4879a4bc520SJung-uk Kim */
4889a4bc520SJung-uk Kim DtSetTableLength ();
4899a4bc520SJung-uk Kim DtSetTableChecksum (&ACPI_CAST_PTR (ACPI_TABLE_CDAT, AslGbl_RootTable->Buffer)->Checksum);
4909a4bc520SJung-uk Kim
4919a4bc520SJung-uk Kim DtDumpFieldList (RootField);
4929a4bc520SJung-uk Kim DtDumpSubtableList ();
4939a4bc520SJung-uk Kim return (AE_OK);
4949a4bc520SJung-uk Kim }
4959a4bc520SJung-uk Kim
4969a4bc520SJung-uk Kim /*
497a88e22b7SJung-uk Kim * All other tables must use the common ACPI table header. Insert the
498a88e22b7SJung-uk Kim * current iASL IDs (name, version), and compile the header now.
499a88e22b7SJung-uk Kim */
500a88e22b7SJung-uk Kim DtInsertCompilerIds (*FieldList);
501a88e22b7SJung-uk Kim
502a88e22b7SJung-uk Kim Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader,
5036f1f1a63SJung-uk Kim &AslGbl_RootTable);
504a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
505a88e22b7SJung-uk Kim {
506a88e22b7SJung-uk Kim return (Status);
507a88e22b7SJung-uk Kim }
508a88e22b7SJung-uk Kim
5096f1f1a63SJung-uk Kim DtPushSubtable (AslGbl_RootTable);
510a88e22b7SJung-uk Kim
511d052a1ccSJung-uk Kim /* Validate the signature via the ACPI table list */
512d052a1ccSJung-uk Kim
513d052a1ccSJung-uk Kim TableData = AcpiDmGetTableData (Signature);
5146f1f1a63SJung-uk Kim if (!TableData || AslGbl_CompileGeneric)
515d052a1ccSJung-uk Kim {
5165ef50723SJung-uk Kim /* Unknown table signature and/or force generic compile */
5175ef50723SJung-uk Kim
518a371a5fdSJung-uk Kim DtCompileGeneric ((void **) FieldList, NULL, NULL);
519efcc2a30SJung-uk Kim goto FinishHeader;
520d052a1ccSJung-uk Kim }
521d052a1ccSJung-uk Kim
522a88e22b7SJung-uk Kim /* Dispatch to per-table compile */
523a88e22b7SJung-uk Kim
524a88e22b7SJung-uk Kim if (TableData->CmTableHandler)
525a88e22b7SJung-uk Kim {
526a88e22b7SJung-uk Kim /* Complex table, has a handler */
527a88e22b7SJung-uk Kim
528a88e22b7SJung-uk Kim Status = TableData->CmTableHandler ((void **) FieldList);
529a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
530a88e22b7SJung-uk Kim {
531a88e22b7SJung-uk Kim return (Status);
532a88e22b7SJung-uk Kim }
533a88e22b7SJung-uk Kim }
534a88e22b7SJung-uk Kim else if (TableData->TableInfo)
535a88e22b7SJung-uk Kim {
5365f9b24faSJung-uk Kim /* Simple table, just walk the info table, unless its empty */
537a88e22b7SJung-uk Kim
5385f9b24faSJung-uk Kim if (FieldList && *FieldList)
5395f9b24faSJung-uk Kim {
540a88e22b7SJung-uk Kim Subtable = NULL;
541a88e22b7SJung-uk Kim Status = DtCompileTable (FieldList, TableData->TableInfo,
542ff879b07SJung-uk Kim &Subtable);
543a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
544a88e22b7SJung-uk Kim {
545a88e22b7SJung-uk Kim return (Status);
546a88e22b7SJung-uk Kim }
547a88e22b7SJung-uk Kim
5486f1f1a63SJung-uk Kim DtInsertSubtable (AslGbl_RootTable, Subtable);
549a88e22b7SJung-uk Kim DtPopSubtable ();
550a88e22b7SJung-uk Kim }
5515f9b24faSJung-uk Kim }
552a88e22b7SJung-uk Kim else
553a88e22b7SJung-uk Kim {
554a88e22b7SJung-uk Kim DtFatal (ASL_MSG_COMPILER_INTERNAL, *FieldList,
555a88e22b7SJung-uk Kim "Missing table dispatch info");
556a88e22b7SJung-uk Kim return (AE_ERROR);
557a88e22b7SJung-uk Kim }
558a88e22b7SJung-uk Kim
559efcc2a30SJung-uk Kim FinishHeader:
560efcc2a30SJung-uk Kim
561a88e22b7SJung-uk Kim /* Set the final table length and then the checksum */
562a88e22b7SJung-uk Kim
563a88e22b7SJung-uk Kim DtSetTableLength ();
564a88e22b7SJung-uk Kim AcpiTableHeader = ACPI_CAST_PTR (
5656f1f1a63SJung-uk Kim ACPI_TABLE_HEADER, AslGbl_RootTable->Buffer);
566a88e22b7SJung-uk Kim DtSetTableChecksum (&AcpiTableHeader->Checksum);
567a88e22b7SJung-uk Kim
568efcc2a30SJung-uk Kim DtDumpFieldList (RootField);
569efcc2a30SJung-uk Kim DtDumpSubtableList ();
570a88e22b7SJung-uk Kim return (AE_OK);
571a88e22b7SJung-uk Kim }
572a88e22b7SJung-uk Kim
573a88e22b7SJung-uk Kim
574a88e22b7SJung-uk Kim /******************************************************************************
575a88e22b7SJung-uk Kim *
576a88e22b7SJung-uk Kim * FUNCTION: DtCompileTable
577a88e22b7SJung-uk Kim *
578a88e22b7SJung-uk Kim * PARAMETERS: Field - Current field list pointer
579a88e22b7SJung-uk Kim * Info - Info table for this ACPI table
580a88e22b7SJung-uk Kim * RetSubtable - Compile result of table
581a88e22b7SJung-uk Kim *
582a88e22b7SJung-uk Kim * RETURN: Status
583a88e22b7SJung-uk Kim *
584a88e22b7SJung-uk Kim * DESCRIPTION: Compile a subtable
585a88e22b7SJung-uk Kim *
586a88e22b7SJung-uk Kim *****************************************************************************/
587a88e22b7SJung-uk Kim
588a88e22b7SJung-uk Kim ACPI_STATUS
DtCompileTable(DT_FIELD ** Field,ACPI_DMTABLE_INFO * Info,DT_SUBTABLE ** RetSubtable)589a88e22b7SJung-uk Kim DtCompileTable (
590a88e22b7SJung-uk Kim DT_FIELD **Field,
591a88e22b7SJung-uk Kim ACPI_DMTABLE_INFO *Info,
592ff879b07SJung-uk Kim DT_SUBTABLE **RetSubtable)
593a88e22b7SJung-uk Kim {
594a88e22b7SJung-uk Kim DT_FIELD *LocalField;
595a88e22b7SJung-uk Kim UINT32 Length;
596a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable;
597a371a5fdSJung-uk Kim DT_SUBTABLE *InlineSubtable = NULL;
598a88e22b7SJung-uk Kim UINT32 FieldLength = 0;
599a88e22b7SJung-uk Kim UINT8 FieldType;
600a88e22b7SJung-uk Kim UINT8 *Buffer;
601a88e22b7SJung-uk Kim UINT8 *FlagBuffer = NULL;
602313a0c13SJung-uk Kim char *String;
6033f0275a0SJung-uk Kim UINT32 CurrentFlagByteOffset = 0;
604a371a5fdSJung-uk Kim ACPI_STATUS Status = AE_OK;
605a88e22b7SJung-uk Kim
606a88e22b7SJung-uk Kim
607a009b7dcSJung-uk Kim if (!Field || !Info)
608a88e22b7SJung-uk Kim {
609a88e22b7SJung-uk Kim return (AE_BAD_PARAMETER);
610a88e22b7SJung-uk Kim }
611f1db5ef7SJung-uk Kim if (!*Field)
612f1db5ef7SJung-uk Kim {
613f1db5ef7SJung-uk Kim /*
614f1db5ef7SJung-uk Kim * The field list is empty, this means that we are out of fields to
615f1db5ef7SJung-uk Kim * parse. In other words, we are at the end of the table.
616f1db5ef7SJung-uk Kim */
617f1db5ef7SJung-uk Kim return (AE_END_OF_TABLE);
618f1db5ef7SJung-uk Kim }
619a88e22b7SJung-uk Kim
620313a0c13SJung-uk Kim /* Ignore optional subtable if name does not match */
621313a0c13SJung-uk Kim
622313a0c13SJung-uk Kim if ((Info->Flags & DT_OPTIONAL) &&
6235ef50723SJung-uk Kim strcmp ((*Field)->Name, Info->Name))
624313a0c13SJung-uk Kim {
625313a0c13SJung-uk Kim *RetSubtable = NULL;
626313a0c13SJung-uk Kim return (AE_OK);
627313a0c13SJung-uk Kim }
628313a0c13SJung-uk Kim
629a88e22b7SJung-uk Kim Length = DtGetSubtableLength (*Field, Info);
630d052a1ccSJung-uk Kim if (Length == ASL_EOF)
631d052a1ccSJung-uk Kim {
632d052a1ccSJung-uk Kim return (AE_ERROR);
633d052a1ccSJung-uk Kim }
634d052a1ccSJung-uk Kim
635313a0c13SJung-uk Kim Subtable = UtSubtableCacheCalloc ();
636a88e22b7SJung-uk Kim
6370b94ba42SJung-uk Kim if (Length > 0)
6380b94ba42SJung-uk Kim {
63967d9aa44SJung-uk Kim String = UtLocalCacheCalloc (Length);
640313a0c13SJung-uk Kim Subtable->Buffer = ACPI_CAST_PTR (UINT8, String);
6410b94ba42SJung-uk Kim }
642313a0c13SJung-uk Kim
643a88e22b7SJung-uk Kim Subtable->Length = Length;
644a88e22b7SJung-uk Kim Subtable->TotalLength = Length;
645a88e22b7SJung-uk Kim Buffer = Subtable->Buffer;
646a88e22b7SJung-uk Kim
647a88e22b7SJung-uk Kim LocalField = *Field;
648a371a5fdSJung-uk Kim Subtable->Name = LocalField->Name;
649a88e22b7SJung-uk Kim
650a88e22b7SJung-uk Kim /*
651a88e22b7SJung-uk Kim * Main loop walks the info table for this ACPI table or subtable
652a88e22b7SJung-uk Kim */
653a88e22b7SJung-uk Kim for (; Info->Name; Info++)
654a88e22b7SJung-uk Kim {
6553f0275a0SJung-uk Kim if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
6563f0275a0SJung-uk Kim {
6573f0275a0SJung-uk Kim continue;
6583f0275a0SJung-uk Kim }
6593f0275a0SJung-uk Kim
660a88e22b7SJung-uk Kim if (!LocalField)
661a88e22b7SJung-uk Kim {
6626f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Found NULL field - Field name \"%s\" needed",
663a88e22b7SJung-uk Kim Info->Name);
6646f1f1a63SJung-uk Kim DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
665a88e22b7SJung-uk Kim Status = AE_BAD_DATA;
666a88e22b7SJung-uk Kim goto Error;
667a88e22b7SJung-uk Kim }
668a88e22b7SJung-uk Kim
6690b94ba42SJung-uk Kim /* Maintain table offsets */
6700b94ba42SJung-uk Kim
6716f1f1a63SJung-uk Kim LocalField->TableOffset = AslGbl_CurrentTableOffset;
672a88e22b7SJung-uk Kim FieldLength = DtGetFieldLength (LocalField, Info);
6736f1f1a63SJung-uk Kim AslGbl_CurrentTableOffset += FieldLength;
6740b94ba42SJung-uk Kim
675a88e22b7SJung-uk Kim FieldType = DtGetFieldType (Info);
6766f1f1a63SJung-uk Kim AslGbl_InputFieldCount++;
677a88e22b7SJung-uk Kim
678a009b7dcSJung-uk Kim if (FieldType != DT_FIELD_TYPE_INLINE_SUBTABLE &&
679a009b7dcSJung-uk Kim strcmp (Info->Name, LocalField->Name))
680a009b7dcSJung-uk Kim {
681a009b7dcSJung-uk Kim sprintf (AslGbl_MsgBuffer, "found \"%s\" expected \"%s\"",
682a009b7dcSJung-uk Kim LocalField->Name, Info->Name);
683a009b7dcSJung-uk Kim DtError (ASL_ERROR, ASL_MSG_INVALID_LABEL, LocalField, AslGbl_MsgBuffer);
684a009b7dcSJung-uk Kim }
685a009b7dcSJung-uk Kim
686a88e22b7SJung-uk Kim switch (FieldType)
687a88e22b7SJung-uk Kim {
688a88e22b7SJung-uk Kim case DT_FIELD_TYPE_FLAGS_INTEGER:
689a88e22b7SJung-uk Kim /*
690a88e22b7SJung-uk Kim * Start of the definition of a flags field.
691a88e22b7SJung-uk Kim * This master flags integer starts at value zero, in preparation
692a88e22b7SJung-uk Kim * to compile and insert the flag fields from the individual bits
693a88e22b7SJung-uk Kim */
694a88e22b7SJung-uk Kim LocalField = LocalField->Next;
695a88e22b7SJung-uk Kim *Field = LocalField;
696a88e22b7SJung-uk Kim
697a88e22b7SJung-uk Kim FlagBuffer = Buffer;
6983f0275a0SJung-uk Kim CurrentFlagByteOffset = Info->Offset;
699a88e22b7SJung-uk Kim break;
700a88e22b7SJung-uk Kim
701a88e22b7SJung-uk Kim case DT_FIELD_TYPE_FLAG:
702a88e22b7SJung-uk Kim
703a88e22b7SJung-uk Kim /* Individual Flag field, can be multiple bits */
704a88e22b7SJung-uk Kim
705a88e22b7SJung-uk Kim if (FlagBuffer)
706a88e22b7SJung-uk Kim {
7073f0275a0SJung-uk Kim /*
7083f0275a0SJung-uk Kim * We must increment the FlagBuffer when we have crossed
7093f0275a0SJung-uk Kim * into the next flags byte within the flags field
7103f0275a0SJung-uk Kim * of type DT_FIELD_TYPE_FLAGS_INTEGER.
7113f0275a0SJung-uk Kim */
7123f0275a0SJung-uk Kim FlagBuffer += (Info->Offset - CurrentFlagByteOffset);
7133f0275a0SJung-uk Kim CurrentFlagByteOffset = Info->Offset;
7143f0275a0SJung-uk Kim
715a88e22b7SJung-uk Kim DtCompileFlag (FlagBuffer, LocalField, Info);
716a88e22b7SJung-uk Kim }
717a88e22b7SJung-uk Kim else
718a88e22b7SJung-uk Kim {
719a88e22b7SJung-uk Kim /* TBD - this is an internal error */
720a88e22b7SJung-uk Kim }
721a88e22b7SJung-uk Kim
722a88e22b7SJung-uk Kim LocalField = LocalField->Next;
723a88e22b7SJung-uk Kim *Field = LocalField;
724a88e22b7SJung-uk Kim break;
725a88e22b7SJung-uk Kim
726a88e22b7SJung-uk Kim case DT_FIELD_TYPE_INLINE_SUBTABLE:
727a88e22b7SJung-uk Kim /*
728a88e22b7SJung-uk Kim * Recursion (one level max): compile GAS (Generic Address)
729a88e22b7SJung-uk Kim * or Notify in-line subtable
730a88e22b7SJung-uk Kim */
731a88e22b7SJung-uk Kim *Field = LocalField;
732a88e22b7SJung-uk Kim
733a371a5fdSJung-uk Kim switch (Info->Opcode)
734a88e22b7SJung-uk Kim {
735a371a5fdSJung-uk Kim case ACPI_DMT_GAS:
736a371a5fdSJung-uk Kim
737a88e22b7SJung-uk Kim Status = DtCompileTable (Field, AcpiDmTableInfoGas,
738ff879b07SJung-uk Kim &InlineSubtable);
739a371a5fdSJung-uk Kim break;
740a371a5fdSJung-uk Kim
741a371a5fdSJung-uk Kim case ACPI_DMT_HESTNTFY:
742a371a5fdSJung-uk Kim
743a88e22b7SJung-uk Kim Status = DtCompileTable (Field, AcpiDmTableInfoHestNotify,
744ff879b07SJung-uk Kim &InlineSubtable);
745a371a5fdSJung-uk Kim break;
746a371a5fdSJung-uk Kim
747a371a5fdSJung-uk Kim case ACPI_DMT_IORTMEM:
748a371a5fdSJung-uk Kim
749a371a5fdSJung-uk Kim Status = DtCompileTable (Field, AcpiDmTableInfoIortAcc,
750ff879b07SJung-uk Kim &InlineSubtable);
751a371a5fdSJung-uk Kim break;
752a371a5fdSJung-uk Kim
753a371a5fdSJung-uk Kim default:
7546f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "Invalid DMT opcode: 0x%.2X",
755a371a5fdSJung-uk Kim Info->Opcode);
7566f1f1a63SJung-uk Kim DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, AslGbl_MsgBuffer);
757a371a5fdSJung-uk Kim Status = AE_BAD_DATA;
758a371a5fdSJung-uk Kim break;
759a88e22b7SJung-uk Kim }
760a88e22b7SJung-uk Kim
761a88e22b7SJung-uk Kim if (ACPI_FAILURE (Status))
762a88e22b7SJung-uk Kim {
763a88e22b7SJung-uk Kim goto Error;
764a88e22b7SJung-uk Kim }
765a88e22b7SJung-uk Kim
766a88e22b7SJung-uk Kim DtSetSubtableLength (InlineSubtable);
767a88e22b7SJung-uk Kim
7685ef50723SJung-uk Kim memcpy (Buffer, InlineSubtable->Buffer, FieldLength);
769a88e22b7SJung-uk Kim LocalField = *Field;
770a88e22b7SJung-uk Kim break;
771a88e22b7SJung-uk Kim
7720b94ba42SJung-uk Kim case DT_FIELD_TYPE_LABEL:
7730b94ba42SJung-uk Kim
7740b94ba42SJung-uk Kim DtWriteFieldToListing (Buffer, LocalField, 0);
7750b94ba42SJung-uk Kim LocalField = LocalField->Next;
7760b94ba42SJung-uk Kim break;
7770b94ba42SJung-uk Kim
778a88e22b7SJung-uk Kim default:
779a88e22b7SJung-uk Kim
780a88e22b7SJung-uk Kim /* Normal case for most field types (Integer, String, etc.) */
781a88e22b7SJung-uk Kim
782a88e22b7SJung-uk Kim DtCompileOneField (Buffer, LocalField,
783a88e22b7SJung-uk Kim FieldLength, FieldType, Info->Flags);
784d244b227SJung-uk Kim
785d244b227SJung-uk Kim DtWriteFieldToListing (Buffer, LocalField, FieldLength);
786a88e22b7SJung-uk Kim LocalField = LocalField->Next;
787a88e22b7SJung-uk Kim
788a88e22b7SJung-uk Kim if (Info->Flags & DT_LENGTH)
789a88e22b7SJung-uk Kim {
790a88e22b7SJung-uk Kim /* Field is an Integer that will contain a subtable length */
791a88e22b7SJung-uk Kim
792a88e22b7SJung-uk Kim Subtable->LengthField = Buffer;
793a88e22b7SJung-uk Kim Subtable->SizeOfLengthField = FieldLength;
794a88e22b7SJung-uk Kim }
795a88e22b7SJung-uk Kim break;
796a88e22b7SJung-uk Kim }
797a88e22b7SJung-uk Kim
798a88e22b7SJung-uk Kim Buffer += FieldLength;
799a88e22b7SJung-uk Kim }
800a88e22b7SJung-uk Kim
801a88e22b7SJung-uk Kim *Field = LocalField;
802a88e22b7SJung-uk Kim *RetSubtable = Subtable;
803a88e22b7SJung-uk Kim return (AE_OK);
804a88e22b7SJung-uk Kim
805a88e22b7SJung-uk Kim Error:
806a88e22b7SJung-uk Kim ACPI_FREE (Subtable->Buffer);
807a88e22b7SJung-uk Kim ACPI_FREE (Subtable);
808a88e22b7SJung-uk Kim return (Status);
809a88e22b7SJung-uk Kim }
810a371a5fdSJung-uk Kim
811a371a5fdSJung-uk Kim
812a371a5fdSJung-uk Kim /******************************************************************************
813a371a5fdSJung-uk Kim *
814f8146b88SJung-uk Kim * FUNCTION: DtCompileTwoSubtables
815f8146b88SJung-uk Kim *
816f8146b88SJung-uk Kim * PARAMETERS: List - Current field list pointer
817f8146b88SJung-uk Kim * TableInfo1 - Info table 1
818f8146b88SJung-uk Kim * TableInfo1 - Info table 2
819f8146b88SJung-uk Kim *
820f8146b88SJung-uk Kim * RETURN: Status
821f8146b88SJung-uk Kim *
822f8146b88SJung-uk Kim * DESCRIPTION: Compile tables with a header and one or more same subtables.
823f8146b88SJung-uk Kim * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT
824f8146b88SJung-uk Kim *
825f8146b88SJung-uk Kim *****************************************************************************/
826f8146b88SJung-uk Kim
827f8146b88SJung-uk Kim ACPI_STATUS
DtCompileTwoSubtables(void ** List,ACPI_DMTABLE_INFO * TableInfo1,ACPI_DMTABLE_INFO * TableInfo2)828f8146b88SJung-uk Kim DtCompileTwoSubtables (
829f8146b88SJung-uk Kim void **List,
830f8146b88SJung-uk Kim ACPI_DMTABLE_INFO *TableInfo1,
831f8146b88SJung-uk Kim ACPI_DMTABLE_INFO *TableInfo2)
832f8146b88SJung-uk Kim {
833f8146b88SJung-uk Kim ACPI_STATUS Status;
834f8146b88SJung-uk Kim DT_SUBTABLE *Subtable;
835f8146b88SJung-uk Kim DT_SUBTABLE *ParentTable;
836f8146b88SJung-uk Kim DT_FIELD **PFieldList = (DT_FIELD **) List;
837f8146b88SJung-uk Kim
838f8146b88SJung-uk Kim
839ff879b07SJung-uk Kim Status = DtCompileTable (PFieldList, TableInfo1, &Subtable);
840f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
841f8146b88SJung-uk Kim {
842f8146b88SJung-uk Kim return (Status);
843f8146b88SJung-uk Kim }
844f8146b88SJung-uk Kim
845f8146b88SJung-uk Kim ParentTable = DtPeekSubtable ();
846f8146b88SJung-uk Kim DtInsertSubtable (ParentTable, Subtable);
847f8146b88SJung-uk Kim
848f8146b88SJung-uk Kim while (*PFieldList)
849f8146b88SJung-uk Kim {
850ff879b07SJung-uk Kim Status = DtCompileTable (PFieldList, TableInfo2, &Subtable);
851f8146b88SJung-uk Kim if (ACPI_FAILURE (Status))
852f8146b88SJung-uk Kim {
853f8146b88SJung-uk Kim return (Status);
854f8146b88SJung-uk Kim }
855f8146b88SJung-uk Kim
856f8146b88SJung-uk Kim DtInsertSubtable (ParentTable, Subtable);
857f8146b88SJung-uk Kim }
858f8146b88SJung-uk Kim
859f8146b88SJung-uk Kim return (AE_OK);
860f8146b88SJung-uk Kim }
861f8146b88SJung-uk Kim
862f8146b88SJung-uk Kim
863f8146b88SJung-uk Kim /******************************************************************************
864f8146b88SJung-uk Kim *
865a371a5fdSJung-uk Kim * FUNCTION: DtCompilePadding
866a371a5fdSJung-uk Kim *
867a371a5fdSJung-uk Kim * PARAMETERS: Length - Padding field size
868a371a5fdSJung-uk Kim * RetSubtable - Compile result of table
869a371a5fdSJung-uk Kim *
870a371a5fdSJung-uk Kim * RETURN: Status
871a371a5fdSJung-uk Kim *
872a371a5fdSJung-uk Kim * DESCRIPTION: Compile a subtable for padding purpose
873a371a5fdSJung-uk Kim *
874a371a5fdSJung-uk Kim *****************************************************************************/
875a371a5fdSJung-uk Kim
876a371a5fdSJung-uk Kim ACPI_STATUS
DtCompilePadding(UINT32 Length,DT_SUBTABLE ** RetSubtable)877a371a5fdSJung-uk Kim DtCompilePadding (
878a371a5fdSJung-uk Kim UINT32 Length,
879a371a5fdSJung-uk Kim DT_SUBTABLE **RetSubtable)
880a371a5fdSJung-uk Kim {
881a371a5fdSJung-uk Kim DT_SUBTABLE *Subtable;
882a371a5fdSJung-uk Kim /* UINT8 *Buffer; */
883a371a5fdSJung-uk Kim char *String;
884a371a5fdSJung-uk Kim
885a371a5fdSJung-uk Kim
886a371a5fdSJung-uk Kim Subtable = UtSubtableCacheCalloc ();
887a371a5fdSJung-uk Kim
888a371a5fdSJung-uk Kim if (Length > 0)
889a371a5fdSJung-uk Kim {
89067d9aa44SJung-uk Kim String = UtLocalCacheCalloc (Length);
891a371a5fdSJung-uk Kim Subtable->Buffer = ACPI_CAST_PTR (UINT8, String);
892a371a5fdSJung-uk Kim }
893a371a5fdSJung-uk Kim
894a371a5fdSJung-uk Kim Subtable->Length = Length;
895a371a5fdSJung-uk Kim Subtable->TotalLength = Length;
896a371a5fdSJung-uk Kim /* Buffer = Subtable->Buffer; */
897a371a5fdSJung-uk Kim
898a371a5fdSJung-uk Kim *RetSubtable = Subtable;
899a371a5fdSJung-uk Kim return (AE_OK);
900a371a5fdSJung-uk Kim }
901