dttable.c revision 1.7.2.1 1 /******************************************************************************
2 *
3 * Module Name: dttable.c - handling for specific ACPI tables
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
10 *
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.
25 *
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.
29 *
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.
42 */
43
44 /* Compile routines for the basic ACPI tables */
45
46 #include "aslcompiler.h"
47 #include "dtcompiler.h"
48
49 #define _COMPONENT DT_COMPILER
50 ACPI_MODULE_NAME ("dttable")
51
52
53 /******************************************************************************
54 *
55 * FUNCTION: DtCompileRsdp
56 *
57 * PARAMETERS: PFieldList - Current field list pointer
58 *
59 * RETURN: Status
60 *
61 * DESCRIPTION: Compile RSDP.
62 *
63 *****************************************************************************/
64
65 ACPI_STATUS
66 DtCompileRsdp (
67 DT_FIELD **PFieldList)
68 {
69 DT_SUBTABLE *Subtable;
70 ACPI_TABLE_RSDP *Rsdp;
71 ACPI_RSDP_EXTENSION *RsdpExtension;
72 ACPI_STATUS Status;
73
74
75 /* Compile the "common" RSDP (ACPI 1.0) */
76
77 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1,
78 &Gbl_RootTable, TRUE);
79 if (ACPI_FAILURE (Status))
80 {
81 return (Status);
82 }
83
84 Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer);
85 DtSetTableChecksum (&Rsdp->Checksum);
86
87 if (Rsdp->Revision > 0)
88 {
89 /* Compile the "extended" part of the RSDP as a subtable */
90
91 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2,
92 &Subtable, TRUE);
93 if (ACPI_FAILURE (Status))
94 {
95 return (Status);
96 }
97
98 DtInsertSubtable (Gbl_RootTable, Subtable);
99
100 /* Set length and extended checksum for entire RSDP */
101
102 RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer);
103 RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length;
104 DtSetTableChecksum (&RsdpExtension->ExtendedChecksum);
105 }
106
107 return (AE_OK);
108 }
109
110
111 /******************************************************************************
112 *
113 * FUNCTION: DtCompileFadt
114 *
115 * PARAMETERS: List - Current field list pointer
116 *
117 * RETURN: Status
118 *
119 * DESCRIPTION: Compile FADT.
120 *
121 *****************************************************************************/
122
123 ACPI_STATUS
124 DtCompileFadt (
125 void **List)
126 {
127 ACPI_STATUS Status;
128 DT_SUBTABLE *Subtable;
129 DT_SUBTABLE *ParentTable;
130 DT_FIELD **PFieldList = (DT_FIELD **) List;
131 ACPI_TABLE_HEADER *Table;
132 UINT8 FadtRevision;
133 UINT32 i;
134
135
136 /* Minimum table is the FADT version 1 (ACPI 1.0) */
137
138 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
139 &Subtable, TRUE);
140 if (ACPI_FAILURE (Status))
141 {
142 return (Status);
143 }
144
145 ParentTable = DtPeekSubtable ();
146 DtInsertSubtable (ParentTable, Subtable);
147
148 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
149 FadtRevision = Table->Revision;
150
151 /* Revision 0 and 2 are illegal */
152
153 if ((FadtRevision == 0) ||
154 (FadtRevision == 2))
155 {
156 DtError (ASL_ERROR, 0, NULL,
157 "Invalid value for FADT revision");
158
159 return (AE_BAD_VALUE);
160 }
161
162 /* Revision out of supported range? */
163
164 if (FadtRevision > ACPI_FADT_MAX_VERSION)
165 {
166 DtError (ASL_ERROR, 0, NULL,
167 "Unknown or unsupported value for FADT revision");
168
169 return (AE_BAD_VALUE);
170 }
171
172 /* Compile individual sub-parts of the FADT, per-revision */
173
174 for (i = 3; i <= ACPI_FADT_MAX_VERSION; i++)
175 {
176 if (i > FadtRevision)
177 {
178 break;
179 }
180
181 /* Compile the fields specific to this FADT revision */
182
183 Status = DtCompileTable (PFieldList, FadtRevisionInfo[i],
184 &Subtable, TRUE);
185 if (ACPI_FAILURE (Status))
186 {
187 return (Status);
188 }
189
190 DtInsertSubtable (ParentTable, Subtable);
191 }
192
193 return (AE_OK);
194 }
195
196
197 /******************************************************************************
198 *
199 * FUNCTION: DtCompileFacs
200 *
201 * PARAMETERS: PFieldList - Current field list pointer
202 *
203 * RETURN: Status
204 *
205 * DESCRIPTION: Compile FACS.
206 *
207 *****************************************************************************/
208
209 ACPI_STATUS
210 DtCompileFacs (
211 DT_FIELD **PFieldList)
212 {
213 DT_SUBTABLE *Subtable;
214 UINT8 *ReservedBuffer;
215 ACPI_STATUS Status;
216 UINT32 ReservedSize;
217
218
219 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
220 &Gbl_RootTable, TRUE);
221 if (ACPI_FAILURE (Status))
222 {
223 return (Status);
224 }
225
226 /* Large FACS reserved area at the end of the table */
227
228 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
229 ReservedBuffer = UtLocalCalloc (ReservedSize);
230
231 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
232
233 ACPI_FREE (ReservedBuffer);
234 DtInsertSubtable (Gbl_RootTable, Subtable);
235 return (AE_OK);
236 }
237