2005-04-16 18:20:36 -04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: tbxfroot - Find the root ACPI table (RSDT)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 - 2005, R. Byron Moore
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
|
|
|
#include <acpi/actables.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_TABLES
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MODULE_NAME("tbxfroot")
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
/* Local prototypes */
|
|
|
|
static acpi_status
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags);
|
2005-04-18 22:49:35 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-07-08 00:00:00 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_validate_rsdp
|
|
|
|
*
|
|
|
|
* PARAMETERS: Rsdp - Pointer to unvalidated RSDP
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Validate the RSDP (ptr)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_status acpi_tb_validate_rsdp(struct rsdp_descriptor *rsdp)
|
2005-07-08 00:00:00 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_ENTRY();
|
2005-07-08 00:00:00 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The signature and checksum must both be correct
|
|
|
|
*/
|
2005-08-05 00:44:28 -04:00
|
|
|
if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* Nope, BAD Signature */
|
|
|
|
|
|
|
|
return (AE_BAD_SIGNATURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the standard checksum */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
if (acpi_tb_generate_checksum(rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
|
2005-07-08 00:00:00 -04:00
|
|
|
return (AE_BAD_CHECKSUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check extended checksum if table version >= 2 */
|
|
|
|
|
|
|
|
if ((rsdp->revision >= 2) &&
|
2005-08-05 00:44:28 -04:00
|
|
|
(acpi_tb_generate_checksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) !=
|
|
|
|
0)) {
|
2005-07-08 00:00:00 -04:00
|
|
|
return (AE_BAD_CHECKSUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_find_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: Signature - String with ACPI table signature
|
|
|
|
* oem_id - String with the table OEM ID
|
2005-04-18 22:49:35 -04:00
|
|
|
* oem_table_id - String with the OEM Table ID
|
|
|
|
* table_ptr - Where the table pointer is returned
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
|
|
|
|
* Signature, OEM ID and OEM Table ID.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_tb_find_table(char *signature,
|
|
|
|
char *oem_id,
|
|
|
|
char *oem_table_id, struct acpi_table_header ** table_ptr)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_table_header *table;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_TRACE("tb_find_table");
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Validate string lengths */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) ||
|
|
|
|
(ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) ||
|
|
|
|
(ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) {
|
|
|
|
return_ACPI_STATUS(AE_AML_STRING_LIMIT);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* The DSDT pointer is contained in the FADT, not the RSDT.
|
|
|
|
* This code should suffice, because the only code that would perform
|
|
|
|
* a "find" on the DSDT is the data_table_region() AML opcode -- in
|
|
|
|
* which case, the DSDT is guaranteed to be already loaded.
|
|
|
|
* If this becomes insufficient, the FADT will have to be found first.
|
|
|
|
*/
|
|
|
|
if (!acpi_gbl_DSDT) {
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
table = acpi_gbl_DSDT;
|
2005-08-05 00:44:28 -04:00
|
|
|
} else {
|
2005-04-16 18:20:36 -04:00
|
|
|
/* Find the table */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_get_firmware_table(signature, 1,
|
|
|
|
ACPI_LOGICAL_ADDRESSING,
|
|
|
|
&table);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check oem_id and oem_table_id */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id,
|
|
|
|
sizeof(table->oem_id))) ||
|
|
|
|
(oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id,
|
|
|
|
sizeof(table->oem_table_id)))) {
|
|
|
|
return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n",
|
|
|
|
table->signature));
|
2005-04-18 22:49:35 -04:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
*table_ptr = table;
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_get_firmware_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: Signature - Any ACPI table signature
|
|
|
|
* Instance - the non zero instance of the table, allows
|
|
|
|
* support for multiple tables of the same type
|
|
|
|
* Flags - Physical/Virtual support
|
|
|
|
* table_pointer - Where a buffer containing the table is
|
|
|
|
* returned
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: This function is called to get an ACPI table. A buffer is
|
|
|
|
* allocated for the table and returned in table_pointer.
|
|
|
|
* This table will be a complete table including the header.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_get_firmware_table(acpi_string signature,
|
|
|
|
u32 instance,
|
|
|
|
u32 flags, struct acpi_table_header **table_pointer)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_pointer address;
|
|
|
|
struct acpi_table_header *header = NULL;
|
|
|
|
struct acpi_table_desc *table_info = NULL;
|
|
|
|
struct acpi_table_desc *rsdt_info;
|
|
|
|
u32 table_count;
|
|
|
|
u32 i;
|
|
|
|
u32 j;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_TRACE("acpi_get_firmware_table");
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that at least the table manager is initialized. We don't
|
|
|
|
* require that the entire ACPI subsystem is up for this interface.
|
|
|
|
* If we have a buffer, we must have a length too
|
|
|
|
*/
|
2005-08-05 00:44:28 -04:00
|
|
|
if ((instance == 0) || (!signature) || (!table_pointer)) {
|
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure that we have a RSDP */
|
|
|
|
|
|
|
|
if (!acpi_gbl_RSDP) {
|
|
|
|
/* Get the RSDP */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_os_get_root_pointer(flags, &address);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "RSDP not found\n"));
|
|
|
|
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Map and validate the RSDP */
|
|
|
|
|
|
|
|
if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_os_map_memory(address.pointer.physical,
|
|
|
|
sizeof(struct
|
|
|
|
rsdp_descriptor),
|
|
|
|
(void *)&acpi_gbl_RSDP);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2005-08-05 00:44:28 -04:00
|
|
|
} else {
|
2005-04-16 18:20:36 -04:00
|
|
|
acpi_gbl_RSDP = address.pointer.logical;
|
|
|
|
}
|
|
|
|
|
2005-07-08 00:00:00 -04:00
|
|
|
/* The RDSP signature and checksum must both be correct */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_tb_validate_rsdp(acpi_gbl_RSDP);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the RSDT address via the RSDP */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_tb_get_rsdt_address(&address);
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2005-09-30 19:03:00 -04:00
|
|
|
"RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_gbl_RSDP,
|
|
|
|
ACPI_FORMAT_UINT64(address.pointer.value)));
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Insert processor_mode flags */
|
|
|
|
|
|
|
|
address.pointer_type |= flags;
|
|
|
|
|
|
|
|
/* Get and validate the RSDT */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc));
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!rsdt_info) {
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_tb_get_table(&address, rsdt_info);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_tb_validate_rsdt(rsdt_info->pointer);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a scratch table header and table descriptor */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header));
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!header) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc));
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!table_info) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the number of table pointers within the RSDT */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
table_count =
|
|
|
|
acpi_tb_get_table_count(acpi_gbl_RSDP, rsdt_info->pointer);
|
2005-04-16 18:20:36 -04:00
|
|
|
address.pointer_type = acpi_gbl_table_flags | flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search the RSDT/XSDT for the correct instance of the
|
|
|
|
* requested table
|
|
|
|
*/
|
|
|
|
for (i = 0, j = 0; i < table_count; i++) {
|
ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>
ACPICA 20050617:
Moved the object cache operations into the OS interface
layer (OSL) to allow the host OS to handle these operations
if desired (for example, the Linux OSL will invoke the
slab allocator). This support is optional; the compile
time define ACPI_USE_LOCAL_CACHE may be used to utilize
the original cache code in the ACPI CA core. The new OSL
interfaces are shown below. See utalloc.c for an example
implementation, and acpiosxf.h for the exact interface
definitions. Thanks to Alexey Starikovskiy.
acpi_os_create_cache
acpi_os_delete_cache
acpi_os_purge_cache
acpi_os_acquire_object
acpi_os_release_object
Modified the interfaces to acpi_os_acquire_lock and
acpi_os_release_lock to return and restore a flags
parameter. This fits better with many OS lock models.
Note: the current execution state (interrupt handler
or not) is no longer passed to these interfaces. If
necessary, the OSL must determine this state by itself, a
simple and fast operation. Thanks to Alexey Starikovskiy.
Fixed a problem in the ACPI table handling where a valid
XSDT was assumed present if the revision of the RSDP
was 2 or greater. According to the ACPI specification,
the XSDT is optional in all cases, and the table manager
therefore now checks for both an RSDP >=2 and a valid
XSDT pointer. Otherwise, the RSDT pointer is used.
Some ACPI 2.0 compliant BIOSs contain only the RSDT.
Fixed an interpreter problem with the Mid() operator in the
case of an input string where the resulting output string
is of zero length. It now correctly returns a valid,
null terminated string object instead of a string object
with a null pointer.
Fixed a problem with the control method argument handling
to allow a store to an Arg object that already contains an
object of type Device. The Device object is now correctly
overwritten. Previously, an error was returned.
ACPICA 20050624:
Modified the new OSL cache interfaces to use ACPI_CACHE_T
as the type for the host-defined cache object. This allows
the OSL implementation to define and type this object in
any manner desired, simplifying the OSL implementation.
For example, ACPI_CACHE_T is defined as kmem_cache_t for
Linux, and should be defined in the OS-specific header
file for other operating systems as required.
Changed the interface to AcpiOsAcquireObject to directly
return the requested object as the function return (instead
of ACPI_STATUS.) This change was made for performance
reasons, since this is the purpose of the interface in the
first place. acpi_os_acquire_object is now similar to the
acpi_os_allocate interface. Thanks to Alexey Starikovskiy.
Modified the initialization sequence in
acpi_initialize_subsystem to call the OSL interface
acpi_osl_initialize first, before any local initialization.
This change was required because the global initialization
now calls OSL interfaces.
Restructured the code base to split some files because
of size and/or because the code logically belonged in a
separate file. New files are listed below.
utilities/utcache.c /* Local cache interfaces */
utilities/utmutex.c /* Local mutex support */
utilities/utstate.c /* State object support */
parser/psloop.c /* Main AML parse loop */
Signed-off-by: Len Brown <len.brown@intel.com>
2005-06-24 00:00:00 -04:00
|
|
|
/*
|
|
|
|
* Get the next table pointer, handle RSDT vs. XSDT
|
|
|
|
* RSDT pointers are 32 bits, XSDT pointers are 64 bits
|
|
|
|
*/
|
|
|
|
if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
|
2005-08-05 00:44:28 -04:00
|
|
|
address.pointer.value =
|
|
|
|
(ACPI_CAST_PTR
|
|
|
|
(RSDT_DESCRIPTOR,
|
|
|
|
rsdt_info->pointer))->table_offset_entry[i];
|
|
|
|
} else {
|
|
|
|
address.pointer.value =
|
|
|
|
(ACPI_CAST_PTR
|
|
|
|
(XSDT_DESCRIPTOR,
|
|
|
|
rsdt_info->pointer))->table_offset_entry[i];
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the table header */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_tb_get_table_header(&address, header);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compare table signatures and table instance */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
/* An instance of the table was found */
|
|
|
|
|
|
|
|
j++;
|
|
|
|
if (j >= instance) {
|
|
|
|
/* Found the correct instance, get the entire table */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status =
|
|
|
|
acpi_tb_get_table_body(&address, header,
|
|
|
|
table_info);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*table_pointer = table_info->pointer;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did not find the table */
|
|
|
|
|
|
|
|
status = AE_NOT_EXIST;
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
cleanup:
|
2005-05-26 00:00:00 -04:00
|
|
|
if (rsdt_info->pointer) {
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_os_unmap_memory(rsdt_info->pointer,
|
|
|
|
(acpi_size) rsdt_info->pointer->length);
|
2005-05-26 00:00:00 -04:00
|
|
|
}
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MEM_FREE(rsdt_info);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
if (header) {
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MEM_FREE(header);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
if (table_info) {
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MEM_FREE(table_info);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
EXPORT_SYMBOL(acpi_get_firmware_table);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* TBD: Move to a new file */
|
|
|
|
|
|
|
|
#if ACPI_MACHINE_WIDTH != 16
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_find_root_pointer
|
|
|
|
*
|
2005-04-18 22:49:35 -04:00
|
|
|
* PARAMETERS: Flags - Logical/Physical addressing
|
|
|
|
* rsdp_address - Where to place the RSDP address
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* RETURN: Status, Physical address of the RSDP
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Find the RSDP
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
struct acpi_table_desc table_info;
|
|
|
|
acpi_status status;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_TRACE("acpi_find_root_pointer");
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Get the RSDP */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_tb_find_rsdp(&table_info, flags);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
|
|
|
|
"RSDP structure not found, %s Flags=%X\n",
|
|
|
|
acpi_format_exception(status), flags));
|
2005-04-18 22:49:35 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
rsdp_address->pointer_type = ACPI_PHYSICAL_POINTER;
|
|
|
|
rsdp_address->pointer.physical = table_info.physical_address;
|
2005-08-05 00:44:28 -04:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_scan_memory_for_rsdp
|
|
|
|
*
|
|
|
|
* PARAMETERS: start_address - 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-08-05 00:44:28 -04:00
|
|
|
static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_status status;
|
|
|
|
u8 *mem_rover;
|
|
|
|
u8 *end_address;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_TRACE("tb_scan_memory_for_rsdp");
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
end_address = start_address + length;
|
|
|
|
|
|
|
|
/* Search from given start address for the requested length */
|
|
|
|
|
|
|
|
for (mem_rover = start_address; mem_rover < end_address;
|
2005-08-05 00:44:28 -04:00
|
|
|
mem_rover += ACPI_RSDP_SCAN_STEP) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* The RSDP signature and checksum must both be correct */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status =
|
|
|
|
acpi_tb_validate_rsdp(ACPI_CAST_PTR
|
|
|
|
(struct rsdp_descriptor, mem_rover));
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* Sig and checksum valid, we have found a real RSDP */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"RSDP located at physical address %p\n",
|
|
|
|
mem_rover));
|
|
|
|
return_PTR(mem_rover);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-07-08 00:00:00 -04:00
|
|
|
/* No sig match or bad checksum, keep searching */
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Searched entire block, no RSDP was found */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Searched entire block from %p, valid RSDP was not found\n",
|
|
|
|
start_address));
|
|
|
|
return_PTR(NULL);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_find_rsdp
|
|
|
|
*
|
2005-04-18 22:49:35 -04:00
|
|
|
* PARAMETERS: table_info - Where the table info is returned
|
2005-04-16 18:20:36 -04:00
|
|
|
* Flags - Current memory mode (logical vs.
|
|
|
|
* physical addressing)
|
|
|
|
*
|
|
|
|
* RETURN: Status, RSDP physical address
|
|
|
|
*
|
|
|
|
* DESCRIPTION: search lower 1_mbyte of memory for the root system descriptor
|
|
|
|
* pointer structure. If it is found, set *RSDP to point to it.
|
|
|
|
*
|
|
|
|
* NOTE1: The RSDp must be either in the first 1_k of the Extended
|
|
|
|
* BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
|
|
|
|
* Only a 32-bit physical address is necessary.
|
|
|
|
*
|
|
|
|
* NOTE2: This function is always available, regardless of the
|
|
|
|
* initialization state of the rest of ACPI.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
static acpi_status
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-05 00:44:28 -04:00
|
|
|
u8 *table_ptr;
|
|
|
|
u8 *mem_rover;
|
|
|
|
u32 physical_address;
|
|
|
|
acpi_status status;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_FUNCTION_TRACE("tb_find_rsdp");
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
2005-04-18 22:49:35 -04:00
|
|
|
* Scan supports either logical addressing or physical addressing
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
|
|
|
if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
|
2005-04-18 22:49:35 -04:00
|
|
|
/* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_os_map_memory((acpi_physical_address)
|
|
|
|
ACPI_EBDA_PTR_LOCATION,
|
|
|
|
ACPI_EBDA_PTR_LENGTH,
|
|
|
|
(void *)&table_ptr);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
|
|
|
|
"Could not map memory at %8.8X for length %X\n",
|
|
|
|
ACPI_EBDA_PTR_LOCATION,
|
|
|
|
ACPI_EBDA_PTR_LENGTH));
|
|
|
|
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MOVE_16_TO_32(&physical_address, table_ptr);
|
2005-04-18 22:49:35 -04:00
|
|
|
|
|
|
|
/* Convert segment part to physical address */
|
|
|
|
|
|
|
|
physical_address <<= 4;
|
2005-08-05 00:44:28 -04:00
|
|
|
acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* EBDA present? */
|
|
|
|
|
|
|
|
if (physical_address > 0x400) {
|
|
|
|
/*
|
2005-04-18 22:49:35 -04:00
|
|
|
* 1b) Search EBDA paragraphs (EBDa is required to be a
|
|
|
|
* minimum of 1_k length)
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_os_map_memory((acpi_physical_address)
|
|
|
|
physical_address,
|
|
|
|
ACPI_EBDA_WINDOW_SIZE,
|
|
|
|
(void *)&table_ptr);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
|
|
|
|
"Could not map memory at %8.8X for length %X\n",
|
|
|
|
physical_address,
|
|
|
|
ACPI_EBDA_WINDOW_SIZE));
|
|
|
|
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
mem_rover = acpi_tb_scan_memory_for_rsdp(table_ptr,
|
|
|
|
ACPI_EBDA_WINDOW_SIZE);
|
|
|
|
acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
if (mem_rover) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* Return the physical address */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
physical_address +=
|
|
|
|
ACPI_PTR_DIFF(mem_rover, table_ptr);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
table_info->physical_address =
|
2005-08-05 00:44:28 -04:00
|
|
|
(acpi_physical_address) physical_address;
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
|
|
|
|
*/
|
2005-08-05 00:44:28 -04:00
|
|
|
status = acpi_os_map_memory((acpi_physical_address)
|
|
|
|
ACPI_HI_RSDP_WINDOW_BASE,
|
|
|
|
ACPI_HI_RSDP_WINDOW_SIZE,
|
|
|
|
(void *)&table_ptr);
|
|
|
|
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
|
|
|
|
"Could not map memory at %8.8X for length %X\n",
|
|
|
|
ACPI_HI_RSDP_WINDOW_BASE,
|
|
|
|
ACPI_HI_RSDP_WINDOW_SIZE));
|
|
|
|
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
mem_rover =
|
|
|
|
acpi_tb_scan_memory_for_rsdp(table_ptr,
|
|
|
|
ACPI_HI_RSDP_WINDOW_SIZE);
|
|
|
|
acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
if (mem_rover) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* Return the physical address */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
physical_address =
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF(mem_rover,
|
|
|
|
table_ptr);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
table_info->physical_address =
|
2005-08-05 00:44:28 -04:00
|
|
|
(acpi_physical_address) physical_address;
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Physical addressing
|
|
|
|
*/
|
|
|
|
else {
|
2005-04-18 22:49:35 -04:00
|
|
|
/* 1a) Get the location of the EBDA */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_MOVE_16_TO_32(&physical_address, ACPI_EBDA_PTR_LOCATION);
|
|
|
|
physical_address <<= 4; /* Convert segment to physical address */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* EBDA present? */
|
|
|
|
|
|
|
|
if (physical_address > 0x400) {
|
|
|
|
/*
|
2005-04-18 22:49:35 -04:00
|
|
|
* 1b) Search EBDA paragraphs (EBDa is required to be a minimum of
|
|
|
|
* 1_k length)
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
2005-08-05 00:44:28 -04:00
|
|
|
mem_rover =
|
|
|
|
acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
|
|
|
|
(physical_address),
|
|
|
|
ACPI_EBDA_WINDOW_SIZE);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (mem_rover) {
|
2005-07-08 00:00:00 -04:00
|
|
|
/* Return the physical address */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
table_info->physical_address =
|
|
|
|
ACPI_TO_INTEGER(mem_rover);
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-18 22:49:35 -04:00
|
|
|
/* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
mem_rover =
|
|
|
|
acpi_tb_scan_memory_for_rsdp(ACPI_PHYSADDR_TO_PTR
|
|
|
|
(ACPI_HI_RSDP_WINDOW_BASE),
|
|
|
|
ACPI_HI_RSDP_WINDOW_SIZE);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (mem_rover) {
|
|
|
|
/* Found it, return the physical address */
|
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
table_info->physical_address =
|
|
|
|
ACPI_TO_INTEGER(mem_rover);
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-08 00:00:00 -04:00
|
|
|
/* A valid RSDP was not found */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-05 00:44:28 -04:00
|
|
|
ACPI_REPORT_ERROR(("No valid RSDP was found\n"));
|
|
|
|
return_ACPI_STATUS(AE_NOT_FOUND);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|