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;
136 /* Minimum table is the FADT version 1 (ACPI 1.0) */
138 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
140 if (ACPI_FAILURE (Status))
145 ParentTable = DtPeekSubtable ();
146 DtInsertSubtable (ParentTable, Subtable);
148 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
149 FadtRevision = Table->Revision;
151 /* Revision 0 and 2 are illegal */
153 if ((FadtRevision == 0) ||
156 DtError (ASL_ERROR, 0, NULL,
157 "Invalid value for FADT revision");
159 return (AE_BAD_VALUE);
162 /* Revision out of supported range? */
164 if (FadtRevision > ACPI_FADT_MAX_VERSION)
166 DtError (ASL_ERROR, 0, NULL,
167 "Unknown or unsupported value for FADT revision");
169 return (AE_BAD_VALUE);
172 /* Compile individual sub-parts of the FADT, per-revision */
174 for (i = 3; i <= ACPI_FADT_MAX_VERSION; i++)
176 if (i > FadtRevision)
181 /* Compile the fields specific to this FADT revision */
183 Status = DtCompileTable (PFieldList, FadtRevisionInfo[i],
185 if (ACPI_FAILURE (Status))
190 DtInsertSubtable (ParentTable, Subtable);
197 /******************************************************************************
199 * FUNCTION: DtCompileFacs
201 * PARAMETERS: PFieldList - Current field list pointer
205 * DESCRIPTION: Compile FACS.
207 *****************************************************************************/
211 DT_FIELD **PFieldList)
213 DT_SUBTABLE *Subtable;
214 UINT8 *ReservedBuffer;
219 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
220 &Gbl_RootTable, TRUE);
221 if (ACPI_FAILURE (Status))
226 /* Large FACS reserved area at the end of the table */
228 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
229 ReservedBuffer = UtLocalCalloc (ReservedSize);
231 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
233 ACPI_FREE (ReservedBuffer);
234 DtInsertSubtable (Gbl_RootTable, Subtable);