| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
|  | 2 | * | 
|  | 3 | * Module Name: tbxfroot - Find the root ACPI table (RSDT) | 
|  | 4 | * | 
|  | 5 | *****************************************************************************/ | 
|  | 6 |  | 
|  | 7 | /* | 
| Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore | 
| 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 |  | 
|  | 44 | #include <linux/module.h> | 
|  | 45 |  | 
|  | 46 | #include <acpi/acpi.h> | 
|  | 47 | #include <acpi/actables.h> | 
|  | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define _COMPONENT          ACPI_TABLES | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("tbxfroot") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | /* Local prototypes */ | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 53 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 54 | acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 |  | 
|  | 58 | /******************************************************************************* | 
|  | 59 | * | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 60 | * FUNCTION:    acpi_tb_validate_rsdp | 
|  | 61 | * | 
|  | 62 | * PARAMETERS:  Rsdp        - Pointer to unvalidated RSDP | 
|  | 63 | * | 
|  | 64 | * RETURN:      Status | 
|  | 65 | * | 
|  | 66 | * DESCRIPTION: Validate the RSDP (ptr) | 
|  | 67 | * | 
|  | 68 | ******************************************************************************/ | 
|  | 69 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 70 | acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp) | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 71 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 72 | ACPI_FUNCTION_ENTRY(); | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 73 |  | 
|  | 74 | /* | 
|  | 75 | *  The signature and checksum must both be correct | 
|  | 76 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 77 | if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 78 | /* Nope, BAD Signature */ | 
|  | 79 |  | 
|  | 80 | return (AE_BAD_SIGNATURE); | 
|  | 81 | } | 
|  | 82 |  | 
|  | 83 | /* Check the standard checksum */ | 
|  | 84 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 85 | if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 86 | return (AE_BAD_CHECKSUM); | 
|  | 87 | } | 
|  | 88 |  | 
|  | 89 | /* Check extended checksum if table version >= 2 */ | 
|  | 90 |  | 
|  | 91 | if ((rsdp->revision >= 2) && | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != | 
|  | 93 | 0)) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 94 | return (AE_BAD_CHECKSUM); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | return (AE_OK); | 
|  | 98 | } | 
|  | 99 |  | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 100 | /******************************************************************************* | 
|  | 101 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | * FUNCTION:    acpi_tb_find_table | 
|  | 103 | * | 
|  | 104 | * PARAMETERS:  Signature           - String with ACPI table signature | 
|  | 105 | *              oem_id              - String with the table OEM ID | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 106 | *              oem_table_id        - String with the OEM Table ID | 
|  | 107 | *              table_ptr           - Where the table pointer is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | * | 
|  | 109 | * RETURN:      Status | 
|  | 110 | * | 
|  | 111 | * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the | 
|  | 112 | *              Signature, OEM ID and OEM Table ID. | 
|  | 113 | * | 
|  | 114 | ******************************************************************************/ | 
|  | 115 |  | 
|  | 116 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | acpi_tb_find_table(char *signature, | 
|  | 118 | char *oem_id, | 
|  | 119 | char *oem_table_id, struct acpi_table_header ** table_ptr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | acpi_status status; | 
|  | 122 | struct acpi_table_header *table; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 124 | ACPI_FUNCTION_TRACE("tb_find_table"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 |  | 
|  | 126 | /* Validate string lengths */ | 
|  | 127 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 128 | if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) || | 
|  | 129 | (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) || | 
|  | 130 | (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) { | 
|  | 131 | return_ACPI_STATUS(AE_AML_STRING_LIMIT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } | 
|  | 133 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 134 | if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | /* | 
|  | 136 | * The DSDT pointer is contained in the FADT, not the RSDT. | 
|  | 137 | * This code should suffice, because the only code that would perform | 
|  | 138 | * a "find" on the DSDT is the data_table_region() AML opcode -- in | 
|  | 139 | * which case, the DSDT is guaranteed to be already loaded. | 
|  | 140 | * If this becomes insufficient, the FADT will have to be found first. | 
|  | 141 | */ | 
|  | 142 | if (!acpi_gbl_DSDT) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | table = acpi_gbl_DSDT; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 146 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | /* Find the table */ | 
|  | 148 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | status = acpi_get_firmware_table(signature, 1, | 
|  | 150 | ACPI_LOGICAL_ADDRESSING, | 
|  | 151 | &table); | 
|  | 152 | if (ACPI_FAILURE(status)) { | 
|  | 153 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } | 
|  | 155 | } | 
|  | 156 |  | 
|  | 157 | /* Check oem_id and oem_table_id */ | 
|  | 158 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 159 | if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id, | 
|  | 160 | sizeof(table->oem_id))) || | 
|  | 161 | (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id, | 
|  | 162 | sizeof(table->oem_table_id)))) { | 
|  | 163 | return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | } | 
|  | 165 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n", | 
|  | 167 | table->signature)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 168 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | *table_ptr = table; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 170 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } | 
|  | 172 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /******************************************************************************* | 
|  | 174 | * | 
|  | 175 | * FUNCTION:    acpi_get_firmware_table | 
|  | 176 | * | 
|  | 177 | * PARAMETERS:  Signature       - Any ACPI table signature | 
|  | 178 | *              Instance        - the non zero instance of the table, allows | 
|  | 179 | *                                support for multiple tables of the same type | 
|  | 180 | *              Flags           - Physical/Virtual support | 
|  | 181 | *              table_pointer   - Where a buffer containing the table is | 
|  | 182 | *                                returned | 
|  | 183 | * | 
|  | 184 | * RETURN:      Status | 
|  | 185 | * | 
|  | 186 | * DESCRIPTION: This function is called to get an ACPI table. A buffer is | 
|  | 187 | *              allocated for the table and returned in table_pointer. | 
|  | 188 | *              This table will be a complete table including the header. | 
|  | 189 | * | 
|  | 190 | ******************************************************************************/ | 
|  | 191 |  | 
|  | 192 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | acpi_get_firmware_table(acpi_string signature, | 
|  | 194 | u32 instance, | 
|  | 195 | u32 flags, struct acpi_table_header **table_pointer) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 197 | acpi_status status; | 
|  | 198 | struct acpi_pointer address; | 
|  | 199 | struct acpi_table_header *header = NULL; | 
|  | 200 | struct acpi_table_desc *table_info = NULL; | 
|  | 201 | struct acpi_table_desc *rsdt_info; | 
|  | 202 | u32 table_count; | 
|  | 203 | u32 i; | 
|  | 204 | u32 j; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | ACPI_FUNCTION_TRACE("acpi_get_firmware_table"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 |  | 
|  | 208 | /* | 
|  | 209 | * Ensure that at least the table manager is initialized.  We don't | 
|  | 210 | * require that the entire ACPI subsystem is up for this interface. | 
|  | 211 | * If we have a buffer, we must have a length too | 
|  | 212 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | if ((instance == 0) || (!signature) || (!table_pointer)) { | 
|  | 214 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } | 
|  | 216 |  | 
|  | 217 | /* Ensure that we have a RSDP */ | 
|  | 218 |  | 
|  | 219 | if (!acpi_gbl_RSDP) { | 
|  | 220 | /* Get the RSDP */ | 
|  | 221 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 222 | status = acpi_os_get_root_pointer(flags, &address); | 
|  | 223 | if (ACPI_FAILURE(status)) { | 
|  | 224 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n")); | 
|  | 225 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } | 
|  | 227 |  | 
|  | 228 | /* Map and validate the RSDP */ | 
|  | 229 |  | 
|  | 230 | if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 231 | status = acpi_os_map_memory(address.pointer.physical, | 
|  | 232 | sizeof(struct | 
|  | 233 | rsdp_descriptor), | 
|  | 234 | (void *)&acpi_gbl_RSDP); | 
|  | 235 | if (ACPI_FAILURE(status)) { | 
|  | 236 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 238 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | acpi_gbl_RSDP = address.pointer.logical; | 
|  | 240 | } | 
|  | 241 |  | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 242 | /* The RDSP signature and checksum must both be correct */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 244 | status = acpi_tb_validate_rsdp(acpi_gbl_RSDP); | 
|  | 245 | if (ACPI_FAILURE(status)) { | 
|  | 246 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } | 
|  | 248 | } | 
|  | 249 |  | 
|  | 250 | /* Get the RSDT address via the RSDP */ | 
|  | 251 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 252 | acpi_tb_get_rsdt_address(&address); | 
|  | 253 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
| Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 254 | "RSDP located at %p, RSDT physical=%8.8X%8.8X\n", | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | acpi_gbl_RSDP, | 
|  | 256 | ACPI_FORMAT_UINT64(address.pointer.value))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 |  | 
|  | 258 | /* Insert processor_mode flags */ | 
|  | 259 |  | 
|  | 260 | address.pointer_type |= flags; | 
|  | 261 |  | 
|  | 262 | /* Get and validate the RSDT */ | 
|  | 263 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 264 | rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | if (!rsdt_info) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 266 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } | 
|  | 268 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | status = acpi_tb_get_table(&address, rsdt_info); | 
|  | 270 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | goto cleanup; | 
|  | 272 | } | 
|  | 273 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 274 | status = acpi_tb_validate_rsdt(rsdt_info->pointer); | 
|  | 275 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | goto cleanup; | 
|  | 277 | } | 
|  | 278 |  | 
|  | 279 | /* Allocate a scratch table header and table descriptor */ | 
|  | 280 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 281 | header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | if (!header) { | 
|  | 283 | status = AE_NO_MEMORY; | 
|  | 284 | goto cleanup; | 
|  | 285 | } | 
|  | 286 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | if (!table_info) { | 
|  | 289 | status = AE_NO_MEMORY; | 
|  | 290 | goto cleanup; | 
|  | 291 | } | 
|  | 292 |  | 
|  | 293 | /* Get the number of table pointers within the RSDT */ | 
|  | 294 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 295 | table_count = | 
|  | 296 | acpi_tb_get_table_count(acpi_gbl_RSDP, rsdt_info->pointer); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | address.pointer_type = acpi_gbl_table_flags | flags; | 
|  | 298 |  | 
|  | 299 | /* | 
|  | 300 | * Search the RSDT/XSDT for the correct instance of the | 
|  | 301 | * requested table | 
|  | 302 | */ | 
|  | 303 | for (i = 0, j = 0; i < table_count; i++) { | 
| Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 304 | /* | 
|  | 305 | * Get the next table pointer, handle RSDT vs. XSDT | 
|  | 306 | * RSDT pointers are 32 bits, XSDT pointers are 64 bits | 
|  | 307 | */ | 
|  | 308 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 309 | address.pointer.value = | 
|  | 310 | (ACPI_CAST_PTR | 
|  | 311 | (RSDT_DESCRIPTOR, | 
|  | 312 | rsdt_info->pointer))->table_offset_entry[i]; | 
|  | 313 | } else { | 
|  | 314 | address.pointer.value = | 
|  | 315 | (ACPI_CAST_PTR | 
|  | 316 | (XSDT_DESCRIPTOR, | 
|  | 317 | rsdt_info->pointer))->table_offset_entry[i]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } | 
|  | 319 |  | 
|  | 320 | /* Get the table header */ | 
|  | 321 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 322 | status = acpi_tb_get_table_header(&address, header); | 
|  | 323 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | goto cleanup; | 
|  | 325 | } | 
|  | 326 |  | 
|  | 327 | /* Compare table signatures and table instance */ | 
|  | 328 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 329 | if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | /* An instance of the table was found */ | 
|  | 331 |  | 
|  | 332 | j++; | 
|  | 333 | if (j >= instance) { | 
|  | 334 | /* Found the correct instance, get the entire table */ | 
|  | 335 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | status = | 
|  | 337 | acpi_tb_get_table_body(&address, header, | 
|  | 338 | table_info); | 
|  | 339 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | goto cleanup; | 
|  | 341 | } | 
|  | 342 |  | 
|  | 343 | *table_pointer = table_info->pointer; | 
|  | 344 | goto cleanup; | 
|  | 345 | } | 
|  | 346 | } | 
|  | 347 | } | 
|  | 348 |  | 
|  | 349 | /* Did not find the table */ | 
|  | 350 |  | 
|  | 351 | status = AE_NOT_EXIST; | 
|  | 352 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | cleanup: | 
| Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 354 | if (rsdt_info->pointer) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 355 | acpi_os_unmap_memory(rsdt_info->pointer, | 
|  | 356 | (acpi_size) rsdt_info->pointer->length); | 
| Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 357 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 358 | ACPI_MEM_FREE(rsdt_info); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 |  | 
|  | 360 | if (header) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 361 | ACPI_MEM_FREE(header); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } | 
|  | 363 | if (table_info) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 364 | ACPI_MEM_FREE(table_info); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 366 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 369 | EXPORT_SYMBOL(acpi_get_firmware_table); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 |  | 
|  | 371 | /* TBD: Move to a new file */ | 
|  | 372 |  | 
|  | 373 | #if ACPI_MACHINE_WIDTH != 16 | 
|  | 374 |  | 
|  | 375 | /******************************************************************************* | 
|  | 376 | * | 
|  | 377 | * FUNCTION:    acpi_find_root_pointer | 
|  | 378 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 379 | * PARAMETERS:  Flags                   - Logical/Physical addressing | 
|  | 380 | *              rsdp_address            - Where to place the RSDP address | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | * | 
|  | 382 | * RETURN:      Status, Physical address of the RSDP | 
|  | 383 | * | 
|  | 384 | * DESCRIPTION: Find the RSDP | 
|  | 385 | * | 
|  | 386 | ******************************************************************************/ | 
|  | 387 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | struct acpi_table_desc table_info; | 
|  | 391 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | ACPI_FUNCTION_TRACE("acpi_find_root_pointer"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 |  | 
|  | 395 | /* Get the RSDP */ | 
|  | 396 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | status = acpi_tb_find_rsdp(&table_info, flags); | 
|  | 398 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 399 | ACPI_EXCEPTION((AE_INFO, status, | 
|  | 400 | "RSDP structure not found - Flags=%X", flags)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 401 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } | 
|  | 404 |  | 
|  | 405 | rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER; | 
|  | 406 | rsdp_address->pointer.physical = table_info.physical_address; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 407 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | } | 
|  | 409 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | /******************************************************************************* | 
|  | 411 | * | 
|  | 412 | * FUNCTION:    acpi_tb_scan_memory_for_rsdp | 
|  | 413 | * | 
|  | 414 | * PARAMETERS:  start_address       - Starting pointer for search | 
|  | 415 | *              Length              - Maximum length to search | 
|  | 416 | * | 
|  | 417 | * RETURN:      Pointer to the RSDP if found, otherwise NULL. | 
|  | 418 | * | 
|  | 419 | * DESCRIPTION: Search a block of memory for the RSDP signature | 
|  | 420 | * | 
|  | 421 | ******************************************************************************/ | 
|  | 422 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 423 | static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | acpi_status status; | 
|  | 426 | u8 *mem_rover; | 
|  | 427 | u8 *end_address; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 |  | 
|  | 431 | end_address = start_address + length; | 
|  | 432 |  | 
|  | 433 | /* Search from given start address for the requested length */ | 
|  | 434 |  | 
|  | 435 | for (mem_rover = start_address; mem_rover < end_address; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 436 | mem_rover += ACPI_RSDP_SCAN_STEP) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 437 | /* The RSDP signature and checksum must both be correct */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 439 | status = | 
|  | 440 | acpi_tb_validate_rsdp(ACPI_CAST_PTR | 
|  | 441 | (struct rsdp_descriptor, mem_rover)); | 
|  | 442 | if (ACPI_SUCCESS(status)) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 443 | /* Sig and checksum valid, we have found a real RSDP */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
|  | 446 | "RSDP located at physical address %p\n", | 
|  | 447 | mem_rover)); | 
|  | 448 | return_PTR(mem_rover); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } | 
|  | 450 |  | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 451 | /* No sig match or bad checksum, keep searching */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } | 
|  | 453 |  | 
|  | 454 | /* Searched entire block, no RSDP was found */ | 
|  | 455 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 456 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
|  | 457 | "Searched entire block from %p, valid RSDP was not found\n", | 
|  | 458 | start_address)); | 
|  | 459 | return_PTR(NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | } | 
|  | 461 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | /******************************************************************************* | 
|  | 463 | * | 
|  | 464 | * FUNCTION:    acpi_tb_find_rsdp | 
|  | 465 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 466 | * PARAMETERS:  table_info              - Where the table info is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | *              Flags                   - Current memory mode (logical vs. | 
|  | 468 | *                                        physical addressing) | 
|  | 469 | * | 
|  | 470 | * RETURN:      Status, RSDP physical address | 
|  | 471 | * | 
|  | 472 | * DESCRIPTION: search lower 1_mbyte of memory for the root system descriptor | 
|  | 473 | *              pointer structure.  If it is found, set *RSDP to point to it. | 
|  | 474 | * | 
|  | 475 | *              NOTE1: The RSDp must be either in the first 1_k of the Extended | 
|  | 476 | *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) | 
|  | 477 | *              Only a 32-bit physical address is necessary. | 
|  | 478 | * | 
|  | 479 | *              NOTE2: This function is always available, regardless of the | 
|  | 480 | *              initialization state of the rest of ACPI. | 
|  | 481 | * | 
|  | 482 | ******************************************************************************/ | 
|  | 483 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 484 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 485 | acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 487 | u8 *table_ptr; | 
|  | 488 | u8 *mem_rover; | 
|  | 489 | u32 physical_address; | 
|  | 490 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 492 | ACPI_FUNCTION_TRACE("tb_find_rsdp"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 |  | 
|  | 494 | /* | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 495 | * Scan supports either logical addressing or physical addressing | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | */ | 
|  | 497 | if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 498 | /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ | 
|  | 499 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 500 | status = acpi_os_map_memory((acpi_physical_address) | 
|  | 501 | ACPI_EBDA_PTR_LOCATION, | 
|  | 502 | ACPI_EBDA_PTR_LENGTH, | 
|  | 503 | (void *)&table_ptr); | 
|  | 504 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 505 | ACPI_ERROR((AE_INFO, | 
|  | 506 | "Could not map memory at %8.8X for length %X", | 
|  | 507 | ACPI_EBDA_PTR_LOCATION, | 
|  | 508 | ACPI_EBDA_PTR_LENGTH)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 509 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 510 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } | 
|  | 512 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 513 | ACPI_MOVE_16_TO_32(&physical_address, table_ptr); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 514 |  | 
|  | 515 | /* Convert segment part to physical address */ | 
|  | 516 |  | 
|  | 517 | physical_address <<= 4; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 518 | acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 |  | 
|  | 520 | /* EBDA present? */ | 
|  | 521 |  | 
|  | 522 | if (physical_address > 0x400) { | 
|  | 523 | /* | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 524 | * 1b) Search EBDA paragraphs (EBDa is required to be a | 
|  | 525 | *     minimum of 1_k length) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 527 | status = acpi_os_map_memory((acpi_physical_address) | 
|  | 528 | physical_address, | 
|  | 529 | ACPI_EBDA_WINDOW_SIZE, | 
|  | 530 | (void *)&table_ptr); | 
|  | 531 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 532 | ACPI_ERROR((AE_INFO, | 
|  | 533 | "Could not map memory at %8.8X for length %X", | 
|  | 534 | physical_address, | 
|  | 535 | ACPI_EBDA_WINDOW_SIZE)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 536 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 537 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | } | 
|  | 539 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 540 | mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr, | 
|  | 541 | ACPI_EBDA_WINDOW_SIZE); | 
|  | 542 | acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 |  | 
|  | 544 | if (mem_rover) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 545 | /* Return the physical address */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 547 | physical_address += | 
|  | 548 | ACPI_PTR_DIFF(mem_rover, table_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 550 | table_info->physical_address = | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 551 | (acpi_physical_address) physical_address; | 
|  | 552 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | } | 
|  | 554 | } | 
|  | 555 |  | 
|  | 556 | /* | 
|  | 557 | * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh | 
|  | 558 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 559 | status = acpi_os_map_memory((acpi_physical_address) | 
|  | 560 | ACPI_HI_RSDP_WINDOW_BASE, | 
|  | 561 | ACPI_HI_RSDP_WINDOW_SIZE, | 
|  | 562 | (void *)&table_ptr); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 563 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 564 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 565 | ACPI_ERROR((AE_INFO, | 
|  | 566 | "Could not map memory at %8.8X for length %X", | 
|  | 567 | ACPI_HI_RSDP_WINDOW_BASE, | 
|  | 568 | ACPI_HI_RSDP_WINDOW_SIZE)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 569 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 570 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } | 
|  | 572 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 573 | mem_rover = | 
|  | 574 | acpi_tb_scan_memory_for_rsdp(table_ptr, | 
|  | 575 | ACPI_HI_RSDP_WINDOW_SIZE); | 
|  | 576 | acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 |  | 
|  | 578 | if (mem_rover) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 579 | /* Return the physical address */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 581 | physical_address = | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 582 | ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover, | 
|  | 583 | table_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 585 | table_info->physical_address = | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 586 | (acpi_physical_address) physical_address; | 
|  | 587 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | } | 
|  | 589 | } | 
|  | 590 |  | 
|  | 591 | /* | 
|  | 592 | * Physical addressing | 
|  | 593 | */ | 
|  | 594 | else { | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 595 | /* 1a) Get the location of the EBDA */ | 
|  | 596 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 597 | ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION); | 
|  | 598 | physical_address <<= 4;	/* Convert segment to physical address */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 |  | 
|  | 600 | /* EBDA present? */ | 
|  | 601 |  | 
|  | 602 | if (physical_address > 0x400) { | 
|  | 603 | /* | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 604 | * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of | 
|  | 605 | *     1_k length) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 607 | mem_rover = | 
|  | 608 | acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR | 
|  | 609 | (physical_address), | 
|  | 610 | ACPI_EBDA_WINDOW_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | if (mem_rover) { | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 612 | /* Return the physical address */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 614 | table_info->physical_address = | 
|  | 615 | ACPI_TO_INTEGER(mem_rover); | 
|  | 616 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } | 
|  | 618 | } | 
|  | 619 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 620 | /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ | 
|  | 621 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 622 | mem_rover = | 
|  | 623 | acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR | 
|  | 624 | (ACPI_HI_RSDP_WINDOW_BASE), | 
|  | 625 | ACPI_HI_RSDP_WINDOW_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | if (mem_rover) { | 
|  | 627 | /* Found it, return the physical address */ | 
|  | 628 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 629 | table_info->physical_address = | 
|  | 630 | ACPI_TO_INTEGER(mem_rover); | 
|  | 631 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | } | 
|  | 633 | } | 
|  | 634 |  | 
| Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 635 | /* A valid RSDP was not found */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 637 | ACPI_ERROR((AE_INFO, "No valid RSDP was found")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 638 | return_ACPI_STATUS(AE_NOT_FOUND); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | } | 
|  | 640 |  | 
|  | 641 | #endif |