1 |
1275 |
phoenix |
/******************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* Module Name: tbgetall - Get all required ACPI tables
|
4 |
|
|
*
|
5 |
|
|
*****************************************************************************/
|
6 |
|
|
|
7 |
|
|
/*
|
8 |
|
|
* Copyright (C) 2000 - 2004, R. Byron Moore
|
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 |
|
|
|
45 |
|
|
#include <acpi/acpi.h>
|
46 |
|
|
#include <acpi/actables.h>
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
#define _COMPONENT ACPI_TABLES
|
50 |
|
|
ACPI_MODULE_NAME ("tbgetall")
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
/*******************************************************************************
|
54 |
|
|
*
|
55 |
|
|
* FUNCTION: acpi_tb_get_primary_table
|
56 |
|
|
*
|
57 |
|
|
* PARAMETERS: Address - Physical address of table to retrieve
|
58 |
|
|
* *table_info - Where the table info is returned
|
59 |
|
|
*
|
60 |
|
|
* RETURN: Status
|
61 |
|
|
*
|
62 |
|
|
* DESCRIPTION: Maps the physical address of table into a logical address
|
63 |
|
|
*
|
64 |
|
|
******************************************************************************/
|
65 |
|
|
|
66 |
|
|
acpi_status
|
67 |
|
|
acpi_tb_get_primary_table (
|
68 |
|
|
struct acpi_pointer *address,
|
69 |
|
|
struct acpi_table_desc *table_info)
|
70 |
|
|
{
|
71 |
|
|
acpi_status status;
|
72 |
|
|
struct acpi_table_header header;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
ACPI_FUNCTION_TRACE ("tb_get_primary_table");
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
/* Ignore a NULL address in the RSDT */
|
79 |
|
|
|
80 |
|
|
if (!address->pointer.value) {
|
81 |
|
|
return_ACPI_STATUS (AE_OK);
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
/*
|
85 |
|
|
* Get the header in order to get signature and table size
|
86 |
|
|
*/
|
87 |
|
|
status = acpi_tb_get_table_header (address, &header);
|
88 |
|
|
if (ACPI_FAILURE (status)) {
|
89 |
|
|
return_ACPI_STATUS (status);
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/* Clear the table_info */
|
93 |
|
|
|
94 |
|
|
ACPI_MEMSET (table_info, 0, sizeof (struct acpi_table_desc));
|
95 |
|
|
|
96 |
|
|
/*
|
97 |
|
|
* Check the table signature and make sure it is recognized.
|
98 |
|
|
* Also checks the header checksum
|
99 |
|
|
*/
|
100 |
|
|
table_info->pointer = &header;
|
101 |
|
|
status = acpi_tb_recognize_table (table_info, ACPI_TABLE_PRIMARY);
|
102 |
|
|
if (ACPI_FAILURE (status)) {
|
103 |
|
|
return_ACPI_STATUS (status);
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
/* Get the entire table */
|
107 |
|
|
|
108 |
|
|
status = acpi_tb_get_table_body (address, &header, table_info);
|
109 |
|
|
if (ACPI_FAILURE (status)) {
|
110 |
|
|
return_ACPI_STATUS (status);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
/* Install the table */
|
114 |
|
|
|
115 |
|
|
status = acpi_tb_install_table (table_info);
|
116 |
|
|
return_ACPI_STATUS (status);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
/*******************************************************************************
|
121 |
|
|
*
|
122 |
|
|
* FUNCTION: acpi_tb_get_secondary_table
|
123 |
|
|
*
|
124 |
|
|
* PARAMETERS: Address - Physical address of table to retrieve
|
125 |
|
|
* *table_info - Where the table info is returned
|
126 |
|
|
*
|
127 |
|
|
* RETURN: Status
|
128 |
|
|
*
|
129 |
|
|
* DESCRIPTION: Maps the physical address of table into a logical address
|
130 |
|
|
*
|
131 |
|
|
******************************************************************************/
|
132 |
|
|
|
133 |
|
|
acpi_status
|
134 |
|
|
acpi_tb_get_secondary_table (
|
135 |
|
|
struct acpi_pointer *address,
|
136 |
|
|
acpi_string signature,
|
137 |
|
|
struct acpi_table_desc *table_info)
|
138 |
|
|
{
|
139 |
|
|
acpi_status status;
|
140 |
|
|
struct acpi_table_header header;
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
ACPI_FUNCTION_TRACE_STR ("tb_get_secondary_table", signature);
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
/* Get the header in order to match the signature */
|
147 |
|
|
|
148 |
|
|
status = acpi_tb_get_table_header (address, &header);
|
149 |
|
|
if (ACPI_FAILURE (status)) {
|
150 |
|
|
return_ACPI_STATUS (status);
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
/* Signature must match request */
|
154 |
|
|
|
155 |
|
|
if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) {
|
156 |
|
|
ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n",
|
157 |
|
|
signature, header.signature));
|
158 |
|
|
return_ACPI_STATUS (AE_BAD_SIGNATURE);
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
/*
|
162 |
|
|
* Check the table signature and make sure it is recognized.
|
163 |
|
|
* Also checks the header checksum
|
164 |
|
|
*/
|
165 |
|
|
table_info->pointer = &header;
|
166 |
|
|
status = acpi_tb_recognize_table (table_info, ACPI_TABLE_SECONDARY);
|
167 |
|
|
if (ACPI_FAILURE (status)) {
|
168 |
|
|
return_ACPI_STATUS (status);
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
/* Get the entire table */
|
172 |
|
|
|
173 |
|
|
status = acpi_tb_get_table_body (address, &header, table_info);
|
174 |
|
|
if (ACPI_FAILURE (status)) {
|
175 |
|
|
return_ACPI_STATUS (status);
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
/* Install the table */
|
179 |
|
|
|
180 |
|
|
status = acpi_tb_install_table (table_info);
|
181 |
|
|
return_ACPI_STATUS (status);
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
/*******************************************************************************
|
186 |
|
|
*
|
187 |
|
|
* FUNCTION: acpi_tb_get_required_tables
|
188 |
|
|
*
|
189 |
|
|
* PARAMETERS: None
|
190 |
|
|
*
|
191 |
|
|
* RETURN: Status
|
192 |
|
|
*
|
193 |
|
|
* DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must
|
194 |
|
|
* already be loaded and validated.
|
195 |
|
|
*
|
196 |
|
|
* Get the minimum set of ACPI tables, namely:
|
197 |
|
|
*
|
198 |
|
|
* 1) FADT (via RSDT in loop below)
|
199 |
|
|
* 2) FACS (via FADT)
|
200 |
|
|
* 3) DSDT (via FADT)
|
201 |
|
|
*
|
202 |
|
|
******************************************************************************/
|
203 |
|
|
|
204 |
|
|
acpi_status
|
205 |
|
|
acpi_tb_get_required_tables (
|
206 |
|
|
void)
|
207 |
|
|
{
|
208 |
|
|
acpi_status status = AE_OK;
|
209 |
|
|
u32 i;
|
210 |
|
|
struct acpi_table_desc table_info;
|
211 |
|
|
struct acpi_pointer address;
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
ACPI_FUNCTION_TRACE ("tb_get_required_tables");
|
215 |
|
|
|
216 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
|
217 |
|
|
acpi_gbl_rsdt_table_count));
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
|
221 |
|
|
|
222 |
|
|
/*
|
223 |
|
|
* Loop through all table pointers found in RSDT.
|
224 |
|
|
* This will NOT include the FACS and DSDT - we must get
|
225 |
|
|
* them after the loop.
|
226 |
|
|
*
|
227 |
|
|
* The only tables we are interested in getting here is the FADT and
|
228 |
|
|
* any SSDTs.
|
229 |
|
|
*/
|
230 |
|
|
for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
|
231 |
|
|
/* Get the table address from the common internal XSDT */
|
232 |
|
|
|
233 |
|
|
address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
|
234 |
|
|
|
235 |
|
|
/*
|
236 |
|
|
* Get the tables needed by this subsystem (FADT and any SSDTs).
|
237 |
|
|
* NOTE: All other tables are completely ignored at this time.
|
238 |
|
|
*/
|
239 |
|
|
status = acpi_tb_get_primary_table (&address, &table_info);
|
240 |
|
|
if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
|
241 |
|
|
ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n",
|
242 |
|
|
acpi_format_exception (status),
|
243 |
|
|
ACPI_FORMAT_UINT64 (address.pointer.value)));
|
244 |
|
|
}
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
/* We must have a FADT to continue */
|
248 |
|
|
|
249 |
|
|
if (!acpi_gbl_FADT) {
|
250 |
|
|
ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n"));
|
251 |
|
|
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
/*
|
255 |
|
|
* Convert the FADT to a common format. This allows earlier revisions of the
|
256 |
|
|
* table to coexist with newer versions, using common access code.
|
257 |
|
|
*/
|
258 |
|
|
status = acpi_tb_convert_table_fadt ();
|
259 |
|
|
if (ACPI_FAILURE (status)) {
|
260 |
|
|
ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n"));
|
261 |
|
|
return_ACPI_STATUS (status);
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
/*
|
265 |
|
|
* Get the FACS (Pointed to by the FADT)
|
266 |
|
|
*/
|
267 |
|
|
address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
|
268 |
|
|
|
269 |
|
|
status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info);
|
270 |
|
|
if (ACPI_FAILURE (status)) {
|
271 |
|
|
ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n",
|
272 |
|
|
acpi_format_exception (status)));
|
273 |
|
|
return_ACPI_STATUS (status);
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
/*
|
277 |
|
|
* Create the common FACS pointer table
|
278 |
|
|
* (Contains pointers to the original table)
|
279 |
|
|
*/
|
280 |
|
|
status = acpi_tb_build_common_facs (&table_info);
|
281 |
|
|
if (ACPI_FAILURE (status)) {
|
282 |
|
|
return_ACPI_STATUS (status);
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
/*
|
286 |
|
|
* Get/install the DSDT (Pointed to by the FADT)
|
287 |
|
|
*/
|
288 |
|
|
address.pointer.value = acpi_gbl_FADT->Xdsdt;
|
289 |
|
|
|
290 |
|
|
status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info);
|
291 |
|
|
if (ACPI_FAILURE (status)) {
|
292 |
|
|
ACPI_REPORT_ERROR (("Could not get/install the DSDT\n"));
|
293 |
|
|
return_ACPI_STATUS (status);
|
294 |
|
|
}
|
295 |
|
|
|
296 |
|
|
/* Set Integer Width (32/64) based upon DSDT revision */
|
297 |
|
|
|
298 |
|
|
acpi_ut_set_integer_width (acpi_gbl_DSDT->revision);
|
299 |
|
|
|
300 |
|
|
/* Dump the entire DSDT */
|
301 |
|
|
|
302 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
|
303 |
|
|
"Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
|
304 |
|
|
acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width));
|
305 |
|
|
ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
|
306 |
|
|
|
307 |
|
|
/* Always delete the RSDP mapping, we are done with it */
|
308 |
|
|
|
309 |
|
|
acpi_tb_delete_tables_by_type (ACPI_TABLE_RSDP);
|
310 |
|
|
return_ACPI_STATUS (status);
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
|