dttable.c revision 1.8.2.1 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: dttable.c - handling for specific ACPI tables
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.2 christos /*
8 1.8.2.1 bouyer * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.2 christos * Redistribution and use in source and binary forms, with or without
12 1.2 christos * modification, are permitted provided that the following conditions
13 1.2 christos * are met:
14 1.2 christos * 1. Redistributions of source code must retain the above copyright
15 1.2 christos * notice, this list of conditions, and the following disclaimer,
16 1.2 christos * without modification.
17 1.2 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.2 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.2 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.2 christos * including a substantially similar Disclaimer requirement for further
21 1.2 christos * binary redistribution.
22 1.2 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.2 christos * of any contributors may be used to endorse or promote products derived
24 1.2 christos * from this software without specific prior written permission.
25 1.2 christos *
26 1.2 christos * Alternatively, this software may be distributed under the terms of the
27 1.2 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.2 christos * Software Foundation.
29 1.2 christos *
30 1.2 christos * NO WARRANTY
31 1.2 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.2 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.2 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.2 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.2 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.2 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.2 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.2 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.2 christos */
43 1.1 jruoho
44 1.7 christos /* Compile routines for the basic ACPI tables */
45 1.1 jruoho
46 1.1 jruoho #include "aslcompiler.h"
47 1.1 jruoho #include "dtcompiler.h"
48 1.1 jruoho
49 1.1 jruoho #define _COMPONENT DT_COMPILER
50 1.1 jruoho ACPI_MODULE_NAME ("dttable")
51 1.1 jruoho
52 1.1 jruoho
53 1.1 jruoho /******************************************************************************
54 1.1 jruoho *
55 1.1 jruoho * FUNCTION: DtCompileRsdp
56 1.1 jruoho *
57 1.1 jruoho * PARAMETERS: PFieldList - Current field list pointer
58 1.1 jruoho *
59 1.1 jruoho * RETURN: Status
60 1.1 jruoho *
61 1.1 jruoho * DESCRIPTION: Compile RSDP.
62 1.1 jruoho *
63 1.1 jruoho *****************************************************************************/
64 1.1 jruoho
65 1.1 jruoho ACPI_STATUS
66 1.1 jruoho DtCompileRsdp (
67 1.1 jruoho DT_FIELD **PFieldList)
68 1.1 jruoho {
69 1.1 jruoho DT_SUBTABLE *Subtable;
70 1.2 christos ACPI_TABLE_RSDP *Rsdp;
71 1.2 christos ACPI_RSDP_EXTENSION *RsdpExtension;
72 1.1 jruoho ACPI_STATUS Status;
73 1.1 jruoho
74 1.1 jruoho
75 1.2 christos /* Compile the "common" RSDP (ACPI 1.0) */
76 1.2 christos
77 1.1 jruoho Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1,
78 1.7 christos &Gbl_RootTable, TRUE);
79 1.1 jruoho if (ACPI_FAILURE (Status))
80 1.1 jruoho {
81 1.1 jruoho return (Status);
82 1.1 jruoho }
83 1.1 jruoho
84 1.2 christos Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer);
85 1.2 christos DtSetTableChecksum (&Rsdp->Checksum);
86 1.1 jruoho
87 1.2 christos if (Rsdp->Revision > 0)
88 1.1 jruoho {
89 1.2 christos /* Compile the "extended" part of the RSDP as a subtable */
90 1.2 christos
91 1.1 jruoho Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2,
92 1.7 christos &Subtable, TRUE);
93 1.1 jruoho if (ACPI_FAILURE (Status))
94 1.1 jruoho {
95 1.1 jruoho return (Status);
96 1.1 jruoho }
97 1.1 jruoho
98 1.1 jruoho DtInsertSubtable (Gbl_RootTable, Subtable);
99 1.2 christos
100 1.2 christos /* Set length and extended checksum for entire RSDP */
101 1.2 christos
102 1.2 christos RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer);
103 1.2 christos RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length;
104 1.2 christos DtSetTableChecksum (&RsdpExtension->ExtendedChecksum);
105 1.1 jruoho }
106 1.1 jruoho
107 1.1 jruoho return (AE_OK);
108 1.1 jruoho }
109 1.1 jruoho
110 1.1 jruoho
111 1.1 jruoho /******************************************************************************
112 1.1 jruoho *
113 1.7 christos * FUNCTION: DtCompileFadt
114 1.1 jruoho *
115 1.1 jruoho * PARAMETERS: List - Current field list pointer
116 1.1 jruoho *
117 1.1 jruoho * RETURN: Status
118 1.1 jruoho *
119 1.7 christos * DESCRIPTION: Compile FADT.
120 1.1 jruoho *
121 1.1 jruoho *****************************************************************************/
122 1.1 jruoho
123 1.1 jruoho ACPI_STATUS
124 1.7 christos DtCompileFadt (
125 1.1 jruoho void **List)
126 1.1 jruoho {
127 1.7 christos ACPI_STATUS Status;
128 1.1 jruoho DT_SUBTABLE *Subtable;
129 1.1 jruoho DT_SUBTABLE *ParentTable;
130 1.1 jruoho DT_FIELD **PFieldList = (DT_FIELD **) List;
131 1.7 christos ACPI_TABLE_HEADER *Table;
132 1.8.2.1 bouyer UINT8 Revision;
133 1.1 jruoho
134 1.1 jruoho
135 1.7 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
136 1.7 christos &Subtable, TRUE);
137 1.7 christos if (ACPI_FAILURE (Status))
138 1.1 jruoho {
139 1.7 christos return (Status);
140 1.7 christos }
141 1.1 jruoho
142 1.7 christos ParentTable = DtPeekSubtable ();
143 1.7 christos DtInsertSubtable (ParentTable, Subtable);
144 1.1 jruoho
145 1.7 christos Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
146 1.8.2.1 bouyer Revision = Table->Revision;
147 1.1 jruoho
148 1.8.2.1 bouyer if (Revision == 2)
149 1.7 christos {
150 1.8.2.1 bouyer Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2,
151 1.8.2.1 bouyer &Subtable, TRUE);
152 1.8.2.1 bouyer if (ACPI_FAILURE (Status))
153 1.1 jruoho {
154 1.8.2.1 bouyer return (Status);
155 1.1 jruoho }
156 1.1 jruoho
157 1.8.2.1 bouyer DtInsertSubtable (ParentTable, Subtable);
158 1.8.2.1 bouyer }
159 1.8.2.1 bouyer else if (Revision >= 2)
160 1.8.2.1 bouyer {
161 1.8.2.1 bouyer Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3,
162 1.7 christos &Subtable, TRUE);
163 1.2 christos if (ACPI_FAILURE (Status))
164 1.2 christos {
165 1.2 christos return (Status);
166 1.2 christos }
167 1.2 christos
168 1.2 christos DtInsertSubtable (ParentTable, Subtable);
169 1.8.2.1 bouyer
170 1.8.2.1 bouyer if (Revision >= 5)
171 1.8.2.1 bouyer {
172 1.8.2.1 bouyer Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5,
173 1.8.2.1 bouyer &Subtable, TRUE);
174 1.8.2.1 bouyer if (ACPI_FAILURE (Status))
175 1.8.2.1 bouyer {
176 1.8.2.1 bouyer return (Status);
177 1.8.2.1 bouyer }
178 1.8.2.1 bouyer
179 1.8.2.1 bouyer DtInsertSubtable (ParentTable, Subtable);
180 1.8.2.1 bouyer }
181 1.8.2.1 bouyer
182 1.8.2.1 bouyer if (Revision >= 6)
183 1.8.2.1 bouyer {
184 1.8.2.1 bouyer Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6,
185 1.8.2.1 bouyer &Subtable, TRUE);
186 1.8.2.1 bouyer if (ACPI_FAILURE (Status))
187 1.8.2.1 bouyer {
188 1.8.2.1 bouyer return (Status);
189 1.8.2.1 bouyer }
190 1.8.2.1 bouyer
191 1.8.2.1 bouyer DtInsertSubtable (ParentTable, Subtable);
192 1.8.2.1 bouyer }
193 1.2 christos }
194 1.2 christos
195 1.7 christos return (AE_OK);
196 1.2 christos }
197 1.2 christos
198 1.2 christos
199 1.2 christos /******************************************************************************
200 1.2 christos *
201 1.7 christos * FUNCTION: DtCompileFacs
202 1.2 christos *
203 1.7 christos * PARAMETERS: PFieldList - Current field list pointer
204 1.2 christos *
205 1.2 christos * RETURN: Status
206 1.2 christos *
207 1.7 christos * DESCRIPTION: Compile FACS.
208 1.2 christos *
209 1.2 christos *****************************************************************************/
210 1.2 christos
211 1.2 christos ACPI_STATUS
212 1.7 christos DtCompileFacs (
213 1.7 christos DT_FIELD **PFieldList)
214 1.2 christos {
215 1.7 christos DT_SUBTABLE *Subtable;
216 1.7 christos UINT8 *ReservedBuffer;
217 1.2 christos ACPI_STATUS Status;
218 1.7 christos UINT32 ReservedSize;
219 1.2 christos
220 1.2 christos
221 1.7 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
222 1.7 christos &Gbl_RootTable, TRUE);
223 1.2 christos if (ACPI_FAILURE (Status))
224 1.2 christos {
225 1.2 christos return (Status);
226 1.2 christos }
227 1.2 christos
228 1.7 christos /* Large FACS reserved area at the end of the table */
229 1.2 christos
230 1.7 christos ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
231 1.7 christos ReservedBuffer = UtLocalCalloc (ReservedSize);
232 1.2 christos
233 1.7 christos DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
234 1.2 christos
235 1.7 christos ACPI_FREE (ReservedBuffer);
236 1.7 christos DtInsertSubtable (Gbl_RootTable, Subtable);
237 1.2 christos return (AE_OK);
238 1.2 christos }
239