1 /******************************************************************************
3 * Module Name: tbgetall - Get all required ACPI tables
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2006, R. Byron Moore
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 #include <acpi/acpi.h>
45 #include <acpi/actables.h>
47 #define _COMPONENT ACPI_TABLES
48 ACPI_MODULE_NAME("tbgetall")
50 /* Local prototypes */
52 acpi_tb_get_primary_table(struct acpi_pointer
*address
,
53 struct acpi_table_desc
*table_info
);
56 acpi_tb_get_secondary_table(struct acpi_pointer
*address
,
57 acpi_string signature
,
58 struct acpi_table_desc
*table_info
);
60 /*******************************************************************************
62 * FUNCTION: acpi_tb_get_primary_table
64 * PARAMETERS: Address - Physical address of table to retrieve
65 * *table_info - Where the table info is returned
69 * DESCRIPTION: Maps the physical address of table into a logical address
71 ******************************************************************************/
74 acpi_tb_get_primary_table(struct acpi_pointer
*address
,
75 struct acpi_table_desc
*table_info
)
78 struct acpi_table_header header
;
80 ACPI_FUNCTION_TRACE(tb_get_primary_table
);
82 /* Ignore a NULL address in the RSDT */
84 if (!address
->pointer
.value
) {
85 return_ACPI_STATUS(AE_OK
);
88 /* Get the header in order to get signature and table size */
90 status
= acpi_tb_get_table_header(address
, &header
);
91 if (ACPI_FAILURE(status
)) {
92 return_ACPI_STATUS(status
);
95 /* Clear the table_info */
97 ACPI_MEMSET(table_info
, 0, sizeof(struct acpi_table_desc
));
100 * Check the table signature and make sure it is recognized.
101 * Also checks the header checksum
103 table_info
->pointer
= &header
;
104 status
= acpi_tb_recognize_table(table_info
, ACPI_TABLE_PRIMARY
);
105 if (ACPI_FAILURE(status
)) {
106 return_ACPI_STATUS(status
);
109 /* Get the entire table */
111 status
= acpi_tb_get_table_body(address
, &header
, table_info
);
112 if (ACPI_FAILURE(status
)) {
113 return_ACPI_STATUS(status
);
116 /* Install the table */
118 status
= acpi_tb_install_table(table_info
);
119 return_ACPI_STATUS(status
);
122 /*******************************************************************************
124 * FUNCTION: acpi_tb_get_secondary_table
126 * PARAMETERS: Address - Physical address of table to retrieve
127 * *table_info - Where the table info is returned
131 * DESCRIPTION: Maps the physical address of table into a logical address
133 ******************************************************************************/
136 acpi_tb_get_secondary_table(struct acpi_pointer
*address
,
137 acpi_string signature
,
138 struct acpi_table_desc
*table_info
)
141 struct acpi_table_header header
;
143 ACPI_FUNCTION_TRACE_STR(tb_get_secondary_table
, signature
);
145 /* Get the header in order to match the signature */
147 status
= acpi_tb_get_table_header(address
, &header
);
148 if (ACPI_FAILURE(status
)) {
149 return_ACPI_STATUS(status
);
152 /* Signature must match request */
154 if (!ACPI_COMPARE_NAME(header
.signature
, signature
)) {
156 "Incorrect table signature - wanted [%s] found [%4.4s]",
157 signature
, header
.signature
));
158 return_ACPI_STATUS(AE_BAD_SIGNATURE
);
162 * Check the table signature and make sure it is recognized.
163 * Also checks the header checksum
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
);
171 /* Get the entire table */
173 status
= acpi_tb_get_table_body(address
, &header
, table_info
);
174 if (ACPI_FAILURE(status
)) {
175 return_ACPI_STATUS(status
);
178 /* Install the table */
180 status
= acpi_tb_install_table(table_info
);
181 return_ACPI_STATUS(status
);
184 /*******************************************************************************
186 * FUNCTION: acpi_tb_get_required_tables
192 * DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must
193 * already be loaded and validated.
195 * Get the minimum set of ACPI tables, namely:
197 * 1) FADT (via RSDT in loop below)
201 ******************************************************************************/
203 acpi_status
acpi_tb_get_required_tables(void)
205 acpi_status status
= AE_OK
;
207 struct acpi_table_desc table_info
;
208 struct acpi_pointer address
;
210 ACPI_FUNCTION_TRACE(tb_get_required_tables
);
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "%d ACPI tables in RSDT\n",
213 acpi_gbl_rsdt_table_count
));
215 address
.pointer_type
= acpi_gbl_table_flags
| ACPI_LOGICAL_ADDRESSING
;
218 * Loop through all table pointers found in RSDT.
219 * This will NOT include the FACS and DSDT - we must get
220 * them after the loop.
222 * The only tables we are interested in getting here is the FADT and
225 for (i
= 0; i
< acpi_gbl_rsdt_table_count
; i
++) {
227 /* Get the table address from the common internal XSDT */
229 address
.pointer
.value
= acpi_gbl_XSDT
->table_offset_entry
[i
];
232 * Get the tables needed by this subsystem (FADT and any SSDTs).
233 * NOTE: All other tables are completely ignored at this time.
235 status
= acpi_tb_get_primary_table(&address
, &table_info
);
236 if ((status
!= AE_OK
) && (status
!= AE_TABLE_NOT_SUPPORTED
)) {
237 ACPI_WARNING((AE_INFO
,
238 "%s, while getting table at %8.8X%8.8X",
239 acpi_format_exception(status
),
240 ACPI_FORMAT_UINT64(address
.pointer
.
245 /* We must have a FADT to continue */
247 if (!acpi_gbl_FADT
) {
248 ACPI_ERROR((AE_INFO
, "No FADT present in RSDT/XSDT"));
249 return_ACPI_STATUS(AE_NO_ACPI_TABLES
);
253 * Convert the FADT to a common format. This allows earlier revisions of
254 * the table to coexist with newer versions, using common access code.
256 status
= acpi_tb_convert_table_fadt();
257 if (ACPI_FAILURE(status
)) {
259 "Could not convert FADT to internal common format"));
260 return_ACPI_STATUS(status
);
263 /* Get the FACS (Pointed to by the FADT) */
265 address
.pointer
.value
= acpi_gbl_FADT
->xfirmware_ctrl
;
267 status
= acpi_tb_get_secondary_table(&address
, FACS_SIG
, &table_info
);
268 if (ACPI_FAILURE(status
)) {
269 ACPI_EXCEPTION((AE_INFO
, status
,
270 "Could not get/install the FACS"));
271 return_ACPI_STATUS(status
);
275 * Create the common FACS pointer table
276 * (Contains pointers to the original table)
278 status
= acpi_tb_build_common_facs(&table_info
);
279 if (ACPI_FAILURE(status
)) {
280 return_ACPI_STATUS(status
);
283 /* Get/install the DSDT (Pointed to by the FADT) */
285 address
.pointer
.value
= acpi_gbl_FADT
->Xdsdt
;
287 status
= acpi_tb_get_secondary_table(&address
, DSDT_SIG
, &table_info
);
288 if (ACPI_FAILURE(status
)) {
289 ACPI_ERROR((AE_INFO
, "Could not get/install the DSDT"));
290 return_ACPI_STATUS(status
);
293 /* Set Integer Width (32/64) based upon DSDT revision */
295 acpi_ut_set_integer_width(acpi_gbl_DSDT
->revision
);
297 /* Dump the entire DSDT */
299 ACPI_DEBUG_PRINT((ACPI_DB_TABLES
,
300 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
301 acpi_gbl_DSDT
->length
, acpi_gbl_DSDT
->length
,
302 acpi_gbl_integer_bit_width
));
304 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8
, acpi_gbl_DSDT
),
305 acpi_gbl_DSDT
->length
);
307 /* Always delete the RSDP mapping, we are done with it */
309 acpi_tb_delete_tables_by_type(ACPI_TABLE_ID_RSDP
);
310 return_ACPI_STATUS(status
);