patch-2.4.22 linux-2.4.22/drivers/acpi/tables/tbget.c
Next file: linux-2.4.22/drivers/acpi/tables/tbgetall.c
Previous file: linux-2.4.22/drivers/acpi/tables/tbconvrt.c
Back to the patch index
Back to the overall index
- Lines: 1039
- Date:
2003-08-25 04:44:41.000000000 -0700
- Orig file:
linux-2.4.21/drivers/acpi/tables/tbget.c
- Orig date:
2001-10-24 14:06:22.000000000 -0700
diff -urN linux-2.4.21/drivers/acpi/tables/tbget.c linux-2.4.22/drivers/acpi/tables/tbget.c
@@ -1,754 +1,492 @@
/******************************************************************************
*
* Module Name: tbget - ACPI Table get* routines
- * $Revision: 56 $
*
*****************************************************************************/
/*
- * Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 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 "acpi.h"
-#include "achware.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/actables.h>
#define _COMPONENT ACPI_TABLES
- MODULE_NAME ("tbget")
-
-#define RSDP_CHECKSUM_LENGTH 20
+ ACPI_MODULE_NAME ("tbget")
/*******************************************************************************
*
- * FUNCTION: Acpi_tb_get_table_ptr
+ * FUNCTION: acpi_tb_get_table
*
- * PARAMETERS: Table_type - one of the defined table types
- * Instance - Which table of this type
- * Table_ptr_loc - pointer to location to place the pointer for
- * return
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * table_info - Where table info is returned
*
- * RETURN: Status
+ * RETURN: None
*
- * DESCRIPTION: This function is called to get the pointer to an ACPI table.
+ * DESCRIPTION: Get entire table of unknown size.
*
******************************************************************************/
acpi_status
-acpi_tb_get_table_ptr (
- acpi_table_type table_type,
- u32 instance,
- acpi_table_header **table_ptr_loc)
+acpi_tb_get_table (
+ struct acpi_pointer *address,
+ struct acpi_table_desc *table_info)
{
- acpi_table_desc *table_desc;
- u32 i;
-
-
- FUNCTION_TRACE ("Tb_get_table_ptr");
-
+ acpi_status status;
+ struct acpi_table_header header;
- if (!acpi_gbl_DSDT) {
- return_ACPI_STATUS (AE_NO_ACPI_TABLES);
- }
- if (table_type > ACPI_TABLE_MAX) {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
+ ACPI_FUNCTION_TRACE ("tb_get_table");
/*
- * For all table types (Single/Multiple), the first
- * instance is always in the list head.
+ * Get the header in order to get signature and table size
*/
- if (instance == 1) {
- /*
- * Just pluck the pointer out of the global table!
- * Will be null if no table is present
- */
- *table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer;
- return_ACPI_STATUS (AE_OK);
+ status = acpi_tb_get_table_header (address, &header);
+ if (ACPI_FAILURE (status)) {
+ return_ACPI_STATUS (status);
}
+ /* Get the entire table */
- /*
- * Check for instance out of range
- */
- if (instance > acpi_gbl_acpi_tables[table_type].count) {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- /* Walk the list to get the desired table
- * Since the if (Instance == 1) check above checked for the
- * first table, setting Table_desc equal to the .Next member
- * is actually pointing to the second table. Therefore, we
- * need to walk from the 2nd table until we reach the Instance
- * that the user is looking for and return its table pointer.
- */
- table_desc = acpi_gbl_acpi_tables[table_type].next;
- for (i = 2; i < instance; i++) {
- table_desc = table_desc->next;
+ status = acpi_tb_get_table_body (address, &header, table_info);
+ if (ACPI_FAILURE (status)) {
+ ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n",
+ header.length, acpi_format_exception (status)));
+ return_ACPI_STATUS (status);
}
- /* We are now pointing to the requested table's descriptor */
-
- *table_ptr_loc = table_desc->pointer;
-
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_tb_get_table
+ * FUNCTION: acpi_tb_get_table_header
*
- * PARAMETERS: Physical_address - Physical address of table to retrieve
- * *Buffer_ptr - If Buffer_ptr is valid, read data from
- * buffer rather than searching memory
- * *Table_info - Where the table info is returned
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * return_header - Where the table header is returned
*
* RETURN: Status
*
- * DESCRIPTION: Maps the physical address of table into a logical address
+ * DESCRIPTION: Get an ACPI table header. Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
*
******************************************************************************/
acpi_status
-acpi_tb_get_table (
- ACPI_PHYSICAL_ADDRESS physical_address,
- acpi_table_header *buffer_ptr,
- acpi_table_desc *table_info)
+acpi_tb_get_table_header (
+ struct acpi_pointer *address,
+ struct acpi_table_header *return_header)
{
- acpi_table_header *table_header = NULL;
- acpi_table_header *full_table = NULL;
- u32 size;
- u8 allocation;
- acpi_status status = AE_OK;
-
-
- FUNCTION_TRACE ("Tb_get_table");
-
-
- if (!table_info) {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
-
- if (buffer_ptr) {
- /*
- * Getting data from a buffer, not BIOS tables
- */
- table_header = buffer_ptr;
- status = acpi_tb_validate_table_header (table_header);
- if (ACPI_FAILURE (status)) {
- /* Table failed verification, map all errors to BAD_DATA */
+ acpi_status status = AE_OK;
+ struct acpi_table_header *header = NULL;
- return_ACPI_STATUS (AE_BAD_DATA);
- }
- /* Allocate buffer for the entire table */
+ ACPI_FUNCTION_TRACE ("tb_get_table_header");
- full_table = ACPI_MEM_ALLOCATE (table_header->length);
- if (!full_table) {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- /* Copy the entire table (including header) to the local buffer */
+ /*
+ * Flags contains the current processor mode (Virtual or Physical addressing)
+ * The pointer_type is either Logical or Physical
+ */
+ switch (address->pointer_type) {
+ case ACPI_PHYSMODE_PHYSPTR:
+ case ACPI_LOGMODE_LOGPTR:
- size = table_header->length;
- MEMCPY (full_table, buffer_ptr, size);
+ /* Pointer matches processor mode, copy the header */
- /* Save allocation type */
+ ACPI_MEMCPY (return_header, address->pointer.logical, sizeof (struct acpi_table_header));
+ break;
- allocation = ACPI_MEM_ALLOCATED;
- }
+ case ACPI_LOGMODE_PHYSPTR:
- /*
- * Not reading from a buffer, just map the table's physical memory
- * into our address space.
- */
- else {
- size = SIZE_IN_HEADER;
+ /* Create a logical address for the physical pointer*/
- status = acpi_tb_map_acpi_table (physical_address, &size, &full_table);
+ status = acpi_os_map_memory (address->pointer.physical, sizeof (struct acpi_table_header),
+ (void *) &header);
if (ACPI_FAILURE (status)) {
+ ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n",
+ ACPI_HIDWORD (address->pointer.physical),
+ ACPI_LODWORD (address->pointer.physical),
+ sizeof (struct acpi_table_header)));
return_ACPI_STATUS (status);
}
- /* Save allocation type */
+ /* Copy header and delete mapping */
- allocation = ACPI_MEM_MAPPED;
- }
+ ACPI_MEMCPY (return_header, header, sizeof (struct acpi_table_header));
+ acpi_os_unmap_memory (header, sizeof (struct acpi_table_header));
+ break;
- /* Return values */
+ default:
- table_info->pointer = full_table;
- table_info->length = size;
- table_info->allocation = allocation;
- table_info->base_pointer = full_table;
+ ACPI_REPORT_ERROR (("Invalid address flags %X\n",
+ address->pointer_type));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
- return_ACPI_STATUS (status);
+ return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_tb_get_all_tables
+ * FUNCTION: acpi_tb_get_table_body
*
- * PARAMETERS: Number_of_tables - Number of tables to get
- * Table_ptr - Input buffer pointer, optional
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * Header - Header of the table to retrieve
+ * table_info - Where the table info is returned
*
* RETURN: Status
*
- * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must
- * already be loaded and validated.
+ * DESCRIPTION: Get an entire ACPI table with support to allow the host OS to
+ * replace the table with a newer version (table override.)
+ * Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
*
******************************************************************************/
acpi_status
-acpi_tb_get_all_tables (
- u32 number_of_tables,
- acpi_table_header *table_ptr)
+acpi_tb_get_table_body (
+ struct acpi_pointer *address,
+ struct acpi_table_header *header,
+ struct acpi_table_desc *table_info)
{
- acpi_status status = AE_OK;
- u32 index;
- acpi_table_desc table_info;
-
-
- FUNCTION_TRACE ("Tb_get_all_tables");
+ acpi_status status;
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Number of tables: %d\n", number_of_tables));
+ ACPI_FUNCTION_TRACE ("tb_get_table_body");
- /*
- * Loop through all table pointers found in RSDT.
- * This will NOT include the FACS and DSDT - we must get
- * them after the loop
- */
- for (index = 0; index < number_of_tables; index++) {
- /* Clear the Table_info each time */
-
- MEMSET (&table_info, 0, sizeof (acpi_table_desc));
-
- /* Get the table via the XSDT */
-
- status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS)
- ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]),
- table_ptr, &table_info);
-
- /* Ignore a table that failed verification */
-
- if (status == AE_BAD_DATA) {
- continue;
- }
-
- /* However, abort on serious errors */
-
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-
- /* Recognize and install the table */
-
- status = acpi_tb_install_table (table_ptr, &table_info);
- if (ACPI_FAILURE (status)) {
- /*
- * Unrecognized or unsupported table, delete it and ignore the
- * error. Just get as many tables as we can, later we will
- * determine if there are enough tables to continue.
- */
- acpi_tb_uninstall_table (&table_info);
- }
- }
-
-
- /*
- * Convert the FADT to a common format. This allows earlier revisions of the
- * table to coexist with newer versions, using common access code.
- */
- status = acpi_tb_convert_table_fadt ();
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-
-
- /*
- * Get the minimum set of ACPI tables, namely:
- *
- * 1) FADT (via RSDT in loop above)
- * 2) FACS
- * 3) DSDT
- *
- */
-
- /*
- * Get the FACS (must have the FADT first, from loop above)
- * Acpi_tb_get_table_facs will fail if FADT pointer is not valid
- */
- status = acpi_tb_get_table_facs (table_ptr, &table_info);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-
- /* Install the FACS */
-
- status = acpi_tb_install_table (table_ptr, &table_info);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
- /*
- * Create the common FACS pointer table
- * (Contains pointers to the original table)
- */
- status = acpi_tb_build_common_facs (&table_info);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ if (!table_info || !address) {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/*
- * Get the DSDT (We know that the FADT is valid now)
+ * Attempt table override.
*/
- status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt),
- table_ptr, &table_info);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-
- /* Install the DSDT */
+ status = acpi_tb_table_override (header, table_info);
+ if (ACPI_SUCCESS (status)) {
+ /* Table was overridden by the host OS */
- status = acpi_tb_install_table (table_ptr, &table_info);
- if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
- /* Dump the DSDT Header */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of DSDT Header:\n"));
- DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, sizeof (acpi_table_header));
-
- /* Dump the entire DSDT */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
- "Hex dump of DSDT (After header), size %d (%x)\n",
- acpi_gbl_DSDT->length, acpi_gbl_DSDT->length));
- DUMP_BUFFER ((u8 *) (acpi_gbl_DSDT + 1), acpi_gbl_DSDT->length);
-
- /*
- * Initialize the capabilities flags.
- * Assumes that platform supports ACPI_MODE since we have tables!
- */
- acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities ();
-
-
- /* Always delete the RSDP mapping, we are done with it */
-
- acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP);
+ /* No override, get the original table */
+ status = acpi_tb_get_this_table (address, header, table_info);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_tb_verify_rsdp
+ * FUNCTION: acpi_tb_table_override
*
- * PARAMETERS: Number_of_tables - Where the table count is placed
+ * PARAMETERS: Header - Pointer to table header
+ * table_info - Return info if table is overridden
*
- * RETURN: Status
+ * RETURN: None
*
- * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
+ * DESCRIPTION: Attempts override of current table with a new one if provided
+ * by the host OS.
*
******************************************************************************/
acpi_status
-acpi_tb_verify_rsdp (
- ACPI_PHYSICAL_ADDRESS rsdp_physical_address)
+acpi_tb_table_override (
+ struct acpi_table_header *header,
+ struct acpi_table_desc *table_info)
{
- acpi_table_desc table_info;
- acpi_status status;
- u8 *table_ptr;
+ struct acpi_table_header *new_table;
+ acpi_status status;
+ struct acpi_pointer address;
- FUNCTION_TRACE ("Tb_verify_rsdp");
+ ACPI_FUNCTION_TRACE ("tb_table_override");
/*
- * Obtain access to the RSDP structure
+ * The OSL will examine the header and decide whether to override this
+ * table. If it decides to override, a table will be returned in new_table,
+ * which we will then copy.
*/
- status = acpi_os_map_memory (rsdp_physical_address, sizeof (RSDP_DESCRIPTOR),
- (void **) &table_ptr);
+ status = acpi_os_table_override (header, &new_table);
if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-
- /*
- * The signature and checksum must both be correct
- */
- if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
- /* Nope, BAD Signature */
+ /* Some severe error from the OSL, but we basically ignore it */
- status = AE_BAD_SIGNATURE;
- goto cleanup;
+ ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n",
+ acpi_format_exception (status)));
+ return_ACPI_STATUS (status);
}
- if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) {
- /* Nope, BAD Checksum */
+ if (!new_table) {
+ /* No table override */
- status = AE_BAD_CHECKSUM;
- goto cleanup;
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
- /* TBD: Check extended checksum if table version >= 2 */
-
- /* The RSDP supplied is OK */
-
- table_info.pointer = (acpi_table_header *) table_ptr;
- table_info.length = sizeof (RSDP_DESCRIPTOR);
- table_info.allocation = ACPI_MEM_MAPPED;
- table_info.base_pointer = table_ptr;
-
- /* Save the table pointers and allocation info */
+ /*
+ * We have a new table to override the old one. Get a copy of
+ * the new one. We know that the new table has a logical pointer.
+ */
+ address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
+ address.pointer.logical = new_table;
- status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info);
+ status = acpi_tb_get_this_table (&address, new_table, table_info);
if (ACPI_FAILURE (status)) {
- goto cleanup;
+ ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n",
+ acpi_format_exception (status)));
+ return_ACPI_STATUS (status);
}
+ /* Copy the table info */
- /* Save the RSDP in a global for easy access */
-
- acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer;
- return_ACPI_STATUS (status);
-
-
- /* Error exit */
-cleanup:
+ ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n",
+ table_info->pointer->signature));
- acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR));
- return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: Acpi_tb_get_rsdt_address
- *
- * PARAMETERS: None
- *
- * RETURN: RSDT physical address
- *
- * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the
- * version of the RSDP
- *
- ******************************************************************************/
-
-ACPI_PHYSICAL_ADDRESS
-acpi_tb_get_rsdt_address (void)
-{
- ACPI_PHYSICAL_ADDRESS physical_address;
-
-
- FUNCTION_ENTRY ();
-
-
- /*
- * For RSDP revision 0 or 1, we use the RSDT.
- * For RSDP revision 2 (and above), we use the XSDT
- */
- if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
- /* 0.71 RSDP has 64bit Rsdt address field */
- physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address;
-#else
- physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address;
-#endif
- }
-
- else {
- physical_address = (ACPI_PHYSICAL_ADDRESS)
- ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address);
- }
-
- return (physical_address);
+ return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
- * FUNCTION: Acpi_tb_validate_rsdt
+ * FUNCTION: acpi_tb_get_this_table
*
- * PARAMETERS: Table_ptr - Addressable pointer to the RSDT.
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * Header - Header of the table to retrieve
+ * table_info - Where the table info is returned
*
* RETURN: Status
*
- * DESCRIPTION: Validate signature for the RSDT or XSDT
+ * DESCRIPTION: Get an entire ACPI table. Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
*
******************************************************************************/
acpi_status
-acpi_tb_validate_rsdt (
- acpi_table_header *table_ptr)
+acpi_tb_get_this_table (
+ struct acpi_pointer *address,
+ struct acpi_table_header *header,
+ struct acpi_table_desc *table_info)
{
- u32 no_match;
+ struct acpi_table_header *full_table = NULL;
+ u8 allocation;
+ acpi_status status = AE_OK;
- PROC_NAME ("Tb_validate_rsdt");
+ ACPI_FUNCTION_TRACE ("tb_get_this_table");
/*
- * For RSDP revision 0 or 1, we use the RSDT.
- * For RSDP revision 2 (and above), we use the XSDT
+ * Flags contains the current processor mode (Virtual or Physical addressing)
+ * The pointer_type is either Logical or Physical
*/
- if (acpi_gbl_RSDP->revision < 2) {
- no_match = STRNCMP ((char *) table_ptr, RSDT_SIG,
- sizeof (RSDT_SIG) -1);
- }
- else {
- no_match = STRNCMP ((char *) table_ptr, XSDT_SIG,
- sizeof (XSDT_SIG) -1);
- }
-
-
- if (no_match) {
- /* Invalid RSDT or XSDT signature */
-
- REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
-
- DUMP_BUFFER (acpi_gbl_RSDP, 20);
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR,
- "RSDT/XSDT signature at %X is invalid\n",
- acpi_gbl_RSDP->rsdt_physical_address));
-
- return (AE_BAD_SIGNATURE);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: Acpi_tb_get_table_pointer
- *
- * PARAMETERS: Physical_address - Address from RSDT
- * Flags - virtual or physical addressing
- * Table_ptr - Addressable address (output)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create an addressable pointer to an ACPI table
- *
- ******************************************************************************/
-
-acpi_status
-acpi_tb_get_table_pointer (
- ACPI_PHYSICAL_ADDRESS physical_address,
- u32 flags,
- u32 *size,
- acpi_table_header **table_ptr)
-{
- acpi_status status;
-
-
- FUNCTION_ENTRY ();
-
-
- if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
- *size = SIZE_IN_HEADER;
- status = acpi_tb_map_acpi_table (physical_address, size, table_ptr);
- }
-
- else {
- *size = 0;
- *table_ptr = (acpi_table_header *) (ACPI_TBLPTR) physical_address;
-
- status = AE_OK;
- }
-
- return (status);
-}
-
+ switch (address->pointer_type) {
+ case ACPI_PHYSMODE_PHYSPTR:
+ case ACPI_LOGMODE_LOGPTR:
-/*******************************************************************************
- *
- * FUNCTION: Acpi_tb_get_table_rsdt
- *
- * PARAMETERS: Number_of_tables - Where the table count is placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
- *
- ******************************************************************************/
+ /* Pointer matches processor mode, copy the table to a new buffer */
-acpi_status
-acpi_tb_get_table_rsdt (
- u32 *number_of_tables)
-{
- acpi_table_desc table_info;
- acpi_status status;
- ACPI_PHYSICAL_ADDRESS physical_address;
+ full_table = ACPI_MEM_ALLOCATE (header->length);
+ if (!full_table) {
+ ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n",
+ header->signature, header->length));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ /* Copy the entire table (including header) to the local buffer */
- FUNCTION_TRACE ("Tb_get_table_rsdt");
+ ACPI_MEMCPY (full_table, address->pointer.logical, header->length);
+ /* Save allocation type */
- /*
- * Get the RSDT from the RSDP
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
- acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address),
- LODWORD(acpi_gbl_RSDP->rsdt_physical_address)));
+ allocation = ACPI_MEM_ALLOCATED;
+ break;
- physical_address = acpi_tb_get_rsdt_address ();
+ case ACPI_LOGMODE_PHYSPTR:
+ /*
+ * Just map the table's physical memory
+ * into our address space.
+ */
+ status = acpi_os_map_memory (address->pointer.physical, (acpi_size) header->length,
+ (void *) &full_table);
+ if (ACPI_FAILURE (status)) {
+ ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
+ header->signature,
+ ACPI_HIDWORD (address->pointer.physical),
+ ACPI_LODWORD (address->pointer.physical), header->length));
+ return (status);
+ }
- /* Get the RSDT/XSDT */
+ /* Save allocation type */
- status = acpi_tb_get_table (physical_address, NULL, &table_info);
- if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT, %s\n",
- acpi_format_exception (status)));
- return_ACPI_STATUS (status);
- }
+ allocation = ACPI_MEM_MAPPED;
+ break;
- /* Check the RSDT or XSDT signature */
+ default:
- status = acpi_tb_validate_rsdt (table_info.pointer);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n",
+ address->pointer_type));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/*
- * Valid RSDT signature, verify the checksum. If it fails, just
- * print a warning and ignore it.
+ * Validate checksum for _most_ tables,
+ * even the ones whose signature we don't recognize
*/
- status = acpi_tb_verify_table_checksum (table_info.pointer);
+ if (table_info->type != ACPI_TABLE_FACS) {
+ status = acpi_tb_verify_table_checksum (full_table);
+#if (!ACPI_CHECKSUM_ABORT)
+ if (ACPI_FAILURE (status)) {
+ /* Ignore the error if configuration says so */
- /* Convert and/or copy to an XSDT structure */
-
- status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ status = AE_OK;
+ }
+#endif
}
- /* Save the table pointers and allocation info */
-
- status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
+ /* Return values */
- acpi_gbl_XSDT = (xsdt_descriptor *) table_info.pointer;
+ table_info->pointer = full_table;
+ table_info->length = (acpi_size) header->length;
+ table_info->allocation = allocation;
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n",
+ full_table->signature,
+ ACPI_HIDWORD (address->pointer.physical),
+ ACPI_LODWORD (address->pointer.physical), full_table));
return_ACPI_STATUS (status);
}
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: Acpi_tb_get_table_facs
+ * FUNCTION: acpi_tb_get_table_ptr
*
- * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from
- * buffer rather than searching memory
- * *Table_info - Where the table info is returned
+ * PARAMETERS: table_type - one of the defined table types
+ * Instance - Which table of this type
+ * table_ptr_loc - pointer to location to place the pointer for
+ * return
*
* RETURN: Status
*
- * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This
- * function assumes the global variable FADT has been
- * correctly initialized. The value of FADT->Firmware_ctrl
- * into a far pointer which is returned.
+ * DESCRIPTION: This function is called to get the pointer to an ACPI table.
*
- *****************************************************************************/
+ ******************************************************************************/
acpi_status
-acpi_tb_get_table_facs (
- acpi_table_header *buffer_ptr,
- acpi_table_desc *table_info)
+acpi_tb_get_table_ptr (
+ acpi_table_type table_type,
+ u32 instance,
+ struct acpi_table_header **table_ptr_loc)
{
- acpi_table_header *table_ptr = NULL;
- u32 size;
- u8 allocation;
- acpi_status status = AE_OK;
+ struct acpi_table_desc *table_desc;
+ u32 i;
- FUNCTION_TRACE ("Tb_get_table_facs");
+ ACPI_FUNCTION_TRACE ("tb_get_table_ptr");
- /* Must have a valid FADT pointer */
-
- if (!acpi_gbl_FADT) {
+ if (!acpi_gbl_DSDT) {
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
- size = sizeof (FACS_DESCRIPTOR);
- if (buffer_ptr) {
- /*
- * Getting table from a file -- allocate a buffer and
- * read the table.
- */
- table_ptr = ACPI_MEM_ALLOCATE (size);
- if(!table_ptr) {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- MEMCPY (table_ptr, buffer_ptr, size);
-
- /* Save allocation type */
-
- allocation = ACPI_MEM_ALLOCATED;
+ if (table_type > ACPI_TABLE_MAX) {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- else {
- /* Just map the physical memory to our address space */
+ /*
+ * For all table types (Single/Multiple), the first
+ * instance is always in the list head.
+ */
+ if (instance == 1) {
+ /* Get the first */
- status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl),
- &size, &table_ptr);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
+ if (acpi_gbl_table_lists[table_type].next) {
+ *table_ptr_loc = acpi_gbl_table_lists[table_type].next->pointer;
}
+ return_ACPI_STATUS (AE_OK);
+ }
- /* Save allocation type */
-
- allocation = ACPI_MEM_MAPPED;
+ /*
+ * Check for instance out of range
+ */
+ if (instance > acpi_gbl_table_lists[table_type].count) {
+ return_ACPI_STATUS (AE_NOT_EXIST);
}
+ /* Walk the list to get the desired table
+ * Since the if (Instance == 1) check above checked for the
+ * first table, setting table_desc equal to the .Next member
+ * is actually pointing to the second table. Therefore, we
+ * need to walk from the 2nd table until we reach the Instance
+ * that the user is looking for and return its table pointer.
+ */
+ table_desc = acpi_gbl_table_lists[table_type].next;
+ for (i = 2; i < instance; i++) {
+ table_desc = table_desc->next;
+ }
- /* Return values */
+ /* We are now pointing to the requested table's descriptor */
- table_info->pointer = table_ptr;
- table_info->length = size;
- table_info->allocation = allocation;
- table_info->base_pointer = table_ptr;
+ *table_ptr_loc = table_desc->pointer;
- return_ACPI_STATUS (status);
+ return_ACPI_STATUS (AE_OK);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)