1 /******************************************************************************
3 * Module Name: dttable.c - handling for specific ACPI tables
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 /* Compile routines for the basic ACPI tables */
46 #include <contrib/dev/acpica/compiler/aslcompiler.h>
47 #include <contrib/dev/acpica/compiler/dtcompiler.h>
49 #define _COMPONENT DT_COMPILER
50 ACPI_MODULE_NAME ("dttable")
53 /******************************************************************************
55 * FUNCTION: DtCompileRsdp
57 * PARAMETERS: PFieldList - Current field list pointer
61 * DESCRIPTION: Compile RSDP.
63 *****************************************************************************/
67 DT_FIELD **PFieldList)
69 DT_SUBTABLE *Subtable;
70 ACPI_TABLE_RSDP *Rsdp;
71 ACPI_RSDP_EXTENSION *RsdpExtension;
75 /* Compile the "common" RSDP (ACPI 1.0) */
77 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1,
78 &Gbl_RootTable, TRUE);
79 if (ACPI_FAILURE (Status))
84 Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer);
85 DtSetTableChecksum (&Rsdp->Checksum);
87 if (Rsdp->Revision > 0)
89 /* Compile the "extended" part of the RSDP as a subtable */
91 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2,
93 if (ACPI_FAILURE (Status))
98 DtInsertSubtable (Gbl_RootTable, Subtable);
100 /* Set length and extended checksum for entire RSDP */
102 RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer);
103 RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length;
104 DtSetTableChecksum (&RsdpExtension->ExtendedChecksum);
111 /******************************************************************************
113 * FUNCTION: DtCompileFadt
115 * PARAMETERS: List - Current field list pointer
119 * DESCRIPTION: Compile FADT.
121 *****************************************************************************/
128 DT_SUBTABLE *Subtable;
129 DT_SUBTABLE *ParentTable;
130 DT_FIELD **PFieldList = (DT_FIELD **) List;
131 ACPI_TABLE_HEADER *Table;
135 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
137 if (ACPI_FAILURE (Status))
142 ParentTable = DtPeekSubtable ();
143 DtInsertSubtable (ParentTable, Subtable);
145 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
146 Revision = Table->Revision;
150 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2,
152 if (ACPI_FAILURE (Status))
157 DtInsertSubtable (ParentTable, Subtable);
159 else if (Revision >= 2)
161 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3,
163 if (ACPI_FAILURE (Status))
168 DtInsertSubtable (ParentTable, Subtable);
172 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5,
174 if (ACPI_FAILURE (Status))
179 DtInsertSubtable (ParentTable, Subtable);
184 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6,
186 if (ACPI_FAILURE (Status))
191 DtInsertSubtable (ParentTable, Subtable);
199 /******************************************************************************
201 * FUNCTION: DtCompileFacs
203 * PARAMETERS: PFieldList - Current field list pointer
207 * DESCRIPTION: Compile FACS.
209 *****************************************************************************/
213 DT_FIELD **PFieldList)
215 DT_SUBTABLE *Subtable;
216 UINT8 *ReservedBuffer;
221 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
222 &Gbl_RootTable, TRUE);
223 if (ACPI_FAILURE (Status))
228 /* Large FACS reserved area at the end of the table */
230 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
231 ReservedBuffer = UtLocalCalloc (ReservedSize);
233 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
235 ACPI_FREE (ReservedBuffer);
236 DtInsertSubtable (Gbl_RootTable, Subtable);