13446Smrj /****************************************************************************** 23446Smrj * 33446Smrj * Module Name: tbxfroot - Find the root ACPI table (RSDT) 4*7851SDana.Myers@Sun.COM * $Revision: 1.106 $ 53446Smrj * 63446Smrj *****************************************************************************/ 73446Smrj 83446Smrj /****************************************************************************** 93446Smrj * 103446Smrj * 1. Copyright Notice 113446Smrj * 12*7851SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. 133446Smrj * All rights reserved. 143446Smrj * 153446Smrj * 2. License 163446Smrj * 173446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 183446Smrj * rights. You may have additional license terms from the party that provided 193446Smrj * you this software, covering your right to use that party's intellectual 203446Smrj * property rights. 213446Smrj * 223446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 233446Smrj * copy of the source code appearing in this file ("Covered Code") an 243446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 253446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 263446Smrj * make derivatives, distribute, use and display any portion of the Covered 273446Smrj * Code in any form, with the right to sublicense such rights; and 283446Smrj * 293446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 303446Smrj * license (with the right to sublicense), under only those claims of Intel 313446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 323446Smrj * offer to sell, and import the Covered Code and derivative works thereof 333446Smrj * solely to the minimum extent necessary to exercise the above copyright 343446Smrj * license, and in no event shall the patent license extend to any additions 353446Smrj * to or modifications of the Original Intel Code. No other license or right 363446Smrj * is granted directly or by implication, estoppel or otherwise; 373446Smrj * 383446Smrj * The above copyright and patent license is granted only if the following 393446Smrj * conditions are met: 403446Smrj * 413446Smrj * 3. Conditions 423446Smrj * 433446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 443446Smrj * Redistribution of source code of any substantial portion of the Covered 453446Smrj * Code or modification with rights to further distribute source must include 463446Smrj * the above Copyright Notice, the above License, this list of Conditions, 473446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 483446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 493446Smrj * contain a file documenting the changes Licensee made to create that Covered 503446Smrj * Code and the date of any change. Licensee must include in that file the 513446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 523446Smrj * must include a prominent statement that the modification is derived, 533446Smrj * directly or indirectly, from Original Intel Code. 543446Smrj * 553446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 563446Smrj * Redistribution of source code of any substantial portion of the Covered 573446Smrj * Code or modification without rights to further distribute source must 583446Smrj * include the following Disclaimer and Export Compliance provision in the 593446Smrj * documentation and/or other materials provided with distribution. In 603446Smrj * addition, Licensee may not authorize further sublicense of source of any 613446Smrj * portion of the Covered Code, and must include terms to the effect that the 623446Smrj * license from Licensee to its licensee is limited to the intellectual 633446Smrj * property embodied in the software Licensee provides to its licensee, and 643446Smrj * not to intellectual property embodied in modifications its licensee may 653446Smrj * make. 663446Smrj * 673446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 683446Smrj * substantial portion of the Covered Code or modification must reproduce the 693446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 703446Smrj * provision in the documentation and/or other materials provided with the 713446Smrj * distribution. 723446Smrj * 733446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 743446Smrj * Intel Code. 753446Smrj * 763446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 773446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 783446Smrj * other dealings in products derived from or relating to the Covered Code 793446Smrj * without prior written authorization from Intel. 803446Smrj * 813446Smrj * 4. Disclaimer and Export Compliance 823446Smrj * 833446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 843446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 853446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 863446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 873446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 883446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 893446Smrj * PARTICULAR PURPOSE. 903446Smrj * 913446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 923446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 933446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 943446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 953446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 963446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 973446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 983446Smrj * LIMITED REMEDY. 993446Smrj * 1003446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 1013446Smrj * software or system incorporating such software without first obtaining any 1023446Smrj * required license or other approval from the U. S. Department of Commerce or 1033446Smrj * any other agency or department of the United States Government. In the 1043446Smrj * event Licensee exports any such software from the United States or 1053446Smrj * re-exports any such software from a foreign destination, Licensee shall 1063446Smrj * ensure that the distribution and export/re-export of the software is in 1073446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 1083446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1093446Smrj * any of its subsidiaries will export/re-export any technical data, process, 1103446Smrj * software, or service, directly or indirectly, to any country for which the 1113446Smrj * United States government or any agency thereof requires an export license, 1123446Smrj * other governmental approval, or letter of assurance, without first obtaining 1133446Smrj * such license, approval or letter. 1143446Smrj * 1153446Smrj *****************************************************************************/ 1163446Smrj 1173446Smrj #define __TBXFROOT_C__ 1183446Smrj 1193446Smrj #include "acpi.h" 1203446Smrj #include "actables.h" 1213446Smrj 1223446Smrj 1233446Smrj #define _COMPONENT ACPI_TABLES 1243446Smrj ACPI_MODULE_NAME ("tbxfroot") 1253446Smrj 1263446Smrj /* Local prototypes */ 1273446Smrj 1283446Smrj static UINT8 * 1293446Smrj AcpiTbScanMemoryForRsdp ( 1303446Smrj UINT8 *StartAddress, 1313446Smrj UINT32 Length); 1323446Smrj 133*7851SDana.Myers@Sun.COM static ACPI_STATUS 134*7851SDana.Myers@Sun.COM AcpiTbValidateRsdp ( 135*7851SDana.Myers@Sun.COM ACPI_TABLE_RSDP *Rsdp); 136*7851SDana.Myers@Sun.COM 1373446Smrj 1383446Smrj /******************************************************************************* 1393446Smrj * 1403446Smrj * FUNCTION: AcpiTbValidateRsdp 1413446Smrj * 142*7851SDana.Myers@Sun.COM * PARAMETERS: Rsdp - Pointer to unvalidated RSDP 1433446Smrj * 1443446Smrj * RETURN: Status 1453446Smrj * 1463446Smrj * DESCRIPTION: Validate the RSDP (ptr) 1473446Smrj * 1483446Smrj ******************************************************************************/ 1493446Smrj 150*7851SDana.Myers@Sun.COM static ACPI_STATUS 1513446Smrj AcpiTbValidateRsdp ( 152*7851SDana.Myers@Sun.COM ACPI_TABLE_RSDP *Rsdp) 1533446Smrj { 1543446Smrj ACPI_FUNCTION_ENTRY (); 1553446Smrj 1563446Smrj 1573446Smrj /* 158*7851SDana.Myers@Sun.COM * The signature and checksum must both be correct 159*7851SDana.Myers@Sun.COM * 160*7851SDana.Myers@Sun.COM * Note: Sometimes there exists more than one RSDP in memory; the valid 161*7851SDana.Myers@Sun.COM * RSDP has a valid checksum, all others have an invalid checksum. 1623446Smrj */ 163*7851SDana.Myers@Sun.COM if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, sizeof (ACPI_SIG_RSDP)-1) != 0) 1643446Smrj { 1653446Smrj /* Nope, BAD Signature */ 1663446Smrj 1673446Smrj return (AE_BAD_SIGNATURE); 1683446Smrj } 1693446Smrj 1703446Smrj /* Check the standard checksum */ 1713446Smrj 172*7851SDana.Myers@Sun.COM if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) 1733446Smrj { 1743446Smrj return (AE_BAD_CHECKSUM); 1753446Smrj } 1763446Smrj 1773446Smrj /* Check extended checksum if table version >= 2 */ 1783446Smrj 1793446Smrj if ((Rsdp->Revision >= 2) && 180*7851SDana.Myers@Sun.COM (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) 1813446Smrj { 1823446Smrj return (AE_BAD_CHECKSUM); 1833446Smrj } 1843446Smrj 1853446Smrj return (AE_OK); 1863446Smrj } 1873446Smrj 1883446Smrj 1893446Smrj /******************************************************************************* 1903446Smrj * 191*7851SDana.Myers@Sun.COM * FUNCTION: AcpiTbFindRsdp 1923446Smrj * 193*7851SDana.Myers@Sun.COM * PARAMETERS: TableAddress - Where the table pointer is returned 1943446Smrj * 195*7851SDana.Myers@Sun.COM * RETURN: Status, RSDP physical address 1963446Smrj * 197*7851SDana.Myers@Sun.COM * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor 198*7851SDana.Myers@Sun.COM * pointer structure. If it is found, set *RSDP to point to it. 1993446Smrj * 200*7851SDana.Myers@Sun.COM * NOTE1: The RSDP must be either in the first 1K of the Extended 201*7851SDana.Myers@Sun.COM * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) 202*7851SDana.Myers@Sun.COM * Only a 32-bit physical address is necessary. 2033446Smrj * 204*7851SDana.Myers@Sun.COM * NOTE2: This function is always available, regardless of the 205*7851SDana.Myers@Sun.COM * initialization state of the rest of ACPI. 2063446Smrj * 2073446Smrj ******************************************************************************/ 2083446Smrj 2093446Smrj ACPI_STATUS 2103446Smrj AcpiFindRootPointer ( 211*7851SDana.Myers@Sun.COM ACPI_SIZE *TableAddress) 2123446Smrj { 213*7851SDana.Myers@Sun.COM UINT8 *TablePtr; 214*7851SDana.Myers@Sun.COM UINT8 *MemRover; 215*7851SDana.Myers@Sun.COM UINT32 PhysicalAddress; 2163446Smrj 2173446Smrj 2183446Smrj ACPI_FUNCTION_TRACE (AcpiFindRootPointer); 2193446Smrj 2203446Smrj 221*7851SDana.Myers@Sun.COM /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ 2223446Smrj 223*7851SDana.Myers@Sun.COM TablePtr = AcpiOsMapMemory ( 224*7851SDana.Myers@Sun.COM (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, 225*7851SDana.Myers@Sun.COM ACPI_EBDA_PTR_LENGTH); 226*7851SDana.Myers@Sun.COM if (!TablePtr) 2273446Smrj { 228*7851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, 229*7851SDana.Myers@Sun.COM "Could not map memory at %8.8X for length %X", 230*7851SDana.Myers@Sun.COM ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); 2313446Smrj 232*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_NO_MEMORY); 2333446Smrj } 2343446Smrj 235*7851SDana.Myers@Sun.COM ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); 236*7851SDana.Myers@Sun.COM 237*7851SDana.Myers@Sun.COM /* Convert segment part to physical address */ 238*7851SDana.Myers@Sun.COM 239*7851SDana.Myers@Sun.COM PhysicalAddress <<= 4; 240*7851SDana.Myers@Sun.COM AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); 241*7851SDana.Myers@Sun.COM 242*7851SDana.Myers@Sun.COM /* EBDA present? */ 243*7851SDana.Myers@Sun.COM 244*7851SDana.Myers@Sun.COM if (PhysicalAddress > 0x400) 245*7851SDana.Myers@Sun.COM { 246*7851SDana.Myers@Sun.COM /* 247*7851SDana.Myers@Sun.COM * 1b) Search EBDA paragraphs (EBDA is required to be a 248*7851SDana.Myers@Sun.COM * minimum of 1K length) 249*7851SDana.Myers@Sun.COM */ 250*7851SDana.Myers@Sun.COM TablePtr = AcpiOsMapMemory ( 251*7851SDana.Myers@Sun.COM (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, 252*7851SDana.Myers@Sun.COM ACPI_EBDA_WINDOW_SIZE); 253*7851SDana.Myers@Sun.COM if (!TablePtr) 254*7851SDana.Myers@Sun.COM { 255*7851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, 256*7851SDana.Myers@Sun.COM "Could not map memory at %8.8X for length %X", 257*7851SDana.Myers@Sun.COM PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); 258*7851SDana.Myers@Sun.COM 259*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_NO_MEMORY); 260*7851SDana.Myers@Sun.COM } 261*7851SDana.Myers@Sun.COM 262*7851SDana.Myers@Sun.COM MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); 263*7851SDana.Myers@Sun.COM AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); 264*7851SDana.Myers@Sun.COM 265*7851SDana.Myers@Sun.COM if (MemRover) 266*7851SDana.Myers@Sun.COM { 267*7851SDana.Myers@Sun.COM /* Return the physical address */ 268*7851SDana.Myers@Sun.COM 269*7851SDana.Myers@Sun.COM PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); 270*7851SDana.Myers@Sun.COM 271*7851SDana.Myers@Sun.COM *TableAddress = PhysicalAddress; 272*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_OK); 273*7851SDana.Myers@Sun.COM } 274*7851SDana.Myers@Sun.COM } 275*7851SDana.Myers@Sun.COM 276*7851SDana.Myers@Sun.COM /* 277*7851SDana.Myers@Sun.COM * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 278*7851SDana.Myers@Sun.COM */ 279*7851SDana.Myers@Sun.COM TablePtr = AcpiOsMapMemory ( 280*7851SDana.Myers@Sun.COM (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, 281*7851SDana.Myers@Sun.COM ACPI_HI_RSDP_WINDOW_SIZE); 282*7851SDana.Myers@Sun.COM 283*7851SDana.Myers@Sun.COM if (!TablePtr) 284*7851SDana.Myers@Sun.COM { 285*7851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, 286*7851SDana.Myers@Sun.COM "Could not map memory at %8.8X for length %X", 287*7851SDana.Myers@Sun.COM ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); 288*7851SDana.Myers@Sun.COM 289*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_NO_MEMORY); 290*7851SDana.Myers@Sun.COM } 291*7851SDana.Myers@Sun.COM 292*7851SDana.Myers@Sun.COM MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); 293*7851SDana.Myers@Sun.COM AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); 294*7851SDana.Myers@Sun.COM 295*7851SDana.Myers@Sun.COM if (MemRover) 296*7851SDana.Myers@Sun.COM { 297*7851SDana.Myers@Sun.COM /* Return the physical address */ 298*7851SDana.Myers@Sun.COM 299*7851SDana.Myers@Sun.COM PhysicalAddress = (UINT32) 300*7851SDana.Myers@Sun.COM (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr)); 301*7851SDana.Myers@Sun.COM 302*7851SDana.Myers@Sun.COM *TableAddress = PhysicalAddress; 303*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_OK); 304*7851SDana.Myers@Sun.COM } 305*7851SDana.Myers@Sun.COM 306*7851SDana.Myers@Sun.COM /* A valid RSDP was not found */ 307*7851SDana.Myers@Sun.COM 308*7851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, "A valid RSDP was not found")); 309*7851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_NOT_FOUND); 3103446Smrj } 3113446Smrj 3123446Smrj ACPI_EXPORT_SYMBOL (AcpiFindRootPointer) 3133446Smrj 3143446Smrj 3153446Smrj /******************************************************************************* 3163446Smrj * 3173446Smrj * FUNCTION: AcpiTbScanMemoryForRsdp 3183446Smrj * 3193446Smrj * PARAMETERS: StartAddress - Starting pointer for search 3203446Smrj * Length - Maximum length to search 3213446Smrj * 3223446Smrj * RETURN: Pointer to the RSDP if found, otherwise NULL. 3233446Smrj * 3243446Smrj * DESCRIPTION: Search a block of memory for the RSDP signature 3253446Smrj * 3263446Smrj ******************************************************************************/ 3273446Smrj 3283446Smrj static UINT8 * 3293446Smrj AcpiTbScanMemoryForRsdp ( 3303446Smrj UINT8 *StartAddress, 3313446Smrj UINT32 Length) 3323446Smrj { 3333446Smrj ACPI_STATUS Status; 3343446Smrj UINT8 *MemRover; 3353446Smrj UINT8 *EndAddress; 3363446Smrj 3373446Smrj 3383446Smrj ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp); 3393446Smrj 3403446Smrj 3413446Smrj EndAddress = StartAddress + Length; 3423446Smrj 3433446Smrj /* Search from given start address for the requested length */ 3443446Smrj 3453446Smrj for (MemRover = StartAddress; MemRover < EndAddress; 3463446Smrj MemRover += ACPI_RSDP_SCAN_STEP) 3473446Smrj { 3483446Smrj /* The RSDP signature and checksum must both be correct */ 3493446Smrj 350*7851SDana.Myers@Sun.COM Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); 3513446Smrj if (ACPI_SUCCESS (Status)) 3523446Smrj { 3533446Smrj /* Sig and checksum valid, we have found a real RSDP */ 3543446Smrj 3553446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 3563446Smrj "RSDP located at physical address %p\n", MemRover)); 3573446Smrj return_PTR (MemRover); 3583446Smrj } 3593446Smrj 3603446Smrj /* No sig match or bad checksum, keep searching */ 3613446Smrj } 3623446Smrj 3633446Smrj /* Searched entire block, no RSDP was found */ 3643446Smrj 3653446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 3663446Smrj "Searched entire block from %p, valid RSDP was not found\n", 3673446Smrj StartAddress)); 3683446Smrj return_PTR (NULL); 3693446Smrj } 3703446Smrj 371