xref: /onnv-gate/usr/src/uts/intel/io/acpica/tables/tbxfroot.c (revision 9980:13d7f3eec672)
13446Smrj /******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
43446Smrj  *
53446Smrj  *****************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj #define __TBXFROOT_C__
1173446Smrj 
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.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 
1337851SDana.Myers@Sun.COM static ACPI_STATUS
1347851SDana.Myers@Sun.COM AcpiTbValidateRsdp (
1357851SDana.Myers@Sun.COM     ACPI_TABLE_RSDP         *Rsdp);
1367851SDana.Myers@Sun.COM 
1373446Smrj 
1383446Smrj /*******************************************************************************
1393446Smrj  *
1403446Smrj  * FUNCTION:    AcpiTbValidateRsdp
1413446Smrj  *
1427851SDana.Myers@Sun.COM  * PARAMETERS:  Rsdp                - Pointer to unvalidated RSDP
1433446Smrj  *
1443446Smrj  * RETURN:      Status
1453446Smrj  *
1463446Smrj  * DESCRIPTION: Validate the RSDP (ptr)
1473446Smrj  *
1483446Smrj  ******************************************************************************/
1493446Smrj 
1507851SDana.Myers@Sun.COM static ACPI_STATUS
AcpiTbValidateRsdp(ACPI_TABLE_RSDP * Rsdp)1513446Smrj AcpiTbValidateRsdp (
1527851SDana.Myers@Sun.COM     ACPI_TABLE_RSDP         *Rsdp)
1533446Smrj {
1543446Smrj     ACPI_FUNCTION_ENTRY ();
1553446Smrj 
1563446Smrj 
1573446Smrj     /*
1587851SDana.Myers@Sun.COM      * The signature and checksum must both be correct
1597851SDana.Myers@Sun.COM      *
1607851SDana.Myers@Sun.COM      * Note: Sometimes there exists more than one RSDP in memory; the valid
1617851SDana.Myers@Sun.COM      * RSDP has a valid checksum, all others have an invalid checksum.
1623446Smrj      */
163*9980SDana.Myers@Sun.COM     if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
164*9980SDana.Myers@Sun.COM             sizeof (ACPI_SIG_RSDP)-1) != 0)
1653446Smrj     {
1663446Smrj         /* Nope, BAD Signature */
1673446Smrj 
1683446Smrj         return (AE_BAD_SIGNATURE);
1693446Smrj     }
1703446Smrj 
1713446Smrj     /* Check the standard checksum */
1723446Smrj 
1737851SDana.Myers@Sun.COM     if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
1743446Smrj     {
1753446Smrj         return (AE_BAD_CHECKSUM);
1763446Smrj     }
1773446Smrj 
1783446Smrj     /* Check extended checksum if table version >= 2 */
1793446Smrj 
1803446Smrj     if ((Rsdp->Revision >= 2) &&
1817851SDana.Myers@Sun.COM         (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
1823446Smrj     {
1833446Smrj         return (AE_BAD_CHECKSUM);
1843446Smrj     }
1853446Smrj 
1863446Smrj     return (AE_OK);
1873446Smrj }
1883446Smrj 
1893446Smrj 
1903446Smrj /*******************************************************************************
1913446Smrj  *
192*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiFindRootPointer
1933446Smrj  *
1947851SDana.Myers@Sun.COM  * PARAMETERS:  TableAddress            - Where the table pointer is returned
1953446Smrj  *
1967851SDana.Myers@Sun.COM  * RETURN:      Status, RSDP physical address
1973446Smrj  *
1987851SDana.Myers@Sun.COM  * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
1997851SDana.Myers@Sun.COM  *              pointer structure.  If it is found, set *RSDP to point to it.
2003446Smrj  *
2017851SDana.Myers@Sun.COM  * NOTE1:       The RSDP must be either in the first 1K of the Extended
2027851SDana.Myers@Sun.COM  *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
2037851SDana.Myers@Sun.COM  *              Only a 32-bit physical address is necessary.
2043446Smrj  *
2057851SDana.Myers@Sun.COM  * NOTE2:       This function is always available, regardless of the
2067851SDana.Myers@Sun.COM  *              initialization state of the rest of ACPI.
2073446Smrj  *
2083446Smrj  ******************************************************************************/
2093446Smrj 
2103446Smrj ACPI_STATUS
AcpiFindRootPointer(ACPI_SIZE * TableAddress)2113446Smrj AcpiFindRootPointer (
2127851SDana.Myers@Sun.COM     ACPI_SIZE               *TableAddress)
2133446Smrj {
2147851SDana.Myers@Sun.COM     UINT8                   *TablePtr;
2157851SDana.Myers@Sun.COM     UINT8                   *MemRover;
2167851SDana.Myers@Sun.COM     UINT32                  PhysicalAddress;
2173446Smrj 
2183446Smrj 
2193446Smrj     ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
2203446Smrj 
2213446Smrj 
2227851SDana.Myers@Sun.COM     /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
2233446Smrj 
2247851SDana.Myers@Sun.COM     TablePtr = AcpiOsMapMemory (
2257851SDana.Myers@Sun.COM                 (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
2267851SDana.Myers@Sun.COM                 ACPI_EBDA_PTR_LENGTH);
2277851SDana.Myers@Sun.COM     if (!TablePtr)
2283446Smrj     {
2297851SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO,
2307851SDana.Myers@Sun.COM             "Could not map memory at %8.8X for length %X",
2317851SDana.Myers@Sun.COM             ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
2323446Smrj 
2337851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_NO_MEMORY);
2343446Smrj     }
2353446Smrj 
2367851SDana.Myers@Sun.COM     ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
2377851SDana.Myers@Sun.COM 
2387851SDana.Myers@Sun.COM     /* Convert segment part to physical address */
2397851SDana.Myers@Sun.COM 
2407851SDana.Myers@Sun.COM     PhysicalAddress <<= 4;
2417851SDana.Myers@Sun.COM     AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
2427851SDana.Myers@Sun.COM 
2437851SDana.Myers@Sun.COM     /* EBDA present? */
2447851SDana.Myers@Sun.COM 
2457851SDana.Myers@Sun.COM     if (PhysicalAddress > 0x400)
2467851SDana.Myers@Sun.COM     {
2477851SDana.Myers@Sun.COM         /*
2487851SDana.Myers@Sun.COM          * 1b) Search EBDA paragraphs (EBDA is required to be a
2497851SDana.Myers@Sun.COM          *     minimum of 1K length)
2507851SDana.Myers@Sun.COM          */
2517851SDana.Myers@Sun.COM         TablePtr = AcpiOsMapMemory (
2527851SDana.Myers@Sun.COM                     (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
2537851SDana.Myers@Sun.COM                     ACPI_EBDA_WINDOW_SIZE);
2547851SDana.Myers@Sun.COM         if (!TablePtr)
2557851SDana.Myers@Sun.COM         {
2567851SDana.Myers@Sun.COM             ACPI_ERROR ((AE_INFO,
2577851SDana.Myers@Sun.COM                 "Could not map memory at %8.8X for length %X",
2587851SDana.Myers@Sun.COM                 PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
2597851SDana.Myers@Sun.COM 
2607851SDana.Myers@Sun.COM             return_ACPI_STATUS (AE_NO_MEMORY);
2617851SDana.Myers@Sun.COM         }
2627851SDana.Myers@Sun.COM 
2637851SDana.Myers@Sun.COM         MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
2647851SDana.Myers@Sun.COM         AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
2657851SDana.Myers@Sun.COM 
2667851SDana.Myers@Sun.COM         if (MemRover)
2677851SDana.Myers@Sun.COM         {
2687851SDana.Myers@Sun.COM             /* Return the physical address */
2697851SDana.Myers@Sun.COM 
2707851SDana.Myers@Sun.COM             PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
2717851SDana.Myers@Sun.COM 
2727851SDana.Myers@Sun.COM             *TableAddress = PhysicalAddress;
2737851SDana.Myers@Sun.COM             return_ACPI_STATUS (AE_OK);
2747851SDana.Myers@Sun.COM         }
2757851SDana.Myers@Sun.COM     }
2767851SDana.Myers@Sun.COM 
2777851SDana.Myers@Sun.COM     /*
2787851SDana.Myers@Sun.COM      * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
2797851SDana.Myers@Sun.COM      */
2807851SDana.Myers@Sun.COM     TablePtr = AcpiOsMapMemory (
2817851SDana.Myers@Sun.COM                 (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
2827851SDana.Myers@Sun.COM                 ACPI_HI_RSDP_WINDOW_SIZE);
2837851SDana.Myers@Sun.COM 
2847851SDana.Myers@Sun.COM     if (!TablePtr)
2857851SDana.Myers@Sun.COM     {
2867851SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO,
2877851SDana.Myers@Sun.COM             "Could not map memory at %8.8X for length %X",
2887851SDana.Myers@Sun.COM             ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
2897851SDana.Myers@Sun.COM 
2907851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_NO_MEMORY);
2917851SDana.Myers@Sun.COM     }
2927851SDana.Myers@Sun.COM 
2937851SDana.Myers@Sun.COM     MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
2947851SDana.Myers@Sun.COM     AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
2957851SDana.Myers@Sun.COM 
2967851SDana.Myers@Sun.COM     if (MemRover)
2977851SDana.Myers@Sun.COM     {
2987851SDana.Myers@Sun.COM         /* Return the physical address */
2997851SDana.Myers@Sun.COM 
3007851SDana.Myers@Sun.COM         PhysicalAddress = (UINT32)
3017851SDana.Myers@Sun.COM             (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
3027851SDana.Myers@Sun.COM 
3037851SDana.Myers@Sun.COM         *TableAddress = PhysicalAddress;
3047851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_OK);
3057851SDana.Myers@Sun.COM     }
3067851SDana.Myers@Sun.COM 
3077851SDana.Myers@Sun.COM     /* A valid RSDP was not found */
3087851SDana.Myers@Sun.COM 
3097851SDana.Myers@Sun.COM     ACPI_ERROR ((AE_INFO, "A valid RSDP was not found"));
3107851SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_NOT_FOUND);
3113446Smrj }
3123446Smrj 
ACPI_EXPORT_SYMBOL(AcpiFindRootPointer)3133446Smrj ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
3143446Smrj 
3153446Smrj 
3163446Smrj /*******************************************************************************
3173446Smrj  *
3183446Smrj  * FUNCTION:    AcpiTbScanMemoryForRsdp
3193446Smrj  *
3203446Smrj  * PARAMETERS:  StartAddress        - Starting pointer for search
3213446Smrj  *              Length              - Maximum length to search
3223446Smrj  *
3233446Smrj  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
3243446Smrj  *
3253446Smrj  * DESCRIPTION: Search a block of memory for the RSDP signature
3263446Smrj  *
3273446Smrj  ******************************************************************************/
3283446Smrj 
3293446Smrj static UINT8 *
3303446Smrj AcpiTbScanMemoryForRsdp (
3313446Smrj     UINT8                   *StartAddress,
3323446Smrj     UINT32                  Length)
3333446Smrj {
3343446Smrj     ACPI_STATUS             Status;
3353446Smrj     UINT8                   *MemRover;
3363446Smrj     UINT8                   *EndAddress;
3373446Smrj 
3383446Smrj 
3393446Smrj     ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
3403446Smrj 
3413446Smrj 
3423446Smrj     EndAddress = StartAddress + Length;
3433446Smrj 
3443446Smrj     /* Search from given start address for the requested length */
3453446Smrj 
3463446Smrj     for (MemRover = StartAddress; MemRover < EndAddress;
3473446Smrj          MemRover += ACPI_RSDP_SCAN_STEP)
3483446Smrj     {
3493446Smrj         /* The RSDP signature and checksum must both be correct */
3503446Smrj 
3517851SDana.Myers@Sun.COM         Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
3523446Smrj         if (ACPI_SUCCESS (Status))
3533446Smrj         {
3543446Smrj             /* Sig and checksum valid, we have found a real RSDP */
3553446Smrj 
3563446Smrj             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
3573446Smrj                 "RSDP located at physical address %p\n", MemRover));
3583446Smrj             return_PTR (MemRover);
3593446Smrj         }
3603446Smrj 
3613446Smrj         /* No sig match or bad checksum, keep searching */
3623446Smrj     }
3633446Smrj 
3643446Smrj     /* Searched entire block, no RSDP was found */
3653446Smrj 
3663446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
3673446Smrj         "Searched entire block from %p, valid RSDP was not found\n",
3683446Smrj         StartAddress));
3693446Smrj     return_PTR (NULL);
3703446Smrj }
3713446Smrj 
372