Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Bob Moore | 42f4786 | 2013-06-08 00:59:02 +0000 | [diff] [blame] | 3 | * Module Name: tbutils - ACPI Table utilities |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
David E. Box | 82a8094 | 2015-02-05 15:20:45 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2015, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("tbutils") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /* Local prototypes */ |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 52 | static acpi_physical_address |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); |
| 54 | |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 55 | #if (!ACPI_REDUCED_HARDWARE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | /******************************************************************************* |
| 57 | * |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame] | 58 | * FUNCTION: acpi_tb_initialize_facs |
| 59 | * |
| 60 | * PARAMETERS: None |
| 61 | * |
| 62 | * RETURN: Status |
| 63 | * |
| 64 | * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global |
| 65 | * for accessing the Global Lock and Firmware Waking Vector |
| 66 | * |
| 67 | ******************************************************************************/ |
| 68 | |
| 69 | acpi_status acpi_tb_initialize_facs(void) |
| 70 | { |
Lv Zheng | c04e1fb | 2015-07-01 14:43:11 +0800 | [diff] [blame^] | 71 | struct acpi_table_facs *facs32; |
| 72 | struct acpi_table_facs *facs64; |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame] | 73 | |
Bob Moore | 22e5b40 | 2011-11-16 10:57:28 +0800 | [diff] [blame] | 74 | /* If Hardware Reduced flag is set, there is no FACS */ |
| 75 | |
| 76 | if (acpi_gbl_reduced_hardware) { |
| 77 | acpi_gbl_FACS = NULL; |
| 78 | return (AE_OK); |
| 79 | } |
| 80 | |
Lv Zheng | c04e1fb | 2015-07-01 14:43:11 +0800 | [diff] [blame^] | 81 | (void)acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, |
| 82 | ACPI_CAST_INDIRECT_PTR(struct |
| 83 | acpi_table_header, |
| 84 | &facs32)); |
| 85 | (void)acpi_get_table_by_index(ACPI_TABLE_INDEX_X_FACS, |
| 86 | ACPI_CAST_INDIRECT_PTR(struct |
| 87 | acpi_table_header, |
| 88 | &facs64)); |
| 89 | |
| 90 | if (acpi_gbl_use32_bit_facs_addresses) { |
| 91 | acpi_gbl_FACS = facs32 ? facs32 : facs64; |
| 92 | } else { |
| 93 | acpi_gbl_FACS = facs64 ? facs64 : facs32; |
| 94 | } |
| 95 | |
| 96 | return (AE_OK); |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame] | 97 | } |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 98 | #endif /* !ACPI_REDUCED_HARDWARE */ |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame] | 99 | |
| 100 | /******************************************************************************* |
| 101 | * |
Bob Moore | c857303 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 102 | * FUNCTION: acpi_tb_tables_loaded |
| 103 | * |
| 104 | * PARAMETERS: None |
| 105 | * |
| 106 | * RETURN: TRUE if required ACPI tables are loaded |
| 107 | * |
| 108 | * DESCRIPTION: Determine if the minimum required ACPI tables are present |
| 109 | * (FADT, FACS, DSDT) |
| 110 | * |
| 111 | ******************************************************************************/ |
| 112 | |
| 113 | u8 acpi_tb_tables_loaded(void) |
| 114 | { |
| 115 | |
Lv Zheng | c04e1fb | 2015-07-01 14:43:11 +0800 | [diff] [blame^] | 116 | if (acpi_gbl_root_table_list.current_table_count >= 4) { |
Bob Moore | c857303 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 117 | return (TRUE); |
| 118 | } |
| 119 | |
| 120 | return (FALSE); |
| 121 | } |
| 122 | |
| 123 | /******************************************************************************* |
| 124 | * |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 125 | * FUNCTION: acpi_tb_check_dsdt_header |
| 126 | * |
| 127 | * PARAMETERS: None |
| 128 | * |
| 129 | * RETURN: None |
| 130 | * |
| 131 | * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect |
| 132 | * if the DSDT has been replaced from outside the OS and/or if |
| 133 | * the DSDT header has been corrupted. |
| 134 | * |
| 135 | ******************************************************************************/ |
| 136 | |
| 137 | void acpi_tb_check_dsdt_header(void) |
| 138 | { |
| 139 | |
| 140 | /* Compare original length and checksum to current values */ |
| 141 | |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 142 | if (acpi_gbl_original_dsdt_header.length != acpi_gbl_DSDT->length || |
| 143 | acpi_gbl_original_dsdt_header.checksum != acpi_gbl_DSDT->checksum) { |
Bob Moore | 3b3ea77 | 2012-07-16 09:39:54 +0800 | [diff] [blame] | 144 | ACPI_BIOS_ERROR((AE_INFO, |
| 145 | "The DSDT has been corrupted or replaced - " |
| 146 | "old, new headers below")); |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 147 | acpi_tb_print_table_header(0, &acpi_gbl_original_dsdt_header); |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 148 | acpi_tb_print_table_header(0, acpi_gbl_DSDT); |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 149 | |
Lin Ming | aa2110c | 2010-04-08 14:34:27 +0800 | [diff] [blame] | 150 | ACPI_ERROR((AE_INFO, |
| 151 | "Please send DMI info to linux-acpi@vger.kernel.org\n" |
| 152 | "If system does not work as expected, please boot with acpi=copy_dsdt")); |
| 153 | |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 154 | /* Disable further error messages */ |
| 155 | |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 156 | acpi_gbl_original_dsdt_header.length = acpi_gbl_DSDT->length; |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 157 | acpi_gbl_original_dsdt_header.checksum = |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 158 | acpi_gbl_DSDT->checksum; |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| 162 | /******************************************************************************* |
| 163 | * |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 164 | * FUNCTION: acpi_tb_copy_dsdt |
| 165 | * |
| 166 | * PARAMETERS: table_desc - Installed table to copy |
| 167 | * |
| 168 | * RETURN: None |
| 169 | * |
| 170 | * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory. |
| 171 | * Some very bad BIOSs are known to either corrupt the DSDT or |
| 172 | * install a new, bad DSDT. This copy works around the problem. |
| 173 | * |
| 174 | ******************************************************************************/ |
| 175 | |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 176 | struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index) |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 177 | { |
| 178 | struct acpi_table_header *new_table; |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 179 | struct acpi_table_desc *table_desc; |
| 180 | |
| 181 | table_desc = &acpi_gbl_root_table_list.tables[table_index]; |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 182 | |
| 183 | new_table = ACPI_ALLOCATE(table_desc->length); |
| 184 | if (!new_table) { |
| 185 | ACPI_ERROR((AE_INFO, "Could not copy DSDT of length 0x%X", |
| 186 | table_desc->length)); |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 187 | return (NULL); |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | ACPI_MEMCPY(new_table, table_desc->pointer, table_desc->length); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 191 | acpi_tb_uninstall_table(table_desc); |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 192 | |
| 193 | acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list. |
| 194 | tables[ACPI_TABLE_INDEX_DSDT], |
| 195 | ACPI_PTR_TO_PHYSADDR(new_table), |
| 196 | ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, |
| 197 | new_table); |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 198 | |
| 199 | ACPI_INFO((AE_INFO, |
| 200 | "Forced DSDT copy: length 0x%05X copied locally, original unmapped", |
| 201 | new_table->length)); |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 202 | |
| 203 | return (new_table); |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /******************************************************************************* |
| 207 | * |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 208 | * FUNCTION: acpi_tb_get_root_table_entry |
| 209 | * |
| 210 | * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry |
| 211 | * table_entry_size - sizeof 32 or 64 (RSDT or XSDT) |
| 212 | * |
| 213 | * RETURN: Physical address extracted from the root table |
| 214 | * |
| 215 | * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on |
| 216 | * both 32-bit and 64-bit platforms |
| 217 | * |
| 218 | * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on |
| 219 | * 64-bit platforms. |
| 220 | * |
| 221 | ******************************************************************************/ |
| 222 | |
| 223 | static acpi_physical_address |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 224 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 225 | { |
| 226 | u64 address64; |
| 227 | |
| 228 | /* |
| 229 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): |
| 230 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT |
| 231 | */ |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 232 | if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) { |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 233 | /* |
| 234 | * 32-bit platform, RSDT: Return 32-bit table entry |
| 235 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return |
| 236 | */ |
| 237 | return ((acpi_physical_address) |
| 238 | (*ACPI_CAST_PTR(u32, table_entry))); |
| 239 | } else { |
| 240 | /* |
| 241 | * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 242 | * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, |
| 243 | * return 64-bit |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 244 | */ |
| 245 | ACPI_MOVE_64_TO_64(&address64, table_entry); |
| 246 | |
| 247 | #if ACPI_MACHINE_WIDTH == 32 |
| 248 | if (address64 > ACPI_UINT32_MAX) { |
| 249 | |
Bob Moore | ea5d8eb | 2007-02-02 19:48:20 +0300 | [diff] [blame] | 250 | /* Will truncate 64-bit address to 32 bits, issue warning */ |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 251 | |
Bob Moore | 3b3ea77 | 2012-07-16 09:39:54 +0800 | [diff] [blame] | 252 | ACPI_BIOS_WARNING((AE_INFO, |
| 253 | "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X)," |
| 254 | " truncating", |
| 255 | ACPI_FORMAT_UINT64(address64))); |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 256 | } |
| 257 | #endif |
| 258 | return ((acpi_physical_address) (address64)); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /******************************************************************************* |
| 263 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 264 | * FUNCTION: acpi_tb_parse_root_table |
| 265 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 266 | * PARAMETERS: rsdp - Pointer to the RSDP |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 267 | * |
| 268 | * RETURN: Status |
| 269 | * |
| 270 | * DESCRIPTION: This function is called to parse the Root System Description |
| 271 | * Table (RSDT or XSDT) |
| 272 | * |
| 273 | * NOTE: Tables are mapped (not copied) for efficiency. The FACS must |
| 274 | * be mapped and cannot be copied because it contains the actual |
| 275 | * memory location of the ACPI Global Lock. |
| 276 | * |
| 277 | ******************************************************************************/ |
| 278 | |
Lv Zheng | 45c9f78 | 2013-10-31 09:31:24 +0800 | [diff] [blame] | 279 | acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 280 | { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 281 | struct acpi_table_rsdp *rsdp; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 282 | u32 table_entry_size; |
| 283 | u32 i; |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 284 | u32 table_count; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 285 | struct acpi_table_header *table; |
| 286 | acpi_physical_address address; |
| 287 | u32 length; |
| 288 | u8 *table_entry; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 289 | acpi_status status; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 290 | u32 table_index; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 291 | |
| 292 | ACPI_FUNCTION_TRACE(tb_parse_root_table); |
| 293 | |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 294 | /* Map the entire RSDP and extract the address of the RSDT or XSDT */ |
| 295 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 296 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); |
| 297 | if (!rsdp) { |
| 298 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 299 | } |
| 300 | |
| 301 | acpi_tb_print_table_header(rsdp_address, |
| 302 | ACPI_CAST_PTR(struct acpi_table_header, |
| 303 | rsdp)); |
| 304 | |
Lv Zheng | fab4610 | 2014-01-08 13:43:40 +0800 | [diff] [blame] | 305 | /* Use XSDT if present and not overridden. Otherwise, use RSDT */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 306 | |
Lv Zheng | fab4610 | 2014-01-08 13:43:40 +0800 | [diff] [blame] | 307 | if ((rsdp->revision > 1) && |
| 308 | rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) { |
Bob Moore | a18ecf4 | 2005-08-15 03:42:00 -0800 | [diff] [blame] | 309 | /* |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 310 | * RSDP contains an XSDT (64-bit physical addresses). We must use |
| 311 | * the XSDT if the revision is > 1 and the XSDT pointer is present, |
| 312 | * as per the ACPI specification. |
Bob Moore | a18ecf4 | 2005-08-15 03:42:00 -0800 | [diff] [blame] | 313 | */ |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 314 | address = (acpi_physical_address) rsdp->xsdt_physical_address; |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 315 | table_entry_size = ACPI_XSDT_ENTRY_SIZE; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 316 | } else { |
| 317 | /* Root table is an RSDT (32-bit physical addresses) */ |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 318 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 319 | address = (acpi_physical_address) rsdp->rsdt_physical_address; |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 320 | table_entry_size = ACPI_RSDT_ENTRY_SIZE; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 321 | } |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 322 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 323 | /* |
| 324 | * It is not possible to map more than one entry in some environments, |
| 325 | * so unmap the RSDP here before mapping other tables |
| 326 | */ |
| 327 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); |
| 328 | |
| 329 | /* Map the RSDT/XSDT table header to get the full table length */ |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 330 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 331 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); |
| 332 | if (!table) { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 333 | return_ACPI_STATUS(AE_NO_MEMORY); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 334 | } |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 335 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 336 | acpi_tb_print_table_header(address, table); |
| 337 | |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 338 | /* |
| 339 | * Validate length of the table, and map entire table. |
| 340 | * Minimum length table must contain at least one entry. |
| 341 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 342 | length = table->length; |
| 343 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); |
| 344 | |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 345 | if (length < (sizeof(struct acpi_table_header) + table_entry_size)) { |
Bob Moore | 3b3ea77 | 2012-07-16 09:39:54 +0800 | [diff] [blame] | 346 | ACPI_BIOS_ERROR((AE_INFO, |
| 347 | "Invalid table length 0x%X in RSDT/XSDT", |
| 348 | length)); |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 349 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | table = acpi_os_map_memory(address, length); |
| 353 | if (!table) { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 354 | return_ACPI_STATUS(AE_NO_MEMORY); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | /* Validate the root table checksum */ |
| 358 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 359 | status = acpi_tb_verify_checksum(table, length); |
| 360 | if (ACPI_FAILURE(status)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 361 | acpi_os_unmap_memory(table, length); |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 362 | return_ACPI_STATUS(status); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 363 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 364 | |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 365 | /* Get the number of entries and pointer to first entry */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 366 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 367 | table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / |
| 368 | table_entry_size); |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 369 | table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header)); |
| 370 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 371 | /* |
Lv Zheng | c04e1fb | 2015-07-01 14:43:11 +0800 | [diff] [blame^] | 372 | * First three entries in the table array are reserved for the DSDT |
| 373 | * and 32bit/64bit FACS, which are not actually present in the |
| 374 | * RSDT/XSDT - they come from the FADT |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 375 | */ |
Lv Zheng | c04e1fb | 2015-07-01 14:43:11 +0800 | [diff] [blame^] | 376 | acpi_gbl_root_table_list.current_table_count = 3; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 377 | |
Lv Zheng | 671cc68 | 2014-01-08 13:43:34 +0800 | [diff] [blame] | 378 | /* Initialize the root table array from the RSDT/XSDT */ |
| 379 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 380 | for (i = 0; i < table_count; i++) { |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 381 | |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 382 | /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ |
| 383 | |
Lv Zheng | 0f929fbf | 2014-04-30 10:05:56 +0800 | [diff] [blame] | 384 | address = |
| 385 | acpi_tb_get_root_table_entry(table_entry, table_entry_size); |
| 386 | |
| 387 | /* Skip NULL entries in RSDT/XSDT */ |
| 388 | |
| 389 | if (!address) { |
| 390 | goto next_table; |
| 391 | } |
| 392 | |
| 393 | status = acpi_tb_install_standard_table(address, |
| 394 | ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, |
| 395 | FALSE, TRUE, |
| 396 | &table_index); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 397 | |
| 398 | if (ACPI_SUCCESS(status) && |
| 399 | ACPI_COMPARE_NAME(&acpi_gbl_root_table_list. |
| 400 | tables[table_index].signature, |
| 401 | ACPI_SIG_FADT)) { |
| 402 | acpi_tb_parse_fadt(table_index); |
| 403 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 404 | |
Lv Zheng | 0f929fbf | 2014-04-30 10:05:56 +0800 | [diff] [blame] | 405 | next_table: |
| 406 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 407 | table_entry += table_entry_size; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 408 | } |
| 409 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 410 | acpi_os_unmap_memory(table, length); |
| 411 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | return_ACPI_STATUS(AE_OK); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 413 | } |