ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

tbxfroot.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
00004  *
00005  *****************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 #define __TBXFROOT_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "actables.h"
00121 
00122 
00123 #define _COMPONENT          ACPI_TABLES
00124         ACPI_MODULE_NAME    ("tbxfroot")
00125 
00126 /* Local prototypes */
00127 
00128 static UINT8 *
00129 AcpiTbScanMemoryForRsdp (
00130     UINT8                   *StartAddress,
00131     UINT32                  Length);
00132 
00133 static ACPI_STATUS
00134 AcpiTbValidateRsdp (
00135     ACPI_TABLE_RSDP         *Rsdp);
00136 
00137 
00138 /*******************************************************************************
00139  *
00140  * FUNCTION:    AcpiTbValidateRsdp
00141  *
00142  * PARAMETERS:  Rsdp                - Pointer to unvalidated RSDP
00143  *
00144  * RETURN:      Status
00145  *
00146  * DESCRIPTION: Validate the RSDP (ptr)
00147  *
00148  ******************************************************************************/
00149 
00150 static ACPI_STATUS
00151 AcpiTbValidateRsdp (
00152     ACPI_TABLE_RSDP         *Rsdp)
00153 {
00154     ACPI_FUNCTION_ENTRY ();
00155 
00156 
00157     /*
00158      * The signature and checksum must both be correct
00159      *
00160      * Note: Sometimes there exists more than one RSDP in memory; the valid
00161      * RSDP has a valid checksum, all others have an invalid checksum.
00162      */
00163     if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
00164             sizeof (ACPI_SIG_RSDP)-1) != 0)
00165     {
00166         /* Nope, BAD Signature */
00167 
00168         return (AE_BAD_SIGNATURE);
00169     }
00170 
00171     /* Check the standard checksum */
00172 
00173     if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
00174     {
00175         return (AE_BAD_CHECKSUM);
00176     }
00177 
00178     /* Check extended checksum if table version >= 2 */
00179 
00180     if ((Rsdp->Revision >= 2) &&
00181         (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
00182     {
00183         return (AE_BAD_CHECKSUM);
00184     }
00185 
00186     return (AE_OK);
00187 }
00188 
00189 
00190 /*******************************************************************************
00191  *
00192  * FUNCTION:    AcpiFindRootPointer
00193  *
00194  * PARAMETERS:  TableAddress            - Where the table pointer is returned
00195  *
00196  * RETURN:      Status, RSDP physical address
00197  *
00198  * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
00199  *              pointer structure.  If it is found, set *RSDP to point to it.
00200  *
00201  * NOTE1:       The RSDP must be either in the first 1K of the Extended
00202  *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
00203  *              Only a 32-bit physical address is necessary.
00204  *
00205  * NOTE2:       This function is always available, regardless of the
00206  *              initialization state of the rest of ACPI.
00207  *
00208  ******************************************************************************/
00209 
00210 ACPI_STATUS
00211 AcpiFindRootPointer (
00212     ACPI_SIZE               *TableAddress)
00213 {
00214     UINT8                   *TablePtr;
00215     UINT8                   *MemRover;
00216     UINT32                  PhysicalAddress;
00217 
00218 
00219     ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
00220 
00221 
00222     /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
00223 
00224     TablePtr = AcpiOsMapMemory (
00225                 (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
00226                 ACPI_EBDA_PTR_LENGTH);
00227     if (!TablePtr)
00228     {
00229         ACPI_ERROR ((AE_INFO,
00230             "Could not map memory at 0x%8.8X for length %u",
00231             ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
00232 
00233         return_ACPI_STATUS (AE_NO_MEMORY);
00234     }
00235 
00236     ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
00237 
00238     /* Convert segment part to physical address */
00239 
00240     PhysicalAddress <<= 4;
00241     AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
00242 
00243     /* EBDA present? */
00244 
00245     if (PhysicalAddress > 0x400)
00246     {
00247         /*
00248          * 1b) Search EBDA paragraphs (EBDA is required to be a
00249          *     minimum of 1K length)
00250          */
00251         TablePtr = AcpiOsMapMemory (
00252                     (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
00253                     ACPI_EBDA_WINDOW_SIZE);
00254         if (!TablePtr)
00255         {
00256             ACPI_ERROR ((AE_INFO,
00257                 "Could not map memory at 0x%8.8X for length %u",
00258                 PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
00259 
00260             return_ACPI_STATUS (AE_NO_MEMORY);
00261         }
00262 
00263         MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
00264         AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
00265 
00266         if (MemRover)
00267         {
00268             /* Return the physical address */
00269 
00270             PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
00271 
00272             *TableAddress = PhysicalAddress;
00273             return_ACPI_STATUS (AE_OK);
00274         }
00275     }
00276 
00277     /*
00278      * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
00279      */
00280     TablePtr = AcpiOsMapMemory (
00281                 (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
00282                 ACPI_HI_RSDP_WINDOW_SIZE);
00283 
00284     if (!TablePtr)
00285     {
00286         ACPI_ERROR ((AE_INFO,
00287             "Could not map memory at 0x%8.8X for length %u",
00288             ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
00289 
00290         return_ACPI_STATUS (AE_NO_MEMORY);
00291     }
00292 
00293     MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
00294     AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
00295 
00296     if (MemRover)
00297     {
00298         /* Return the physical address */
00299 
00300         PhysicalAddress = (UINT32)
00301             (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
00302 
00303         *TableAddress = PhysicalAddress;
00304         return_ACPI_STATUS (AE_OK);
00305     }
00306 
00307     /* A valid RSDP was not found */
00308 
00309     ACPI_ERROR ((AE_INFO, "A valid RSDP was not found"));
00310     return_ACPI_STATUS (AE_NOT_FOUND);
00311 }
00312 
00313 ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
00314 
00315 
00316 /*******************************************************************************
00317  *
00318  * FUNCTION:    AcpiTbScanMemoryForRsdp
00319  *
00320  * PARAMETERS:  StartAddress        - Starting pointer for search
00321  *              Length              - Maximum length to search
00322  *
00323  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
00324  *
00325  * DESCRIPTION: Search a block of memory for the RSDP signature
00326  *
00327  ******************************************************************************/
00328 
00329 static UINT8 *
00330 AcpiTbScanMemoryForRsdp (
00331     UINT8                   *StartAddress,
00332     UINT32                  Length)
00333 {
00334     ACPI_STATUS             Status;
00335     UINT8                   *MemRover;
00336     UINT8                   *EndAddress;
00337 
00338 
00339     ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
00340 
00341 
00342     EndAddress = StartAddress + Length;
00343 
00344     /* Search from given start address for the requested length */
00345 
00346     for (MemRover = StartAddress; MemRover < EndAddress;
00347          MemRover += ACPI_RSDP_SCAN_STEP)
00348     {
00349         /* The RSDP signature and checksum must both be correct */
00350 
00351         Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
00352         if (ACPI_SUCCESS (Status))
00353         {
00354             /* Sig and checksum valid, we have found a real RSDP */
00355 
00356             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
00357                 "RSDP located at physical address %p\n", MemRover));
00358             return_PTR (MemRover);
00359         }
00360 
00361         /* No sig match or bad checksum, keep searching */
00362     }
00363 
00364     /* Searched entire block, no RSDP was found */
00365 
00366     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
00367         "Searched entire block from %p, valid RSDP was not found\n",
00368         StartAddress));
00369     return_PTR (NULL);
00370 }
00371 

Generated on Sat May 26 2012 04:25:56 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.