dttable.c revision 1.11.2.2 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.11.2.2 martin * Copyright (C) 2000 - 2020, 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
48 1.1 jruoho #define _COMPONENT DT_COMPILER
49 1.1 jruoho ACPI_MODULE_NAME ("dttable")
50 1.1 jruoho
51 1.1 jruoho
52 1.1 jruoho /******************************************************************************
53 1.1 jruoho *
54 1.1 jruoho * FUNCTION: DtCompileRsdp
55 1.1 jruoho *
56 1.1 jruoho * PARAMETERS: PFieldList - Current field list pointer
57 1.1 jruoho *
58 1.1 jruoho * RETURN: Status
59 1.1 jruoho *
60 1.1 jruoho * DESCRIPTION: Compile RSDP.
61 1.1 jruoho *
62 1.1 jruoho *****************************************************************************/
63 1.1 jruoho
64 1.1 jruoho ACPI_STATUS
65 1.1 jruoho DtCompileRsdp (
66 1.1 jruoho DT_FIELD **PFieldList)
67 1.1 jruoho {
68 1.1 jruoho DT_SUBTABLE *Subtable;
69 1.2 christos ACPI_TABLE_RSDP *Rsdp;
70 1.2 christos ACPI_RSDP_EXTENSION *RsdpExtension;
71 1.1 jruoho ACPI_STATUS Status;
72 1.1 jruoho
73 1.1 jruoho
74 1.2 christos /* Compile the "common" RSDP (ACPI 1.0) */
75 1.2 christos
76 1.1 jruoho Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1,
77 1.11.2.1 christos &AslGbl_RootTable);
78 1.1 jruoho if (ACPI_FAILURE (Status))
79 1.1 jruoho {
80 1.1 jruoho return (Status);
81 1.1 jruoho }
82 1.1 jruoho
83 1.11.2.1 christos Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, AslGbl_RootTable->Buffer);
84 1.2 christos DtSetTableChecksum (&Rsdp->Checksum);
85 1.1 jruoho
86 1.2 christos if (Rsdp->Revision > 0)
87 1.1 jruoho {
88 1.2 christos /* Compile the "extended" part of the RSDP as a subtable */
89 1.2 christos
90 1.1 jruoho Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2,
91 1.11 christos &Subtable);
92 1.1 jruoho if (ACPI_FAILURE (Status))
93 1.1 jruoho {
94 1.1 jruoho return (Status);
95 1.1 jruoho }
96 1.1 jruoho
97 1.11.2.1 christos DtInsertSubtable (AslGbl_RootTable, Subtable);
98 1.2 christos
99 1.2 christos /* Set length and extended checksum for entire RSDP */
100 1.2 christos
101 1.2 christos RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer);
102 1.11.2.1 christos RsdpExtension->Length = AslGbl_RootTable->Length + Subtable->Length;
103 1.2 christos DtSetTableChecksum (&RsdpExtension->ExtendedChecksum);
104 1.1 jruoho }
105 1.1 jruoho
106 1.1 jruoho return (AE_OK);
107 1.1 jruoho }
108 1.1 jruoho
109 1.1 jruoho
110 1.1 jruoho /******************************************************************************
111 1.1 jruoho *
112 1.7 christos * FUNCTION: DtCompileFadt
113 1.1 jruoho *
114 1.1 jruoho * PARAMETERS: List - Current field list pointer
115 1.1 jruoho *
116 1.1 jruoho * RETURN: Status
117 1.1 jruoho *
118 1.7 christos * DESCRIPTION: Compile FADT.
119 1.1 jruoho *
120 1.1 jruoho *****************************************************************************/
121 1.1 jruoho
122 1.1 jruoho ACPI_STATUS
123 1.7 christos DtCompileFadt (
124 1.1 jruoho void **List)
125 1.1 jruoho {
126 1.7 christos ACPI_STATUS Status;
127 1.1 jruoho DT_SUBTABLE *Subtable;
128 1.1 jruoho DT_SUBTABLE *ParentTable;
129 1.1 jruoho DT_FIELD **PFieldList = (DT_FIELD **) List;
130 1.7 christos ACPI_TABLE_HEADER *Table;
131 1.9 christos UINT8 Revision;
132 1.1 jruoho
133 1.1 jruoho
134 1.7 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
135 1.11 christos &Subtable);
136 1.7 christos if (ACPI_FAILURE (Status))
137 1.1 jruoho {
138 1.7 christos return (Status);
139 1.7 christos }
140 1.1 jruoho
141 1.7 christos ParentTable = DtPeekSubtable ();
142 1.7 christos DtInsertSubtable (ParentTable, Subtable);
143 1.1 jruoho
144 1.7 christos Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
145 1.9 christos Revision = Table->Revision;
146 1.8 christos
147 1.9 christos if (Revision == 2)
148 1.8 christos {
149 1.9 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2,
150 1.11 christos &Subtable);
151 1.9 christos if (ACPI_FAILURE (Status))
152 1.9 christos {
153 1.9 christos return (Status);
154 1.9 christos }
155 1.8 christos
156 1.9 christos DtInsertSubtable (ParentTable, Subtable);
157 1.8 christos }
158 1.9 christos else if (Revision >= 2)
159 1.7 christos {
160 1.9 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3,
161 1.11 christos &Subtable);
162 1.9 christos if (ACPI_FAILURE (Status))
163 1.9 christos {
164 1.9 christos return (Status);
165 1.9 christos }
166 1.8 christos
167 1.9 christos DtInsertSubtable (ParentTable, Subtable);
168 1.8 christos
169 1.9 christos if (Revision >= 5)
170 1.9 christos {
171 1.9 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5,
172 1.11 christos &Subtable);
173 1.9 christos if (ACPI_FAILURE (Status))
174 1.9 christos {
175 1.9 christos return (Status);
176 1.9 christos }
177 1.8 christos
178 1.9 christos DtInsertSubtable (ParentTable, Subtable);
179 1.1 jruoho }
180 1.1 jruoho
181 1.9 christos if (Revision >= 6)
182 1.9 christos {
183 1.9 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6,
184 1.11 christos &Subtable);
185 1.9 christos if (ACPI_FAILURE (Status))
186 1.9 christos {
187 1.9 christos return (Status);
188 1.9 christos }
189 1.8 christos
190 1.9 christos DtInsertSubtable (ParentTable, Subtable);
191 1.2 christos }
192 1.2 christos }
193 1.2 christos
194 1.7 christos return (AE_OK);
195 1.2 christos }
196 1.2 christos
197 1.2 christos
198 1.2 christos /******************************************************************************
199 1.2 christos *
200 1.7 christos * FUNCTION: DtCompileFacs
201 1.2 christos *
202 1.7 christos * PARAMETERS: PFieldList - Current field list pointer
203 1.2 christos *
204 1.2 christos * RETURN: Status
205 1.2 christos *
206 1.7 christos * DESCRIPTION: Compile FACS.
207 1.2 christos *
208 1.2 christos *****************************************************************************/
209 1.2 christos
210 1.2 christos ACPI_STATUS
211 1.7 christos DtCompileFacs (
212 1.7 christos DT_FIELD **PFieldList)
213 1.2 christos {
214 1.7 christos DT_SUBTABLE *Subtable;
215 1.7 christos UINT8 *ReservedBuffer;
216 1.2 christos ACPI_STATUS Status;
217 1.7 christos UINT32 ReservedSize;
218 1.2 christos
219 1.2 christos
220 1.7 christos Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
221 1.11.2.1 christos &AslGbl_RootTable);
222 1.2 christos if (ACPI_FAILURE (Status))
223 1.2 christos {
224 1.2 christos return (Status);
225 1.2 christos }
226 1.2 christos
227 1.7 christos /* Large FACS reserved area at the end of the table */
228 1.2 christos
229 1.7 christos ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
230 1.7 christos ReservedBuffer = UtLocalCalloc (ReservedSize);
231 1.2 christos
232 1.7 christos DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
233 1.2 christos
234 1.7 christos ACPI_FREE (ReservedBuffer);
235 1.11.2.1 christos DtInsertSubtable (AslGbl_RootTable, Subtable);
236 1.2 christos return (AE_OK);
237 1.2 christos }
238