2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: tbxfroot - Find the root ACPI table (RSDT)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-01-13 16:12:34 +00:00
|
|
|
/*
|
2012-01-11 21:25:42 +00:00
|
|
|
* Copyright (C) 2000 - 2012, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2011-01-13 16:12:34 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
#define __TBXFROOT_C__
|
|
|
|
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acpi.h"
|
2009-06-01 21:02:40 +00:00
|
|
|
#include "accommon.h"
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "actables.h"
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_TABLES
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("tbxfroot")
|
2000-12-01 09:36:25 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
/* Local prototypes */
|
|
|
|
|
|
|
|
static UINT8 *
|
|
|
|
AcpiTbScanMemoryForRsdp (
|
|
|
|
UINT8 *StartAddress,
|
|
|
|
UINT32 Length);
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
static ACPI_STATUS
|
|
|
|
AcpiTbValidateRsdp (
|
|
|
|
ACPI_TABLE_RSDP *Rsdp);
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiTbValidateRsdp
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: Rsdp - Pointer to unvalidated RSDP
|
2005-11-01 22:11:18 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Validate the RSDP (ptr)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
static ACPI_STATUS
|
2005-11-01 22:11:18 +00:00
|
|
|
AcpiTbValidateRsdp (
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_RSDP *Rsdp)
|
2005-11-01 22:11:18 +00:00
|
|
|
{
|
|
|
|
ACPI_FUNCTION_ENTRY ();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-03-22 17:24:05 +00:00
|
|
|
* The signature and checksum must both be correct
|
|
|
|
*
|
|
|
|
* Note: Sometimes there exists more than one RSDP in memory; the valid
|
|
|
|
* RSDP has a valid checksum, all others have an invalid checksum.
|
2005-11-01 22:11:18 +00:00
|
|
|
*/
|
2009-06-01 21:02:40 +00:00
|
|
|
if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
|
|
|
|
sizeof (ACPI_SIG_RSDP)-1) != 0)
|
2005-11-01 22:11:18 +00:00
|
|
|
{
|
|
|
|
/* Nope, BAD Signature */
|
|
|
|
|
|
|
|
return (AE_BAD_SIGNATURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the standard checksum */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
|
2005-11-01 22:11:18 +00:00
|
|
|
{
|
|
|
|
return (AE_BAD_CHECKSUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check extended checksum if table version >= 2 */
|
|
|
|
|
|
|
|
if ((Rsdp->Revision >= 2) &&
|
2007-03-22 17:24:05 +00:00
|
|
|
(AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
|
2005-11-01 22:11:18 +00:00
|
|
|
{
|
|
|
|
return (AE_BAD_CHECKSUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2009-06-01 21:02:40 +00:00
|
|
|
* FUNCTION: AcpiFindRootPointer
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: TableAddress - Where the table pointer is returned
|
2001-06-29 20:11:04 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* RETURN: Status, RSDP physical address
|
2001-06-29 20:11:04 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
|
|
|
|
* pointer structure. If it is found, set *RSDP to point to it.
|
2001-06-29 20:11:04 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* NOTE1: The RSDP must be either in the first 1K of the Extended
|
|
|
|
* BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
|
|
|
|
* Only a 32-bit physical address is necessary.
|
2001-06-29 20:11:04 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* NOTE2: This function is always available, regardless of the
|
|
|
|
* initialization state of the rest of ACPI.
|
2001-06-29 20:11:04 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiFindRootPointer (
|
2009-06-01 21:02:40 +00:00
|
|
|
ACPI_SIZE *TableAddress)
|
2001-06-29 20:11:04 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
UINT8 *TablePtr;
|
|
|
|
UINT8 *MemRover;
|
|
|
|
UINT32 PhysicalAddress;
|
2001-06-29 20:11:04 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
|
2002-07-30 19:33:39 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
TablePtr = AcpiOsMapMemory (
|
|
|
|
(ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
|
|
|
|
ACPI_EBDA_PTR_LENGTH);
|
|
|
|
if (!TablePtr)
|
2001-06-29 20:11:04 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_ERROR ((AE_INFO,
|
2010-03-05 19:58:45 +00:00
|
|
|
"Could not map memory at 0x%8.8X for length %u",
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
|
2004-12-01 23:14:10 +00:00
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Convert segment part to physical address */
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
PhysicalAddress <<= 4;
|
|
|
|
AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* EBDA present? */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (PhysicalAddress > 0x400)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
/*
|
2007-03-22 17:24:05 +00:00
|
|
|
* 1b) Search EBDA paragraphs (EBDA is required to be a
|
|
|
|
* minimum of 1K length)
|
2005-11-01 22:11:18 +00:00
|
|
|
*/
|
2007-03-22 17:24:05 +00:00
|
|
|
TablePtr = AcpiOsMapMemory (
|
2009-06-01 21:02:40 +00:00
|
|
|
(ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EBDA_WINDOW_SIZE);
|
|
|
|
if (!TablePtr)
|
2001-06-29 20:11:04 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_ERROR ((AE_INFO,
|
2010-03-05 19:58:45 +00:00
|
|
|
"Could not map memory at 0x%8.8X for length %u",
|
2007-03-22 17:24:05 +00:00
|
|
|
PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
2001-06-29 20:11:04 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
|
|
|
|
AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (MemRover)
|
2001-06-29 20:11:04 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Return the physical address */
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
*TableAddress = PhysicalAddress;
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
2001-06-29 20:11:04 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*
|
|
|
|
* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
|
|
|
|
*/
|
|
|
|
TablePtr = AcpiOsMapMemory (
|
|
|
|
(ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
|
|
|
|
ACPI_HI_RSDP_WINDOW_SIZE);
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!TablePtr)
|
2005-11-01 22:11:18 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_ERROR ((AE_INFO,
|
2010-03-05 19:58:45 +00:00
|
|
|
"Could not map memory at 0x%8.8X for length %u",
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
|
|
|
|
AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (MemRover)
|
2002-02-23 05:10:40 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Return the physical address */
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
PhysicalAddress = (UINT32)
|
|
|
|
(ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
|
|
|
|
|
|
|
|
*TableAddress = PhysicalAddress;
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* A valid RSDP was not found */
|
|
|
|
|
2012-07-11 16:51:47 +00:00
|
|
|
ACPI_BIOS_ERROR ((AE_INFO, "A valid RSDP was not found"));
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_NOT_FOUND);
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiTbScanMemoryForRsdp
|
|
|
|
*
|
|
|
|
* PARAMETERS: StartAddress - Starting pointer for search
|
|
|
|
* Length - Maximum length to search
|
|
|
|
*
|
|
|
|
* RETURN: Pointer to the RSDP if found, otherwise NULL.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Search a block of memory for the RSDP signature
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
static UINT8 *
|
2002-02-23 05:10:40 +00:00
|
|
|
AcpiTbScanMemoryForRsdp (
|
|
|
|
UINT8 *StartAddress,
|
|
|
|
UINT32 Length)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
ACPI_STATUS Status;
|
2002-02-23 05:10:40 +00:00
|
|
|
UINT8 *MemRover;
|
2004-12-01 23:14:10 +00:00
|
|
|
UINT8 *EndAddress;
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
EndAddress = StartAddress + Length;
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
/* Search from given start address for the requested length */
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
for (MemRover = StartAddress; MemRover < EndAddress;
|
|
|
|
MemRover += ACPI_RSDP_SCAN_STEP)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
/* The RSDP signature and checksum must both be correct */
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
|
2005-11-01 22:11:18 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
2002-02-23 05:10:40 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
/* Sig and checksum valid, we have found a real RSDP */
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
2004-12-01 23:14:10 +00:00
|
|
|
"RSDP located at physical address %p\n", MemRover));
|
2002-02-23 05:10:40 +00:00
|
|
|
return_PTR (MemRover);
|
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
/* No sig match or bad checksum, keep searching */
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Searched entire block, no RSDP was found */
|
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
2005-11-01 22:11:18 +00:00
|
|
|
"Searched entire block from %p, valid RSDP was not found\n",
|
|
|
|
StartAddress));
|
2002-02-23 05:10:40 +00:00
|
|
|
return_PTR (NULL);
|
|
|
|
}
|
|
|
|
|